@sheetxl/sdk 0.4.13 → 0.4.15
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/browser/cjs/17vteff17iwu-nts.cjs +15 -0
- package/browser/cjs/B1o0X3p_6PiLx4jI.cjs +7 -0
- package/browser/cjs/B339rTr1BsEIo2__.cjs +6 -0
- package/browser/cjs/B6Vc2J26WiHxBQya.cjs +13 -0
- package/browser/cjs/BKAC72r7ywoOltA0.cjs +6 -0
- package/browser/cjs/BVA-ijQaNPkp7YbF.cjs +124 -0
- package/browser/cjs/BXtVRHEodCTlDHKt.cjs +32 -0
- package/browser/cjs/Br5SOD3y14JWQxmm.cjs +6 -0
- package/browser/cjs/BsZ6vhnXHmCHlGZX.cjs +1501 -0
- package/browser/cjs/Bv5GejhVjiiKkQo4.cjs +6 -0
- package/browser/cjs/Bve-_MKdvTST-nYO.cjs +6 -0
- package/browser/cjs/C2h4aMcaEv25R8td.cjs +6 -0
- package/browser/cjs/CK47_UoX6YUMsgbq.cjs +6 -0
- package/browser/cjs/CkXszTzijjKe-x3s.cjs +6 -0
- package/browser/cjs/CnOPibl4Egdph8iO.cjs +6 -0
- package/browser/cjs/CnoRxKqF7cmfYPie.cjs +6 -0
- package/browser/cjs/CwNSe9CinOcKHt9p.cjs +6 -0
- package/browser/cjs/D-TMUgYRD9-WKuJt.cjs +6 -0
- package/browser/cjs/D65Kj_FHrWptDBz6.cjs +6 -0
- package/browser/cjs/DDwxGPgeEH75VzI6.cjs +6 -0
- package/browser/cjs/DEnI4zCWAmN4uqYL.cjs +60 -0
- package/browser/cjs/DEyIncQzUFxinblH.cjs +6 -0
- package/browser/cjs/DJwiyf8nrWTrcqsg.cjs +6 -0
- package/browser/{esm/bC-pS6WlvqHBcNXl.mjs → cjs/DN99k_K8Xt6Cxpbg.cjs} +3 -4
- package/browser/cjs/DR8AZfpEdPwolzLA.cjs +6 -0
- package/browser/cjs/DY7NS5zPRAYW9B4z.cjs +6 -0
- package/browser/cjs/DZoB22ts1B-Uo1_8.cjs +6 -0
- package/browser/cjs/HFD-Ka0JKfOFb-v8.cjs +6 -0
- package/browser/cjs/HrYBZlmkaRPlgpBr.cjs +6 -0
- package/browser/cjs/J0QRcnocFqaCEpXb.cjs +6 -0
- package/browser/cjs/dL-d0P2RzXjtzTKk.cjs +6 -0
- package/browser/cjs/f4q2aiebC4Dk2JpQ.cjs +6 -0
- package/browser/cjs/index.cjs +3 -4
- package/browser/cjs/jAhE-WFeXtkOENRt.cjs +6 -0
- package/browser/esm/1RDByGQ0b6fJxh7d.mjs +10 -0
- package/{node/esm/DLDt1F5JzQq5aKdG.mjs → browser/esm/B1J_tEX0ArjgmDxo.mjs} +1 -1
- package/browser/esm/B6bUGsiDUEqxcpxj.mjs +10 -0
- package/browser/esm/B7TVQO7b5fKHjmdS.mjs +10 -0
- package/{node/esm/CBdo244r3xwae4_o.mjs → browser/esm/B9pQrZA0Y-_hUwWi.mjs} +1 -1
- package/{node/esm/axtXmmwYm1aHBXjg.mjs → browser/esm/BUjgpjT28_Y-kidw.mjs} +1 -1
- package/{node/esm/L0bRh78pniyMZ_3v.mjs → browser/esm/Be8lmKk3pIbpatrW.mjs} +1 -1
- package/browser/esm/BqlVyzcHZSLgnGUm.mjs +10 -0
- package/browser/esm/C6ugA4r8ZBnWJ7SS.mjs +1575 -0
- package/{node/esm/tw0tbG4pvPai6vfe.mjs → browser/esm/CL7ql8UZhgDNpfsM.mjs} +1 -1
- package/{node/esm/Bq3GEYeFkbO3vHHx.mjs → browser/esm/CVlNXQ7d_YZ1bp7F.mjs} +1 -1
- package/browser/esm/C_viEPf8wfrM9XrP.mjs +472 -0
- package/{node/esm/DZl6ZagrmdiXKi9x.mjs → browser/esm/Cf9USLOKImk5ry05.mjs} +1 -1
- package/{node/esm/Bb5FApoZ10dDGlM-.mjs → browser/esm/CqsGDFsS_swdf3vs.mjs} +1 -1
- package/{node/esm/Dlftv7TykJRVk7Wx.mjs → browser/esm/D6yAkYqQpt4Mti36.mjs} +1 -1
- package/browser/esm/D8PCv7S4DISHUIuf.mjs +5651 -0
- package/{node/esm/C6FEsnCdmUvcIDzA.mjs → browser/esm/DC2efMTBtgG0Qg9v.mjs} +1 -1
- package/{node/esm/j5mlBPjSlgnHX9pH.mjs → browser/esm/DJGZqsQxGcCptrL0.mjs} +1 -1
- package/browser/esm/DJSB1iCmSRlSH8T3.mjs +820 -0
- package/browser/esm/DOkO-X1qYgsIKnNj.mjs +3974 -0
- package/{node/esm/dRD2c-s3aQJNoK6m.mjs → browser/esm/DYE2NR7zRrGqd22q.mjs} +1 -1
- package/browser/esm/{DQ6InIROOs1_L5ez.mjs → DZh5MHkoTH4JibFE.mjs} +7 -2
- package/browser/esm/DoyfObpnizfLGHs3.mjs +21 -0
- package/browser/esm/Dqvs0M5ZN2pHLCwm.mjs +24 -0
- package/{node/esm/DMhTOGJLYCiHGnjP.mjs → browser/esm/DxIixek4CImRs91l.mjs} +1 -1
- package/{node/esm/CoowIrBw0vTXnosY.mjs → browser/esm/PWnhitKV1qE65Z3V.mjs} +1 -1
- package/browser/esm/QkxRNX4E_VTO1B3P.mjs +24269 -0
- package/{node/esm/cWKERSoNy_Mo5gOQ.mjs → browser/esm/SLFayFhlPi4T8AO6.mjs} +1 -1
- package/{node/esm/DQvu2JlpO07Yqcvx.mjs → browser/esm/Sr5fscnOJ2IHKKrp.mjs} +1 -1
- package/browser/esm/WUmLxNLfFn0Ozmm-.mjs +10 -0
- package/browser/esm/favrNBo9HOjnV2Y3.mjs +29 -0
- package/browser/esm/index.mjs +84 -2
- package/browser/esm/jdkRKboN0ZTz9YBf.mjs +10 -0
- package/browser/esm/tJR0NVUIbWFQCJp0.mjs +426 -0
- package/licenses/dependencies.txt +3 -3
- package/node/esm/{DNTdUrrAs4YsX782.mjs → AfI5dmtnxoAFOc1C.mjs} +1 -1
- package/node/esm/{Dxqu9uwKDQHBrAqJ.mjs → B1E5b-6lOZJnl4aN.mjs} +2 -2
- package/{browser/cjs/DOptrVmGD_5mAjIJ.cjs → node/esm/B1J_tEX0ArjgmDxo.mjs} +5 -2
- package/node/esm/B9pQrZA0Y-_hUwWi.mjs +10 -0
- package/node/esm/{CKO3kzDC1TBjmP6a.mjs → BEvzdM3wAA2DOPpb.mjs} +1 -1
- package/node/esm/{BmkbBs1Yla2RsZ_s.mjs → BEwii9DEp24ukOxk.mjs} +1 -1
- package/node/esm/{DNLKWsIB7wfMRm8a.mjs → BRakFf60UlCdEoH2.mjs} +2 -2
- package/node/esm/BUjgpjT28_Y-kidw.mjs +10 -0
- package/node/esm/{B-cEaNMrVscFjP28.mjs → BWh89wRFsoTmi9Ib.mjs} +1 -1
- package/node/esm/{DOdqJUKquKrouyJg.mjs → Bd7nQztitF7jnRgP.mjs} +1 -1
- package/node/esm/Be8lmKk3pIbpatrW.mjs +10 -0
- package/node/esm/C9Z0bg7XW6ng3z7k.mjs +80 -0
- package/node/esm/{CsI4IQyunxqLyMWY.mjs → CBuT_Rm4rHFEv2-k.mjs} +1 -1
- package/node/esm/CL7ql8UZhgDNpfsM.mjs +10 -0
- package/node/esm/{G0slAplR6jB1csaY.mjs → CV_B2BH1zuSdWD_e.mjs} +1 -1
- package/node/esm/CVlNXQ7d_YZ1bp7F.mjs +10 -0
- package/node/esm/{BZScF0z5mvap-tCk.mjs → C_eVpG1TqI_0_Zfz.mjs} +1 -1
- package/node/esm/Cf9USLOKImk5ry05.mjs +10 -0
- package/node/esm/{moaVD3gybeaMfy_q.mjs → Cm8B2CXlnA5r12FE.mjs} +1 -1
- package/node/esm/{o47K-SM01hvIUrc0.mjs → CpNeEylJssyF4zm3.mjs} +2 -2
- package/node/esm/CqsGDFsS_swdf3vs.mjs +10 -0
- package/node/esm/D6yAkYqQpt4Mti36.mjs +10 -0
- package/node/esm/DC2efMTBtgG0Qg9v.mjs +10 -0
- package/node/esm/DJGZqsQxGcCptrL0.mjs +10 -0
- package/node/esm/DYE2NR7zRrGqd22q.mjs +10 -0
- package/node/esm/{DHJoU9KsVtSXERyd.mjs → DmxrrAcKGuZW16bw.mjs} +4 -4
- package/node/esm/DxIixek4CImRs91l.mjs +10 -0
- package/node/esm/PWnhitKV1qE65Z3V.mjs +10 -0
- package/node/esm/{n0CrIZcZCwIu-yiw.mjs → RP8av-gx71hD40p7.mjs} +1 -1
- package/node/esm/SLFayFhlPi4T8AO6.mjs +10 -0
- package/node/esm/Sr5fscnOJ2IHKKrp.mjs +10 -0
- package/node/esm/index.mjs +3434 -3183
- package/package.json +4 -4
- package/browser/cjs/99FHKXLdlCef5nfT.cjs +0 -7
- package/browser/cjs/B5eveWag0dzzgkgX.cjs +0 -7
- package/browser/cjs/BJA1_CndBCMNr53J.cjs +0 -7
- package/browser/cjs/BVE8RsCx6dH-PJ3G.cjs +0 -7
- package/browser/cjs/BbvyF-KASTBWusEs.cjs +0 -7
- package/browser/cjs/BfAJd561Nzaudhz_.cjs +0 -7
- package/browser/cjs/BlgZLqYSIZleOo8h.cjs +0 -7
- package/browser/cjs/BpoOeB751mnCS6V-.cjs +0 -7
- package/browser/cjs/CE7l7CfFaLMonVMB.cjs +0 -7
- package/browser/cjs/CHBhqMbMhjW9YdAF.cjs +0 -7
- package/browser/cjs/CIJiAsckzAZgx8n4.cjs +0 -7
- package/browser/cjs/CgOy3BgHFueAFAeL.cjs +0 -7
- package/browser/cjs/Cl0gNER1w9A58kbc.cjs +0 -13
- package/browser/cjs/CmBrJtijpbCUSPWR.cjs +0 -10
- package/browser/cjs/CuYGUMy7ROX5G_sm.cjs +0 -7
- package/browser/cjs/Czqso66RMuDka4LC.cjs +0 -7
- package/browser/cjs/D-NvwNeGLHGiv00z.cjs +0 -7
- package/browser/cjs/DHVBvApvjbLRsOju.cjs +0 -7
- package/browser/cjs/DORshTQEHNF0VHvp.cjs +0 -7
- package/browser/cjs/DRKq7WhWW37UIj1Q.cjs +0 -7
- package/browser/cjs/DhWK7BDP7ZhYYPga.cjs +0 -7
- package/browser/cjs/DpSwAPYhahtG5EKw.cjs +0 -7
- package/browser/cjs/DvioTOgF2jNUKBcT.cjs +0 -7
- package/browser/cjs/DwSf7lami5Uh2Uh6.cjs +0 -7
- package/browser/cjs/Dy6R4NfGavsHaUnQ.cjs +0 -10
- package/browser/cjs/HEI6Q0oyMX2A1gth.cjs +0 -7
- package/browser/cjs/_Lz_D28ElE-H04r8.cjs +0 -7
- package/browser/cjs/hONph4eRHAvmiEYv.cjs +0 -7
- package/browser/cjs/nQYA0VPzyPNFcvaF.cjs +0 -7
- package/browser/cjs/pPrxgr769sUGB5WL.cjs +0 -7
- package/browser/cjs/sqCd-isdKO-WsW_F.cjs +0 -7
- package/browser/cjs/xobXrowL2Qx-kWv9.cjs +0 -7
- package/browser/esm/4lHZjpF3_ugmKKui.mjs +0 -7
- package/browser/esm/67bnWHzYa5DZMY6A.mjs +0 -7
- package/browser/esm/BDYJEEaksgeY1UaE.mjs +0 -7
- package/browser/esm/BG0zhw4ripZzsL-w.mjs +0 -7
- package/browser/esm/BOfILXwwP1BW8Bsw.mjs +0 -7
- package/browser/esm/BPEwv5xX4DLnd-8o.mjs +0 -7
- package/browser/esm/BUeaoQihd7nbjV5D.mjs +0 -7
- package/browser/esm/Bb8asJ4COo3sy4Gt.mjs +0 -7
- package/browser/esm/BbJAEyq0pAF7biF-.mjs +0 -7
- package/browser/esm/BuoPWoEzsXvQsZFU.mjs +0 -7
- package/browser/esm/By_8JXNSh9nnHyBW.mjs +0 -7
- package/browser/esm/C4K5CBXvVExqCdpa.mjs +0 -7
- package/browser/esm/CKUiTXSrn9Xg_ph1.mjs +0 -10
- package/browser/esm/CLP8NgXNjnLl-iMQ.mjs +0 -7
- package/browser/esm/CVGuaXPdnO65bXE5.mjs +0 -7
- package/browser/esm/ClgHaEbC8eHvV73x.mjs +0 -7
- package/browser/esm/CoZh7nD_zQLfTNcp.mjs +0 -7
- package/browser/esm/D2jQMy8XvCDNeRaM.mjs +0 -7
- package/browser/esm/D3D_Ad9RkEvBe7Wz.mjs +0 -7
- package/browser/esm/D5dJ7VFFZvIOU2As.mjs +0 -7
- package/browser/esm/D8vW0N6EH97lDhnP.mjs +0 -7
- package/browser/esm/DB9YIl5l53cTx_qf.mjs +0 -7
- package/browser/esm/DFbUKmUyr8XjG6uR.mjs +0 -7
- package/browser/esm/DROuUTBh0ijsxsde.mjs +0 -7
- package/browser/esm/Dq1V1gMAXsC87zqO.mjs +0 -13
- package/browser/esm/Ds_YxbxItIu7PKA-.mjs +0 -7
- package/browser/esm/Ho-V23ZRWrnAVftS.mjs +0 -7
- package/browser/esm/j21djw_rEjBtpjRd.mjs +0 -7
- package/browser/esm/kXWocze33jAxVJq6.mjs +0 -10
- package/browser/esm/qi0568hNwcdjIMy6.mjs +0 -7
- package/browser/esm/yVExwiZwWE8vLSFO.mjs +0 -7
- package/node/esm/k3luU7uFD82_cpo4.mjs +0 -80
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";/**
|
|
2
|
+
* @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.4.15
|
|
3
|
+
*
|
|
4
|
+
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
5
|
+
* License: The license can be found at https://www.sheetxl.com/license.
|
|
6
|
+
*/const U={Number:"n",String:"s",Boolean:"b",Error:"e",RichData:"r",Null:"z"};var hs;exports.w=void 0,exports.n=void 0,(hs=exports.w||(exports.w={})).Orientation={Column:"column",Row:"row"},hs.Orientations={...hs.Orientation,Both:"both"},hs.Direction={Up:"up",Down:"down",Left:"left",Right:"right"},(s=>{s.Code={Parse:0,Null:1,Div0:2,Value:3,Ref:4,Name:5,Num:6,NA:7,GettingData:8,Spill:9,Connect:10,Blocked:11,Unknown:12,Field:13,Calc:14,Busy:16,Python:19,Timeout:20},s.Label={Parse:"#PARSE!",Null:"#NULL!",Div0:"#DIV/0!",Value:"#VALUE!",Ref:"#REF!",Name:"#NAME?",Num:"#NUM!",NA:"#N/A",GettingData:"#GETTING_DATA",Spill:"#SPILL!",Connect:"#CONNECT!",Blocked:"#BLOCKED!",Unknown:"#UNKNOWN!",Field:"#FIELD!",Calc:"#CALC!",Busy:"#BUSY!",Python:"#PYTHON!",Timeout:"#TIMEOUT!"};class e extends Error{constructor(b,w,E,I){super(E,I),this._label=w,this._code=b,this.details=I}static{this.code=s.Code.Unknown}get isFormulaError(){return!0}getLabel(){return this._label}getCode(){return this._code}equals(b){return!!b&&(this._code===b._code||this._code===b.code)}get[Symbol.toStringTag](){return"[FormulaError]"}toString(){return this.message||this._label}}s.Known=e;class t extends e{constructor(b,w){super(s.Code.Parse,s.Label.Parse,b,w)}static{this.code=s.Code.Parse}getDetails(){const b=this.details;return{line:b?.line??1,column:b?.column??1,offset:b?.offset??0,length:b?.length??0}}}s.Parse=t;class n extends e{constructor(b,w){super(s.Code.Null,s.Label.Null,b,w)}static{this.code=s.Code.Null}}s.Null=n;class r extends e{constructor(b,w){super(s.Code.Div0,s.Label.Div0,b,w)}static{this.code=s.Code.Div0}}s.Div0=r;class o extends e{constructor(b,w){super(s.Code.Value,s.Label.Value,b,w)}static{this.code=s.Code.Value}}s.Value=o;class i extends e{constructor(b,w){super(s.Code.Ref,s.Label.Ref,b,w)}static{this.code=s.Code.Ref}}s.Ref=i;class a extends e{constructor(b,w){super(s.Code.Name,s.Label.Name,b,w)}static{this.code=s.Code.Name}}s.Name=a;class l extends e{constructor(b,w){super(s.Code.Num,s.Label.Num,b,w)}static{this.code=s.Code.Num}}s.Num=l;class c extends e{constructor(b,w){super(s.Code.NA,s.Label.NA,b,w)}static{this.code=s.Code.NA}}s.NA=c;class h extends e{constructor(b,w){super(s.Code.GettingData,s.Label.GettingData,b,w)}static{this.code=s.Code.GettingData}}s.GettingData=h;class u extends e{constructor(b,w){super(s.Code.Spill,s.Label.Spill,b,w)}static{this.code=s.Code.Spill}}s.Spill=u;class d extends e{constructor(b,w){super(s.Code.Connect,s.Label.Connect,b,w)}static{this.code=s.Code.Connect}}s.Connect=d;class g extends e{constructor(b,w){super(s.Code.Blocked,s.Label.Blocked,b,w)}static{this.code=s.Code.Blocked}}s.Blocked=g;class m extends e{constructor(b,w){super(s.Code.Unknown,s.Label.Unknown,b,w)}static{this.code=s.Code.Unknown}}s.Unknown=m;class f extends e{constructor(b,w){super(s.Code.Field,s.Label.Field,b,w)}static{this.code=s.Code.Field}}s.Field=f;class _ extends e{constructor(b,w){super(s.Code.Calc,s.Label.Calc,b,w)}static{this.code=s.Code.Calc}}s.Calc=_;class p extends e{constructor(b,w){super(s.Code.Busy,s.Label.Busy,b,w)}static{this.code=s.Code.Busy}}s.Busy=p;class S extends e{constructor(b,w){super(s.Code.Python,s.Label.Python,b,w)}static{this.code=s.Code.Python}}s.Python=S;class C extends e{constructor(b,w){super(s.Code.Timeout,s.Label.Timeout,b,w)}static{this.code=s.Code.Timeout}}s.Timeout=C})(exports.n||(exports.n={}));const Ue={};Ue[exports.n.Code.Parse]=exports.n.Parse,Ue[exports.n.Code.Null]=exports.n.Null,Ue[exports.n.Code.Div0]=exports.n.Div0,Ue[exports.n.Code.Value]=exports.n.Value,Ue[exports.n.Code.Ref]=exports.n.Ref,Ue[exports.n.Code.Name]=exports.n.Name,Ue[exports.n.Code.Num]=exports.n.Num,Ue[exports.n.Code.NA]=exports.n.NA,Ue[exports.n.Code.GettingData]=exports.n.GettingData,Ue[exports.n.Code.Spill]=exports.n.Spill,Ue[exports.n.Code.Connect]=exports.n.Connect,Ue[exports.n.Code.Blocked]=exports.n.Blocked,Ue[exports.n.Code.Unknown]=exports.n.Unknown,Ue[exports.n.Code.Field]=exports.n.Field,Ue[exports.n.Code.Calc]=exports.n.Calc,Ue[exports.n.Code.Busy]=exports.n.Busy,Ue[exports.n.Code.Python]=exports.n.Python,Ue[exports.n.Code.Timeout]=exports.n.Timeout;const og=new Map,tc=new Map,sg=new Map,ig=new Map,Ac=Object.keys(Ue);for(let s=0;s<Ac.length;s++){const e=Ac[s],t=Ue[e];sg.set(exports.n.Label[e],t),ig.set(exports.n.Code[e],t);const n=new t;og.set(n.getLabel(),n),tc.set(n.getCode(),n)}const If=tc.get(exports.n.Code.Unknown);var De;(De=exports.n||(exports.n={})).BuiltIn={Parse:new De.Parse,Null:new De.Null,Div0:new De.Div0,Value:new De.Value,Ref:new De.Ref,Name:new De.Name,Num:new De.Num,NA:new De.NA,GettingData:new De.GettingData,Spill:new De.Spill,Connect:new De.Connect,Blocked:new De.Blocked,Unknown:new De.Unknown,Field:new De.Field,Calc:new De.Calc,Busy:new De.Busy,Python:new De.Python,Timeout:new De.Timeout},De.getBuiltInByLabel=s=>og.get(s),De.newTypedError=(s,e,t)=>{let n;return n=typeof s=="string"?sg.get(s):ig.get(s),n||(n=De.Unknown),new n(e,t)},De.getBuiltInById=s=>tc.get(s)||If;let ag=class{constructor(s){this._subscribeFn=s}subscribe(s,e,t){const n=typeof s=="object"?{next:s.next||(()=>{}),error:s.error||(()=>{}),complete:s.complete||(()=>{}),unsubscribe:()=>{}}:{next:s||(()=>{}),error:e||(()=>{}),complete:t||(()=>{}),unsubscribe:()=>{}},r=this._subscribeFn(n);return n.unsubscribe=()=>{typeof r=="function"&&r()},n}},lg=class{getRange(s){throw new us}getReference(s,e){throw new us}getNumberFormat(s,e){return e?.toString()??""}fromOADate(s){return new Date(s)}toOADate(s){return s.getTime()}getValueAt(s,e){return null}getEntireCoords(){return Af}isValidDate(s){return(s instanceof Date||Object.prototype.toString.call(s)==="[object Date]")&&!isNaN(s.getTime())}getPosition(){return Rf}getFormulaAt(s,e){return null}getSpillAt(s,e){return null}getSheetIndex(s){return-1}getSheetCount(){return 1}markVolatile(){}formatResults(s){}getFunction(s){return null}getAddress(s,e){throw new us}parseAsDateTime(s,e){throw new us}getRuntime(){return Mf}};class us extends Error{constructor(e="Not implemented in StubbedFormulaContext"){super(e),this.name="NotImplementedError"}}const Rf=Object.freeze({colIndex:0,rowIndex:0}),Af=Object.freeze({colStart:0,rowStart:0,colEnd:Math.pow(2,14)-1,rowEnd:Math.pow(2,20)-1}),Mf={getCurrencySymbol:()=>"$",getNumberDecimalSeparator:()=>".",getNumberGroupSeparator:()=>",",isDate1904:()=>!1,getLocation:()=>"unknown",getVersion:()=>"1.0.0",getOS:()=>"unknown",getUser:()=>"unidentified",getDescription:()=>"Stubbed Formula Context"},Tf=new lg,Oe={Up:"up",Down:"down",Left:"left",Right:"right"},ln={TopLeft:"tl",Top:"t",TopRight:"tr",Left:"l",Center:"c",Right:"r",BottomLeft:"bl",Bottom:"b",BottomRight:"br"},Me={html:"text/html",plain:"text/plain",png:"image/png"},Ff=Object.freeze({left:0,top:0}),Nf=Object.freeze({left:0,top:0,bottom:0,right:0}),kf=Object.freeze({x:0,y:0,width:0,height:0}),Yo=Object.freeze(Object.defineProperty({__proto__:null,EmptyBounds:kf,EmptyRect:Nf,EmptyTopLeft:Ff},Symbol.toStringTag,{value:"Module"})),ie={Column:"column",Row:"row"},Yn={...ie,Both:"both"},Of=Object.freeze({colIndex:0,rowIndex:0}),Bf=Object.freeze({colStart:0,rowStart:0,colEnd:0,rowEnd:0}),cg=(s,e)=>s.colStart===e.colStart?s.rowStart-e.rowStart:s.colStart-e.colStart,hg=(s,e)=>s.rowStart===e.rowStart?s.colStart-e.colStart:s.rowStart-e.rowStart,Df=(s,e)=>s.rowEnd===e.rowEnd?e.colEnd-s.colEnd:e.rowEnd-s.rowEnd,Lf=(s,e)=>s.colEnd===e.colEnd?e.rowEnd-s.rowEnd:e.colEnd-s.colEnd,Mc=(s,e)=>s.colIndex===e.colIndex?s.rowIndex-e.rowIndex:s.colIndex-e.colIndex,Tc=(s,e)=>s.rowIndex===e.rowIndex?s.colIndex-e.colIndex:s.rowIndex-e.rowIndex,ug=(s=ie.Row,e=!1)=>e?s!==ie.Column?Df:Lf:s!==ie.Column?hg:cg,Fc=(s,e)=>s===e||!(!s||!e)&&s.rowIndex===e.rowIndex&&s.colIndex===e.colIndex,wl=(s,e)=>s===e||!(!s||!e)&&s.rowStart===e.rowStart&&s.rowEnd===e.rowEnd&&s.colStart===e.colStart&&s.colEnd===e.colEnd,yl=(s,e)=>!(!s||!e||s.colStart>e.colEnd||e.colStart>s.colEnd||s.rowStart>e.rowEnd||e.rowStart>s.rowEnd),Nc=(s,e)=>{if(s===e)return!0;if(!s||!e||s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(!wl(s[t],e[t]))return!1;return!0},na=(s,e,t)=>{if(!s&&!e)return null;if(!s)return t?e:{...e};if(!e)return t?s:{...s};const n=Math.min(s.colStart,e.colStart),r=Math.min(s.rowStart,e.rowStart),o=Math.max(s.colEnd,e.colEnd),i=Math.max(s.rowEnd,e.rowEnd);let a=t;return a?(a.colStart=n,a.rowStart=r,a.colEnd=o,a.rowEnd=i):a={colStart:n,rowStart:r,colEnd:o,rowEnd:i},a},kc=(s,e)=>{if(!e||e.length===0)return s;const t={...s};for(let n=0;n<e.length;n++){const r=e[n];yl(t,r)&&(t.rowStart=Math.min(t.rowStart,r.rowStart),t.colStart=Math.min(t.colStart,r.colStart),t.rowEnd=Math.max(t.rowEnd,r.rowEnd),t.colEnd=Math.max(t.colEnd,r.colEnd))}return t},Pf=[null,null],zf=(s,e,t)=>{if(s[0].value===s[1].value)return e};function Oc(s,e=2,t,n=ie.Row,r){let o=[...s];if(e<=0||s.length<=1)return o;let i=n===ie.Column,a=0,l=!1;do{const c=o.sort(ug(i?ie.Row:ie.Column));o=[],o.push(c[0]);const h=c.length;let u=0,d=c[0],g=d.colStart,m=d.rowStart,f=d.colEnd,_=d.rowEnd;for(let p=1;p<h;p++){const S=c[p];let C=!1;if(C=i?d&&m===S.rowStart&&_===S.rowEnd&&f+1===S.colStart:d&&g===S.colStart&&f===S.colEnd&&_+1===S.rowStart,C){let y={colStart:g,rowStart:m,colEnd:i?S.colEnd:f,rowEnd:i?_:S.rowEnd};if(d.value!==void 0&&(y.value=d.value),t){const b=r??[null,null];b[0]=d,b[1]=S,y=t(b,y,n)}if(y){o[u]=y,l=!0,d=y,g=d.colStart,m=d.rowStart,f=d.colEnd,_=d.rowEnd;continue}}o[++u]=S,d=S,g=d.colStart,m=d.rowStart,f=d.colEnd,_=d.rowEnd}a++,i=!i,a===1&&(l=!0)}while(a<e&&l&&o.length>1);return o}const k=Object.freeze(Object.defineProperty({__proto__:null,EmptyCell:Of,EmptyRange:Bf,cellToRange:(s,e)=>{if(!s)return null;let t=e;return t||(t={...s},delete t.colIndex,delete t.rowIndex),t.colStart=s.colIndex??0,t.rowStart=s.rowIndex??0,t.colEnd=s.colIndex??0,t.rowEnd=s.rowIndex??0,t},columnFirstCellComparator:Mc,columnFirstRangeComparator:cg,createCellComparator:(s=ie.Row,e=!1)=>e?s!==ie.Column?(t,n)=>t.rowIndex===n.rowIndex?n.colIndex-t.colIndex:n.rowIndex-t.rowIndex:(t,n)=>t.colIndex===n.colIndex?n.rowIndex-t.rowIndex:n.colIndex-t.colIndex:s!==ie.Column?Tc:Mc,createConflatingRanges:(s,e=!1)=>{const t=[];let n,r,o=Number.MIN_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER;return{append:(a,l,c)=>{let h=!0;const u=c!==void 0;if(u){const m=s?s(r,c,e):r===c?c:void 0;m===void 0?h=!1:c=m}if(h&&l===i+1&&a===o)return e?n.rowEnd=l:n.colEnd=l,i=l,void(r=c);n&&t.push(n);const d=e?a:l,g=e?l:a;n={colStart:d,rowStart:g,colEnd:d,rowEnd:g},u&&(n.value=c),o=a,i=l,r=c},done:a=>(n&&(t.push(n),n=null),a?Oc(t,3,a===!0?zf:a,e?ie.Column:ie.Row,Pf):t)}},createRangeComparator:ug,defaultRange:(s,e,t)=>s?t?(t.colStart=s.colStart??e.colStart,t.rowStart=s.rowStart??e.rowStart,t.colEnd=s.colEnd??e.colEnd,t.rowEnd=s.rowEnd??e.rowEnd,t):{colStart:s.colStart??e.colStart,rowStart:s.rowStart??e.rowStart,colEnd:s.colEnd??e.colEnd,rowEnd:s.rowEnd??e.rowEnd}:e,extendRangeToIntersectingRanges:kc,extendRangeToUnionRanges:(s,e)=>{if(!e||e.length===0)return s;let t=s,n=null;for(;!wl(t,n);)n=t,t=kc(n,e);return t},indexOfCoords:(s,e)=>{const t={colStart:s.colIndex,rowStart:s.rowIndex,colEnd:s.colIndex,rowEnd:s.rowIndex};for(let n=e.length-1;n>=0;n--)if(yl(t,e[n]))return n;return-1},intersectRanges:(s,e,t)=>{if(!s)return t?e:{...e};if(!e)return t?s:{...s};if(!s&&!e||s.rowStart>e.rowEnd||s.rowEnd<e.rowStart||s.colStart>e.colEnd||s.colEnd<e.colStart)return null;const n=Math.max(s.colStart,e.colStart),r=Math.max(s.rowStart,e.rowStart),o=Math.min(s.colEnd,e.colEnd),i=Math.min(s.rowEnd,e.rowEnd);let a=t;return a?(a.colStart=n,a.rowStart=r,a.colEnd=o,a.rowEnd=i):a={colStart:n,rowStart:r,colEnd:o,rowEnd:i},a},isCellWithinRange:(s,e)=>!(!s||!e||s.rowIndex<e.rowStart||s.rowIndex>e.rowEnd||s.colIndex<e.colStart||s.colIndex>e.colEnd),isEqualCells:Fc,isEqualRanges:wl,isEqualRangesArrays:Nc,isEqualSelectionCoords:(s,e)=>s===e||!(!s||!e)&&s.rangeIndex===e.rangeIndex&&!!Fc(s.cell,e.cell)&&Nc(s.ranges,e.ranges),isRangeWithinRange:(s,e)=>!(s.rowStart<e.rowStart||s.rowEnd>e.rowEnd||s.colStart<e.colStart||s.colEnd>e.colEnd),isRangesIntersect:yl,isSingleCell:s=>!!s&&s.rowEnd===s.rowStart&&s.colStart===s.colEnd,isValidRange:s=>!(!s||typeof s.colStart!="number"||s.colStart<0||typeof s.colEnd!="number"||s.colEnd<s.colStart||typeof s.rowStart!="number"||s.rowStart<0||typeof s.rowEnd!="number"||s.rowEnd<s.rowStart),mergeRangedValues:Oc,rowFirstCellComparator:Tc,rowFirstRangeComparator:hg,sanitizeRange:s=>s?{colStart:s.colIndex??s.colStart??0,rowStart:s.rowIndex??s.rowStart??0,colEnd:s.colIndex??s.colEnd??0,rowEnd:s.rowIndex??s.rowEnd??0}:null,translateRange:(s,e=-s.rowStart,t=-s.colStart,n)=>n?(n.colStart=s.colStart+t,n.rowStart=s.rowStart+e,n.colEnd=s.colEnd+t,n.rowEnd=s.rowEnd+e,n):{colStart:s.colStart+t,rowStart:s.rowStart+e,colEnd:s.colEnd+t,rowEnd:s.rowEnd+e},unionRanges:na,unionRangesArrays:(s,e,t)=>{if(!s||s.length===0)return null;if(s.length===1&&!e)return s[0];let n=s[0];for(let r=1;r<s.length;r++)n=na(n,s[r],t);return e&&(n=na(n,e,t)),n}},Symbol.toStringTag,{value:"Module"})),Wf=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.element"):60103;function jf(s){return function(e){return!!e&&typeof e=="object"}(s)&&!function(e){const t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||function(n){return n.$$typeof===Wf}(e)}(s)}function bo(s,e){return e.clone!==!1&&e.isMergeableObject(s)?tr((t=s,Array.isArray(t)?[]:{}),s,e):s;var t}function Hf(s,e,t){return s.concat(e).map(function(n){return bo(n,t)})}function Bc(s){return Object.keys(s).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(s))}function Dc(s,e){try{return e in s}catch{return!1}}function tr(s,e,t){(t=t||{}).arrayMerge=t.arrayMerge||Hf,t.isMergeableObject=t.isMergeableObject||jf,t.cloneUnlessOtherwiseSpecified=bo;const n=Array.isArray(e);return n===Array.isArray(s)?n?t.arrayMerge(s,e,t):function(r,o,i){const a={};return i.isMergeableObject(r)&&Bc(r).forEach(function(l){a[l]=bo(r[l],i)}),Bc(o).forEach(function(l){(function(c,h){return Dc(c,h)&&!(Object.hasOwnProperty.call(c,h)&&Object.propertyIsEnumerable.call(c,h))})(r,l)||(Dc(r,l)&&i.isMergeableObject(o[l])?a[l]=function(c,h){if(!h.customMerge)return tr;const u=h.customMerge(c);return typeof u=="function"?u:tr}(l,i)(r[l],o[l],i):a[l]=bo(o[l],i))}),a}(s,e,t):bo(e,t)}tr.all=function(s,e){if(!Array.isArray(s))throw new Error("first argument should be an array");return s.reduce(function(t,n){return tr(t,n,e)},{})};const Vf=Object.freeze([]),Gf=Object.freeze({}),Lc=s=>s,js=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(s){let e=16*Math.random()|0;return(s==="x"?e:3&e|8).toString(16)}),dg=(s,e)=>s===e||!(!Array.isArray(s)||!Array.isArray(e)||s.length!==e.length)&&s.every((t,n)=>t===e[n]),Qr=s=>typeof s=="object"&&!Array.isArray(s)&&s!==null,gg=s=>typeof s!="object"||Array.isArray(s)||s===null?s:(Object.keys(s).forEach(function(e){s[e]&&typeof s[e]=="object"?gg(s[e]):s[e]!==null&&s[e]!==void 0||delete s[e],typeof s[e]=="object"&&Object.keys(s[e]).length===0&&delete s[e]}),Object.keys(s).length===0?null:s),$f=(s,e)=>!(s!==e&&!dg(s,e)&&!s.isEqual?.(e)),mg=(s,e,t=$f)=>{if(s==null||s===e)return null;if(!s||typeof s!="object"||Array.isArray(s)||s.isImmutable?.())return t(s,e)?null:s;const n=Object.keys(s);if(n.length===0)return null;let r=!1;for(let o=0;o<n.length;o++){const i=n[o];mg(s[i],e?.[i],t)===null&&(r=!0,delete s[i])}return r&&Object.keys(s).length===0?null:void 0},Pc=typeof performance=="object"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now(),zc=s=>s==null,Wc=(s,e)=>!(e.left>s.right||e.right<s.left||e.top>s.bottom||e.bottom<s.top),jc=!(typeof window>"u"||!window.document||!window.document.createElement),ht={Windows:"windows",MacOS:"macos",IOS:"ios",Linux:"linux",Android:"android",Safari:"safari",Firefox:"firefox",Node:"node",Unknown:"unknown"},Wo=()=>{if(fg())return ht.Node;const s=globalThis.navigator!==void 0&&globalThis.navigator.userAgent?globalThis.navigator.userAgent.toLowerCase():"";return s?/(win32|win64|windows|wince)/i.test(s)?ht.Windows:/(macintosh|macintel|macppc|mac68k|macos)/i.test(s)?ht.MacOS:/(iphone|ipad|ipod)/i.test(s)?ht.IOS:/android/.test(s)?ht.Android:/linux/.test(s)?ht.Linux:/^((?!chrome|android|).)*safari/i.test(s)?ht.Safari:/^((?!chrome|android|Seamonkey).)*firefox/i.test(s)?ht.Firefox:ht.Unknown:ht.Unknown};function fg(){return typeof process<"u"&&process.release?.name==="node"||(typeof process<"u"&&process.browser,!1)}const Hc=(s,e=!1)=>(document.hasFocus()||e)&&(s===document.activeElement||s?.contains(document.activeElement)),N=Object.freeze(Object.defineProperty({__proto__:null,EmptyArray:Vf,EmptyObject:Gf,OSType:ht,arrayMove:function(s,e,t){const n=s.slice();return n.splice(t<0?n.length+t:t,0,n.splice(e,1)[0]),n},asNumber:s=>{const e=(t=>1*t)(s);return Number.isFinite(e)?e:0},camelToPrettyCase:s=>s.length===1?s.toUpperCase():s.replace(/([A-Z])/g," $1").replace(/^./,function(e){return e.toUpperCase()}).trim(),canUseDOM:jc,cancelTimeout:s=>{cancelAnimationFrame(s.id)},castToString:s=>s==null||s===void 0?"":typeof s!="string"?""+s:s,cloneObject:s=>zc(s)?s:JSON.parse(JSON.stringify(s)),consoleWithNoSource:(...s)=>new Promise(e=>{setTimeout(()=>{Function("console.log.apply(console, arguments)").apply(null,s),e()})}),debounce:function(s,e=300,t=!1){let n,r,o,i,a=0;function l(){let h=Date.now()-a;h<e&&h>=0?n=setTimeout(l,e-h):(n=null,t||(i=s.apply(o,r),o=r=null))}e==null&&(e=100);const c=function(){o=globalThis,r=arguments,a=Date.now();var h=t&&!n;return n||(n=setTimeout(l,e)),h&&(i=s.apply(o,r),o=r=null),i};return c.clear=function(){n&&(clearTimeout(n),n=null)},c.flush=function(){n&&(i=s.apply(o,r),o=r=null,clearTimeout(n),n=null)},c},deepEqual:function s(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;let n,r,o;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!s(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!s(r[1],t.get(r[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){let i=o[r];if(!(i==="_owner"&&e.$$typeof||s(e[i],t[i])))return!1}return!0}return e!=e&&t!=t},deepFreeze:function s(e){return Object.freeze(e),Object.keys(e).forEach(t=>{typeof e[t]!="object"||e[t]===null||Object.isFrozen(e[t])||s(e[t])}),e},deepMerge:tr,diffValues:(s,e)=>{const t={},n=Object.keys(e),r=n.length;for(let o=0;o<r;o++){const i=n[o];s[i]!==e[i]&&(s[i]===void 0?t[i]=e[i]:t[i]=s[i])}return Object.keys(t).length===0?null:t},findEqualOrGreater:function(s,e,t=Lc){let n=0,r=s.length-1;for(;n<=r;){let o=Math.floor((n+r)/2),i=t(s[o]);if(i===e)return o;i<e?n=o+1:r=o-1}return n},findEqualOrLesser:function(s,e,t=Lc){let n=s.length-1,r=0;for(;n>=r;){let o=Math.floor((n+r)/2),i=t(s[o]);if(i===e)return o;i>e?n=o-1:r=o+1}return n},findNextStep:(s,e=!0,t=15,n=10,r=400)=>{const o=Math.max(s-n,0)+(e?1:-1);return Math.min(r,Math[e?"ceil":"floor"](o/t)*t+n)},getDPI:()=>{let s=1;return typeof window=="object"&&(s=window.devicePixelRatio||1),s},getFromPath:(s,e)=>{const t=e.split(".");let n=s;for(let r=0;r<t.length;r++){const o=t[r];if(!n)return null;let i=n[o];if(typeof i=="function"&&(i=i.bind(n)()),!i||!Qr(i))return i;n=i}return n??null},getOS:Wo,hasFocus:Hc,isDefined:s=>s!=null,isEmpty:s=>s==null||s==="",isEqualArrays:dg,isEqualBounds:(s,e)=>s===e||!(s&&!e||e&&!s)&&s.x===e.x&&s.y===e.y&&s.width===e.width&&s.height===e.height,isEqualObjectKeys:(s,e)=>{if(s===e)return!0;if(s&&!e||e&&!s)return!1;const t=Object.keys(s);if(t.length!==Object.keys(e).length)return!1;for(let n=0;n<t.length;n++)if(s[t[n]]!==e[t[n]])return!1;return!0},isNode:fg,isNullOrUndefined:zc,isNumeric:s=>{const e=1*s;return Number.isFinite(e)&&typeof e=="number"},isObject:Qr,isPromiseLike:s=>!!s&&typeof s.then=="function",isRectInsideRect:(s,e)=>s.top>=e.top&&s.bottom<=e.bottom&&s.left>=e.left&&s.right<=e.right,isRectIntersect:Wc,mergeContentful:(...s)=>{const e=s.length;if(e>0&&s[e-1]!==void 0&&!Qr(s[e-1]))return s[e-1];let t=s[0]||{};for(let n=1;n<e;n++)t=tr(t,s[n]||{},{arrayMerge:(r,o)=>[...o]});return t},nextTick:s=>{typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(()=>{s()}):(typeof setImmediate=="function"?setImmediate:setTimeout)(()=>{s()})},openFileDialog:(s="*.*")=>new Promise((e,t)=>{if(!jc)return void t("Unable to open dialog with no dom.");const n=document.createElement("input");n.type="file",n.accept=s;let r=null,o=!1;globalThis.addEventListener?.("focus",()=>{setTimeout(()=>{r||o||(o=!0,e(null))},1e3)},{once:!0,passive:!0}),n.onchange=()=>{if(r=n.files[0],r){if(o)return void console.warn("File open detected after faux cancel.",r);e(r)}},n.autofocus=!0,n.click()}),rafThrottle:s=>{let e,t=!1,n=function(){t=!1,s(e)};return function(r){e=r,e&&e.persist&&e.persist(),t||(t=!0,requestAnimationFrame(n))}},removeEmptyProperties:gg,removeEqualValues:mg,removeListenerAll:s=>{if(!s)return[];for(let e=0;e<s.length;e++)s[e]&&s[e]();return[]},requestTimeout:(s,e)=>{const t=Pc(),n={id:requestAnimationFrame(function r(){Pc()-t>=e?s.call(null):n.id=requestAnimationFrame(r)})};return n},roundAccurately:(s,e=0)=>{if(s==null||!isFinite(s))return null;const t=10**e;return Number(Math.round(s*t)/t)},setToPath:(s,e,t)=>{const n=e.split(".");let r=s;if(!r)throw new Error("Can not set path to a null path.");for(let o=0;r&&o<n.length-1;o++){const i=n[o];let a=r[i];if(a==null&&(a={},r[i]=a),!Qr(a))throw new Error("Can not set path to a non object path.");r=a}if(typeof t!="number"&&typeof t!="boolean"&&typeof t!="string"&&!Qr(t))throw new Error(`Can not set path to ${t} that is not a a supported primitive.`);return r[n[n.length-1]]=t,s},splitNumber:s=>{let e=Math.abs(s);if(isNaN(e)||!isFinite(s))return null;let t=0|e,n=e-t,r=0,o=0,i=1;if(n>5e-8)for(;o<8&&Math.abs(r/i-n)>5e-8;)o++,i*=10,r=Math.round(n*i);return{ip:Math.trunc(s),fp:r,ipLength:Math.ceil(Math.log10(t+1)),fpLength:o}},subtractRect:(s,e,t=!1)=>{if(!e)return[s];if(!Wc(s,e))return[];const n=[];let r=s;const o=()=>{e.top>r.top&&e.top<r.bottom&&(n.push({...r,bottom:e.top}),r={...r,top:e.top})},i=()=>{e.bottom>r.top&&e.bottom<r.bottom&&(n.push({...r,top:e.bottom}),r={...r,bottom:e.bottom})},a=()=>{e.right>r.left&&e.right<r.right&&(n.push({...r,left:e.right}),r={...r,right:e.right})},l=()=>{e.left>r.left&&e.left<r.right&&(n.push({...r,right:e.left}),r={...r,left:e.left})};return t?(l(),a(),o(),i()):(o(),i(),a(),l()),n},textToKey:s=>s.replace(/[^a-zA-Z0-9]/g,"").toLowerCase(),throttle:function(s,e){let t=null;return(...n)=>{const r=Date.now();(!t||r-t>=e)&&(t=r,s(...n))}},toSafeJSON:function s(e){if(e===null||typeof e!="object")return e;if(typeof e.toJSON=="function")return e.toJSON();if(Array.isArray(e))return e.map(n=>s(n));if(typeof e.toString=="function"&&e.toString!==Object.prototype.toString)return e.toString();const t={};for(const n in e)e.hasOwnProperty(n)&&(t[n]=s(e[n]));return t},transpose:s=>{if(!s)return s;const e=s.length,t=s[0].length,n=[];for(let r=0;r<t;r++)n[r]=Array(e);for(let r=0;r<e;r++)for(let o=0;o<t;o++)n[o][r]=s[r][o];return n},uuidV4:js,validEnumValue:(s,e)=>{if(!Object.values(s).includes(e))throw new Error(`Invalid type: ${e??"null"}. Must be one of: ${Object.values(e).join(", ")}.`)},whenFocus:async(s,e=!1)=>new Promise(t=>{Hc(s,e)?t(!0):s.addEventListener("focusin",()=>{t(!0)},{once:!0}),s.focus()})},Symbol.toStringTag,{value:"Module"})),pg=Object.freeze(Object.defineProperty({__proto__:null,MESSAGE_ERROR_INVALID_ARG:s=>`Invalid argument: '${s}'.`},Symbol.toStringTag,{value:"Module"})),_g=s=>{const e=new Uint8Array(s),t=e.byteLength;let n="";for(let r=0;r<t;r++)n+=String.fromCharCode(e[r]);if(typeof window<"u"&&typeof globalThis.btoa=="function")return globalThis.btoa(n);if(typeof Buffer<"u")return Buffer.from(n,"binary").toString("base64");throw new Error("Unsupported environment")},Cl=s=>new Promise((e,t)=>{if(s)if(typeof FileReader<"u"){const n=new FileReader;n.onload=()=>{e(n.result)},n.onerror=()=>{t(n.error)},n.readAsText(s)}else if(typeof Buffer<"u"){const n=r=>Buffer.from(r).toString("utf-8");s.arrayBuffer().then(r=>{e(n(r))}).catch(r=>{t(r)})}else t(new Error("Unsupported environment"));else e("")}),Ar=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MIME_TYPE:"*/*",arrayBufferToBase64:_g,base64ToArrayBuffer:s=>{const e=typeof window<"u"&&typeof globalThis.atob=="function"?globalThis.atob(s):Buffer.from(s,"base64").toString("binary"),t=e.length,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);return n.buffer},blobToString:Cl},Symbol.toStringTag,{value:"Module"})),Sg="data:image/png;base64,",wg="Unable to resolve image.",Vc=s=>new Promise(async(e,t)=>{let n=null;try{n=new Image,n.src=s,n.addEventListener("load",function(){e({width:n.naturalWidth,height:n.naturalHeight})},{once:!0}),n.addEventListener("error",function(){URL.revokeObjectURL(s),t("Invalid Image")},{once:!0}),await n.decode("sync")}catch{n?.src&&URL.revokeObjectURL(n.src)}n||t(wg)}),ra="image/svg+xml",Bo=Object.freeze(Object.defineProperty({__proto__:null,DATA_URL_PNG_PREFIX:Sg,getImageDataUrl:(s,e=1)=>new Promise(async(t,n)=>{let r=null;try{r=new Image,r.src=s,r.addEventListener("load",function(){try{const o=document.createElement("canvas");o.width=r.naturalWidth,o.height=r.naturalHeight,o.getContext("2d").drawImage(r,0,0);const i=o.toDataURL("image/png",e);t({elemImg:r,dataUrl:i})}catch(o){URL.revokeObjectURL(s),n(o)}},{once:!0}),r.addEventListener("error",function(){URL.revokeObjectURL(s),n("Invalid Image")},{once:!0}),await r.decode("sync")}catch{r?.src&&URL.revokeObjectURL(r.src)}r||n(wg)}),loadImageDetails:async(s,e=null)=>{let t=null;const n=async()=>{try{const o=e??"image/*",i=URL.createObjectURL(new Blob([s],{type:o})),a=await Vc(i);t={mimeType:o,naturalDimensions:a,asUrl:i}}catch{}},r=async()=>{try{const o=new TextDecoder().decode(s),i=URL.createObjectURL(new Blob([o],{type:ra})),a=await Vc(i);t={mimeType:e??ra,naturalDimensions:a,asUrl:i,asSVGText:o}}catch{}};if(e===ra?await r():e.startsWith("image/")?await n():(await n(),t||await r()),!t)throw new Error("Failed to load image");return t}},Symbol.toStringTag,{value:"Module"}));function Hs(s,e){e||(e={}),typeof e=="function"&&(e={cmp:e});let t=typeof e.cycles=="boolean"&&e.cycles;const n=e.cmp&&function(o){return function(i){return function(a,l){const c={key:a,value:i[a]},h={key:l,value:i[l]};return o(c,h)}}}(e.cmp);let r=[];return function o(i){if(i&&i.toJSON&&typeof i.toJSON=="function"&&(i=i.toJSON()),i===void 0)return;if(typeof i=="number")return isFinite(i)?""+i:"null";if(typeof i!="object")return JSON.stringify(i);let a;if(Array.isArray(i)){a="[";for(let h=0;h<i.length;h++)h&&(a+=","),a+=o(i[h])||"null";return a+"]"}if(i===null)return"null";if(r.indexOf(i)!==-1){if(t)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}const l=r.push(i)-1,c=Object.keys(i).sort(n&&n(i));a="";for(let h=0;h<c.length;h++){const u=c[h],d=o(i[u]);d&&(a&&(a+=","),a+=JSON.stringify(u)+":"+d)}return r.splice(l,1),"{"+a+"}"}(s)}var Gc;exports.it=void 0,(Gc=exports.it||(exports.it={})).resolveTypedUpdates=(s,e,t,n)=>{if(s===null)return s;if(s===void 0)return n;let r=s;if(e?.shorthand){const l=e?.shorthand(s,t);l!==void 0&&(r=l)}if(r!==null&&e?.getSubType){const l=e.getSubType(r);l&&(e=l)}const o=e?.properties,i=e?.arrayType??!1;let a=r;if(e&&e.merge&&a&&n)a=e.merge(a,n,t);else if(!i&&o){const l=Object.keys({...r,...n});a=null;for(let c=0;c<l.length;c++){const h=l[c];let u,d=r[h];if(d!==void 0){const g=o[h];u=g?(0,Gc.resolveTypedUpdates)(d,g,t,n?.[h]):d}else u=n?.[h];u!=null&&(a=a??{},a[h]=u)}}return a};class $r extends Error{constructor(e,t=null){super(e,t),this.name="ChainedError",this._cause=t}get cause(){return this._cause}}class yg extends $r{constructor(e="Partial Error",t=null){super(e,t)}}class Ne extends yg{constructor(e="Out of bounds",t=null){super(e,t),this.name="OutOfBoundsError"}}class Cg extends $r{constructor(e="Partial Error",t=null){super(e,t)}}class Ot extends $r{constructor(e="Null not supported",t=null){super(e,t)}}class bl extends Error{constructor(e="Null not supported",t){super(e),this._type=t}get type(){return this._type}}class nc extends $r{constructor(e="Not implemented",t=null){super(e,t)}}const $c=`The Safari browser does not support advanced copy and paste.
|
|
7
|
+
Copy and paste will be limited to within the browser tab.
|
|
8
|
+
|
|
9
|
+
Please use Chrome or Edge if external copy and paste is required.`,oa=`You do not have permissions to access the clipboard.
|
|
10
|
+
All copy and paste operations will be limited to the browser tab.`,bg={Safari:`The Safari browser does not support advanced copy and paste.
|
|
11
|
+
Copy and paste will be limited to within the browser tab.
|
|
12
|
+
|
|
13
|
+
Please use Chrome or Edge if external copy and paste is required.`,Perms:oa,PermsWrite:Wo()===ht.Safari?$c:oa,PermsRead:Wo()===ht.Safari?$c:oa},sa=async()=>new Promise(s=>{document.hasFocus()?s():globalThis.addEventListener?.("focus",()=>{s()},{once:!0}),document.activeElement.focus?.()}),ia=async(s,e,t)=>{if(Wo()===ht.Safari)return await t(new Error(bg.Safari));try{const n=async i=>{try{return await i()}catch(a){if(a.message?.includes("Document is not focused"))return!1;throw a}},r=await globalThis?.navigator?.permissions?.query({name:s,allowWithoutGesture:!0,allowWithoutSanitization:!0});let o=!1;if(r.state==="prompt"&&(o=await n(e)),o||r.state!=="granted"||(o=await e()),!o)return await t(new Error(r.state))}catch(n){return n.message==="No valid data on clipboard"||n.name==="DataError"?void 0:await t(n)}},Eg=async s=>{try{return await s.read({unsanitized:[Me.html]})}catch{}return await s.read()},vg=async(s,e)=>{if(!s)return null;const t=await Eg(s);let n=!1;for(let r=0;!n&&t&&r<t.length;r++)if(n=t[r].types.includes(e),n)return await t[r].getType(e);return n?void 0:null};if(!globalThis.ClipboardItem){const s=(t,n)=>new Blob([n],{type:t});class e{constructor(n,r){this._items={},this._types=Object.keys(n);const o={},i=Object.keys(n);for(let a=0;a<i.length;a++){const l=i[a];let c=n[l];o[l]=typeof c=="string"?s(l,c):c}this._items=o,this._presentationStyle=r?.presentationStyle??"unspecified"}get types(){return this._types}getType(n){return Promise.resolve(this._items[n])}supports(n){return!0}}globalThis.ClipboardItem=e}const wi=async(s,e=Me.html)=>new Promise(async(t,n)=>{try{const r=await vg(s,e);if(r){const o=new FileReader;o.onload=()=>{t(o.result)},o.onerror=()=>{t("")},o.readAsText(r)}else t("")}catch(r){n(r)}}),El=async(s,e=Me.html)=>{const t=await wi(s,e);if(!t)return null;let n=null;try{n=new DOMParser().parseFromString(t,Me.html)}catch{console.warn("Can't parse html from clipboard.")}return n},xg=async s=>{s&&await s.writeText("")},Uf={readBlobFromClipboard:vg,readStringFromClipboard:wi,readHTMLFromClipboard:El,clearClipboard:xg},jo="clipboard-uuid",ur="web text/uuid",Uc=s=>`<div style="display:none" ${jo}="${s}"/>`,qf=(s,e)=>{let t=null;try{const n=new DOMParser().parseFromString(e,Me.html);n.body.firstElementChild.setAttribute(jo,s),t=n.getElementsByTagName("body")[0].innerHTML}catch(n){console.warn("Can't embed uuid.",n)}return t},qc=(s,e)=>{if(!e||!s)return!1;try{const t=e.querySelectorAll(`[${jo}="${s}"]`);if(t&&t.length===1)return!0;if(e.querySelector("parsererror"))throw new Error("We are unable to parse node");return!1}catch{return!1}};class vl{constructor(e){if(e?.nativeClipboard===void 0||e?.nativeClipboard===!0)try{this._nativeClipboard=globalThis?.navigator.clipboard}catch{e?.nativeClipboard===!0&&console.warn("NativeClipboard option set to true but no native clipboard available.")}else this._nativeClipboard=e?.nativeClipboard===!1?null:e?.nativeClipboard;this._disableCheckOnFocus=e?.disableCheckOnFocus??!1,this._init()}async _checkForChanges(){this._nativeClipboard&&this._state&&!this._disableCheckOnFocus&&await ia("clipboard-read",async()=>{await sa();const e=await wi(this._nativeClipboard,ur);if(!this._state||e&&e===this._state.uuid)return!0;const t=await El(this._nativeClipboard,Me.html);return!this._state||(qc(this._state.uuid,t)||this.clear(),!0)},async e=>{e?.message==="denied"||e.message?.includes("Document is not focused")||Wo()===ht.Safari||console.warn("Unable to detect clipboard changes: ",e)})}_init(){const e=this;this._listeners=new Map,this._listenersCapture=new Map,this._state=null,this._nativeClipboard&&(this._onFocus=()=>{e._checkForChanges()},this._onBlur=()=>{globalThis.addEventListener?.("focus",e._onFocus,{once:!0})},globalThis.addEventListener?.("blur",this._onBlur),this._nativeClipboard.addEventListener("clipboardchange",t=>{e._checkForChanges()}))}async read(){if(!this._nativeClipboard)return this._state?.items??null;const e=this;return await ia("clipboard-read",async()=>{if(await sa(),this._state?.uuid){const t=await wi(this._nativeClipboard,ur);if(t&&t===e._state.uuid)return!0;const n=await El(this._nativeClipboard,Me.html);if(qc(e._state?.uuid,n))return!0}return e._state={items:await Eg(this._nativeClipboard),uuid:null,ref:null},this.dispatchEvent(new Event("clipboardread")),!0},async t=>{this.dispatchEvent(new Event("clipboarderrorread"))}),this._state?.items??[]}async write(e){return this._write({uuid:js(),items:e,ref:null})}async _write(e){if(!this._nativeClipboard)return this._state=e,this.dispatchEvent(new Event("clipboardwrite")),this.dispatchEvent(new Event("clipboardchange")),null;const t=this,n=[],r=e.uuid;let o=e.items??[];const i=()=>{t._state={uuid:r,ref:e.ref,items:n},t.dispatchEvent(new Event("clipboardwrite")),t.dispatchEvent(new Event("clipboardchange"))};await ia("clipboard-write",async()=>{await sa(),r&&o.length===0&&(o.push(new ClipboardItem({[ur]:new Blob([r],{type:ur})})),o.push(new ClipboardItem({[Me.html]:new Blob([Uc(r)],{type:Me.html})})));for(let a=0;a<Math.min(1,o.length);a++){const l=o[a];let c=l.types.indexOf(Me.html),h=null;if(c!==-1){const g=await l.getType(Me.html);h=await Cl(g),h&&(h=qf(r,h))}if(!h&&l.types.includes(Me.plain)){const g=await l.getType(Me.plain);if(g){let m=null;typeof g=="string"?(console.warn("text as string",g),m=g):m=await Cl(g),m&&(h=`<div ${jo}="${r}">${m}</div>`)}}if(!h&&l.types.includes(Me.png)){const g=await l.getType(Me.png),m=_g(await g.arrayBuffer());h=`<div ${jo}="${r}"><img src="${Sg+m}"/></div>`}!h&&r&&(h=Uc(r));const u=new Blob([h??""],{type:Me.html}),d={};for(let g=0;g<l.types.length;g++){const m=l.types[g];d[m]=g===c?u:l.getType(m)}h&&c===-1&&(d[Me.html]=u),r&&(d[ur]=new Blob([r],{type:ur})),n.push(new ClipboardItem(d))}try{n&&n.length!==0?await this._nativeClipboard.write(n):await xg(this._nativeClipboard)}catch(a){a.message?.includes("Document is not focused")||console.warn("Unable to write to native clipboard: ",a)}return i(),!0},async a=>{this.dispatchEvent(new Event("clipboarderrorwrite")),i()})}async writeReference(e){if(!e)return void this.clear();let t=null;const n={};try{const o=await e.toText?.()??null;o&&(n[Me.plain]=new Blob([o??""],{type:Me.plain}))}catch(o){t=o}try{const o=await e.toHtml?.()??null;o&&(n[Me.html]=new Blob([o],{type:Me.html}))}catch(o){t=o,console.warn("export to html",o)}try{const o=await e.toImage?.()??null;o&&(n[Me.png]=o)}catch(o){t=o,console.warn("export to png",o)}const r=this._write({uuid:js(),ref:e,items:Object.keys(n).length>0?[new ClipboardItem(n)]:null});if(t)throw t;return r}clear(e=!1){this._state&&(this._state=null,e&&this._write({uuid:null,ref:null,items:null}),this.dispatchEvent(new Event("clipboardwrite")),this.dispatchEvent(new Event("clipboardchange")))}async readReference(){return await this.read(),this._state?.ref??null}readText(){return new Promise(async(e,t)=>{const n=await this.read();let r=null;for(let i=0;!r&&n&&i<n.length;i++)n[i].types.includes(Me.plain)&&(r=await n[i].getType(Me.plain));if(!r)return void e("");const o=new FileReader;o.onload=()=>{e(o.result)},o.readAsText(r),o.onerror=i=>{t(i)}})}async writeText(e){const t=[new ClipboardItem({[Me.plain]:new Blob([e],{type:Me.plain})})];return this._write({uuid:js(),items:t,ref:null})}addEventListener(e,t,n={}){const r=n?.capture?this._listenersCapture:this._listeners;let o=r.get(e);o||(o=new Map,r.set(e,o)),o.set(t,typeof n=="boolean"?{}:n)}dispatchEvent(e){if(!e)return;const t=n=>{const r=n.get(e.type);r&&r.forEach((o,i)=>{try{typeof i=="function"?i(e):i.handleEvent&&i.handleEvent(e),o.once&&r.delete(i)}catch(a){console.warn(a)}})};return t(this._listenersCapture),t(this._listeners),!0}removeEventListener(e,t,n){const r=n?.capture?this._listenersCapture:this._listeners,o=r.get(e);o&&(o.delete(t),o.size===0&&r.delete(e))}close(){globalThis.removeEventListener?.("focus",this._onFocus),globalThis.removeEventListener?.("blur",this._onBlur)}}var aa;(aa=vl||(vl={})).ErrorMessages=bg,aa.Global=new aa;class Jc{constructor(e=100){this._maxStack=e,this._undoStack=[],this._redoStack=[],this._repeatOperation=null,this._listeners=new Set}get maxStack(){return this._maxStack}undo(e=1){if(this._undoStack.length===0)return;let t=!1;try{for(let n=0;n<e&&this._undoStack.length>0;n++){const r=this._undoStack[this._undoStack.length-1];r.redo=r.undo(),this._undoStack.pop(),typeof r.redo=="function"?this._redoStack.push(r):this._redoStack=[],t=!0}}catch(n){throw n}finally{t&&this._notifyOnStackChange()}}redo(e=1){if(this._redoStack.length===0)return void(this._repeatOperation!==null&&this._repeatOperation.repeat());let t=!1;try{for(let n=0;n<e&&this._redoStack.length>0;n++){const r=this._redoStack[this._redoStack.length-1];r.redo(),this._redoStack.pop(),this._undoStack.push(r),t=!0}}catch(n){throw n}finally{t&&this._notifyOnStackChange()}}hasUndo(){return this._undoStack.length>0}getTopUndoDescription(){return this._undoStack.length===0?null:this._undoStack[this._undoStack.length-1].description}hasRedo(){return this._redoStack.length>0||this._repeatOperation!==null}getTopRedoDescription(){return this._repeatOperation!==null?this._repeatOperation.description:this._redoStack.length===0?null:this._redoStack[this._redoStack.length-1].description}getUndoDescriptions(){if(this._undoDescriptions)return this._undoDescriptions;const e=[];for(let t=this._undoStack.length-1;t>=0;t--)e.push(this._undoStack[t].description);return this._undoDescriptions=e,this._undoDescriptions}getRedoDescriptions(){if(this._redoDescriptions)return this._redoDescriptions;const e=[];for(let t=this._redoStack.length-1;t>=0;t--)e.push(this._redoStack[t].description);return e.length===0&&this._repeatOperation!==null&&e.push(this._repeatOperation.description),this._redoDescriptions=Object.freeze(e),this._redoDescriptions}addUndoOperation(e){const t={description:e.description,undo:e.undo,redo:null};this._undoStack.push(t),this._redoStack=[],this._undoStack.length>this._maxStack&&this._undoStack.shift(),this._notifyOnStackChange()}setRepeatableOperation(e){this._repeatOperation=e??null,this._redoStack=[],this._notifyOnStackChange()}clear(e=!0){this._undoStack=[],this._redoStack=[],this._repeatOperation=null,this._undoDescriptions=null,this._redoDescriptions=null,e&&this._notifyOnStackChange()}addListener(e){const t=this._listeners;return t.add(e),()=>{t.delete(e)}}_notifyOnStackChange(){this._undoDescriptions=null,this._redoDescriptions=null,this._listeners.forEach(e=>{e.onStackChange?.()})}}const Kc=(s,e)=>{const t=new Map;return s.forEach((n,r)=>{e.get(r)!==n&&t.set(r,n)}),t};let Xc=!1;class Yc{constructor(e){this._record=e}getId(){return this._record.id}getDescription(){return this._record.description}getMeta(){return Object.freeze(this._record.meta)}getAuthor(){return this._record.author}getTimestamp(){return this._record.timestamp}getOperation(){return this._record.operation}}class Bt{constructor(e){this._listeners=new Set,this._listenersState=new Map,this._commits=new Map,this._locked=!1,this._current=null,this._pending=null,this._isSync=e?.sync??Xc,this._isTransient=e?.transient??!1,this._author=e?.author;const t={id:"0",description:"initial",meta:{},author:this._author,timestamp:Date.now(),states:new Map,version:0,previousId:null},n={record:t,commit:new Yc(t)};this._current=n,this._cacheModel=null,this._cacheState=null,this._states=t.states,this._transactionStack=[],this._transactionOpen=!1;const r=new Map;r.set(t.id,n),this._commits=r}static{this.setDefaultSync=e=>{Xc=e}}getLog(e,t=100){const n=[];let r=e;do{const o=this._commits.get(r);if(!o)throw new Error(`Invalid commit id: '${r}'`);if(n.push(o.commit),r=o.record.previousId,!r)return n}while(n.length<t)}getCommitCount(){return this._commits.size}isOpenTransaction(){return this._transactionStack.length>0||this._transactionOpen}getPendingView(){const e=this._transactionStack;return e.length>0?e[0].getView():null}getState(e){const t=this._transactionStack;if(t.length===0){if(this._cacheModel===e)return this._cacheState;const n=this._states.get(e);return this._cacheModel=e,this._cacheState=n,n}return t[t.length-1].getState(e)}getCurrentCommit(){return this._pending?.commit??this._current.commit}restore(e,t){const n=this._getCommitContainer(e,t);if(this._current.commit.getId()===n.commit.getId())return n.commit;let r;t?.viewId&&t?.viewId!=="custom"||(r=n.record.viewAfter);const o=Kc(n.record.states,this._current.record.states);this._notifyStates("onBeforeCommitStart",this._current,o,r,!0,!1),this._current=n,this._states=this._current.record.states,this._cacheModel=null,this._cacheState=null,this._notifyStates("onAfterStateChange",n,o,r,!1,!0,!0),this._notify("onCommitChange",n.commit,!0),this._transactionOpen=!0;try{this._notifyStates("onRestoreOrRevert",n,n.record.states,r,!1,!0)}finally{this._transactionOpen=!1}return n.commit}revert(e,t){const n=this._getCommitContainer(e,t),r=this._commits.get(n.record.previousId);if(!r)throw new Error(`Invalid commit id: '${n.record.previousId}'`);let o;t?.viewId&&t?.viewId!==" custom"||(o=n.record.viewBefore??n.record.viewAfter);const i=Kc(r.record.states,this._current.record.states);this._notifyStates("onBeforeCommitStart",this._current,i,o,!0,!1),this._current=r,this._states=this._current.record.states,this._cacheModel=null,this._cacheState=null,this._notifyStates("onAfterStateChange",r,i,o,!0,!1,!0),this._notify("onCommitChange",r.commit,!0),this._transactionOpen=!0;try{this._notifyStates("onRestoreOrRevert",r,r.record.states,o,!0,!0)}finally{this._transactionOpen=!1}return r.commit}_getCommitContainer(e,t){const n=this._commits.get(e);if(!n)throw new Error(`Invalid commit id: '${e}'`);if(this._isTransient)throw new Error("Cannot revert transient store");if(t?.force&&this._transactionStack.length>0&&this._transactionStack[0].rollback(),this._transactionStack.length!==0)throw new Error("Open transactions.");return n}_pruneForwards(e){}beginCommit(e,t){const n=this._transactionStack,r=n.length;if(this._locked)throw console.warn("TransactionStore locked",n),new Error(`TransactionStore is locked by '${n[r-1].getDescription()}`);const o=e?.preventFurtherTransactions,i=this,a=(c,h,u)=>{const d=i._transactionStack;r!==d.length-1&&console.warn("Transaction stack out of sync",r,d.length,d),o&&(this._locked=!1),d.pop(),t?.(c,h,u),d.length===0&&(i._pending=null)};let l;if(n.length===0){const c=this._current.record,h={states:new Map,id:N.uuidV4(),description:typeof e=="string"?e:e?.description??null,meta:{},timestamp:Date.now(),author:null,version:c.version+1,previousId:c.id,viewBefore:null,viewAfter:{},operation:e?.operation},u={record:h,commit:new Yc(h)};this._pending=u,this._notify("onCommitStart",u.commit),l=new Jf(this,u,c?.states,e,a)}else l=n[n.length-1].beginTransaction(e,a);return o&&(this._locked=!0),this._transactionStack.push(l),l}doBatch(e,t,n){let r;const o=this.beginCommit(t,n),i=this.getCurrentCommit();try{r=e?.(i);const a=()=>{o.commit(t)};if(r&&typeof r.then=="function")return new Promise((l,c)=>{r.then(h=>{try{a(),l(h)}catch(u){c(u)}}).catch(h=>{o.rollback(),c(h)})});a()}catch(a){throw o.rollback(),a}return r}remove(e){return!!e}addListener(e){const t=this._listeners;return t.add(e),()=>{t.delete(e)}}addStateListener(e,t){if(!e)throw new Error("Model is required");if(!t)throw new Error("Listener is required");let n=this._listenersState.get(e);return n||(n=new Set,this._listenersState.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this._listenersState.delete(e)}}dispatchEvents(e,t=!1){!t||this._isSync?e():setTimeout(e,0)}_commitRecord(e,t,n){let r=e.record,o=e.commit;if(!this._isTransient){if(n){const i=this._commits.get(r.previousId);if(i){r.previousId=i.record.id;const a=i.record,l=a.states;l&&r.states.forEach((c,h)=>{l.set(h,c)}),a.viewAfter={...a.viewAfter,...r.viewAfter},a.meta={...a.meta,...r.meta},a.timestamp=r.timestamp,r=a,o=i.commit,e={record:r,commit:o}}}this._commits.set(r.id,e)}this._current=e,this._states=this._current.record.states,this._cacheModel=null,this._cacheState=null,n||this._notify("onCommitChange",o),this._notifyStates("onAfterStateChange",e,t,e.record.viewAfter,!1,!1,!0),n||this._notify("onCommitEnd",o,!0)}_notifyStates(e,t,n,r,o=!1,i=!1,a=!1){const l=t.commit,c=this._listenersState;n.forEach((h,u)=>{const d=c.get(u);d&&this.dispatchEvents(()=>{d.forEach(g=>{g[e]?.(h,r,l,o,i)})},a)})}_notify(e,t,n=!1){this.dispatchEvents(()=>{this._listeners.forEach(r=>{r[e]?.(t)})},n)}}class Ig{constructor(e,t){this._children=new Set,this._depth=0,this._container=null,this._closed=!1,this._container=e,t=typeof t=="string"?{description:t}:t,this._description=t?.description??"",t?.viewBefore!==void 0&&(e.record.viewBefore=e.record.viewBefore&&t.viewBefore?{...e.record.viewBefore,...t.viewBefore}:t.viewBefore),t?.viewAfter!==void 0&&(e.record.viewAfter=e.record.viewAfter&&t.viewAfter?{...e.record.viewAfter,...t.viewAfter}:t.viewAfter)}getView(){return this._container.record.viewAfter??this._container.record.viewBefore}getDepth(){return this._depth}getDescription(){return this._description}getStates(){return this._states}beginTransaction(e,t){this._ensureOpen();const n=new Kf(this,this._container,typeof e=="string"?{description:e}:e,t);return this._children||this._children,this._children.add(n),n}updateState(e,t){this._ensureOpen();const n=this.getState(e),r=typeof t=="function"?t(n):t===void 0?n:{...n,...t};if(r){let o=this._states;o||(o=new Map,this._states=o),o.set(e,r)}return r}commit(e){if(this._ensureOpen(),typeof e=="string"&&(e={description:e}),e){if(e.description&&(this._description=e.description),e.meta&&(this._meta=N.mergeContentful(e.meta,this._meta)),e.viewAfter!==void 0){const t=this._container.record;let n=e.viewAfter;if(n===null)t.viewAfter=null;else{const r=t.viewAfter;typeof n=="function"&&(n=n(r)),t.viewAfter={...r,...n}}}if(e.viewBefore!==void 0){const t=this._container.record;let n=e.viewBefore;if(n===null)t.viewAfter=null;else{const r=t.viewBefore;typeof n=="function"&&(n=n(r)),t.viewBefore={...r,...n}}}}return this._children&&this._children.forEach(t=>{t.commit(e)}),this}isClose(){return this._closed}_ensureOpen(){if(this._closed)throw this._descriptions&&console.warn(`stack: [${this._descriptions.join(",")}]`),new Error("Transaction already closed")}_removeChild(e){this._children.delete(e),this._mergeStates(e._states)}_mergeStates(e){if(!e||e.size===0)return;let t=this._states;return t?(e.forEach((n,r)=>{const o=this.updateState(r,n);t.set(r,o)}),t):(this._states=e,e)}}class Jf extends Ig{constructor(e,t,n,r,o){super(t,r),this._store=e,this._prevStates=n,this._onClose=o,this._states=new Map,this._meta=t.record.meta}getId(){return this._container.commit.getId()}getParent(){return this}commit(e){const t=this._states,n=this._container,r=n.record.viewAfter;this._store._notifyStates("onBeforeCommitStart",n,t,r,!1,!1),super.commit(e),this._store._notifyStates("onBeforeCommitEnd",n,t,r,!1,!1);const o=new Map(this._prevStates);return this._states.forEach((i,a)=>{i===null?o.delete(a):o.set(a,i)}),this._states=o,this._description&&(n.record.description=this._description),this._meta&&(n.record.meta=this._meta),n.record.states=o,this._closed=!0,this._onClose?.(this,!1,e),this._store._commitRecord(n,t,e?.forceAmend??!1),this}rollback(){return this._ensureOpen(),this._children&&this._children.forEach(e=>{e.rollback()}),this._closed=!0,this._onClose?.(this,!0,null),this}updateState(e,t){const n=super.updateState(e,t);return this._states.set(e,n),n}getState(e){let t=this._states.get(e);return t||(t=this._prevStates.get(e)),t}_mergeStates(e){return!e||e.size===0?new Map:super._mergeStates(e)}}class Kf extends Ig{constructor(e,t,n,r){if(super(t,n),!e)throw new Error("Parent transaction required");this._parent=e,this._depth=this._parent.getDepth()+1,this._onClose=r}getId(){return this._parent.getId()}getParent(){return this._parent}getState(e){const t=this._states?this._states.get(e):void 0;return t!==void 0?t:this._parent.getState(e)}commit(e){return super.commit(e),this._parent._removeChild(this),this._closed=!0,this._onClose?.(this,!1,e),this._parent??this}rollback(){return this._ensureOpen(),this._children&&this._children.forEach(e=>{e.rollback()}),this._parent._removeChild(this),this._closed=!0,this._onClose?.(this,!0,null),this._parent??this}}const Rg=()=>{try{return"0.4.15"}catch{return""}},_n=Object.freeze(Object.defineProperty({__proto__:null,getBuildDate:()=>{try{return"Sat Aug 09 2025"}catch{return""}},getBuildVersion:Rg},Symbol.toStringTag,{value:"Module"})),Xf=`
|
|
14
|
+
https://www.sheetxl.com ${Rg()}`,la="#1976d2",Yf=()=>typeof window=="object"?window.location.hostname:N.getOS(),dr=Object.freeze(Object.defineProperty({__proto__:null,generateNodeId:async()=>"0",getKey:async()=>{throw new Error("getKey is not implemented in browser environment")},printBanner:async s=>{const e=s?console.log:N.consoleWithNoSource,t=`%c
|
|
15
|
+
███████╗██╗ ██╗███████╗███████╗████████╗ ██╗ ██╗██╗
|
|
16
|
+
██╔════╝██║ ██║██╔════╝██╔════╝╚══██╔══╝ ╚██╗██╔╝██║
|
|
17
|
+
███████╗███████║█████╗ █████╗ ██║ ╚███╔╝ ██║
|
|
18
|
+
╚════██║██╔══██║██╔══╝ ██╔══╝ ██║ ██╔██╗ ██║
|
|
19
|
+
███████║██║ ██║███████╗███████╗ ██║ ██╔╝ ██╗███████╗
|
|
20
|
+
╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝${Xf}
|
|
21
|
+
`;return await e(`${t}`,`font-family:monospace;color:${la};font-size:12px;`),Promise.resolve()},printDetails:async(s,e=!1,t=!1,n=!1)=>{let r;const o=console.log,i=[`color:${la};font-size:12px`];if(s.isEval()?(i.push(`font-family:monospace;color:${la};font-size:12px;`),r="%cEvaluation Only",i[0]="color:#E12929;font-size:12px",r+=`%c
|
|
22
|
+
Please visit https://my.sheetxl.com to register.`):(r=`%cLicensee: ${s.licensee()??"Invalid License"}
|
|
23
|
+
`,r+=`Expires: ${s.expiration()?.toLocaleDateString()??"Never"}`,s.domains()&&s.domains().length>0&&(r+=`
|
|
24
|
+
Domains: ${s.domains().join(", ")}`),s.cpuCount()>0&&(r+=`
|
|
25
|
+
Cpus: ${s.cpuCount()}`)),!n&&s.exceptions().length>0){i.push("color:red;font-size:12px"),r+=`
|
|
26
|
+
Exceptions:
|
|
27
|
+
%c`;for(let a=0;a<s.exceptions().length;a++)r+=` ${s.exceptions()[a]}`}return t&&(i.push("color:#FFA726;font-size:12px"),r+="%c",r+=`
|
|
28
|
+
Location: '${Yf()}'`,r+=`
|
|
29
|
+
KeyFrom: '${s.keyFrom()}'`),await o(`${r}`,...i),Promise.resolve()},setKey:async(s,e=!1)=>{throw new Error("setKey is not implemented in browser environment")}},Symbol.toStringTag,{value:"Module"}));function me(s,e){const t=rc();return me=function(n,r){let o=t[n-=356];if(me.pqfNtr===void 0){const l=function(c,h){let u,d,g=[],m=0,f="";for(c=function(_){let p="",S="";for(let C,y,b=0,w=0;y=_.charAt(w++);~y&&(C=b%4?64*C+y:y,b++%4)?p+=String.fromCharCode(255&C>>(-2*b&6)):0)y="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=".indexOf(y);for(let C=0,y=p.length;C<y;C++)S+="%"+("00"+p.charCodeAt(C).toString(16)).slice(-2);return decodeURIComponent(S)}(c),d=0;d<256;d++)g[d]=d;for(d=0;d<256;d++)m=(m+g[d]+h.charCodeAt(d%h.length))%256,u=g[d],g[d]=g[m],g[m]=u;d=0,m=0;for(let _=0;_<c.length;_++)d=(d+1)%256,m=(m+g[d])%256,u=g[d],g[d]=g[m],g[m]=u,f+=String.fromCharCode(c.charCodeAt(_)^g[(g[d]+g[m])%256]);return f};me.juTltl=l,s=arguments,me.pqfNtr=!0}const i=n+t[0],a=s[i];return a?o=a:(me.yqzJPC===void 0&&(me.yqzJPC=!0),o=me.juTltl(o,r),s[i]=o),o},me(s,e)}function Zr(s,e,t,n,r){return me(e- -991,r)}(function(){const s="NkeP",t="lR8P",n="NkeP",o="OF(6",a="vpKc",c="hz&m",h="sorI";function m(S,C,y,b,w){return me(b-393,C)}const f=rc();function _(S,C,y,b,w){return me(S- -517,C)}function p(S,C,y,b,w){return me(w-192,b)}for(;;)try{if(parseInt(p(0,0,0,s,632))/1+-parseInt(p(0,0,0,"jrbg",559))/2*(parseInt(p(0,0,0,t,601))/3)+parseInt(m(0,n,0,924))/4*(-parseInt(_(-16,"*yhr"))/5)+-parseInt(p(0,0,0,o,662))/6*(parseInt(p(0,0,0,a,580))/7)+parseInt(p(0,0,0,"(1Pq",766))/8+-parseInt(p(0,0,0,c,621))/9+parseInt(m(0,h,0,809))/10===205140)break;f.push(f.shift())}catch{f.push(f.shift())}})();const yi=()=>{const s="Wm8X";if(typeof window===e(-367,-430,"M1p^"))return window[e(-327,-366,s)][e(-413,-479,"y$xV")];function e(r,o,i,a,l){return me(r- -824,i)}return N[t="s%[j",n=1059,me(n-496,t)]();var t,n},xl=()=>{const s="DymX",e="hJI1";function t(n,r,o,i,a){return me(r- -132,i)}return yi()[t(0,335,0,s)](t(0,356,0,"kvla"))||yi()===t(0,447,0,e)};function Rt(s,e,t,n,r){return me(s-210,e)}function rc(){const s=["W77dGSojWQ3cImkK","W7yjW7CHzhi","W5FdNSoZW6iZWPfsdSoBza","C8osW5DEW69s","wgCADSknBSk4","p8oXF8k2B8kIqHVdMIpdQKy","oSklWRxcI8kgW7FcVmov","z8kCWQFcLmk5j2ZdVSoeA8oHWRfZ","F8oChCkJhmofWOKAqq","WR3cGCo5WPKhWOBdNumMESkZv8olyeq","DCodW6TAW6bpdq","fmkjsmk2nCkh","tmoSzCksWO5pWRKAWOyTzryB","ACkvW79/WO46qmoJ","WQiEWPVdRIddRYG","W6LPECkHW45wW6afcCkHpttdJN4a","wHpdS8oLWRTpW7FcRCkR","gq83WQfN","kCoXvCkoWPDCW7eeWQBdUv3cT8ozWQW1lG7dLda","WQjoeSo2zaGdW5HlqwOsBw/cH8k6","WRjMWO3dUsXU","pCoSAmkrASk/rXddSde","aSo/WPiKW7iDW4G","lmoXC8ka","W53dHCoeW7eCWPDs","W5ldHmo3W7ukWPS","bSo3wmknWPbiW4DqWQZdS0G","W4WLdCk3W7vbWP3dLGOxmCkTW5JdQCoLxwPSxsa","hSobbCo4WRRdUW","wSklWQJcLSk1mv3dUmoi","WRuvWOZdSHVdSdKb","W4y5W78tWOiYv8o3dSkC","WPJcSmkQhwutsW","W6GWwu4wdgK","W6a6tK4tchvygG","fCobh8oDWRVdULRdHSkZWPvHWR8","W4uZW6K0F25Bphy","WOtdOmk8WQLtcG","W5pcICknbSoqa1LLW68/gmoMWPZdIG","F8kpW7P4WQWG","pCosd8kUfIzHW5viBSkuWPNdQmoyWQnzW5ZcVSoL","hSkkC8kApSkxWQO7","W7xdGSotWOJcICkLcmocWPZcSCo5WQ4","WOtcVhJcLCoHvmk5CG","gmoZoCkcnL4","W7BdGSotWQVcLCkGfW","yMejCSkvF8kWESo0W4PMW57cLCoaqJKoAa","WQTCWQfZw0jWd2/cTq","e8o7WOOvW7iVW58OxmkC","bmoSWPe8W74OW5S","nmoXzCktBSkJ","a8oQwCkg","WRVcISkanvG4yG","W5FdN8o+WR4CWOzcdSo/EmoY","pmoMpG","q8ogW5XxW6vccf3cRG","xSo/ySksWP9/WOGgWOeMyW","jSkAWPuiW5Wh","WRVcKmoIWRK","W77cQSo3WQNdS8o3u8kiWRTB","W4ldL8o+W6uvWRHa","imoUv8khWOXoW6bnWQZdRW3cSCofWQuO","WOddUmkrWP84W7NcIvdcKNJcGSkIW6qY","q8o+W7RdNSoqr8kkCxpcSc3cL2W","tmopeSkOaCoj","lCoscSoZWQFdT1FdLSks","WPbVWRPNW5fWaSoZbmkga8kqsa","rCoWW7NdKCoCw8kP","W4JcIZ7cUKT5hSkAW4y","F1/cHGHgAttdGSoSW4ldJmknWQ8VW6RcTW","WRKiWQBdRIJdVa","pvP0gvddJX9fca9ijCot","l8omm8keWPxdUfuPWP1i","e8ouimkFWRJdO3uPWQHDBMrl","WQNcKCo9WQSaWORdGLqGBCkOsSow","WQ7cLCkomv1R","pwrYaLGvWOuTW5/dR8opAmoAW4lcUSofW5Wuld4","t8oEW5btW6mLWOZcNfhcUG","gG0YWQzNWPu/WQHuW4Svia","W5hdMmoK","whSEyCknzCkdm8oLW5O","W6aZgmkZW6LCWPdcMqGn","W5RdTdtdIh3dOsa","WRDWWQ3dStXJ","WRZcGCoSWQ8hWP3dLfq","WQ7cGmkFmumY","WOFcJSkJW4aDWO1tdmox","vmoyfCkI","W755FSkl","W4uCW6SVFM52aKFcRSo1W5G","ECoiW41sW75F","WQ7cLSkzdLa5","aSoZkCkola1iW4fHxG","W4HUW7FdIfW9jmocf8kuFmkbW4nDWOG","W6VdGmoZW7WzWPPxh8o/","WP4uW4JdRsxdUIGhWPOlwMiRdLrPWPZcScG","WRCEWPZdGZNdScenWQ0pdNC","W4pdTq3dHhJdUYe","W4a9gSk6W6XjWO3cNWKqCSkeW5/dUCoLe3jS","fNmXa0CmWO0RW5/dRW","W7adW7aO","WOhcOfxcM8oXwa","WQ3cLmkan0m","W5f8F8kkW5vlW4Gek8kLjIVdLa","A8kqf0ddRK7dNSkuW4e","kmkCWR3cKG","aSowbmoYWQFdOfm","d8o5k8kCWOdcPa","W4ZdSudcNCkKW6pdMu/dH8o2","WRLMWPFdKqS","W6ldKSouWQi","da0+WQ1PWRq","W7BdImokWQVcLCkIfW","WRLMWO3dUYPNW53dTmkHW6ldISoLESog","WRVdTCkCW6JdISogECkd","WPFdRCklWPmG","WRDWWQBdQdLQ","WRS+pCovW7bjW78VgSkt","WPavgKjxkv/dLcu","W5xcJCkxcCoChxPhW7q4aSo3WP0","vmkUWRmAW6jfWQSvoGbdCCoD","WOhdTCoVW5ddKComCSkkWO5lzCoTbCkv","n8oSlCk7WOhcTmk8W71U","WOhcVw3cLCo5vmkY","W6zpcCoYFKqEW6DncgKhFgG","WRr5tmo4WQKgW4NdMfC","W6CWvgKnd3C","W5TKW4/dPuO1jmodbCkqESkxW7LgWPq/hci","dmoRC8kDWPHd","W7NdRLNcH8kPW6ddILpdImoQW74","cCo0W6fpWROaW7OZora","sCoOF8kOWOjqWOW","W5mLx0yrffHkamkIW7RdIW","W73dMmoKW7eCWPDss8o+F8oSW77dQSkg","omowo8kxWRO","dKxcQCoJWOTJ","fSo9qSkGWPXw","amoGrSkcWOTw","cSkpWPmTW5SqWPRcGMZcRSkGc3S","ymkEW7vRWQ07","WQtcQh3dImkoWOzYWOdcVCoU","Amkeb0ddVW","W5xcPmouW4XTW4lcSM/cSKpcRW","FSkxefBdOfK","W44+W6eYWOqY","htTiiCkOqmkNkSoFW4m","W5hdPHhdJcFcVa","aSo4W7zUWRehW74rmbO","mSoOn8kBWOVcOSkjW4zJW7fOWPNdJa","aSo/jmkmnHy","WRWEWOBdPJJdSq","WO3dRSkPWPuWW7m","nmo9AmkrDmk4sZtdUZS","yCkyWR3cM8k1ou/dNmoFBmo7WQbYeW","ewbWj1BdMbv0ja","W5JdN8oXW7uEWO1timo/Aq","a8o/WO0bW6uYW5a1vCkl","W5ePW7G/","l8oaWPtcNqRdSmkhumojuG","ErRdKmk6lYWyzmoEWRldJKlcQa","WQNcLmoHWRig","w0zOW74QWOurWOzNW5O7","WPJcPMJcNa","fCkpWOKgW4yB","W7u5eSk4W60","WQ13WOldRcX1W77dUmkBW6u","W4ddSWpdM2xdUXpdQCkOaW","nmoiWQ9TWP0xuSoDW7m","W5ddK8oMW7ezWPjfo8oOECoVW6VdPSkm","E8ovW4LVW6vlda","FSoVW6BdMCoBqq","W5ZdQIRdJmkGCSkBCJxcGSko","W6eUd8k3W7beWOO","oMuKb1SrWObKW73dTCkmFSoeW5tcVmkmW5eymhRcScf1W4tcKtNdGq","CGpcKCkZiJ0fF8oqWQJcH13cO8ojWOKOdCoVEMRcTmo2WQKHW4C","x3ypDG","qmkDxmkPW7JcOGpdImknWQ5yWQ95","aw4Ka0ulWOe","W6OEW7aOzf5rf0JcQCo8W5K","WQ52WPddTG","W61KBmkrW7HqW6GehSkW","W4PZW6ddR1KGiCojl8kc","F8kCy8kMWRVdPfqRWPe","w0XJW7eIW6rTW6X6W5C6eSo8kq","WRSvbfTmjLVdHq","W6hdL8olWQpcIa","uGpcKCkZ","lmkBWQFcLW","WPymfKmcc1/dGZNcOCkja0DuzSos","emkSWQZcICkeamoTm1xcQXRcS2/cOa","tCo6W7RdL8obxq","bSo7WPOKW7q+","WQ3dQSoOWOLtcG","qmksW7HPWRCGuCkRW60kFmoqcHBcISofWOyNW4qbwmkugSkDWOT+DmoWWRy","W5hdGmoZW7W","WRuigejHl1FdKH/cOmkEaW","vGBcK8k2pG","uSoRW7xdGSobrSknAM7cTG","W5mcW68NFhnqq0xcQCoZW4/dTHarCKNcH2pdHq","W5dcICkxaSoldL5qW5m5eSo3WRddIG","abaYWQy","W53dQaBdJfJdRa","W5hcVmo/W5qaqGD4xSkpWPZcG1K","WRqEWPZdOcxdTt45WPShfgy8bq","FmkjW7rHWRaGuq","r8k6buhdTuJdMmkLW7K","W4FcMCkkdW","W5O7cCk/W7DCWR3cKXiFo8kKW4u","ySkyWR3cUmkPpfddQmo7ymoNWQD+ggq","W4tcMmkyfConhh1CW6K+","b8oRWPWIW6mPW5CVvW","W51Ad8o6EvWPW5jlag4FAG","W6VdHSoGW7KEWOO","tCotW5zzWOC8WRlcGLtcImkn","WQmigejlnfm","WR8tfePmnfpdHq","WOhcOf7cGSo0uq","WRqFa21xlLRdHbJcRSkoaW","W6tdHSolWR/cMCkkeG","WQZdTCkHW6/dL8odCSkZWPrAlCoOd8k/W7NdHSovWRRcVW","WRFcO2NcNCo7sq","AaxcGSk2osGZD8orWQJdGL8","wXdcNSk4iZq","CCo9ECkvWOvj","W63dUutcImk0W47dMg3dLmoMW6ldKLWQ","iXeTWQL/WRG+W7XzW4SAnSo1eWrtWQbiWQhdIq","wgCADSknBSk4bCo9W5T1W5lcICosuW8ky8ot"];return(rc=function(){return s})()}const Qf=(s,e,t=126)=>((n,r,o=126)=>{const l="y$xV",h="lR8P",u="*yhr";function d(C,y,b,w,E){return me(E- -291,w)}let g=n[m=-111,f="J)g]",me(m- -523,f)]("");var m,f,_,p;function S(C,y,b,w,E){return me(b- -519,E)}for(let C=0;C<g[d(0,0,0,"NkeP",99)];C++)g[C][d(0,0,0,"oKla",165)](0)<=o&&(g[C]=String[d(0,0,0,l,131)]((g[C][S(0,0,7,0,h)](0)+r)%o));return g[_=u,p=43,me(p- -511,_)]("")})(s,t-e),Zf=s=>{const n="3rr#",i="0b[n",l="ar[D",h="semb",u="vpKc",f="@!qU",p="@!qU",S="ar[D",y="*yhr";let E=s;const I=E[E[A(1031,1031,988,1063,"4Alj")]-1],x=I[v(568,669,657,573,n)](0)-52;function v(F,L,D,P,B){return me(P-166,B)}function R(F,L,D,P,B){return me(P- -994,B)}function A(F,L,D,P,B){return me(D-484,B)}function M(F,L,D,P,B){return me(D- -120,L)}function T(F,L,D,P,B){return me(P-256,L)}if(E=E[A(842,1030,921,889,i)](0,E[M(409,"s%[j",354)]-1),E=E[M(304,l,267)]("")[R(0,0,0,-590,h)]()[A(883,1022,911,989,u)](""),E=(F=>{const P="Yi0q",B="w9&S";function O(G,$,te,J,ne){return me(G-529,$)}return typeof window===O(900,"wDxJ")?window[O(1041,"ar[D")](F):Buffer[j="4eQy",H=79,me(H- -426,j)](F,O(902,P))[W=-10,V=B,me(W- -578,V)](O(952,"GJ*O"));var W,V,j,H})(E),E=E[T(712,"Fs0q",870,797)](),E[E[R(0,0,0,-540,"J)g]")]-1]!==I)throw new Error;E=E[v(0,0,0,724,f)](0,E[A(0,0,861,0,"7ej)")]-1),E=Qf(E,x);try{!E[T(0,"0gcN",0,692)]("{")&&(E="{"+E);const F=JSON[T(0,p,0,624)](E),L={licensee:F.l,domains:F.d,nodeId:F.n,expiry:F.e,developerCount:F.dc,cpuCount:F.cc,type:F.t};return F.f&&(L[T(0,S,0,794)]=F.f),L}catch{throw new Error(v(0,0,0,591,y))}},ep=(s,e)=>{const n="semb";function i(c,h,u,d,g){return me(u-803,d)}return{licensee:()=>null,expiration:()=>null,domains:()=>[],developerCount:()=>0,cpuCount:()=>0,type:()=>i(0,0,1380,"Wm8X"),exceptions:()=>{return[(c=n,h=801,i(0,0,h- -402,c)+s+"'")];var c,h},isValidFor:c=>!1,isValid:()=>!1,isEval:()=>!1,features:()=>{return Object[c="vpKc",h=518,me(h- -47,c)]({});var c,h},keyFrom:()=>s,getBuildVersion:_n[a="3rr#",l=1371,me(l-902,a)],getBuildDate:_n[i(0,0,1353,"7ej)")]};var a,l},tp=(s,e,t,n)=>{const r="J)g]",o="Fs0q";function a(h,u,d,g,m){return me(d-910,h)}function l(h,u,d,g,m){return me(h-612,m)}function c(h,u,d,g,m){return me(h-305,u)}return{licensee:()=>s[l(1054,0,0,0,"y$xV")],expiration:()=>new Date(s[l(1151,0,0,0,"NLaM")]),domains:()=>s[a("sorI",0,1431)]??[],developerCount:()=>s[c(821,"WzO@")]??1,cpuCount:()=>{return s[h="z@HR",u=1083,me(u-588,h)]??0;var h,u},type:()=>s[a("*9cG",0,1312)]??c(877,"y$xV"),exceptions:()=>e,isValidFor:h=>{return!(e?.[u=144,d=o,a(d,0,u- -1284)]>0);var u,d},isValid:()=>!0,isEval:()=>!1,features:()=>Object[l(1177,0,0,0,"vpKc")](s[c(765,"M*9R")]??{}),keyFrom:()=>t,getBuildVersion:_n[l(1075,0,0,0,"ar[D")],getBuildDate:_n[c(801,r)]}},Qc=s=>{const n="GJ*O",o="4eQy",a="Pt6b";function c(f,_,p,S,C){return me(C- -736,f)}let h=N[u("kCX(",979,990,1028,1061)];function u(f,_,p,S,C){return me(C-499,f)}function d(f,_,p,S,C){return me(_- -419,S)}if(xl()||N[u("s%[j",0,0,0,1036)]()){const f=_n[c("y$xV",0,0,0,-292)](),_=new Date(f),p=new Date;Math[u("NLaM",0,0,0,1055)]((p[c("[CQe",0,0,0,-378)]()-_[c("M1p^",0,0,0,-340)]())/864e5)>=120&&(h=[u(n,0,0,0,900)])}else h=[c(o,0,0,0,-221)];return{licensee:()=>c("hJI1",0,0,0,-184),expiration:()=>null,domains:()=>[yi()],developerCount:()=>1,cpuCount:()=>0,type:()=>u("GJ*O",0,0,0,912),isEval:()=>!0,exceptions:()=>h,isValidFor:()=>h[c("GJ*O",0,0,0,-287)]===0,isValid:()=>!1,features:()=>Object[d(0,-49,0,"@!qU")]({}),keyFrom:()=>s,getBuildVersion:_n[d(0,16,0,"gaPJ")],getBuildDate:_n[g=a,m=-49,me(m- -538,g)]};var g,m};function Ut(s,e,t,n,r){return me(s-534,t)}function Wt(s,e,t,n,r){return me(n- -223,r)}function vn(s,e,t,n,r){return me(n-106,r)}const Fe={promise:null,details:null,bannerPrinted:!1,detailsPrinted:!1,licenseKey:null,keyFrom:null};let ca=!1,Zc=!1;const eh=Rt(717,"oKla")[Wt(0,0,0,248,"vpKc")]("")[Rt(628,"0b[n")]((s,e)=>e+s,"");class np{constructor(){const e="oKla";var t,n,r,o;this[r=-56,o="@!qU",Rt(r- -698,o)][t=581,n=e,Rt(t- -143,n)]=null}async[vn(0,0,0,631,"(#NZ")](e,t=!1){const n="x&b3",o="Yi0q",g="oKla",_="oKla",S="Wm8X",y="(1Pq",E="NkeP",I="hJI1",R="NLaM",L="vpKc",P="7ej)",z="oKla";if(!e||e[G(696,632,720,"sorI")](J(1410,n,1331,1378))||e[J(1288,o,1217,1273)](j(1259,"NLaM",1341))||e[j(1154,"sorI",1095)](J(1323,"lR8P",1264,1241))||e[J(1311,"*9cG",1338,1414)](te(45,101,106,16,"oKla")))return ca=!0,await this[G(947,915,844,g)](!0);function j(ne,Z,q,oe,ce){return vn(0,0,0,ne-624,Z)}function H(ne,Z,q,oe,ce){return Rt(ce-429,oe)}if(ca=!1,!t&&Fe[J(1432,n,1352,1426)]){const ne=await this[j(1278,_)]();if(ne[G(835,861,774,"oKla")]()&&!ne[J(1271,S,1412,1323)]())return ne}function G(ne,Z,q,oe,ce){return Zr(0,q-1287,0,0,oe)}Fe[H(0,0,0,y,996)]=e,Fe[J(1546,"kvla",1364,1460)]=j(1095,E),Fe[H(0,0,0,I,1038)]=null,Fe[G(0,0,802,R)]=null;const $=await this[te(107,190,72,80,"gaPJ")]();function te(ne,Z,q,oe,ce){return vn(0,0,0,ne- -482,ce)}function J(ne,Z,q,oe,ce){return Rt(oe-670,Z)}if(!$[J(0,"M1p^",0,1344)]())throw await this[J(0,"Wm8X",0,1327)](!0),new Error(H(0,0,0,L,1091));if(N[H(0,0,0,P,1163)]()&&(await dr[te(-13,0,0,0,"4eQy")](e,t),!(await this[J(0,"Fs0q",0,1342)]())[J(0,"Yi0q",0,1416)]()))throw await this[H(0,0,0,z,1078)](!0),new Error(J(0,"hJI1",0,1361));return $}async[Zr(0,-472,0,0,"Pt6b")](e=!1){const n="*yhr",o="0b[n",c="4Alj",h="kvla",u="oKla",d="y$xV",m="x&b3",_="*9cG",y="4eQy",b="DymX",T="M*9R",D="sorI",B="w9&S",z="kvla",O="gaPJ",j="[CQe",G="J)g]",$="#089",te="4Alj";if(Fe[ge(655,736,"Yi0q",741,642)])return Fe[ee(86,"Pt6b",84)];function oe(de,he,we,fe,ve){return Ut(fe- -546,0,de)}if(!this[ee(-93,"(#NZ",-15)][le(-546,-635,"J)g]")]&&(this[oe(n,0,0,478)][le(-515,-453,"0b[n")]=new Error("FV")),Fe[le(-488,-595,o)])return Fe[Y(234,"y$xV")];let ce=null;function Y(de,he,we,fe,ve){return Ut(de- -741,0,he)}Fe[ge(455,576,"DymX",478,522)]=new Promise(de=>{ce=de});let se,Q=null;const re=async(de,he)=>{function we(fe,ve,Te,ye,ue){return le(ye-206,ve-444,Te)}try{const fe=Zf(he),ve=await(async ye=>{const Ce="Yi0q",ut="*9cG",Vt="4eQy",mt="sF1^",Rc="s%[j",bf="wDxJ",Ef="m2uP",vf="Fs0q",xf="7ej)",as=ye[Xr(902,866,"J)g]")];function Kr(bt,En,Lt,cr,hr){return me(hr- -546,En)}const ls=ye[cs(1143,1192,"M1p^",1103,1124)]?new Date(ye[lr(386,378,402,"4eQy")]):null,ta=ye[cs(1038,1038,Ce,1116,1008)];function cs(bt,En,Lt,cr,hr){return me(hr-580,Lt)}const $t=[];function Xr(bt,En,Lt,cr,hr){return me(bt-336,Lt)}function Yr(bt,En,Lt,cr,hr){return me(cr- -179,Lt)}function lr(bt,En,Lt,cr,hr){return me(En-14,cr)}if(ls?isNaN(ls)?$t[lr(0,428,0,"M*9R")](lr(0,514,0,ut)):ls<new Date&&$t[Kr(0,"3rr#",0,0,-4)](Yr(0,0,Vt,293)+ls[Yr(0,0,mt,402)]()):$t[Kr(0,"0gcN",0,0,-113)](Yr(0,0,"GJ*O",207)),N[Xr(801,0,"z@HR")]()){if(!ta)return $t[Xr(900,0,"J)g]")](Xr(756,0,"DymX")),$t;const bt=await dr[lr(0,581,0,Rc)]();bt!==ta&&$t[lr(0,398,0,bf)](Yr(0,0,Ef,344)+ta+Xr(809,0,"m8Gp")+bt)}else{if(xl())return $t;if(as&&as[Kr(0,vf,0,0,-28)]!==0){let bt=!1;const En=yi();for(let Lt=0;!bt&&Lt<as[Kr(0,"OF(6",0,0,-184)];Lt++)bt=En[lr(0,498,0,xf)](as[Lt]);!bt&&$t[Kr(0,"Wm8X",0,0,-157)](Yr(0,0,"oKla",181))}else $t[cs(0,0,Rc,0,986)](cs(0,0,"semb",0,1110))}return $t})(fe),Te=tp(fe,ve,de);return Te[we(0,-281,te,-310)]()[we(0,-367,"s%[j",-311)]>0&&(se=Te),Te}catch{se=ep(de)}};Fe[ge(537,369,c,380,470)]&&(Q=await re(Fe[Y(373,h)],Fe[oe(u,0,0,370)]));let K=!1;if(ca&&(K=!0,Q=Qc(le(-576,-669,d))),!Q)if(N[ee(81,"Wm8X",-32)]()){if(!Q){const de=process[ee(59,"oKla",136)],he=de[le(-497,-576,m)]||de[ge(575,532,"NLaM",501,577)]||de[oe("*9cG",0,0,446)]||de[le(-538,-597,_)];he&&(Q=await re(ee(71,"NLaM",-10),he))}if(!Q){const de=await dr[ee(17,"hz&m",51)]();de&&(Q=await re(ee(6,y,-65),de))}!Q&&(K=!0)}else{if(!Q)try{const de=await fetch("./"+eh);let he=null;if(de[ee(19,b,14,8,48)]===200){const we=(await de[le(-514,-522,"4Alj",-533,-563)]())[le(-422,-366,"WzO@",-316,-422)](`
|
|
30
|
+
`);for(let fe=0;!he&&fe<we[Y(169,m)];fe++){const ve=we[fe][ee(85,T,82,88,14)]();ve[ge(578,454,"s%[j",466,483)]("#")||ve[le(-574,-461,D,-636,-667)]===0||(he=ve)}}if(he){const we=oe("zhv1",0,0,510)+eh+"')";Q=await re(we,he)}}catch{}!Q&&xl()&&(K=!0)}function ee(de,he,we,fe,ve){return Wt(0,0,0,de- -251,he)}function le(de,he,we,fe,ve){return Wt(0,0,0,de- -768,we)}function ge(de,he,we,fe,ve){return Rt(ve- -119,we)}if(!Q&&K&&(Q=Qc(le(-416,0,B))),!Q&&se&&(Q=se),!Q&&(Q={licensee:()=>null,expiration:()=>null,domains:()=>[],developerCount:()=>0,cpuCount:()=>0,type:()=>null,isEval:()=>!1,exceptions:()=>[le(-442,0,"7ej)")],isValidFor:de=>!1,isValid:()=>!1,features:()=>Object[ge(0,0,"oKla",0,570)]({}),keyFrom:()=>Y(212,"hz&m"),getBuildVersion:_n[ge(0,0,"sF1^",0,638)],getBuildDate:_n[ee(-15,c)]}),Fe[Y(280,z)]=Q,ce(Q),e&&!(Fe[ge(0,0,"[CQe",0,557)]&&Fe[ee(-94,O)])&&(K||Q[Y(346,"semb")]()[oe(b,0,0,354)]>0||Q[oe("ar[D",0,0,526)]()?.pb)){if(Zc)return void setTimeout(()=>{var de,he;this[de=-413,he=$,le(de-17,0,he)](!1,!1)},8e3);await this[ge(0,0,j,0,541)](!1,!1)}return Fe[Y(292,G)]}async[Wt(0,0,0,225,"GJ*O")](e){const n="[CQe",r="7ej)",o="Pt6b",a="m8Gp";function l(f,_,p,S,C){return Wt(0,0,0,S-123,f)}function c(f,_,p,S,C){return Ut(p- -625,0,f)}function h(f,_,p,S,C){return vn(0,0,0,p- -521,_)}Fe[m(440,"#089",349)]=!0;const u=await this[d="0b[n",g=-334,Ut(g- -1370,0,d)]();var d,g;function m(f,_,p,S,C){return Rt(p- -236,_)}return await dr[h(0,n,95)](e),!Fe[h(0,r,15)]&&(u[c("4eQy",0,491)]()||u[c("hJI1",0,444)]()[l(o,0,0,382)]>0)&&await this[m(0,a,412)](e),Promise[l("7ej)",0,0,368)]()}async[Rt(644,"hJI1")](e=!1,t=!1,n=!1){const r="(1Pq",o="gaPJ",l="s%[j",h="sF1^";function g(b,w,E,I,x){return Ut(E- -1230,0,w)}Fe[C(1102,1052,"0gcN",1074,1025)]=!0;const m=await this[f=r,_=40,Wt(0,0,0,_- -111,f)]();var f,_,p,S;Fe[C(1010,1073,o,940,994)]||!(m[p=l,S=970,Ut(S- -134,0,p)]()||m[g(0,h,-288)]()[g(0,"*yhr",-241)]>0)?await dr[y(0,"vpKc",0,1112)](m,e,t,n):await this[y(967,"kvla",1014,939)](e);function C(b,w,E,I,x){return Rt(x-323,E)}function y(b,w,E,I,x){return Ut(I-46,0,w)}}async[Wt(0,0,0,288,"NkeP")](e,t){const n="gaPJ",o="kCX(",l="#089",c="w9&S",h="lR8P";if(!e&&(Fe[m(478,"sorI",443)]||Fe[g(-333,"m8Gp",-419)]))return;Fe[g(-450,n,-377)]=!0,Fe[m(293,o,377)]=!0,await this[g(-463,"GJ*O",-463)](e);const u=N[g(-533,"WzO@",-465)](),d=e||u?console[m(474,l,434)]:N[g(-465,c,-501)];function g(p,S,C,y,b){return Wt(0,0,0,p- -688,S)}function m(p,S,C,y,b){return vn(0,0,0,C- -180,S)}var f,_;u&&d(""),await this[f=h,_=373,Rt(_- -364,f)](e,t),d("")}[Rt(695,"wDxJ")](){return this[e="M1p^",t=1233,Zr(0,t-1715,0,0,e)]();var e,t}[vn(0,0,0,497,"hJI1")](e){return this[t=812,n="sorI",Wt(0,0,0,t-638,n)](!0,e);var t,n}[Wt(0,0,0,160,"0b[n")](){function t(n,r,o,i,a){return Ut(n- -235,0,i)}return Fe[t(872,0,0,"0gcN")]||Fe[t(694,0,0,"oKla")]}[Zr(0,-463,0,0,"ar[D")](e){Zc=!0}async[Ut(890,0,"kCX(")](){return this[e="*yhr",t=-204,vn(0,0,0,t- -853,e)](!0);var e,t}async[Ut(939,0,"*yhr")](e,t){const n="]M9H",o="3rr#";function i(l,c,h,u,d){return vn(0,0,0,c- -398,d)}const a=await this[i(0,93,0,0,n)]();return await this[i(0,265,0,0,o)](!0,e,t),a}async[Zr(0,-415,0,0,"#089")](){const e="0gcN";var n,r;return await dr[n=760,r=e,Wt(0,0,0,n-557,r)]()}}const oc=new np,Il=(s,e)=>{const t=[];for(let n=0;n<s.length;n++){const r=s[n];t.push({x:r.x+e.x,y:r.y+e.y})}return t},Rl=(s,e)=>{if(!s)return{...e};if(!e)return{...s};let t=Math.min(s.x,e.x),n=Math.min(s.y,e.y);return{x:t,y:n,width:Math.max(s.width+s.x,e.width+e.x)-t,height:Math.max(s.height+s.y,e.height+e.y)-n}},ha=s=>[{x:s.x,y:s.y},{x:s.x+s.width,y:s.y},{x:s.x+s.width,y:s.y+s.height},{x:s.x,y:s.y+s.height}],Al=s=>{let e=Number.MAX_SAFE_INTEGER,t=Number.MAX_SAFE_INTEGER,n=Number.MIN_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;for(let o=0;o<s.length;o++){let i=s[o];e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x),r=Math.max(r,i.y)}return{x:e,y:t,width:n-e,height:r-t}},ua=(s,e,t)=>{if(!t){const a=Al(s);t={x:a.x+a.width/2,y:a.y+a.height/2}}s=Il(s,{x:-t.x,y:-t.y});const n=e*Math.PI/180,r=Math.sin(n),o=Math.cos(n),i=[];for(let a=0;a<s.length;a++){const l=s[a],c=o*l.x-r*l.y,h=r*l.x+o*l.y;i.push({x:c,y:h})}return s=Il(i,{x:t.x,y:t.y})},Ag=(s,e,t,n,r,o,i,a,l=!0)=>{if(s===t&&e===n||r===i&&o===a)return!1;let c=(a-o)*(t-s)-(i-r)*(n-e);if(c===0)return!1;let h=((i-r)*(e-o)-(a-o)*(s-r))/c,u=((t-s)*(e-o)-(n-e)*(s-r))/c;return(!l||!(h<0||h>1||u<0||u>1))&&{x:s+h*(t-s),y:e+h*(n-e)}},it=(s,e,t=!0)=>Ag(s.p1.x,s.p1.y,s.p2.x,s.p2.y,e.p1.x,e.p1.y,e.p2.x,e.p2.y,t),ds=s=>({top:{p1:s[0],p2:s[1]},left:{p1:s[3],p2:s[0]},right:{p1:s[1],p2:s[2]},bottom:{p1:s[2],p2:s[3]}}),th=(s,e,t)=>{let n=t*Math.PI/180,r=Math.sin(n),o=Math.cos(n);return{x:s*o-e*r,y:s*r+e*o}},xn=(s,e)=>{let t=s.p2.x-e.x,n=s.p2.y-e.y;const r=th(t,n,90);t=r.x+e.x,n=r.y+e.y;let o=s.p1.x-e.x,i=s.p1.y-e.y;const a=th(o,i,90);return o=a.x+e.x,i=a.y+e.y,{p1:{x:o,y:i},p2:{x:t,y:n}}},rp=Object.freeze(Object.defineProperty({__proto__:null,angleToPoints:(s,e)=>{const t=(180-s)/180*Math.PI,n=Math.abs(e.width*Math.sin(t))+Math.abs(e.height*Math.cos(t)),r=Math.sin(t)*n/2,o=Math.cos(t)*n/2,i=e.width/2,a=e.height/2;return{x1:i-r,y1:a-o,x2:i+r,y2:a+o}},boundsToPoints:ha,centerPoint:s=>({x:s.width/2+s.x,y:s.height/2+s.y}),clipToOuterRect:(s,e,t=0)=>{if(t<0&&(t+=360),t>90&&t<=180?t+=180:t>180&&t<=270&&(t-=180),t===0||t===180)return{height:e.height,width:e.width};if(t===90||t===270)return{height:e.width,width:e.height};let n=ha({...e,x:0,y:0}),r=ha({...s,x:0,y:0});r=Il(r,{x:e.width/2-s.width/2,y:e.height/2-s.height/2}),r=ua(r,t);let o=ds(r),i=ds(n);if(t>90){const l=it(o.top,i.top);if(l){const h=l,u=it(o.bottom,i.bottom,!1)||r[3];r[0]=it(o.top,xn(o.bottom,u),!1)||r[0],r[1]=h,r[3]=u,r[2]=it(o.bottom,xn(o.top,h),!1)||r[2],o=ds(r)}const c=it(o.top,i.left);if(c){const h=c,u=it(o.bottom,i.right,!1)||r[2];r[0]=h,r[1]=it(o.top,xn(o.bottom,u),!1)||r[1],r[3]=it(o.bottom,xn(o.top,h),!1)||r[3],r[2]=u}}else if(t<90){const l=it(o.top,i.top);if(l){const h=l,u=it(o.bottom,i.bottom,!1)||r[2];r[0]=h,r[1]=it(o.top,xn(o.bottom,u),!1)||r[1],r[3]=it(o.bottom,xn(o.top,h),!1)||r[3],r[2]=u,o=ds(r)}const c=it(o.top,i.right);if(c){const h=c,u=it(o.bottom,i.left,!1)||r[3];r[0]=it(o.top,xn(o.bottom,u),!1)||r[0],r[1]=h,r[3]=u,r[2]=it(o.bottom,xn(o.top,h),!1)||r[2]}}r=ua(r,-t);const a=Al(r);return{width:a.width,height:a.height}},findIntersectMath:(s,e,t,n)=>{let r=Ag(s.x,s.y,e.x,e.y,5e4,0,-5e4,0);return r&&(t=Math.min(t,r.x),n=Math.max(n,r.x)),{min:t,max:n}},leastSquaresSlopeAndIntercept:s=>{let e=0,t=0,n=0,r=0,o=0,i=0,a=0,l=s.length;if(l===0)return{m:0,b:0};if(l===1)return{m:1,b:s[0]};for(let h=0;h<l;h++)i=h+1,a=s[h],a==null||isNaN(a)||(e+=i,t+=a,r+=i*i,n+=i*a,o++);const c=(o*n-e*t)/(o*r-e*e);return{m:c,b:t/o-c*e/o}},minBoundingRect:Al,rotatePoints:ua,unionBounds:Rl},Symbol.toStringTag,{value:"Module"}));class Se{constructor(e,t,n){this._root=da,this._size=0,this._maxNodeSize=n>=4?Math.min(n,256):32,this._compare=t||Se.defaultComparator,e&&this.setPairs(e)}get size(){return this._size}get length(){return this._size}get isEmpty(){return this._size===0}clear(){this._root=da,this._size=0}forEach(e,t){return t!==void 0&&(e=e.bind(t)),this.forEachPair((n,r)=>e(r,n,this))}forEachPair(e,t){const n=this.minKey(),r=this.maxKey();return this.forRange(n,r,!0,e,t)}get(e,t){return this._root.get(e,t,this)}set(e,t,n){this._root.isShared&&(this._root=this._root.clone());const r=this._root.set(e,t,n,this);return r===!0||r===!1?r:(this._root=new Do([this._root,r]),!0)}has(e){return this.forRange(e,e,!0,void 0)!==0}delete(e){return this.editRange(e,e,!0,Se.DeleteRange)!==0}with(e,t,n){const r=this.clone();return r.set(e,t,n)||n?r:this}withPairs(e,t){const n=this.clone();return n.setPairs(e,t)!==0||t?n:this}withKeys(e,t){const n=this.clone();let r=!1;for(let o=0;o<e.length;o++)r=n.set(e[o],void 0,!1)||r;return t&&!r?this:n}without(e,t){return this.withoutRange(e,e,!0,t)}withoutKeys(e,t){const n=this.clone();return n.deleteKeys(e)||!t?n:this}withoutRange(e,t,n,r){const o=this.clone();return o.deleteRange(e,t,n)===0&&r?this:o}filter(e,t){const n=this.greedyClone();let r;return n.editAll((o,i,a)=>{if(!e(o,i,a))return r=Se.DeleteValue}),!r&&t?this:n}mapValues(e){const t=this.greedyClone();return t.editAll((n,r,o)=>e(r,n,o)),t}reduce(e,t){let n,r=0,o=t;const i=this.entries(this.minKey());for(;!(n=i.next()).done;)o=e(o,n.value,r++,this);return o}entries(e,t){const n=this.findPath(e);if(n===void 0)return gr();let{nodeQueue:r,nodeIndex:o,leaf:i}=n,a=t!==void 0?1:0,l=e===void 0?-1:i.indexOf(e,0,this._compare)-1;return gr(()=>{e:for(;;)switch(a){case 0:if(++l<i.keys.length)return{done:!1,value:[i.keys[l],i.values[l]]};a=2;continue;case 1:if(++l<i.keys.length){const h=i.keys[l],u=i.values[l];return t?(t.done=!1,t.value[0]=h,t.value[1]=u,t):{done:!1,value:[h,u]}}a=2;case 2:for(var c=-1;;){if(++c>=r.length){a=3;continue e}if(++o[c]<r[c].length)break}for(;c>0;c--)r[c-1]=r[c][o[c]].children,o[c-1]=0;i=r[0][o[0]],l=-1,a=t!==void 0?1:0;continue;case 3:return Ml}})}entriesReversed(e,t,n){if(e===void 0&&(n=void 0,(e=this.maxKey())===void 0))return gr();let{nodeQueue:r,nodeIndex:o,leaf:i}=this.findPath(e)||this.findPath(this.maxKey());wt(!r[0]||i===r[0][o[0]],"wat!");let a=i.indexOf(e,0,this._compare);!n&&a<i.keys.length&&this._compare(i.keys[a],e)<=0&&a++;let l=t!==void 0?1:0;return gr(()=>{e:for(;;)switch(l){case 0:if(--a>=0)return{done:!1,value:[i.keys[a],i.values[a]]};l=2;continue;case 1:if(--a>=0){const h=i.keys[a],u=i.values[a];return t?(t.done=!1,t.value[0]=h,t.value[1]=u,t):{done:!1,value:[h,u]}}l=2;case 2:for(var c=-1;;){if(++c>=r.length){l=3;continue e}if(--o[c]>=0)break}for(;c>0;c--)r[c-1]=r[c][o[c]].children,o[c-1]=r[c-1].length-1;i=r[0][o[0]],a=i.keys.length,l=t!==void 0?1:0;continue;case 3:return Ml}})}findPath(e){let t,n,r=this._root;if(r.isLeaf)t=nh,n=nh;else{t=[],n=[];for(let o=0;!r.isLeaf;o++){if(t[o]=r.children,n[o]=e===void 0?0:r.indexOf(e,0,this._compare),n[o]>=t[o].length)return;r=t[o][n[o]]}t.reverse(),n.reverse()}return{nodeQueue:t,nodeIndex:n,leaf:r}}diffAgainst(e,t,n,r){if(e._compare!==this._compare)throw new Error("SortedMap: Comparators are not the same.");if(this.isEmpty||e.isEmpty)return this.isEmpty&&e.isEmpty?void 0:this.isEmpty?n===void 0?void 0:Se.stepToEnd(Se.makeDiffCursor(e),n):t===void 0?void 0:Se.stepToEnd(Se.makeDiffCursor(this),t);const{_compare:o}=this,i=Se.makeDiffCursor(this),a=Se.makeDiffCursor(e);let l=!0,c=!0,h=Se.compare(i,a,o);for(;l&&c;){const u=Se.compare(i,a,o),{leaf:d,internalSpine:g,levelIndices:m}=i,{leaf:f,internalSpine:_,levelIndices:p}=a;if(d||f){if(h!==0){if(u===0){if(d&&f&&r){const S=d.values[m[m.length-1]],C=f.values[p[p.length-1]];if(!Object.is(S,C)){const y=r(i.currentKey,S,C);if(y&&y.break)return y.break}}}else if(u>0){if(f&&n){const S=f.values[p[p.length-1]],C=n(a.currentKey,S);if(C&&C.break)return C.break}}else if(t&&d&&h!==0){const S=d.values[m[m.length-1]],C=t(i.currentKey,S);if(C&&C.break)return C.break}}}else if(!d&&!f&&u===0){const S=g.length-1,C=_.length-1,y=g[S][m[S]];if(_[C][p[C]]===y){h=0,l=Se.step(i,!0),c=Se.step(a,!0);continue}}h=u,u<0?l=Se.step(i):c=Se.step(a)}return l&&t?Se.finishCursorWalk(i,a,o,t):c&&n?Se.finishCursorWalk(a,i,o,n):void 0}static finishCursorWalk(e,t,n,r){const o=Se.compare(e,t,n);if(o===0){if(!Se.step(e))return}else o<0&&wt(!1,"cursor walk terminated early");return Se.stepToEnd(e,r)}static stepToEnd(e,t){let n=!0;for(;n;){const{leaf:r,levelIndices:o,currentKey:i}=e;if(r){const a=t(i,r.values[o[o.length-1]]);if(a&&a.break)return a.break}n=Se.step(e)}}static makeDiffCursor(e){const{_root:t,height:n}=e;return{height:n,internalSpine:[[t]],levelIndices:[0],leaf:void 0,currentKey:t.maxKey()}}static step(e,t){const{internalSpine:n,levelIndices:r,leaf:o}=e;if(t===!0||o){const i=r.length;if(t===!0||r[i-1]===0){const a=n.length;if(a===0)return!1;const l=a-1;let c=l;for(;c>=0;){if(r[c]>0)return c<i-1&&(e.leaf=void 0,r.pop()),c<l&&(e.internalSpine=n.slice(0,c+1)),e.currentKey=n[c][--r[c]].maxKey(),!0;c--}return!1}{const a=--r[i-1];return e.currentKey=o.keys[a],!0}}{const i=n.length,a=i-1,l=n[a][r[a]];if(l.isLeaf){e.leaf=l;const c=r[i]=l.values.length-1;e.currentKey=l.keys[c]}else{const c=l.children;n[i]=c;const h=c.length-1;r[i]=h,e.currentKey=c[h].maxKey()}return!0}}static compare(e,t,n){const{height:r,currentKey:o,levelIndices:i}=e,{height:a,currentKey:l,levelIndices:c}=t,h=n(l,o);if(h!==0)return h;const u=r<a?r:a;return i.length-(r-u)-(c.length-(a-u))}keys(e,t){const n=this.entries(e,t);return gr(()=>{const r=n.next();return r.value&&(r.value=r.value[0]),r})}values(e,t){const n=this.entries(e,t);return gr(()=>{const r=n.next();return r.value&&(r.value=r.value[1]),r})}get maxNodeSize(){return this._maxNodeSize}minKey(){return this._root.minKey()}maxKey(){return this._root.maxKey()}clone(){this._root.isShared=!0;const e=new Se(void 0,this._compare,this._maxNodeSize);return e._root=this._root,e._size=this._size,e}greedyClone(e){const t=new Se(void 0,this._compare,this._maxNodeSize);return t._root=this._root.greedyClone(e),t._size=this._size,t}toArray(e=2147483647){const t=this.minKey(),n=this.maxKey();return t!==void 0?this.getRange(t,n,!0,e):[]}keysArray(){const e=[];return this._root.forRange(this.minKey(),this.maxKey(),!0,!1,this,0,(t,n)=>{e.push(t)}),e}valuesArray(){const e=[];return this._root.forRange(this.minKey(),this.maxKey(),!0,!1,this,0,(t,n)=>{e.push(n)}),e}toString(){return this.toArray().toString()}setIfNotPresent(e,t){return this.set(e,t,!1)}nextHigherPair(e,t){return e===void 0?this._root.minPair(t):this._root.getPairOrNextHigher(e,this._compare,!1,t)}nextHigherKey(e,t){const n=this.nextHigherPair(e,t);return n&&n[0]}nextLowerPair(e,t){return e===void 0?this._root.maxPair(t):this._root.getPairOrNextLower(e,this._compare,!1,t)}nextLowerKey(e,t){const n=this.nextLowerPair(e,t);return n&&n[0]}getPairOrNextLower(e,t){return this._root.getPairOrNextLower(e,this._compare,!0,t)}getPairOrNextHigher(e,t){return this._root.getPairOrNextHigher(e,this._compare,!0,t)}changeIfPresent(e,t){return this.editRange(e,e,!0,(n,r)=>({value:t}))!==0}getRange(e,t,n,r=67108863){const o=[];return this._root.forRange(e,t,n,!1,this,0,(i,a)=>(o.push([i,a]),o.length>r?Se.Break:void 0)),o}setPairs(e,t){let n=0;for(let r=0;r<e.length;r++)this.set(e[r][0],e[r][1],t)&&n++;return n}forRange(e,t,n,r,o){const i=this._root.forRange(e,t,n,!1,this,o||0,r);return typeof i=="number"?i:i.break}forEditRange(e,t,n,r,o,i){return this._root.forRange(e,t,n,r,this,i||0,o)}editRange(e,t,n,r,o){let i=this._root;i.isShared&&(this._root=i=i.clone());try{const a=i.forRange(e,t,n,!0,this,o||0,r);return typeof a=="number"?a:a.break}finally{let a;for(;i.keys.length<=1&&!i.isLeaf;)a||=i.isShared,this._root=i=i.keys.length===0?da:i.children[0];a&&(i.isShared=!0)}}editAll(e,t){return this.editRange(this.minKey(),this.maxKey(),!0,e,t)}deleteRange(e,t,n){return this.editRange(e,t,n,Se.DeleteRange)}deleteKeys(e){let t=0;for(let n=0;n<e.length;n++)this.delete(e[n])&&t++;return t}get height(){let e=this._root,t=-1;for(;e;)t++,e=e.isLeaf?void 0:e.children[0];return t}freeze(){const e=this;e.clear=e.set=e.editRange=function(){throw new Error("SortedMap: Attempted to modify when frozen.")}}unfreeze(){delete this.clear,delete this.set,delete this.editRange}get isFrozen(){return this.hasOwnProperty("editRange")}checkValid(){const e=this._root.checkValid(0,this,0);wt(e===this.size,"size mismatch: counted ",e,"but stored",this.size)}}function gr(s=()=>Ml){const e={next:s};return Symbol&&Symbol.iterator&&(e[Symbol.iterator]=function(){return this}),e}Symbol&&Symbol.iterator&&(Se.prototype[Symbol.iterator]=Se.prototype.entries),Se.prototype.where=Se.prototype.filter,Se.prototype.setRange=Se.prototype.setPairs,Se.prototype.add=Se.prototype.set;class Ho{get isLeaf(){return this.children===void 0}constructor(e=[],t){this.keys=e,this.values=t||et,this.isShared=void 0}maxKey(){return this.keys[this.keys.length-1]}indexOf(e,t,n){const r=this.keys;let o=0,i=r.length,a=i>>1;for(;o<i;){const l=n(r[a],e);if(l<0)o=a+1;else{if(!(l>0)){if(l===0)return a;if(e==e)return r.length;throw new Error("SortedMap: NaN was used as a key.")}i=a}a=o+i>>1}return a^t}minKey(){return this.keys[0]}minPair(e){if(this.keys.length!==0)return(e=e??[null,null])[0]=this.keys[0],e[1]=this.values[0],e}maxPair(e){if(this.keys.length===0)return;const t=this.keys.length-1;return(e=e??[null,null])[0]=this.keys[t],e[1]=this.values[t],e}clone(){const e=this.values,t=e===et?e:e.slice(0),n=this.keys.slice(0);return new Ho(n,t)}greedyClone(e){return this.isShared&&!e?this:this.clone()}get(e,t,n){const r=this.indexOf(e,-1,n._compare);return r<0?t:this.values[r]}getPairOrNextLower(e,t,n,r){const o=this.indexOf(e,-1,t),i=o<0?~o-1:n?o:o-1;if(i>=0){const a=this.keys[i],l=this.values[i];return r?(r[0]=a,r[1]=l,r):[a,l]}}getPairOrNextHigher(e,t,n,r){const o=this.indexOf(e,-1,t),i=o<0?~o:n?o:o+1;if(i<this.keys.length){const a=this.keys[i],l=this.values[i];return r?(r[0]=a,r[1]=l,r):[a,l]}}checkValid(e,t,n){const r=this.keys.length,o=this.values.length;return wt(this.values===et?r<=o:r===o,"keys/values length mismatch: depth",e,"with lengths",r,o,"and baseIndex",n),wt(e===0||r>0,"empty leaf at depth",e,"and baseIndex",n),r}set(e,t,n,r){let o=this.indexOf(e,-1,r._compare);if(o<0){if(o=~o,r._size++,this.keys.length<r._maxNodeSize)return this.insertInLeaf(o,e,t,n,r);{const i=this.splitOffRightSide();let a=this;return o>this.keys.length&&(o-=this.keys.length,a=i),a.insertInLeaf(o,e,t,n,r),i}}if(n!==!1){t!==void 0&&this.reifyValues(),this.keys[o]=e;let i=t;if(typeof n=="function"){const a=n(this.values[o],e,t);a!==void 0&&(i=a)}this.values[o]=i}return!1}reifyValues(){return this.values===et?this.values=this.values.slice(0,this.keys.length):this.values}insertInLeaf(e,t,n,r,o){if(this.keys.splice(e,0,t),this.values===et){for(;et.length<o._maxNodeSize;)et.push(void 0);if(n===void 0)return!0;this.values=et.slice(0,this.keys.length-1)}let i=n;if(typeof r=="function"){const a=r(void 0,t,n);a!==void 0&&(i=a)}return this.values.splice(e,0,i),!0}takeFromRight(e){let t=this.values;e.values===et?t!==et&&t.push(void 0):(t=this.reifyValues(),t.push(e.values.shift())),this.keys.push(e.keys.shift())}takeFromLeft(e){let t=this.values;e.values===et?t!==et&&t.unshift(void 0):(t=this.reifyValues(),t.unshift(e.values.pop())),this.keys.unshift(e.keys.pop())}splitOffRightSide(){const e=this.keys.length>>1,t=this.keys.splice(e),n=this.values===et?et:this.values.splice(e);return new Ho(t,n)}forRange(e,t,n,r,o,i,a){const l=o._compare;let c,h;if(t===e){if(!n||(h=(c=this.indexOf(e,-1,l))+1,c<0))return i}else c=this.indexOf(e,0,l),h=this.indexOf(t,-1,l),h<0?h=~h:n===!0&&h++;const u=this.keys,d=this.values;if(a!==void 0)for(let g=c;g<h;g++){const m=u[g],f=a(m,d[g],i++);if(f!==void 0){if(f.break!==void 0)return f;if(r===!0){if(m!==u[g]&&o._compare(m,u[g])!==0||this.isShared===!0)throw new Error("SortedMap: illegally changed or cloned in editRange.");f.delete?(this.keys.splice(g,1),this.values!==et&&this.values.splice(g,1),o._size--,g--,h--):f.hasOwnProperty("value")&&(d[g]=f.value)}}}else i+=h-c;return i}mergeSibling(e,t){if(this.keys.push.apply(this.keys,e.keys),this.values===et){if(e.values===et)return;this.values=this.values.slice(0,this.keys.length)}this.values.push.apply(this.values,e.reifyValues())}}class Do extends Ho{constructor(e,t){if(!t){t=[];for(let n=0;n<e.length;n++)t[n]=e[n].maxKey()}super(t),this.children=e}clone(){const e=this.children.slice(0);for(let t=0;t<e.length;t++)e[t].isShared=!0;return new Do(e,this.keys.slice(0))}greedyClone(e){if(this.isShared&&!e)return this;const t=new Do(this.children.slice(0),this.keys.slice(0));for(let n=0;n<t.children.length;n++)t.children[n]=t.children[n].greedyClone(e);return t}minKey(){return this.children[0].minKey()}minPair(e){return this.children[0].minPair(e)}maxPair(e){return this.children[this.children.length-1].maxPair(e)}get(e,t,n){const r=this.indexOf(e,0,n._compare),o=this.children;return r<o.length?o[r].get(e,t,n):void 0}getPairOrNextLower(e,t,n,r){const o=this.indexOf(e,0,t),i=this.children;if(o>=i.length)return this.maxPair(r);const a=i[o].getPairOrNextLower(e,t,n,r);return a===void 0&&o>0?i[o-1].maxPair(r):a}getPairOrNextHigher(e,t,n,r){const o=this.indexOf(e,0,t),i=this.children,a=i.length;if(o>=a)return;const l=i[o].getPairOrNextHigher(e,t,n,r);return l===void 0&&o<a-1?i[o+1].minPair(r):l}checkValid(e,t,n){const r=this.keys.length,o=this.children.length;wt(r===o,"keys/children length mismatch: depth",e,"lengths",r,o,"baseIndex",n),wt(r>1||e>0,"internal node has length",r,"at depth",e,"baseIndex",n);let i=0,a=this.children,l=this.keys,c=0;for(let u=0;u<o;u++)i+=a[u].checkValid(e+1,t,n+i),c+=a[u].keys.length,wt(i>=c,"wtf",n),wt(u===0||a[u-1].constructor===a[u].constructor,"type mismatch, baseIndex:",n),a[u].maxKey()!==l[u]&&wt(!1,"keys[",u,"] =",l[u],"is wrong, should be ",a[u].maxKey(),"at depth",e,"baseIndex",n),u===0||t._compare(l[u-1],l[u])<0||wt(!1,"sort violation at depth",e,"index",u,"keys",l[u-1],l[u]);const h=c===0;return(h||c>t.maxNodeSize*o)&&wt(!1,h?"too few":"too many","children (",c,i,") at depth",e,"maxNodeSize:",t.maxNodeSize,"children.length:",o,"baseIndex:",n),i}set(e,t,n,r){const o=this.children,i=r._maxNodeSize,a=r._compare;let l=Math.min(this.indexOf(e,0,a),o.length-1),c=o[l];if(c.isShared&&(o[l]=c=c.clone()),c.keys.length>=i){let u;l>0&&(u=o[l-1]).keys.length<i&&a(c.keys[0],e)<0?(u.isShared&&(o[l-1]=u=u.clone()),u.takeFromRight(c),this.keys[l-1]=u.maxKey()):(u=o[l+1])!==void 0&&u.keys.length<i&&a(c.maxKey(),e)<0&&(u.isShared&&(o[l+1]=u=u.clone()),u.takeFromLeft(c),this.keys[l]=o[l].maxKey())}const h=c.set(e,t,n,r);if(h===!1)return!1;if(this.keys[l]=c.maxKey(),h===!0)return!0;if(this.keys.length<i)return this.insert(l+1,h),!0;{const u=this.splitOffRightSide();let d=this;return a(h.maxKey(),this.maxKey())>0&&(d=u,l-=this.keys.length),d.insert(l+1,h),u}}insert(e,t){this.children.splice(e,0,t),this.keys.splice(e,0,t.maxKey())}splitOffRightSide(){const e=this.children.length>>1;return new Do(this.children.splice(e),this.keys.splice(e))}takeFromRight(e){this.keys.push(e.keys.shift()),this.children.push(e.children.shift())}takeFromLeft(e){this.keys.unshift(e.keys.pop()),this.children.unshift(e.children.pop())}forRange(e,t,n,r,o,i,a){const l=o._compare,c=this.keys,h=this.children;let u=this.indexOf(e,0,l),d=u,g=Math.min(t===e?u:this.indexOf(t,0,l),c.length-1);if(r){if(d<=g)try{for(;d<=g;d++){h[d].isShared&&(h[d]=h[d].clone());const m=h[d].forRange(e,t,n,r,o,i,a);if(c[d]=h[d].maxKey(),typeof m!="number")return m;i=m}}finally{const m=o._maxNodeSize>>1;for(u>0&&u--,d=g;d>=u;d--)h[d].keys.length<=m&&(h[d].keys.length!==0?this.tryMerge(d,o._maxNodeSize):(c.splice(d,1),h.splice(d,1)));h.length!==0&&h[0].keys.length===0&&wt(!1,"emptiness bug")}}else for(;d<=g;d++){const m=h[d].forRange(e,t,n,r,o,i,a);if(typeof m!="number")return m;i=m}return i}tryMerge(e,t){const n=this.children;return e>=0&&e+1<n.length&&n[e].keys.length+n[e+1].keys.length<=t&&(n[e].isShared&&(n[e]=n[e].clone()),n[e].mergeSibling(n[e+1],t),n.splice(e+1,1),this.keys.splice(e+1,1),this.keys[e]=n[e].maxKey(),!0)}mergeSibling(e,t){const n=this.keys.length;this.keys.push.apply(this.keys,e.keys);const r=e.children;if(this.children.push.apply(this.children,r),e.isShared&&!this.isShared)for(let o=0;o<r.length;o++)r[o].isShared=!0;this.tryMerge(n-1,t)}}const et=[],Ml=Object.freeze({done:!0,value:void 0}),da=function(){const s=new Ho;return s.isShared=!0,s}(),nh=[],wt=(s,...e)=>{if(!s)throw e.unshift("SortedMap:"),new Error(e.join(" "))};var In;(In=Se||(Se={})).DeleteValue=Object.freeze({delete:!0}),In.Break=Object.freeze({break:!0}),In.DeleteRange=()=>In.DeleteValue,In.EmptySortedMap=(()=>{const s=new In;return s.freeze(),s})(),In.defaultComparator=function(s,e){if(Number.isFinite(s)&&Number.isFinite(e))return s-e;let t=typeof s,n=typeof e;if(t!==n)return t<n?-1:1;if(t==="object"){if(s===null)return e===null?0:-1;if(e===null)return 1;if(t=typeof(s=s.valueOf()),n=typeof(e=e.valueOf()),t!==n)return t<n?-1:1}return s<e?-1:s>e?1:s===e?0:Number.isNaN(s)?Number.isNaN(e)?0:-1:Number.isNaN(e)?1:Array.isArray(s)?0:Number.NaN},In.simpleComparator=function(s,e){return s>e?1:s<e?-1:0};const rh=[-1,null],op={done:!1,value:[-1,null]};exports.Tuple=void 0,(s=>{s.Builder=class{constructor(t,n=0,r=0){this._tuples=[],this._minors=null,this._values=null,this._minorMin=Number.MAX_SAFE_INTEGER,this._minorMax=0,this._majorIndex=Number.MIN_SAFE_INTEGER,this._minorIndex=Number.MIN_SAFE_INTEGER,this._offsetMajor=0,this._offsetMinor=0,this._createList=t,this._offsetMajor=n,this._offsetMinor=r}addValues(t,n,r){if(r&&r.isIList)return this.addValue(t,n,r);Array.isArray(r)||(r=[r]),this.addValue(t,n,r[0]);const o=r.length,i=this._values;for(let a=1;a<o;a++)i.push(r[a]);return this._minorIndex=this._minorIndex+i.length-1,this}addValue(t,n,r){const o=this._majorIndex,i=this._minorIndex;if(t+=this._offsetMajor,n+=this._offsetMinor,t<o||t===o&&n<=i)throw new e(`major: ${t}, minor: ${n}, prevMajor: ${this._majorIndex}, prevMinor: ${this._minorIndex}`);let a=this._minors;if(t!==o){if(a){this._minorMin=Math.min(this._minorMin,a[0][0]);const l=a[a.length-1];this._minorMax=Math.max(this._minorMax,l[0]+l[1].length-1)}this._minors=a=[],this._tuples.push([t,a]),this._majorIndex=t}if(r&&r.isIList){n===i+1&&o!==t&&this._values;const l=r;a.push([n,l]),n=n+l.length-1}else{let l=null;n!==i+1||o!==t?(this._values=l=[],a.push([n,l])):l=this._values,l.push(r)}return this._minorIndex=n,this}build(){const t=this._tuples;if(t.length===0)return null;const n=this._minors;this._minorMin=Math.min(this._minorMin,n[0][0]);const r=n[n.length-1];this._minorMax=Math.max(this._minorMax,r[0]+r[1].length-1);const o=this._createList;if(o){const i=n.length;for(let a=0;a<i;a++)n[a][1]=o(n[a][1])}return{tuples:t,bounds:{majorStart:t[0][0],minorStart:this._minorMin,majorEnd:t[t.length-1][0],minorEnd:this._minorMax}}}},s.TransposedBuilder=class{constructor(t,n=0,r=0){this._majorMin=Number.MAX_SAFE_INTEGER,this._majorMax=0,this._majorIndex=Number.MIN_SAFE_INTEGER,this._minorIndex=Number.MIN_SAFE_INTEGER,this._offsetMajor=0,this._offsetMinor=0,this._createList=t,this._offsetMajor=n,this._offsetMinor=r,this._minors=new Se}addValues(t,n,r){Array.isArray(r)||(r=[r]);const o=r.length;for(let i=0;i<o;i++){const a=n+i;this.addValue(t,a,r[i])}return this}addValue(t,n,r){let o,i;const a=this._majorIndex;let l=this._minorIndex;if(t+=this._offsetMajor,n+=this._offsetMinor,i=this._current,t!==a){if(this._majorIndex=t,t<a)throw new e(`major: ${t}, minor: ${n}, prevMajor: ${this._majorIndex}, prevMinor: ${this._minorIndex}`);l=Number.MIN_SAFE_INTEGER}else if(i=this._current,n<=l)throw new e(`major: ${t}, minor: ${n}, prevMajor: ${this._majorIndex}, prevMinor: ${this._minorIndex}`);if(i&&i.minor===n&&(o=i.span),o)i.minor>=n&&i.next&&(this._current=i.next);else{const g=this._minors,m=i?i.next??i.prev:null;if(m){let f;const _=m.minor;m&&m.minor===n?(i=m,o=i.span):f=_>n?g.getPairOrNextHigher(n,rh):g.getPairOrNextLower(n,rh),f&&(i=f[1],f[0]===n&&(o=i.span))}if(!o){this._majorMin=Math.min(this._majorMin,t),o=[n,[[t,[]]]];const f={minor:n,span:o,prev:null,next:null};i&&(i.minor<n?(f.prev=i,f.next=i.next,i.next&&(i.next.prev=f),i.next=f):(f.prev=i.prev,f.next=i,i.prev&&(i.prev.next=f),i.prev=f)),g.set(n,f),this._current=f;const _=this._first;(!_||n<_.minor)&&(this._first=f),f.next&&(this._current=f.next)}}let c=o[1];const h=c[c.length-1];let u=h[0],d=h[1];return u+d.length!==t&&(d=[],u=t,c.push([u,d])),d.push(r),this._majorMax=Math.max(this._majorMax,t),this._minorIndex=n,this}build(){const t=[],n=this._createList,r=this._minors.entries(void 0,op);let o=r.next();for(;!o.done;){const i=o.value[1].span;if(n)for(let a=0;a<i.length;a++)i[a][1]=this._createList(i[a][1]);t.push(i),o=r.next()}return t.length===0?null:{tuples:t,bounds:{majorStart:t[0][0],minorStart:this._majorMin,majorEnd:t[t.length-1][0],minorEnd:this._majorMax}}}};class e extends $r{constructor(n="Out of order",r=null){super(n,r),this.name="OutOfOrderError"}}s.OutOfOrderError=e})(exports.Tuple||(exports.Tuple={}));const sp={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function ga(s){return(e={})=>{const t=e.width?String(e.width):s.defaultWidth;return s.formats[t]||s.formats[s.defaultWidth]}}const ip={date:ga({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:ga({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:ga({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},ap={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function eo(s){return(e,t)=>{let n;if((t?.context?String(t.context):"standalone")==="formatting"&&s.formattingValues){const r=s.defaultFormattingWidth||s.defaultWidth,o=t?.width?String(t.width):r;n=s.formattingValues[o]||s.formattingValues[r]}else{const r=s.defaultWidth,o=t?.width?String(t.width):s.defaultWidth;n=s.values[o]||s.values[r]}return n[s.argumentCallback?s.argumentCallback(e):e]}}function to(s){return(e,t={})=>{const n=t.width,r=n&&s.matchPatterns[n]||s.matchPatterns[s.defaultMatchWidth],o=e.match(r);if(!o)return null;const i=o[0],a=n&&s.parsePatterns[n]||s.parsePatterns[s.defaultParseWidth],l=Array.isArray(a)?function(h,u){for(let d=0;d<h.length;d++)if(u(h[d]))return d}(a,h=>h.test(i)):function(h,u){for(const d in h)if(Object.prototype.hasOwnProperty.call(h,d)&&u(h[d]))return d}(a,h=>h.test(i));let c;return c=s.valueCallback?s.valueCallback(l):l,c=t.valueCallback?t.valueCallback(c):c,{value:c,rest:e.slice(i.length)}}}var no;const lp={code:"en-US",formatDistance:(s,e,t)=>{let n;const r=sp[s];return n=typeof r=="string"?r:e===1?r.one:r.other.replace("{{count}}",e.toString()),t?.addSuffix?t.comparison&&t.comparison>0?"in "+n:n+" ago":n},formatLong:ip,formatRelative:(s,e,t,n)=>ap[s],localize:{ordinalNumber:(s,e)=>{const t=Number(s),n=t%100;if(n>20||n<10)switch(n%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},era:eo({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:eo({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:s=>s-1}),month:eo({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:eo({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:eo({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(no={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:s=>parseInt(s,10)},(s,e={})=>{const t=s.match(no.matchPattern);if(!t)return null;const n=t[0],r=s.match(no.parsePattern);if(!r)return null;let o=no.valueCallback?no.valueCallback(r[0]):r[0];return o=e.valueCallback?e.valueCallback(o):o,{value:o,rest:s.slice(n.length)}}),era:to({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:to({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:s=>s+1}),month:to({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:to({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:to({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}},oh=(s,e)=>{switch(s){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},sh=(s,e)=>{switch(s){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},ih={p:sh,P:(s,e)=>{const t=s.match(/(P+)(p+)?/)||[],n=t[1],r=t[2];if(!r)return oh(s,e);let o;switch(n){case"P":o=e.dateTime({width:"short"});break;case"PP":o=e.dateTime({width:"medium"});break;case"PPP":o=e.dateTime({width:"long"});break;default:o=e.dateTime({width:"full"})}return o.replace("{{date}}",oh(n,e)).replace("{{time}}",sh(r,e))}},cp=/^D+$/,hp=/^Y+$/,up=["D","DD","YY","YYYY"];function dp(s){return cp.test(s)}function gp(s){return hp.test(s)}function ah(s,e,t){const n=function(r,o,i){const a=r[0]==="Y"?"years":"days of the month";return`Use \`${r.toLowerCase()}\` instead of \`${r}\` (in \`${o}\`) for formatting ${a} to the input \`${i}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}(s,e,t);if(console.warn(n),up.includes(s))throw new RangeError(n)}const lh=Symbol.for("constructDateFrom");function Nr(s,e){return typeof s=="function"?s(e):s&&typeof s=="object"&&lh in s?s[lh](e):s instanceof Date?new s.constructor(e):new Date(e)}let mp={};function Mg(){return mp}function Ci(s,e){return Nr(e||s,s)}class Tg{constructor(){this.subPriority=0}validate(e,t){return!0}}class fp extends Tg{constructor(e,t,n,r,o){super(),this.value=e,this.validateValue=t,this.setValue=n,this.priority=r,o&&(this.subPriority=o)}validate(e,t){return this.validateValue(e,this.value,t)}set(e,t,n){return this.setValue(e,t,this.value,n)}}class pp extends Tg{constructor(e,t){super(),this.priority=10,this.subPriority=-1,this.context=e||(n=>Nr(t,n))}set(e,t){return t.timestampIsSet?e:Nr(e,function(n,r){const o=function(i){return typeof i=="function"&&i.prototype?.constructor===i}(r)?new r(0):Nr(r,0);return o.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),o.setHours(n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()),o}(e,this.context))}}let Vs=class{run(s,e,t,n){const r=this.parse(s,e,t,n);return r?{setter:new fp(r.value,this.validate,this.set,this.priority,this.subPriority),rest:r.rest}:null}validate(s,e,t){return!0}};const Fg=/^(1[0-2]|0?\d)/,_p=/^(3[0-1]|[0-2]?\d)/,Sp=/^\d/,wp=/^\d{1,2}/,yp=/^\d{1,3}/,Cp=/^\d{1,4}/;function Sn(s,e){return s&&{value:e(s.value),rest:s.rest}}function Bn(s,e){const t=e.match(s);return t?{value:parseInt(t[0],10),rest:e.slice(t[0].length)}:null}function Lo(s,e){switch(s){case 1:return Bn(Sp,e);case 2:return Bn(wp,e);case 3:return Bn(yp,e);case 4:return Bn(Cp,e);default:return Bn(new RegExp("^\\d{1,"+s+"}"),e)}}class Ng extends Vs{constructor(){super(...arguments),this.incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"],this.priority=110}parse(e,t,n){const r=o=>o-1;switch(t){case"M":return Sn(Bn(Fg,e),r);case"MM":return Sn(Lo(2,e),r);case"Mo":return Sn(n.ordinalNumber(e,{unit:"month"}),r);case"MMM":return n.month(e,{width:"abbreviated",context:"formatting"})||n.month(e,{width:"narrow",context:"formatting"});case"MMMMM":return n.month(e,{width:"narrow",context:"formatting"});default:return n.month(e,{width:"wide",context:"formatting"})||n.month(e,{width:"abbreviated",context:"formatting"})||n.month(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=11}set(e,t,n){return e.setMonth(n,1),e.setHours(0,0,0,0),e}}const bp=[31,28,31,30,31,30,31,31,30,31,30,31],Ep=[31,29,31,30,31,30,31,31,30,31,30,31];function vp(s,e,t){const n=Mg(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,o=Ci(s,t?.in),i=o.getDay(),a=7-r;return function(l,c,h){const u=Ci(l,h?.in);return isNaN(c)?Nr(h?.in||l,NaN):(c&&u.setDate(u.getDate()+c),u)}(o,e<0||e>6?e-(i+a)%7:((e%7+7)%7+a)%7-(i+a)%7,t)}const Eo={y:new class extends Vs{constructor(){super(...arguments),this.priority=130,this.incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"]}parse(s,e,t){const n=r=>({year:r,isTwoDigitYear:e==="yy"});switch(e){case"y":return Sn(Lo(4,s),n);case"yo":return Sn(t.ordinalNumber(s,{unit:"year"}),n);default:return Sn(Lo(e.length,s),n)}}validate(s,e){return e.isTwoDigitYear||e.year>0}set(s,e,t){const n=s.getFullYear();if(t.isTwoDigitYear){const o=function(i,a){const l=a>0,c=l?a:1-a;let h;if(c<=50)h=i||100;else{const u=c+50;h=i+100*Math.trunc(u/100)-(i>=u%100?100:0)}return l?h:1-h}(t.year,n);return s.setFullYear(o,0,1),s.setHours(0,0,0,0),s}const r="era"in e&&e.era!==1?1-t.year:t.year;return s.setFullYear(r,0,1),s.setHours(0,0,0,0),s}},M:new Ng,d:new class extends Vs{constructor(){super(...arguments),this.priority=90,this.subPriority=1,this.incompatibleTokens=["Y","R","q","Q","w","I","D","i","e","c","t","T"]}parse(s,e,t){switch(e){case"d":return Bn(_p,s);case"do":return t.ordinalNumber(s,{unit:"date"});default:return Lo(e.length,s)}}validate(s,e){const t=function(r){return r%400==0||r%4==0&&r%100!=0}(s.getFullYear()),n=s.getMonth();return t?e>=1&&e<=Ep[n]:e>=1&&e<=bp[n]}set(s,e,t){return s.setDate(t),s.setHours(0,0,0,0),s}},E:new class extends Vs{constructor(){super(...arguments),this.priority=90,this.incompatibleTokens=["D","i","e","c","t","T"]}parse(s,e,t){switch(e){case"E":case"EE":case"EEE":return t.day(s,{width:"abbreviated",context:"formatting"})||t.day(s,{width:"short",context:"formatting"})||t.day(s,{width:"narrow",context:"formatting"});case"EEEEE":return t.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(s,{width:"short",context:"formatting"})||t.day(s,{width:"narrow",context:"formatting"});default:return t.day(s,{width:"wide",context:"formatting"})||t.day(s,{width:"abbreviated",context:"formatting"})||t.day(s,{width:"short",context:"formatting"})||t.day(s,{width:"narrow",context:"formatting"})}}validate(s,e){return e>=0&&e<=6}set(s,e,t,n){return(s=vp(s,t,n)).setHours(0,0,0,0),s}}},xp=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Ip=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Rp=/^'([^]*?)'?$/,Ap=/''/g,Mp=/\S/,Tp=/[a-zA-Z]/;function Fp(s,e,t,n){const r=()=>Nr(n?.in||t,NaN),o=Object.assign({},Mg()),i=n?.locale??o.locale??lp,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,l=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??o.weekStartsOn??o.locale?.options?.weekStartsOn??0;if(!e)return s?r():Ci(t,n?.in);const c={firstWeekContainsDate:a,weekStartsOn:l,locale:i},h=[new pp(n?.in,t)],u=e.match(Ip).map(_=>{const p=_[0];return p in ih?(0,ih[p])(_,i.formatLong):_}).join("").match(xp),d=[];for(let _ of u){!n?.useAdditionalWeekYearTokens&&gp(_)&&ah(_,e,s),!n?.useAdditionalDayOfYearTokens&&dp(_)&&ah(_,e,s);const p=_[0],S=Eo[p];if(S){const{incompatibleTokens:C}=S;if(Array.isArray(C)){const b=d.find(w=>C.includes(w.token)||w.token===p);if(b)throw new RangeError(`The format string mustn't contain \`${b.fullToken}\` and \`${_}\` at the same time`)}else if(S.incompatibleTokens==="*"&&d.length>0)throw new RangeError(`The format string mustn't contain \`${_}\` and any other token at the same time`);d.push({token:p,fullToken:_});const y=S.run(s,_,i.match,c);if(!y)return r();h.push(y.setter),s=y.rest}else{if(p.match(Tp))throw new RangeError("Format string contains an unescaped latin alphabet character `"+p+"`");if(_==="''"?_="'":p==="'"&&(_=Np(_)),s.indexOf(_)!==0)return r();s=s.slice(_.length)}}if(s.length>0&&Mp.test(s))return r();const g=h.map(_=>_.priority).sort((_,p)=>p-_).filter((_,p,S)=>S.indexOf(_)===p).map(_=>h.filter(p=>p.priority===_).sort((p,S)=>S.subPriority-p.subPriority)).map(_=>_[0]);let m=Ci(t,n?.in);if(isNaN(+m))return r();const f={};for(const _ of g){if(!_.validate(m,c))return r();const p=_.set(m,f,c);Array.isArray(p)?(m=p[0],Object.assign(f,p[1])):m=p}return m}function Np(s){return s.match(Rp)[1].replace(Ap,"'")}const kg=s=>!isNaN(s)&&(Object.prototype.toString.call(s)==="[object Date]"||s instanceof Date);function ch(s,e,t){let n=s,r=s.length,o=e.length;for(var i=r;i<o;++i){const a=e[i];if(a==="#")return n;n=t?n+a:a+n}return n}function Ct(s,e){for(var t="";t.length<e;)t+=s;return t}function kr(s){for(var e="",t=s.length-1;t>=0;)e+=s.charAt(t--);return e}function Ft(s,e){var t=""+s;return t.length>=e?t:Ct("0",e-t.length)+t}function Tl(s,e){var t=""+s;return t.length>=e?t:Ct(" ",e-t.length)+t}function bi(s,e){var t=""+s;return t.length>=e?t:t+Ct(" ",e-t.length)}var hh=Math.pow(2,32);function mr(s,e){return s>hh||s<-hh?function(t,n){var r=""+Math.round(t);return r.length>=n?r:Ct("0",n-r.length)+r}(s,e):function(t,n){var r=""+t;return r.length>=n?r:Ct("0",n-r.length)+r}(Math.round(s),e)}function Gs(s,e){return e=e||0,s.length>=7+e&&(32|s.charCodeAt(e))==103&&(32|s.charCodeAt(e+1))==101&&(32|s.charCodeAt(e+2))==110&&(32|s.charCodeAt(e+3))==101&&(32|s.charCodeAt(e+4))==114&&(32|s.charCodeAt(e+5))==97&&(32|s.charCodeAt(e+6))==108}var uh=[["Sun","Sunday"],["Mon","Monday"],["Tue","Tuesday"],["Wed","Wednesday"],["Thu","Thursday"],["Fri","Friday"],["Sat","Saturday"]],ma=[["J","Jan","January"],["F","Feb","February"],["M","Mar","March"],["A","Apr","April"],["M","May","May"],["J","Jun","June"],["J","Jul","July"],["A","Aug","August"],["S","Sep","September"],["O","Oct","October"],["N","Nov","November"],["D","Dec","December"]],Zn={0:"General",1:"0",2:"0.00",3:"#,##0",4:"#,##0.00",5:"$#,##0_);($#,##0)",6:"$#,##0_);[Red]($#,##0)",7:"$#,##0.00_);($#,##0.00)",8:"$#,##0.00_);[Red]($#,##0.00)",9:"0%",10:"0.00%",11:"0.00E+00",12:"# ?/?",13:"# ??/??",14:"m/d/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",23:"General",24:"General",25:"General",26:"General",27:"m/d/yyyy",28:"m/d/yyyy",29:"m/d/yyyy",30:"m/d/yyyy",32:"h:mm:ss",31:"m/d/yyyy",33:"h:mm:ss",34:"h:mm:ss",35:"h:mm:ss",36:"m/d/yyyy",37:"#,##0_);(#,##0)",38:"#,##0_);[Red](#,##0)",39:"#,##0.00_);(#,##0.00)",40:"#,##0.00_);[Red](#,##0.00)",41:'_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)',42:'_($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)',43:'_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)',44:'_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)',45:"mm:ss",46:"[h]:mm:ss",47:"mmss.0",48:"##0.0E+0",49:"@",50:"m/d/yyyy",51:"m/d/yyyy",52:"m/d/yyyy",53:"m/d/yyyy",54:"m/d/yyyy",55:"m/d/yyyy",56:'"上午/下午 "hh"時"mm"分"ss"秒 "'},dh={5:37,6:38,7:39,8:40,23:0,24:0,25:0,26:0,27:14,28:14,29:14,30:14,31:14,50:14,51:14,52:14,53:14,54:14,55:14,56:14,57:14,58:14,59:1,60:2,61:3,62:4,67:9,68:10,69:12,70:13,71:14,72:14,73:15,74:16,75:17,76:20,77:21,78:22,79:45,80:46,81:47,82:0},kp={5:'"$"#,##0_);\\("$"#,##0\\)',63:'"$"#,##0_);\\("$"#,##0\\)',6:'"$"#,##0_);[Red]\\("$"#,##0\\)',64:'"$"#,##0_);[Red]\\("$"#,##0\\)',7:'"$"#,##0.00_);\\("$"#,##0.00\\)',65:'"$"#,##0.00_);\\("$"#,##0.00\\)',8:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',66:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',41:'_(* #,##0_);_(* \\(#,##0\\);_(* "-"_);_(@_)',42:'_("$"* #,##0_);_("$"* \\(#,##0\\);_("$"* "-"_);_(@_)',43:'_(* #,##0.00_);_(* \\(#,##0.00\\);_(* "-"??_);_(@_)',44:'_("$"* #,##0.00_);_("$"* \\(#,##0.00\\);_("$"* "-"??_);_(@_)'};function Ei(s,e,t){for(var n=s<0?-1:1,r=s*n,o=0,i=1,a=0,l=1,c=0,h=0,u=Math.floor(r);c<e&&(a=(u=Math.floor(r))*i+o,h=u*c+l,!(r-u<5e-8));)r=1/(r-u),o=i,i=a,l=c,c=h;if(h>e&&(c>e?(h=l,a=o):(h=c,a=i)),!t)return[0,n*a,h];var d=Math.floor(n*a/h);return[d,n*a-d*h,h]}function vo(s,e,t){if(s>2958465||s<0)return null;var n=0|s,r=Math.floor(86400*(s-n)),o=0,i=[],a={D:n,T:r,u:86400*(s-n)-r,y:0,m:0,d:0,H:0,M:0,S:0,q:0};if(Math.abs(a.u)<1e-6&&(a.u=0),e&&e.date1904&&(n+=1462),a.u>.9999&&(a.u=0,++r===86400&&(a.T=r=0,++n,++a.D)),n===60)i=t?[1317,10,29]:[1900,2,29],o=3;else if(n===0)i=t?[1317,8,29]:[1900,1,0],o=6;else{n>60&&--n;var l=new Date(1900,0,1);l.setDate(l.getDate()+n-1),i=[l.getFullYear(),l.getMonth()+1,l.getDate()],o=l.getDay(),n<60&&(o=(o+6)%7),t&&(o=function(c,h){h[0]-=581;var u=c.getDay();return c<60&&(u=(u+6)%7),u}(l,i))}return a.y=i[0],a.m=i[1],a.d=i[2],a.S=r%60,r=Math.floor(r/60),a.M=r%60,r=Math.floor(r/60),a.H=r,a.q=o,a}var Og=new Date(1899,11,31,0,0,0),Op=Og.getTime(),Bp=new Date(1900,2,1,0,0,0);function sc(s,e=!1){var t=s.getTime();return e?t-=1262304e5:s>=Bp&&(t+=864e5),(t-(Op+6e4*(s.getTimezoneOffset()-Og.getTimezoneOffset())))/864e5}function fa(s){return s.indexOf(".")===-1?s:s.replace(/(?:\.0*|(\.\d*[1-9])0+)$/,"$1")}function Dp(s){var e,t=Math.floor(Math.log(Math.abs(s))*Math.LOG10E);return e=t>=-4&&t<=-1?s.toPrecision(10+t):Math.abs(t)<=9?function(n){var r=n<0?12:11,o=fa(n.toFixed(12));return o.length<=r||(o=n.toPrecision(10)).length<=r?o:n.toExponential(5)}(s):t===10?s.toFixed(10).substr(0,12):function(n){var r=fa(n.toFixed(11));return r.length>(n<0?12:11)||r==="0"||r==="-0"?n.toPrecision(6):r}(s),fa(function(n){return n.indexOf("E")===-1?n:n.replace(/(?:\.0*|(\.\d*[1-9])0+)[Ee]/,"$1E").replace(/(E[+-])(\d)$/,"$10$2")}(e.toUpperCase()))}function pa(s,e){switch(typeof s){case"string":return s;case"boolean":return s?"TRUE":"FALSE";case"number":return(0|s)===s?s.toString(10):Dp(s);case"undefined":return"";case"object":if(s==null)return"";if(kg(s))return $g(14,sc(s,e&&e.date1904),e)}throw new Error("unsupported value in General format: "+s)}function Lp(s,e,t,n){var r,o="",i=0,a=0,l=t.y,c=0;switch(s){case 98:l=t.y+543;case 121:switch(e.length){case 1:case 2:r=l%100,c=2;break;default:r=l%1e4,c=4}break;case 109:switch(e.length){case 1:case 2:r=t.m,c=e.length;break;case 3:return ma[t.m-1][1];case 5:return ma[t.m-1][0];default:return ma[t.m-1][2]}break;case 100:switch(e.length){case 1:case 2:r=t.d,c=e.length;break;case 3:return uh[t.q][0];default:return uh[t.q][1]}break;case 104:switch(e.length){case 1:case 2:r=1+(t.H+11)%12,c=e.length;break;default:throw new Error("bad hour format: "+e)}break;case 72:switch(e.length){case 1:case 2:r=t.H,c=e.length;break;default:throw new Error("bad hour format: "+e)}break;case 77:switch(e.length){case 1:case 2:r=t.M,c=e.length;break;default:throw new Error("bad minute format: "+e)}break;case 115:if(e!=="s"&&e!=="ss"&&e!==".0"&&e!==".00"&&e!==".000")throw new Error("bad second format: "+e);return t.u!==0||e!=="s"&&e!=="ss"?(a=n>=2?n===3?1e3:100:n===1?10:1,(i=Math.round(a*(t.S+t.u)))>=60*a&&(i=0),e==="s"?i===0?"0":""+i/a:(o=Ft(i,2+n),e==="ss"?o.substr(0,2):"."+o.substr(2,e.length-1))):Ft(t.S,e.length);case 90:switch(e){case"[h]":case"[hh]":r=24*t.D+t.H;break;case"[m]":case"[mm]":r=60*(24*t.D+t.H)+t.M;break;case"[s]":case"[ss]":r=60*(60*(24*t.D+t.H)+t.M)+Math.round(t.S+t.u);break;default:throw new Error("bad absolute time format: "+e)}c=e.length===3?1:2;break;case 101:r=l,c=1}return c>0?Ft(r,c):""}function Dn(s){if(s.length<=3)return s;for(var e=s.length%3,t=s.substr(0,e);e!==s.length;e+=3)t+=(t.length>0?",":"")+s.substr(e,3);return t}var Bg=/%/g;function Dg(s,e){var t,n=s.indexOf("E")-s.indexOf(".")-1;if(s.match(/^#+0.0E\+0$/)){if(e===0)return"0.0E+0";if(e<0)return"-"+Dg(s,-e);var r=s.indexOf(".");r===-1&&(r=s.indexOf("E"));var o=Math.floor(Math.log(e)*Math.LOG10E)%r;if(o<0&&(o+=r),(t=(e/Math.pow(10,o)).toPrecision(n+1+(r+o)%r)).indexOf("e")===-1){var i=Math.floor(Math.log(e)*Math.LOG10E);for(t.indexOf(".")===-1?t=t.charAt(0)+"."+t.substr(1)+"E+"+(i-t.length+o):t+="E+"+(i-o);t.substr(0,2)==="0.";)t=(t=t.charAt(0)+t.substr(2,r)+"."+t.substr(2+r)).replace(/^0+([1-9])/,"$1").replace(/^0+\./,"0.");t=t.replace(/\+-/,"-")}t=t.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(a,l,c,h){return l+c+h.substr(0,(r+o)%r)+"."+h.substr(o)+"E"})}else t=e.toExponential(n);return s.match(/E\+00$/)&&t.match(/e[+-]\d$/)&&(t=t.substr(0,t.length-1)+"0"+t.charAt(t.length-1)),s.match(/E-/)&&t.match(/e\+/)&&(t=t.replace(/e\+/,"e")),t.replace("e","E")}var Lg=/[0#?] (\?+)( ?)\/( ?)(\d+)/,Pg=/^([0#?]+)\.([0#?]+)/,zg=/\).*[0#]/,Wg=/\(###\) ###\\?-####/;function At(s){var e="";let t,n=s.length;for(var r=0;r!==n;++r)switch(t=s.charAt(r),t){case"#":break;case" ":e+=" ";break;case"0":e+="0";break;case"?":e+="?";break;default:e+=String.fromCharCode(cc)}return e}function gh(s,e){var t=Math.pow(10,e);return""+Math.round(s*t)/t}function mh(s,e){var t=Math.pow(10,e);return Math.round(s*t)/t}function fh(s,e){var t=s-Math.floor(s),n=Math.pow(10,e);return e<(""+Math.round(t*n)).length?0:Math.round(t*n)}function _t(s,e,t){if(s.charCodeAt(0)===40&&!e.match(zg)){var n=e.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return t>=0?_t("n",n,t):"("+_t("n",n,-t)+")"}if(e.charCodeAt(e.length-1)===44)return function(f,_,p){let S=_.length-1;for(;_.charCodeAt(S-1)===44;)--S;return wn(f,_.substr(0,S),p/Math.pow(10,3*(_.length-S)))}(s,e,t);if(e.indexOf("%")!==-1)return function(f,_,p){let S=_.replace(Bg,""),C=_.length-S.length;return wn(f,S,p*Math.pow(10,2*C))+Ct("%",C)}(s,e,t);if(e.indexOf("E")!==-1)return Dg(e,t);if(e.charCodeAt(0)===36)return"$"+_t(s,e.substr(e.charAt(1)===" "?2:1),t);var r,o,i,a,l=Math.abs(t),c=t<0?"-":"";if(e.match(/^00+$/))return c+mr(l,e.length);if(e.match(/^[#?]+$/))return(r=mr(t,0))==="0"&&(r=""),r.length>e.length?r:At(e.substr(0,e.length-r.length))+r;if(o=e.match(Lg))return function(f,_,p){var S=parseInt(f[4],10),C=Math.round(_*S),y=Math.floor(C/S),b=C-y*S,w=S;return p+(y===0?"":""+y)+" "+(b===0?Ct(" ",f[1].length+1+f[4].length):Tl(b,f[1].length)+f[2]+"/"+f[3]+Ft(w,f[4].length))}(o,l,c);if(e.match(/^#+0+$/))return c+mr(l,e.length-e.indexOf("0"));if(o=e.match(Pg)){i=Math.trunc(gh(t,o[2].length));var h=function(f){if(!isFinite(f))return 0;for(var _=1,p=0;Math.round(f*_)/_!==f;)_*=10,p++;return p}(a=mh(Math.abs(i-t),o[2].length));return a=(a=""+mh(a,h)).replace(/^0\./,""),r=ch(""+Math.abs(i),o[1])+"."+ch(""+a,o[2],!0),r=e.indexOf("0.")!==-1?r:r.replace(/^0\./,"."),t<0?"-"+r:r}if(o=(e=e.replace(/^#+([0.])/,"$1")).match(/^(0*)\.(#*)$/))return c+gh(l,o[2].length).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,o[1].length?"0.":".");if(o=e.match(/^#{1,3},##0(\.?)$/))return c+Dn(mr(l,0));if(o=e.match(/^#,##0\.([#0]*0)$/))return t<0?"-"+_t(s,e,-t):Dn(""+(Math.floor(t)+function(f,_){return _<(""+Math.round((f-Math.floor(f))*Math.pow(10,_))).length?1:0}(t,o[1].length)))+"."+Ft(fh(t,o[1].length),o[1].length);if(o=e.match(/^#,#*,#0/))return _t(s,e.replace(/^#,#*,/,""),t);if(o=e.match(/^([0#]+)(\\?-([0#]+))+$/))return r=kr(_t(s,e.replace(/[\\-]/g,""),t)),i=0,kr(kr(e.replace(/\\/g,"")).replace(/[0#]/g,function(f){return i<r.length?r.charAt(i++):f==="0"?"0":""}));if(e.match(Wg))return"("+(r=_t(s,"##########",t)).substr(0,3)+") "+r.substr(3,3)+"-"+r.substr(6);var u="";if(o=e.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return i=Math.min(o[4].length,7),a=Ei(l,Math.pow(10,i)-1,!1),r=""+c,(u=wn("n",o[1],a[1])).charAt(u.length-1)===" "&&(u=u.substr(0,u.length-1)+"0"),r+=u+o[2]+"/"+o[3],(u=bi(a[2],i)).length<o[4].length&&(u=At(o[4].substr(o[4].length-u.length))+u),r+=u;if(o=e.match(/[#0?] ([#0?]+)( ?)\/( ?)([#0?]+)/))return i=Math.min(Math.max(o[1].length,o[4].length),7),a=Ei(l,Math.pow(10,i)-1,!0),c+_t(s,e.substring(0,o.index+1),a[0])+" "+(a[1]?Tl(a[1],i)+o[2]+"/"+o[3]+bi(a[2],i):Ct(" ",2*i+1+o[2].length+o[3].length));if(o=e.match(/^[#0?]+$/))return r=mr(t,0),e.length<=r.length?r:At(e.substr(0,e.length-r.length))+r;if(o=e.match(/^([#0?]+)\.([#0]+)$/)){r=""+t.toFixed(Math.min(o[2].length,10)).replace(/([^0])0+$/,"$1"),i=r.indexOf(".");var d=e.indexOf(".")-i,g=e.length-r.length-d;return At(e.substr(0,d)+r+e.substr(e.length-g))}if(o=e.match(/^00,000\.([#0]*0)$/))return i=fh(t,o[1].length),t<0?"-"+_t(s,e,-t):Dn(function(f){return f<2147483647&&f>-2147483648?""+(f>=0?0|f:f-1|0):""+Math.floor(f)}(t)).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(f){return"00,"+(f.length<3?Ft(0,3-f.length):"")+f})+"."+Ft(i,o[1].length);switch(e){case"###,##0.00":return _t(s,"#,##0.00",t);case"###,###":case"##,###":case"#,###":var m=Dn(mr(l,0));return m!=="0"?c+m:"";case"###,###.00":return _t(s,"###,##0.00",t).replace(/^0\./,".");case"#,###.00":return _t(s,"#,##0.00",t).replace(/^0\./,".")}throw new Error("unsupported format |"+e+"|")}function jg(s,e){var t,n=s.indexOf("E")-s.indexOf(".")-1;if(s.match(/^#+0.0E\+0$/)){if(e===0)return"0.0E+0";if(e<0)return"-"+jg(s,-e);var r=s.indexOf(".");r===-1&&(r=s.indexOf("E"));var o=Math.floor(Math.log(e)*Math.LOG10E)%r;if(o<0&&(o+=r),!(t=(e/Math.pow(10,o)).toPrecision(n+1+(r+o)%r)).match(/[Ee]/)){var i=Math.floor(Math.log(e)*Math.LOG10E);t.indexOf(".")===-1?t=t.charAt(0)+"."+t.substr(1)+"E+"+(i-t.length+o):t+="E+"+(i-o),t=t.replace(/\+-/,"-")}t=t.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(a,l,c,h){return l+c+h.substr(0,(r+o)%r)+"."+h.substr(o)+"E"})}else t=e.toExponential(n);return s.match(/E\+00$/)&&t.match(/e[+-]\d$/)&&(t=t.substr(0,t.length-1)+"0"+t.charAt(t.length-1)),s.match(/E-/)&&t.match(/e\+/)&&(t=t.replace(/e\+/,"e")),t.replace("e","E")}function Kt(s,e,t){if(s.charCodeAt(0)===40&&!e.match(zg)){var n=e.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return t>=0?Kt("n",n,t):"("+Kt("n",n,-t)+")"}if(e.charCodeAt(e.length-1)===44)return function(m,f,_){for(var p=f.length-1;f.charCodeAt(p-1)===44;)--p;return wn(m,f.substr(0,p),_/Math.pow(10,3*(f.length-p)))}(s,e,t);if(e.indexOf("%")!==-1)return function(m,f,_){var p=f.replace(Bg,""),S=f.length-p.length;return wn(m,p,_*Math.pow(10,2*S))+Ct("%",S)}(s,e,t);if(e.indexOf("E")!==-1)return jg(e,t);if(e.charCodeAt(0)===36)return"$"+Kt(s,e.substr(e.charAt(1)===" "?2:1),t);var r,o,i,a,l=Math.abs(t),c=t<0?"-":"";if(e.match(/^00+$/))return c+Ft(l,e.length);if(e.match(/^[#?]+$/))return r=""+t,t===0&&(r=""),r.length>e.length?r:At(e.substr(0,e.length-r.length))+r;if(o=e.match(Lg))return function(m,f,_){return _+(f===0?"":""+f)+Ct(" ",m[1].length+2+m[4].length)}(o,l,c);if(e.match(/^#+0+$/))return c+Ft(l,e.length-e.indexOf("0"));if(o=e.match(Pg))return r=(""+t).replace(/^([^.]+)$/,"."+At(o[2])).replace(/\.$/,"."+At(o[2])),r=Ft(Math.abs(t),o[1].length)+r.replace(/\.(\d*)$/,function(m,f){return"."+f+Ct("0",At(o[2]).length-f.length)}),r=e.indexOf("0.")!==-1?r:r.replace(/^0\./,"."),t<0?"-"+r:r;if(e=e.replace(/^#+([0.])/,"$1"),o=e.match(/^(0*)\.(#*)$/))return c+(""+l).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,o[1].length?"0.":".");if(o=e.match(/^#{1,3},##0(\.?)$/))return c+Dn(""+l);if(o=e.match(/^#,##0\.([#0]*0)$/))return t<0?"-"+Kt(s,e,-t):Dn(""+t)+"."+Ct("0",o[1].length);if(o=e.match(/^#,#*,#0/))return Kt(s,e.replace(/^#,#*,/,""),t);if(o=e.match(/^([0#]+)(\\?-([0#]+))+$/))return r=kr(Kt(s,e.replace(/[\\-]/g,""),t)),i=0,kr(kr(e.replace(/\\/g,"")).replace(/[0#]/g,function(m){return i<r.length?r.charAt(i++):m==="0"?"0":""}));if(e.match(Wg))return"("+(r=Kt(s,"##########",t)).substr(0,3)+") "+r.substr(3,3)+"-"+r.substr(6);var h="";if(o=e.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return i=Math.min(o[4].length,7),a=Ei(l,Math.pow(10,i)-1,!1),r=""+c,(h=wn("n",o[1],a[1])).charAt(h.length-1)===" "&&(h=h.substr(0,h.length-1)+"0"),r+=h+o[2]+"/"+o[3],(h=bi(a[2],i)).length<o[4].length&&(h=At(o[4].substr(o[4].length-h.length))+h),r+=h;if(o=e.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))return i=Math.min(Math.max(o[1].length,o[4].length),7),c+((a=Ei(l,Math.pow(10,i)-1,!0))[0]||(a[1]?"":"0"))+" "+(a[1]?Tl(a[1],i)+o[2]+"/"+o[3]+bi(a[2],i):Ct(" ",2*i+1+o[2].length+o[3].length));if(o=e.match(/^[#0?]+$/))return r=""+t,e.length<=r.length?r:At(e.substr(0,e.length-r.length))+r;if(o=e.match(/^([#0]+)\.([#0]+)$/)){r=""+t.toFixed(Math.min(o[2].length,10)).replace(/([^0])0+$/,"$1"),i=r.indexOf(".");var u=e.indexOf(".")-i,d=e.length-r.length-u;return At(e.substr(0,u)+r+e.substr(e.length-d))}if(o=e.match(/^00,000\.([#0]*0)$/))return t<0?"-"+Kt(s,e,-t):Dn(""+t).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(m){return"00,"+(m.length<3?Ft(0,3-m.length):"")+m})+"."+Ft(0,o[1].length);switch(e){case"###,###":case"##,###":case"#,###":var g=Dn(""+l);return g!=="0"?c+g:"";default:if(e.match(/\.[0#?]*$/))return Kt(s,e.slice(0,e.lastIndexOf(".")),t)+At(e.slice(e.lastIndexOf(".")))}throw new Error("unsupported format |"+e+"|")}function wn(s,e,t){return(0|t)===t?Kt(s,e,t):_t(s,e,t)}function Hg(s){var e=[],t=!1;const n=s.length;for(var r=0,o=0;r<n;++r)switch(s.charCodeAt(r)){case 34:t=!t;break;case 95:case 42:case 92:++r;break;case 59:e[e.length]=s.substr(o,r-o),o=r+1}if(e[e.length]=s.substr(o),t===!0)throw new Error("Format |"+s+"| unterminated string ");return e}var Vg=/\[[HhMmSs\u0E0A\u0E19\u0E17]*\]/;function Gg(s){for(var e=0,t="",n="",r=s.length;e<r;)switch(t=s.charAt(e)){case"G":Gs(s,e)&&(e+=6),e++;break;case'"':for(;s.charCodeAt(++e)!==34&&e<s.length;);++e;break;case"\\":case"_":e+=2;break;case"@":++e;break;case"B":case"b":if(s.charAt(e+1)==="1"||s.charAt(e+1)==="2")return!0;case"M":case"D":case"Y":case"H":case"S":case"E":case"m":case"d":case"y":case"h":case"s":case"e":case"g":return!0;case"A":case"a":case"上":if(s.substr(e,3).toUpperCase()==="A/P"||s.substr(e,5).toUpperCase()==="AM/PM"||s.substr(e,5).toUpperCase()==="上午/下午")return!0;++e;break;case"[":for(n=t;s.charAt(e++)!=="]"&&e<s.length;)n+=s.charAt(e);if(n.match(Vg))return!0;break;case".":case"0":case"#":for(;e<s.length&&("0#?.,E+-%".indexOf(t=s.charAt(++e))>-1||t==="\\"&&s.charAt(e+1)==="-"&&"0#".indexOf(s.charAt(e+2))>-1););break;case"?":for(;s.charAt(++e)===t;);break;case"*":++e,s.charAt(e)!==" "&&s.charAt(e)!=="*"||++e;break;case"(":case")":++e;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(;e<s.length&&"0123456789".indexOf(s.charAt(++e))>-1;);break;default:++e}return!1}var ph=/\[(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)\]/;function _h(s,e){if(e==null)return!1;var t=parseFloat(e[2]);switch(e[1]){case"=":if(s===t)return!0;break;case">":if(s>t)return!0;break;case"<":if(s<t)return!0;break;case"<>":if(s!==t)return!0;break;case">=":if(s>=t)return!0;break;case"<=":if(s<=t)return!0}return!1}function $g(s,e,t){t==null&&(t=N.EmptyObject);var n="";switch(typeof s){case"string":n=s==="m/d/yy"&&t.dateNF?t.dateNF:s;break;case"number":(n=s===14&&t.dateNF?t.dateNF:(t.table!=null?t.table:Zn)[s])==null&&(n=t.table&&t.table[dh[s]]||Zn[dh[s]]),n==null&&(n=kp[s]||"General")}if(Gs(n,0))return pa(e,t);kg(e)&&(e=sc(e,t.date1904));var r=function(o,i){var a=Hg(o),l=a.length,c=a[l-1].indexOf("@");if(c!==-1&&a[l-1][c-1]==="\\"&&(c=-1),l<4&&c>-1&&--l,a.length>4)throw new Error("We can't find right format for |"+a.join("|")+"|");if(typeof i!="number")return[4,a.length===4||c>-1?a[a.length-1]:"@"];switch(a.length){case 1:a=c>-1?["General","General","General",a[0]]:[a[0],a[0],a[0],"@"];break;case 2:a=c>-1?[a[0],a[0],a[0],a[1]]:[a[0],a[1],a[0],"@"];break;case 3:a=c>-1?[a[0],a[1],a[0],a[2]]:[a[0],a[1],a[2],"@"]}var h=i>0?a[0]:i<0?a[1]:a[2];if(a[0].indexOf("[")===-1&&a[1].indexOf("[")===-1)return[l,h];if(a[0].match(/\[[=<>]/)!=null||a[1].match(/\[[=<>]/)!=null){var u=a[0].match(ph),d=a[1].match(ph);return _h(i,u)?[l,a[0]]:_h(i,d)?[l,a[1]]:[l,a[u!=null&&d!=null?2:1]]}return[l,h]}(n,e);if(Gs(r[1]))return pa(e,t);if(e===!0)e="TRUE";else if(e===!1)e="FALSE";else if(e===""||e==null)return"";return function(o,i,a,l){var c,h,u,d=[],g="",m=0,f="",_="t",p="H";let S=o.length;for(;m<S;)switch(f=o.charAt(m)){case"G":if(!Gs(o,m))throw new Error("unrecognized character "+f+" in "+o);d[d.length]={t:"G",v:"General"},m+=7;break;case'"':for(g="";(u=o.charCodeAt(++m))!==34&&m<o.length;)g+=String.fromCharCode(u);d[d.length]={t:"t",v:g},++m;break;case"\\":var C=o.charAt(++m),y=C==="("||C===")"?C:"t";d[d.length]={t:y,v:C},++m;break;case"@":d[d.length]={t:"T",v:i},++m;break;case"B":case"b":if(o.charAt(m+1)==="1"||o.charAt(m+1)==="2"){if(c==null&&(c=vo(i,a,o.charAt(m+1)==="2"))==null)return"";d[d.length]={t:"X",v:o.substr(m,2)},_=f,m+=2;break}case"M":case"D":case"Y":case"H":case"S":case"E":f=f.toLowerCase();case"m":case"d":case"y":case"h":case"s":case"e":case"g":if(i<0||c==null&&(c=vo(i,a))==null)return"";for(g=f;++m<o.length&&o.charAt(m).toLowerCase()===f;)g+=f;f==="m"&&_.toLowerCase()==="h"&&(f="M"),f==="h"&&(f=p),d[d.length]={t:f,v:g},_=f;break;case"A":case"a":case"上":var b={t:f,v:f};if(c==null&&(c=vo(i,a)),o.substr(m,3).toUpperCase()==="A/P"?(c!=null&&(b.v=c.H>=12?"P":"A"),b.t="T",p="h",m+=3):o.substr(m,5).toUpperCase()==="AM/PM"?(c!=null&&(b.v=c.H>=12?"PM":"AM"),b.t="T",m+=5,p="h"):o.substr(m,5).toUpperCase()==="上午/下午"?(c!=null&&(b.v=c.H>=12?"下午":"上午"),b.t="T",m+=5,p="h"):(b.t="t",++m),c==null&&b.t==="T")return"";d[d.length]=b,_=f;break;case"[":for(g=f;o.charAt(m++)!=="]"&&m<o.length;)g+=o.charAt(m);if(g.slice(-1)!=="]")throw new Error('unterminated "[" block: |'+g+"|");if(g.match(Vg)){if(c==null&&(c=vo(i,a))==null)return"";d[d.length]={t:"Z",v:g.toLowerCase()},_=g.charAt(1)}else g.indexOf("$")>-1&&(g=(g.match(/\$([^-[\]]*)/)||[])[1]||"$",Gg(o)||(d[d.length]={t:"t",v:g}));break;case".":if(c!=null){for(g=f;++m<o.length&&(f=o.charAt(m))==="0";)g+=f;d[d.length]={t:"s",v:g};break}case"0":case"#":for(g=f;++m<o.length&&"0#?.,E+-%".indexOf(f=o.charAt(m))>-1;)g+=f;d[d.length]={t:"n",v:g};break;case"?":for(g=f;o.charAt(++m)===f;)g+=f;d[d.length]={t:f,v:g},_=f;break;case"*":if(++m,!(g=o.charAt(m)))throw new Error("no character specified for repeat function: "+o);d[d.length]={t:"R",v:g},++m;break;case"_":if(++m,!(g=o.charAt(m)))throw new Error("no character specified for spacing function: "+o);d[d.length]={t:"S",v:g},++m;break;case"(":case")":d[d.length]={t:l===1?"t":f,v:f},++m;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(g=f;m<o.length&&"0123456789".indexOf(o.charAt(++m))>-1;)g+=o.charAt(m);d[d.length]={t:"D",v:g};break;case" ":d[d.length]={t:f,v:f},++m;break;case"$":d[d.length]={t:"t",v:"$"},++m;break;default:if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(f)===-1)throw new Error("unrecognized character "+f+" in "+o);d[d.length]={t:"t",v:f},++m}var w,E=0,I=0;for(m=d.length-1,_="t";m>=0;--m)switch(d[m].t){case"h":case"H":d[m].t=p,_="h",E<1&&(E=1);break;case"s":(w=d[m].v.match(/\.0+$/))&&(I=Math.max(I,w[0].length-1)),E<3&&(E=3);case"d":case"y":case"M":case"e":_=d[m].t;break;case"m":_==="s"&&(d[m].t="M",E<2&&(E=2));break;case"X":break;case"Z":E<1&&d[m].v.match(/[Hh]/)&&(E=1),E<2&&d[m].v.match(/[Mm]/)&&(E=2),E<3&&d[m].v.match(/[Ss]/)&&(E=3)}switch(E){case 0:break;case 1:c.u>=.5&&(c.u=0,++c.S),c.S>=60&&(c.S=0,++c.M),c.M>=60&&(c.M=0,++c.H);break;case 2:c.u>=.5&&(c.u=0,++c.S),c.S>=60&&(c.S=0,++c.M)}var x,v="";for(S=d.length,m=0;m<S;++m)switch(d[m].t){case"t":case"T":case" ":case"D":break;case"X":d[m].v="",d[m].t=";";break;case"d":case"m":case"y":case"h":case"H":case"M":case"s":case"e":case"b":case"Z":d[m].v=Lp(d[m].t.charCodeAt(0),d[m].v,c,I),d[m].t="t";break;case"n":case"?":for(x=m+1;d[x]!=null&&((f=d[x].t)==="?"||f==="D"||(f===" "||f==="t")&&d[x+1]!=null&&(d[x+1].t==="?"||d[x+1].t==="t"&&d[x+1].v==="/")||d[m].t==="("&&(f===" "||f==="n"||f===")")||f==="t"&&(d[x].v==="/"||d[x].v===" "&&d[x+1]!=null&&d[x+1].t==="?"));)d[m].v+=d[x].v,d[x]={v:"",t:";"},++x;v+=d[m].v,m=x-1;break;case"G":d[m].t="t",d[m].v=pa(i,a)}var R,A,M="";if(v.length>0){v.charCodeAt(0)===40?(R=i<0&&v.charCodeAt(0)===45?-i:i,A=wn("n",v,R)):(A=wn("n",v,R=i<0&&l>1?-i:i),R<0&&d[0]&&d[0].t==="t"&&(A=A.substr(1),d[0].v="-"+d[0].v)),x=A.length-1;var T=d.length;for(S=d.length,m=0;m<S;++m)if(d[m]!=null&&d[m].t!=="t"&&d[m].v.indexOf(".")>-1){T=m;break}var F=S;if(T===S&&A.indexOf("E")===-1){for(m=d.length-1;m>=0;--m)d[m]!=null&&"n?".indexOf(d[m].t)!==-1&&(x>=d[m].v.length-1?(x-=d[m].v.length,d[m].v=A.substr(x+1,d[m].v.length)):x<0?d[m].v="":(d[m].v=A.substr(0,x+1),x=-1),d[m].t=d[m].v.indexOf("?")>=0?"N":"t",F=m);x>=0&&F<d.length&&(d[F].v=A.substr(0,x+1)+d[F].v)}else if(T!==d.length&&A.indexOf("E")===-1){for(x=A.indexOf(".")-1,m=T;m>=0;--m)if(d[m]!=null&&"n?".indexOf(d[m].t)!==-1){for(h=d[m].v.indexOf(".")>-1&&m===T?d[m].v.indexOf(".")-1:d[m].v.length-1,M=d[m].v.substr(h+1);h>=0;--h)x>=0&&(d[m].v.charAt(h)==="0"||d[m].v.charAt(h)==="#"||d[m].v.charAt(h)==="?")&&(M=A.charAt(x--)+M);d[m].v=M,d[m].t=M.indexOf("?")>=0?"N":"t",F=m}for(x>=0&&F<d.length&&(d[F].v=A.substr(0,x+1)+d[F].v),x=A.indexOf(".")+1,m=T;m<d.length;++m)if(d[m]!=null&&("n?(".indexOf(d[m].t)!==-1||m===T)){for(h=d[m].v.indexOf(".")>-1&&m===T?d[m].v.indexOf(".")+1:0,M=d[m].v.substr(0,h);h<d[m].v.length;++h)x<A.length&&(M+=A.charAt(x++));d[m].v=M,d[m].t=M.indexOf("?")>=0?"N":"t",F=m}}}for(m=0;m<S;++m)d[m]!=null&&"n?".indexOf(d[m].t)>-1&&(R=l>1&&i<0&&m>0&&d[m-1].v==="-"?-i:i,d[m].v=wn(d[m].t,d[m].v,R),d[m].t=d[m].v.indexOf("?")>=0?"N":"t");var L="";for(S=d.length,m=0;m<S;m++)if(d[m].t==="R")a?.onRepeatChar?.(L.length,d[m].v);else if(d[m].t==="S")a?.onSpacingChar?.(L.length,d[m].v),L+=a?.spacingCharacter??" ";else if(d[m].t==="N"){M=d[m].v;for(var D=0;D<M.length;D++)(f=M[D])==="?"&&(a?.onDigitChar?.(L.length,f),f=a?.digitCharacter??" "),L+=f}else d[m]!=null&&(L+=d[m].v);return L}(r[1],e,t,r[0])}function Sh(s,e){if(typeof e!="number"){e=+e||-1;for(var t=0;t<392;++t)if(Zn[t]!==void 0){if(Zn[t]===s){e=t;break}}else e<0&&(e=t);e<0&&(e=391)}return Zn[e]=s,e}const Ve={format:$g,dateNumLocal:sc,load:Sh,split_fmt:Hg,_table:Zn,load_table:function(s){for(var e=0;e!==392;++e)s[e]!==void 0&&Sh(s[e],e)},parse_date_code:vo,is_date:Gg,get_table:function(){return Ve._table=Zn}},$e="\\s*([-]?[0-9e]*[.]?[0-9]+)",Pp=new RegExp(`^rgb\\(${$e},${$e},${$e}\\)$`),zp=new RegExp(`^rgba\\(${$e},${$e},${$e},${$e}\\)$`),Wp=new RegExp(`^lrgb\\(${$e},${$e},${$e}\\)$`),jp=new RegExp(`^lrgba\\(${$e},${$e},${$e},${$e}\\)$`),Hp=new RegExp(`^hsl\\(${$e},${$e},${$e}\\)$`),Vp=new RegExp(`^hsla\\(${$e},${$e},${$e},${$e}\\)$`),Gp=new RegExp(/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/),$p=new RegExp(/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/),Up=new RegExp("^index(\\d+)$","i"),_a=(s,e,t)=>[parseFloat(s),parseFloat(e),parseFloat(t)],Sa=(s,e=255)=>{const t=[...s];for(var n=0;n<s.length;n++)t[n]=s[n]/e;return t},wh=(s,e=0)=>{const t=[...s];for(var n=0;n<s.length;n++)N.roundAccurately(s[n],e+8)%1==.5?t[n]=Math.floor(s[n]):t[n]=N.roundAccurately(s[n],e);return t},ot=(s,e=!0)=>{const t=[...s],n=e?1:255;for(var r=0;r<s.length;r++)t[r]=Math.max(0,Math.min(n,s[r]));return t},Mr=s=>Math.max(0,Math.min(1,s)),Ug=s=>((s%=360)<0&&(s-=360),s),nr=s=>{const e=[...s];for(var t=0;t<s.length;t++)e[t]=$s(s[t]);return e},or=s=>{const e=[...s];for(var t=0;t<s.length;t++)e[t]=Us(s[t]);return e},$s=s=>s<.04045?s/12.92:Math.pow((s+.055)/1.055,2.4),Us=s=>s<.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055,sr=s=>{let e=s[0],t=s[1],n=s[2];e%=360,e/=360,t/=100,n/=100;let r=n<.5?n*(1+t):n+t-t*n,o=2*n-r;return[Math.max(0,wa(o,r,e+1/3)),Math.max(0,wa(o,r,e)),Math.max(0,wa(o,r,e-1/3))]},wa=(s,e,t)=>(t<0&&(t+=1),t>1&&(t-=1),6*t<1?s+6*(e-s)*t:2*t<1?e:3*t<2?s+6*(e-s)*(2/3-t):s),zn=s=>{let e=s[0],t=s[1],n=s[2],r=Math.min(e,Math.min(t,n)),o=Math.max(e,Math.max(t,n)),i=0;o===r?i=0:o===e?i=(60*(t-n)/(o-r)+360)%360:o===t?i=60*(n-e)/(o-r)+120:o===n&&(i=60*(e-t)/(o-r)+240);const a=(o+r)/2;let l=0;return l=o===r?0:a<=.5?(o-r)/(o+r):(o-r)/(2-o-r),[i,100*l,100*a]},rt=0,ya=1,ro=2,qs=0,Js=1,Ks=2,Xs=0,Ys=1,Qs=2,qp=(s,e)=>{let t=e/100;return((n,r)=>{let o=nr(n);o[0]=r(o[0],o),o[1]=r(o[1],o),o[2]=r(o[2],o);let i=or(o);return i=ot(i),i})(s,(n,r)=>n*t)},gs=2.55,Jp=(s,e)=>{const t=zn(s),n=t[2],r=N.roundAccurately((o=n,(i=e)>0?(o*gs*(1-i)+(255-255*(1-i)))/gs:i<0?o*gs*(1+i)/gs:o),3);var o,i;t[2]=r;let a=sr(t);return a=ot(a),a},Kp=(s,e)=>{let t=nr(s),n=e/100;for(var r=0;r<3;r++)t[r]=t[r]*n+(1-n);let o=or(t);return o=ot(o),o},Ca=(s,e,t)=>{let n=zn(e),r=t/1;s===rt&&(r=Ug(t)),n[s]=r;let o=sr(n);return o=ot(o),o},ba=(s,e,t)=>{let n=zn(e);if(s===rt){let o=t/360;n[rt]=360*(n[rt]/360+o),n[rt]%=360,n[rt]<0&&(n[rt]-=360)}else{let o=t/.1;n[s]=.1*(n[s]/.1+o)}let r=sr(n);return r=ot(r),r},Ea=(s,e,t)=>{let n=zn(e),r=t/100;n[s]=n[s]*r,s===rt&&(n[rt]=Ug(n[rt]));let o=sr(n);return o=ot(o),o},tn=(s,e,t,n)=>{let r=nr(e),o=t/100;n===Xs?r[s]=o:n===Ys?r[s]+=o:n===Qs&&(r[s]*=o);let i=or(r);return i=ot(i),i},Xp=s=>{let e=nr(s),t=.213*e[qs]+.715*e[Js]+.072*e[Ks];e[0]=t,e[1]=t,e[2]=t;let n=or(e);return n=ot(n),n},Yp=s=>{let e=zn(s);e[rt]+=180,e[rt]%=360,e[rt]<0&&(e[rt]-=360);let t=sr(e);return t=ot(t),t},yh=(s,e=!0)=>{let t=e?nr(s):[...s];const n=e?1:255;return t[0]=n-t[0],t[1]=n-t[1],t[2]=n-t[2],e&&(t=or(t)),t=ot(t,e),t},Qp=s=>{const e=[0,0,0];return e[0]=Us(s[0]),e[1]=Us(s[1]),e[2]=Us(s[2]),ot(e)},Zp=s=>{const e=[0,0,0];return e[0]=$s(s[0]),e[1]=$s(s[1]),e[2]=$s(s[2]),ot(e)},Ch=(s,e,t,n=null)=>{const r=o=>{let i=o.toString(16);return i.length===1?"0"+i:i};return(n===null?"":r(Math.round(255*n)))+r(Number(s)).toUpperCase()+r(Number(e)).toUpperCase()+r(Number(t)).toUpperCase()},fr=.2126,Rn=.7152,pr=.0722;var dn;(s=>{s.RGBA=class{constructor(t,n,r,o=1){this._private={red:t,green:n,blue:r,alpha:o}}get red(){return this._private.red}get green(){return this._private.green}get blue(){return this._private.blue}get alpha(){return this._private.alpha??1}toString(t=!0){return t&&this._private.alpha!==null?`rgba(${this.red},${this.green},${this.blue},${this.alpha})`:`rgb(${this.red},${this.green},${this.blue})`}isEqual(t){return!!t&&t.red===this.red&&t.green===this.green&&t.blue===this.blue&&t.alpha===this.alpha}isAlmostEqual(t){if(!t)return!1;const n=1.5;return!(Math.abs(t.red-this.red)>n)&&!(Math.abs(t.green-this.green)>n)&&!(Math.abs(t.blue-this.blue)>n)&&!(Math.abs(t.alpha-this.alpha)>n)}},s.HSLA=class{constructor(t,n,r,o){this._private={hue:t,sat:n,lum:r,alpha:o}}get hue(){return this._private.hue}get sat(){return this._private.sat}get lum(){return this._private.lum}get alpha(){return this._private.alpha??1}toString(t=!0){return t&&this._private.alpha!==null?`hsla(${this.hue},${this.sat},${this.lum},${this.alpha})`:`hsl(${this.hue},${this.sat},${this.lum})`}isEqual(t){return!!t&&t.hue===this.hue&&t.sat===this.sat&&t.lum===this.lum&&t.alpha===this.alpha}isAlmostEqual(t){if(!t)return!1;const n=1.5;return!(Math.abs(t.hue-this.hue)>n)&&!(Math.abs(t.sat-this.sat)>n)&&!(Math.abs(t.lum-this.lum)>n)&&!(Math.abs(t.alpha-this.alpha)>n)}};class e extends s.RGBA{toString(n=!0){return n&&this._private.alpha!==null?"#"+Ch(this.red,this.green,this.blue,this.alpha??1).toUpperCase():"#"+Ch(this.red,this.green,this.blue).toUpperCase()}}s.HEX=e})(dn||(dn={}));const e0=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,t0=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Zs=function(s){if(!s)return null;s=s.replace(e0,function(t,n,r,o){return n+n+r+r+o+o});let e=t0.exec(s);return e?new dn.RGBA(parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)):null},bh=["000000","FFFFFF","FF0000","00FF00","0000FF","FFFF00","FF00FF","00FFFF","000000","FFFFFF","FF0000","00FF00","0000FF","FFFF00","FF00FF","00FFFF","800000","008000","000080","808000","800080","008080","C0C0C0","808080","9999FF","993366","FFFFCC","CCFFFF","660066","FF8080","0066CC","CCCCFF","000080","FF00FF","FFFF00","00FFFF","800080","800000","008080","0000FF","00CCFF","CCFFFF","CCFFCC","FFFF99","99CCFF","FF99CC","CC99FF","FFCC99","3366FF","33CCCC","99CC00","FFCC00","FF9900","FF6600","666699","969696","003366","339966","003300","333300","993300","993366","333399","333333"],Xn=new Map;for(let s=0;s<bh.length;s++)Xn.set(s,Zs(bh[s]));Xn.set(-4105,null),Xn.set(-4142,null),Xn.set(64,Zs("000000")),Xn.set(65,Zs("FFFFFF")),Xn.set(81,Zs("FFFFFF"));const vi=s=>Xn.get(s),ae={General:"General",Number:"Number",Currency:"Currency",Accounting:"Accounting",ShortDate:"Short Date",LongDate:"Long Date",MediumDate:"Medium Date",ShortTime:"Short Time",MediumTime:"Medium Time",LongTime:"Long Time",Comma:"Comma",Percentage:"Percentage",Fraction:"Fraction",Scientific:"Scientific",Text:"Text",Special:"Special",Custom:"Custom"};let va=null;const qg=()=>va||(va=Intl.DateTimeFormat().resolvedOptions().locale??"en-US",va),n0=/^\[\$-(.*?)\]/i,r0=/^[0-9a-fA-F]+$/,o0=Ve.split_fmt,ic=(s,e,t)=>{const n=n0.exec(s);let r=qg();if(n&&n[1]){let o=n[1];r0.test(o)||o.includes("-")}if(Eh[s]&&(s=Eh[s]),typeof e=="number"){const o=xo(s,e,{locale:r,...t});if(o!==null)return o.fmt}return Ve.format(s,e,t)},xo=(s,e,t)=>{if(typeof e!="number")return null;const n=qr(e,t?.date1904??!1),r=t?.locale??qg();let o=!1,i=s,a=-1;if((a=i.indexOf("Short Date"))!==-1){const l=new Intl.DateTimeFormat(r).format(n);i=i.substring(0,a)+l+i.substring(a+10),o=!0}if((a=i.indexOf("Medium Date"))!==-1){const l=Ve.format(Ve.get_table()[15],e,t);i=i.substring(0,a)+l+i.substring(a+11),o=!0}if((a=i.indexOf("Long Date"))!==-1){const l=new Intl.DateTimeFormat(r,{dateStyle:"full"}).format(n);i=i.substring(0,a)+l+i.substring(a+9),o=!0}if((a=i.indexOf("Short Time"))!==-1){const l=Ve.format(Ve.get_table()[20],e,t);i=i.substring(0,a)+l+i.substring(a+10),o=!0}if((a=i.indexOf("Medium Time"))!==-1){const l=Ve.format(Ve.get_table()[18],e,t);i=i.substring(0,a)+l+i.substring(a+11),o=!0}if((a=i.indexOf("Long Time"))!==-1){const l=new Intl.DateTimeFormat(r,{timeStyle:"medium"}).format(n);i=i.substring(0,a)+l+i.substring(a+9),o=!0}return o?{fmt:i,date:n}:null},Eh=Object.freeze({"General Number":"General","General Date":"m/d/yyyy h:mm","Medium Date":Ve.get_table()[15],"Medium Time":Ve.get_table()[18],"Short Time":Ve.get_table()[20],Currency:'"$"#,##0.00_);[Red]\\("$"#,##0.00\\)',Fixed:Ve.get_table()[2],Standard:Ve.get_table()[4],Percent:Ve.get_table()[10],Scientific:Ve.get_table()[11],"Yes/No":'"Yes";"Yes";"No";@',"True/False":'"True";"True";"False";@',"On/Off":'"Yes";"Yes";"No";@'}),s0=Object.freeze({black:0,white:1,red:2,green:3,blue:4,yellow:5,magenta:6,cyan:7}),i0=s=>{let e=null;if((s=s.toLowerCase()).startsWith("color")){const t=parseInt(s.substring(5));t>=0&&t<=56&&(e=`Index${t+7}`)}if(!e){const t=s0[s];t!==void 0&&(e=vi(t).toString())}return e},Jg="=",a0="<>",Kg=">",Fl="<",Xg=">=",l0="<=",Un=new Map;Un.set(Jg,(s,e)=>s===e),Un.set(a0,(s,e)=>s!==e),Un.set(Kg,(s,e)=>s>e),Un.set(Fl,(s,e)=>s<e),Un.set(Xg,(s,e)=>s>=e),Un.set(l0,(s,e)=>s<=e);const c0=/(Black|Blue|Cyan|Green|Magenta|Red|White|Yellow|Color[0-9]+)/i,h0=/(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)/i,u0=/\[(.*?)\]/g,d0=(s,e)=>{const t={color:null,condition:null};let n=null,r=new RegExp(u0);for(;(n=r.exec(s))!==null;){let o=!1,i=c0.exec(n[1]);if(i){if(o=!0,t.color)throw new Error(`format error, two colors specified: '${s}' and '${t.color}'.`);t.color=i0(i[1]),t.color||console.warn("Unable to parse LegacyColor",i[1])}let a=h0.exec(n[1]);if(a){if(o=!0,t.condition)throw new Error(`Format error, two conditions specified: ' ${s}'`);t.condition={op:a[1],comp:parseFloat(a[2])}}if(!o)return t}return t.condition||(t.condition=e),t},g0=(s,e)=>{let t=(r=>{const o=[];if(!r)return o;const i=r.split(";");for(let a=0;a<i.length;a++){let l=null;i.length===2?a===0?l={op:Xg,comp:0}:a===1&&(l={op:Fl,comp:0}):i.length!==3&&i.length!==4||(l=a===0?{op:Kg,comp:0}:a===1?{op:Fl,comp:0}:a===2?{op:Jg,comp:0}:null);const c=i[a],h=d0(c,l);o.push({format:c,colorAndCondition:h})}return o})(s),n=t[0].colorAndCondition;if(t.length===1&&n&&!n.condition&&n.color)return n.color;for(let r=0;r<t.length;r++){n=t[r].colorAndCondition;let o=n?.condition??void 0;if(r===3)return typeof e=="string"&&n?.color?n.color:null;if(o&&typeof e=="number"&&Un.get(o.op)(e,o.comp))return n?.color??null}},vh=s=>{if(s===ae.MediumDate||s===ae.LongDate||s===ae.ShortDate||s===ae.MediumTime||s===ae.LongTime||s===ae.ShortTime)return!0},m0=(s,e)=>s===e?0:vh(s)?1:vh(e)?-1:s===ae.Percentage?1:e===ae.Percentage?-1:s===ae.Currency||s===ae.Accounting?1:e===ae.Currency||e===ae.Accounting?-1:0,Ur=s=>(s instanceof Date||Object.prototype.toString.call(s)==="[object Date]")&&!isNaN(s.getTime()),f0=(s,e,t)=>{return t==="month"||t==="months"||t==="m"?(n=s,12*((r=e).getUTCFullYear()-n.getUTCFullYear())+(r.getUTCMonth()-n.getUTCMonth())+(r.getUTCDate()-n.getUTCDate()<0?-1:0)):t==="year"||t==="years"||t==="y"?((o,i)=>Math.abs(i.getFullYear()-o.getFullYear()))(s,e):t==="day"||t==="days"||t==="d"?((o,i)=>Math.floor((Date.UTC(i.getFullYear(),i.getMonth(),i.getDate())-Date.UTC(o.getFullYear(),o.getMonth(),o.getDate()))/864e5))(s,e):void console.warn("invalid unit"+t);var n,r},ms="d",xh="m",Ih="y",Rh=(s,e,t)=>{if(t==="month"||t==="months"||t==="m"){const n=new Date(s.getTime());return new Date(n.setMonth(n.getMonth()+e))}if(t==="year"||t==="years"||t==="y"){const n=new Date(s.getTime());return n.setFullYear(n.getFullYear()+e),n}if(t==="day"||t==="days"||t==="d"){const n=new Date(s.getTime());return n.setDate(n.getDate()+e),n}if(t==="hour"||t==="hours"||t==="h"){const n=new Date(s.getTime());return n.setHours(n.getHours()+e),n}return console.warn("invalid unit"+t),null},qr=(s,e=!1)=>{let t=Ve.parse_date_code(s,{date1904:e});return t?new Date(t.y,t.m-1,t.d,t.H,t.M,t.S,Math.round(1e3*t.u)):null},Qo=(s,e=!1)=>isNaN(s)?null:Ve.dateNumLocal(s,e),p0=new class extends Ng{parse(s,e,t){const n=r=>r-1;switch(e){case"M":return Sn(Bn(Fg,s),n);case"MM":return Sn(Lo(2,s),n);case"Mo":return Sn(t.ordinalNumber(s,{unit:"month"}),n);case"MMM":return t.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(s,{width:"narrow",context:"formatting"});default:return t.month(s,{width:"wide",context:"formatting"})}}},nn=(s=>{let e=s,t=[];for(let n=0;n<e.length;n++){let r=e[n][0].indexOf("yyy")>-1,o=e[n][0].indexOf(".")>-1,i=e[n][0].indexOf("-")>-1;t.push({parseFormat:e[n][0],numberFormat:e[n][1],todaysYear:!r,windowYear:!0,containsDot:o,containsDash:i}),r&&t.push({parseFormat:e[n][0].replace(/yyy/g,"yyyy"),numberFormat:e[n][1],todaysYear:!1,windowYear:!1,containsDot:o,containsDash:i})}return t})([["MM-d","d-mmm"],["MM-yyy","mmm-yy"],["M-yyy","mmm-yy"],["M-d-yyy","m/d/yyyy"],["yyy-M-d","m/d/yyyy"],["yyy-d-M","m/d/yyyy"],["d.MMM","d-mmm"],["d.MMMM","d-mmm"],["d.MMM.yyy","d-mmm-yy"],["d.MMMM.yyy","d-mmm-yy"],["MMM.d","d-mmm"],["MMMM.d","d-mmm"],["MMM.yyy","mmm-yy"],["MMMM.yyy","mmm-yy"],["MMM dd, yyy","d-mmm-yy"],["MMMM dd, yyy","d-mmm-yy"],["EEE, MMMM dd, yyy","[$-x-sysdate]ddd, mmmm dd, yyyy"],["EEEE, MMMM dd, yyy","[$-x-sysdate]dddd, mmmm dd, yyyy"]]),_0={year:0,month:1,day:0,hour:0,minute:0,second:0,millis:0},S0=(s,e=!1)=>{const t={..._0,...s};return t.year=e?1904:1900,t.dow=-1,t.oaDateTime=((n,r=!1)=>{if(!n)return null;let o=n.day,i=n.hour;i>24&&(o+=Math.floor(i/24),i%=24),o>60&&--o;const a=new Date(n.year,n.month-1,o,i,n.minute,n.second,n.millis);return Qo(a,r)})(t,e),t},w0=new RegExp("([0-9]{1,2})\\s*(P[M]?|A[M]?)\\s*$","i"),y0=new RegExp("([0-9]+)\\s*\\:$","i"),xa=new RegExp("(\\s*[0-9]{1,2})\\s+(P[M]?|A[M]?)\\s*$","i"),Ah=new RegExp("(\\s*[0-9]{1,4})\\s*([\\.]{1}\\s*[0-9]+)?\\s*\\:","i"),C0=new RegExp("(\\s*[0-9]{1,4})\\s*([\\.]{1}\\s*[0-9]*)?\\s*$","i"),Yg=(s,e=!1,t=!1)=>{if(!s||s.trim().length<2||s.indexOf(":")===-1&&s.match(xa)===null)return null;let n=null,r=null,o=null,i=!1,a=!1,l="h:mm AM/PM",c=[],h=s,u=null;do{let _=h.indexOf(":");_===-1?(c.push(h),h=null):(c.push(h.substring(0,_+1)),h=h.substring(_+1,h.length))}while(c.length<3&&h&&h.length>0);if(h?.length>0)return null;const d=(_,p,S)=>{let C=_.match(p);if(!C)return null;u===null&&(u=_.substring(0,C.index));let y=parseInt(C[1]);if(C[2]&&o===null){if(S){let w=parseFloat(C[2].substring(1,C[2].length));isNaN(w)||(r=w)}let b=parseFloat(C[2]);isNaN(b)||(n=b),o=S}return y},g=(_,p)=>{let S=_.match(p);if(!S||S.length!==3)return null;u===null&&(u=_.substring(0,S.index)),i=!0;let C=parseInt(S[1]);return a=S[2].charAt(0)==="p"||S[2].charAt(0)==="P",C};c[c.length-1].trim().length===0&&c.pop();const m=[];if(c.length>0){let _=d(c[0],y0,!1);if(_===null&&(_=g(c[0],w0)),_===null)return null;m.push(_)}if(c.length>2){let _=d(c[1],Ah,!0);if(_===null&&(_=g(c[0],xa)),_===null)return null;m.push(_)}if(c.length>1){const _=c[c.length-1];let p=d(_,Ah,!1);if(p===null&&(p=d(_,C0,!1)),p===null&&(p=g(_,xa)),p===null)return null;m.push(p)}if(u!==null&&u.length>0&&!t)return null;if(o===!0&&(m.length===2&&m.splice(1,0,0),m[2]=r||0),i){if(m[0]>12||m[1]>=60||m[2]>=60)return null;m[0]===12?m[0]=a?12:0:a&&(m[0]+=12)}else l=c.length>2?"h:mm:ss":"h:mm",m[0]>23&&(l="[h]:mm:ss"),n!==null&&(l="mm:ss.0"),m[1]>=60&&(l="General"),m[2]>=60&&(l="General");l!=="General"&&(m.length===1&&m.push(0),m.length===2&&(n===null?m.push(0):m.unshift(0)));let f={hour:m[0]??0,minute:m[1]??0,second:m[2]??0,millis:1e3*(n??0)};return{numberFormat:l,parsed:S0(f,e),leadingText:u}},b0={},ac=(s,e=!1,t=null)=>{const n=t??Date.now(),r=new Date(n).getFullYear();let o=s.trim().replaceAll(/\s+/g," ");o=o.replaceAll(/\s*([-/])\s*/g,"$1");let i=o.replaceAll(/[-/ ]/g,"."),a=o.replaceAll(/[/]/g,"-");const l=Eo.M;Eo.M=p0;for(let c=0;c<nn.length;c++){let h=o;nn[c].containsDot?h=i:nn[c].containsDash&&(h=a);let u=Fp(h,nn[c].parseFormat,n,b0),d=Ve.dateNumLocal(u,e);if(Ur(u)&&(nn[c].windowYear||d>0)){if(nn[c].windowYear){let m=u.getFullYear()<=29?2e3+u.getFullYear():1900+u.getFullYear();u.setFullYear(m)}if(nn[c].todaysYear&&u.setFullYear(r),d=Ve.dateNumLocal(u,e),nn[c].parseFormat.indexOf("EEE")>-1){const m=ic("ddd",d,{date1904:e});if(!h.toLowerCase().includes(m.toLowerCase()))return null}let g=nn[c].numberFormat;return Eo.M=l,{asOADate:d,asJSDate:u,numberFormat:g}}}return Eo.M=l,null};function Zo(s){if(!s)return!1;let e=s.replaceAll(/\[([^)]+)\]/g,"").toLowerCase();return e=e.replaceAll(/".*"/g,""),e=e.replaceAll(/\\./g,""),e=e.replace(/[_*]./g,""),!e.includes("time")&&!!(e.includes("d")||e.includes("m")&&!e.includes("h")&&!e.includes("s")||e.includes("y")||e==="short date"||e==="medium date"||e==="long date")}function Hi(s){if(!s)return!1;let e=s.replaceAll(/\[([^)]+)\]/g,"").toLowerCase();return e=e.replaceAll(/".*"/g,""),e=e.replaceAll(/\\./g,""),e=e.replace(/[_*]./g,""),!e.includes("date")&&!(!e.includes("h")&&!e.includes("s")&&e!=="short time"&&e!=="medium time"&&e!=="long time")}var Mh,rn;exports.IText=void 0,(Mh=exports.IText||(exports.IText={})).SmallCaps={None:"none",Small:"small",All:"all"},Mh.StrikeStyle={None:"none",Single:"single",Double:"double"},exports.ITextFrame=void 0,(rn=exports.ITextFrame||(exports.ITextFrame={})).TabStop=class{},rn.HorizontalAlignment={General:"general",Left:"left",Center:"center",Right:"right",Justify:"justify",Distributed:"distributed",CenterContinuous:"centerContinuous",Fill:"fill"},rn.VerticalAlignment={Top:"top",Center:"center",Bottom:"bottom",Justify:"justify",Distributed:"distributed"},rn.Orientation={Horizontal:"horizontal",Vertical:"90",Vertical270:"270",Stacked:"stacked"},rn.ReadingDirection={Auto:"auto",LeftToRight:"ltr",RightToLeft:"rtl"},rn.Overflow={Visible:"visible",Wrap:"wrap",Clip:"clip",Shrink:"shrink",Ellipsis:"ellipsis"},rn.Autofit={None:"none",Normal:"normal",Shape:"shape"},rn.TabStopAlignment={Default:"default",Left:"left",Right:"right",Center:"center"},rn.toCSSHorizontalTextAlign=s=>s?s.toLowerCase():null;const Qg=(s,e,t=1e3)=>{if(!s)throw new Error("A template string must be specified.");if(e(s))return s;let n=new RegExp(/\d+/,"g").exec(s),r=null,o=0;n!==null?(r=s,o=parseFloat(n[0]),isNaN(o)&&(o=0)):(o=1,r=`${s}_${o}`);let i=isNaN(o)?0:o;for(;o<i+t;)try{const a=r.replace(/\d+/g,()=>""+o++);if(e(a))return a}catch{}throw new Error(`Unable to find valid name for '${s}'.`)},zr=(s,e=!1)=>{if(!s||s.length===0)return s;const t=s.charAt(0);if(t>="a"&&t<="z"){const n=String.fromCharCode(t.charCodeAt(0)-32);return e?n+s.slice(1).toLowerCase():n+s.slice(1)}return s},Th=s=>{if(!s||typeof s!="string")return"";const e=s.split(/[\\/]/).pop()||"",t=e.lastIndexOf(".");return e===""||t<1?"":e.slice(t+1)},Zg=s=>s.toLowerCase().replace(/([-_][a-z])/g,e=>e.toUpperCase().replace("-","").replace("_","")),em=(s,e=36)=>s.substring(0,36)+(s.length>e?"…":""),ei=s=>{if(s===void 0)return 0;let e=s.toString().split(".");return e.length<=1?0:e[1].length||0},tm=new RegExp(/^["|'|`](.*)["|'|`]$/),E0=new RegExp("^([a-zA-Z]+:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i"),nm=(s=",",e="'")=>new RegExp(`\\s*${s}\\s*(?=(?:[^${e}]*${e}[^${e}]*${e})*[^${e}]*$)`,"g"),rm=nm(),lc=s=>s.replace(tm,"$1"),om=(s,e="'")=>`${e}${s}${e}`,sm=(s,e=void 0,t=void 0)=>{let n=rm;return e===void 0&&t===void 0||(n=nm(e,t)),s.split(n)},im=s=>{let e;try{e=new URL(s)}catch{return!1}return(e.protocol==="http:"||e.protocol==="https:")&&E0.test(s)},v0=new RegExp(/^[^\s@]+@[^\s@]+\.[^\s@]+$/i),am=s=>!!s.toLowerCase().startsWith("mailto:")||v0.test(s),lm=s=>((s>=26?lm((s/26|0)-1):"")+"abcdefghijklmnopqrstuvwxyz"[s%26|0]).toUpperCase(),x0=Object.freeze(Object.defineProperty({__proto__:null,DefaultUnQuoteRegEx:rm,camelToSnake:s=>s&&s.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`),capitalize:zr,clampString:em,countDecimals:ei,findValidTextValue:Qg,getBaseName:(s,e=!1)=>{if(!s||typeof s!="string")return"";const t=s.split(/[\\/]/).pop()||"";if(t==="")return"";const n=Th(t),r=n.length===0?t:t.slice(0,t.length-n.length-1);return e?zr(r,!0):r},getFileNameExtension:Th,isQuoted:s=>s&&s.length>1&&tm.test(s)&&s[0]===s[s.length-1],isValidEmail:am,isValidHttpUrl:im,numberToAlphabet:lm,quote:om,snakeToCamel:Zg,splitUnquoted:sm,unquote:lc},Symbol.toStringTag,{value:"Module"})),I0=(s,e,t,n=null)=>{const r=(e||11*exports.IFont.getDeviceScale())/exports.IFont.getDeviceScale(),o=n?.letterSpacing||0,i=s.length,a=i*(.55*r)-(s.match(/[il.,;!|]/g)||[]).length*r*.15+(s.match(/[mwMW]/g)||[]).length*r*.1+(i>0?(i-1)*o:0),l=Math.ceil(1.2*r),c=Math.ceil(.8*r),h=Math.ceil(.2*r),u=Math.ceil(.45*r),d=Math.ceil(1.1*r),g=Math.max(1,Math.ceil(.08*r));return{width:a,lineHeight:l,baseline:c,lineGap:h,strikePosition:u,underlinePosition:d,strikeThickness:g,underlineThickness:g,actualBoundingBoxLeft:0,actualBoundingBoxRight:a,actualBoundingBoxAscent:c,actualBoundingBoxDescent:l-c,fontBoundingBoxAscent:c,fontBoundingBoxDescent:l-c,emHeightAscent:c,emHeightDescent:l-c,hangingBaseline:.8*c,alphabeticBaseline:c,ideographicBaseline:l}},tt={},Fh=(s,e)=>{let t="normal";return s&&e?t="bold italic":s?t="bold":e&&(t="italic"),t},Nh=s=>s.split(",").map(e=>{const t=(e=e.trim()).indexOf(" ")>=0,n=e.indexOf('"')>=0||e.indexOf("'")>=0;return t&&!n&&(e=`"${e}"`),e}).join(", "),kh=new Map,Ia=new Map;let on=null;const R0=(s,e,t,n=null)=>{const r=n?.letterSpacing||0;typeof window>"u"||tt.contextMeasure||(tt.canvasMeasure=document?document.createElement("canvas"):null,tt.contextMeasure=tt.canvasMeasure.getContext("2d"),tt.contextMeasure.letterSpacing=`${r}px`,tt.contextMeasure.textRendering="geometricPrecision",tt.contextMeasure.textBaseline="alphabetic",tt.contextMeasure.textAlign="left");const o=t||"calibri",i=e||11*exports.IFont.getDeviceScale(),a=n?.isBold||!1,l=n?.isItalic||!1;let c=null;if(s==="#"||s==="0"||s==="M"||s===""||s==="_"||s==="-"){c=((f,_,p,S,C,y)=>f+Math.round(100*_)/100+p+S+C+y)(s,i,o,a,l,r);const m=kh.get(c);if(m)return m}if(on&&on.text===s&&on.size===e&&on.family===t&&on.options?.isBold===n?.isBold&&on.options?.isItalic===n?.isItalic&&on.options?.letterSpacing===n?.letterSpacing)return on.metrics;let h={};const u=Fh(a,l)+" "+N.roundAccurately(i,2)+"px "+Nh(o);tt.contextMeasure?(tt.contextMeasure.font=u,tt.contextMeasure.letterSpacing=`${n?.letterSpacing??0}px`,h=tt.contextMeasure.measureText(s)):h.width=s.length*N.roundAccurately(i/exports.IFont.getDeviceScale()*.6,2);let d=Ia.get(u);if(!d&&typeof window<"u"){const m=document.createElement("div");m.style.visibility="hidden",m.style.position="absolute";const f=document.createElement("span");f.textContent="Mj",f.style.fontSize="100px",f.style.fontWeight=n?.isBold?"bold":"normal",f.style.fontStyle=n?.isItalic?"italic":"normal",f.style.fontFamily=`'${o}'`,f.style.lineHeight="1.2",m.appendChild(f),document.body.appendChild(m);const _=m.getBoundingClientRect(),p=f.getBoundingClientRect();document.body.removeChild(m),tt.contextMeasure.font=Fh(a,l)+" "+N.roundAccurately(100,2)+"px "+Nh(o);const S=tt.contextMeasure.measureText("M"),C=_.bottom-_.top,y=C-(S.fontBoundingBoxAscent+S.fontBoundingBoxDescent),b=S.fontBoundingBoxAscent+p.top,w=tt.contextMeasure.measureText("_"),E=b-w.actualBoundingBoxAscent,I=Math.max(1,Math.abs(w.actualBoundingBoxAscent+w.actualBoundingBoxDescent)),x=tt.contextMeasure.measureText("-"),v=N.roundAccurately(b-x.actualBoundingBoxAscent+Math.max(1,.05*C,0)),R=I,A=i/100;d={lineHeight:Math.ceil(C*A),baseline:Math.ceil(b*A),lineGap:Math.ceil(y*A),strikePosition:Math.ceil(v*A),underlinePosition:Math.ceil(E*A),strikeThickness:Math.ceil(R*A),underlineThickness:Math.ceil(I*A)},tt.contextMeasure.font=u,Ia.set(u,d)}d||(d={lineHeight:Math.ceil(1.2*i),baseline:Math.ceil(i)+Math.floor(.1*i),lineGap:Math.ceil(.1*i),strikePosition:Math.ceil(.55*i)+Math.floor(.1*i),strikeThickness:1,underlinePosition:Math.ceil(1.1*i),underlineThickness:1},Ia.set(u,d));const g={...h,width:h.width,...d};return c!==null&&kh.set(c,g),on={text:s,size:e,family:t,options:n,metrics:g},g};let _r=null;const A0=()=>{if(_r)return _r;try{const s=document.createElement("canvas"),e=s.getContext&&s.getContext("2d");e&&typeof e.fillText=="function"&&(_r=R0)}catch{}return _r||(console.warn("⚠️ CanvasFontMeasurer not available, falling back to SimpleFontMeasurer"),_r=I0),_r};let fs=null;var sn;exports.IFont=void 0,(sn=exports.IFont||(exports.IFont={})).Style={Normal:"normal",Italic:"italic"},sn.Scheme={Major:"major",Minor:"minor",None:"none"},sn.UnderlineStyle={None:"none",Double:"double",DoubleAccounting:"doubleAccounting",Single:"single",SingleAccounting:"singleAccounting"},sn.VerticalAlignment={Baseline:"baseline",Sub:"sub",Super:"super"},sn.setSharedMeasurer=s=>{fs=s},sn.getSharedMeasurer=()=>fs||(fs=A0(),fs),sn.getDeviceScale=()=>96/72*1,sn.getPanoseFallback=s=>{const e=[],t=s.length;for(let i=0;i<t;i+=2)e.push(parseInt(s.substring(i,i+2),16));const n=e[0],r=e[1],o=e[3];switch(n){case 2:return o===9?"monospace":r>=2&&r<=8?"serif":"sans-serif";case 3:return"cursive";case 4:return"fantasy";case 5:return"monospace";default:return"sans-serif"}},sn.GenericName={Serif:"serif",SanSerif:"sans-serif",MonoSpace:"monospace",Cursive:"cursive",Fantasy:"fantasy",SystemUI:"system-ui",UISystem:"ui-system",UISerif:"ui-serif",UISanSerif:"ui-sans-serif",UIMonoSpace:"ui-monospace",UIRounded:"ui-rounded",Math:"math",Emoji:"emoji",Fangsong:"fangsong"};class cm{constructor(e){this._private={input:e},typeof e=="string"?this._private.name=e:Object.assign(this._private,e)}toJSON(){return this._private.input}getFamily(){return this._private.name}getPitch(){return this._private.pitch}getPanose(){return this._private.panose}toString(){return typeof this._private.input=="string"?this._private.input:JSON.stringify(this._private.input)}get isIFont(){return!0}}const hm=["Arial","Arial Black","Brush Script MT","Calibri","Comic Sans MS","Courier New","Garamond","Georgia","Impact","Luminari","Palatino Linotype","Tahoma","Times New Roman","Trebuchet MS","Verdana"],gt=new Map;gt.set(exports.IFont.GenericName.Serif,["Tahoma"]),gt.set(exports.IFont.GenericName.SanSerif,["Calibri"]),gt.set(exports.IFont.GenericName.MonoSpace,["Courier New"]),gt.set(exports.IFont.GenericName.Cursive,["Comic Sans MS"]),gt.set(exports.IFont.GenericName.Fantasy,["Luminari"]),gt.set(exports.IFont.GenericName.UISystem,["Arial"]),gt.set(exports.IFont.GenericName.UISerif,["Tahoma"]),gt.set(exports.IFont.GenericName.UISanSerif,["Arial"]),gt.set(exports.IFont.GenericName.UIMonoSpace,["Courier New"]),gt.set(exports.IFont.GenericName.UIRounded,["Arial"]),gt.set(exports.IFont.GenericName.Math,[]),gt.set(exports.IFont.GenericName.Emoji,[]),gt.set(exports.IFont.GenericName.Fangsong,[]);const Nl=new Map;let um=[];hc(hm);const M0=eval;function hc(s){s||hc(hm);let e=[];for(let t=0;t<s.length;t++){let n=s[t];typeof n=="string"&&(n=new cm(n));let r=!0;const o="document";try{r=M0(`${o}.fonts.check('12px ${n.getFamily()}')`)}catch{}const i={fontRef:n,loaded:r};e.push(i),Nl.set(n.getFamily(),i)}um=Object.freeze(e)}const Ra=new Map,T0=Object.freeze(Object.defineProperty({__proto__:null,findBestMatch:(s,e)=>{const t=Ra.get(s);if(t)return t.fontRef===null?null:t;let n=[s];e.fallbacks&&(n=n.concat(e.fallbacks));let r=null;for(let o=0;!r&&o<n.length;o++){let i=n[o];if(r=Nl.get(i),!r){const a=gt.get(i);if(a)for(let l=0;!r&&l<a.length;l++)r=Nl.get(a[l])}}return r?Ra.set(s,r):Ra.set(s,{fontRef:null,loaded:!1}),r},getFontList:function(){return um},setFontList:hc},Symbol.toStringTag,{value:"Module"}));class Vi{constructor(e,t,n,r=null,o=null,i=null){this._private={wrapped:!0,insets:Yo.EmptyRect,orientation:exports.ITextFrame.Orientation.Horizontal,autoFit:exports.ITextFrame.Autofit.None,fontScale:1,vertical:!1,columnCount:1,columnSpacing:0,verticalAlignment:exports.ITextFrame.VerticalAlignment.Center,horizontalCentered:!1,lineReduction:0,isSpaceFirstLastPara:!1,presetTextWarp:null,paragraphs:N.EmptyArray},this._bounds=null,this._textBounds=null,this._lines=null,this._lastLayoutDims=void 0,this._lastLayout=void 0,this._private=Object.assign(this._private,e||{}),this._defaultFont=t,this._alignment=n,this._lines=r,this._bounds=Object.freeze(o),this._textBounds=Object.freeze(i)}visitParas(e){e?.visitTextFrame?.(this);const t=this.paragraphs,n=t.length;for(let r=0;r<n;r++){const o=t[r];e?.visitTextParagraph?.(o,r,n);const i=o.runs,a=i.length;for(let l=0;l<a;l++)e?.visitTextRun?.(i[l],l,a)}}visitLines(e){e?.visitTextFrame?.(this);const t=this.lines,n=t.length;for(let r=0;r<n;r++){const o=t[r];e?.visitTextLine?.(o,r,n);const i=o.runs,a=i.length;for(let l=0;l<a;l++)e?.visitTextRun?.(i[l],l,a)}}layout(e=null){return this._lastLayout&&this._lastLayoutDims?.width===e?.width&&this._lastLayoutDims?.height===e?.height||(this._lastLayout=P0(this,this._defaultFont,this._alignment,e),this._lastLayoutDims=e),this._lastLayout}clone(e){const t=e?.visitTextFrame?.(this),n=Object.assign(this._private,t||{});return delete n.bounds,new Vi(n,this._defaultFont,this._alignment)}equals(e){return N.deepEqual(this._private,e._private)}createTemporaryTextFrame(e,t){return Ui(e,this._defaultFont,this._alignment,t??this._private.wrapped)}get bounds(){if(this._bounds===null)throw new Error(Oh);return this._bounds}get textBounds(){if(this._textBounds===null)throw new Error(Oh);return this._textBounds}get lines(){return this._lines}get wrapped(){return this._private.wrapped}get insets(){return this._private.insets}get orientation(){return this._private.orientation}get autoFit(){return this._private.autoFit}get fontScale(){return this._private.fontScale}get vertical(){return this._private.vertical}get columnCount(){return this._private.columnCount}get columnSpacing(){return this._private.columnSpacing}get verticalAlignment(){return this._private.verticalAlignment}get horizontalCentered(){return this._private.horizontalCentered}get lineReduction(){return this._private.lineReduction}get isSpaceFirstLastPara(){return this._private.isSpaceFirstLastPara}get presetTextWarp(){return this._private.presetTextWarp}get paragraphs(){return this._private.paragraphs}}const Oh="bounds can not be used until layout";class Bh{static{this.NL=`
|
|
31
|
+
`}static{this.DefaultLineSpacing=100}static{this.DefaultTabWidth=72}}class Gi{constructor(e){this._private={defaultFontSize:11,defaultTabSize:Bh.DefaultTabWidth,tabOverrides:N.EmptyArray,spacingBefore:0,spacingAfter:0,lineSpacing:Bh.DefaultLineSpacing,align:exports.ITextFrame.HorizontalAlignment.Left,endParagraphSize:0,indentLevel:0,leadingIndent:0,hangingIndent:0,rightMargin:0,bullet:null},this._private=Object.assign(this._private,e||{})}clone(e){const t=e?.visitTextParagraph?.(this,0,1),n=Object.assign(this._private,t||{});return delete n.bounds,new Gi(n)}equals(e){return N.deepEqual(this._private,e._private)}get bounds(){return this._bounds}get defaultFontSize(){return this._private.defaultFontSize}get defaultTabSize(){return this._private.defaultTabSize}get tabOverrides(){return this._private.tabOverrides}get spacingBefore(){return this._private.spacingBefore}get spacingAfter(){return this._private.spacingAfter}get lineSpacing(){return this._private.lineSpacing}get align(){return this._private.align}get endParagraphSize(){return this._private.endParagraphSize}get indentLevel(){return this._private.indentLevel}get leadingIndent(){return this._private.leadingIndent}get hangingIndent(){return this._private.hangingIndent}get rightMargin(){return this._private.rightMargin}get bullet(){return this._private.bullet}get runs(){return this._private.runs}}class $i{constructor(e,t=null){this._private={text:null,fontName:"Arial",bold:!1,italic:!1,superSub:!1,fontSize:11,letterSpacing:0,kerningMin:10,smallCaps:exports.IText.SmallCaps.None,offset:0,strikeStyle:exports.IText.StrikeStyle.None},this._private={...this._private,...e},this._bounds=t}clone(e){const t=e?.visitTextRun?.(this,0,1),n=Object.assign(this._private,t||{});return delete n.bounds,new $i(n)}equals(e){return N.deepEqual(this._private,e._private)}get bounds(){return this._bounds}get text(){return this._private.text}get fontName(){return this._private.fontName}get bold(){return this._private.bold}get italic(){return this._private.italic}get fontSize(){return this._private.fontSize}get superSub(){return this._private.superSub}get letterSpacing(){return this._private.letterSpacing}get kerningMin(){return this._private.kerningMin}get smallCaps(){return this._private.smallCaps}get offset(){return this._private.offset}get strikeStyle(){return this._private.strikeStyle}}class dm{constructor(e,t,n){this._private={},this._private={bounds:e,baseline:t,runs:n}}get bounds(){return this._private.bounds}get baseline(){return this._private.baseline}get runs(){return this._private.runs}get bullet(){return null}}function uc(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Dh,Lh,Ph,zh,Wh,jh;function F0(){if(zh)return Ph;zh=1;const s=new Uint8Array(new Uint32Array([305419896]).buffer)[0]===18,e=(t,n,r)=>{let o=t[n];t[n]=t[r],t[r]=o};return Ph={swap32LE:t=>{s&&(n=>{const r=n.length;for(let o=0;o<r;o+=4)e(n,o,o+3),e(n,o+1,o+2)})(t)}}}var N0=function(){if(jh)return Wh;jh=1;const s=function(){if(Lh)return Dh;function t(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function n(w,E){this.source=w,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=E,this.destLen=0,this.ltree=new t,this.dtree=new t}Lh=1;var r=new t,o=new t,i=new Uint8Array(30),a=new Uint16Array(30),l=new Uint8Array(30),c=new Uint16Array(30),h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),u=new t,d=new Uint8Array(320);function g(w,E,I,x){var v,R;for(v=0;v<I;++v)w[v]=0;for(v=0;v<30-I;++v)w[v+I]=v/I|0;for(R=x,v=0;v<30;++v)E[v]=R,R+=1<<w[v]}var m=new Uint16Array(16);function f(w,E,I,x){var v,R;for(v=0;v<16;++v)w.table[v]=0;for(v=0;v<x;++v)w.table[E[I+v]]++;for(w.table[0]=0,R=0,v=0;v<16;++v)m[v]=R,R+=w.table[v];for(v=0;v<x;++v)E[I+v]&&(w.trans[m[E[I+v]]++]=v)}function _(w){w.bitcount--||(w.tag=w.source[w.sourceIndex++],w.bitcount=7);var E=1&w.tag;return w.tag>>>=1,E}function p(w,E,I){if(!E)return I;for(;w.bitcount<24;)w.tag|=w.source[w.sourceIndex++]<<w.bitcount,w.bitcount+=8;var x=w.tag&65535>>>16-E;return w.tag>>>=E,w.bitcount-=E,x+I}function S(w,E){for(;w.bitcount<24;)w.tag|=w.source[w.sourceIndex++]<<w.bitcount,w.bitcount+=8;var I=0,x=0,v=0,R=w.tag;do x=2*x+(1&R),R>>>=1,++v,I+=E.table[v],x-=E.table[v];while(x>=0);return w.tag=R,w.bitcount-=v,E.trans[I+x]}function C(w,E,I){var x,v,R,A,M,T;for(x=p(w,5,257),v=p(w,5,1),R=p(w,4,4),A=0;A<19;++A)d[A]=0;for(A=0;A<R;++A){var F=p(w,3,0);d[h[A]]=F}for(f(u,d,0,19),M=0;M<x+v;){var L=S(w,u);switch(L){case 16:var D=d[M-1];for(T=p(w,2,3);T;--T)d[M++]=D;break;case 17:for(T=p(w,3,3);T;--T)d[M++]=0;break;case 18:for(T=p(w,7,11);T;--T)d[M++]=0;break;default:d[M++]=L}}f(E,d,0,x),f(I,d,x,v)}function y(w,E,I){for(;;){var x,v,R,A,M=S(w,E);if(M===256)return 0;if(M<256)w.dest[w.destLen++]=M;else for(x=p(w,i[M-=257],a[M]),v=S(w,I),A=R=w.destLen-p(w,l[v],c[v]);A<R+x;++A)w.dest[w.destLen++]=w.dest[A]}}function b(w){for(var E,I;w.bitcount>8;)w.sourceIndex--,w.bitcount-=8;if((E=256*(E=w.source[w.sourceIndex+1])+w.source[w.sourceIndex])!==(65535&~(256*w.source[w.sourceIndex+3]+w.source[w.sourceIndex+2])))return-3;for(w.sourceIndex+=4,I=E;I;--I)w.dest[w.destLen++]=w.source[w.sourceIndex++];return w.bitcount=0,0}return function(w,E){var I;for(I=0;I<7;++I)w.table[I]=0;for(w.table[7]=24,w.table[8]=152,w.table[9]=112,I=0;I<24;++I)w.trans[I]=256+I;for(I=0;I<144;++I)w.trans[24+I]=I;for(I=0;I<8;++I)w.trans[168+I]=280+I;for(I=0;I<112;++I)w.trans[176+I]=144+I;for(I=0;I<5;++I)E.table[I]=0;for(E.table[5]=32,I=0;I<32;++I)E.trans[I]=I}(r,o),g(i,a,4,3),g(l,c,2,1),i[28]=0,a[28]=258,Dh=function(w,E){var I,x,v=new n(w,E);do{switch(I=_(v),p(v,2,0)){case 0:x=b(v);break;case 1:x=y(v,r,o);break;case 2:C(v,v.ltree,v.dtree),x=y(v,v.ltree,v.dtree);break;default:x=-3}if(x!==0)throw new Error("Data error")}while(!I);return v.destLen<v.dest.length?typeof v.dest.slice=="function"?v.dest.slice(0,v.destLen):v.dest.subarray(0,v.destLen):v.dest}}(),{swap32LE:e}=F0();return Wh=class{constructor(t){const n=typeof t.readUInt32BE=="function"&&typeof t.slice=="function";if(n||t instanceof Uint8Array){let r;if(n)this.highStart=t.readUInt32LE(0),this.errorValue=t.readUInt32LE(4),r=t.readUInt32LE(8),t=t.slice(12);else{const o=new DataView(t.buffer);this.highStart=o.getUint32(0,!0),this.errorValue=o.getUint32(4,!0),r=o.getUint32(8,!0),t=t.subarray(12)}t=s(t,new Uint8Array(r)),t=s(t,new Uint8Array(r)),e(t),this.data=new Uint32Array(t.buffer)}else({data:this.data,highStart:this.highStart,errorValue:this.errorValue}=t)}get(t){let n;return t<0||t>1114111?this.errorValue:t<55296||t>56319&&t<=65535?(n=(this.data[t>>5]<<2)+(31&t),this.data[n]):t<=65535?(n=(this.data[2048+(t-55296>>5)]<<2)+(31&t),this.data[n]):t<this.highStart?(n=this.data[2080+(t>>11)],n=this.data[n+(t>>5&63)],n=(n<<2)+(31&t),this.data[n]):this.data[this.data.length-4]}}}();const k0=uc(N0);var Hh,Vh={},O0=(Hh||(Hh=1,function(s){var e=typeof Uint8Array<"u"?Uint8Array:Array,t=43,n=47,r=48,o=97,i=65,a=45,l=95;function c(h){var u=h.charCodeAt(0);return u===t||u===a?62:u===n||u===l?63:u<r?-1:u<r+10?u-r+26+26:u<i+26?u-i:u<o+26?u-o+26:void 0}s.toByteArray=function(h){var u,d,g,m,f,_;if(h.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var p=h.length;f=h.charAt(p-2)==="="?2:h.charAt(p-1)==="="?1:0,_=new e(3*h.length/4-f),g=f>0?h.length-4:h.length;var S=0;function C(y){_[S++]=y}for(u=0,d=0;u<g;u+=4,d+=3)C((16711680&(m=c(h.charAt(u))<<18|c(h.charAt(u+1))<<12|c(h.charAt(u+2))<<6|c(h.charAt(u+3))))>>16),C((65280&m)>>8),C(255&m);return f===2?C(255&(m=c(h.charAt(u))<<2|c(h.charAt(u+1))>>4)):f===1&&(C((m=c(h.charAt(u))<<10|c(h.charAt(u+1))<<4|c(h.charAt(u+2))>>2)>>8&255),C(255&m)),_},s.fromByteArray=function(h){var u,d,g,m=h.length%3,f="";function _(S){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(S)}function p(S){return _(S>>18&63)+_(S>>12&63)+_(S>>6&63)+_(63&S)}for(u=0,g=h.length-m;u<g;u+=3)f+=p(d=(h[u]<<16)+(h[u+1]<<8)+h[u+2]);switch(m){case 1:f+=_((d=h[h.length-1])>>2),f+=_(d<<4&63),f+="==";break;case 2:f+=_((d=(h[h.length-2]<<8)+h[h.length-1])>>10),f+=_(d>>4&63),f+=_(d<<2&63),f+="="}return f}}(Vh)),Vh),kl={};const B0=[[4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,3,4,4,4,4,4,4,4,4,4,4,4],[0,4,4,1,1,4,4,4,4,1,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,4,4,4,4,1,1,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[4,4,4,1,1,1,4,4,4,1,1,1,1,1,1,1,1,1,1,1,4,2,4,1,1,1,1,1,1,1,1,1,1],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,1,1,1,1,1,1,4,2,4,1,1,1,1,1,1,1,1,1,1],[0,4,4,1,1,1,4,4,4,0,0,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,0,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,0,1,0,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,0,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,0,0,1,1,1,1,1,1,1,0,0,4,2,4,1,1,1,1,1,0,1,1,1,0],[1,4,4,1,1,1,4,4,4,0,0,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,0,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,0,1,4,4,4,0,0,1,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,0,1,4,4,4,0,0,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,1,1,1,1,1,1,4,2,4,1,1,1,1,1,1,1,1,1,0],[0,4,4,1,1,1,4,4,4,0,0,0,0,0,0,1,1,1,0,4,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,1,1,1,1,1,1,4,2,4,1,1,1,1,1,1,1,1,1,1],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,1,1,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,1,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,1,1,1,1,0,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,1,1,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,1,0,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,0,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,1,0,0,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,1,1,0],[0,4,4,1,1,1,4,4,4,0,1,0,0,0,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[1,4,4,1,1,1,4,4,4,1,1,1,1,1,0,1,1,1,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0],[0,4,4,1,1,0,4,4,4,0,0,0,0,0,0,0,0,0,0,0,4,2,4,0,0,0,0,0,0,0,0,1,0]],D0=new k0(uc(O0).toByteArray("AAgOAAAAAAAQ4QAAAQ0P8vDtnQuMXUUZx+eyu7d7797d9m5bHoWltKVUlsjLWE0VJNigQoMVqkStEoNQQUl5GIo1KKmogEgqkKbBRki72lYabZMGKoGAjQRtJJDaCCIRiiigREBQS3z+xzOTnZ3O+3HOhd5NfpkzZx7fN9988zivu2M9hGwB28F94DnwEngd/Asc1EtIs9c/bIPDwCxwLDgezHcodyo4w5C+CCwBS8FnwSXgCnA1uFbI93XwbXAbWAfWgx+CzWAb+An4KfgFeAzsYWWfYuFz4CXwGvgb+Dfo6yNkEEwGh4CZYB44FpwI3g1OY+kfBItZOo2fB84Hy8DF4HJwNbiWpV8PVoO1LH4n2NRXyN+KcAd4kNVP9XsY4aPgcfAbsBfs6SniL4K/sPjfEf6HlanXCRkCw2BGvUh/keWfXS/CY+pFXs7x9XHmM94LTmWIeU2cgbxnS/k/B3kf86jDhU8L9V2E40vAFWAlWFUfb++NOL4F3C7JX4/4GiE+hvgWsF0oS7mXldspnN+F493gyXrh9xTav0cg3EvzgVfBG6wsmVSEkxBOBgdPGpd7JI6PnqRvJ68/xlbHof53gPeA94OzwLngk+ACsAwsByvASrAK3MB0Ws3CtQjvBJvAVrADPMDSHkb4CNijaccTwvnf4fiPEs8Lxy+D18A/QU8/xjgYBjPAbDAKTgYLwOngTHAO+EQ/8wuEF4EvsPiVCFf2+9tsFStzA8LVHuXXBsi6QyqzUYiPMR/7Mc7dAx7oL8bzw/3u/Bw8Bp4Az4AXwCtgHzsmDXP5fiF9iiVvly5d0sHngar16NKlS5cuXbp06fLmYlqHXrcd3ph4P0THUY3iXh49novju4S0tzfs5d+JPKewfAsRntZb3K9ZhOMlrO6lCC8An28U9+OuovcPcPxlVu5rCL/VmHh/iHIrzn3fIPu7SN8Axmg+8AOwEWwCm7tp3bRuWjetm5Y8bSu4B9zbKO6ZVsnORrVU3f4uXTqZ2H3sLoyx3eDXjfDndE9qyj6L838CfwVvgFpzYnof4oNgOhgBc8Fos9DrZIQLmtXPP1MmF6wGj4H+KXoWguvADkXaPil+YpuQy8Am8Ey7ODdtmJDF4HowBp4De6HDTNjhfHAHeBr0DBBy0kDxfPbcgSIusgrcWhtnJ8vL+TPix7UIOQtcBq4C28Cr4KRBnANbwSuDE+s50JgyNNFuXbp06XIgsXjIvPafjvXozKY+fVFz/z0LT1uCtKVSWbrOLWPnztG8e0Xfy7ol8XtZJi7WtG+5od2UFXQ/A12vUeS7jp27yVKHjdsU9lXB869TyNvAzt0lpP2oWbwLdjiO78bx/Sz+EMJHwK9Y/LcIfw+eZ3F67/Hl5vh9xX80J+rwX8SvRDhpgL17iPAQMHNArfPrqHPewLheI+AERV6efwV418B4nOZ/H+IfYHV8GOF5LJ3eAz0fx8sM9S0fUNud39O9CulfGZhY5huI3wzWgNvBelbHZoTbNPVpfYjKQpkHwUNgl0LWblbnk0LbbDxr0OMFpL3iqWdu9nWYPlVAWkXY39LnGdCkDbeqv1YNbfcMQ3t9oe8lzm6NH9N1ZB6Ln4BwfkJZJk7RyFnYKt6b/JDQXx9p5X+eFdqOjzM9P9MB/lUlFzr20aXIdzlY4dmn9F3YqtvoO76/2hp/D/xA5Zue88nNyL8GbFbs075X0tyUig3Qd2MCnf//HjnzpbsR3g9+1kHzzVjdnE71/qVBX9rGPUh/ysNWe1neFzvIDi5zAufV1sT0N0poR22wkFUfTOPfA4N2mbZ5fSrqOHSw+IbkSBbOGSzSRgf91/GTUWYBOB2cIZQ/G8cfBZ8CFwrnL8XxF8FKcA24jqXdiPA7Qr61OF7H4mMItwzuv2/YLth1ISt3Hzu3k4W7EH5JqPdRHD/O4k+z8A8IX5Lq3y7Z4nXE9xn6kX6vQ4bKfy+ok+hH+xf3hq9dnTTHhjKd2GmDuWA242iHMq4cC7A8kJ7i8o1+skSa7Jieo38HCWnoNjKFhdSFBxzpZ7QE6lI8N4S14aASZcryaV/WWHw66f6NHuCoxuQxmvM56GX9QMd8Q4D65ywGP+ZzRJuM+zQvx/MOS2VFeqQ4IXnH26zM9Xe6/E6D+4foAzzuajPZp8Qyw5ayZVDWuH0z0BtYRkeIDqH9KO9VbH1btd/lhNqCzvl8zeLnG0S/hnU6baHfpiuO6yy0rd+DHURo/zYF5H26j03rQsip2ndzz82u1z9N4VjWKWeb68Tedpt95HRVXp7H1R6p+/Wt4FPy/PpWwscOLRJ+PVWF/+W0iVyGzs18TIvXkOJ1Wxm66vSXz+vylenrZcj1ub439W+K8RNCGTJi2p/TJ1K23VaXr35tRpnzmjxequgfcfyk6B/TGBVlyedsNgpdd/h+W1U3P99QyFPNo1X3TwpM/WLTIWYfoBqXrv6iskHZ/RFr79R6hIyHBrH3f1nrUVnjP8SnZZ+rYtzr9Exld5MNbPNErusAPg+77u/eDOPftU9yj39TH7rezxd1LvsZQJlzkWlOirG/79zjMj/mtHUKu7vKy+3/LnXr9okyKedjX5/0He9iP/j63LwOQdarEVlfy8OO/Lqw023j6xcqmwxLiOd6heM2i9cV9LJy8jMJ23yQ+rpbfu7EQ/pXE8KYvUSqvVnb4XzZa6LrHMXHR+zcLvqWbm/Bn0/HzIs6fWPHoat8XfnDKmZGxRxeMbn2UqZ5Q94nmcZRbqqUXbZ8+lcjE+cPX11t814orvvAXNcG8vqj2vvk1MGn3anlj0bIT72v47bvE+Lc98T9b6r7AKn6j+8Duf7D0nnZx/j7Zjn0j9nbpSTndaLr9WNLivP+iN23xF7L+fqv6ZouFyb78jxVXvv5jJ9YUs9/sddO8h7KNg5jrhfaJGztT6G7KF+1d6yCmD5Kdb2fan60rSc552fZr3zeQ9DpnPp+Si5cx5Ktv2QfSzF/mMbWdOm46rFI4XstnU9xeqX4NKb7TKEdcr6pZOK3ID1k/LvFHkVczEuZLEDr499YqvqBym1aEHWgcvoYOtv0M91qQl5TfpO/in6rWx8OVpT1Wedkv3f5xom3T/xeR/6Gx6V86PWAOB4bBpqWdN+yTcVxjIyGRz/FrDGu6w/3d7kPm8StX8RyPu+uuvpNju/vTLJV37GpvoM0oZPnW87VLnL/5pDno1NoW1R6yedU6TyUv3u19a3KFnIbTLYz+ZCLP4T0tU1uivFgso0pnsJ/UtXvarNY28Xq5cvkBDrQP/E5ZaiuQwwfmTlsOiQRU1fMuqrDd/3ISSuwjOwXOfTyGUMpZIXq4GpLn3pUcdfzch2x7XO1u2uZHOPb1G6b3Xg9PH1IIWeEpJlPQtqos2EKW8b0u8rnuP1UeVLoXJb9be0uG9nnbchjU+XTszT5VeNBThPHnc5OKj1U9aj0GTHIVaGy1YhEWT4ixns00DT+XEzWn/7VAsIc63Cov3OdyhwjrnaqQqZvWKXdypRdlq+k8msZ031U+Rm4fA+3TtyeR9hwfW9G9yxDN0fZMN33F+9TE6md4hwoxumfaUzI9fN3PFT3xVV2msrQ3UsnChm6Nulk8TndpS28D3zX9tTIPsF/z7Am5OkTjm1tI1JZW74+4VgsZ0N3L1yXV3WeP5uR7TGHHdvC3JQlxybfpd22tDlk/2eofRK8TzrN/qnar/K/OUTth6I/+jAnEptNbPvFHP2gs40N3+dfMWtwqvVct7/wfd8gtQ7imifial9ZJ9/3IHLYU6eDj3+4PhsNhX+vwvcWLnu6kGfEMe8DuciPfUfGZB8X/7HJy/Gefe5n+VRGFd/wyP2ta7/LO4yh/sbLV/k9lev6kfO9Dt/5U67b1/6u/epqB1U9Me23jfHY9sscAg4tkbLl+e4/U36rJ9ddxfd6sg5vq5ice42Wpk/pb9FOJ36/W9tpv4kbC79nUbZceX8Zu6/qJ+P3WvhvA8v3reh7Jbn2d6rrNC7XNZTLma4Ba0JI9efX2uLzF5scG/w9UNU1ZxW+ymUfzELeTllXlQ1rUuhzjS5fp9c964iFBOqeSz63bU065nZKdU+mDEz3qHIjjifquw0pnb/raRtvrnsYcb46ihT3taoYz6brdNW9l6rWRnE/navdPn1XlR1km7hcz1WlH/elKuSOSvLLuE8U6m8uzwRdfcGl73VyTHuyMvzJ1Sa2cWDTP/Z63Kc94n2B1PYr24dz1JlyHLlcP+S4B6vD1c9EW4q2LWstCvUjeVy63k/LMYdUNd5D1xQfvVTzX1VjkMsUv88N8VH5fReVn/Fjn++/h6X6Q8a6b1/q3g/i/ewi0/Scs8zxXeV6mWIOUPlPzBgdFerW+bZrm2P18dnjuK6HunEp+rHvPMXbr+sHVb/lnL+pTP57jPw9Cvk3PW178JD9qChfzuvTf7Htl38L1QUf/VKu9SFjwWbTWPvFEvu7Uq76y7+31g6QlYPc669pbsm9Xur2LWI9Pu8ypfDXqm3A2z8s1FWGn4ntL9NfQu2oSlftX9uetvTtv7J8Ql4zxfXGZ3zk8PeQ9w59x2uMfqI8/q5eKh/l9cb2rwsu9rSNl06ZP2Pmxtz+rNMx93yno0n2/82rVH7rQ+y9P15H6FyRun9ViH81ATmffI7nJ5r8uXXW6enbP6b/B8/l5OifVHYLnb9S39s2zcc+Ph+rh8+eQgVPS72elzGWY/tUtbbabBpDiI7yN1q6/4th2y+ErAc5+9BVvu/7KamJbWNZeuqI/R4tRf+YyD1HmOZM1bMV3/14Sn10c0Xu+Sj1nOXb5jL73ncdy02uvlXZNde65dOHYl7Vs4KYuS6FzWLn2zJlpZqPXPVPOa5yzKOyn1VhT9lmMfdbfH7D11Wf2PXN5h9y+dD287+qxgSnaYmnIrRtIb8pJe6/Uv9OVer6Whn0zfGO/BEloZI9ojmfAlUflClDd178bTmVHVTpZXOkAlk/lb42UujmI89HH5V+cl7XtowY6vTxLVWok6UrGzoGTHN+bB+6ri05687VNpvfuvRfaP2uMlNQth1D5JjGelm/8yn+9p3p/7qk9gnfeddXZmq/Sm333PJT659Kv1zjNbZ9uv2Oi//67CV8/N1nj1DmviyXDNVeJkaeaX8UsyesYg8cu2+NvdaPfb+lLDu5tvt/")),Gh=function(s){switch(s){case 33:case 39:case 40:case 42:return 12;case 35:return 5;default:return s}},$h=function(s){switch(s){case 37:case 38:return 34;case 41:return 22;default:return s}};class Aa{constructor(e,t=!1){this.position=e,this.required=t}}kl=class{nextCodePoint(){const s=this.string.charCodeAt(this.pos++),e=this.string.charCodeAt(this.pos);return 55296<=s&&s<=56319&&56320<=e&&e<=57343?(this.pos++,1024*(s-55296)+(e-56320)+65536):s}nextCharClass(){return Gh(D0.get(this.nextCodePoint()))}getSimpleBreak(){switch(this.nextClass){case 41:return!1;case 34:case 37:case 38:return this.curClass=34,!1;case 36:return this.curClass=36,!1}return null}getPairTableBreak(s){let e=!1;switch(B0[this.curClass][this.nextClass]){case 0:e=!0;break;case 1:e=s===41;break;case 2:if(e=s===41,!e)return e=!1,e;break;case 3:if(s!==41)return e}return this.LB8a&&(e=!1),!this.LB21a||this.curClass!==16&&this.curClass!==17?this.LB21a=this.curClass===13:(e=!1,this.LB21a=!1),this.curClass===28?(this.LB30a++,this.LB30a==2&&this.nextClass===28&&(e=!0,this.LB30a=0)):this.LB30a=0,this.curClass=this.nextClass,e}nextBreak(){if(this.curClass==null){let s=this.nextCharClass();this.curClass=$h(s),this.nextClass=s,this.LB8a=s===31,this.LB30a=0}for(;this.pos<this.string.length;){this.lastPos=this.pos;const s=this.nextClass;if(this.nextClass=this.nextCharClass(),this.curClass===34||this.curClass===36&&this.nextClass!==37)return this.curClass=$h(Gh(this.nextClass)),new Aa(this.lastPos,!0);let e=this.getSimpleBreak();if(e===null&&(e=this.getPairTableBreak(s)),this.LB8a=this.nextClass===31,e)return new Aa(this.lastPos)}return this.lastPos<this.string.length?(this.lastPos=this.string.length,new Aa(this.string.length)):null}constructor(s){this.string=s,this.pos=0,this.lastPos=0,this.curClass=null,this.nextClass=null,this.LB8a=!1,this.LB21a=!1,this.LB30a=0}};class L0{constructor(e){this._textMeasurer=e}_measureText(e){const t=this._fontSize,n=this._fontName,r=this._metricOptions;if(this._isSuperSub){const o=this._textMeasurer(e,.6*t,n,r);return{...this._textMeasurer("M",t,n,r),width:o.width}}return this._textMeasurer(e,t,n,r)}_breakWord(e,t,n){let r=0;for(;r<e.length;){let o={startPosition:this._charactersRead+r,text:"",x:0,y:0,width:0,widthWhitespace:0,height:0,baseline:0},i=!1,a=0;const l=this._maxWidth;do{i=!1;const c=e.substring(r,r+a+1),h=c.replace(/\s+$/,""),u=this._measureText(h);let d=u;c.length!==h.length&&(d=this._measureText(c)),(o.x+u.width<=l||c.length<=1)&&(o.text=c,o.width=u.width,o.widthWhitespace=d.width,o.height=Math.max(o.height,u.lineHeight),o.baseline=Math.max(o.baseline,u.baseline),i=!0,a++)}while(i&&r+a<e.length);if(i){const c=e.substring(r,e.length),h=c.replace(/\s+$/,""),u=this._measureText(h);let d=u;c.length!==h.length&&(d=this._measureText(c)),t.startPosition=this._charactersRead+r,t.width=u.width,o.widthWhitespace=d.width,t.height=Math.max(t.height,u.lineHeight),t.baseline=Math.max(t.baseline,u.baseline),t.text=c}else if(n?.(o)===!1)return!1;r+=a}}_breakWhiteSpace(e,t=null){for(;e&&this._charactersRead<e.length;){let n={startPosition:this._charactersRead,text:"",x:0,y:0,width:0,widthWhitespace:0,height:0,baseline:0},r=!1;const o=this._maxWidth,i=this._indent,a=this._breaker;do if(r=!1,n.startPosition===0&&n.text.length===0&&(n.x=i,this._lastBreak=a.nextBreak()),this._lastBreak){const c=e.substring(n.startPosition,this._lastBreak.position),h=c.replace(/\s+$/,""),u=this._measureText(h);let d=u;c.length!==h.length&&(d=this._measureText(c)),n.x+u.width<=o?(n.text=c,n.width=u.width,n.widthWhitespace=d.width,n.height=Math.max(n.height,u.lineHeight),n.baseline=Math.max(n.baseline,u.baseline),r=!0,this._charactersRead=this._lastBreak.position):n.text.length===0&&this._breakWord(c,n,t)!==!1&&(r=!0,this._charactersRead=this._lastBreak.position),(r||c.indexOf(`
|
|
32
|
+
`)===-1)&&this._lastBreak.required&&(this._lastBreak=a.nextBreak(),r=!1)}while(r&&(this._lastBreak=a.nextBreak()));if(t?.(n)===!1)return!1}}wrap(e,t=null){this._breaker=new kl(e),this._linesRead=[],this._charactersRead=0,this._maxXRead=0,this._maxXWhitespaceRead=0,this._maxYRead=0,this._fontName=t?.fontName??"Arial",this._fontSize=t?.fontSize??12,this._metricOptions={isBold:t?.bold??!1,isItalic:t?.italic??!1,letterSpacing:t?.letterSpacing??0},this._isSuperSub=t?.superSub??!1,this._indent=t?.indent??0,this._maxWidth=t?.maxWidth??Number.MAX_SAFE_INTEGER,this._maxWidth<=0&&(this._maxWidth=Number.MAX_SAFE_INTEGER),this._maxHeight=t?.maxHeight??Number.MAX_SAFE_INTEGER,this._maxHeight<=0&&(this._maxHeight=Number.MAX_SAFE_INTEGER);const n=o=>{if(this._linesRead.length>0){let i=this._linesRead[this._linesRead.length-1];o.y=i.y+i.height}if(o.y+o.height>this._maxHeight)return!1;this._maxXRead=Math.max(this._maxXRead,o.x+o.width),this._maxXWhitespaceRead=Math.max(this._maxXWhitespaceRead,o.x+o.widthWhitespace),this._maxYRead=Math.max(this._maxYRead,o.y+o.height),this._linesRead.push(o)};if(e===""){const o=this._measureText(e);n({startPosition:0,text:"",x:0,y:0,width:0,widthWhitespace:0,height:o.lineHeight,baseline:o.baseline})}else if(this._breakWhiteSpace(e,n),new kl(e.charAt(e.length-1).repeat(2)).nextBreak().required){const o=this._measureText(e);n({startPosition:e.length,text:"",x:0,y:0,width:0,widthWhitespace:0,height:o.lineHeight,baseline:o.baseline})}const r={bounds:{x:0,y:0,width:this._maxXRead,widthWhitespace:this._maxXWhitespaceRead,height:this._maxYRead},lines:this._linesRead};return this._breaker=null,this._linesRead=[],r}}const P0=(s,e,t,n=null,r=exports.IFont.getSharedMeasurer())=>{let o="",i=null,a=null;const l=s.paragraphs,c=l.length;for(let y=0;y<c;y++){const b=l[y].runs,w=b.length;for(let E=0;E<w;E++)o+=b[E].text,E===0&&(i=b[E]);y===0&&(a=l[y])}const h=s.insets??Yo.EmptyRect,u=new L0(r),d=n?.width?n.width-h.right-h.left:n?.width,g=n?.height?n.height-h.bottom-h.top:null,m=u.wrap(o,{fontName:i.fontName,fontSize:i.fontSize*exports.IFont.getDeviceScale(),bold:i.bold,italic:i.italic,superSub:i.superSub,letterSpacing:i.letterSpacing,maxWidth:s.wrapped&&d?d:null,maxHeight:g});let f=[];const _=m.lines,p=_.length,S=new Array(p);for(let y=0;y<p;y++){const b=_[y],w={x:b.x,y:b.y,width:b.width,height:b.height},E=new $i({text:b.text,fontName:i.fontFamily,fontSize:i.fontSize,bold:i.bold,italic:i.italic,superSub:i.superSub,letterSpacing:i.letterSpacing},w);f.push(E),S[y]=new dm(w,b.baseline,[E])}const C=new Gi({runs:f,align:a.align});return new Vi({paragraphs:[C],wrapped:s.wrapped,verticalAlignment:s.verticalAlignment},e,t,S,{x:m.bounds.x,y:m.bounds.y,width:m.bounds.widthWhitespace,height:m.bounds.height},{x:m.bounds.x,y:m.bounds.y,width:m.bounds.width,height:m.bounds.height})},Uh=s=>{let e=!1,t=!1;for(let n=0;n<s.length;n++){const r=s.charCodeAt(n);if(r>=65&&r<=90?e=!0:r>=97&&r<=122&&(t=!0),e&&t)return 0}return e?1:t?-1:0},Ui=(s,e,t,n,r=!1)=>{if(s==null)return null;const o=new $i({text:s,fontName:e.toCSS().fontFamily,fontSize:e.getSize(),bold:e.getWeight()>400,italic:e.getStyle()===exports.IFont.Style.Italic,superSub:!r&&(e.getVerticalAlignment()===exports.IFont.VerticalAlignment.Sub||e.getVerticalAlignment()===exports.IFont.VerticalAlignment.Super),letterSpacing:e.getLetterSpacing()}),i=r?exports.ITextFrame.HorizontalAlignment.Left:t.getHorizontal(),a=t.getVertical(),l=new Gi({runs:[o],align:i});let c=[];return c.push(new dm(null,e.getSize(),[o])),new Vi({paragraphs:[l],wrapped:n&&(t.getOverflow()===exports.ITextFrame.Overflow.Wrap||i===exports.ITextFrame.HorizontalAlignment.Justify||i===exports.ITextFrame.HorizontalAlignment.Distributed||a===exports.ITextFrame.VerticalAlignment.Justify||a===exports.ITextFrame.VerticalAlignment.Distributed),verticalAlignment:a},e,t,c)},ps=(s,e,t,n)=>({x:s*n-e*t,y:s*t+e*n}),qh=s=>{let e=0,t=0,n=0,r=0,o=0,i=0,a=0,l=s.length;if(l===0)return{m:0,b:0};if(l===1)return{m:1,b:s[0]};for(let h=0;h<l;h++)i=h+1,a=s[h],a==null||isNaN(a)||(e+=i,t+=a,r+=i*i,n+=i*a,o++);const c=(o*n-e*t)/(o*r-e*e);return{m:c,b:t/o-c*e/o}},Ol=(s,e)=>{if(e===null)return null;const t=N.isObject(e);return s!=null&&t?N.mergeContentful(s,e):t?N.cloneObject(e):e},z0=(s,e,t)=>s==null||typeof s=="object"&&Object.keys(s).length===0;function dc(s,e,t,n){if(s===e)return s??null}function W0(s){return s==null}function j0(s,e,t=1,n){if(t===0)return{preceding:s?[...s]:[],modified:[],trailing:[]};const r=function(l,c,h=1){let u=N.findEqualOrGreater(l,c,f=>f.max);const d=l.slice(0,u),g=[],m=[];if(!l[u])return{preceding:d,modified:g,trailing:m};for(let f=u;f<l.length;f++)c+h<l[f].min?m.push({...l[f],min:l[f].min-h,max:l[f].max-h}):c>=l[f].min?Math.max(c,l[f].max+1-h)>l[f].min&&g.push({...l[f],max:Math.max(c-1,l[f].max-h)}):c<l[f].min&&c+h<=l[f].max&&g.push({...l[f],min:Math.max(c,l[f].min-h),max:l[f].max-h});return{preceding:d,modified:g,trailing:m}}(s,e,t),o=r.preceding,i=r.trailing;let a=[];return o.length>0&&a.push(o.pop()),a=a.concat(r.modified),i.length>0&&a.push(i.shift()),{preceding:o,modified:rr(a,{onMerge:dc}).modified,trailing:i}}function Bl(s,e,t){if(!s)throw new Error("runs can not be null");if(!e)return{preceding:[],modified:s?[...s]:[],trailing:[]};const n=function(i,a,l,c,h=!1){if(!a)return{preceding:[],modified:i?[...i]:[],trailing:[]};let u,d=N.findEqualOrGreater(i,a.min,S=>S.max),g=i.slice(0,d),m=i.slice(d),f=[],_={...a},p=m[0]||{min:a.min,max:a.max,value:void 0};for(u=h?(S,C,y)=>{const b=(c||Ol)(C,y,S);b!==void 0?S.value=b:delete S.value,f.push(S)}:(S,C,y)=>{const b=(c||Ol)(C??null,y,S);b!==void 0?S.value=b:delete S.value,f.push(S)};m.length>=0&&_.max-_.min>=0;){if(_.min<p.min)u({min:_.min,max:Math.min(_.max,p.min-1)},void 0,_.value),_={min:p.min,max:_.max,value:_.value},p={min:_.min,max:p.max,value:p.value};else if(_.min>p.min){const S=p.value!==void 0&&l?l(p,_.min):[p.value,p.value];f.push({min:p.min,max:Math.min(_.min,p.max)-1,value:S[0]}),_={min:Math.min(_.min,p.max),max:_.max,value:_.value},p={min:_.min,max:p.max,value:S[1]}}else{const S=p.value!==void 0&&l?l(p,_.min):[p.value,p.value];u({min:p.min,max:Math.min(_.max,p.max)},S[0],_.value),_={min:Math.min(_.max,p.max)+1,max:_.max,value:_.value},p={min:Math.min(_.max,p.max)+1,max:p.max,value:S[1]}}p.min<=p.max?m[0]=p:(m=m.slice(1),p=m[0]||{min:p.min,max:_.max})}return{preceding:g,modified:f,trailing:m}}(s,e,t?.onSplit,t?.onUpdate,t?.inPlace);let r=[];n.preceding.length>0&&r.push(n.preceding.pop()),r=r.concat(n.modified),n.trailing.length>0&&r.push(n.trailing.shift());const o=function(i,a){if(!i||i.length===0)return{preceding:[],modified:i?[...i]:[],trailing:[]};const l=Math.min(i.length-1,a?.startOffset??0),c=Math.min(i.length,a?.endOffset??i.length),h=a?.cull??W0;let u=i.slice(0,l),d=i.slice(c);const g=[];for(let m=l;m<c;m++)h(i[m].value,i[m].min,i[m].max)!==!0&&g.push(i[m]);return{preceding:u,modified:g,trailing:d}}(rr(r,{onMerge:t?.onMerge??dc}).modified,{cull:t?.isCull||z0});return{preceding:n.preceding,modified:o.modified,trailing:n.trailing}}function Xt(s){return[...s.preceding,...s.modified,...s.trailing]}function rr(s,e){if(!s||s.length===0)return{preceding:[],modified:s?[...s]:[],trailing:[]};const t=Math.min(s.length-1,e?.startOffset??0),n=Math.min(s.length,e?.endOffset??s.length),r=e?.onMerge??dc;let o=s.slice(0,t),i=s.slice(n);const a=[];let l={...s[t]},c=s[t]?.max||0;for(let h=t+1;h<=n;h++){const u=s[h];let d=!1;if(u&&u.min<=s[h-1].max+1)if(l.value===void 0&&u.value===void 0)d=!0;else{const g=r(l.value,u.value,l.max-l.min+1,u.max-u.min+1);g!==void 0&&(d=!0,l.value=g)}d?l.max=Math.max(c,u.max):(a.push(l),l={...s[h]},u&&(l.max=Math.max(c,u.max))),l&&(c=l.max)}return{preceding:o,modified:a,trailing:i}}function Jh(s){return s&&s.sort((e,t)=>{let n=e.min-t.min;return n===0&&(n=e.max-t.max),n})}const Kh=(s,e=!1)=>{if(!s||s.length===0)return N.EmptyArray;const t=e?s:s.sort(),n=[];let r=null;for(let o=0;o<t.length;o++){const i=t[o];r?r.max===i-1?r.max=i:(n.push(r),r={min:i,max:i}):r={min:i,max:i}}return r&&n.push(r),n},Xh=(s,e)=>s?e?s||e?s.min>e.max||s.max<e.min?null:{min:Math.max(s.min,e.min),max:Math.min(s.max,e.max)}:null:{...s}:{...e},gm=s=>{const e=s.length===0;return{runs:s,run:{min:e?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,max:e?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,value:null},index:Number.MAX_SAFE_INTEGER}},mm=(s,e)=>{const t=e.run,n=t.min,r=t.max;if(s>=n&&s<=r)return t.value;let o=e.index;const i=e.runs;if(o<i.length-1&&s>r){o++;const h=i[o],u=h.min,d=h.max;if(s>=u&&s<=d)return e.index=o,t.min=u,t.max=d,t.value=h.value,t.value}if(o!==Number.MAX_SAFE_INTEGER&&o>0&&s<n){o--;const h=i[o],u=h.min,d=h.max;if(s>=u&&s<=d)return e.index=o,t.min=u,t.max=d,t.value=h.value,t.value}if(o=N.findEqualOrGreater(i,s,h=>h.max),o===i.length)return o=i.length,e.index=o,t.min=i[o-1].max+1,t.max=Number.MAX_SAFE_INTEGER,t.value=null,null;const a=i[o],l=a.min,c=a.max;if(s>=l&&s<=c){e.index=o,t.min=l,t.max=c;const h=a.value;return t.value=h,h}return o--,e.index=o,t.min=o>=0?i[o].max+1:Number.MIN_SAFE_INTEGER,t.max=l-1,t.value=null,null},Yh=function(s,e,t,n){if(s.length===0){if(t!=null||n!=null){const c=e({min:t??n,max:n??t});if(c&&c.break)return c}return}const r=t??s[0].min,o=n??s[s.length-1].max;let i=r-1,a=N.findEqualOrGreater(s,r,c=>c.max),l=s[a];for(;l&&l.min<=o;){if(i<l.min-1){const h=e({min:Math.max(i+1,r),max:Math.min(l.min-1,o)});if(h&&h.break)return h}const c=e({...l,min:Math.max(l.min,r),max:Math.min(l.max,o)});if(c&&c.break)return c;i=l.max,l=s[++a]}if(i<o){const c=e({min:Math.min(i+1,o),max:o});if(c&&c.break)return c}},Qh=new RegExp("([0-9]+)$");var _s,Ss;exports.AutoFill=void 0,(s=>{s.Date=class{constructor(a){this._options=a}canFill(a,l){return Ur(a)}createFillAt(a,l){l={...this._options,...l};let c=0,h=this._options?.unit;h||(h=a.length===1?ms:((g,m=!1)=>{if(!g||g.length<1)return ms;let f=g;m||(f=g.slice(),f=f.sort((C,y)=>C.getTime()-y.getTime()));let _=!1,p=-1,S=-1;for(let C=0;C<f.length;C++){let y=f[C];if(C>f.length-1&&y.getTime()<f[C+1].getTime())throw new Error("Dates are expected to be sorted.");let b=12*y.getFullYear()+y.getMonth();if(b===S)return ms;S=b;let w=y.getFullYear();w>p?p=w:_=!0}return _?xh:Ih})(a));const u=Rh(a[0],0,h);u.setHours(0,0,0,0);let d=1;l?.reverse&&(d*=-1,c*=-1);for(let g=1;g<a.length;g++){let m=f0(a[g-1],a[g],h);if(g===1)d=m;else if(m!==d)return null}return a.length===1&&l.multiFill,g=>{const m=Rh(u,d*g,h);if(c!==0){const f=0+c*g,_=f%1440,p=Math.floor(_/60),S=_%60;m.setHours(p,S,0,0);const C=Math.floor(f/1440),y=Math.floor(C/365),b=C%365,w=Math.floor(b/30),E=b%30;y>0&&m.setFullYear(m.getFullYear()+y),w>0&&m.setMonth(m.getMonth()+w),E>0&&m.setDate(m.getDate()+E)}return m}}},s.Linear=class{constructor(a){this._options=a}canFill(a,l){return typeof a=="number"||a===null}createFillAt(a,l){l={...this._options,...l};const c=qh(a),h=c.b;let u=c.m;return a.length===1?(l.reverse&&(u=-u),l.multiFill?d=>d*u+h:null):d=>u*(d+1)+h}};const e={value:null,template:null},t={sensitivity:"accent"};s.Ordinal=class{_template(a){const l=a.match(Qh);if(!l)return null;const c=l[1],h=a.lastIndexOf(c);return h===-1?null:a.substring(0,h)}canFill(a,l){if(a===null)return!0;if(typeof a!="string")return e.value=null,!1;const c=this._template(a);return c&&(l===void 0||l===e.value&&c.localeCompare(e.template,void 0,t)===0)?(e.value=a,e.template=c,!0):(e.value=null,!1)}createFillAt(a,l){const c=[],h=a[0];let u=null,d=null,g=0;if(h){const S=h.match(Qh);if(S){u=S[1],u.startsWith("0")&&(g=u.length);const C=h.lastIndexOf(u);d=h.substring(0,C)}}const m=a.length;for(let S=0;S<m;S++){const C=a[S];let y=null;if(C){const b=C.substring(d.length,C.length);b.startsWith("0")&&(g=Math.max(g,b.length));const w=parseFloat(b);isNaN(w)||(y=w)}c.push(y)}const f=qh(c),_=f.b;let p=f.m;return p!==0&&Number.isInteger(p)?S=>{if(a[S%m]===null)return null;const C=(m===1?l.reverse?-S:S:p*(S+1))+_,y=""+Math.abs(C),b="0".repeat(Math.max(0,g-y.length))+y;return d+b}:null}},s.Copy=class{canFill(a,l){return!0}createFillAt(a,l){const c=a.length;return h=>a[h%c]??null}};const n=Object.freeze(["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]),r=Object.freeze(["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]),o=Object.freeze(["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]),i=Object.freeze(["January","February","March","April","May","June","July","August","September","October","November","December"]);s.List=class{constructor(a){this._lists=[],this._map=new Map;const l=[];if(a?.customLists){const u=a.customLists;for(let d=u.length-1;d>0;d--)l.push(u[d])}l.push(i),l.push(o),l.push(r),l.push(n);const c=this._map,h=[];for(let u=0;u<l.length;u++){const d=l[u],g=[];h.push(g);for(let m=0;m<d.length;m++){const f=d[m],_=zr(f,!0),p=_.toLowerCase().trim();let S=c.get(p);S||(S=[],c.set(p,S));const C={value:_,asKey:p,major:u,minor:m};S.push(C),g.push(C)}}this._lists=Object.freeze(h)}canFill(a,l){return a===null?!0:typeof a!="string"?!1:!!this._map.get(a.toLowerCase().trim())}createFillAt(a,l){const c=[],h=a[0];c.push(h.toLowerCase().trim());const u=this._map.get(c[0]);let d;const g=new Map,m=new Set;for(let v=0;v<u.length;v++){const R=u[v];g.set(R.major,R)}if(a.length>1){for(let v=1;v<a.length;v++){const R=a[v].toLowerCase().trim(),A=this._map.get(R);if(!A)return null;v===1&&(d=A),c.push(R);for(let M=0;M<A.length;M++){const T=A[M].major;g.has(T)&&m.add(T)}}if(m.size===0)return null}let f=null;const _=this._lists;for(let v=0;!f&&v<_.length;v++)(a.length===1||m.has(v))&&(f=g.get(v));if(!f)return null;let p=null;for(let v=0;!p&&d&&v<d.length;v++)d[v].asKey===c[1]&&(p=d[v]);let S=!1,C=!1;const y=Uh(h);y===1?S=!0:(y===-1||Uh(h[0])===-1)&&(C=!0);const b=_[f.major];let w=f.minor,E=1;if(c.length>1){E=p.minor-f.minor;for(let v=2;v<c.length;v++)if(b[v+w].minor-b[v-1+w].minor!==E)return null}a.length===1&&l?.reverse&&(E=-E);const I=a.length,x=b.length;return v=>{if(a[v%I]===null)return null;let R=(v*E+w)%x;R<0&&(R=x+R);const A=b[R].value??null;return S?A.toUpperCase():C?A.toLowerCase():A}}},s.Composite=class{constructor(a){a=Array.isArray(a)?[...a]:[a],this._fillers=a}canFill(a,l){return!0}createFillAt(a,l){const c=this._fillers;l={multiFill:a.length>1,...l};const h=a.length;let u=0,d=!1;for(let E=0;!d&&E<=h;E++)a[E]===null?u++:d=!0;let g=0;d=!1;for(let E=h-1;!d&&E>=u;E--)a[E]===null?g++:d=!0;const m=[];let f=null,_=null,p=[],S=u,C=0;const y=E=>{if(f&&f.max+1===S){const I=f.value;I.fillAt.push(E),f.max=S,I.length++,I.valuesLength++}else f={min:S,max:S,value:{fillAt:[E],start:S,length:1,valuesLength:h,blankInterval:0}};m.push(f)},b=h-g;for(S=u;S<b;){let E=a[S];if(E===null){S++;continue}_=null;let I,x=1,v=!1;for(let T=0;!v&&T<c.length+1;T++){const F=c[T];F&&(v=F.canFill(E,I),v&&(_=F))}if(!_){E!==null&&y(E),S++;continue}let R=0;C=0,I=E;do E=a[S+x],v=_.canFill(E,I),v&&(E!==null?(I=E,R>0&&(x-R===1?C=R:R!==C&&(C=0)),R=0):R++,x++);while(v&&S+x<b);p=[a[S]];const A=1+C,M=x-R;for(let T=A;T<M;T+=A)p.push(a[S+T]);if(p.length>0){const T=p.length,F=T+(T-1)*C,L=_.createFillAt?.(p,l)??p;m.push({min:S,max:S+F-1,value:{fillAt:L,start:S,length:F,valuesLength:T,blankInterval:C}})}S+=x}const w=gm(m);return E=>{const I=E>=0,x=Math.abs(E),v=mm(x%h,w);if(!v)return null;const R=Math.floor(x/h),A=v.length,M=v.start,T=(R+(I?1:0))*M+(R+(I?0:1))*(h-(M+A));let F=E+(I?-T:T);const L=v.blankInterval;if(L!==0){let P=F%A;if(P%(1+L)!==0)return null;F=Math.floor(P/(1+L))+v.valuesLength*R}const D=v.fillAt;return typeof D=="function"?D(F):D[F%D.length]}}},s.Types={Series:new s.Composite([new s.Date,new s.Linear,new s.Ordinal,new s.List]),DateDays:new s.Date({unit:ms}),DateMonths:new s.Date({unit:xh}),DateYears:new s.Date({unit:Ih}),Copy:new s.Copy},s.fillTo=(a,l,c,h)=>{const u=[],d=l.length,g=a.createFillAt(l,h);for(let m=d;m<c;m++)u.push(g(m));return u}})(exports.AutoFill||(exports.AutoFill={})),exports.IPrint=void 0,exports.IPrint||(exports.IPrint={}),exports.IFill=void 0,(_s=exports.IFill||(exports.IFill={})).Type={None:"none",Solid:"solid",Gradient:"gradient",Pattern:"pattern",Image:"pattern",Background:"background",Group:"group",Custom:"custom"},_s.GradientType={Linear:"linear",Path:"path",Circular:"circular",Rect:"rect"},_s.TileMirror={None:"none",Vertical:"v",Horizontal:"h",Both:"b"},_s.BuiltInSheetPattern={None:"none",Solid:"solid",DarkGray:"darkGray",MediumGray:"mediumGray",LightGray:"lightGray",Gray0625:"gray0625",Gray125:"gray125",DarkHorizontal:"darkHorizontal",DarkVertical:"darkVertical",DarkDown:"darkDown",DarkUp:"darkUp",DarkGrid:"darkGrid",DarkTrellis:"darkTrellis",LightHorizontal:"lightHorizontal",LightVertical:"lightVertical",LightDown:"lightDown",LightUp:"lightUp",LightGrid:"lightGrid",LightTrellis:"lightTrellis",Custom:"custom"},exports.IColor=void 0,(Ss=exports.IColor||(exports.IColor={})).AdjustmentType={Alpha:"alpha",AlphaOff:"alphaOff",AlphaMod:"alphaMod",Hue:"hue",Sat:"sat",Lum:"lum",HueOff:"hueOff",SatOff:"satOff",LumOff:"lumOff",HueMod:"hueMod",SatMod:"satMod",LumMod:"lumMod",Red:"red",Green:"green",Blue:"blue",RedOff:"redOff",GreenOff:"greenOff",BlueOff:"blueOff",RedMod:"redMod",GreenMod:"greenMod",BlueMod:"blueMod",Shade:"shade",Tint:"tint",ETint:"eTint",Gray:"gray",Comp:"comp",Inv:"inv",Gamma:"gamma",InvGamma:"invGamma"},Ss.Named={ActiveBorder:"activeBorder",ActiveCaption:"activeCaption",CaptionText:"captionText",AppWorkspace:"appWorkspace",BtnFace:"btnFace",BtnShadow:"btnShadow",DkShadow3d:"3dDkShadow",BtnHighlight:"btnHighlight",Light3d:"3dLight",BtnText:"btnText",Background:"background",GrayText:"grayText",Highlight:"highlight",HighlightText:"highlightText",HotLight:"hotLight",InactiveBorder:"inactiveBorder",InactiveCaption:"inactiveCaption",InactiveCaptionText:"inactiveCaptionText",InfoBk:"infoBk",InfoText:"infoText",Menu:"menu",MenuText:"menuText",ScrollBar:"scrollBar",Window:"window",WindowFrame:"windowFrame",WindowText:"windowText",Transparent:"transparent",AliceBlue:"aliceBlue",AntiqueWhite:"antiqueWhite",Aqua:"aqua",Aquamarine:"aquamarine",Azure:"azure",Beige:"beige",Bisque:"bisque",Black:"black",BlanchedAlmond:"blanchedAlmond",Blue:"blue",BlueViolet:"blueViolet",Brown:"brown",BurlyWood:"burlyWood",CadetBlue:"cadetBlue",Chartreuse:"chartreuse",Chocolate:"chocolate",Coral:"coral",CornflowerBlue:"cornflowerBlue",Cornsilk:"cornsilk",Crimson:"crimson",Cyan:"cyan",DkBlue:"dkBlue",DkCyan:"dkCyan",DkGoldenrod:"dkGoldenrod",DkGray:"dkGray",DkGreen:"dkGreen",DkKhaki:"dkKhaki",DkMagenta:"dkMagenta",DkOliveGreen:"dkOliveGreen",DkOrange:"dkOrange",DkOrchid:"dkOrchid",DkRed:"dkRed",DkSalmon:"dkSalmon",DkSeaGreen:"dkSeaGreen",DkSlateBlue:"dkSlateBlue",DkSlateGray:"dkSlateGray",DkTurquoise:"dkTurquoise",DkViolet:"dkViolet",DeepPink:"deepPink",DeepSkyBlue:"deepSkyBlue",DimGray:"dimGray",DodgerBlue:"dodgerBlue",Firebrick:"firebrick",FloralWhite:"floralWhite",ForestGreen:"forestGreen",Fuchsia:"fuchsia",Gainsboro:"gainsboro",GhostWhite:"ghostWhite",Gold:"gold",Goldenrod:"goldenrod",Gray:"gray",Green:"green",GreenYellow:"greenYellow",Honeydew:"honeydew",HotPink:"hotPink",IndianRed:"indianRed",Indigo:"indigo",Ivory:"ivory",Khaki:"khaki",Lavender:"lavender",LavenderBlush:"lavenderBlush",LawnGreen:"lawnGreen",LemonChiffon:"lemonChiffon",LtBlue:"ltBlue",LtCoral:"ltCoral",LtCyan:"ltCyan",LtGoldenrodYellow:"ltGoldenrodYellow",LtGray:"ltGray",LtGreen:"ltGreen",LtPink:"ltPink",LtSalmon:"ltSalmon",LtSeaGreen:"ltSeaGreen",LtSkyBlue:"ltSkyBlue",LtSlateGray:"ltSlateGray",LtSteelBlue:"ltSteelBlue",LtYellow:"ltYellow",Lime:"lime",LimeGreen:"limeGreen",Linen:"linen",Magenta:"magenta",Maroon:"maroon",MedAquamarine:"medAquamarine",MedBlue:"medBlue",MedOrchid:"medOrchid",MedPurple:"medPurple",MedSeaGreen:"medSeaGreen",MedSlateBlue:"medSlateBlue",MedSpringGreen:"medSpringGreen",MedTurquoise:"medTurquoise",MedVioletRed:"medVioletRed",MidnightBlue:"midnightBlue",MintCream:"mintCream",MistyRose:"mistyRose",Moccasin:"moccasin",NavajoWhite:"navajoWhite",Navy:"navy",OldLace:"oldLace",Olive:"olive",OliveDrab:"oliveDrab",Orange:"orange",OrangeRed:"orangeRed",Orchid:"orchid",PaleGoldenrod:"paleGoldenrod",PaleGreen:"paleGreen",PaleTurquoise:"paleTurquoise",PaleVioletRed:"paleVioletRed",PapayaWhip:"papayaWhip",PeachPuff:"peachPuff",Peru:"peru",Pink:"pink",Plum:"plum",PowderBlue:"powderBlue",Purple:"purple",Red:"red",RosyBrown:"rosyBrown",RoyalBlue:"royalBlue",SaddleBrown:"saddleBrown",Salmon:"salmon",SandyBrown:"sandyBrown",SeaGreen:"seaGreen",SeaShell:"seaShell",Sienna:"sienna",Silver:"silver",SkyBlue:"skyBlue",SlateBlue:"slateBlue",SlateGray:"slateGray",Snow:"snow",SpringGreen:"springGreen",SteelBlue:"steelBlue",Tan:"tan",Teal:"teal",Thistle:"thistle",Tomato:"tomato",Turquoise:"turquoise",Violet:"violet",Wheat:"wheat",White:"white",WhiteSmoke:"whiteSmoke",Yellow:"yellow",YellowGreen:"yellowGreen",ButtonFace:"buttonFace",ButtonHighlight:"buttonHighlight",ButtonShadow:"buttonShadow",GradientActiveCaption:"gradientActiveCaption",GradientInactiveCaption:"gradientInactiveCaption",MenuBar:"menuBar",MenuHighlight:"menuHighlight"},Ss.Scheme={Bg1:"bg1",Bg2:"bg2",Tx1:"tx1",Tx2:"tx2",Accent1:"accent1",Accent2:"accent2",Accent3:"accent3",Accent4:"accent4",Accent5:"accent5",Accent6:"accent6",Hlink:"hlink",FolHlink:"folHlink"},Ss.Type={Scheme:"scheme",Named:"named",Index:"index",HSL:"hsl",RGB:"rgb",LRGB:"lrgb",Hex:"hex"};const Zh=[[4290032820,1,exports.IColor.Named.ActiveBorder,!0],[4288263377,2,exports.IColor.Named.ActiveCaption,!0],[4278190080,3,exports.IColor.Named.CaptionText,!0],[4289440683,4,exports.IColor.Named.AppWorkspace,!0],[4293980400,5,exports.IColor.Named.BtnFace,!0],[4285098345,6,exports.IColor.Named.BtnShadow,!0],[4278190080,7,exports.IColor.Named.DkShadow3d,!0],[4293125091,8,exports.IColor.Named.BtnHighlight,!0],[4293125091,9,exports.IColor.Named.Light3d,!0],[4278190080,10,exports.IColor.Named.BtnText,!0],[4278190080,11,exports.IColor.Named.Background,!0],[4285361517,12,exports.IColor.Named.GrayText,!0],[4281571839,13,exports.IColor.Named.Highlight,!0],[4294967295,14,exports.IColor.Named.HighlightText,!0],[4278216396,15,exports.IColor.Named.HotLight,!0],[4294244348,16,exports.IColor.Named.InactiveBorder,!0],[4290760155,17,exports.IColor.Named.InactiveCaption,!0],[4278190080,18,exports.IColor.Named.InactiveCaptionText,!0],[4294967265,19,exports.IColor.Named.InfoBk,!0],[4278190080,20,exports.IColor.Named.InfoText,!0],[4293980400,21,exports.IColor.Named.Menu,!0],[4278190080,22,exports.IColor.Named.MenuText,!0],[4291348680,23,exports.IColor.Named.ScrollBar,!0],[4294967295,24,exports.IColor.Named.Window,!0],[4284769380,25,exports.IColor.Named.WindowFrame,!0],[4278190080,26,exports.IColor.Named.WindowText,!0],[16777215,27,exports.IColor.Named.Transparent],[4293982463,28,exports.IColor.Named.AliceBlue],[4294634455,29,exports.IColor.Named.AntiqueWhite],[4278255615,30,exports.IColor.Named.Aqua],[4286578644,31,exports.IColor.Named.Aquamarine],[4293984255,32,exports.IColor.Named.Azure],[4294309340,33,exports.IColor.Named.Beige],[4294960324,34,exports.IColor.Named.Bisque],[4278190080,35,exports.IColor.Named.Black],[4294962125,36,exports.IColor.Named.BlanchedAlmond],[4278190335,37,exports.IColor.Named.Blue],[4287245282,38,exports.IColor.Named.BlueViolet],[4289014314,39,exports.IColor.Named.Brown],[4292786311,40,exports.IColor.Named.BurlyWood],[4284456608,41,exports.IColor.Named.CadetBlue],[4286578432,42,exports.IColor.Named.Chartreuse],[4291979550,43,exports.IColor.Named.Chocolate],[4294934352,44,exports.IColor.Named.Coral],[4284782061,45,exports.IColor.Named.CornflowerBlue],[4294965468,46,exports.IColor.Named.Cornsilk],[4292613180,47,exports.IColor.Named.Crimson],[4278255615,48,exports.IColor.Named.Cyan],[4278190219,49,exports.IColor.Named.DkBlue],[4278225803,50,exports.IColor.Named.DkCyan],[4290283019,51,exports.IColor.Named.DkGoldenrod],[4289309097,52,exports.IColor.Named.DkGray],[4278215680,53,exports.IColor.Named.DkGreen],[4290623339,54,exports.IColor.Named.DkKhaki],[4287299723,55,exports.IColor.Named.DkMagenta],[4283788079,56,exports.IColor.Named.DkOliveGreen],[4294937600,57,exports.IColor.Named.DkOrange],[4288230092,58,exports.IColor.Named.DkOrchid],[4287299584,59,exports.IColor.Named.DkRed],[4293498490,60,exports.IColor.Named.DkSalmon],[4287609995,61,exports.IColor.Named.DkSeaGreen],[4282924427,62,exports.IColor.Named.DkSlateBlue],[4281290575,63,exports.IColor.Named.DkSlateGray],[4278243025,64,exports.IColor.Named.DkTurquoise],[4287889619,65,exports.IColor.Named.DkViolet],[4294907027,66,exports.IColor.Named.DeepPink],[4278239231,67,exports.IColor.Named.DeepSkyBlue],[4285098345,68,exports.IColor.Named.DimGray],[4280193279,69,exports.IColor.Named.DodgerBlue],[4289864226,70,exports.IColor.Named.Firebrick],[4294966e3,71,exports.IColor.Named.FloralWhite],[4280453922,72,exports.IColor.Named.ForestGreen],[4294902015,73,exports.IColor.Named.Fuchsia],[4292664540,74,exports.IColor.Named.Gainsboro],[4294506751,75,exports.IColor.Named.GhostWhite],[4294956800,76,exports.IColor.Named.Gold],[4292519200,77,exports.IColor.Named.Goldenrod],[4286611584,78,exports.IColor.Named.Gray],[4278222848,79,exports.IColor.Named.Green],[4289593135,80,exports.IColor.Named.GreenYellow],[4293984240,81,exports.IColor.Named.Honeydew],[4294928820,82,exports.IColor.Named.HotPink],[4291648604,83,exports.IColor.Named.IndianRed],[4283105410,84,exports.IColor.Named.Indigo],[4294967280,85,exports.IColor.Named.Ivory],[4293977740,86,exports.IColor.Named.Khaki],[4293322490,87,exports.IColor.Named.Lavender],[4294963445,88,exports.IColor.Named.LavenderBlush],[4286381056,89,exports.IColor.Named.LawnGreen],[4294965965,90,exports.IColor.Named.LemonChiffon],[4289583334,91,exports.IColor.Named.LtBlue],[4293951616,92,exports.IColor.Named.LtCoral],[4292935679,93,exports.IColor.Named.LtCyan],[4294638200,94,exports.IColor.Named.LtGoldenrodYellow],[4292072403,95,exports.IColor.Named.LtGray],[4287688336,96,exports.IColor.Named.LtGreen],[4294948545,97,exports.IColor.Named.LtPink],[4294942842,98,exports.IColor.Named.LtSalmon],[4280332970,99,exports.IColor.Named.LtSeaGreen],[4287090426,100,exports.IColor.Named.LtSkyBlue],[4286023833,101,exports.IColor.Named.LtSlateGray],[4289774814,102,exports.IColor.Named.LtSteelBlue],[4294967264,103,exports.IColor.Named.LtYellow],[4278255360,104,exports.IColor.Named.Lime],[4281519410,105,exports.IColor.Named.LimeGreen],[4294635750,106,exports.IColor.Named.Linen],[4294902015,107,exports.IColor.Named.Magenta],[4286578688,108,exports.IColor.Named.Maroon],[4284927402,109,exports.IColor.Named.MedAquamarine],[4278190285,110,exports.IColor.Named.MedBlue],[4290401747,111,exports.IColor.Named.MedOrchid],[4287852763,112,exports.IColor.Named.MedPurple],[4282168177,113,exports.IColor.Named.MedSeaGreen],[4286277870,114,exports.IColor.Named.MedSlateBlue],[4278254234,115,exports.IColor.Named.MedSpringGreen],[4282962380,116,exports.IColor.Named.MedTurquoise],[4291237253,117,exports.IColor.Named.MedVioletRed],[4279834992,118,exports.IColor.Named.MidnightBlue],[4294311930,119,exports.IColor.Named.MintCream],[4294960353,120,exports.IColor.Named.MistyRose],[4294960309,121,exports.IColor.Named.Moccasin],[4294958765,122,exports.IColor.Named.NavajoWhite],[4278190208,123,exports.IColor.Named.Navy],[4294833638,124,exports.IColor.Named.OldLace],[4286611456,125,exports.IColor.Named.Olive],[4285238819,126,exports.IColor.Named.OliveDrab],[4294944e3,127,exports.IColor.Named.Orange],[4294919424,128,exports.IColor.Named.OrangeRed],[4292505814,129,exports.IColor.Named.Orchid],[4293847210,130,exports.IColor.Named.PaleGoldenrod],[4288215960,131,exports.IColor.Named.PaleGreen],[4289720046,132,exports.IColor.Named.PaleTurquoise],[4292571283,133,exports.IColor.Named.PaleVioletRed],[4294963157,134,exports.IColor.Named.PapayaWhip],[4294957753,135,exports.IColor.Named.PeachPuff],[4291659071,136,exports.IColor.Named.Peru],[4294951115,137,exports.IColor.Named.Pink],[4292714717,138,exports.IColor.Named.Plum],[4289781990,139,exports.IColor.Named.PowderBlue],[4286578816,140,exports.IColor.Named.Purple],[4294901760,141,exports.IColor.Named.Red],[4290547599,142,exports.IColor.Named.RosyBrown],[4282477025,143,exports.IColor.Named.RoyalBlue],[4287317267,144,exports.IColor.Named.SaddleBrown],[4294606962,145,exports.IColor.Named.Salmon],[4294222944,146,exports.IColor.Named.SandyBrown],[4281240407,147,exports.IColor.Named.SeaGreen],[4294964718,148,exports.IColor.Named.SeaShell],[4288696877,149,exports.IColor.Named.Sienna],[4290822336,150,exports.IColor.Named.Silver],[4287090411,151,exports.IColor.Named.SkyBlue],[4285160141,152,exports.IColor.Named.SlateBlue],[4285563024,153,exports.IColor.Named.SlateGray],[4294966010,154,exports.IColor.Named.Snow],[4278255487,155,exports.IColor.Named.SpringGreen],[4282811060,156,exports.IColor.Named.SteelBlue],[4291998860,157,exports.IColor.Named.Tan],[4278222976,158,exports.IColor.Named.Teal],[4292394968,159,exports.IColor.Named.Thistle],[4294927175,160,exports.IColor.Named.Tomato],[4282441936,161,exports.IColor.Named.Turquoise],[4293821166,162,exports.IColor.Named.Violet],[4294303411,163,exports.IColor.Named.Wheat],[4294967295,164,exports.IColor.Named.White],[4294309365,165,exports.IColor.Named.WhiteSmoke],[4294967040,166,exports.IColor.Named.Yellow],[4288335154,167,exports.IColor.Named.YellowGreen],[4293980400,168,exports.IColor.Named.ButtonFace],[4294967295,169,exports.IColor.Named.ButtonHighlight],[4288716960,170,exports.IColor.Named.ButtonShadow],[4290367978,171,exports.IColor.Named.GradientActiveCaption],[4292338930,172,exports.IColor.Named.GradientInactiveCaption],[4293980400,173,exports.IColor.Named.MenuBar],[4281571839,174,exports.IColor.Named.MenuHighlight]],H0=new class{constructor(){this._lookupByName=new Map;for(let s=0;s<Zh.length;s++){const e=Zh[s],t=e[0],n=(t>>24&255)/255,r=t>>16&255,o=t>>8&255,i=255&t,a={id:e[1],name:e[2],rgbaColor:{r,g:o,b:i,a:n},system:e.length>3};this._lookupByName.set(a.name.toLowerCase(),a)}}valueOfName(s){return this._lookupByName.get(s?s.toLowerCase():"transparent")}},Ma=[{scheme:exports.IColor.Scheme.Tx1,description:"First Text Color"},{scheme:exports.IColor.Scheme.Tx2,description:"Second Text Color"},{scheme:exports.IColor.Scheme.Bg1,description:"First Background Color"},{scheme:exports.IColor.Scheme.Bg2,description:"Second Background Color"},{scheme:exports.IColor.Scheme.Accent1,description:"Accent 1"},{scheme:exports.IColor.Scheme.Accent2,description:"Accent 2"},{scheme:exports.IColor.Scheme.Accent3,description:"Accent 3"},{scheme:exports.IColor.Scheme.Accent4,description:"Accent 4"},{scheme:exports.IColor.Scheme.Accent5,description:"Accent 5"},{scheme:exports.IColor.Scheme.Accent6,description:"Accent 6"},{scheme:exports.IColor.Scheme.Hlink,description:"Hyperlink"},{scheme:exports.IColor.Scheme.FolHlink,description:"Followed Hyperlink"},{scheme:"dk1",description:"Text/Background - Dark 1"},{scheme:"lt1",description:"Text/Background - Light 1"},{scheme:"dk2",description:"Text/Background - Dark 2"},{scheme:"lt2",description:"Text/Background - Light 2"}],fm=new Map;for(let s=0;s<Ma.length;s++)fm.set(Ma[s].scheme.toLowerCase(),Ma[s]);const eu=s=>s?{srgb:[s.red/255,s.green/255,s.blue/255],alpha:s.alpha!==void 0?s.alpha:1}:null,tu=function(s,e,t,n){let r=eu((c=>{let h=H0.valueOfName(c);return h?new dn.RGBA(h.rgbaColor.r,h.rgbaColor.g,h.rgbaColor.b,h.rgbaColor.a):null})(s)),o=null,i=null,a=null;if(r===null&&(l=s,fm.get(l.toLowerCase()))){if(!e)throw new Error("a scheme val was used but a schemeLookup was not provided");o=s,i=e(o),r=eu(i),a=exports.IColor.Type.Scheme}var l;if(r===null){let c=s.match(Gp)||s.match($p);if(c){let h,u=1;c.length===4?h=[parseInt(c[1],16),parseInt(c[2],16),parseInt(c[3],16)]:(h=[parseInt(c[2],16),parseInt(c[3],16),parseInt(c[4],16)],u=Mr(parseInt(c[1],16)/255)),h=Sa(h),h=ot(h),r={srgb:h,alpha:u},a=exports.IColor.Type.Hex}}if(r===null){let c=s.match(Pp)||s.match(zp);if(c){let h=_a(c[1],c[2],c[3]);h=Sa(h),h=ot(h),r={srgb:h,alpha:c[4]?Mr(parseFloat(c[4])):1},a=exports.IColor.Type.RGB}}if(r===null){let c=s.match(Wp)||s.match(jp);if(c){let h=_a(c[1],c[2],c[3]);h=Sa(h,100),h=or(h),h=ot(h),r={srgb:h,alpha:c[4]?Mr(parseFloat(c[4])):1},a=exports.IColor.Type.LRGB}}if(r===null){let c=s.match(Hp)||s.match(Vp);if(c){let h=_a(c[1],c[2],c[3]);h=sr(h),h=ot(h),r={srgb:h,alpha:c[4]?Mr(parseFloat(c[4])):1},a=exports.IColor.Type.HSL}}if(r===null){let c=s.match(Up);if(c){const h=parseInt(c[1]);let u=t?.(h)??vi(h);u&&(r={srgb:[u.red/255,u.green/255,u.blue/255],alpha:u.alpha},a=exports.IColor.Type.Index)}}if(r===null)throw new Error("Not a valid color format: "+s);return{srgbAlpha:r,key:o,color:i,type:a}},Dl=new Map,Ta=Object.keys(exports.IColor.AdjustmentType);for(let s=0;s<Ta.length;s++)Dl.set(exports.IColor.AdjustmentType[Ta[s]].toLowerCase(),exports.IColor.AdjustmentType[Ta[s]]);const nu=new RegExp("\\s+\\s*(?![^()]*\\))|,\\s*(?![^()]*\\))"),ru=new RegExp("\\s*[,]\\s*|\\s+");let Fa=null;const ou={[exports.IColor.Scheme.Bg1]:"window",[exports.IColor.Scheme.Bg2]:"E7E6E6",[exports.IColor.Scheme.Tx1]:"windowText",[exports.IColor.Scheme.Tx2]:"44546A",[exports.IColor.Scheme.Accent1]:"4472C4",[exports.IColor.Scheme.Accent2]:"ED7D31",[exports.IColor.Scheme.Accent3]:"A5A5A5",[exports.IColor.Scheme.Accent4]:"FFC000",[exports.IColor.Scheme.Accent5]:"5B9BD5",[exports.IColor.Scheme.Accent6]:"70AD47",[exports.IColor.Scheme.Hlink]:"0563C1",[exports.IColor.Scheme.FolHlink]:"954F72"};class Ge{constructor(e,t,n,r=null){let o=null,i=null;if(e instanceof Ge)o=e.getVal(),e.getAdjustments()&&(i=[...e.getAdjustments()]);else if(typeof e=="string"){const a=this._parse(e);o=a.val,i=a.adjs}else e?.val&&(o=e.val,i=e.adjs);if(!o)throw new Error("Unable to determine color value");this._private={val:o,adjs:i,schemeLookup:t,indexedLookup:n,parsedVal:tu(o,t,n),adjusted:null,resolved:null}}_parse(e){let t=null,n=e.toLowerCase().trim();const r=n.split(nu);if(r&&(t=r[0],n=n.substring(t.length,n.length).trim()),!t)throw new Error("no color key found");const o=[],i=n.split(ru);for(let a=0;a<i.length;a++){const l=i[a];if(!l)continue;const c=Dl.get(l.toLowerCase());if(!c)throw new Error("Invalid adjustment type:"+l);let h=null;if(!(c===exports.IColor.AdjustmentType.Gray||c===exports.IColor.AdjustmentType.Comp||c===exports.IColor.AdjustmentType.Inv||c===exports.IColor.AdjustmentType.Gamma||c===exports.IColor.AdjustmentType.InvGamma)){a++;const u=i[a];if(h=parseFloat(u),h==null)throw new Error(`Invalid adjustment value: missing value for'${l}'`);if(isNaN(h))throw new Error("Invalid adjustment value:"+u)}o.push({[c]:h})}return{val:t,adjs:o}}_forceDark(e=!0){this._resolve();const t=this._private.resolved;let n=[t.red,t.green,t.blue];n=((a,l)=>{l=(l%360+360)%360;const c=[1,0,0,0,1,0,0,0,1],h=Math.cos(l*Math.PI/180),u=Math.sin(l*Math.PI/180);c[0]=fr+.7874*h-fr*u,c[1]=Rn-Rn*h-Rn*u,c[2]=pr-pr*h+.9278*u,c[3]=fr-fr*h+.143*u,c[4]=Rn+(1-Rn)*h+.14*u,c[5]=pr-pr*h-.283*u,c[6]=fr-fr*h-.7874*u,c[7]=Rn-Rn*h+Rn*u,c[8]=pr+.9278*h+pr*u;const d=_=>Math.round(Math.max(0,Math.min(255,_))),g=a[0],m=a[1],f=a[2];return[d(c[0]*g+c[1]*m+c[2]*f),d(c[3]*g+c[4]*m+c[5]*f),d(c[6]*g+c[7]*m+c[8]*f)]})(n,180),n=yh(n,!1);let r=nr(n);const o=zn(r);if(o[ro]=.95*o[ro],r=sr(o),n=or(r),n=wh(n),n=ot(n,!1),e)return new dn.RGBA(n[0],n[1],n[2],t.alpha);const i=zn(nr(n));return new dn.HSLA(i[0],i[1],i[2],t.alpha)}_resolve(){if(this._private.resolved){if(!this._private.parsedVal.key)return;let o=this._private.schemeLookup(this._private.parsedVal.key);if(o===this._private.parsedVal.color||o?.isEqual(this._private.parsedVal.color))return}const e=tu(this._private.val,this._private.schemeLookup,this._private.indexedLookup,this._private.last);let t=((o,i)=>{let a=[...o.srgb],l=o.alpha!==void 0?o.alpha:1;for(var c=0;i&&c<i.length;c++){const h=i[c],u=Object.keys(h)[0],d=h[u];u===exports.IColor.AdjustmentType.Alpha?(l=d/100,l=Math.max(0,Math.min(1,l))):u===exports.IColor.AdjustmentType.AlphaOff?(l+=d/100,l=Math.max(0,Math.min(1,l))):u===exports.IColor.AdjustmentType.AlphaMod?(l*=d/100,l=Math.max(0,Math.min(1,l))):u===exports.IColor.AdjustmentType.Hue?a=Ca(rt,a,d):u===exports.IColor.AdjustmentType.Sat?a=Ca(ya,a,d):u===exports.IColor.AdjustmentType.Lum?a=Ca(ro,a,d):u===exports.IColor.AdjustmentType.HueOff?a=ba(rt,a,d):u===exports.IColor.AdjustmentType.SatOff?a=ba(ya,a,d):u===exports.IColor.AdjustmentType.LumOff?a=ba(ro,a,d):u===exports.IColor.AdjustmentType.HueMod?a=Ea(rt,a,d):u===exports.IColor.AdjustmentType.SatMod?a=Ea(ya,a,d):u===exports.IColor.AdjustmentType.LumMod?a=Ea(ro,a,d):u===exports.IColor.AdjustmentType.Red?a=tn(qs,a,d,Xs):u===exports.IColor.AdjustmentType.Green?a=tn(Js,a,d,Xs):u===exports.IColor.AdjustmentType.Blue?a=tn(Ks,a,d,Xs):u===exports.IColor.AdjustmentType.RedOff?a=tn(qs,a,d,Ys):u===exports.IColor.AdjustmentType.GreenOff?a=tn(Js,a,d,Ys):u===exports.IColor.AdjustmentType.BlueOff?a=tn(Ks,a,d,Ys):u===exports.IColor.AdjustmentType.RedMod?a=tn(qs,a,d,Qs):u===exports.IColor.AdjustmentType.GreenMod?a=tn(Js,a,d,Qs):u===exports.IColor.AdjustmentType.BlueMod?a=tn(Ks,a,d,Qs):u===exports.IColor.AdjustmentType.Shade?a=qp(a,d):u===exports.IColor.AdjustmentType.Tint?a=Kp(a,d):u===exports.IColor.AdjustmentType.ETint?a=Jp(a,d):u===exports.IColor.AdjustmentType.Gray?a=Xp(a):u===exports.IColor.AdjustmentType.Comp?a=Yp(a):u===exports.IColor.AdjustmentType.Inv?a=yh(a,d):u===exports.IColor.AdjustmentType.Gamma?a=Qp(a):u===exports.IColor.AdjustmentType.InvGamma?a=Zp(a):console.warn("unknown adjustmentType: "+u)}return{srgb:a,alpha:l}})(e.srgbAlpha,this._private.adjs),n=((o,i=255)=>{const a=[...o];for(var l=0;l<o.length;l++)a[l]=o[l]*i;return a})(t.srgb);n=wh(n);let r=Mr(t.alpha);this._private.adjusted=t,this._private.parsedVal=e,this._private.resolved=new dn.RGBA(n[0],n[1],n[2],r)}static parse(e,t,n,r=null){if(e instanceof Ge)return e;const o=e;let i=null,a=o?.trim(),l=null;try{if(!i){const u=a?.split(nu);u&&(i=u[0],a=a.substring(i.length,a.length).trim())}if(!i)throw new Error("no color found");const c=[],h=a.split(ru);for(let u=0;u<h.length;u++){const d=h[u];if(!d)continue;const g=Dl.get(d.toLowerCase());if(!g)throw new Error("Invalid adjustment type:"+d);let m=null;if(!(g===exports.IColor.AdjustmentType.Gray||g===exports.IColor.AdjustmentType.Comp||g===exports.IColor.AdjustmentType.Inv||g===exports.IColor.AdjustmentType.Gamma||g===exports.IColor.AdjustmentType.InvGamma)){u++;const f=h[u];if(m=parseFloat(f),m==null)throw new Error(`Invalid adjustment value: missing value for'${d}'`);if(isNaN(m))throw new Error("Invalid adjustment value:"+f)}c.push({[g]:m})}l=new Ge({val:i,adjs:c},t,n,r)}catch(c){throw c}return l}static getDefaultSchemeLookup(){if(!Fa){const e=new Map,t=Object.keys(ou);for(let n=0;n<t.length;n++){const r=t[n];e.set(r.toLowerCase(),Ge.parse(ou[r],null))}Fa=n=>e.get(n.toLowerCase())?.toRGBA()}return Fa}isEqual(e){return e instanceof Ge&&this.toString().toLowerCase()===e.toString().toLowerCase()}getVal(){return this._private.val}getAdjustments(){return this._private.adjs}adjust(e){return new Ge({val:this._private.val,adjs:this._private.adjs?this._private.adjs.concat(e):e},this._private.schemeLookup,this._private.indexedLookup,this._private.last)}getType(){return this._resolve(),this._private.parsedVal.type??null}toCSS(e=!1,t=!0){const n=e?this._forceDark():this.toRGBA();return n.alpha===0?"none":n.toString(t)}toRGBA(e=!1){return this._resolve(),e?this._forceDark():this._private.resolved}toHSLA(e=!1){if(this._resolve(),e)return this._forceDark(!1);let t=zn(this._private.adjusted.srgb);return new dn.HSLA(t[0],t[1],t[2],Mr(this._private.adjusted.alpha??1))}toHex(e=!1){this._resolve();const t=e?this._forceDark():this._private.resolved;return new dn.HEX(t.red,t.green,t.blue,t.alpha??1)}toBlackOrWhite(e=!1,t=157){const n=this.toRGBA(e),r=.299*n.red+.587*n.green+.114*n.blue>t;return new Ge(r?"#000000":"#FFFFFF",this._private.schemeLookup,this._private.indexedLookup,this._private.last)}get[Symbol.toStringTag](){return this.toString()}toString(){let e=this._private.val;const t=this._private.adjs;for(let n=0;t&&n<t.length;n++){const r=t[n];if(!r)continue;const o=Object.keys(r)[0];e+=" "+o;const i=r[o];typeof i=="number"&&(e+=" "+i),n<t.length-1&&(e+=",")}return e}get isIColor(){return!0}}var su;exports.IBorder=void 0,(su=exports.IBorder||(exports.IBorder={})).StrokeStyle={None:"none",DashDot:"dashDot",MediumDashDot:"mediumDashDot",Dotted:"dotted",Hair:"hair",Thin:"thin",Medium:"medium",Thick:"thick",MediumDashDotDot:"mediumDashDotDot",DashDotDot:"dashDotDot",Dashed:"dashed",MediumDashed:"mediumDashed",SlantDashDot:"slantDashDot",Double:"double"},su.Edge={Left:"left",Top:"top",Right:"right",Bottom:"bottom",Horizontal:"horizontal",Vertical:"vertical",DiagonalUp:"diagonalUp",DiagonalDown:"diagonalDown"};const pm=[],_m=new Map,iu=Object.freeze([[exports.IBorder.StrokeStyle.Thin,"Thin",1,null],[exports.IBorder.StrokeStyle.Hair,"Hair",1,[1,1]],[exports.IBorder.StrokeStyle.Dotted,"Dotted",1,[2,2]],[exports.IBorder.StrokeStyle.Dashed,"Dashed",1,[3,1]],[exports.IBorder.StrokeStyle.DashDot,"Dash Dot",1,[3,3,9,3]],[exports.IBorder.StrokeStyle.DashDotDot,"Dash Dot Dot",1,[3,3,3,3,9,3]],[exports.IBorder.StrokeStyle.Double,"Double",3,null],[exports.IBorder.StrokeStyle.Medium,"Medium",2,null],[exports.IBorder.StrokeStyle.MediumDashed,"Medium Dashed",2,[9,3]],[exports.IBorder.StrokeStyle.MediumDashDot,"Medium Dash Dot",2,[3,3,9,3]],[exports.IBorder.StrokeStyle.MediumDashDotDot,"Medium Dash Dot Dot",2,[3,3,3,3,9,3]],[exports.IBorder.StrokeStyle.SlantDashDot,"Slant Dash Dot",2,[5,1,11,1]],[exports.IBorder.StrokeStyle.Thick,"Thick",3,null],[exports.IBorder.StrokeStyle.None,"None",0,null]]);for(let s=0;s<iu.length;s++){const e=iu[s],t=e[0],n=Object.freeze({style:t,description:e[1],width:e[2],pattern:e[3]});pm.push(n),_m.set(t,n)}(s=>{s.isEqualStrokes=(e,t)=>!(e&&!t||t&&!e)&&(e===t||e.getStyle()===t.getStyle()&&e.getColor().isEqual(t.getColor())),s.oppositeEdge=e=>e===s.Edge.Left?s.Edge.Right:e===s.Edge.Right?s.Edge.Left:e===s.Edge.Top?s.Edge.Bottom:e===s.Edge.Bottom?s.Edge.Top:e,s.BuiltInDefinitionsArray=pm,s.BuiltInDefinitions=_m})(exports.IBorder||(exports.IBorder={}));const V0={Text:"text",Repeat:"repeat",Spacing:"spacing"},au=s=>!(!s.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/)&&!s.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/)),G0=Object.freeze({formatValue:ic,isFractionFormat:au,adjustDecimalPlaces:(s,e)=>{if(!s)return"";const t=(i,a)=>{let l=i||"";const c=l.length===0||l.endsWith(".")?"0":l.charAt(l.length-1);return a<0?(l=l.substring(0,Math.max(0,l.length+a)),l==="."&&(l="")):(l.startsWith(".")||(l+="."),l+=c.repeat(a)),l},n=(i,a)=>{if(i==="General")return a>0?"0"+t("",a):i;if(au(i))return i;let l=i,c=-1,h=-1,u=l.indexOf("E");if(u>=0&&(l=l.substring(0,u)),c=l.indexOf("."),c>=0){l=l.substring(c,l.length);let d=l&&l.match(/([.]{1}[0,#]+)/);if(!d)return i;l=d[1],h=c+l.length}else{if(a<=0)return i;c=l.lastIndexOf("0"),c<0&&(c=l.lastIndexOf("#")),c>=0&&(c+=1),h=c,l=""}return c===-1?i:(l=t(l,a),i.substring(0,c)+l+i.substring(h,i.length))},r=[];let o=o0(s);for(let i=0;i<o.length;i++)r.push(n(o[i].trim(),e));return r.join(";")}}),$0=Ve._table,gc=s=>s===14?"Short Date":$0[s]??null,oo=[{numberFormat:"General",formatType:ae.General,primary:1},{numberFormat:"0",formatType:ae.Number,regMatch:/^0[.]{0,1}[0]*$/,args:{decimalPlaces:0,separator:!1}},{numberFormat:"#,##0.00",formatType:ae.Number,regMatch:/^#,##0[.]{0,1}[0]*$/,primary:2,args:{decimalPlaces:2,separator:!0}},{numberFormat:"#,##0_);(#,##0)",formatType:ae.Number,args:{decimalPlaces:0,separator:!0}},{numberFormat:"#,##0_);[Red](#,##0)",formatType:ae.Number,args:{decimalPlaces:0,separator:!0}},{numberFormat:"#,##0.00_);(#,##0.00)",formatType:ae.Number,args:{decimalPlaces:2,separator:!0}},{numberFormat:"#,##0.00_);[Red](#,##0.00)",formatType:ae.Number,args:{decimalPlaces:2,separator:!0}},{numberFormat:"$#,##0.00",formatType:ae.Currency,primary:3,args:{decimalPlaces:2,currencySymbol:"$"}},{numberFormat:"$#,##0_);($#,##0)",formatType:ae.Currency,args:{decimalPlaces:0,currencySymbol:"$"}},{numberFormat:"$#,##0_);[Red]($#,##0)",formatType:ae.Currency,args:{decimalPlaces:0,currencySymbol:"$"}},{numberFormat:"$#,##0.00_);($#,##0.00)",formatType:ae.Currency,args:{decimalPlaces:2,currencySymbol:"$"}},{numberFormat:"$#,##0.00_);[Red]($#,##0.00)",formatType:ae.Currency,args:{decimalPlaces:2,currencySymbol:"$"}},{numberFormat:'_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)',primary:4,formatType:ae.Accounting},{numberFormat:'_($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)',formatType:ae.Accounting},{numberFormat:'_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)',formatType:ae.Accounting},{numberFormat:'_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)',formatType:ae.Accounting},{numberFormat:"Short Date",formatType:ae.ShortDate,primary:5},{numberFormat:"d-mmm-yy",formatType:ae.MediumDate,primary:5.5},{numberFormat:"Long Date",formatType:ae.LongDate,primary:6},{numberFormat:"h:mm",formatType:ae.ShortTime,primary:7},{numberFormat:"h:mm AM/PM",formatType:ae.MediumTime,primary:7.5},{numberFormat:"Long Time",formatType:ae.LongTime,primary:8},{numberFormat:'_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)',formatType:ae.Comma,primary:9},{numberFormat:"0.00%",formatType:ae.Percentage,primary:10,args:{decimalPlaces:2},regMatch:/^^[0#?]*[.]{0,1}[0#?]*%*$/},{numberFormat:"0%",formatType:ae.Percentage,args:{decimalPlaces:0}},{numberFormat:"# ?/?",formatType:ae.Fraction,primary:11},{numberFormat:"# ??/??",formatType:ae.Fraction},{numberFormat:"0.00E+00",formatType:ae.Scientific,primary:12,args:{decimalPlaces:2},regMatch:/^[0#?]*[.]{0,1}[0#?]*E\+[0#?]*$/},{numberFormat:"##0.0E+0",formatType:ae.Custom,args:{decimalPlaces:0}},{numberFormat:"@",formatType:ae.Text,primary:13},{numberFormat:"d-mmm",formatType:ae.Custom},{numberFormat:"mmm-yy",formatType:ae.Custom},{numberFormat:"h:mm:ss",formatType:ae.Custom},{numberFormat:"m/d/yyyy h:mm",formatType:ae.Custom},{numberFormat:"mm:ss",formatType:ae.Custom},{numberFormat:"mm:ss.0",formatType:ae.Custom},{numberFormat:"[h]:mm:ss",formatType:ae.Custom}],Na=[{numberFormat:"00000",formatType:ae.Special,primary:11},{numberFormat:"00000-0000",formatType:ae.Special},{numberFormat:"[<=9999999]###-####;(###) ###-####",formatType:ae.Special},{numberFormat:"000-00-0000",formatType:ae.Special}],es=new Map,Io=[];for(let s=0;s<oo.length;s++){let e=oo[s].numberFormat.toLowerCase();es.set(e,oo[s]),oo[s].regMatch&&Io.unshift(oo[s])}for(let s=0;s<Na.length;s++){let e=Na[s].numberFormat.toLowerCase();es.set(e,Na[s])}const Ll=[],Sm=new Map;es.forEach(function(s,e,t){s.primary&&(Ll.push(s),Sm.set(N.textToKey(s.formatType),s.numberFormat))}),Ll.sort(function(s,e){return s.primary-e.primary});const lu=es.get(ae.General.toLowerCase());class U0{lookupStyle(e){if(!e)return lu;if(typeof e=="number"&&(e=gc(e)),!e.toLowerCase)return console.warn("Invalid numberFormat",e),lu;e=e.toLowerCase();let t=es.get(e);if(t)return t;for(let n=0;!t&&n<Io.length;n++)Io[n].regMatch&&e.match(Io[n].regMatch)&&(t=Io[n]);return t||{numberFormat:e,formatType:ae.Custom}}lookupPrimary(){return Ll}lookupDefault(e){return Sm.get(N.textToKey(e))}}var ws,cu;exports.NumberFormat=void 0,(ws=exports.NumberFormat||(exports.NumberFormat={})).Type=ae,ws.Parser=G0,ws.Styles=new U0,ws.ParseRunType=V0,exports.IStyle=void 0,(cu=exports.IStyle||(exports.IStyle={})).BuiltInName={Normal:"Normal",RowLevel:"RowLevel_#",ColLevel:"ColLevel_#",Comma:"Comma",Currency:"Currency",Percent:"Percent",Comma0:"Comma [0]",Currency0:"Currency [0]",Hyperlink:"Hyperlink",FollowedHyperlink:"Followed Hyperlink",Note:"Note",WarningText:"Warning Text",Unknown12:"??-12",Unknown13:"??-13",Unknown14:"??-14",Title:"Title",Heading1:"Heading 1",Heading2:"Heading 2",Heading3:"Heading 3",Heading4:"Heading 4",Input:"Input",Output:"Output",Calculation:"Calculation",CheckCell:"Check Cell",LinkedCell:"Linked Cell",Total:"Total",Good:"Good",Bad:"Bad",Neutral:"Neutral",Accent1:"Accent1",Accent1_20:"20% - Accent1",Accent1_40:"40% - Accent1",Accent1_60:"60% - Accent1",Accent2:"Accent2",Accent2_20:"20% - Accent2",Accent2_40:"40% - Accent2",Accent2_60:"60% - Accent2",Accent3:"Accent3",Accent3_20:"20% - Accent3",Accent3_40:"40% - Accent3",Accent3_60:"60% - Accent3",Accent4:"Accent4",Accent4_20:"20% - Accent4",Accent4_40:"40% - Accent4",Accent4_60:"60% - Accent4",Accent5:"Accent5",Accent5_20:"20% - Accent5",Accent5_40:"40% - Accent5",Accent5_60:"60% - Accent5",Accent6:"Accent6",Accent6_20:"20% - Accent6",Accent6_40:"40% - Accent6",Accent6_60:"60% - Accent6",ExplanatoryText:"Explanatory Text"},cu.IconSet={Arrows3:"3Arrows",ArrowsGray3:"3ArrowsGray",Flags3:"3Flags",Signs3:"3Signs",Symbols3:"3Symbols",Symbols3_2:"3Symbols2",TrafficLights3:"3TrafficLights1",TrafficLights3_2:"3TrafficLights2",Arrows4:"4Arrows",ArrowsGray4:"4ArrowsGray",Rating4:"4Rating",RedToBlack4:"4RedToBlack",TrafficLights4:"4TrafficLights",Arrows5:"5Arrows",ArrowsGray5:"5ArrowsGray",Quarters5:"5Quarters",Rating5:"5Rating"};const q0=(s,e,t,n,r)=>{const o=JSON.parse(JSON.stringify(s.definition));o.adjs||(o.adjs=[]);let i="",a=0,l=0;e>0?(l=e,a=100-e,i=`Lighter ${e}%`):e<0&&(a=100+e,i=`Darker ${-e}%`),a&&o.adjs.push({[exports.IColor.AdjustmentType.LumMod]:a}),l&&o.adjs.push({[exports.IColor.AdjustmentType.LumOff]:l});const c=new Ge({val:o.val,adjs:o.adjs},t),h=c.toString();n?.set(h,c);const u=c.toRGBA().toString();return r?.set(u,c),{description:s.description+", "+i,definition:o}},J0=(s,e,t,n)=>{let r=[];for(let o=0;o<s.length;o++){let i=[];r.push(i);const a=c=>{for(let h=0;h<c.length;h++)i.push(q0(s[o],c[h],e,t,n))};let l=new Ge({val:s[o].definition.val,adjs:s[o].definition.adjs},e).toHSLA().lum;a(l===0?[50,35,25,15,5]:l===100?[-5,-15,-25,-35,-50]:l<=20?[90,75,50,25,10]:l>=80?[-10,-25,-50,-75,-90]:[80,60,40,-25,-50])}return r};exports.ITheme=void 0,(exports.ITheme||(exports.ITheme={})).buildPalette=J0,exports.IThemeCollection=void 0,(exports.IThemeCollection||(exports.IThemeCollection={})).BuiltInSearchType={BuiltIn:"builtIn",All:"all",Custom:"custom"};const K0=[["Office","windowText","window","0E2841","E8E8E8","156082","E97132","196B24","0F9ED5","A02B93","4EA72E","467886","96607D"],["Office 2013-2022","windowText","window","44546A","E7E6E6","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47","0563C1","954F72"],["Office 2007-2010","windowText","window","1F497D","EEECE1","4F81BD","C0504D","9BBB59","8064A2","4BACC6","F79646","0000FF","800080"],["Grayscale","windowText","window","000000","F8F8F8","DDDDDD","B2B2B2","969696","808080","5F5F5F","4D4D4D","5F5F5F","919191"],["Atlas","windowText","window","454545","E0E0E0","F81B02","FC7715","AFBF41","50C49F","3B95C4","B560D4","FC5A1A","B49E74"],["Banded","2C2C2C","FFFFFF","099BDD","F2F2F2","FFC000","A5D028","08CC78","F24099","828288","F56617","005DBA","6C606A"],["Basis","000000","FFFFFF","565349","DDDDDD","A6B727","DF5327","FE9E00","418AB3","D7D447","818183","F59E00","B2B2B2"],["Berlin","windowText","window","9D360E","E7E6E6","F09415","C1B56B","4BAF73","5AA6C0","D17DF9","FA7E5C","FFAE3E","FCC77E"],["Celestial","windowText","window","18276C","EBEBEB","AC3EC1","477BD1","46B298","90BA4C","DD9D31","E25247","C573D2","CCAEE8"],["Circuit","windowText","window","134770","82FFFF","9ACD4C","FAA93A","D35940","B258D3","63A0CC","8AC4A7","B8FA56","7AF8CC"],["Damask","windowText","window","2A5B7F","ABDAFC","9EC544","50BEA3","4A9CCC","9A66CA","C54F71","DE9C3C","6BA9DA","A0BCD3"],["Depth","windowText","window","455F51","94D7E4","41AEBD","97E9D5","A2CF49","608F3D","F4DE3A","FCB11C","FBCA98","D3B86D"],["Dividend","windowText","window","3D3D3D","EBEBEB","4D1434","903163","B2324B","969FA7","66B1CE","40619D","828282","A5A5A5"],["Droplet","windowText","window","355071","AABED7","2FA3EE","4BCAAD","86C157","D99C3F","CE6633","A35DD1","56BCFE","97C5E3"],["Facet","windowText","window","2C3C43","EBEBEB","90C226","54A021","E6B91E","E76618","C42F1A","918655","99CA3C","B9D181"],["Frame","000000","FFFFFF","545454","BFBFBF","40BAD2","FAB900","90BB23","EE7008","1AB39F","D5393D","90BB23","EE7008"],["Gallery","windowText","window","454545","DFDBD5","B71E42","DE478E","BC72F0","795FAF","586EA6","6892A0","FA2B5C","BC658E"],["Integral","windowText","window","335B74","DFE3E5","1CADE4","2683C6","27CED7","42BA97","3E8853","62A39F","6B9F25","B26B02"],["Ion Boardroom","windowText","window","3B3059","EBEBEB","B31166","E33D6F","E45F3C","E9943A","9B6BF2","D53DD0","8F8F8F","A5A5A5"],["Ion","windowText","window","1E5155","EBEBEB","B01513","EA6312","E6B729","6AAC90","54849A","9E5E9B","58C1BA","9DFFCB"],["Madison","windowText","window","1F2D29","C5FAEB","A1D68B","5EC795","4DADCF","CDB756","E29C36","8EC0C1","6D9D9B","6D8583"],["Main Event","windowText","window","424242","C8C8C8","B80E0F","A6987D","7F9A71","64969F","9B75B2","80737A","F21213","B6A394"],["Mesh","windowText","window","363D46","EBEBEB","6F6F6F","BFBFA5","DCD084","E7BF5F","E9A039","CF7133","F28943","F1B76C"],["Metropolitan","windowText","window","162F33","EAF0E0","50B4C8","A8B97F","9B9256","657689","7A855D","84AC9D","2370CD","877589"],["Organic","windowText","window","212121","DADADA","83992A","3C9770","44709D","A23C33","D97828","DEB340","A8BF4D","B4CA80"],["Parallax","windowText","window","212121","CDD0D1","30ACEC","80C34F","E29D3E","D64A3B","D64787","A666E1","3085ED","82B6F4"],["Parcel","000000","FFFFFF","4A5356","E8E3CE","F6A21D","9BAFB5","C96731","9CA383","87795D","A0988C","00B0F0","738F97"],["Quotable","windowText","window","212121","636363","00C6BB","6FEBA0","B6DF5E","EFB251","EF755F","ED515C","8F8F8F","A5A5A5"],["Retrospect","000000","window","637052","CCDDEA","E48312","BD582C","865640","9B8357","C2BC80","94A088","2998E3","8C8C8C"],["Savon","windowText","window","1485A4","E3DED1","1CADE4","2683C6","27CED7","42BA97","3E8853","62A39F","F49100","739D9B"],["Slate","windowText","window","212123","DADADA","BC451B","D3BA68","BB8640","AD9277","A55A43","AD9D7B","E98052","F4B69B"],["Slice","windowText","window","146194","76DBF4","052F61","A50E82","14967C","6A9E1F","E87D37","C62324","0D2E46","356A95"],["Vapor Trail","windowText","window","454545","DADADA","DF2E28","FE801A","E9BF35","81BB42","32C7A9","4A9BDC","F0532B","F38B53"],["View","000000","FFFFFF","46464A","D6D3CC","6F6F74","92A9B9","A7B789","B9A489","8D6374","9B7362","67AABF","ABAFA5"],["Wisp","windowText","window","766F54","E3EACF","A53010","DE7E18","9F8351","728653","92AA4C","6AAC91","FB4A18","FB9318"],["Wood Type","windowText","window","696464","E9E5DC","D34817","9B2D1F","A28E6A","956251","918485","855D5D","CC9900","96A9A9"]],X0=[["Office","Calibri Light","Calibri"],["Office 2013-2022","Calibri Light","Calibri"],["Office 2007-2010","Calibri Light","Calibri"],["Grayscale","Calibri Light","Calibri"],["Atlas","Calibri Light","Rockwell"],["Banded","Corbel","Corbel"],["Basis","Corbel","Corbel"],["Berlin","Trebuchet MS","Trebuchet MS"],["Celestial","Calibri Light","Calibri"],["Circuit","Tw Cen MT","Tw Cen MT"],["Damask","Bookman Old Style","Rockwell"],["Depth","Corbel","Corbel"],["Madison","Arial","Arial"],["Main Event","Impact","Impact"],["Mesh","Century Gothic","Century Gothic"],["Metropolitan","Calibri Light","Calibri Light"],["Organic","Garamond","Garamond"],["Parallax","Corbel","Corbel"],["Parcel","Gill Sans MT","Gill Sans MT"],["Quotable","Century Gothic","Century Gothic"],["Retrospect","Calibri Light","Calibri"],["Savon","Century Gothic","Century Gothic"],["Slate","Calisto MT","Calisto MT"],["Slice","Century Gothic","Century Gothic"],["Vapor Trail","Century Gothic","Century Gothic"],["View","Century Schoolbook","Century Schoolbook"],["Wisp","Century Gothic","Century Gothic"],["Wood Type","Rockwell Condensed","Rockwell"]],Y0=[["Office","Office","Office"],["2013-2022","Office 2013-2022","Office 2013-2022"],["Atlas","Atlas","Atlas"],["Banded","Banded","Banded"],["Basis","Basis","Basis"],["Berlin","Berlin","Berlin"],["Celestial","Celestial","Celestial"],["Circuit","Circuit","Circuit"],["Damask","Damask","Damask"],["Depth","Depth","Depth"],["Dividend","Dividend","Dividend"],["Droplet","Droplet","Droplet"],["Facet","Facet","Facet"],["Frame","Frame","Frame"],["Gallery","Gallery","Gallery"],["Grayscale","Grayscale","Grayscale"],["Integral","Integral","Integral"],["Ion Boardroom","Ion Boardroom","Ion Boardroom"],["Ion","Ion","Ion"],["Madison","Madison","Madison"],["Main Event","Main Event","Main Event"],["Mesh","Mesh","Mesh"],["Metropolitan","Metropolitan","Metropolitan"],["Organic","Organic","Organic"],["Parallax","Parallax","Parallax"],["Parcel","Parcel","Parcel"],["Quotable","Quotable","Quotable"],["Retrospect","Retrospect","Retrospect"],["Savon","Savon","Savon"],["Slate","Slate","Slate"],["Slice","Slice","Slice"],["Vapor Trail","Vapor Trail","Vapor Trail"],["View","View","View"],["Wisp","Wisp","Wisp"],["Wood Type","Wood Type","Wood Type"],["Office 2007-2010","Office 2007-2010","Office 2007-2010"]],ka="Themes is readonly. To make modifications create a new DocsThemes instance.",hu={[exports.IColor.Scheme.Bg1]:"lt1",[exports.IColor.Scheme.Bg2]:"lt2",[exports.IColor.Scheme.Tx1]:"dk1",[exports.IColor.Scheme.Tx2]:"dk2",[exports.IColor.Scheme.Accent1]:"accent1",[exports.IColor.Scheme.Accent2]:"accent2",[exports.IColor.Scheme.Accent3]:"accent3",[exports.IColor.Scheme.Accent4]:"accent4",[exports.IColor.Scheme.Accent5]:"accent5",[exports.IColor.Scheme.Accent6]:"accent6",[exports.IColor.Scheme.Hlink]:"hlink",[exports.IColor.Scheme.FolHlink]:"folHlink"},Wr="Office",Pl=[Wr,"Calibri Light","Calibri"],jr=["dk1","lt1","dk2","lt2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"],wm=s=>{const e={};for(let t=0;t<s.length;t++){const n=s[t],r=n[0],o={name:r};e[r]=o;for(let i=0;i<jr.length;i++){const a=jr[i],l=n[i+1];if(!l)continue;const c=Ge.parse(l);l&&(o[a]=c.toString())}}return e},ym=s=>{const e={};for(let t=0;t<s.length;t++){const n=s[t],r=n[0],o={name:r};e[r]=o,o.majorFont=n[1]??Pl[1],o.minorFont=n[2]??Pl[2]}return e},Q0=wm([[Wr,"windowText","window","44546A","E7E6E6","4472C4","ED7D31","A5A5A5","FFC000","5B9BD5","70AD47","0563C1","954F72"]]),Z0=ym([Pl]),Vo=Q0[Wr],xr=Z0[Wr];let Yt=null;const e_=new class{constructor(){this._colors={};for(let s=0;s<jr.length;s++){const e=jr[s],t=Ge.parse(Vo[e]);this._colors[e]=t}}getName(){return Vo.name}getDk1(){return this._colors.dk1}getLt1(){return this._colors.lt1}getDk2(){return this._colors.dk2}getLt2(){return this._colors.lt2}getAccent1(){return this._colors.accent1}getAccent2(){return this._colors.accent2}getAccent3(){return this._colors.accent3}getAccent4(){return this._colors.accent4}getAccent5(){return this._colors.accent5}getAccent6(){return this._colors.accent6}getHlink(){return this._colors.hlink}getFolHlink(){return this._colors.folHlink}toJSON(){return null}};class t_{constructor(e,t=e_){this._delegate=t,this._fromJSON(e)}_fromJSON(e){if(this._overrides={},!e)return;const t=Object.keys(e);if(t.length!==0)for(let n=0;n<t.length;n++){const r=t[n];this._overrides[r]=r==="name"?e[r]:Ge.parse(e[r])}}_value(e,t){return this._overrides&&this._overrides[e]!==null&&this._overrides[e]!==void 0?this._overrides[e]:this._delegate?.[t]?.()}getName(){return this._value("name","getName")}getDk1(){return this._value("dk1","getDk1")}getLt1(){return this._value("lt1","getLt1")}getDk2(){return this._value("dk2","getDk2")}getLt2(){return this._value("lt2","getLt2")}getAccent1(){return this._value("accent1","getAccent1")}getAccent2(){return this._value("accent2","getAccent2")}getAccent3(){return this._value("accent3","getAccent3")}getAccent4(){return this._value("accent4","getAccent4")}getAccent5(){return this._value("accent5","getAccent5")}getAccent6(){return this._value("accent6","getAccent6")}getHlink(){return this._value("hlink","getHlink")}getFolHlink(){return this._value("folHlink","getFolHlink")}toJSON(){const e=N.toSafeJSON(this._overrides),t=this.getName();return t&&(e.name=t),e}}const n_=new class{constructor(){this._colors={};for(let s=0;s<jr.length;s++){const e=jr[s],t=Ge.parse(Vo[e]);this._colors[e]=t}}getName(){return xr.name}getMajorFont(){return xr.majorFont}getMinorFont(){return xr.minorFont}getMajorFallbacks(){return xr.majorFallbacks}getMinorFallbacks(){return xr.minorFallbacks}};class r_{constructor(e,t=n_){this._delegate=t,this._fromJSON(e)}_fromJSON(e){if(this._overrides={},!e)return;const t=Object.keys(e);if(t.length!==0)for(let n=0;n<t.length;n++){const r=t[n];this._overrides[r]=e[r]}}_value(e,t){return this._overrides&&this._overrides[e]!==null&&this._overrides[e]!==void 0?this._overrides[e]:this._delegate?.[t]?.()}getName(){return this._value("name","getName")}getMajorFont(){return this._value("majorFont","getMajorFont")}getMinorFont(){return this._value("minorFont","getMinorFont")}getMajorFallbacks(){return this._value("majorFallbacks","getMajorFallbacks")}getMinorFallbacks(){return this._value("minorFallbacks","getMinorFallbacks")}toJSON(){const e=N.toSafeJSON(this._overrides),t=this.getName();return t&&(e.name=t),e}}class xi{constructor(e,t=null,n=null){if(this._cacheColors=new Map,!t&&e?.name){const l=Yt?Yt.get(e.name.toLowerCase()):null;l&&(t=l)}if(!t&&Yt&&(t=Yt.get(Wr.toLowerCase())),this._name=e?.name??t?.getName(),!this._name)throw new Error("Theme must have a name.");this._builtInID=n,this._delegate=t,this._colors=new t_(e?.colors,this._delegate?.getColorScheme()),this._fonts=new r_(e?.fonts,this._delegate?.getFontScheme());const r=hu,o={},i=Object.keys(r);for(let l=0;l<i.length;l++){const c=i[l];o[c]=`get${zr(r[c])}`}o.dk1="getDk1",o.dk2="getDk2",o.lt1="getLt1",o.lt2="getLt2",o.folhlink="getFolHlink",this._colorMap=o;const a=this;this._schemeLookup=l=>{let c=a._cacheColors[l];if(c)return c;const h=a._colorMap[l];if(!h)throw new Error(`Invalid color scheme key: ${l}`);const u=a.getColorScheme();let d=u[h].bind(u)();return d||(d=Vo[hu[l]??l]),c=new Ge(d).toRGBA(),a._cacheColors[l]=c,c}}get builtInID(){return this._builtInID??null}getName(){return this._name??this._delegate?.getName()??null}isCustom(){return this._builtInID!==null&&this._builtInID!==void 0}getColorScheme(){return this._colors}getFontScheme(){return this._fonts}schemeLookup(){return this._schemeLookup}parseColor(e){return Ge.parse(e,this._schemeLookup)}toJSON(){const e={name:this.getName()},t=this._colors.toJSON();t&&(Object.keys(t).length>1||t.name&&t.name!==e.name)&&(e.colors=t);const n=this._fonts.toJSON();return n&&(Object.keys(n).length>1||n.name&&n.name!==e.name)&&(e.fonts=n),Object.keys(e).length===1&&e.name===Wr?null:e}}const o_=()=>{if(Yt)return Yt;const s=((t,n,r)=>{const o=[];for(let i=0;i<t.length;i++){const a=t[i],l=a[0],c=n[a[1]]??Vo,h=r[a[2]]??xr;o.push({name:l,colors:c,fonts:h})}return o})(Y0,wm(K0),ym(X0)),e=new Map;for(let t=0;t<s.length;t++){const n=new xi(s[t]),r=new xi(null,n,t+1);e.set(r.getName().toLowerCase(),r)}return Yt=e,e};class mc{constructor(e=null,t=!1){o_(),this._isReadOnly=t,this._customMap=new Map,this._defaultTheme=this.getByName("Office")}getDefaultTheme(){return this._defaultTheme}setDefaultTheme(e){if(this._isReadOnly)throw new Error(ka);if(!e)throw new Error("Theme cannot be null.");const t=this.getDefaultTheme();return this.getByName(e.getName())||this.setCustomTheme(e),this._defaultTheme=e,t}getByName(e){return e=e.toLowerCase(),this._customMap.get(e)||(Yt.get(e)??null)}search(e){const t=e?.type??exports.IThemeCollection.BuiltInSearchType.All,n=new Map;return t!==exports.IThemeCollection.BuiltInSearchType.BuiltIn&&t!==exports.IThemeCollection.BuiltInSearchType.All||Yt.forEach((o,i)=>n.set(i,o)),t!==exports.IThemeCollection.BuiltInSearchType.Custom&&t!==exports.IThemeCollection.BuiltInSearchType.All||this._customMap.forEach((o,i)=>n.set(i,o)),e?.selected&&n.set(e.selected.getName().toLowerCase(),e.selected),(o=>{const i=[...o];return i.sort((a,l)=>N.isDefined(a.builtInID)&&!N.isDefined(l.builtInID)?1:!N.isDefined(a.builtInID)&&N.isDefined(l.builtInID)?-1:N.isDefined(a.builtInID)&&N.isDefined(l.builtInID)?a.builtInID-l.builtInID:a.getName().localeCompare(l.getName())),i})(Array.from(n.values()))}getCount(){return this._customMap.size+Yt.size}setCustomTheme(e){if(this._isReadOnly)throw new Error(ka);const t=e.getName().toLowerCase(),n=this._customMap.get(t);return this._customMap.set(t,e),n??null}deleteCustomTheme(e){if(this._isReadOnly)throw new Error(ka);let t=null;t=typeof e=="string"?e.toLowerCase():e.getName().toLowerCase();const n=this._customMap.get(t);return this._customMap.delete(t),n??null}}exports.ITableStyle=void 0,(exports.ITableStyle||(exports.ITableStyle={})).ElementType={WholeTable:"wholeTable",FirstColumnStripe:"firstColumnStripe",SecondColumnStripe:"secondColumnStripe",FirstRowStripe:"firstRowStripe",SecondRowStripe:"secondRowStripe",LastColumn:"lastColumn",FirstColumn:"firstColumn",HeaderRow:"headerRow",TotalRow:"totalRow",FirstHeaderCell:"firstHeaderCell",LastHeaderCell:"lastHeaderCell",FirstTotalCell:"firstTotalCell",LastTotalCell:"lastTotalCell"},(exports.ITableStyle||(exports.ITableStyle={})).Empty=class{constructor(s){this._normalStyle=s}getName(){return"None"}isShownInTableStyles(){return!1}isShownInPivotStyles(){return!1}getRanged(s){return null}getProperties(){return N.EmptyObject}isBuiltIn(){return!0}delete(){}toJSON(){return null}get isITableStyle(){return!0}},exports.IAnchored=void 0,(exports.IAnchored||(exports.IAnchored={})).Type={Absolute:"absolute",OneCell:"oneCell",TwoCell:"twoCell"};const Tt="Model has been closed. No further operations are allowed.",uu="Name is required";class st{constructor(e,t){this._listeners=new Set,this._pending=null,this._listeners=new Set,this._transactions=t??new Bt({transient:!0}),this._src=e;const n=this;this._transactionsRemoveListener=this._transactions?.addListener({onCommitEnd(r){const o=n._pending;if(!o)return;n._pending=null;const i=r.getId(),a=new Set;for(let l=0;l<o.length;l++){const c=o[l];c.commitId===i&&n._doNotify(c.listeners,c.removes,c.options,a)}}})}addListeners(e,t){const n=t?.transactional??this._transactions.isOpenTransaction(),r={listeners:e},o=this,i=()=>{if(!n)return void o._listeners.delete(r);const a=o._transactions.getState(o)?.listeners,l=new Set(a);l.delete(r);const c=o._transactions.beginCommit();try{c.updateState(o,{listeners:l}),c.commit({forceAmend:!0})}catch(h){throw c.rollback(),h}};if(r.remove=t?.once?i:null,n){const a=o._transactions.getState(o)?.listeners,l=new Set(a);l.add(r);const c=this._transactions.beginCommit();try{c.updateState(o,{listeners:l}),c.commit({forceAmend:!0})}catch(h){throw c.rollback(),h}}else o._listeners.add(r);return i}async _doNotify(e,t=null,n,r){const o=n?.source??this._src,i=[],a=n?.params;for(let c=0;c<e.length;c++){const h=e[c];r&&r.has(h)||(r?.add(h),i.push(h(o,a)))}let l=null;if(t&&(l=()=>{for(let c=0;c<t.length;c++)t[c]()}),n?.async)return new Promise(async(c,h)=>{try{const u=await Promise.all(i);l?.(),c(u)}catch(u){l?.(),h(u)}});l?.()}notify(e,t){let n=null,r=null;const o=u=>{u.forEach(d=>{const g=d.listeners[e];g&&(n||(n=[]),n.push(g),d.remove&&(r||(r=[]),r.push(d.remove)))})},i=t?.transactional??this._transactions.isOpenTransaction();if(i){const u=this._transactions.getState(this)?.listeners;u&&o(u)}const a=n,l=r;n=null,r=null,o(this._listeners);const c=n,h=r;if(n=null,r=null,i){if(a&&this._doNotify(a,l,t),c){let u=this._pending;return u||(this._pending=u=[]),u.push({commitId:this._transactions.getCurrentCommit().getId(),listeners:c,removes:h,options:t}),this._doNotify(c,l,t)}}else if(c)return this._doNotify(c,h,t)}close(){this._transactions.remove(this),this._transactionsRemoveListener()}}class ir{constructor(e){this._emitter=null,this._closed=!1,this._options={...e};const t=this;this._transactions=this._options?.transactions??new Bt({transient:!0}),this._emitter=new st(this,this._transactions),this._updateState({isDeleted:!1}),e?.json&&this._fromJSON(e.json),this._options?.setContainerReadOnlyCallback?.(()=>{t._processOnContainerReadOnly()}),this._transactionsRemoveListener=this._transactions.addStateListener(this,{onAfterStateChange(n,r,o){t._processStateChange(n,r,o)},onRestoreOrRevert(n,r,o){t._processRestoreOrRevert(n,r,o)}}),this._processInit()}_fromJSON(e){}isReadOnly(){return this._options.isReadOnly?.()??!1}isDeleted(){return this._getState().isDeleted??!1}getType(){return this._options.type}get isIModel(){return!0}_processTransactionDone(e){}_getDescription(){return null}_getState(){if(this._closed)throw new Error(Tt);return this._transactions.getState(this)}_beginCommit(e){return this._transactions.beginCommit(typeof e=="string"?{description:e}:e)}_getTransactions(){return this._transactions}_updateState(e,t,n){if(this._closed)throw new Error(Tt);if(!e)return;const r=this._beginCommit(t?.description);try{r.updateState(this,e);let o=!1;if(n)for(let i=0;i<n.length;i++){const a=n[i];o=o||a==="onAnyChange",this._emitter.notify(a)}!o&&n&&n.length>0&&this._emitter.notify("onAnyChange"),r.commit()}catch(o){throw r.rollback(),o}return this}_getEmitter(){return this._emitter}_processInit(){}_processStateChange(e,t,n){}_processRestoreOrRevert(e,t,n){this._emitter.notify("onInvalidated")}delete(e){if(this._getState().isDeleted)throw new Error("Model has been deleted.");this._options.deleteFromContainer&&this._options.deleteFromContainer?.(e),this._delete()}_delete(){const e=this._getDescription(),t="Delete",n=e?`${t} ${e}`:t,r=this._beginCommit(n);try{this._processDelete(),r.commit()}catch(o){throw r.rollback(),o}}_processOnContainerDeleted(){this._processDelete()}_processDelete(){this._updateState({isDeleted:!0},null,["onDelete"])}_processOnContainerReadOnly(){this._emitter.notify("onReadOnlyChange")}addListeners(e,t){return this._emitter.addListeners(e,t)}beginCommit(e){return this._beginCommit(e)}doBatch(e,t){const n=this;return this._transactions.doBatch(e,typeof t=="string"?{description:t}:t,r=>{n._processTransactionDone(r)})}isClosed(){return this._closed}close(){this._closed||(this._emitter.notify("onClose"),this._closed=!0,this._transactionsRemoveListener?.())}}class Cm extends ir{_fromJSON(e){const t={};if(t.name=e?.name??null,!t.name)throw new Error(uu);t.comment=e?.comment??null,t.hidden=e?.hidden??!1,t.scope=e?.scope??null,this._updateState(t,{description:this._options.createDescription??"Create Item"+(t.name?` '${t.name}'`:"")})}_toJSON(){const e=this._getState(),t={name:e.name};return e.comment&&(t.comment=e.comment),e.hidden&&(t.hidden=e.hidden),e.hidden&&(t.hidden=e.hidden),t}getName(){return this._getState().name}setName(e,t){if(!e)throw new Error(uu);return this._updateState({name:e},{description:`Update Named '${e}'`,...t})}getComment(){return this._getState().comment}setComment(e,t){return this._updateState({comment:e},{description:"Set Comment",...t})}isHidden(){return this._getState().hidden}getScope(){return this._getState().scope}get isINamed(){return!0}}var dt;exports.ISort=void 0,(exports.ISort||(exports.ISort={})).SortOn={Value:"value",FillColor:"fillColor",FontColor:"fontColor",Icon:"icon"},exports.Sort=void 0,(dt=exports.Sort||(exports.Sort={})).CaseInsensitiveOptions={sensitivity:"base",numeric:!1},dt.CaseSensitiveOptions={sensitivity:"case",numeric:!1},dt.BooleanCollator=Object.freeze({type:U.Boolean,compare:(s,e,t)=>s===!0?1:-1}),dt.StringCollator=Object.freeze({type:U.String,compare:(s,e,t)=>s.localeCompare(e,"en",t),defaultOptions:dt.CaseInsensitiveOptions}),dt.NumberCollator=Object.freeze({type:U.Number,compare:(s,e,t)=>s<e?-1:1}),dt.RichDataCollator=Object.freeze({type:U.RichData,compare:(s,e,t)=>s.type.localeCompare(e.type,"en")}),dt.DefaultRangeOptions=Object.freeze({hasHeader:!1,reverse:!1,includeHidden:!1,collatorOptions:dt.CaseInsensitiveOptions,orientation:exports.w.Orientation.Row,offset:0}),dt.DefaultCollators=Object.freeze([dt.BooleanCollator,dt.StringCollator,dt.NumberCollator,dt.RichDataCollator]);const s_=(s,e,t,n)=>{let r;for(;!(r=s.next()).done;)try{e(r.value[1],r.value[0],t)}catch(o){if(typeof s.throw!="function")throw o;s.throw(o)}typeof s.return=="function"&&s.return()},bm=s=>{const e=s.next.bind(s),t={next:n=>{const r=e(n);return r.done?Re:{done:r.done,value:r.value[1]}},[Symbol.iterator]:()=>t,...s.return&&{return:s.return.bind(s)},...s.throw&&{throw:s.throw.bind(s)}};return t},so=s=>{if(!s||s.length===0)return null;let e=Number.MAX_SAFE_INTEGER,t=-1,n=null;return(r,o=!1)=>{if(r===e)return r;o!==!1&&(e=Number.MAX_SAFE_INTEGER),r!==e+(o?-1:1)&&(t=((a,l,c=!0)=>{if(!a||a.length===0)return null;let h,u=-1;return c?(u=N.findEqualOrGreater(a,l,d=>d.max),h=a[u]):(u=N.findEqualOrLesser(a,l,d=>d.min),h=a[u]),h?(c?l>h.max&&(u+=1,h=a[u]):l<h.min&&(u-=1,h=a[u]),h?u:-1):-1})(s,r,!o),n=s[t]);let i=r;if(o)for(;n&&i<=n.max;)i=n.min-1,n=s[--t];else for(;n&&i>=n.min;)i=n.max+1,n=s[++t];return e=i,i}},Re=Object.freeze({done:!0,value:void 0}),qe=Object.freeze({next:()=>Re,[Symbol.iterator]:()=>qe});var Or;Object.seal({done:!1,value:void 0}),(s=>{s.isList=t=>!!t&&!!t.isIList,s.isListLike=t=>!!t&&typeof t.length=="number"&&typeof t.at=="function",s.fromArray=(t,n,r,o)=>new e(t,n,r,o);class e{constructor(n,r,o,i){this.g=r,this.s=o;let a=n??i;if(o&&n&&!i){i=new Array(n.length);for(let l=0;l<n.length;l++){let c=n[l];i[l]=o(c,l)}a=i}this.a=a??N.EmptyArray,r&&(this.at=l=>{l<0&&(l=a.length+l);const c=a[l];if(c!==void 0)return r(c,l)})}at(n){const r=this.a;return n<0&&(n=r.length+n),r[n]}fromArray(n){return new e(n,this.g,this.s)}get length(){return this.a.length}get isIList(){return!0}}s.ArrayList=e})(Or||(Or={}));class kt{constructor(e){if(this._s=null,this._r=null,this._l=0,e&&e.length>0){const t=Or.isList(e)&&!Array.isArray(e)?e:new Or.ArrayList(e);this._s=t,this._l=e.length}}at(e){const t=this._s;if(t)return t.at(e);const n=this._c;if(n&&n.min<=e&&n.max>=e){const l=n.value;return l.v.at(e-n.min+l.s)}const r=this._r,o=N.findEqualOrGreater(r,e,l=>l.max),i=r[o];if(!i)return;const a=i.value;return this._c=i,a.v.at(e-i.min+a.s)}toArray(e=Number.MAX_SAFE_INTEGER){const t=[],n=this.entries(i_);let r=n.next();for(;!r.done&&t.length<e;)t.push(r.value[1]),r=n.next();return t}entries(e){const t=this.length;if(t===0)return qe;let n,r,o,i=!0,a=0,l=t-1;if(e){i=!e.reverse;const g=e.bounds;g&&(a=Math.max(g.min??a,a),l=Math.min(g.max??l,l)),n=e.reuseResult??null,r=e.processSkip}const c=i?1:-1;let h=(i?a:l)-c;const u=this._s;if(u)o=g=>{if(!(g<a||g>l))return u.at(g)};else{const g=this._r;let m=i?0:g.length-1,f=g[m];const _=(p,S)=>{const C=p===m?f:g[p];if(C&&S>=C.min&&S<=C.max)return m=p,f=C,C};o=p=>{if(p<a||p>l)return;let S=_(m,p);if(S||(S=_(m+c,p)),!S){const y=N.findEqualOrGreater(g,p,b=>b.max);S=_(y,p)}if(!S)return;const C=S.value;return C.v.at(p-S.min+C.s)}}const d={next:g=>{let m,f=h+c;return g!==void 0&&(g<0&&(g=t+g),f=g),f<a||f>l||r&&(f=r(f,!i),f<a||f>l)?Re:(m=o(f),h=f,n?(Ro.done=!1,Ro.value[0]=f,Ro.value[1]=m,Ro):{done:!1,value:[h,m]})},[Symbol.iterator]:()=>d};return d}slice(e,t=void 0){const n=this._r??du(this._s);if(!n)return Oa;const r=this.length;if(e=Math.min(Math.max(0,e),r),(t=Math.min(Math.max(0,t??r),r))-e<=0)return Oa;if(e<=0&&t>=r)return this;const o=e,i=t-1;let a=[],l=0;for(let h=0;h<n.length;h++){let u=n[h];const d=u.max;if(o===0&&d<=i){a.push(u);continue}const g=u.min;if(g>i){h=n.length;continue}if(d<o){l=d+1;continue}const m=Math.max(0,o-g),f=Math.max(0,d-i),_=f+m,p=u.value;a.push({min:g-l,max:d-_-l,value:{s:p.s+m,e:p.e-f,v:p.v}}),l+=_}const c=new kt;return c._r=a,c._l=i-o+1,c}concat(e){if(!e)return this;if(!Or.isListLike(e))throw new Error("Value must be IListLike");const t=this._l;if(t===0)return e.isIReadableList?e:e.length===0?Oa:new kt(e);const n=e,r=e.length;if(r===0)return this;const o=this._r??du(this._s),i=o.slice(0,o.length-1);let a=o[o.length-1],l=a?a.min:0,c=a?a.max:0,h=a?a.value:null,u=h?h.v:null,d=h?h.e-h.s:0;const g=_=>{const p=_.s,S=_.e,C=S-p;if(C+d<a_&&u&&u.fromArray){let w=_.v;const E=[],I=h.s,x=h.e;for(let R=I;R<=x;R++)E.push(u.at(R));for(let R=p;R<=S;R++)E.push(w.at(R));const v=u.fromArray(E);if(v)return w=v,d=w.length-1,h={s:0,e:d,v:w},a={min:l,max:l+d,value:h},c=l+d,void(u=w)}i.push(a);const y=c+1,b=y+C;a={min:y,max:b,value:_},l=y,c=b,h=a?a.value:null,u=h?h.v:null,d=h?h.e-h.s:0};if(e instanceof kt){const _=e._s;if(_)g({s:0,e:_.length-1,v:_});else{const p=e._r;for(let S=0;S<p.length;S++)g(p[S].value)}}else g({s:0,e:r-1,v:n});i.push(a);const m=new kt,f=t+r;return i.length===1&&i[0].min===0&&i[0].max===f-1?m._s=i[0].value.v:m._r=i,m._l=f,m}get length(){return this._l}[Symbol.iterator](){return bm(this.entries())}get isIReadableList(){return!0}get isIList(){return!0}get[Symbol.toStringTag](){return"[ImmutableList]"}toString(){const e=this.length;if(e===0)return"";let t="";for(let n=0;n<e;n++){n>0&&(t+=",");const r=this.at(n);t+=r==null?"":String(r)}return t}}const du=s=>[{min:0,max:s.length-1,value:{s:0,e:s.length-1,v:s}}],Oa=new kt,Ro=Object.seal({done:!1,value:[-1,null]}),i_=Object.freeze({reverse:!1,bounds:{min:0,max:Number.MAX_SAFE_INTEGER},skipRuns:null,reuseResult:Ro}),a_=4;var Ii;(s=>{const e=(n,r)=>{const o=n!==ie.Row;return r?(i,a)=>{if(i===a)return 0;const l=i[0],c=i[1],h=a[1];if(c===h)return l?-1:1;const u=a[0];let d=0,g=0;if(o?(d=l?c.colEnd:c.colStart,g=u?h.colEnd:h.colStart):(d=l?c.rowEnd:c.rowStart,g=u?h.rowEnd:h.rowStart),d===g&&l!==u)return l?-1:1;if(d!==g)return g-d;let m=0,f=0;if(o?(m=l?c.colStart:c.colEnd,f=u?h.colStart:h.colEnd):(m=l?c.rowStart:c.rowEnd,f=u?h.rowStart:h.rowEnd),m===f&&l!==u)return l?-1:1;if(m!==f)return f-m;const _=i[2]??0;return(a[2]??0)-_}:(i,a)=>{if(i===a)return 0;const l=i[0],c=i[1],h=a[1];if(c===h)return l?-1:1;const u=a[0];let d=0,g=0;if(o?(d=l?c.colStart:c.colEnd,g=u?h.colStart:h.colEnd):(d=l?c.rowStart:c.rowEnd,g=u?h.rowStart:h.rowEnd),d===g&&l!==u)return l?-1:1;if(d!==g)return d-g;let m=0,f=0;return o?(m=l?c.colEnd:c.colStart,f=u?h.colEnd:h.colStart):(m=l?c.rowEnd:c.rowStart,f=u?h.rowEnd:h.rowStart),m===f&&l!==u?l?-1:1:m!==f?m-f:(i[2]??0)-(a[2]??0)}};class t{constructor(r,o){if(this._isColumn=!0,this._isByCell=!1,this._isReverse=!1,this._cursor=null,this._reuse=null,this._localReuse={done:!1,value:[null,null]},this._eventsMajor=null,this._eventMajorIndex=0,this._majorStart=0,this._majorEnd=0,this._eventMinorPeek=null,this._minorStart=0,this._minorEnd=0,!r||r.length===0)return;let i=ie.Column,a=!1,l=!0,c=!1;o&&(i=o.orientation??ie.Column,this._isColumn=l=i!==ie.Row,this._isReverse=a=o.reverse??!1,this._isByCell=c=o.byCell??!1);const h=r.length,u=new Array(2*h);for(let f=0;f<h;f++){const _=r[f],p=[null,null];u[2*f]=[!0,_,f,p],u[2*f+1]=[!1,_,f,p]}u.sort(e(i,a)),this._eventsMajor=u;const d=u[0][1];this._majorStart=a?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,this._majorEnd=l?a?d.colEnd+1:d.colStart-1:a?d.rowEnd+1:d.rowStart-1,this._eventsMinor=new Se(null,e(l?ie.Row:ie.Column,a));const g=new Array(16);g.length=0,this._cursor={cell:null,range:{colStart:d.colStart,rowStart:d.rowStart,colEnd:d.colEnd,rowEnd:d.rowEnd},overlaps:g},c&&(this._cursor.cell={colIndex:a?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,rowIndex:a?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER});const m=o?.reuseIterator;m&&(this._reuse=m,m.value=this._cursor)}next(r){const o=this._isColumn,i=this._isReverse;if(r){if(!this._isByCell)throw new Error("nextCell is only supported when byCell is true");const x=k.createCellComparator(o?ie.Column:ie.Row,i);let v;do{const R=this._cursor,A=R.cell;if(A.colIndex!==Number.MAX_SAFE_INTEGER&&x(A,r)>=0)throw new Error("nextCell must be after the current iteration cell");if(v=this.next(),v.done)return v;const M=v.value.cell;if(x(M,r)>=0)return v;const T=R.range;if(o){const F=r.colIndex===A.colIndex;A.rowIndex=i?F?Math.max(r.rowIndex,T.rowStart):T.rowStart:F?Math.min(r.rowIndex,T.rowEnd):T.rowEnd}else{const F=r.rowIndex===A.rowIndex;A.colIndex=i?F?Math.max(r.colIndex,T.colStart):T.colStart:F?Math.min(r.colIndex,T.colEnd):T.colEnd}if(x(A,r)>=0)return M.rowIndex=A.rowIndex,M.colIndex=A.colIndex,v}while(!v.done);return v}let a=this._cursor;if(!a)return Re;let l=this._reuse;if(!l){const x=a.cell,v=a.range,R={cell:null,range:{colStart:v.colStart,rowStart:v.rowStart,colEnd:v.colEnd,rowEnd:v.rowEnd},overlaps:[...a.overlaps]};x&&(R.cell={colIndex:x.colIndex,rowIndex:x.rowIndex}),this._cursor=R,l={done:!1,value:R}}const c=l.value,h=c.range,u=c.cell,d=this._isByCell,g=i?-1:1;let m=!1;if(d){const x=u.rowIndex,v=u.colIndex,R=o?x:v,A=o?i?h.rowStart:h.rowEnd:i?h.colStart:h.colEnd;if((i?R>=A:R<=A)&&(o?u.rowIndex=x+g:u.colIndex=v+g,i?R>A:R<A))return l;const M=o?u.colIndex:u.rowIndex,T=o?i?h.colStart:h.colEnd:i?h.rowStart:h.rowEnd;(i?M>T:M<T)&&(m=!0)}const f=c.overlaps;let _=this._majorStart,p=this._majorEnd,S=this._eventsMinor,C=this._minorStart,y=this._minorEnd,b=this._eventsMinorIterator,w=this._eventMinorPeek,E=w;for(;E&&!E.done;){const x=E.value[0];if(x[0])E=null;else{if(w=b.next(),w.done)f.length=0;else{const v=x[1];let R=f.length;if(R>1){const A=f.indexOf(v);A!==-1&&(f[A]=f[R-1])}if(f.length=R-1,R=f.length,R>0){const A=w.value[0],M=A[1],T=o?i?M.colStart:M.colEnd:i?M.rowStart:M.rowEnd;if(i?_>=T:_<=T){let F=!1;if(A[0]){const L=o?i?M.rowEnd:M.rowStart:i?M.colEnd:M.colStart;(i?L<y+g:L>y+g)&&(C=y+g,y=L-g,F=!0)}else{const L=o?i?M.rowStart:M.rowEnd:i?M.colStart:M.colEnd;(i?L<y:L>y)&&(C=y+g,y=L,F=!0)}if(F)return o?(h.rowStart=i?y:C,h.rowEnd=i?C:y):(h.colStart=i?y:C,h.colEnd=i?C:y),this._minorStart=C,this._minorEnd=y,this._eventMinorPeek=w,l}}}w.done&&(w=null),E=w}}if(!w)if(m){b=S.entries(void 0,this._localReuse),w=b.next(),this._eventsMinorIterator=b;const x=w.value[0][1],v=o?i?x.rowEnd:x.rowStart:i?x.colEnd:x.colStart;o?(u.colIndex=u.colIndex+g,u.rowIndex=v):(u.colIndex=v,u.rowIndex=u.rowIndex+g)}else{let x=this._eventMajorIndex;const v=this._eventsMajor,R=v.length;if(x>=R)return this._cursor=null,Re;let A=v[x],M=A[0],T=!1;for(;!M&&!T&&A;){const L=A[1],D=o?i?L.colStart:L.colEnd:i?L.rowStart:L.rowEnd;if(i?D<p:D>p){T=!0;continue}const P=A[3];S.delete(P[0]),S.delete(P[1]),x++,A=v[x],A&&(M=A[0])}let F=S.size>0?p+g:-1;for(T=!1;M&&!T&&A;){const L=A[1];if(F!==-1&&(o?i?L.colEnd:L.colStart:i?L.rowEnd:L.rowStart)!==F){T=!0;continue}const D=A[2],P=[!0,L,D],B=[!1,L,D],z=A[3];if(z[0]=P,z[1]=B,S.set(P,0),S.set(B,0),F===-1&&(F=o?i?L.colEnd:L.colStart:i?L.rowEnd:L.rowStart),x++,A=v[x],!A||(M=A[0],!M))continue;const O=A[1];(o?i?O.colEnd:O.colStart:i?O.rowEnd:O.rowStart)!==F&&(T=!0)}if(F!==-1&&(_=F),d&&(o?u.colIndex=_:u.rowIndex=_),this._eventMajorIndex=x,x>=R)return this._eventsMinorIterator=b,this._cursor=null,Re;if(A){const L=A[0],D=A[1],P=o?i?D.colEnd:D.colStart:i?D.rowEnd:D.rowStart,B=o?i?D.colStart:D.colEnd:i?D.rowStart:D.rowEnd;p=L?P-g:B}f.length=0,b=S.entries(void 0,this._localReuse),w=b.next(),this._eventsMinorIterator=b}let I=w;do{const x=I.value;I=null;const v=x[0],R=v[1];if(!v[0])continue;const A=o?i?R.rowEnd:R.rowStart:i?R.colEnd:R.colStart;C!==A&&(C=A),w=b.next();const M=w.value[0],T=M[0],F=M[1],L=o?i?F.rowEnd:F.rowStart:i?F.colEnd:F.colStart;if(T&&L===C)I=w;else{const D=o?i?R.rowStart:R.rowEnd:i?R.colStart:R.colEnd,P=o?i?F.rowStart:F.rowEnd:i?F.colStart:F.colEnd;y=(i?Math.max:Math.min)(D,T?L-g:P),d&&(o?u.rowIndex=C:u.colIndex=C)}f[f.length]=Object.freeze(R)}while(I);return o?(h.colStart=i?p:_,h.colEnd=i?_:p,h.rowStart=i?y:C,h.rowEnd=i?C:y):(h.rowStart=i?p:_,h.rowEnd=i?_:p,h.colStart=i?y:C,h.colEnd=i?C:y),this._eventMinorPeek=w,this._minorStart=C,this._minorEnd=y,this._majorStart=_,this._majorEnd=p,l}return(r){return null}throw(r){return null}[Symbol.iterator](){return this}}s.IteratorInstance=t})(Ii||(Ii={}));const Fn=(s,e=Oe.Right,t=null)=>{if(!s)return s;if(s.length===0)return[];const n=e===Oe.Right,r=e===Oe.Left,o=e===Oe.Up,i=e===Oe.Down;return s.sort((a,l)=>{if(!a&&!l)return 0;if(a&&!l)return-1;if(l&&!a)return 1;const c=t?.(a,l)??0;return c!==0?c:n?a.rowStart===l.rowStart?a.colStart-l.colStart:a.rowStart-l.rowStart:i?a.colStart===l.colStart?a.rowStart-l.rowStart:a.colStart-l.colStart:r?a.rowStart===l.rowStart?l.colStart-a.colStart:l.rowStart-a.rowStart:o?a.colStart===l.colStart?l.rowStart-a.rowStart:l.colStart-a.colStart:0})},l_=(s,e)=>{const t=e.min,n=s.min;if(e.max===Number.MAX_SAFE_INTEGER){const r=t,o=s.max;return n<=r&&r<=o?0:o<r?-1:n>r?1:(console.warn("coords are not inserted correctly",s,e),0)}return n-t};class Wn{constructor(e){this._runs=null,this._dataCoords=null,this._count=0,this._length=0,this._maxCoords=null,this._options=e,e?.maxCoords&&(this._maxCoords=Object.freeze({...e.maxCoords})),this._runs=new Se(void 0,l_,e?.nodeSize),this._reuseRunsIterator={done:!1,value:[null,null]},this._reuseRunsEntry=[null,null]}_validateBounds(e=Number.MIN_SAFE_INTEGER,t=Number.MAX_SAFE_INTEGER){const n=this._maxCoords,r=n?.min??Number.MIN_SAFE_INTEGER,o=n?.max??Number.MAX_SAFE_INTEGER;if(e<r||t>o)throw new Ne}entries(e){let t,n,r=Number.MIN_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER,i=!0;e&&(e?.bounds&&(r=e.bounds?.min??Number.MIN_SAFE_INTEGER,o=e.bounds?.max??Number.MAX_SAFE_INTEGER,this._validateBounds(r,o)),i=!e.reverse,t=c_(e.reuseResult),n=e.processSkip);const a=this._dataCoords;if(!a)return qe;r=Math.max(a.min,r),o=Math.min(a.max,o);let l=null,c=null,h=Number.MAX_SAFE_INTEGER,u=Number.MIN_SAFE_INTEGER;if(n){const _=n;n=(p,S)=>_(p+h,S)-h}const d=_=>{let p;_!==Number.MIN_SAFE_INTEGER&&_!==Number.MAX_SAFE_INTEGER&&(Et.min=_,p=Et),l=i?this._runs.entries(p,this._reuseRunsIterator):this._runs.entriesReversed(p,this._reuseRunsIterator),h=Number.MAX_SAFE_INTEGER,u=Number.MIN_SAFE_INTEGER,c=null},g=_=>{if(_!==void 0){if(_<h||_>u)return void(c=void 0);_-=h}if(!c)return;let p=c.next(_);if(!c)return;let S=p.value,C=S?.[1];return p.done?void(c=void 0):h_(S[0]+h,C,t)},m=_=>{let p;return p=g(_),p||(p=(S=>{let C;do{if(S!==void 0&&d(S),!l)return;if(C=l.next(),C.done)return void(l=void 0);const y=C.value,b=y[0],w=y[1],E=b.min,I=b.max,x=Math.max(E,r)-E,v=Math.max(x,Math.min(I,o))-E;Sr.bounds.min=x,Sr.bounds.max=v,Sr.reverse=!i,Sr.processSkip=n,Sr.reuseResult=t,h=E,u=I,c=w.entries(Sr);const R=g(S);if(R)return R;S=void 0}while(!C.done);l=void 0})(_),p||Re)},f={next(_){if(_!==void 0&&(_<0||_>o))throw new Ne;return m(_)},return:_=>null,throw:_=>null};return d(i?r:o),f}runs(e){let t,n=Number.MIN_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,o=!0,i=!1;e&&(e.bounds&&(n=e.bounds?.min??Number.MIN_SAFE_INTEGER,r=e.bounds?.max??Number.MAX_SAFE_INTEGER,this._validateBounds(n,r),e.overflowRun&&(i=!0)),o=!e.reverse,t=u_(e.reuseResult));const a=this._dataCoords;if(!a)return qe;n=Math.max(a.min,n),r=Math.min(a.max,r);let l=null;const c=u=>{let d;u!==Number.MIN_SAFE_INTEGER&&u!==Number.MAX_SAFE_INTEGER&&(Et.min=u,d=Et),l=o?this._runs.entries(d,this._reuseRunsIterator):this._runs.entriesReversed(d,this._reuseRunsIterator)},h={next(u){if(u!==void 0){if(u<n||u>r)throw new Ne;c(u)}if(!l)return Re;const d=l.next();if(d.done)return l=void 0,Re;const g=d.value,m=g[0];let f=m;const _=f.min,p=f.max;if(o&&_>r||!o&&p<n)return Re;let S=g[1];return i||(p>r&&(S=S.slice(0,S.length-(p-r)),f={...f},f.max=r),_<n&&(S=S.slice(n-_),f===m&&(f={...f}),f.min=n)),d_(f,S,t)},return:u=>null,throw:u=>null};return c(o?n:r),h}slice(e,t){const n=this._runs,r=n.minKey().min,o=n.maxKey().max;if(t===void 0&&(t=o+1),this._count===0||e<=r&&t-1>=o)return this.clone();const i=Math.max(r,e),a=Math.min(o,t-1),l=a-i,c=[];let h=0;Da.bounds.min=i,Da.bounds.max=a;const u=this.runs(Da);let d=u.next();for(;!d.done;){const m=d.value;let f=m[0],_=m[1];f={min:f.min-i,max:f.max-i},f.min<0&&(_=_.slice(-f.min),f.min=0),f.max>=l&&(_=_.slice(0,_.length-(f.max-l)),f.max=l),h+=_.length,c.push([f,_]),d=u.next()}const g=new Wn(this._options);return g._runs.setPairs(c),g._updateCount(h),g}concat(e){const t=this.clone();if(!e||e.length===0)return t;const n=this._runs.nextLowerPair(void 0,this._reuseRunsEntry),r=n[0],o=n[1],i=r.max+1;let a=!1,l=0;const c=[];if(e.isISparseList){const h=e.runs();let u=h.next();for(;!u.done;){const d=u.value;let g=d[0];const m={min:g.min+i,max:g.max+i};let f=d[1];if(g.min===0){a=!0,l-=o.length,f=o.concat(f);const _=r.min;m.min=_,m.max=f.length-1+_}l+=f.length,c.push([m,f]),u=h.next()}}else{const h=e.length,u={min:r.min,max:h-1+i};e=o.concat(e),a=!0,l+=h,c.push([u,e])}return a&&t._runs.delete(r),t._runs.setPairs(c),t._updateCount(l),t}toArray(e=Number.MAX_SAFE_INTEGER,t=!0){if(this.length===0)return N.EmptyArray;const n=t?0:Number.MIN_SAFE_INTEGER,r=Math.min(this._runs.maxKey().max,e);return Ba.bounds.min=Number.MIN_SAFE_INTEGER,Ba.bounds.max=r,g_(this.entries(Ba),t,r,n)}get isIReadableList(){return!0}get length(){return this._length}getCoords(){return this._dataCoords}clear(){this._runs.clear(),this._dataCoords=null,this._count=0,this._length=0}get isISparseList(){return!0}get isIList(){return!0}_updateCount(e){if(this._count+=e,this._lastRunsRead=void 0,this._lastListRead=void 0,this._count>0){const t=this._runs,n=Object.freeze({min:t.minKey().min,max:t.maxKey().max});this._dataCoords=n,this._length=n.max+1}else this._dataCoords=null,this._length=0}_update(e,t,n=null,r=void 0){const o=e,i=o+t-1;let a=0,l=i,c=i,h=null,u=null;Et.min=o,wr.min=i,(n||r)&&(Et.min-=1,wr.min+=1);const d=this._runs;let g=!1;if(d.editRange(Et,wr,!0,(m,f,_)=>{const p=m.min,S=m.max;return p<o&&S+1>=o&&(l=p,h=f),p-1<=i&&S>i&&(c=p,u=f),a-=S-p+1,g=!0,Se.DeleteValue}),n||r===void 0||(n=new kt([r])),n){let m=n;g=!0;let f=o;h&&(h=h.slice(0,o-l),m=h.concat(m),f=l),u&&(u=u.slice(i+1-c),m=m.concat(u)),a+=m.length,d.set({min:f,max:f+m.length-1},m)}else h&&(h=h.slice(0,o-l),a+=h.length,d.set({min:l,max:l+h.length-1},h)),u&&(u=u.slice(i+1-c),a+=u.length,d.set({min:i+1,max:i+u.length},u));return this._updateCount(a),g}setAt(e,t){if(e===void 0)throw new Ot;return this._validateBounds(e,e),this._update(e,1,null,t)}setRunAt(e,t){if(!t||t.length===0)return!1;if(e===void 0||!t.length)throw new Ot;const n=t.length;return this._validateBounds(e,e+n-1),this._update(e,n,t)}delete(e,t){return t===void 0&&(t=Math.max(this.getCoords().max-e+1,0)),!(t<=0)&&(this._validateBounds(e,e),this._update(e,t,null))}shift(e,t){if(t===0)return!1;let n=e,r=e;t<0&&(r=e-t-1),this._validateBounds(n,r);const o=this._runs,i=o.maxKey();if(t<0&&r>=i.max&&n<=o.minKey().min)return this._runs.clear(),this._dataCoords=null,this._count=0,this._length=0,!0;let a=0,l=n,c=r,h=null,u=null;Et.min=l,wr.min=i.min,t<0&&(Et.min-=1,wr.min+=1);let d=!1;const g=[];if(o.editRange(Et,wr,!0,(m,f,_)=>{const p=m.min,S=m.max;return p<n&&S+1>=n&&(l=p,h=f),(p<n||t<0)&&p-1<=r&&m.max>r&&(c=p,u=f),t>0&&p>=n||t<0&&p-1>r?g.push([{min:p+t,max:S+t},f]):a-=S-p+1,d=!0,Se.DeleteValue}),t>0){const m=h||u;m&&(h=m.slice(0,n-l),c=e+t,u=m.slice(n-l))}else h&&(h=h.slice(0,n-l)),u&&(u=u.slice(r+1-c),c=e),h&&u&&l+h.length===c&&(h=h.concat(u),u=null);return h&&h.length>0&&(a+=h.length,o.set({min:l,max:l+h.length-1},h)),u&&(a+=u.length,o.set({min:c,max:c+u.length-1},u)),g.length>0&&o.setPairs(g),this._updateCount(a),d}at(e){Et.min=e;const t=this._lastRunsRead;if(t){const i=t.min;if(i<=e&&t.max>=e)return this._lastListRead.at(e-i)}let n,r;const o=this._runs.getPairOrNextHigher(Et,f_);if(o&&(n=o[0],r=o[1]),this._lastRunsRead=n,this._lastListRead=r,!(!n||e<n.min||e>n.max))return r.at(e-n.min)}[Symbol.iterator](){return bm(this.entries())}clone(){const e=new Wn(this._options);return e._runs=this._runs.clone(),e._count=this._count,e._dataCoords=this._dataCoords,e._length=this._length,e}getMaxCoords(){return this._maxCoords||null}getCount(){return this._count}getRunsCount(){return this._runs.size}get[Symbol.toStringTag](){return"[SparseList]"}}Wn||(Wn={});const c_=s=>typeof s!="boolean"?(s&&!s.value&&(s.value=[-1,null]),s):s===!0?fc:void 0,h_=(s,e,t)=>{const n=t??{done:!1,value:[-1,null]},r=n.value;return r[0]=s,r[1]=e,n},u_=s=>typeof s!="boolean"?(s&&!s.value&&(s.value=[null,null]),s):s===!0?m_:void 0,d_=(s,e,t)=>{const n=t??{done:!1,value:[null,null]},r=n.value;return r[0]=s,r[1]=e,n},g_=(s,e=!1,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER)=>{const r=[];let o=s.next(),i=Math.max(n,0)-1;for(;!o.done;){if(e){const a=o.value[0];for(let l=i;l<a-1;l++)r.push(void 0);i=a}r.push(o.value[1]),o=s.next()}if(e)for(let a=i;a<t;a++)r.push(void 0);return r},m_=Object.seal({done:!1,value:[{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},null]}),fc=Object.seal({done:!1,value:[-1,null]}),Sr={reverse:!1,bounds:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},processSkip:null,reuseResult:fc},Ba=Object.freeze({reverse:!1,bounds:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},processSkip:null,reuseResult:fc}),Et={min:0,max:Number.MAX_SAFE_INTEGER},wr={min:0,max:Number.MAX_SAFE_INTEGER},f_=[null,null],Da={bounds:{min:0,max:0},overflowRun:!0};class p_{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(e){return this.data.children.length===0?[]:this._all(this.data,e??[])}isEmpty(){return this.data.children.length===0}search(e,t){let n=this.data;if(n.children.length===0||!Cs(e,n))return N.EmptyArray;const r=t??[],o=this.toBBox,i=[];for(;n;){const a=n.children,l=a.length,c=n.leaf;for(let h=0;h<l;h++){const u=a[h],d=c?o(u):u;Cs(e,d)&&(c?r.push(u):Pa(e,d)?this._all(u,r):i.push(u))}n=i.pop()}return r}collides(e){let t=this.data;if(!Cs(e,t))return!1;const n=[];for(;t;){for(let r=0;r<t.children.length;r++){const o=t.children[r],i=t.leaf?this.toBBox(o):o;if(Cs(e,i)){if(t.leaf||Pa(e,i))return!0;n.push(o)}}t=n.pop()}return!1}load(e){if(!e||!e.length)return this;const t=this._minEntries;if(e.length<t){for(let r=0;r<e.length;r++)this.insert(e[r]);return this}let n=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}else this.data=n;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Ir([]),this}remove(e,t){if(!e)return this;let n=this.data;const r=this.toBBox(e),o=[],i=[];let a,l,c;for(;n||o.length;){if(n||(n=o.pop(),l=o[o.length-1],a=i.pop(),c=!0),n.leaf){const h=__(e,n.children,t);if(h!==-1)return n.children.splice(h,1),o.push(n),this._condense(o),this}c||n.leaf||!Pa(n,r)?l?(a++,n=l.children[a],c=!1):n=null:(o.push(n),i.push(a),a=0,l=n,n=n.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,r){const o=n-t+1;let i,a=this._maxEntries;if(o<=a)return i=Ir(e.slice(t,n+1)),yr(i,this.toBBox),i;r||(r=Math.ceil(Math.log(o)/Math.log(a)),a=Math.ceil(o/Math.pow(a,r-1))),i=Ir([]),i.leaf=!1,i.height=r;const l=Math.ceil(o/a),c=l*Math.ceil(Math.sqrt(a));gu(e,t,n,c,this.compareMinX);for(let h=t;h<=n;h+=c){const u=Math.min(h+c-1,n);gu(e,h,u,l,this.compareMinY);for(let d=h;d<=u;d+=l){const g=Math.min(d+l-1,u);i.children.push(this._build(e,d,g,r-1))}}return yr(i,this.toBBox),i}_chooseSubtree(e,t,n,r){for(;r.push(t),!t.leaf&&r.length-1!==n;){let o,i=1/0,a=1/0;for(let l=0;l<t.children.length;l++){const c=t.children[l],h=La(c),u=y_(e,c)-h;u<a?(a=u,i=h<i?h:i,o=c):u===a&&h<i&&(i=h,o=c)}t=o||t.children[0]}return t}_insert(e,t,n=!1){const r=n?e:this.toBBox(e),o=[],i=this._chooseSubtree(r,this.data,t,o);for(i.children.push(e),Mo(i,r);t>=0&&o[t].children.length>this._maxEntries;)this._split(o,t),t--;this._adjustParentBBoxes(r,o,t)}_split(e,t){const n=e[t],r=n.children.length,o=this._minEntries;this._chooseSplitAxis(n,o,r);const i=this._chooseSplitIndex(n,o,r),a=Ir(n.children.splice(i,n.children.length-i));a.height=n.height,a.leaf=n.leaf,yr(n,this.toBBox),yr(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(n,a)}_splitRoot(e,t){this.data=Ir([e,t]),this.data.height=e.height+1,this.data.leaf=!1,yr(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let r=-1,o=1/0,i=1/0;for(let a=t;a<=n-t;a++){const l=Ao(e,0,a,this.toBBox),c=Ao(e,a,n,this.toBBox),h=C_(l,c),u=La(l)+La(c);h<o?(o=h,r=a,i=u<i?u:i):h===o&&u<i&&(i=u,r=a)}return r||n-t}_chooseSplitAxis(e,t,n){const r=e.leaf?this.compareMinX:S_,o=e.leaf?this.compareMinY:w_;this._allDistMargin(e,t,n,r)<this._allDistMargin(e,t,n,o)&&e.children.sort(r)}_allDistMargin(e,t,n,r){e.children.sort(r);const o=this.toBBox,i=Ao(e,0,t,o),a=Ao(e,n-t,n,o);let l=ys(i)+ys(a);for(let c=t;c<n-t;c++){const h=e.children[c];Mo(i,e.leaf?o(h):h),l+=ys(i)}for(let c=n-t-1;c>=t;c--){const h=e.children[c];Mo(a,e.leaf?o(h):h),l+=ys(a)}return l}_adjustParentBBoxes(e,t,n){for(let r=n;r>=0;r--)Mo(t[r],e)}_condense(e){for(let t,n=e.length-1;n>=0;n--)e[n].children.length===0?n>0?(t=e[n-1].children,t.splice(t.indexOf(e[n]),1)):this.clear():yr(e[n],this.toBBox)}}function __(s,e,t){if(!t)return e.indexOf(s);for(let n=0;n<e.length;n++)if(t(s,e[n]))return n;return-1}function yr(s,e){Ao(s,0,s.children.length,e,s)}function Ao(s,e,t,n,r=null){r||(r=Ir(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let o=e;o<t;o++){const i=s.children[o];Mo(r,s.leaf?n(i):i)}return r}function Mo(s,e){return s.minX=Math.min(s.minX,e.minX),s.minY=Math.min(s.minY,e.minY),s.maxX=Math.max(s.maxX,e.maxX),s.maxY=Math.max(s.maxY,e.maxY),s}function S_(s,e){return s.minX-e.minX}function w_(s,e){return s.minY-e.minY}function La(s){return(s.maxX-s.minX)*(s.maxY-s.minY)}function ys(s){return s.maxX-s.minX+(s.maxY-s.minY)}function y_(s,e){return(Math.max(e.maxX,s.maxX)-Math.min(e.minX,s.minX))*(Math.max(e.maxY,s.maxY)-Math.min(e.minY,s.minY))}function C_(s,e){const t=Math.max(s.minX,e.minX),n=Math.max(s.minY,e.minY),r=Math.min(s.maxX,e.maxX),o=Math.min(s.maxY,e.maxY);return Math.max(0,r-t)*Math.max(0,o-n)}function Pa(s,e){return s.minX<=e.minX&&s.minY<=e.minY&&e.maxX<=s.maxX&&e.maxY<=s.maxY}function Cs(s,e){return e.minX<=s.maxX&&e.minY<=s.maxY&&e.maxX>=s.minX&&e.maxY>=s.minY}function Ir(s){return{children:s,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function gu(s,e,t,n,r){const o=[e,t];for(;o.length;){if((t=o.pop())-(e=o.pop())<=n)continue;const i=e+Math.ceil((t-e)/n/2)*n;Em(s,i,e,t,r),o.push(e,i,i,t)}}function Em(s,e,t,n,r){for(;n>t;){if(n-t>600){const l=n-t+1,c=e-t+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1);Em(s,e,Math.max(t,Math.floor(e-c*u/l+d)),Math.min(n,Math.floor(e+(l-c)*u/l+d)),r)}const o=s[e];let i=t,a=n;for(io(s,t,e),r(s[n],o)>0&&io(s,t,n);i<a;){for(io(s,i,a),i++,a--;r(s[i],o)<0;)i++;for(;r(s[a],o)>0;)a--}r(s[t],o)===0?io(s,t,a):(a++,io(s,a,n)),a<=e&&(t=a+1),e<=a&&(n=a-1)}}function io(s,e,t){const n=s[e];s[e]=s[t],s[t]=n}class mu extends p_{toBBox(e){return{minX:10*e.colStart,minY:10*e.rowStart,maxX:10*e.colEnd+5,maxY:10*e.rowEnd+5}}compareMinX(e,t){return e.colStart-t.colStart}compareMinY(e,t){return e.rowStart-t.rowStart}isEmpty(){return this.data.children.length===0}searchRange(e,t=!1,n){if(this.isEmpty())return N.EmptyArray;const r=this.search(this.toBBox(e),n);return t?r.filter(o=>o.colStart>=e.colStart&&o.rowStart>=e.rowStart&&o.colEnd<=e.colEnd&&o.rowEnd<=e.rowEnd):r}}class be{constructor(e){this._shared=null,this._rTree=null,this._cloneKey=null,this._lastMiss={colStart:Number.MAX_SAFE_INTEGER,rowStart:0,colEnd:0,rowEnd:0},this._lastSingle=null,this._lastSingleResult=null,this._options=e,this._rTree=new mu(e?.maxNodeEntries??16)}visitRanges(e,t,n=null){let r=this.search(e);n&&(r=Fn(r,n));const o=[],i=[];let a=null;const l=r.length;for(let c=0;!a&&c<l;c++){const h=r[c],u=t?.(h);u&&(u.delete===!0?i.push(h):u.update!==void 0&&(i.push(h),o.push(u.update)),u&&u.break===!0&&(a=u))}for(let c=0;c<i.length;c++)this.remove(i[c]);return this.load(o),a}getBoundingCoords(){const e=this._getReadTree().toJSON();return e&&e.children&&e.children.length!==0?{colStart:e.minX/10,rowStart:e.minY/10,colEnd:(e.maxX-5)/10,rowEnd:(e.maxY-5)/10}:null}size(){return this._getReadTree().all().length}isEmpty(){return this._getReadTree().isEmpty()}search(e,t=!1,n){const r=this._getReadTree();if(r.isEmpty())return N.EmptyArray;let o;if(!t){if(o=this._lastMiss,o.colStart!==Number.MAX_SAFE_INTEGER&&k.isRangeWithinRange(e,o))return N.EmptyArray;if(this._lastSingle&&k.isRangeWithinRange(e,o))return this._lastSingleResult}const i=r.searchRange(e,t,n);return t||(i.length===0?(o.colStart=e.colStart,o.rowStart=e.rowStart,o.colEnd=e.colEnd,o.rowEnd=e.rowEnd):i.length===1?(this._lastSingle=i[0],this._lastSingleResult=i):(this._lastMiss.colStart=Number.MAX_SAFE_INTEGER,this._lastSingle=null,this._lastSingleResult=null)),i}has(e){const t=this._getReadTree();return t.collides(t.toBBox(e))}all(e){return this._getReadTree().all(e)}shift(e){const t=e.range,n=e.direction,r=e.cloneIfUpdate??!1,o=e.coordValidator??null,i=e.onShift??null,a=n===Oe.Left||n===Oe.Right,l=a?ie.Column:ie.Row,c=n===Oe.Up||n===Oe.Left?-1:1,h=(a?t.colEnd-t.colStart+1:t.rowEnd-t.rowStart+1)*c,u=[],d=[];let g=null;const m=this.getBoundingCoords();if(!m)return this;const f=n===Oe.Up||n===Oe.Left?Oe.Right:Oe.Left,_=new Map,p=new Map,S=this._options?.updateEntryOptions,C=S?.isMergeOnShift??!1,y=S?.isSplitOnExpand??!1,b=S?.isTrailingEdge??!1,w=n===Oe.Left||n===Oe.Up,E=S?.getSplit??ti,I=S?.getShifted,x=S?.onShifted,v=S?.onRemoved,R=S?.onMerged,A=S?.onUpdated,M=x?[]:null,T=v?[]:null,F=A?[]:null;this.visitRanges({colStart:t.colStart-(a?1:0),rowStart:t.rowStart-(a?0:1),colEnd:a?m.colEnd:t.colEnd,rowEnd:a?t.rowEnd:m.rowEnd},P=>{if((a?P.colEnd<t.colStart:P.rowEnd<t.rowStart)&&!b)return;const B=x_(t,P,a?Yn.Column:Yn.Row),z=P.group;if(w&&!z&&t.colStart<=P.colStart&&t.rowStart<=P.rowStart&&t.colEnd>=P.colEnd&&t.rowEnd>=P.rowEnd){const H=_u(P,null,{after:null,before:P,intersect:t,isSplit:B,orientation:l,amount:h},I,E,i,!1);if(H===void 0)return;if(H===null)return g=k.unionRanges(g,P),T&&T.push(P),void u.push(P)}let O={...P};n===Oe.Right?(t.colStart<=O.colStart&&(O.colStart+=h),O.colEnd+=h):n===Oe.Left?t.colStart<O.colStart?(O.colStart=Math.max(O.colStart+h,t.colStart),O.colEnd=Math.max(O.colEnd+h,O.colStart-1)):O.colEnd+=Math.max(h,t.colStart-O.colEnd-1):n===Oe.Down?(t.rowStart<=O.rowStart&&(O.rowStart+=h),O.rowEnd+=h):n===Oe.Up&&(t.rowStart<O.rowStart?(O.rowStart=Math.max(O.rowStart+h,t.rowStart),O.rowEnd=Math.max(O.rowEnd+h,t.rowStart-1)):O.rowEnd+=Math.max(h,t.rowStart-O.rowEnd-1)),(O.colEnd<O.colStart||O.rowEnd<O.rowStart)&&(O=null);const W=_u(P,O,{after:O,before:P,intersect:t,isSplit:B,orientation:l,amount:h},I,E,i,y&&h>0);if(W===void 0)return;const V=W===null?[O]:W,j=V.length;if(V[0]!==P||j!==1){if(o)for(let G=0;G<j;G++){const $=V[G];$&&o($)}let H;z?(_.set(z.uuid,z),H=[],p.set(P.uuid,H)):u.push(P);for(let G=0;G<j;G++){const $=V[G];g=k.unionRanges(g,$),z?H.push($):(d.push($),M&&M.push($),F&&F.push(P))}}},f);let L=null;L=r&&(u.length>0||d.length>0||p.size>0)?this.clone():this,L._updateNodes(d,u),p.size>0&&L._updateGroupedEntries(_,p);let D=N.EmptyArray;if(C&&m&&g){let P=!0;if(h>0&&(P=a?t.rowStart>m.rowStart||t.rowEnd<m.rowEnd:t.colStart>m.colStart||t.colEnd<m.colEnd),P){const B=fu(g,k.unionRanges(m,g),a?0:1,a?1:0);R&&(D=L._mergeNodes(B,!1))}}return A&&F.length>0&&A(F),x&&M.length>0&&x(M),R&&D.length>0&&R(D),v&&T.length>0&&v(T),L}insertNonOverlapping(e,t){const n=t?.onIntersect??((C,y)=>({...C,value:y.value})),r=this.search(e),o=new Map,i=new Map,a=this._options?.updateEntryOptions,l=a?.onUpdated,c=a?.onRemoved,h=a?.onMerged,u=a?.getSplit,d=a?.getIntersect,g=a?.getUpdate;let m=null,f=null,_=null,p=function(C,y,b){const w=b?.getIntersect??E_,E=b?.getUpdate??v_;if(C.length===0){if(w){const B=w({...y,value:null},y);y=B&&B.value!==null?{...B}:null}if(E){const B=E(y);B!==void 0&&(y=B)}return y?[y]:N.EmptyArray}const I=b?.getSplit??b_,x=(B,z,O=!0)=>{const W=z.search(B),V=W.length;for(let j=0;j<V;j++){const H=W[j];if(k.isEqualRanges(H,B))continue;z?.remove(H);const G=Hr(H,B,I,O);for(let $=0;$<G.length;$++){const te=G[$];z.insert(te),x(te,z,!1)}}},v=new be;v.load(C),x(y,v);const R=new be;R.load([y]);const A=v.search(y);for(let B=0;B<A.length;B++)x(A[B],R);const M=(B,z,O)=>{let W=z.search(B);console.assert(W.length<=1,"intersecting incorrect ranges");const V=W[0]??{...B,value:null};if(k.isEqualRanges(V,B)){let j=w(V,B);z.remove(V),O.insert(j)}else{z.remove(V);const j=Hr(V,B,I),H=j.length;for(let G=0;G<H;G++){const $=j[G];if(k.isEqualRanges($,B)){const te=w($,B);O.insert(te)}else z.insert($)}}},T=new be,F=R.all(),L=F.length;for(let B=0;B<L;B++)M(F[B],v,T);const D=(B,z)=>{const O=B.all(),W=O.length;for(let V=0;V<W;V++){let j=O[V];if(E){const H=E(j);H!==void 0&&(j=H)}j!==null&&j.value!==null&&z.push(j)}},P=v.all();return D(T,P),P}(r,e,{getSplit:(C,y,b,w)=>{let E;return u?(E=u(C,y,b,w),E):(E=ti(C,y,b,w),E)},getIntersect:(C,y)=>{d&&(y=d(C,y));const b=n(C,y);return b===void 0||(b===null||b.value===null)&&C.value?.onRemove?.(C),b},getUpdate:C=>{const y=C?.group;if(y){o.set(y.uuid,y);let w=i.get(C.lastId??C.uuid);w||(w=[],i.set(C.lastId??C.uuid,w)),w.push(C.value===null?null:C)}let b=C;if(g&&(b=g(C)),b&&b.value!==null)l&&(m||(m=[]),m.push(b));else if(c&&!_){_=[];let w=b&&b.value===null?b:{...C,value:null};_.push(w)}return b}});const S=this.getBoundingCoords();if(o.size>0){const C=[],y=p.length;for(let b=0;b<y;b++){let w=p[b];w.group||C.push(w)}p=C}if(this._updateNodes(p,r,t?.onUpdates),o.size>0&&this._updateGroupedEntries(o,i),S&&!t?.noMerge){const C=fu(e,k.unionRanges(S,e)),y=this.search(C);if(y.length>1){const b=a?.getMerged??pu;let w=y;w=gn(w,ie.Column,1,b),w=gn(w,ie.Row,1,b),y.length!==w.length&&(h&&w.length>0&&(f=w),this._updateNodes(w,y,t?.onUpdates))}}return m&&l(m),f&&h(f),_&&c(_),this}insertGroup(e,t){t=t??N.uuidV4();const n=[],r=e.length;for(let o=0;o<r;o++){const i={...e[o],group:{entries:n,uuid:t,offset:o},uuid:N.uuidV4()};n.push(i),e[o]=i}return this.load(e),this._options?.updateEntryOptions?.onGroupUpdate?.(e,t),this}createCopiedEntries(e,t,n,r,o){return I_(this,e,t,n,r,o,this._options?.updateEntryOptions?.getSplit??ti)}_updateGroupedEntries(e,t){const n=[],r=[],o=new Map,i=e.values();let a=i.next();for(;!a.done;){const l=a.value,c=l.entries,h=l.uuid,u=[];for(let d=0;d<c.length;d++){let g=c[d];n.push(g);let m=t.get(g.uuid);m===void 0&&(m=[{...g}]);for(let f=0;f<m.length;f++){let _=m[f];_!==null&&(_={..._,group:{offset:u.length,entries:u,uuid:h}},u.push(_),r.push(_))}}u.sort((d,g)=>d.group.offset-g.group.offset),o.set(h,u),a=i.next()}if(this._updateNodes(r,n),o){const l=this._options?.updateEntryOptions?.onGroupUpdate;if(l){const c=o.entries();let h=c.next();for(;!h.done;){const u=h.value[0];l(h.value[1],u),h=c.next()}}}}_copy(e,t){let n=e.rTree.all();const r=new mu(this._options?.maxNodeEntries);return t&&(n=n.concat(t)),n.length>0&&r.load(n),{refCount:1,rTree:r}}_updateNodes(e,t,n){if(!(e&&e.length!==0||t&&t.length!==0))return;const r=this._getWritableTree();if(t){const o=t.length;for(let i=0;i<o;i++)r.remove(t[i])}e.length>0&&r.load(e),n?.(e,t,this),this._options?.updateEntryOptions?.onUpdates?.(e,t,this)}_mergeNodes(e,t){const n=this.search(e,t);let r=N.EmptyArray;if(n.length>1){const o=this._options?.updateEntryOptions.getMerged??pu;let i=n;i.length>1&&(i=gn(i,ie.Column,1,o)),i.length>1&&(i=gn(i,ie.Row,1,o)),n.length!==i.length&&(r=i,this._updateNodes(i,n))}return r}_getReadTree(){return this._shared?.rTree??this._rTree}_ensureWritable(e){const t=this._shared;if(!t)return;if(t.refCount--,t.refCount===0)return this._shared=null,void(e&&this._rTree.load(e));const n=this._copy(t,e);this._shared=null,this._rTree=n.rTree}_getWritableTree(e){return this._lastMiss.colStart=Number.MAX_SAFE_INTEGER,this._lastSingle=null,this._lastSingleResult=null,this._shared?(this._ensureWritable(e),this._rTree):(e&&this._rTree.load(e),this._rTree)}remove(e,t){return e&&this._getWritableTree().remove(e,t??k.isEqualRanges),this}insert(e){return e&&this._getWritableTree().insert(e),this}load(e){return e&&e.length>0&&this._getWritableTree(e),this}clear(){return this.isEmpty()||this._getWritableTree().clear(),this}clone(e=null){if(e!==null&&this._cloneKey===e)return this;let t=this._shared;t||(t={rTree:this._rTree,refCount:1},this._shared=t),t.refCount++;const n=new be(this._options);return n._shared=t,n._cloneKey=e,n}fromJSON(e){return this._getWritableTree().fromJSON(e),this}}const fu=(s,e=s,t=1,n=1)=>({...s,colStart:Math.max(s.colStart-t,e.colStart),rowStart:Math.max(s.rowStart-n,e.rowStart),colEnd:Math.min(s.colEnd+t,e.colEnd),rowEnd:Math.min(s.rowEnd+n,e.rowEnd)});function b_(s,e,t,n){return[{...e[0],value:s.value},{...e[0],value:s.value}]}function E_(s,e){return{...s}}function Hr(s,e,t=null,n=!0){if(k.isEqualRanges(s,e))return[{...s}];const r=k.intersectRanges(s,e,R_);if(!r)return null;const o=[],i=s.uuid;let a=s;if(a.rowStart<r.rowStart){const l={...a,colStart:a.colStart,rowStart:a.rowStart,colEnd:a.colEnd,rowEnd:r.rowStart-1};i&&(n&&(l.lastId=i),l.uuid=N.uuidV4());const c={...a,colStart:a.colStart,rowStart:r.rowStart,colEnd:a.colEnd,rowEnd:a.rowEnd};i&&(n&&(c.lastId=i),c.uuid=N.uuidV4());const h=c.rowStart-l.rowStart;vt[0]=l,vt[1]=c;const u=t(a,vt,ie.Row,h);u!==void 0&&(o.push(u[0]),a=u[1])}if(a.rowEnd>r.rowEnd){const l={...a,colStart:a.colStart,rowStart:a.rowStart,colEnd:a.colEnd,rowEnd:r.rowEnd};i&&(n&&(l.lastId=i),l.uuid=N.uuidV4());const c={...a,colStart:a.colStart,rowStart:r.rowEnd+1,colEnd:a.colEnd,rowEnd:a.rowEnd};i&&(n&&(c.lastId=i),c.uuid=N.uuidV4());const h=c.rowStart-l.rowStart;vt[0]=l,vt[1]=c;const u=t(a,vt,ie.Row,h);u!==void 0&&(o.push(u[1]),a=u[0])}if(a.colStart<r.colStart){const l={...a,colStart:a.colStart,rowStart:a.rowStart,colEnd:r.colStart-1,rowEnd:a.rowEnd};i&&(n&&(l.lastId=i),l.uuid=N.uuidV4());const c={...a,colStart:r.colStart,rowStart:a.rowStart,colEnd:a.colEnd,rowEnd:a.rowEnd};i&&(n&&(c.lastId=i),c.uuid=N.uuidV4());const h=c.colStart-l.colStart;vt[0]=l,vt[1]=c;const u=t(a,vt,ie.Column,h);u!==void 0&&(o.push(u[0]),a=u[1])}if(a.colEnd>r.colEnd){const l={...a,colStart:a.colStart,rowStart:a.rowStart,colEnd:r.colEnd,rowEnd:a.rowEnd};i&&(n&&(l.lastId=i),l.uuid=N.uuidV4());const c={...a,colStart:r.colEnd+1,rowStart:a.rowStart,colEnd:a.colEnd,rowEnd:a.rowEnd};i&&(n&&(c.lastId=i),c.uuid=N.uuidV4());const h=c.colStart-l.colStart;vt[0]=l,vt[1]=c;const u=t(a,vt,ie.Column,h);u!==void 0&&(o.push(u[1]),a=u[0])}return a===s&&(a={...s}),o.push(a),o}function v_(s){return s.value===null?null:s}function gn(s,e=ie.Column,t=2,n,r){let o=[...s];if(t<=0||s.length<=1)return o;let i=e===ie.Column,a=0,l=!1;do{const c=o.sort(k.createRangeComparator(i?ie.Row:ie.Column));o=[],l=!1,o.push(c[0]);for(let h=1;h<c.length;h++){const u=c[h],d=o[o.length-1];let g=!1;if(g=i?d&&d.rowStart===u.rowStart&&d.rowEnd===u.rowEnd&&d.colEnd+1===u.colStart:d&&d.colStart===u.colStart&&d.colEnd===u.colEnd&&d.rowEnd+1===u.rowStart,g){let m={...d,colEnd:i?u.colEnd:d.colEnd,rowEnd:i?d.rowEnd:u.rowEnd};if(n){const f=r??[null,null];f[0]=d,f[1]=u,m=n(f,m,e)}if(m){o[o.length-1]=m,l=!0;continue}}o.push(u)}a++,i=!i}while(a<t&&l&&o.length>1);return o}const zl=(s,e=2,t=ie.Row,n,r,o)=>{if(s.length<=1)return[...s];let i=[];const a=t===ie.Column,l=new Ii.IteratorInstance(s,{orientation:a?ie.Row:ie.Column});let c=l.next();for(;!c.done;){const h=c.value;c=l.next();const u=h.range;if(e>0){const d=i[i.length-1];let g=!1;if(g=a?d&&d.rowStart===u.rowStart&&d.rowEnd===u.rowEnd&&d.colEnd+1===u.colStart:d&&d.colStart===u.colStart&&d.colEnd===u.colEnd&&d.rowEnd+1===u.rowStart,g){let m={...d,colEnd:a?u.colEnd:d.colEnd,rowEnd:a?d.rowEnd:u.rowEnd};if(m){i[i.length-1]=m;continue}}}i.push(u)}return e>1&&(i=gn(i,a?ie.Row:ie.Column,e,n,o)),i};function ti(s,e,t,n){const r=s.value;if(r?.getSplit){const o=r.getSplit(e,t,n);if(o===void 0)return;e[0].value=o[0],e[1].value=o[1]}return e}function pu(s,e,t){const n=s[0].value,r=s[1].value;if(n?.getMerged&&r){const o=n.getMerged(s[1].value,k.sanitizeRange(e),t);if(o===void 0)return;e.value=o}return e}const x_=(s,e,t=Yn.Both)=>{const n=i=>i?s.rowStart>e.rowStart&&s.rowStart<=e.rowEnd||s.rowEnd<e.rowEnd&&s.rowEnd>=e.rowStart:s.colStart>e.colStart&&s.colStart<=e.colEnd||s.colEnd<e.colEnd&&s.colEnd>=e.colStart;let r=t===Yn.Column,o=t===Yn.Row;return t===Yn.Both&&(r=o=!0),!(!r||!n(!0))||!(!o||!n(!1))};function _u(s,e,t,n,r,o,i){const a=t.orientation===ie.Column,l=t.intersect,c=(h,u)=>{let d=h.value,g=null,m=u.after;if(i){let f=null,_=0,p=0;if(a&&l.colStart>h.colStart?(f={...h,colEnd:l.colStart-1},p=u.amount):!a&&l.rowStart>h.rowStart&&(f={...h,rowEnd:l.rowStart-1},_=u.amount),f){const S=Hr(s,f,r);if(S.length>1)for(let C=0;C<S.length;C++){let y=S[C];k.isEqualRanges(y,f)?(g=g??[],g.push(y)):(m=y,d=y.value,u={...u,after:{...y,colStart:y.colStart+p,rowStart:y.rowStart+_,colEnd:y.colEnd+p,rowEnd:y.rowEnd+_,uuid:N.uuidV4()},before:y,intersect:f,isSplit:!0})}}}if(n?m=n(u.before,u.after,u):d&&d.getShifted?m=d.getShifted(u):u.after&&(m={...u.after,value:h.value}),m!==void 0)return o&&(m!==u.after&&(u={...u,after:m}),o(u)),m=(f=>{if(!f){const _=s.value;return _.onRemove&&_.onRemove(k.sanitizeRange(t.before)),null}return f})(m),m&&(g=g??[],g.push(m)),g};if(t.isSplit){let h;h=a?{...s,rowStart:Math.max(l.rowStart,t.before.rowStart),rowEnd:Math.min(l.rowEnd,t.before.rowEnd)}:{...s,colStart:Math.max(l.colStart,t.before.colStart),colEnd:Math.min(l.colEnd,t.before.colEnd)};const u=Hr(s,h,r),d=[];for(let g=0;g<u.length;g++){const m=u[g];if(k.isEqualRanges(m,h)){let f=null;e&&(f=a?{colStart:e.colStart,rowStart:h.rowStart,colEnd:e.colEnd,rowEnd:h.rowEnd,value:m.value}:{colStart:h.colStart,rowStart:e.rowStart,colEnd:h.colEnd,rowEnd:e.rowEnd,value:m.value});const _=c(m,{...t,before:m,after:f});if(_)for(let p=0;p<_.length;p++)d.push(_[p])}else d.push(m)}return d}return c(s,t)}const I_=(s,e,t,n,r,o,i)=>{const a=t.colEnd-t.colStart+1,l=t.rowEnd-t.rowStart+1,c=t.colStart-e.colStart,h=t.rowStart-e.rowStart,u=n?.transpose??!1;let d=1,g=1;u?(d=e.rowEnd-e.rowStart+1,g=e.colEnd-e.colStart+1):(d=e.colEnd-e.colStart+1,g=e.rowEnd-e.rowStart+1);const m=Math.ceil(a/d),f=Math.ceil(l/g),_=r??[],p=o??N.EmptyArray,S=t.colEnd,C=t.rowEnd;return s.visitRanges(e,y=>{let b=y.value;if(!b.copyTo)return;let w=y;if(!k.isRangeWithinRange(w,e)){const F=Hr(w,e,i);w=F[F.length-1]}b=w.value;let E=w.colEnd-w.colStart+1,I=w.rowEnd-w.rowStart+1,x=c+w.colStart,v=h+w.rowStart;if(u){x=w.rowStart-e.rowStart+t.colStart,v=w.colStart-e.colStart+t.rowStart;const F=E;E=I,I=F}let R=m,A=f;const M=a<=R*E,T=l<=A*I;if(M||T){const F=b?.canTile?.({colStart:x,rowStart:v,colEnd:Math.min(x+(M?a:E)-1,S),rowEnd:Math.min(v+(T?l:I)-1,C)},n);!M||F!==!0&&F!==ie.Column||(E=a,R=1),!T||F!==!0&&F!==ie.Row||(I=l,A=1)}for(let F=0;F<R;F++){const L=x+F*d;for(let D=0;D<A;D++){const P=v+D*g,B=Math.min(L+E-1,S),z=Math.min(P+I-1,C),O={colStart:L,rowStart:P,colEnd:B,rowEnd:z};if(L>B||P>z)continue;const W=b.copyTo(O,n);W&&_.push({...O,value:W})}}},Oe.Right),{inserts:_,removes:p}},vt=[null,null],R_={colStart:0,rowStart:0,colEnd:0,rowEnd:0},yt=(s=Number.MIN_SAFE_INTEGER,e=Number.MIN_SAFE_INTEGER,t=Number.MAX_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER,r,o,i)=>{if(o&&(s!==Number.MIN_SAFE_INTEGER&&s<o.colStart||e!==Number.MIN_SAFE_INTEGER&&e<o.rowStart||t!==Number.MAX_SAFE_INTEGER&&t>o.colEnd||n!==Number.MAX_SAFE_INTEGER&&n>o.rowEnd))throw new Ne;return i&&(s=Math.max(i.colStart,s),e=Math.max(i.rowStart,e),t=Math.min(i.colEnd,t),n=Math.min(i.rowEnd,n),t<s||n<e)?null:(ao.majorStart=r?s:e,ao.majorEnd=r?t:n,ao.minorStart=r?e:s,ao.minorEnd=r?n:t,ao)},Go=(s,e,t)=>{const n={colStart:0,rowStart:0,colEnd:0,rowEnd:0};return n.colStart=e?s.majorStart:s.minorStart,n.rowStart=e?s.minorStart:s.majorStart,n.colEnd=e?s.majorEnd:s.minorEnd,n.rowEnd=e?s.minorEnd:s.majorEnd,n},ao={majorStart:0,majorEnd:0,minorStart:0,minorEnd:0},Su=(s,e)=>s[0]-e[0];class vm{constructor(e,t){this._isColumn=!0,this._isReverse=!1,this._skipMajors=!1,this._majorMin=Number.MAX_SAFE_INTEGER,this._majorMax=Number.MIN_SAFE_INTEGER,this._minorMin=Number.MAX_SAFE_INTEGER,this._minorMax=Number.MIN_SAFE_INTEGER,this._majorIndex=Number.MIN_SAFE_INTEGER,this._minorIndex=Number.MIN_SAFE_INTEGER,this._delegateMajorIndex=Number.MIN_SAFE_INTEGER,this._delegateMinorIndex=Number.MIN_SAFE_INTEGER,this._delegate=e;const n=(t.orientation??ie.Column)===ie.Column;this._isColumn=n,this._isReverse=t.reverse??!1,this._skipMajors=t.skipMajors??!1;const r=t.bounds,o=r.colStart,i=r.rowStart,a=r.colEnd,l=r.rowEnd;this._majorMin=n?o:i,this._majorMax=n?a:l,this._minorMin=n?i:o,this._minorMax=n?l:a,this._processMajorSkip=n?t.processColumnSkip:t.processRowSkip,this._processMinorSkip=n?t.processRowSkip:t.processColumnSkip;const c=e.next();this._delegateResult=c,this._initialize()}_initialize(){const e=this._isColumn,t=this._isReverse,n=t?-1:1;let r=t?this._majorMax:this._majorMin,o=(t?this._minorMax:this._minorMin)-n;const i=this._processMinorSkip;i&&(o=i(o,t));const a=this._processMajorSkip;a&&(r=a(r,t)),this._majorIndex=r,this._minorIndex=o;const l=this._delegateResult;if(l.done)this._delegateMajorIndex=this._majorMax,this._delegateMinorIndex=this._minorMax+n;else{const c=l.value[0];this._delegateMajorIndex=e?c.colIndex:c.rowIndex,this._delegateMinorIndex=e?c.rowIndex:c.colIndex}}next(e){e!==void 0&&(this._delegateResult=this._delegate.next(e),this._initialize());const t=this._isReverse,n=this._isColumn,r=this._majorMin,o=this._majorMax;let i=this._majorIndex,a=this._minorIndex;if(i>o||i<r)return Re;let l=this._delegateMajorIndex,c=this._delegateMinorIndex,h=this._delegateResult.done;if(i===l&&a===c){const g=this._delegate.next();if(this._delegateResult=g,h=g.done,h)l=t?r:o,l=t?this._minorMin:this._minorMax;else{const m=g.value[0];l=n?m.colIndex:m.rowIndex,c=n?m.rowIndex:m.colIndex}this._delegateMajorIndex=l,this._delegateMinorIndex=c}const u=t?-1:1;if(this._minorIndex=a+=u,i===l&&a===c&&!h)return this._delegateResult;const d=this._processMinorSkip;if(d&&(a=d(a,t)),a>this._minorMax||a<this._minorMin){i+=u;const g=this._processMajorSkip;g&&(i=g(i,t)),this._skipMajors&&(!t&&i<l||t&&i>l)&&(i=l),this._majorIndex=i,a=t?this._minorMax:this._minorMin}return this._minorIndex=a,i===l&&a===c&&!h?this._delegateResult:i>o||i<r?Re:{done:!1,value:[{colIndex:n?i:a,rowIndex:n?a:i}]}}return(e){return null}throw(e){return null}[Symbol.iterator](){return this}}class Wl{constructor(e){this._isColumn=!0,this._majorSize=Number.MAX_SAFE_INTEGER,this._minorSize=Number.MAX_SAFE_INTEGER,this._majorMin=Number.MAX_SAFE_INTEGER,this._majorMax=Number.MIN_SAFE_INTEGER,this._minorMin=Number.MAX_SAFE_INTEGER,this._minorMax=Number.MIN_SAFE_INTEGER,this._majorIndex=Number.MAX_SAFE_INTEGER,this._minorIndex=Number.MAX_SAFE_INTEGER,this._minorOffset=0,this._minorRepeat=0,this._majorOffset=-1,this._majorRepeat=1,this._pattern=[];const t=e.delegate;this._delegate=t;const n=(e.orientation??ie.Column)===ie.Column;this._isColumn=n;const r=e.dims,o=e.bounds,i=o.colStart,a=o.rowStart,l=o.colEnd,c=o.rowEnd;if(this._majorSize=1+(n?l-i:c-a),this._minorSize=1+(n?c-a:l-i),this._majorMin=n?i:a,this._minorMin=n?a:i,this._majorMax=(n?i+r.major:a+r.major)-1,this._minorMax=(n?a+r.minor:i+r.minor)-1,this._majorSize>this._majorMax+1||this._minorSize>this._minorMax+1)throw new Error("The dimensions must be larger than the bounds.");const h=t.next();this._nextDelegateResult=h,this._initialize()}_initialize(){const e=this._isColumn,t=this._nextDelegateResult;if(t.done)this._nextResult=Re;else{const n=t.value[0],r=e?n.colIndex:n.rowIndex,o=e?n.rowIndex:n.colIndex,i=[[o,t.value[1]]];this._minorSpan=i,this._majorIndex=r,this._minorIndex=o,this._pattern.push([r,i]),this._nextResult=t}}next(e){if(e!==void 0)throw new nc;const t=this._nextResult,n=this._isColumn;let r=this._majorIndex,o=this._nextDelegateResult;if(!o.done){const c=o.value[0];if((n?c.colIndex:c.rowIndex)===r&&(o=this._delegate.next(),this._nextDelegateResult=o,!o.done)){const h=o.value,u=h[0],d=n?u.colIndex:u.rowIndex,g=n?u.rowIndex:u.colIndex;if(d===r)return this._minorSpan.push([g,h[1]]),this._minorOffset=this._minorSpan.length-1,this._minorIndex=g,this._nextResult=o,t}}const i=this._minorMax;let a=this._minorIndex;if(a<i){let c=this._minorOffset;c++;const h=this._minorSpan;c>=h.length&&(c=0,this._minorRepeat++);const u=h[c],d=this._minorMin;if(a=d+(u[0]-d+this._minorSize*this._minorRepeat),this._minorIndex=a,this._minorOffset=c,a<=i){const g=[{colIndex:n?r:a,rowIndex:n?a:r},u[1]];return this._nextResult={done:!1,value:g},t}}if(!o.done){const c=o.value,h=c[0],u=n?h.colIndex:h.rowIndex,d=n?h.rowIndex:h.colIndex,g=[[d,c[1]]];return this._pattern.push([u,g]),this._majorIndex=u,this._minorSpan=g,this._minorOffset=0,this._minorIndex=d,this._minorRepeat=0,this._nextResult=o,t}const l=this._majorMax;if(r<l){let c=this._majorOffset;c++;const h=this._pattern;c>=h.length&&(c=0,this._majorRepeat++);const u=h[c],d=u[1],g=d[0],m=this._majorMin;if(r=m+(u[0]-m+this._majorSize*this._majorRepeat),this._majorIndex=r,this._majorOffset=c,r<=l){this._minorSpan=d,this._minorOffset=0,a=g[0],this._minorIndex=a,this._minorRepeat=0;const f=[{colIndex:n?r:a,rowIndex:n?a:r},g[1]];return this._nextResult={done:!1,value:f},t}}return t.done||(this._nextResult=Re),t}return(e){return null}throw(e){return null}[Symbol.iterator](){return this}}class wu{constructor(e,t,n){this._comparator=e?.comparator??k.createCellComparator(e.orientation??ie.Column,e.reverse??!1),this._iterator1=t,this._iterator2=n;const r=t.next();this._nextResult1=r;const o=n.next();this._nextResult2=o,e?.reuseResult&&(e.reuseResult===!0?this._reuseResult={done:!1,value:[void 0,void 0,void 0,void 0]}:this._reuseResult=e.reuseResult)}next(e){let t=this._nextResult1,n=this._nextResult2;if(t.done&&n.done)return t;if(t.done){const a=n;this._nextResult2=this._iterator2.next();const l=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};l.done=!1;const c=l.value,h=a.value;return c[2]=h[0],c[3]=h[1],c[0]=void 0,c[1]=void 0,l}if(n.done){const a=t;this._nextResult1=this._iterator1.next();const l=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};l.done=!1;const c=l.value,h=a.value;return c[0]=h[0],c[1]=h[1],c[2]=void 0,c[3]=void 0,l}let r=(0,this._comparator)(t.value[0],n.value[0]);if(r<0){const a=t;this._nextResult1=this._iterator1.next();const l=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};l.done=!1;const c=l.value,h=a.value;return c[0]=h[0],c[1]=h[1],c[2]=void 0,c[3]=void 0,l}if(r>0){const a=n;this._nextResult2=this._iterator2.next();const l=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};l.done=!1;const c=l.value,h=a.value;return c[2]=h[0],c[3]=h[1],c[0]=void 0,c[1]=void 0,l}this._nextResult1=this._iterator1.next(),this._nextResult2=this._iterator2.next();const o=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};o.done=!1;const i=o.value;return i[0]=t.value[0],i[1]=t.value[1],i[2]=n.value[0],i[3]=n.value[1],o}return(e){return null}throw(e){return null}[Symbol.iterator](){return this}}const yu="Must be an array of arrays.",ni=(s,e,t)=>{const n=e.majorStart,r=e.minorStart,o=e.majorEnd,i=[],a=e.minorEnd-r+1,l=typeof s=="function";for(let c=n;c<=o;c++){const h=new Array(a);if(l)if(t){let d=r;for(let g=0;g<a;g++)h[g]=s(d++,c)}else{let d=r;for(let g=0;g<a;g++)h[g]=s(c,d++)}else h.fill(s,0,a);const u=[[r,h]];i.push([c,u])}return{tuples:i,bounds:e}},Ri=(s,e=!1,t=null,n=!1)=>{let r=0,o=0,i=Number.MAX_SAFE_INTEGER,a=Number.MAX_SAFE_INTEGER;if(t&&(r=t.majorStart??0,o=t.minorStart??0,i=(t.majorEnd??Number.MAX_SAFE_INTEGER)-r+1,a=(t.minorEnd??Number.MAX_SAFE_INTEGER)-o+1),e){const c=r;r=o,o=c;const h=i;i=a,a=h}if(!Array.isArray(s))throw new Error(yu);if(s.length>i)throw new Ne;const l=e?new exports.Tuple.TransposedBuilder:new exports.Tuple.Builder;for(let c=0;c<s.length;c++){let h=s[c];if(h!=null&&h.length!==0){if(!Array.isArray(h))throw new Error(yu);if(h.length>a)throw new Ne;if(n){let u=-1;for(let d=0;d<h.length;d++)h[d]==null?u!==-1&&(l.addValues(c+r,o+u,h.slice(u,d)),u=-1):u===-1&&(u=d);u!==-1&&l.addValues(c+r,o+u,h.slice(u))}else l.addValues(c+r,o,h)}}return l.build()},A_=(s,e,t)=>{if(s===e)return e},M_=(s,e,t)=>{if(s[0].value===s[1].value)return e},T_=[null,null],Ln=(s=!0,e=A_)=>{const t=[];let n,r,o=Number.MIN_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER;return{append:(a,l,c)=>{let h=!0;if(c!==void 0){const g=r===void 0?c:e(r,c,s);g===void 0?h=!1:c=g}if(h&&l===i+1&&a===o)return s?n.rowEnd=l:n.colEnd=l,i=l,void(r=c);n&&t.push(n);const u=s?a:l,d=s?l:a;n={colStart:u,rowStart:d,colEnd:u,rowEnd:d,value:c},o=a,i=l,r=c},done:(a=!1)=>(n&&(t.push(n),n=null),a?gn(t,s?ie.Column:ie.Row,2,M_,T_):t)}};class Zt{constructor(e){this._major=null,this._dataCoords=null,this._count=0,this._isColumn=!0,this._lastMajor=Number.MIN_SAFE_INTEGER,this._lastMinorSpan=null,this._maxCoords=null,this._isShared=!1,this._options={orientation:ie.Row,...e},this._isColumn=(e?.orientation??ie.Column)===ie.Column,e?.maxCoords&&(this._maxCoords=Object.freeze({colStart:Math.max(0,e.maxCoords.colStart??0),rowStart:Math.max(0,e.maxCoords.rowStart??0),colEnd:Math.min(Number.MAX_SAFE_INTEGER,e.maxCoords.colEnd??Number.MAX_SAFE_INTEGER),rowEnd:Math.min(Number.MAX_SAFE_INTEGER,e.maxCoords.rowEnd??Number.MAX_SAFE_INTEGER)})),this._createRun=e?.createRun??(t=>new kt(t)),this._optionsMinor={},this._major=new Wn({nodeSize:F_})}getRuns(e){const t=this._isColumn,n=this._maxCoords,r=this.getCoords();if(!r)return qe;const o=e?.bounds;let i,a;if(o){const _=yt(o?.colStart??Number.MIN_SAFE_INTEGER,o?.rowStart??Number.MIN_SAFE_INTEGER,o?.colEnd??Number.MAX_SAFE_INTEGER,o?.rowEnd??Number.MAX_SAFE_INTEGER,t,n,r);if(!_)return qe;i={bounds:{min:_.majorStart,max:_.majorEnd}},a={bounds:{min:_.minorStart,max:_.minorEnd}}}const l=this._major.entries(i);let c=l.next();if(c.done)return qe;let h=c.value[0],u=c.value[1],d=u.runs(a),g=d.next();if(g.done)return qe;let m=g.value[0].min,f=g.value[1];return{[Symbol.iterator](){return this},next(){if(c.done)return Re;const _={done:!1,value:[h,m,f]};for(g=d.next();g.done&&!c.done;)c=l.next(),c.done||(h=c.value[0],u=c.value[1],d=u.runs(a),g=d.next());return g.done||(m=g.value[0].min,f=g.value[1]),_}}}getOrientation(){return this._isColumn?ie.Column:ie.Row}entries(e){const t=this._isColumn;let n=t,r=!0;const o=this._maxCoords,i=this.getCoords(),a=yt(Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,t,o,i);if(!a)return qe;let l,c,h,u=a.majorStart,d=a.majorEnd,g=a.minorStart,m=a.minorEnd,f=!1;if(e){e?.orientation&&(n=e?.orientation===ie.Column,r=t===n);const w=e?.bounds;if(w){const E=yt(w.colStart,w.rowStart,w.colEnd,w.rowEnd,t,o,i);if(!E)return qe;u=E.majorStart,d=E.majorEnd,g=E.minorStart,m=E.minorEnd}f=e.reverse??!1,h=(E=>typeof E!="boolean"?E:E===!0?{done:!1,value:[{colIndex:-1,rowIndex:-1},null]}:void 0)(e.reuseResult),l=t?e.processColumnSkip:e.processRowSkip,l&&(f?d=l(d,f):u=l(u,f)),c=t?e.processRowSkip:e.processColumnSkip,c&&(f?m=c(d,f):g=c(g,f))}if(!i)return qe;r||u!==d||(r=!0),Le.bounds.min=u,Le.bounds.max=d,Le.reverse=f,Le.processSkip=l,Le.reuseResult=To;let _=this._major.entries(Le),p=Cu();const S=w=>{if(!w.nextActive)return;const E=v=>{const R=w.nextMinorIndex,A=w.nextMinorValue,M=w.nextActive;return v?(w.nextMinorIndex=v[0],w.nextMinorValue=v[1],w.nextActive=!0):(w.nextActive=!1,w.nextMinorIndex=f?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,w.nextMinorValue=null),w.value=A,w.minorIndex=R,w.active=M,An[0]=w.majorIndex,An[1]=R,An[2]=A,An},I=w.minorIterator;if(!I)return E();const x=I.next();return x.done&&(w.minorIterator=null),E(x.value)},C=w=>{if(_)for(;;){const E=_.next();if(E.done)return void(_=void 0);const I=E.value,x=I[1];x||console.warn("issue",x),w.majorIndex=I[0],w.active=!0,w.nextActive=!1,xt.bounds.min=g,xt.bounds.max=m,xt.reverse=f,xt.processSkip=c,xt.reuseResult=xm;const v=x.entries(xt),R=v.next();if(!R.done){const A=R.value;return w.nextMinorIndex=A[0],w.nextMinorValue=A[1],w.minorIterator=v,w.nextActive=!0,S(w)}}};let y=null;if(r)y=()=>{let w;return w=S(p),w||(w=C(p),w||void 0)};else{const w=f?m:g,E=f?g:m;let I,x=w,v=E,R=!0;const A=()=>{if(p.nextMajorCursor)return p=p.nextMajorCursor,p;p=I,(x<g||x>m||x===v)&&(p=null),x=v,v=E};y=()=>{for(;p;){let M=null;if(R){let T=I?Cu():p;if(M=C(T),M){I?(T.prevMajorCursor=p,p.nextMajorCursor=T,p=T):I=p,v=f?Math.max(v,p.nextMinorIndex):Math.min(v,p.nextMinorIndex);const F=p.minorIndex;F!==w&&(v=f?Math.max(v,F):Math.min(v,F),M=null)}else R=!1,A()}else{const T=p.minorIndex,F=p.nextMinorIndex;T===x?(An[0]=p.majorIndex,An[1]=T,An[2]=p.value,M=An):!f&&T>x||f&&T<x?v=f?Math.max(v,T):Math.min(v,T):!f&&F>x||f&&F<x?v=f?Math.max(v,F):Math.min(v,F):M=S(p),p.active&&(v=f?Math.max(v,p.nextMinorIndex):Math.min(v,p.nextMinorIndex)),E===x||p.active||(p.prevMajorCursor?p.prevMajorCursor.nextMajorCursor=p.nextMajorCursor:I=p.nextMajorCursor,p.nextMajorCursor&&(p.nextMajorCursor.prevMajorCursor=p.prevMajorCursor)),A()}if(M)return M}}}return{next(w){if(w)throw new nc("Iterator with next argument is not supported.");const E=y();return E?((x,v,R,A,M)=>{const T=M??{done:!1,value:[{colIndex:-1,rowIndex:-1},null]},F=T.value,L=F[0];return L.colIndex=A?x:v,L.rowIndex=A?v:x,F[1]=R,T})(E[0],E[1],E[2],t,h):Re},[Symbol.iterator](){return this},return:w=>null,throw:w=>null}}values(e){const t=this.entries(e);let n;return e?.reuseResult&&(n=e.reuseResult===!0?{done:!1,value:null}:e.reuseResult),{next(r){const o=t.next(r);return o.done?Re:n?(n.value=o.value[1],n):{done:!1,value:o.value[1]}},[Symbol.iterator](){return this},return:r=>null,throw:r=>null}}keys(e){const t=this.entries(e);let n;return e?.reuseResult&&(n=e.reuseResult===!0?{done:!1,value:null}:e.reuseResult),{next(r){const o=t.next(r);return o.done?Re:n?(n.value=o.value[0],n):{done:!1,value:o.value[0]}},[Symbol.iterator](){return this},return:r=>null,throw:r=>null}}_updateMajorSpan(e,t=!1){if(!e||e.length===0)return;t&&e.sort((l,c)=>l[0]-c[0]);const n=this._major,r=e[0];let o=r[0],i=o,a=[r[1]];for(let l=1;l<e.length;l++){const c=e[l],h=c[0],u=c[1];h===i+1?a.push(u):(n.setRunAt(o,new kt(a)),o=h,a=[u]),i=h}a.length>0&&n.setRunAt(o,new kt(a))}setValues(e){if(!e)throw new Ot;if(e.length===0)return this;const t=(e=e.sort(Su))[0][0],n=e[e.length-1][0];let r=Number.MIN_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER;const i=this._isColumn,a=this._maxCoords;if(a){const b=i?a.colStart:a.rowStart,w=i?a.colEnd:a.rowEnd;if(t<b||n>w)throw new Ne;r=i?a.rowStart:a.colStart,o=i?a.rowEnd:a.colEnd}if(!e||e.length===0)return this;let l=Number.MAX_SAFE_INTEGER,c=Number.MIN_SAFE_INTEGER,h=0,u=t-1;const d=[],g=(b,w,E)=>{if(u===E)throw new exports.Tuple.OutOfOrderError(`Duplicate major Indices: {${E}}.`);u=E,w=w.sort(Su),b=b.clone();let I=Number.MIN_SAFE_INTEGER;const x=w.length;for(let v=0;v<x;v++){const R=w[v],A=R[0],M=R[1],T=A+M.length-1;if(I>=A)throw new exports.Tuple.OutOfOrderError(`Overlapping minor Indices: {${E}, ${A}}.`);if(A<r||T>o)throw new Ne;if(M&&M.length>0){const F=b.getCount();b.setRunAt(A,m(M));const L=b.getCount();h+=L-F,l=Math.min(l,b.getCoords().min),c=Math.max(c,b.getCoords().max)}I=T}_++,d.push([E,b])},m=this._createRun,f=this._optionsMinor;let _=0;const p=()=>{const b=e[_],w=b[0],E=b[1],I=new Wn(f);g(I,E,w)},S=this._major;Le.bounds.min=t,Le.bounds.max=n,Le.reverse=!1,Le.processSkip=null,Le.reuseResult=To;const C=S.entries(Le);let y=C.next();for(;!y.done;){const b=y.value,w=b[0];let E=e[_],I=E[0];if(I>w)y=C.next();else{for(;I<w;)p(),E=e[_],I=E[0];if(I===w){const x=E[1],v=b[1];g(v,x,w)}y=C.next()}}for(;e[_];)p();return this._updateMajorSpan(d),this._updateCountAndCoords(h,t,l,n,c),this}_updateCountAndCoords(e,t,n,r,o,i=!1){const a=this._count+e;if(this._count=a,this._lastMajor=Number.MIN_SAFE_INTEGER,!this._dataCoords)return;const l=this._isColumn;let c=l?t:n,h=l?n:t,u=l?r:o,d=l?o:r;if(a===0)this._dataCoords=null;else{const g=this._dataCoords;g&&(c=(i?Math.max:Math.min)(c,g.colStart),h=(i?Math.max:Math.min)(h,g.rowStart),u=(i?Math.min:Math.max)(u,g.colEnd),d=(i?Math.min:Math.max)(d,g.rowEnd));const m={colStart:c,rowStart:h,colEnd:u,rowEnd:d};this._dataCoords=m}}clear(){this._major.clear(),this._dataCoords=null,this._count=0}delete(e){const t=this._count;if(!e)return this.clear(),t>0;const n=this._isColumn,r=this._maxCoords,o=this.getCoords(),i=yt(e.colStart,e.rowStart,e.colEnd,e.rowEnd,n,r,o);if(!i||t===0)return!1;if(k.isRangeWithinRange(o,e))return this.clear(),t>0;const a=i.majorStart,l=i.majorEnd,c=i.minorStart,h=i.minorEnd;let u=n?o.colStart:o.rowStart,d=n?o.colEnd:o.rowEnd;const g=n?o.rowStart:o.colStart,m=n?o.rowEnd:o.colEnd;let f=!1,_=0;const p=this._major;if(c<=g&&h>=m){Le.bounds.min=a,Le.bounds.max=l;const I=p.entries(Le);let x=I.next();for(;!x.done;)_-=x.value[1].getCount(),x=I.next();return p.delete(a,l-a+1),this._count+=_,this._dataCoords=null,_!==0}const S=[],C=this._isShared,y=[];Le.bounds.min=a,Le.bounds.max=l,xt.reverse=!1,xt.processSkip=null,xt.reuseResult=To;const b=p.entries(Le);let w=b.next();for(;!w.done;){const I=w.value,x=I[0];let v=I[1];const R=v.getCoords(),A=R.min,M=R.max;if(c<=A&&h>=A||c<=M&&c<=M)if((A===g&&c<=g||M===m&&h>=m)&&(f=!0),A>=c&&M<=h)S.push(x),_-=v.getCount();else{const T=v.getCount();C&&(v=v.clone(),y.push([x,v])),v.delete(c,h-c+1),_+=v.getCount()-T}w=b.next()}this._updateMajorSpan(y);const E=S.length;if(E>0){const I=Kh(S,!0);for(let v=0;v<I.length;v++){const R=I[v];p.delete(R.min,R.max-R.min+1)}const x=p.getCoords();if(!x)return this.clear(),!0;u=x.min,d=x.max}return f?(this._count+=_,this._dataCoords=null,!0):E===0?(this._count+=_,_!==0):(this._updateCountAndCoords(_,u,g,d,m,!0),_!==0)}shift(e,t){if(!e||!t)throw new Ot;const n=this._isColumn,r=this._maxCoords,o=t===Oe.Right||t===Oe.Down,i=t===Oe.Left||t===Oe.Right,a=yt(e.colStart,e.rowStart,e.colEnd,e.rowEnd,n,r,e);if(!a)return!1;const l=a.majorStart,c=a.majorEnd,h=a.minorStart,u=a.minorEnd,d=this.getCoords();if(!d)return!1;const g=n?d.colStart:d.rowStart,m=n?d.colEnd:d.rowEnd,f=n?d.rowStart:d.colStart,_=n?d.rowEnd:d.colEnd,p=h<=f&&u>=_,S=n===i;if((S&&p||!S&&l<=g&&c>=m)&&!yt(d.colStart,d.rowStart,d.colEnd+(o&&i?e.colEnd-e.colStart+1:0),d.rowEnd+(o&&!i?e.rowEnd-e.rowStart+1:0),n,r)||S&&l>m||!S&&h>_)return!1;let C=S?c-l+1:u-h+1;if(!o&&(C*=-1,k.isRangeWithinRange(d,e)))return this.clear(),!0;let y=0;const b=this._major,w=[];if(Le.bounds.min=l,Le.bounds.max=S?Number.MAX_SAFE_INTEGER:c,xt.reverse=!o,xt.processSkip=null,xt.reuseResult=To,S&&p){if(!o){Le.bounds.max=c;const O=b.entries(Le);let W=O.next();for(;!W.done;)y-=W.value[1].getCount(),W=O.next()}b.shift(l,C);const z=b.getCoords();return this._dataCoords=null,this._updateCountAndCoords(y,z.min,f,z.max,_),!0}let E=n?d.colStart:d.rowStart,I=n?d.colEnd:d.rowEnd,x=n?d.rowStart:d.colStart,v=n?d.rowEnd:d.colEnd;o||(x=Number.MAX_SAFE_INTEGER,v=Number.MIN_SAFE_INTEGER);let R=Number.MAX_SAFE_INTEGER;r&&(R=i?r.colEnd:r.rowEnd);const A=new Set,M=S?new Map:null,T=[],F=b.entries(Le),L={bounds:{min:h,max:u}};let D=F.next();for(;!D.done;){const z=D.value,O=z[0],W=z[1].clone(),V=W.getCoords(),j=V.min,H=V.max;if(S&&M.set(O,W),h<=H){const G=W.getCount();S?(O>=l-C&&s_(W.runs(L),(te,J)=>{const ne=J.min,Z=J.max;let q=te;ne-1<=u&&Z>u&&(q=q.slice(0,u+1-ne)),ne<h&&Z+1>=h&&(q=q.slice(h-ne)),T.push({majorIndex:O+C,minorIndex:Math.max(ne,h),run:q})}),W.delete(h,u-h+1)):W.shift(h,C);const $=W.getCount();if($===0)A.add(O),x=Math.min(x,H),v=Math.max(v,j);else{const te=W.getCoords();if(x=Math.min(x,te.min),v=Math.max(v,te.max),v>R)throw new Ne}y+=$-G,w.push([O,W])}D=F.next()}const P=this._optionsMinor;let B=!1;for(let z=0;z<T.length;z++){const O=T[z],W=O.majorIndex,V=O.run;let j=M.get(W);j||(j=new Wn(P),M.set(W,j),w.push([W,j]),B=!0),j.setRunAt(O.minorIndex,V),y+=V.length,E=Math.min(E,W),I=Math.max(I,W),A&&A.delete(W)}if(this._updateMajorSpan(w,B),A&&A.size>0){const z=Array.from(A.values()),O=Kh(z);for(let V=0;V<O.length;V++){const j=O[V];b.delete(j.min,j.max-j.min+1)}const W=b.getCoords();if(!W)return this.clear(),!0;E=W.min,I=W.max}if(v!==_||x!==f)return this._count+=y,this._dataCoords=null,!0;{const z=this._count+y;this._count=z,this._dataCoords=z===0?null:Object.freeze({colStart:n?E:x,rowStart:n?x:E,colEnd:n?I:v,rowEnd:n?v:I})}return y!==0||!k.isEqualRanges(d,this.getCoords())}getCount(){return this._count}getValueAt(e,t){const n=this._isColumn,r=n?t:e,o=n?e:t,i=this._lastMajor;let a;if(i===r&&i!==Number.MIN_SAFE_INTEGER?a=this._lastMinorSpan:(a=this._major.at(r),this._lastMajor=r,this._lastMinorSpan=a),!!a)return a.at(o)}setValueAt(e,t,n){const r=this._isColumn,o=[r?t:e,[[r?e:t,[n]]]];this.setValues([o])}copyTo(e,t,n){if(this.getCount()===0)return;const r=this.getOrientation(),o=e.getOrientation(),i=this.getRuns({bounds:n});let a=i.next();const l=k.cellToRange(t);l.colEnd=n.colEnd-n.colStart+t.colIndex,l.rowEnd=n.rowEnd-n.rowStart+t.rowIndex;const c=this._isColumn,h=this._maxCoords,u=this.getCoords();let d,g=yt(n.colStart??Number.MIN_SAFE_INTEGER,n.rowStart??Number.MIN_SAFE_INTEGER,n.colEnd??Number.MAX_SAFE_INTEGER,n.rowEnd??Number.MAX_SAFE_INTEGER,c,h,u);g={...g};const m=o!==ie.Row,f=e.getMaxCoords();d=yt(l?.colStart??Number.MIN_SAFE_INTEGER,l?.rowStart??Number.MIN_SAFE_INTEGER,l?.colEnd??Number.MAX_SAFE_INTEGER,l?.rowEnd??Number.MAX_SAFE_INTEGER,m,f),d={...d};const _=d.majorStart-g.majorStart,p=d.minorStart-g.minorStart,S=r===o?new exports.Tuple.Builder:new exports.Tuple.TransposedBuilder;for(;!a.done;){const y=a.value[0];let b=a.value[1],w=a.value[2];b+w.length>g.minorEnd&&(w=w.slice(0,g.minorEnd-b+1)),b<g.minorStart&&(w=w.slice(g.minorStart-b),b=g.minorStart),S.addValues(y+_,b+p,w),a=i.next()}const C=S.build();e.delete(l),C&&e.setValues(C.tuples)}getCoords(){if(this._dataCoords)return this._dataCoords;if(this._major.getCount()===0)return null;let e=Number.MAX_SAFE_INTEGER,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;const o=this._major.entries();let i=o.next();for(;!i.done;){const c=i.value,h=c[0];e=Math.min(h,e),t=Math.max(h,t);const u=c[1].getCoords();n=Math.min(u.min,n),r=Math.max(u.max,r),i=o.next()}const a=this._isColumn,l=Object.freeze({colStart:a?e:n,rowStart:a?n:e,colEnd:a?t:r,rowEnd:a?r:t});return this._dataCoords=l,l}clone(e){this._isShared=!0;const t=new Zt(this._options);return t._isShared=!0,t._major=this._major.clone(),t._dataCoords=this._dataCoords,t._count=this._count,t}cloneEmpty(e){return new Zt(this._options)}getMaxCoords(){return this._maxCoords||null}get[Symbol.toStringTag](){let e="";const t=this.getCoords();if(t){const n=t.colEnd-t.colStart+1,r=t.rowEnd-t.rowStart+1;e=`${this.getCount()}-${this._isColumn?n:r}x${this._isColumn?r:n}`}return`[SparseGrid:${e}]`}}Zt||(Zt={});const F_=12;Object.seal({done:!1,value:null});const An=[-1,-1,null],xm=Object.seal({done:!1,value:[-1,null]}),To=Object.seal({done:!1,value:[-1,null]}),xt={bounds:{min:-1,max:-1},reverse:!1,processSkip:null,reuseResult:xm},Le={bounds:{min:-1,max:-1},reverse:!1,processSkip:null,reuseResult:To},Cu=()=>({majorIndex:-1,minorIndex:-1,value:null,active:!1,nextMinorIndex:-1,nextActive:!1,nextMinorValue:null,minorIterator:null,nextMajorCursor:null,prevMajorCursor:null});class Ai{constructor(e){if(this._l=0,this._at=null,this._dt=bu.Undefined,this._a32=null,this._a64=null,this._cv=null,this._vt=null,this._vi32=null,this._vi64=null,this._vf32=null,this._vf64=null,!e)throw new Error("options is required");const t=e.length;if(this._l=t,this._dt=e.type,this._cv=e.getCoercedValue??null,t>0){e.types&&(this._at=e.types,this._vt=new Uint8Array(this._at));const n=e.values32??null;n&&(this._a32=n,this._vi32=new Int32Array(n),this._vf32=new Float32Array(n));const r=e.values64??null;if(r&&(this._a64=r,this._vf64=new Float64Array(r),this._vi64=new BigInt64Array(r)),!n&&!r)throw new Error("values32 or values64 is required")}}getConstructorOptions(){return{length:this._l,type:this._dt,types:this._at,values32:this._a32,values64:this._a64,getCoercedValue:this._cv}}at(e){if(e>>>0>=this._l)return;const t=this._vt,n=t&&t[e]||this._dt;let r,o=!1;switch(this._vi32?r=this._vi32[e]:(o=!0,r=Number(this._vi64[e])),n){case ri:return o?Number(r):r;case Po:return o?this._vf64[e]:this._vf32[e];case oi:return!!r;case si:case ii:return this._cv(n,o?Number(r):r);case Fo:return this._vi64[o?e:r];case No:return this._vf64[o?e:r];case Am:return Number.NaN;case Mm:return Number.MAX_SAFE_INTEGER;case Tm:return Number.MIN_SAFE_INTEGER;case Im:return 1/0;case Rm:return-1/0;case Fm:return null;case pc:case ai:return}return this._cv(n,o?Number(r):r)}toArray(e){const t=[],n=Math.max(e,this._l);for(let r=0;r<n;r++)t.push(this.at(r));return t}get length(){return this._l}get[Symbol.toStringTag](){return"[MixTypedArrayList]"}toString(){const e=this._a32,t=this._a64;let n="";return e&&!t?n="32":t&&!e&&(n="64"),`{${n}${this._at?"":":SINGLE_TYPE"}}:${this._l}}`}static _createArrayBuffer(e){try{return new SharedArrayBuffer(e)}catch{}return new ArrayBuffer(e)}static fromArray(e,t,n,r,o=N_){const i=e.length;if(i===0)return new Ai({type:bu.Undefined,length:i,getCoercedValue:n});let a=this._createArrayBuffer(i*Int8Array.BYTES_PER_ELEMENT),l=new Uint8Array(a),c=0,h=!1,u=Eu(e[0],r);for(let w=0;w<i;w++){const E=e[w],I=Eu(E,r);I!==No&&I!==Fo||c++,u!==I&&(l[w]=I,h=!0)}h||(l=null,a=null);let d,g,m,f,_,p,S,C,y=!1;c/i>o&&(y=!0,c=i),c!==0&&(m=this._createArrayBuffer(c*BigInt64Array.BYTES_PER_ELEMENT),f=new BigInt64Array(m),_=new Float64Array(m)),y?(d=f,g=_):(p=this._createArrayBuffer(i*Int32Array.BYTES_PER_ELEMENT),S=new Int32Array(p),C=new Float32Array(p),d=S,g=C);let b=u;if(y)for(let w=0;w<i;w++){const E=e[w];switch(l&&(b=l[w]||u),b){case ri:d[w]=BigInt(E);break;case oi:d[w]=BigInt(E?1:0);break;case Po:g[w]=E;break;case Fo:d[w]=E;break;case No:g[w]=E;break;case si:case ii:d[w]=BigInt(t?.(b,E)??0);break;default:b>127&&b<255&&(d[w]=BigInt(t?.(b,E)??0))}}else{let w=0;for(let E=0;E<i;E++){const I=e[E];switch(l&&(b=l[E]||u),b){case ri:d[E]=I;break;case oi:d[E]=I?1:0;break;case Po:g[E]=I;break;case Fo:S[E]=w,f[w]=I,w++;break;case No:S[E]=w,_[w]=I,w++;break;case si:case ii:d[E]=t?.(b,I)??0;break;default:b>127&&b<255&&(d[E]=t?.(b,I)??0)}}}return new Ai({length:i,types:h?a:null,type:u,values32:p,values64:m,getCoercedValue:n})}}const N_=.1,ri=1,Po=2,oi=3,Fo=4,No=5,si=6,ii=7,Im=8,Rm=9,Am=10,Mm=11,Tm=12,Fm=13,pc=14,ai=127,bu={Undefined:pc},Eu=(s,e)=>{switch(typeof s){case"number":const t=s;return Number.isNaN(t)?Am:t===1/0?Im:t===-1/0?Rm:Object.is(t,-0)?Po:t===Number.MAX_SAFE_INTEGER?Mm:t===Number.MIN_SAFE_INTEGER?Tm:Number.isInteger(t)&&t<=2147483647&&t>=-2147483648?ri:Math.fround(t)===t?Po:No;case"string":return si;case"boolean":return oi;case"object":if(s===null)return Fm;if(s instanceof Error)return ii;if(!e)return ai;const n=e(s);if(n<128||n>255)throw new Error("Custom type must be between 128 and 255");return n;case"bigint":return Fo;case"undefined":return pc;case"symbol":case"function":return ai}return ai},ko=s=>{if(!s||s.length<=1)return!1;if(s.length===2)return k.isRangesIntersect(s[0],s[1]);const e=new be;e.load(s);for(let t=0;t<s.length;t++)if(e.search(s[t]).length>1)return!0;return!1},jl=(s,e,t)=>{const n=[];if(k.isRangesIntersect(s,e)){const r=N.subtractRect({top:s.rowStart,left:s.colStart,bottom:s.rowEnd+1,right:s.colEnd+1},{top:e.rowStart,left:e.colStart,bottom:e.rowEnd+1,right:e.colEnd+1},t===ie.Column);for(let o=0;o<r.length;o++){const i={colStart:r[o].left,rowStart:r[o].top,colEnd:r[o].right-1,rowEnd:r[o].bottom-1};n.push(i)}}else n.push(s);return n},vu=(s,e,t)=>{if(e&&s?.[0])for(let n=0;n<s.length;n++){const r=s[n];k.intersectRanges(r,e)&&t(r,!k.isRangeWithinRange(r,e),n)}},xu=(s,e)=>{const t=s.colStart,n=s.rowStart,r=e.colStart,o=e.rowStart;return(i,a)=>{const l=i.colIndex-t,c=a.colIndex-r;return l===c?i.rowIndex-n-(a.rowIndex-o):l-c}},Iu=(s,e)=>{const t=s.colStart,n=s.rowStart,r=e.colStart,o=e.rowStart;return(i,a)=>{const l=i.rowIndex-n,c=a.rowIndex-o;return l===c?i.colIndex-t-(a.colIndex-r):l-c}},li=(s,e,t=!1,n=!1)=>{let r=e.colEnd-e.colStart+1,o=e.rowEnd-e.rowStart+1;if(n){const c=r;r=o,o=c}const i={colStart:s.colStart,rowStart:s.rowStart,colEnd:s.colStart+r-1,rowEnd:s.rowStart+o-1};if(t){let c=s.colStart,h=s.rowStart;return k.isSingleCell(s)?(c+=r-1,h+=o-1):(c+=s.colEnd-s.colStart,h+=s.rowEnd-s.rowStart),i.colEnd=n?h:c,i.rowEnd=n?c:h,i}const a=s.colEnd-s.colStart+1;if(a%r!==0)return i;const l=s.rowEnd-s.rowStart+1;return l%o!==0||(i.colEnd=s.colStart+a-1,i.rowEnd=s.rowStart+l-1),i};class za{constructor(e,t){this._l=0,e&&t>0&&(this._u=e,this._l=t)}at(e){if(e>this._l||e<0||!this._u)return;const t=Math.floor(e%this._u.length);return this._u.at(t)}toArray(e){const t=[],n=this._u,r=n.length;for(let o=0;o<e;o++){const i=Math.floor(o%r);t.push(n.at(i))}return t}get length(){return this._l}get[Symbol.toStringTag](){return"[RepeatingList]"}get isIList(){return!0}}class nt{constructor(e,t,n=null,r=!1){this._isLiteral=!1,this._values=e,this._coords=t,this._type=n,this._isLiteral=r}getValueAt(e,t,n){const r=this._coords;if(!r)return;let o=this._values.getValueAt(e+r.rowStart,t+r.colStart)??null;o===void 0&&(o=null);const i=n?.type,a=i!==void 0?i:this._type;return a&&(o=Nt(o,Ye(o,!0),a)),o}_applyBuilder(e,t,n=!1){if(!t)return e;const r=t.build();return r&&(n&&(e=e.clone()),e.setValues(r.tuples)),e}_cloneFromBuilder(e,t,n,r){if(!e)return this;const o=e.build();if(!o)return this;let i=this._values;const a=i.getOrientation(),l=(t?.orientation??a)===exports.w.Orientation.Column,c=Go(o.bounds,l),h=this._coords??k.EmptyRange,u=Math.max(c.colEnd-c.colStart+1,n??h.colEnd-h.colStart+1),d=Math.max(c.rowEnd-c.rowStart+1,r??h.rowEnd-h.rowStart+1),g=h.colStart,m=h.rowStart,f=g+u-1,_=m+d-1;return i=i.clone(),i.setValues(o.tuples),new nt(i,{colStart:g,rowStart:m,colEnd:f,rowEnd:_},this._type,this._isLiteral)}forEach(e,t){if(!e)return;const n=this.entries(t);let r=n.next();for(;!r.done;){const o=r.value,i=e(o.value,o.coords,this);if(i)return i.break;r=n.next()}}reduce(e,t,n){if(!e)return t;const r=this.entries(n);let o=r.next(),i=t;for(;!o.done;){const a=o.value;i=e(i,a.value,a.coords,this),o=r.next()}return i}some(e,t){if(!e)return!1;const n=this.entries(t);let r=n.next();for(;!r.done;){const o=r.value;if(e(o.value,o.coords,this))return!0;r=n.next()}return!1}every(e,t){if(!e)return!0;const n=this.entries(t);let r=n.next();for(;!r.done;){const o=r.value;if(!e(o.value,o.coords,this))return!1;r=n.next()}return!0}replace(e,t){let n;if(n=e?.isIRange?e:km(e,this._values,this._coords,this._type),this.size===0)return n;if(n.size===0)return this;const r=this._values.clone(),o=n._values,i=n._coords??k.EmptyRange,a=this._coords??k.EmptyRange,l=a.colStart,c=a.rowStart,h=l+(t.colIndex??0),u=c+(t.rowIndex??0);o.copyTo(r,{colIndex:h,rowIndex:u},i);const d=Math.max(this.getWidth(),n.getWidth()+(t?.colIndex??0)),g=Math.max(this.getHeight(),n.getHeight()+(t?.rowIndex??0));return new nt(r,{colStart:l,rowStart:c,colEnd:l+d-1,rowEnd:c+ +g-1},this._type)}slice(e){if(!e)return this;const t=this._coords??k.EmptyRange,n=(e.colStart??0)+t.colStart,r=(e.rowStart??0)+t.rowStart,o={colStart:n,rowStart:r,colEnd:(e.colEnd??t.colEnd-n)+t.colStart,rowEnd:(e.rowEnd??t.rowEnd-r)+t.rowStart},i=k.intersectRanges(t,o);return new nt(this._values,i,this._type)}resize(e,t,n=null){if(e<0||t<0)throw new Error(`Invalid resize dimensions: ${e} x ${t}`);const r=this._coords??k.EmptyRange,o=r.colEnd-r.colStart+1,i=r.rowEnd-r.rowStart+1;if(e===o&&t===i)return this;const a={colStart:r.colStart,rowStart:r.rowStart,colEnd:r.colStart+e-1,rowEnd:r.rowStart+t-1};let l=this._values;return(e>o||t>i)&&(l=l.clone(),e>o&&(Xe.colStart=r.colEnd+1,Xe.rowStart=r.rowStart,Xe.colEnd=r.colEnd,Xe.rowEnd=r.rowEnd,this._fill(l,r,n)),t>i&&(Xe.colStart=r.colStart,Xe.rowStart=r.rowEnd+1,Xe.colEnd=r.colEnd,Xe.rowEnd=r.rowEnd,this._fill(l,r,n))),new nt(l,a,this._type)}_mergeIterators(e,t,n){const r=this._coords??k.EmptyRange,o=e._coords??k.EmptyRange,i=this._values.getOrientation(),a=n?.orientation??i,l=a!==exports.w.Orientation.Row,c=this._entries(n),h=this._entries(n),u=r.colStart,d=r.rowStart,g=u-o.colStart,m=d-o.rowStart,f=a===i?new exports.Tuple.Builder:new exports.Tuple.TransposedBuilder,_=new wu({...n,bounds:r,comparator:(l?xu:Iu)(r,o)},c,h);let p=_.next();for(;!p.done;){const S=p.value;let C=S[1],y=S[3];const b=S[0],w=S[2],E=b?b.colIndex:w.colIndex+g,I=b?b.rowIndex:w.rowIndex+m,x=t(C,y,{colIndex:E-u,rowIndex:I-d},this),v=l?E:I,R=l?I:E;f.addValue(v,R,x),p=_.next()}return f}intersect(e,t,n){if(!e)throw new Error("Invalid range to intersect");const r=e,o=this._coords??null,i=r._coords??null;if(!k.intersectRanges(o,i))return new nt(this._values,null,this._type);const a=this._mergeIterators(r,t,n);return this._cloneFromBuilder(a,n)}startIncrementalUpdates(e){const t=e?.orientation??exports.w.Orientation.Column,n=this._values.getOrientation(),r=(e?.orientation??n)!==exports.w.Orientation.Row,o=t===n?new exports.Tuple.Builder:new exports.Tuple.TransposedBuilder,i=this,a=this._coords??k.EmptyRange,l=a.colStart,c=a.rowStart,h=r?l:c,u=r?c:l,d={pushAt(g,m,f){const _=r?m:g,p=r?g:m;return o.addValue(_+h,p+u,f),d},pushMultipleAt(g,m,f){const _=r?m:g,p=r?g:m;return o.addValues(_+h,p+u,f),d},apply(){const g=o.build();return g?(g.bounds.majorStart=h,g.bounds.minorStart=u,i._cloneFromBuilder(o,e)):null}};return d}map(e,t){const n=this._values;if(!this._coords||n.getCount()===0)return this;const r=n.getOrientation(),o=t?.orientation??r;let i;const a=this.entries(t);let l=a.next();l.done||(i=this._createTupleBuilder(o));const c=o===exports.w.Orientation.Column;for(;!l.done;){const h=l.value,u=h.coords,d=e(h.value,u,this),g=c?u.colIndex:u.rowIndex,m=c?u.rowIndex:u.colIndex;i.addValue(g,m,d),l=a.next()}return this._cloneFromBuilder(i,t)}filter(e,t){const n=this._values;if(!this._coords||n.getCount()===0)return this;const r=n.getOrientation(),o=t?.orientation??r,i=this._createTupleBuilder(o),a=this.entries(t);let l=a.next();const c=o===exports.w.Orientation.Column;for(;!l.done;){const h=l.value,u=h.coords,d=h.value;if(e(d,u,this)){const g=c?u.colIndex:u.rowIndex,m=c?u.rowIndex:u.colIndex;i.addValue(g,m,d)}l=a.next()}return this._cloneFromBuilder(i,t)}broadcast(e,t,n){let r=this._coords;if(e==null)return this;let o=n?.type,i=n?.otherType??o;const a=o?Nt(null,U.Null,o):null,l=i?Nt(null,U.Null,i):null;let c;if(e.isIRange)c=e;else{const B=this._values.clone();B.setValueAt(0,0,e),c=new nt(B,k.EmptyRange,Ye(e,!0))}const h=c,u=this.getWidth(),d=this.getHeight(),g=h.getWidth(),m=h.getHeight();let f=Math.min(u,g),_=Math.min(d,m),p=Math.max(u,g),S=Math.max(d,m);const C=n?.mismatchFill;let y=!1;if(u!==g)if(u===1)f=g;else if(g===1)f=u;else{if(!C)throw new Error(`Incompatible shapes for broadcast: width dimensions ${u} and ${g} must be equal or one must be 1`);y=!0}if(d!==m)if(d===1)_=m;else if(m===1)_=d;else{if(!C)throw new Error(`Incompatible shapes for broadcast: height dimensions ${d} and ${m} must be equal or one must be 1`);y=!0}const b=this._values.getOrientation(),w=b,E=w===exports.w.Orientation.Column;r=r??k.EmptyRange;let I,x,v=h._coords??k.EmptyRange;if(y&&(r={colStart:r.colStart,rowStart:r.rowStart,colEnd:r.colStart+f-1,rowEnd:r.rowStart+f-1},v={colStart:v.colStart,rowStart:v.rowStart,colEnd:v.colStart+f-1,rowEnd:v.rowStart+f-1}),u===1&&u<g||d===1&&d<m){const B={...r};u===1&&(B.colEnd=B.colStart),d===1&&(B.rowEnd=B.rowStart),I=new Wl({delegate:this._entries({...n,orientation:w,bounds:B,reuseResult:!1}),bounds:B,orientation:w,dims:{major:E?f:_,minor:E?_:f}})}else I=this._entries({...n,orientation:w,bounds:r,reuseResult:!1});if(g===1&&g<u||m===1&&m<d){const B={...v};g===1&&(B.colEnd=B.colStart),m===1&&(B.rowEnd=B.rowStart),x=new Wl({delegate:h._entries({...n,type:i??null,orientation:w,bounds:B,reuseResult:!1}),bounds:B,orientation:w,dims:{major:E?f:_,minor:E?_:f}})}else x=h._entries({...n,type:i??null,orientation:w,bounds:v,reuseResult:!1});const R=r.colStart,A=r.rowStart,M=R-v.colStart,T=A-v.rowStart,F=w===b?new exports.Tuple.Builder:new exports.Tuple.TransposedBuilder,L=new wu({...n,bounds:r,comparator:(E?xu:Iu)(r,v)},I,x);let D,P=L.next();for(;!P.done;){const B=P.value;let z=B[1],O=B[3];const W=B[0],V=B[2],j=W?W.colIndex:V.colIndex+M,H=W?W.rowIndex:V.rowIndex+T;let G,$;z instanceof exports.n.Value?G=z:O instanceof exports.n.Value&&(G=O),$=G||t(z??a,O??l,{colIndex:j-R,rowIndex:H-A},this);const te=E?j:H,J=E?H:j;F.addValue(te,J,$),P=L.next()}if(C&&p>f||S>_){const B=this._values.clone();if(this._applyBuilder(B,F),p>f){const z=yt(R+f,A,R+p-1,A+S-1,E),O=ni(C,z,E);B.setValues(O.tuples)}if(S>_){const z=yt(R,A+_,R+p-1,A+S-1,E),O=ni(C,z,E);B.setValues(O.tuples)}D=new nt(B,{colStart:R,rowStart:A,colEnd:R+p-1,rowEnd:A+S-1},this._type)}else D=this._cloneFromBuilder(F,n,p,S);return D}_fill(e,t,n){if(n===null)return void e.delete(t);const r=e.getOrientation()===exports.w.Orientation.Column,o=yt(t.colStart,t.rowStart,t.colEnd,t.rowEnd,r),i=ni(n,o,r);e.setValues(i.tuples)}_validateCoords(e){}fill(e,t){let n=this._coords;if(!n&&!t)return this;n=n??k.EmptyRange,t&&(Xe.colStart=(t.colStart??0)+n.colStart,Xe.rowStart=(t.rowStart??0)+n.rowStart,Xe.colEnd=(t.colEnd??n.colEnd-n.colStart)+n.colStart,Xe.rowEnd=(t.rowEnd??n.rowEnd-n.rowStart)+n.rowStart),this._validateCoords(Xe);const r=this._values.clone();return this._fill(r,Xe,e),(Xe.rowEnd>n.rowEnd||Xe.colEnd>n.colEnd)&&(n={colStart:n.colStart,rowStart:n.rowStart,colEnd:Math.max(n.colEnd,Xe.colEnd),rowEnd:Math.max(n.rowEnd,Xe.rowEnd)}),new nt(r,n,this._type)}empty(){const e=this._values.cloneEmpty();return new nt(e,null,this._type)}flatten(e){const t=[],n=this.values(e);let r=n.next();for(;!r.done;)t.push(r.value),r=n.next();return t}fillEmpty(e,t=1,n=1){const r=this._coords;if(!r)return this;const o=this._values;if(t<1&&n<1)throw new Error("Must be at least size of 1");const i=o.getOrientation(),a=i,l=a===exports.w.Orientation.Column,c=Math.max(this.getWidth(),t),h=Math.max(this.getHeight(),n),u=l?r.colStart:r.rowStart,d=l?r.rowStart:r.colStart,g=l?r.colStart+c-1:r.rowStart+h-1,m=l?r.rowStart+h-1:r.colStart+c-1,f=o.getRuns({bounds:{colStart:r.colStart,rowStart:r.rowStart,colEnd:l?g:m,rowEnd:l?m:g},overflowRun:!0});let _=f.next(),p=u,S=d;const C=a===i?new exports.Tuple.Builder:new exports.Tuple.TransposedBuilder;for(;!_.done;){const y=_.value,b=y[0];for(;p<b;){const v=new za([e],m+1-S);C.addValues(p,S,v),p++,S=d}const w=y[1],E=Math.max(w,d),I=y[2],x=Math.min(w+I.length-1,m);if(S<E){const v=new za([e],w-S);C.addValues(p,S,v)}S=x+1,x>=m?(p=b+1,S=d):p=b,_=f.next()}for(;p<=g;){const y=new za([e],m+1-S);C.addValues(p,S,y),p++,S=d}return this._cloneFromBuilder(C,void 0,c,h)}transpose(){if(this.size<=1)return this;const e=this._values.getOrientation(),t=this._coords,n=this.getWidth(),r=this.getHeight(),o=this._entries({orientation:e===exports.w.Orientation.Column?exports.w.Orientation.Row:exports.w.Orientation.Column,bounds:t,reuseResult:!0}),i=e===exports.w.Orientation.Column,a=new exports.Tuple.Builder,l=i?t.colStart:t.rowStart,c=i?t.rowStart:t.colStart;let h=o.next();for(;!h.done;){const u=h.value,d=u[0],g=i?d.colIndex:d.rowIndex-l,m=(i?d.rowIndex:d.colIndex-c)+l,f=g+c,_=u[1];a.addValue(m,f,_),h=o.next()}return this._cloneFromBuilder(a,void 0,r,n)}values(e){const t=this.entries(e);return{[Symbol.iterator](){return this},next(){const n=t.next();return n.done?Re:{done:!1,value:n.value.value}}}}_createTupleBuilder(e){const t=this._coords,n=this._values.getOrientation(),r=e??n,o=r!==exports.w.Orientation.Row,i=o?t.colStart:t.rowStart,a=o?t.rowStart:t.colStart;return r===n?new exports.Tuple.Builder(null,i,a):new exports.Tuple.TransposedBuilder(null,i,a)}entries(e){const t=this._coords;if(!t)return qe;const n=e?.bounds;if(e={...e,bounds:t},n){const i=(n.colStart??0)-t.colStart,a=(n.rowStart??0)-t.rowStart,l=Math.max(i+t.colStart,t.colStart),c=Math.max(a+t.rowStart,t.rowStart),h=Math.min((n.colEnd??Number.MAX_SAFE_INTEGER)-i,t.colEnd-t.colStart)+1,u=Math.min((n.rowEnd??Number.MAX_SAFE_INTEGER)-a,t.rowEnd-t.rowStart)+1;e.bounds={colStart:l,rowStart:c,colEnd:l+h-1,rowEnd:c+u-1}}const r=this._entries(e),o={[Symbol.iterator]:()=>o,next(){for(;;){let i=r.next();if(i.done)return Re;const a=i.value,l=a[0];return{done:!1,value:{coords:{colIndex:l.colIndex-t.colStart,rowIndex:l.rowIndex-t.rowStart},value:a[1]}}}}};return o}_entries(e){if(!this._coords)return qe;let t=this._values.entries(e);const n=e?.type??this._type;let r=null;if(e?.includeEmpty&&(t=new vm(t,e),n&&(r=Nt(null,U.Null,n))),n){const o=t,i=e.coerce??!1,a=e.includeBoolean??!1,l=e.includeMistyped??!1;t={[Symbol.iterator]:()=>t,next(){for(;;){let c=o.next();if(c.done)return Re;const h=c.value,u=h[1];let d=u;if(d==null)d=r;else if(n&&(i||!l)){let g=Ye(d,!0),m=g!==n;if(m&&(i&&(d=Nt(d,g,n,a),m=d?.isFormulaError),m&&!l))continue}return d===u?c:{done:!1,value:[h[0],d]}}}}}return t}getValues(e){if(!this._coords)return[[]];const t={...e,includeEmpty:!0,reverse:!1,bounds:{colStart:0,rowStart:0,colEnd:this.getWidth()-1,rowEnd:this.getHeight()-1}};let n=!1;t.orientation=e?.orientation??exports.w.Orientation.Row,e&&(e.maxHeight&&(t.bounds.rowEnd=0+e.maxHeight-1),e.maxWidth&&(t.bounds.colEnd=0+e.maxWidth-1),e.trailingEmpties&&(n=e.trailingEmpties),t.orientation=e?.orientation??exports.w.Orientation.Row);const r=[];if(!n){t.includeEmpty=!1,t.reverse=!0;const u=this.entries(t).next();if(u.done)return k_;const d=u.value.coords;t.bounds.colEnd=d.colIndex,t.bounds.rowEnd=d.rowIndex,t.includeEmpty=!0,t.reverse=!1}const o=this.entries(t),i=t.orientation!==exports.w.Orientation.Row,a=e?.onValue;let l,c=-1,h=[];for(l=o.next();!l.done;){const u=l.value,d=u.coords,g=i?d.colIndex:d.rowIndex;g!==c&&(h=[],r.push(h),c=g);let m=u.value;if(a){const f=a(m,d.rowIndex,d.colIndex,this);f!==void 0&&(m=f)}h.push(m),l=o.next()}return r}toType(e){return new nt(this._values,this._coords,e,this._isLiteral)}getWidth(){const e=this._coords;return e?e.colEnd-e.colStart+1:0}getHeight(){const e=this._coords;return e?e.rowEnd-e.rowStart+1:0}get size(){const e=this._coords;return e?(e.colEnd-e.colStart+1)*(e.rowEnd-e.rowStart+1):0}isLiteral(){return this._isLiteral}getScalarType(){return this._type}[Symbol.iterator](){const e=this.entries();return{next(){const t=e.next();return t.done?Re:{done:!1,value:t.value.value}},[Symbol.iterator](){return this}}}get[Symbol.toStringTag](){return"[Range]"}toString(){const e=this._coords,t=e?`${e.colEnd-e.colStart+1}x${e.rowEnd-e.rowStart+1}`:exports.n.Ref.toString();let n="{";const r=this.entries({includeEmpty:!0,orientation:exports.w.Orientation.Row});let o=r.next(),i=0,a=o.value?.coords.rowIndex??0;for(;!o.done&&i<10;){const l=o.value;l.coords.rowIndex>a?(n+=";",a=l.coords.rowIndex):i>0&&(n+=","),i++;let c=l.value;typeof c=="string"?c=`"${c}"`:typeof c=="boolean"&&(c=c?"TRUE":"FALSE"),n+=c,o=r.next()}return o.done?n+="}":n+="...",`[${t}:${n}]`}get isIRange(){return!0}}const Xe={colStart:Number.MIN_SAFE_INTEGER,rowStart:Number.MIN_SAFE_INTEGER,colEnd:Number.MAX_SAFE_INTEGER,rowEnd:Number.MAX_SAFE_INTEGER},k_=Object.freeze([Object.freeze([null])]),ts=Object.freeze({colStart:0,rowStart:0,colEnd:Math.pow(2,14)-1,rowEnd:Math.pow(2,20)-1}),O_=Object.freeze({colIndex:0,rowIndex:0}),Mi=()=>ts,Ye=(s,e=!1)=>typeof s=="number"?isNaN(s)||s===1/0||s===-1/0?U.Error:U.Number:typeof s=="string"?U.String:typeof s=="boolean"?U.Boolean:s?.isFormulaError?U.Error:s===null?U.Null:N.isObject(s)&&s.hasOwnProperty("type")&&typeof s.type=="string"?U.RichData:e&&Ur(s)?"Date":s===void 0?(console.warn("undefined"),U.Null):null,Ru=new Map([[U.Null,"any"],[U.Number,"number"],[U.String,"string"],[U.Boolean,"boolean"],[U.Error,"FormulaError"],[U.RichData,"richData"],["*","Scalar"]]),B_=new Map([["p","IReferenceRange"],["r","IRange"]]),D_={orientation:exports.w.Orientation.Row},Nt=(s,e,t=U.Number,n=!1,r=!1)=>{if(e===t||!t)return e===U.Number&&(s=ns(s,null,"number")),s;if(t===U.Number){switch(e){case U.Null:return 0;case U.String:let o=0;try{const i=of(s);o=i&&typeof i.value=="number"?i.value:Number.NaN}catch{}return!Number.isFinite(o)||Math.abs(o)>999e305?exports.n.BuiltIn.Value:o;case U.Boolean:return n?s?1:0:exports.n.BuiltIn.Value;case"Date":return Qo(s,r)??exports.n.BuiltIn.Value;case U.Error:return s}return s.toString()}if(t===U.String){switch(e){case U.Null:return"";case U.Number:return s.toString();case U.Boolean:return s?"TRUE":"FALSE";case U.Error:return s}return s}if(t===U.Boolean){switch(e){case U.Null:return 0;case U.Number:return!!s;case U.String:let o=s.trim().toUpperCase();return o==="TRUE"||o!=="FALSE"&&exports.n.BuiltIn.Value;case U.Error:return s}return exports.n.BuiltIn.Value}if(t==="Date"){switch(e){case U.Number:return qr(s,r)??exports.n.BuiltIn.Value;case U.String:try{const o=ac(s,r);if(o)return o.asJSDate??exports.n.BuiltIn.Value}catch{}return s;case U.Error:return s}return exports.n.BuiltIn.Value}return exports.n.BuiltIn.Value},Au=s=>{let e=s;for(;Array.isArray(e);){if(e.length>1)return!1;e=e[0]}return!e||!e.isIRange||e.size===1},Nm=(s,e,t,n,r,o=!1)=>{if(Array.isArray(t)){const i=t.length;for(let a=0;a<i;a++){let l=t[a];if(Array.isArray(l)){const c=Nm(s,e,l,n,r,o);if(o)continue;if(c instanceof exports.n.Value)return c}else{if(n){if(l=Nt(l,Ye(l,!0),n,o),o)continue;if(l instanceof exports.n.Value)return l}e.push(l)}}return}if(t&&t.colStart!==void 0){let i=s.getReference?.(t);n&&(i=i.toType(n)),t=i}if(t?.isIRange)return((i,a)=>{let l=i.next();for(;!l.done;){let c=l.value;if(c instanceof exports.n.Value)return c;a.push(c),l=i.next()}})(t.values({type:n,coerce:!0,includeMistyped:!o,...D_}),e);if(n){if(t=Nt(t,Ye(t,!0),n,r!==null),o)return;if(t instanceof exports.n.Value)return t}e.push(t)},lo=(s,e,t,n,r,o)=>{if(r==="r"){let a=t;return a&&a.isIReferenceRange?(n&&(a=a.toType(n)),void e.push(t)):new exports.n.Value("Cannot convert a literal to a reference.")}let i=t?.isIRange?t:null;if(r!=="l"){if(i){const a=i.getValues({type:n});return void e.push(a)}{Array.isArray(t)||(t=[t]);const a=t.length,l=new Array(a);for(let c=0;c<a;c++){let h=t[c];Array.isArray(h)||(h=[h]);const u=h.length,d=new Array(u);for(let g=0;g<u;g++){let m=h[g];if(n&&(m=Nt(m,Ye(m,!0),n)),m instanceof exports.n.Value)return m;d[g]=m}l[c]=d}e.push(l)}}else{if(i)n&&i.getScalarType()!==n&&(i=i.toType(n));else try{if(!o&&(t=ns(t),n&&(t=Nt(t,Ye(t,!0),n,!0),t?.isFormulaError&&n!==U.Error)))return e.push(t),t;i=s.getRange(t),n&&(i=i.toType(n))}catch(a){return a}e.push(i)}},ns=(s,e,t=typeof s)=>{if(t==="number")return isNaN(s)?exports.n.BuiltIn.Num:isFinite(s)?s+=0:exports.n.BuiltIn.Div0;if(s==null)return null;if(!e)return s;if(Array.isArray(s))try{s=e.getRange(s)}catch{return exports.n.BuiltIn.Value}return e.isValidDate(s)?(e.formatResults("Short Date"),e.toOADate(s)):s},km=(s,e,t,n)=>{let r;r=Array.isArray(s)?Array.isArray(s[0])?s:[s]:[[s]],e||(e=new Zt({orientation:exports.w.Orientation.Column}));const o=e.getOrientation()===exports.w.Orientation.Column,i=Ri(r,o,yt(t?.colStart??0,t?.rowStart??0,void 0,void 0,o),!0),a=Go(i.bounds,o);return e.setValues(i.tuples),new nt(e,a,n,!t)},L_=new RegExp(/^([$]?[a-zA-Z]*[$]?[0-9]*)[:]?([$]?[a-zA-Z]*[$]?[0-9]*)?$/),P_=new RegExp(/^(R(?:\[?[-+]?\d+\]?|\d+)?C(?:\[?[-+]?\d+\]?|\d+)?)(:(R(?:\[?[-+]?\d+\]?|\d+)?C(?:\[?[-+]?\d+\]?|\d+)?))?$/,"i"),z_=new RegExp(/^(R?)(\[?[-+]?\d+\]?|\d+)?(C?)(\[?[-+]?\d+\]?|\d+)?$/,"i"),W_=new RegExp("(?:'[^']+'|[A-Za-z0-9_\\-.]+?!)?(\\$?[A-Za-z]+\\$?\\d+(?::\\$?[A-Za-z]+\\$?\\d+)?|\\$?[A-Za-z]+:\\$?[A-Za-z]+|\\$?\\d+:\\$?\\d+)","g"),j_=/\s+/g,H_=/"(?:[^"]|"")*"|\[[^[\]]+\]/g,Wa=/[\uE000-\uF8FF]/g,Ke="#REF!",Om=Math.pow(2,14),V_=Math.pow(2,20);let Mu,Tu;const Ht=s=>(Mu===s||(Tu=""+(s+1),Mu=s),Tu);let Fu,ja;const Dt=s=>{if(Fu===s)return ja;if(Fu=s,s<0)throw new Error("invalid column "+s);let e="";for(++s;s;s=Math.floor((s-1)/26))e=String.fromCharCode((s-1)%26+65)+e;return ja=e,ja},G_=/[^a-zA-Z0-9]/,rs=s=>s?Dt(s.colIndex)+Ht(s.rowIndex):null,Hn=s=>{if(!s)return Ke;const e=Dt(s.colIndex),t=Ht(s.rowIndex);return(s.$colIndex?"$"+e:e)+(s.$rowIndex?"$"+t:t)},_c=(s,e)=>{let t=s??e;var n;return t&&(t=lc(t),t=t.replace(/'/g,"''"),n=t,G_.test(n)&&(t=om(t))),t},Bm=(s,e)=>s?s+(s.endsWith("!")?"":"!")+e:Ke,Cn=(s,e,t=rs)=>{if(!s)return null;const n=s.colStart,r=s.rowStart,o=s.colEnd,i=s.rowEnd;if(n===o&&r===i)return t({colIndex:n,rowIndex:r});s={...e,...s};const a=n===Number.MIN_SAFE_INTEGER||e&&n<=e.colStart&&o>=e.colEnd,l=r===Number.MIN_SAFE_INTEGER||e&&r<=e.rowStart&&i>=e.rowEnd;let c=null;c=l?Dt(n):a?Ht(r):t({colIndex:n,rowIndex:r});let h=null;return h=l?Dt(o):a?Ht(i):t({colIndex:o,rowIndex:i}),c+":"+h},Ha=(s,e,t=Hn)=>{if(!s)return Ke;const n=s.colIndex,r=s.rowIndex,o=n===Number.MIN_SAFE_INTEGER;let i=null;if(r===Number.MIN_SAFE_INTEGER?(i=Dt(n),s.$colIndex&&(i="$"+i)):o?(i=Ht(r),s.$rowIndex&&(i="$"+i)):i=t(s),s.sheetName||e){const a=_c(s.sheetName,e);i=Bm(a,i)}return i},mn=(s,e,t=Hn)=>{if(!s)return Ke;const n=s.rowStart!==void 0&&s.rowStart===s.rowEnd;if(s.colStart!==void 0&&s.colStart===s.colEnd&&n)return t({colIndex:s.colStart,rowIndex:s.rowStart,$colIndex:s.$colStart,$rowIndex:s.$rowStart});s={...e,...s};const r=e&&s.rowStart<=e.rowStart&&s.rowEnd>=e.rowEnd,o=e&&s.colStart<=e.colStart&&s.colEnd>=e.colEnd;let i=null;r?(i=Dt(s.colStart),i=s.$colStart?"$"+i:i):o?(i=Ht(s.rowStart),i=s.$rowStart?"$"+i:i):i=t({colIndex:s.colStart,rowIndex:s.rowStart,$colIndex:s.$colStart,$rowIndex:s.$rowStart});let a=null;return r?(a=Dt(s.colEnd),a=s.$colEnd?"$"+a:a):o?(a=Ht(s.rowEnd),a=s.$rowEnd?"$"+a:a):a=t({colIndex:s.colEnd,rowIndex:s.rowEnd,$colIndex:s.$colEnd,$rowIndex:s.$rowEnd}),i+":"+a},qi=(s,e,t=Hn)=>{const n=mn(s,e,t),r=_c(s?.sheetName,e?.sheetName);return Bm(r,n)},Dm=(s,e=!1)=>{if(!s)return null;let t=0,n=0,r=!1,o=!1;const i=s.length;for(let l=0;l<i;++l){const c=s.charCodeAt(l);if(c>=48&&c<=57){if(n=10*n+(c-48),t===0&&!e)return}else if(c>=65&&c<=90){if(t=26*t+(c-64),n!==0)return}else if(c>=97&&c<=122){if(t=26*t+(c-96),n!==0)return}else{if(c!==36)return;if(t!==0||r){if(n!==0||o)return;o=!0}else r=!0}}const a={};return e||n!==0&&t!==0?(t>0&&(a.colIndex=t-1,r&&(a.$colIndex=r)),n>0&&(a.rowIndex=n-1,(o||e&&r)&&(a.$rowIndex=o||e&&r)),a):null},Mt=(s,e=ts,t=!1)=>{if(!s)return null;let n=s.toUpperCase();const r=zm(n,t);let o=null,i=null;if(r?.[1]){const l=!!r[2],c=t?ci:Dm;o=c(r[1],l),i=c(r[2]??r[1],l)}if(!o&&!i||o&&i&&(o.rowIndex===void 0&&i.rowIndex!==void 0||o.rowIndex!==void 0&&i.rowIndex===void 0||o.colIndex===void 0&&i.colIndex!==void 0||o.colIndex!==void 0&&i.colIndex===void 0))return null;const a={};return o&&(o.colIndex!==void 0&&(a.colStart=o.colIndex),o.rowIndex!==void 0&&(a.rowStart=o.rowIndex),o.$colIndex!==void 0&&(a.$colStart=o.$colIndex),o.$rowIndex!==void 0&&(a.$rowStart=o.$rowIndex),a?.colStart!==void 0&&a?.colStart>e?.colEnd)?null:(i&&(i.colIndex!==void 0&&(a.colEnd=i.colIndex),i.rowIndex!==void 0&&(a.rowEnd=i.rowIndex),i.$colIndex!==void 0&&(a.$colEnd=i.$colIndex),i.$rowIndex!==void 0&&(a.$rowEnd=i.$rowIndex)),{...e,...a})},os=(s,e,t=!1)=>{const n=(o=>{const i=o.lastIndexOf("!");if(i===-1)return null;let a=o.slice(0,i);return a=lc(a),a=a.replace(/''/g,"'"),[a,o.slice(i+1)]})(s);let r;if(n){if(r=Mt(n[1],e,t),!r)return null;r.sheetName=n[0]}else r=Mt(s,e,t);return r||null},Sc=(s,e,t=mn,n=Hn)=>{if(!s||s.length===0)return null;const r=[],o=s.length;for(let i=0;i<o;i++){const a=s[i];let l=null;a?a.rowIndex!==void 0||a.colIndex!==void 0?l=n(a):a.rowStart!==void 0||a.colStart!==void 0?l=t(a,e,n):typeof a=="string"&&(l=a):l=Ke,l&&r.push(l)}return r},Lm=(s,e,t=qi,n=Hn)=>{const r=Sc(s,e,t,n);return r?r.join(","):Ke},Pm=(s,e,t,n=os,r,o=!1)=>{if(e!==null){if(typeof e=="string"){const i=n(e,t,o);if(!i){const a=r?.(e);if(a){const l=a.length;for(let c=0;c<l;c++){const h=a[c];Pm(s,h,t,n,r,o)}}return}e=i}else e.isICellRange?e=e.getCoords():e.isICell&&(e=k.cellToRange(e.getCoords()));if(e!==null){if(e.rowStart!==void 0||e.colStart!==void 0||e.colEnd!==void 0||e.rowEnd!==void 0){const i=e;s.push({...t,...i})}else if(e.rowIndex!==void 0||e.colIndex!==void 0){const i=e,a={...t,...i,colStart:i.colIndex,rowStart:i.rowIndex,colEnd:i.colIndex,rowEnd:i.rowIndex};a.sheetName===null&&t.sheetName&&(a.sheetName=t.sheetName),delete a.colIndex,delete a.rowIndex,s.push(a)}}else s.push(null)}else s.push(null)},wc=(s,e,t=os,n,r=!1)=>{if(!s)return[e];let o;o=typeof s=="string"?sm(s):s.isICellRanges?s.getCoords():Array.isArray(s)?s:[s];const i=[],a=o.length;for(let l=0;l<a;l++){const c=o[l];Pm(i,c,e,t,n,r)}return i},Tr=(s,e)=>{let t=0,n=0;const r=s.length;for(let o=0;o<r;++o){const i=s.charCodeAt(o);if(i>=48&&i<=57){if(t=10*t+(i-48),n===0)return}else if(i>=65&&i<=90){if(n=26*n+(i-64),t!==0)return}else if(!(i>=97&&i<=122)||(n=26*n+(i-96),t!==0))return}return e?(e.colIndex=n-1,e.rowIndex=t-1,e):{colIndex:n-1,rowIndex:t-1}},ci=(s,e=!1,t)=>{t?(t.colIndex=Number.MIN_SAFE_INTEGER,t.rowIndex=Number.MIN_SAFE_INTEGER,t.$colIndex=!1,t.$rowIndex=!1):t={colIndex:Number.MIN_SAFE_INTEGER,rowIndex:Number.MIN_SAFE_INTEGER,$colIndex:!1,$rowIndex:!1};const n=z_.exec(s);if(!n)return null;const r=n[1],o=n[3];if(!(e||r&&o))return null;if(r){const i=n[2];i?i&&(i.startsWith("[")?(t.rowIndex=parseInt(i.slice(1,-1)),t.$rowIndex=!1):(t.rowIndex=parseInt(i)-1,t.$rowIndex=!0)):(t.rowIndex=0,t.$rowIndex=!1)}if(o){const i=n[4];i?i.startsWith("[")?(t.colIndex=parseInt(i.slice(1,-1)),t.$colIndex=!1):(t.colIndex=parseInt(i)-1,t.$colIndex=!0):(t.colIndex=0,t.$colIndex=!1)}return t},Hl=(s,e)=>{let t=0,n=0,r=!1,o=!1;const i=s.length;for(let a=0;a<i;++a){const l=s.charCodeAt(a);l>=48&&l<=57?t=10*t+(l-48):l>=65&&l<=90?n=26*n+(l-64):l>=97&&l<=122?n=26*n+(l-96):l===36&&(a===0?r=!0:o=!0)}return n--,t--,e.colIndex=n,e.rowIndex=t,t===-1?(e.$colIndex=r,e.$rowIndex=!1,e):n===-1?(e.$colIndex=!1,e.$rowIndex=r,e):(e.$colIndex=r,e.$rowIndex=o,e)},$_=s=>{let e=0;const t=s.length;for(let n=0;n<t;++n){const r=s.charCodeAt(n);if(r>=65&&r<=90)e=26*e+(r-64);else{if(!(r>=97&&r<=122))return e-1;e=26*e+(r-96)}}return e-1},St=(s,e)=>{let t=e;t?(t.rowStart=0,t.colStart=0,t.rowEnd=0,t.colEnd=0):t={rowStart:0,colStart:0,rowEnd:0,colEnd:0};let n=0,r=0,o=0,i=s.length;for(n=0;r<i&&(o=s.charCodeAt(r),o>96&&o<123&&(o-=32),!(o<65||o>91));++r)n=26*n+(o-64);for(t.colStart=--n,n=0;r<i;++r){let a=s.charCodeAt(r)-48;if(a<0||a>9)break;n=10*n+a}if(t.rowStart=--n,r===i||s.charCodeAt(++r)===58)return t.colEnd=t.colStart,t.rowEnd=t.rowStart,t;for(n=0;r!==i&&(o=s.charCodeAt(r),o>96&&o<123&&(o-=32),!(o<65||o>91));++r)n=26*n+(o-64);for(t.colEnd=--n,n=0;r!==i;++r){let a=s.charCodeAt(r)-48;if(a<0||a>9)break;n=10*n+a}return t.rowEnd=--n,t},zm=(s,e=!1)=>{const t=s.match(e?P_:L_);return s.endsWith(":")?null:t},Vl={rowIndex:-1,colIndex:-1,$colIndex:!1,$rowIndex:!1},Va=(s,e,t,n=Om)=>{let r=s.lastIndexOf("!"),o="";r!==-1&&(o=s.slice(0,r)+"!",s=s.slice(r+1));let i=null;const a=()=>{let c="";const h=i.rowIndex;if(h!==-1)if(i.$rowIndex)c+=`R${h+1}`;else{const g=h-e;c+=g===0?"R":`R[${g}]`}let u="";const d=i.colIndex;if(d!==-1)if(i.$colIndex)u+=`C${d+1}`;else{const g=d-t;u+=g===0?"C":`C[${g}]`}o+=c+u};r=s.lastIndexOf(":");const l=r!==-1;if(l){const c=s.slice(0,r);s=s.slice(r+1),i=Hl(c,Vl),i.colIndex!==-1&&i.rowIndex!==-1&&(a(),o+=":")}return i=Hl(s,Vl),!l&&i.colIndex>n?s:(a(),o)},Br=[],U_=s=>(Br.push(s),String.fromCharCode(57344+Br.length-1)),q_=s=>{const e=s.charCodeAt(0)-57344;return Br[e]},J_=(s,e,t)=>{let n="";const r=s.length;for(let o=0;o<r;o++){const i=s[o];n+=typeof i=="string"?i:Wm(i,e,t)}return n},hi=(s,e)=>{let t="";const n=s.rowIndex;n!==Number.MIN_SAFE_INTEGER&&(s.$rowIndex?t+=`R${n+1}`:t+=n===0?"R":`R[${n+1}]`);let r="";const o=s.colIndex;return o!==Number.MIN_SAFE_INTEGER&&(s.$colIndex?r+=`C${o+1}`:r+=o===0?"C":`C[${o+1}]`),s.sheetName&&(t=_c(s.sheetName,e)+"!"+t),t+r},Wm=(s,e,t)=>{let n="";const r=s.colIndex;r!==Number.MIN_SAFE_INTEGER&&(s.$colIndex?n+="$"+Dt(r):n+=Dt(r+t));const o=s.rowIndex;return o!==Number.MIN_SAFE_INTEGER&&(s.$rowIndex?n+="$"+Ht(o):n+=Ht(o+e)),n},K_=(s,e,t,n)=>{Br.length=0;let r=0,o=s.replace(H_,U_),i=0,a=o.replace(W_,(l,c,h)=>{const u=Va(l,e,t);if(n){if(h>i){const g=o.slice(i,h).replace(Wa,(m,f)=>Br[r++]);n.push(g)}const d=l.lastIndexOf(":");if(d!==-1){const g=l.slice(0,d),m=l.slice(d+1),f=Va(g,e,t),_=Va(m,e,t);n.push(ci(f,!0)??f),n.push(":"),n.push(ci(_,!0)??_)}else n.push(ci(u,!0)??u)}return i=h+l.length,u});if(n&&i<o.length){const l=o.slice(i);n.push(l.replace(Wa,(c,h)=>Br[r++]))}return a=a.toUpperCase().replace(j_,""),a.replace(Wa,q_)},Dr="Must specify an address.",jm="Only a single range is allowed for this operation. Use 'getRanges' instead.",Hm="Invalid range. The Range must be specified as '{ TOP_LEFT:BOTTOM_RIGHT }'.",$o=s=>`Invalid address. Can not parse ${typeof s=="string"?`'${s}' `:""}as an address or named item.`,_e=()=>{throw new Error("Invalid range.")};class er{constructor(e,t,n=!1){this._c=e,this._cycleId=t,this._e=n}getCycleId(){return this._cycleId}getError(){return this._e}getCoords(){return this._c}setError(e,t){const n=this._c;return{...n,value:new er(n,t,e)}}getShifted(e){const t=e.after;if(!t)return null;const n=k.sanitizeRange(t);return{...n,value:new er(n,this._cycleId,this._e)}}getMerged(e,t,n){}getSplit(e,t){}}class jt{constructor(e,t){this._c=e,this._o=t}getCoords(){return this._c}getOrientation(){return this._o}getShifted(e){return e.after?{...e.after,value:new jt(e.after,this._o)}:null}getMerged(e,t,n){const r=this._o;return new jt(t,r)}getSplit(e,t){const n=this._o;return[new jt(e[0],n),new jt(e[1],n)]}getState(){return this._c}}const Nu=(s,e)=>{if(!s||s.length===0)return N.EmptyArray;const t=[],n=e?exports.w.Orientation.Column:exports.w.Orientation.Row;for(let r=0;r<s.length;r++){const o=s[r],i=o[0],a=o[1];for(let l=0;l<a.length;l++){const c=a[l],h=c[0],u=c[1].length-1,d={colStart:e?i:h,rowStart:e?h:i,colEnd:e?i:h+u,rowEnd:e?h+u:i,value:new jt({colStart:e?i:h,rowStart:e?h:i,colEnd:e?i:h+u,rowEnd:e?h+u:i},n)};t.push(d)}}return t},Gl=0,ku=1;class hn{constructor(e,t,n){this.ref=e,this.formula=t;const r=e.colStart,o=e.rowStart;if(n){const i=n,a=i.length;for(let l=0;l<a;l++){const c=[...i[l]];i[l]=c;const h=c.length;for(let u=0;u<h;u++){const d={...c[u]};c[u]=d,d.colIndex=u+r,d.rowIndex=l+o,d.block=this}}this.calcs=i}else{const i=t.getDirectPrecedentsAt(o,r),a=i?.length??0,l=new Array(e.rowEnd-o+1),c=e.colEnd-r+1,h=l.length;for(let u=0;u<h;u++){const d=new Array(c),g=d.length;for(let m=0;m<g;m++)d[m]={block:this,colIndex:m+r,rowIndex:u+o,cycleId:0,markId:0,inDegree:0,dependents:N.EmptyArray,inputs:a===0?N.EmptyArray:new Array(a),precedents:a===0?N.EmptyArray:new Array(a),dynamic:null,cachedValue:void 0,removed:!1,pending:!1,pendingPrecedents:!1,pendingPromise:null,pendingResolved:!1,state:Gl,error:void 0};l[u]=d}this.calcs=l}}toJSON(){const e=this.ref;return[Cn(e),this.formula.getTextAt(e.rowStart,e.colStart)]}getCoords(){return this.ref}getShifted(e){if(!e.after)return null;const t=k.sanitizeRange(e.after),n=[...this.calcs],r=new hn(t,this.formula,n);return{...e.after,value:r}}setReferenceAt(e,t){const n=this.formula.setReferenceAt(e,t),r=[...this.calcs];return new hn(this.ref,n,r)}getMerged(e,t,n){const r=this.formula,o=e.formula;if(!r.isEquals(o))return;const i=this.calcs,a=e.calcs;let l;if(n===exports.w.Orientation.Row)l=[...i,...a];else{const c=i.length;l=new Array(c);for(let h=0;h<c;h++)l[h]=[...i[h],...a[h]]}return new hn(t,r,l)}getSplit(e,t,n){const r=this.formula,o=t===exports.w.Orientation.Column;let i,a;const l=this.calcs;if(o){const c=l.length;i=new Array(c),a=new Array(c);for(let h=0;h<c;h++){const u=l[h];i[h]=u.slice(0,n),a[h]=u.slice(n)}}else i=l.slice(0,n),a=l.slice(n);return[new hn(e[0],r,i),new hn(e[1],r,a)]}copyTo(e,t){const n=this.formula;return new hn(e,n)}canTile(e,t){return!0}onRemove(e){const t=e.value.calcs,n=t.length;for(let r=0;r<n;r++){const o=t[r],i=o.length;for(let a=0;a<i;a++){const l=o[a];l.pendingPromise&&(l.pendingPromise.cancelled=!0),l.removed=!0}}}}const Ou=Object.freeze({break:!0});var X;(X||(X={})).Type={Style:"style",Table:"table",Merge:"merge",Hyperlink:"hyperlink",Comments:"comments",Unlock:"unlock",Contentful:"contentful",Conditional:"conditional",Formula:"formula",Spill:"spill",Continuous:"continuous",Pending:"pending",CalcError:"calcError"};const X_=Object.freeze({[X.Type.Style]:!1,[X.Type.Table]:!1,[X.Type.Merge]:!1,[X.Type.Hyperlink]:!1,[X.Type.Comments]:!1,[X.Type.Unlock]:!1,[X.Type.Formula]:!1,[X.Type.Spill]:!1,[X.Type.Pending]:!1,[X.Type.CalcError]:!1,[X.Type.Contentful]:!1,[X.Type.Conditional]:!1,[X.Type.Continuous]:!1}),Vm=Object.freeze({[X.Type.Style]:!1,[X.Type.Table]:!1,[X.Type.Merge]:!1,[X.Type.Hyperlink]:!1,[X.Type.Comments]:!1,[X.Type.Unlock]:!1,[X.Type.Formula]:!1,[X.Type.Spill]:!1,[X.Type.Pending]:!1,[X.Type.CalcError]:!1,[X.Type.Conditional]:!1,[X.Type.Continuous]:!1}),Y_=Object.freeze({[X.Type.Style]:!1,[X.Type.Table]:!0,[X.Type.Merge]:!1,[X.Type.Hyperlink]:!1,[X.Type.Comments]:!1,[X.Type.Unlock]:!1,[X.Type.Formula]:!1}),Q_=Object.freeze({[X.Type.Style]:!1,[X.Type.Table]:!1,[X.Type.Hyperlink]:!1,[X.Type.Comments]:!1,[X.Type.Unlock]:!1,[X.Type.Contentful]:!1,[X.Type.Formula]:!1}),bs="This sheet is protected. To make a change, unprotect the sheet. You might be requested to enter a password.",Z_=(s="update")=>`Unable to ${s}, this sheet is protected. To make a change, unprotect the sheet. You might be requested to enter a password.`,Ti="The range is outside of the bounds of the sheet.",Bu="Listener can not be null",Du="We can't insert items. The sheet is protected.",Lu=s=>`We can't create a ${s} that overlaps with another table or merge.`,Pu="Overlapping ranges can not be merged.",Ga="We can't insert cells because this would push values off the end of the worksheet. These cells may appear empty but they have some formatting or formulas. Delete enough rows or columns and try again.",zu="Unable to partially fill over merged cells.",Wu="Unable to sort merged cells unless they are all the same size.",ft="Sheet has been closed. No further operations are allowed.",Lr="IteratorContext can only be used during visit.",ju="When using addresses directly from the sheet do not include the sheet name.",Gm=s=>`Unable to return more than ${s} values. To access values in a more scalable solution use 'ICellRange.forEach' or an iterator.`,Hu="Multiple selection ranges can not be copied.",Vu="Unable to determine source.",Gu="When pasting before or after the cut area both areas must align.",Cr=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,$u=new Set,$l=typeof process=="object"&&process?process:{},$m=(s,e,t,n)=>{typeof $l.emitWarning=="function"?$l.emitWarning(s,e,t,n):console.error(`[${t}] ${e}: ${s}`)};let Fi=globalThis.AbortController,Uu=globalThis.AbortSignal;if(Fi===void 0){Uu=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,n){this._onabort.push(n)}},Fi=class{constructor(){e()}signal=new Uu;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const n of this.signal._onabort)n(t);this.signal.onabort?.(t)}}};let s=$l.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1";const e=()=>{s&&(s=!1,$m("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}const Nn=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),Um=s=>Nn(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?ui:null:null;class ui extends Array{constructor(e){super(e),this.fill(0)}}class Fr{heap;length;static#l=!1;static create(e){const t=Um(e);if(!t)return[];Fr.#l=!0;const n=new Fr(e,t);return Fr.#l=!1,n}constructor(e,t){if(!Fr.#l)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class yc{#l;#u;#f;#R;#p;#F;#N;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#_;#r;#n;#e;#c;#d;#a;#s;#S;#i;#w;#y;#g;#C;#I;#h;#k;static unsafeExposeInternals(e){return{starts:e.#y,ttls:e.#g,sizes:e.#w,keyMap:e.#r,keyList:e.#n,valList:e.#e,next:e.#c,prev:e.#d,get head(){return e.#a},get tail(){return e.#s},free:e.#S,isBackgroundFetch:t=>e.#t(t),backgroundFetch:(t,n,r,o)=>e.#D(t,n,r,o),moveToTail:t=>e.#T(t),indexes:t=>e.#b(t),rindexes:t=>e.#E(t),isStale:t=>e.#m(t)}}get max(){return this.#l}get maxSize(){return this.#u}get calculatedSize(){return this.#_}get size(){return this.#o}get fetchMethod(){return this.#F}get memoMethod(){return this.#N}get dispose(){return this.#f}get onInsert(){return this.#R}get disposeAfter(){return this.#p}constructor(e){const{max:t=0,ttl:n,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:i,updateAgeOnHas:a,allowStale:l,dispose:c,onInsert:h,disposeAfter:u,noDisposeOnSet:d,noUpdateTTL:g,maxSize:m=0,maxEntrySize:f=0,sizeCalculation:_,fetchMethod:p,memoMethod:S,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:y,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:w,ignoreFetchAbort:E}=e;if(t!==0&&!Nn(t))throw new TypeError("max option must be a nonnegative integer");const I=t?Um(t):Array;if(!I)throw new Error("invalid max value: "+t);if(this.#l=t,this.#u=m,this.maxEntrySize=f||this.#u,this.sizeCalculation=_,this.sizeCalculation){if(!this.#u&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(S!==void 0&&typeof S!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#N=S,p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#F=p,this.#I=!!p,this.#r=new Map,this.#n=new Array(t).fill(void 0),this.#e=new Array(t).fill(void 0),this.#c=new I(t),this.#d=new I(t),this.#a=0,this.#s=0,this.#S=Fr.create(t),this.#o=0,this.#_=0,typeof c=="function"&&(this.#f=c),typeof h=="function"&&(this.#R=h),typeof u=="function"?(this.#p=u,this.#i=[]):(this.#p=void 0,this.#i=void 0),this.#C=!!this.#f,this.#k=!!this.#R,this.#h=!!this.#p,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!E,this.maxEntrySize!==0){if(this.#u!==0&&!Nn(this.#u))throw new TypeError("maxSize must be a positive integer if specified");if(!Nn(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#V()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!y,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!a,this.ttlResolution=Nn(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!Nn(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#L()}if(this.#l===0&&this.ttl===0&&this.#u===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#l&&!this.#u){const x="LRU_CACHE_UNBOUNDED";(v=>!$u.has(v))(x)&&($u.add(x),$m("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",x,yc))}}getRemainingTTL(e){return this.#r.has(e)?1/0:0}#L(){const e=new ui(this.#l),t=new ui(this.#l);this.#g=e,this.#y=t,this.#P=(o,i,a=Cr.now())=>{if(t[o]=i!==0?a:0,e[o]=i,i!==0&&this.ttlAutopurge){const l=setTimeout(()=>{this.#m(o)&&this.#v(this.#n[o],"expire")},i+1);l.unref&&l.unref()}},this.#A=o=>{t[o]=e[o]!==0?Cr.now():0},this.#x=(o,i)=>{if(e[i]){const a=e[i],l=t[i];if(!a||!l)return;o.ttl=a,o.start=l,o.now=n||r();const c=o.now-l;o.remainingTTL=a-c}};let n=0;const r=()=>{const o=Cr.now();if(this.ttlResolution>0){n=o;const i=setTimeout(()=>n=0,this.ttlResolution);i.unref&&i.unref()}return o};this.getRemainingTTL=o=>{const i=this.#r.get(o);if(i===void 0)return 0;const a=e[i],l=t[i];return!a||!l?1/0:a-((n||r())-l)},this.#m=o=>{const i=t[o],a=e[o];return!!a&&!!i&&(n||r())-i>a}}#A=()=>{};#x=()=>{};#P=()=>{};#m=()=>!1;#V(){const e=new ui(this.#l);this.#_=0,this.#w=e,this.#M=t=>{this.#_-=e[t],e[t]=0},this.#z=(t,n,r,o)=>{if(this.#t(n))return 0;if(!Nn(r)){if(!o)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(n,t),!Nn(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return r},this.#O=(t,n,r)=>{if(e[t]=n,this.#u){const o=this.#u-e[t];for(;this.#_>o;)this.#B(!0)}this.#_+=e[t],r&&(r.entrySize=n,r.totalCalculatedSize=this.#_)}}#M=e=>{};#O=(e,t,n)=>{};#z=(e,t,n,r)=>{if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#b({allowStale:e=this.allowStale}={}){if(this.#o)for(let t=this.#s;this.#W(t)&&(!e&&this.#m(t)||(yield t),t!==this.#a);)t=this.#d[t]}*#E({allowStale:e=this.allowStale}={}){if(this.#o)for(let t=this.#a;this.#W(t)&&(!e&&this.#m(t)||(yield t),t!==this.#s);)t=this.#c[t]}#W(e){return e!==void 0&&this.#r.get(this.#n[e])===e}*entries(){for(const e of this.#b())this.#e[e]===void 0||this.#n[e]===void 0||this.#t(this.#e[e])||(yield[this.#n[e],this.#e[e]])}*rentries(){for(const e of this.#E())this.#e[e]===void 0||this.#n[e]===void 0||this.#t(this.#e[e])||(yield[this.#n[e],this.#e[e]])}*keys(){for(const e of this.#b()){const t=this.#n[e];t===void 0||this.#t(this.#e[e])||(yield t)}}*rkeys(){for(const e of this.#E()){const t=this.#n[e];t===void 0||this.#t(this.#e[e])||(yield t)}}*values(){for(const e of this.#b())this.#e[e]===void 0||this.#t(this.#e[e])||(yield this.#e[e])}*rvalues(){for(const e of this.#E())this.#e[e]===void 0||this.#t(this.#e[e])||(yield this.#e[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(const n of this.#b()){const r=this.#e[n],o=this.#t(r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,this.#n[n],this))return this.get(this.#n[n],t)}}forEach(e,t=this){for(const n of this.#b()){const r=this.#e[n],o=this.#t(r)?r.__staleWhileFetching:r;o!==void 0&&e.call(t,o,this.#n[n],this)}}rforEach(e,t=this){for(const n of this.#E()){const r=this.#e[n],o=this.#t(r)?r.__staleWhileFetching:r;o!==void 0&&e.call(t,o,this.#n[n],this)}}purgeStale(){let e=!1;for(const t of this.#E({allowStale:!0}))this.#m(t)&&(this.#v(this.#n[t],"expire"),e=!0);return e}info(e){const t=this.#r.get(e);if(t===void 0)return;const n=this.#e[t],r=this.#t(n)?n.__staleWhileFetching:n;if(r===void 0)return;const o={value:r};if(this.#g&&this.#y){const i=this.#g[t],a=this.#y[t];if(i&&a){const l=i-(Cr.now()-a);o.ttl=l,o.start=Date.now()}}return this.#w&&(o.size=this.#w[t]),o}dump(){const e=[];for(const t of this.#b({allowStale:!0})){const n=this.#n[t],r=this.#e[t],o=this.#t(r)?r.__staleWhileFetching:r;if(o===void 0||n===void 0)continue;const i={value:o};if(this.#g&&this.#y){i.ttl=this.#g[t];const a=Cr.now()-this.#y[t];i.start=Math.floor(Date.now()-a)}this.#w&&(i.size=this.#w[t]),e.unshift([n,i])}return e}load(e){this.clear();for(const[t,n]of e){if(n.start){const r=Date.now()-n.start;n.start=Cr.now()-r}this.set(t,n.value,n)}}set(e,t,n={}){if(t===void 0)return this.delete(e),this;const{ttl:r=this.ttl,start:o,noDisposeOnSet:i=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:l}=n;let{noUpdateTTL:c=this.noUpdateTTL}=n;const h=this.#z(e,t,n.size||0,a);if(this.maxEntrySize&&h>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.#v(e,"set"),this;let u=this.#o===0?void 0:this.#r.get(e);if(u===void 0)u=this.#o===0?this.#s:this.#S.length!==0?this.#S.pop():this.#o===this.#l?this.#B(!1):this.#o,this.#n[u]=e,this.#e[u]=t,this.#r.set(e,u),this.#c[this.#s]=u,this.#d[u]=this.#s,this.#s=u,this.#o++,this.#O(u,h,l),l&&(l.set="add"),c=!1,this.#k&&this.#R?.(t,e,"add");else{this.#T(u);const d=this.#e[u];if(t!==d){if(this.#I&&this.#t(d)){d.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:g}=d;g===void 0||i||(this.#C&&this.#f?.(g,e,"set"),this.#h&&this.#i?.push([g,e,"set"]))}else i||(this.#C&&this.#f?.(d,e,"set"),this.#h&&this.#i?.push([d,e,"set"]));if(this.#M(u),this.#O(u,h,l),this.#e[u]=t,l){l.set="replace";const g=d&&this.#t(d)?d.__staleWhileFetching:d;g!==void 0&&(l.oldValue=g)}}else l&&(l.set="update");this.#k&&this.onInsert?.(t,e,t===d?"update":"replace")}if(r===0||this.#g||this.#L(),this.#g&&(c||this.#P(u,r,o),l&&this.#x(l,u)),!i&&this.#h&&this.#i){const d=this.#i;let g;for(;g=d?.shift();)this.#p?.(...g)}return this}pop(){try{for(;this.#o;){const e=this.#e[this.#a];if(this.#B(!0),this.#t(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#h&&this.#i){const e=this.#i;let t;for(;t=e?.shift();)this.#p?.(...t)}}}#B(e){const t=this.#a,n=this.#n[t],r=this.#e[t];return this.#I&&this.#t(r)?r.__abortController.abort(new Error("evicted")):(this.#C||this.#h)&&(this.#C&&this.#f?.(r,n,"evict"),this.#h&&this.#i?.push([r,n,"evict"])),this.#M(t),e&&(this.#n[t]=void 0,this.#e[t]=void 0,this.#S.push(t)),this.#o===1?(this.#a=this.#s=0,this.#S.length=0):this.#a=this.#c[t],this.#r.delete(n),this.#o--,t}has(e,t={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=t,o=this.#r.get(e);if(o!==void 0){const i=this.#e[o];if(this.#t(i)&&i.__staleWhileFetching===void 0)return!1;if(!this.#m(o))return n&&this.#A(o),r&&(r.has="hit",this.#x(r,o)),!0;r&&(r.has="stale",this.#x(r,o))}else r&&(r.has="miss");return!1}peek(e,t={}){const{allowStale:n=this.allowStale}=t,r=this.#r.get(e);if(r===void 0||!n&&this.#m(r))return;const o=this.#e[r];return this.#t(o)?o.__staleWhileFetching:o}#D(e,t,n,r){const o=t===void 0?void 0:this.#e[t];if(this.#t(o))return o;const i=new Fi,{signal:a}=n;a?.addEventListener("abort",()=>i.abort(a.reason),{signal:i.signal});const l={signal:i.signal,options:n,context:r},c=(g,m=!1)=>{const{aborted:f}=i.signal,_=n.ignoreFetchAbort&&g!==void 0;if(n.status&&(f&&!m?(n.status.fetchAborted=!0,n.status.fetchError=i.signal.reason,_&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),f&&!_&&!m)return h(i.signal.reason);const p=u;return this.#e[t]===u&&(g===void 0?p.__staleWhileFetching?this.#e[t]=p.__staleWhileFetching:this.#v(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,g,l.options))),g},h=g=>{const{aborted:m}=i.signal,f=m&&n.allowStaleOnFetchAbort,_=f||n.allowStaleOnFetchRejection,p=_||n.noDeleteOnFetchRejection,S=u;if(this.#e[t]===u&&(!p||S.__staleWhileFetching===void 0?this.#v(e,"fetch"):f||(this.#e[t]=S.__staleWhileFetching)),_)return n.status&&S.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw g};n.status&&(n.status.fetchDispatched=!0);const u=new Promise((g,m)=>{const f=this.#F?.(e,o,l);f&&f instanceof Promise&&f.then(_=>g(_===void 0?void 0:_),m),i.signal.addEventListener("abort",()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(g(void 0),n.allowStaleOnFetchAbort&&(g=_=>c(_,!0)))})}).then(c,g=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=g),h(g))),d=Object.assign(u,{__abortController:i,__staleWhileFetching:o,__returned:void 0});return t===void 0?(this.set(e,d,{...l.options,status:void 0}),t=this.#r.get(e)):this.#e[t]=d,d}#t(e){if(!this.#I)return!1;const t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Fi}async fetch(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:g=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:f,forceRefresh:_=!1,status:p,signal:S}=t;if(!this.#I)return p&&(p.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:p});const C={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:i,noDisposeOnSet:a,size:l,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:m,ignoreFetchAbort:g,status:p,signal:S};let y=this.#r.get(e);if(y===void 0){p&&(p.fetch="miss");const b=this.#D(e,y,C,f);return b.__returned=b}{const b=this.#e[y];if(this.#t(b)){const x=n&&b.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",x&&(p.returnedStale=!0)),x?b.__staleWhileFetching:b.__returned=b}const w=this.#m(y);if(!_&&!w)return p&&(p.fetch="hit"),this.#T(y),r&&this.#A(y),p&&this.#x(p,y),b;const E=this.#D(e,y,C,f),I=E.__staleWhileFetching!==void 0&&n;return p&&(p.fetch=w?"stale":"refresh",I&&w&&(p.returnedStale=!0)),I?E.__staleWhileFetching:E.__returned=E}}async forceFetch(e,t={}){const n=await this.fetch(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){const n=this.#N;if(!n)throw new Error("no memoMethod provided to constructor");const{context:r,forceRefresh:o,...i}=t,a=this.get(e,i);if(!o&&a!==void 0)return a;const l=n(e,a,{options:i,context:r});return this.set(e,l,i),l}get(e,t={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:i}=t,a=this.#r.get(e);if(a!==void 0){const l=this.#e[a],c=this.#t(l);return i&&this.#x(i,a),this.#m(a)?(i&&(i.get="stale"),c?(i&&n&&l.__staleWhileFetching!==void 0&&(i.returnedStale=!0),n?l.__staleWhileFetching:void 0):(o||this.#v(e,"expire"),i&&n&&(i.returnedStale=!0),n?l:void 0)):(i&&(i.get="hit"),c?l.__staleWhileFetching:(this.#T(a),r&&this.#A(a),l))}i&&(i.get="miss")}#j(e,t){this.#d[t]=e,this.#c[e]=t}#T(e){e!==this.#s&&(e===this.#a?this.#a=this.#c[e]:this.#j(this.#d[e],this.#c[e]),this.#j(this.#s,e),this.#s=e)}delete(e){return this.#v(e,"delete")}#v(e,t){let n=!1;if(this.#o!==0){const r=this.#r.get(e);if(r!==void 0)if(n=!0,this.#o===1)this.#H(t);else{this.#M(r);const o=this.#e[r];if(this.#t(o)?o.__abortController.abort(new Error("deleted")):(this.#C||this.#h)&&(this.#C&&this.#f?.(o,e,t),this.#h&&this.#i?.push([o,e,t])),this.#r.delete(e),this.#n[r]=void 0,this.#e[r]=void 0,r===this.#s)this.#s=this.#d[r];else if(r===this.#a)this.#a=this.#c[r];else{const i=this.#d[r];this.#c[i]=this.#c[r];const a=this.#c[r];this.#d[a]=this.#d[r]}this.#o--,this.#S.push(r)}}if(this.#h&&this.#i?.length){const r=this.#i;let o;for(;o=r?.shift();)this.#p?.(...o)}return n}clear(){return this.#H("delete")}#H(e){for(const t of this.#E({allowStale:!0})){const n=this.#e[t];if(this.#t(n))n.__abortController.abort(new Error("deleted"));else{const r=this.#n[t];this.#C&&this.#f?.(n,r,e),this.#h&&this.#i?.push([n,r,e])}}if(this.#r.clear(),this.#e.fill(void 0),this.#n.fill(void 0),this.#g&&this.#y&&(this.#g.fill(0),this.#y.fill(0)),this.#w&&this.#w.fill(0),this.#a=0,this.#s=0,this.#S.length=0,this.#_=0,this.#o=0,this.#h&&this.#i){const t=this.#i;let n;for(;n=t?.shift();)this.#p?.(...n)}}}var qu;exports.ICell=void 0,(qu=exports.ICell||(exports.ICell={})).CalcStatus={Ready:"ready",Stale:"stale",Pending:"pending",Streaming:"streaming"},qu.Content={Values:"values",Formats:"formats",Formulas:"formula",Hyperlinks:"hyperlinks",Tables:"tables",Notes:"notes",Comments:"comments",Warnings:"warnings",Errors:"errors",Merges:"merges"};class eS{constructor(e,t,n){if(!n)throw new Ot;if(typeof n=="string"&&(n={address:n}),typeof n.address!="string")throw new Error("Invalid hyperlink");this._t=e,this._r=t,this._p=n}open(e,t){return this._r(this.getAddress(),null,e??this.getTarget(),t)}getTarget(){let e=this._p.target;return e||(this._p.address.startsWith("#")?"_self":"_blank")}getDisplayText(){return this._t()??this.getAddress()}getAddress(){return this._p.address??""}getTooltip(){return this._p.tooltip??null}get isIHyperlink(){return!0}}function Ju(s){return!/^(-?\d|--)/.test(s)}function Ku(s){const e=[];let t="",n="",r=7;for(let o,i=0;o=s.charAt(i);i++)if(/[a-zA-Z\d\xa0-\uffff_-]/.test(o)&&r===7)t+=o;else if(o==="\\"&&r===7)r=6;else if(o===" "&&r===7){if(t!==""){if(!Ju(t))return null;e.push(t),t=""}}else if(r===6)/[0-9a-f]/i.test(o)?(n+=o,r=8):(t+=o,r=7);else{if(r!==8)return null;/[0-9a-f]/i.test(o)&&n.length<6?n+=o:(t+=String.fromCodePoint(parseInt(n,16)),t+=o,n="",r=7)}if(t!==""){if(!Ju(t))return null;e.push(t)}return e.join(" ")}function Xu(s,e){let t=e,n="";const r={"font-family":[]};for(let o,i=0;o=s.charAt(i);i+=1)if(t!==4||o!=='"'&&o!=="'")if(t===3&&o===",")t=4,n="";else if(t===4&&o===","){const a=Ku(n);a&&r["font-family"].push(a),n=""}else if(t===5&&o===" ")/^(?:\+|-)?(?:[0-9]*\.)?[0-9]+(?:deg|grad|rad|turn)$/.test(n)?(r["font-style"]+=" "+n,n=""):i-=1,t=1;else if(t!==1||o!==" "&&o!=="/")t===2&&o===" "?(/^(?:\+|-)?([0-9]*\.)?[0-9]+(?:em|ex|ch|rem|vh|vw|vmin|vmax|px|mm|cm|in|pt|pc|%)?$/.test(n)&&(r["line-height"]=n),t=4,n=""):n+=o;else{if(/^(?:(?:xx|x)-large|(?:xx|s)-small|small|large|medium)$/.test(n)||/^(?:larg|small)er$/.test(n)||/^(?:\+|-)?(?:[0-9]*\.)?[0-9]+(?:em|ex|ch|rem|vh|vw|vmin|vmax|px|mm|cm|in|pt|pc|%)$/.test(n))t=o==="/"?2:4,r["font-size"]=n;else if(/^italic$/.test(n))r["font-style"]=n;else if(/^oblique$/.test(n))r["font-style"]=n,t=5;else if(/^small-caps$/.test(n))r["font-variant"]=n;else if(/^(?:bold(?:er)?|lighter|normal)$/.test(n))r["font-weight"]=n;else if(/^[+-]?(?:[0-9]*\.)?[0-9]+(?:e[+-]?(?:0|[1-9][0-9]*))?$/.test(n)){const a=parseFloat(n);a>=1&&a<=1e3&&(r["font-weight"]=n)}else/^(?:(?:ultra|extra|semi)-)?(?:condensed|expanded)$/.test(n)&&(r["font-stretch"]=n);n=""}else{let a=i+1;do if(a=s.indexOf(o,a)+1,!a)return null;while(s.charAt(a-2)==="\\");r["font-family"].push(s.slice(i+1,a-1).replace(/\\('|")/g,"$1")),i=a-1,t=3,n=""}if(t===3&&!/^\s*$/.test(n))return null;if(t===4){const o=Ku(n);o&&r["font-family"].push(o)}return r}const di=s=>{if(typeof s!="string")return null;let e=function(o){const i=Xu(o,4);return i!==null?i["font-family"]:null}(s);Array.isArray(e)&&e.length===0&&(e=null),e=e?{"font-family":e}:function(o){const i=Xu(o,1);return i!==null&&i["font-size"]&&i["font-family"].length?i:null}(s);let t=null,n=null,r=null;if(e){let o=e["font-family"];const i=o.shift();i&&(t=i),o.length>0&&(n=o),e["font-size"]!==void 0&&(r=e["font-size"])}return{family:t,fallbacks:n,size:r}},Qt=(s,e=!1)=>s?.toHex(e)?.toString(!1).toLowerCase()??null,Yu=s=>s==null?null:N.roundAccurately(s,2)+"pt",qm=(s,e)=>{let t="";const n=s&&s!==exports.IFont.UnderlineStyle.None;return e&&(t+="line-through"),n&&e&&(t+=" "),n&&(t+="underline",s!==!0&&s!==exports.IFont.UnderlineStyle.Single&&s!==exports.IFont.UnderlineStyle.SingleAccounting||(t+=" solid"),s!==exports.IFont.UnderlineStyle.Double&&s!==exports.IFont.UnderlineStyle.DoubleAccounting||(t+=" double")),t},tS=Object.freeze({underline:exports.IFont.UnderlineStyle.None,strike:!1}),Jm=s=>s?(s=s.toLowerCase())==="single"?exports.IFont.UnderlineStyle.Single:s==="double"?exports.IFont.UnderlineStyle.Double:s==="single-accounting"||s==="singleaccounting"?exports.IFont.UnderlineStyle.SingleAccounting:s==="double-accounting"||s==="doubleaccounting"?exports.IFont.UnderlineStyle.DoubleAccounting:exports.IFont.UnderlineStyle.None:exports.IFont.UnderlineStyle.None,Qu=s=>s?s.toLowerCase():null,Zu=s=>s?s===exports.ITextFrame.Overflow.Visible||s===exports.ITextFrame.Overflow.Clip||s===exports.ITextFrame.Overflow.Shrink?"nowrap":s===exports.ITextFrame.Overflow.Wrap?"normal":void 0:null,Ni=(s,e)=>{let t="";if(s&&(s.includes(" ")&&(s='"'+s+'"'),t=s),e)for(let n=0;n<e.length;n++)t.length>0&&(t+=", "),t+=e[n];return t},ed=s=>{let e="",t=!1,n="";for(let r=0;r<s.length;r++){const o=s.charAt(r);t&&o!=="]"&&o!=='"'?e+=o:o==='"'?(e+="\\0022",t=!t):["[","]",",","#",".","@","/",":",";","-"," "].includes(o)?(e+="\\"+o,o==="["?t=!0:o==="]"&&(t=!1)):["(",")"].includes(o)?e+=n==="_"?"\\"+o:"\\\\\\"+o:["$"].includes(o)?e+="\\0022"+o+"\\0022":e+=o,n=o}return'"'+e+'"'},nS="Thin",rS="Hairline",oS="Extra Light",sS="Ultra Light",iS="Light",td="Normal",aS="Regular",lS="Medium",cS="Semi Bold",hS="Demi Bold",uS="Bold",dS="Extra Bold",gS="Ultra Bold",mS="Black",fS="Heavy",pS="Extra Black",_S="Ultra Black",SS="lighter",wS="normal",yS="bold",CS="bolder",Pe=new Map;Pe.set(N.textToKey(nS),100),Pe.set(N.textToKey(rS),100),Pe.set(N.textToKey(oS),200),Pe.set(N.textToKey(sS),200),Pe.set(N.textToKey(iS),300),Pe.set(N.textToKey(td),400),Pe.set(N.textToKey(aS),400),Pe.set(N.textToKey(lS),500),Pe.set(N.textToKey(cS),600),Pe.set(N.textToKey(hS),600),Pe.set(N.textToKey(td),400),Pe.set(N.textToKey(uS),700),Pe.set(N.textToKey(dS),800),Pe.set(N.textToKey(gS),800),Pe.set(N.textToKey(mS),900),Pe.set(N.textToKey(fS),900),Pe.set(N.textToKey(pS),950),Pe.set(N.textToKey(_S),950),Pe.set(N.textToKey(SS),100),Pe.set(N.textToKey(wS),400),Pe.set(N.textToKey(yS),700),Pe.set(N.textToKey(CS),700);const bS="xx-small",ES="x-small",vS="small",xS="medium",IS="large",RS="x-large",AS="xx-large",MS="xxx-large",TS="smaller",FS="larger",NS="math",kS=new RegExp("^[0-9]*[.]?[0-9]+$","g"),It=new Map;It.set(N.textToKey(bS),s=>.4*s),It.set(N.textToKey(ES),s=>.5*s),It.set(N.textToKey(vS),s=>.6*s),It.set(N.textToKey(xS),s=>s),It.set(N.textToKey(IS),s=>1.1*s),It.set(N.textToKey(RS),s=>1.25*s),It.set(N.textToKey(AS),s=>1.5*s),It.set(N.textToKey(MS),s=>2*s),It.set(N.textToKey(TS),s=>.9*s),It.set(N.textToKey(FS),s=>1.1*s),It.set(N.textToKey(NS),s=>s);const Pr=(s,e=11,t="pt")=>{if(!s)return null;let n=e;s=s.trim().toLowerCase();const r=t==="pt"?exports.IFont.getDeviceScale():1,o=t==="pt"?1:exports.IFont.getDeviceScale();if(kS.test(s)){const i=parseFloat(s);isNaN(i)||(s=i+t)}if(s.endsWith("pt"))n=parseFloat(s.substring(0,s.length-2).trim())*o;else if(s.endsWith("px"))n=parseFloat(s.substring(0,s.length-2).trim())/r;else if(s.endsWith("em"))n=parseFloat(s.substring(0,s.length-2).trim())*e;else if(s.endsWith("rem"))n=parseFloat(s.substring(0,s.length-3).trim())*e;else if(s.endsWith("%"))n=parseFloat(s.substring(0,s.length-1).trim())/100*e;else if(typeof s=="string"){const i=N.textToKey(s),a=It.get(i);if(a)return a(e)}return isNaN(n)?null:n},He=new Map;He.set(exports.IFill.BuiltInSheetPattern.None,{description:"None",cssKey:"none"}),He.set(exports.IFill.BuiltInSheetPattern.Solid,{description:"Solid",cssKey:"solid"}),He.set(exports.IFill.BuiltInSheetPattern.DarkGray,{description:"75% gray",cssKey:"gray-75"}),He.set(exports.IFill.BuiltInSheetPattern.MediumGray,{description:"50% gray",cssKey:"gray-50"}),He.set(exports.IFill.BuiltInSheetPattern.LightGray,{description:"25% gray",cssKey:"gray-25"}),He.set(exports.IFill.BuiltInSheetPattern.Gray125,{description:"12.5% Gray",cssKey:"gray-125"}),He.set(exports.IFill.BuiltInSheetPattern.Gray0625,{description:"6.25% Gray",cssKey:"gray-0625"}),He.set(exports.IFill.BuiltInSheetPattern.DarkHorizontal,{description:"Horizontal Strip",cssKey:"horz-stripe"}),He.set(exports.IFill.BuiltInSheetPattern.DarkVertical,{description:"Vertical Strip",cssKey:"vert-stripe"}),He.set(exports.IFill.BuiltInSheetPattern.DarkDown,{description:"Reverse Diagonal Stripe",cssKey:"reverse-diag-stripe"}),He.set(exports.IFill.BuiltInSheetPattern.DarkUp,{description:"Diagonal Strip",cssKey:"diag-stripe"}),He.set(exports.IFill.BuiltInSheetPattern.DarkGrid,{description:"Diagonal Crosshatch",cssKey:"diag-cross"}),He.set(exports.IFill.BuiltInSheetPattern.DarkTrellis,{description:"Thick Diagonal Crosshatch",cssKey:"thick-diag-cross"}),He.set(exports.IFill.BuiltInSheetPattern.LightHorizontal,{description:"Thin Horizontal Stripe",cssKey:"thin-horz-stripe"}),He.set(exports.IFill.BuiltInSheetPattern.LightVertical,{description:"Thin Vertical Stripe",cssKey:"thin-vert-stripe"}),He.set(exports.IFill.BuiltInSheetPattern.LightDown,{description:"Thin Reverse Diagonal Stripe",cssKey:"thin-reverse-diag-stripe"}),He.set(exports.IFill.BuiltInSheetPattern.LightUp,{description:"Thin Diagonal Stripe",cssKey:"thin-diag-stripe"}),He.set(exports.IFill.BuiltInSheetPattern.LightGrid,{description:"Thin Horizontal Cross",cssKey:"thin-horz-cross"}),He.set(exports.IFill.BuiltInSheetPattern.LightTrellis,{description:"Thin Diagonal Cross",cssKey:"thin-diag-cross"});let gi="";const Km=new Map;He.forEach((s,e)=>{gi.length>0&&(gi+="|"),gi+="\\b"+s.cssKey+"\\b",Km.set(s.cssKey,e)});const OS=new RegExp(`(\\s*(?:${gi}))`,"g"),BS=s=>{if(!s)return null;let e=s.toLowerCase();e=e.replace(/;/,"");let t=e.match(OS);if(!t)return null;let n=null;t&&t.length>0&&(n=(o=>{if(!o)return null;let i=e.indexOf(o);return e=e.substring(0,i)+e.substring(i+o.length,e.length),o.trim()})(t[0])),e=e.trim();const r=e?e.trim():null;return!n&&!r?null:{patternType:Km.get(n??"solid"),foreground:r??null}},Xm=(s,e=!1,t=null)=>{if(!s||!s.getStops()||s.getStops().length<1)return null;if(s.getStops().length===1)return Qt(s.getStops()[0].getColor(),e);let n="";for(let o=0;o<s.getStops().length;o++){const i=s.getStops()[o];n+=Qt(i.getColor(),e)+" "+100*(i.getOffset()??o*(s.getStops().length-1))+"%",o<s.getStops().length-1&&(n+=", ")}let r=s.getAngle()??0;if(s.getGradientType()===exports.IFill.GradientType.Path){const o=Qt(s.getStops()[0]?.getColor(),e),i=Qt((s.getStops()[1]??s.getStops()[0])?.getColor(),e),a=s.getFillTo()??{left:0,top:0,right:0,bottom:0},l=-1;let c=`${100-l}% ${100-l}%`;if(r=315,a.left===1&&a.right===1&&a.right===1&&a.bottom===1)r=135,c=`${l}% ${l}%`;else if(a.top!==0&&a.bottom!==0&&a.left===0&&a.right===0)r=225,c=`${100-l}% ${l}%`;else if(a.left===1&&a.right!==0&&a.top===0&&a.bottom===0)r=45,c=`${l}% ${100-l}%`;else if(a.left!==0&&a.right!==0&&a.top!==0&&a.bottom!==0)return`radial-gradient(${n})`;const h=70;return`conic-gradient(from ${r}deg at ${c}, ${o} 0deg, ${i} ${h/2}deg,${i} ${360-h/2}deg, ${o} 360deg)`}return`linear-gradient(${r}deg, ${n})`},lt=new Map;lt.set(exports.IBorder.StrokeStyle.None,{size:null,cssKey:"none"}),lt.set(exports.IBorder.StrokeStyle.DashDot,{size:.5,cssKey:"dot-dash"}),lt.set(exports.IBorder.StrokeStyle.DashDotDot,{size:.5,cssKey:"dot-dot-dash"}),lt.set(exports.IBorder.StrokeStyle.Dashed,{size:.5,cssKey:"dashed"}),lt.set(exports.IBorder.StrokeStyle.MediumDashed,{size:1,cssKey:"dashed"}),lt.set(exports.IBorder.StrokeStyle.Dotted,{size:.5,cssKey:"dotted"}),lt.set(exports.IBorder.StrokeStyle.MediumDashDot,{size:1,cssKey:"dot-dash"}),lt.set(exports.IBorder.StrokeStyle.MediumDashDotDot,{size:1,cssKey:"dot-dot-dash"}),lt.set(exports.IBorder.StrokeStyle.Hair,{size:.5,cssKey:"hairline"}),lt.set(exports.IBorder.StrokeStyle.Thin,{size:.5,cssKey:"solid"}),lt.set(exports.IBorder.StrokeStyle.Thick,{size:1.5,cssKey:"solid"}),lt.set(exports.IBorder.StrokeStyle.Medium,{size:1,cssKey:"solid"}),lt.set(exports.IBorder.StrokeStyle.Double,{size:2,cssKey:"double"}),lt.set(exports.IBorder.StrokeStyle.SlantDashDot,{size:1,cssKey:"dot-dash-slanted"});const qn=s=>{if(!s)return"none";const e=lt.get(s.getStyle());if(!e)return null;if(e.cssKey==="none")return e.cssKey;let t=((n,r=!1)=>n?.toRGBA(r).toString(!1)??null)(s?.getColor());return t=t?" "+t:"",`${e.size!==null?`${e.size}pt `:""}${e.cssKey}${t}`};let ki=[];const nd=new Set,Ul=new Map,zo=(s,e)=>{let t=s.size!==null?`${s.size.toString()} ${s.cssKey}`:s.cssKey;Ul.set(t,e),nd.has(s.cssKey)||(ki.push(s.cssKey),nd.add(s.cssKey))};lt.forEach(zo);const $a=Object.keys(exports.IBorder.StrokeStyle);for(let s=0;s<$a.length;s++)zo({size:null,cssKey:$a[s].toLowerCase()},exports.IBorder.StrokeStyle[$a[s]]);zo({size:null,cssKey:"double"},exports.IBorder.StrokeStyle.Double),zo({size:null,cssKey:"solid"},exports.IBorder.StrokeStyle.Medium),zo({size:null,cssKey:"hidden"},exports.IBorder.StrokeStyle.None),ki.sort((s,e)=>e.length-s.length);let mi="";for(let s=0;s<ki.length;s++)mi.length>0&&(mi+="|"),mi+="\\b"+ki[s]+"\\b";const DS=new RegExp(`(\\s*(?:${mi}))`,"g"),LS=new RegExp("(\\s*[0-9]*[.]?[0-9]+(?:pt|px){0,1})","g"),Ym=s=>{if(!s)return null;let e=s.toLowerCase(),t=e.match(DS);if(!t)return null;const n=c=>{if(!c)return null;let h=e.indexOf(c);return e=e.substring(0,h)+e.substring(h+c.length,e.length).trim(),c.trim()};let r=null;if(t&&t.length>0&&(r=n(t[0])),!r)return null;let o=null;if(t=e.match(LS),t&&t.length>0){let c=n(t[0]);o=parseFloat(c.substring(0,c.length-2))}e=e.trim();const i=e?e.trim():null;let a=o===null?r:`${o.toString()} ${r}`,l=Ul.get(a);return l||(l=Ul.get(r)),l?{color:i,style:l}:null},PS="start",zS="end",WS="left",jS="right",HS="center",VS="justify",GS="justify-all",$S="baseline",US="top",qS="middle",JS="bottom",KS="sub",XS="text-top",YS="justify",QS="distributed",kn=new Map;kn.set(N.textToKey(PS),exports.ITextFrame.HorizontalAlignment.Left),kn.set(N.textToKey(WS),exports.ITextFrame.HorizontalAlignment.Left),kn.set(N.textToKey(zS),exports.ITextFrame.HorizontalAlignment.Right),kn.set(N.textToKey(jS),exports.ITextFrame.HorizontalAlignment.Right),kn.set(N.textToKey(HS),exports.ITextFrame.HorizontalAlignment.Center),kn.set(N.textToKey(VS),exports.ITextFrame.HorizontalAlignment.Justify),kn.set(N.textToKey(GS),exports.ITextFrame.HorizontalAlignment.Justify);const cn=new Map;cn.set(N.textToKey($S),exports.ITextFrame.VerticalAlignment.Bottom),cn.set(N.textToKey(US),exports.ITextFrame.VerticalAlignment.Top),cn.set(N.textToKey(qS),exports.ITextFrame.VerticalAlignment.Center),cn.set(N.textToKey(JS),exports.ITextFrame.VerticalAlignment.Bottom),cn.set(N.textToKey(KS),exports.ITextFrame.VerticalAlignment.Bottom),cn.set(N.textToKey(XS),exports.ITextFrame.VerticalAlignment.Top),cn.set(N.textToKey(YS),exports.ITextFrame.VerticalAlignment.Justify),cn.set(N.textToKey(QS),exports.ITextFrame.VerticalAlignment.Distributed);const Qm=(s,e)=>{if(s instanceof Ge)return{color:s};if(typeof s=="string")try{return{color:s==="none"||s==="transparent"?null:e(s)}}catch(t){throw t}return s},Uo={shorthand:(s,e)=>{if(!s||s==="none"||s==="transparent")return null;try{return e.parseColor(s).toString()}catch(t){console.warn("error",t)}return s},merge:(s,e,t)=>s},Mn={shorthand:(s,e)=>{if(typeof s=="string"&&(s=Ym(s)),!s)return null;const t={};return s.style&&(t.style=s.style),s.color&&(t.color=s.color),s.isIStroke?s.getProperties():t},properties:{color:Uo}},rd={shorthand:(s,e)=>s==="none"||s==="transparent"||typeof s=="object"&&Object.keys(s).length===0?{type:exports.IFill.Type.None}:(s.getType?.(),exports.IFill.Type.None,s)},od={shorthand:(s,e)=>(typeof(s=Qm(s,e.parseColor.bind(e)))=="object"&&s.color&&(s.type=exports.IFill.Type.Solid),s),merge:(s,e,t)=>s.color?s:(e?.toJSON&&(e=e.toJSON()),e?.type===exports.IFill.Type.Solid?{...e}:e?.type===exports.IFill.Type.Gradient?{type:exports.IFill.Type.Solid,color:e?.stops?.[0]?.color??t.parseColor(exports.IColor.Scheme.Bg1)}:e?.type===exports.IFill.Type.Pattern?{type:exports.IFill.Type.Solid,color:e?.foreground??t.parseColor(exports.IColor.Scheme.Bg1)}:s?{...s}:null),properties:{color:Uo}},sd={shorthand:(s,e)=>(typeof s=="object"&&s.stops&&(s.type=exports.IFill.Type.Gradient),s),merge:(s,e,t)=>s.stops?s:(e?.toJSON&&(e=e.toJSON()),e?.type===exports.IFill.Type.Gradient?{...e}:e?.type===exports.IFill.Type.Solid?{type:exports.IFill.Type.Gradient,stops:[{offset:0,color:e?.color??exports.IColor.Scheme.Accent1},{offset:1,color:exports.IColor.Scheme.Bg1}]}:e?.type===exports.IFill.Type.Pattern?{type:exports.IFill.Type.Gradient,stops:[{offset:0,color:e?.foreground??exports.IColor.Scheme.Bg1},{offset:1,color:e?.background??exports.IColor.Scheme.Accent1}]}:s?{...s}:null),properties:{stops:{shorthand:(s,e)=>s,arrayType:{shorthand:(s,e)=>s=Qm(s,e.parseColor.bind(e)),properties:{color:Uo}}}}},id={shorthand:(s,e)=>{if(typeof s=="object"){const t=s;(t.foreground||t.background||t.patternType)&&(t.type=exports.IFill.Type.Pattern,t.patternType=t.patternType??exports.IFill.BuiltInSheetPattern.Solid)}return s},merge:(s,e,t)=>{if(s.background&&s.foreground)return s;e?.toJSON&&(e=e.toJSON());const n=exports.IFill.BuiltInSheetPattern.MediumGray;return e?.type===exports.IFill.Type.Pattern?{...e,...s}:e?.type===exports.IFill.Type.Solid?{patternType:n,...s,foreground:e?.color??exports.IColor.Named.WindowText,background:exports.IColor.Scheme.Bg1}:e?.type===exports.IFill.Type.Gradient?{patternType:n,...s,foreground:e?.stops?.[0]?.color??exports.IColor.Named.WindowText,background:e?.stops?.[1]?.color??exports.IColor.Scheme.Bg1}:s?{type:exports.IFill.Type.Pattern,patternType:exports.IFill.BuiltInSheetPattern.Solid,foreground:exports.IColor.Named.WindowText,background:exports.IColor.Scheme.Bg1,...s}:null},properties:{foreground:Uo,background:Uo}},We={properties:{font:{shorthand:(s,e)=>{if(typeof s=="string"){const t=di(s);if(t){const n={};if(t.family&&(n.family=t.family),t.fallbacks&&(n.fallbacks=t.fallbacks),t.size&&(n.size=Pr(t.size)),Object.keys(t).length>0)return n}}return s},properties:{family:{shorthand:(s,e)=>di(s)?.family??null},fallbacks:{shorthand:(s,e)=>{if(typeof s!="string")return s;let t=di(s);if(!t)return null;let n=[t.family];return t.fallbacks&&(n=n.concat(t.fallbacks)),n}},size:{shorthand:(s,e)=>{let t=s;return typeof s=="string"&&(t=Pr(s,e.getNormal().getFont().getSize())),isNaN(t)||typeof t!="number"?null:(t=Math.max(1,Math.min(N.roundAccurately(t,1),409)),t)}},weight:{shorthand:(s,e)=>{if(typeof s!="string")return s;const t=(n=>{let r=400;if(r=typeof n=="number"?n:parseFloat(n),!isNaN(r))return r;if(typeof n=="string"){const o=N.textToKey(n),i=Pe.get(o);if(i)return i}return r})(s);return isNaN(t)||typeof t!="number"?null:t}},underline:{shorthand:(s,e)=>s?s===!0?exports.IFont.UnderlineStyle.Single:Jm(s):exports.IFont.UnderlineStyle.None}}},fill:{shorthand:(s,e)=>{const t=[rd,od,sd,id];for(let n=0;n<t.length;n++){let r=t[n]?.shorthand?.(s,e);if(r?.type)return r}return s},getSubType:s=>s.type===exports.IFill.Type.None?rd:s.type===exports.IFill.Type.Solid?od:s.type===exports.IFill.Type.Gradient?sd:s.type===exports.IFill.Type.Pattern?id:null},alignment:{properties:{indent:{shorthand:(s,e)=>{let t=s;return typeof s=="string"&&(t=parseFloat(s)),isNaN(t)||typeof t!="number"?null:t}},rotation:{shorthand:(s,e)=>{let t=s;return typeof s=="string"&&(t=parseFloat(s)),isNaN(t)||typeof t!="number"?null:(t%=360,t<0&&(t+=360),t)}}}},border:{shorthand:(s,e)=>{if(typeof s=="string"){const t=Ym(s);return{left:t,right:t,top:t,bottom:t,horizontal:null,vertical:null,diagonalUp:null,diagonalDown:null}}return s.isIBorder?s.getProperties():s},properties:{top:Mn,left:Mn,right:Mn,bottom:Mn,horizontal:Mn,vertical:Mn,diagonalUp:Mn,diagonalDown:Mn}},numberFormat:{shorthand:(s,e)=>{if(typeof s=="string"){let t=exports.NumberFormat.Styles.lookupDefault(s);return t!==void 0?t:s}return typeof s=="number"?gc(s):null}}}},ZS={properties:{style:We}},ew=Object.freeze({displayText:"",conditionalColor:null,repeatChars:N.EmptyArray,spacingChars:N.EmptyArray,repeatPlaceholder:null,formattedRuns:Object.freeze({runs:N.EmptyArray,length:0,width:0,lastRepeatIndex:-1}),canWrap:!1,asDate:null,isDateFormat:!1,isTimeFormat:!1,isDate1904:!1}),Zm=(s,e,t,n,r,o=!1)=>{if(s==null)return ew;let i="",a=null,l=null,c=null;if(t===U.Error)i=s.getLabel();else if(t===U.RichData)i="(Rich Object)";else if(t===U.Boolean)i=s?"TRUE":"FALSE";else if(n)try{i=ic(n,s,{date1904:o,spacingCharacter:"",digitCharacter:"",onRepeatChar:(E,I)=>{l||(l=[]),l.push({offset:E,char:I})},onSpacingChar:(E,I)=>{c||(c=[]),c.push({offset:E,char:I})},onDigitChar:E=>{c||(c=[]),c.push({offset:E,char:"0"})}})}catch{}const h=Zo(n),u=Hi(n),d=h||u?qr(s,o):null;(h||u)&&parseFloat(s)<0&&(a="#",i=a.repeat(5));let g=null;const m=e.getAlignment(),f=m.getHorizontal(),_=m.getVertical(),p=m.getOverflow(),S=!(t!==U.String||f===exports.ITextFrame.HorizontalAlignment.Fill||l!==null&&l.length!==0||p!==exports.ITextFrame.Overflow.Wrap&&f!==exports.ITextFrame.HorizontalAlignment.Justify&&f!==exports.ITextFrame.HorizontalAlignment.Distributed&&_!==exports.ITextFrame.VerticalAlignment.Justify&&_!==exports.ITextFrame.VerticalAlignment.Distributed);let C=i;S||t!==U.String||(C=C.replaceAll(/\n/g,""));const y=c?.length>0||l?.length>0;if(p!==exports.ITextFrame.Overflow.Wrap||y){const E=e.getFont();let I=E.getSize();E.isSuperSub()&&(I*=E.getSuperSubScale());let x=[];for(let L=0;L<c?.length;L++){const D=c[L],P=e.measureText(D.char,I).width;x.push({...D,type:"spacing",width:P})}if(l?.length>0){const L=l[l.length-1],D=e.measureText(L.char,I).width;x.push({...L,type:"repeat",width:D})}x=x.sort((L,D)=>L.offset-D.offset);let v=[],R=0,A=0,M=-1,T=-1;const F=L=>{const D={type:"text",width:e.measureText(L,I).width,text:L};v.push(D),A+=D.width,R+=L.length};for(let L=0;L<x.length;L++){const D=x[L];if(T!==D.offset){const B=C.substring(R,D.offset);B&&F(B)}const P={type:D.type,width:D.width,text:D.char};D.type!=="repeat"?A+=P.width:M=v.length,v.push(P),T=D.offset}if(R<C.length){let L=C.substring(R,C.length);L&&F(L)}g={runs:Object.freeze(v),length:R,width:A,lastRepeatIndex:M}}const b=g0(n,s),w={displayText:i??"",conditionalColor:b?r(b):null,repeatChars:l??N.EmptyArray,spacingChars:c??N.EmptyArray,repeatPlaceholder:a,formattedRuns:g,canWrap:S,asDate:d,isDateFormat:h,isTimeFormat:u,isDate1904:o};return Object.freeze(w)},je=Object.freeze({fallbacks:N.EmptyArray,weight:400,style:exports.IFont.Style.Normal,fill:exports.IColor.Scheme.Tx1,letterSpacing:null,underline:exports.IFont.UnderlineStyle.None,strike:!1,scheme:exports.IFont.Scheme.Minor,verticalAlign:exports.IFont.VerticalAlignment.Baseline,shadow:!1,outline:!1,extend:!1}),Tn=Object.freeze({style:exports.IBorder.StrokeStyle.None,color:exports.IColor.Scheme.Tx1}),tw=Object.freeze({[exports.IBorder.Edge.Top]:Tn,[exports.IBorder.Edge.Left]:Tn,[exports.IBorder.Edge.Bottom]:Tn,[exports.IBorder.Edge.Right]:Tn,[exports.IBorder.Edge.Horizontal]:Tn,[exports.IBorder.Edge.Vertical]:Tn,[exports.IBorder.Edge.DiagonalUp]:Tn,[exports.IBorder.Edge.DiagonalDown]:Tn}),nw=Object.freeze({horizontal:exports.ITextFrame.HorizontalAlignment.General,vertical:exports.ITextFrame.VerticalAlignment.Bottom,indent:0,relativeIndent:0,overflow:exports.ITextFrame.Overflow.Visible,rotation:0,stacked:!1,quotePrefix:!1,justifyLastLine:!1,readingOrder:exports.ITextFrame.ReadingDirection.Auto,readingDirection:exports.ITextFrame.ReadingDirection.Auto}),rw=Object.freeze({locked:!1,formulaHidden:!1}),ef=Object.freeze({fill:{type:exports.IFill.Type.None},numberFormat:"General",alignment:nw,font:je,border:tw,protection:rw,quotePrefix:!1,namedStyle:null}),ow=(()=>{const s=[{named:exports.IStyle.BuiltInName.Normal},{named:exports.IStyle.BuiltInName.RowLevel},{named:exports.IStyle.BuiltInName.ColLevel},{named:exports.IStyle.BuiltInName.Comma,numberFormat:'_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)'},{named:exports.IStyle.BuiltInName.Currency,numberFormat:'_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)'},{named:exports.IStyle.BuiltInName.Percent,numberFormat:"0%"},{named:exports.IStyle.BuiltInName.Comma0,numberFormat:'_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)'},{named:exports.IStyle.BuiltInName.Currency0,numberFormat:'_($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)'},{named:exports.IStyle.BuiltInName.Hyperlink,font:{...je,fill:exports.IColor.Scheme.Hlink,underline:exports.IFont.UnderlineStyle.Single}},{named:exports.IStyle.BuiltInName.FollowedHyperlink,font:{...je,fill:exports.IColor.Scheme.FolHlink,underline:exports.IFont.UnderlineStyle.Single}},{named:exports.IStyle.BuiltInName.Note,fill:"FFFFFFCC",font:{...je,style:exports.IFont.Style.Normal,fill:exports.IColor.Scheme.Tx1},border:{left:{style:exports.IBorder.StrokeStyle.Thin,color:"FFB2B2B2"},top:{style:exports.IBorder.StrokeStyle.Thin,color:"FFB2B2B2"},right:{style:exports.IBorder.StrokeStyle.Thin,color:"FFB2B2B2"},bottom:{style:exports.IBorder.StrokeStyle.Thin,color:"FFB2B2B2"}}},{named:exports.IStyle.BuiltInName.WarningText,font:{...je,fill:"FFFF0000"}},{named:exports.IStyle.BuiltInName.Unknown12},{named:exports.IStyle.BuiltInName.Unknown13},{named:exports.IStyle.BuiltInName.Unknown14},{named:exports.IStyle.BuiltInName.Title,font:{...je,size:18,fill:exports.IColor.Scheme.Tx2}},{named:exports.IStyle.BuiltInName.Heading1,font:{...je,size:15,weight:"bold",fill:exports.IColor.Scheme.Tx2},border:{bottom:{style:exports.IBorder.StrokeStyle.Thick,color:exports.IColor.Scheme.Accent1}}},{named:exports.IStyle.BuiltInName.Heading2,font:{...je,size:13,weight:"bold",fill:exports.IColor.Scheme.Tx2},border:{bottom:{style:exports.IBorder.StrokeStyle.Thick,color:"accent1 lumMod 40, lumOff 60"}}},{named:exports.IStyle.BuiltInName.Heading3,font:{...je,weight:"bold",fill:exports.IColor.Scheme.Tx2},border:{bottom:{style:exports.IBorder.StrokeStyle.Medium,color:"accent1 lumMod 40, lumOff 60"}}},{named:exports.IStyle.BuiltInName.Heading4,font:{weight:"bold",fill:exports.IColor.Scheme.Tx2,...je}},{named:exports.IStyle.BuiltInName.Input,fill:"FFFFCC99",font:{...je,fill:"FF3F3F76"},border:{left:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"},top:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"},right:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"},bottom:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"}}},{named:exports.IStyle.BuiltInName.Output,fill:"FFF2F2F2",font:{...je,fill:"FF3F3F3F"},border:{left:{style:exports.IBorder.StrokeStyle.Thin,color:"FF3F3F3F"},top:{style:exports.IBorder.StrokeStyle.Thin,color:"FF3F3F3F"},right:{style:exports.IBorder.StrokeStyle.Thin,color:"FF3F3F3F"},bottom:{style:exports.IBorder.StrokeStyle.Thin,color:"FF3F3F3F"}}},{named:exports.IStyle.BuiltInName.Calculation,fill:"FFF2F2F2",font:{...je,fill:"FFFA7D00"},border:{left:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"},top:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"},right:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"},bottom:{style:exports.IBorder.StrokeStyle.Thin,color:"FF7F7F7F"}}},{named:exports.IStyle.BuiltInName.CheckCell,fill:"FFA5A5A5",font:{...je,fill:exports.IColor.Scheme.Bg1},border:{left:{style:exports.IBorder.StrokeStyle.Double,color:"FF3F3F3F"},top:{style:exports.IBorder.StrokeStyle.Double,color:"FF3F3F3F"},right:{style:exports.IBorder.StrokeStyle.Double,color:"FF3F3F3F"},bottom:{style:exports.IBorder.StrokeStyle.Double,color:"FF3F3F3F"}}},{named:exports.IStyle.BuiltInName.LinkedCell,font:{...je,fill:"FFFA7D00"},border:{bottom:{style:exports.IBorder.StrokeStyle.Double,color:"FFFF8001"}}},{named:exports.IStyle.BuiltInName.Total,font:{...je,weight:"bold",fill:exports.IColor.Scheme.Tx1},border:{top:{style:exports.IBorder.StrokeStyle.Thin,color:exports.IColor.Scheme.Accent1},bottom:{style:exports.IBorder.StrokeStyle.Double,color:exports.IColor.Scheme.Accent1}}},{named:exports.IStyle.BuiltInName.Good,fill:"FFC6EFCE",font:{...je,fill:"FF006100"}},{named:exports.IStyle.BuiltInName.Bad,fill:"FFFFC7CE",font:{...je,fill:"FF9C0006"}},{named:exports.IStyle.BuiltInName.Neutral,fill:"FFFFEB9C",font:{...je,fill:"FF9C5700"}},{named:exports.IStyle.BuiltInName.Accent1},{named:exports.IStyle.BuiltInName.Accent1_20},{named:exports.IStyle.BuiltInName.Accent1_40},{named:exports.IStyle.BuiltInName.Accent1_60},{named:exports.IStyle.BuiltInName.Accent2},{named:exports.IStyle.BuiltInName.Accent2_20},{named:exports.IStyle.BuiltInName.Accent2_40},{named:exports.IStyle.BuiltInName.Accent2_60},{named:exports.IStyle.BuiltInName.Accent3},{named:exports.IStyle.BuiltInName.Accent3_20},{named:exports.IStyle.BuiltInName.Accent3_40},{named:exports.IStyle.BuiltInName.Accent3_60},{named:exports.IStyle.BuiltInName.Accent4},{named:exports.IStyle.BuiltInName.Accent4_20},{named:exports.IStyle.BuiltInName.Accent4_40},{named:exports.IStyle.BuiltInName.Accent4_60},{named:exports.IStyle.BuiltInName.Accent5},{named:exports.IStyle.BuiltInName.Accent5_20},{named:exports.IStyle.BuiltInName.Accent5_40},{named:exports.IStyle.BuiltInName.Accent5_60},{named:exports.IStyle.BuiltInName.Accent6},{named:exports.IStyle.BuiltInName.Accent6_20},{named:exports.IStyle.BuiltInName.Accent6_40},{named:exports.IStyle.BuiltInName.Accent6_60},{named:exports.IStyle.BuiltInName.ExplanatoryText,font:{...je,style:exports.IFont.Style.Italic,fill:"FF7F7F7F"}}];for(let e=29;e<=52;e++){const t=(e-29)%4,n=Math.floor((e-29)/4);let r="";t===1?r=" lumMod 20, lumOff 80":t===2?r=" lumMod 40, lumOff 60":t===3&&(r=" lumMod 60, lumOff 40"),s[e].fill=`accent${n+1}${r}`,s[e].font={fill:t===0?exports.IColor.Scheme.Bg1:exports.IColor.Scheme.Tx1,...je}}return N.deepFreeze(s)})(),sw=new class{_svgImage(s,e,t,n=8){return{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${n}' height='${n}' viewBox='0 0 ${n} ${n}' shape-rendering='crispEdges' %3E%3Cpath d='${t}' stroke='${s}' %3E%3C/path%3E%3C/svg%3E")`,backgroundRepeat:"repeat",backgroundSize:`${n}px ${n}px`,backgroundPositionX:"0px",backgroundPositionY:"0px",backgroundPosition:""+-n,backgroundColor:e}}toCSS(s,e,t){return s&&s!==exports.IFill.BuiltInSheetPattern.None?s===exports.IFill.BuiltInSheetPattern.Solid?{background:t}:s===exports.IFill.BuiltInSheetPattern.Gray0625?this._svgImage(e,t,"M 0.5 0.5 L 0.5 1.5 M 0.5 4.5 L 0.5 5.5 M 4.5 2.5 L 4.5 3.5 M 4.5 6.5 L 4.5 7.5",8):s===exports.IFill.BuiltInSheetPattern.LightGray?this._svgImage(e,t,"M 0.5 0.5 L 0.5 1.5 M 0.5 2.5 L 0.5 3.5 M 2.5 -0.5 L 2.5 0.5 M 2.5 1.5 L 2.5 2.5 M 2.5 3.5 L 2.5 4.5",4):s===exports.IFill.BuiltInSheetPattern.MediumGray?this._svgImage(e,t,"M 0.5 0.5 L 0.5 1.5 M 1.5 1.5 L 1.5 2.5 M 1.5 -0.5 L 1.5 0.5 M -0.5 -0.5 L -0.5 0.5",2):s===exports.IFill.BuiltInSheetPattern.DarkGray?this._svgImage(e,t,"M 0 0 L 0 4 M 1 1 L 1 2 M 1 3 L 1 4 M 2 0 L 2 4 M 3 0.5 L 3 1.5 M 3 2.5 L 3 3.5 M 4 0 L 4 4",4):s===exports.IFill.BuiltInSheetPattern.LightHorizontal?this._svgImage(e,t,"M 0 2 L 4 2",4):s===exports.IFill.BuiltInSheetPattern.DarkHorizontal?this._svgImage(e,t,"M 0 2 L 4 2 M 0 3 L 4 3",4):s===exports.IFill.BuiltInSheetPattern.LightVertical?this._svgImage(e,t,"M 2 0 L 2 4",4):s===exports.IFill.BuiltInSheetPattern.DarkVertical?this._svgImage(e,t,"M 2 0 L 2 4 M 3 0 L 3 4",4):s===exports.IFill.BuiltInSheetPattern.LightUp?this._svgImage(e,t,"M 0.5 0.5 L 0.5 1.5 M 1.5 3.5 L 1.5 4.5 M 1.5 -0.5 L 1.5 0.5 M 2.5 2.5 L 2.5 3.5 M 3.5 1.5 L 3.5 2.5",4):s===exports.IFill.BuiltInSheetPattern.DarkUp?this._svgImage(e,t,"M 0.5 -0.5 L 0.5 1.5 M 0.5 3.5 L 0.5 4.5 M 1.5 2.5 L 1.5 4.5 M 2.5 1.5 L 2.5 3.5 M 3.5 0.5 L 3.5 2.5 M 1.5 -0.5 L 1.5 0.5",4):s===exports.IFill.BuiltInSheetPattern.LightDown?this._svgImage(e,t,"M 0.5 0 L 0.5 1 M 1.5 1 L 1.5 2 M 2.5 2 L 2.5 3 M 3.5 3 L 3.5 4",4):s===exports.IFill.BuiltInSheetPattern.DarkDown?this._svgImage(e,t,"M 0.5 -0.5 L 0.5 2 M 1.5 1 L 1.5 3 M 2.5 2 L 2.5 4 M 3.5 3 L 3.5 5 M 3.5 -0.5 L 3.5 1.0",4):s===exports.IFill.BuiltInSheetPattern.LightGrid?this._svgImage(e,t,"M 1.5 -0.5 L 1.5 4.5 M -0.5 1.5 L 4.5 1.5",4):s===exports.IFill.BuiltInSheetPattern.DarkGrid?this._svgImage(e,t,"M 0.5 -0.5 L 0.5 1.5 M 1.5 -0.5 L 1.5 1.5 M 2.5 1.5 L 2.5 3.5 M 3.5 1.5 L 3.5 3.5 M 0.5 3.5 L 0.5 4.5 M 1.5 3.5 L 1.5 4.5",4):s===exports.IFill.BuiltInSheetPattern.LightTrellis?this._svgImage(e,t,"M 0.5 0.5 L 0.5 1.5 M 1.5 3.5 L 1.5 4.5 M 1.5 -0.5 L 1.5 0.5 M 2.5 2.5 L 2.5 3.5 M 3.5 1.5 L 3.5 2.5 M 1.5 1.5 L 1.5 2.5 M 3.5 3.5 L 3.5 4.5 M 3.5 -0.5 L 3.5 0.5",4):s===exports.IFill.BuiltInSheetPattern.DarkTrellis?this._svgImage(e,t,"M 0 0 L 4 0 M 0 1 L 2 1 M 0 2 L 4 2 M 2 3 L 4 3 M 0 4 L 4 4",4):(exports.IFill.BuiltInSheetPattern.Custom,this._svgImage(e,t,"M 0.5 0.5 L 0.5 1.5 M 0.5 4.5 L 0.5 5.5 M 2.5 2.5 L 2.5 3.5 M 2.5 6.5 L 2.5 7.5 M 4.5 0.5 L 4.5 1.5 M 4.5 4.5 L 4.5 5.5 M 6.5 2.5 L 6.5 3.5 M 6.5 6.5 L 6.5 7.5",8)):{background:"none"}}},Ji=(s,e,t)=>{if(e===void 0)return;if(e===null)return null;if(e.isIStyle)return e._p.getProperties();let n=null;return typeof e=="function"?n=e(typeof t=="function"?t():t):n=e,n};class iw{constructor(e,t){this._c=e,this._p=Object.freeze(Array.isArray(t)?t:[t??null])}value(e){const t=this._p;for(let n=t.length-1;n>=0;n--){const r=t[n];if(!r)continue;const o=r[e];if(o!==void 0)return o}}values(e){const t=this._p,n=t.length;let r;for(let o=0;o<n;o++){const i=t[o];if(!i)continue;const a=i[e];a!==void 0&&(r===void 0&&(r=[]),r.push(a))}return r}getProperties(){const e=this._p;return e?e[e.length-1]:null}toJSON(){return null}}class bn{constructor(e,t){this._c=e,this._p=Object.freeze(t)}_value(e){const t=this._p;for(let n=t.length-1;n>=0;n--){const r=t[n];if(!r)continue;const o=r[e];if(o!==void 0)return o}}_values(e){const t=this._p,n=t.length;let r;for(let o=0;o<n;o++){const i=t[o];if(!i)continue;const a=i[e];a!==void 0&&(r===void 0&&(r=[]),r.push(a))}return r}getProperties(){const e=this._p;return e?e[e.length-1]:null}toJSON(){return null}}class br extends bn{constructor(e,t,n){super(t,n),this._edge=e}getStyle(){return this._value("style")}getColor(){const e=this._value("color");return e?this._c.parseColor(e):null}isNone(){return this.getStyle()===exports.IBorder.StrokeStyle.None}toCSS(){const e=qn(this);switch(this._edge){case exports.IBorder.Edge.Left:return{borderLeft:e};case exports.IBorder.Edge.Right:return{borderRight:e};case exports.IBorder.Edge.Top:return{borderTop:e};case exports.IBorder.Edge.Bottom:return{borderBottom:e};case exports.IBorder.Edge.DiagonalUp:case exports.IBorder.Edge.DiagonalDown:return{borderDiagonalUp:e}}}get isIStroke(){return!0}}class aw extends bn{getLeft(){return new br(exports.IBorder.Edge.Left,this._c,this._values(exports.IBorder.Edge.Left))}getRight(){return new br(exports.IBorder.Edge.Right,this._c,this._values(exports.IBorder.Edge.Right))}getTop(){return new br(exports.IBorder.Edge.Top,this._c,this._values(exports.IBorder.Edge.Top))}getBottom(){return new br(exports.IBorder.Edge.Bottom,this._c,this._values(exports.IBorder.Edge.Bottom))}getDiagonalUp(){return new br(exports.IBorder.Edge.DiagonalUp,this._c,this._values(exports.IBorder.Edge.DiagonalUp))}getDiagonalDown(){return new br(exports.IBorder.Edge.DiagonalDown,this._c,this._values(exports.IBorder.Edge.DiagonalDown))}isEmpty(){return!1}get isIBorder(){return!0}}class lw extends bn{get isITextBoxAlignment(){return!0}getHorizontal(){return this._value("horizontal")}getVertical(){return this._value("vertical")}getIndent(){return this._value("indent")}getRelativeIndent(){return this._value("relativeIndent")}getOverflow(){return this._value("overflow")}getRotation(){return this._value("rotation")}getStacked(){return this._value("stacked")}getJustifyLastLine(){return this._value("justifyLastLine")}getReadingDirection(){return this._value("readingDirection")}}class cw extends bn{isEqualMeasure(e){return!!e&&this.getFamily()===e.getFamily()&&!!N.isEqualArrays(this.getFallbacks(),e.getFallbacks())&&this.getSize()===e.getSize()&&this.getWeight()===e.getWeight()&&this.getStyle()===e.getStyle()&&this.getStrike()===e.getStrike()&&this.getScheme()===e.getScheme()&&this.getShadow()===e.getShadow()&&this.getOutline()===e.getOutline()&&this.getLetterSpacing()===e.getLetterSpacing()&&this.getVerticalAlignment()===e.getVerticalAlignment()}isSuperSub(){const e=this.getVerticalAlignment();return e===exports.IFont.VerticalAlignment.Sub||e===exports.IFont.VerticalAlignment.Super}isSuperScript(){const e=this.getVerticalAlignment();return e===exports.IFont.VerticalAlignment.Sub||e===exports.IFont.VerticalAlignment.Super}getSuperSubScale(){return this.getFamily(),this.getSize(),this.getVerticalAlignment(),.6}getSuperSubShift(){return this.getFamily(),e=this.getSize(),(t=this.getVerticalAlignment())===exports.IFont.VerticalAlignment.Super?-e/3:t===exports.IFont.VerticalAlignment.Sub?e/5:0;var e,t}toCSS(e,t=1,n=!1){const r={fontFamily:Ni(this.getFamily(),this.getFallbacks()),letterSpacing:`${this.getLetterSpacing()}px`,fontWeight:this.getWeight(),fontStyle:this.getStyle(),textDecoration:qm(this.getUnderline(),this.getStrike()),color:this.getFill().toCSS(e),fontSize:`${N.roundAccurately(this.getSize()*exports.IFont.getDeviceScale()*t,2)}px`,textRendering:"geometricPrecision"};if(n){const o=this._c.getNormal().getFont().toCSS(e,t,!1),i=r.textDecoration,a=r.fontWeight;N.removeEqualValues(r,o),i&&(r.textDecoration=i),a&&(r.fontWeight=a)}return r}getFamily(){return this._value("family")??this._c.getTheme().getFontScheme().getMinorFont()}getFallbacks(){let e=this._value("fallbacks")??this._c.getTheme().getFontScheme().getMinorFallbacks()??N.EmptyArray;return this.getFamily()==="Aptos Narrow"&&(e=["Calibri",...e]),e}getSize(){return this._value("size")??this._c.getDefaultFontSize()??11}getWeight(){return this._value("weight")}getStyle(){return this._value("style")}getFill(){const e=this._value("fill");return this._c.parseColor(e??exports.IColor.Scheme.Bg1)}getLetterSpacing(){return this._value("letterSpacing")??this.getSize()/-25}getUnderline(){return this._value("underline")}getStrike(){return this._value("strike")}getScheme(){return this._value("scheme")}getVerticalAlignment(){return this._value("verticalAlign")}getShadow(){return this._value("shadow")}getOutline(){return this._value("outline")}getExtend(){return this._value("extend")}get isIStyledFont(){return!0}}const hw=Object.freeze({background:"none"});class ad extends bn{getType(){return exports.IFill.Type.None}toCSS(e){return hw}toJSON(){return{type:exports.IFill.Type.None}}}class uw extends bn{getType(){return exports.IFill.Type.Solid}getColor(){return this._c.parseColor(this._value("color")??exports.IColor.Scheme.Bg1)}toCSS(e){return{background:this.getColor().toCSS(e)}}toJSON(){return{type:exports.IFill.Type.Solid,color:this.getColor()?.toString()??null}}}class dw extends bn{getOffset(){return this._value("offset")??0}getColor(){return this._c.parseColor(this._value("color")??exports.IColor.Scheme.Bg1)}}class gw extends bn{getType(){return exports.IFill.Type.Gradient}getStops(){const e=this._value("stops")??[],t=[],n=this._c;for(let r=0;r<e.length;r++){const o=e[r];t.push(new dw(n,[o]))}return t}getGradientType(){return this._value("gradientType")??exports.IFill.GradientType.Linear}getAngle(){return this._value("angle")??0}getFillTo(){return this._value("fillTo")??null}toCSS(e,t){const n=Xm(this,e,t);return n?{background:n}:null}toJSON(){const e={type:exports.IFill.Type.Gradient};if(this.getStops().length>0){let t=[];for(let n=0;n<t.length;n++)t.push({offset:t[n].offset,color:t[n].color.toString()});e.stops=t}return this.getAngle()!==0&&(e.angle=this.getAngle()),this.getGradientType()!==exports.IFill.GradientType.Linear&&(e.gradientType=this.getGradientType()),this.getFillTo()&&(e.fillTo=this.getFillTo()),e}}class mw extends bn{getType(){return exports.IFill.Type.Pattern}getBackground(){const e=this._value("background")??exports.IColor.Named.Window;return this._c.parseColor(e)}getForeground(){return this._c.parseColor(this._value("foreground")??exports.IColor.Scheme.Tx1)}getPatternType(){return this._value("patternType")??exports.IFill.BuiltInSheetPattern.None}toCSS(e){const t=this.getBackground().toCSS(e),n=this.getForeground().toCSS(e);return this.getPatternType()===exports.IFill.BuiltInSheetPattern.None?{background:"none"}:this.getPatternType()===exports.IFill.BuiltInSheetPattern.Solid?{background:this.getForeground().toCSS(e)}:sw.toCSS(this.getPatternType(),n,t)}toJSON(){const e={type:exports.IFill.Type.Pattern};this.getPatternType()!==exports.IFill.BuiltInSheetPattern.None&&(e.patternType=this.getPatternType());const t=this.getForeground();t&&(e.foreground=t.toString());const n=this.getBackground();return n&&(e.background=n.toString()),e}}class tf{constructor(e){this._options=e,this._c=e.styles,this._p=new iw(e.styles,e.properties),this._hasVisibleStyling=!this.getFill()||this.getFill().getType()!==exports.IFill.Type.None||!this.getBorder().isEmpty()}hasVisibleStyling(){return this._hasVisibleStyling}isNormal(){return!1}getNamed(){const e=this._p.value("named")??exports.IStyle.BuiltInName.Normal;return this._c.getNamed(e)}createTemporaryStyle(e){const t=this._c,n=Ji(0,e,this),r=this._options,o=r.range,i=r.direct.cloneWithUpdate(n);return Vr(t,i,o)}measureText(e,t=this.getFont().getSize(),n,r){const o=this.getFont();n||(n=o.getFamily());let i=o.getFallbacks();n==="Aptos Narrow"&&(i=["Calibri",...i]);const a=Ni(n,i);return exports.IFont.getSharedMeasurer()(e,t*exports.IFont.getDeviceScale(),a,{isBold:o.getWeight()>400,isItalic:o.getStyle().includes("italic"),letterSpacing:o.getLetterSpacing(),...r})}createTemporaryTextFrame(e,t=!1){return Ui(e,this.getFont(),this.getAlignment(),t)}getBestFit(){if(this._bestFit!==void 0)return this._bestFit;const e=this.getInsets(),t=this.measureText("My");return this._bestFit={width:null,height:t.lineHeight+e.top+e.bottom},this._bestFit}getInsets(){if(this._insets!==void 0)return this._insets;const e=(this.getFont().getSize(),1),t=(n=this.getFont().getSize(),Math.max(2,Math.round(n<225?n/5:n/3.5)));var n;const r={top:e,left:t,bottom:e,right:t},o=this._p,i=o?.value("insets");return i&&(i.top!==void 0&&(r.top+=i.top),i.left!==void 0&&(r.left+=i.left),i.bottom!==void 0&&(r.bottom+=i.bottom),i.right!==void 0&&(r.right+=i.right)),this._insets=Object.freeze(r),this._insets}getBorder(){return new aw(this._c,this._p.values("border"))}getFont(){return new cw(this._c,this._p.values("font"))}getFill(){const e=this._p;let t=e.values("fill"),n=e.value("fill");return n.type===exports.IFill.Type.None?new ad(this._c,t):n.type===exports.IFill.Type.Solid||!n.type&&n.color?new uw(this._c,t):n.type===exports.IFill.Type.Gradient?new gw(this._c,t):n.type===exports.IFill.Type.Pattern?new mw(this._c,t):new ad(this._c,t)}getAlignment(){return new lw(this._c,this._p.values("alignment"))}getNumberFormat(){const e=this._p.value("numberFormat");return typeof e=="number"?gc(e):e}getQuotePrefix(){return this._p.value("quotePrefix")}get isIStyle(){return!0}}const Vr=(s,e,t)=>{const n=t?.rowStart??k.EmptyCell.rowIndex,r=t?.colStart??k.EmptyCell.colIndex,o=[ef],i=s.getNormalRanged(),a=i.getPropertiesAt(n,r,null);if(a&&o.push(a),!e)return new fw({styles:s,range:t,properties:o,layerTypes:null,direct:i});const l=e.getPropertiesAt(n,r,null);return l&&o.push(l),new tf({styles:s,range:t,properties:o,direct:e})};class fw extends tf{isNormal(){return!0}}const Vn=(s,e)=>{if(s&&!e||e&&!s)return!1;if(s===e)return!0;if(s.style!==e.style)return!1;if(s.color===e.color)return!0;let t=s.color;(s&&s.color).isIColor&&(t=s.color.toString());let n=e.color;return(e&&e.color).isIColor&&(n=e.color.toString()),t===n};class Je{constructor(e,t,n,r){this._c=e,this._r=t,this._p=n??null,this._t=r??null,this._e=this._p===null||Object.keys(this._p).length===1&&this._p.named===exports.IStyle.BuiltInName.Normal}isEmpty(){return this._e}getProperties(){return this._p}getCoords(){return this._r}cloneWithUpdate(e){if(e===void 0)return this;const t=this._c,n=this._r,r=this._p,o=exports.it.resolveTypedUpdates(e,We,t,r);return new Je(t,n,o)}copyTo(e,t){const n=this._c,r=this._r,o=e.rowStart-r.rowStart,i=e.colStart-r.colStart;let a=null;return k.isEqualRanges(r,this._t)||(a=k.translateRange(r,o,i)),new Je(n,e,this._p,a)}canTile(e,t){return!this._p.border}_createShifted(e){return new Je(this._c,e,this._p)}getShifted(e){return e.after?{...e.after,value:this._createShifted(k.sanitizeRange(e.after))}:null}getSplit(e,t){const n=this._c,r=this._p,o=this._r;let i=r;const a=e[0];let l=r;const c=e[1],h=r?r.border:null;if(h){const d=t===exports.w.Orientation.Column;if(d?h.left!==void 0||h.right!==void 0||h.vertical!==void 0:h.top!==void 0||h.bottom!==void 0||h.horizontal!==void 0){i={...i};const g=this._splitBorderRange(h,o,a,d);g?i.border=g:g===null&&delete i.border,l={...l};const m=this._splitBorderRange(h,o,c,d);m?l.border=m:m===null&&delete l.border}}const u=this._t;return[new Je(n,e[0],i,u),new Je(n,e[1],l,u)]}getMerged(e,t,n){const r=n===exports.w.Orientation.Column,o=this._p,i=e._p;if(o&&!i||i&&!o||!o&&!i)return;let a=Object.keys(o),l=Object.keys(i);if(a.length!==l.length)return;for(let d=0;d<a.length;d++){const g=a[d];if(g==="border")continue;const m=o[g],f=i[g];if(!N.deepEqual(m,f))return}const c=o.border,h=i.border;if(c&&!h||h&&!c)return;const u=this._c;if(c||h){const d=r?exports.IBorder.Edge.Top:exports.IBorder.Edge.Left,g=r?exports.IBorder.Edge.Bottom:exports.IBorder.Edge.Right;if(!Vn(c[d],h[d])||!Vn(c[g],h[g]))return;const m=this._r,f=e._r,_=1+(r?m.rowEnd-m.rowStart:m.colEnd-m.colStart),p=1+(r?m.colEnd-m.colStart:m.rowEnd-m.rowStart),S=1+(r?f.colEnd-f.colStart:f.rowEnd-f.rowStart),C=r?exports.IBorder.Edge.Horizontal:exports.IBorder.Edge.Vertical;if(_>1&&!Vn(c[C],h[C]))return;const y=r?exports.IBorder.Edge.Right:exports.IBorder.Edge.Bottom,b=r?exports.IBorder.Edge.Left:exports.IBorder.Edge.Top;if(!Vn(c[y],h[b]))return;const w=r?exports.IBorder.Edge.Vertical:exports.IBorder.Edge.Horizontal,E=c[y];if(p>1&&!Vn(E,c[w]))return;const I=S===1?h[b]:h[w];if(S>1&&!Vn(I,h[w])||!Vn(E,I))return;const x={border:{[d]:c[d],[g]:c[g],[C]:c[C],[w]:E,[b]:c[b],[y]:h[y]}},v=exports.it.resolveTypedUpdates(x,We,u,o);return new Je(u,t,v)}return new Je(u,t,this._p)}hasTrailingEdge(){return!0}isMergeOnShift(){return!0}_splitBorderRange(e,t,n,r){const o=r?exports.IBorder.Edge.Left:exports.IBorder.Edge.Top,i=r?exports.IBorder.Edge.Right:exports.IBorder.Edge.Bottom,a=r?exports.IBorder.Edge.Vertical:exports.IBorder.Edge.Horizontal,l=r?t.colStart:t.rowStart,c=r?t.colEnd:t.rowEnd,h=r?n.colStart:n.rowStart,u=r?n.colEnd:n.rowEnd;let d={...e};return delete d[o],delete d[i],delete d[a],l===h?e[o]&&(d[o]=e[o]):e[a]&&(d[o]=e[a]),c===u?e[i]&&(d[i]=e[i]):e[a]&&(d[i]=e[a]),u-h>0&&e[a]&&(d[a]=e[a]),Object.keys(d).length===0?null:d}_localizeBorderRange(e,t,n){if(!e)return;let r=null;const o=t.rowStart,i=t.rowEnd,a=n.rowStart,l=n.rowEnd;e.top&&a===o&&(r=r??{},r.top=e.top),e.bottom&&l===i&&(r=r??{},r.bottom=e.bottom),e.horizontal&&(l-a>0&&(r=r??{},r.horizontal=e.horizontal),a>o&&(r=r??{},r.top=e.horizontal),l<i&&(r=r??{},r.bottom=e.horizontal));const c=t.colStart,h=t.colEnd,u=n.colStart,d=n.colEnd;return e.left&&u===c&&(r=r??{},r.left=e.left),e.right&&d===h&&(r=r??{},r.right=e.right),e.vertical&&(d-u>0&&(r=r??{},r.vertical=e.vertical),u>c&&(r=r??{},r.left=e.vertical),d<h&&(r=r??{},r.right=e.vertical)),r}_localizeBorder(e,t,n,r){if(!e)return;let o=null;const i=t.rowStart,a=t.rowEnd;e.top&&n===i&&(o=o??{},o.top=e.top),e.bottom&&n===a&&(o=o??{},o.bottom=e.bottom),e.horizontal&&(n>i&&(o=o??{},o.top=e.horizontal),n<a&&(o=o??{},o.bottom=e.horizontal));const l=t.colStart,c=t.colEnd;return e.left&&r===l&&(o=o??{},o.left=e.left),e.right&&r===c&&(o=o??{},o.right=e.right),e.vertical&&(r>l&&(o=o??{},o.left=e.vertical),r<c&&(o=o??{},o.right=e.vertical)),o}getPropertiesAt(e,t,n){const r=this._p;let o=r,i=null;const a=this._t;if(a){const u=this._r,d=a.colEnd-a.colStart+1,g=a.rowEnd-a.rowStart+1;t=u.colStart+(t-u.colStart+(a.colStart-u.colStart))%d,e=u.rowStart+(e-u.rowStart+(a.rowStart-u.rowStart))%g}const l=r?.font;l&&l.fill&&(i=i??this._c.getNormalRanged().getPropertiesAt(e,t,n),i&&i.font&&l.fill===i.font.fill&&(o===r&&(o={...o}),o.font={...l},delete o.font.fill));const c=r?.fill;c&&(i=i??this._c.getNormalRanged().getPropertiesAt(e,t,n),i&&N.deepEqual(c,i.fill)&&(o===r&&(o={...o}),delete o.fill));const h=o?.border;if(h){const u=a??this._r,d=this._localizeBorder(h,u,e,t);d!==void 0&&(o===r&&(o={...o}),d===null?delete o.border:o.border=d)}return o}toJSON(){return N.toSafeJSON(this._p)}}const pw=Object.freeze({value:null,style:null,hyperlink:null,formula:null,type:U.Null,stringToParse:null}),ld=Object.seal({value:void 0,style:void 0,hyperlink:void 0,formula:void 0,type:void 0,stringToParse:void 0}),_w=Object.seal({value:void 0,style:void 0,hyperlink:void 0,formula:void 0}),Sw=Object.freeze({width:1,height:1}),ww=new yc({max:1e3}),yw=new class{isEditAllowed(){return!0}isFormulaHidden(){return!1}get isICellProtection(){return!0}},ql=(s,e,t=null,n=null,r=!1)=>{if(s===void 0)return;if(s===null)return pw;if(s&&s.isICell){const p=s,S=ld;return S.value=p.getValue(),p.getStyle().isNormal()||(S.style=p.getStyle()._p.getProperties()),S.formula=p.getFormulaText(),S.hyperlink=p.getHyperlink(),S.type=p.getType(),S}let o;s.value!==void 0||s.style!==void 0||s.hyperlink!==void 0?o=s:(o=_w,o.value=s,o.style=void 0,o.hyperlink=void 0);const i=ld;i.type=void 0,i.value=void 0,i.style=void 0,i.formula=void 0,i.hyperlink=void 0,i.stringToParse=void 0;let a,l=o.value,c=!1;if(o.value!==void 0&&(a=Ye(l),a||(c=Ur(l),c&&(a=U.Number)),!a))throw new Error("Invalid cell type. See documentation for information on valid built in cell types and creating custom cell types.");let h,u,d=null,g=null,m;if(a===U.String){if(m=o.value,t){let p=n?.get(m);if(!p){const S=m.length,C=m.charAt(0);C==="="&&S>1?(u=m.substring(1),l=null):(p=of(m,t),!p||typeof p.value!="string"||C!=="+"&&C!=="-"||(u="="+m,l=null),p!==void 0&&n&&n.set(m,p))}p&&(p.value!==void 0&&(l=p.value,a=Ye(l)),p.style!==void 0&&(d=p.style),p.hyperlink!==void 0&&(h=p.hyperlink)),!r&&t.parse&&(g=m)}}else if(c){const p=t?.date1904??e.date1904;l=Qo(o.value,p),d=S=>{if(!Zo(S.getNumberFormat()))return{numberFormat:"Short Date"}}}else l=o.value;let f=o.style;if(f&&f.isIStyle&&(f=f._p.getProperties()),h=o.hyperlink??h,d)if(f){const p=f;f=S=>{let C=S.createTemporaryStyle(d);return C=C.createTemporaryStyle(p),C=C._p.getProperties(),C}}else f=d;let _=!1;return l!==void 0&&(l===null?(i.value=null,i.type=U.Null):(i.value=l,i.type=a),_=!0),f!==void 0&&(i.style=f,_=!0),h!==void 0&&(i.hyperlink=h,_=!0),u!==void 0&&(i.formula=u,_=!0),r||(i.stringToParse=g,_=!0),_?(i.type=a,i):void 0},nf=(s,e,t,n)=>Zm(t,e,s,e.getNumberFormat(),r=>n.styles.parseColor(r),n.date1904),rf=(s,e,t,n,r=!1)=>{if(s===U.Null)return null;let o="";if(r)o=""+t;else{const i=nf(s,e,t,n);if(i.formattedRuns){const a=i.formattedRuns.runs;for(let l=0;l<a.length;l++)o+=a[l].text}else o=i.displayText}return Ui(o,e.getFont(),e.getAlignment(),s===U.String,r)},Cc=(s,e)=>{const t=e.getInsets();if(s===U.Null)return t;let n=t;const r=Ki(s,e),o=e.getAlignment().getIndent();if(o&&(r===exports.ITextFrame.HorizontalAlignment.Left||r===exports.ITextFrame.HorizontalAlignment.Right)){n={...t};const i=e.measureText(" ".repeat(1*o)),a=Math.min(3,Math.max(1,(26-e.getFont().getSize())/2));let l=i.width*a;r===exports.ITextFrame.HorizontalAlignment.Left?n.left+=l:r===exports.ITextFrame.HorizontalAlignment.Right&&(n.right+=l)}return Object.freeze(n)},Ki=(s,e)=>{const t=e.getAlignment(),n=t.getRotation(),r=t.getHorizontal();return n!==0&&r===exports.ITextFrame.HorizontalAlignment.General?n>0&&n<90||n>180&&n<=270?exports.ITextFrame.HorizontalAlignment.Right:exports.ITextFrame.HorizontalAlignment.Left:r===exports.ITextFrame.HorizontalAlignment.General?s===U.Null?exports.ITextFrame.HorizontalAlignment.Left:s===U.Boolean||s===U.Error?exports.ITextFrame.HorizontalAlignment.Center:e.getNumberFormat()==="@"?exports.ITextFrame.HorizontalAlignment.Left:s===U.Number?exports.ITextFrame.HorizontalAlignment.Right:exports.ITextFrame.HorizontalAlignment.Left:r},Cw=(s,e,t,n,r,o,i,a)=>{if(e===U.Null||n==="")return null;const l=s.colIndex;if(!((D,P,B=!1,z=!1)=>{if(D===U.Null)return!1;const O=P.getAlignment(),W=O.getHorizontal();if(W===exports.ITextFrame.HorizontalAlignment.CenterContinuous)return!0;if(W===exports.ITextFrame.HorizontalAlignment.Fill||W===exports.ITextFrame.HorizontalAlignment.Distributed||D!==U.String||O.getOverflow()!==exports.ITextFrame.Overflow.Visible||W===exports.ITextFrame.HorizontalAlignment.Right&&B||W===exports.ITextFrame.HorizontalAlignment.Center&&B&&z||z&&(W===exports.ITextFrame.HorizontalAlignment.General||W===exports.ITextFrame.HorizontalAlignment.Left))return!1;const V=O.getVertical();return V!==exports.ITextFrame.VerticalAlignment.Justify&&V!==exports.ITextFrame.VerticalAlignment.Distributed})(e,t,r!==null&&r.colIndex+1===l,o!==null&&o.colIndex-1===l))return null;const c=Ew(e,t,n,a),h=t.getAlignment().getHorizontal(),u=h===exports.ITextFrame.HorizontalAlignment.Fill,d=h===exports.ITextFrame.HorizontalAlignment.CenterContinuous||u;if(!c&&!d)return null;const g=(m=Ki(e,t))===exports.ITextFrame.HorizontalAlignment.Center||m===exports.ITextFrame.HorizontalAlignment.CenterContinuous?ln.Center:m===exports.ITextFrame.HorizontalAlignment.Right?ln.Right:ln.Left;var m;let f=0,_=0,p=0,S=0,C=1;if(d&&n!==null&&i.directStyle){const D=i.directStyle.getCoords();C=Math.min(a.nextContentful(s,D.colEnd),D.colEnd)-s.colIndex+1}const y=a.colHeaders,b=y.findOffset.bind(y),w=y.findIndex.bind(y);let E=b(l);const I=E;let x=b(l+C),v=x-E,R=l,A=l;const M={x:0,y:0,width:v,height:c?.height??0},T=l-l+C;let F=c?c.width-v:0,L=M;return u&&(F=0),v>0&&F>0&&(g===ln.Center&&(F/=2),g!==ln.Left&&g!==ln.Center||(A=w(x+F),o!==null&&(A=Math.min(A,o.colIndex-1)),x=b(A),S=F,_=A-l),g!==ln.Right&&g!==ln.Center||(R=w(E-F),r!==null&&(R=Math.max(R,r.colIndex+1)),E=b(R),p=F,f=l-R),M.x=I-E,L.x=M.x),{anchorBounds:M,leftIndex:f,rightIndex:_,leftOffset:p,rightOffset:S,colSpan:T,colBounds:L}};class bw{constructor(e,t){if(this._styles=e,this._rs=t,t?.table){const n=t?.table;this._table=n.getStyle().getRanged(n)}if(t?.conditionals){this._conditionals=[];for(let n=0;n<t.conditionals.length;n++){const r=t.conditionals[n];this._conditionals.push(r)}}}getCoords(){return k.EmptyRange}getPropertiesAt(e,t,n){let r=null,o=this._rs.directStyle?.getPropertiesAt(e,t,n)??null;const i=this._styles;if(o&&o.named){const h=o.named;if(h!==exports.IStyle.BuiltInName.Normal){const u=this._styles.getNamed(h);u?r=u.getRanged().getPropertiesAt(e,t,n):console.warn(`A named styled was referenced but not found: '${h}'.`)}}let a=null;const l=this._table?.getPropertiesAt(e,t,n);l&&(a=a?exports.it.resolveTypedUpdates(l,We,i,a):l),r&&(a=a?exports.it.resolveTypedUpdates(r,We,i,a):r);const c=this._conditionals;if(c)for(let h=0;h<c.length;h++){const u=c[h].getPropertiesAt(e,t,n);u&&(a=a?exports.it.resolveTypedUpdates(u,We,i,a):u)}return o&&(a=a?exports.it.resolveTypedUpdates(o,We,i,a):o),a}cloneWithUpdate(e){return(this._rs.directStyle??this._styles.getNormalRanged()).cloneWithUpdate(e)}}const Oi=(s,e,t,n)=>{if(!t)return n.styles.getNormal();const r=n.styles;return Vr(r,t?new bw(r,t):null,e)},On=(s,e,t,n,r,o,i,a=null,l=ww)=>{if(t===null)return e?e.getBestFit():null;const c=s===U.String,h=e.getFont(),u=h.getWeight(),d=h.getSize(),g=h.getFamily(),m=e.getAlignment(),f=m.getOverflow(),_=m.getRotation(),p=m.getVertical(),S=e.getNumberFormat(),C=c&&f===exports.ITextFrame.Overflow.Visible,y=c&&(f===exports.ITextFrame.Overflow.Wrap||p===exports.ITextFrame.VerticalAlignment.Justify||p===exports.ITextFrame.VerticalAlignment.Distributed),b=(a??"")+"\0"+d+g+u+S+_+C+y+o+i+(a?"":t),w=l.get(b);if(w)return w;let E=null,I=null;const x=Cc(s,e),v=x.top+x.bottom+ +Aw(e);let R=!1,A=!1;i&&(A=!0,(_!==0||y)&&(A=!1));const M=A?void 0:rf(s,e,t,n),T=x.left+x.right+2;if(M){if(s===U.Number&&S==="General"&&o){let D=t,P=N.splitNumber(D),B="";B=Math.abs(D)>=Math.pow(10,12)||Math.abs(D)<=Math.pow(10,-12)?`0.${"0".repeat(Math.max(2,Math.min(P.ipLength,5)))}E+00`:Math.abs(P.ipLength)===0?"0.0":Math.abs(P.fpLength)>0?"0".repeat(P.ipLength)+".0":"0".repeat(P.ipLength),D<0&&(B="-"+B),B="0".repeat(B.length);const z=e.measureText(B);E=z.width,I=z.lineHeight}else{let D=null;y&&(D={width:Math.max(1,r-T)});const P=M.layout(D);E=P.bounds.width,I=P.bounds.height}if(E!==null&&(E+=T),I!==null&&(I+=v),R=s===U.String,_){R&&f===exports.ITextFrame.Overflow.Wrap&&(R=!1);const D=((P,B)=>{const{x:z,y:O,width:W,height:V}=P,j=B*Math.PI/180,H=Math.sin(j),G=Math.cos(j),$=W/2,te=V/2,J=ps(-$,-te,H,G),ne=ps($,-te,H,G),Z=ps(-$,te,H,G),q=ps($,te,H,G);let oe=Math.min(J.x,ne.x,Z.x,q.x)+$,ce=Math.max(J.x,ne.x,Z.x,q.x)+$,Y=Math.min(J.y,ne.y,Z.y,q.y)+te;return{x:z+oe,y:O+Y,width:ce-oe,height:Math.max(J.y,ne.y,Z.y,q.y)+te-Y}})({x:0,y:0,width:E,height:I},_);E=D.width,I=D.height}}else I=e.getBestFit().height;o&&R&&(E=0);const F={width:E,height:I},L=Object.freeze(F);return l.set(b,L),L},Ew=(s,e,t,n)=>{const r=Cc(s,e),o=Ki(s,e);let i=r.left+r.right;o===exports.ITextFrame.HorizontalAlignment.Left?i=r.right:o===exports.ITextFrame.HorizontalAlignment.Right?i=r.left:o===exports.ITextFrame.HorizontalAlignment.Center&&(i=r.left+r.right);const a=On(s,e,t,n,Number.MAX_SAFE_INTEGER,!1,!1);return{width:Math.ceil(a.width-i),height:Math.ceil(a.height)}};class jn{constructor(e,t,n=U.Null,r=null,o=null,i=null,a=null){this._options=e,this._coords=t??null,this._t=n,this._rs=o,this._v=r,this._p=i,this._n=a}isEqual(e){if(!e)return!1;if(this===e)return!0;const t=e;return!!t.isICell&&this._v===t._v&&!!k.isEqualCells(this._coords,e.getCoords())&&this._options.sheet===t._options?.sheet}getCoords(){return this._coords}getA1(){const e=this._coords;return e?mn(this._options.resolveRange(e).getCoords()):Ke}getSource(){return this._options.sheet}select(e){return this._options.opener("#"+rs(this._coords),e)}getColumnFilter(){if(!this._rs)return null;let e=null;if(this._rs.table){const t=this._rs.table.getHeaderRange().getCoords();if(t&&k.isCellWithinRange(this._coords,t)){const n=this._coords.colIndex-t.colStart;e=this._rs.table.getColumnFilter(n)??null}}return e}getProtection(){return yw}getTextOverflow(){const e=this._to;if(e!==void 0)return e;if(this._rs&&this._rs.merge)return this._to=null,null;const t=this.getStyle(),n=Cw(this._coords,this._t,t,this._v,this._p,this._n,this._rs,this._options);return n===null||n.leftIndex===0&&n.rightIndex===0&&n.colSpan<=1?(this._to=null,null):(this._to=n,this._to)}getRenderHorizontalAlignment(){return Ki(this._t,this.getStyle())}isEmpty(){return this._v===null&&!this._rs}getExtrusions(){const e=this._rs;if(!e&&this._to===null)return null;if(e){const r=e.merge;if(r!==void 0)return r.getCoords()}const t=this.getTextOverflow();if(!t)return null;const n=this._coords;return{colStart:n.colIndex-t.leftIndex,rowStart:n.rowIndex,colEnd:n.colIndex+t.rightIndex+t.colSpan-1,rowEnd:n.rowIndex}}isEditAllowed(){const e=this._options;return e?!e.getProtection().isLocked()||!!this._rs&&this.getProtection().isEditAllowed():!0}isFormulaHidden(){return!!this._options.getProtection().isLocked()&&!!this._rs&&this.getProtection().isFormulaHidden()}isContentful(){return this._v!==null}getBestFit(e,t=!1){return e===void 0&&(e=this._options.sheet.getColumnHeaders().getSpanSize(this._coords.colIndex)??64),On(this._t,this.getStyle(),this._v,this._options,e,t,!1)}getInsets(){return this._v===null?this.getStyle().getInsets():Cc(this._t,this.getStyle())}getTextFrame(e){let t,n;if(e&&(n=this.getFormulaText()),t=n??this._v,t===null)return null;const r=this.getStyle();return n?((o,i)=>i===U.Null?null:Ui(i,o.getFont(),o.getAlignment(),!1,!0))(r,t,this._options):rf(this._t,r,t,this._options,e)}getValue(){return this._v}getFormula(){let e=this._rs?.formula;if(!e)return null;const t=this._coords;return t?(Array.isArray(e)&&(e=e[0]),new xw(this._options,e,t)):null}getFormulaText(){let e=this._rs?.formula;if(!e)return null;const t=this._coords;return t?(Array.isArray(e)&&(e=e[0]),"="+e.getFormulaTextAt(t.rowIndex,t.colIndex)):null}getCalcStatus(){const e=this._rs;return e&&e.pending?exports.ICell.CalcStatus.Pending:exports.ICell.CalcStatus.Ready}getType(){return this._t}getStyle(e=!1){if(!e&&this._styleConditional)return this._styleConditional;if(e&&this._styleSpecific)return this._styleSpecific;const t=Oi(0,k.cellToRange(this._coords),this._rs,this._options);return e?this._styleSpecific=t:this._styleConditional=t,t}createTemporaryCell(e){const t=this._options;if(e===null)return new jn(t,this._coords,null);const n=ql(e,this._options);let r=this._rs;if(n.style!==void 0){const a=this._coords??k.EmptyCell,l=k.cellToRange(a),c=()=>Oi(0,l,this._rs,this._options),h=Ji(this._options.styles,n.style,c),u=(this._rs?.directStyle??new Je(t.styles,l)).cloneWithUpdate(h);r={...r,directStyle:u}}let o=this._t,i=this._v;return n&&n.value!==void 0&&(i=n.value,o=n.type),i===this._v&&o===this._t&&r===this._rs?this:i!==null||r?new jn(this._options,this._coords,o,i,r):new jn(this._options,this._coords)}_isDate1904(){return this._options.date1904}getNumberFormat(e){if(e!==void 0){const t=this._v;return Zm(t,this.getStyle(),this._t,e,n=>this._options.styles.parseColor(n),this._isDate1904())}return nf(this._t,this.getStyle(),this._v,this._options)}toDate(){return this._t!==U.Number?null:this._rs?this.getNumberFormat().asDate:null}toText(e){return this.getNumberFormat(e).displayText}toTextUnformatted(e){if(e){const n=this.getFormulaText();if(n)return n}let t=this._v;return this.isSpillOverflow()&&(t=null),((n,r,o,i)=>{if(r===U.Null||n==null)return"";if(r===U.Number){const a=n,l=Zo(o),c=Hi(o);if(l||c){const h=parseFloat(n),u=h%1!=0,d=h>=1;if(h<0)return N.castToString(n);if(!l||c||u)if(!c||l||d){const g=xo("Short Date",a,i),m=xo("Long Time",a,i);if(g&&m)return g.fmt+" "+m.fmt}else{const g=xo("Long Time",a,i);if(g)return g.fmt}else{const g=xo("Short Date",a,i);if(g)return g.fmt}}}if(r===U.Number&&o.endsWith("%")){let a=N.roundAccurately(100*parseFloat(n));if(!isNaN(a))return a+"%"}return r===U.Boolean?n?"TRUE":"FALSE":r===U.Error?n?.getLabel?.()??exports.n.Label.Unknown:r===U.RichData?"(Rich Object)":N.castToString(n)})(t,this._t,this.getStyle().getNumberFormat(),{date1904:this._isDate1904()})}getComments(){const e=this._rs?.comments;return e?Object.freeze(e):null}getHyperlink(){const e=this._rs?.hyperlink;return e?new eS(this.toText.bind(this),this._options.opener,e):null}getErrors(){const e=this._rs;return e&&e.calcError?[e.calcError]:N.EmptyArray}getWarnings(){return N.EmptyArray}getSpans(){const e=this._rs?.merge;if(!e)return Sw;const t=e.getCoords();return Object.freeze({width:t.colEnd-t.colStart+1,height:t.rowEnd-t.rowStart+1})}isTopLeft(){const e=this._rs?.merge;if(!e)return!0;const t=e.getCoords();return this._coords&&this._coords.colIndex===t.colStart&&this._coords.rowIndex===t.rowStart}getSpill(){let e=this._rs?.spills;if(!e||!this._coords)return null;Array.isArray(e)||(Es[0]=e,e=Es);let t=null;for(let n=0;!t&&n<e.length;n++){const r=e[n];r.getError()||(t=r)}return t||(t=e[0]),this._options.getRange(t.getCoords())}isSpillOverflow(){let e=this._rs?.spills;if(!e)return!1;if(!this._coords)return null;Array.isArray(e)||(Es[0]=e,e=Es);for(let t=0;t<e.length;t++){const n=e[t].getCoords();if(this._coords.colIndex===n.colStart&&this._coords.rowIndex===n.rowStart)return!1}return!0}get[Symbol.toStringTag](){return"[Cell]"}toString(){let e="{blank}";return this._v!==null&&(e=this.toTextUnformatted(),this.getType()===U.String&&(e=`'${e}'`)),`${this.getA1()} => ${e}`}get isICell(){return!0}}let vw=class extends jn{constructor(s){super(s,null,null,null)}isEmpty(){return!0}isContentful(){return!1}toString(){return"{EMPTY CELL}"}};class xw{constructor(e,t,n){this._options=e,this._entry=t,this._coords=n}getTokens(e){const t=this._coords;return t?this._entry.getTokensAt(t.rowIndex,t.colIndex,e):N.EmptyArray}evaluate(e){const t=this._coords;return t?this._options.calcGraph().evaluateAt(t.rowIndex,t.colIndex,e):N.EmptyArray}toText(e){const t=this._coords;return t?"="+this._entry.getFormulaTextAt(t.rowIndex,t.colIndex,e):null}getDirectPrecedents(){const e=this._coords;return e?this._options.calcGraph().getDirectPrecedentsAt(e.rowIndex,e.colIndex):N.EmptyArray}getReferences(){const e=this._coords;return e?this._entry.getReferencesAt(e.rowIndex,e.colIndex):N.EmptyArray}setReferenceAt(e,t){const n=this._coords;return n?(this._options.calcGraph().setReferenceAt(n.rowIndex,n.colIndex,e,t),this):N.EmptyArray}get[Symbol.toStringTag](){return"[Formula]"}toString(){return this.toText()}}const Es=[null];let Ua;const Bi=(s,e,t,n=!1)=>{const r=t===exports.w.Orientation.Row,o=s.length,i=new Array(o);for(let a=0;a<o;a++){const l=s[a];if(r){const c=l.colEnd-l.colStart+1;i[a]={...l,colStart:n?l.colEnd+1:l.colStart,rowStart:e.rowStart,colEnd:n?l.colEnd+c:l.colEnd,rowEnd:e.rowEnd}}else{const c=l.rowEnd-l.rowStart+1;i[a]={...l,colStart:e.colStart,rowStart:n?l.rowEnd+1:l.rowStart,colEnd:e.colEnd,rowEnd:n?l.rowEnd+c:l.rowEnd}}}return i},qo=(s,e,t)=>{const n=e,r=s.length;for(let o=0;o<r;o++){const i=s[o];if((i.rowStart<=n.rowStart&&i.rowEnd>=n.rowEnd)!==t)return!t}return t},Jo=(s,e,t)=>{const n=e,r=s.length;for(let o=0;o<r;o++){const i=s[o];if((i.colStart<=n.colStart&&i.colEnd>=n.colEnd)!==t)return!t}return t},cd=(s,e)=>{let t=0;const n=s.length;for(let r=0;r<n;r++){const o=s[r];e===exports.w.Orientation.Column?t+=o.colEnd-o.colStart+1:t+=o.rowEnd-o.rowStart+1}return t},Iw=(s,e)=>{if(e){if(s.colStart<=e.colStart&&s.colEnd>=e.colEnd)return exports.w.Orientation.Row;if(s.rowStart<=e.rowStart&&s.rowEnd>=e.rowEnd)return exports.w.Orientation.Column}return s?(t=>t.rowEnd-t.rowStart>t.colEnd-t.colStart?exports.w.Orientation.Column:exports.w.Orientation.Row)(s):exports.w.Orientation.Row},vs=()=>!1,qa=()=>!0,xs=()=>null,hd=()=>qe,an=()=>0,ud=new class extends jn{constructor(){super(null,null)}createTemporaryCell(){return this}getType(){return U.Error}getWarnings(){return[Ke]}getStyle(s=!1){return Ua||(Ua=new Jr().getNormal(),Ua)}toString(){return`${this._coords?rs(this._coords):Ke} => ${this._v??"{blank}"}`}},qt=()=>Pn,Pn={forEach:()=>{},[Symbol.iterator]:hd,entries:hd,select:_e,find:_e,calculate:_e,getCell:()=>ud,getValue:xs,setValue:_e,setValues:_e,updateCells:_e,updateStyle:_e,getCells:()=>[[ud]],getStyleUpdater:_e,getValues:()=>[[null]],getBounds:xs,getIntersect:qt,getUnion:qt,getDifferences:_e,getResizeBy:qt,getResizeTo:qt,getOffsetBy:qt,getOffsetTo:qt,getFixed:qt,getUsedRange:qt,getEntireRows:qt,getEntireColumns:qt,getSurrounding:_e,getExtended:_e,isEntireRows:vs,isEntireColumns:vs,isEntireRange:vs,getWidth:an,getHeight:an,size:0,sort:_e,clear:_e,setHyperlink:_e,setComments:_e,merge:_e,unmerge:_e,getMerges:_e,insert:_e,insertFrom:_e,delete:_e,getDefaultShiftOrientation:_e,getDefaultSortCriteria:_e,autoFill:_e,autoFit:_e,getSnapshot:_e,copyFrom:_e,doBatch:_e,startIncrementalUpdates:_e,getRowHeaders:_e,getColumnHeaders:_e,getCounts:_e,getCount:an,isContentful:vs,addListener:_e,getColumnStart:an,getRowStart:an,getColumnEnd:an,getRowEnd:an,getRowCount:an,getColumnCount:an,getVisible:_e,getCoords:xs,isEmpty:qa,toString:()=>Ke,getA1:()=>Ke,isInvalid:qa,getSource:xs,isReadOnly:qa,isICellRange:!0};function fn(s,e=null,t=null,n=Ke){return s||t?Object.freeze({...Pn,getSheet:()=>s,bounds:()=>t,getA1:()=>n,toString:()=>t?Cn(t,e):n}):Pn}const Rw=/^[\\+-]?[0-9]*\.?[0-9]*$/,of=(s,e,t)=>{if(s===void 0)throw new Error("A value is required to create a cell from a text.");const n=t??{value:null};if((s=N.castToString(s)).trim()==="")return n;if(s.toUpperCase()==="TRUE"||s.toUpperCase()==="FALSE")return n.value=s.toUpperCase()==="TRUE",n;if(s.startsWith("'")&&!e?.ignoreQuotePrefix)return n.style={quotePrefix:!0},n.value=s.substring(1,s.length),n;n.value=s;const r=",",o="$",i=".";let a=s.trim(),l=1,c=!1;a=(_=>{const p=new RegExp("([(]{1}([^(|^)]+)[)]{1})").exec(_);if(p?.[2]){const S=_.substring(0,p.index)+p[2].trim()+_.substring(p.index+("("+p[2]+")").length-1,_.length-1);return S.indexOf("(")>-1||S.indexOf(")")>-1?_:(c=!0,l=-1,S)}return _})(a);let h=0;a=(_=>{const p=new RegExp("[0-9]+([eE][-+]?[0-9]+)?$").exec(_);if(p?.[1]){const S=_.substring(0,_.length-p[1].length);let C=1,y=p[1].substring(1,p[1].length);if(y.startsWith("-")?(y=y.substring(1,y.length),C=-1):y.startsWith("+")&&(y=y.substring(1,y.length)),!isNaN(y))return h=y*C,S}return _})(a);let u=!1;if(a=(_=>{const p=new RegExp(`^(\\${o}[\\ ]*\\-|\\${o}[\\ ]*\\+|\\-[\\ ]*\\${o}|\\+[\\ ]*\\${o}|\\-|\\+)?`).exec(_);if(p?.[1]){const S=p?.[1].indexOf(o)>-1,C=p?.[1].indexOf("-")>-1,y=p?.[1].indexOf("+")>-1,b=(S?o:"")+_.substring(p.index+p[1].length,_.length).trim(),w=b.indexOf("-")>-1,E=b.indexOf("+")>-1;return w||E?_:(u=C||y,C&&(l=-1),b)}return _})(a),u&&(c||a.length===0))return n;let d=!1;if(a=(_=>{if(new RegExp(`^(?:\\${o}[\\ ]*)?((\\d{1,3}(${r}\\d{3})*)|(\\d*))(\\${i}|\\${i}\\d*)?(?:[\\ ]*\\%)?$`).test(a)){const p=_.replace(new RegExp(`${r}`,"g"),"");return d=p.length<_.length,p}return _})(a),a.match(Rw)&&!isNaN(a)){if(n.value=a*l,h!==0)n.value=n.value*Math.pow(10,h),n.style={numberFormat:`0${i+"0".repeat(2)}E+00`};else if(d){let _=ei(a);n.style=_>0?{numberFormat:`#${r}##0${i+"0".repeat(2)}`}:{numberFormat:`#${r}##0`}}return n}if(a.trimEnd().endsWith("%")&&a.trimEnd().length>1){let _=a.substring(0,a.length-1);if(!isNaN(_)){n.value=_*l/100;const p=ei(_);n.style=S=>{if(!S.getNumberFormat().includes("%"))return{numberFormat:p>0?`0${i+"0".repeat(2)}%`:"0%"}}}return n}if(a.startsWith(o)&&s.trim().length>1){let _=a.replace(o,"");if(!isNaN(_)){let p=ei(_);n.value=_*l,n.style=S=>{if(S.getNumberFormat().includes(o))return;let C;return C=p>0?`${o}#${r}##0${i+"0".repeat(2)}_);[Red](${o}#${r}##0${i+"0".repeat(2)})`:`${o}#${r}##0_);[Red](${o}#${r}##0)`,{numberFormat:C}}}return n}let g=null,m=null;try{m=Yg(s,e?.date1904,!0);let _=s;m&&(_=m.leadingText),_.trim().length>0&&(g=ac(_,e?.date1904)),!g&&m?.leadingText.trim().length>0&&(m=null)}catch{}if(g||m){n.style=p=>{let S=p.getNumberFormat();const C=Zo(S);if(g&&C)return;const y=Hi(S);if(!m||!y){if(g&&m&&!C&&!y?S="m/d/yyyy h:mm":g&&!C?S=g.numberFormat:m&&!y&&(S=m.numberFormat),m&&m.parsed.oaDateTime>1&&(S="General"),g&&!C&&!m){const b=exports.NumberFormat.Parser.formatValue(g.numberFormat,g.asOADate,{date1904:e?.date1904}),w=Intl.DateTimeFormat().resolvedOptions().locale??"en-US";b===new Intl.DateTimeFormat(w).format(g.asJSDate)?S="Short Date":b===new Intl.DateTimeFormat(w,{dateStyle:"full"}).format(g.asJSDate)?S="Long Date":b===new Intl.DateTimeFormat(w,{timeStyle:"medium"}).format(g.asJSDate)&&(S="Long Time")}return{numberFormat:S}}};let _=0;return g&&(_+=g.asOADate),m&&(_+=m.parsed.oaDateTime),n.value=_,n}const f=exports.n.getBuiltInByLabel(s);return f?(n.value=f,n):(n.value=s,im(s)?n.hyperlink=s:am(s)&&(n.hyperlink=s,n.hyperlink.toLowerCase().startsWith("mailto:")||(n.hyperlink=`mailto:${n.hyperlink}`)),n)},Aw=s=>{const e=s.getFont().getUnderline()===exports.IFont.UnderlineStyle.SingleAccounting,t=s.getFont().getUnderline()===exports.IFont.UnderlineStyle.DoubleAccounting;let n=0;return(e||t)&&(n=s.measureText("").underlineThickness+1,t?n*=2:n+=1),n},Ja=s=>{const e=[];return s.getUsedRange().forEachSpan((t,n)=>{const r=n.getCoords();t===0&&e.push(r)},{includeStyles:!1}),Xt(rr(e))},Ka=(s,e,t,n)=>{const r=n?.asJSDate;let o;t?o=Vm:(r||n?.includeMergeOverflow)&&(o={},r&&(o[X.Type.Style]=!1,o[X.Type.Table]=!1),n.includeMergeOverflow&&(o[X.Type.Merge]=!1));const i=n?.orientation??exports.w.Orientation.Row,a=n?.maxSize??1e4,l=s({includeEmpty:!0,orientation:i,reverse:n?.reverse,excludeHidden:n?.excludeHidden,includeMergeOverflow:n?.includeMergeOverflow,includeRangeTypes:o,bounds:e,excludeCellDetails:!r}),c=i!==exports.w.Orientation.Row,h=[];let u,d=-1,g=null,m=0;for(u=l.next();!u.done;){if(m>a)throw new Error(Gm(a));const f=u.value,_=f.context.getCoords(),p=c?_.colIndex:_.rowIndex;p!==d&&(g=[],h.push(g),d=p);let S=f.value;if(t)S=f.context.getCell();else if(r&&S!==null&&typeof S=="number"){const C=f.context.getCell().toDate();C&&(S=C)}g.push(S),u=l.next(),m++}return h},Oo=(s,e)=>s===e||!(!s||!e)&&s.rowStart===e.rowStart&&s.rowEnd===e.rowEnd&&s.colStart===e.colStart&&s.colEnd===e.colEnd&&s.$rowStart===e.$rowStart&&s.$rowEnd===e.$rowEnd&&s.$colStart===e.$colStart&&s.$colEnd===e.$colEnd,sf=(s,e)=>{if(!s)return;const t={...s};return e?typeof e=="boolean"?(t.$colStart=e,t.$rowStart=e,t.$colEnd=e,t.$rowEnd=e,t):(typeof e.colStart=="boolean"&&(t.$colStart=e.colStart),typeof e.rowStart=="boolean"&&(t.$rowStart=e.rowStart),typeof e.colEnd=="boolean"&&(t.$colEnd=e.colEnd),typeof e.rowEnd=="boolean"&&(t.$rowEnd=e.rowEnd),t):t};class Xa{constructor(e,t,n){const r=this;this.setState=o=>{const i=o[0];let a=o[1],l=o[2];if(t&&t.includeMergeOverflow&&l&&l.merge){const h=t.bounds,u=l.merge.getCoords();let d=!1;const g=u.colStart,m=u.rowStart,f=h.colStart,_=h.rowStart,p=i.colIndex,S=i.rowIndex;!d&&g<f&&m>=_&&p===f&&S===m&&(d=!0),!d&&m<_&&g>=f&&S===_&&p===g&&(d=!0),!d&&m<_&&g<f&&S===_&&p===f&&(d=!0),d&&(a=l.merge.tvTl(),l=l.merge.rsTl())}l&&Object.keys(l).length===0&&(l=null);let c=a;return a===void 0?(this._t=null,this._v=null,c=null):(this._t=Ye(c),this._v=c),this._r=l,this._p=o[3],this._n=o[4],this._c=i,c},this.clear=()=>{r._c=null},this.context={getCoords(){const o=r._c;if(!o)throw new Error(Lr);return o},getCell(){const o=r._c;if(!o)throw new Error(Lr);if(this.excludeCellDetails)throw new Error("IteratorContext can only return a cell if the forEach excludeCellDetails has not been set to false.");const i=r._r,a=r._t,l=r._v;return l!==null||i?new jn(n,o,a,l,i,r._p,r._n):new jn(n,o)},getType:()=>r._t,getA1(o){if(!r.context)throw new Error(Lr);let i=r._c;return o&&(i={...r._c,...o}),n.resolveRange(i).toString()},toJSDate(o){if(r._t!==U.Number)return null;let i=o;if(i===void 0)i=r._v;else if(typeof i!="number")throw new Error("The arguments are not valid.");return qr(i,n.date1904)}}}}const yn=(s,e)=>{if(s||e)return s&&e?{...s,...e}:s||e},dd=(s,e,t,n=exports.w.Orientation.Row)=>{const r=s.getRange(e,{excludeHidden:n}),o=r.forEach((p,S)=>({break:S.getCoords()}),{excludeCellDetails:!0,orientation:n});if(!o)return;const i=n===exports.w.Orientation.Row,a=new Map,l=new Map,c=new Map;let h=null;const u=s.getRange(o).getMerges();let d=u.length>0?1+(i?u[0].rowEnd-u[0].rowStart:u[0].colEnd-u[0].colStart):1;const g=i?o.rowIndex:o.colIndex;if(r.forEach((p,S)=>{const C=S.getCoords(),y=i?C.colIndex:C.rowIndex,b=i?C.rowIndex:C.colIndex;if(b===g)a.set(y,p);else{if(b!==g+d)return Ou;typeof p=="string"?h=!1:p!==null&&l.set(y,p)}if(h!=null)return Ou},{orientation:n,excludeCellDetails:!0,address:e}),h===null){const p=l.entries();let S=p.next();for(;h===null&&!S.done;){const[C,y]=S.value,b=a.get(C);b&&(typeof b=="string"?c.set(C,b):h=!1),S=p.next()}h=h??c.size>0}const m={colStart:o.colIndex,rowStart:o.rowIndex,colEnd:e.colEnd,rowEnd:e.rowEnd};if(m.colStart>m.colEnd||m.rowStart>m.rowEnd||k.isSingleCell(m))return null;const f=Math.min(Math.max(t?.colIndex??0,m.colStart),m.colEnd),_=Math.min(Math.max(t?.rowIndex??0,m.rowStart),m.rowEnd);return{coords:m,options:{...exports.Sort.DefaultRangeOptions,hasHeader:h,orientation:n,offset:n===exports.w.Orientation.Row?f-m.colStart:_-m.rowStart},headers:c}},gd=(s,e,t=null)=>Or.fromArray(s,(n,r)=>{const o=n?.[1];if(o==null)return null;let i=n[0]??null;switch(o){case U.String:i=e.getById(i);break;case U.Error:i=exports.n.getBuiltInById(i)}return i},(n,r)=>{const o=Ye(n);let i=n;switch(o){case U.String:i=e.add(i);break;case U.Error:i=i.getCode()}return[i,o]},t),md=(s,e)=>{const t=[],n=e?exports.w.Orientation.Column:exports.w.Orientation.Row,r=s.length;for(let o=0;o<r;o++){const i=s[o],a=i[0],l=i[1],c=l.length;for(let h=0;h<c;h++){const u=l[h],d=u[0],g=u[1].length-1,m={colStart:e?a:d,rowStart:e?d:a,colEnd:e?a:d+g,rowEnd:e?d+g:a,value:new jt({colStart:e?a:d,rowStart:e?d:a,colEnd:e?a:d+g,rowEnd:e?d+g:a},n)};t.push(m)}}return t},co=(s,e,t=-1)=>{if(!s||s.length===0)return null;const n=s.length===1&&s[0].rowStart===s[0].rowEnd&&s[0].colStart===s[0].colEnd,r=t===-1?s.length-1:Math.min(Math.max(0,t),s.length-1);return{cell:e??{rowIndex:s[r].rowStart,colIndex:s[r].colStart},ranges:n?[]:[...s],rangeIndex:n?-1:r}},Rr=s=>{if(!s)return null;const e=[];if(s.ranges&&s.ranges.length>0){const t=Math.max(0,Math.min(s.rangeIndex??0,s.ranges.length));for(let n=t;n<s.ranges.length;n++)e.push(s.ranges[n]);for(let n=0;n<t;n++)e.push(s.ranges[n])}else s.cell&&e.push(k.cellToRange(s.cell));return e},Be=(s,e)=>{if(!s||s.length===0)return null;let t=s.length-1;const n=s[t],r=s[0];if(!r||!r)return null;const o=s.length===1&&r.rowStart===r.rowEnd&&r.colStart===r.colEnd;return n?{cell:{rowIndex:n.rowStart,colIndex:n.colStart},ranges:o?[]:[...s],rangeIndex:o?-1:t}:null},fd="Item has been closed. No further operations are allowed.";class Xi{constructor(e){if(this._emitter=null,this._closed=!1,!e)throw new Error("Anchored.ConstructorOptions is required");if(this._options={...e},!this._options.initialAnchor)throw new Error("Initial anchor is required");const t=this;this._transactions=this._options.transactions??new Bt({transient:!0}),this._emitter=new st(this,this._transactions),this._updateState({anchor:this._options.initialAnchor},{description:e?.createDescription??"Create Anchored Item"}),this._options.setContainerShiftCallback?.(n=>t._processContainerShift(n)),this._options.setContainerLayoutCallback?.(()=>{t._processContainerLayout()}),this._options.setContainerDeleteCallback?.(()=>{t._processContainerDelete()}),this._options.setContainerProtectionCallback?.(()=>{t._processContainerProtection()}),this._transactionsRemoveListener=this._transactions.addStateListener(this,{onBeforeCommitStart(n,r,o){t._processBeforeCommitStart(n,r,o)},onAfterStateChange(n,r,o){t._processStateChange(n,r,o),t._processAnchorCoords(),t._emitter.notify("onAnchorCoordsChange")},onRestoreOrRevert(n,r,o){t._processRestoreOrRevert(n,r,o)}})}_getEmitter(){return this._emitter}delete(e){this._options.deleteFromContainer?.(e)}getAnchorCoords(){return this._getState()?.anchor??null}getAnchorType(){return this._getState()?.anchorType??exports.IAnchored.Type.TwoCell}isProtected(){return this._options.isProtected?.()??!1}beginCommit(e){return this._beginCommit(e)}_getState(){if(this._closed)throw new Error(fd);return this._transactions.getState(this)}_beginCommit(e){return this._transactions.beginCommit(typeof e=="string"?{description:e}:e)}_getTransactions(){return this._transactions}_updateState(e,t,n){if(this._closed)throw new Error(fd);if(!e)return;const r=this._beginCommit(t?.description);try{r.updateState(this,e);let o=!1;if(n)for(let i=0;i<n.length;i++){const a=n[i];o=o||a==="onAnyChange",this._emitter.notify(a)}!o&&n&&n.length>0&&this._emitter.notify("onAnyChange"),r.commit()}catch(o){throw r.rollback(),o}return this}_processContainerShift(e){let t=null;const n={anchor:e.after};return e.after||(n.isDeleted=!0,t=["onDelete"]),this._updateState(n,{description:"Update Anchor"},t),e.after}_processBeforeCommitStart(e,t,n){}_processStateChange(e,t,n){}_processRestoreOrRevert(e,t,n){this._emitter.notify("onInvalidated")}_processAnchorCoords(){}_processContainerLayout(){}_getDescription(){return null}_delete(){const e=this._getDescription(),t="Delete",n=e?`${t} ${e}`:t,r=this._beginCommit(n);try{this._processDelete(),r.commit()}catch(o){throw r.rollback(),o}}_processContainerDelete(){this._processDelete()}_processDelete(){}_processContainerProtection(){this._emitter.notify("onProtectedChange")}addListeners(e,t){return this._emitter.addListeners(e,t)}isClosed(){return this._closed}_processClose(){this._closed=!0,this._emitter.notify("onClose"),this._transactionsRemoveListener?.()}close(){this._closed||this._processClose()}get isIAnchored(){return!0}}var Gn;exports.AddressUtils=void 0,(Gn=exports.AddressUtils||(exports.AddressUtils={})).fastStringToCol=$_,Gn.fastStringToCell=Tr,Gn.fastStringToRange=St,Gn.rangeToString=Cn,Gn.cellToString=Hn,Gn.normalizeA1ToR1C1=K_,Gn.resolveRelativeToA1=J_;const Mw=(s,e)=>s.offset-e.offset,pd=s=>{if(!s||s.size===0)return[];let e=[];return s.forEach((t,n)=>{t&&Object.keys(t).length!==0&&e.push({...t,offset:n})}),e.sort(Mw)};class Tw extends Xi{constructor(e){super({...e,createDescription:"Insert AutoSort"}),this._apply=e.apply,this._processUpdate=e.processUpdate,this._fromJSON(e.json)}getRange(){return this._getState().anchor}getFieldAt(e){const t=this._getState().byOffset.get(e)??null;return t?Object.keys(t).length===0||Object.keys(t).length===1&&t.hasOwnProperty("offset")?null:{collatorOptions:null,...t}:null}insertSort(){return null}getSort(){return null}apply(e){const t=this._getState().byOffset,n=new Map(t);for(let r=0;r<e.length;r++){const o={...e[r]},i=o.offset;delete o.offset,n.set(i,o)}return this._updateState({byOffset:n},{description:"Set Sort Criteria"}),this.reapply()}setFieldAt(e,t){const n=this._getState().byOffset,r=new Map(n);return t&&Object.keys(t).length>0?r.set(e,t):r.delete(e),this._updateState({byOffset:r},{description:"Sort"}),this.reapply()}_processStateChange(e,t,n){super._processStateChange(e,t,n),this._processUpdate?.()}reapply(){const e=this._getState(),t=pd(e.byOffset);return this._apply?.(t),this}clear(){return this._updateState({byOffset:new Map},{description:"Clear Sort"}),this.reapply()}_fromJSON(e){const t=e??{},n={byOffset:new Map};if(t.fields)for(let r=0;r<t.fields.length;r++){let o=t.fields[r];const i=o.offset;o={...t.fields[r]},delete o.offset,n.byOffset.set(i,o)}this._updateState(n,{description:"Load"})}toJSON(){const e={},t=this._getState();t.anchor&&(e.ref=exports.AddressUtils.rangeToString(t.anchor,this._options.maxRangeCoords));const n=pd(t.byOffset);return n.length>0&&(e.fields=n),Object.keys(e).length===0?null:e}}const Fw=(s,e)=>s.offset-e.offset,Ya=s=>{if(!s||s.size===0)return[];let e=[];return s.forEach((t,n)=>{t&&Object.keys(t).length!==0&&e.push({...t,offset:n})}),e.sort(Fw)},_d=(s,e=new Map)=>{if(!s||s.length===0)return e;for(let t=0;t<s.length;t++){const n={...s[t]},r=n.offset;delete n.offset,e.set(r,n)}return e},Qa=s=>{let e=0;const t=s.entries();let n=null;do n=t.next(),n.value?.[1]&&n.value[1].hiddenButton&&e++;while(!n.done);return e};class af extends Xi{constructor(e){super({...e,createDescription:"Insert AutoFilter"}),this._apply=e.apply,this._processUpdate=e.processUpdate,e.setFilterCoordsCallback?.(t=>{this._getState().anchor}),this._fromJSON(e.json)}getCoords(){return this._getState().anchor}getFieldAt(e){const t=this._getState().byOffset.get(e)??null;return t?Object.keys(t).length===0||Object.keys(t).length===1&&t.hasOwnProperty("offset")?null:{hiddenButton:!1,criteria:N.EmptyArray,...t}:null}insertSort(){return null}getSort(){return null}apply(e){const t=this._getState().byOffset,n=new Map(t);return _d(e,n),this._updateState({byOffset:n,hiddenCount:Qa(n)},{description:"Set Filter Criteria"}),this.reapply()}setFieldAt(e,t){const n=this._getState(),r=n.anchor.colEnd-n.anchor.colStart+1;if(e<0||e>r-1)throw new Error(`Invalid range: '${e}'`);const o=n.byOffset,i=new Map(o);t&&Object.keys(t).length>0?i.set(e,t):i.delete(e);const a=o.get(e)?.hiddenButton===!0?1:0,l=t?.hiddenButton===!0?1:0;return this._updateState({byOffset:i,hiddenCount:Math.min(r,Math.max(0,n.hiddenCount+l-a))},{description:"Set Filter Criteria"}),this.reapply()}getShowFilterButton(){const e=this._getState(),t=e.anchor,n=t.colEnd-t.colStart+1;return e.hiddenCount<n}setShowFilterButton(e){const t=this.getAnchorCoords(),n=t.colEnd-t.colStart+1;let r=Array(n);const o=this._getState().byOffset,i=Ya(o);for(let l=0;i&&l<i.length;l++){const c={...i[l]};r[c.offset]=c,e?delete c.hiddenButton:c.hiddenButton=!0}if(!e)for(let l=0;l<r.length;l++)r[l]||(r[l]={hiddenButton:!0});const a=new Map;for(let l=0;l<r.length;l++){const c=r[l];a.set(l,c)}return this._updateState({byOffset:a,hiddenCount:e?a.size:0},{description:(e?"Hide":"Show")+" Filter Buttons"}),this._processUpdate?.(),this}_processStateChange(e,t,n){super._processStateChange(e,t,n),this._processUpdate?.()}_processContainerShift(e){if(e.after&&e.orientation===exports.w.Orientation.Column){let t=e.intersect.colStart-e.before.colStart,n=e.amount;t<=0&&(n-=t,t=0);const r=this._getState().byOffset,o=new Map(r);if(r.forEach((i,a)=>{i&&Object.keys(i).length!==0&&(a>=t&&o.delete(a),a>t&&o.set(a+n,i))}),n>0&&this._getState().hiddenCount>0)for(let i=t;i<t+n;i++)o.set(i,{hiddenButton:!0});this._updateState({byOffset:o,hiddenCount:Qa(o),sort:null},{description:"Update Fields"})}return super._processContainerShift(e)}reapply(){const e=this._getState(),t=Ya(e.byOffset);return this._apply?.(t),this}clear(){return this._updateState({byOffset:new Map,hiddenCount:0,sort:null},{description:"Set Filter Criteria"}),this.reapply()}_fromJSON(e){const t=e??{},n={byOffset:new Map,hiddenCount:0};t.fields&&(_d(t.fields,n.byOffset),n.hiddenCount=Qa(n.byOffset)),t.sort,this._updateState(n,{description:"Load"})}toJSON(){const e={},t=this._getState();t.anchor&&(e.ref=Cn(t.anchor,this._options.maxRangeCoords));const n=Ya(t.byOffset);return n.length>0&&(e.fields=n),t.sort,Object.keys(e).length===0?null:e}}const Jl="A table must have a least one row for the data.",Sd="Table1",Is=Object.freeze({showRowStripes:!0,showColumnStripes:!1,showFirstColumn:!1,showLastColumn:!1}),wd=(s,e,t)=>{if(s.length!==e.length)return console.warn("make columns the same length"),!1;const n=new Set;for(let l=0;l<e.length;l++){const c=e[l]?.name;c&&n.add(c.toLocaleLowerCase())}for(let l=0;t&&l<t.length;l++){const c=t[l]?.name;c&&n.add(c.toLocaleLowerCase())}const r=(l,c="")=>{if(!l)return!1;const h=l.toLocaleLowerCase();return h===c||!n.has(h)};let o=1;const i=(l,c,h,u,d=1e3)=>{if(u(l,h=(h??"").trim().toLocaleLowerCase()))return l;for(;o<d;)try{const g=c+ ++o;if(u(g,h))return g}catch{}throw new Error(`Unable to find valid name for '${c}'.`)};let a=0;for(let l=0;l<s.length;l++){const c=s[l]?.name;if(c&&c===e[l]?.name)continue;const h=i(c,s[l]?.name||"Column",e[l]?.name,r);n.add(h.toLocaleLowerCase()),e[l]?.name!==h&&(s[l].name=h,a++)}return a>0};class Nw{constructor(e,t,n,r){this._name=e,this._filter=t,this._sort=n,this._offset=r}getName(){return this._name}getField(){return this._filter?this._filter.getFieldAt(this._offset)??null:null}setField(e){return this._filter?(this._filter.setFieldAt(this._offset,e),this):this}getSortField(){return this._sort?this._sort.getFieldAt(this._offset):null}setSortField(e){return this._sort?(this._sort.setFieldAt(this._offset,e),this):this}reapply(){return this._filter?.reapply(),this}clear(){return this._filter?.setFieldAt(this._offset,null),this._sort?.setFieldAt(this._offset,null),this}hasHiddenButton(){return this._filter?.getFieldAt(this._offset)?.hiddenButton??!1}}class kw extends Cm{constructor(e,t,n,r){super({...r,type:"namedTable"}),this._names=e,this._sheet=t,this._table=n;const o=this;this._table.addListeners({onDelete:()=>{o._options.deleteFromContainer?o._options.deleteFromContainer?.():o._delete()},onAnyChange:()=>{o._emitter.notify("onAnyChange")},onAnchorCoordsChange:()=>{o._emitter.notify("onAnyChange")}},{transactional:!0})}async select(e){return await this._table.select(e),this}getRanges(){return this._names.getRanges(this._table.getUsedRange())}getScope(){return null}getType(){return"table"}getName(){return this._table.getName()}getValue(){return this._table}}class lf extends Xi{constructor(e){if(super({...e,createDescription:"Insert Table"}),this._isUpdatingHeader=!1,this._colHeadersSizeUnlistener=null,this._rowHeadersSizeUnlistener=null,this._visibleRange=null,this._isHeaderVisible=!0,this._isTotalVisible=!0,this._isFirstColumnVisible=!0,this._isLastColumnVisible=!0,this._range=null,!e.json)throw new Error("json is required");if(!e.json.ref)throw new Error("json.ref is required");const t=this;this._styles=e.styles??e.sheet?.getStyles()??new Jr,this._names=e.names,this._sheet=e.sheet,this._processTableUpdate=e.processTableUpdate,this._setNameOnContainer=e.setNameOnContainer,this._options={...e},this._styleCache=null,this._stylePropsCache=null,this._stylesRemoveListener=this._styles.addListeners({onTableStylesChange(){t._styleCache=null,t._stylePropsCache=null,t._getEmitter().notify("onStyleChange"),t._getEmitter().notify("onAnyChange")}});const n={...e?.json};if(e.sheet){const r=e.sheet;if(this._autoExpandRemoveListener=r.getEntireRange().addListener(a=>{if(a.trigger!=="setCells"||a.isUndo)return;const l=t.getAnchorCoords();if(!l)return;let c=a.getSource().getCoords();Array.isArray(c)&&(c=c[0]);let h=null;if(c.rowStart>=l.rowStart&&c.rowEnd<=l.rowEnd&&c.colStart>=l.colStart&&c.colStart<=l.colEnd+1&&c.colEnd>l.colEnd){const u={...c,colStart:l.colEnd+1};if(r.getRange(u).isContentful()){const d={...u,rowStart:l.rowStart,rowEnd:u.rowStart-1};if(d.rowEnd-d.rowStart<0||!r.getRange(d).isContentful()){const g={...u,rowStart:u.rowEnd+1,rowEnd:l.rowEnd};(g.rowEnd-g.rowStart<0||!r.getRange(g).isContentful())&&(h={...l,colEnd:c.colEnd})}}}else if(!t.getShowTotals()&&c.colStart>=l.colStart&&c.colEnd<=l.colEnd&&c.rowStart>=l.rowStart&&c.rowStart<=l.rowEnd+1&&c.rowEnd>l.rowEnd){const u={...c,rowStart:l.rowEnd+1};if(r.getRange(u).isContentful()){const d={...u,colStart:l.colStart,colEnd:u.colStart-1};if(d.colEnd-d.colStart<0||!r.getRange(d).isContentful()){const g={...u,colStart:u.colEnd+1,colEnd:l.colEnd};(g.colEnd-g.colStart<0||!r.getRange(g).isContentful())&&(h={...l,rowEnd:c.rowEnd})}}}if(h&&r.getRange(h).getMerges().length>0&&(h=null),h&&r.getTables().search({address:h}).length!==1&&(h=null),h){const u=t._beginCommit("Table Auto Expansion");try{t.resize(h),u.commit({viewAfter:null})}catch(d){u.rollback(),console.warn("Unable to AutoExpand"),console.warn(d)}}},{transactional:!1,ignoreShifts:!0}),this._headerValueListener=()=>{if(this._isUpdatingHeader)return;const a=this._columnsFromSheet();a&&this._updateColumns(a.columns,!1,a.forceUpdate,null)},e.readSheetHeader){const a=this._columnsFromSheet();n.columns=a.columns}const o=()=>{const a=this.getAnchorCoords();let l=0,c=0;if(a&&(l=r.getColumnHeaders().findVisibleIndex(a.colEnd).min,c=r.getRowHeaders().findVisibleIndex(a.rowEnd).min),a&&(l<a.colEnd||c<a.rowEnd)){const h=r.getColumnHeaders(),u=r.getRowHeaders(),d=h.findVisibleIndex(a.colStart).max,g=u.findVisibleIndex(a.rowStart).max;this._visibleRange={colStart:d,colEnd:l,rowStart:g,rowEnd:c},this._isHeaderVisible=!u.at(a.rowStart).isHidden(),this._isTotalVisible=!u.at(a.rowEnd).isHidden(),this._isFirstColumnVisible=!h.at(a.colStart).isHidden(),this._isLastColumnVisible=!h.at(a.colEnd).isHidden()}else this._visibleRange=null,this._isHeaderVisible=!0,this._isTotalVisible=!0,this._isFirstColumnVisible=!0,this._isLastColumnVisible=!0},i={onSizesChange:()=>{o()}};this._colHeadersSizeUnlistener=r.getColumnHeaders().addListeners(i),this._rowHeadersSizeUnlistener=r.getRowHeaders().addListeners(i),o()}this._fromJSON(n),this._names&&(this._namedItem=this._createNamed(),this._namedItem&&this._names.add(this._namedItem))}getSnapshot(e){const t=this.toJSON(),n=this.getAnchorCoords(),r=this.getName(),o={...t};delete o.ref;const i=this,a=Object.freeze({...e});let l=!1;return{async copyTo(c,h){const u=c.tables,d=c.range;({...a,...h}).isCut&&!l&&(i.delete(),l=!0);const g={colStart:d.colStart,rowStart:d.rowStart,colEnd:n.colEnd-n.colStart+d.colStart,rowEnd:n.rowEnd-n.rowStart+d.rowStart};return u.add(g,{json:o,isLoad:!0,hasHeader:!0,styleName:o.styleOptions?.name??null}),g},getCoords:()=>n,getSource:()=>i,getName:()=>r,getMarkOptions:()=>a,isISnapshot:!0}}getAnchorType(){return exports.IAnchored.Type.TwoCell}getStyle(){if(this._styleCache)return this._styleCache;const e=this._getState();return e?(this._styleCache=this._styles.getTableStyle(e.styleOptions.name)??this._styles.getDefaultTableStyle(),this._styleCache):this._styles.getTableStyle(null)}addRows(e,t=1){const n={...this._getState().anchor};return n.rowEnd+=t,this._modifyTable({anchor:n},"Add Table Row"+(t>1?"s":"")),this}deleteRowsAt(e,t=1){let n={...this._getState().anchor};return n.rowEnd-=t,n.rowEnd<n.rowStart&&(n=null),this._modifyTable({anchor:n},"Delete Table Row"+(t>1?"s":"")),this}addColumn(e,t){const n=this._getState(),r={...n.anchor};r.colEnd+=1;const o=[],i={name:`${t??n.columns[e-1]?.name??`Column${e+1}`}3`};o.push(i);const a=[...n.columns.slice(0,e),...o,...n.columns.slice(e)];return this._modifyTable({anchor:r,columns:a},"Add Table Column"),i}getColumns(){return this._getState()?.columns}convertToRange(e=Number.MAX_SAFE_INTEGER){let t=this._beginCommit("Convert to Range");try{if(this._sheet){const n=this.getAnchorCoords(),r=(n.colEnd-n.colStart+1)*(n.rowEnd-n.rowStart+1);if(r>e)throw new Error(`There are ${r} and there is a limit of ${e}.`);const o=this._sheet.getRange(n),i=o.startIncrementalUpdates({orientation:exports.w.Orientation.Column});o.forEach((a,l)=>{const c=l.getCoords(),h=l.getCell();i.pushAt(c.rowIndex,c.colIndex,{style:h.getStyle(!1)})},{includeEmpty:!0,orientation:exports.w.Orientation.Column}),i.apply()}this.delete()}catch{t.rollback(),t=null}return t&&t.commit(),this._sheet.getRange(this._getState()?.anchor)}resize(e,t="Resize Table"){let n=this._sheet.getRange(e).getCoords();const r=this._getState().anchor;if(r.rowStart!==n.rowStart||n.colEnd<r.colStart||n.colStart>r.colEnd)throw new Error("The top of the table must not change and the new table location must overlap with the original table.");const o=this._beginCommit(t);try{n=this._options.setContainerCoords(e),k.isEqualRanges(n,r)||this._modifyTable({anchor:n}),o.commit()}catch(i){throw console.warn(i),o.rollback(),i}return this._sheet.getRange(n)}getName(){return this._getState()?.name}setName(e){const t=this._beginCommit(`Set Table Name '${e}'`);try{this._modifyTable({name:e}),t.commit()}catch(n){throw t.rollback(),n}return this}getDescription(){return this._getState()?.description}setDescription(e){return this._modifyTable({description:e})}select(e){return this.getUsedRange().select(e)}getRange(){return this._range?this._range:this._getState()?this._range=this._sheet.getRange(this._getState().anchor):Pn}_processRestoreOrRevert(e,t,n){this._styleCache=null,super._processRestoreOrRevert(e,t,n)}_processAnchorCoords(){this._range=null,super._processAnchorCoords()}getUsedRange(){const e=this._getUsedCoords();return e?this._sheet.getRange(e):Pn}_getUsedCoords(){const e=this._getState(),t=e.headerRowCount,n=e.totalsRowCount,r=e.anchor;if(!r)return null;const o={...r,rowStart:r.rowStart+t,rowEnd:r.rowEnd-n};return o.rowEnd<o.rowStart||o.colEnd<o.colStart?null:o}getHeaderRange(){const e=this._getHeaderCoords();return e?this._sheet.getRange(e):Pn}_getHeaderCoords(){const e=this._getState(),t=e.headerRowCount;if(t<1)return null;const n=e.anchor;return n?{...n,rowEnd:n.rowStart+t-1}:null}getTotalRange(){const e=this._getTotalCoords();return e?this._sheet.getRange(e):Pn}_getTotalCoords(){const e=this._getState(),t=e.totalsRowCount;if(t<1)return null;const n=e.anchor;return n?{...n,rowStart:n.rowEnd-t+1}:null}getStyleOptions(){return this.isClosed()?Is:this._getState()?.styleOptions}updateStyleOptions(e,t="Update Style Info"){const n=this.getStyleOptions(),r=e?{...n,...e}:Is;return this._modifyTable({styleOptions:r},t),this._styleCache=null,this._getEmitter().notify("onStyleChange"),this}getStyleAt(e){let t=this._stylePropsCache;return t||(t=this.getStyle().getRanged(this),this._stylePropsCache=t),Vr(this._styles,t,k.cellToRange(e))}getShowTotals(){return this._getState()?.totalsRowCount>0}setShowTotals(e){return this._modifyTable({totalsRowCount:e?1:0},"Toggle Show Totals")}getShowHeaders(){return this._getState()?.headerRowCount>0}setShowHeaders(e){return this._modifyTable({headerRowCount:e?1:0},"Toggle Show Headers")}getShowFilterButton(){const e=this.getFilter();return!!e&&e.getShowFilterButton()}setShowFilterButton(e){const t=this.getFilter();return t?(t.setShowFilterButton(e),this):this}_applyFilterAndSort(){console.log("apply Filter",this.getFilter(),this.getSort()),this._processTableUpdate?.(),this._getEmitter().notify("onAnyChange")}_processUpdate(){this._processTableUpdate?.(),this._getEmitter().notify("onAnyChange")}_createFilter(e){const t=this;return new af({initialAnchor:this._getUsedCoords(),maxRangeCoords:this._options.maxRangeCoords,json:e,transactions:this._getTransactions(),setContainerShiftCallback(n){t._filterShiftCallback=n},setFilterCoordsCallback(n){t._filterCoordsCallback=n},deleteFromContainer:n=>{this._updateState({filter:null},{description:n?.description??"Delete Filter"}),t._processUpdate?.()},apply:n=>{t._applyFilterAndSort()},processUpdate:()=>{t._processUpdate?.()},isProtected:()=>t.isProtected()})}insertFilter(){let e=this.getFilter();return e||(e=this._createFilter(),this._updateState({filter:e},{description:"Insert Filter"}),e)}getFilter(){return this._getState()?.filter??null}_createSort(e){const t=this;return new Tw({initialAnchor:this._getUsedCoords(),maxRangeCoords:this._options.maxRangeCoords,json:e,transactions:this._getTransactions(),deleteFromContainer:n=>{this._updateState({sort:null},{description:n?.description??"Delete Sort"}),t._processUpdate?.()},apply:n=>{t._applyFilterAndSort()},processUpdate:()=>{t._processUpdate?.()},isProtected:()=>t.isProtected()})}insertSort(){let e=this.getSort();return e||(e=this._createSort(),this._updateState({sort:e},{description:"Insert Sort"}),e)}getSort(){return this._getState()?.sort??null}getColumnFilter(e){const t=this.getFilter();if(!t)return null;const n=this.getSort();let r=null;return r=this._getState()?.columns[e],r===null?null:new Nw(r.name,t,n,e)}getVisibleRefRangeCoords(){return this._visibleRange?this._visibleRange:this.getAnchorCoords()}getVisibleCellCoords(e){return e&&this._visibleRange?{colIndex:Math.min(this._visibleRange.colEnd,Math.max(this._visibleRange.colStart,this._sheet.getColumnHeaders().findVisibleIndex(e.colIndex).min)),rowIndex:Math.min(this._visibleRange.rowEnd,Math.max(this._visibleRange.rowStart,this._sheet.getRowHeaders().findVisibleIndex(e.rowIndex).min))}:e}isHeaderVisible(){return this._isHeaderVisible}isTotalVisible(){return this._isTotalVisible}isFirstColumnVisible(){return this._isFirstColumnVisible}isLastColumnVisible(){return this._isLastColumnVisible}_columnsFromSheet(){const e=this._getHeaderCoords();if(!e||!this._sheet){const n=this.getAnchorCoords();return{columns:n?Array(n.colEnd-n.colStart+1).fill(null):[],forceUpdate:!0}}const t={columns:[],forceUpdate:!1};return this._sheet.getRange({...e,rowEnd:e.rowStart}).forEach((n,r)=>{const o=r.getCell();t.columns.push({name:o.toText()}),t.forceUpdate=t.forceUpdate||o.getType()!==U.String},{includeEmpty:!0}),t}_updateColumns(e,t,n=!1,r){if(this._isUpdatingHeader)return;const o=this._getHeaderCoords(),i=this._getUsedCoords(),a=[];if(i){const d=i.colEnd-i.colStart+1;for(let g=0;g<d;g++){const m=e[g];a.push({...m})}}let l=!1;const c=this._getState().columns;if(l=t?((d,g)=>{const m=new Set,f=S=>!!S&&!m.has(S.toLocaleLowerCase()),_=(S,C,y,b)=>b(S)?S:C+(y+1);let p=0;for(let S=0;S<d.length;S++){const C=_(d[S]?.name||g[S]?.name,d[S]?.name||"Column",p,f);m.add(C.toLocaleLowerCase()),d[S]?.name!==C&&(d[S].name=C,p++)}return p>0})(a,c):wd(a,c,r),!(n||c.length!==a.length||l))return;const h="Update Columns";this._isUpdatingHeader=!0;let u=this._beginCommit(h);try{if(this._updateState({columns:a},{description:h}),this._sheet&&o){const d=this._sheet.getEntireRange().startIncrementalUpdates({orientation:exports.w.Orientation.Row});for(let g=0;g<a.length;g++){const m=a[g].name;d.pushAt(o.rowStart,o.colStart+g,m)}d.apply({textParser:!1})}}catch{u.rollback()}return u&&u.commit(),this._isUpdatingHeader=!1,a}_processDelete(){this._getState().headerRemoveListener?.(),this._updateState({headerRemoveListener:null}),super._processDelete()}_processFilterUpdate(){const e=this._getUsedCoords();console.log("process on Filter and Sort dataRange",e)}_processContainerShift(e){if(e.isSplit)throw new Error("We can not partially insert or remove cells as this would split a table.");const t=this._getState();if(e.after&&e.after.rowStart+t.headerRowCount>=e.after.rowEnd+1)throw new Error(Jl);const n=e.orientation===exports.w.Orientation.Column;if(e.amount<0&&e.after&&!n){const o=this._getHeaderCoords();if(o&&e.intersect.rowStart<=o.rowEnd&&e.intersect.rowEnd>=o.rowStart)throw new Error("We can not remove rows that contain table headers. Remove the table header.")}const r=super._processContainerShift(e);if(n){let o=e.amount,i=e.intersect.colStart-e.before.colStart;if(i<=0&&o>0)return;i<0&&(o-=i,i=0);const a=this._getState()?.columns;let l=[...a],c=[],h=[];if(o>0){l.splice(i,0,...Array(o).fill(null)),c=[...l];const u=new Set;for(let _=0;_<a.length;_++)u.add(a[_]?.name?.toLowerCase().trim());const d=a[i-1],g=d?.name?.match(/\d+$/);let m=null,f=0;g&&(m=g.input.substring(0,g.index),f=parseInt(g[0]));for(let _=0;_<o;_++){let p={...d};c[i+_]=p;const S=m+(f+_+1);S&&!u.has(S.toLowerCase().trim())&&(p.name=S)}wd(c,l,null)}else c=l,h=c.splice(i,-o);this._updateState({columns:c},{description:"Process Columns"}),this._updateColumns(c,!1,!0,h)}else e.after||this._updateState({columns:[]},{description:"Process Columns"});return e.after||this._delete(),this._filterShiftCallback&&this._filterShiftCallback({...e,after:this._getUsedCoords()}),r}_modifyTable(e,t="Modify Table"){if(this.isClosed())throw new Error("Table has been closed. No further operations are allowed.");const n=this._getState(),r=n.anchor,o=n.headerRowCount,i=this._getHeaderCoords();let a=this._beginCommit(t);try{if(this._updateState(e),e.name!==void 0){if(!e.name)throw new Error("Table must have a name.");this._setNameOnContainer?.(e.name)}let l=e.anchor??null;if((e.anchor!==void 0||e.headerRowCount!==void 0||e.totalsRowCount!==void 0)&&e.headerRowCount!==void 0&&o!==e.headerRowCount)if(e.headerRowCount>o){const c=r.rowStart-(e.headerRowCount-o);this._sheet&&(c<this._options.maxRangeCoords.rowStart||this._sheet.getRange({...r,rowStart:c,rowEnd:r.rowStart-1}).isContentful())?(this._sheet.getRange({...r,rowStart:r.rowStart+e.headerRowCount,rowEnd:r.rowStart+e.headerRowCount}).insert(exports.w.Orientation.Row),l={...r,rowEnd:r.rowEnd+(e.headerRowCount-o)}):l={...r,rowStart:r.rowStart+(o-e.headerRowCount)}}else i&&this._sheet&&this._sheet.doBatch(()=>{this._sheet.getRange(i).clear()},{}),l={...r,rowStart:r.rowStart+(o-(e.headerRowCount??o))};if(l){let c=n.columns;const h=e.headerRowCount!==void 0&&e.headerRowCount!==n.headerRowCount||e.totalsRowCount!==void 0&&e.totalsRowCount!==n.totalsRowCount,u=l.colStart!==r.colStart||l.colEnd!==r.colEnd;let d=[];if(u){const g=[...n.columns];l.colEnd>r.colEnd?g.splice(r.colEnd+1,0,...Array(l.colEnd-r.colEnd).fill(null)):l.colEnd<r.colEnd&&(d=g.splice(l.colEnd-1,r.colEnd-l.colEnd)),l.colStart<r.colStart?g.splice(0,0,...Array(r.colStart-l.colStart).fill(null)):l.colStart>r.colStart&&(d=d.concat(g.splice(0,l.colStart-r.colStart))),c=g}if(this._options.setContainerCoords?.(l),this._updateState({anchor:l,columns:c},{description:t}),!this._getUsedCoords())throw new Error(Jl);if(u||h){const g=h?{columns:c,forceUpdate:!0}:this._columnsFromSheet();g&&(this._updateColumns(g.columns,!1,g.forceUpdate,d),this._processHeaderListener())}this._filterCoordsCallback?.(l)}e.styleOptions!==void 0&&(this._styleCache=null),this._getEmitter().notify("onAnyChange"),a.commit()}catch(l){throw a.rollback(),l}return this}addListeners(e,t){return this._emitter.addListeners(e,t)}_processStateChange(e,t,n){super._processStateChange(e,t,n),this._styleCache=null,this._stylePropsCache=null,this._processTableUpdate?.(),this._getEmitter().notify("onAnyChange")}_processHeaderListener(){if(this._getState().headerRemoveListener?.(),this._sheet){let t=this._getHeaderCoords();if(!t){const r=this._getUsedCoords();t={...r,rowEnd:r.rowStart}}const n=this._sheet.getRange(t).addListener(this._headerValueListener,{transactional:!0});this._updateState({headerRemoveListener:n})}}toJSON(){const e={},t=this._getState();if(!t)return null;if(t.name&&(e.name=t.name),t.anchor&&(e.ref=Cn(t.anchor,this._options.maxRangeCoords)),t.description&&(e.description=t.description),t.headerRowCount!==1&&(e.headerRowCount=t.headerRowCount),t.totalsRowCount!==0&&(e.totalsRowCount=t.totalsRowCount),t.columns&&(e.columns=[...t.columns]),t.styleOptions){const n=N.diffValues(t.styleOptions,{...Is,name:null});n&&(e.styleOptions=n)}if(t.filter){const n=t.filter.toJSON();n&&(e.filter=n,delete e.filter.ref)}return e}_createNamed(){return this._sheet?.getName()&&this._names?new kw(this._names,this._sheet,this,{transactions:this._getTransactions(),json:{name:this.getName()}}):null}_fromJSON(e){const t=e??{},n={headerRowCount:1,totalsRowCount:0};var r;if(t.name&&(n.name=t.name),t.ref&&(t.ref=(r=t.ref)&&typeof r=="string"?Mt(r):r),this._names){const a=this._names.findValidName(n.name??Sd);n.name!==a&&(n.name=a)}n.name||(n.name=Sd),t.description&&(n.description=t.description),t.headerRowCount!==void 0&&(n.headerRowCount=t.headerRowCount),t.totalsRowCount!==void 0&&(n.totalsRowCount=t.totalsRowCount),n.columns=t.columns??N.EmptyArray,n.styleOptions={...Is,...t.styleOptions};const o="Insert Table";this._updateState(n,{description:o});const i=this._columnsFromSheet();i&&(n.columns=this._updateColumns(i.columns,!0,i.forceUpdate,null),delete n.columns),t.sort&&(n.sort=this._createSort(t.sort)),t.filter&&(n.filter=this._createFilter(t.filter)),this._modifyTable(n,o),this._processHeaderListener()}close(){super.close(),this.isClosed()||(this._autoExpandRemoveListener?.(),this._getState()?.headerRemoveListener?.(),this._updateState({headerRemoveListener:null},{description:"Close Table"}),this._stylesRemoveListener?.(),this._colHeadersSizeUnlistener?.(),this._rowHeadersSizeUnlistener?.())}get isITable(){return!0}}let pt=null;const ho="TableStyleMedium2",Pt=(s,e,t)=>{if(!s.border)return s;let n=((o,i,a)=>{if(!o)return o;let l=null;return(o.top||o.horizontal)&&(i.rowIndex!==a.rowStart||i.colIndex<a.colStart||i.colIndex>a.colEnd)&&(l=l??{...o},delete l.top,o.horizontal&&(l.top=o.horizontal)),(o.bottom||o.horizontal)&&(i.rowIndex!==a.rowEnd||i.colIndex<a.colStart||i.colIndex>a.colEnd)&&(l=l??{...o},delete l.bottom,o.horizontal&&(l.bottom=o.horizontal)),(o.left||o.vertical)&&(i.colIndex!==a.colStart||i.rowIndex<a.rowStart||i.rowIndex>a.rowEnd)&&(l=l??{...o},delete l.left,o.vertical&&(l.left=o.vertical)),(o.right||o.vertical)&&(i.colIndex!==a.colEnd||i.rowIndex<a.rowStart||i.rowIndex>a.rowEnd)&&(l=l??{...o},delete l.right,o.vertical&&(l.right=o.vertical)),o.horizontal&&(l=l??{...o},delete l.horizontal),o.vertical&&(l=l??{...o},delete l.vertical),l??o})(s.border,e,t),r=s;return n!==s.border&&(r={...s},Object.keys(n).length>0?r.border=n:delete r.border),r};class Ow{constructor(e,t,n){this._table=e,this._styles=t,this._properties=n}_resolveProperties(e){const t={name:e.name},n=this._styles,r=Object.values(exports.ITableStyle.ElementType),o=r.length;for(let i=0;i<o;i++){const a=r[i],l=e[a];if(!l||!N.isObject(l))continue;const c=exports.it.resolveTypedUpdates(Object.freeze(l),We,n);t[a]=c}return Object.freeze(t)}getCoords(){return this._table.getAnchorCoords()}getPropertiesAt(e,t){const n=this._table,r=this._styles,o=this._properties;Za.rowIndex=e,Za.colIndex=t;const i=n.getVisibleCellCoords(Za),a=n.getVisibleRefRangeCoords();if(!a)return null;const l=Math.max(0,a.colEnd-a.colStart)+1,c=Math.max(0,a.rowEnd-a.rowStart)+1,h=Math.max(0,i.rowIndex-a.rowStart),u=Math.max(0,i.colIndex-a.colStart),d={rowIndex:h,colIndex:u},g=n.getStyleOptions();let m={},f=!1,_=0;n.isHeaderVisible()&&(_=n.getShowHeaders()?1:0,f=_>h);let p=!1,S=0;n.isTotalVisible()&&(S=n.getShowTotals()?1:0,p=c-S<=h);let C=u===l-1&&g.showLastColumn;n.isLastColumnVisible()||(C=!1);let y=u===0&&g.showFirstColumn;n.isFirstColumnVisible()||(y=!1);const b=!f&&!p;if(o.wholeTable&&(m=o.wholeTable,m.border&&(m=Pt(m,d,{rowStart:0,rowEnd:c-1,colStart:0,colEnd:l-1}))),b&&g.showColumnStripes){const w=o.firstColumnStripe?.size??1,E=o.secondColumnStripe?.size??1;let I=u%(w+E);const x=I<w;x||(I-=w);let v=x?o.firstColumnStripe:o.secondColumnStripe;if(v){const R={rowIndex:h,colIndex:I},A={rowStart:_,rowEnd:c-S-1,colStart:0,colEnd:Math.min(l-u,x?w:E)};x&&I===0&&u>0&&v.border?.left&&o.secondColumnStripe?.border.right&&(v={...v},v.border={...v.border},delete v.border.left),x&&I===w-1&&u<l-1&&v.border?.right&&o.secondColumnStripe?.border.left&&(v={...v},v.border={...v.border},delete v.border.right);const M=v.border?Pt(v,R,A):v;m=exports.it.resolveTypedUpdates(M,We,r,m)}}if(b&&g.showRowStripes){const w=_,E=o.firstRowStripe?.size??1,I=o.secondRowStripe?.size??1;let x=(h-w)%(E+I);const v=x<E;v||(x-=E);let R=v?o.firstRowStripe:o.secondRowStripe;if(R){const A={colIndex:u,rowIndex:x},M={colStart:0,colEnd:l-1,rowStart:0,rowEnd:Math.min(c-h,v?E:I)};v&&x===0&&h>w&&R.border?.top&&o.secondRowStripe?.border.bottom&&(R={...R},R.border={...R.border},delete R.border.top),v&&x===E-1&&h<c-1&&R.border?.bottom&&o.secondRowStripe?.border.top&&(R={...R},R.border={...R.border},delete R.border.bottom);const T=R.border?Pt(R,A,M):R;m=exports.it.resolveTypedUpdates(T,We,r,m)}}if(C&&o.lastColumn){let w=o.lastColumn;w.border&&(w=Pt(w,d,{rowStart:0,rowEnd:c-1,colStart:l-1,colEnd:l-1})),m=exports.it.resolveTypedUpdates(w,We,r,m)}if(y&&o.firstColumn){let w=o.firstColumn;w.border&&(w=Pt(w,d,{rowStart:0,rowEnd:c-1,colStart:0,colEnd:0})),m=exports.it.resolveTypedUpdates(w,We,r,m)}if(f&&o.headerRow){let w=o.headerRow;w.border&&(w=Pt(w,d,{rowStart:0,rowEnd:_-1,colStart:0,colEnd:l-1})),m=exports.it.resolveTypedUpdates(w,We,r,m)}if(p&&o.totalRow){let w=o.totalRow;w.border&&(w=Pt(w,d,{rowStart:c-S,rowEnd:c-1,colStart:0,colEnd:l-1})),m=exports.it.resolveTypedUpdates(w,We,r,m)}if(f&&y&&o.firstHeaderCell){let w=o.firstHeaderCell;w.border&&(w=Pt(w,d,{rowStart:0,rowEnd:_-1,colStart:0,colEnd:0})),m=exports.it.resolveTypedUpdates(w,We,r,m)}if(f&&C&&o.lastHeaderCell){let w=o.lastHeaderCell;w.border&&(w=Pt(w,d,{rowStart:0,rowEnd:_-1,colStart:l-1,colEnd:l-1})),m=exports.it.resolveTypedUpdates(w,We,r,m)}if(p&&y&&o.firstTotalCell){let w=o.firstTotalCell;w.border&&(w=Pt(w,d,{rowStart:c-S,rowEnd:c-1,colStart:0,colEnd:0})),m=exports.it.resolveTypedUpdates(w,We,r,m)}if(p&&C&&o.lastTotalCell){let w=o.lastTotalCell;w.border&&(w=Pt(w,d,{rowStart:c-S,rowEnd:c-1,colStart:l-1,colEnd:l-1})),m=exports.it.resolveTypedUpdates(w,We,r,m)}return f&&o.headerRow&&n.getColumnFilter(u)&&!n.getColumnFilter(u).hasHiddenButton()&&(m.insets={right:15}),m}}class yd{constructor(e,t,n,r){this._styles=e,this._isBuiltIn=n,this._doDelete=r,this._properties=N.deepFreeze(this._resolveProperties(t)),this.isShownInTableStyles()}_resolveProperties(e){const t={name:e.name};e.table!==void 0&&(t.table=e.table),e.pivot!==void 0&&(t.pivot=e.pivot);const n=this._styles,r=Object.values(exports.ITableStyle.ElementType),o=r.length;for(let i=0;i<o;i++){const a=r[i],l=e[a];if(!l||!N.isObject(l))continue;const c=exports.it.resolveTypedUpdates(Object.freeze(l),We,n);t[a]=c}return Object.freeze(t)}delete(){if(!this._doDelete)throw new Error("Not able to delete builtin style.");this._doDelete(this._properties.name)}getRanged(e){return new Ow(e,this._styles,this._properties)}getProperties(){return this._properties}getName(){return this._properties.name}isShownInTableStyles(){return this._properties.table!==!1}isShownInPivotStyles(){return this._properties.pivot??!1}isBuiltIn(){return this._isBuiltIn}toJSON(){const e=N.cloneObject(this._properties);return e.name=this._properties.name,e}get isITableStyle(){return!0}}const Za={rowIndex:0,colIndex:0};class Bw extends Je{constructor(e,t){super(e,k.EmptyRange,t)}isEmpty(){return this._p===null}getCoords(){return this._r}cloneWithUpdate(e){if(e===void 0)return this;const t=this._c,n=this._r,r=exports.it.resolveTypedUpdates(e,We,t,this._p);return new Je(t,n,r)}_createShifted(e){return new Je(this._c,e,this._p)}getShifted(e){return e.after?{...e.after,value:this._createShifted(k.sanitizeRange(e.after))}:null}getSplit(e,t){const n=this._c,r=this._p;return[new Je(n,e[0],r),new Je(n,e[1],r)]}getMerged(e,t,n){const r=this._p,o=e._p;if(r&&!o||o&&!r||!r&&!o)return;let i=Object.keys(r),a=Object.keys(o);if(r.named===exports.IStyle.BuiltInName.Normal&&(i=i.filter(c=>c.toLowerCase()!==exports.IStyle.BuiltInName.Normal)),o.named===exports.IStyle.BuiltInName.Normal&&(a=a.filter(c=>c.toLowerCase()!==exports.IStyle.BuiltInName.Normal)),i.length!==a.length)return;for(let c=0;c<i.length;c++){const h=i[c],u=r[h],d=o[h];if(!N.deepEqual(u,d))return}const l=this._c;return new Je(l,t,this._p)}getPropertiesAt(e,t){return this._p}toJSON(){return N.toSafeJSON(this._p)}}class Cd{constructor(e,t,n,r=null){this._name=t.name,this._properties=t,this._rangeStyle=new Bw(e,t.style),this._doDelete=n,this._builtInID=r}getRanged(){return this._rangeStyle}getName(){return this._name}isHidden(){return this._properties.hidden??!1}getILevel(){return this._properties.iLevel??null}getBuiltInID(){return this._builtInID}delete(){this._doDelete?.(this)}toJSON(){return this._properties?N.toSafeJSON(this._properties):null}get isINamed(){return!0}}let Dw=class{constructor(s,e,t,n,r){this._state=s,this._normalJSON=e??{},this._toJSONInternal=t,this._fromJSONInternal=n,this._onLastEnd=r,this._state.openScopes.add(this),this._isClosed=!1,this._state.byJSONs.set(Hs(this._normalJSON),0),this._state.byIds.set(0,this._normalJSON)}endPersist(){if(!this._state.openScopes.delete(this))throw new Error("PersistScope is closed.");this._isClosed=!0,this._state.openScopes.size===0&&this._onLastEnd()}getElementID(s){if(this._isClosed)throw new Error("PersistScope is closed.");const e=Hs(s=s??{});let t=this._state.byJSONs.get(e);return t!==void 0||(t=this._state.byJSONs.size,this._state.byJSONs.set(e,t),this._state.byIds.set(t,s)),t}getElementJSON(s){if(this._isClosed)throw new Error("PersistScope is closed.");return this._state.byIds.get(s)??null}fromJSON(s){if(this._isClosed)throw new Error("PersistScope is closed.");const e=JSON.parse(JSON.stringify(s||{}));this._fromJSONInternal(e);const t=e.direct;if(t)for(let n=0;n<t.length;n++){const r=n,o=t[n],i=Hs(o);this._state.byIds.set(r,o),this._state.byJSONs.set(i,r)}}toJSON(){if(this._isClosed)throw new Error("PersistScope is closed.");const s=[];return this._state.byIds.forEach((e,t)=>{s[t]=e}),s.length===1&&s.splice(0,1),this._toJSONInternal(s)}};class Jr{constructor(e=null,t=null,n=11){this._emitter=null,this._normalRanged=null,this._theme=e??new mc().getDefaultTheme(),this._defaultFontSize=n;const r=this;this._emitter=new st(this),this._schemeLookup=o=>r._theme.schemeLookup()(o),this._indexedColors=this._fromJSONIndexedColors(t),this._indexedLookup=o=>{const i=this._indexedColors[o];return i?i.toRGBA():vi(o)},this._initializeBuiltIns(),this._customCellStyles=new Map,this._customTableStyles=new Map,this._indexedColors=[],this._mruColors=[],this._persistCache=null}_initializeNamedStyles(e,t){for(let n=0;n<e.length;n++){const r=e[n],o={...r},i=r.named;delete o.named;const a=exports.it.resolveTypedUpdates(o,We,this),l=new Cd(this,{name:i,style:a},this._hideOrRemoveNamed.bind(this),n);i===exports.IStyle.BuiltInName.Normal&&(this._normalRanged=l.getRanged(),this._normalStyle=Vr(this,null)),t.set(i.toLowerCase(),l)}}_initializeTableStyles(){const e=(()=>{if(pt)return pt;pt=new Map;const n=(u,d)=>{if(d===0)return"TableStyleNone";let g="Custom";return u==="l"?g="Light":u==="m"?g="Medium":u==="d"&&(g="Dark"),`TableStyle${g}${d}`},r=(u,d=0)=>d===0?u:d>0?`${u} lumMod ${100-d}, lumOff ${d}`:d<0?`${u} lumMod ${100+d}`:void 0,o=u=>({type:exports.IFill.Type.Pattern,patternType:exports.IFill.BuiltInSheetPattern.Solid,foreground:u,background:u}),i=(u,d=!1)=>{const g={fill:u};return d&&(g.weight=700),g},a=(u,d=exports.IBorder.StrokeStyle.Thin)=>({style:d,color:u}),l=(u,d)=>{for(let g=0;g<7;g++)u.push(d(`accent${g+1}`))};let c=0,h=[];h.push(["dk1",r("bg1",-15),"dk1"]),l(h,u=>[r(u,-25),r(u,80),u]),c=1;for(let u=0;u<7;u++){const d=n("l",u+c),g=h[u][0],m=h[u][1]??g,f=h[u][2]??g;pt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),border:{top:a(f),bottom:a(f)}},headerRow:{font:i(g,!0),border:{bottom:a(f)}},totalRow:{font:i(g,!0),border:{top:a(f)}},firstColumn:{font:i(g,!0)},lastColumn:{font:i(g,!0)},firstRowStripe:{fill:o(m)},firstColumnStripe:{fill:o(m)}}))}c+=7,h=[],h.push(["dk1","dk1","lt1"]),l(h,u=>["dk1",u,"lt1"]);for(let u=0;u<7;u++){const d=n("l",u+c),g=h[u][0],m=h[u][1],f=h[u][2];pt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),border:{left:a(m),right:a(m),top:a(m),bottom:a(m)}},headerRow:{font:i(f,!0),fill:o(m)},totalRow:{font:i(g,!0),border:{top:a(m,exports.IBorder.StrokeStyle.Double)}},firstColumn:{font:i(g,!0)},lastColumn:{font:i(g,!0)},firstRowStripe:{border:{top:a(m)}},secondRowStripe:{border:{top:a(m)}},firstColumnStripe:{border:{left:a(m)}},secondColumnStripe:{border:{left:a(m)}}}))}c+=7,h=[],h.push(["dk1",r("bg1",-15)]),l(h,u=>[u,r(u,80)]);for(let u=0;u<7;u++){const d=n("l",u+c),g="dk1",m=h[u][0],f=h[u][1];pt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),border:{left:a(m),right:a(m),top:a(m),bottom:a(m),horizontal:a(m),vertical:a(m)}},headerRow:{font:i(g,!0)},totalRow:{font:i(g,!0),border:{top:a(m,exports.IBorder.StrokeStyle.Double)}},firstColumn:{font:i(g,!0)},lastColumn:{font:i(g,!0)},firstRowStripe:{fill:o(f)},firstColumnStripe:{fill:o(f)}}))}c=1,h=[],h.push(["dk1","dk1",r("bg1",-15)]),l(h,u=>[u,r(u,40),r(u,80)]);for(let u=0;u<7;u++){const d=n("m",u+c),g="dk1",m="lt1",f=h[u][0],_=h[u][1],p=h[u][2];pt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),border:{left:a(_),right:a(_),top:a(_),bottom:a(_),horizontal:a(_)}},headerRow:{font:i(m,!0),fill:o(f)},totalRow:{font:i(g,!0),border:{top:a(f,exports.IBorder.StrokeStyle.Double)}},firstColumn:{font:i(g,!0)},lastColumn:{font:i(g,!0)},firstRowStripe:{fill:o(p)},firstColumnStripe:{fill:o(p)}}))}c+=7,h=[],h.push(["dk1",r("bg1",-15),r("bg1",-35)]),l(h,u=>[u,r(u,80),r(u,60)]);for(let u=0;u<7;u++){const d=n("m",u+c),g="dk1",m="lt1",f=h[u][0],_=h[u][1],p=h[u][2];pt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),fill:o(_),border:{horizontal:a(m),vertical:a(m)}},headerRow:{font:i(m,!0),fill:o(f),border:{bottom:a(m,exports.IBorder.StrokeStyle.Thick)}},totalRow:{font:i(m,!0),fill:o(f),border:{top:a(m,exports.IBorder.StrokeStyle.Thick)}},firstColumn:{font:i(m,!0),fill:o(f)},lastColumn:{font:i(m,!0),fill:o(f)},firstRowStripe:{fill:o(p)},firstColumnStripe:{fill:o(p)}}))}c+=7,h=[],h.push(["dk1",r("bg1",-15),r("bg1",-35)]),l(h,u=>[u,r(u,80),r(u,60)]);for(let u=0;u<7;u++){const d=n("m",u+c),g="dk1",m="lt1",f=h[u][0],_=r("bg1",-15);pt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),border:{top:a(g,exports.IBorder.StrokeStyle.Medium),bottom:a(g,exports.IBorder.StrokeStyle.Medium),left:u===0?a(g,exports.IBorder.StrokeStyle.Thin):void 0,right:u===0?a(g,exports.IBorder.StrokeStyle.Thin):void 0,horizontal:u===0?a(g,exports.IBorder.StrokeStyle.Thin):void 0,vertical:u===0?a(g,exports.IBorder.StrokeStyle.Thin):void 0}},headerRow:{font:i(m,!0),fill:o(f),border:{bottom:a(g,exports.IBorder.StrokeStyle.Medium)}},totalRow:{border:{top:a(g,exports.IBorder.StrokeStyle.Double)}},firstColumn:{font:i(m,!0),fill:o(f)},lastColumn:{font:i(m,!0),fill:o(f)},firstRowStripe:{fill:o(_)},firstColumnStripe:{fill:o(_)}}))}c+=7,h=[],h.push(["dk1",r("bg1",-15),r("bg1",-35),"dk1"]),l(h,u=>[u,r(u,80),r(u,60),r(u,40)]);for(let u=0;u<7;u++){const d=n("m",u+c),g="dk1",m=h[u][0],f=h[u][1],_=h[u][2],p=h[u][3];pt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),fill:o(f),border:{top:a(p),right:a(p),left:a(p),bottom:a(p),vertical:a(p),horizontal:a(p)}},headerRow:{font:i(g),fill:o(f)},totalRow:{font:i(g),border:{top:a(m,exports.IBorder.StrokeStyle.Medium)}},firstColumn:{font:i(g,!0)},lastColumn:{font:i(g,!0)},firstRowStripe:{fill:o(_)},firstColumnStripe:{fill:o(_)}}))}c=1,h=[],h.push(["dk1",r("dk1",15),r("dk1",25),r("dk1",50)]),l(h,u=>["dk1",r(u,-50),r(u,-25),u]);for(let u=0;u<7;u++){const d=n("d",u+c),g="lt1",m=h[u][0],f=h[u][1],_=h[u][2],p=h[u][3];pt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),fill:o(p)},headerRow:{font:i(g,!0),fill:o(m),border:{bottom:a(g,exports.IBorder.StrokeStyle.Medium)}},totalRow:{font:i(g,!0),fill:o(f),border:{top:a(g,exports.IBorder.StrokeStyle.Medium)}},firstColumn:{font:i(g,!0),fill:o(_),border:{right:a(g,exports.IBorder.StrokeStyle.Medium)}},lastColumn:{font:i(g,!0),fill:o(_),border:{left:a(g,exports.IBorder.StrokeStyle.Medium)}},firstRowStripe:{fill:o(_)},firstColumnStripe:{fill:o(_)}}))}c+=7,h=[],h.push([r("bg1",-15),"dk1",r("bg1",-35)]),h.push([r("accent1",80),"accent2",r("accent1",60)]),h.push([r("accent3",80),"accent4",r("accent3",60)]),h.push([r("accent5",80),"accent6",r("accent5",60)]);for(let u=0;u<4;u++){const d=n("d",u+c),g="dk1",m="lt1",f=h[u][0],_=h[u][1],p=h[u][2];pt.set(d.toLocaleLowerCase(),Object.freeze({name:d,wholeTable:{font:i(g),fill:o(f)},headerRow:{font:i(m,!0),fill:o(_)},totalRow:{font:i(g,!0),border:{top:a(g,exports.IBorder.StrokeStyle.Double)}},firstColumn:{font:i(g,!0)},lastColumn:{font:i(g,!0)},firstRowStripe:{fill:o(p)},firstColumnStripe:{fill:o(p)}}))}return pt})(),t=new Map;return e.forEach((n,r)=>{const o=n.name.toLowerCase(),i=new yd(this,n,!0);t.set(o,i)}),t}_initializeBuiltIns(){const e=new Map;this._builtInsCellStyles=e,this._initializeNamedStyles(ow,e),this._builtInsTableStyles=this._initializeTableStyles(),this._emptyTableStyle=new exports.ITableStyle.Empty(this._normalStyle)}getNormal(){return this._normalStyle}getNormalRanged(){return this._normalRanged}setTheme(e){this._theme=e,this._emitter.notify("onThemeChange"),this._emitter.notify("onAnyChange")}getTheme(){return this._theme}setDefaultFontSize(e){this._defaultFontSize=e,this._emitter.notify("onDefaultFontChange"),this._emitter.notify("onAnyChange")}getDefaultFontSize(){return this._defaultFontSize}beginPersist(){return this._persistCache||(this._persistCache={byIds:new Map,byJSONs:new Map,openScopes:new Set}),new Dw(this._persistCache,{},this._toJSONInternal.bind(this),this._fromJSONInternal.bind(this),()=>{this._persistCache=null})}getNamed(e){if(!e)return null;e=e.toLowerCase();let t=null;return this._customCellStyles&&(t=this._customCellStyles.get(e)),t||(t=this._builtInsCellStyles.get(e)),t??null}getCustomNamed(){const e=Array.from(this._customCellStyles.values());return e.sort((t,n)=>t.getName().localeCompare(n.getName())),e}setNamed(e,t=!1){if(!e||!e.name||!e.style)throw new Ot;this.validateStyleName(e.name,!1);const n=this._setCustomCellStyleInternal(e,t);return this._emitter.notify("onNamedStylesChange"),this._emitter.notify("onAnyChange"),n}_setCustomCellStyleInternal(e,t=!1,n=0){const r=e.name.toLowerCase(),o=this._builtInsCellStyles.get(r),i=o?.getBuiltInID()??null;let a=null;t&&(a=(this._customCellStyles.get(r)??o)?._properties??null);const l=Ji(0,e.style,this.getNormal());e={...e,style:l};const c=exports.it.resolveTypedUpdates(e,ZS,this,a),h=new Cd(this,c,this._hideOrRemoveNamed.bind(this),i);return c.name===exports.IStyle.BuiltInName.Normal&&(this._normalRanged=h.getRanged(),this._normalStyle=Vr(this,null)),this._customCellStyles.set(r,h),h}_setCustomTableStyleInternal(e,t){const n=e.toLowerCase();let r=this._customTableStyles.get(n)??this._builtInsTableStyles.get(n);r&&(e=r.getName());const o=new yd(this,{...t,name:e},!1,this._deleteCustomTableStyle.bind(this));return this._customTableStyles.set(n,o),o}_hideOrRemoveNamed(e){let t=null;if(t=typeof e=="string"?e:e?.getName?.(),!t||(t=t.toLowerCase(),t===exports.IStyle.BuiltInName.Normal.toLowerCase()))return!1;const n=this._builtInsCellStyles.get(t);let r=!1;if(n&&!n.isHidden()){const o=n.toJSON();this.setNamed({...o,hidden:!0}),r=!0}else t=t.toLowerCase(),r=this._customCellStyles.delete(t);return r&&(this._emitter.notify("onNamedStylesChange"),this._emitter.notify("onAnyChange")),r}getTableStyle(e){if(!e)return this._emptyTableStyle;let t=this._customTableStyles.get(e.toLowerCase());return t||(t=this._builtInsTableStyles.get(e.toLowerCase())),t??null}getCustomTableStyles(){const e=Array.from(this._customTableStyles.values());return e.sort((t,n)=>t.getName().localeCompare(n.getName())),e}setDefaultTableStyle(e){const t=e?.toLowerCase();return this._defaultTableStyle=this._customTableStyles.get(t)??this._builtInsTableStyles.get(t)??this._builtInsTableStyles.get(ho.toLowerCase()),this._emitter.notify("onTableStylesChange"),this._emitter.notify("onAnyChange"),e===this._defaultTableStyle.getName()}getDefaultTableStyle(){return this._defaultTableStyle||(this._defaultTableStyle=this._builtInsTableStyles.get(ho.toLowerCase())),this._defaultTableStyle}_deleteCustomTableStyle(e){const t=this._customTableStyles.get(e?.toLowerCase());return!!t&&(this._customTableStyles.delete(e.toLowerCase()),this._defaultTableStyle?.getName()===t.getName()&&(this._defaultTableStyle=this._builtInsTableStyles.get(ho.toLowerCase())),this._emitter.notify("onTableStylesChange"),this._emitter.notify("onAnyChange"),!0)}setCustomTableStyle(e,t){const n=this._setCustomTableStyleInternal(e,t);return this._emitter.notify("onTableStylesChange"),this._emitter.notify("onAnyChange"),n}validateStyleName(e,t=!1){if(!e||e.trim().length===0)throw new Error("Style name cannot be empty.");if(t&&this.getNamed(e)!==null)throw new Error("Style name is already taken.")}normalize(e){if(!e)return null;const t=exports.it.resolveTypedUpdates(e,We,this),n=ef;let r=null;if(r=t.named?this.getNamed(t.named)?.getRanged().getPropertiesAt(0,0,null):this._normalRanged.getPropertiesAt(0,0,null),r){const i={...r};N.removeEqualValues(t,i)}const o=this.getTheme().getFontScheme();return N.removeEqualValues(t,{font:{size:this.getDefaultFontSize(),family:o.getMinorFont(),fallbacks:o.getMinorFallbacks()}}),N.removeEqualValues(t,n),t}schemeLookup(){return this._schemeLookup}indexedLookup(){return this._indexedLookup}parseColor(e){return Ge.parse(e,this._schemeLookup,this._indexedLookup)}recentColors(){return this._mruColors}addRecentColor(e){if(!e)return;const t=this._mruColors,n=[],r=e.toString();for(let o=0;o<t.length&&o<10;o++)t[o].toString()!==r&&n.push(t[o]);return n.unshift(e),this._mruColors=Object.freeze(n),this._mruColors}clearRecentColors(){this._mruColors=Object.freeze([])}getIndexedColors(){return this._indexedColors}setCustomIndexedColors(e){this._indexedColors=e?.length>0?[...e]:null}getCustomIndexedColors(){const e=Math.max(this._indexedColors?.length,66),t=[];for(let n=0;n<e;n++)this._indexedColors[n]!==null&&t.push(this._indexedColors[n]??new Ge(vi(n)?.toString()));return t}addListeners(e,t){return this._emitter.addListeners(e,t)}_toJSONInternal(e){const t={};e.length>0&&(t.direct=e);const n=this.getCustomNamed();let r=[];for(let l=0;l<n.length;l++){let c=n[l].toJSON();r.push(c)}r.length>0&&(t.named=r);const o={};this._defaultTableStyle&&this._defaultTableStyle.getName()!==ho&&(o.defaultTableStyle=this._defaultTableStyle.getName());const i={},a=this.getCustomTableStyles();for(let l=0;l<a.length;l++){let c=a[l].toJSON();delete c.name,c&&Object.keys(c).length>0&&(i[a[l].getName()]=c)}if(Object.keys(i).length>0&&(o.styles=i),Object.keys(o).length>0&&(t.tables=o),this._indexedColors.length>0){t.indexedColors=[];for(let l=0;l<this._indexedColors.length;l++)t.indexedColors.push(this._indexedColors[l].toString())}if(this._mruColors.length>0){t.mruColors=[];for(let l=0;l<this._mruColors.length;l++)t.mruColors.push(this._mruColors[l].toString())}return Object.keys(t).length===0?null:t}_fromJSONIndexedColors(e){if(!e||e.length===0)return N.EmptyArray;const t=[];if(e?.length>0)for(let n=0;n<e.length;n++)try{t.push(this.parseColor(e[n]))}catch{console.warn("Unable to parse color: "+e[n])}return t}_fromJSONInternal(e){this._indexedColors=this._fromJSONIndexedColors(e.indexedColors);const t=e.named;for(let o=0;t&&o<t.length;o++)this._setCustomCellStyleInternal(e.named[o]);let n=ho;if(this._defaultTableStyle=null,e.tables){e.tables.defaultTableStyle&&(n=e.tables.defaultTableStyle);const o=e.tables.styles?Object.keys(e.tables.styles):null;for(let i=0;o&&i<o.length;i++){const a=o[i],l=e.tables.styles[a];this._setCustomTableStyleInternal(a,l)}}this._defaultTableStyle=this.getTableStyle(n);let r=[];if(e.mruColors?.length>0)for(let o=0;o<e.mruColors.length;o++)try{r.push(this.parseColor(e.mruColors[o]))}catch{console.warn("Unable to parse color: "+e.mruColors[o])}this._mruColors=r}}const el="BinaryResource must have only one initial data value.",tl="Resource is closed.";class fi{constructor(e){if(this._listeners=new Set,this._type=e.type,this._name=e?.name,e.base64){const t=e.base64;this._asArrayBufferResolve=async()=>{const n=await Promise.resolve(t);return Promise.resolve(Ar.base64ToArrayBuffer(n))}}if(e.fetch){if(this._asArrayBufferResolve)throw new Error(el);const t=e.fetch;this._asArrayBufferResolve=async()=>{let n,r=null;r=typeof t=="string"?t:e.input;const o=await fetch(r,n),i=o.headers.get("Content-Type");return!this._type&&i&&(this._type=i),o.arrayBuffer()}}if(e.buffer){if(this._asArrayBufferResolve)throw new Error(el);this._asArrayBufferResolve=async()=>{let t=null;return t=typeof e.buffer=="function"?await e.buffer():e.buffer,Promise.resolve(t)}}if(e.file){if(this._asArrayBufferResolve)throw new Error(el);this._asArrayBufferResolve=async()=>await(await Promise.resolve(e.file)).arrayBuffer()}if(!this._asArrayBufferResolve)throw new Error("BinaryResource must have an initial data value.");this._refs=new Set,this._isClosed=!1}getName(){return this._name}async toJSONAsync(){const e=await this.toBuffer(),t={base64:Ar.arrayBufferToBase64(e)};return this._type!==Ar.DEFAULT_MIME_TYPE&&(t.type=this._type),this._name&&(t.name=this._name),t}async toBuffer(){if(this._asArrayBuffer)return this._asArrayBuffer;try{this._asArrayBuffer=this._asArrayBufferResolve()}catch(e){throw e}return this._asArrayBuffer}async getType(){return this._type?this._type:(await this.toBuffer(),this._type??Ar.DEFAULT_MIME_TYPE)}addReference(e){if(this._isClosed)throw new Error(tl);this._refs.add(e)}deleteReference(e){if(this._isClosed)throw new Error(tl);if(this._refs.size===0||!this._refs.has(e))return;this._refs.delete(e);const t=this;if(this._refs.size===0){const n=this._listeners;n.forEach(r=>{r.onUnload?.(t),n.delete(r)}),this._asArrayBuffer=null,this._isClosed=!0}}addUnloadListener(e){if(this._isClosed)throw new Error(tl);this._listeners.add(e)}get isIResource(){return!0}isClosed(){return this._isClosed}}let Lw=class{constructor(s,e,t){this._state=s,this._fromJSON=e,this._onLastEnd=t,this._state.openScopes.add(this),this._isClosed=!1}endPersist(){if(!this._state.openScopes.delete(this))throw new Error("PersistScope is closed.");this._isClosed=!0,this._state.openScopes.size===0&&this._onLastEnd()}toResourceId(s){if(this._isClosed)throw new Error("PersistScope is closed.");let e=this._state.byRefs.get(s);return e!==void 0||(e=this._state.byRefs.size,this._state.byRefs.set(s,e),this._state.byIds.set(e,s)),e}fromResourceId(s){return this._state.byIds.get(s)??null}fromJSON(s){if(this._isClosed)throw new Error("PersistScope is closed.");if(!s||s.length===0)return;const e=this._state.byRefs.size;for(let t=0;t<s.length;t++){const n=s[t],r=this._fromJSON(n);this._state.byRefs.set(r,e+t),this._state.byIds.set(e+t,r)}}toJSONAsync(){if(this._isClosed)throw new Error("PersistScope is closed.");const s=[];return this._state.byRefs.forEach((e,t)=>{s[e]=Promise.resolve(t.toJSONAsync())}),Promise.all(s)}};class bc{constructor(){this._resources=new Set}add(e){if(typeof e=="string"){let r=!1;this._resources.forEach(o=>{o.getName()===e&&(r=!0,e=o)}),r||(e=new fi({name:e,fetch:e,type:null}))}let t=null;t=e instanceof fi?e:new fi({...e});const n=this;return this._resources.has(t)||(t.addUnloadListener({onUnload:r=>{n._resources.delete(t)}}),this._resources.add(t)),t}getCount(){return this._resources.size}beginPersist(){this._persistOpen||(this._persistOpen={byRefs:new Map,byIds:new Map,openScopes:new Set});const e={},t=new Set,n=this;return new Lw(this._persistOpen,r=>{const o=n.add({base64:r.base64,name:r.name,type:r.type});return o.addReference(e),t.add(o),o},()=>{t.forEach(r=>{r.deleteReference(e)}),n._persistOpen=null})}}class Pw{constructor(e,t,n){this._state=e,this._fromJSON=t,this._onLastEnd=n,this._state.openScopes.add(this),this._isClosed=!1}endPersist(){if(!this._state.openScopes.delete(this))throw new Error("PersistScope is closed.");this._isClosed=!0,this._state.openScopes.size===0&&this._onLastEnd()}add(e){if(this._isClosed)throw new Error("PersistScope is closed.");let t=this._state.byRefs.get(e);return t!==void 0||(t=this._state.byRefs.size,this._state.byRefs.set(e,t),this._state.byIds.set(t,e)),t}at(e){return this._state.byIds.get(e)??null}fromJSON(e){if(this._isClosed)throw new Error("PersistScope is closed.");e&&e.length!==0&&this._fromJSON(e)}toJSONAsync(){if(this._isClosed)throw new Error("PersistScope is closed.");const e=[];return this._state.byRefs.forEach((t,n)=>{e[t]=Promise.resolve(n.toJSONAsync?n.toJSONAsync():n)}),Promise.all(e)}}class Yi{constructor(){this._nextId=0,this._lastReadId=-1,this._lastReadValue=null,this._stringsByText=new Map,this._stringsById=new Map}addMultiple(e,t=!1){const n=this._stringsByText,r=this._stringsById,o=e.length;let i=this._nextId;for(let a=0;a<o;a++){const l=e[a];n.get(l)!==void 0&&t||(n.set(l,i),r.set(i,l),i++)}this._lastReadId=-1,this._nextId=i}add(e){const t=this._stringsByText,n=t.get(e);if(n!==void 0)return n;const r=this._nextId++;return t.set(e,r),this._stringsById.set(r,e),this._lastReadId=-1,r}getById(e){if(this._lastReadId===e)return this._lastReadValue;const t=this._stringsById.get(e)??null;return this._lastReadId=e,this._lastReadValue=t,t}getCount(){return this._stringsById.size}beginPersist(){this._persistOpen||(this._persistOpen={byRefs:new Map,byIds:new Map,openScopes:new Set});const e=this;return new Pw(this._persistOpen,t=>(Array.isArray(t)?e.addMultiple(t):e.add(t),t),()=>{e._persistOpen=null})}}exports.IPicture=void 0,exports.IPicture||(exports.IPicture={});class cf extends ir{constructor(e){super(e),e.json&&(this._resource=e.fromResourceId(e.json.resId))}getType(){return"picture"}toJSON(e){const t={},n=e?.(this._resource);n!==null&&(t.resId=n);const r=this._getState();return r&&r.effects&&(t.effects=r.effects),t}getTypeDescription(){return"Picture"}async _asDataUrl(){if(this._dataUrl)return this._dataUrl;const e=await this.getDetails(),t=await Bo.getImageDataUrl(e.asUrl());return this._dataUrl=t.dataUrl,this._dataUrl}toHtml(){return null}async toImage(){const e=(await this._asDataUrl()).substring(Bo.DATA_URL_PNG_PREFIX.length),t=Ar.base64ToArrayBuffer(e);return new Blob([t],{type:Me.png})}async getDetails(){return this._details||(this._details=new Promise(async(e,t)=>{try{const n=await this._resource.toBuffer(),r=await this._resource.getType(),o=await Bo.loadImageDetails(n,r);e({getNaturalDimensions:()=>o.naturalDimensions,asUrl:()=>o.asUrl,asSVGText:()=>o.asSVGText})}catch(n){t(n)}})),this._details}_fromDrawingJSON(e,t){this._resource?.deleteReference(this),this._resource=t?.(e.resId),this._resource.addReference(this)}_toDrawingJSON(e){const t={},n=e?.(this._resource);return n!==null&&(t.resId=n),t}_processDelete(){super._processDelete()}}exports.ICalculation=void 0,(exports.ICalculation||(exports.ICalculation={})).Status={Ready:"ready",Error:"error",Starting:"starting",Stopping:"stopping",Off:"off"};class Ko extends nt{constructor(e,t=null,n,r,o){if(super(e,n,t),this._sheetName=r||null,this._getEntireCoords=o??Mi,this._coords=zw(n,this._getEntireCoords()),!n)throw new Error("ReferenceRange requires a coords");this._validateCoords(n)}toType(e){return new Ko(this._values,e,this._coords,this._sheetName,this._getEntireCoords)}getCoords(){return this._coords}get isIReferenceRange(){return!0}isLiteral(){return!1}_validateCoords(e){const t=this._getEntireCoords?.();if(t&&(e.rowStart<t.rowStart&&e.rowStart!==Number.MIN_SAFE_INTEGER||e.rowEnd>t.rowEnd&&e.rowEnd!==Number.MAX_SAFE_INTEGER||e.colStart<t.colStart&&e.colStart!==Number.MIN_SAFE_INTEGER||e.colEnd>t.colEnd&&e.colEnd!==Number.MAX_SAFE_INTEGER))throw new Ne}get[Symbol.toStringTag](){return"[ReferenceRange]"}toString(){return`${Cn(this._coords,this._getEntireCoords?.())}`}}const zw=(s,e)=>{let t=s.rowStart,n=s.rowEnd,r=s.colStart,o=s.colEnd,i=!1;return r===Number.MIN_SAFE_INTEGER&&(r=e.colStart,i=!0),t===Number.MIN_SAFE_INTEGER&&(t=e.rowStart,i=!0),n===Number.MAX_SAFE_INTEGER&&(n=e.rowEnd,i=!0),o===Number.MAX_SAFE_INTEGER&&(o=e.colEnd,i=!0),i?{rowStart:t,rowEnd:n,colStart:r,colEnd:o}:s},bd=(s,e)=>s.value?.once===e.value?.once,Ww=(s,e)=>s.colStart===e.colStart&&s.rowStart===e.rowStart,hf=(s,e,t)=>!!t&&s===t.rowStart&&e===t.colStart,jw=(s,e=0,t=0)=>{const n=s._values,r=s._coords,o=n.getRuns({bounds:r}),i=n.getOrientation()!==exports.w.Orientation.Row,a=i?r.colStart:r.rowStart,l=i?r.rowStart:r.colStart,c=new exports.Tuple.Builder(null,e,t);let h=o.next();for(;!h.done;){const u=h.value;c.addValues(u[0]-a,u[1]-l,u[2]),h=o.next()}return c.build()},pi=(s,e,t,n,r,o,i,a,l,c,h,u,d=!1)=>{let g,m,f=null,_=r.size();u===void 0&&(u=o.getOrientation()===exports.w.Orientation.Column);const p=e?e.length:0,S=t?t.length:0;let C;const y=p+S;for(let w=0;w<y&&_>0;w++){const E=w<p?e[w]:t[w-p],I=r.search(E),x=I.length;for(let v=0;v<x;v++){const R=I[v];if(!hf(R.rowStart,R.colStart,E)){if(R.value.getError())continue;C||(C=[]),C.push(R)}r.remove(R,Ww);const A=R.value;A.getCycleId()!==s&&l?.insert(R),A.getError()||(o.delete(R),n.insertNonOverlapping({colStart:R.colStart,rowStart:R.rowStart,colEnd:R.colEnd,rowEnd:R.rowEnd,value:null},{onIntersect:(M,T)=>{if(M.value!==null)return i?.push(M),f=k.unionRanges(f,M),a?.insertNonOverlapping(M),f=k.unionRanges(f,M),T}})),_--}}for(let w=0;w<p;w++){const E=e[w],I={colStart:E.colStart,rowStart:E.rowStart,colEnd:E.colEnd,rowEnd:E.rowEnd,value:null};n.insertNonOverlapping(I,{onIntersect:(x,v)=>{if(x.value===null)return;const R=k.sanitizeRange(v);return d&&a?.insertNonOverlapping(R),c?.insertNonOverlapping({...v,value:!1}),i?.push(R),f=k.unionRanges(f,R),v}}),h?.insertNonOverlapping(I,{onIntersect:(x,v)=>{if(x.value!==null)return i?.push(v),f=k.unionRanges(f,v),v},onUpdates:(x,v,R)=>{m||(m=[]);const A=x.length;for(let T=0;T<A;T++){const F=x[T];m.push(F)}g||(g=[]);const M=v.length;for(let T=0;T<M;T++){const F=v[T],L=k.sanitizeRange(F);g.push(L)}}})}const b=u?exports.w.Orientation.Column:exports.w.Orientation.Row;if(C){const w=C.length,E=new Array(w);for(let I=0;I<w;I++){const x=C[I],v=x.value.setError(!0,s);l?.insert(v),E[I]=v,f=k.unionRanges(f,x);const R={colStart:x.colStart,rowStart:x.rowStart,colEnd:x.colStart,rowEnd:x.rowStart};n.insertNonOverlapping({colStart:x.colStart,rowStart:x.rowStart,colEnd:x.colStart,rowEnd:x.rowStart,value:new jt(x,b)}),i?.push(R)}r.load(E)}for(let w=0;w<S;w++){const E=k.sanitizeRange(t[w]);n.insertNonOverlapping({colStart:E.colStart,rowStart:E.rowStart,colEnd:E.colEnd,rowEnd:E.rowEnd,value:new jt(E,b)}),d&&a?.insertNonOverlapping(E),i?.push(E),f=k.unionRanges(f,E)}return f},Kl=(s,e,t)=>{if(!e)return s;const n=e.block;if(!n)return s;const r=s??[],o=e.colIndex,i=e.rowIndex;let a,l,c,h;t?(a=t.colStart,l=t.rowStart,c=t.colEnd,h=t.rowEnd):(a=o,l=i,c=o,h=i);const u={colStart:a,rowStart:l,colEnd:c,rowEnd:h,value:{blockEntry:{colStart:a,rowStart:l,colEnd:c,rowEnd:h,value:n},width:1,height:1,index:-1,$absWidth:!1,$absHeight:!1,once:e}};let d=e.dynamic;return d||(d=[],e.dynamic=d),d.push(u),r.push(u),r};class Ec{constructor(e){this._fullCalcRequired=!1,this._iterationId=0,this._cycleId=1,this._pendingInvalidations=new Set,this._emitter=null,this._isProcessingJSON=!1,this._collectDirties=(o,i=!1,a,l)=>{const c=this._formulaSpatial,h=this._precedentSpatial;let u=$w,d=0;if(i){const g=c.all();for(let m=0;m<g.length;m++){const f=g[m].value.calcs,_=f.length;for(let p=0;p<_;p++){const S=f[p],C=S.length;for(let y=0;y<C;y++){const b=S[y];b.markId!==o&&(u[d++]=b,b.markId=o,b.pending=!1,b.pendingResolved=!1,b.pendingPromise&&(b.pendingPromise.cancelled=!0))}}}}else{const g=a.length;for(let m=0;m<g;m++){const f=a[m];Id.length=0;const _=Id;h.search(f,!1,_),c.search(f,!1,_);const p=_.length;if(p===0)continue;const S=f.colStart,C=f.rowStart,y=f.colEnd-S,b=f.rowEnd-C;for(let w=0;w<p;w++){const E=_[w],I=E.value,x=I.blockEntry?.value??I,v=x.ref,R=v.colEnd-v.colStart,A=v.rowEnd-v.rowStart,M=E.colEnd-E.colStart-R,T=E.rowEnd-E.rowStart-A,F=I.once;if(F)F.markId<=o&&(F.removed?(h.remove(E,bd),F.removed=!1):u[d++]=F,F.markId=o);else{let L=0,D=0,P=R,B=A;if(!I.$absHeight){const O=C-E.rowStart;D=Math.min(Math.max(O-T,0),A),B=Math.min(b+C,A)}if(!I.$absWidth){const O=S-E.colStart;L=Math.min(Math.max(O-M,0),R),P=Math.min(y+O,R)}const z=x.calcs;for(let O=D;O<=B;O++){const W=z[O];for(let V=L;V<=P;V++){const j=W[V];j.markId!==o&&(u[d++]=j,j.markId=o,j.pendingPromise&&(j.pendingPromise.cancelled=!0))}}}}}l&&l.forEach(m=>{if(Array.isArray(m)){const f=m.length;for(let _=0;_<f;_++){const p=m[_],S=p.length;for(let C=0;C<S;C++){const y=p[C];y.markId===o||y.removed||(u[d++]=y,y.markId=o,y.pendingPromise&&(y.pendingPromise.cancelled=!0))}}}else m.markId===o||m.removed||(u[d++]=m,m.markId=o,m.pendingPromise&&(m.pendingPromise.cancelled=!0))})}return u.length=d,u};const t=(e={strings:new Yi,...e}).getEntireCoords??Mi;if(this._getEntireCoords=t,this._options=e,this._strings=e.strings,this._onCalculated=e?.onCalculated??(()=>{}),this._cycleId=1,this._values=new Zt({orientation:exports.w.Orientation.Column}),this._getFormulaParser=e.getFormulaParser,!this._getFormulaParser)throw new Error("Formula parser is not defined");this._latest={graph:this},this._iterationId=0;const n=this;this._formulaSpatial=new be({updateEntryOptions:{isMergeOnShift:!0,isSplitOnExpand:!0,onUpdates:(o,i,a)=>{const l=a._cloneKey??n;if(l._isProcessingJSON)return;let c=l._notifyFormulaInsertEntries,h=l._notifyFormulaRemoveEntries;const u=l._precedentSpatial,d=i?i.length:0;if(d>0){let m=h?h.length:0;h?h.length=m+d:(h=new Array(d),l._notifyFormulaRemoveEntries=h);for(let f=0;f<d;f++){const _=i[f],p=_.value,S=p.ref;h[m+f]=S;const C=S.rowStart,y=S.colStart,b=p.formula.getDirectPrecedentsAt(C,y);if(!b)continue;const w=b.length;for(let E=0;E<w;E++){const I=b[E];if(I===null||I instanceof exports.n.Known)continue;const x=u.search(I),v=x.length;for(let R=0;R<v;R++){const A=x[R];A.value.blockEntry.value===_.value&&u.remove(A)}}}}const g=o?o.length:0;if(g>0){const m=[];for(let f=0;f<g;f++){const _=o[f],p=_.colEnd-_.colStart,S=_.rowEnd-_.rowStart,C=_.value,y=C.formula,b=C.ref,w=b.rowStart,E=b.colStart,I=[],x=y.getDirectPrecedentsAt(w,E,!0,Rs,As),v=x.length;for(let R=0;R<v;R++){const A=x[R];if(A instanceof exports.n.Known)continue;const M=Rs[R],T=As[R],F={colStart:A.colStart,rowStart:A.rowStart,colEnd:A.colEnd+(T?0:p),rowEnd:A.rowEnd+(M?0:S),value:{blockEntry:_,width:p+1,height:S+1,index:R,$absWidth:T,$absHeight:M,once:null}};I.push(A),m.push(F)}c||(c=[],l._notifyFormulaInsertEntries=c),c.push({colStart:_.colStart,rowStart:_.rowStart,colEnd:_.colEnd,rowEnd:_.rowEnd,value:{tokens:y.getTokens(),references:y.getReferences(),precedents:I}})}u.load(m)}}}}),this._contentfulSpatial=new be({updateEntryOptions:{isSplitOnExpand:!0,isMergeOnShift:!0}});const r={updateEntryOptions:{isSplitOnExpand:!0,isMergeOnShift:!1}};this._precedentSpatial=new be(r),this._volatile=new Set,this._spillSpatial=new be(r),this._errorSpatial=new be(r),this._pendingSpatial=new be(r),this._invalidations=new be,this._notifyValues=new be,this._notifySpills=new be,this._notifyFormats=new be,this._notifyPending=new be,this._calculation=e.calculation,this._clearScope()}addListeners(e,t){return this._emitter||(this._emitter=new st(this)),this._emitter.addListeners(e,t)}shift(e){const t=e.cloneIfUpdate??!0?this.clone(this):this,n={...e};delete n.cloneIfUpdate,delete n.onShift,t._values.shift(n.range,n.direction);const r=t._contentfulSpatial;t._contentfulSpatial=r.shift(n);const o=t._spillSpatial;t._spillSpatial=o.shift(n);const i=t._formulaSpatial;if(i.isEmpty())return t;const a=e.range,l=e.direction,c=l===exports.w.Direction.Left||l===exports.w.Direction.Right;l!==exports.w.Direction.Up&&exports.w.Direction.Left,c?(a.colEnd,a.colStart):(a.rowEnd,a.rowStart),t._notifyFormulaInsertEntries,t._notifyFormulaRemoveEntries;const h=t._getEntireCoords(),u=new Map;this._precedentSpatial.visitRanges({...a,colEnd:c?h.colEnd:a.colEnd,rowEnd:c?a.rowEnd:h.rowEnd},p=>{let S=p.value;if(p.value.once)return;let C=S.blockEntry,y=u.get(C);y||(y={rows:[],cols:[],index:[]},u.set(C,y)),y.index.push(S.index)});const d=[],g=[],m=u.entries();let f=m.next();const _=(p,S,C,y)=>{let b=p.value;const w=b.formula.getReferences(),E=S.length;for(let I=0;I<E;I++){const x=w[I];x!==null&&(x instanceof exports.n.Known||typeof x!="string"&&x[I])}return p.value=b,p};for(;!f.done;){const[p,S]=f.value,C=p.value,y=S.rows.sort(),b=y.length,w=S.cols.sort().length,E=S.index.sort();if(g.push(p),b===0&&w===0){const x={...p};_(x,E),d.push(x),f=m.next();continue}let I=0;for(let x=0;x<b;x++){const v=y[x];if(v===I)continue;al[0]={colStart:C.ref.colStart,rowStart:I,colEnd:C.ref.colEnd,rowEnd:v-1,value:C},al[1]={colStart:C.ref.colStart,rowStart:v,colEnd:C.ref.colStart,rowEnd:C.ref.rowEnd,value:C};const R=Jw(C,al,exports.w.Orientation.Row,v);let A=R[0];_(A,E),d.push(A),A=R[1],_(A,E),d.push(A),I=v}f=m.next()}return i._updateNodes(d,g),t._fullCalcRequired=!0,this._invalidate(d),t}clone(e){if(e!==void 0&&this._cloneKey===e)return this;const t=new Ec(this._options);t._cloneKey=e,t._values=this._values.clone(t),t._contentfulSpatial=this._contentfulSpatial.clone(t),t._formulaSpatial=this._formulaSpatial.clone(t),t._precedentSpatial=this._precedentSpatial.clone(t),t._volatile=new Set(this._volatile),t._spillSpatial=this._spillSpatial.clone(t),t._errorSpatial=this._errorSpatial.clone(t),t._pendingSpatial=this._pendingSpatial.clone(t),t._invalidations=this._invalidations.clone(t),t._notifyValues=this._notifyValues.clone(t),t._notifySpills=this._notifySpills.clone(t),t._notifyFormats=this._notifyFormats.clone(t),t._notifyPending=this._notifyPending.clone(t);const n=this._notifyFormulaInsertEntries;n&&(t._notifyFormulaInsertEntries=[...n]);const r=this._notifyFormulaRemoveEntries;r&&(t._notifyFormulaRemoveEntries=[...r]);const o=this._pendingActions;return o&&(t._pendingActions=[...o]),t._cycleId=this._cycleId,t._emitter=this._emitter,t._fullCalcRequired=this._fullCalcRequired,this._latest.graph=t,t._iterationId=this._iterationId+1,t}invalidate(e){const t=this._invalidations;if(Array.isArray(e)){const n=e.length;for(let r=0;r<n;r++){let o=e[r];typeof o=="string"&&(o=St(o)),t.insertNonOverlapping(o)}}else{let n=e;typeof n=="string"&&(n=St(n)),t.insertNonOverlapping(n)}}setFormulaAt(e,t){let n,r=null;return typeof e=="string"?n=St(e,ke):(ke.colStart=e.colIndex,ke.rowStart=e.rowIndex,ke.colEnd=e.colIndex,ke.rowEnd=e.rowIndex,n=ke),t?r=this._setInputs(null,[{colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colEnd,rowEnd:n.rowEnd,value:t}]):this.delete(n),r}getFormulaAt(e,t){let n;typeof e=="string"&&(n=St(e,ke));const r=this._formulaSpatial.search(n);if(r.length===0)return null;const o=r[0].value;return o.formula?o.formula.getTextAt(n.rowStart,n.colStart,t):void 0}_formulaAt(e,t){_o.colStart=t,_o.rowStart=e,_o.colEnd=t,_o.rowEnd=e;const n=this._formulaSpatial.search(_o);if(n.length===0)throw new Error(`No formula found at ${rs({rowIndex:e,colIndex:t})}`);return n[0]}getDirectPrecedentsAt(e,t,n){return this._formulaAt(e,t).value.formula.getDirectPrecedentsAt(e,t,n)}getReferencesAt(e,t){return this._formulaAt(e,t).value.formula.getReferences()}setReferenceAt(e,t,n,r){const o=this._formulaAt(e,t).value.formula.setReferenceAt(n,r).getTextAt(e,t);return this.setFormulaAt({rowIndex:e,colIndex:t},o),this}evaluateAt(e,t,n){const r=this._formulaAt(e,t),o=r.value,i=o.ref,a=i.colStart-t,l=i.rowStart-e,c=this._calculation._getContext(),h=this._calculation._getScope();return h.sheetName=this._options.getSheetName?.(),h.rowIndex=e,h.colIndex=t,h.node=o.calcs[l][a],r.value.formula.evaluate(c,n)}setInputAt(e,t){let n=null;const r=typeof e=="string"?Tr(e,Vw):e;if(t!==null){const o=new exports.Tuple.Builder,i=this._values.getOrientation()===exports.w.Orientation.Column,a=i?r.colIndex:r.rowIndex,l=i?r.rowIndex:r.colIndex;o.addValue(a,l,t),n=this.setInputs(o.build(),null)}else this.delete(k.cellToRange(r,ke));return n}setInputs(e,t){return this._setInputs(e,t)}delete(e){typeof e=="string"&&(e=Mt(e));const t=this._setInputs(null,[{...e,value:null}],e);return this._emitter?.notify("onInvalidate"),t.removes}_createCopySpillEntries(e,t,n,r,o){const i=r??[],a=o??[],l=t.colStart,c=t.rowStart,h=t.colEnd,u=t.rowEnd,d=n.colStart,g=n.rowStart,m=e.search(t),f=m.length;for(let _=0;_<f;_++){const p=m[_];a&&a.push(p);const S=p.rowStart,C=p.colStart;if(S<c||S>u||C<l||C>h||p.value.getError())continue;const y=d+(p.colEnd-C),b=g+(p.rowEnd-S),w={colStart:d,rowStart:g,colEnd:y,rowEnd:b};i.push({colStart:d,rowStart:g,colEnd:y,rowEnd:b,value:new er(w,0,!1)})}return{removes:a,inserts:i}}_copyCalcs(e,t,n){const r=e._formulaSpatial;if(r.isEmpty())return;const o=this._getEntireCoords(),i=o.colStart,a=o.rowStart,l=o.colEnd,c=o.rowEnd,h=r.createCopiedEntries(t,n),u=h.inserts;let d=u.length,g=0;const m=e._spillSpatial;let f=[];for(;g<d;){let _=u[g],p=_.value,S=p.ref,C=S.colStart,y=S.rowStart,b=S.colEnd,w=S.rowEnd;this._createCopySpillEntries(m,t,S,f,null);let E=p.formula.getReferences();const I=E.length;for(let x=0;x<I;x++){const v=E[x];if(!v||v.isFormulaError||typeof v=="string")continue;const R=v,A=R.colStart,M=R.rowStart,T=R.colEnd,F=R.rowEnd;let L=R.$colStart?A:A+C,D=R.$rowStart?M:M+y,P=R.$colEnd?T:T+b,B=R.$rowEnd?F:F+w;if(A===Number.MIN_SAFE_INTEGER&&(L=i,P=l),M===Number.MIN_SAFE_INTEGER&&(D=a,B=c),L<i||P>l||D<a||B>c){const z=i-L,O=a-D,W=l-P,V=c-B;po.colStart=Math.max(C,C+z),po.rowStart=Math.max(y,y+O),po.colEnd=Math.min(b,b+W),po.rowEnd=Math.min(w,w+V);const j=Hr(_,po,ti);if(j){const H=j.length;_=j[H-1],p=_.value,S=p.ref,C=S.colStart,y=S.rowStart,b=S.colEnd,w=S.rowEnd;for(let G=0;G<H-1;G++){const $=j[G];u.push($),d++}}else p=p.setReferenceAt(x,null),_.value=p,E=p.formula.getReferences()}}u[g++]=_}this._formulaSpatial._updateNodes(u,h.removes),r._mergeNodes({colStart:n.colStart-1,rowStart:n.rowStart-1,colEnd:n.colEnd+1,rowEnd:n.rowEnd+1}),f&&this._spillSpatial._updateNodes(f,[]),this._fullCalcRequired=!0,this._invalidate(u),this._invalidate(h.removes)}_moveCalcs(e,t,n){const r=e._formulaSpatial.createCopiedEntries(t,n);console.log("_moveCalcs",r,"from:",t,"to:",n);const o=this._formulaSpatial,i=(g,m,f,_)=>{let p=g.value;const S=p.formula.getReferences(),C=S.length,y=m.colStart-f.colStart,b=m.rowStart-f.rowStart,w=p.ref,E=f.colStart-w.colStart,I=f.colEnd-w.colEnd,x=f.rowStart-w.rowStart,v=f.rowEnd-w.rowEnd;for(let R=0;R<C;R++){const A=S[R];if(!A||A.isFormulaError||typeof A=="string")continue;const M=A,T=M.colStart,F=M.rowStart,L=M.colEnd,D=M.rowEnd;let P=y,B=b;const z=E<=T&&I>=L||T==Number.MIN_SAFE_INTEGER,O=x<=F&&v>=D||F==Number.MIN_SAFE_INTEGER;let W=!O;M.$colStart||P===0||T===Number.MIN_SAFE_INTEGER?W=!1:W||(W=T<E||T>I,W||!M.$colEnd||M.$colStart||(W=!0));let V=!z;M.$rowStart||B===0||F===Number.MIN_SAFE_INTEGER?V=!1:V||(V=F<x||F>v,W||!M.$rowEnd||M.$rowStart||(V=!0));let j=!O;M.$colEnd||P===0||F===Number.MIN_SAFE_INTEGER?j=!1:j||(j=L<E||L>I,W||!M.$colStart||M.$colEnd||(j=!0));let H=!z;if(M.$rowEnd||B===0||F===Number.MIN_SAFE_INTEGER?H=!1:H||(H=D<x||D>v,H||!M.$rowEnd||M.$rowStart||(H=!0)),!(W||j||V||H))continue;const G={...M};W&&(G.colStart+=P),V&&(G.rowStart+=B),j&&(G.colEnd+=P),H&&(G.rowEnd+=B),p=p.setReferenceAt(R,G)}return g.value=p,g},a=e._spillSpatial;let l=[],c=[];const h=r.inserts,u=h.length;for(let g=0;g<u;g++){const m=h[g];this._createCopySpillEntries(a,t,m,l,c),h[g]=i(m,t,n)}o._updateNodes(r.inserts,[]),e._formulaSpatial._updateNodes([],r.removes);const d=[];l.length>0&&(this._spillSpatial._updateNodes(l,[]),e._spillSpatial._updateNodes([],c),pi(this._cycleId,c,N.EmptyArray,e._contentfulSpatial,a,e._values,d,e._notifyValues,e._notifySpills,e._notifyPending,e._errorSpatial,e._values.getOrientation()!==exports.w.Orientation.Row,!1)),this._fullCalcRequired=!0,this._invalidate(r.inserts),e._invalidate(d),e._invalidate(r.removes)}getSnapshot(e){const t=this,n=Object.freeze({...e});let r=n.range;return typeof r=="string"&&(r=St(r)),{async copyTo(o,i){const a=o.calcGraph;let l=o.range;typeof l=="string"&&(l=St(l));const c=li(l,r,i?.fitDestination,i?.transpose);return{...n,...i}.isCut?a._moveCalcs(t,r,c):a._copyCalcs(t,r,c),l},getCoords:()=>r,getSource:()=>t,getName:()=>"Calculation",getMarkOptions:()=>n,isISnapshot:!0}}autoFill(e,t){return typeof e=="string"&&(e=St(e)),typeof t=="string"&&(t=St(t)),this._copyCalcs(this,e,t),this}_scheduleRecalculation(e){const t=this._pendingInvalidations;if(e)if(Array.isArray(e)){const r=e.length;for(let o=0;o<r;o++)t.add(e[o])}else t.add(e);const n=this;N.debounce(()=>{const r=n._latest.graph,o=r._volatile,i=r._cycleId;t.forEach(a=>{a.cycleId>i||o.add(a)}),t.clear(),r.calculate()},100)()}_notifyCalculated(e){const t=this,n=t._notifyValues,r=n.all();return new Promise(o=>{N.nextTick(()=>{const i=t._cycleId;let a,l=t._fullCalcRequired;l||(typeof e=="boolean"?l=e:e&&(a=e,l=a.full??!1));const c={};let h=null;const u=r.length;if(u>0){n.clear();let C=r,y=null;for(let R=0;R<u;R++){const A=r[R],M=A.colStart,T=A.colEnd;if(M!==T){y||(y=[]);for(let F=M+1;F<=T;F++)y.push({colStart:F,rowStart:A.rowStart,colEnd:F,rowEnd:A.rowEnd});A.colEnd=M}}y&&(C=r.concat(y)),C.sort(k.columnFirstRangeComparator);const b=new exports.Tuple.Builder(R=>new kt(R));let w;const E=t._values,I=E.getOrientation()===exports.w.Orientation.Column,x=C.length;for(let R=0;R<x;R++){const A=C[R];h=k.unionRanges(h,A,ke);const M=E.getRuns({bounds:A});let T=M.next();const F=A.colStart,L=A.rowStart,D=A.colEnd,P=A.rowEnd,B=I?L:F,z=I?D:P,O=I?P:D;let W=I?F:L,V=B;for(;!T.done;){const j=T.value,H=j[0];for(;W<H;)w||(w=[]),w.push({colStart:I?W:V,rowStart:I?V:W,colEnd:I?W:O,rowEnd:I?O:W}),W++,V=B;const G=j[1],$=j[2],te=Math.max(G,B),J=Math.min(G+$.length-1,O);b.addValues(H,te,$),V<te&&(w||(w=[]),w.push({colStart:I?H:V,rowStart:I?V:H,colEnd:I?H:te-1,rowEnd:I?te-1:H})),V=J+1,J>=O?(W=H+1,V=B):W=H,T=M.next()}for(;W<=z;)V<=O&&(w||(w=[]),w.push({colStart:I?W:V,rowStart:I?V:W,colEnd:I?W:O,rowEnd:I?O:W})),W++,V=B}const v=b.build();v&&(c.valueInserts=v),w&&(c.valueRemoves=w)}const d=t._notifyPending,g=d.all();if(g.length>0){d.clear();const C=t._pendingSpatial;let y;const b=g.length;for(let w=0;w<b;w++){const E=g[w];C.insertNonOverlapping(E,{onIntersect:(I,x)=>(y||(y=[]),y.push({...x}),h=k.unionRanges(h,x),x.value===!1&&(x.value=null),x)})}y&&y.length>0&&(c.pendingUpdates=y,h=k.unionRangesArrays(y,h,ke))}const m=t._notifySpills,f=m.all();if(f.length>0){m.clear();const C=t._spillSpatial;let y,b,w;const E=f.length;for(let I=0;I<E;I++){const x=f[I],v=x.value;if(v.getCycleId()!==i)y||(y=[]),y.push({colStart:x.colStart,rowStart:x.rowStart,colEnd:x.colEnd,rowEnd:x.rowEnd});else{const R=C.search(x),A=R.length;for(let M=0;M<A;M++){let T=R[M];if(hf(x.rowStart,x.colStart,T)&&v.getCycleId()===i){b||(b=[],w=new Set);const F=Dt(T.colStart)+Ht(T.rowStart);if(w.has(F))continue;w.add(F),b.push({colStart:x.colStart,rowStart:x.rowStart,colEnd:x.colEnd,rowEnd:x.rowEnd,value:T.value.getError()})}}}}b&&(c.spillInserts=b,h=k.unionRangesArrays(b,h,ke)),y&&(c.spillRemoves=y,h=k.unionRangesArrays(y,h,ke))}const _=t._notifyFormats.all();_.length>0&&(c.formatInserts=_,h=k.unionRangesArrays(_,h,ke),t._notifyFormats.clear());const p=t._notifyFormulaInsertEntries;if(p){const C=t._formulaSpatial;for(let y=p.length-1;y>=0;y--){const b=p[y];C.search(b).length===0?p.splice(y,1):h=k.unionRanges(h,b,ke)}c.formulaInserts=p,t._notifyFormulaInsertEntries=void 0}const S=t._notifyFormulaRemoveEntries;S&&(c.formulaRemoves=S,h=k.unionRangesArrays(S,h,ke),t._notifyFormulaRemoveEntries=void 0),h&&(c.bounds=k.sanitizeRange(h)),Object.keys(c).length===0?c.cycleId=i-1:(c.cycleId=i,t._cycleId++),l&&(c.isFull=!0),t._fullCalcRequired=!1,t._options.onCalculated?.(c),o(c)})})}_setInputs(e,t,n){if(this._calculation.getStatus()===exports.ICalculation.Status.Starting)return this._addToPending(()=>{const x=this._setInputs(e,t,n),v={formulaInserts:x.inserts??N.EmptyArray,formulaRemoves:x.removes??N.EmptyArray,cycleId:this._cycleId,bounds:k.unionRanges(k.unionRangesArrays(x.inserts),k.unionRangesArrays(x.removes))};return Promise.resolve(v)}),qw;const r=this._values.getOrientation()!==exports.w.Orientation.Row,o=this._spillSpatial,i=this._errorSpatial,a=this._contentfulSpatial,l=[],c=this._formulaSpatial;let h,u,d=!c.isEmpty(),g=d?[]:null,m=this._values;if(e&&e.tuples){if(h=e.tuples,g){let x=e.bounds;if(d)if(x){const A=Go(x,r);l.push(A)}else{const A={colStart:Number.MIN_SAFE_INTEGER,rowStart:Number.MIN_SAFE_INTEGER,colEnd:Number.MAX_SAFE_INTEGER,rowEnd:Number.MAX_SAFE_INTEGER};l.push(A)}const v={majorStart:0,minorStart:0,majorEnd:0,minorEnd:0},R=h.length;for(let A=0;A<R;A++){const M=h[A],T=M[0];v.majorStart=T,v.majorEnd=T;const F=M[1],L=F.length;for(let D=0;D<L;D++){const P=F[D];v.minorStart=P[0];const B=P[1];v.minorEnd=v.minorStart+B.length-1;const z=Go(v,r);g&&c.search(z).length>0&&g.push(z)}}}u=Nu(e.tuples,r)}(n||h)&&(pi(this._cycleId,n?[n]:N.EmptyArray,u,a,o,m,l,this._notifyValues,this._notifySpills,this._notifyPending,i,r,!1),n&&m.delete(n),h&&m.setValues(h));const f=this._calculation._getContext(),_=this._calculation._getScope();let p,S;_.sheetName=this._options.getSheetName?.();const C=this._getFormulaParser(),y=(x,v)=>{const R=x.rowStart,A=x.colStart,M={...x,value:null};if(c.insertNonOverlapping(M,{noMerge:!0,onIntersect:(T,F)=>T.value===null?null:(S||(S=[]),S.push(T),F)}),v!==null){_.rowIndex=R,_.colIndex=A;const T=C.parse(f,v),F=new hn(x,T),L={...x,value:F};p||(p=[]),p.push(L)}},b=g?g.length:0;for(let x=0;x<b;x++)y(g[x],null);const w=t?t.length:0;for(let x=0;x<w;x++){const v=t[x],R=v.value;y(k.sanitizeRange(v),R)}const E=S?S.length:0,I=this._precedentSpatial;for(let x=0;x<E;x++){const v=S[x].value.calcs;if(v){const R=v.length;for(let A=0;A<R;A++){const M=v[A];for(let T=0;T<M.length;T++){const F=M[T];if(F.dynamic){for(let L=0;L<F.dynamic.length;L++){const D=F.dynamic[L];I.remove(D)}F.dynamic=null}}}}}return t&&(c._updateNodes(p,N.EmptyArray),pi(this._cycleId,S,p,a,o,m,l,this._notifyValues,this._notifySpills,this._notifyPending,i,r,!0)),this._invalidate(l),{inserts:this._notifyFormulaInsertEntries??N.EmptyArray,removes:this._notifyFormulaRemoveEntries??N.EmptyArray}}_invalidate(e){if(!e||e.length==0)return;const t=this._invalidations,n=gn(e,exports.w.Orientation.Column,2);for(let r=0;r<n.length;r++)t.insertNonOverlapping(n[r]);this._emitter?.notify("onInvalidate")}_markAndPlan(e,t,n){let r;mo=0,il=0,Fs=0,fo=0;const o=this._precedentSpatial,i=this._formulaSpatial;ol=0,Ts=0;const a=this._cycleId,l=t.length;for(let d=0;d<l;d++){const g=t[d];g.markId!==n&&(g.markId=n,g.cycleId=a,g.inDegree=0,nl[mo++]=g,rl[Ts++]=g)}const c=(d,g,m)=>{(e||d.state===Gl)&&(r||(r=[]),r.push(g),e||m(d))},h=d=>{d.markId!==n&&(d.markId=n,d.cycleId=a,d.inDegree=0,nl[mo++]=d,rl[Ts++]=d)};for(;ol<Ts;){const d=rl[ol++],g=d.colIndex,m=d.rowIndex;ke.colStart=g,ke.rowStart=m,ke.colEnd=g,ke.rowEnd=m;const f=o.search(ke),_=f.length;if(_===0)d.dependents=N.EmptyArray;else for(let p=0;p<_;p++){const S=f[p],C=S.value.once;C?c(C,S,h):vd(S,m,g,h)}}for(let d=0;d<mo;d++){const g=nl[d],m=g.block,f=g.rowIndex,_=g.colIndex,p=m.formula.getDirectPrecedentsAt(f,_);let S=0;const C=g.precedents;for(let y=0;y<p.length;y++){const b=p[y];if(b.isFormulaError){C[y]=b;continue}{const A=b;A.calc=void 0,C[y]=A}const w=b.colStart,E=b.rowStart,I=b.colEnd,x=b.rowEnd,v=i.search(b),R=v.length;for(let A=0;A<R;A++){const M=v[A],T=M.colStart,F=M.rowStart,L=M.colEnd,D=M.rowEnd,P=Math.max(T,w),B=Math.max(F,E),z=Math.min(L,I),O=Math.min(D,x),W=M.value.calcs;for(let V=B;V<=O;V++){const j=W[V-F];for(let H=P;H<=z;H++){const G=j[H-T];G.markId===n&&(b.calc=G,S++)}}}}g.inDegree=S,g.inDegree===0&&(sl[Fs++]=g)}const u=d=>{d.markId===n&&(d.inDegree--,d.inDegree===0&&(sl[Fs++]=d))};for(;il<Fs;){const d=sl[il++];xd[fo++]=d;const g=d.colIndex,m=d.rowIndex;ke.colStart=g,ke.rowStart=m,ke.colEnd=g,ke.rowEnd=m;const f=o.search(ke),_=f.length;for(let p=0;p<_;p++){const S=f[p],C=S.value.once;C?c(C,S,u):vd(S,m,g,u)}}return fo<mo?{completed:!1,onces:r}:{completed:!0,onces:r}}_evaluate(e){const t=this._calculation._getContext(),n=this._calculation._getScope();n.sheetName=this._options.getSheetName?.();let r=Uw;r.length=0;let o=0,i=!0;const a=this._cycleId,l=this._invalidations,c=this._contentfulSpatial,h=this._notifyValues,u=this._notifySpills,d=this._precedentSpatial,g=this._spillSpatial,m=this._values,f=m.getOrientation(),_=f===exports.w.Orientation.Column;let p;n.spillSpatial=this._spillSpatial,n.values=m;const S=t.getEntireCoords.bind(t);let C;for(let y=0;y<fo;y++){const b=xd[y];if(b.state===ku&&a===b.cycleId){b.state=Gl;continue}if(b.dynamic){for(let q=0;q<b.dynamic.length;q++){const oe=b.dynamic[q];d.remove(oe)}b.dynamic=null}const w=b.block,E=b.colIndex,I=b.rowIndex;let x=e?void 0:b.cachedValue,v=b.error;!v&&x&&x.isFormulaError&&(v=x);let R=!1;const A=b.precedents;if(A){const q=A.length,oe=b.inputs;for(let ce=0;ce<q;ce++){const Y=A[ce],se=Y.calc;if(se&&se.pending){R=!0;continue}if(Y.isFormulaError){oe[ce]=Y;continue}const Q=Y.colStart,re=Y.rowStart,K=Y.colEnd;Y.rowEnd!==re||Q!==K?(o>0&&(r.length=o,Ed(r,m,h,_),o=0),oe[ce]=new Ko(m,null,{...Y},null,S)):oe[ce]=se===void 0?Y:se.cachedValue}b.pendingPrecedents=R}const M=_?E:I,T=_?I:E;n.node=b,n.colIndex=E,n.rowIndex=I;const F=w.formula;let L,D;const P=b.pending;let B=P;if((R||b.pendingPromise)&&(B=!0,L=b.cachedValue??null,b.pendingPromise&&(b.pendingResolved?(b.pendingPromise=null,b.pendingResolved=!1,B=!1):(b.pendingPromise.cancelled=!0,L=void 0))),L===void 0&&(n.formula=F,n.colIndex=E,n.rowIndex=I,L=F.evaluate(t,void 0,b.inputs),n.formula=null,D=L&&L.then?L:null,B=!!D),B!==P&&(b.pending=B,p||(p=Ln(_)),p.append(M,T,B)),D&&(L=b.cachedValue??null,!D.__originator)){D.__originator=a;const q=b;Ms.add(q),q.pendingPromise=D,q.pendingResolved=!1,D.then(oe=>{if(Ms.delete(q),D.cancelled)return;q.pendingPromise=D,q.pendingResolved=!0;let ce=ns(oe,t);ce===null&&(ce=0),q.cachedValue=ce,this._scheduleRecalculation(q)},oe=>{})}let z=1,O=1;const W=x instanceof nt;let V;const j=x instanceof exports.n.Spill;if(W||j){uo.colStart=E,uo.rowStart=I,uo.colEnd=E,uo.rowEnd=I;const q=g.search(uo);for(let oe=0;!V&&oe<q.length;oe++){const ce=q[oe];ce.colStart===E&&ce.rowStart===I&&(V=ce)}if(V){if(W){const ce=x;z=ce.getWidth(),O=ce.getHeight()}const oe={colStart:E,rowStart:I,colEnd:E+z-1,rowEnd:I+O-1};g.remove(V),V&&V.value.getError()||(c.insertNonOverlapping({...oe,value:null}),m.delete(oe),h.insertNonOverlapping(oe))}}let H=1,G=1;const $=L,te=$?.isIRange;let J,ne=L instanceof exports.n.Spill;if(te&&$.size>1){H=$.getWidth(),G=$.getHeight();const q={colStart:E,rowStart:I,colEnd:E+H-1,rowEnd:I+G-1},oe=t.getEntireCoords(),ce=!k.isRangeWithinRange(q,oe);if(ce&&(q.colEnd=Math.min(q.colEnd,oe.colEnd),q.rowEnd=Math.min(q.rowEnd,oe.rowEnd)),ne=ce,!ne){const Q=c.search(q);if(ne=Q.length>1,!ne&&Q.length===1){const re=Q[0],K=k.intersectRanges(q,re,ke);(K&&(K.rowEnd!==K.rowStart||K.colStart!==K.colEnd)||K.colStart!==E||K.rowStart!==I)&&(ne=!0)}}let Y,se;if(ne)L=exports.n.BuiltIn.Spill,H=1,G=1,Y=[[M,[[T,[L]]]]],m.setValues(Y),se={colStart:E,rowStart:I,colEnd:E,rowEnd:I};else{const Q=jw($,M,T);Q&&(Y=Q.tuples),Y&&m.setValues(Y),se=q}J={...q,value:new er(q,a,ne)},g.insert(J),C=Kl(C,b,q),h.insertNonOverlapping(se),l.insertNonOverlapping(se),c.insertNonOverlapping({...se,value:new jt(se,f)})}(!k.isEqualRanges(V,J)||ne||j)&&(V&&u.insert(V),J&&u.insert(J)),H===z&&G===O||(b.state=ku,l.insertNonOverlapping({colStart:E,rowStart:I,colEnd:E+Math.max(H,z)-1,rowEnd:I+Math.max(G,O)-1}),i=!1);let Z=L&&L.isFormulaError?L:null;F.getError()&&(Z=F.getError()),(Z||v&&!e)&&(Z&&!Z.equals(v)||v&&v.equals(Z)),b.cachedValue=L,r[o++]=b}if(n.node=null,n.colIndex=Number.MAX_SAFE_INTEGER,n.rowIndex=Number.MAX_SAFE_INTEGER,p){const y=p.done(!0);this._notifyPending.load(y)}return o>0&&(r.length=o,Ed(r,m,h,_),o=0),{completed:i,dynamic:C,count:fo}}async calculate(e){const t=this._calculation.getStatus();if(t===exports.ICalculation.Status.Starting)return void this._addToPending(()=>this.calculate(e));if(t!==exports.ICalculation.Status.Ready)return;let n=this._fullCalcRequired;n||(typeof e=="boolean"?n=e:e&&(n=e.full??!1));const r=this._invalidations;if(this._formulaSpatial.isEmpty()){if(r.clear(),Ms.size>0){const h=++go;Ms.forEach(u=>{u.markId=h})}return this._notifyCalculated(e)}let o=n;const i=this._volatile;let a=++go,l=this._collectDirties(a,o,r.all(),i);if(r.clear(),i.clear(),!o&&l.length===0)return this._notifyCalculated(e);o&&this._clearCalcs();const c=this._resetScope();for(;l.length>0;){a=++go;const h=this._markAndPlan(o,l,a).onces;if(h){const d=this._precedentSpatial,g=h.length;for(let m=0;m<g;m++)d.remove(h[m],bd)}l.length=0;const u=this._evaluate(o);if(u.dynamic&&this._precedentSpatial.load(u.dynamic),c.dynamicPrecedentsInserts&&(this._precedentSpatial.load(c.dynamicPrecedentsInserts),c.dynamicPrecedentsInserts=[]),c.conflatingFormats){const d=c.conflatingFormats.done(!0),g=this._notifyFormats;for(let m=0;m<d.length;m++){const f=d[m];g.insertNonOverlapping(f)}c.conflatingFormats=null}u.completed||(o=!1,a=++go,l=this._collectDirties(a,o,r.all(),i),r.clear())}return this._clearScope(),this._notifyCalculated(e)}_clearScope(){const e=this._calculation._getScope();e&&(e.rowIndex=0,e.colIndex=0,e.node=null,e.values=this._values,e.formulaSpatial=this._formulaSpatial,e.volatile=this._volatile,e.conflatingFormats=null,e.dynamicPrecedentsInserts=null,e.formula=null,e.getEntireCoords=Mi)}_resetScope(){const e=this._calculation._getScope();if(e)return e.rowIndex=0,e.colIndex=0,e.node=null,e.values=this._values,e.formulaSpatial=this._formulaSpatial,e.volatile=this._volatile,e.conflatingFormats=null,e.dynamicPrecedentsInserts=null,e.formula=null,e.getEntireCoords=this._getEntireCoords,e}_clearCalcs(){const e=this._values,t=this._spillSpatial,n=this._contentfulSpatial,r=t.all();for(let o=0;o<r.length;o++){const i=r[o];i.value.getError()||(e.delete(i),n.insertNonOverlapping({...i,value:null}))}t.clear(),this._errorSpatial.clear(),this._pendingSpatial.clear(),this._volatile.clear(),this._clearNotifications()}_clearNotifications(){this._invalidations.clear(),this._notifyValues.clear(),this._notifySpills.clear(),this._notifyFormats.clear(),this._notifyPending.clear()}_clearAll(){this._cycleId!==1&&this._cycleId++,go++,this._formulaSpatial.clear(),this._contentfulSpatial.clear(),this._pendingInvalidations.clear(),this._values.clear(),this._precedentSpatial.clear(),this._volatile.clear(),this._spillSpatial.clear(),this._errorSpatial.clear(),this._pendingSpatial.clear(),this._clearNotifications(),this._notifyFormulaInsertEntries=void 0,this._notifyFormulaRemoveEntries=void 0}_addToPending(e){let t=this._pendingActions;if(!t){this._pendingActions=t=[];const n=this;n._calculation.addListeners({onReady:()=>{(async()=>{const r=n._pendingActions,o=r.length;for(let i=0;i<o;i++){const a=r[i],l=await a.bind(n)();n._options.onCalculated?.(l)}this._pendingActions=null})()},onError:()=>{}},{once:!0})}t.push(e)}fromJSON(e){const t=this._calculation.getStatus();if(t===exports.ICalculation.Status.Starting)return void this._addToPending(()=>Promise.resolve(this.fromJSON(e)));if(t!==exports.ICalculation.Status.Ready)return;this._clearAll();const n={cycleId:0,isFull:!0};if(!e)return n;this._isProcessingJSON=!0;try{if(e.data){const i=e.data;this._values.setValues(i);const a=this._values.getOrientation()===exports.w.Orientation.Column,l=Nu(i,a);this._contentfulSpatial.load(l)}const r=this._formulaSpatial,o=e.formulas;if(o){const i=e.dynamic,a=new Set;if(i){const p=i.length;for(let S=0;S<p;S++){const C=i[S],y=C[0].split(":")[0];a.add(y)}}const l=o.length,c=new Array(l),h=[],u=[],d=this._calculation._getContext(),g=this._calculation._getScope();g.colIndex=0,g.rowIndex=0;const m=this._getFormulaParser();for(let p=0;p<l;p++){const S=o[p],C=S[0],y=St(C),b=S[1],w=y.rowStart,E=y.colStart;g.colIndex=E,g.rowIndex=w;let I=m.parse(d,b);const x=I.getDirectPrecedentsAt(w,E,!0,Rs,As),v=x.length;v===1&&(I=I.wrapImplicit(w,E,a));const R={...y},A=new hn(R,I);y.value=A,c[p]=y;const M=y.rowEnd,T=y.colEnd-E,F=M-w,L=[];for(let D=0;D<v;D++){const P=x[D];if(P instanceof exports.n.Known)continue;const B=Rs[D],z=As[D],O={colStart:P.colStart,rowStart:P.rowStart,colEnd:P.colEnd+(z?0:T),rowEnd:P.rowEnd+(B?0:F),value:{blockEntry:y,width:T+1,height:F+1,index:D,$absWidth:z,$absHeight:B,once:null}};L.push(P),u.push(O)}h.push({colStart:R.colStart,rowStart:R.rowStart,colEnd:R.colEnd,rowEnd:R.rowEnd,value:{tokens:I.getTokens(),references:I.getReferences(),precedents:L}})}if(r.load(c),this._precedentSpatial.load(u),h.length>0&&(n.formulaInserts=h),i){const p=[],S=[];let C;const y=this._values,b=i.length;for(let w=0;w<b;w++){const E=i[w],I=E[0],x=St(I),v=E[1],R={...x},A=R.colStart,M=R.rowStart,T=R.colEnd,F=R.rowEnd;Er.colStart=A,Er.rowStart=M,Er.colEnd=A,Er.rowEnd=M;const L=r.search(Er);if(L.length!==1)continue;const D=L[0].value,P=D.ref,B=D.calcs,z=M-P.rowStart,O=A-P.colStart,W=B[z][O];if(v)W.cachedValue=exports.n.BuiltIn.Spill;else{const j=new nt(y,R);W.cachedValue=j}x.value=new er(R,0,v),S.push(x);const V={colStart:A,rowStart:M,colEnd:T,rowEnd:F,value:v};k.isSingleCell(V)||p.push(V),Kl(C,W,R)}this._spillSpatial.load(S),this._precedentSpatial.load(C),p.length>0&&(n.spillInserts=p)}const f=e.volatile,_=f?f.length:0;if(_>0){const p=this._volatile,S=C=>{p.add(C)};for(let C=0;C<_;C++){const y=f[C],b=St(y,Er),w=r.search(b),E=w.length;for(let I=0;I<E;I++){const x=w[I];Hw(x,b,S)}}}}}catch(r){throw r}finally{this._isProcessingJSON=!1}return n}async toJSON(e=!1){const t=this._formulaSpatial.all(),n=t.length;if(n===0)return null;const r={};if(n>0){const l=new Array(n);for(let c=0;c<n;c++){const h=t[c];l[c]=h.value.toJSON()}r.formulas=l}const o=this._spillSpatial.all(),i=o.length;if(i>0){const l=this._getEntireCoords(),c=new Array(i);for(let h=0;h<i;h++){const u=o[h],d=Cn(u,l);c[h]=[d,u.value.getError()]}r.dynamic=c}const a=this._volatile;if(a.size>0){const l=a.values();let c=l.next();const h=this._values.getOrientation()===exports.w.Orientation.Column,u=Ln(!0);for(;!c.done;){const f=c.value;if(Array.isArray(f))for(let _=0;_<f.length;_++){const p=f[_];for(let S=0;S<p.length;S++){const C=p[S],y=C.colIndex,b=C.rowIndex,w=h?y:b,E=h?b:y;u.append(w,E)}}else{const _=f.colIndex,p=f.rowIndex,S=h?_:p,C=h?p:_;u.append(S,C)}c=l.next()}const d=u.done(!0),g=d.length,m=new Array(g);for(let f=0;f<g;f++){const _=d[f],p=Cn(_,this._getEntireCoords());m[f]=p}r.volatile=m}return r}}const Ed=(s,e,t,n)=>{const r=new exports.Tuple.Builder(Gw),o=Ln(n);s.sort(n?k.columnFirstCellComparator:k.rowFirstCellComparator);const i=s.length;for(let c=0;c<i;c++){const h=s[c],u=h.colIndex,d=h.rowIndex;if(!h.cachedValue?.isIRange){const m=n?u:d,f=n?d:u;let _=h.cachedValue;r.addValue(m,f,_),o.append(m,f)}}const a=r.build();a&&a.tuples&&e.setValues(a.tuples);const l=o.done(!0);for(let c=0;c<l.length;c++){const h=l[c];t.insertNonOverlapping(h)}},Hw=(s,e,t)=>{const n=s.colStart,r=s.rowStart,o=s.colEnd,i=s.rowEnd,a=e.colStart,l=e.rowStart,c=e.colEnd,h=e.rowEnd,u=Math.max(n,a),d=Math.max(r,l),g=Math.min(o,c),m=Math.min(i,h),f=s.value.calcs;for(let _=d;_<=m;_++){const p=_-r,S=f[p];for(let C=u;C<=g;C++){const y=C-n;t(S[y],p,y)}}},vd=(s,e,t,n)=>{const r=s.value,o=r.$absHeight,i=r.$absWidth,a=r.width,l=r.height,c=r.blockEntry.value.calcs,h=t-s.colStart,u=e-s.rowStart,d=Math.min(Math.max(h,0),a-1),g=Math.min(Math.max(u,0),l-1);if(o||i)if(i){const m=c[g];for(let f=0;f<a;f++)n(m[f])}else if(o)for(let m=0;m<l;m++)n(c[m][d]);else for(let m=0;m<l;m++){const f=c[m];for(let _=0;_<a;_++)n(f[_])}else n(c[g][d])},Vw={rowIndex:0,colIndex:0},ke={rowStart:0,colStart:0,rowEnd:0,colEnd:0},Rs=[],As=[],Er={rowStart:0,colStart:0,rowEnd:0,colEnd:0},uo={rowStart:0,colStart:0,rowEnd:0,colEnd:0};new exports.n.Calc("Cyclical dependency");const Gw=s=>new kt(s);let go=0;const ar=1e4,$w=new Array(ar),Uw=new Array(ar),Ms=new Set,nl=new Array(ar);let mo=0;const rl=new Array(ar);let ol=0,Ts=0;const sl=new Array(ar);let il=0,Fs=0;const xd=new Array(ar);let fo=0;const Id=new Array(ar),po={colStart:0,rowStart:0,colEnd:0,rowEnd:0},_o={colStart:0,rowStart:0,colEnd:0,rowEnd:0},al=[null,null],qw=Object.freeze({inserts:N.EmptyArray,removes:N.EmptyArray});function Jw(s,e,t,n){const r=s;if(r?.getSplit){const o=r.getSplit(e,t,n);if(o===void 0)return;e[0].value=o[0],e[1].value=o[1]}return e}class Kw{constructor(e,t=!0){this._options={...Qw,...e},this._getFunction=this._options.getFunction,this._isColumn=t}_setInstanceScope(e){this._instanceScope=e}async _initialize(){const e=await oc._validate(!0),t=Yw();this._calcScope=t,this._runtime=new Xw(this._options,e);const{initializeBuiltIns:n}=await Promise.resolve().then(()=>require("./B1o0X3p_6PiLx4jI.cjs")),r=this;return this._builtInFunctions=Object.freeze(n(()=>r)),{builtInFunctions:this._builtInFunctions,calcScope:this._calcScope}}getBuiltInFunctions(){return this._builtInFunctions}getFunction(e){return this._builtInFunctions.get(e)??this._getFunction?.(e)}getNumberFormat(e,t){return exports.NumberFormat.Parser.formatValue(e,t,{date1904:this._options.isDate1904?.()??!1})}getEntireCoords(){return this._calcScope.getEntireCoords()}getFormulaAt(e,t){const n=this._calcScope.formulaSpatial;if(!n)return null;So.colStart=t,So.rowStart=e,So.colEnd=t,So.rowEnd=e;const r=n.search(So);return r.length===0?null:r[0].value.formula.getTextAt(e,t)??null}markVolatile(){const e=this._calcScope,t=e.volatile;t&&t.add(e.node)}formatResults(e){const t=this._calcScope,n=this._isColumn,r=n?t.colIndex:t.rowIndex,o=n?t.rowIndex:t.colIndex;t.conflatingFormats||(t.conflatingFormats=Ln(n)),t.conflatingFormats.append(r,o,e)}getSheetIndex(e){const t=this._calcScope;return e===void 0&&(e=t.sheetName),this._options.getSheetIndex?.(e)??-1}getSheetCount(){return this._options.getSheetCount?.()??1}isValidDate(e){return Ur(e)}fromOADate(e){return qr(e,this._options.isDate1904?.()??!1)}toOADate(e){return Qo(e,this._options.isDate1904?.()??!1)}_fromTuples(e,t=null,n=!1){if(!e)return null;const r=Go(e.bounds,!0),o=this._calcScope,i=this._isColumn?exports.w.Orientation.Column:exports.w.Orientation.Row,a=new Zt({orientation:i,maxCoords:o.getEntireCoords()});return a.setValues(e.tuples),new nt(a,r,t,n)}getValueAt(e,t){return this._calcScope.values.getValueAt(e,t)??null}getSpillAt(e,t){const n=this._calcScope.spillSpatial;if(!n)return null;wo.rowStart=e,wo.colStart=t,wo.rowEnd=e,wo.colEnd=t;const r=n.search(wo);if(r.length===0)return null;for(let o=0;o<r.length;o++){const i=r[o];if(i.rowStart===e&&i.colStart===t)return this.getReference(k.sanitizeRange(i))}return null}getRange(e,t){if(e?.isIRange)return e;let n;const r=Array.isArray(e);if(t=t??r,r)if(Array.isArray(e[0]))n=e;else{if(e[0]?.isIRange)throw exports.n.BuiltIn.Value;n=[e]}else n=[[e]];const o=this._isColumn,i=o?exports.w.Orientation.Column:exports.w.Orientation.Row,a=this._fromTuples(Ri(n,o,yt(0,0,void 0,void 0,o),!0),void 0,t);if(a)return a;const l=new Zt({orientation:i,maxCoords:this._calcScope.getEntireCoords()});return new nt(l,k.EmptyRange,void 0,t)}getPosition(){const e=this._calcScope;return{colIndex:e.colIndex,rowIndex:e.rowIndex}}getReference(e,t){if(!e)throw exports.n.BuiltIn.Ref;const n=this._calcScope,r=n.getEntireCoords;if(typeof e=="string"){if(t)throw exports.n.BuiltIn.Ref;try{const c=wc(e,r(),os,()=>{throw exports.n.BuiltIn.Ref},t);if(c.length>1)throw exports.n.BuiltIn.Ref;e=c[0]}catch{throw exports.n.BuiltIn.Ref}}if(!e)throw exports.n.BuiltIn.Ref;const o=n.values;let i;const a=n.node;let l;if(a){const c=a.precedents;l=Zw(c,e)}if(l){const c=l.calc;i=c&&c.isIReferenceRange?c.cachedValue:new Ko(o,void 0,e,null,r)}else n.dynamicPrecedentsInserts=Kl(n.dynamicPrecedentsInserts,a,e),i=new Ko(o,void 0,e,null,r);return i}getAddress(e,t=!1){e||(e=this.getPosition());const n=this.getEntireCoords().sheetName;return e.colIndex!==void 0?((r,o,i=!1)=>i?hi(r,o):Ha(r,o))(e,n,t):((r,o,i=!1)=>(i?hi({colIndex:r.colStart,rowIndex:r.rowStart,$colIndex:r.$colStart,$rowIndex:r.$rowStart,sheetName:r.sheetName},o):Ha({colIndex:r.colStart,rowIndex:r.rowStart,$colIndex:r.$colStart,$rowIndex:r.$rowStart,sheetName:r.sheetName},o))+":"+(i?hi({colIndex:r.colEnd,rowIndex:r.rowEnd,$colIndex:r.$colEnd,$rowIndex:r.$rowEnd},null):Ha({colIndex:r.colEnd,rowIndex:r.rowEnd,$colIndex:r.$colEnd,$rowIndex:r.$rowEnd},null)))(e,n,t)}parseAsDateTime(e,t=!1){return function(n,r=!1,o=!1){let i=n,a=Yg(n,r,!0);a&&(i=a.leadingText);let l=null;if(i.trim().length>0&&(l=ac(i,r),!l&&o))return null;!l&&a?.leadingText.trim().length>0&&(a=null);let c=0;return l&&(c+=l.asOADate),a&&(c+=a.parsed.oaDateTime),c}(e,this._options.isDate1904?.()??!1,t)}getRuntime(){return this._runtime}get[Symbol.toStringTag](){return"[CalculationContext]"}toString(){let e="";const t=this._instanceScope;let n;return t&&(n=t.toString?.()),n&&n&&(e=`${e}:[${n}]`),e}}class Xw{constructor(e,t){this._options=e,this._license=t}getCurrencySymbol(){return"$"}getNumberDecimalSeparator(){return"."}getNumberGroupSeparator(){return","}isDate1904(){return this._options.isDate1904?.()??!1}getDescription(){return"Calculation Runtime"}getLocation(){return N.isNode()?process.cwd():window.location?.href??"/"}getVersion(){try{const e="0.4.15";if(e.indexOf(".env.")===-1)return`${e}`}catch{return"local"}}getOS(){return N.getOS()}getUser(){return this._license?.licensee?.()??null}}const Yw=()=>({rowIndex:0,colIndex:0,sheetName:null,node:null,values:null,formulaSpatial:null,spillSpatial:null,volatile:null,conflatingFormats:null,dynamicPrecedentsInserts:null,formula:null,getEntireCoords:()=>ts}),Qw={getSheetIndex:s=>-1,getSheetCount:()=>1,getSheetName:()=>null,getEntireCoords:()=>ts,getNamed:(s,e)=>null,getFunction:s=>null,isDate1904:()=>!1},Zw=(s,e)=>{if(!s)return;const t=s.length;if(t===0)return;const n=e.colStart,r=e.rowStart,o=e.colEnd,i=e.rowEnd;for(let a=0;a<t;a++){const l=s[a],c=l;if(c!==void 0&&l.colStart===n&&l.rowStart===r&&l.colEnd===o&&l.rowEnd===i)return c}return null},So={rowStart:0,colStart:0,rowEnd:0,colEnd:0},wo={rowStart:0,colStart:0,rowEnd:0,colEnd:0};class ey{_setScope(e){this._scope=e}_getScope(e=!1){const t=this._scope;if(!t&&!e)throw new Error("FunctionContext can only be used in a function.");return t}getNumberFormat(e,t){return this._getScope().getNumberFormat(e,t)}getEntireCoords(){return this._getScope().getEntireCoords()??ts}isValidDate(e){return this._getScope().isValidDate(e)}parseAsDateTime(e,t){return this._getScope().parseAsDateTime(e,t)}fromOADate(e){return this._getScope().fromOADate(e)}toOADate(e){return this._getScope().toOADate(e)}getRange(e){return this._getScope().getRange(e)}getValueAt(e,t){return this._getScope().getValueAt(e,t)}getPosition(){return this._getScope().getPosition?.()??O_}getReference(e,t){return this._getScope().getReference(e,t)}getFormulaAt(e,t){return this._getScope().getFormulaAt?.(e,t)??null}getSpillAt(e,t){return this._getScope().getSpillAt?.(e,t)??null}getSheetIndex(e){return this._getScope().getSheetIndex?.(e)??-1}getSheetCount(){return this._getScope().getSheetCount?.()??1}markVolatile(){this._getScope().markVolatile?.()}formatResults(e){this._getScope().formatResults?.(e)}getFunction(e){return this._getScope().getFunction?.(e)??null}getAddress(e,t){return this._getScope().getAddress(e,t)}getRuntime(){return this._getScope().getRuntime()}get[Symbol.toStringTag](){return"[FormulaContext]"}toString(){const e=this._getScope();if(e){const t=e.toString?.();if(t)return t}return e?"":"{NO SCOPE}"}}const uf=new ey,Di="__SHEETXL";let Qn;const Rd={FormulaContext:Qn,ScalarType:U,IRange:exports.w,FormulaError:exports.n,Observable:ag};let _i;function vc(s){Qn||(Qn=uf,Rd.FormulaContext=Qn),_i=globalThis[Di],globalThis[Di]=Rd,Qn._setScope(s)}function Li(){_i?(globalThis[Di]=_i,_i=void 0):delete globalThis[Di],Qn&&Qn._setScope(null)}var pn;(pn||(pn={})).Context={Workbook:"workbook",Sheet:"sheet",Ranges:"ranges",Range:"range",Calculation:"calculation"};class Xo{constructor(e,t,n,r=null,o=!1){this._ct=pn.Context.Calculation,this._builtIn=!1,this._broadcast=!1,this._pj=null,this._json=e,this._n=e.name,this._d=new oy(e),this._ct=e.context??pn.Context.Calculation;const i=e.parameters;let a;this._pj=i,t||(console.log(`TypeFunction '${e.name}' was not provided a function implementation.`),t=()=>{}),this._fn=t.bind(this),this._cf=n??ny,this._builtIn=o,a=r?typeof r=="function"?r:()=>Promise.resolve(r):ty(e),this._descFn=a;const l=i?.length??0;let c=l===1||l===2;c&&(i[0].arrayDepth>0||i[0].range)&&(c=!1),c&&l===2&&(i[1].arrayDepth>0||i[1].range)&&(c=!1),this._broadcast=c}execute(...e){const t=this._pj,n=[],r=this._cf?.();vc(r);let o=!1,i=null;const a=t?.length??0;let l,c=this._broadcast;if(c){const h=Au(e[0]);if(a===1&&h)c=!1;else if(a===2){const u=Au(e[1]);h&&u&&(c=!1)}}try{for(let u=0;!o&&u<a;u++){const d=t[u];let g=d.scalar??null;g!==U.Null&&g!=="*"||(g=null);let m=d.range??null;const f=d.rest??!1,_=d.optional??!1;let p=e[u];if(_&&p===null&&(p=void 0),p===void 0){if(_){n.push(void 0);continue}if(!_&&!f)throw u<=e.length?Md.ARGS_TOO_FEW([d.name],this._n):Md.PARAM_MISSING(d.name,this._n);if(u>=e.length){o=!0;continue}}const S=d.arrayDepth??0;let C=(d.range?2:0)+S;const y=d.rest??!1;if(y)for(;u<e.length&&!i;)p!==void 0&&(i=Xl(r,n,p,g,m,S,y,C)),p=e[++u];else c&&(m="l",C=2),i=Xl(r,n,p,g,m,S,y,C),o=!!i}if(i)throw i;for(;n.length>0&&n[n.length-1]===void 0;)n.length--;const h=this._fn;if(c){if(n.length===1){const u=n[0];let d=t[0].scalar;d!==U.Null&&d!=="*"||(d=null),l=u.map(g=>{if(g instanceof exports.n.Known)return g;let m=g;try{m=h(m),(Array.isArray(m)||m?.isIRange)&&(m=exports.n.BuiltIn.Value)}catch(f){m=f}return m},{type:d})}if(n.length===2){const u=n[0];let d=t[0].scalar;d!==U.Null&&d!=="*"||(d=null);const g=n[1];let m=t[1].scalar;m!==U.Null&&m!=="*"||(m=null),l=u.broadcast(g,(f,_)=>{if(f instanceof exports.n.Known)return f;if(_ instanceof exports.n.Known)return _;let p;try{p=h(f,_),(Array.isArray(p)||p?.isIRange)&&(p=exports.n.BuiltIn.Value)}catch(S){p=S}return p},{type:d,otherType:m})}}else l=h(...n);l=ns(l,r)}catch(h){throw h}finally{Li()}return l}getName(){return this._n}getDeclaration(){return this._d}async getDescriptor(e){if(this._desc)return this._desc;const t=await Promise.resolve(this._descFn(e));return this._desc=new sy(this,t),this._desc}isBuiltIn(){return this._builtIn}getContext(){const e=this._ct;if(e==="sheet"||e==="workbook"||e==="ranges"||e==="range"){const t=this._json;return t&&t.behavior&&t.behavior.default?"autoRun":"macro"}return"formula"}get[Symbol.toStringTag](){return"[TypedFunction]"}toString(){let e="";const t=this._pj;return t.length>0&&(e=t.map(n=>{let r=n.name;return n.rest&&(r="..."+r),n.optional&&(r+="?"),r+=": "+((o,i)=>{if(i){const a=B_.get(i)??"InvalidRange";return o?`${a}<${Ru.get(o)??"InvalidScalar"}>`:a}return Ru.get(o)??"InvalidScalar"})(n.scalar,n.range),r+="[]".repeat(n.arrayDepth),r}).join(", ")),`${this.getName()}(${e})`}get isIFunction(){return!0}get isITypedFunction(){return!0}}const ty=s=>async e=>{const t={};for(let n=0;n<s.parameters.length;n++)t[s.parameters[n].name]=N.camelToPrettyCase(s.parameters[n].description);return{summary:N.camelToPrettyCase(s.name),parameters:t,category:"User Defined"}},ny=()=>null;class df{constructor(e){this._s=e.scalar,this._r=e.range??null,this._d=e.arrayDepth??0}getScalarType(){return this._s}getRangeType(){return this._r}getArrayDepth(){return this._d}}class ry extends df{constructor(e){super(e),this._n=e.name,this._o=e.optional??!1,this._rest=e.rest??!1,this._e=e.enums?Object.freeze(e.enums):N.EmptyArray}getName(){return this._n}isOptional(){return this._o}isRest(){return this._rest}getEnums(){return this._e}}class Ad extends df{constructor(e){super(e),this._a=e.async??!1,this._stream=e.stream??!1}isAsync(){return this._a}isStreaming(){return this._stream}}class oy{constructor(e){if(this._n=e.name,e.parameters){const t=e.parameters.length,n=new Array(t);for(let r=0;r<t;r++)n[r]=new ry(e.parameters[r]);this._p=Object.freeze(n)}else this._p=N.EmptyArray;e.returnType?this._r=new Ad(e.returnType):this._r=new Ad({scalar:null,arrayDepth:0,range:null})}getName(){return this._n}getParameters(){return this._p}getReturnType(){return this._r}}class sy{constructor(e,t){if(this._n=t.name,this._fn=e,this._s=t.summary??N.camelToPrettyCase(t.name),this._c=t.category??"Uncategorized",this._h=t.hidden??!1,t.links&&t.links.length>0){const n=t.links.length,r=new Array(n);for(let o=0;o<n;o++)r[o]=Object.freeze([t.links[o][0],t.links[o][1]]);this._l=Object.freeze(r)}else this._l=N.EmptyArray;if(t.parameters){for(const n in t.parameters)if(Object.prototype.hasOwnProperty.call(t.parameters,n)){const r=t.parameters[n].description,o=t.parameters[n].example,i=t.parameters[n].defaultValue,a={};r&&(a.description=r),o&&(a.example=o),i!==void 0&&(a.defaultValue=i),Object.freeze(a)}}}getName(){return this._n}getSummary(){return this._s}getCategory(){return this._c}isHidden(){return this._h}getLinks(){return this._l}getParameters(){return this._p}get[Symbol.toStringTag](){return"[Descriptor]"}toString(){const e=this._fn;return`${this.getSummary()}: ${e}`}}const Xl=(s,e,t,n,r,o,i,a)=>{if(t&&t.colStart!==void 0)if(r)t=s.getReference?.(t);else{const l=t.colStart,c=t.rowStart,h=t.colEnd;t=t.rowEnd!==c||l!==h?s.getReference?.(t):s.getValueAt(c,l)}if(a===0){let l=((c,h=null,u=!1)=>{let d=c;for(;Array.isArray(d);){if(d.length>1)return u?exports.n.BuiltIn.Value:d;d=d[0]}if(d?.isIRange){if(d.size!==1)return u?exports.n.BuiltIn.Value:d;d=d.getValueAt(0,0)}return h&&(d=Nt(d,Ye(d,!0),h)),d})(t,n,!0);return l instanceof exports.n.Known?l:void e.push(l)}if(a===2)return lo(s,e,t,n,r,Array.isArray(t));if(a===1||a===3){let l;const c=i?e:[];if(r){const h=Array.isArray(t);if(h){const u=t.length;for(let d=0;!l&&d<u;d++)l=lo(s,c,t[d],n,r,h)}else l=lo(s,c,t,n,r,h)}else if(a===3){let h=(u=>{let d=u,g=0;for(;Array.isArray(d);)g++,d=d[0];return d.isIRange&&(g+=2),g})(t);for(let u=h;u<2;u++)t=[t],h++;if(h===3){const u=t.length;for(let d=0;!l&&d<u;d++)l=lo(s,c,t[d],n,r,!0)}else l=lo(s,c,t,n,r,!0)}else l=Nm(s,c,t,n,r,r!==null);return l?.isFormulaError?l:void(i||e.push(c))}{if(!Array.isArray(t)){if(n&&(t=Nt(t,Ye(t,!0),n,!1),t?.isFormulaError))return e.push(t),t;t=[t]}const l=t.length;for(let c=0;c<l;c++){const h=[],u=Xl(s,h,t[c],n,r,o,i,a-1);if(u?.isFormulaError)return u;h.length>0&&e.push(h)}}},Md={PARAM_MISSING:(s,e)=>new exports.n.NA(`Parameter ${s} is missing${e?` for ${e}`:""}.`),ARGS_TOO_FEW:(s,e)=>new exports.n.Parse(`Argument type ${s.join(", ")} is missing${e?` for ${e}`:""}.`)};class gf{constructor(e){this._emitter=null,this._readonly=null,this._closed=!1,this._options={...e};const t=this;this._transactions=this._options.transactions??new Bt({transient:!0}),this._transactionsRemoveListener=this._transactions.addStateListener(this,{onAfterStateChange(n,r,o){t._emitter.notify("onCollectionChange")}}),this._emitter=new st(this,this._transactions),this._readonly=e?.readonlyFunctions,this._initState()}search(e){const t=this._getState();if(!t)return N.EmptyArray;const n=e?.name?e.name.toUpperCase():null,r=e?.type?e.type:null;let o;e?.category&&e.category.toUpperCase(),e?.text&&e.text;const i=(l,c)=>(!n||c===n)&&(!r||l.getContext()===r)&&(o||(o=[]),void o.push(l)),a=this._readonly;return a&&a.forEach(i),t.itemsByKey.forEach(i),o??N.EmptyArray}getByName(e){if(!e)return null;const t=this._getState();if(!t)return null;if(!t)return N.EmptyArray;const n=e.toUpperCase(),r=this._readonly;if(!r||!r.size)return null;let o=r.get(n);return o||(o=t.itemsByKey.get(n),o||null)}getCount(){const e=this._getState();if(!e)return 0;let t=e.itemsByKey.size;return this._readonly&&(t+=this._readonly.size),t}validateName(e){return this._validateName(e)}_validateName(e,t=!1){if(this._closed)throw new Error(Tt)}add(e){if(this._closed)throw new Error(Tt);if(!e)throw new Error("Item must be specified.");let t;if(e.isIFunction){const o=e,i=e._json;t=new Xo(i,o._fn,()=>this._options.context,o._desc)}else{const o=e;t=new Xo(o.declaration,o.execute,()=>this._options.context,o.descriptor)}const n=this._getState(),r=t.getName().toUpperCase();return n.itemsByKey.set(r,t),t}beginCommit(e){return this._beginCommit(e)}_getState(){if(this._closed)throw new Error(Tt);return this._transactions.getState(this)}_beginCommit(e){return this._transactions.beginCommit(typeof e=="string"?{description:e}:e)}_updateState(e,t="Update",n){if(!e)return;const r=this._beginCommit(t);try{r.updateState(this,e),r.commit(n)}catch(o){throw r.rollback(),o}}_initState(){this._updateState(e=>({...e,itemsByKey:new Map}),"Initialize",{forceAmend:!0})}addListeners(e,t){return this._emitter.addListeners(e,t)}isClosed(){return this._closed}close(){this._closed||(this._emitter.notify("onClose"),this._closed=!0,this._transactionsRemoveListener?.())}get isFunctionCollection(){return!0}}class xc extends ir{constructor(e){super(e),this._status=exports.ICalculation.Status.Off,this._statusTransition=null,this._emitter=new st(this)}_getContext(){return this._context}_getScope(){return this._scope}start(){return this._statusTransition||(this._statusTransition=(async()=>{if(this._status===exports.ICalculation.Status.Off)try{this._status=exports.ICalculation.Status.Starting,this._emitter.notify("onStatusChange"),this._emitter.notify("onStarting");const e=this,t=this._options,n=l=>e.getFunctions().getByName(l)??t?.getFunction?.(l),r=new Kw({...t,getFunction:n});this._context=r;const o=await r._initialize(),i=o.builtInFunctions;this._functions=new gf({transactions:this._transactions,context:r,readonlyFunctions:i});const a=await Promise.resolve().then(()=>require("./BVA-ijQaNPkp7YbF.cjs"));this._formulaParser=new a.FormulaParser,this._scope=o.calcScope,this._status=exports.ICalculation.Status.Ready,this._emitter.notify("onStatusChange"),this._emitter.notify("onReady")}catch(e){throw this._status=exports.ICalculation.Status.Off,this._emitter.notify("onError",e),this._emitter.notify("onStatusChange"),e}finally{this._statusTransition=null}})()),this._statusTransition}_createGraph(e){const t=this._options;return new Ec({...t,...e,getFormulaParser:()=>this._formulaParser,calculation:this})}async stop(){this._status===exports.ICalculation.Status.Ready&&(this._status=exports.ICalculation.Status.Stopping,this._emitter.notify("onStatusChange"),this._emitter.notify("onStopping"),this._status=exports.ICalculation.Status.Off,this._emitter.notify("onStatusChange"),this._emitter.notify("onStop"))}getStatus(){return this._status}getFunctions(){return this._checkReady(),this._functions}getRuntime(){return this._checkReady(),this._runtime}_checkReady(){if(this._status!==exports.ICalculation.Status.Ready)throw new Error(this._statusMessage())}_statusMessage(){switch(this._status){case exports.ICalculation.Status.Off:return"Calculation is off";case exports.ICalculation.Status.Starting:return"Calculation is starting";case exports.ICalculation.Status.Ready:return"Calculation is ready";default:return"Unknown calculation status"}}}var Ns,ks;exports.ICellRange=void 0,exports.ICellRange||(exports.ICellRange={}),exports.ICellHeaderRange=void 0,exports.ICellHeaderRange||(exports.ICellHeaderRange={}),exports.IMovable=void 0,exports.IMovable||(exports.IMovable={}),exports.IAutoFilter=void 0,(Ns=exports.IAutoFilter||(exports.IAutoFilter={})).NumberFilterOperatorType={Equal:"equal",GreaterThan:"greaterThan",GreaterThanOrEqual:"greaterThanOrEqual",LessThan:"lessThan",LessThanOrEqual:"lessThanOrEqual",NotEqual:"notEqual"},Ns.Type={Color:"color",Custom:"custom",Dynamic:"dynamic",Items:"items",Icon:"icon",Top10:"top10"},Ns.DynamicType={AboveAverage:"aboveAverage",BelowAverage:"belowAverage",LastMonth:"lastMonth",LastQuarter:"lastQuarter",LastWeek:"lastWeek",LastYear:"lastYear",M1:"M1",M2:"M2",M3:"M3",M4:"M4",M5:"M5",M6:"M6",M7:"M7",M8:"M8",M9:"M9",M10:"M10",M11:"M11",M12:"M12",NextMonth:"nextMonth",NextQuarter:"nextQuarter",NextWeek:"nextWeek",Null:"null",Q1:"Q1",Q2:"Q2",Q3:"Q3",Q4:"Q4",ThisMonth:"thisMonth",ThisQuarter:"thisQuarter",ThisWeek:"thisWeek",Today:"today",Tomorrow:"tomorrow",YearToDate:"yearToDate",Yesterday:"yesterday"},Ns.DateItemGroupingType={Day:"day",Hour:"hour",Minute:"minute",Month:"month",Second:"Second",Year:"year"},exports.IConditionalFormat=void 0,(ks=exports.IConditionalFormat||(exports.IConditionalFormat={})).Type={AboveAverage:"aboveAverage",BeginsWith:"beginsWith",CellIs:"cellIs",ColorScale:"colorScale",ContainsBlanks:"containsBlanks",ContainsErrors:"containsErrors",ContainsText:"containsText",DataBar:"dataBar",DuplicateValues:"duplicateValues",EndsWith:"endsWith",Expression:"expression",IconSet:"iconSet",NotContainsBlanks:"notContainsBlanks",NotContainsErrors:"notContainsErrors",NotContainsText:"notContainsText",TimePeriod:"timePeriod",Top10:"top10",UniqueValues:"uniqueValues"},ks.OperatorType={BeginsWith:"beginsWith",Between:"between",ContainsText:"containsText",EndsWith:"endsWith",Equal:"equal",GreaterThan:"greaterThan",GreaterThanOrEqual:"greaterThanOrEqual",LessThan:"lessThan",LessThanOrEqual:"lessThanOrEqual",NotBetween:"notBetween",NotContains:"notContains",NotEqual:"notEqual"},ks.TimePeriod={Last7Days:"last7Days",LastMonth:"lastMonth",LastWeek:"lastWeek",NextMonth:"nextMonth",NextWeek:"nextWeek",ThisMonth:"thisMonth",ThisWeek:"thisWeek",Today:"today",Tomorrow:"tomorrow",Yesterday:"yesterday"},ks.ConditionalBoundsType={Formula:"formula",Max:"max",Min:"min",Num:"num",Percent:"percent",Percentile:"percentile"},exports.ISheetView=void 0,(exports.ISheetView||(exports.ISheetView={})).HeaderTextStyle={A1:"a1",Zero:"zero",One:"one"};class iy{constructor(e,t,n,r){this._mergedReading=[],this._colsReading=[],this._rowsReading=[],this._styles=e,this._topLeft=r??{rowIndex:0,colIndex:0},this._sheet=new Gr({styles:this._styles,date1904:t,container:{getName:()=>n,getIndex:()=>1}}),this._cellUpdater=this._sheet.getEntireRange().startIncrementalUpdates()}applyCSSStyle(e,t){let n=!1;e.style||(e.style={},n=!0);let r=e.style,o={...t};if(t.msoIgnore){const u=t.msoIgnore.split(",");let d=Object.keys(o);for(let g=0;g<d.length;g++){const m=d[g];u.includes(m)&&delete o[m]}}const i=di(o.fontFamily);r.font={},i&&(r.font.family=i.family,r.font.fallbacks=i.fallbacks,r.font.size=i.size),r.font.size=o.fontSize,r.font.weight=o.fontWeight,r.font.style=o.fontStyle,r.font.fill=o.color;const a=(u=>{if(!u)return tS;let d=exports.IFont.UnderlineStyle.None,g=!1;return(u=u.toLowerCase()).includes("underline")&&(d=exports.IFont.UnderlineStyle.Single),(u.includes("line-through")||u.includes("linethrough"))&&(g=!0),{underline:d,strike:g}})(o.textDecoration);r.font.underline=a.underline,r.font.strike=a.strike,o.textUnderlineStyle&&(r.font.underline=Jm(o.textUnderlineStyle)),r.alignment={},o?.textAlign&&(r.alignment.horizontal=(u=>{const d=N.textToKey(u);return kn.get(d)||null})(o.textAlign)),o?.textAlign&&!r.alignment.horizontal&&o?.textAlign!=="general"&&(o.textAlign==="center-across"?r.alignment.horizontal=exports.ITextFrame.HorizontalAlignment.CenterContinuous:o.textAlign==="fill"?r.alignment.horizontal=exports.ITextFrame.HorizontalAlignment.Fill:o.textAlign==="121"||o.textAlign==="010"?(r.alignment.horizontal=exports.ITextFrame.HorizontalAlignment.Distributed,r.alignment.justifyLastLine=o.textAlign==="121"):console.warn("unknown text-align",o.textAlign)),o.verticalAlign&&(o.verticalAlign.toLowerCase()==="super"?r.font.verticalAlign=exports.IFont.VerticalAlignment.Super:o.verticalAlign.toLowerCase()==="sup"?r.font.verticalAlign=exports.IFont.VerticalAlignment.Sub:r.alignment.vertical=(u=>{const d=N.textToKey(u);return cn.get(d)||null})(o.verticalAlign),r.alignment.vertical||(o.verticalAlign==="121"?r.alignment.vertical=exports.ITextFrame.VerticalAlignment.Distributed:console.warn("unknown vertical-align",o.verticalAlign))),o.msoCharIndentCount&&(r.alignment.indent=o.msoCharIndentCount),o.whiteSpace&&(r.alignment.overflow=o.whiteSpace==="no-wrap"||o.whiteSpace==="nowrap"?exports.ITextFrame.Overflow.Visible:exports.ITextFrame.Overflow.Wrap),o.msoTextControl==="shrinktofit"&&(r.alignment.overflow=exports.ITextFrame.Overflow.Shrink);let l=null;if(o.background?l=o.background:o.backgroundColor&&(l=o.backgroundColor),l&&(r.fill={color:l}),o.msoPattern){let u=BS(o.msoPattern);u&&(u.patternType===exports.IFill.BuiltInSheetPattern.Solid?r.fill={color:u.foreground}:u.patternType!==exports.IFill.BuiltInSheetPattern.None&&(l&&(u.background=l),r.fill=u))}o.msoRotate!==void 0&&(r.alignment.rotation=(u=>{let d=parseFloat(u);return isNaN(d)||(d%=360,d>0?d=360-d:d<0&&(d*=-1)),d})(o.msoRotate));const c=(u,d)=>{u&&(r.border||(r.border={}),r.border[u]=d)};o.border&&o.border!=="none"&&(c("top",o.border),c("left",o.border),c("right",o.border),c("bottom",o.border)),o.borderTop&&c("top",o.borderTop),o.borderLeft&&c("left",o.borderLeft),o.borderRight&&c("right",o.borderRight),o.borderBottom&&c("bottom",o.borderBottom),o.msoDiagonalUp&&c("diagonalUp",o.msoDiagonalUp),o.msoDiagonalDown&&c("diagonalDown",o.msoDiagonalDown);let h=r.numberFormat;o.msoNumberFormat&&(h=(u=>{let d=u.replace(/(\\[0-9]{4})/g,g=>String.fromCharCode(parseInt(g.replace(/\\/g,""),16)));return d=d.replace(/(\\.{1})/g,g=>g.substring(g.length-1,g.length)),d.includes("\\")&&(d=d.replace(/(\\.{1})/g,g=>g.substring(g.length-1,g.length))),d=d.replace(/^"(.*)"$/,"$1"),d})(o.msoNumberFormat),h.includes("\\")?h=null:h==="Fixed"?h=exports.NumberFormat.Styles.lookupStyle(r.numberFormat).formatType===exports.NumberFormat.Type.Number?null:exports.NumberFormat.Type.Number:h==="Percent"&&(h=exports.NumberFormat.Styles.lookupStyle(r.numberFormat).formatType===exports.NumberFormat.Type.Percentage?null:exports.NumberFormat.Type.Percentage)),h&&(r.numberFormat=h),e.style=this._styles.normalize(r),n&&Object.keys(e.style).length===0&&delete e.style}onCell(e,t,n,r,o){const i=r(o);let a={value:t!==void 0?t:n??""};if(typeof a.value=="string"&&a.value.length===0&&(a.value=void 0),i&&this.applyCSSStyle(a,i),o?.tagName.toUpperCase()==="TD"){let l=a.style,c=l?.font??{};(o.querySelectorAll("s").length>0||o.querySelectorAll("strike").length>0)&&(c.strike=!0),o.querySelectorAll("sub").length>0&&(c.verticalAlign=exports.IFont.VerticalAlignment.Sub),o.querySelectorAll("sup").length>0&&(c.verticalAlign=exports.IFont.VerticalAlignment.Super),(o.querySelectorAll("b").length>0||o.querySelectorAll("strong").length>0)&&(c.weight=700),o.querySelectorAll("i").length>0&&(c.style=exports.IFont.Style.Italic),o.querySelectorAll("u").length>0&&(c.underline=exports.IFont.UnderlineStyle.Single),Object.keys(c).length>0&&(l||(l={},a.style=l),l.font||(l.font=c));const h=o.querySelectorAll("a");if(h.length>0){const u=h[0].getAttribute("href");u&&(a.hyperlink=u)}}if(!k.isSingleCell(e)){const l={rowStart:this._topLeft.rowIndex+e.rowStart,colStart:this._topLeft.colIndex+e.colStart,rowEnd:this._topLeft.rowIndex+e.rowEnd,colEnd:this._topLeft.colIndex+e.colEnd};this._mergedReading.push(l)}if((a.value!==void 0||a.style||!(Object.keys(a).length<=1))&&(this._cellUpdater.pushAt(this._topLeft.rowIndex+e.rowStart,this._topLeft.colIndex+e.colStart,a),!k.isSingleCell(e)&&i.msoIgnore)){if(i.msoIgnore.includes("colspan")){const l={};i&&this.applyCSSStyle(l,i);const c=e.colEnd-e.colStart;for(let h=1;h<=c;h++)this._cellUpdater.pushAt(this._topLeft.rowIndex+e.rowStart,this._topLeft.colIndex+e.colStart+h,l);e={...e,colEnd:e.colStart}}i.msoIgnore.includes("rowspan")&&(e={...e,rowEnd:e.rowStart})}}onNoTable(e,t,n){this.onCell({rowStart:this._topLeft.rowIndex,colStart:this._topLeft.colIndex,rowEnd:this._topLeft.rowIndex,colEnd:this._topLeft.colIndex},e,null,t,n)}onRowStart(e,t,n,r){const o=n(r);if(o.msoHeightSource!=="userset")return;let i=r.getAttribute("height")??o.height,a=null;if(i&&(a=Pr(i,this._styles.getNormal().getFont().getSize(),"px")),a===null)for(let l=0;l<r.cells.length;l++){const c=r.cells[l],h=c.getAttribute("height")??n(c).height;let u=Pr(h,this._styles.getNormal().getFont().getSize(),"px");u!==null&&(a=Math.max(u,a??0))}a!==null&&this._rowsReading.push({address:{min:this._topLeft.rowIndex+e,max:this._topLeft.rowIndex+e+t-1},update:{size:a*exports.IFont.getDeviceScale()}})}onColumn(e,t,n,r){const o=n(r);if(o.msoWidthSource!=="userset")return;let i=r.getAttribute("width")??o.width,a=null;i&&(a=Pr(i,this._styles.getNormal().getFont().getSize(),"px")),a!==null&&this._colsReading.push({address:{min:this._topLeft.colIndex+e,max:this._topLeft.colIndex+e+t-1},update:{size:a*exports.IFont.getDeviceScale()}})}onDone(){this._colsReading.length>0&&this._sheet.getColumnHeaders().updateHeaderPairs(this._colsReading),this._rowsReading.length>0&&this._sheet.getRowHeaders().updateHeaderPairs(this._rowsReading),this._sheet.doBatch(()=>{this._cellUpdater.apply()}),this._mergedReading.length>0&&this._sheet.getRanges(this._mergedReading).merge()}sheet(){return this._sheet}}let Td=!1;class ay{constructor(e,t){this._mapStylesByName=new Map,this._arrStyleNames=[],this._mapStylesByName=e,this._arrStyleNames=t}setNode(e){this._node=e}addStyle(e,t){t!=null&&(this._node?.styles||(this._node.styles=new Map),this._node.styles.set(e,t))}addAttribute(e,t){t!=null&&(this._node?.attributes||(this._node.attributes=new Map),this._node.attributes.set(e,t),e.toLowerCase()==="rowspan"&&parseInt(t)>1&&(this._node.rowspan=parseInt(t)),e.toLowerCase()==="colspan"&&parseInt(t)>1&&(this._node.colspan=parseInt(t)))}addSharedStyle(e,t){let n=this._mapStylesByName.get(e);n?n={...t}:(this._arrStyleNames.push(e),n=t),this._mapStylesByName.set(e,n)}setPlainText(e){this._node.plainText=e}setHTMLText(e){this._node.htmlText=e.replace(/(?:\r\n|\r|\n)/g,"<br>")}}const Fd=s=>{const e={};if(!s)return e;s.endsWith(";")||(s+=";");const t=new RegExp(';(?=([^"]*"[^"]*")*[^"]*$)',"gsm");let n,r=0;for(;(n=t.exec(s))!==null;){try{let o=s.substring(r,n.index).trim();const i=new RegExp(':(?=([^"]*"[^"]*")*[^"]*$)',"gsm");let a,l,c;for(;(c=i.exec(o))!==null;)a=unescape(o.substring(0,c.index)).trim(),l=unescape(o.substring(c.index+1,o.length)).trim();l!==null&&l!=="null"&&(a&&(a=Zg(a)),e[a]=l)}catch(o){console.warn(o)}r=n.index+1}return e},Os=(s,e)=>{const t=[];if(!s)return t;const n=s.children;for(let r=0;r<n.length;r++){const o=n.item(r);if(o.nodeType===1){const i=o.tagName.toUpperCase();e.includes(i)&&t.push(o)}}return t},ly=(s,e,t)=>{try{let n=null,r=null;const o=l=>((c,h)=>{if(!c)return{};let u={},d=h.get(c.localName);d&&(u=Object.assign(u,d));const g=c.getAttribute("class");if(g){const f=h.get("."+g);f&&(u=Object.assign(u,f))}const m=c.getAttribute("style");if(m){const f=Fd(m);f&&(u=Object.assign(u,f))}return c.getAttribute("align")&&!u.textAlign&&(u.textAlign=c.getAttribute("align")),u})(l,r);if(s)try{n=[];const l="P, H1, H2, H3, H4, H5, H6, PRE",c=s.querySelector("parsererror");if(c)return console.warn("error",c),!1;const h=s.querySelectorAll("html"),u=h[h.length-1];r=(p=>{const S=p.querySelectorAll("style"),C=new Map;if(S.length<=0)return C;for(let y=0;y<S.length;y++){const b=S[y].childNodes;for(let w=0;w<b.length;w++)if(b[w].nodeType===Node.TEXT_NODE){const E=new RegExp("<!--(.*)-->","gs");let I=b[w].textContent;const x=E.exec(b[w].textContent);if(x&&x.length>1&&(I=x[1]),I=I.replace(/^\s/,""),I?.startsWith("table")){const v=new RegExp("{(.*?)}","gs");let R,A=0;for(;(R=v.exec(I))!==null;)try{const M=I.substring(A,R.index),T=Fd(R[1]);C.set(M.trim(),T),A=R.index+R[0].length}catch(M){console.warn(M)}return C}}}return C})(u);const d=u.querySelectorAll("body"),g=d[d.length-1];let f=g.querySelectorAll("table")[0],_=!1;if(!f){let p=g.querySelectorAll("span");f=p[0],_=p.length>1}if(f||(f=Os(g,l)[0]),f||(f=Os(s,l)[0]),f?.nodeName.toUpperCase()==="TABLE"){t.onStart?.(r);const p=f;t.onTableStart?.(o,p);const S=Os(p,"COLGROUP");for(let b=0;S&&b<S.length;b++){const w=Os(S[b],"COL");let E=0;for(let I=0;I<w.length;I++){const x=w[I],v=parseFloat(x.getAttribute("span")),R=isNaN(v)?1:v;t.onColumn?.(E,R,o,x),E+=R}}const C=p.rows;let y=0;for(let b=0;b<C.length;b++){const w=C[b],E=parseFloat(w.getAttribute("span")),I=isNaN(E)?1:E;t.onRowStart?.(y,I,o,w);const x=[];n.push(x);const v=w.cells;for(let R=0;R<v.length;R++){let A=v[R],M=!1;for(let T=0;!M&&T<A.childNodes.length;T++)if(A.childNodes[T].nodeType===8){const F=A.childNodes[T].textContent;if(F!=="[if gte vml 1]"){if(F!=="[if !vml]"){if(F==="[endif]"){const L=A.childNodes[T+1];L?.querySelectorAll&&L.querySelectorAll("table, td").length===2&&(A=L?.querySelectorAll("table, td")[1],M=!0)}}}}x.push({htmlValue:A.textContent?.replace(/^"|"$/gi,""),element:A})}y+=I,t.onRowDow?.(y,I,o,w)}t.onTableDone?.(o,p)}else{if(f?.nodeName.toUpperCase()==="SPAN"){const p=e?e[0]?.[0]:null,S=_&&p?p:f.textContent.replace(/^"|"$/gi,"");return t.onStart?.(r),t.onCell({colStart:0,colEnd:0,rowStart:0,rowEnd:0},e?e[0]?.[0]:null,S,o,f),t.onDone?.(),!0}if(f?.textContent){const p=f.textContent.replace(/^"|"$/gi,"");return t.onStart?.(r),t.onNoTable?.(p,o,f),t.onDone?.(),!0}}}catch(l){console.warn(l),n=null}!n||n.length!==0&&(n.length!==1||n[0]!==null&&n[0].length!==0)||(n=null);const i=e&&(e.length===0||e.length===1&&(e[0]===null||e[0].length===0));n&&i&&(e=null);const a=l=>{const c=new Set;let h=1,u=1;for(let d=0;d<Math.max(e?e.length:0,n?n.length:0);d++){let g=0,m=0,f=n&&n[d]?n[d].length:e[d]?e[d].length:0;for(;m<f;){const _=d+"-"+g;if(!c.has(_)){h=Math.max(h,g+1),u=Math.max(u,d+1);let p=null;const S=n?n[d]?.[m]?.element:void 0;if(S&&(S.getAttribute("rowspan")||S.getAttribute("colspan"))){const C=parseInt(S.getAttribute("colspan"))||1,y=parseInt(S.getAttribute("rowspan"))||1;h=Math.max(h,g+C),u=Math.max(u,d+y),p={rowStart:d,colStart:g,rowEnd:d+Math.max(0,y-1),colEnd:g+Math.max(0,C-1)};for(let b=d;b<d+y;b++)for(let w=g;w<g+C;w++)b===d&&w===g||c.add(b+"-"+w)}else p={rowStart:d,colStart:g,rowEnd:d,colEnd:g};l(p,e?e[d]?.[g]:void 0,n?n[d]?.[m]?.htmlValue:null,o,S||null),m++}g++}}};if(n&&e){let l=0,c=0;a(h=>{l=Math.max(l,h.colEnd+1),c=Math.max(c,h.rowEnd+1)}),e&&n&&(e.length!==c||e[0].length!==l)&&(console.warn("mismatched mimeTypes",e,n),e=null)}return a(t.onCell.bind(t)),t.onDone?.(),!i||n!==null}catch(n){throw console.warn(n),n}};exports.ISheet=void 0,(exports.ISheet||(exports.ISheet={})).Visibility={Visible:"visible",Hidden:"hidden",VeryHidden:"veryHidden"};class Pi extends Xi{static{this.instanceCounter=0}constructor(e){if(super(e),!e.content)throw new Error("Content type is required");this._content=e.content,this._uuid=N.uuidV4(),this._optionsMovable=e;const t=this;this._optionsMovable.setContainerZIndexCallback?.(()=>{t._processZIndex()}),this._optionsMovable.setContainerSelectionCallback?.((r,o)=>{t._processContainerSelect(r,o)}),e.json&&this._fromJSON(e.json);const n=this._content.addListeners({onDelete:()=>{t._options.deleteFromContainer&&t._options.deleteFromContainer?.()}},{transactional:!0});this._updateState({contentListenerRemove:n},null,[])}getUUID(){return this._uuid}getContent(){return this._content}_processStateChange(e,t,n){super._processStateChange(e,t,n),this._getEmitter().notify("onBoundsChange"),this._getEmitter().notify("onAnyChange")}_processZIndex(){this._getEmitter().notify("onAnyChange")}_processContainerSelect(e,t){this._getEmitter().notify("onSelectionChange")}isSelected(){return this._optionsMovable.isSelected?.()??!1}async scrollIntoView(e){return this._optionsMovable.scrollIntoView?.(e)??!1}async select(e){if(await this._optionsMovable.select?.(e)===!1)return!1;if(e?.autoFocus!==!1){const t=await this._getEmitter().notify("onRequestFocus",{async:!0});if(!t)return!1;for(let n=0;n<t.length;n++)if(t[n]===!1)return!1}return!0}unselect(){const e=this._optionsMovable.isSelected?.()??!1;return this._optionsMovable.unselect?.(),e}_clone(){const e=this.isSelected(),t=this.getZIndex(),n=this._optionsMovable.getMaxBounds,r=this._options.maxRangeCoords,o=this.getContent(),i={beginPersistResource:this._optionsMovable.beginPersistResource,getBoundsAtCoords:this._optionsMovable.getBoundsAtCoords,getCoordsAtBounds:this._optionsMovable.getCoordsAtBounds,isSelected:()=>e,getZIndex:()=>t,getMaxBounds:n,maxRangeCoords:r,transactions:new Bt({transient:!0}),json:this.toJSON(),initialAnchor:this.getAnchorCoords(),content:o},a=new Pi(i),l=this._getState();return a._updateState({...l}),a}getSnapshot(e,t){const n=this._optionsMovable.getCoordsAtBounds(e),r=this._getState().offsets;let o=this.getAnchorCoords();if((r.br.x>0||r.br.y>0)&&(o={...o},o.colEnd-=r.br.x>0?1:0,o.rowEnd-=r.br.y>0?1:0),!k.isRangeWithinRange(o,n))return null;const i=this,a=i._clone(),l=Object.freeze({...t});let c=!1;return{async copyTo(u,d){const g={...l,...d};return await a._doCopy(u,g),g.isCut&&!c&&(i.delete(),c=!0),u.bounds},getCoords:()=>a.getBounds(),getSource:()=>a,getName:()=>a.getName(),getMarkOptions:()=>l,toText:()=>a._toText(),toHtml:()=>a._toHtml(),toImage:()=>a._toImage(),isISnapshot:!0}}async _doCopy(e,t){const n=this._optionsMovable.beginPersistResource(),r=this.toJSON(n.toResourceId.bind(n));r.content.json.name=`${this.getName()} (Copy)`;const o=r.content.json;delete r.content;const i=e.movables;if(!i)throw new Error("Movables is required");const a=e.bounds??this.getBounds();try{await i.add({...r,...t,fromResourceId:n.fromResourceId.bind(n),bounds:a,type:this.getContent().getType(),json:o,description:"Copy Movable"})}finally{n.endPersist()}}_toText(){return this.getContent().toText?.()}_toHtml(){return this.getContent().toHtml?.()}_toImage(){return this.getContent().toImage?.()}setName(e){return this._updateState({name:e},{description:"Set Movable Name"},["onNameChange"]),this}getName(){return this.isClosed()?null:this._getState()?.name}setDescription(e){return this._updateState({description:e},{description:"Set Movable Description"}),this}getDescription(){return this.isClosed()?null:this._getState()?.description}setHidden(e=!1){return this._updateState({hidden:e},{description:"Set Movable Visibility"}),this}isHidden(){return this._getState()?.hidden??!1}setLockAspectRatio(e){return this._updateState({lockAspectRatio:e},{description:"Set Lock Aspect Ratio"}),this}isLockAspectRatio(){return this._getState()?.lockAspectRatio??this._optionsMovable.defaultLockAspectRatio??!1}setRotation(e=0){return this._updateState({rotation:e},{description:"Set Movable Rotation"}),this}getRotation(){return this._getState()?.rotation??0}moveToBack(){return this._optionsMovable.moveToBackOnContainer?.(),this}moveBackward(){return this._optionsMovable.moveBackwardOnContainer?.(),this}moveToFront(){return this._optionsMovable.moveToFrontOnContainer?.(),this}moveForward(){return this._optionsMovable.moveForwardOnContainer?.(),this}getZIndex(){return this._optionsMovable.getZIndex?.()??0}setBounds(e,t){if(!e)return this;let n={...this.getBounds(),...e};if(this._optionsMovable.getMaxBounds&&(n={x:Math.max(n.x,this._optionsMovable.getMaxBounds().x),y:Math.max(n.y,this._optionsMovable.getMaxBounds().y),width:Math.min(n.width,this._optionsMovable.getMaxBounds().width),height:Math.min(n.height,this._optionsMovable.getMaxBounds().height)}),n.width<0||n.height<0)throw new Ne;const r=this._updateMovableLocation({bounds:n,anchorType:exports.IAnchored.Type.Absolute}),o=this._beginCommit(t?.description??"Set Movable Bounds");return this._updateState({offsets:r.offsets,anchor:r.anchor},{description:"Update Movable Bounds"}),this._options.setContainerCoords(r.anchor),this._invalidateBounds(),o.commit(),this}_updateMovableLocation(e){let t=e.offsets??{tl:{x:0,y:0},br:{x:0,y:0}},n=e.anchor??this.getAnchorCoords(),r=e.anchorType??this.getAnchorType();const o=e.bounds??this.getBounds();if(o){if(r===exports.IAnchored.Type.Absolute){n=this._optionsMovable.getCoordsAtBounds(o);const i=this._optionsMovable.getBoundsAtCoords(n);t={...t,tl:{x:o.x-i.x,y:o.y-i.y}}}if(r===exports.IAnchored.Type.Absolute||r===exports.IAnchored.Type.OneCell){const i=this._optionsMovable.getBoundsAtCoords({rowStart:n.rowStart,colStart:n.colStart,colEnd:n.colStart,rowEnd:n.rowStart}),a=this._optionsMovable.getCoordsAtBounds({x:i.x,y:i.y,width:o.width+Math.min(i.width,t.tl.x),height:o.height+Math.min(i.height,t.tl.y)});n={...n,colEnd:a.colEnd,rowEnd:a.rowEnd};const l=this._optionsMovable.getBoundsAtCoords({colStart:n.colEnd,rowStart:n.rowEnd,colEnd:n.colEnd,rowEnd:n.rowEnd}),c=o.width-(l.x-i.x-Math.min(t?.tl.x??0,i.width)),h=o.height-(l.y-i.y-Math.min(t?.tl.y??0,i.height));t={...t,br:{x:c,y:h}}}return t!==e.offsets&&(t.br.y<=0&&(t.br={...t.br,y:0},n.rowEnd--),t.br.x<=0&&(t.br={...t.br,x:0},n.colEnd--)),{anchor:n,offsets:t}}}_calcAbsoluteBounds(e,t={tl:{x:0,y:0},br:{x:0,y:0}}){if(!e)return null;const n=this._optionsMovable.getBoundsAtCoords({rowStart:e.rowStart,colStart:e.colStart,colEnd:e.colStart,rowEnd:e.rowStart});let r=t.br.x?0:1,o=t.br.y?0:1;const i=this._optionsMovable.getBoundsAtCoords({colStart:e.colEnd+r,rowStart:e.rowEnd+o,colEnd:e.colEnd+r,rowEnd:e.rowEnd+o}),a=Math.min(n.x+(t?.tl.x??0),n.x+n.width),l=Math.min(n.y+(t?.tl.y??0),n.y+n.height);return{x:a,y:l,width:Math.min(i.x+(t?.br.x??0),i.x+i.width)-a,height:Math.min(i.y+(t?.br.y??0),i.y+i.height)-l}}getBounds(){return this._getState()?.bounds}setAnchorType(e){return N.validEnumValue(exports.IAnchored.Type,e),this._updateState({anchorType:e},{description:"Set Movable Resize Behavior"},["onAnchorTypeChange"]),this}_processContainerShift(e){const t=this.getAnchorType(),n=this._getState()?.offsets;let r=n,o=!1;const i=e.before,a=e.orientation===exports.w.Orientation.Column,l=e.intersect,c=e.amount;let h=e.after;if(t!==exports.IAnchored.Type.Absolute){let g=a?l.colStart:l.rowStart,m=a?i.colStart:i.rowStart;t===exports.IAnchored.Type.TwoCell&&(m=a?i.colEnd:i.rowEnd),o=g<=m}if(o&&(t!==exports.IAnchored.Type.OneCell||h)||(h=i),o&&h&&c<0&&(a?(l.colStart<=i.colStart&&l.colEnd>=i.colStart&&(r={...r,tl:{...r.tl,x:0}}),r.br.x>0&&l.colStart<=i.colEnd&&l.colEnd>=i.colEnd&&(r={...r,br:{...r.br,x:0}},h={...h,colEnd:h.colEnd+1})):(l.rowStart<=i.rowStart&&l.rowEnd>=i.rowStart&&(r={...r,tl:{...r.tl,y:0}}),r.br.y>0&&l.rowStart<=i.rowEnd&&l.rowEnd>=i.rowEnd&&(r={...r,br:{...r.br,y:0}},h={...h,rowEnd:h.rowEnd+1}))),h!==null){const{offsets:g,anchor:m}=this._updateMovableLocation({anchor:h,offsets:r});r=g,h=m}let u=null;const d=this._beginCommit("Shifting Movable Bounds");try{if(n!==r||!k.isEqualRanges(i,h)){const g={offsets:r,anchor:h};this._updateState(g)}this._invalidateBounds(),u=super._processContainerShift({...e,after:h}),d.commit()}catch(g){throw d.rollback(),g}return u}_invalidateBounds(){const e=this.getAnchorCoords();if(e===null)return null;const t=this._getState()?.offsets,n=this._calcAbsoluteBounds(e,t);this._updateState({bounds:n},null,["onBoundsChange"])}_processContainerDelete(){super._processContainerDelete(),this._getState().contentListenerRemove?.(),this.getContent().delete()}_processContainerLayout(){const e=this.getAnchorCoords(),t=this._getState()?.offsets,{offsets:n,anchor:r}=this._updateMovableLocation({anchor:e,offsets:t}),o=this._beginCommit("Updating Movable Bounds");try{if(t!==n||e!==r){const i={offsets:n,anchor:r};this._updateState(i)}this._invalidateBounds(),super._processContainerLayout(),o.commit()}catch(i){throw o.rollback(),i}}_processAnchorCoords(){super._processAnchorCoords()}_fromJSON(e){const t={tl:{x:0,y:0},br:{x:0,y:0}},n={...k.EmptyRange};e.anchor&&(t.tl.x=e.anchor.tl?.x??0,t.tl.y=e.anchor.tl?.y??0,t.br.x=e.anchor.br?.x??0,t.br.y=e.anchor.br?.y??0,n.colStart=e.anchor.tl?.c??0,n.rowStart=e.anchor.tl?.r??0,n.colEnd=Math.max(n.colStart,(e.anchor.br?.c??0)+(t.br.x>0?0:-1)),n.rowEnd=Math.max(n.rowStart,(e.anchor.br?.r??0)+(t.br.y>0?0:-1)));const r=this._beginCommit("Load Movable"),o=e.content.json,i={offsets:t,name:o.name??null,description:o.name??null,hidden:o.hidden??!1,rotation:o.rotation??0,lockAspectRatio:o.lockAspect??null};e.anchorType&&(i.anchorType=e.anchorType),i.name||(i.name=`${this._content.getTypeDescription()} ${++Pi.instanceCounter}`),i.bounds=this._calcAbsoluteBounds(n,t),this._updateState(i,{description:"Load Movable"}),this._optionsMovable.setContainerCoords?.(n),r.commit()}toJSON(e){const t=this._getState(),n=t.anchor,r=t.offsets,o={tl:{c:n.colStart,r:n.rowStart},br:{c:n.colEnd+(r.br.x?0:1),r:n.rowEnd+(r.br.y?0:1)}};r&&(r.tl?.x&&(o.tl.x=N.roundAccurately(r.tl.x,1)),r.tl?.y&&(o.tl.y=N.roundAccurately(r.tl.y,1)),r.br?.x&&(o.br.x=N.roundAccurately(r.br.x,1)),r.br?.y&&(o.br.y=N.roundAccurately(r.br.y,1)));const i=this._content.toJSON(e)??{},a={anchor:o,content:{type:this._content.getType(),json:i}},l=t.anchorType;return l&&l!==exports.IAnchored.Type.TwoCell&&(a.anchorType=this.getAnchorType()),t.hidden&&(a.hidden=t.hidden),t.name&&(a.name=t.name),t.description&&(a.name=t.description),t.rotation!==void 0&&t.rotation!==0&&(a.rotation=t.rotation),N.isDefined(t.lockAspectRatio)&&t.lockAspectRatio!==this._optionsMovable.defaultLockAspectRatio&&(a.lockAspect=t.lockAspectRatio),a}get isIMovable(){return!0}}class cy{constructor(e,t,n,r,o,i){this._add=e,this._search=t,this._getCount=n,this._updateSelected=r,this._addListeners=o,this._addImage=i}async add(e){return this._add(e)}search(e){return this._search(e)}getCount(){return this._getCount()}updateSelected(e,t){return this._updateSelected(e,t)}addListeners(e,t){return this._addListeners(e,t)}addImage(e,t){return this._addImage(e,t)}}const ll={transactional:!0,ignoreDataChanges:!0};class Nd extends Cm{constructor(e){super({...e,type:"namedReference"});const t=this;this._listener=r=>{const o=this._getState().ranges;let i=r.getSource(),a=!1;const l={ranges:i};if(r.trigger==="moveCells"){const u=t._getState(),d=r.getTo(),g=r.getFrom(),m=[];for(let p=0;p<o.getCount();p++){const S=o.at(p);if(m.push(S.getCoords()),!S.isInvalid()){for(let C=0;C<g.getCount();C++){const y=g.at(C).getCoords(),b=S.getCoords();if(!k.isRangeWithinRange(b,y))continue;const w=d.getCoords(),E=w.colStart-y.colStart+b.colStart,I=w.rowStart-y.rowStart+b.rowStart,x={...b,colStart:E,rowStart:I,colEnd:E+(b.colEnd-b.colStart),rowEnd:I+(b.rowEnd-b.rowStart)};(d.size!==1||k.isRangeWithinRange(x,w))&&(m[p]=d.getSource().getRange(x).getCoords(),a=!0)}if(!a)return}}const f=this._options.addressToRanges(m);let _;u.removeListener?.(),f.isInvalid()||(_=f.addListener(t._listener,ll)),l.ranges=f,l.removeListener=_}this._updateState(l,null,["onRangesChange"]);const c=i.getCoords();let h=!c||c.length===0;for(let u=0;!h&&u<c.length;u++)if(!c[u]){h=!0;break}h&&t.delete()};const n=e.value;if(n&&!n.isInvalid()){const r=n.addListener(this._listener,ll);this._updateState({ranges:n,removeListener:r},null)}}setReference(e){const t=this._options.addressToRanges(e);if(t&&!t.isInvalid()){this._getState().removeListener?.();const r=t.addListener(this._listener,ll);this._updateState({ranges:t,removeListener:r},null)}return null}async select(e){return await this._getState().ranges.select(e),this}getRanges(){return this._getState().ranges}setHidden(e=!1,t){return this._updateState({hidden:e},{description:"Set Hidden",...t},[]),this}setScope(e,t){return this._updateState({scope:e},{description:"Set Scope",...t},[]),this}getType(){return"reference"}getValue(){return this._getState().ranges}toJSON(){const e=super._toJSON();return e.ref=this._getState().ranges.toString(),e}_getDescription(){return`Named '${this.getName()}'`}_processDelete(){const e=this._getState();e&&e.removeListener?.(),super._processDelete()}}const kd="Item must be specified.",Od="Name must be a non-empty string",Bd=(s,e=null)=>`Named item '${s}' already exists${e?`in scope ${e}`:""}.`,Dd=s=>{const e=[];for(let t=0;t<s.getCount();t++){let n=null;try{n=s.at(t),n.isICellRange&&(n=n.getFixed(!0))}catch(r){console.warn("Invalid range",r)}e.push(n?n.toString().toLowerCase():Ke)}return e.sort(),e.join(",")},hy=/^[^a-zA-Z_\\]+$/,uy=/^[^a-zA-Z0-9_.]+$/;class mf{constructor(e){this._emitter=null,this._closed=!1,this._lastLookup=N.EmptyArray,this._lastLookupAddress=null,this._lastLookupScope=null,this._lastLookupType=null,this._allowExtrudes=!1,this._options={...e};const t=this;this._transactions=this._options.transactions??new Bt({transient:!0}),this._transactionsRemoveListener=this._transactions.addStateListener(this,{onAfterStateChange(n,r,o){r?.initial||t._emitter.notify("onCollectionChange")}}),this._emitter=new st(this,this._transactions),this._initState(),this._fromJSON(this._options?.json)}search(e){if(this.isClosed())return N.EmptyArray;const t=this._getState();if(!t)return N.EmptyArray;const n=t.itemsSpatial;if(n.isEmpty())return N.EmptyArray;if(e&&e.address===this._lastLookupAddress&&e.scope===this._lastLookupScope&&e.type===this._lastLookupType&&e.allowExtrudes===this._allowExtrudes)return this._lastLookup;this._lastLookupAddress=e?.address??void 0,this._lastLookupScope=e?.scope??void 0,this._lastLookupType=e?.type??void 0,this._allowExtrudes=e?.allowExtrudes??void 0;let r=null;if(e?.address){const h=this._options.addressToRanges(e?.address);if(!h)return console.warn("invalid address",e?.address),this._lastLookup=null,null;r=h.getCoords()}let o=null;if(r){o=[];for(let h=0;h<r.length;h++){const u=n.search(r[h]);for(let d=0;d<u.length;d++)o.push(u[d])}}else o=n.all();if(!o||o.length===0)return this._lastLookup=N.EmptyArray,N.EmptyArray;const i=new Set,a=new Set;o.forEach(h=>{const u=h.value;if(!e?.type||u.getType()===e.type){if(r&&!e?.allowExtrudes){const d=u.getRanges?.();if(!d||d.getCount()===0)return;for(let g=0;g<r.length;g++)if(!k.isRangeWithinRange(h,r[g]))return}!e?.scope||u.getScope()!==e.scope&&e.scope!=="all"?u.getScope()||a.add(u):i.add(u)}});const l=new Map;a.forEach(h=>{l.set(h.getName(),h)}),i.forEach(h=>{l.set(h.getName(),h)});let c=[];return l.forEach(h=>{c.push(h)}),c=c.sort((h,u)=>{let d=h.getType().localeCompare(u.getType());return d!==0?d:h.getName().localeCompare(u.getName())}),this._lastLookup=c,c}lookupByRanges(e){const t=this._options.addressToRanges(e);if(!t||t.getCount()===0)return null;const n=this._getState();if(!n||n.itemsByKey.size===0)return null;const r=Dd(t),o=n.itemsByFullRange.get(r);if(!o)return null;const i=[];return o.forEach(a=>{const l=n.itemsByKey.get(a);l&&i.push(l.item)}),i.length>0?i:null}getByName(e,t=!1){if(!e)return null;const n=this._getState();if(!n||n.itemsByKey.size===0||typeof e!="string")return null;const r=e.toLowerCase(),o=this._options.getCurrentScope();if(!t&&o){const a=r+":"+o.toLowerCase(),l=n.itemsByKey.get(a);if(l)return l.item}return n.itemsByKey.get(r)?.item??null}getCount(){const e=this._getState();return e?e.itemsByKey.size:0}getRanges(e){const t=this._options.addressToRanges(e),n=[];for(let r=0;r<t.getCount();r++){const o=t.at(r).getFixed(!0).getCoords();n.push(o)}return this._options.addressToRanges(n)}findValidName(e,t=null,n=!1){if(!e)throw new Error("A template string must be specified.");const r=this,o=i=>{try{return r._validateName(i,t,n),!0}catch{}return!1};return o(e)?e:Qg(e,o)}validateName(e,t=null,n=!1){return this._validateName(e,t,n)}_validateName(e,t,n=!1){if(this._closed)throw new Error(Tt);if(!e||e.length===0)throw new Error(Od);if(e.length>255)throw new Error("Name must not exceed 255 characters.");if(e.indexOf(" ")!==-1)throw new Error("Name must not contain any spaces.");const r=e.trim().toLowerCase(),o=r.substring(1,e.length-1);if(new RegExp(hy).test(r[0]))throw new Error("First letter must be either a letter, an underscore, or a backslash.");if(new RegExp(uy).test(o))throw new Error("Name must be either letters, numbers, periods or underscores.");if(r.length===1&&(r[0]==="r"||r[0]==="c"))throw new Error("Name can not be 'r' or 'c'.");if(((l,c=V_,h=Om,u=!1)=>{let d=zm(l,u);if(!d||d[2]||!d[1])return!1;const g=Hl(l,Vl);if(!g)return!1;const m=g.rowIndex;if(m<0||m>c)return!1;const f=g.colIndex;return!(f<0||f>=h)})(e))throw new Error("Name can not be an address.");let i=e.toLowerCase()?.trim();t&&(i=i+":"+t.toLowerCase());const a=this._getState()?.itemsByKey.get(i);if(a){const l=a.item.getRanges();if(!n||l||l.getCount()>0)throw new Error(Bd(e,t))}}addReference(e,t,n=!1){const r=this._options.addressToRanges(t),o=this.getByName(e);let i=null;const a=this._beginCommit(`${o&&n?"Update":"Insert"} Named '${e}'`);try{if(o){if(!n)throw new Error(Bd(e));this._delete(o,{description:`Delete Named '${o.getName()}'`})}i=new Nd({value:r,addressToRanges:this._options.addressToRanges,json:{name:e,ref:r.toString()},transactions:this._transactions}),this.add(i),a.commit()}catch(l){throw a.rollback(),l}return i}add(e){if(this._closed)throw new Error(Tt);if(!e)throw new Error(kd);if(!e.getName||typeof e=="string")throw new Error("Add must take a 'INamed' object. To add a string use 'addReference'.");if(this._validateName(e.getName(),e.getScope(),!1),this._options.isReadOnly?.())throw new Error("Names are read-only.");const t=this._beginCommit(`Insert Named Item '${e.getName()}'`),n=this._add([e]);if(n===null)return t.rollback(),null;const r=n.itemsByKey.get(e.getName().toLowerCase());return this._updateState(o=>({...o,...n})),t.commit(),r?.item??null}_toKey(e){let t=e.getName().toLowerCase();return t.startsWith("_xlnm.")&&(t=t.substring(6)),e.getScope()?t+":"+e.getScope().toLowerCase():t}_delete(e,t){if(!e)throw new Error(kd);if(this._closed)throw new Error(Tt);const n=this._beginCommit(t?.description??`Delete Named Item '${e.getName()}'`);let r=null;try{const o=this._getState()?.itemsByKey,i=this._toKey(e);if(r=o.get(i),!r)throw new Error(`Item '${e.getName()}' does not exist.`);const a=this._cloneState();this._index(i,null,a),this._updateState(l=>({...l,...a})),n.commit()}catch(o){throw n.rollback(),o}return this._emitter.notify("onCollectionChange"),r.item}_cloneState(){const e=this._getState();return{itemsBySource:new Map(e.itemsBySource),itemsByKey:new Map(e.itemsByKey),itemsSpatial:e.itemsSpatial.clone(),itemsByFullRange:new Map(e.itemsByFullRange),itemsByPartialRange:new Map(e.itemsByPartialRange)}}_index(e,t,n){const r=n.itemsByKey.get(e);if(r){const i=r.asPartialRanges;if(i)for(let l=0;l<i.length;l++){const c=n.itemsByPartialRange.get(i[l]);if(c)if(c.size===1)n.itemsByPartialRange.delete(i[l]);else{const h=new Set(c);h.delete(e),n.itemsByPartialRange.set(i[l],h)}}const a=r.asFullRange;if(a){const l=n.itemsByFullRange.get(a);if(l)if(l.size===1)n.itemsByFullRange.delete(a);else{const c=new Set(l);c.delete(e),n.itemsByFullRange.set(a,c)}}if(r.nodes)for(let l=0;l<r.nodes.length;l++)n.itemsSpatial.remove(r.nodes[l]);r.unwatch?.(),n.itemsByKey.delete(e),n.itemsBySource.delete(r.item)}let o=null;if(t){let i=[],a=null,l=null;o=t.getRanges?.();const c=this._toKey(t);if(o){const{asFullRange:g,asPartialRanges:m,asRanges:f}=(_=>{const p=_.getCoords(),S=Dd(_),C=S.split(",");return{asFullRange:S,asPartialRanges:C,asRanges:p}})(o);if(a=g,l=m,f){for(let _=0;_<m.length;_++){let p=n.itemsByPartialRange.get(m[_]);const S=p?new Set(p):new Set;S.add(c),n.itemsByPartialRange.set(m[_],S),i.push({...f[_],value:t})}if(n.itemsSpatial.load(i),g){let _=n.itemsByFullRange.get(g);const p=_?new Set(_):new Set;p.add(c),n.itemsByFullRange.set(g,p)}}}const h=this,u=t.addListeners({onDelete:g=>{h._delete(g)},onAnyChange:g=>{const m=h._beginCommit(`Update Named '${g.getName()}'`);try{const f=h._cloneState(),_=f.itemsBySource.get(g).globalKey;h._index(_,g,f),h._updateState(p=>({...p,...f})),m.commit()}catch(f){throw m.rollback(),f}}},{transactional:!0}),d={item:t,asFullRange:a,asPartialRanges:l,unwatch:u,nodes:i,globalKey:c};n.itemsByKey.set(c,d),n.itemsBySource.set(t,d)}}_add(e){if(this._closed)throw new Error(Tt);const t=this._getState();if(!e)return t;const n=this._cloneState();for(let r=0;r<e.length;r++){const o=e[r];if(!o.getName())throw new Error(Od);const i=this._toKey(o);try{this._index(i,o,n)}catch(a){console.warn(`Unable to add named item '${i}'.`,a)}}return n}beginCommit(e){return this._beginCommit(e)}_getState(){if(this._closed)throw new Error(Tt);return this._transactions.getState(this)}_beginCommit(e){return this._transactions.beginCommit(typeof e=="string"?{description:e}:e)}_updateState(e,t="Update"){if(!e)return;this._lastLookup=N.EmptyArray,this._lastLookupAddress=null,this._lastLookupType=null,this._lastLookupScope=null;const n=this._beginCommit(t);try{n.updateState(this,e),n.commit()}catch(r){throw n.rollback(),r}}fromJSON(e){if(this._closed)throw new Error(Tt);this._fromJSON(e)}_initState(){this._updateState(e=>({...e,items:new Set,itemsByKey:new Map,itemsSpatial:new be,itemsByFullRange:new Map,itemsByPartialRange:new Map}))}_fromJSON(e){const t=this._beginCommit("Load Names");try{if(e){const n=[];for(let o=0;o<e.length;o++){const i=e[o];try{const a=this._options.addressToRanges(i.ref),l=new Nd({value:a,addressToRanges:this._options.addressToRanges,deleteFromContainer:c=>{this._delete(l,c)},json:i,transactions:this._transactions});n.push(l)}catch(a){console.warn("Unable to load named item.",i,a.message)}}const r=this._add(n);this._updateState(o=>({...o,...r}))}t.commit({viewAfter:{initial:!0}})}catch(n){throw t.rollback(),n}}toJSON(){const e=this._getState();if(!e||e.itemsByKey.size===0)return null;const t=[],n=Array.from(e.itemsByKey.keys()).sort();for(let r=0;r<n.length;r++){const o=e.itemsByKey.get(n[r]).item,i=o.toJSON?.();i&&t.push(i)}return t.length===0?null:t}addListeners(e,t){return this._emitter.addListeners(e,t)}isClosed(){return this._closed}close(){this._closed||(this._emitter.notify("onClose"),this._closed=!0,this._transactionsRemoveListener?.())}get isNamedCollection(){return!0}}class dy extends ir{constructor(e){super(e),e.json&&this._updateState({data:e.json})}getType(){return"chart"}getDescription(){return`Chart: ${this._getState()?.data?.types?.[0]?.type??"unknown"}`}toJSON(e){const t=this._getState();let n=null;return t&&t.data&&(n=t.data),n}getTypeDescription(){return"Chart"}}class gy extends ir{constructor(e){super(e),e.json&&this._updateState({data:e.json})}getType(){return"shape"}getDescription(){return`Shape: ${this._getState()?.data}`}toJSON(e){const t=this._getState();let n=null;return t&&t.data&&(n=t.data),n}getTypeDescription(){return"Shape"}}class my extends ir{constructor(e){super(e),e.json&&this._updateState({data:e.json})}getType(){return"custom"}getDescription(){return`CustomElement: ${this._getState()?.data}`}toJSON(e){const t=this._getState();let n=null;return t&&t.data&&(n=t.data),n}getTypeDescription(){return"CustomElement"}}const Ld=(s,e,t=!0,n=!0)=>{let r=0,o=0;if(!t&&!n)return{x:r,y:o};let i=!1,a=0;do{const l={x:e.x+r,y:e.y+o,width:0,height:0},c=s.search({bounds:l});if(i=!1,c.length>0){for(let h=0;!i&&h<c.length;h++){const u=c[h].getBounds();u.x===l.x&&u.y===l.y&&(i=!0)}i&&(r+=t?16:0,o+=n?16:0)}}while(i&&++a<100);return{x:r,y:o}};class fy{constructor(e,t,n){this._add=e,this._get=t,this._getByName=n}add(e,t){if(!e)throw new Error(Jl);return this._add(e,t)}search(e){if(e&&e.name&&Object.keys(e).length===0)return[this._getByName(e.name)];let t;e?.address&&(t=e.address);const n=this._get(t,e?.excludeHidden,e?.fullyContained);if(e?.name){const r=e.name.toLocaleLowerCase();for(let o=0;o<n.length;o++)if(n[o].getName().toLocaleLowerCase()===r)return[n[o]]}return n}getByName(e){if(typeof e!="string")throw new Error("Get by name must take a valid name.");return this._getByName(e)}getCount(){return this._get(null,!1,!1).length}}const ct=(s,e,t)=>{if(!s)return e;let n=e;const r=t===exports.w.Direction.Right||t===exports.w.Direction.Down;for(;;){const o=s(n,!r);if(o===0)return n;r?n+=o:n-=o}},py=Object.freeze({colIndex:0,rowIndex:0}),Yl=Object.freeze([]),cl=Object.freeze({cell:k.EmptyCell,ranges:Yl,rangeIndex:-1}),ff=(s,e=exports.w.Direction.Right,t,n,r,o=null)=>{if(o&&k.isEqualSelectionCoords(o,s))return s;const i=s.ranges[s.rangeIndex];if(!k.isRangesIntersect({rowStart:s.cell.rowIndex,colStart:s.cell.colIndex,rowEnd:s.cell.rowIndex,colEnd:s.cell.colIndex},i))return s;let a={...s.cell},l=s.rangeIndex;switch(e){case exports.w.Direction.Right:a.colIndex=ct(r,a.colIndex+1,e);break;case exports.w.Direction.Left:a.colIndex=ct(r,a.colIndex-1,e);break;case exports.w.Direction.Down:a.rowIndex=ct(n,a.rowIndex+1,e);break;case exports.w.Direction.Up:a.rowIndex=ct(n,a.rowIndex-1,e)}const c=d=>{if(d){l=s.rangeIndex>=s.ranges.length-1?0:s.rangeIndex+1;const g=s.ranges[l];a={colIndex:g.colStart,rowIndex:g.rowStart}}else{l=s.rangeIndex<=0?s.ranges.length-1:s.rangeIndex-1;const g=s.ranges[l];a={colIndex:g.colEnd,rowIndex:g.rowEnd}}};if(e===exports.w.Direction.Right&&a.colIndex>i.colEnd&&a.rowIndex===i.rowEnd)c(!0);else if(e===exports.w.Direction.Left&&a.colIndex<i.colStart&&a.rowIndex===i.rowStart)c(!1);else if(e===exports.w.Direction.Down&&a.colIndex===i.colEnd&&a.rowIndex>i.rowEnd)c(!0);else if(e===exports.w.Direction.Up&&a.colIndex===i.colStart&&a.rowIndex<i.rowStart)c(!1);else{let d=a.rowIndex,g=a.colIndex;switch(e){case exports.w.Direction.Right:g>i.colEnd&&(d=ct(n,d+1,e),g=i.colStart,d>i.rowEnd&&(d=i.rowStart));break;case exports.w.Direction.Left:g<i.colStart&&(d=ct(n,d-1,e),g=i.colEnd,d<i.rowStart&&(d=i.rowEnd));break;case exports.w.Direction.Down:d>i.rowEnd&&(g=ct(r,g+1,e),d=i.rowStart,g>i.colEnd&&(g=i.colStart));break;case exports.w.Direction.Up:d<i.rowStart&&(g=ct(r,g-1,e),d=i.rowEnd,g<i.colStart&&(g=i.colEnd))}a={rowIndex:d,colIndex:g}}let h=t(a);if(!k.isRangeWithinRange(h,i)){const d=k.intersectRanges(h,i);d&&(h=d)}let u={rowStart:ct(n,h.rowStart,exports.w.Direction.Down),colStart:ct(r,h.colStart,exports.w.Direction.Right),rowEnd:ct(n,h.rowEnd,exports.w.Direction.Up),colEnd:ct(r,h.colEnd,exports.w.Direction.Left)};if(u.rowStart!==a.rowIndex||u.colStart!==a.colIndex){switch(e){case exports.w.Direction.Right:s.ranges[l].colStart===u.colStart&&s.ranges[l].colEnd===u.colEnd&&(a.rowIndex=u.rowEnd),a.colIndex=u.colEnd;break;case exports.w.Direction.Left:s.ranges[l].colStart===u.colStart&&s.ranges[l].colEnd===u.colEnd&&(a.rowIndex=u.rowStart),a.rowIndex===u.rowStart?a.colIndex=u.colStart+1:a.colIndex=u.colStart;break;case exports.w.Direction.Down:s.ranges[l].rowStart===u.rowStart&&s.ranges[l].rowEnd===u.rowEnd&&(a.colIndex=u.colEnd),a.rowIndex=u.rowEnd;break;case exports.w.Direction.Up:s.ranges[l].rowStart===u.rowStart&&s.ranges[l].rowEnd===u.rowEnd&&(a.colIndex=u.colStart),a.colIndex===u.colStart?a.rowIndex=u.rowStart+1:a.rowIndex=u.rowStart}return o&&console.warn("call recursive > 1"),ff({cell:a,ranges:s.ranges,rangeIndex:l},e,t,n,r,o??s)}return{ranges:s.ranges,cell:a,rangeIndex:l}};class _y{constructor(e){this._adjusting=null,this._emitter=null,this._coords=cl,this._sheet=e.sheet,this._emitter=new st(this);const t=e.sheet;this._adjusting=null,this._hiddenRowsAt=(n,r)=>t.getRowHeaders().hiddenHeadersAt(n,r),this._hiddenColumnsAt=(n,r)=>t.getColumnHeaders().hiddenHeadersAt(n,r),this._getCellCoordsAsRangeCoords=n=>{const r=k.cellToRange(n);if(t.isClosed())return r;const o=t.getRange(r,{excludeHidden:!0}).getMerges();return o.length===0?r:o[0]},this._canSelectionSpanMergedCells=n=>{const r=t.getRange(n);return r.isEntireColumns()||r.isEntireRows()},this._getMergedRanges=n=>t.getRange(n,{excludeHidden:!0}).getMerges(),this._isContentfulCell=()=>!1,this._contentfulCellFinder=(n,r,o,i,a,l)=>{const c=t.getSelectedRange().getExtended(i,n).getCoords();switch(i){case exports.w.Direction.Up:return c.rowStart;case exports.w.Direction.Down:return c.rowEnd;case exports.w.Direction.Left:return c.colStart;case exports.w.Direction.Right:return c.colEnd}},this._scrollCellCoordsIntoView=(n,r)=>t.scrollTo(n,r?{scroll:r}:void 0),this._selectionPolicy=e.selectionPolicy??"multiple",this._newSelectionMode=e.newSelectionMode??"clear"}navigate(e,t=!1,n=!1,r=0){const o=this._coords;if(!o.cell)return this;let i=o.cell,a=o.cell;if(t&&o.ranges.length>0){const S=o.ranges[o.rangeIndex],C=o.cell;switch(e){case exports.w.Direction.Up:a={rowIndex:C.rowIndex===S.rowStart?S.rowEnd:S.rowStart,colIndex:S.colEnd},i={rowIndex:C.rowIndex===S.rowStart?S.rowStart:S.rowEnd,colIndex:S.colStart};break;case exports.w.Direction.Down:a={rowIndex:C.rowIndex===S.rowEnd?S.rowStart:S.rowEnd,colIndex:S.colEnd},i={rowIndex:C.rowIndex===S.rowEnd?S.rowEnd:S.rowStart,colIndex:S.colStart};break;case exports.w.Direction.Left:a={rowIndex:S.rowEnd,colIndex:C.colIndex===S.colStart?S.colEnd:S.colStart},i={rowIndex:S.rowStart,colIndex:C.colIndex===S.colStart?S.colStart:S.colEnd};break;case exports.w.Direction.Right:a={rowIndex:S.rowEnd,colIndex:C.colIndex===S.colEnd?S.colStart:S.colEnd},i={rowIndex:S.rowStart,colIndex:C.colIndex===S.colEnd?S.colEnd:S.colStart}}}const l=this._getCellCoordsAsRangeCoords(a);let{rowStart:c,colStart:h}=l;const u=this._magicCell;if(u)switch(e){case exports.w.Direction.Up:case exports.w.Direction.Down:u.colIndex>=l.colStart&&u.colIndex<=l.colEnd&&(h=u.colIndex);break;case exports.w.Direction.Left:case exports.w.Direction.Right:u.rowIndex>=l.rowStart&&u.rowIndex<=l.rowEnd&&(c=u.rowIndex)}if(!r){const S=this._getMaxRange();switch(e){case exports.w.Direction.Up:c=ct(this._hiddenRowsAt,Math.max(l.rowStart-1,S.rowStart??0),e);break;case exports.w.Direction.Down:c=ct(this._hiddenRowsAt,Math.min(l.rowEnd+1,S.rowEnd??Number.MAX_SAFE_INTEGER),e);break;case exports.w.Direction.Left:h=ct(this._hiddenColumnsAt,Math.max(l.colStart-1,S.colStart??0),e);break;case exports.w.Direction.Right:h=ct(this._hiddenColumnsAt,Math.min(l.colEnd+1,S.colEnd??Number.MAX_SAFE_INTEGER),e)}if(n){const C=this._getMaxRange();let y=0;switch(e){case exports.w.Direction.Up:y=C.rowStart??0,c=this._contentfulCellFinder({...a,colIndex:this._coords.cell.colIndex},this._isContentfulCell,this._hiddenRowsAt,e,!1,Math.max(y,this._hiddenRowsAt(y,!1)));break;case exports.w.Direction.Down:y=C.rowEnd??Number.MAX_SAFE_INTEGER,c=this._contentfulCellFinder({...a,colIndex:this._coords.cell.colIndex},this._isContentfulCell,this._hiddenRowsAt,e,!1,Math.min(y,y-this._hiddenRowsAt(y,!0)));break;case exports.w.Direction.Left:y=C.colStart??0,h=this._contentfulCellFinder({...a,rowIndex:this._coords.cell.rowIndex},this._isContentfulCell,this._hiddenColumnsAt,e,!1,Math.max(y,this._hiddenColumnsAt(y,!1)));break;case exports.w.Direction.Right:y=C.colEnd??Number.MAX_SAFE_INTEGER,h=this._contentfulCellFinder({...a,rowIndex:this._coords.cell.rowIndex},this._isContentfulCell,this._hiddenColumnsAt,e,!1,Math.min(y,y-this._hiddenColumnsAt(y,!0)))}}}let d=null;r&&(d={});const g={rowIndex:c,colIndex:h},m=this._getCellCoordsAsRangeCoords(g),f={rowIndex:m.rowStart,colIndex:m.colStart};t||(this._magicCell=g);const _=this._firstActiveCoords,p=k.isEqualCells(_,f)&&k.isEqualCells(_,i);if(t&&!p?this.modify(f,i):this.clearAndModify(f),d)this._scrollCellCoordsIntoView(d);else{if(t&&_){const S=this._getMaxRange();if(e===exports.w.Direction.Right&&_.colIndex===S.colEnd||e===exports.w.Direction.Left&&_.colIndex===S.colStart||e===exports.w.Direction.Up&&_.rowIndex===S.rowEnd||e===exports.w.Direction.Down&&_.rowIndex===S.rowStart)return this}e===exports.w.Direction.Left||e===exports.w.Direction.Right?this._scrollCellCoordsIntoView({colStart:g.colIndex}):e!==exports.w.Direction.Up&&e!==exports.w.Direction.Down||this._scrollCellCoordsIntoView({rowStart:g.rowIndex})}return this}getCoords(){return this._coords}updateCoords(e){const t=this._coords;if(k.isEqualSelectionCoords(t,e))return;const n=((r,o,i)=>{if(!r)return cl;let a=o.cell;k.isEqualCells(a,r?.cell)||(a=Object.freeze({colIndex:Math.max(0,Math.min(r?.cell?.colIndex??o.cell?.colIndex??0)),rowIndex:Math.max(0,Math.min(r?.cell?.rowIndex??o?.cell?.rowIndex??0))}));const l=r?.ranges?[...r.ranges]:[];let c=!1;const h=l.length;let u=h===0;for(let f=0;f<h;f++){const _=l[f];l[f]=Object.freeze({colStart:Math.max(i.colStart,Math.min(_.colStart,i.colEnd)),colEnd:Math.max(i.colStart,Math.min(_.colEnd,i.colEnd)),rowStart:Math.max(i.rowStart,Math.min(_.rowStart,i.rowEnd)),rowEnd:Math.max(i.rowStart,Math.min(_.rowEnd,i.rowEnd))}),u=u||k.isCellWithinRange(a,_),c=c||Object.keys(_).length>4}let d=o?.ranges??[];!c&&k.isEqualRangesArrays(d,l)||(d=l);let g=r?.rangeIndex??o?.rangeIndex??cl.rangeIndex;if(g=Math.max(-1,Math.min(g,d.length-1)),!u){const f=d[g];let _=a.rowIndex;_<f.rowStart?_=f.rowStart:_>f.rowEnd&&(_=f.rowEnd);let p=a.rowIndex;p<f.colStart?p=f.colStart:p>f.colEnd&&(p=f.colEnd),a=Object.freeze({colIndex:p,rowIndex:_})}return Object.freeze({cell:a,ranges:d,rangeIndex:g})})(e,this._coords,this._getMaxRange());return this._coords=n,!k.isEqualCells(n.cell,t.cell)&&this._scrollCellCoordsIntoView({colStart:n.cell.colIndex,rowStart:n.cell.rowIndex}),this._emitter.notify("onChange"),this}isEntire(){const e=this._coords;if(e.ranges.length===0)return!1;const t=this._getMaxRange();for(let n=0;n<e.ranges.length;n++){const r=e.ranges[n];if(!k.isRangeWithinRange(t,r))return!1}return!0}traverse(e=exports.w.Orientation.Row,t=!1){let n=exports.w.Direction.Right;n=e===exports.w.Orientation.Row?t?exports.w.Direction.Left:exports.w.Direction.Right:t?exports.w.Direction.Up:exports.w.Direction.Down;const r=this._coords;if(r.ranges.length===0)return this.navigate(n);const o=this._getCellCoordsAsRangeCoords(r.cell);if(k.isEqualRangesArrays([o],r.ranges))return this.navigate(n);const i=ff(r,n,this._getCellCoordsAsRangeCoords.bind(this),this._hiddenRowsAt.bind(this),this._hiddenColumnsAt.bind(this));this.updateCoords(i)}clear(){this._setSelectionRanges(Yl)}modify(e,t,n){if(this._selectionPolicy==="single")return;const r=this._coords,o=this._rangesFromCellOptional(r,e,t??r.cell);if(!o)return;const i=r.rangeIndex;this._setSelectionRanges(a=>a.length?a.map((l,c)=>i===c?o:l):[o]),n&&o&&this._setSelectionCell({colIndex:o.colStart,rowIndex:o.rowStart})}append(e,t=e,n){if(this._selectionPolicy!=="multiple"||!e||this._isCellOutOfBounds(e)||this._isCellOutOfBounds(t))return;const r=this._coords,o=this._cellToRangeActual(e,t);if(!o)return;const i=r.ranges.length>0?[...r.ranges]:[this._cellToRangeActual(r.cell,r.cell)];i.push(o);const a={ranges:i,cell:{rowIndex:o.rowStart,colIndex:o.colStart,...n},rangeIndex:i.length-1};k.isEqualSelectionCoords(a,r)||this.updateCoords(a)}clearAndModify(e,t,n){const r=this._coords;e={...r.cell,...e},t=t??e;const o=this._rangesFromCellOptional(r,e,t);if(!o)return;const i={rowIndex:o.rowStart,colIndex:o.colStart},a={...i,...n},l=this._newSelectionMode;l==="clear"?(this._firstActiveCoords=a,this.clear()):l==="modify"?this.modify(i):this.append(i),this._setSelectionCell(a)}setAdjusting(e){this._adjusting=e,this._emitter.notify("onAdjustingChange")}getAdjusting(){return this._adjusting}addListeners(e,t){return this._emitter.addListeners(e,t)}_setSelectionRanges(e){const t=this._coords;let n=typeof e=="function"?e(t.ranges):e??Yl;if(k.isEqualRangesArrays(n,t.ranges))return;let r=Math.max(n.length?0:-1,Math.min(t.rangeIndex,n.length-1)),o=t.cell;r===-1||k.isCellWithinRange(o,n[r])||(o={rowIndex:n[r].rowStart,colIndex:n[r].colStart}),n.length===1&&k.isSingleCell(n[0])&&k.isCellWithinRange(o,n[0])&&(n=[],r=-1);const i={cell:o,ranges:n,rangeIndex:r};k.isEqualSelectionCoords(i,t)||this.updateCoords(i)}_setSelectionCell(e){const t=this._coords,n=e??py,r=this._getCellCoordsAsRangeCoords(n);if(!k.isSingleCell(r)&&t.ranges.length===0)return this.updateCoords({ranges:[r],rangeIndex:0,cell:n});if(k.isEqualCells(n,t.cell))return;let o=t.ranges,i=t.rangeIndex;t.ranges.length===1&&(k.isSingleCell(t.ranges[0])&&k.isCellWithinRange(n,t.ranges[0])||!k.isCellWithinRange(n,t.ranges[0]))&&(o=[],i=-1);const a={ranges:o,rangeIndex:i,cell:n};return k.isEqualSelectionCoords(a,t)?void 0:this.updateCoords(a)}_isCellOutOfBounds(e){const t=this._getMaxRange();return e.rowIndex<t.rowStart||e.colIndex<t.colStart||e.colIndex>t.colEnd||e.rowIndex>t.rowEnd}_cellToRangeActual(e,t){const n={rowStart:Math.min(e.rowIndex,t.rowIndex),colStart:Math.min(e.colIndex,t.colIndex),rowEnd:Math.max(e.rowIndex,t.rowIndex),colEnd:Math.max(e.colIndex,t.colIndex)};if(this._canSelectionSpanMergedCells(n))return n;const r=this._getCellCoordsAsRangeCoords(e),o=this._getCellCoordsAsRangeCoords(t),i={rowStart:Math.min(r.rowStart,o.rowStart),colStart:Math.min(r.colStart,o.colStart),rowEnd:Math.max(r.rowEnd,o.rowEnd),colEnd:Math.max(r.colEnd,o.colEnd)},a=this._getMergedRanges(i);return k.extendRangeToUnionRanges(i,a)}_rangesFromCellOptional(e,t,n){const r=e.ranges.length>0?e.ranges[e.rangeIndex]:{rowStart:e.cell.rowIndex,colStart:e.cell.colIndex,rowEnd:e.cell.rowIndex,colEnd:e.cell.colIndex},o={rowStart:Math.min(t.rowIndex??r.rowStart,n.rowIndex??r.rowStart),colStart:Math.min(t.colIndex??r.colStart,n.colIndex??r.colStart),rowEnd:Math.max(t.rowIndex??r.rowEnd,n.rowIndex??r.rowEnd),colEnd:Math.max(t.colIndex??r.colEnd,n.colIndex??r.colEnd)},i={rowIndex:o.rowStart,colIndex:o.colStart},a={rowIndex:o.rowEnd,colIndex:o.colEnd};if(!(this._isCellOutOfBounds(i)||this._isCellOutOfBounds(a)))return this._cellToRangeActual(i,a)}_getMaxRange(){return this._sheet.getEntireRange().getCoords()}toString(){let e="";return e+=`selection:[${this._sheet.getRange(this._coords.cell).toString()}`,this._coords.ranges&&this._coords.ranges.length>0&&(e+=`, ${this._sheet.getRanges(this._coords.ranges).toString()}`),this._coords.rangeIndex!==void 0&&this._coords.rangeIndex!==-1&&(e+=`, ${this._coords.rangeIndex}`),e+="]",e}}class zi{constructor(e,t){this._c=e,this._m=t}getModel(){return this._m}getCoords(){return this._c}getPropertiesAt(e,t,n){return this._m.getPropertiesAt(e,t,n)}getSplit(e){const t=this._m;return[new zi(e[0],t),new zi(e[1],t)]}}class Sy extends ir{constructor(e){if(super({...e}),this._coordsCache=null,!e.json)throw new Error("json is required");this._sheet=e.sheet,this._styles=e.sheet?.getStyles()??new Jr,this._options={...e},e.setOnContainerCoordsChange(this._processCoordsChange.bind(this)),e.setCreateSpatial(this._createSpatial.bind(this)),this._getContainerRanges=e.getContainerRanges,this._setContainerRanges=e.setContainerRanges;const t=this;this._options.transactions.addStateListener(this,{onRestoreOrRevert(){t._coordsCache=null},onBeforeCommitEnd(){t._coordsCache=null}}),this._fromJSON({...e.json})}getRanges(){return this._getContainerRanges()}setRanges(e,t){const n=this.getRanges(),r=this._setContainerRanges(e,t);return this._processCoordsChange({before:n?.getCoords()??null,after:r?.getCoords()??null}),this}setType(e,t){return this._updateState({type:e},{description:"Set Conditional Format Type",...t}),this}getType(){return this._getState().type}setPriority(e,t){return this._updateState({priority:e},{description:"Set Priority",...t}),this}getPriority(){return this._getState().priority}setStopIfTrue(e,t){return this._updateState({stopIfTrue:e},{description:`Set Stop ${e??!1}`,...t}),this}getStopIfTrue(){return this._getState().stopIfTrue??!1}getScalar(){return this._getState().value??null}getColorScale(){return this._getState().colorScale??null}getContainsText(){return this._getState().text}getCustom(){return this._getState().formulas}getDataBar(){return this._getState().dataBar??null}getIconSet(){return this._getState().iconSet}getPresetCriteria(){return this._getState().style}getTopBottom(){return this._getState()}getSnapshot(e){this.toJSON();const t=null,n=this,r=Object.freeze({...e});let o=!1;return{async copyTo(i,a){i.conditionals;const l=i.range;({...r,...a}).isCut&&!o&&(n.delete(),o=!0);const c={colStart:l.colStart,rowStart:l.rowStart,colEnd:t.colEnd-t.colStart+l.colStart,rowEnd:t.rowEnd-t.rowStart+l.rowStart};return console.log("implement copyTo"),c},getCoords:()=>t,getSource:()=>n,getName:()=>"Conditional Format",getMarkOptions:()=>r,isISnapshot:!0}}_processRestoreOrRevert(e,t,n){super._processRestoreOrRevert(e,t,n)}_createSpatial(e){return new zi(e,this)}_processCoordsChange(e){this._coordsCache=null,e.after?this._emitter.notify("onAnyChange"):this._delete()}update(e,t){if(this.isClosed())throw new Error("Table has been closed. No further operations are allowed.");const n=this._getState(),r=this._beginCommit(t?.description??"Update Conditional Format");try{const o={...n,...e};this._updateState(o,t),this._getEmitter().notify("onAnyChange"),r.commit()}catch(o){throw r.rollback(),o}return this}_processDelete(){this._getState(),super._processDelete()}_processStateChange(e,t,n){super._processStateChange(e,t,n),this._getEmitter().notify("onAnyChange")}toJSON(){const e={},t=this._getState();if(t===null)return null;const n=this.getRanges()?.toString();return n?(e.ref=n,e.type=t.type,t.priority!==0&&(e.priority=t.priority),t.stopIfTrue&&(e.stopIfTrue=t.stopIfTrue),t.style&&(e.style=t.style),t.colorScale&&(e.colorScale=t.colorScale),t.dataBar&&(e.dataBar=t.dataBar),t.iconSet&&(e.iconSet=t.iconSet),t.aboveAverage&&(e.aboveAverage=t.aboveAverage),t.equalAverage&&(e.equalAverage=t.equalAverage),t.stdDev!==0&&(e.stdDev=t.stdDev),t.bottom&&(e.bottom=t.bottom),t.percent&&(e.percent=t.percent),t.rank!==0&&(e.rank=t.rank),t.operator&&(e.operator=t.operator),t.formulas&&(e.formulas=t.formulas),t.text&&(e.text=t.text),t.timePeriod&&(e.timePeriod=t.timePeriod),e):null}_fromJSON(e){const t={};t.type=e.type??exports.IConditionalFormat.Type.CellIs,t.priority=e.priority??0,t.stopIfTrue=e.stopIfTrue??!1,t.style=e.style??null,t.colorScale=e.colorScale??null,t.dataBar=e.dataBar??null,t.iconSet=e.iconSet??null,t.aboveAverage=e.aboveAverage??!1,t.equalAverage=e.equalAverage??!1,t.stdDev=e.stdDev??0,t.bottom=e.bottom??!1,t.percent=e.percent??!1,t.rank=e.rank??0,t.operator=e.operator??null,t.formulas=e.formulas??null,t.text=e.text??null,t.timePeriod=e.timePeriod??null,this._updateState(t,{description:"Initialize Conditional Format"})}close(){super.close(),this.isClosed()||(this._updateState({},{description:"Close Conditional"}),this._stylesRemoveListener?.())}getCoords(){return this.getRanges().getCoords()[0]}getPropertiesAt(e,t,n){let r=this._coordsCache;r||(r=this._coordsCache=this.getRanges().getCoords());let o=0,i=0;const a={rowIndex:e,colIndex:t};for(let c=0;c<r.length;c++){const h=r[c];if(k.isCellWithinRange(a,h)){const u=e-h.rowStart,d=t-h.colStart;i=o+(u*(h.colEnd-h.colStart+1)+d+1)}o+=(h.rowEnd-h.rowStart+1)*(h.colEnd-h.colStart+1)}let l={fill:{type:"solid",color:"red"}};return l.fill.color=((c,h,u,d)=>{let g=1;h!==0&&(g=c/h);const m=u[0]+g*(d[0]-u[0]),f=u[1]+g*(d[1]-u[1]),_=u[2]+g*(d[2]-u[2]);return`rgb(${Math.round(m)}, ${Math.round(f)}, ${Math.round(_)})`})(i,o,[255,255,255],[255,0,0]),l}get isIConditionalFormat(){return!0}}class wy{constructor(e,t){this._add=e,this._get=t}add(e,t){if(!e)throw new Error(Dr);return this._add(e,t)}search(e){let t;return e?.address&&(t=e.address),this._get(t,e?.excludeHidden,e?.fullyContained)}getCount(){return this._get(null,!1,!1).length}}const Pd=(s,e)=>{if(e){if(e.getType()===exports.IFill.Type.Solid)s.background=Qt(e.getColor())||"none",s["mso-pattern"]="black none";else if(e.getType()===exports.IFill.Type.Pattern){const t=e;s.background=Qt(t.getBackground())||"none";const n=Qt(t.getForeground())||"";if(t.getPatternType()===exports.IFill.BuiltInSheetPattern.Solid)s["mso-pattern"]=`${s.background} none`,s.background=n;else{const r=(o=>He.get(o)?.cssKey??"solid")(t.getPatternType());s["mso-pattern"]=n+(r?" ":"")+r}}else if(e.getType()===exports.IFill.Type.Gradient){const t=e;s.background=Qt(t.getStops()?.[0]?.getColor())||"auto",s.msoGradient=Xm(t)||"auto"}}};class yy{constructor(e,t){if(this._visitedStyles=new Map,this._lastStyleClassId=63,this._wroteTD=!1,!e)throw new Error("Can not create with a null sheet.");this._sheet=e,this._includeSizeInCell=t??!1,this._normalStyle=e.getStyles().getNormal()}_createCSSStyle(e){const t=this._normalStyle,n={},r=(d,g)=>d===g||!(d&&!g)&&!(!d&&g)&&g.isEqual?.(d),o=e.getFont(),i=t.getFont();var a;r(o.getFill(),i.getFill())||(n.color=Qt(o.getFill())),r(o.getSize(),i.getSize())||(n["font-size"]=Yu(o.getSize())),r(o.getWeight(),i.getWeight())||(n["font-weight"]=o.getWeight()),r(o.getStyle(),i.getStyle())||(n["font-style"]=o.getStyle()),r(o.getUnderline(),i.getUnderline())||(n["text-decoration"]="underline",n["text-underline-style"]=(a=o.getUnderline())===exports.IFont.UnderlineStyle.Single?"single":a===exports.IFont.UnderlineStyle.Double?"double":a===exports.IFont.UnderlineStyle.SingleAccounting?"single-accounting":a===exports.IFont.UnderlineStyle.DoubleAccounting?"double-accounting":"none"),r(o.getFamily(),i.getFamily())&&r(o.getFallbacks(),i.getFallbacks())||(n["font-family"]=Ni(o.getFamily(),o.getFallbacks())),r(e.getNumberFormat(),t.getNumberFormat())||(n["mso-number-format"]=ed(e.getNumberFormat()));const l=e.getAlignment(),c=t.getAlignment();if(!r(l.getHorizontal(),c.getHorizontal())){const d=l.getHorizontal();d===exports.ITextFrame.HorizontalAlignment.CenterContinuous?n["text-align"]="center-across":d===exports.ITextFrame.HorizontalAlignment.Fill?n["text-align"]="fill":d===exports.ITextFrame.HorizontalAlignment.Distributed?n["text-align"]=l.getJustifyLastLine()?"121":"010":n["text-align"]=exports.ITextFrame.toCSSHorizontalTextAlign(d)}if(!r(l.getVertical(),c.getVertical())){const d=l.getVertical();d===exports.ITextFrame.VerticalAlignment.Distributed?n["vertical-align"]="121":n["vertical-align"]=Qu(d)}if(!r(l.getOverflow(),c.getOverflow())){const d=l.getOverflow();n["white-space"]=Zu(d),d===exports.ITextFrame.Overflow.Shrink&&(n["mso-text-control"]="shrinktofit")}var h;r(l.getRotation(),c.getRotation())||(n["mso-rotate"]=(h=l.getRotation(),(h%=360)<0&&(h+=360),h>180?h=360-h:h>1&&(h*=-1),h)),r(l.getIndent(),c.getIndent())||(n["mso-char-indent-count"]=l.getIndent()),r(e.getFill(),i.getFill())||Pd(n,e.getFill());const u=e.getBorder();return u.getTop().isNone()||(n["border-top"]=qn(u.getTop())),u.getLeft().isNone()||(n["border-left"]=qn(u.getLeft())),u.getRight().isNone()||(n["border-right"]=qn(u.getRight())),u.getBottom().isNone()||(n["border-bottom"]=qn(u.getBottom())),u.getDiagonalUp().isNone()||(n["border-mso-diagonal-up"]=qn(u.getDiagonalUp())),u.getDiagonalDown().isNone()||(n["border-mso-diagonal-down"]=qn(u.getDiagonalDown())),Object.keys(n).length===0?null:n}_createCSSNormalStyle(){const e=this._normalStyle,t={"padding-top":"1px","padding-left":"1px","padding-right":"1px","mso-ignore":"padding"},n=e.getFont(),r=e.getAlignment();return t.color=Qt(n.getFill()),Pd(t,e.getFill()),t["font-size"]=Yu(n.getSize()),t["font-weight"]=n.getWeight(),t["font-style"]=n.getStyle(),t["text-decoration"]=qm(n.getUnderline(),n.getStrike()),t["font-family"]=Ni(n.getFamily(),n.getFallbacks()),t["mso-font-charset"]="0",t["mso-background-source"]="auto",t["mso-number-format"]=ed(e.getNumberFormat()),t["text-align"]=exports.ITextFrame.toCSSHorizontalTextAlign(r.getHorizontal()),t["vertical-align"]=Qu(r.getVertical()),t.border="none",t["mso-pattern"]="auto",t["white-space"]=Zu(r.getOverflow()),r.getOverflow()===exports.ITextFrame.Overflow.Shrink&&(t["mso-text-control"]="shrinktofit"),t["mso-rotate"]="0",r.getIndent()>0&&(t["mso-char-indent-count"]=r.getIndent()),t["mso-protection"]="locked visible",t}onCell(e,t,n){let r;const o=e.getSpans();if(o.width>1||o.height>1){if(!e.isTopLeft())return!1;o.height>1&&n.addAttribute("rowspan",o.height),o.width>1&&n.addAttribute("colspan",o.width)}let i=e.toTextUnformatted();e.getNumberFormat().repeatPlaceholder&&(i=e.getNumberFormat().repeatPlaceholder.repeat(5)),n.setPlainText(i||"");const a=e.getStyle(),l=a.getFont();if(l.getVerticalAlignment()===exports.IFont.VerticalAlignment.Super&&(i=`<sup>${i}</sup>`),l.getVerticalAlignment()===exports.IFont.VerticalAlignment.Sub&&(i=`<sub>${i}</sub>`),l.getStrike()&&(i=`<s>${i}</s>`),e.getHyperlink()&&(i=`<a href="${e.getHyperlink().getAddress()}">${i}</a>`),n.setHTMLText(i||" "),!this._wroteTD){const h=this._createCSSNormalStyle();n.addSharedStyle("td",h),this._wroteTD=!0}let c=this._visitedStyles.get(a);if(!c){const h=this._createCSSStyle(a);h&&(c="xl"+ ++this._lastStyleClassId,this._visitedStyles.set(a,c),n.addSharedStyle("."+c,h))}if(c&&n.addAttribute("class",c),this._includeSizeInCell){const h=this._sheet.getColumnHeaders().at(t.colIndex).getSize();n.addAttribute("width",h),n.addStyle("width",N.roundAccurately(h/exports.IFont.getDeviceScale(),2)+"pt");const u=this._sheet.getRowHeaders().at(t.rowIndex).getSize();n.addAttribute("height",u),n.addStyle("height",N.roundAccurately(u/exports.IFont.getDeviceScale(),2)+"pt")}return r}onRow(e,t,n,r){const o=e.getSize();r.addAttribute("height",o),r.addStyle("height",N.roundAccurately(o/exports.IFont.getDeviceScale(),2)+"pt"),e.isCustomSize()&&r.addStyle("mso-height-source","userset")}onColumn(e,t,n,r){const o=e.getSize();r.addAttribute("width",o),r.addStyle("width",N.roundAccurately(o/exports.IFont.getDeviceScale(),2)+"pt"),e.isCustomSize()&&r.addStyle("mso-width-source","userset"),n>1&&r.addAttribute("colspan",n)}}const zd=(s,e,t)=>{const n=s.getOrientation()===ie.Column,r=(n?"Column":"Row")+" Copy",o=s.getSnapshot(t);return{...o,getName:()=>r,getCoords:()=>e,copyTo:async(i,a)=>{const l=n?i.getColumnHeaders():i.getRowHeaders(),c={...t,...a};if(c.includeHeaders===!0){const h=await o.copyTo(l,c);return n?{colStart:h.min,rowStart:e.rowStart,colEnd:h.max,rowEnd:e.rowEnd}:{colStart:e.colStart,rowStart:h.min,colEnd:e.colEnd,rowEnd:h.max}}},getMarkOptions:()=>t}},Cy=(s,e,t,n,r,o)=>{const i=t[0];let a,l;const c=()=>{if(l!==void 0)return;const[h,u]=((d,g)=>{const m=g.getRowHeaders(),f=g.getColumnHeaders(),_=g.getUsedRange()?.getCoords(),p=m.getUsedRange()?.getCoords(),S=f.getUsedRange()?.getCoords(),C={...k.EmptyRange,..._,colEnd:Math.max(_?.colEnd??0,S?.max??0),rowEnd:Math.max(_?.rowEnd??0,p?.max??0)},y=new Map,b=[];d.onStart?.();const w={rows:[],cols:[]},E=new ay(y,b);E.setNode(w),d.onTable?.(E,C);let I=0;f.forEachSpan((P,B)=>{const z=B.getCoords();I=I+z.max-z.min+1;const O={};E.setNode(O),d.onColumn?.(B.getCellHeader(),z.min,z.max-z.min+1,E),w.cols.push(O)},{address:C,includeEmpty:!0,includeStyles:!0});let x=0;const v=[];if(m.forEachSpan((P,B)=>{const z=B.getCoords();x=x+z.max-z.min+1,v.push({min:z.min,max:z.max,value:B.getCellHeader()})},{address:C,includeEmpty:!0,includeStyles:!0,excludeHidden:!1}),I*x>5e4){if(!Td)throw Td=!0,new Cg("Unable to write more than 50000 cells to system clipboard. Items can still be pasted within the application to but if you want to copy to another application select a smaller set of data.");return[null,null]}let R=0,A=-1,M=null;g.forEach((P,B)=>{const z=B.getCoords(),O=B.getCell();if(z.rowIndex!==A){z.rowIndex>v[R].max&&++R;const V=v[R];M={cells:[]},E.setNode(M),d.onRow?.(V.value,z.rowIndex,1,E),w.rows.push(M),A=z.rowIndex}const W={};E.setNode(W),d.onCell(O,z,E)!==!1&&M.cells.push(W)},{address:C,includeEmpty:!0,excludeHidden:!1}),d.onDone?.(),w.rows.length===0&&w.rows.push({cells:[]});const T=[];for(let P=0;P<b.length;P++){const B=b[P],z=y.get(B);T.push(B);let O="";const W=Object.keys(z);for(let V=0;V<W.length;V++){O+=" ",V===0&&(O+="{");const j=W[V];O+=`${j}:${z[j]};`,V===W.length-1?O+="}":O+=`
|
|
33
|
+
`}T.push(O)}const F=[`<div clipboard-uuid=xxx>
|
|
34
|
+
<html
|
|
35
|
+
xmlns:v="urn:schemas-microsoft-com:vml"
|
|
36
|
+
xmlns:o="urn:schemas-microsoft-com:office:office"
|
|
37
|
+
xmlns:x="urn:schemas-microsoft-com:office:excel"
|
|
38
|
+
xmlns="http://www.w3.org/TR/REC-html40"
|
|
39
|
+
>`];F.push(`<head>
|
|
40
|
+
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
|
|
41
|
+
<meta name=ProgId content=Excel.Sheet>
|
|
42
|
+
<meta name=Generator content="Microsoft Excel 15">`),F.push(`<style>
|
|
43
|
+
table
|
|
44
|
+
{mso-displayed-decimal-separator:"\\.";
|
|
45
|
+
mso-displayed-thousand-separator:"\\,";}
|
|
46
|
+
@page
|
|
47
|
+
{margin:.75in .25in .75in .25in;
|
|
48
|
+
mso-header-margin:.3in;
|
|
49
|
+
mso-footer-margin:.3in;
|
|
50
|
+
mso-horizontal-page-align:center;}
|
|
51
|
+
tr
|
|
52
|
+
{mso-height-source:auto;}
|
|
53
|
+
col
|
|
54
|
+
{mso-width-source:auto;}
|
|
55
|
+
br
|
|
56
|
+
{mso-data-placement:same-cell;}`),T.length>0&&F.push(T.join(`
|
|
57
|
+
`)),F.push("</style>"),F.push("</head>"),F.push("<body>"),F.push("<table>"),F.push("<!--StartFragment-->");const L=P=>{let B=(O=>{let W="";return O&&O.attributes&&O.attributes.length!==0&&O.attributes.forEach((V,j)=>{W.length>0&&(W+=" "),W+=`${j}=${V}`}),W})(P);B.length>0&&(B=" "+B);let z=(O=>{let W="";return O&&O.styles&&O.styles.length!==0&&(O.styles.forEach((V,j)=>{W.length>0&&(W+=";"),W+=j+":"+V}),W.length>0&&(W=`style='${W}'`)),W})(P);return z.length>0&&(z=" "+z),`${B}${z}`},D=[];return w.cols?.forEach(P=>{F.push(` <col${L(P)}>`)}),w.rows.forEach(P=>{F.push(` <tr${L(P)}>`);const B=[];P.cells.forEach(z=>{F.push(` <td${L(z)}>${z.htmlText??z.plainText??""}</td>`);const O=`${N.castToString(z.plainText??"")?.replace(/"/g,'""')}`;B.push(O)}),D.push(B.join(" ")),F.push(" </tr>")}),F.push("<!--EndFragment-->"),F.push("</table>"),F.push("</body>"),F.push("</html>"),F.push("</div>"),[F.join(`
|
|
58
|
+
`),D.join(`
|
|
59
|
+
`).concat(`
|
|
60
|
+
`)]})(new yy(e),e.getRange(i));a=h??null,l=u??null};return{copyTo(h,u){const d={...r,...u};return u.isCut,o(h,d)},getMarkOptions:()=>r,getSource:()=>s,getName:()=>n,getCoords:()=>i,toText:()=>(c(),l),toHtml:()=>(c(),a),toImage:()=>null,isISnapshot:!0}},Si=(s,e)=>Math.round(s*e),Wd=(s,e,t)=>{const n=[],r=[];if(!s||s.length===0)return{sizes:n,hidden:r};if(!e||!t)return console.warn("_HeaderUtils:default size and scaleFactor should be available"),{sizes:n,hidden:r};let o=0,i=0,a=0,l=null,c=-2;for(let h=0;h<s.length;h++){const u=s[h],d=u.min,g=u.max;o=n.length===0?0:n[n.length-1].runningOffsetMax,n.length>0&&n[n.length-1].spanSize>0&&o++,i<u.min&&n.push({indexMin:i,indexMax:d-1,runningOffsetMin:o,runningOffsetMax:Math.round(o+(d-i)*e*t)-1,runningHiddenRuns:a,spanSize:Math.round(e*t)});const m=n.length,f=n[m-1];o=m===0?0:f.runningOffsetMax,m>0&&f.spanSize>0&&o++;let _=0;u.value.h||(_=Si(u.value?.sz??e,t));const p=_===0?0:-1;_===0&&(a+=g-d+1,c+1===d?l.max=g:(l={min:d,max:g,value:!0},r.push(l)),c=g),m>0&&f.spanSize===_&&f.indexMax+1===d?(f.indexMax=g,f.runningHiddenRuns=a,f.runningOffsetMax=f.runningOffsetMin+(g+1-f.indexMin)*_+p):n.push({indexMin:d,indexMax:g,runningOffsetMin:o,runningOffsetMax:Math.round(o+(g+1-d)*_)+p,runningHiddenRuns:a,spanSize:_}),i=g+1}return{sizes:n,hidden:r}};function hl(s,e,t){t!==void 0&&(t!==null?s[e]=t:delete s[e])}const ul=()=>{},jd=()=>0,by=()=>!1,pf=(s,e,t,n)=>{if(n!==void 0){if(n===null)return null;if(n?.isICellHeader)return n._headerState;if(n){const r=n,o={...t};let i,a=r.hidden,l=r.size;if(r.size!==void 0){if(typeof l=="function"){const c=t?.sz===void 0?s.getDefaultSize():t?.sz*s.getScaleFactor();l=l?.(c)}if(typeof l=="string"&&(l=Pr(l,e.getNormal().getFont().getSize(),"px")),typeof l=="number"){const c=s.getMinSize(),h=s.getMaxSize();l=Math.max(c,Math.min(N.roundAccurately(l,c),h)),r.relativeSize!==!0&&(l/=s.getScaleFactor()),isNaN(l)&&(console.warn("headerSize can not be NaN"),l=void 0),l===0&&(a=!0,l=void 0),i=!r.autoSize}else l===null?(l=null,i=!r.autoSize):l!==void 0&&(console.warn("headerSize can not be type",l),l=void 0)}return hl(o,"sz",l),hl(o,"h",a),hl(o,"csz",i),Object.keys(o).length===0?null:o}}};class Ic{constructor(e,t,n){this._sheetHeader=e;const r=this._sheetHeader.getSheet().getStyles();this._styles=r,this._headerState=t,this._template=n}getSize(){const e=this._headerState?.sz;return Math.round(e===void 0?this._sheetHeader.getDefaultSize():e*this._sheetHeader.getScaleFactor())}getDisplayText(){return""+this.asCell().getValue()}getOrientation(){return this._sheetHeader.getOrientation()}isHidden(){return this._headerState?.h??!1}isCustomSize(){return this._headerState?.cs??!1}getSheetHeader(){return this._sheetHeader}getStyle(){return this._headerState?.s??this._styles.getNormal()}asCell(){return this._cellTemplate||(this._cellTemplate=this._sheetHeader.getSheet().createTemporaryCell({style:this.getStyle(),...this._template})),this._cellTemplate}getSizeRelative(){return this.getSize()/this._sheetHeader.getScaleFactor()}createTemporaryCellHeader(e){const t=pf(this._sheetHeader,this._sheetHeader.getSheet().getStyles(),this._headerState,e);return new Ic(this._sheetHeader,t,this._template)}isEqual(e){if(!e)return!1;if(e===this)return;const t=e;if(!t.isICellHeader)return!1;const n=this._headerState,r=t._headerState;return n===r||!(n&&!r||r&&!n)&&this.getSize()===t.getSize()&&this.isCustomSize()===t.isCustomSize()&&this.isHidden()===t.isHidden()&&this.getStyle()===t.getStyle()}isEmpty(){const e=this._headerState;return!e||e.sz===void 0&&e.csz===void 0&&!e.cs&&e.h===void 0&&!(!e.s||e.s!==this._styles.getNormal()||e.cs)}get isICellHeader(){return!0}}const Bs="The columns are protected. To make a change, unprotect the sheet. You might be requested to enter a password.",Ds="The rows are protected. To make a change, unprotect the sheet. You might be requested to enter a password.",Jn="Rows",Kn="Columns";class Hd{constructor(e){if(this._emitter=null,this._closed=!1,this._scaleFactor=1,this._defaultSize=-1,this._defaultCustomSize=-1,this._defaultPxSize=1,this._isColumn=!0,this._indexedSizes=[],this._indexedHidden=[],this._headerRunCoords=null,this._hasCustomFormats=!1,this._hasStyles=!1,this._hasHidden=!1,this._lastHeaderRead=null,this._readCache=null,this._lastVisibleRunsRead=null,this._lastVisibleRunCoords=null,this._options={isProtected:()=>!1,getUpdateId:()=>null,scaleFactor:()=>1,defaultSize:()=>100,minSize:()=>0,maxSize:()=>500,orientation:exports.w.Orientation.Column,createCellHeader:(i,a,l)=>new Ic(i,a,l),...e},!this._options.sheet)throw new Error("An ISheet must be provided");if(this._emptyHeader=this._options.createCellHeader(this,null,null),this._scaleFactor=this._options.scaleFactor(),this._defaultSize=this._options.defaultSize(),this._defaultSize<=0)throw new Error("defaultSize must be greater than 0");this._defaultPxSize=Si(this._defaultSize,this._scaleFactor);const t=this._options.orientation===exports.w.Orientation.Column;this._isColumn=t;const n=this._options.maxSheetCoords??{colStart:0,rowStart:0,colEnd:Number.MAX_SAFE_INTEGER,rowEnd:Number.MAX_SAFE_INTEGER};this._maxSheetCoords=n;const r=t?n.colEnd:n.rowEnd;this._maxDataIndex=r,this._maxRunCoords={min:0,max:r},this._maxDataRange=this.getRange(this._maxRunCoords),this._maxRangeCoords={colStart:0,rowStart:0,colEnd:t?r:0,rowEnd:t?0:r};const o=this;this._options.setContainerShiftedCallback&&this._options.setContainerShiftedCallback((i,a)=>{a<0?o._deleteHeaders(i,-a):o._insertHeaders(i,a)}),this._options.sheet&&(this._sheetRemoveListener=this._options.sheet.addListeners({onProtectionChange(){},onSelectionChange(i){o._selection=i.getSelection().getCoords(),o._selectionRuns=null},onStyleChange:()=>{},onViewChange(){const i={runs:o._headers};o._invalidSizes(),o._emitter.notify("onSizesChange",{params:i})}},{transactional:!1}),o._selection=o._options.sheet.getSelection().getCoords()),this._transactions=this._options.transactions??new Bt({transient:!0}),this._emitter=new st(o,this._transactions),this._transactionsRemoveListener=this._transactions.addStateListener(this,{onAfterStateChange(i){o._lastHeaders!==i.headers&&o._onHeaderChange()}}),this.fromJSON(this._options?.json)}addListeners(e,t){return this._emitter.addListeners(e,t)}_invalidSizes(){const e=this._defaultCustomSize===-1?this._options.defaultSize():this._defaultCustomSize,t=this._options.scaleFactor();if(e!==this._defaultSize||t!==this._scaleFactor){this._defaultSize=e,this._scaleFactor=t,this._defaultPxSize=Si(e,t);const n=Wd(this._headers,e,t);this._indexedSizes=n.sizes,this._indexedHidden=n.hidden,this._lastVisibleRunsRead=null,this._lastVisibleRunCoords=null}}_onHeaderChange(){this._lastHeaders=null;const e=this._headers,t=this._getState();this._defaultCustomSize=t.defaultCustomSize;const n=this._defaultCustomSize===-1?this._options.defaultSize():this._defaultCustomSize;this._defaultSize=n;const r=this._scaleFactor;this._defaultPxSize=Si(n,r);const o=Wd(e,n,r);this._indexedSizes=o.sizes,this._indexedHidden=o.hidden,this._lastHeaderRead=null,this._readCache=gm(this._lastHeaders),this._lastVisibleRunsRead=null,this._lastVisibleRunCoords=null;const i=this._options.sheet.getStyles().getNormal();let a=!1,l=!1,c=!1,h=-1;for(let g=e.length-1;g>=0;g--){const m=e[g],f=m.value,_=f.s,p=f.csz||f.sz!==n;h!==-1||!p&&_===i||(h=m.max),a=a||f.cs,l=l||f.s!==i,c=c||f.h||f.sz===0}h=Math.min(h??0,this._maxDataIndex);const u=Math.min(e[0]?.min??h,h);this._headerRunCoords=Object.freeze({min:u,max:h}),this._hasCustomFormats=a,this._hasStyles=l,this._hasHidden=c;const d=t.runs;this._emitter.notify("onSizesChange",{params:d})}getSheet(){return this._options.sheet}getOrientation(){return this._isColumn?exports.w.Orientation.Column:exports.w.Orientation.Row}getTextAt(e){return this._options.getTextAt?.(e)??e+""}_scanHeaders(e,t,n,r,o,i){const a=o?.min??null,l=o?.max??null,c=i?.includeEmpty??!1,h=i?.includeStyles??!1,u=i?.excludeHidden??!1,d=i?.includeSizes??!1,g=this,m=this._options.sheet.getStyles().getNormal(),f=this._defaultSize,_=this._scaleFactor,p=this._emptyHeader;let S;const C={getCoords(){if(!S)throw new Error(Lr);return{min:S.min,max:S.max}},getIndex:()=>S.min,getCellHeader(){if(!S)throw new Error(Lr);return S.value?n(g,S.value):p},getA1(b){if(!S)throw new Error(Lr);return this._parseHeaderRangeAddress({min:a+b,end:a+b})??S}},y=Yh(t,b=>{const w=b.value;if(!c&&!w)return;let E=c;if(d&&!E&&w&&(w.csz||w.sz!==f)&&(E=!0),h&&!E&&w&&(w.s&&w.s!==m||w.cs)&&(E=!0),w&&w.h===!0&&(E=!u),!E)return;let I=f;b.value&&(I=b.value.h?0:b.value?.sz??f),I*=_,S=b;const x=e(I,C);return x&&x.break?x:void 0},a,l);return S=null,y}getRange(e,t){if(!e)throw new Error(Dr);const n=this,r=this._parseHeaderRangeAddress(e);if(r.min<0||r.max>this._maxDataIndex)return function(l){return Object.freeze({getCoords:()=>null,getOrientation:()=>l.getOrientation(),toString:()=>Ke,getA1:()=>Ke,getCount:jd,getVisibleCount:jd,isEntireHeaders:by,forEach:ul,forEachSpan:ul,forEachVisibleSpan:ul,getUsedRange:_e,getSnapshot:_e,updateHeaders:_e,clear:_e,setHidden:_e,setSize:_e,at:_e,doBatch:_e,getSheetHeader:()=>l,isICellHeaderRange:!0})}(this);const o=(l,c,h,u=n._options.createCellHeader)=>{let d=r;if(c?.address){const m=n._parseHeaderRangeAddress(c?.address);if(m&&(d=Xh(r,m),!d))return}const g=this._scanHeaders(l,h,u,t,d,c);if(g&&g.break)return g.break},i=()=>{const l=n._isColumn?{colStart:r.min,colEnd:r.max}:{rowStart:r.min,rowEnd:r.max};return mn(l,n._maxRangeCoords)??Ke},a={getCoords:()=>r,getA1:i,toString:i,forEach:(l,c)=>{let h=Number.MAX_SAFE_INTEGER,u=null;const d={getIndex:()=>h,getCellHeader:()=>u.getCellHeader(),getA1:g=>u.getA1(g),getCoords:()=>u.getCoords()};return o((g,m)=>{u=m;for(let f=r.min;f<r.max;f++)h=f,l(g,d)},c,this._headers,()=>this.at(void 0))},forEachSpan:(l,c)=>o(l,c,this._headers),forEachVisibleSpan:(l,c)=>{const h=r?.min??null,u=r?.max??null;let d;if(d=c?.includeHidden?l(h,u):Yh(this._indexedHidden,g=>{if(g.value)return;const m=l(g.min,g.max);return m&&m.break?m:void 0},h,u),d&&d.break)return d.break},updateHeaders:(l,c)=>(n.updateHeaderPairs([{address:r,update:l}],{description:c?.description??`Update ${n._isColumn?Kn:Jn} ${toString()}`,...c}),a),setHidden:l=>(n.setHidden(r,l),a),getUsedRange:l=>{const c=n._headerRunCoords;return!c||c.min<0||c.max>n._maxDataIndex?null:Xh(c,r)?n.getRange(c,l):null},getCount:()=>r.max-r.min+1,getVisibleCount:()=>n.getVisibleCount(r.min,r.max),isEntireHeaders:()=>{const l=n._maxRunCoords;return!(r.min>l.min||r.max<l.max)},getSnapshot:l=>this._getSnapshot(r,l),clear:()=>(n._clear(r),a),setSize:(l,c)=>(n.setSize(r,l,c),a),at:l=>n.at(r.min+l),getOrientation:()=>n.getOrientation(),doBatch:(l,c)=>this.doBatch(h=>l(h),c),getSheetHeader:()=>n,isICellHeaderRange:!0};return Object.freeze(a)}getSelectedRange(e){const t=(n=>{if(!n)return null;let r=k.cellToRange(n.cell);for(let o=0;o<n.ranges.length;o++)r=k.unionRanges(r,n.ranges[o]);return r})(this._options.sheet.getSelection().getCoords());return this.getRange(t,e)}getUsedRange(e){return this.getRange(this._headerRunCoords,e)}getEntireRange(e){return e?this.getRange(this._maxRangeCoords,e):this._maxDataRange}at(e){if(e<0||e>this._maxDataIndex)return this._emptyHeader;if(this._lastHeaderRead?.offset===e)return this._lastHeaderRead.header;const t=mm(e,this._readCache);if(!t)return this._emptyHeader;const n=this._options.getTextAt?.(e)??e+"",r=this._options.createCellHeader(this,t,{value:n});return this._lastHeaderRead={offset:e,header:r},r}updateHeaderPairs(e,t){if(this.isProtected())throw new Error(this._isColumn?Bs:Ds);return this._updatePairsInternal(e,t)}_parseHeaderRangeAddress(e){if(e==null)throw new Error("Must specify a range.");const t=((n,r,o)=>{if(n==null)return null;let i={};if(typeof n=="number")i.colStart=n,i.colEnd=n,i.rowStart=n,i.rowEnd=n;else if(typeof n=="string"){if(r){if(n.match(/[0-9]+/))throw new Error("Invalid range address for header orientation")}else if(n.match(/[a-zA-Z]+/))throw new Error("Invalid range address for header orientation");let l=Mt(n,o);if(!l){const c=Dm(n.toUpperCase(),!0);c?.colIndex!==void 0&&(i.colStart=c.colIndex,i.colEnd=c.colIndex),c?.rowIndex!==void 0&&(i.rowStart=c.rowIndex,i.rowEnd=c.rowIndex)}i={...i,...l}}const a={min:void 0,max:void 0};return r?(a.min=n.min??n.colStart??i.colStart,a.max=n.max??n.colEnd??i.colEnd):(a.min=n.min??n.rowStart??i.rowStart,a.max=n.max??n.rowEnd??i.rowEnd),a.min===void 0||a.max===void 0?null:a})(e,this._isColumn,this._maxRangeCoords);if(!t)throw new Error("Invalid header range.");return t}update(e,t,n){if(!e||(Array.isArray(e)||(e=[e]),e.length===0))return;const r=[];for(let o=0;o<e.length;o++){const i=this._parseHeaderRangeAddress(e[o]);this.getRange(i).forEachSpan((a,l)=>{const c=l.getCoords();r.push({address:c,update:t})},{includeEmpty:!0})}return this.updateHeaderPairs(r,n),this}setSize(e,t=null,n){(n?.relativeSize??!1)||typeof t!="number"||(t+="px");const r={size:t,autoSize:n?.autoSize??!1},o=`Resize ${this._isColumn?Kn:Jn}`;return this.update(e,r,{description:o,...n}),this}setHidden(e,t=null){const n={hidden:t},r=`${t?"Unhide":"Hide"} ${this._isColumn?Kn:Jn}`;return this.update(e,n,{description:r}),this}_clear(e,t){const n="Clear "+(this._isColumn?"Column Headers":"Row Headers");this.updateHeaderPairs([{address:e,update:null}],{description:n,...t})}_getSnapshot(e,t){if(e.min<0)return N.EmptyArray;t=Object.freeze({...t});const n=this,r=this._getState(),o=(this._isColumn?"Column":"Row")+" Headers";return{copyTo(a,l){const c={...t,...l},h=a.getCoords(),u=h.min-e.min,d=[];if(n._scanHeaders((g,m)=>{const f=m.getCoords();d.push({address:{min:f.min+u,max:f.max+u},update:m.getCellHeader()})},r.headers,n._options.createCellHeader,null,e,{includeSizes:!0,includeStyles:!0}),!c.fitDestination){let g=e.max-e.min+1,m=h.max-h.min+1,f=N.roundAccurately(m/g);if(f>1&&m%g===0){const _=d.length;for(let p=0;p<f;p++)for(let S=0;S<_;S++){const C=d[S],y=C.address,b=(p+1)*g;d.push({address:{min:y.min+b,max:y.max+b},update:C.update})}}}if(a.doBatch(()=>{a.clear(),a.getSheetHeader()._updatePairsInternal(d)},o),c.isCut){const g=n._maxRunCoords;e.min<=g.min&&e.max>=g.max&&n._clear(e)}return h},getCoords:()=>e,toText:()=>null,toHtml:()=>null,toImage:()=>null,getSource:()=>n,getName:()=>o,isISnapshot:!0}}isProtected(){return this._options?.isProtected()??!1}getScaleFactor(){return this._options.scaleFactor()??1}get _headers(){return this._lastHeaders===null&&(this._lastHeaders=this._getState()?.headers),this._lastHeaders}_updatePairsInternal(e,t){if(!e||e.length===0)return null;const n=t?.skipCustomSize??!1,r=this._isColumn,o=this.getSheet().getStyles(),i=this._beginCommit({description:t?.description??`Update ${r?Kn:Jn}`});let a=[...this._getState().headers],l=!1,c=!1;const h=r?exports.IBorder.Edge.Top:exports.IBorder.Edge.Left;exports.IBorder.oppositeEdge(h);const u=r?exports.IBorder.Edge.Right:exports.IBorder.Edge.Bottom;exports.IBorder.oppositeEdge(u);const d=this,g=(y,b)=>{if(this.isProtected())throw new Error(this._isColumn?Bs:Ds);c=c||b===null,!c&&b&&(c=!!b.isICellHeader||b?.size!==void 0||b?.hidden!==void 0),l=l||b===null||b?.style!==void 0||b?.isICellHeader;const w={onUpdate:(E,I)=>n&&E&&E.csz?E:pf(d,o,E,I),onSplit:E=>[E.value,E.value],onMerge:(E,I,x,v)=>{if(!(E&&!I||!E&&I||!E&&!I)&&E.sz===I.sz&&E.csz===I.csz&&E.h===I.h&&E.cs===I.cs)return E},isCull:(E,I,x)=>E===void 0};a=Xt(Bl(a,{min:y.min,max:y.max,value:b},w))},m=e.length,f=new Array(m);for(let y=0;y<m;y++){const b=e[y],w=this._parseHeaderRangeAddress(b.address);if(w.min<0||w.max>this._maxDataIndex)throw new Ne(Ti);g(w,b.update),f[y]=w}let _=!1,p=a.length;if(p>0&&a[0].min===0&&a[p-1].max===this._maxDataIndex){let y=a[0],b=!1,w=-1;for(let x=0;!b&&x<p;x++){const v=a[x],R=v.min;if(w+1!==R){b=!0;continue}const A=v.max;w=A,y.max-y.min<A-R&&(y=v)}b||(this._defaultCustomSize=y.value?.sz??-1,_=!0);const E=this._defaultCustomSize===-1?this._options.defaultSize():this._defaultCustomSize,I=[];for(let x=0;x<p;x++){const v=a[x],R=v.value;if(R===null)continue;const A=Object.keys(R);A.length!==0&&(A.length!==1||R.sz===void 0||R.sz!==null&&R.sz!==E)&&I.push(v)}a=I,p=a.length}const S=[],C=this._defaultSize;for(let y=0;y<p;y++){const b=a[y],w=b.value;if(w===null)continue;let E=!1;w.sz!==void 0&&w.sz!==C&&(E=!0),w.csz&&(E=!0),w.h&&(E=!0),w.cs&&(E=!0),E&&S.push(b)}return a=S,p=a.length,_&&d._invalidSizes(),this._updateState({headers:a,defaultCustomSize:this._defaultCustomSize,runs:f}),i.commit(),f}hasCustomFormats(){return this._hasCustomFormats}hasCustomStyles(){return this._hasStyles}hasHidden(){return this._hasHidden}getDefaultSize(){return this._defaultPxSize}getMaxSize(){return Math.ceil(this._options.maxSize()*this._options.scaleFactor())}getMinSize(){return Math.floor(this._options.minSize()*this._options.scaleFactor())}findOffset(e){return((t,n,r)=>{if(n<0)return 0;if(!t||t.length===0)return n*r;const o=t[t.length-1];if(n>o.indexMax)return o.runningOffsetMax+Math.round((n-o.indexMax-1)*r+(o.spanSize!==0?1:0));const i=t.length===1?0:N.findEqualOrGreater(t,n,c=>c.indexMax),a=t[i],l=n-a.indexMin;return a.runningOffsetMin+l*a.spanSize})(this._indexedSizes,e,this._defaultPxSize)}findIndex(e){return Math.min(Math.max(0,((t,n,r)=>{if(!t||t.length===0)return Math.floor(n/r);const o=t[t.length-1];if(n>o.runningOffsetMax)return o.indexMax+Math.ceil((n-o.runningOffsetMax)/r);let i=t.length===1?0:N.findEqualOrGreater(t,n,c=>c.runningOffsetMax);const a=t[i];if(a.spanSize===0)return Math.max(0,a.indexMin-1);const l=n-a.runningOffsetMin;return a.indexMin+Math.floor(l/a.spanSize)})(this._indexedSizes,e,this._defaultPxSize)),this._maxDataIndex)}findVisibleIndex(e){return this._lastVisibleRunsRead===e||(this._lastVisibleRunCoords=((t,n,r=Number.MAX_SAFE_INTEGER)=>{if(!t||t.length===0)return{min:n,max:n};let o=t.length-1,i=t[o];if(n>i.indexMax){const l=n-i.runningHiddenRuns;return{min:l,max:l}}o=t.length===1?0:N.findEqualOrGreater(t,n,l=>l.indexMax),i=t[o];const a=i.spanSize===0?Math.max(-1,i.indexMin-1-(t[o-1]?.runningHiddenRuns??1)):n-i.runningHiddenRuns;return{min:a,max:a+Math.min(r+1,i.spanSize===0?1:0)}})(this._indexedSizes,e,this._maxDataIndex),this._lastVisibleRunsRead=e),this._lastVisibleRunCoords}getSpanSize(e,t=e+1){return this.findOffset(t)-this.findOffset(e)}getVisibleCount(e,t){if(e>t)throw new Error("Invalid arguments.");if(e<0||t>this._maxDataIndex)throw new Ne;return this._hasHidden?((n,r,o)=>{let i=o-r+1;if(n.length===0)return i;let a=n.length-1,l=n[a];if(r>l.indexMax)return i;a=n.length===1?0:N.findEqualOrGreater(n,r,u=>u.indexMax),l=n[a];let c=l.runningHiddenRuns;if(l.spanSize===0&&r<=l.indexMax){const u=l.indexMax-l.indexMin+1;i-=Math.min(u,l.indexMax-r+1)}o>l.indexMax&&a<n.length&&(a=N.findEqualOrGreater(n,o,u=>u.indexMax),l=n[Math.min(a,n.length-1)]);let h=l.runningHiddenRuns;if(l.spanSize===0&&l.indexMin<=o){const u=l.indexMax-l.indexMin+1;i-=Math.min(u,o-l.indexMin+1),h-=u}return i-=h-c,i})(this._indexedSizes,e,t):t-e+1}isSelectedAll(e){const t=this.getSelectedRuns();if(t.length===0)return!1;const n=N.findEqualOrGreater(t,e,o=>o.max),r=t[n];return!(!r||e<r.min||e>r.max)&&r.value.isSelectedAll}isSelected(e){const t=this.getSelectedRuns();if(t.length===0)return!1;const n=N.findEqualOrGreater(t,e,o=>o.max),r=t[n];return!(!r||e<r.min||e>r.max)}getSelectedRuns(){let e=this._selectionRuns;return e||(this._selection&&(e=((t,n,r)=>{let o=[];n?.ranges&&n.ranges.length>0?o=n.ranges:n?.cell&&(o=[k.cellToRange(n?.cell)]);let i=[];const a=t.getOrientation()===exports.w.Orientation.Column;for(let l=0;o&&l<o.length;l++){const c=o[l],h=a?c.colStart:c.rowStart,u=a?c.colEnd:c.rowEnd,d=a?c.rowStart:c.colStart,g=a?c.rowEnd:c.colEnd,m=a?r.rowStart:r.colStart,f=a?r.rowEnd:r.colEnd,_=d<=m&&g>=f;i=Xt(Bl(i,{min:h,max:u,value:{isSelectedAll:!1}},{onUpdate:(p,S)=>{const C=Ol(p,S);return C.isSelectedAll=p?.isSelectedAll||_,C}}))}return i})(this,this._selection,this._maxSheetCoords)),e||(e=N.EmptyArray)),this._selectionRuns=e,this._selectionRuns}hiddenHeadersAt(e,t=!1){if(this._indexedSizes.length===0)return 0;let n=this._indexedSizes.length===1?0:N.findEqualOrGreater(this._indexedSizes,e,o=>o.indexMax),r=this._indexedSizes[n];return!r||r.spanSize!==0||r.indexMin>e||r.indexMax<e?0:t?e-r.indexMin+1:r.indexMax-e+1}_insertHeaders(e,t){if(this.isProtected())throw new Error(this._isColumn?Bs:Ds);if(t<=0)return;const n=this._beginCommit({description:`Insert ${this._isColumn?Kn:Jn}`}),r=this._getState();let o=[...r.headers];o=Xt(((a,l,c=1)=>{const h=N.findEqualOrGreater(a,l,m=>m.max),u=a.slice(0,h),d=[],g=[];if(!a[h])return{preceding:u,modified:g,trailing:d};a[h].min>=l?d.push({...a[h],min:a[h].min+c,max:a[h].max+c}):g.push({...a[h],min:a[h].min,max:a[h].max+c});for(let m=h+1;m<a.length;m++)d.push({...a[m],min:a[m].min+c,max:a[m].max+c});return{preceding:u,modified:g,trailing:d}})(o,e,t));const i=[{min:e,max:e+t}];this._updateState({headers:o,runs:Xt(rr([...r?.runs??[],...i]))}),n.commit()}_deleteHeaders(e,t){if(this.isProtected())throw new Error(this._isColumn?Bs:Ds);const n=this._beginCommit({description:`Delete ${this._isColumn?Kn:Jn}`}),r=this._getState();let o=[...r.headers];o=Xt(j0(o,e,t));const i=[{min:e,max:e+t}];this._updateState({headers:o,runs:Xt(rr([...r?.runs??[],...i]))}),n.commit()}beginCommit(e){return this._beginCommit(typeof e=="string"?{description:e}:e)}doBatch(e,t){return this._transactions.doBatch(e,typeof t=="string"?{description:t}:{description:"Update Header",...t})}isClosed(){return this._closed}close(){this._sheetRemoveListener?.(),this._emitter.close(),this._transactionsRemoveListener?.(),this._closed=!0}_getState(){return this._transactions.getState(this)}_beginCommit(e){return this._transactions.beginCommit(e)}_updateState(e){const t=this._transactions.beginCommit();try{t.updateState(this,e),this._onHeaderChange(),t.commit()}catch(n){throw t.rollback(),n}}fromJSON(e){const t=e||{};this._defaultCustomSize=t.defaultSize??-1,this._defaultCustomSize<=0&&(this._defaultCustomSize=-1),this._invalidSizes();const n=this._options.sheet.getStyles().beginPersist();try{const r=[],o=t.headers?t.headers.length:0,i=this._maxDataIndex;for(let a=0;a<o;a++){let l=t.headers[a];if(l.min>=i)continue;let c={min:l.min,max:Math.min(l.max,i)};const h={};l.sz!==void 0&&l.sz!==-1&&(h.sz=l.sz),l.h!==void 0&&(h.h=l.h),l.csz!==void 0&&(h.csz=l.csz),l.cs!==void 0&&(h.cs=l.cs),Object.keys(h).length===0&&(h.cs=!0),c.value=h,r.push(c)}this._updateState({headers:r,defaultCustomSize:this._defaultCustomSize})}finally{n.endPersist()}}toJSON(){if(this._headers.length===0&&this._defaultCustomSize===-1)return null;const e={headers:[]};if(this._defaultCustomSize!==-1&&(e.defaultSize=N.roundAccurately(this._defaultCustomSize,8)),this._headers.length===0)return e;const t=this._defaultCustomSize,n=this.getSheet().getStyles().beginPersist();for(let r=0;r<this._headers.length;r++){const o=this._headers[r],i=o.value;if(!i)continue;const a={min:o.min,max:o.max};i.sz!==void 0&&i.sz!==t&&(a.sz=N.roundAccurately(i.sz,8),i.csz!==void 0&&(a.csz=i.csz)),i.h===!0&&(a.h=i.h),Object.keys(a).length>2&&e.headers.push(a)}return n.endPersist(),e}}class Vd{constructor(e,t,n){this._c=e,this._tvTl=t,this._rsTl=n}tvTl(){return this._tvTl(this._c)}rsTl(){return this._rsTl(this._c)}getCoords(){return this._c}}const _f=s=>{let e="";const t=hi,n=s.length;for(let r=0;r<n;r++){const o=s[r];o.type==="cell"?e+=t(o.value):e+=o.value}return e},Sf=(s,e=0,t=0)=>{let n="";const r=Wm,o=s.length;for(let i=0;i<o;i++){const a=s[i];a.type==="cell"?n+=r(a.value,e,t):n+=a.value}return n};class Ey{constructor(e,t,n){this._c=e,this._tokens=t,this._references=n||N.EmptyArray}getFormulaTextAt(e,t,n=!1){return n?_f(this._tokens):Sf(this._tokens,e,t)}getTokensAt(e,t,n){let r=this._tokens;return n!==void 0&&(r=((o,i)=>{const a=o.length,l=[];if(i===void 0)return N.EmptyArray;let c=-1,h=!1;for(let u=0;!h&&u<a;u++){const d=o[u],g=d.evalIndex??Number.MAX_SAFE_INTEGER;if(c===-1){if(g!==i)continue;c=u}g>i?h=!0:l.push(d)}h=!1;for(let u=c-1;!h&&u>=0;u--){const d=o[u];(d.evalIndex??Number.MAX_SAFE_INTEGER)>i?h=!0:l.unshift(d)}return l.length>1&&l[0].type==="whitespace"&&l.shift(),l.length>1&&l[l.length-1].type==="whitespace"&&l.pop(),l})(r,n)),r=((o,i=0,a=0)=>{const l=o.length,c=new Array(l);for(let h=0;h<l;h++){const u=o[h];if(u.type!=="cell"){c[h]=u;continue}const d={...u},g={...d.value};d.value=g,c[h]=d,g.colIndex===Number.MIN_SAFE_INTEGER||g.$colIndex||(g.colIndex+=a),g.rowIndex===Number.MIN_SAFE_INTEGER||g.$rowIndex||(g.rowIndex+=i)}return c})(r,e,t),r}getReferencesAt(e,t){return((n,r=0,o=0)=>{const i=n.length,a=new Array(i);for(let l=0;l<i;l++){const c=n[l];if(typeof c=="string"||c instanceof exports.n.Known){a[l]=c;continue}const h={...c};a[l]=h,h.colStart===Number.MIN_SAFE_INTEGER||h.$colStart||(h.colStart+=o),h.rowStart===Number.MIN_SAFE_INTEGER||h.$rowStart||(h.rowStart+=r),h.colEnd===Number.MIN_SAFE_INTEGER||h.$colEnd||(h.colEnd+=o),h.rowEnd===Number.MIN_SAFE_INTEGER||h.$rowEnd||(h.rowEnd+=r)}return a})(this._references,e,t)}toJSON(){const e=this._c;return[Cn(e),this.getFormulaTextAt(e.rowStart,e.colStart)]}getCoords(){return this._c}}class Wi{constructor(e,t,n){this.groupId=e,this.uuid=t,this.noShift=n}onRemove(e){}getShifted(e){if(!e.after)return null;const t=this.noShift;return t?void 0:{...e.after,value:new Wi(this.groupId,this.uuid,t)}}getSplit(e,t){}copyTo(e,t){return new Wi(this.groupId,this.uuid,this.noShift)}canTile(e,t){return!1}}class ji{constructor(e,t,n,r,o,i,a,l,c,h){this.uuid=e,this.spatialsIds=t,this.isRanges=r,this.coords=n,this.sheet=o,this.generation=i,this.handler=a,this.handlerW=l,this.removeListener=c,this.options=h}delete(){this.removeListener()}createRangeEvent(e,t){const n=this;let r;const o=()=>{if(r)return r;const a=n.sheet,l=n.isRanges,c=n.coords;return t||!c||c.length===0?fn(a,a.getEntireRange().getCoords(),null,t):l?(r=a.getRanges(n.coords),r):(r=a.getRange(n.coords[0]),r)},i=e.trigger;return{getSource:o,trigger:i,isTransactional:e.isTransactional??!0,toString:()=>`SheetRangeEvent: ('${i}', ${o().toString()})`,timeStamp:e.timeStamp??Date.now()}}notify(e,t){const n=this.createRangeEvent(e,t),r=this.handler??this.handlerW.deref();try{r?.(n)}catch(o){console.warn(o)}this.options?.once&&this.removeListener()}processRemove(e){const t=this.spatialsIds,n=t.indexOf(e.value.uuid);console.assert(n!==-1,"invalid uuid");const r=this.coords,o=r.slice(0,n).concat(r.slice(n+1)),i=t.slice(0,n).concat(t.slice(n+1));return new ji(this.uuid,i,o,this.isRanges,this.sheet,this.generation,this.handler,this.handlerW,this.removeListener,this.options)}processShift(e){const t=this.spatialsIds.indexOf(e.value.uuid);console.assert(t!==-1,"invalid uuid");const n=[...this.coords];return n[t]={...n[t],...k.sanitizeRange(e)},new ji(this.uuid,this.spatialsIds,n,this.isRanges,this.sheet,this.generation,this.handler,this.handlerW,this.removeListener,this.options)}processSplit(e){}processMerge(e){}}const wf=Object.freeze({coords:k.EmptyCell,topLeft:Yo.EmptyTopLeft}),vy=Object.freeze({cell:k.EmptyCell,ranges:N.EmptyArray,rangeIndex:0}),dl=Object.freeze({selection:vy,topLeft:Yo.EmptyTopLeft,freezePanes:wf,showRowHeaders:!0,showColumnHeaders:!0,showRowGridlines:!0,showColumnGridlines:!0,rowHeaderStyle:exports.ISheetView.HeaderTextStyle.One,columnHeaderStyle:exports.ISheetView.HeaderTextStyle.A1,showFormulas:!1,showZeros:!0,zoomScale:100,gridLineColor:null});class gl{constructor(e){if(this._emitter=null,!e?.sheet)throw new Error("SheetView requires a sheet.");const t=new st(this);this._emitter=t,this._sheet=e.sheet,this.clear(!1),e.json&&this._fromJSON(e.json)}addListeners(e,t){return this._emitter.addListeners(e,t)}setTopLeft(e){return this._state.topLeft=Object.freeze({left:e?.left??this._state.topLeft.left,top:e?.top??this._state.topLeft.top}),this._emitter.notify("onTopLeftChange"),this}getTopLeft(){return this._state.topLeft}getFreezePanes(){return this._state.freezePanes}setFreezePanes(e){return this._state.freezePanes=this._mergeFreezePanes(e),this._emitter.notify("onFreezeSplitChange"),this}_mergeFreezePanes(e){return e?{...this._state.freezePanes,coords:{colIndex:e?.coords?.colIndex??this._state.freezePanes.coords.colIndex,rowIndex:e?.coords?.rowIndex??this._state.freezePanes.coords.rowIndex},topLeft:{left:e?.topLeft?.left??this._state.topLeft.left,top:e?.topLeft?.top??this._state.topLeft.top}}:wf}isShowRowHeaders(){return this._state.showRowHeaders}setShowRowHeaders(e){return this._state.showRowHeaders=e,this._notifyAll(),this}isShowColumnHeaders(){return this._state.showColumnHeaders}setShowColumnHeaders(e){return this._state.showColumnHeaders=e,this._notifyAll(),this}isShowRowGridlines(){return this._state.showRowGridlines}setShowRowGridlines(e){return this._state.showRowGridlines=e,this._notifyAll(),this}isShowColumnGridlines(){return this._state.showColumnGridlines}setShowColumnGridlines(e){return this._state.showColumnGridlines=e,this._notifyAll(),this}getRowHeaderStyle(){return this._state.rowHeaderStyle}setRowHeaderStyle(e){return this._state.rowHeaderStyle=e,this._notifyAll(),this}getColumnHeaderStyle(){return this._state.columnHeaderStyle}setColumnHeaderStyle(e){return this._state.columnHeaderStyle=e,this._notifyAll(),this}getZoomScale(){return this._state.zoomScale}setZoomScale(e){return this._state.zoomScale=e,this._notifyAll(),this}isShowFormulas(){return this._state.showFormulas}setShowFormulas(e){return this._state.showFormulas=e,this._notifyAll(),this}isShowZeros(){return this._state.showZeros}setShowZeros(e){return this._state.showZeros=e,this._notifyAll(),this}getGridLineColor(){return this._state.gridLineColor}setGridLineColor(e){return this._state.gridLineColor=e,this._notifyAll(),this}setRangeSelection(e){return this._state.selection=e,this._emitter.notify("onRangeSelectionChange"),this}getRangeSelection(){return this._state.selection}getMovableSelection(){return this._movableSelection}setMovableSelection(e){const t=this._movableSelection;return this._movableSelection=Object.freeze(e??[]),N.isEqualArrays(t,this._movableSelection)||this._emitter.notify("onMovableSelectionChange"),this}selectMovables(e,t=!1){const n=new Set(this._sheet.getMovables().search());let r=null,o=!1;if(t){r=[...this._movableSelection];for(let i=e.length-1;i>=0;i--){const a=e[i];let l=r.indexOf(a);if(l!==i){if(o=!0,!n.has(a))throw new Error(`Movable ${a.getName()} not found in sheet.`);l!==-1&&r.splice(l,1),r.unshift(a)}}}else o=!N.isEqualArrays(e,this._movableSelection),r=[...e];o&&(this._movableSelection=r,this._emitter.notify("onRangeSelectionChange"),this._emitter.notify("onMovableSelectionChange"))}unselectMovables(e){const t=this._movableSelection,n=[];for(let r=0;r<t.length;r++){const o=t[r];e.indexOf(o)===-1&&n.push(o)}return t.length!==n.length&&(this._movableSelection=n,this._emitter.notify("onRangeSelectionChange"),this._emitter.notify("onMovableSelectionChange")),this}_notifyAll(){const e=this._emitter;e.notify("onRangeSelectionChange"),e.notify("onTopLeftChange"),e.notify("onFreezeSplitChange"),e.notify("onAnyChange")}toJSON(){const e={},t=Object.keys(this._state);for(let r=0;r<t.length;r++){const o=this._state[t[r]];o!=null&&o!==dl[t[r]]&&(e[t[r]]=o)}delete e.movableSelection,delete e.gridLineColor,this._state.gridLineColor instanceof Ge&&(e.gridLineColor=this._state.gridLineColor.toString()),delete e.topLeft,!this._state.topLeft||this._state.topLeft.left===0&&this._state.topLeft.top===0||(e.topLeft={left:this._state.topLeft.left??0,top:this._state.topLeft.top??0}),delete e.selection;const n=this._state.selection;if(n){let r={};!n.cell||n.cell.colIndex===0&&n.cell.rowIndex===0||(r.cell=rs(n.cell)),n.ranges&&n.ranges.length>0&&(r.ranges=Sc(n.ranges),n.rangeIndex!==void 0&&n.rangeIndex!==-1&&n.rangeIndex!==0&&(r.rangeIndex=n.rangeIndex)),Object.keys(r).length>0&&(e.selection=r)}if(delete e.freezePanes,this._state.freezePanes&&(this._state.freezePanes.coords.colIndex!==0||this._state.freezePanes.coords.rowIndex!==0)){const r={};this._state.freezePanes.coords.colIndex!==0&&(r.c=this._state.freezePanes.coords.colIndex),this._state.freezePanes.coords.rowIndex!==0&&(r.r=this._state.freezePanes.coords.rowIndex),this._state.freezePanes.topLeft.left!==0&&(r.x=this._state.freezePanes.topLeft.left),this._state.freezePanes.topLeft.top!==0&&(r.y=this._state.freezePanes.topLeft.top),e.freezePanes=r}return Object.keys(e).length===0?null:e}_fromJSON(e){let t=JSON.parse(JSON.stringify(e||{}));t?.zoomScale&&(t.zoomScale=N.roundAccurately(parseFloat(e.zoomScale),2));const n=r=>{const o=this._sheet.getRange(r).getBounds(),i=(t.zoomScale??100)/100;return{x:o.x*i,y:o.y*i,width:o.width*i,height:o.height*i}};if(typeof t?.gridLineColor=="string"&&(this._sheet?.getStyles()?t.gridLineColor=this._sheet.getStyles().parseColor(e.gridLineColor):console.warn("Style was created with no styles so gridLineColor can't be parsed.")),t.topLeft)if(typeof t.topLeft=="string"){const r=n(Tr(t.topLeft));t.topLeft={left:r.x,top:r.y}}else t.topLeft=Object.freeze({left:t.topLeft?.left??t?.x??0,top:t.topLeft?.top??t?.y??0});if(t.selection){let r=Tr(t.selection.cell??"A1");if(t.selection.cell=r,t.selection.ranges){let o=Math.max(0,Math.min(t.selection.rangeIndex??t.selection.ranges?.length-1,t.selection.ranges?.length-1));t.selection.rangeIndex=o;let i=!1;for(let a=0;a<t.selection.ranges.length;a++){const l=St(t.selection.ranges[a]);t.selection.ranges[a]=l,a===o&&r&&!k.isCellWithinRange(r,l)&&(i=!0)}if(i)for(let a=0;i&&a<t.selection.ranges.length;a++)k.isCellWithinRange(r,t.selection.ranges[a])&&(i=!1,t.selection.rangeIndex=a);i&&(t.selection.ranges.push(k.cellToRange(r)),t.selection.rangeIndex=t.selection.ranges.length-1)}else delete t.selection.rangeIndex}if(t.freezePanes){const r=t.freezePanes;if(typeof r.coords=="string"&&(r.coords=Tr(r.coords)),typeof r.topLeft=="string"){const o=Tr(r.topLeft),i=n({colIndex:o.colIndex+1,rowIndex:o.rowIndex+1}),a=n({colIndex:(r?.coords?.colIndex??-1)+1,rowIndex:(r?.coords?.rowIndex??-1)+1});r.topLeft={left:0,top:0},t.topLeft||(t.topLeft={top:0,left:0}),o.colIndex>0&&(r.topLeft.left=t.topLeft?.left??0,t.topLeft.left=i.x-a.x+r.topLeft.left),o.rowIndex>0&&(r.topLeft.top=t.topLeft?.top??0,t.topLeft.top=i.y-a.y+r.topLeft.top)}t.freezePanes={coords:{colIndex:r?.coords?.colIndex??t.freezePanes?.c??0,rowIndex:r?.coords?.rowIndex??t.freezePanes?.r??0},topLeft:{left:r?.topLeft?.left??t.freezePanes?.x??0,top:r?.topLeft?.top??t.freezePanes?.y??0}}}this.update(t)}clear(e=!0){return this._state={...dl},this._movableSelection=Object.freeze([]),e&&this._notifyAll(),this}update(e){return this._state={...dl,...this._state,...e},this._state.freezePanes=this._mergeFreezePanes(this._state.freezePanes),this._state.zoomScale=Math.min(400,Math.max(10,this._state.zoomScale)),this._notifyAll(),this}get isISheetView(){return!0}}async function Gd(){const{getCrypto:s}=await Promise.resolve().then(()=>require("./DN99k_K8Xt6Cxpbg.cjs"));return s()}const $d=async(s,e,...t)=>{const n=xy(...t);return s.subtle.digest(e,n)},xy=(...s)=>{const e=s.reduce((r,o)=>r+o.byteLength,0),t=new Uint8Array(e);let n=0;return s.forEach(r=>{t.set(new Uint8Array(r),n),n+=r.byteLength}),t.buffer},Ud=s=>{const e=new Uint8Array(s);let t="";for(let n=0;n<e.byteLength;n++)t+=String.fromCharCode(e[n]);return btoa(t)};class un{static{this.DefaultAlgo="SHA-512"}static{this.DefaultSpinCount=1e5}static async generateSaltAndHash(e,t=un.DefaultAlgo,n=un.DefaultSpinCount){if(!e)return null;const r=(await Gd()).getRandomValues(new Uint8Array(16)),o=Ud(r.buffer);return{salt:o,hash:await un._convertPasswordToHash(e,o,t,n)}}static async verifyPassword(e,t,n=un.DefaultAlgo,r=un.DefaultSpinCount){if(!e||!t)throw new Ot;return((o,i)=>{const a=o.length,l=i.length;let c=a===l?0:1;for(let h=0;h<Math.max(a,l);h++)c|=o.charCodeAt(h%a)^i.charCodeAt(h%l);return c===0})(await un._convertPasswordToHash(e,t.salt,n,r),t.hash)}static async _convertPasswordToHash(e,t,n,r){const o=await Gd();n=n.toUpperCase();const i=(c=>{const h=new ArrayBuffer(2*c.length),u=new DataView(h);for(let d=0;d<c.length;d++)u.setUint16(2*d,c.charCodeAt(d),!0);return new Uint8Array(h)})(e),a=(c=>{const h=atob(c),u=new Uint8Array(h.length);for(let d=0;d<h.length;d++)u[d]=h.charCodeAt(d);return u.buffer})(t);let l=await $d(o,n,a,i.buffer);for(let c=0;c<r;c++){const h=new Uint32Array([c]).buffer;l=await $d(o,n,l,h)}return Ud(l)}}class yf{constructor(e,t=!1){this._emitter=null,this._emitter=new st(this),this.fromJSON(e),this._isReadOnly=t}async lock(e,t,n,r){if(this._isReadOnly)return this;if(this.isLocked()&&!this._isPaused)throw new Error("Cannot lock an already locked object. Use unlock first.");try{this._validatePassword()}catch{throw new Error("A password is already set. Unlock first to change.")}let o;if(t){const i=await un.generateSaltAndHash(t,n,r);o={salt:i.salt,hash:i.hash},n&&(o.algorithm=n),r&&(o.spinCount=r)}else o=null;return e=e??{},this._updateProperties(e),this._properties=e,this._password=o,this._emitter.notify("onLockChange"),this._emitter.notify("onChange"),this}async unlock(e){if(this._isReadOnly)throw new Error("Cannot unlock a readonly workbook.");return await this._validatePassword(e),this._clearProperties(),this._password=null,this._identities=null,this._password=null,this._emitter.notify("onLockChange"),this._emitter.notify("onChange"),this}checkPassword(e){return this._validatePassword(e)}hasPassword(){return this._password!==null}async pause(e){return this._emitter.notify("onLockChange"),this._emitter.notify("onChange"),await this._validatePassword(e),this._password&&(this._isPaused=!0),this}resume(){return this._isPaused=!1,this}isPaused(){return this._isPaused}isLocked(){return this._properties!==null&&!this._isPaused}isReadOnly(){return this._isReadOnly}async _validatePassword(e){const t=this._password;if(!(e&&e.length!==0||t&&t.hash))return!0;if(!e)throw new Error("Password is required.");if(!await un.verifyPassword(e,{salt:t.salt,hash:t.hash},t.algorithm,t.spinCount))throw new Error("Invalid password.");return!0}getProperties(){return this._properties}_isPropertyAllowed(e){if(this._isReadOnly)return!1;if(!this.isLocked())return!0;const t=this._properties[e];return typeof t=="boolean"&&t}_updateProperties(e){this._properties={...e,...this._properties??{}}}_clearProperties(){this._properties=null}addListeners(e,t){return this._emitter.addListeners(e,t)}fromJSON(e){this._password=null,this._identities=null,this._isPaused=!1,this._properties=null,this._fromJSON(e??null),e&&(e.password&&(this._password=e.password),e.identities&&(this._identities=e.identities))}_fromJSON(e){}_toJSON(e){return e}toJSON(){if(!this._properties)return null;let e={};return e=this._toJSON(e)??{},this._password&&(e.password=this._password),this._identities&&(e.identities=this._identities),e}}const Iy=Object.freeze({selectLockedCells:!0,selectUnlockedCells:!0,autoFilter:!1,deleteColumns:!1,deleteRows:!1,formatCells:!1,formatColumns:!1,formatRows:!1,insertColumns:!1,insertHyperlinks:!1,insertRows:!1,objects:!1,pivotTables:!1,scenarios:!1,sheet:!1,sort:!1,verifier:null});class qd extends yf{isAutoFilterAllowed(){return this._isPropertyAllowed("autoFilter")}isDeleteColumnsAllowed(){return this._isPropertyAllowed("deleteColumns")}isDeleteRowsAllowed(){return this._isPropertyAllowed("deleteRows")}isFormatCellsAllowed(){return this._isPropertyAllowed("formatCells")}isFormatColumnsAllowed(){return this._isPropertyAllowed("formatColumns")}isFormatRowsAllowed(){return this._isPropertyAllowed("formatRows")}isInsertColumnsAllowed(){return this._isPropertyAllowed("insertColumns")}isInsertHyperlinksAllowed(){return this._isPropertyAllowed("insertHyperlinks")}isInsertRowsAllowed(){return this._isPropertyAllowed("insertRows")}isObjectsAllowed(){return this._isPropertyAllowed("objects")}isPivotTablesAllowed(){return this._isPropertyAllowed("pivotTables")}isScenariosAllowed(){return this._isPropertyAllowed("scenarios")}isSortAllowed(){return this._isPropertyAllowed("sort")}isSelectLockedCellsAllowed(){return!1}isSelectUnlockedCellsAllowed(){return!1}_updateProperties(e){super._updateProperties(e),this._properties=e}_clearProperties(){super._clearProperties(),this._properties=null}_fromJSON(e){super._fromJSON(e),this._properties=e}_toJSON(e){let t=this._properties;if(t){e={...e,...t};const n=Object.keys(t);for(let r=0;r<n.length;r++){const o=t[n[r]];o!=null&&o!==Iy[n[r]]&&(e[n[r]]=o)}}return super._toJSON(e)}}class ss{constructor(e,t,n){this._coords=Object.freeze(e),this._sheet=t,this._readOnly=n?.readOnly??null}_createRanges(e,t){let n=this._options;return t&&(n={...this._options,getOptions:yn(this._options?.getOptions,t)}),new ss(e,this._sheet,n)}_createRange(e,t){let n=this._options;return t&&(n={...this._options,getOptions:yn(this._options?.getOptions,t)}),new is(e,this._sheet,n)}_validateWrite(){const e=this._readOnly;if(e)throw new Error(e)}getCoords(){return this._coords}[Symbol.iterator](){const e=this.entries({excludeCellDetails:!0});return{next(){const t=e.next();return t.done?Re:{done:!1,value:t.value.value}},[Symbol.iterator](){return this}}}entries(e){const t=this.getCoords(),n=e?.reverse??!1;let r=n?t.length-1:0;const o=this;let i=o._createRange(t[r]),a=i.entries(e),l=a.next();return{next(){let c=l;do{if(l.done){if(r=n?r-1:r+1,r>=t.length||r<0)return l=Re,c;i=o._createRange(t[r]),a=i.entries(e)}l=a.next()}while(l.done);return c},[Symbol.iterator](){return this}}}async select(e){const t=await this._sheet._autoSelect(e??!0,Be(this.getCoords()));return this._createRanges(t)}calculate(){const e=this.getCoords();return this._sheet._calculate(e),this}addListener2(e,t){return this._sheet._addRangesListeners2(this.getCoords(),e,t,!0)}addListener(e,t){return this._sheet._addRangesListeners(this.getCoords(),e,t)}find(e,t){return this._sheet._find(this.getCoords(),e,t)}getFlattened(e){const t=this.getCoords();if(t.length===1)return this._createRanges(t,e);const n=e?.orientations??exports.w.Orientations.Both,r=n===exports.w.Orientations.Both,o=r?Number.MAX_SAFE_INTEGER:1,i=n===exports.w.Orientations.Row?exports.w.Orientation.Column:exports.w.Orientation.Row;let a=zl(t,o,i);if(r){const l=zl(t,o,exports.w.Orientation.Column);l.length<a.length&&(a=l)}return this._createRanges(a,e)}getVisible(e){const t=this._sheet._getVisible(this.getCoords(),e);return t&&t.length!==0?this._createRanges(t,e):null}getFixed(e){const t=[],n=this.getCoords();for(let r=0;r<n.length;r++)t.push(sf(n[r],e));return this._createRanges(t,e)}autoFit(e){return this._validateWrite(),this._sheet._autoFit(this.getCoords(),e),this}clear(e,t){return this._validateWrite(),this._sheet._clear(this.getCoords(),e,t),this}updateStyle(e,t){return this._validateWrite(),this._sheet._updateStyles(this.getCoords(),e,t),this}getStyleUpdater(){return this._sheet._getStyleUpdater(this.getCoords())}merge(e){return this._validateWrite(),this._sheet._merge(this.getCoords(),e),this}unmerge(e){return this._validateWrite(),this._sheet._unmerge(this.getCoords(),e),this}getMerges(){return this._sheet._getMerges(this.getCoords(),this._options?.excludeHidden??!1)}insert(e,t){return this._validateWrite(),this._sheet._insertCells(this.getCoords(),e,t),this}delete(e,t){return this._validateWrite(),this._sheet._deleteCells(this.getCoords(),e,t),this}async insertFrom(e,t){this._validateWrite();const n=await this._sheet._insertFrom(this.getCoords(),e,t);return n?this._createRanges([n]):null}async copyFrom(e,t){const n=await this._sheet._copyFrom(this.getCoords()[0],e,t);return n?this._createRanges([n]):null}isInvalidAny(){const e=this.getCoords();if(!e||e.length===0)return!0;for(let t=0;t<e.length;t++)if(e[t]===null)return!0;return!1}getSnapshot(e){return this._sheet._getSnapshot(this.getCoords(),e)}getEntireRows(e,t){return this._createRanges(Bi(this.getCoords(),this._sheet._entireCoords,exports.w.Orientation.Column,e),t)}getEntireColumns(e,t){return this._createRanges(Bi(this.getCoords(),this._sheet._entireCoords,exports.w.Orientation.Row,e),t)}getDefaultShiftOrientation(){return this._sheet._getDefaultShiftOrientation(this.getCoords()[0])}getCount(){return this.getCoords()?.length??0}getCounts(e){return this._sheet._contentCounts(this.getCoords(),e,this._options?.excludeHidden??!1)}isContentful(){return this._sheet._isContentful(this.getCoords(),this._options?.excludeHidden??!1)}getRowCount(){return cd(this.getCoords(),exports.w.Orientation.Row)}getColumnCount(){return cd(this.getCoords(),exports.w.Orientation.Column)}isEntireRowsAny(){return qo(this.getCoords(),this._sheet._entireCoords,!1)}isEntireColumnsAny(){return Jo(this.getCoords(),this._sheet._entireCoords,!1)}isEntireRows(){return qo(this.getCoords(),this._sheet._entireCoords,!0)}isEntireColumns(){return Jo(this.getCoords(),this._sheet._entireCoords,!0)}isOverlapping(){return ko(this.getCoords())}at(e){const t=this.getCoords();if(e<0||e>t.length-1)throw new Ne;return this._createRange(t[e])}isReadOnly(){return this._readOnly!==null}isInvalid(){return!1}getA1(){return Lm(this.getCoords(),this._sheet._entireCoords,mn,Hn)}getSource(){return this._sheet}doBatch(e,t){return this._sheet.doBatch(n=>e(n),typeof t=="string"?t:{description:"Ranges Update",...t})}get[Symbol.toStringTag](){return"[SheetRanges]"}toString(){return this.getA1()}get isICellRanges(){return!0}}class is{constructor(e,t,n){this._coords=Object.freeze(e),this._sheet=t,this._readOnly=n?.readOnly??null}getCoords(){return this._coords}_createRange(e,t){const n=this._sheet;if(!e)return fn(n,n._entireCoords);if(n._validateCoords(e),n._closed)return fn(null,n._entireCoords,e);let r=this._options;return t&&(r={...this._options,getOptions:yn(this._options?.getOptions,t)}),new is(e,this._sheet,r)}_createRanges(e,t){let n=this._options;return t&&(n={...this._options,getOptions:yn(this._options?.getOptions,t)}),new ss(e,this._sheet,n)}_deriveRanges(e,t){const n=this.getCoords();let r=n;return t&&(r=t(n),!r)?null:this._createRanges(r,e)}_deriveRange(e,t,n){if(!e)return this;let r=this._sheet._rangeToCoords(e);if(!r)return this;const o=this.getCoords();if(Oo(r,o))return this;if(n){const l=n(r,o);if(!l)return this;r={...o,...l}}var i,a;return i=r,(a=o)&&(a.$colStart===void 0?delete i.$colStart:i.$colStart=a.$colStart,a.$rowStart===void 0?delete i.$rowStart:i.$rowStart=a.$rowStart,a.$colEnd===void 0?delete i.$colEnd:i.$colEnd=a.$colEnd,a.$rowEnd===void 0?delete i.$rowEnd:i.$rowEnd=a.$rowEnd),this._createRange(r,yn(this._options?.getOptions,t))}_validateMaxSize(e=5e4){const t=this.getCoords(),n=this._sheet,r=n._colHeaders.getVisibleCount(t.colStart,t.colEnd);if(n._rowHeaders.getVisibleCount(t.rowStart,t.rowEnd)*r>e)throw new Error(Gm(e))}[Symbol.iterator](){const e=this.entries({excludeCellDetails:!0});return{next(){const t=e.next();return t.done?Re:{done:!1,value:t.value.value}},[Symbol.iterator](){return this}}}entries(e){const t=this.getCoords();let n=t;const r=this._sheet;if(e?.address){const i=r._rangeToCoords(e?.address);if(!i)throw new Error($o(e?.address));if(n=k.intersectRanges(i,t),!n)return qe}n.colEnd<n.colStart&&(n.colStart=t.colStart,n.colEnd=t.colEnd),n.rowEnd<n.rowStart&&(n.rowStart=t.rowStart,n.rowEnd=t.rowEnd);const o=this._options?.excludeHidden??!1;return r._cellIterator({excludeHidden:o,...e,includeRangeTypes:!e?.excludeCellDetails,bounds:n})}forEach(e,t){if(!e)return;const n=this.entries(t);let r=n.next();for(;!r.done;){const o=r.value,i=e(o.value,o.context);if(i)return i.break;r=n.next()}}_validateWrite(){const e=this._readOnly;if(e)throw new Error(e)}updateCells(e,t,n){this._validateWrite();const r=this.getCoords();n||(n=r);const o=this._sheet,i=o._isDataColumn,a={majorStart:i?r.colStart:r.rowStart,majorEnd:i?r.colEnd:r.rowEnd,minorStart:i?r.rowStart:r.colStart,minorEnd:i?r.rowEnd:r.colEnd},l=(t?.orientation??exports.w.Orientation.Row)===exports.w.Orientation.Column!==i,c=Ri(Array.isArray(e)?e:[[e]],l,a);return o._updateTuples(c,{description:t?.description??`Set ${k.isSingleCell(n)?"Cell":"Range"} ${mn(n,o._entireCoords)}`,...t},null,{isCell:!0}),this}setValue(e,t){if(Array.isArray(e))throw new Error("'setValue' expects a single value; when working with an array use 'setValue'.");return this._setValueOrValues(e,t)}setValues(e,t){if(!Array.isArray(e))throw new Error("'setValues' expects a 2d array; when working with a single value use 'setValue'.");return this._setValueOrValues(e,t)}_setValueOrValues(e,t){this._validateWrite();let n=this.getCoords(),r=this;const o=this._sheet,i=o._isDataColumn,a=(t?.orientation??exports.w.Orientation.Row)===exports.w.Orientation.Column,l=Array.isArray(e);if(t?.skipBoundsCheck&&l){const d=e;let g=Math.max(0,d.length-1),m=0;for(let S=0;S<d.length;S++)m=Math.max(m,d[S].length-1);const f=a?n.colStart:n.rowStart,_=a?n.rowStart:n.colStart,p={...n,colEnd:a?f+g:_+m,rowEnd:a?_+m:f+g};k.isEqualRanges(p,n)||(n=p,r=this._deriveRange(p,t))}const c={majorStart:i?n.colStart:n.rowStart,majorEnd:i?n.colEnd:n.rowEnd,minorStart:i?n.rowStart:n.colStart,minorEnd:i?n.rowEnd:n.colEnd},h=a!==i;let u=null;return u=l?Ri(Array.isArray(e)?e:[[e]],h,c):ni(e,c,i),o._updateTuples(u,{description:t?.description??`Set ${k.isSingleCell(n)?"Value":"Values"} ${mn(n,o._entireCoords)}`,...t}),r}getValues(e){this._validateMaxSize(e?.maxSize);const t=this.getCoords(),n=this._sheet;return Ka(n._cellIterator.bind(this._sheet),t,!1,e)}getValue(e){const t=this.getCoords();return this._sheet._getScalar(t.rowStart,t.colStart,e?.asJSDate)}calculate(e){return this._sheet._calculate([this.getCoords()],{full:e}),this}getCells(e){this._validateMaxSize(e?.maxSize);const t=this.getCoords(),n=this._sheet;return Ka(n._cellIterator.bind(this._sheet),t,!0,e)}getCell(){const e=this.getCoords(),t=this._sheet,n=Ka(t._cellIterator.bind(this._sheet),{colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colStart,rowEnd:e.rowStart},!0,null);return n.length===0?t._emptyCell:n[0][0]}async select(e){const t=this._sheet,n=await t._autoSelect(e??!0,Be([this.getCoords()]));return this._createRange(n[0])}find(e,t){return this._sheet._find([this.getCoords()],e,t)}getFixed(e){return this._createRange(sf(this.getCoords(),e))}getSurrounding(e){const t=this._sheet;return this._createRange(t._surroundingRegion(this.getCoords(),e))}getExtended(e,t){let n=null;const r=this.getCoords();switch(e){case exports.w.Direction.Up:n={colIndex:r.colStart,rowIndex:r.rowStart};break;case exports.w.Direction.Down:n={colIndex:r.colStart,rowIndex:r.rowEnd};break;case exports.w.Direction.Left:n={colIndex:r.colStart,rowIndex:r.rowStart};break;case exports.w.Direction.Right:n={colIndex:r.colEnd,rowIndex:r.rowStart}}const o=this._sheet,i=t?o._cellToCoords(t):n;if(!k.isCellWithinRange(i,r))throw new Error("Invalid cell.");let a=o._extendRange(e,i);return a=k.unionRanges(r,a),this._createRange(a)}getEntireRows(e,t){const n=this._sheet;return this._createRange(Bi([this.getCoords()],n._entireCoords,exports.w.Orientation.Column,e)[0],t)}getEntireColumns(e,t){const n=this._sheet;return this._createRange(Bi([this.getCoords()],n._entireCoords,exports.w.Orientation.Row,e)[0],t)}getRowHeaders(e){const t=this.getCoords();return this._sheet._rowHeaders.getRange(t,e)}getColumnHeaders(e){const t=this.getCoords();return this._sheet._colHeaders.getRange(t,e)}getDifferences(e,t){return this._deriveRanges(t,n=>{const r=this._sheet,o=r._rangeToCoords(e),i=jl(n,o,exports.w.Orientation.Row);return r._getVisible(i,t)})}getIntersect(e,t){return this._deriveRange(e,t,(n,r)=>k.intersectRanges(n,r))}getUnion(e,t){return this._deriveRange(e,t,(n,r)=>k.unionRanges(n,r))}getResizeTo(e,t,n){if(t=t??0,(e=e??0)<0||t<0)throw new Error("Invalid range. The Range must be at a size of at least 1x1'.");const r=this.getCoords();return this._deriveRange({colStart:r.colStart,rowStart:r.rowStart,colEnd:t+r.colStart-1,rowEnd:e+r.rowStart-1},n)}getResizeBy(e,t,n){e=e??0,t=t??0;const r=this.getCoords();return this._deriveRange({colStart:r.colStart,rowStart:r.rowStart,colEnd:r.colEnd+t,rowEnd:r.rowEnd+e},n)}getOffsetTo(e,t,n){const r=this.getCoords(),o=t,i=e,a={colStart:o,rowStart:i,colEnd:r.colEnd-r.colStart+o,rowEnd:r.rowEnd-r.rowStart+i};return this._deriveRange(a,n)}getOffsetBy(e,t,n){const r=this.getCoords(),o=r.colStart+e,i=r.rowStart+t,a={colStart:o,rowStart:i,colEnd:r.colEnd-r.colStart+o,rowEnd:r.rowEnd-r.rowStart+i};return this._deriveRange(a,n)}getUsedRange(e){const t=this._sheet._getUsedCoords(e);if(!t)return null;const n=k.intersectRanges(t,this.getCoords());return n?this._deriveRange(n,e):null}isEmpty(){const e=this._sheet._getUsedCoords();return e?!k.intersectRanges(e,this.getCoords()):!0}getColumnStart(){return this.getCoords().colStart}getRowStart(){return this.getCoords().rowStart}getColumnEnd(){return this.getCoords().colEnd}getRowEnd(){return this.getCoords().rowEnd}getColumnCount(){const e=this.getCoords();return e.colEnd-e.colStart+1}getRowCount(){const e=this.getCoords();return e.rowEnd-e.rowStart+1}getVisible(e){return this._deriveRanges(e,t=>this._sheet._getVisible([t],e))}isContentful(e){return this._sheet._isContentful([this.getCoords()],e,this._options?.excludeHidden??!1)}getCounts(e){return this._sheet._contentCounts([this.getCoords()],e,this._options?.excludeHidden??!1)}getCount(e){return this._sheet._getCount([this.getCoords()],e,this._options?.excludeHidden??!1)}isEntireRows(){const e=this._sheet;return qo([this.getCoords()],e._entireCoords,!0)}isEntireColumns(){const e=this._sheet;return Jo([this.getCoords()],e._entireCoords,!0)}isEntireRange(){const e=this.getCoords(),t=this._sheet;return Jo([e],t._entireCoords,!0)&&qo([e],t._entireCoords,!0)}getWidth(){const e=this._coords;return e.colEnd-e.colStart+1}getHeight(){const e=this._coords;return e.rowEnd-e.rowStart+1}get size(){const e=this._coords;return e.colEnd-e.colStart+1*(e.rowEnd-e.rowStart+1)}getBounds(){return this._sheet._getBoundsAtCoords(this.getCoords())}isInvalid(){return!1}getDefaultShiftOrientation(){return this._sheet._getDefaultShiftOrientation(this.getCoords())}getDefaultSortCriteria(e,t){return this._sheet._getDefaultSortCriteria(this.getCoords(),e,t)}getMerges(){return this._sheet._getMerges([this.getCoords()],this._options?.excludeHidden??!1)}getSnapshot(e){return this._sheet._getSnapshot([this.getCoords()],e)}isReadOnly(){return this._readOnly!==null}addListener2(e,t){return this._sheet._addRangesListeners2([this.getCoords()],e,t,!1)}addListener(e,t){return this._sheet._addRangesListeners([this.getCoords()],e,t)}getSource(){return this._sheet}autoFill(e,t){this._validateWrite();const n=this._sheet,r=n._rangeToCoords(e,()=>[],!0);return n._autoFill(this.getCoords(),r,t)?this._createRange(r):this}autoFit(e){return this._validateWrite(),this._sheet._autoFit([this.getCoords()],e),this}clear(e,t){return this._validateWrite(),this._sheet._clear([this.getCoords()],e,t),this}setHyperlink(e,t){return this._validateWrite(),this._sheet._setHyperlinks([this.getCoords()],e,t),this}setComments(e,t){return this._validateWrite(),this._sheet._setComments([this.getCoords()],e,t),this}setFormula(e,t){return this._validateWrite(),this._sheet._setFormula([this.getCoords()],e,t),this}updateStyle(e,t){return this._validateWrite(),this._sheet._updateStyles([this.getCoords()],e,t),this}getStyleUpdater(){return this._sheet._getStyleUpdater([this.getCoords()])}merge(e){return this._validateWrite(),this._sheet._merge([this.getCoords()],e),this}unmerge(e){return this._validateWrite(),this._sheet._unmerge([this.getCoords()],e),this}insert(e,t){return this._validateWrite(),this._sheet._insertCells([this.getCoords()],e,t),this}async insertFrom(e,t){this._validateWrite();const n=this._sheet,r=await n._insertFrom([this.getCoords()],e,t);return r?this._createRange(r):null}async copyFrom(e,t){this._validateWrite();const n=this._sheet,r=await n._copyFrom(this.getCoords(),e,t);return r?this._createRange(r):null}delete(e,t){return this._validateWrite(),this._sheet._deleteCells([this.getCoords()],e,t),this}sort(e){this._validateWrite();const t=this.getCoords(),n=this._sheet._sort(t,e);return k.isEqualRanges(n,t)?this:this._createRange(n)}doBatch(e,t){return this._sheet.doBatch(n=>e(n),typeof t=="string"?t:{description:"Range Update",...t})}startIncrementalUpdates(e){return this._sheet._createIncrementalUpdater(e,this)}getA1(){const e=this._sheet;return mn(this.getCoords(),e._entireCoords)}get[Symbol.toStringTag](){return"[SheetRange]"}toString(){const e=this._sheet;return mn(this.getCoords(),e._entireCoords)}get isICellRange(){return!0}}const Ry=Math.pow(2,14),Ay=Math.pow(2,20),Jd=s=>`${s}`,Kd=s=>Dt(s),Xd=s=>`${s+1}`;let My=0;const Yd=()=>[];let Ty=0;class Gr{constructor(e){this._lastTransactionUUID=null,this._emitter=null,this._initializing=!0,this._emitterMovables=null,this._rangesListenerSorted=null,this._lastCellDecoded={address:null,coords:null},this._lastCellSelected={coords:null,cell:null},this._lastCellRead={coords:null,cell:null},this._lastValueRead={range:null,isDateOrTime:null},this._lastGetRangeRead={},this._lastUsedCoordsRead={coords:null,range:null},this._lastActiveRead={selection:null,range:null,ranges:null},this._lastRangeRead={address:null,range:null,ranges:null},this._isDataColumn=!0,this._isDate1904=!1,this._colHeaders=null,this._colHeadersShiftCallback=null,this._colHeadersListener=null,this._colHeadersRemoveListener=null,this._rowHeaders=null,this._rowHeadersShiftCallback=null,this._rowHeadersListener=null,this._rowHeadersRemoveListener=null,this._closed=!1;const t=Object.freeze({...e});oc._validate(!0),this._transactions=t.transactions??new Bt,this._ownTransactions=!t.transactions;const n=this._beginCommit({description:"New Sheet"}),r=this;try{this._entireCoords=Object.freeze({colStart:0,rowStart:0,colEnd:(t.maxColumns??Ry)-1,rowEnd:(t.maxRows??Ay)-1}),this._strings=t.strings??new Yi,this._ownStrings=!t.strings;const o=t.styles??new Jr;this._styles=o,this._ownStyles=!t.styles,this._names=t.names??new mf({addressToRanges:a=>r.getRanges(a),getCurrentScope:()=>r.getName(),isReadOnly:()=>r._options.readonly??!1,transactions:r._transactions}),this._ownNames=!t.names,this._namesRemoveListener=this._names.addListeners({onCollectionChange:a=>{r._calculateFull()}},{transactional:!1}),this._calculation=t.calculation??new xc({getNamed:(a,l)=>{Qd.address=a,Qd.scope=l;const c=this._names.search({address:a,scope:l});return c&&c.length!==0?c[0].getRanges().getCoords():null},getSheetIndex:a=>a===void 0||a===r.getName()?1:0,getSheetCount:()=>1,isDate1904:()=>r.isDate1904(),strings:r._strings,transactions:r._transactions}),this._ownsCalculation=!t.calculation,this._normalStyleRanged=o.getNamed(exports.IStyle.BuiltInName.Normal).getRanged(),this._resources=t.resources??new bc,this._ownResources=!t.resources;const i=async()=>{this._ownsCalculation&&await this._calculation.start(),this._starting=null};this._starting=i(),t.container?.setNameChangeCallback&&t.container.setNameChangeCallback(()=>{r._emitter.notify("onNameChange");const a=this._getState().rangesListenerMap,l=new Map;a.forEach((h,u)=>{l.set(u,{beforeState:h,afterState:h})});const c=this._beginCommit({description:"Set Name"});c.updateState(r,{}),c.commit({viewAfter:{ranges:[r._entireCoords],listeners:l},forceAmend:!0}),r._calculateFull()}),t.container?.setVisibilityCallback&&t.container.setVisibilityCallback(()=>{r._emitter.notify("onVisibilityChange")}),t.container?.setIndexCallback&&t.container.setIndexCallback(()=>{r._calculateFull()}),this._movables=new cy(this._addMovable.bind(this),this._searchMovables.bind(this),()=>{const a=r._getState();return a?a.movableMapModel?.size??0:0},this._updateSelectedMovables.bind(this),(a,l)=>this._emitterMovables.addListeners(a,l),this._addImage.bind(this)),this._emitterMovables=new st(this._movables,this._transactions),this._tables=new fy(this._addTable.bind(this),(a,l,c)=>{const h=a?this._rangeToCoords(a):this._entireCoords;return r._getRangedEntries("tableSpatial",[h],{excludeHidden:l,fullyContained:c,onEntry:u=>u.model})},a=>{const l=r._getState();return l?l.tableMapName.get(a.toLocaleLowerCase()):null}),this._conditionals=new wy(this._addConditional.bind(this),(a,l,c)=>{const h=a?this._rangeToCoords(a):this._entireCoords,u=new Set;return r._getRangedEntries("conditionalSpatial",[h],{excludeHidden:l,fullyContained:c,onEntry:d=>{u.add(d.getModel())}}),Array.from(u)}),this._isDate1904=t.date1904??!1,this._options=t,this._emitter=new st(this,this._transactions),this._entireRange=this.getRange(this._entireCoords),this._initState(),t?.container?.beforeFromJSON?.(this),t.json&&this._fromJSON(t.json),n.commit({viewAfter:{initial:!0,skipProtectionCheck:!0}})}catch(o){throw n.rollback(),o}this._initializing=!1}_createRange(e,t,n=null){if(!e)return fn(this,this._entireCoords);if(this._validateCoords(e),this._closed)return fn(null,this._entireCoords,e);n===null&&this._options.readonly&&(n="Readonly sheet");let r=null;return(t||n)&&(r={getOptions:t,readOnly:n}),new is((o=>{if(!o)return null;const i={colStart:o.colIndex??o.colStart??0,rowStart:o.rowIndex??o.rowStart??0,colEnd:o.colIndex??o.colEnd??0,rowEnd:o.rowIndex??o.rowEnd??0};return(o.$colStart||o.$colIndex)&&(i.$colStart=!0),(o.$colEnd||o.$colIndex)&&(i.$colEnd=!0),(o.$rowStart||o.$rowIndex)&&(i.$rowStart=!0),(o.$rowEnd||o.$rowIndex)&&(i.$rowEnd=!0),i})(e),this,r)}_createRanges(e,t,n=null){let r=null;return n===null&&this._options.readonly&&(n="Readonly sheet"),(t||n)&&(r={getOptions:t,readOnly:n}),new ss(e,this,r)}getRange(e,t){let n=!t&&e&&(e.rowStart!==void 0||typeof e=="string");if(n){if(typeof e=="string"){if(this._lastRangeRead.address===e)return this._lastRangeRead.range}else if(e.rowStart!==void 0&&Oo(e,this._lastRangeRead.address))return this._lastRangeRead.range}const r=this._rangesToCoords(e);if(r.length>1)throw new Error(jm);const o=this._createRange(r[0],t);return n&&(this._lastRangeRead.address={...e},this._lastRangeRead.range=o),o}getRanges(e,t){if(!e)throw new Error(Dr);const n=this._rangesToCoords(e);if(n.length===0)throw this._createRangeError(e);return this._createRanges(n,t)}getSelectedRange(e){const t=this.getSelection().getCoords();if(!e&&this._lastActiveRead.selection===t&&this._lastActiveRead.range)return this._lastActiveRead.range;const n=Rr(t),r=this.getRange(n[0]);return e||(this._lastActiveRead.selection=t,this._lastActiveRead.range=r,this._lastActiveRead.ranges=this.getRanges(n)),r}getSelectedRanges(e){const t=this.getSelection().getCoords();if(!e&&this._lastActiveRead.selection===t&&this._lastActiveRead.ranges)return this._lastActiveRead.ranges;const n=Rr(t),r=this.getRanges(n,e);return e||(this._lastActiveRead.selection=t,this._lastActiveRead.ranges=r,this._lastActiveRead.range=this.getRange(n[0])),r}getEntireRange(e){return e?this.getRange(this._entireCoords,e):this._entireRange}getUsedRange(e){const t=this._getUsedCoords(),n=t?this.getRange(t,e):null;return e||(this._lastUsedCoordsRead.coords=t,this._lastUsedCoordsRead.range=n),n}_cellToCoords(e){if(this._lastCellDecoded.address===e)return this._lastCellDecoded.coords;const t=this._rangeToCoords(e);if(!t||!k.isSingleCell(t))throw new Error("Only a single cell is allowed.");const n={colIndex:t.colStart,rowIndex:t.rowStart};return this._lastCellDecoded.address=e,this._lastCellDecoded.coords=n,n}_validateCoords(e,t=Ti){if(!k.isRangeWithinRange(e,this._entireCoords))throw new Ne(t);const n=e.colStart,r=e.rowStart,o=e.colEnd,i=e.rowEnd;if(i<r||o<n)throw new Error(Hm);if(!(Number.isInteger(n)&&Number.isFinite(n)&&Number.isInteger(r)&&Number.isFinite(r)&&Number.isInteger(o)&&Number.isFinite(o)&&Number.isInteger(i)&&Number.isFinite(i)))throw new Error("Invalid range. All points must be valid integers.")}_createRangeError(e){return e?new Error(Dr):new Error($o(e))}_protectionCheck(e=null,t=null,n=null){if(e&&this._closed)return;if(!this._initializing&&this._options.readonly)throw new Error(((a="update")=>`Unable to ${a}, this sheet is readonly.`)(n));t&&!Array.isArray(t)&&(t=[t]);const r=e(t),o=this.getProtection();if(o?.getProperties()){if(r.length===0)throw new Error(bs);if(r){const a=r.length;for(let l=0;l<a;l++)if(o[r[l]]!==!0)throw new Error(Z_())}}}_rangesToCoords(e,t=null,n=!0,r=!1){if(t&&this._closed||e==null)return N.EmptyArray;const o=this,i=wc(e,this._entireCoords,r?Mt:os,l=>{if(n&&typeof l=="string"){const c=o.getNames()?.getByName(l);if(c)return c.getRanges().getCoords();const h=this._options.resolveRange?.(l);if(h&&h.getSource()===o)return console.warn(ju),[h.getCoords()];throw new Error(`Invalid sheet reference '${l}'.`)}}),a=i.length;for(let l=0;l<a;l++){const c=i[l];if(c){if(r){const h=c.sheetName;if(h&&h!==this.getName())throw new Error(ju)}this._validateCoords(c)}}if(!t)return i;if(i.length===0)throw this._createRangeError(e);return this._protectionCheck(t,i),i}_rangeToCoords(e,t=null,n=!0){if(!e)throw new Error(Dr);const r=t?i=>t(i):void 0,o=this._rangesToCoords(e,r,n);if(o.length===0)throw new Error($o(e));return o[0]}_collectRanges(e,t=[],n=!0,r=this._getState(),o=!1){if(!n||Object.keys(n).length===0)return;const i=l=>n===!0||n[l]!==void 0,a=(l,c,h)=>{if(n!==!0&&n[l]===void 0)return;const u=c.search(e,!1),d=u.length;if(d===0)return;const g=n[l];for(let m=0;m<d;m++){const f=u[m];if(g&&!k.isRangeWithinRange(e,f))continue;const _=k.intersectRanges(e,f);let p=f.value;p===void 0&&(p=!0),t.push({..._,value:{[h]:p}})}};if(i(X.Type.Merge)&&r.mergeSpatial){const l=r.mergeSpatial.search(e),c=l.length;for(let h=0;h<c;h++){const u=l[h],d=o?u:k.intersectRanges(e,u);t.push({...d,value:{merge:u.value}})}}if(a(X.Type.Unlock,r.unlockSpatial,"unlock"),a(X.Type.Contentful,r.contentfulSpatial,"contentful"),a(X.Type.Continuous,r.continuousFillSpatial,"continuous"),a(X.Type.Hyperlink,r.hyperlinkSpatial,"hyperlink"),a(X.Type.Comments,r.commentsSpatial,"comments"),a(X.Type.Style,r.directStyleSpatial,"directStyle"),a(X.Type.Formula,r.formulaSpatial,"formula"),a(X.Type.Pending,r.pendingSpatial,"pending"),a(X.Type.CalcError,r.calcErrorsSpatial,"calcError"),a(X.Type.Spill,r.spillSpatial,"spills"),i(X.Type.Conditional)&&r.conditionalSpatial){const l=r.conditionalSpatial.search(e),c=n[X.Type.Conditional],h=l.length;for(let u=0;u<h;u++){const d=l[u],g=k.intersectRanges(e,d);c&&!g||t.push({...g,value:{conditionals:[d.value]}})}}if(i(X.Type.Table)&&r.tableSpatial){const l=r.tableSpatial.search(e),c=n[X.Type.Table],h=l.length;for(let u=0;u<h;u++){const d=l[u];if(c&&!k.isRangeWithinRange(e,d))continue;const g=k.intersectRanges(e,d);t.push({...g,value:{table:d.value.model}})}}}_cellIterator(e){const t=this._cellOptions,n=this._strings,r=this._cellStateIterator(e);return{next(o){const i=r.next(o);if(i.done)return Re;const a=i.value,l=new Xa(n,e,t),c=l.context;return{done:!1,value:{value:l.setState(a),context:c}}},[Symbol.iterator](){return this}}}_rangeStateIterator(e){const t=this._getState();if(!t||!e||!e.includeRangeTypes)return qe;const n=e?.bounds??this._getUsedCoords()??this._entireCoords;let r=null;e.includeRangeTypes===!0?r=X_:N.isObject(e.includeRangeTypes)&&(r=e.includeRangeTypes);const o=e?.excludeHidden,i=o===!0||o===exports.w.Orientation.Row,a=o===!0||o===exports.w.Orientation.Column,l=[],c=this,h={includeHidden:!a},u={min:n.colStart,max:n.colEnd},d={includeHidden:!i},g={min:n.rowStart,max:n.rowEnd};this._rowHeaders.getRange(g).forEachVisibleSpan((C,y)=>{this._colHeaders.getRange(u).forEachVisibleSpan((b,w)=>{c._collectRanges({rowStart:C,rowEnd:y,colStart:b,colEnd:w},l,r,t)},h)},d);const m=new Ii.IteratorInstance(l,e),f=e?.reverse??!1,_=e?.byCell;let p;return{next:C=>{if(p=m.next(C),p.done)return Re;const y=p.value,b=y.range,w={colIndex:b.colStart,rowIndex:b.rowStart},E={colIndex:b.colEnd,rowIndex:b.rowEnd};let I=null;_&&(I={...y.cell});const x=(v=>{if(!v)return null;let R=null;const A=v.length;for(let M=0;M<A;M++){const T=v[M].value;if(!T)continue;R||(R={...R});const F=Object.keys(T),L=F.length;for(let D=0;D<L;D++){const P=F[D],B=R[P];if(B)if(Array.isArray(B)){const z=T[P];if(Array.isArray(z)){const O=z.length;for(let W=0;W<O;W++)B.push(z[W])}else B.push(z)}else R[P]=[B,T[P]];else R[P]=T[P]}}return R})(y.overlaps);return{done:!1,value:{start:f?E:w,end:f?w:E,cell:I,intersection:x}}}}}_cellStateIterator(e){const t=this._getState();if(!t)return qe;const n=e?.bounds??this._entireCoords,r=e?.orientation??exports.w.Orientation.Row,o=e?.reverse??!1,i=e?.includeEmpty,a={bounds:n,orientation:r,reverse:o};let l;i&&(l={bounds:n,orientation:r,reverse:o});const c=e?.excludeHidden;if(c===!0||c===exports.w.Orientation.Row){const A=Ja(this._rowHeaders);a.processRowSkip=so(A),i&&(l.processRowSkip=so(A))}if(c===!0||c===exports.w.Orientation.Column){const A=Ja(this._colHeaders);a.processColumnSkip=so(A),i&&(l.processRowSkip=so(A))}const h=i||!e?.ignoreEmptyIntersections;let u=e.includeRangeTypes;u===!0&&(u=Vm);const d=this._getState().contentfulSpatial,g=u?this._rangeStateIterator({bounds:n,orientation:r,reverse:o,includeRangeTypes:u,excludeHidden:e.excludeHidden,byCell:!0}):qe,m=e?.includeMergeOverflow??!1,f=t?.cellValuesGrid??null;let _=f?f.entries(a):qe,p=_.next(),S=null,C=null,y=null;p.done||(S=p.value[0],C=p.value[1]);let b=g.next(),w=null;const E=r!==exports.w.Orientation.Row;let I;const x=k.createCellComparator(r,o);let v;if(!b.done){const A=b.value;v=A.start,w=A.intersection}I=A=>{let M=null,T=null,F=null,L=!1,D=!1;if(S&&v){const j=x(S,v);j<0?(M=S,T=C,L=!0):j>0?(M=v,F=w,D=!0):(M=S,T=C,F=w,L=!0,D=!0)}else if(S)M=S,T=C,L=!0;else{if(!v||!h)return Re;M=v,F=w,D=!0}if(L&&(p=_.next(),p.done?S=null:(S=p.value[0],C=p.value[1])),D){const j=h?void 0:S;if(b=g.next(j),b.done)v=null,w=null;else{const H=b.value;v=H.cell,w=H.intersection}}let P=!1;const B=M.rowIndex,z=M.colIndex;E||(P=B===y?.rowIndex);let O=!1;E||(O=B===S?.rowIndex);let W=null;if(P)W=y;else if(m&&!y){Jt.rowStart=B,Jt.rowEnd=B,Jt.colStart=z-5,Jt.colEnd=z-1;const j=d.search(Jt,!1);if(j.length>0){j.sort(k.columnFirstRangeComparator);const H=j[j.length-1];W={colIndex:H.colStart,rowIndex:H.rowStart}}}let V=null;if(O)V=S;else if(m&&!S){Jt.colStart=z+1,Jt.rowStart=B,Jt.colEnd=z+5,Jt.rowEnd=B;const j=d.search(Jt,!1);if(j.length>0){j.sort(k.columnFirstRangeComparator);const H=j[0];V={colIndex:H.colStart,rowIndex:H.rowStart}}}return L&&(y=M),{done:!1,value:[M,T,F,W,V]}};let R={next:I,return:A=>null,throw:A=>null};return i&&(R=new vm(R,a)),R}_indexMerges(e,t=null){if(!(e&&e.length!==0||t&&t.length!==0))return;const n=this._getState();if(!n)return;const r=this._beginCommit({description:"indexMerges"}),o=n.mergeSpatial.clone();if(t){const i=t.length;for(let a=0;a<i;a++)o.remove(t[a])}if(e){const i=Q_,a=u=>this._getState().cellValuesGrid.getValueAt(u.rowStart,u.colStart),l=u=>{const d=this._getState();if(!d)return;const g=[];return this._collectRanges(u,g,i,d),{...g?.[0]??null}},c=[],h=e.length;for(let u=0;u<h;u++){const d=e[u];c.push({...d,value:new Vd(d,a,l)})}o.load(c)}this._updateState({mergeSpatial:o}),r.commit()}_updateStyles(e,t,n,r=!1){const o=n?.description??"Update Style";this._protectionCheck(()=>["formatCells"],e,o);const i=this._beginCommit({description:o}),a=co(e);try{const l=this._getState();if(!l)return N.EmptyArray;const c=l.directStyleSpatial,h=i.getId(),u=c.clone(h);let d=l.continuousFillSpatial;const g=!d.isEmpty();let m=null;const f=this._styles,_=e.length;for(let p=0;p<_;p++){const S=(I,x)=>{let v=null;const R=Ji(0,x,()=>{if(v)return v;const A=I.getCoords();return v=Vr(f,I,A),v});return I.cloneWithUpdate(R)},C=e[p],y=C.value,b=y!==void 0?y:t,w=S(new Je(f,C),b),E=(I,x)=>{if(r&&I.value&&I.value.getProperties()?.numberFormat)return I;const v=k.sanitizeRange(I);let R=null,A=I.value;typeof b=="function"&&A?R=S(A,b):(A||(A=new Je(f,v)),R=A.cloneWithUpdate(x.value._p??null)),R.isEmpty()&&(R=null);let M=!1;if(R){const T=R._p?.alignment?.horizontal;!T||T!==exports.ITextFrame.HorizontalAlignment.CenterContinuous&&T!==exports.ITextFrame.HorizontalAlignment.Fill||(M=!0)}return(M||g)&&(m||(m=[]),m.push({...I,value:M?R:null})),{...x,value:R}};u.insertNonOverlapping({...C,value:w},{onIntersect:E})}if(m){d=d.clone();const p=m.length;for(let S=0;S<p;S++){const C=m[S];d.insertNonOverlapping(C)}}if(this._lastUsedCoordsRead.coords=null,this._updateState({directStyleSpatial:u,continuousFillSpatial:d}),n?.autoFit){const p=typeof n.autoFit=="boolean"?ml:n.autoFit;this._autoFit(e,p)}this._emitter.notify("onStyleChange"),r?i.commit({forceAmend:!0}):this._commitAndAutoSelect(i,a,n?.autoSelect,{viewAfter:{ranges:e}})}catch(l){throw i.rollback(),l}}_createIncrementalUpdater(e,t=null,n){const r=e?.orientation??exports.w.Orientation.Row,o=e?.allowUnorderedWrites??!1,i=r===exports.w.Orientation.Column,a=this._isDataColumn,l=i!==a,c=this;let h,u,d,g=l?new exports.Tuple.TransposedBuilder:new exports.Tuple.Builder,m=null;if(t){const C=t.getCoords(),y=C.colStart,b=C.rowStart,w=C.colEnd,E=C.rowEnd;m=(I,x)=>{if(I<b||I>E||x<y||x>w)throw new Ne}}i?(u=(C,y,b)=>(m?.(C,y),g.addValue(y,C,b),h),d=(C,y,b)=>(m?.(C,y+(b?.length??0)),g.addValues(y,C,b),h)):(u=(C,y,b)=>(m?.(C,y),g.addValue(C,y,b),h),d=(C,y,b)=>(m?.(C+(b?.length??0),y),g.addValues(C,y,b),h));const f=C=>{const y=g.build();return y&&c._updateTuples(y,C,null,n),t},_=o!==!1?k.createCellComparator(e?.orientation):null,p=N.isObject(o)?o:void 0;let S=null;return h=Object.freeze({push:(C,y)=>{const b=c._cellToCoords(C);return _&&(S&&_(b,S)<=0&&(f(p),g=l?new exports.Tuple.TransposedBuilder:new exports.Tuple.Builder),S=b),u(i?b.colIndex:b.rowIndex,i?b.rowIndex:b.colIndex,y)},pushAt:u,pushMultipleAt:d,apply:f}),h}_updateTuples(e,t,n=void 0,r=null){if(!e)return;const o=r?.isCell??!1,i=r?.isHyperlink??!1,a=e.tuples,l=e.bounds,c=this._beginCommit({description:t?.description??"Update Cells"});let h=null;const u=this._isDataColumn,d=u?exports.w.Orientation.Column:exports.w.Orientation.Row,g=this.getProtection().isLocked(),m=this.getProtection().isFormatCellsAllowed(),f=this._strings,_=l.majorStart,p=l.majorEnd,S=l.minorStart,C=l.minorEnd,y={colStart:u?_:S,rowStart:u?S:_,colEnd:u?p:C,rowEnd:u?C:p},b=this;(n=n??((re,K)=>{b._validateCoords(re,K??Ti)}))(y);const w={[X.Type.Style]:!1,[X.Type.Table]:!1};let E=!1;g&&this._hasRangedEntries("unlockSpatial",y)&&(w[X.Type.Unlock]=!1,E=!0),this._hasRangedEntries("mergeSpatial",y)&&(w[X.Type.Merge]=!1,E=!0);const I=this._rangeStateIterator({bounds:y,orientation:d,includeRangeTypes:w,reuseIterator:{done:!1,value:null}});let x=I.next(),v=-1,R=-1,A=-1,M=-1,T=null;if(!x.done){const re=x.value,K=re.start,ee=re.end;v=u?K.colIndex:K.rowIndex,R=u?ee.colIndex:ee.rowIndex,A=u?K.rowIndex:K.colIndex,M=u?ee.rowIndex:ee.colIndex,T=re.intersection}let F=(re,K)=>{do{if(!T||re<=A&&K<A)return null;if(re>=v&&K>=A&&re<=R&&K<=M)return T;if(x=I.next(),x.done)T=null,F=null,E=!1;else{const ee=x.value;v=u?ee.start.colIndex:ee.start.rowIndex,R=u?ee.end.colIndex:ee.end.rowIndex,A=u?ee.start.rowIndex:ee.start.colIndex,M=u?ee.end.rowIndex:ee.end.colIndex,T=ee.intersection}}while(T);return T};const L=c.getState(this),D=L.cellValuesGrid.clone(),P=L.calcGraph.clone(),B=L.formulaSpatial.clone(),z=L.spillSpatial.clone(),O=L.pendingSpatial.clone(),W=L.calcErrorsSpatial.clone(),V=L.contentfulSpatial.clone(),j=Ln(u),H=Ln(u,(re,K)=>{if(re===K)return K}),G=Ln(u,(re,K)=>{if(re===K)return K}),$=Ln(u,(re,K)=>{if(re===K)return K}),te=[];let J=null,ne=null;if(t?.textParser!==!1){const re=t&&t.textParser!==!0?t.textParser:{};ne={ignoreQuotePrefix:!1,date1904:this._isDate1904,dateNF:!1,parse:null,...re},J=new Xa(f,null,this._cellOptions)}const Z=[],q=this._cellOptions,oe=new Map,ce=gd,Y=(re,K,ee)=>{const le=F?.(K,ee);if(le?.merge){const we=le.merge.getCoords(),fe=u?we.colStart:we.rowStart,ve=u?we.rowStart:we.colStart;if(fe!==K||ve!==ee)return}if(o&&re&&re.isICell){const we=re;if(we.isTopLeft()){const fe=we.getSpans();te.push({colStart:u?K:ee,rowStart:u?ee:K,colEnd:(u?K:ee)+fe.width-1,rowEnd:(u?ee:K)+fe.height-1})}}let ge=ql(re,q,ne,oe);if(ge===void 0)return;const de=ge.value;if(ge.stringToParse){Co[0].colIndex=u?K:ee,Co[0].rowIndex=u?ee:K,Co[1]=de,Co[2]=le,J.setState(Co);const we=ne?.parse(ge.stringToParse,J.context),fe=ql(we,q,ne,oe,!0);if(J.clear(),fe===null)return fe;fe!==void 0&&(ge={...fe})}if(g){if(g&&(re===null||ge.value!==void 0))throw new Error(bs);if(!m&&ge.style!==void 0)throw new Error(bs)}if(!i){const we=ge.style;we===void 0||we===null&&!o||H.append(K,ee,we);const fe=ge.hyperlink;fe===void 0||fe===null&&!o||G.append(K,ee,fe)}const he=ge.formula;return he===void 0||he===null&&!o||$.append(K,ee,he),de};let se=-1,Q=-1;try{const re=a.length;for(let Te=0;Te<re;Te++){const ye=a[Te],ue=ye[0];if(se>=ue)throw new exports.Tuple.OutOfOrderError(`Duplicate or out of order major indices: {${ue}}.`);if(se=ue,Q=Number.MIN_SAFE_INTEGER,ue<_||ue>p)throw new Ne("Provided major bounds is invalid");const Ee=ye[1],xe=[],Ie=Ee.length;for(let pe=0;pe<Ie;pe++){const Ce=Ee[pe],Ae=Ce[1],Qe=Ae.length;let Ze=Ce[0],ze=Ze;if(Q>ze)throw new exports.Tuple.OutOfOrderError(`Duplicate or out of order minor indices: {${ze}}.`);if(ze<S||ze+Qe>C+1)throw new Ne("Provided minor bounds is invalid");let ut=[];for(let Vt=0;Vt<Qe;Vt++){const en=Ae[Vt];let mt=null;if(E||typeof en!="number"?(E||en!==null||o)&&(mt=Y(en,ue,ze)):mt=en,mt==null){if(mt===null&&j.append(ue,ze),ut.length>0){const Gt=ce(ut,f);xe.push([Ze,Gt]),ut=[]}Ze=ze+1}else ut.push(mt);ze++}if(Q=ze,ut.length>0){const Vt=ce(ut,f);xe.push([Ze,Vt]),ut=null}}xe.length>0&&Z.push([ue,xe])}const K=j.done(),ee=K.length;for(let Te=0;Te<ee;Te++){const ye=K[Te];D.delete(K[Te]),V.insertNonOverlapping({...ye,value:null});const ue=P.delete(ye);this._updateFormulaSpatial(B,null,ue)}let le;Z.length>0&&(D.setValues(Z),le={tuples:Z,bounds:l});let ge,de=$.done();if(de.length>1&&(de=gn(de,exports.w.Orientation.Column,1)),le||de.length>0){const Te=P.setInputs(le,de);ge=this._updateFormulaSpatial(B,Te.inserts,Te.removes,L.directStyleSpatial)}const he=md(Z,u),we=he.length;for(let Te=0;Te<we;Te++)V.insertNonOverlapping(he[Te]);const fe=H.done();fe.length>0&&this._updateStyles(fe),te.length>0&&this._merge(te);const ve=G.done();if(ve.length>0&&this._setHyperlinks(ve),this._updateState({cellValuesGrid:D,contentfulSpatial:V,calcGraph:P,formulaSpatial:B,spillSpatial:z,pendingSpatial:O,calcErrorsSpatial:W}),ge&&ge.length>0&&this._updateStyles(ge,void 0,{},!0),t?.autoFit){const Te=typeof t.autoFit=="boolean"?ml:t.autoFit;this._autoFit([y],Te)}h={ranges:[y]},this._addEvent("data",y),this._commitAndAutoSelect(c,h,t?.autoSelect,{viewAfter:{formulas:[y],ranges:[y]}})}catch(re){throw c.rollback(),re}}_sort(e,t){typeof t=="boolean"&&(t={reverse:t});const n=t?.description??"Sort "+(t?.reverse?"Descending":"Ascending");this._protectionCheck(()=>["sort"],e,n);let r=1,o=1,i=!1;const a=this._getMerges([e]);if(a.length>0){i=!0;let j=a[0];if(r=j.colEnd-j.colStart+1,o=j.rowEnd-j.rowStart+1,(e.colEnd-e.colStart+1)%r!=0||(e.rowEnd-e.rowStart+1)%o!=0)throw new Error(Wu);const H=a.length;for(let G=1;G<H;G++){const $=a[G];if($.colEnd-$.colStart+1!==r||$.rowEnd-$.rowStart+1!==o)throw new Error(Wu)}}const l=t?.orientation??exports.w.Orientation.Row,c=l===exports.w.Orientation.Row;let h=t?.offset??0,u=e;t?.hasHeader&&(u={...u},c?u.rowStart+=o:u.colStart+=r,h=Math.max(h-1,0));const d={offset:h,reverse:t?.reverse??exports.Sort.DefaultRangeOptions.reverse,collatorOptions:t?.collatorOptions??exports.Sort.DefaultRangeOptions.collatorOptions},g=c?u.colStart:u.rowStart,m=c?u.colEnd-u.colStart:u.rowEnd-u.rowStart,f=[];if(t?.fields){const j=t?.fields.length??0;for(let H=0;H<j;H++){let G=t.fields[H];typeof G=="number"&&(G={offset:G}),f.push(G)}}else f.push(d);const _=f.length;for(let j=0;j<_;j++){const H=f[j]={...d,...f[j]};if(H.offset<0||H.offset>m)throw new Ne("The sort offset is outside of the bounds of the sort.");H.offset+=g}const p=[];let S=null,C=null,y=null,b=Number.MIN_SAFE_INTEGER;f.sort((j,H)=>j.offset-H.offset);let w=null;const E=t?.includeHidden??!1;if(!E){const j=Ja(c?this._rowHeaders:this._colHeaders);w=so(j)}const I=this._cellIterator({bounds:u,orientation:l,excludeHidden:!E&&l,includeRangeTypes:{[X.Type.Style]:!1,[X.Type.Merge]:!1}}),x=c?o:r;let v=(c?u.rowStart:u.colStart)-x,R=I.next();for(;!R.done;){const j=R.value.context,H=j.getCell();if(i&&!H.isTopLeft()){R=I.next();continue}const G=j.getCoords(),$=c?G.rowIndex:G.colIndex,te=c?G.colIndex:G.rowIndex;if(v!==$){for(v+=x,w&&(v=w(v));v<$;)p.push(null),v+=x;C=[],y=[],S={minorIndex:$,values:C,sortValues:y},p.push(S),v=$,b=f[0].offset}for(;te>b;){const J=f[y.length];b=J?J.offset:Number.MAX_SAFE_INTEGER,te>b&&y.push(null)}te===b&&y.push(H),C.push(H),R=I.next()}if(!S||p.length===0)return;const A=new Map,M=new Map,T=t?.collators??exports.Sort.DefaultCollators,F=T.length;for(let j=0;j<F;j++)A.set(T[j].type,T[j].compare),M.set(T[j].type,j);let L=null,D=null,P=null;p.sort((j,H)=>{const G=f.length;for(let $=0;$<G;$++){const te=f[$],J=j?j.sortValues[$]:null,ne=H?H.sortValues[$]:null,Z=J?J.getValue():null,q=ne?ne.getValue():null,oe=Z===null,ce=q===null;if(Z===q)continue;if(oe&&ce)return 0;if(!oe&&ce)return-1;if(oe&&!ce)return 1;const Y=J.getType(),se=ne.getType();let Q=0;if(Y!==se){let re=M.get(Y);Q=M.get(se)-re}else{let re=D;if(L!==Y){re=A.get(Y),D=re,L=Y;let K=M.get(se);P={...T[K].defaultOptions,...te.collatorOptions}}Q=re(Z,q,P)}return te.reverse&&(Q*=-1),Q}return 0});const B=this._beginCommit({description:n});let z=[u];E||(z=this._getVisible(z,{orientations:c?exports.w.Orientations.Row:exports.w.Orientations.Column})),this._clear(z,void 0,void 0,!0);const O=this._createIncrementalUpdater({orientation:l});let W=c?u.rowStart:u.colStart;const V=p.length;for(let j=0;j<V;j++){const H=p[j];if(w&&(W=w(W)),H){const G=H.values,$=G.length;for(let te=0;te<$;te++){const J=G[te],ne=c?W:J.getCoords().rowIndex,Z=c?J.getCoords().colIndex:W;O.pushAt(ne,Z,J)}}W+=x}return O.apply(),B.commit(),u}_autoFill(e,t,n){const{direction:r,amount:o}=((f,_)=>{let p=exports.w.Direction.Down,S=0;const C={...f};if(_.colStart<f.colStart?(p=exports.w.Direction.Left,S=f.colStart-_.colStart,C.colStart=_.colStart):_.colEnd>f.colEnd?(p=exports.w.Direction.Right,S=_.colEnd-f.colEnd,C.colEnd=_.colEnd):_.rowStart<f.rowStart?(p=exports.w.Direction.Up,S=f.rowStart-_.rowStart,C.rowStart=_.rowStart):_.rowEnd>f.rowEnd&&(p=exports.w.Direction.Down,S=_.rowEnd-f.rowEnd,C.rowEnd=_.rowEnd),!k.isEqualRanges(C,_))throw new Error("Autofill destination must be the same as the range for 3 of the 4 edges.");return{direction:p,amount:S}})(e,t);if(o<=0)return!1;const i=r===exports.w.Direction.Up||r===exports.w.Direction.Down,a=this.getSelection().getCoords(),l=[],c=n?.previewOnly,h=n?.contentsOnly,u=n?.filler??exports.AutoFill.Types.Series,d={...n?.fillerOptions};let g=null,m=null;try{const f={...e};let _={...e};const p=[e],S=this._getMerges(p);if(S.length>0&&!k.isRangeWithinRange(k.unionRangesArrays(S),e))throw new Error(zu);const C={..._};let y=1;if(r===exports.w.Direction.Left)f.colStart=_.colStart=e.colStart-o,f.colEnd=e.colStart-1,y=S.length===0?y:e.colEnd+1-e.colStart,C.rowStart=C.rowEnd;else if(r===exports.w.Direction.Right)f.colEnd=_.colEnd=e.colEnd+o,f.colStart=e.colEnd+1,y=S.length===0?y:e.colEnd+1-e.colStart,C.rowStart=C.rowEnd;else if(r===exports.w.Direction.Up)f.rowStart=_.rowStart=e.rowStart-o,f.rowEnd=e.rowStart-1,y=S.length===0?y:e.rowEnd+1-e.rowStart,C.colStart=C.colEnd;else{if(r!==exports.w.Direction.Down)throw new Error(pg.MESSAGE_ERROR_INVALID_ARG(r));f.rowEnd=_.rowEnd=e.rowEnd+o,f.rowStart=e.rowEnd+1,y=S.length===0?y:e.rowEnd+1-e.rowStart,C.colStart=C.colEnd}if(o%y!==0)throw new Error((Y=>`When filling with merged cells the amount to fill must be a multiple of the input range [${Y}].`)(y));const b=i?"rowIndex":"colIndex",w=i?"colIndex":"rowIndex",E=i?e.rowEnd+1-e.rowStart:e.colEnd+1-e.colStart,I=i?e.rowStart:e.colStart,x=i?e.rowEnd:e.colEnd,v=i?t.rowStart:t.colStart,R=i?t.rowEnd:t.colEnd,A=i?r===exports.w.Direction.Down:r===exports.w.Direction.Right;A||(d.reverse=!0);const M=A?x+1:v,T=(A?R:I-1)-M+1,F=i?e.colEnd:e.rowEnd;l.push(k.unionRanges(f,e));const L=[];let D=null;c||(g=this._beginCommit({description:"Auto Fill",operation:{name:"autoFill",params:[e,t,n]}}));const P=this._cellIterator({bounds:c?C:e,reverse:!A,orientation:i?exports.w.Orientation.Column:exports.w.Orientation.Row,includeRangeTypes:{[X.Type.Style]:!1}});let B=P.next();for(;!B.done;){const Y=B.value.context,se=Y.getCell(),Q=Y.getCoords();D?.oppositeIndex!==Q[w]&&(D={oppositeIndex:Q[w],lastIndex:A?I-1:x+1,values:[]},L.push(D));const re=Q[b];if(A)for(let ee=D.lastIndex+1;ee<re;ee++)D.values.push(null);else for(let ee=D.lastIndex-1;ee>re;ee--)D.values.push(null);D.lastIndex=re;const K=se.toDate();if(K)D.values.push(K);else{let ee=se.getValue();D.values.push(ee)}B=P.next()}const z=L.length;for(let Y=0;Y<z;Y++){const se=L[Y].values;for(let Q=se.length;Q<E;Q++)se.push(null)}const O=(Y,se)=>{if(Y.canFill(se[0],[])){const Q=Y.createFillAt(se,d);if(Q)return Q}return exports.AutoFill.Types.Copy.createFillAt(se)},W=this;if(c){const Y=L[L.length-1];if(L[L.length-1]?.oppositeIndex!==F)return null;const se=O(u,Y.values);return c(Q=>{const re=W._rangeToCoords(Q);let K;r===exports.w.Direction.Down||r===exports.w.Direction.Right?K={rowIndex:re.rowEnd,colIndex:re.colEnd}:r===exports.w.Direction.Left?K={rowIndex:re.rowEnd,colIndex:re.colStart}:r===exports.w.Direction.Up&&(K={rowIndex:re.rowStart,colIndex:re.colEnd});const ee=i?K.rowIndex:K.colIndex,le={value:se(A?ee-I:I-ee+E-1)};let ge=null;return ge=h?this.createTemporaryCell(le,K):this.createTemporaryCell(null,K).createTemporaryCell(le),ge}),!1}const V=this._createIncrementalUpdater({orientation:i?exports.w.Orientation.Column:exports.w.Orientation.Row}),j=L.length;L.sort((Y,se)=>Y.oppositeIndex-se.oppositeIndex);for(let Y=0;Y<j;Y++){const se=Y,Q=O(u,L[se].values),re=L[se].oppositeIndex,K=A?E:E+T-1,ee=this.isDate1904();for(let le=0;le<T;le++){let ge=Q(K+(A?le:-le));Ur(ge)&&(ge=Qo(ge,ee));const de=M+le;i?V.pushAt(de,re,ge):V.pushAt(re,de,ge)}}this._clear([f],n?.contentsOnly?exports.ICell.Content.Formats:void 0),V.apply();const H=this._getMerges([_]),G=k.unionRangesArrays(H);if(H.length>0&&!k.isRangeWithinRange(G,_))throw new Error(zu);if(H.length>0){const Y=[],se=o/y;if(i){const Q=e.rowEnd-e.rowStart+1,re=r===exports.w.Direction.Up?f.rowStart:e.rowEnd+1,K=H.length;for(let ee=0;ee<K;ee++){const le=H[ee],ge=le.rowStart-e.rowStart,de=le.rowEnd-le.rowStart+1;for(let he=0;he<se;he++){const we=he*Q;Y.push({colStart:le.colStart,rowStart:re+we+ge,colEnd:le.colEnd,rowEnd:re+we+ge+de-1})}}}else{const Q=e.colEnd-e.colStart+1,re=r===exports.w.Direction.Left?f.colStart:e.colEnd+1,K=H.length;for(let ee=0;ee<K;ee++){const le=H[ee],ge=le.colStart-e.colStart,de=le.colEnd-le.colStart+1;for(let he=0;he<se;he++){const we=he*Q;Y.push({colStart:re+we+ge,rowStart:le.rowStart,colEnd:re+we+ge+de-1,rowEnd:le.rowEnd})}}}this._merge(Y)}const $=this._getState(),te={},J={};J.directStyleSpatial=$.directStyleSpatial,J.continuousFillSpatial=$.continuousFillSpatial;let ne=e,Z=f;if(!A){let Y=(i?_.rowEnd+1-_.rowStart:_.colEnd+1-_.colStart)%E;const se=i?"rowStart":"colStart",Q=i?"rowEnd":"colEnd";Y!==0&&(Z={...f,[Q]:Math.min(f[Q],f[se]+Y)},ne={...e,[se]:e[Q]-Y+1},f[se]=f[se]+Y)}const q=Object.keys(J),oe=q.length;for(let Y=0;Y<oe;Y++){const se=q[Y],Q=J[se].createCopiedEntries(ne,Z),re=$[se].clone(),K=Q.removes,ee=K.length;for(let le=0;le<ee;le++)re.remove(K[le]);re.load(Q.inserts),te[se]=re}if(A){const Y=this.getTables().search({address:{rowIndex:e.rowEnd,colIndex:e.colEnd}});if(Y.length===1){const se=Y[0],Q=se.getRange().getCoords();se.resize({colStart:Q.colStart,rowStart:Q.rowStart,colEnd:i?Q.colEnd:f.colEnd,rowEnd:i?f.rowEnd:Q.rowEnd})}}const ce=$.calcGraph.clone();ce.autoFill(e,f),te.calcGraph=ce,this._updateState(te),m={...a,ranges:l},g.commit({viewBefore:{view:this.getView(),selection:Be([e]),selectOptions:n?.autoSelect},viewAfter:{view:this.getView(),selection:m,selectOptions:n?.autoSelect}}),this._autoSelect(n?.autoSelect??!1,m)}catch(f){throw g?.rollback(),f}return!0}_setHyperlinks(e,t,n){const r=n?.description??"Set Hyperlink";this._protectionCheck(()=>["insertHyperlinks","formatCells"],e,r);const o=Be(e),i=this._beginCommit({description:r});let a=null;try{const l=this._getState();if(!l)return N.EmptyArray;const c=l.hyperlinkSpatial;let h=c,u=l.directStyleSpatial.clone();const d=e.length;for(let g=0;g<d;g++){const m=e[g];let f=null;const _=m.value,p=_!==void 0?_:t;let S;if(p!==null){if(p.isIHyperlink)S={...p._j},f=p.getDisplayText();else if(typeof p=="string")S={address:p},f=p;else if(p.address){const C=p,y={...C};delete y.displayText,S=y,f=C.displayText??C.address}}else S=null;if(a=k.unionRanges(a,m),c===h&&(h=c.clone()),S!==null||c.size()>0){if(f&&t){const C=this._createIncrementalUpdater({orientation:exports.w.Orientation.Column},void 0,{isHyperlink:!0});for(let y=m.colStart;y<=m.colEnd;y++)for(let b=m.rowStart;b<=m.rowEnd;b++)C.pushAt(b,y,f);C.apply()}if(S===null)this._getRangedEntries("hyperlinkSpatial",[m],{onEntry:(C,y)=>(h.insertNonOverlapping({...y,value:S}),y.value)});else{h.insertNonOverlapping({...m,value:S});const C=this._styles,y=b=>{const w=b.value??new Je(C,k.sanitizeRange(b));let E={...w.getPropertiesAt(0,0,null)};if(E.named){const I=C.getNamed(E.named)?.getRanged().getPropertiesAt(0,0,null);E=N.mergeContentful(I,E)}return delete E.font,E.named=exports.IStyle.BuiltInName.Hyperlink,{...b,value:w.cloneWithUpdate(E)}};u.insertNonOverlapping({...m,value:null},{onIntersect:y})}}}this._lastUsedCoordsRead.coords=null,this._updateState({hyperlinkSpatial:h,directStyleSpatial:u}),this._commitAndAutoSelect(i,o,n?.autoSelect,{viewAfter:{ranges:e}})}catch(l){throw i.rollback(),l}}_updateFormulaSpatial(e,t,n,r){if(n){const i=n.length;for(let a=0;a<i;a++){const l=n[a];e.remove(l)}}let o;if(t){const i=[],a=t.length;for(let l=0;l<a;l++){const c=t[l],h=k.sanitizeRange(c),u=new Ey(h,c.value.tokens,c.value.references);if(i.push({colStart:h.colStart,rowStart:h.rowStart,colEnd:h.colEnd,rowEnd:h.rowEnd,value:u}),!r)continue;const d=c.value.precedents;let g,m,f=!1;const _=d.length;for(let p=0;!f&&p<_;p++){const S=d[p],C=S.colStart;if(S.colStart===void 0)continue;const y=S.rowStart;zt.colStart=C,zt.rowStart=y,zt.colEnd=C,zt.rowEnd=y;const b=r.search(zt)[0];if(b){const w=b.value.getPropertiesAt(y,C,null),E=w?.numberFormat;if(E)if(g){m||(m=exports.NumberFormat.Styles.lookupStyle(g)?.formatType);const I=exports.NumberFormat.Styles.lookupStyle(E)?.formatType;m0(I,m)>0?(m=I,g=E):f=!0}else g=E}}g&&(o||(o=[]),o.push({colStart:h.colStart,rowStart:h.rowStart,colEnd:h.colEnd,rowEnd:h.rowEnd,value:{numberFormat:g}}))}e.load(i)}return o}_realizeCalcedValues(e){if(!e)return;const t=this._getState();if(!t)return;const n=e.valueInserts,r=e.spillRemoves,o=e.errorRemoves,i=t.cellValuesGrid;e.isFull&&(t.calcErrorsSpatial.clear(),t.spillSpatial.clear(),t.pendingSpatial.clear());const a=e.valueRemoves;if(a){const g=t.contentfulSpatial,m=a.length;for(let f=0;f<m;f++){const _=a[f];i.delete(_),g.insertNonOverlapping({..._,value:null})}}if(r){const g=t.spillSpatial,m=r.length;for(let f=0;f<m;f++){const _=r[f];g.remove(_)}}if(o){const g=t.calcErrorsSpatial,m=o.length;for(let f=0;f<m;f++){const _=o[f];g.remove(_)}}this._updateFormulaSpatial(t.formulaSpatial,e.formulaInserts,e.formulaRemoves);const l=e.formatInserts;if(l){const g=l.length;for(let m=0;m<g;m++){const f=l[m],_={numberFormat:f.value};f.value=_}this._updateStyles(l,void 0,{autoFit:!0},!0)}if(n){const g=n.tuples;i.setValues(g);const m=this._isDataColumn,f=m?exports.w.Orientation.Column:exports.w.Orientation.Row,_=t.contentfulSpatial,p=g.length;for(let S=0;S<p;S++){const C=g[S],y=C[0],b=C[1],w=b.length;for(let E=0;E<w;E++){const I=b[E],x=I[0],v=x+I[1].length-1,R={colStart:m?y:x,rowStart:m?x:y,colEnd:m?y:v,rowEnd:m?v:y};_.insertNonOverlapping({colStart:R.colStart,rowStart:R.rowStart,colEnd:R.colEnd,rowEnd:R.rowEnd,value:new jt(R,f)})}}}const c=e.spillInserts;if(c){const g=c.length;for(let m=0;m<g;m++){const f=c[m],_=f.value;f.value=new er(k.sanitizeRange(f),0,_)}t.spillSpatial.load(c)}const h=e.pendingUpdates;if(h){const g=t.pendingSpatial,m=h.length;for(let f=0;f<m;f++){const _=h[f];_.value===!1&&(_.value=null),g.insertNonOverlapping(_)}}const u=e.errorInserts;u&&t.calcErrorsSpatial.load(u);const d=e.formulaInserts;if(d){const g=gn(d);this._autoFit(g,ml)}if((e.bounds||e.isFull)&&!this._initializing){const g=this._rangesListenerMap;if(g.size>0){const m={isDataChange:!0,isTransactional:!1,timeStamp:Date.now(),isUndo:!1,trigger:"calc"};this._notifyRangeListeners(this._rangeListenerSpatial,g,[e.bounds??this._entireCoords],m)}(c||r)&&this._emitter.notify("onSpillsChange")}}_calculate(e,t){const n=this._getState().calcGraph;n.invalidate(e),n.calculate(t)}_calculateFull(){this._initializing||N.debounce(()=>{this._getState()?.calcGraph.calculate({full:!0})},100)()}_setComments(e,t,n){const r=n?.description??"Set Comments",o=Be(e),i=this._beginCommit({description:r});let a=null;try{const l=this._getState();if(!l)return N.EmptyArray;const c=l.commentsSpatial;let h=c;const u=e.length;for(let d=0;d<u;d++){const g=e[d];let m=null;if(t!==null){let f=t;if(!f)continue;m=typeof f=="string"?{content:{runs:{text:f}}}:{...f}}a=k.unionRanges(a,g),c===h&&(h=c.clone()),h.insertNonOverlapping({...g,value:m})}this._lastUsedCoordsRead.coords=null,this._updateState({commentsSpatial:h}),this._commitAndAutoSelect(i,o,n?.autoSelect,{viewAfter:{ranges:e}})}catch(l){throw i.rollback(),l}}_clear(e,t=null,n,r=!1,o=!1){let i=null,a="Clear",l=!1,c=!1,h=!1,u=!1;t===exports.ICell.Content.Formulas?(a=`${a} Formulas`,u=!0):t===exports.ICell.Content.Values?(a=`${a} Values`,u=!0):t===exports.ICell.Content.Formats?(a=`${a} Formats`,l=!0,i=["formatCells"]):t===exports.ICell.Content.Comments?(a=`${a} Comments`,h=!0):t===exports.ICell.Content.Hyperlinks?(a=`${a} Hyperlinks`,c=!0,i=["formatCells"]):(i=[],a=`${a} All`,u=!0,l=!0,c=!0,h=!0),i!==null&&this._protectionCheck(()=>i,e,n?.description??a);const d=Be(e),g=this._beginCommit({description:n?.description??a});let m=this._getState(),f=m.cellValuesGrid,_=m.calcGraph,p=m.contentfulSpatial,S=m.formulaSpatial,C=m.spillSpatial,y=m.pendingSpatial,b=m.calcErrorsSpatial,w=m.rangesListenerSpatial2;u&&(f=f.clone(),_=_.clone(),p=p.clone(),S=S.clone(),C=C.clone(),y=y.clone(),b=b.clone());try{if(c&&this._setHyperlinks(e,null),h&&this._setComments(e,null),l&&(this._updateStyles(e,null),r||this._unmerge(e)),l||u){pi(0,e,[],p,C,f);const E=e.length;for(let I=0;I<E;I++){const x=e[I];if(u){f.delete(x);const A={...x,value:null};p.insertNonOverlapping(A);const M=_.delete(x);this._updateFormulaSpatial(S,null,M)}const v=this.getTables().search({address:x}),R=v.length;for(let A=0;A<R;A++){const M=v[A];k.isRangeWithinRange(M.getAnchorCoords(),x)&&(t===exports.ICell.Content.Formats?M.updateStyleOptions({name:null}):M.delete())}if(l){let A=m.conditionalSpatial;A.size()>0&&(A=A.clone(g.getId()),A.insertNonOverlapping({...x,value:null},{noMerge:!0}),m=this._updateState({conditionalSpatial:A}))}if(o){const A=w.search(x),M=A.length;for(let T=0;T<M;T++){const F=A[T];k.isRangeWithinRange(F,x)&&(w===m.rangesListenerSpatial2&&(w=w.clone()),console.log("cut and move listener"),w.remove(F))}}}}this._updateState({cellValuesGrid:f,calcGraph:_,contentfulSpatial:p,formulaSpatial:S,spillSpatial:C,pendingSpatial:y,calcErrorsSpatial:b,rangesListenerSpatial2:w}),this._commitAndAutoSelect(g,d,n?.autoSelect,{viewAfter:{ranges:e}})}catch(E){throw g.rollback(),E}}_merge(e,t=null){if(this._protectionCheck(Yd,e),e.length===1&&k.isSingleCell(e[0]))return;let n=exports.w.Orientations.Both;t?.orientations?n=t?.orientations:t===exports.w.Orientations.Row?n=exports.w.Orientations.Row:t===exports.w.Orientations.Column&&(n=exports.w.Orientations.Column);const r=t?.discardMultipleValues??!1;let o=Be(e);const i=this.getSelection().getCoords();let a=null;const l=this._beginCommit({description:t?.description??"Merge"});let c=e[0];try{const h=this._getMerges(e);if(ko(e)||h.length>0){const g=k.unionRangesArrays(h),m=k.unionRangesArrays(e);if(!(!g&&!m||g&&m&&k.isRangeWithinRange(g,m)))throw console.warn(Pu,e),new Error(Pu);this._unmerge(h)}const u=this._createIncrementalUpdater({orientation:exports.w.Orientation.Column}),d=[];try{const g=this._entireCoords,m=this._getState().contentfulSpatial;let f=!1;const _=C=>{const y={rowIndex:C.rowStart,colIndex:C.colStart};let b=null;if(f){let w=0;const E=m.search(C),I=E.length;for(let x=0;x<I;x++){const v=k.intersectRanges(E[x],C);if(v&&(w+=(v.rowEnd-v.rowStart+1)*(v.colEnd-v.colStart+1)),w>1)throw new bl("Merging cells would cause some values to be discarded. Use 'discardMultipleValues' option if desired.","discardMultipleValues")}}if(b||(b=y),!k.isEqualCells(b,y)){const w=this.getRange(b).getCell();u.pushAt(C.rowStart,C.colStart,w),u.pushAt(b.rowIndex,b.colIndex,null)}d.push(C),c=k.unionRanges(c,C)},p=[...e].sort(k.createRangeComparator(exports.w.Orientation.Column)),S=p.length;for(let C=0;C<S;C++){const y=p[C];if(!k.isSingleCell(y)){if(a||!i||!k.isCellWithinRange(i.cell,y)||i.cell.rowIndex===y.rowStart&&i.cell.colIndex===y.colStart||(a={...o,cell:{rowIndex:y.rowStart,colIndex:y.colStart}}),!r&&(f=m.search(y).length>0),this._validateOrRemoveOverlaps(y,"merge"),y.colStart<g.colStart||y.rowStart<g.rowStart||y.colEnd>g.colEnd||y.rowEnd>g.rowEnd)throw new Error("We can't merge outside of the maximum cell location.");if(n===exports.w.Orientations.Column){const b=y.rowEnd!==g.rowEnd?y.rowEnd:Math.max(1,g.rowEnd);for(let w=y.rowStart;w<=b;w++)_({...y,rowStart:w,rowEnd:w})}else if(n===exports.w.Orientations.Row){const b=y.colEnd!==g.colEnd?y.colEnd:Math.max(1,g.colEnd);for(let w=y.colStart;w<=b;w++)_({...y,colStart:w,colEnd:w})}else _(y)}}u.apply(),this._indexMerges(d),this._updateState({})}catch(g){throw g.type?new bl(g.message??"Unable to merge",g.type):new Error(g.message??"Unable to merge")}a&&(o=a,this.getSelection().updateCoords(a)),l.commit({viewAfter:{view:this.getView(),selection:o,merges:e,ranges:e,selectOptions:t?.autoSelect}}),this._autoSelect(t?.autoSelect??!1,o)}catch(h){throw l.rollback(),h}}_unmerge(e,t){if(this._protectionCheck(Yd,e),ko(e))throw new Error("We can't unmerge intersecting ranges.");if(!this._getState())return null;const n=k.unionRangesArrays(e),r=Be(e),o=this._beginCommit({description:t?.description??"Unmerge"}),i=o.getState(this).mergeSpatial,a=[];try{const l=e.length;for(let c=0;c<l;c++){const h=e[c],u=i.search(h),d=u.length;for(let g=0;g<d;g++){const m=u[g];if(!k.isSingleCell(h)&&!k.isRangeWithinRange(m,n))throw new Error("We can't unmerge partial cells.");a.push(m)}}if(a.length===0)return o.rollback(),null;this._indexMerges(null,a),this._commitAndAutoSelect(o,r,t?.autoSelect,{viewAfter:{merges:e,ranges:e}})}catch(l){throw o.rollback(),l}}_getMerges(e,t=!1){return e.length===0?N.EmptyArray:this._getRangedEntries("mergeSpatial",e,{excludeHidden:t,fullyContained:!1,onEntry:n=>n.getCoords()})}_clone(){const e={...this._options,container:null};this._ownStyles&&(e.styles=this._styles),this._ownStrings&&(e.strings=this._strings),this._ownResources&&(e.resources=this._resources),this._ownNames&&(e.names=this._names),this._ownsCalculation&&(e.calculation=this._calculation),e.transactions=new Bt({transient:!0});const t=new Gr(e),n=this._transactions.getState(this);t._updateState(n);const r=new gl({sheet:this,json:this.getView().toJSON()});return r.selectMovables(this.getView().getMovableSelection()),t.setView(r),t}_getSnapshot(e,t){if(e.length===0)return N.EmptyArray;const n=this._getState();if(!n)return null;t=Object.freeze({...t});const r=this._clone();r.isMarked=!0;const o=this,i=o.getView(),a="Range",l=[],c=((p,S,C,y)=>{const b=[];let w=null,E=null;const I=C&&C.length>0;if(I){const v=C.length;for(let R=0;R<v;R++){const A=C[R].getSnapshot?.(y);A&&(b.push(A),w=Rl(A.getCoords(),w))}}else if(S){const v=S.length;for(let R=0;R<v;R++){const A=S[R],M=p.getMovables().search({excludeHidden:!1,fullyContained:!0,address:A}),T=M.length;for(let F=0;F<T;F++){const L=M[F].getSnapshot?.(y);L&&(b.push(L),w=Rl(p.getRange(A).getBounds(),w),E=k.unionRanges(E,A))}}}if(b.length===0)return null;const x=()=>y.description??(b?.length===1?zr(b[0]?.getName()):"Drawings");return{copyTo:async(v,R)=>{const A={...y,...R},M=v.getSource(),T=M.getView(),F=T.getMovableSelection(),L=v.getCoords(),D=A?.isCut??!1,P=T.getMovableSelection();T.selectMovables([]);const B=M.beginCommit(A.description??`${D?"Cut":"Copy"} ${x()}`);try{let z=0,O=0;if(P.length>0&&b.length>0){let j=Number.MAX_SAFE_INTEGER,H=Number.MAX_SAFE_INTEGER;for(let q=0;q<F.length;q++){const oe=F[q].getBounds();j=Math.min(oe.x,j),H=Math.min(oe.y,H)}let G=Number.MAX_SAFE_INTEGER,$=Number.MAX_SAFE_INTEGER;const te=b.length;for(let q=0;q<te;q++){const oe=b[q].getCoords();G=Math.min(oe.x,G),$=Math.min(oe.y,$)}z=j-G,O=H-$;const J=b[0].getCoords(),ne={...J,x:J.x+z,y:J.y+O},Z=Ld(M.getMovables(),ne);z+=Z.x,O+=Z.y}else if(w){const j=M.getRange(L).getBounds();z=j.x-w.x,O=j.y-w.y}const W=[],V=b.length;for(let j=0;j<V;j++){const H=b[j],G=H.getCoords(),$={...G,x:G.x+z,y:G.y+O};W.push(H.copyTo({movables:M.getMovables(),bounds:$},{autoSelect:{addToSelection:!0},...A}))}await Promise.all(W),B?.updateState(M,j=>j),B.commit({viewBefore:j=>({...j,view:p.getView(),movableSelection:P})})}catch(z){throw B.rollback(),z}return null},getName:x,getCoords:()=>E,getMarkOptions:()=>y,toText:()=>I?b[0].toText?.()??null:null,toHtml:()=>I?b[0].toHtml?.()??null:null,toImage:()=>I?b[0].toImage?.()??null:null,getSource:()=>p,isISnapshot:!0}})(r,e,i.getMovableSelection(),t);if(c){if(i.getMovableSelection().length>0)return c;l.push(c)}if(e.length>1)throw new Error(Hu);const h={singleMerge:null};l.push({copyTo(p,S){const C={...t,...S};let y=null;if(!C.skipBlanks){const w=p.getSource(),E=p.getCoords(),I=li(E,e[0],C?.fitDestination,C?.transpose);y=w.getRange(I);let x=!1;const v=y.getMerges();if(v.length===1&&k.isEqualRanges(v[0],E))if(k.isSingleCell(e[0]))x=!0;else{const R=(b=_)?{colIndex:b.colStart,rowIndex:b.rowStart}:null;r._getMerges([k.cellToRange(R)]).length===1&&(x=!0)}return x?(h.singleMerge=E,y.clear(C.type??exports.ICell.Content.Values)):y.clear(C.type),I}var b}});const u=r._entireCoords,d=e.length;for(let p=0;p<d;p++){const S=e[p],C=n.rangeListenerSpatial.search(S,!1),y=n.rangesListenerMap;l.push({async copyTo(b,w){if(!w.isCut)return;const E=new Set,I=C.length;for(let x=0;x<I;x++){const v=C[x].value,R=v.id;if(E.has(R))continue;const A=y.get(R);if(E.add(R),A.ranges[v.offset]===null)return;const M={isTransactional:!0,isDataChange:!1,trigger:"moveCells",from:r.getRanges(e),to:b},T=r._createRangeEvent(A.ranges,M);r._notifyRangeListener2(A,T,M)}return null},getMarkOptions:()=>t,getCoords:()=>null,isISnapshot:!0})}const g={excludeHidden:!1,fullyContained:!0,onEntry:p=>p.model};for(let p=0;p<d;p++){const S=e[p],C=r._getRangedEntries("tableSpatial",[S],g),y=C.length;for(let b=0;b<y;b++){const w=C[b],E=w.getAnchorCoords(),I=E.colStart-S.colStart,x=E.rowStart-S.rowStart,v=w.getSnapshot(t);l.push({async copyTo(R,A){const M=R.getSource(),T=R.getCoords();if(r.getProtection().isLocked())return;const F={colStart:T.colStart+I,rowStart:T.rowStart+x,colEnd:T.colEnd+I,rowEnd:T.rowEnd+x};return v.copyTo({tables:M.getTables(),range:F},A)}})}}for(let p=0;p<d;p++){const S=e[p];l.push(zd(o.getColumnHeaders().getRange(S),S,Object.freeze({...t,includeHeaders:S.rowStart<=u.rowStart&&S.rowEnd>=u.rowEnd})))}for(let p=0;p<d;p++){const S=e[p];l.push(zd(o.getRowHeaders().getRange(S),S,Object.freeze({...t,includeHeaders:S.colStart<=u.colStart&&S.colEnd>=u.colEnd})))}const m=Cy(o,r,e,a,t,(p,S)=>r._copyRange(o,r,e,p,S,h));l.push(m);const f=r._getState().calcGraph.getSnapshot({range:e[0]});l.push({async copyTo(p,S){const C=p.getSource(),y=p.getCoords();if(r.getProtection().isLocked())return;const b=C._getState().calcGraph;return f.copyTo({calcGraph:b,range:y},S)}});const _=e[0];return((p,S,C,y,b,w,E=null)=>({async copyTo(I,x){let v=null;const R={...b,...x},A=C.beginCommit(R.description??w);try{const M=p.length;for(let T=0;T<M;T++){const F=await p[T].copyTo(I,R);F&&(v=k.unionRanges(v,F))}A.commit()}catch(M){throw A.rollback(),M}return v},getMarkOptions:()=>b,getName:()=>w,getSource:()=>S,getCoords:()=>y,toText(){let I=E?.toText?.()??null;const x=p.length;for(let v=0;!I&&v<x;v++)I=p?.[v].toText?.();return I??null},toHtml(){let I=E?.toHtml?.()??null;const x=p.length;for(let v=0;!I&&v<x;v++)I=p?.[v].toHtml?.();return I??null},toImage(){let I=E?.toImage?.()??null;const x=p.length;for(let v=0;!I&&v<x;v++)I=p?.[v].toImage?.();return I??null},isISnapshot:!0}))(l,o,r,_,t,a,m)}async _copyRange(e,t,n,r,o,i){if(n.length>1)throw new Error("Only a single selection is supported when using 'Insert Copy'.");if(!n||n.length===0)throw new Error("The source has no range.");const a=r.getSource();let l=r.getCoords(),c={...n[0]};const h=(o={...o}).isCut;let u=!o.type||o.type===exports.ICell.Content.Formats,d=!o.type||o.type===exports.ICell.Content.Values,g=!o.type||o.type===exports.ICell.Content.Formats||o.type===exports.ICell.Content.Hyperlinks;const m=a.getEntireRange(),f=m.getCoords(),_=[],p=[],S=[];let C=[],y=[];const b=(o.fitDestination??!1)&&!k.isSingleCell(l),w=li(l,c,b,o.transpose);if(b&&(c={...c,colEnd:c.colStart+Math.min(w.colEnd-w.colStart,c.colEnd-c.colStart),rowEnd:c.rowStart+Math.min(w.rowEnd-w.rowStart,c.rowEnd-c.rowStart)}),!k.isRangeWithinRange(w,f))throw console.warn(w,f),new Error("We can't paste outside of the sheet bounds.");let E=null;E=o.undoRange?{view:a.getView(),selection:Be([o.undoRange.getCoords()])}:{sheet:a,selection:Be([w])};const I=a.getTransactions().beginCommit({description:o.description??"Paste"});try{if(!this._getState())return N.EmptyArray;const x=new Set,v=o.transpose;let R=!((v||o.adjustCells)&&u)&&x.size===1;if(R){const H=x.values().next();R=k.isRangeWithinRange(c,H.value.getCoords())&&!Oo(c,H.value.getCoords())}R&&(R=a.getTables().search({address:w}).length===0),v&&(R=!0),i.singleMerge&&(u=!1,g=!1);const A=l.colStart-c.colStart,M=l.rowStart-c.rowStart,T=o.adjustCells;let F={...Y_};if(delete F[X.Type.Style],!u){const H=this.getProtection().isLocked();F={},H&&(F[X.Type.Unlock]=!1)}const L=exports.w.Orientation.Column;let D;if(d){D=m.startIncrementalUpdates({orientation:o.transpose?exports.w.Orientation.Row:exports.w.Orientation.Column});const H={orientation:L,includeRangeTypes:F,bounds:c},G=new Xa(this._strings,H,this._cellOptions),$=(Z,q,oe)=>{const ce=Z[0],Y=G.setState(Z),se=G.context,Q=se.getCell(),re=Q.isTopLeft();let K=M,ee=A;if(v){const he=ce.colIndex-c.colStart,we=ce.rowIndex-c.rowStart;K=he+oe+l.rowStart,ee=we+q+l.colStart}else K=M+ce.rowIndex+q,ee=A+ce.colIndex+oe;let le=!1;const ge={value:void 0,style:void 0,hyperlink:void 0};if(d&&(ge.value=Y,le=!0),u){const he=Z[2];he&&(he.directStyle||he.table)&&(ge.style=Q.getStyle(!R),le=!0)}g&&(ge.hyperlink=Q.getHyperlink(),le=!0);let de=ge;if(T&&re){const he=T(Y,se,{rowIndex:K,colIndex:ee},o);he!==void 0&&(de=he,le=!0)}if(le&&(D.pushAt(K,ee,de),u)){const he=Q.getSpans();(he.width>1||he.height>1)&&re&&_.push({colStart:ee,rowStart:K,colEnd:ee+(o.transpose?he.height:he.width)-1,rowEnd:K+(o.transpose?he.width:he.height)-1})}},te=this._cellStateIterator(H);let J={next(){const Z=te.next();if(Z.done)return Re;const q=Z.value[0];let oe;return Z.value&&(oe=[q,Z.value]),{done:Z.done,value:oe}}};if(!i.singleMerge&&!k.isEqualRanges(w,c)){const Z=w.colEnd-w.colStart+1,q=w.rowEnd-w.rowStart+1;J=new Wl({delegate:J,bounds:c,orientation:L,dims:{major:o.transpose?q:Z,minor:o.transpose?Z:q}})}let ne=J.next();for(;!ne.done;){const Z=ne.value,q=Z[1],oe=Z[0],ce=q[0];$(q,oe.rowIndex-ce.rowIndex,oe.colIndex-ce.colIndex),ne=J.next()}}const P=t._getState(),B={},z={transpose:v??!1};u&&(B.directStyleSpatial=P.directStyleSpatial,B.continuousFillSpatial=P.continuousFillSpatial,B.mergeSpatial=P.mergeSpatial),h&&(e._clear([c],void 0,void 0,!1,!0),C.push(c),B.rangesListenerSpatial2=P.rangesListenerSpatial2);const O=a,W=O._getState(),V=Object.keys(B),j=V.length;for(let H=0;H<j;H++){const G=V[H],$=B[G].createCopiedEntries(c,w,z),te=W[G].clone(),J=$.removes,ne=J.length;for(let Z=0;Z<ne;Z++)te.remove(J[Z]);te.load($.inserts),W[G]=te}O._updateState(W),C.push(w),y.push(w),p&&p.length>0&&O._colHeaders.updateHeaderPairs(p),S&&S.length>0&&O._rowHeaders.updateHeaderPairs(S),D?.apply(),_.length>0&&a.getRanges(_).merge(),I.commit({viewBefore:E,viewAfter:H=>({...H,view:a.getView(),selection:Be(y),ranges:C})})}catch(x){throw console.warn(x),I.rollback(),new Error((v=>`Unable to paste: ${v}`)(x.message),{cause:x})}return k.unionRangesArrays(y)}_snapShotFromSource(e,t){if(e.isISnapshot)return e;const n=e;let r=null;if(n?.isICellRanges)throw new Error(Hu);if(r=n?.isICellRange?n:this.getRange(n),r.isICellRange){const o=r;if(o.isInvalid())throw new Error(Vu);return o.getSnapshot(t)}throw new Error(Vu)}async _copyFrom(e,t,n){if(!t)throw new Error("Both a source and a destination are required to copy.");const r=this._snapShotFromSource(t),o="Paste",i=this._beginCommit({description:n?.description??o});let a=null;try{const l=this.getRange(e);a=await r.copyTo(l,n);const c=r.getName(),h=[a];n?.isCut&&h.push(r.getCoords()),i.commit({description:c?n?.description??`${o} ${c}`:o,viewAfter:{view:this.getView(),selection:Be([a]),ranges:h}})}catch(l){throw i.rollback(),l}return a}_createFilter(e,t,n){const r=this;return new af({initialAnchor:e,maxRangeCoords:this._entireCoords,json:t,transactions:this._transactions,deleteFromContainer:o=>{const i=this._beginCommit({description:o?.description??"Delete Filter"});this._updateState({filter:null}),i.commit()},apply:o=>{console.log("apply Filter",o)},processUpdate:()=>{},isProtected:()=>!r._initializing&&!r.getProtection().isAutoFilterAllowed()})}insertFilter(e){const t=this._rangeToCoords(e,()=>["autoFilter"]);let n=this.getFilter();if(n)return n;n=this._createFilter(t);const r=Be([t]),o=this._beginCommit({description:"Insert Filter"});return this._updateState({filter:n}),o.commit({viewAfter:{ranges:[t],view:this.getView(),selection:r,selectOptions:void 0}}),n}getFilter(){return this._getState()?.filter??null}insertSort(e){return this._rangeToCoords(e,()=>["sort"]),null}getSort(){return null}_getDefaultShiftOrientation(e){return Iw(e,this._entireCoords)}_getDefaultSortCriteria(e,t,n){return dd(this,e,n?this._cellToCoords(n):null,t)}async _insertFrom(e,t,n){if(!t)throw new Ot;const r=this._snapShotFromSource(t),o=r.getCoords();let i=li(e[0],o,n?.fitDestination),a=co([i]),l=a;const c=n?.orientation??this._getDefaultShiftOrientation(i),h=this._beginCommit({description:n?.description??"Insert Copied Cells",autoSelect:n?.autoSelect});try{if(this._insertCells([i],c),await this._copyFrom(i,r,{...n,isCut:!1}),n.isCut){const u={...o};if(a=co([u]),i={...i},this===r.getSource()){if(c===exports.w.Orientation.Row){if(i.colStart<u.colStart&&i.colEnd>=u.colStart||i.colEnd>u.colEnd&&i.colStart<=u.colEnd)throw new Error(Gu);if(u.colStart===i.colStart&&u.colEnd===i.colEnd){const d=u.rowEnd-u.rowStart+1;i.rowStart<=u.rowStart?(u.rowStart+=d,u.rowEnd+=d):(i.rowStart-=d,i.rowEnd-=d)}}else{if(i.rowStart<u.rowStart&&i.rowEnd>=u.rowStart||i.rowEnd>u.rowEnd&&i.rowStart<=u.rowEnd)throw new Error(Gu);if(u.rowStart===i.rowStart&&u.rowEnd===i.rowEnd){const d=u.colEnd-u.colStart+1;i.colStart<=u.colStart?(u.colStart+=d,u.colEnd+=d):(i.colStart-=d,i.colEnd-=d)}}l=co([i])}r.getSource().getRanges([u]).delete(c)}h.commit({viewBefore:{ranges:e,view:this.getView(),selection:a,selectOptions:n?.autoSelect},viewAfter:{ranges:e,view:this.getView(),selection:l,selectOptions:n?.autoSelect}}),this._autoSelect(n?.autoSelect??!1,l)}catch(u){throw h.rollback(),u}return i}_insertCells(e,t,n,r=void 0){const o=this;r=r??((f,_)=>{o._validateCoords(f,_??Ga)});const i=n?.description??"Insert Cells",a=(t??this._getDefaultShiftOrientation(e[0]))===exports.w.Orientation.Column;if(this._protectionCheck(()=>[a?"insertColumns":"insertRows"],e,i),ko(e))throw new Error("We can't insert cells with overlapping selections.");const l=this._entireCoords;let c=l.colEnd,h=l.rowEnd;const u=Be(e),d=this._beginCommit({description:i,operation:{name:"insertCells"}}),g=d.getState(this),m=a?exports.w.Direction.Right:exports.w.Direction.Down;try{let f=g.cellValuesGrid,_=g.contentfulSpatial,p=g.unlockSpatial,S=g.mergeSpatial,C=g.directStyleSpatial,y=g.continuousFillSpatial,b=g.conditionalSpatial,w=g.hyperlinkSpatial,E=g.commentsSpatial,I=g.movableSpatial,x=g.tableSpatial,v=g.calcGraph,R=g.rangesListenerSpatial2,A=g.rangeListenerSpatial,M=g.rangesListenerMap;const T=new Map,F=Fn(e.slice(),exports.w.Direction.Left),L=F.length;for(let z=0;z<L;z++){const O=F[z];c=Math.min(c,O.colStart),h=Math.min(h,O.rowStart);const W=a?O.colEnd-O.colStart+1:O.rowEnd-O.rowStart+1,V=f.getCoords();if(V){const $={...O,colEnd:a?Math.max(O.colEnd,V?.colEnd??O.colStart)+(O.colEnd-O.colStart+1):O.colStart,rowEnd:a?O.rowStart:Math.max(O.rowEnd,V?.rowEnd??O.rowStart)+(O.rowEnd-O.rowStart+1)},te=_.search($),J=te.length;for(let ne=0;ne<J;ne++){const Z=te[ne],q={...O};a?q.colEnd=Math.max(q.colEnd,Z.colEnd)+W:q.rowEnd=Math.max(q.rowEnd,Z.rowEnd)+W,r(q)}f=f.clone(),f.shift(O,m),this._updateState({cellValuesGrid:f})}const j=O.colStart<=l.colStart&&O.colEnd>=l.colEnd,H=O.rowStart<=l.rowStart&&O.rowEnd>=l.rowEnd,G=($,te,J,ne)=>{let Z=null;J>1&&(Z=$.at(J-1));const q=ne-J+1;te?.(J,q),Z&&$.updateHeaderPairs([{address:{min:J,max:ne},update:Z}])};j&&G(this._rowHeaders,this._rowHeadersShiftCallback,O.rowStart,O.rowEnd),H&&G(this._colHeaders,this._colHeadersShiftCallback,O.colStart,O.colEnd),_=_.shift({range:O,direction:m,cloneIfUpdate:_===g.contentfulSpatial,coordValidator:r}),p=p.shift({range:O,direction:m,cloneIfUpdate:p===g.unlockSpatial,coordValidator:r}),S=S.shift({range:O,direction:m,cloneIfUpdate:S===g.mergeSpatial,coordValidator:r}),C=C.shift({range:O,direction:m,cloneIfUpdate:C===g.directStyleSpatial,coordValidator:r}),y=y.shift({range:O,direction:m,cloneIfUpdate:y===g.continuousFillSpatial,coordValidator:r}),b=b.shift({range:O,direction:m,cloneIfUpdate:b===g.conditionalSpatial,coordValidator:r}),w=w.shift({range:O,direction:m,cloneIfUpdate:w===g.hyperlinkSpatial,coordValidator:r}),E=E.shift({range:O,direction:m,cloneIfUpdate:E===g.commentsSpatial,coordValidator:r}),I=I.shift({range:O,direction:m,cloneIfUpdate:I===g.movableSpatial,coordValidator:r}),x=x.shift({range:O,direction:m,cloneIfUpdate:x===g.tableSpatial,coordValidator:r}),v=v.shift({range:O,direction:m,cloneIfUpdate:v===g.calcGraph}),A=A.shift({range:O,direction:m,cloneIfUpdate:A===g.rangeListenerSpatial,onShift:$=>{M===g.rangesListenerMap&&(M=new Map(M)),this._processListenerShift(M,T,g.rangesListenerMap,$)}}),R=R.shift({range:O,direction:m,cloneIfUpdate:R===g.rangesListenerSpatial2,coordValidator:r})}let D=g.formulaSpatial,P=g.spillSpatial,B=g.pendingSpatial;v!==g.calcGraph&&(D=D.clone(),P=P.clone(),B=B.clone()),this._updateState({contentfulSpatial:_,unlockSpatial:p,mergeSpatial:S,directStyleSpatial:C,continuousFillSpatial:y,conditionalSpatial:b,hyperlinkSpatial:w,commentsSpatial:E,movableSpatial:I,tableSpatial:x,calcGraph:v,formulaSpatial:D,spillSpatial:P,pendingSpatial:B,rangesListenerSpatial2:R,rangeListenerSpatial:A,rangesListenerMap:M}),this._commitAndAutoSelect(d,u,n?.autoSelect,{viewAfter:{ranges:F,listeners:T}})}catch(f){throw console.warn(f),d.rollback(),f instanceof Ne?new Error(f.message??Ga):f}}_deleteCells(e,t,n){const r=(t??this._getDefaultShiftOrientation(e[0]))===exports.w.Orientation.Column,o=n?.description??"Delete Cells";if(this._protectionCheck(()=>[r?"deleteColumns":"deleteRows"],e,o),ko(e))throw new Error("We can't delete cells with overlapping selections.");const i=this._entireCoords;let a=i.colEnd,l=i.rowEnd;const c=r?exports.w.Direction.Left:exports.w.Direction.Up,h=Be(e),u=this._beginCommit({description:o,operation:{name:"deleteCells"}}),d=u.getState(this);try{let g=d.cellValuesGrid,m=d.contentfulSpatial,f=d.mergeSpatial,_=d.unlockSpatial,p=d.directStyleSpatial,S=d.continuousFillSpatial,C=d.conditionalSpatial,y=d.hyperlinkSpatial,b=d.commentsSpatial,w=d.movableSpatial,E=d.movableMapModel,I=d.tableSpatial,x=d.tableMapModel,v=d.calcGraph,R=d.rangesListenerSpatial2,A=d.rangeListenerSpatial,M=d.rangesListenerMap;const T=new Map,F=Fn(e.slice(),exports.w.Direction.Left),L=F.length;for(let D=0;D<L;D++){const P=F[D];a=Math.min(a,P.colStart),l=Math.min(l,P.rowStart),g.getCoords()&&(g=g.clone(),g.shift(P,c),this._updateState({cellValuesGrid:g}));const B=P.colStart<=i.colStart&&P.colEnd>=i.colEnd,z=P.rowStart<=i.rowStart&&P.rowEnd>=i.rowEnd;B&&this._rowHeadersShiftCallback(P.rowStart,-1*(P.rowEnd-P.rowStart+1)),z&&this._colHeadersShiftCallback(P.colStart,-1*(P.colEnd-P.colStart+1)),m=m.shift({range:P,direction:c,cloneIfUpdate:m===d.contentfulSpatial}),_=_.shift({range:P,direction:c,cloneIfUpdate:_===d.unlockSpatial}),f=f.shift({range:P,direction:c,cloneIfUpdate:f===d.mergeSpatial}),p=p.shift({range:P,direction:c,cloneIfUpdate:p===d.directStyleSpatial}),S=S.shift({range:P,direction:c,cloneIfUpdate:S===d.continuousFillSpatial}),C=C.shift({range:P,direction:c,cloneIfUpdate:C===d.conditionalSpatial}),y=y.shift({range:P,direction:c,cloneIfUpdate:y===d.hyperlinkSpatial}),b=b.shift({range:P,direction:c,cloneIfUpdate:b===d.commentsSpatial}),w=w.shift({range:P,direction:c,cloneIfUpdate:w===d.movableSpatial}),I=I.shift({range:P,direction:c,cloneIfUpdate:I===d.tableSpatial}),v=v.shift({range:P,direction:c,cloneIfUpdate:v===d.calcGraph}),A=A.shift({range:P,direction:c,cloneIfUpdate:A===d.rangeListenerSpatial,onShift:O=>{M===d.rangesListenerMap&&(M=new Map(M)),this._processListenerShift(M,T,d.rangesListenerMap,O)}}),R=R.shift({range:P,direction:c,cloneIfUpdate:R===d.rangesListenerSpatial2})}this._updateState({contentfulSpatial:m,unlockSpatial:_,mergeSpatial:f,directStyleSpatial:p,continuousFillSpatial:S,conditionalSpatial:C,hyperlinkSpatial:y,commentsSpatial:b,movableSpatial:w,movableMapModel:E,tableSpatial:I,tableMapModel:x,calcGraph:v,rangesListenerSpatial2:R,rangeListenerSpatial:A,rangesListenerMap:M}),this._commitAndAutoSelect(u,h,n?.autoSelect,{viewAfter:{ranges:F,listeners:T}})}catch(g){throw u.rollback(),g instanceof Ne?new Error(g.message??Ga):g}}_autoFit(e,t){if(this._closed)throw new Error(ft);t={expandOnly:!1,skipCustomSize:!1,minContent:!1,...t};const n="Autofit";let r;const o=Jo(e,this._entireCoords,!0),i=qo(e,this._entireCoords,!0);!o&&i?(t.orientations=t.orientations??exports.w.Orientations.Column,r=`${n} ${Kn}`):!i&&o?(t.orientations=t.orientations??exports.w.Orientations.Row,r=`${n} ${Jn}`):i&&o?(t.orientations=t.orientations??exports.w.Orientations.Both,r=`${n} All`):(t.orientations=t.orientations??exports.w.Orientations.Both,r=`${n}`);let a=t.orientations!==exports.w.Orientations.Row;this._colHeaders.isProtected()&&(a=!1);let l=t.orientations!==exports.w.Orientations.Column;if(this._rowHeaders.isProtected()&&(l=!1),!l&&!a)return;const c=a&&(t.expandOnly===!1||t.expandOnly===exports.w.Orientation.Row),h=l&&(t.expandOnly===!1||t.expandOnly===exports.w.Orientation.Column),u=t.minContent,d=Be(e),g=this._beginCommit({description:t.description??r});try{let m=Number.MAX_SAFE_INTEGER,f=Number.MIN_SAFE_INTEGER,_=!1,p="",S=-1,C=!1,y=!1,b=!1,w=Number.MAX_SAFE_INTEGER,E=Number.MIN_SAFE_INTEGER;const I=this._styles.getNormal(),x=this._cellOptions,v=t.orientations===exports.w.Orientations.Row,R=new Map,A=zl(e,1);A.sort(k.createRangeComparator(exports.w.Orientation.Column));const M=A.length,T={skipCustomSize:t.skipCustomSize},F=exports.IFont.getDeviceScale(),L=this._defaultRowHeight()*F,D=(B,z=1)=>{if(B!==0&&B!==null&&!(z>1))return B=Math.max(B,L),O=>h?B:Math.max(O,B)},P=(B,z=1)=>{if(B!==0&&B!==null&&!(z>1))return O=>c?B:Math.max(O,B)};for(let B=0;B<M;B++){const z=[];let O=-1,W=!1,V=I,j=-1,H=1,G=1;const $=A[B];let te=$.colStart,J=$.rowStart,ne=$.colEnd,Z=$.rowEnd;const q=this._getUsedCoords();(h||c)&&q&&(te=h?q.colStart:$.colStart,J=c?q.rowStart:$.rowStart,ne=h?q.colEnd:$.colEnd,Z=c?q.rowEnd:$.rowEnd);const oe={includeRangeTypes:{[X.Type.Style]:!1,[X.Type.Contentful]:!1},excludeHidden:!1,bounds:{colStart:te,rowStart:J,colEnd:ne,rowEnd:Z},orientation:exports.w.Orientation.Column},ce=l?[]:void 0,Y=a?[]:void 0,se=(ye,ue,Ee)=>{if(ye>ue)return null;const xe=[];let Ie=ye;const pe=Ee?Ee.length:0;for(let Ce=0;Ce<pe;Ce++){const Ae=Ee[Ce],Qe=Ae.min,Ze=Ae.max;if(Ie>=Qe){Ie=Ze+1;continue}const ze={address:{min:Ie,max:Qe-1},update:Zd};xe.push(ze),Ie=Ze+1}if(Ie<=ue){const Ce={address:{min:Ie,max:ue},update:Zd};xe.push(Ce)}return xe},Q=this._rangeStateIterator(oe);let re=Q.next();for(;!re.done;){const ye=re.value,ue=ye.intersection,Ee=ye.start,xe=ye.end;yo.colStart=Ee.colIndex,yo.rowStart=Ee.rowIndex,yo.colEnd=xe.colIndex,yo.rowEnd=xe.rowIndex;const Ie=k.intersectRanges(yo,$,Fy),pe=Oi(0,Ie,ue,x).getBestFit();if(l){const Ce=Math.max(Ee.rowIndex,J),Ae={address:{min:Ce,max:Math.min(xe.rowIndex,Z)},update:{size:D(pe.height),autoSize:!0}};ce.push(Ae)}if(a){const Ce=Math.max(Ee.colIndex,te),Ae={address:{min:Ce,max:Math.min(xe.colIndex,ne)},update:{size:P(pe.width),autoSize:!0}};Y.push(Ae)}re=Q.next()}if(Y){let ye=this._colHeaders.updateHeaderPairs(Y,T);ye=Xt(rr(Jh(ye)));const ue=se($.colStart,$.colEnd,ye);ue&&this._colHeaders.updateHeaderPairs(ue,T)}if(ce){let ye=this._rowHeaders.updateHeaderPairs(ce,T);ye=Xt(rr(Jh(ye)));const ue=se($.rowStart,$.rowEnd,ye);ue&&this._rowHeaders.updateHeaderPairs(ue,T)}const K=this._cellStateIterator({...oe,includeRangeTypes:{[X.Type.Merge]:!1,[X.Type.Table]:!1,[X.Type.Style]:!1},ignoreEmptyIntersections:!0});let ee,le,ge,de=K.next(),he=1,we=1;for(;!de.done;){const ye=de.value,ue=ye[0],Ee=ye[2];let xe=I;const Ie=Ee?.directStyle??null;Ie===ee?xe=le:(xe=Ie?Oi(0,k.cellToRange(ue,Ny),Ee,x):I,le=xe);let pe=1,Ce=1;const Ae=Ee?.merge??null;if(Ae===ge)pe=he,Ce=we;else{if(Ae){const Gt=Ae.getCoords();pe=Gt.colEnd-Gt.colStart+1,Ce=Gt.rowEnd-Gt.rowStart+1}else pe=1,Ce=1;he=pe,we=Ce}const Qe=ue.colIndex,Ze=ue.rowIndex,ze=ye[1],ut=Ye(ze),Vt=k.isCellWithinRange(ue,$);let en=!1,mt=!1;if(ee!==Ie||pe!==H||Ce!==G||ut===U.String||ut===U.Error||Vt!==W){if(en=!0,(pe>1||Ce>1||ut===U.RichData)&&(mt=!0),!mt&&Ee){const Gt=xe.getAlignment().getHorizontal();Gt!==exports.ITextFrame.HorizontalAlignment.CenterContinuous&&Gt!==exports.ITextFrame.HorizontalAlignment.Fill||(mt=!0)}mt&&(en=!1)}if(ee=Ie,ge=Ae,(O!==Qe||en)&&(O!==Qe&&(j=this._colHeaders.getSpanSize(Qe)),O!==-1&&z.push({col:O,style:V,spanWidth:pe,spanHeight:Ce,minVal:m,maxVal:f,hasZero:_,text:p,textId:S,hasFalse:y,hasTrue:C,hasEmpty:b,minRow:w,maxRow:E,colWidth:j,measureWidth:-1,measureHeight:-1,isFit:W}),O=Qe,V=xe,W=Vt,H=pe,G=Ce,m=Number.MAX_SAFE_INTEGER,f=Number.MIN_SAFE_INTEGER,_=!1,p="",S=-1,y=!1,C=!1,b=!1,w=Ze),E=Ze,!mt)if(ze===null)b=!0;else switch(ut){case U.Number:ze===0&&(_=!0),m=Math.min(m,ze),f=Math.max(f,ze);break;case U.String:p=ze,S=ze;break;case U.Error:p=ze.toString(),S=-1;break;case U.Boolean:ze?C=!0:y=!0}de=K.next()}O!==-1&&z.push({col:O,style:V,spanWidth:H,spanHeight:G,minVal:m,maxVal:f,hasZero:_,text:p,textId:S,hasFalse:y,hasTrue:C,hasEmpty:b,minRow:w,maxRow:E,colWidth:j,measureWidth:-1,measureHeight:-1,isFit:W});let fe=-1,ve=-1;const Te=z.length;for(let ye=0;ye<Te;ye++){const ue=z[ye],Ee=v||!ue.isFit,xe=ue.maxVal,Ie=ue.style,pe=ue.colWidth;if(fe=0,ve=0,xe!==Number.MIN_SAFE_INTEGER){const Ae=On(U.Number,Ie,xe,x,pe,u,Ee);fe=Ae.width,ve=Ae.height;const Qe=ue.minVal;if(Qe*xe<0){const Ze=On(U.Number,Ie,Qe,x,pe,u,Ee);fe=Math.max(fe,Ze.width),ve=Math.max(ve,Ze.height)}if(ue.hasZero&&Qe!==0&&xe!==0){const Ze=On(U.Number,Ie,0,x,pe,u,Ee);fe=Math.max(fe,Ze.width),ve=Math.max(ve,Ze.height)}}const Ce=ue.text;if(Ce.length>0){const Ae=On(U.String,Ie,Ce,x,pe,u,Ee,void 0,R);fe=Math.max(fe,Ae.width),ve=Math.max(ve,Ae.height)}if(ue.hasTrue||ue.hasFalse){const Ae=On(U.Boolean,Ie,!ue.hasFalse,x,pe,u,Ee);fe=Math.max(fe,Ae.width),ve=Math.max(ve,Ae.height)}if(ue.hasEmpty){const Ae=On(U.Boolean,Ie,null,x,pe,u,Ee);fe=Math.max(fe,Ae.width),ve=Math.max(ve,Ae.height)}ue.measureWidth=fe,ue.measureHeight=ve}if(a){const ye=[];for(let ue=0;ue<Te;ue++){let Ee=z[ue];const xe=Ee.col;let Ie=z[ue+1],pe=Ee.measureWidth??0;for(;Ie&&Ie.col===xe;)Ie.measureWidth&&(pe=Math.max(Ie.measureWidth??0,pe)),ue++,Ee=z[ue],Ie=z[ue+1];pe===0&&(pe=null);const Ce=P(pe,Ee.spanWidth);ye.push({address:{min:xe,max:xe},update:{size:Ce,autoSize:!0}})}this._colHeaders.updateHeaderPairs(ye,T)}if(l){let ye=1;const ue={onUpdate:(pe,Ce,Ae)=>{if(!(ye>1))return pe===null?Ce:Math.max(Ce,pe)}};let Ee=[];for(let pe=0;pe<Te;pe++){const Ce=z[pe];ye=Ce.spanHeight,Ee=Xt(Bl(Ee,{min:Ce.minRow,max:Ce.maxRow,value:Ce.measureHeight},ue))}const xe=Ee.length,Ie=new Array(xe);for(let pe=0;pe<xe;pe++){const Ce=Ee[pe],Ae=D(Ce.value,1),Qe={address:{min:Ce.min,max:Ce.max},update:{size:Ae,autoSize:!0}};Ie[pe]=Qe}this._rowHeaders.updateHeaderPairs(Ie,T)}}this._commitAndAutoSelect(g,d,t?.autoSelect,{viewAfter:{ranges:e}})}catch(m){throw g.rollback(),m}}_createRangeEvent(e,t){const n=this,r=()=>{const i=n._getState();return this._closed||i.deleted?fn(null):e?Array.isArray(e)?n._createRanges(e):n._createRange(e):fn(this,this._entireCoords)},o=t.trigger;return{getSource:r,getFrom:()=>t.from??null,getTo:()=>t.to??null,trigger:o,isUndo:t.isUndo??!1,isDataChange:t.isDataChange??!1,isTransactional:t.isTransactional??!0,toString:()=>`SheetRangeEvent: ('${o}', ${r().toString()})`,timeStamp:t.timeStamp??Date.now()}}_notifyAddressListeners(e,t,n,r){const o=t.entries();let i=o.next();const a=r.trigger;for(;!i.done;){const l=i.value[0];let c=i[1];if(c||(c=e.get(l)),c&&!n.has(l)){let h=!1;const u=c.options;u&&(h=a==="address"?u.ignoreAddressChanges:u.ignoreDataChanges),h!==!0&&c.notify(r),n.add(l)}i=o.next()}}_notifyDataListeners(e,t,n=null,r,o){if(!e)return;const i=n.length;for(let a=0;a<i;a++){const l=n[a];if(!l)continue;const c=e.search(l),h=c.length;for(let u=0;u<h;u++){const d=c[u].value.groupId;if(!r.has(d)){const g=t.get(d);g.options?.ignoreDataChanges!==!0&&g.notify(o),r.add(d)}}}}_notifyRangeListeners(e,t,n=null,r){if(!e)return;const o=new Set;r.timeStamp||(r.timeStamp=Date.now());const i=n.length;for(let a=0;a<i;a++){const l=n[a];if(!l)continue;const c=e.search(l),h=c.length;for(let u=0;u<h;u++){const d=c[u].value.id;if(o.has(d))continue;const g=t.get(d);o.add(d);const m=g.ranges,f=m.length;for(let _=0;_<f;_++){const p=m[_],S=this._createRangeEvent(p,r);this._notifyRangeListener2(g,S,r)}}}}_notifyRangeListener2(e,t=null,n=null){if(e.options?.ignoreDataChanges&&n?.isDataChange)return;const o=e.handler??e.handlerW.deref();if(o)try{o?.(t)}catch(i){console.warn(i)}}_notifyUsedRangeChange(){this._lastCellRead.coords=null,this._lastUsedCoordsRead.coords=null,this._emitter.notify("onUsedRangeChange")}_notifyMergeChange(){this._emitter.notify("onMergesChange")}addListeners(e,t){let n=null;if(e.onLayoutChange){const o=e,i={onSizesChange:()=>{o.onLayoutChange(this)}};n=[],n.push(this._colHeaders.addListeners(i,t)),n.push(this._rowHeaders.addListeners(i,t))}let r=this._emitter.addListeners(e,t);if(n){const o=r;r=()=>{const i=n.length;for(let a=0;a<i;a++)n[a]();o()}}return r}_addRangesListeners(e,t,n){if(this._closed)throw new Error(ft);if(!t)throw new Error(Bu);n=n?{...Ps,...n}:Ps;const r=n?.transactional??!1,o=this,i=My++%Number.MAX_SAFE_INTEGER,a=()=>{let f=null,_=null;if(r){const y=o._getState();if(!y)return;f=y.rangeListenerSpatial.clone(),_=new Map(y.rangesListenerMap)}else f=o._rangeListenerSpatial,_=o._rangesListenerMap;const p=_.get(i);if(!p)return void console.log("Listener not found");const S=p.ranges,C=S.length;for(let y=0;y<C;y++){const b=k.sanitizeRange(S[y]);b!==null&&f.remove(b,(w,E)=>{if(E.value.id===i)return!0})}if(_.delete(i),r){const y=this._beginCommit({description:"Remove Range Listener"});this._updateState({rangeListenerSpatial:f,rangesListenerMap:_}),y.commit({forceAmend:!0})}},l=[...e];let c={id:i,handler:null,handlerW:null,removeListener:a,options:n,ranges:l};n?.weakly?c.handlerW=new WeakRef(t):c.handler=t;let h=null,u=null,d=null;if(r){d=this._beginCommit({description:"Add Range Listener"});const f=this._getState();h=f.rangeListenerSpatial.clone(),u=new Map(f.rangesListenerMap)}else h=o._rangeListenerSpatial,u=o._rangesListenerMap;const g=[],m=e.length;for(let f=0;f<m;f++){const _={...e[f],value:{id:i,offset:f,options:n}};g.push(_)}return h.load(g),u.set(i,c),d&&(this._updateState({rangeListenerSpatial:h,rangesListenerMap:u}),d.commit({forceAmend:!0})),a}_addRangesListeners2(e,t,n,r){if(this._closed)throw new Error(ft);if(!t)throw new Error(Bu);n=n?{...Ps,...n}:Ps;const o=n?.transactional??!1,i=this,a=N.uuidV4(),l=Ty++,c=()=>{let b=null,w=null;const E=i._getState();if(!E)return;b=E.rangesListenerSpatial2.clone(),w=E.rangesListenerMap2;const I=w.get(a);if(I){const v=I?.spatialsIds,R=I?.coords,A=v.length;for(let M=0;M<A;M++){const T=v[M],F=R[M];b.remove(F,(L,D)=>{if(D.value.uuid===T)return!0})}w=new Map(E.rangesListenerMap2),w.delete(a)}const x=this._beginCommit({description:"Remove Range Listener"});this._updateState({rangesListenerMap2:w}),x.commit({forceAmend:!0}),o||this._rangesListenerSorted.delete(l)};let h=null,u=this._beginCommit({description:"Add Range Listener"});const d=this._getState();h=d.rangesListenerSpatial2.clone();let g=null,m=null;n?.weakly?m=new WeakRef(t):g=t;const f=[],_=[...e];let p=[];const S=e.length;for(let b=0;b<S;b++){const w={...e[b]};_[b]=w;const E=N.uuidV4(),I=new Wi(a,E,n?.ignoreAddressChanges??!1);p.push(E);const x={...k.sanitizeRange(w),value:I};f.push(x)}h.load(f),n={...n};const C=new ji(a,p,_,r,this,l,g,m,c,n),y=new Map(d.rangesListenerMap2);return y.set(a,C),this._updateState({rangesListenerSpatial2:h,rangesListenerMap2:y}),o||this._rangesListenerSorted.set(l,C),u.commit({forceAmend:!0}),c}_getUsedCoords(e){const t=this._getState();if(!t)return null;let n=t.cellValuesGrid.getCoords();return n=k.unionRanges(t.mergeSpatial.getBoundingCoords(),n),n=k.unionRanges(t.directStyleSpatial.getBoundingCoords(),n),n=k.unionRanges(t.formulaSpatial.getBoundingCoords(),n),n=k.unionRanges(t.spillSpatial.getBoundingCoords(),n),n=k.unionRanges(t.pendingSpatial.getBoundingCoords(),n),n&&(n.colStart=Math.max(n.colStart,this._entireCoords.colStart),n.rowStart=Math.max(n.rowStart,this._entireCoords.rowStart),n.colEnd=Math.min(n.colEnd,this._entireCoords.colEnd),n.rowEnd=Math.min(n.rowEnd,this._entireCoords.rowEnd)),!n||n.rowStart>n.rowEnd||n.colStart>n.colEnd?(this._lastUsedCoordsRead.coords=null,null):(this._lastUsedCoordsRead&&this._lastUsedCoordsRead.coords&&Oo(this._lastUsedCoordsRead.coords,n)||(this._lastUsedCoordsRead.coords=n,this._lastUsedCoordsRead.range=null),this._lastUsedCoordsRead.coords)}_isContentful(e,t){return!!this._contentCounts(e,void 0,t)}_getCount(e,t=!1){const n=this._contentCounts(e,ky,t);return n?n[exports.ICell.Content.Values]??0:0}_contentCounts(e,t,n){if(!t){const u=Object.keys(exports.ICell.Content),d=u.length;t=new Array(d);for(let g=0;g<d;g++){const m=u[g];t[g]=exports.ICell.Content[m]}}const r={},o=t.length;let i,a,l=!1;for(let u=0;u<o;u++){const d=t[u];d===exports.ICell.Content.Values?(r[X.Type.Contentful]=!1,r[X.Type.Table]=!1):d===exports.ICell.Content.Formulas?r[X.Type.Formula]=!1:d===exports.ICell.Content.Formats?r[X.Type.Style]=!1:d===exports.ICell.Content.Tables&&(r[X.Type.Table]=!1,l=!0)}const c=()=>{i=new Set,a={};for(let u=0;u<o;u++){const d=t[u];a[d]=0}},h=e.length;for(let u=0;u<h;u++){const d=e[u],g=this._rangeStateIterator({includeRangeTypes:r,excludeHidden:n,bounds:d});let m=g.next();for(;!m.done;){a||c();const f=m.value,_=(f.end.colIndex-f.start.colIndex+1)*(f.end.rowIndex-f.start.rowIndex+1),p=f.intersection;if(p){p.contentful&&(a[exports.ICell.Content.Values]+=_),p.formula&&(a[exports.ICell.Content.Formulas]+=_);const S=p.table;S&&(l&&!i.has(S)&&(a[exports.ICell.Content.Tables]+=1,i.add(S)),p.contentful||(a[exports.ICell.Content.Values]+=_))}m=g.next()}}return a}getSelectedCell(){const e=this.getSelection().getCoords().cell,t=this._lastCellSelected;if(t?.cell&&k.isEqualCells(e,t.coords))return t.cell;const n=this.getRange(e).getCell();return this._lastCellSelected={coords:e,cell:n},n}find(e,t){return this.getEntireRange().find(e,t)}_find(e,t,n){if(this._closed)throw new Error(ft);if(!t)return null;const r=[...e],o=n?.orientation??exports.w.Orientation.Row,i=n?.reverse,a=!n?.disableWrap,l=n?.from?this._cellToCoords(n?.from):null;let c=null;if(l){let E=-1;for(let T=0;E===-1&&T<r.length;T++)k.isCellWithinRange(l,r[T])&&(E=T);c=k.cellToRange(l);let I=jl(r[E],c,o);I.push(c);const x=k.createRangeComparator(o,i);I.sort(x);let v=-1;const R=I.length;for(let T=0;T<R;T++)x(I[T],c)<=0&&(v=T);r.splice(E,1,...I);const A=E+v,M=[];for(let T=0;T<=A;T++)M.push(r.shift());if(a){const T=M.length;for(let F=0;F<T;F++)r.push(M[F])}}if(r.length===0)return qe;const h=n?.fields?.includes(exports.ICell.Content.Formulas)??!1,u=n?.fields?.includes(exports.ICell.Content.Values)??!0,d=n?.matchEntireCell??!1,g=n?.matchCase??!1,m=n?.useRegex??!1,f=((E,I,x)=>{const v=I?"":"i";return x?new RegExp(E,v):new RegExp((R=>{let A=R.replace(/[|\\{}()[\]^$+.]/g,"\\$&");return A=A.replace(/~\?/g,"\\?"),A=A.replace(/~\*/g,"\\*"),A=A.replace(/~~/g,"~"),A})(E),v)})(t,g,m),_=t.length;let p=(E,I)=>{const x=A=>{if(!A)return!1;let M=!!A.match(f);return M&&d&&A.length!==_&&(M=!1),M},v=I.getCell();let R=!1;return!R&&h?R=x(v.getFormulaText()??v.toTextUnformatted(!0)):u&&(R=x(v.getNumberFormat().displayText)),R};if(n?.matchCustom){const E=n.matchCustom,I={matchCase:g,matchEntireCell:d,useRegex:m,fields:n?.fields??[exports.ICell.Content.Formulas]};let x,v,R=p;const A=()=>R(x,v);p=(M,T)=>(x=M,v=T,E(M,A,I,T))}let S=-1,C=null,y=Re,b=!1;const w=()=>{if(y.done){if(S++,S>=r.length)return void(b=!0);C=this._cellIterator({reverse:i,orientation:o,includeRangeTypes:!1,bounds:r[S]})}if(y=C.next(),!y.done){const E=y.value;return p(E.value,E.context)}return!1};return{next:()=>{let E=null;for(;!b&&!E;)w()&&(E=y.value.context.getCell());return E?{value:E,done:!1}:Re}}}isDate1904(){return this._isDate1904}_surroundingRegion(e,t){const n=this._getState(),r=t?.contentOnly??!1,o=this._entireCoords;if(!r){const l=n.tableSpatial.search(e);if(l.length>0){const c=l[0].value.model,h=c.getUsedRange().getCoords(),u=c.getRange().getCoords();return k.isEqualRanges(h,e)?u:k.isEqualRanges(u,e)?o:h}}const i=r?e:o;return((l,c,h=2e4)=>{if(!c||c.length===0)return null;let u,d=!1;for(let b=0;b<c.length;b++){const w=c[b];u=k.unionRanges(u,w.getBoundingCoords()),d=d||w.search(l).length>0}if(!u)return null;const g={...k.EmptyRange},m=l;let f=d?{...l}:null;if(!f){const b=I=>{let x=[];const v=c.length;for(let R=0;R<v;R++){const A=c[R].search(I),M=A.length;x=M>0?new Array(M):void 0;for(let T=0;T<M;T++){const F=A[T];x[T]=F}}return x||N.EmptyArray},w=b({colStart:l.colEnd,rowStart:l.rowEnd,colEnd:l.colEnd+1,rowEnd:l.rowEnd+1}),E=w.length;if(E>0){f={...l};for(let I=0;I<E;I++){const x=w[I];f.colEnd=Math.max(f.colEnd,x.colStart),f.rowEnd=Math.max(f.rowEnd,x.rowStart)}}}const _={...k.EmptyRange},p=()=>{const b=c.length;for(let w=0;w<b;w++){const E=c[w].search(g),I=E.length;for(let x=0;x<I;x++){const v=E[x];f=k.unionRanges(f,v,_)}}return f};g.colStart=l.colStart,g.rowStart=l.rowStart,g.colEnd=l.colEnd,g.rowEnd=l.rowEnd,p();const S={...f},C={...k.EmptyRange};let y=0;do{if(g.colStart=C.colStart=S.colStart,g.rowStart=C.rowStart=S.rowStart,g.colEnd=C.colEnd=S.colEnd,g.rowEnd=C.rowEnd=S.rowEnd,S.colStart>u.colStart&&(g.colStart=S.colStart-1,g.colEnd=S.colStart-1,g.rowStart=S.rowStart-1,g.rowEnd=S.rowEnd+1,p()),S.rowStart>u.rowStart&&(g.rowStart=S.rowStart-1,g.rowEnd=S.rowStart-1,g.colStart=S.colStart-1,g.colEnd=S.colEnd+1,p()),S.colEnd<u.colEnd&&(g.colStart=S.colEnd+1,g.colEnd=S.colEnd+1,g.rowStart=S.rowStart-1,g.rowEnd=S.rowEnd+1,p()),S.rowEnd<u.rowEnd&&(g.rowStart=S.rowEnd+1,g.rowEnd=S.rowEnd+1,g.colStart=S.colStart-1,g.colEnd=S.colEnd+1,p()),!f)return null;if(S.colStart=f.colStart,S.rowStart=f.rowStart,S.colEnd=f.colEnd,S.rowEnd=f.rowEnd,k.isEqualRanges(S,C))return k.isEqualRanges(m,S)?null:S;if(k.isEqualRanges(S,m))return null;if(k.isEqualRanges(S,C))return S;y++}while(y<h);return null})(e,[n.contentfulSpatial,n.mergeSpatial,n.formulaSpatial,n.spillSpatial,n.pendingSpatial])||i}_extendRange(e,t){if(this._closed)throw new Error(ft);const n=this._entireCoords,r=this,o={excludeHidden:!0,onEntry:(h,u)=>u},i={excludeHidden:!0,onEntry:(h,u)=>h.tvTl()===void 0?null:u};let a;const l=r._getRangedEntries("mergeSpatial",[k.cellToRange(t)],i);l.length>0&&(a=l[0]);const c=[h=>r._getRangedEntries("mergeSpatial",h,i),h=>r._getRangedEntries("contentfulSpatial",h,o)];return((h,u,d,g,m)=>{let f,_,p,S={...u},C=k.cellToRange(S),y=g(C).length>0;if(y){let w=1,E=h===exports.w.Direction.Up||h===exports.w.Direction.Down;d&&(w+=E?d.rowEnd-d.rowStart:d.colEnd-d.colStart),h!==exports.w.Direction.Left&&h!==exports.w.Direction.Up||(w=-w),E?S.rowIndex=S.rowIndex+w:S.colIndex=S.colIndex+w,C=k.cellToRange(S),y=g(C).length>0}switch(h){case exports.w.Direction.Up:C.rowStart=Math.min(m.rowStart,C.rowStart),_=g(C).sort(k.createRangeComparator(exports.w.Orientation.Row,!0)),f=u.rowIndex,p=y?_.length===1&&f===_[0].rowStart?m.rowStart:_[0].rowStart:_.length===0?m.rowStart:_[0].rowEnd;break;case exports.w.Direction.Down:C.rowEnd=Math.max(m.rowEnd,C.rowEnd),_=g(C).sort(k.createRangeComparator(exports.w.Orientation.Row,!1)),f=u.rowIndex,p=y?_.length===1&&f===_[0].rowEnd?m.rowEnd:_[0].rowEnd:_.length===0?m.rowEnd:_[0].rowStart;break;case exports.w.Direction.Left:C.colStart=Math.min(m.colStart,C.colStart),_=g(C).sort(k.createRangeComparator(exports.w.Orientation.Column,!0)),f=u.colIndex,p=y?_.length===1&&f===_[0].colStart?m.colStart:_[0].colStart:_.length===0?m.colStart:_[0].colEnd;break;case exports.w.Direction.Right:C.colEnd=Math.max(m.colEnd,C.colEnd),_=g(C).sort(k.createRangeComparator(exports.w.Orientation.Column,!1)),f=u.colIndex,p=y?_.length===1&&f===_[0].colEnd?m.colEnd:_[0].colEnd:_.length===0?m.colEnd:_[0].colStart}if(y&&_.length>1){let w=!1;for(let E=1;!w&&E<_.length;E++){const I=_[E];switch(h){case exports.w.Direction.Up:I.rowEnd<p-1?w=!0:p=Math.min(p,I.rowStart);break;case exports.w.Direction.Down:I.rowStart>p+1?w=!0:p=Math.max(p,I.rowEnd);break;case exports.w.Direction.Left:I.colEnd<p-1?w=!0:p=Math.min(p,I.colStart);break;case exports.w.Direction.Right:I.colStart>p+1?w=!0:p=Math.max(p,I.colEnd)}}}const b=k.cellToRange(u);switch(h){case exports.w.Direction.Up:b.rowStart=p;break;case exports.w.Direction.Down:b.rowEnd=p;break;case exports.w.Direction.Left:b.colStart=p;break;case exports.w.Direction.Right:b.colEnd=p}return b})(e,t,a,h=>{const u=[],d=[h],g=c.length;for(let m=0;m<g;m++){const f=(0,c[m])(d),_=f.length;for(let p=0;p<_;p++){const S=f[p];u.push(S)}}return u},n)}_defaultFontDims(){if(this._defaultFontBoundsCache)return this._defaultFontBoundsCache;const e=this._styles.getNormal();let t=0,n=0;for(let r=0;r<=9;r++){const o=e.measureText(r.toString());t=Math.ceil(Math.max(o.width,t)),n=Math.max(o.lineHeight,n)}return this._defaultFontBoundsCache={width:t,height:n},this._defaultFontBoundsCache}getColumnWidthAsFontUnit(e){const t=Math.round(this._defaultFontDims().width),n=e/(this.getView().isShowFormulas()?2:1);if(!t||!e)return 0;let r=5;return n<r+t&&(r=n*(r/(r+t))),(n-r)/t}_defaultColWidth(){if(this._defaultColWidthCache)return this._defaultColWidthCache;const e=this._defaultFontDims()?.width||7,t=8*Math.round((8*e+5)/8);return this._defaultColWidthCache=t}_defaultRowHeight(){if(this._defaultRowHeightCache)return this._defaultRowHeightCache;let e=this._defaultFontDims();if(!e||e.width===0)return this._defaultRowHeightCache=20/exports.IFont.getDeviceScale(),this._defaultRowHeightCache;const t=this._styles.getNormal(),n=new Map;let r=e.height+2;return this._colHeaders.getUsedRange().forEachSpan((o,i)=>{const a=i.getCellHeader();a?.getStyle()!==t&&(r=Math.max((l=>{let c=n.get(l);return c===void 0&&(c=l.measureText("M").lineHeight+2,n.set(l,c)),c})(a.getStyle()),r))}),this._defaultRowHeightCache=Math.round(r/exports.IFont.getDeviceScale()*4)/4,this._defaultRowHeightCache}getProtection(){return this._protection??null}async _selectSheet(e,t){if(await this._options.container?.requestSelect?.()===!1)return!1;if(t===!1)return!0;const n={coords:e};t!==!0&&t!==void 0&&(n.scrollIntoView=t);const r=await this._emitter.notify("onRequestScrollIntoView",{params:n,async:!0});if(!r)return!1;const o=r.length;for(let i=0;i<o;i++)if(r[i]===!1)return!1;return!0}async scrollTo(e,t){const n={...t,coords:e},r=await this._emitter.notify("onRequestScrollIntoView",{params:n,async:!0});if(!r)return!1;const o=r.length;for(let i=0;i<o;i++)if(r[i]===!1)return!1}async _commitAndAutoSelect(e,t,n=!1,r){return r={...r,viewAfter:{view:this.getView(),selection:t,selectOptions:n,...r?.viewAfter}},e.commit(r),this._autoSelect(n,t)}async _autoSelect(e,t){if(!e)return;e===!0&&(e={autoFocus:!0,scrollIntoView:!0});const n=e?.autoFocus,r=e?.scrollIntoView,o=e?.anchor,i=this.getSelection().getCoords(),a=Rr(t??i),l=this._entireCoords,c=((f,_,p)=>{if(!f||f.length===0||!_)return N.EmptyArray;const S=[...f];for(let C=0;C<S.length;C++){const y={...S[C]};let b=y;const w=_.search(y),E=y.rowStart<=p.rowStart&&y.rowEnd>=p.rowEnd,I=y.colStart<=p.colStart&&y.colStart>=p.colEnd;for(let x=0;x<w.length;x++){const v=w[x];E||(b.colStart=Math.min(b.colStart,v.colStart),b.colEnd=Math.max(b.colEnd,v.colEnd)),I||(b.rowStart=Math.min(b.rowStart,v.rowStart),b.rowEnd=Math.max(b.rowEnd,v.rowEnd))}S[C]=b}return S})(a,this._getState().mergeSpatial,l);let h=-1,u=null;if(!o){const f=i?.cell;for(let _=0;h===-1&&_<c.length;_++){const p=c[_];k.isCellWithinRange(f,p)&&(h=_,u=f)}}const d=co(c,u,h);this.getSelection().updateCoords(d);const g=d.ranges?.[d.rangeIndex]??k.cellToRange(d.cell),m=await this._selectSheet(g,r);if(r!==!1&&m===!1)return c;if(n!==!1){const f=await this._emitter.notify("onRequestFocus");if(!f)return c;const _=f.length;for(let p=0;p<_;p++)if(f[p]===!1)return c}return c}getSelection(){return this._rangeSelection}getView(){return this._view}setView(e){if(this._closed)throw new Error(ft);if(!e)throw new Error("View can not be empty.");this._viewRemoveListener?.(),this._view=e,this._viewRemoveListener=e.addListeners(this._viewListener,{transactional:!1});const t=this.getSelection().getCoords();return this._rangeSelection.updateCoords(t),this._emitter.notify("onMovableSelectionChange"),this._emitter.notify("onTopLeftChange"),this._emitter.notify("onFreezeSplitChange"),this._emitter.notify("onViewChange",{source:e}),this}getTabColor(){return this._tabColor}setTabColor(e){if(this._closed)throw new Error(ft);return this._tabColor=typeof e=="string"?this._styles.parseColor(e):e??null,this._emitter.notify("onTabColorChange"),this}getRowHeaders(){return this._rowHeaders}getColumnHeaders(){return this._colHeaders}async toJSON(e=!1){if(this._closed)throw new Error(ft);await this._emitter.notify("onBeforeSave",{async:!0}),await Promise.resolve(this._starting);let t={};const n=this._getState();if(!n)return t;try{const _=this._strings.beginPersist();try{if(!e){const b=[],w=this._cellStateIterator({includeRangeTypes:!1,orientation:exports.w.Orientation.Column});let E=w.next(),I=Number.MIN_SAFE_INTEGER,x=Number.MIN_SAFE_INTEGER,v=null,R=null,A=null,M=null;for(;!E.done;){const T=E.value[0],F=T.colIndex,L=T.rowIndex;F!==I&&(M&&b.push(M),v=[],A=[],M=[F,A],I=F,x=L-2),L>x+1&&(v=[],R=[L,v],A.push(R));const D=E.value[1],P=Ye(D);let B;if(P===U.Number||P===U.Boolean)B=D;else if(P===U.String)B=""+_.add(D);else if(P===U.Error)B={t:P,v:D.getCode()};else if(P===U.RichData){const z=D,O=z.type,W=z?.toJSON?.();O&&W&&(B={t:P,v:0})}else console.warn("error",B);v.push(B),x=L,E=w.next()}M&&b.push(M),b.length>0&&(t.data=b)}this._ownStrings&&(t.strings=await _.toJSONAsync())}catch(b){console.warn("error",b)}finally{_.endPersist()}const p=this._colHeaders.toJSON();p&&(p.headers&&p.headers.length>0&&(t.cols=p.headers),p.defaultSize!==void 0&&p.defaultSize!==-1&&(t.defaultColSize=p.defaultSize));const S=this._rowHeaders.toJSON();S&&(S.headers&&S.headers.length>0&&(t.rows=S.headers),S.defaultSize!==void 0&&S.defaultSize!==-1&&(t.defaultRowSize=S.defaultSize));const C=this.getProtection().toJSON();C&&(t.protection=C),this._view.setRangeSelection(this.getSelection().getCoords());const y=this._view.toJSON();y&&(t.view=y),this._tabColor&&(t.tabColor=this._tabColor.toString())}catch(_){console.warn(_)}const r=Fn(n.mergeSpatial.all());r.length>0&&(t.merges=Sc(r));const o=Fn(n.directStyleSpatial.all());if(o.length>0){const _=this._styles.beginPersist();try{const p=[],S=o.length;for(let C=0;C<S;C++){const y=o[C],b=_.getElementID(y.value.toJSON());p.push({r:exports.AddressUtils.rangeToString(y),v:b})}if(t.directStyles=p,this._ownStyles){const C=_.toJSON();C&&Object.keys(C).length>0&&(t.styles=C)}}catch(p){console.warn(p)}finally{_.endPersist()}}const i=Fn(n.hyperlinkSpatial.all()),a=i.length;if(a>0){const _=[];for(let p=0;p<a;p++){const S=i[p];let C=S.value;_.push({r:exports.AddressUtils.rangeToString(S),v:C})}t.hyperlinks=_}const l=Fn(n.commentsSpatial.all()),c=l.length;if(c>0){const _=[];for(let p=0;p<c;p++){const S=l[p],C={...S.value};C.ref=exports.AddressUtils.rangeToString(S),_.push(C)}t.comments=_}const h=this._resources.beginPersist();try{const _=this.getMovables().search(),p=_.length;if(p>0){const S=[];for(let C=0;C<p;C++)try{const y=_[C].toJSON(h.toResourceId.bind(h));y&&S.push(y)}catch(y){console.warn("Unable to persist movable",y)}S.length>0&&(t.movables=S)}this._ownResources&&(t.resources=await h.toJSONAsync())}catch(_){console.warn(_)}finally{h.endPersist()}const u=Fn(n.tableSpatial.all()),d=u.length;if(d>0){const _=[];for(let p=0;p<d;p++){const S=u[p].value.model.toJSON();_.push(S)}t.tables=_}const g=Array.from(n.conditionalModels.values()),m=g.length;if(m>0){const _=[];for(let p=0;p<m;p++){const S=g[p].model.toJSON();_.push(S)}t.conditionals=_}const f=await n.calcGraph.toJSON(!1);if(f){const _=f.formulas;_&&(t.formulas=_);const p=f.dynamic;p&&(t.dynamicArray=p);const S=f.volatile;S&&(t.volatile=S)}return this._emitter.notify("onSave",{params:t}),t}getStyles(){return this._styles}getResources(){return this._resources}getTransactions(){return this._transactions}getStrings(){return this._strings}_searchMovables(e){const t=e?.excludeHidden??!1,n=e?.bounds,r=e?.fullyContained,o=this,i=e?.address?this._rangeToCoords(e?.address):this._entireCoords;return this._getRangedEntries("movableSpatial",[i],{excludeHidden:t,fullyContained:r,onEntry:c=>{if(e?.type&&c.model.getContent().getType()!==e.type)return null;let h=null;if(t&&(c.model.isHidden()||(h=o._getBoundsAtCoords(c.model.getAnchorCoords()),h.width===0||h.height===0)))return null;if(n){h||(h=o._getBoundsAtCoords(c.model.getAnchorCoords()));const u=h,d=n;if(u.y>d.y+d.height||u.y+u.height<d.y||u.x>d.x+d.width||u.x+u.width<d.x)return null}return c.model}}).sort((c,h)=>c.getZIndex()-h.getZIndex())}_updateSelectedMovables(e,t){const n=this.getView().getMovableSelection();if(!n||n.length===0)return;let r="Movables";if(n.length===1){const i=n[0];r=zr(i.getContent().getType())??"Drawing"}const o=this._beginCommit({description:`${t} ${r}`});try{const i=n.length;for(let a=0;a<i;a++)e(n[a]);o.commit()}catch(i){throw o.rollback(),i}}async _addMovable(e){if(!this.getProtection().isObjectsAllowed())throw new Error(Du);if(!e)throw new Error("No movable options provided");if(this._closed)throw new Error(ft);const t={};e?.type&&(t.content={type:e.type,json:e?.json}),e?.anchorType&&(t.anchorType=e?.anchorType),e.bounds&&(t.anchor=null);const n=this._getState().movableSpatial,r=this._beginCommit({description:e?.description??"Insert Drawing"}),o=this._createMovableEntry(t,n.size(),e.fromResourceId),i=n.clone();i.insert(o);const a=this._getState().movableMapModel,l=new Map(a),c=o.value.model;l.set(c,o),this._updateState({movableSpatial:i,movableMapModel:l}),e.bounds&&o.value.model.setBounds(e.bounds,e);let h=null,u=null;if(e?.autoSelect!==!1){h={view:this.getView(),movableSelection:this.getView().getMovableSelection()};let d=e?.autoSelect??!1;d===!0&&(d={autoFocus:!0,scrollIntoView:!0,addToSelection:!1}),d&&this.getView().selectMovables([o.value.model],d.addToSelection),u=g=>({...g,view:this.getView(),movableSelection:this.getView().getMovableSelection()})}return r.commit({viewBefore:h,viewAfter:u}),this._emitterMovables.notify("onCollectionChange"),this._emitter.notify("onMovablesChange"),o.value.model}async _addImage(e,t={type:"picture"}){if(!e)throw new Error("An image must be provided as a string or a resource option.");if(!this.getProtection().isObjectsAllowed())throw new Error(Du);const n=this._resources.add(e),r=await n.toBuffer(),o=await n.getType(),i=this._getBoundsAtCoords(Rr(this.getSelection().getCoords())[0]),{naturalDimensions:a,asUrl:l}=await Bo.loadImageDetails(r,o);URL.revokeObjectURL(l);const c={...i,...a,...t?.bounds};if(N.isNullOrUndefined(t?.bounds?.x)||N.isNullOrUndefined(t?.bounds?.y)){const u=Ld(this.getMovables(),c,N.isNullOrUndefined(t?.bounds?.x),N.isNullOrUndefined(t?.bounds?.y));c.x+=u.x,c.y+=u.y}t?.bounds&&t?.json?.lockAspect!==!1&&(N.isNullOrUndefined(t?.bounds.width)&&N.isDefined(t?.bounds.height)&&(c.width=c.height*a.width/a.height),N.isNullOrUndefined(t?.bounds.height)&&N.isDefined(t?.bounds.width)&&(c.height=c.width*a.height/a.width));const h={...t?.json,resId:0};return await this._addMovable({anchorType:exports.IAnchored.Type.OneCell,description:"Insert Image",...t,bounds:c,type:"picture",json:h,fromResourceId:u=>u!==0?(console.warn("received an unexpected resourceId",u),null):n})}getTables(){return this._tables}getConditionals(){return this._conditionals}getMovables(){return this._movables}_doPerfTest(e=1e7,t=!1){const n=Array.from({length:e},(l,c)=>c);let r,o;r=performance.now(),t&&console.profile("nativeArray");const i=[e];for(let l=0;l<e;l++)i.push(l);t&&console.profileEnd("nativeArray"),window.noLoseArray=i,o=performance.now(),console.log(`NativeArray: ${e} records in ${o-r} milliseconds`),r=performance.now(),t&&console.profile("mixedType");const a=Ai.fromArray(n);t&&console.profileEnd("mixedType"),window.noLoseList=a,o=performance.now(),console.log(`MixedTypedList: ${e} records in ${o-r} milliseconds`)}_validateOrRemoveOverlaps(e,t,n=null,r=!1){const o=this;t!=="merge"&&vu(this._getMerges([e]),e,(c,h)=>{if(h||!r)throw new Error(Lu(t));o._unmerge([c])});const i=[],a=this.getTables().search({address:e}),l=a.length;for(let c=0;c<l;c++){const h=a[c];n!==h&&i.push(h.getAnchorCoords())}vu(i,e,(c,h,u)=>{if(h||!r)throw new Error(Lu(t));a[u].delete()})}_addTable(e,t){let n=this._rangeToCoords(e,()=>["objects"]);const r=this._entireCoords;let o=t?.hasHeader;if(n.rowStart===n.rowEnd){if(n.rowEnd===r.rowEnd)throw new Error("A table must have a least two rows; one for the table header and one for data.");n.rowEnd=n.rowEnd+1}o===void 0&&(o=dd(this,n)?.options?.hasHeader??!1);const i=Be([n]),a={...n},l=this._beginCommit({description:"Insert Table"});let c=null;try{o||(this._isContentful([n])&&this._insertCells([{...n,rowStart:n.rowStart,rowEnd:n.rowStart}],exports.w.Orientation.Row),n={...n,rowEnd:n.rowEnd+1});const h={...t?.json,ref:n};this._validateOrRemoveOverlaps(n,"table",null,!0),h.styleOptions=t?.json?.styleOptions??{},h.styleOptions.name===void 0&&(t?.styleName?h.styleOptions.name=t.styleName:t?.styleName===void 0&&(h.styleOptions.name=this._styles.getDefaultTableStyle().getName()));const u=t?.isLoad;u!==!0&&(h.filter===void 0&&(h.filter={}),h.sort===void 0&&(h.sort={}));const d=this._createTableEntry(h,o&&!u),g=this._getState(),m=g.tableSpatial.clone();m.insert(d);const f=g.tableMapModel,_=new Map(f),p=d.value.model;_.set(p,d);const S=g.tableMapName,C=new Map(S);C.set(p.getName().toLocaleLowerCase(),p),t?.clearFormatting&&this.getRange(n).updateStyle(null),c=d.value.model,this._updateState({tableSpatial:m,tableMapModel:_,tableMapName:C}),this._emitter.notify("onTablesChange"),u||this._autoFit([c.getHeaderRange().getCoords()],{expandOnly:!0});const y=Be([n]);l.commit({viewBefore:{view:this.getView(),selection:i,ranges:[a]},viewAfter:{view:this.getView(),selection:y,ranges:[n]}})}catch(h){throw l.rollback(),h}return c}_addConditional(e,t){const n=this._rangesToCoords(e,()=>["objects"]),r=t?.autoSelect?Be(n):null,o=[...n],i=this._beginCommit({description:t?.description??"Insert Conditional"});let a=null;try{const l={...t,ref:o},c=this._getState(),h=c.conditionalSpatial.clone(),u=new Map(c.conditionalModels),d=this._createConditionalEntries(l,h,u);this._updateState({conditionalSpatial:h,conditionalModels:u}),a=d,i.commit({viewBefore:{view:this.getView(),selection:r,ranges:o},viewAfter:{view:this.getView(),selection:r,ranges:o}}),this._autoSelect(t?.autoSelect,r)}catch(l){throw i.rollback(),l}return a}createTemporaryCell(e,t=null){return e?.createTemporaryCell?e:(t?this.getRange(t).getCell():this._emptyCell).createTemporaryCell(e)}_getBoundsAtCoords(e){const t=this._rowHeaders,n=this._colHeaders,r=n.findOffset(e.colStart),o=t.findOffset(e.rowStart);return{x:r,y:o,width:n.findOffset(e.colEnd+1)-r,height:t.findOffset(e.rowEnd+1)-o}}_getCoordsAtBounds(e){const t=this._rowHeaders,n=this._colHeaders;return{colStart:n.findIndex(e.x),rowStart:t.findIndex(e.y),colEnd:n.findIndex(e.x+e.width),rowEnd:t.findIndex(e.y+e.height)}}getRangeAtBounds(e,t){if(!e)throw new Ot;const n=this._getCoordsAtBounds(e);return this.getRange(n,t)}_getVisible(e,t){if(e.length===0)return e;const n=new be;n.load(e);const r=t?.orientations??exports.w.Orientations.Both,o=(a,l)=>{const c=n.search(a),h=c.length;for(let u=0;u<h;u++){const d=c[u],g=jl(d,a,l);n.remove(d),n.load(g)}},i=this._cellOptions.maxCoords;if(r===exports.w.Orientations.Both||r===exports.w.Orientations.Row){const a=this._rowHeaders,l=e.length;for(let c=0;c<l;c++){const h=e[c];a.getRange({min:h.rowStart,max:h.rowEnd}).forEachSpan((u,d)=>{if(u!==0)return;const g=d.getCoords();o({colStart:i.colStart,rowStart:g.min,colEnd:i.colEnd,rowEnd:g.max},exports.w.Orientation.Row)})}}if(r===exports.w.Orientations.Both||r===exports.w.Orientations.Column){const a=this._colHeaders,l=e.length;for(let c=0;c<l;c++){const h=e[c];a.getRange({min:h.colStart,max:h.colEnd}).forEachSpan((u,d)=>{if(u!==0)return;const g=d.getCoords();o({colStart:g.min,rowStart:i.rowStart,colEnd:g.max,rowEnd:i.rowEnd},exports.w.Orientation.Column)})}}return n.all()}_hasRangedEntries(e,t){const n=this._getState();if(!n)return N.EmptyArray;const r=n[e];if(!r)throw new Error(`Invalid range key ${e}`);return!(!r||r.isEmpty())&&r.has(t)}_getRangedEntries(e,t,n){if(t.length===0)return N.EmptyArray;const r=n?.excludeHidden??!1,o=n?.fullyContained??!1,i=n?.onEntry??null,a=this._getState();if(!a)return N.EmptyArray;const l=a[e];if(!l)throw new Error(`Invalid range key ${e}`);if(!l||l.isEmpty())return N.EmptyArray;const c=new Set,h=_=>{const p=_.length;for(let S=0;S<p;S++){const C=_[S];c.add(C)}},u=t.length;for(let _=0;_<u;_++){const p=t[_];if(r){if(r===!0){const S={min:p.colStart,max:p.colEnd},C={min:p.rowStart,max:p.rowEnd};this._rowHeaders.getRange(C).forEachVisibleSpan((y,b)=>{this._colHeaders.getRange(S).forEachVisibleSpan((w,E)=>{h(l.search({colStart:w,rowStart:y,colEnd:E,rowEnd:b},o))},Ls)},Ls)}else if(r===exports.w.Orientation.Column){const S={min:p.colStart,max:p.colEnd};this._colHeaders.getRange(S).forEachVisibleSpan((C,y)=>{h(l.search({colStart:C,rowStart:p.rowStart,colEnd:y,rowEnd:p.rowEnd},o))},Ls)}else if(r===exports.w.Orientation.Row){const S={min:p.rowStart,max:p.rowEnd};this._rowHeaders.getRange(S).forEachVisibleSpan((C,y)=>{h(l.search({colStart:p.colStart,rowStart:C,colEnd:p.colEnd,rowEnd:y},o))},Ls)}}else h(l.search(p,o))}if(c.size===0)return N.EmptyArray;const d=Array.from(c.values()),g=n?.sort;g&&d.sort(k.createRangeComparator(g.orientation,g.reverse));let m=[];const f=d.length;for(let _=0;_<f;_++){let p;p=void 0,i&&(p=i(d[_].value,d[_])),p===void 0&&(p=d[_].value),p!==null&&m.push(p)}return m||(m=N.EmptyArray),m}_processAnchorShift(e){let t=e.after;const n=k.sanitizeRange(e.after),r=k.sanitizeRange(e.before);e.after&&this._validateCoords(n,"We can't insert cells because this would push items off the end of the worksheet.");const o=e.before.value.processShiftCallback?.({...e,after:n,before:r});return o&&(Oo(o,n)||(t||(t=e.before),t={...t,...o})),t}_processListenerShift(e,t,n,r){if(r.isSplit||r.before.value.options.ignoreShifts)return[r.before];let o=null;r.after&&(o=k.intersectRanges(k.sanitizeRange(r.after),this._entireCoords),r.after,o.colStart,o.rowStart,o.colEnd,o.rowEnd);const i=r.before.value,a=i.id,l=e.get(a),c={...l},h=[...l.ranges];c.ranges=h,h[i.offset]=o?{...h[i.offset],...o}:null,e.set(a,c);const u=n.get(a);t.set(a,{beforeState:u,afterState:c})}delete(){if(this._closed)return;try{this._emitter.notify("onBeforeDelete")}catch(i){throw i instanceof Error?i:new Error(i.message??"Unable to delete.")}const e=this._beginCommit({description:`Delete Sheet '${this.getName()}'`}),t=this._getState();let n=t.rangeListenerSpatial,r=t.rangesListenerMap;const o=new Map;n=n.shift({range:this._entireCoords,direction:exports.w.Direction.Left,cloneIfUpdate:n===t.rangeListenerSpatial,onShift:i=>{r===t.rangesListenerMap&&(r=new Map(r)),this._processListenerShift(r,o,t.rangesListenerMap,i)}}),this._updateState({rangeListenerSpatial:n,rangesListenerMap:r,deleted:!0}),this._deleteCells([this._entireCoords]),this._emitter.notify("onDelete"),this._rangesListenerMap.forEach((i,a)=>{o.set(a,{beforeState:i,afterState:null})}),e.commit({viewAfter:i=>({...i,view:this.getView(),selection:this.getSelection().getCoords(),listeners:o})})}doBatch(e,t){const n=this;return t=typeof t=="string"?{description:t}:{description:"Update Sheet",...t},this._transactions.doBatch(e,t,(r,o)=>{if(r.getDepth()===0&&(n._lastTransactionUUID=r.getId(),t?.autoSelect)){const i=r.getView()?.selection;i&&n._autoSelect(!0,i)}})}isClosed(){return this._closed}close(){if(this._closed)return;this._protectionRemoveListener?.(),this._protection=new qd(void 0,this._options.readonly);const e=this._getState().tableMapModel.keys();for(const t of e)t.close();this._searchMovables().forEach(t=>{t.close()}),this._emitter.notify("onClose"),this._ownResources,this._namesRemoveListener?.(),this._ownNames&&this._names.close(),this._ownsCalculation&&this._calculation.close(),this._ownStyles,this._colHeaders.close(),this._rowHeaders.close(),this._emitter.close(),this._transactionsRemoveListener?.(),this._closed=!0}beginCommit(e){if(this._closed)throw new Error(ft);return this._beginCommit(typeof e=="string"?{description:e}:e)}_getState(){return this._closed?null:this._transactions.getState(this)}_beginCommit(e){const t=this;return this._transactions.beginCommit(e,n=>{n.getDepth()===0&&(t._lastTransactionUUID=n.getId())})}_updateState(e){if(!e)return;this._lastGetRangeRead=null;const t=this._transactions.beginCommit();let n;try{n=t.updateState(this,e),t.commit()}catch(r){throw t.rollback(),r}return n}_addEvent(e,t){const n=this.getTransactions().getPendingView();if(!n)return;let r=n.events;if(r||(r={},n.events=r),e==="address"){let o=r.address;if(o||(o=new Map,r.address=o),typeof t=="string")o.set(t,null);else{const i=t;if(i.options.ignoreAddressChanges)return;o.set(i.uuid,t)}}else if(e==="data")if(typeof t=="string"){let o=r.dataListeners;o||(o=new Map,r.dataListeners=o),o.set(t,null)}else{let o=r.data;o||(o=[],r.data=o),o.push(t)}}_getScalar(e,t,n=!1){const r=this._getState();let o;if(o===void 0&&(o=r.cellValuesGrid.getValueAt(e,t)),o===void 0)return null;let i=o;if(n&&typeof i=="number"){let a=!1;zt.colStart=t,zt.rowStart=e,zt.colEnd=t,zt.rowEnd=e;const l=this._lastValueRead,c=this._lastValueRead.range;if(c&&k.isRangeWithinRange(zt,c))a=l.isDateOrTime;else{const h=r.directStyleSpatial.search(zt)[0];if(h){const u=h.value.getPropertiesAt(e,t,i),d=u?.numberFormat;d&&(a=Zo(d)||Hi(d)),l.range=h,l.isDateOrTime=a}else l.range=null;a&&(i=qr(i,this._isDate1904))}}return i}getStyleUpdater(e,t){return null}_initState(){const e=this,t=()=>{e._lastCellDecoded.address=null,e._lastCellSelected.coords=null,e._lastCellRead.coords=null,e._lastValueRead.range=null,e._lastGetRangeRead={},e._lastUsedCoordsRead.coords=null,e._lastActiveRead.selection=null,e._lastRangeRead.address=null};this._transactionsRemoveListener=this._transactions.addStateListener(this,{onBeforeCommitStart(f,_,p){if(!e._initializing&&!_?.skipProtectionCheck&&e.getProtection().isLocked())throw new Error(bs)},async onBeforeCommitEnd(f,_,p){if(_?.ranges){const S={isDataChange:!0,isTransactional:!0,timeStamp:p.getTimestamp(),trigger:"setCells"},C=f.rangeListenerSpatial,y=f.rangesListenerMap;e._notifyRangeListeners(C,y,_.ranges,S)}if(_?.listeners){const S={isDataChange:!1,isTransactional:!0,timeStamp:p.getTimestamp(),trigger:"shiftCells"},C=f.rangeListenerSpatial,y=f.rangesListenerMap;e._notifyRangeListeners(C,y,_.ranges,S)}},async onRestoreOrRevert(f,_,p,S){if(t(),e._calculateFull(),_&&(_.view===e.getView()&&_.selection&&e._autoSelect(!0,_.selection),_.movableSelection&&e.getView().selectMovables(_.movableSelection)),e._emitter.notify("onInvalidated"),e._emitterMovables.notify("onInvalidated"),e._notifyUsedRangeChange(),e._rangesListenerMap.size>0){const C={isDataChange:!0,isTransactional:!1,timeStamp:p.getTimestamp(),isUndo:S,trigger:"invalidate"},y=f.rangeListenerSpatial,b=f.rangesListenerMap,w=new Set;b.forEach((E,I)=>{const x=E.id;if(w.has(x))return;const v=E.ranges;v&&(w.add(x),e._notifyRangeListeners(y,b,v,C))})}},async onAfterStateChange(f,_,p,S,C){t(),_&&p.getId()!==e._lastTransactionUUID&&_.view===e.getView()&&_.selection&&(S||C)&&e._autoSelect(!0,_.selection),e._lastTransactionUUID=p.getId(),_?.merges&&e._notifyMergeChange();const y=e._rangesListenerSorted;if(y.size>0){e._notifyUsedRangeChange();const b=new Set,w=f.rangesListenerMap2,E={isTransactional:!1,timeStamp:p.getTimestamp()};if((C||S)&&(E.trigger="restore",e._notifyAddressListeners(w,w,b,E),y.size>w.size)){const x=y.values();let v=x.next(),R=!1;for(;!R&&!v.done;){const A=v.value;R=w.has(A.uuid),R||(A.notify(E,"#N/A"),v=x.next())}}const I=_?.events;I&&(I.address&&(E.trigger="address",e._notifyAddressListeners(w,I.address,b,E)),I.dataListeners&&(E.trigger="data",e._notifyAddressListeners(w,I.dataListeners,b,E)),I.data&&(E.trigger="data",e._notifyDataListeners(f.rangesListenerSpatial2,f.rangesListenerMap2,I.data,b,E)))}if(_&&_.ranges&&!_.initial&&f.calcGraph.calculate(),_?.ranges){e._notifyUsedRangeChange();const b=e._rangesListenerMap;if(b.size>0){const w={isDataChange:!0,isTransactional:!1,timeStamp:p.getTimestamp(),isUndo:S,trigger:"setCells"};e._notifyRangeListeners(e._rangeListenerSpatial,b,_.ranges,w)}}},onClose(){const f=e._getState();f&&f.movableSpatial.clear()}});const n=new _y({sheet:this}),r={onChange(){e._emitter.notify("onSelectionChange")}},o=n.addListeners(r,{transactional:!1});this._rangeSelection=n,this._rangeSelectionRemoveListener=o;const i=f=>{const _=e._getState();if(!_)return;const p=_.movableSpatial,S=f.length;for(let C=0;C<S;C++){const y=p.search(f[C]),b=y.length;for(let w=0;w<b;w++)y[w].value.processLayoutCallback?.()}};this._colHeadersListener={onSizesChange:(f,_)=>{const p=[];if(_){const S=_.length;for(let C=0;_&&C<S;C++){const y={colStart:_[C].min,rowStart:e._entireCoords.rowStart,colEnd:e._entireCoords.colEnd,rowEnd:e._entireCoords.rowEnd};p.push(y)}}i(p)}},this._rowHeadersListener={onSizesChange:(f,_)=>{const p=[];if(_){const S=_.length;for(let C=0;C<S;C++){const y=_[C],b={colStart:e._entireCoords.colStart,rowStart:y.min,colEnd:e._entireCoords.colEnd,rowEnd:e._entireCoords.rowEnd};p.push(b)}}i(p)}};let a=new Set;const l={onTopLeftChange(){e._emitter.notify("onTopLeftChange")},onFreezeSplitChange(){e._emitter.notify("onFreezeSplitChange")},onRangeSelectionChange(){const f=e.getSelection().getCoords();e._rangeSelection.updateCoords(f)},onMovableSelectionChange(f){const _=f.getMovableSelection(),p=new Map,S=new Set,C=e._getState().movableMapModel,y=_.length;for(let b=0;b<y;b++){const w=_[b];a.has(w)?a.delete(w):p.set(w,b),S.add(w)}a.forEach(b=>{C.get(b)?.value.processSelectionCallback(!1,!1)}),p.forEach((b,w)=>{C.get(w)?.value.processSelectionCallback(!0,b===0)}),a=S,e._emitter.notify("onMovableSelectionChange")},onAnyChange(){e._emitter.notify("onViewChange")}},c=new gl({sheet:this});this._view=c,this._clearState(),this._viewRemoveListener=c.addListeners(l,{transactional:!1}),this._viewListener=l,this._colHeadersRemoveListener?.();const h=()=>Math.round(this._defaultFontDims().width);this._colHeaders=new Hd({sheet:e,orientation:exports.w.Orientation.Column,maxSheetCoords:this._entireCoords,transactions:this._transactions,isProtected:()=>!e._initializing&&!e.getProtection().isFormatColumnsAllowed(),getTextAt:f=>{const _=this.getView().getColumnHeaderStyle();return _===exports.ISheetView.HeaderTextStyle.A1?Kd(f):_===exports.ISheetView.HeaderTextStyle.Zero?Jd(f):_===exports.ISheetView.HeaderTextStyle.One?Xd(f):void 0},defaultSize:()=>{const f=this.getView().isShowFormulas()?2:1;return this._defaultColWidth()/h()*f},scaleFactor:h,maxSize:()=>255,setContainerShiftedCallback:f=>{this._colHeadersShiftCallback=f}}),this._colHeadersRemoveListener=this._colHeaders.addListeners(this._colHeadersListener,{transactional:!0}),this._rowHeadersRemoveListener?.();const u=exports.IFont.getDeviceScale();this._rowHeaders=new Hd({sheet:e,orientation:exports.w.Orientation.Row,maxSheetCoords:this._entireCoords,transactions:this._transactions,isProtected:()=>!e._initializing&&!e.getProtection().isFormatRowsAllowed(),getTextAt:f=>{const _=this.getView().getRowHeaderStyle();return _===exports.ISheetView.HeaderTextStyle.One?Xd(f):_===exports.ISheetView.HeaderTextStyle.Zero?Jd(f):_===exports.ISheetView.HeaderTextStyle.A1?Kd(f):void 0},defaultSize:()=>this._defaultRowHeight(),scaleFactor:()=>u,minSize:()=>0,maxSize:()=>409,setContainerShiftedCallback:f=>{this._rowHeadersShiftCallback=f}}),this._rowHeadersRemoveListener=this._rowHeaders.addListeners(this._rowHeadersListener,{transactional:!0}),this._defaultFontBoundsCache=null,this._defaultColWidthCache=null,this._defaultRowHeightCache=null;const d={colStart:0,rowStart:0,colEnd:0,rowEnd:0},g=[d],m={excludeHidden:!0,sort:{orientation:exports.w.Orientation.Column,reverse:!1}};this._cellOptions={resolveRange:f=>{const _=this._rangesToCoords(f);return this._createRange(_[0],null)},date1904:this._isDate1904,sheet:this,normalStyleRanged:this._normalStyleRanged,colHeaders:this._colHeaders,styles:this._styles,maxCoords:this._entireCoords,getRange:this.getRange.bind(this),getProtection:this.getProtection.bind(this),calcGraph:()=>this._getState().calcGraph,nextContentful:(f,_,p=!1)=>{d.colStart=p?_:f.colIndex+1,d.rowStart=f.rowIndex,d.colEnd=p?f.colIndex-1:_,d.rowEnd=f.rowIndex,m.sort.reverse=p;const S=e._getRangedEntries("contentfulSpatial",g,m);if(!S||S.length===0)return _;const C=S[0],y=p?C.getState().colStart:C.getState().colEnd;return p?Math.min(y+1,f.colIndex):Math.max(y-1,f.colIndex)},opener:async(f,_,p,S)=>{if(f.startsWith("#")){f=f.substring(1);const C=this._rangesToCoords(f);return await this._autoSelect(_??!0,Be(C)),!0}return window.open(f,p??"_blank",S),!0}},this._emptyCell=new vw(this._cellOptions)}_clearState(){this._lastGetRangeRead=null,this._lastCellDecoded.address=null,this._lastCellSelected.coords=null,this._lastCellRead.coords=null,this._protectionRemoveListener?.(),this._protection=new qd(void 0,this._options.readonly),this._protectionRemoveListener=this._protection.addListeners({onChange(){if(e._closed)throw new Error(ft);e._getState().movableMapModel.forEach(a=>{a.value.processProtectionCallback?.()}),e._getState().tableMapModel.forEach(a=>{a.value.processProtectionCallback?.()}),e._emitter.notify("onProtectionChange")}}),this._stylesRemoveListener?.();const e=this;this._stylesRemoveListener=this._styles.addListeners({onAnyChange(){e._defaultColWidthCache=null,e._defaultRowHeightCache=null,e._defaultFontBoundsCache=null,e._emitter.notify("onLayoutChange"),e._emitter.notify("onStyleChange")}}),this._view.clear(!1),this._rangeListenerSpatial=new be,this._rangesListenerMap=new Map,this._rangesListenerSorted=new Se;const t=a=>{const l=e._getState().rangesListenerSpatial2;if(l.isEmpty())return;const c=a.length;for(let h=0;h<c;h++){const u=a[h],d=l.search(u),g=d.length;for(let m=0;m<g;m++){const f=d[m].value.groupId;e._addEvent("data",f)}}},n=this._entireCoords,r=n.rowEnd,o=n.colEnd,i=this._calculation._createGraph({onCalculated(a){e._realizeCalcedValues(a)},getEntireCoords:()=>e._entireCoords,getSheetName:()=>e.getName()});i.addListeners({onStart(a){},onInvalidate:()=>{}}),this._updateState({rangesListenerSpatial2:new be({updateEntryOptions:{onShifted:a=>{let l=e._getState().rangesListenerMap2;if(l.size===0)return;l=new Map(l);const c=a.length;for(let h=0;h<c;h++){const u=a[h],d=u.value.groupId;let g=l.get(d);g=g.processShift(u),e._addEvent("address",g),l.set(d,g)}e._updateState({rangesListenerMap2:l})},onRemoved:a=>{let l=e._getState().rangesListenerMap2;if(l.size===0)return;l=new Map(l);const c=a.length;for(let h=0;h<c;h++){const u=a[h],d=u.value.groupId;let g=l.get(d);g=g.processRemove(u),e._addEvent("address",g),l.set(d,g)}e._updateState({rangesListenerMap2:l})}}}),rangesListenerMap2:new Map,cellValuesGrid:new Zt({orientation:this._isDataColumn?exports.w.Orientation.Column:exports.w.Orientation.Row}),formulaSpatial:new be,spillSpatial:new be,pendingSpatial:new be,calcErrorsSpatial:new be,calcGraph:i,directStyleSpatial:new be({updateEntryOptions:{isMergeOnShift:!0,isTrailingEdge:!0,onUpdated:t,onRemoved:t}}),continuousFillSpatial:new be({updateEntryOptions:{isMergeOnShift:!0,isTrailingEdge:!0}}),conditionalModels:new Map,conditionalSpatial:new be({updateEntryOptions:{onGroupUpdate(a,l){let c=e._getState().conditionalModels,h=c.get(l);if(!h)return;c=new Map(c);const u=h.spatials;h={...h},h.spatials=a,c.set(l,h),e._updateState({conditionalModels:c}),h.processCoordsChange({before:u,after:h.spatials})}}}),mergeSpatial:new be({updateEntryOptions:{getShifted:(a,l)=>l?(l.value=new Vd(k.sanitizeRange(l),a.value._tvTl,a.value._rsTl),l):null,getSplit(a,l){throw new Error("We can't insert through merges. Unmerge and try again.")},onUpdated:t,onRemoved:t}}),movableMapModel:new Map,movableSpatial:new be({updateEntryOptions:{getShifted(a,l,c){const h=a.value.processShiftCallback?.(c);let u=null;const d=new Map(e._getState().movableMapModel),g=a.value.model;return h?(u={...h,value:{...a.value}},d.set(g,u)):d.delete(g),e._updateState({movableMapModel:d}),u}}}),hyperlinkSpatial:new be({updateEntryOptions:{isSplitOnExpand:!0,isMergeOnShift:!0}}),commentsSpatial:new be({updateEntryOptions:{isSplitOnExpand:!0,isMergeOnShift:!0,onUpdated:t,onRemoved:t}}),tableMapModel:new Map,tableMapName:new Map,tableSpatial:new be({updateEntryOptions:{getShifted(a,l,c){const h=new Map(e._getState().tableMapModel),u=a.value.model,d=a.value.processShiftCallback?.(c);let g=null;return d?(g={...d,value:{...l.value}},h.set(u,g)):h.delete(u),e._updateState({tableMapModel:h}),g}}}),filter:null,sort:null,rangeListenerSpatial:new be,rangesListenerMap:new Map,contentfulSpatial:new be({updateEntryOptions:{isSplitOnExpand:!0,isMergeOnShift:!0,onShifted:a=>{const l=e._getState().rangesListenerSpatial2;if(l.size()===0)return;const c=a.length;for(let h=0;h<c;h++){const u=a[h],d=l.search({colStart:u.colStart,rowStart:u.rowStart,colEnd:o,rowEnd:r}),g=d.length;for(let m=0;m<g;m++){const f=d[m].value.groupId;e._addEvent("data",f)}}},onRemoved:t,onUpdated:t}}),unlockSpatial:new be({updateEntryOptions:{isMergeOnShift:!0}}),deleted:!1}),this._defaultFontBoundsCache=null,this._defaultColWidthCache=null,this._defaultRowHeightCache=null}_createTableEntry(e,t=!1){const n={model:null,processShiftCallback:null,processDeleteCallback:null,processProtectionCallback:null,currentName:null,removeListener:null};let r=null;r=typeof e.ref=="string"?Mt(e.ref,this._entireCoords):e.ref;const o={...r,value:n},i=this,a=()=>n.model?i._getState().tableMapModel?.get(n.model):o,l=(u,d)=>!(!k.isEqualRanges(u,d)||u.value.model!==d.value.model),c={transactions:this._transactions,sheet:this,names:this._names,readSheetHeader:t,json:e,maxRangeCoords:this._entireCoords,setNameOnContainer(u){const d=a().value;if(!d.currentName||d.currentName.toLowerCase()===u.toLowerCase())return;const g="Set Table Name";i._protectionCheck(()=>["objects"],void 0,g);const m=i._beginCommit({description:g});try{const f=i._getState()?.tableMapName,_=u.toLocaleLowerCase();if(f.has(_))throw new Error((S=>`Name must be unique: '${S}' is already in use.`)(u));const p=new Map(f);p.delete(d.currentName),d.currentName=_,p.set(_,d.model),i._updateState({tableMapName:p}),m.commit()}catch(f){throw m.rollback(),f}},setContainerCoords(u,d){if(!u)return;const g=i._rangeToCoords(u,()=>["objects"]),m=a();if(!m)return;const f=m.value.model;i._validateOrRemoveOverlaps(g,"table",f);const _=i._beginCommit({description:d?.description??"Resize Table"}),p=i._getState(),S=p.tableSpatial.clone(),C=p.tableMapModel,y=new Map(C);S.remove(m,l);const b={...m,...g};return S.insert(b),y.set(b.value.model,b),i._updateState({tableSpatial:S,tableMapModel:y}),_.commit({viewAfter:{view:i.getView(),selection:Be([h.getAnchorCoords()])}}),g},deleteFromContainer(u){const d=a();if(!d)return;const g=d.value.model,m=u?.description??`Delete Table '${g.getName()}`;i._protectionCheck(()=>["objects"],void 0,m);const f=i._beginCommit({description:m}),_=i._getState(),p=_.tableSpatial.clone(),S=_.tableMapModel,C=new Map(S),y=_.tableMapName,b=new Map(y);p.remove(d,l),C.delete(g),b.delete(g.getName().toLocaleLowerCase()),d.value.processDeleteCallback?.(),i._updateState({tableSpatial:p,tableMapModel:C,tableMapName:b}),i._emitter.notify("onTablesChange"),f.commit({viewAfter:{sheet:i,view:i.getView(),selection:Be([g.getAnchorCoords()])}})},setContainerDeleteCallback(u){const d=a()?.value??n;d&&(d.processDeleteCallback=u,d.removeListener?.())},isProtected:()=>!i._initializing&&i.getProtection().isLocked(),setContainerProtectionCallback(u){(a()?.value??n).processProtectionCallback=u},setContainerShiftCallback(u){(a()?.value??n).processShiftCallback=u},processTableUpdate(){i._notifyUsedRangeChange()},initialAnchor:r},h=new lf(c);return o.value.model=h,o.value.removeListener=h.addListeners({onStyleChange(u){i._emitter.notify("onStyleChange")},onDelete(u){i._emitter.notify("onStyleChange")}},{transactional:!1}),o.value.currentName=h.getName().toLocaleLowerCase(),o}_createConditionalEntries(e,t,n){const r="Conditional Format",o=()=>["objects"],i=e??{};let a=null;const l=this._entireCoords;if(typeof i.ref=="string"){a=[];const p=i.ref.split(","),S=p.length;for(let C=0;C<S;C++){const y=Mt(p[C],l);y&&a.push(y)}}else a=Array.isArray(i.ref)?i.ref:[i.ref];const c=this,h=N.uuidV4(),u={model:null,removeListener:null,processCoordsChange:null,spatials:null};n.set(h,u);const d=()=>u.model?c._getState().conditionalModels.get(h):u;let g=p=>(console.log("default createSpatialEntry",p),null);const m=(p,S,C)=>{if(!u.model)return void(a=p);let y=S.spatials;if(y){const w=y.length;for(let E=0;E<w;E++)C.remove(y[E])}let b=[];if(p){const w=p.length;for(let E=0;E<w;E++){const I=p[E];b.push({...I,value:g(I)})}b.length>0&&C.insertGroup(b,h)}S.spatials=b},f=()=>{const p=d().spatials??a;return p?c.getRanges(p):null};var _;return u.model=(_={sheet:c,transactions:c._transactions,json:e,type:"conditional",setOnContainerCoordsChange:p=>{d().processCoordsChange=p},setCreateSpatial(p){g=p},setContainerRanges:(p,S)=>{const C=c._rangesToCoords(p,o);if(!u.model)return a=C,C&&C.length>0?c.getRanges(C):null;const y=c._beginCommit({description:S?.description??`Set ${r} Ranges`});let b=Be(C);try{const w=c._getState();let E=w.conditionalSpatial;E=E.clone();let I=w.conditionalModels;I=new Map(I);let x=d();x={...x},I.set(h,x),m(C,x,E),c._updateState({conditionalSpatial:E,conditionalModels:I}),y.commit({viewBefore:{view:c.getView(),selection:Be(f()?.getCoords())},viewAfter:{view:c.getView(),selection:b}}),c._autoSelect(S?.autoSelect,b)}catch(w){throw y.rollback(),w}return C&&C.length>0?c.getRanges(C):null},getContainerRanges:f,deleteFromContainer(p){let S=d();const C=c._beginCommit({description:p?.description??`Set ${r} Ranges`}),y=p?.autoSelect?Be(S.spatials):void 0;try{const b=c._getState();let w=b.conditionalSpatial;w=w.clone();let E=b.conditionalModels;E=new Map(E),S={...S},m(null,S,w),E.delete(h),c._updateState({conditionalSpatial:w,conditionalModels:E}),this._commitAndAutoSelect(C,y,p?.autoSelect)}catch(b){throw C.rollback(),b}},isReadOnly:()=>!1,setContainerReadOnlyCallback(p){}},new Sy({..._,createDescription:`New ${r}`})),u.removeListener=u.model.addListeners({onAnyChange(p){c._emitter.notify("onStyleChange")}},{transactional:!1}),m(a,u,t),u.model}_createMovableEntry(e,t,n){let r=null;if(e?.anchor)r={colStart:e.anchor.tl?.c??0,rowStart:e.anchor.tl?.r??0,colEnd:e.anchor.br?.c??0,rowEnd:e.anchor.br?.r??0},e.anchor.br?.x||(r.colEnd-=1),e.anchor.br?.y||(r.rowEnd-=1);else{const y=Rr(this.getSelection().getCoords())[0];r={colStart:y.colStart,rowStart:y.rowStart,colEnd:y.colEnd,rowEnd:y.rowEnd}}const o={model:null,processShiftCallback:null,processLayoutCallback:null,processDeleteCallback:null,processZIndexCallback:null,processSelectionCallback:null,processProtectionCallback:null,zIndex:t},i={...r,value:o},a=()=>o.model?h._getState()?.movableMapModel?.get(o.model):i,l=(y,b)=>!(!k.isEqualRanges(y,b)||y.value.model!==b.value.model),c=(y,b,w=!0)=>{if(d)return;const E=a();if(!E)return;const I=b??"Update Drawing";h._protectionCheck(()=>["objects"],void 0,I);const x=h._beginCommit({description:I}),v=h._getState()?.movableSpatial,R=v.clone(),A=h._getState()?.movableMapModel,M=new Map(A);y(E,R,M)!==!1&&(h._updateState({movableSpatial:R,movableMapModel:M}),w&&(h._emitterMovables.notify("onCollectionChange",{source:h,transactional:!0}),h._emitter.notify("onMovablesChange")),x.commit({viewAfter:T=>{if(i.value.model.isSelected()&&!T?.movableSelection?.includes(i.value.model)){const F=[...T?.movableSelection??[]];return F.push(i.value.model),{...T,view:this.getView(),movableSelection:F}}}}))},h=this,u=e.content.type;let d=!0;const g=(y,b,w,E)=>{const I=w.all().sort((D,P)=>D.value.zIndex-P.value.zIndex),x=b.value.zIndex;if((y=Math.max(0,Math.min(I.length-1,y)))===x)return!1;const v=[],R=[],A=[],M=x<y,T=D=>{const P=I[D];v.push(P);const B={...P,value:{...P.value,zIndex:M?D-1:D+1}};P.value.zIndex===x&&(B.value.zIndex=y),R.push(B),E.set(B.value.model,B),A.push(B)};if(M)for(let D=x;D<=y;D++)T(D);else for(let D=x;D>=y;D--)T(D);const F=v.length;for(let D=0;D<F;D++)w.remove(v[D],l);w.load(R);const L=A.length;for(let D=0;D<L;D++)A[D].value.processZIndexCallback?.()},m=()=>h._resources.beginPersist(),f=u==="picture",_={content:null,fromResourceId:n,defaultLockAspectRatio:f,beginPersistResource:m,getMaxBounds:()=>h._getBoundsAtCoords(h._entireCoords),transactions:this._transactions,getBoundsAtCoords:h._getBoundsAtCoords.bind(h),getCoordsAtBounds:h._getCoordsAtBounds.bind(h),scrollIntoView:y=>h._selectSheet(a()?.value.model.getAnchorCoords(),y),select:async y=>{const b=a()?.value.model;if(!b)return!1;try{h.getView().selectMovables([b],y?.addToSelection)}catch(E){return console.warn(E),!1}const w=await h._selectSheet(a()?.value.model.getAnchorCoords(),y?.scrollIntoView);return!y?.scrollIntoView||w!==!1},unselect:()=>{const y=a()?.value.model;return!!y&&(h.getView().unselectMovables([y]),!0)},isSelected:()=>h.getView().getMovableSelection().includes(a()?.value.model),setContainerSelectionCallback(y){(a()?.value??o).processSelectionCallback=y},moveToBackOnContainer:()=>{c((y,b,w)=>g(0,y,b,w),"Move to Back")},moveBackwardOnContainer:()=>{c((y,b,w)=>g(y.value.zIndex-1,y,b,w),"Move Backwards")},moveForwardOnContainer(){c((y,b,w)=>g(y.value.zIndex+1,y,b,w),"Move Forward")},moveToFrontOnContainer(){c((y,b,w)=>g(b.size()-1,y,b,w),"Move To Front")},getZIndex:()=>a()?.value.zIndex??0,setContainerZIndexCallback(y){(a()?.value??o).processZIndexCallback=y},setContainerCoords(y){if(!y)return;const b=h._rangeToCoords(y,()=>["objects"]);return c((w,E,I)=>{const x={...w,...b};E.remove(w,l),E.insert(x),I.set(x.value.model,x)},"Update Drawing",!1),b},deleteFromContainer(y){const b=a();b?.value&&h.getView().unselectMovables([b.value.model]);const w=[];c((I,x,v)=>{v.delete(I.value.model),x.remove(I,l),I.value.processDeleteCallback?.(),w.push(I);const R=I.value.model.getZIndex(),A=x.all().sort((D,P)=>D.value.zIndex-P.value.zIndex),M=[],T=[],F=A.length;for(let D=R+1;D<F;D++){const P=A[D];M.push(P);const B={...P,value:{...P.value,zIndex:D-1}};T.push(B),v.set(B.value.model,B)}const L=M.length;for(let D=0;D<L;D++)x.remove(M[D],l);x.load(T)},y?.description??"Delete Drawing",!0);const E=w.length;for(let I=0;I<E;I++)w[I].value.processZIndexCallback?.()},setContainerDeleteCallback(y){(a()?.value??o).processDeleteCallback=y},isProtected:()=>!h._initializing&&!h.getProtection().isObjectsAllowed(),setContainerProtectionCallback(y){(a()?.value??o).processProtectionCallback=y},setContainerShiftCallback(y){(a()?.value??o).processShiftCallback=y},setContainerLayoutCallback(y){(a()?.value??o).processLayoutCallback=y},initialAnchor:r,maxRangeCoords:this._entireCoords,json:e},p=e.content.json,S={type:u,transactions:this._transactions,beginPersistResource:m,fromResourceId:n,defaultLockAspectRatio:f,json:p};let C=null;if(u==="picture")C=new cf(S);else if(u==="chart")C=new dy(S);else if(u==="sp"||u==="cxnSp"||u==="grpSp")C=new gy(S);else{if(u!=="graphicFrame")throw new Error((y=>`Unsupported float type: ${y}`)(u));C=new my(S)}return o.model=new Pi({..._,content:C}),d=!1,i}_fromJSON(e){this._initializing=!0,this._emitter.notify("onBeforeLoad",{params:e}),this._clearState();const t=this._beginCommit({description:"Load Sheet",viewAfter:{initial:!0,skipProtectionCheck:!0}}),n=e||{},r=this._strings,o=r.beginPersist(),i=this._resources.beginPersist(),a=this._styles.beginPersist();try{this._ownStrings&&o.fromJSON(n.strings),this._ownResources&&i.fromJSON(n.resources),this._ownStyles&&a.fromJSON(n.styles),this._colHeaders.fromJSON({headers:n.cols,defaultSize:n.defaultColSize}),this._rowHeaders.fromJSON({headers:n.rows,defaultSize:n.defaultRowSize}),this.setView(new gl({sheet:this,json:n.view})),this._rangeSelection.updateCoords(this._view.getRangeSelection()),n.tabColor&&(this._tabColor=this._styles.parseColor(n.tabColor));let l=this._getState();const c=l.cellValuesGrid,h=l.contentfulSpatial,u=n.data,d=u?.length??0,g=gd,m=[];if(d>0){for(let O=0;O<d;O++){let W=u[O];typeof W=="string"&&(W=JSON.parse(W));const V=W[1],j=V.length;let H;for(let G=0;G<j;G++){const $=V[G][1],te=$.length;for(let J=0;J<te;J++){let ne=$[J],Z=ne?.t;if(Z!==void 0)ne=ne?.v;else switch(typeof ne){case"number":Z=U.Number;break;case"boolean":Z=U.Boolean;break;case"string":Z=U.String,ne=parseInt(ne)}$[J]=[ne,Z]}H=g(null,r,$),V[G][1]=H}m.push(W)}c.setValues(m);const z=md(m,this._isDataColumn);h.load(z)}const f=this._entireCoords,_=l.directStyleSpatial,p=l.continuousFillSpatial,S=this._options.styles;if(e.directStyles){const z=[],O=[],W=e.directStyles,V=(j,H)=>{const G=a.getElementJSON(H),$=new Je(S,k.sanitizeRange(j),G),te={...j,value:$};z.push(te);const J=$._p?.alignment?.horizontal;!J||J!==exports.ITextFrame.HorizontalAlignment.CenterContinuous&&J!==exports.ITextFrame.HorizontalAlignment.Fill||O.push(te)};if(Array.isArray(W)){const j=W.length;for(let H=0;H<j;H++){const G=W[H],$=G.r;V(typeof $=="string"?Mt($,f):$,G.v)}}_.load(z),p.load(O)}l=this._updateState({cellValuesGrid:c,contentfulSpatial:h,directStyleSpatial:_,continuousFillSpatial:p});const C=n.merges;if(C){const z=[],O=C.length;for(let W=0;W<O;W++){const V=Mt(C[W],f);z.push(V)}this._indexMerges(z)}const y=l.hyperlinkSpatial,b=n.hyperlinks;if(b){const z=b,O=[],W=z.length;for(let V=0;V<W;V++){const j=z[V];let H=j.r;H=typeof H=="string"?Mt(H,f):k.sanitizeRange(H);let G=j.v;typeof G=="string"&&(G={address:G}),O.push({...H,value:G})}y.load(O)}const w=l.commentsSpatial,E=n.comments;if(E){const z=E,O=[],W=z.length;for(let V=0;V<W;V++){const j=z[V];let H=j.ref;H=typeof H=="string"?Mt(H,f):k.sanitizeRange(H);const G={...j};delete G.ref,O.push({...H,value:G})}w.load(O)}const I=l.movableMapModel,x=l.movableSpatial;if(n.movables){const z=[],O=n.movables,W=O.length;for(let V=0;V<W;V++){const j=O[V];try{const H=this._createMovableEntry(j,V,i.fromResourceId.bind(i));I.set(H.value.model,H),z.push(H)}catch(H){console.warn("Unable to load movable",V,j,H)}}x.load(z)}const v=l.tableMapModel,R=l.tableMapName,A=l.tableSpatial,M=n.tables;if(M){const z=[],O=M.length;for(let W=0;W<O;W++){const V=M[W],j=this._createTableEntry(V),H=j.value.model;v.set(H,j),R.set(j.value.currentName,H),z.push(j)}A.load(z)}const T=l.conditionalSpatial,F=l.conditionalModels,L=n.conditionals;if(L){const z=L.length;for(let O=0;O<z;O++){const W=L[O];this._createConditionalEntries(W,T,F)}}const D=l.calcGraph,P=D.fromJSON({formulas:n.formulas,data:m,dynamic:n.dynamicArray,volatile:n.volatile});l=this._updateState({hyperlinkSpatial:y,commentsSpatial:w,movableSpatial:x,movableMapModel:I,tableSpatial:A,tableMapModel:v,tableMapName:R,conditionalSpatial:T,conditionalModels:F,calcGraph:D});const B=this._getUsedCoords();B&&this._autoFit([B],{orientations:exports.w.Orientations.Row,skipCustomSize:!0}),t.commit(),P&&this._realizeCalcedValues(P),n.protection&&this._protection.fromJSON(n.protection),this._emitter.notify("onLoad")}finally{a.endPersist(),i.endPersist(),o.endPersist()}this._initializing=!1}getName(){return this._closed?Ke:this._options.container?.getName?.()??null}setName(e){if(this._closed)throw new Error(ft);const t=this._options.container?.setName;if(!t)throw new Error("Unable to set name for sheet.");return t(e),this}getVisibility(){return this._closed?exports.ISheet.Visibility.VeryHidden:this._options.container?.getVisibility?.()??exports.ISheet.Visibility.Hidden}setVisibility(e=!0){if(this._closed)throw new Error(ft);const t=this._options.container?.setVisibility;if(!t)throw new Error("Unable to set visibility for sheet.");let n;return n=e===!0?exports.ISheet.Visibility.Visible:e===!1?exports.ISheet.Visibility.Hidden:e,t(n),this}async select(e){return await this._options.container?.requestSelect?.(e),this}duplicate(){return this._options.container?.duplicate?.()}setPosition(e){return this._options.container?.setPosition(e),this}getNames(){return this._names}getCalculation(){return this._calculation}get[Symbol.toStringTag](){return"[Sheet]"}toString(){return this.getName()||"(untitled sheet)"}get isISheet(){return!0}}const Qd={address:null,scope:null},Fy={colStart:0,rowStart:0,colEnd:0,rowEnd:0},yo={colStart:0,rowStart:0,colEnd:0,rowEnd:0},Ny={colStart:0,rowStart:0,colEnd:0,rowEnd:0},Ls={includeHidden:!1};Object.freeze({[exports.ICell.Content.Values]:Number.MAX_SAFE_INTEGER,[exports.ICell.Content.Formulas]:Number.MAX_SAFE_INTEGER}),Object.freeze({[exports.ICell.Content.Values]:1,[exports.ICell.Content.Formulas]:1});const Ps={ignoreDataChanges:!1},zt={colStart:-1,rowStart:-1,colEnd:-1,rowEnd:-1},Co=[{colIndex:-1,rowIndex:-1},null,null,null,null],ky=[exports.ICell.Content.Values],Zd={size:null,autoSize:!0},ml={skipCustomSize:!0,expandOnly:!0,minContent:!0},Jt={rowStart:0,colStart:0,rowEnd:0,colEnd:0},fl={showFormulaBar:!0,showTabs:!0,tabRatio:600,showHorizontalScrollbar:!0,showVerticalScrollbar:!0,showStatusBar:!0,activeSheetId:null};class Ql{constructor(e){this._emitter=null,this._emitter=new st(this),this._state={...fl},e?.json&&this._fromJSON(e?.json)}isShowFormulaBar(){return this._state.showFormulaBar}setShowFormulaBar(e){return this._state.showFormulaBar=e,this._emitter.notify("onViewChange"),this}isShowTabs(){return this._state.showTabs}setShowTabs(e){return this._state.showTabs=e,this._emitter.notify("onViewChange"),this}getTabRatio(){return this._state.tabRatio}setTabRatio(e){return this._state.tabRatio=e,this._emitter.notify("onViewChange"),this}isShowHorizontalScrollbar(){return this._state.showHorizontalScrollbar}setShowHorizontalScrollbar(e){return this._state.showHorizontalScrollbar=e,this._emitter.notify("onViewChange"),this}isShowVerticalScrollbar(){return this._state.showVerticalScrollbar}setShowVerticalScrollbar(e){return this._state.showVerticalScrollbar=e,this._emitter.notify("onViewChange"),this}isShowStatusBar(){return this._state.showStatusBar}setShowStatusBar(e){return this._state.showStatusBar=e,this._emitter.notify("onViewChange"),this}getActiveSheetId(){return this._state.activeSheetId}setActiveSheetId(e){return this._state.activeSheetId=e,this._emitter.notify("onViewChange"),this}addListeners(e,t){return this._emitter.addListeners(e,t)}toJSON(){let e={};const t=Object.keys(this._state);for(let n=0;n<t.length;n++){const r=this._state[t[n]];r!=null&&r!==fl[t[n]]&&(e[t[n]]=r)}return Object.keys(e).length===0&&(e=null),e}_fromJSON(e,t=!0){let n=e||{};this.update(n,t)}update(e,t=!0){this._state={...fl,...this._state,...e},t&&this._emitter.notify("onViewChange")}}class Oy{constructor(e){this._emitter=null,this._closed=!1,this._options={...e};const t=this;this._transactions=this._options.transactions??new Bt({transient:!0}),this._transactionsRemoveListener=this._transactions.addStateListener(this,{onAfterStateChange(n,r,o){t._emitter.notify("onCollectionChange")}}),this._emitter=new st(this,this._transactions),this._initState(e?.initial)}add(e,t,n){const r=this;t&&t.addListeners({onDelete:c=>{r._updateState(h=>{if(!h.modules[e])return;const u=h.modules[e];if(u){const d={...h};return r._options.onRemove?.(e,u),r._emitter.notify("onCollectionChange"),delete d.modules[e],d}return h},"Delete Module")}},{once:!0});const o=this._getState()?.modules,i=o?.[e],a=n?.replace??!1;if(i&&!a)throw new Error(`Already existing '${e}'`);const l={...o};t?(l[e]=t,r._options.onAdd?.(e,t),this._updateState({modules:l},a?"Save Scripts":"Add Script")):(delete l[e],r._options.onRemove?.(e,null),this._updateState({modules:l},"Remove Script")),r._emitter.notify("onCollectionChange")}search(e){const t=this._getState();if(!t)return N.EmptyArray;const n=t.modules,r=Object.keys(n),o=r.length;if(o===0)return N.EmptyArray;const i=[],a=e?.name?e.name.toUpperCase():null;for(let l=0;l<o;l++){const c=r[l],h=n[c];let u=!0;a&&a!==c.toUpperCase()&&(u=!1),u&&i.push(h)}return i??N.EmptyArray}getByName(e){if(!e)return null;const t=this._getState();if(!t)return null;const n=e.toUpperCase(),r=t.modules,o=Object.keys(r),i=o.length;for(let a=0;a<i;a++){const l=o[a];if(n===l)return r[l]}return null}getCount(){const e=this._getState();return e?Object.keys(e.modules).length:0}beginCommit(e){return this._beginCommit(e)}_getState(){if(this._closed)throw new Error(Tt);return this._transactions.getState(this)}_beginCommit(e){return this._transactions.beginCommit(typeof e=="string"?{description:e}:e)}_updateState(e,t="Update",n){if(!e)return;const r=this._beginCommit(t);try{r.updateState(this,e),r.commit(n)}catch(o){throw r.rollback(),o}}_initState(e){let t=e??{};this._updateState({modules:t},"Initialize",{forceAmend:!0});const n=this._options.onAdd;if(n){const r=Object.keys(t),o=r.length;for(let i=0;i<o;i++){const a=r[i];n(a,t[a])}}}addListeners(e,t){return this._emitter.addListeners(e,t)}toJSON(){const e=this._getState();if(!e)return N.EmptyArray;const t=e.modules,n=Object.keys(t),r=n.length,o={};for(let i=0;i<r;i++){const a=n[i];o[a]=t[a].toJSON()}return o}isClosed(){return this._closed}close(){this._closed||(this._emitter.notify("onClose"),this._closed=!0,this._transactionsRemoveListener?.())}get isFunctionCollection(){return!0}}let pl;const zs="SheetXL",By=pl||(pl=N.deepFreeze({ISheet:{Visibility:exports.ISheet.Visibility},ICell:{Content:exports.ICell.Content,CalcStatus:exports.ICell.CalcStatus},IColor:{Named:exports.IColor.Named,Scheme:exports.IColor.Scheme,Type:exports.IColor.Type,AdjustmentType:exports.IColor.AdjustmentType},Direction:Oe}),pl);let Ws;class Dy extends Xo{constructor(e,t,n,r=null,o=!1){super(e,t,n,r,o)}execute(...e){const t=e[0];if(!t||!t.isIWorkbook)throw new Error(`Macro '${this.getName()}' must be called with a valid workbook as the only argument.`);const n=this._ct;try{const r=[];switch(n){case pn.Context.Workbook:r.push(t);break;case pn.Context.Sheet:r.push(t.getSelectedSheet());break;case pn.Context.Ranges:r.push(t.getSelectedRanges());break;case pn.Context.Range:r.push(t.getSelectedRange());break;default:throw new Error(`Function '${this.getName()}' is not a valid macro function.`)}const o=async(a,l)=>{const c=await l;if(c!==void 0)if(c!==null){if(Array.isArray(c)){if(Ye(c[0]?.[0]))return void a.setValues(c,{skipBoundsCheck:!0})}else if(Ye(c))return void a.setValues([[c]]);c.isICell?a.updateCells(c):c.isICellRange&&await a.copyFrom(c)}else a.clear()};let i;return(async()=>{const a=(await this.getDescriptor()).getSummary()??`Macro '${this.getName()}'`;return await t.doBatch(async()=>{try{const l=t.getSelectedRange();let c=this._cf();c||(c=function(h){return new Proxy(h,{set:(u,d,g)=>(console.log(`Adding property "${d}" with value:`,g),u[d]=g,!0),deleteProperty:(u,d)=>(console.log(`Deleting property "${d}"`),delete u[d])})}({}));try{vc({getPosition:()=>l.getCell().getCoords()}),Ws=globalThis[zs],globalThis[zs]=By,i=this._fn.call(c,...r),Ws?(globalThis[zs]=Ws,Ws=void 0):delete globalThis[zs],Li()}catch(h){throw h}finally{Li()}await o(l,i)}catch(l){throw l}},a),{params:r,results:i}})()}catch(r){throw r}}}class Ly{constructor(e){this._emitter=null;const t=e.json;if(this._json=t,!this._json)throw new Error("Module JSON is required.");this._emitter=new st(this),this._functions=new gf({transactions:null,readonlyFunctions:e.readonlyFunctions})}getFunctions(){return this._functions}getSource(){return this._json.source}getLanguage(){return this._json.language||"typescript"}getErrors(){return null}delete(){this._emitter.notify("onDelete")}addListeners(e,t){return this._emitter.addListeners(e,t)}toJSON(){return this._json}}const Py=async(s,e)=>{let t=null;try{vc(null)}catch(o){console.warn("Error setting global scope",o)}try{t=await new Function("modulePath","return import(modulePath)")(`data:text/javascript,${encodeURIComponent(s.compiled)}`)}catch(o){throw new Error("Invalid Javascript module.",{cause:o})}finally{Li()}if(!e)throw new Error(`No function available for '${s.name??s.commitId}'.`);const n=e.name;let r=t[n];if(!r&&e.behavior.default&&(r=t.default),!r)throw new Error(`Found the descriptor for '${n}' but not the function. The descriptor manifest must be corrupt.`);return r},eg=async(s,e=!1)=>{const t=s?.functions,n=new Map;if(t)for(let r=0;r<t.length;r++){const o=t[r],i=o[0],a=o[1];let l,c=e?()=>{}:await Py(s,i);l=i.context&&i.context!==pn.Context.Calculation?new Dy(i,c,()=>null,a):new Xo(i,c,()=>null,a),n.set(i.name.toUpperCase(),l)}return new Ly({json:s,readonlyFunctions:n})};class zy{constructor(e){this._options=e,this._initState()}_initState(){}getModules(){return this._modules}async createModule(e){const t=await Promise.resolve().then(()=>require("./B6Vc2J26WiHxBQya.cjs")).then(r=>r.index),n=await t.ScriptingUtils.compileTypescript(e);return n?await eg(n,e?.declarationsOnly??!1):null}addModule(e,t,n){this._modules.add(e,t,n)}executeMacro(e,t){const n=this._modules.search({name:t}),r=n.length;for(let o=0;o<r;o++){const i=n[o].getFunctions().getByName(e);if(i)return i.execute(this._options.workbook)}throw new Error(`No macro ${e} found.`)}searchFunction(e){const t=e?.name,n=e?.moduleName,r=e?.type,o=this._modules;if(!o)return N.EmptyArray;const i=o.getCount();if(i===0)return N.EmptyArray;if(n){const l=this._modules.search({name:n});return l.length===0?N.EmptyArray():l[0].getFunctions().search({name:t,type:r})}const a=this._modules.search();for(let l=0;l<i;l++){const c=a[l].getFunctions().search({name:t,type:r});if(c.length>0)return c}return N.EmptyArray}async start(){if(this._modules)return Promise.resolve();const e=this._options?.workbook,t=this._options?.json;let n={};if(t){const a=Object.keys(t);for(let l=0;l<a.length;l++){const c=a[l],h=t[c],u=await eg(h);n[c]=u}}const r=new Oy({transactions:this._options?.transactions,initial:n,onRemove:this._options?.onRemove,onAdd:this._options?.onAdd});this._modules=r;const o=r.search();if(o.length===0)return Promise.resolve(N.EmptyArray);const i=o.length;for(let a=0;a<i;a++){const l=o[a];try{const c=l.getFunctions().search({type:"autoRun"}),h=c.length;for(let u=0;u<h;u++)await c[u].execute(e)}catch(c){console.error("Error executing autoRun script:",c)}}}toJSON(){const e=this._modules;if(!e)throw new Error("Scripts is initializing.");return e.toJSON()}}const Wy=Object.freeze({lockStructure:!1,lockWindows:!1,lockRevision:!1,workbookPassword:null,revisionsPassword:null});class tg extends yf{isWindowsAllowed(){return this._isPropertyAllowed("windows")}isRevisionAllowed(){return this._isPropertyAllowed("revision")}isStructureAllowed(){return this._isPropertyAllowed("structure")}_fromJSON(e){this._properties=e}_toJSON(e){let t=this._properties;if(t){e={...e,...t};const n=Object.keys(t),r=n.length;for(let o=0;o<r;o++){const i=n[o],a=t[i];a!=null&&a!==Wy[i]&&(e[i]=a)}}return super._toJSON(e)}}const _l=s=>`Invalid SheetKey: ${s}`,Sl="A workbook must contain at least one visible worksheet.",ng="Internal error no visible sheetRefs",at="Workbook has been closed. No further operations are allowed.",$n="This workbook structure is protected. To make a change, unprotect the workbook. You might be requested to enter a password.",Qi="A sheet name",Zl=`${Qi} can not be blank.`,jy=`${Qi} can not be longer than 31 characters.`,Hy=`${Qi} can not begin or end with a "'" (single quote).`;class Vy{constructor(e,t){this._add=e,this._get=t}add(e){return this._add(e)}search(e){return this._get(e?.name,e?.visibility)}getByName(e){return this._get(e)?.[0]??null}getCount(){return this._get().length}}const ec=new RegExp(/[\\/\\*?:[\]]+/),Gy=new RegExp(/\(((\d+)(?!.*\d))\)$/,"g"),$y=s=>`Sheet${s+1}`,Cf=(s,e)=>({...Pn,getSource:()=>null,toString:()=>qi(s,e)}),rg=(s,e=!1)=>{if(!s)throw new Error(Zl);if(ec.test(s)){if(!e)throw new Error((n=>`${n?`'${n}'`:Qi} can not contain any of the following characters '\\ , / , * , ? , : , [ , ]'.`)(s));s=s.replace(ec,"")}if(s.length===0)throw new Error(Zl);const t=s.length;if(t>31){if(!e)throw new Error(jy);s=s.substring(0,31)}if(s.charAt(0)==="'"||s.charAt(t-1)==="'"){if(!e)throw new Error(Hy);s=s.replace(/^'|'$/g,"")}return s};class Zi extends ss{constructor(e,t,n,r){super(e,t,r),this._workbook=n}getSource(){return this._workbook}_createRanges(e,t){let n=this._options;return t&&(n={...this._options,getOptions:yn(this._options?.getOptions,t)}),new Zi(e,this._sheet,this._workbook,n)}_createRange(e,t){const n=e?{...e}:null;if(!(n&&this._workbook._getSheetRef(n.sheetName,exports.ISheet.Visibility.VeryHidden))){const o=this._workbook.getSelectedSheet();return delete n?.sheetName,Cf(n,n?{sheetName:Ke,...o.getEntireRange().getCoords()}:null)}let r=this._options;return t&&(r={...this._options,getOptions:yn(this._options.getOptions,t)}),new ea(e,this._sheet,this._workbook,r)}async select(e){const t=[];let n=null;const r=this.getCoords();for(let l=0;l<r.length;l++){const c=r[l];c&&(n||(n=c.sheetName),c&&c.sheetName===n&&t.push(c))}n||(n=this._workbook.getSelectedSheet().getName());const o=this._workbook.getSheets().getByName(n);if(!o)return;const i=await o.getRanges(t).select(e),a=this._workbook._rangesAddressToCoords(i.getCoords());return this._createRanges(a,e)}addListener(e,t){if(!this.getCoords())return()=>{};const n=this._workbook._sheetToWBEvent(e);return super.addListener(n,t)}get[Symbol.toStringTag](){return"[WorkbookRanges]"}toString(){const e=this.getCoords(),t=this._sheet,n=t.getEntireRange().getCoords(),r={sheetName:t.getName(),...n};return Lm(e,r,qi,Hn)}}class ea extends is{constructor(e,t,n,r){super(e,t,r),this._workbook=n}_createRanges(e,t){let n=this._options;return t&&(n={...this._options,getOptions:yn(this._options?.getOptions,t)}),new Zi(e,this._sheet,this._workbook,n)}_createRange(e,t){const n=this._sheet;if(!e)return fn(n,n._entireCoords);if(n._validateCoords(e),n._closed)return fn(null,n._entireCoords,e);let r=this._options;return t&&(r={...this._options,getOptions:yn(this._options?.getOptions,t)}),new ea(e,this._sheet,this._workbook,r)}getSource(){return this._workbook}get[Symbol.toStringTag](){return"[WorkbookRange]"}toString(){const e=this._sheet,t=e?.getEntireRange().getCoords()??null;return qi(this.getCoords(),{...t,sheetName:e.getName()})}addListener(e,t){if(!this.getCoords())return()=>{};const n=this._workbook._sheetToWBEvent(e);return super.addListener(n,t)}}class Uy{constructor(e){this._lastTransactionUUID=null,this._closed=!1,this._initializing=!0,this._emitter=null,this._names=null,this._calculation=null,this._isDate1904=!1;const t=this,n={...e},r=n.json;delete n.json,this._transactions=n.transactions??new Bt,this._ownTransactions=!n.transactions,this._emitter=new st(this,this._transactions);const o=this._beginCommit({description:(r?"Open":"New")+" Workbook"});try{this._strings=n.strings??new Yi,this._ownStrings=!n.strings,this._resources=n.resources??new bc,this._ownResources=!n.resources,this._createSheetName=n.createSheetNameCallback??$y;let i=n.createSheetCallback;i||(i=l=>new Gr(l)),this._sheetOnNameChange=new Map,this._sheetOnVisibilityChange=new Map,this._sheetOnIndexChange=new Map,this._createSheet=(l,c,h,u,d)=>{let g=null;const m={date1904:t.isDate1904(),readonly:t._options.readonly??!1,transactions:t._transactions,styles:t._styles,strings:t._strings,resources:t._resources,names:t._names,calculation:t._calculation,resolveRange:f=>t._options.resolveRange?.(f)??t.getRange(f),container:{beforeFromJSON:f=>{g=f,t._addSheetRef({name:c,id:l,visibility:h??exports.ISheet.Visibility.Visible,sheet:f},u)},getName:()=>{const f=t._getSheetRef(g);return f?f.name:t._createSheetName(1)},setName:f=>{t._getSheetRef(g)&&t._setSheetName(g,f)},getIndex:()=>{const f=t._getSheetRef(g);return f?t._findOffsetForId(f.id,t._getSheetRefs(exports.ISheet.Visibility.VeryHidden)):-1},setIndexCallback:f=>{t._sheetOnIndexChange.set(l,f)},setNameChangeCallback:f=>{t._sheetOnNameChange.set(l,f)},getVisibility:()=>{const f=t._getSheetRef(g);return f?f.visibility:exports.ISheet.Visibility.Visible},setVisibility:f=>{t._setSheetVisibility(g,f)},setVisibilityCallback:f=>{t._sheetOnVisibilityChange.set(l,f)},duplicate:()=>t._duplicateSheet(g),setPosition:f=>{const _=t._getSheetRef(g,exports.ISheet.Visibility.VeryHidden);return!!_&&(t._moveSheet(_,f),!0)},requestSelect:async()=>(t._setSelectedSheet(g),await this._emitter.notify("onRequestSelect",{source:t,params:g,async:!0}),t.getSelectedSheet()===g)}};return d&&(m.json=d),g=i(m,c,u,h),g},this._names=n.names??new mf({addressToRanges:l=>t.getRanges(l),getCurrentScope:()=>t.getSelectedSheet().getName(),isReadOnly:()=>t._options.readonly??!1,transactions:t._transactions}),this._ownNames=!n.names,this._calculation=n.calculation??new xc({getNamed:(l,c)=>{try{vr.address=l,vr.scope=c;const h=this._names.search(vr);return h&&h.length!==0?h[0].getRanges().getCoords():null}catch{return null}},getSheetIndex:l=>{if(l===void 0)return t.getSelectedSheetIndex();const c=this._getSheetRefs(exports.ISheet.Visibility.Hidden);l=l.toLowerCase();for(let h=0;h<c.length;h++)if(c[h].name.toLowerCase()===l)return h;try{vr.address=l,vr.scope=void 0;const h=this._names.search(vr);if(!h||h.length===0)return-1;let d=h[0].getRanges().getCoords()?.[0]?.sheetName;if(!d)return-1;const g=this._getSheetRefs(exports.ISheet.Visibility.Hidden);d=d.toLowerCase();for(let m=0;m<g.length;m++)if(g[m].name.toLowerCase()===d)return m}catch{return-1}return-1},getSheetCount:()=>t.getSheets().getCount(),isDate1904:()=>t.isDate1904(),strings:t._strings,transactions:t._transactions}),this._ownsCalculation=!n.calculation,this._scripts=this._createScripts(),this._ownNames=!n.names,this._options={...n};const a=async()=>{this._ownsCalculation&&await this._calculation.start(),await this._scripts.start(),this._starting=null};this._starting=a(),r?this._fromJSON(r):(this._initState(),this._addSheet(!1)),this._emitter.notify("onLoad"),o.commit()}catch(i){throw o.rollback(),i}this._sheets=new Vy(i=>t._addSheetOptions(i),(i,a)=>i?[this.getSheet(i,a)]:this._getSheets(a)),this._initializing=!1}_initState(){let e=this._getSheetRefs();for(let r=e&&e.length-1;r>=0;r--);this._isDate1904=this._options.date1904??!1,this._theme=this._options.theme??new mc().getDefaultTheme(),this._styles=this._options?.styles??new Jr(this._theme),this._ownStyles=!this._options.styles,this._styles.getTheme()||this._styles.setTheme(this.getTheme()),this._activeSheetOffset=0,this.setView(new Ql),this._listenerProtection?.(),this._protection=new tg(void 0,this._options.readonly??!1),this._listenerProtection=this._protection.addListeners({onChange:r=>{t._emitter.notify("onProtectionChange")}});const t=this;this._transactionsRemoveListener=this._transactions.addStateListener(this,{onAfterStateChange(r,o,i){if(o&&o.activeSheetId!==void 0&&o.view===t.getView()&&i.getId()===t._lastTransactionUUID&&t._getSheetRef(o.activeSheetId)?.sheet.select(),o&&i.getId()!==t._lastTransactionUUID){let a=t.getView().getActiveSheetId();o.view===t.getView()&&(a=o.activeSheetId);let l=0;try{l=t._findOffsetForId(a,r.sheetRefsVisible)}catch{}t._activeSheetOffset=l}t._lastTransactionUUID=i.getId(),t._notifyAllChange()},onRestoreOrRevert(){t._emitter.notify("onInvalidated")}});const n=this._getState();n?.listenersSheets&&(n?.listenersSheets.forEach(r=>{r()}),n?.listenersSheets.clear()),this._updateState({sheetRefsAll:[],sheetRefsVisibleAndHidden:[],sheetRefsVisible:[],refsById:new Map,sheetsById:new Map,refsByLowerCaseName:new Map,sheetsByLowerCaseName:new Map,refsByInstance:new Map,lastId:-1,sheetsCreated:new Set,listenersSheets:new Map})}getView(){return this._view}setView(e){if(this._closed)throw new Error(at);if(!e)throw new Error("View can not be empty.");this._listenerWorkbookView?.();const t=this;return this._listenerWorkbookView=e.addListeners({onViewChange:n=>{const r=t._getState();this._activeSheetOffset=this._findOffsetForId(this._view.getActiveSheetId(),r.sheetRefsVisible),t._emitter.notify("onViewChange")}}),this._view=e,t._emitter.notify("onViewChange"),this}isDate1904(){return this._isDate1904}setDate1904(e){if(this._closed)throw new Error(at);return this._isDate1904=e,this._notifyAllChange(),this}getStyles(){return this._styles}getResources(){return this._resources}getTransactions(){return this._transactions}getStrings(){return this._strings}getTheme(){return this._theme}setTheme(e){if(this._closed)throw new Error(at);if(!e)throw new Error("A value must be provided.");const t=this._theme;return this._theme=e,this.getStyles().setTheme(e),this._emitter.notify("onThemeChange"),t}getSelectedSheetIndex(){return this._activeSheetOffset}getSelectedSheet(){const e=this._getSheetRef(this.getSelectedSheetIndex());return e?e?.sheet:null}getSheet(e,t=exports.ISheet.Visibility.Visible){const n=this._getSheetRef(e,t);if(!n)throw new Ne(`Sheet '${e}' not found.`);return n.sheet}getSheetAt(e,t=exports.ISheet.Visibility.Visible){const n=this._getSheetRef(e,t);if(!n)throw new Ne((r=>`No sheet found at ${r}.`)(e));return n.sheet}getSheets(){return this._sheets}_getSheets(e=exports.ISheet.Visibility.Visible){const t=this._getSheetRefs(e),n=[];for(let r=0;r<t.length;r++)n.push(t[r].sheet);return n}_getSheetRefs(e=exports.ISheet.Visibility.Visible){if(this._closed)return N.EmptyArray;const t=this._getState();return t?e===exports.ISheet.Visibility.Visible?t.sheetRefsVisible:e===exports.ISheet.Visibility.Hidden?t.sheetRefsVisibleAndHidden:e===exports.ISheet.Visibility.VeryHidden?t.sheetRefsAll:N.EmptyArray:[]}_getSheetRef(e,t=exports.ISheet.Visibility.Visible){if(this._closed)return null;let n=null;return typeof e=="number"?this._getSheetRefs(t)[e]:(typeof e=="string"?n=this._getState().refsByLowerCaseName.get(e.toLowerCase()):e instanceof Gr?n=this._getState().refsByInstance.get(e):e?.id&&e.sheet&&(n=this._getState().refsById.get(e.id)),n)}_validateNewSheetName(e,t=!0){if(e==null)return e;if(rg(e),t&&this._getState().sheetsByLowerCaseName.has(e.toLowerCase()))throw new Error("That name is already taken. Try a different one.");return e.substring(0,31)}findValidSheetName(e){e&&(e=rg(e,!0));try{return((t,n)=>{try{if(n(t))return t}catch{}let r,o,i=Gy.exec(t);for(i!==null?(r=t.substring(0,i.index),o=parseFloat(i[1])):(r=t+" ",o=1);o<256;){o++;const a="("+o+")",l=r.substring(0,31-a.length)+a;try{if(n(l))return l}catch{}}throw new Error(t+" is not a valid sheet name")})(e,t=>this._validateNewSheetName(t))}catch{return this._nextSheetName()}}isValidSheetNameCharacter(e){return!ec.test(e)}_addSheetOptions(e){if(this._closed)throw new Error(at);if(!this.getProtection().isStructureAllowed())throw new Error($n);let t=null;e={...e,description:e?.description??"Add Sheet"};const n=this.beginCommit(e);try{t=this._addSheet(!0,e.name,e.index??null);const r=this.getView().getActiveSheetId();let o,i;if(e.autoSelect!==!1){let a=this.getView().getActiveSheetId();a=this._getSheetRef(t).id,e?.autoSelect&&(o={view:this.getView(),activeSheetId:r},i={view:this.getView(),activeSheetId:a})}if(n.commit({description:`Add Sheet '${t.getName()}'`,viewBefore:o,viewAfter:i}),e.autoSelect!==!1){const a=typeof e.autoSelect=="boolean"?void 0:e.autoSelect;t.select(a)}}catch(r){throw n.rollback(),r}return t}_nextSheetName(e=null){let t=e?e.toLowerCase():null;const n=this._getState(),r=n.sheetsByLowerCaseName;if(e&&r.has(t))throw new Error((i=>`The sheet name '${i}' already exist in workbook.`)(e));t=(e=this._validateNewSheetName(e))?e.toLowerCase():null;let o=n.lastId+1;for(;!e;){const i=this._createSheetName(o),a=i.toLowerCase();r.has(a)?o++:e=i}return this._updateState({lastId:o}),e}_addSheet(e,t=null,n=null){t=this._nextSheetName(t);const r=this._getState(),o=this._createSheet(r.lastId,t,exports.ISheet.Visibility.Visible,n,null);if(!o)throw new Error(Zl);return e&&this._emitter.notify("onSheetsChange"),o}_updateSheetRefStates(e){if(this._closed)throw new Error(at);if(!this._initializing&&!this.getProtection().isStructureAllowed())throw new Error($n);const t=e,n=[],r=[];for(let o=0;o<t.length;o++)t[o].visibility===exports.ISheet.Visibility.Visible?(n.push(t[o]),r.push(t[o])):t[o].visibility===exports.ISheet.Visibility.Hidden&&r.push(t[o]);this._updateState({sheetRefsAll:t,sheetRefsVisible:n,sheetRefsVisibleAndHidden:r})}_addSheetRef(e,t=null){const n=this._getState(),r=n.sheetRefsAll,o=Math.max(0,Math.min(r.length,t??r.length));let i=[...r.slice(0,o),e,...r.slice(o)];this._updateSheetRefStates(i);const a=e.sheet,l=e.name.toLowerCase(),c=new Map(n.refsById);c.set(e.id,e);const h=new Map(n.refsByLowerCaseName);h.set(l,e);const u=new Map(n.refsByInstance);u.set(a,e);const d=new Map(n.sheetsById);d.set(e.id,a);const g=new Map(n.sheetsByLowerCaseName);g.set(l,a);const m=this;let f=n.listenersSheets;if(a!==void 0){const S=a.addListeners({onBeforeDelete:C=>{m._validateDeleteSheet(C)},onDelete(C){let y=m._getSheetRef(C,exports.ISheet.Visibility.VeryHidden);if(!y)return;const b=m._beginCommit({description:`Remove Sheet ${y.name}`});try{const w=m._getState(),E=w.sheetRefsAll,I=m._findOffsetForId(y.id,E);let x=[...E];x.splice(I,1),m._updateSheetRefStates(x);const v=new Map(w.refsById);v.delete(y.id);const R=new Map(w.sheetsById);R.delete(y.id);const A=y.name.toLowerCase(),M=new Map(w.refsByLowerCaseName);M.delete(A);const T=new Map(w.sheetsByLowerCaseName);T.delete(A);const F=new Map(w.refsByInstance);F.delete(C),w.listenersSheets.get(y.id)();const L=new Map(w.listenersSheets);L.delete(y.id),m._adjustRemoveSelectionIfRequired(I,y.id),m._adjustSheetNamesIfRequired(),m._emitter.notify("onSheetsChange");const D=new Set(w.sheetsCreated);D.has(a)&&D.delete(a),m._updateState({refsById:v,sheetsById:R,refsByLowerCaseName:M,sheetsByLowerCaseName:T,refsByInstance:F,sheetsCreated:D,listenersSheets:L}),b.commit()}catch(w){throw b.rollback(),w}}});f=new Map(n.listenersSheets),f.set(e.id,S)}let _=n.lastId;_!==-1&&(_=Math.max(_,e.id)),this._updateState({lastId:_}),this._updateState({refsById:c,refsByLowerCaseName:h,refsByInstance:u,sheetsById:d,sheetsByLowerCaseName:g,listenersSheets:f}),this._adjustSheetNamesIfRequired();const p=new Set(this._getState().sheetsCreated);return p.add(e.sheet),this._updateState({sheetsCreated:p}),e}_adjustRemoveSelectionIfRequired(e,t){if(this._view.getActiveSheetId()===t){let n;const r=this._getState().sheetRefsVisible;n=e<r.length?r[e].id:r[e-1].id,this._view.setActiveSheetId(n)}}_adjustSheetNamesIfRequired(){const e=this._getState(),t=e.lastId;if(t===-1)return;let n=this._view.getActiveSheetId();n==null&&(this._view.setActiveSheetId(t),n=t),e.refsById.get(n).visibility===exports.ISheet.Visibility.Visible&&(this._activeSheetOffset=this._findOffsetForId(n,e.sheetRefsVisible))}_validateDeleteSheet(e){if(this._closed)throw new Error(at);if(!this.getProtection().isStructureAllowed())throw new Error($n);let t=this._getSheetRef(e);if(!t)throw new Error((r=>`Invalid reference for delete: ${r}`)(e));const n=this._getState().sheetRefsVisible;if(n.length===1&&n[0].id===t.id)throw new Error(Sl)}_findOffsetForId(e,t){for(let n=0;n<t.length;n++)if(t[n].id===e)return n;throw new Error(ng)}find(e,t){if(this._closed)throw new Error(at);const n=this._getSheets();if(n.length===1)return n[0].find(e,t);const r=!t?.reverse;let o=t?.disableWrap??!1;const i=this.getSelectedSheetIndex();let a=i,l=n[a],c=!1;t={...t,disableWrap:!0};let h,u=l.find(e,t),d=u.next(),g=!1;if(t?.from){const _=this._rangesAddressToCoords(t?.from);h={colIndex:_[0].colStart,rowIndex:_[0].rowStart}}else h={colIndex:0,rowIndex:0};const m=k.createCellComparator(t?.orientation,t?.reverse);delete(t={...t}).from;const f=()=>{if(!g&&d.done&&(c&&a===i?g=!0:r?(a++,a>n.length-1&&(a=0,c=!0)):(a--,a<0&&(a=n.length-1,c=!0)),o&&c&&(g=!0),!g))return l=n[a],u=l.find(e,t),d=u.next(),d;if(!g&&c&&a===i&&(d.done||!d.done&&m(d.value.getCoords(),h)>=0)&&(g=!0),g)return Re;const _=d;return d=u.next(),_};return{next:()=>{let _=f();for(;!g&&_.done;)_=f();return _}}}replace(e,t,n){let r=0,o=null;const i=typeof t=="function",a=n?.maxCount??Number.MAX_SAFE_INTEGER;let l=n.maxCount?"":"All";const c=typeof t=="string"?` with '${em(t)}'`:"";let h=n?.description??"Replace";const u=this._transactions.beginCommit({description:h});try{let d=null,g=null,m=e.next();for(;!m.done&&r<a;){const f=m.value,_=f.getSource();_!==d&&(d=_,g!==null&&g.apply(),g=d.getEntireRange().startIncrementalUpdates({orientation:n?.orientation,allowUnorderedWrites:!0}));const p=i?t(f):t;p!==void 0&&p!==f&&(g.push(f,p),r++,o=f),m=e.next()}g?.apply(),r===1&&a===1&&o&&(l=o.getA1()),u.commit({description:n?.description??`Replace ${l}${c}`})}catch(d){throw u.rollback(),d}return{count:r,last:o}}_nextSheetIndex(e,t=this._getSheetRefs()){return t.length===1?0:(e===void 0&&(e=this.getSelectedSheetIndex()),(e=Math.max(0,Math.min(e,t.length-1)))>=t.length-1?0:e+1)}_prevSheetIndex(e,t=this._getSheetRefs()){return t.length===1?0:(e===void 0&&(e=this.getSelectedSheetIndex()),(e=Math.max(0,Math.min(e,t.length-1)))<=0?t.length-1:e-1)}getNextSheet(e){if(this._closed)throw new Error(at);const t=this._getSheetRefs();return t[this._nextSheetIndex(e,t)]?.sheet??null}getPreviousSheet(e){if(this._closed)throw new Error(at);const t=this._getSheetRefs();return t[this._prevSheetIndex(e,t)]?.sheet??null}async _duplicateSheet(e){if(this._closed)throw new Error(at);if(!this.getProtection().isStructureAllowed())throw new Error($n);const t=this._getSheetRefs(),n=this.getSelectedSheetIndex();let r=null;if(e){if(r=this._getSheetRef(e),!r)throw new Error(_l(r))}else r=t[n];if(!r)return null;const o=r.sheet,i=this._strings.beginPersist(),a=this.getResources().beginPersist(),l=this.getStyles().beginPersist();let c=null;const h=this.beginCommit(`Duplicate '${o.getName()}'`);try{const u=this._getState().refsByInstance.get(o),d=await o.toJSON(),g=t.length+1,m=this.findValidSheetName(u.name),f=this._createSheet(g,m,u.visibility,n,d);this._emitter.notify("onSheetsChange"),c=f,h.commit()}catch(u){throw h.rollback(),u}finally{l.endPersist(),a.endPersist(),i.endPersist()}return c}_createRange(e,t){const n=e?{...e}:null;if(!(n&&this._getSheetRef(n.sheetName,exports.ISheet.Visibility.VeryHidden))){const i=this.getSelectedSheet();return i?(delete n?.sheetName,Cf(n,n?{sheetName:Ke,...i.getEntireRange().getCoords()}:null)):void console.warn(ng)}const r=this.getSelectedSheet();let o=null;return t&&(o={getOptions:t}),new ea(e,r,this,o)}_createRanges(e,t){const n=this.getSelectedSheet();let r=null;return t&&(r={getOptions:t}),new Zi(e,n,this,r)}getRange(e,t){try{const n=this._rangesAddressToCoords(e);if(n.length!==1)throw new Error(jm);return this._createRange(n[0],t)}catch(n){throw n instanceof Ne?new Ne(n.message):new Error(n.message??$o(e))}}getRanges(e,t){const n=this._rangesAddressToCoords(e);if(n.length===0)throw new Error($o(e));return this._createRanges(n,t)}_activeRangeCoords(){const e=this.getSelectedSheet(),t=Rr(e.getSelection().getCoords()),n=e.getName(),r=[];for(let o=0;o<t.length;o++)r.push({sheetName:n,...t[o]});return r}getSelectedRange(e){return this.getRange(this._activeRangeCoords()[0],e)}getSelectedRanges(e){return this.getRanges(this._activeRangeCoords(),e)}getSelectedCell(){return this.getSelectedSheet().getSelectedCell()}_rangesAddressToCoords(e,t=!0,n=exports.ISheet.Visibility.Hidden){if(!e)throw new Error(Dr);const r=this.getSelectedSheet(),o=r?.getEntireRange().getCoords(),i={...o},a=r?.getName();if(a&&(i.sheetName=a),typeof e=="string"){const h=e.trim().toLowerCase();if(h==="r"||h==="c"){const u=this.getSelectedCell().getCoords(),d={};h==="r"?d.rowStart=d.rowEnd=u.rowIndex:d.colStart=d.colEnd=u.colIndex,e=d}}const l=this,c=wc(e,i,os,h=>{if(!t)return null;if(typeof h=="string"){const u=l.getNames().getByName(h);if(u)return u.getRanges()?.getCoords()}throw new Error(`Invalid sheet reference '${h}'.`)});for(let h=0;h<c.length;h++)this._validateCoords(c[h],n);return c}_validateCoords(e,t=exports.ISheet.Visibility.Visible,n=Ti){if(e===null)return;const r=this.getSheet(e.sheetName,t).getEntireRange().getCoords();if(!k.isRangeWithinRange(e,r))throw new Ne(n);if(e.rowEnd<e.rowStart||e.colEnd<e.colStart)throw new Error(Hm)}_updateSheetRef(e,t){const n=this._getState();let r=[...n.sheetRefsAll];r[this._findOffsetForId(e.id,n.sheetRefsAll)]=t,this._updateSheetRefStates(r);const o=new Map(n.refsById);o.set(e.id,t);const i=e.name.toLowerCase(),a=t.name.toLowerCase(),l=new Map(n.refsByLowerCaseName);l.delete(i),l.set(a,t);const c=new Map(n.sheetsByLowerCaseName);let h=c.get(i);c.delete(i),c.set(a,h);const u=new Map(n.refsByInstance);return u.set(h,t),this._updateState({refsById:o,refsByLowerCaseName:l,sheetsByLowerCaseName:c,refsByInstance:u}),t}_setSheetName(e,t){if(this._closed)throw new Error(at);if(!this.getProtection().isStructureAllowed())throw new Error($n);const n=this._getSheetRef(e);if(!n)throw new Error(_l(e));if(t===n.name)return n.sheet;t=this._validateNewSheetName(t);const r=Object.freeze({...n,name:t});let o=null;const i=this.beginCommit("Rename Sheet");try{const a=this._updateSheetRef(n,r);this._adjustSheetNamesIfRequired(),this._sheetOnNameChange.forEach((l,c)=>{n.id===c&&l()}),this._emitter.notify("onSheetsChange"),o=a.sheet,i.commit()}catch(a){throw i.rollback(),a}return o}_setSheetVisibility(e,t=exports.ISheet.Visibility.Visible){if(this._closed)throw new Error(at);if(!this.getProtection().isStructureAllowed())throw new Error($n);const n=this._getSheetRef(e);if(!n)return null;if(t===n.visibility)return;let r=null,o="";t===exports.ISheet.Visibility.Visible?o="Unhide Sheet":t===exports.ISheet.Visibility.Hidden?o="Hide Sheet":t===exports.ISheet.Visibility.VeryHidden&&(o="Very Hide Sheet");const i=this.beginCommit(o);try{const a=this._getState().sheetRefsVisible;if(t!==exports.ISheet.Visibility.Visible&&a.length===1&&a[0].id===n.id)throw new Error(Sl);const l={...n,visibility:t};let c=-1;t!==exports.ISheet.Visibility.Visible&&(c=this._findOffsetForId(n.id,a));const h=this._updateSheetRef(n,l);t!==exports.ISheet.Visibility.Visible&&this._adjustRemoveSelectionIfRequired(c,n.id),r=h.sheet,this._adjustSheetNamesIfRequired(),i.commit()}catch(a){throw i.rollback(),a}return this._sheetOnVisibilityChange.forEach((a,l)=>{n.id===l&&a()}),this._emitter.notify("onSheetsChange"),r}_moveSheet(e,t){if(this._closed)throw new Error(at);if(!this.getProtection().isStructureAllowed())throw new Error($n);let n=null;const r=this.beginCommit(`Move Sheet '${e.name}'`);try{const o=this._getState(),i=o.sheetRefsVisible;if(t<0||t>i.length-1)throw new Error(`Invalid to index: ${t}`);const a={view:this.getView(),activeSheetId:this.getView().getActiveSheetId()},l=o.sheetRefsAll,c=this._findOffsetForId(e.id,l),h=this._findOffsetForId(i[t].id,l);if(c===h)return;const u=l[c];let d=[...l];d.splice(c,1),d.splice(h,0,u),this._updateSheetRefStates(d),this._adjustSheetNamesIfRequired(),this._sheetOnIndexChange.forEach((g,m)=>{m>=c&&m<=h&&g()}),this._emitter.notify("onSheetsChange"),n=u.sheet,r.commit({viewBefore:a,viewAfter:{view:this.getView(),activeSheetId:this.getView().getActiveSheetId()}})}catch(o){throw r.rollback(),o}return n}_setSelectedSheet(e){if(this._closed)throw new Error(at);const t=this._getSheetRef(e);if(!t)throw new Error(_l(e));let n=null;return t.visibility!==exports.ISheet.Visibility.Visible&&this._setSheetVisibility(t,exports.ISheet.Visibility.Visible),this._view.setActiveSheetId(t.id),n=t.sheet,n}getProtection(){return this._protection}getNames(){return this._names}getCalculation(){return this._calculation}getScripts(){return this._scripts??null}_notifyAllChange(){this._emitter.notify("onSheetsChange"),this._emitter.notify("onViewChange")}addListeners(e,t){return this._emitter.addListeners(e,t)}_sheetToWBEvent(e){const t=this;return n=>{const r=()=>{const i=n.getSource();if(i.isICellRanges){const a=[...i.getCoords()];for(let l=0;l<a.length;l++){const c=a[l];!c.sheetName&&i.getSource().getName()&&(a[l]={...c,sheetName:i.getSource().getName()})}return t.getRanges(a)}if(i.isICellRange){const a=i.getCoords(),l=i.getSource().getName();return t.getRange({...a,sheetName:l})}},o={getSource:r,trigger:n.trigger,getFrom:()=>t.getRanges(n.getFrom()),getTo:()=>t.getRange(n.getTo()),isDataChange:n.isDataChange,isTransactional:n.isTransactional,isUndo:n.isUndo,toString:()=>`WorkbookRangeEvent: ('${n.trigger}', ${r().toString()})`,timeStamp:Date.now()};e(o)}}_fromJSON(e){if(this._emitter.notify("onBeforeLoad",{params:e}),this._initState(),!e.sheets||e.sheets.length===0)throw new Error(Sl);e.theme&&(this._theme=new xi(e.theme),this._styles.setTheme(this._theme));const t=this._strings.beginPersist(),n=this._resources.beginPersist(),r=this._styles.beginPersist();try{t.fromJSON(e.strings),n.fromJSON(e.resources),r.fromJSON(e.styles),e.date1904&&(this._isDate1904=!0),e.view||(e.view={});const o=e.sheets,i=o.length;let a=e.view.activeSheetId??null;a!==null&&(a=Math.min(Math.max(1,a),i));let l=null;for(let h=0;h<i;h++){const u=o[h],d=u.visibility||exports.ISheet.Visibility.Visible,g=h+1;d===exports.ISheet.Visibility.Visible?l=g:a!==null&&a===g&&(a=null),this._createSheet(g,u.name,d,void 0,u.sheet)}this._updateState({lastId:l}),e.names&&this._names.fromJSON(e.names),e.view.activeSheetId=a??l,this.setView(new Ql({json:e.view})),this._adjustSheetNamesIfRequired(),this._listenerProtection?.();const c=this;this._protection=new tg(e?.protection,this._options?.readonly),this._listenerProtection=this._protection.addListeners({onChange:h=>{c._emitter.notify("onProtectionChange",{source:h})}}),e.scripts&&(this._scripts=this._createScripts(e.scripts)),this._emitter.notify("onLoad")}finally{r.endPersist(),n.endPersist(),t.endPersist()}}_createScripts(e){return new zy({transactions:this._transactions,json:e,workbook:this,onAdd:(t,n)=>{const r=this._calculation;r.getStatus()!==exports.ICalculation.Status.Off&&r.start().then(()=>{const o=n.getFunctions().search({type:"formula"});for(let i=0;i<o.length;i++){const a=o[i];this._calculation.getFunctions().add(a)}})},onRemove:(t,n)=>{}})}async toJSON(e=!1){if(this._closed)throw new Error(at);await this._emitter.notify("onBeforeSave",{async:!0});const t={sheets:[]};await Promise.resolve(this._starting);const n=this._theme.toJSON();(n?Object.keys(n).length:0)>0&&(t.theme=n);const r=this._strings.beginPersist(),o=this._resources.beginPersist(),i=this._styles.beginPersist();try{const a=this._getSheetRef(this.getSelectedSheetIndex()).id;let l=a,c=null;const h=this._getState(),u=h.sheetRefsAll,d=h.sheetsById;for(let C=0;C<u.length;C++){const y=u[C],b=C+1,w=await d.get(y.id).toJSON(e),E={name:y.name,sheet:w};y.visibility===exports.ISheet.Visibility.Visible?c=b:E.visibility=y.visibility,y.id===a&&(l=b),t.sheets.push(E)}const g=i.toJSON();g&&Object.keys(g).length>0&&(t.styles=g);const m=this.getProtection().toJSON();m&&(t.protection=m);const f=await r.toJSONAsync();f&&f.length>0&&(t.strings=f);const _=await o.toJSONAsync();_&&_.length>0&&(t.resources=_);const p=this._names.toJSON();p&&p.length>0&&(t.names=p);const S=this._view.toJSON();S&&(l!==c?S.activeSheetId=l:delete S.activeSheetId,Object.keys(S).length>0&&(t.view=S))}finally{i.endPersist(),o.endPersist(),r.endPersist()}if(this._scripts){const a=this._scripts.toJSON();a&&Object.keys(a).length>0&&(t.scripts=a)}return this._isDate1904&&(t.date1904=!0),this._emitter.notify("onSave",{params:t}),t}isClosed(){return this._closed}close(){if(this._closed)return;this._emitter.notify("onClose");const e=this._getState();e.listenersSheets.forEach(n=>{n()}),e.listenersSheets.clear();const t=e.sheetRefsAll;for(let n=t.length-1;n>=0;n--)try{t[n].sheet.close()}catch(r){console.warn("error on close",r)}this._ownResources,this._ownNames&&this._names.close(),this._ownsCalculation&&this._calculation.close(),this._ownStyles,this._transactionsRemoveListener?.(),this._closed=!0}beginCommit(e){if(this._closed)throw new Error(at);return this._beginCommit(typeof e=="string"?{description:e}:e)}doBatch(e,t){const n=this;return t=typeof t=="string"?{description:t}:{description:"Update Workbook",...t},this._transactions.doBatch(e,t,(r,o)=>{r.getDepth()===0&&(n._lastTransactionUUID=r.getId())})}_beginCommit(e){const t=this;return this._transactions.beginCommit(typeof e=="string"?{description:e}:e,n=>{n.getDepth()===0&&(t._lastTransactionUUID=n.getId())})}_getState(){return this._transactions.getState(this)}_updateState(e,t="Update Workbook"){if(!e)return;const n=this._beginCommit(t);try{n.updateState(this,e),n.commit()}catch(r){throw n.rollback(),r}}get options(){return this._options}get[Symbol.toStringTag](){return"[Workbook]"}toString(){return""}get isIWorkbook(){return!0}}const vr={address:null,scope:null};exports.$t=yg,exports.Calculation=xc,exports.Color=Ge,exports.ExternalRangeClipboardItem=class{constructor(s,e,t,n){if(this._parsed=void 0,!s)throw new Ot("nativeItems are required.");this._native=s,this._markOptions=Object.freeze(e??{}),this._styles=t,this._isDate1904=n}getItemType(){return"range"}isCut(){return!1}toText(){return this._native?.text}toHtml(){return this._native?.html?.documentElement.outerHTML||null}toImage(){return this._native?.image}getItem(){const s=this._parsed;if(s===void 0)throw new Error("Must call 'parse()' before getItem().");if(s===null)return null;if(this._snapshot)return this._snapshot;const e=this;return this._snapshot={copyTo:(t,n)=>s.copyTo(t,{...e._markOptions,...n}),getMarkOptions:()=>e._markOptions,getName:()=>s?.getName()??"Clipboard Data",getCoords:()=>s?.getCoords?.()??null,toText:()=>e.toText(),toHtml:()=>e.toHtml(),toImage:()=>e.toImage(),getSource:()=>s?.getSource?.()??null,isISnapshot:!0},this._snapshot}async parse(){let s,e=this._native?.text,t=this._native.html;if(t===null&&e&&e.includes("<table"))try{const n=new DOMParser().parseFromString(e,Me.html),r=n.querySelector("parsererror");if(r)throw new Error("Unable to parse: "+r);t=n,e=null}catch{console.warn("Discovered text as html table but could could not parse.")}try{const n=new iy(this._styles,this._isDate1904,t?"HTML":"Text"),r=await Promise.resolve(e?((i,a=" ")=>new Promise((l,c)=>{Promise.resolve().then(()=>require("./17vteff17iwu-nts.cjs")).then(h=>h.papaparse_min).then(h=>{try{const u=h.parse(i,{delimiter:a}).data;u.length>1&&(u[u.length-1].length===0||u[u.length-1].length===1&&u[u.length-1][0].length===0)&&u.pop(),l(u)}catch(u){console.warn(u),c(u)}},h=>{c(h)})}))(e):[[]]);let o;if(ly(t,r,n)?(s=n.sheet(),o=s.getUsedRange()):t=null,o)return this._parsed={async copyTo(i,a){return(await i.copyFrom(o,a))?.getCoords()??null},getCoords:()=>o.getCoords(),getSource:()=>s,getName:()=>s.getName()},!0}catch(n){throw n}if(!e&&!t&&this._native.image){const n=this;return this._parsed={async copyTo(r,o){const i=r.getSource(),a=await i.getMovables().addImage({buffer:n._native.image.arrayBuffer()},{type:"picture",description:"Copy Image from Clipboard"});return i.getView().selectMovables([a]),null},getName:()=>"Image"},!0}return!1}get isClipboardItem(){return!0}},exports.FormulaContext=uf,exports.GeomUtils=rp,exports.Gt=Yo,exports.Ht=Yn,exports.I=lg,exports.IFontCollection=T0,exports.Kt=k,exports.LicenseManager=oc,exports.M=U,exports.Picture=cf,exports.Qt=Bo,exports.RangeClipboardItem=class{constructor(s){if(!s)throw new Ot("snapshot is required.");this._snapshot=s}getItemType(){return"range"}getItem(){return this._snapshot}editMode(){return this._snapshot?.getMarkOptions().editMode??null}isCut(){return this._snapshot?.getMarkOptions().isCut??!1}getName(){return this._snapshot.getName()}toText(){return this._snapshot.toText()}toHtml(){return this._snapshot.toHtml()}toImage(){return this._snapshot.toImage()}get isClipboardItem(){return!0}},exports.Resource=fi,exports.ResourceCollection=bc,exports.Sheet=Gr,exports.SimpleFontFace=cm,exports.StringCollection=Yi,exports.StyleCollection=Jr,exports.Table=lf,exports.TextUtils=x0,exports.Theme=xi,exports.ThemeCollection=mc,exports.TransactionStore=Bt,exports.TransactionUndoManager=class extends Jc{constructor(s,e=50){super(e),this._transactions=s;const t=this;s?.addListener({onCommitEnd:n=>{n.getDescription()&&t.addUndoOperation({description:n.getDescription(),undo:()=>(s.revert(n.getId()),()=>{s.restore(n.getId())})})}})}clear(){super.clear()}close(){this._removeLister()}},exports.TypedFunction=Xo,exports.Vt=ln,exports.Workbook=Uy,exports.WorkbookView=Ql,exports.Wt=Oe,exports.Xt=Ar,exports.Yt=N,exports.Zt=pg,exports.ae=nc,exports.coerceScalar=Nt,exports.colToString=Dt,exports.defaultGetEntireCoords=Mi,exports.ee=class{constructor(){this._resolve=null,this._result=void 0,this._handled=null,this._reject=null,this._error=void 0,this._promise=null,this._promise=new Promise((s,e)=>{this._resolve=s,this._reject=e,this._handled==="resolve"?s(this._result):this._handled==="reject"&&e(this._error)})}resolve(s){this._resolve?this._resolve(s):this._handled||(this._result=s),this._handled="resolve"}reject(s){this._reject?this._reject(s):this._handled||(this._error=s),this._handled="reject"}async wait(){await this._promise}},exports.getDefaultExportFromCjs=uc,exports.gridFromArray=km,exports.h=Me,exports.ie=bl,exports.j=ag,exports.k=$r,exports.le=Uf,exports.minCoerce=ns,exports.ne=Ne,exports.oe=Ot,exports.re=Cg,exports.rowToString=Ht,exports.se=Jc,exports.te=Hs,exports.toAbsoluteRange=(s,e,t,n)=>{let r=s.colStart,o=s.rowStart,i=s.colEnd,a=s.rowEnd;const l=s.$colStart??!1,c=s.$rowStart??!1,h=s.$colEnd??!1,u=s.$rowEnd??!1;if(l||r===Number.MIN_SAFE_INTEGER||(r+=t),c||o===Number.MIN_SAFE_INTEGER||(o+=e),h||i===Number.MAX_SAFE_INTEGER||(i+=t),u||a===Number.MAX_SAFE_INTEGER||(a+=e),r>i){const g=r;r=i,i=g}if(o>a){const g=o;o=a,a=g}let d;return n?(d=n,d.colStart=r,d.rowStart=o,d.colEnd=i,d.rowEnd=a,d.$colStart=l,d.$rowStart=c,d.$colEnd=h,d.$rowEnd=u):d={colStart:r,rowStart:o,colEnd:i,rowEnd:a,$colStart:l,$rowStart:c,$colEnd:h,$rowEnd:u},s.sheetName&&(d.sheetName=s.sheetName),d},exports.tokensToA1=Sf,exports.tokensToR1C1=_f,exports.typeFromJsValue=Ye,exports.ut=vl,exports.y=ie,exports.z=Tf;
|