@sheetxl/mcp 0.8.0-beta.23 → 0.8.0-beta.24
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/assets/{CSisGJ4hiDhTi19U.js → 2YT_wstXIH6UIigi.js} +1 -1
- package/assets/{E-KM5RFByUxjlkId.js → 3VycPrqi6qgLOgGY.js} +6 -6
- package/assets/{B2zUUqxAJ1RiM7YI.js → 6CBUVbF01Bedq0e2.js} +43 -43
- package/assets/{BVUfaOAGhdMim8yB.js → 76dPHG5RYA7MUV_g.js} +3 -3
- package/assets/{CtlrxXVgZDIOcuc1.js → 7IzItpr7MkdnaAwh.js} +169 -169
- package/assets/{BBuB6ffvyg2Cd7V5.js → 7vPlH3_rhJxmmBvG.js} +1 -1
- package/assets/{aTxgpOOxLenli4af.js → 9GnbVPKozgrJpeLW.js} +1 -1
- package/assets/{DuQU8JjPLBIK804w.js → B-5mBXpY9i6-eCrZ.js} +29 -29
- package/assets/{CH8DNTUgM79xk8Tt.js → B-t1q2NS61c2B8E4.js} +1 -1
- package/assets/{BomatnedZsGMF7MW.js → B16G2473LTkZP6Mq.js} +150 -131
- package/assets/{DoP6myQHGI-X1gNy.js → B4uS01J0mrSJSftQ.js} +84 -84
- package/assets/{CC7EfXPwp7_nSBIz.js → B6caaQsfOpFEgYQ4.js} +1 -1
- package/assets/{2xkoVdiI70Gpaxoc.js → B7lATTNffVTrDsKE.js} +2 -2
- package/assets/{DgLQfXTWavoBetna.js → B8bEJ65vQRqsfBlS.js} +5 -5
- package/assets/{BGxwDpW8DkO8W0Ig.js → BAVltO4Xf7lC0Xr6.js} +1 -1
- package/assets/{CgYef9dYxY8YyUTE.js → BH7ctzMzOYVTGxzA.js} +1 -1
- package/assets/{CBMMHYgUAhgiJhJE.js → BJqo8c5bFKjnq69G.js} +11 -11
- package/assets/{CQCPJBQD0qv9y8qE.js → BJwiwzwx4Bl5L4Vq.js} +1 -1
- package/assets/{BJMeWtr7TiLNpt17.js → BPNLZ07Bu_B8Yhf1.js} +1 -1
- package/assets/{BWeaY19OpTJK5v0n.js → BWLavTnANLUerdS0.js} +2 -2
- package/assets/{gver5Sz7ZO6ZyrOi.js → BXWGS09xFG81nnIT.js} +1 -1
- package/assets/{DvkBNkPyR5kuS0Uo.js → BaYk1vO2hP2S3_1w.js} +2 -2
- package/assets/{PVGDjdR9C4stMNpM.js → BifwlrCmEVtjh_1U.js} +1 -1
- package/assets/{BPtf3_nlovO4r9Bm.js → BjyXkr-CzV8mVx0t.js} +1 -1
- package/assets/{DACd4ZjYwzNE7Koc.js → BkHeIMSE7-LehRCs.js} +1 -1
- package/assets/{DLuQ_rdu0XjYF7Jq.js → BkekCZ17YTtd07_C.js} +2 -2
- package/assets/{BDSNdgf_hbhX1DhN.js → BnNB_ejvNaLu6B3o.js} +1 -1
- package/assets/{f_dBJuakO_BJ7Tvm.js → BrJd9jVVv9SQzZol.js} +335 -335
- package/assets/{1J1R3dclFOh322Yr.js → BrYc6PLonux_gI6b.js} +209 -209
- package/assets/{CrTLWpsRNBSyTLor.js → BxwB3iTNSE1TgHkb.js} +1 -1
- package/assets/{Cx1bc-Dsja7W3GlB.js → By1QPrSxtnRiJu0R.js} +2 -2
- package/assets/{jKIDENA_QP4bEX49.js → ByYJTTTUuu67hDF-.js} +4 -4
- package/assets/{DXmebUOAhtW4V6BO.js → C-nA4SXN5hWHaxV6.js} +556 -556
- package/assets/{BNEBXKAh-N4Tygk7.js → C0uu0vLKQh0S508B.js} +23 -23
- package/assets/{Bjk1Twm0RFO_3fS8.js → C6PNMev7cs5JLgwy.js} +1 -1
- package/assets/{Cl04_aSpBHTwfsQR.js → C9iFJ52KwQTePQ81.js} +10248 -10246
- package/assets/{dep8oZGwBmUpxjHl.js → CCF6CwJ6cbeLRl23.js} +1 -1
- package/assets/{Cg1tSmK_AGJa2VeI.js → CEk658HeLJk2cAjM.js} +3 -3
- package/assets/{DiJexWBIzdGj1H0H.js → CFNtPYPfDPH-3BXK.js} +1 -1
- package/assets/CFT_tDogP98gTbh7.js +304 -0
- package/assets/{BKpicdc9H5WnZPb-.js → CFWwwr74qRKOBrg9.js} +1 -1
- package/assets/{5MnsnJcajdtAujE2.js → CIY_RiLu1_FmRLAA.js} +1 -1
- package/assets/{DcO0gub7cRKVw4xB.js → CIw6ZC3K9x-ccacl.js} +1 -1
- package/assets/{KhdF512BKcJXZMvq.js → CJ2hV-9ipqOEkLSG.js} +1 -1
- package/assets/{wKkW4LO-iUp92LVC.js → CKD460cQOgwF6uSV.js} +1 -1
- package/assets/{NDe-uS1n_Q7u1H3m.js → CM-q_J5aF6YXmjeu.js} +3 -3
- package/assets/{a9lvcAd7rWsWSWAo.js → CR1aLf7CWEfPTO9a.js} +1 -1
- package/assets/{BlhJHu9ni2T9IaM1.js → CSXmTA6w6Pnbtqvb.js} +1 -1
- package/assets/{DfBERTJjS9LP0RSp.js → CT4czEKWIj1GeQN8.js} +1 -1
- package/assets/{Dg5QmWm0uBTEjZy4.js → CUYQlZz5zWsUdmRy.js} +1 -1
- package/assets/{ChbkkN_JqbAGrUwB.js → CbJWbjmv4bz4ppIZ.js} +303 -303
- package/assets/{C8G_px4dGuR2KjJh.js → Cf0zmfQYfJ7zM0Ya.js} +1 -1
- package/assets/{2XwVsSfo5wF5K-HA.js → Ch9w7xFxVMrvGuC_.js} +1 -1
- package/assets/{BZaXHnsJ6RkCZsnz.js → CmkgQ5-IG0BSCM3R.js} +3 -3
- package/assets/{DZt1ONN8CTTfmHGn.js → CmwNIrRssYuLN2fn.js} +606 -606
- package/assets/{t4qTfgdlstczTs2z.js → CnI4Nli8vtWdFKvf.js} +21 -21
- package/assets/{BdUFL3lVdwifHrf0.js → CnKX5SPVE2iuSK42.js} +1 -1
- package/assets/{DPjWOMoJ-elAAOmS.js → CpvJUGg9ckuCIpIS.js} +1 -1
- package/assets/{DN1RRp4qQfCq3JAO.js → Cxzowsi6ASdZtzeI.js} +1 -1
- package/assets/{BYbzf-TVwbKQPCyK.js → CzRvg04_TIbwBH5C.js} +3 -3
- package/assets/{D7oYfHgO0kEqAnPV.js → D-vo2bQyAmStQmD9.js} +1 -1
- package/assets/{Cl8_HMhRgzPzqFc7.js → D6d1DKL15m52ZCuC.js} +1 -1
- package/assets/{DUytcsu0MV3GnsrM.js → D8k9de_hen-KqBWe.js} +1 -1
- package/assets/{B3YRTBFhX61z6rJv.js → DE7G34oYbvrfXbJ7.js} +385 -380
- package/assets/{YtxPcFPURJF6CxWu.js → DFVQIZ2zZyAphhCF.js} +1 -1
- package/assets/{BynbAjhJnLjyP7HH.js → DGI_8HyNF0eAv0P5.js} +1 -1
- package/assets/{DtETpSxSR8C1voac.js → DGOgx3-IyO8bjF_t.js} +94 -94
- package/assets/{CyhngJo16o7G18lq.js → DIgPlkEabQdKNUQn.js} +1 -1
- package/assets/{KMTTqSwDthnXnD4F.js → DJGYlGr2Zj7SkYqc.js} +1 -1
- package/assets/{BazhmjGvrL7pqVQP.js → DJfpKncnYnrr28G0.js} +1 -1
- package/assets/{DV3PnM9lo0AW-YOA.js → DL8pez0eKo8arYPj.js} +3 -3
- package/assets/{BcWSfKJ9Atkc0X_p.js → DM-yGHahbfA_uarn.js} +1 -1
- package/assets/{DIAQ_WlBCWhgHt-z.js → DMDTS0LH9Ke9t-3z.js} +1 -1
- package/assets/{D5O3m16KeyU_oXqH.js → DNSWaXblwhTtI3w7.js} +1 -1
- package/assets/{D-PYDPXobSWiPh1D.js → DOSWSyKkK4eSi4PD.js} +2 -2
- package/assets/{Bbmh8_bdk_HrQ5Y6.js → DPLTGglaPovTg9e5.js} +1 -1
- package/assets/{WuKVkvMPAOmRaCDY.js → DPYFRLJbHGlrcrJq.js} +2 -2
- package/assets/{CqP4H_-kRRjcxO91.js → DRq6lQLndj73WT35.js} +1 -1
- package/assets/{BI8kb-rd9dW85XJs.js → DRzZ4bEyLRGVOLzV.js} +1 -1
- package/assets/{CnUYevzhUJYNqLad.js → DUbIxDAzW1dzrtdI.js} +1 -1
- package/assets/{Dawi8y7JWn6A9gAx.js → DXCTHw-ZutNIuo_2.js} +1 -1
- package/assets/{CEsRqYMd5IjnAzzX.js → D_tdoUtUe7cApQJn.js} +4 -4
- package/assets/{WH1Vl-MDWX3vSMn1.js → DaF9L7No8h8a-cqb.js} +2 -2
- package/assets/{BULbMlvQuB2WFBFE.js → DaHD9SY75O8wDy3p.js} +2 -2
- package/assets/{C6_KHS3-ROddeSbS.js → Daaro0HbHkKXkBP-.js} +2 -2
- package/assets/{CE-9VKh5-Xwxnxmu.js → DczQhB3mRSUw6GCf.js} +1 -1
- package/assets/Dfv_T_PQVL0O3lu5.js +14 -0
- package/assets/{Cidwv57sKqhIrpHP.js → Dhy6iU_09lrQnOAV.js} +28 -28
- package/assets/{DL8wUEe2Kx7bjDYP.js → Dk9zYXO3VoBhTdex.js} +1 -1
- package/assets/{DrKr8dXQEQ3Aukmt.js → DkQ4kxEKhKYQgfjK.js} +1 -1
- package/assets/{BLr8y5StL65VZQxG.js → Dlqk7XqKnAZ8Pcj3.js} +89 -89
- package/assets/{CwrOCbcS4IHLsERQ.js → DqSBb1HmgeU7eg_i.js} +84 -84
- package/assets/{D60N4r1a2YsNEwqj.js → Ds4TB1hn56-RK6_f.js} +1 -1
- package/assets/{L9RIicOHtZd2Rx8g.js → DtVSjxL6N_7WyM8Z.js} +1 -1
- package/assets/{CGLapmkNccH1g_ZJ.js → DuEtCJEnG_GnJzTX.js} +1 -1
- package/assets/{DJ2jlogB1DWlGM-J.js → DwNcvKM47ZHfvQM6.js} +1 -1
- package/assets/{DbbNJyL67KdOK7nc.js → DyiH3LlinD-38bG7.js} +1 -1
- package/assets/{DSyZaCML62gSnudE.js → Jy-_0a72nn5Iv1NK.js} +1 -1
- package/assets/{CPZgEZ2jKoo7hS6g.js → KMzONx2Ps841nJHj.js} +8 -8
- package/assets/{CndRpNCcV89ncnqz.js → LM2rVDHdB0jVUFcT.js} +1 -1
- package/assets/{D5PpcRuJYSv0i2y9.js → MosMza0-rXD8uHX_.js} +2 -2
- package/assets/{sIWsnPhnHm_MeeM9.js → NAWWzA_hk4wYtsPP.js} +2 -2
- package/assets/{BbU6aT_c6-4tkcCw.js → P6V3JAiRpC3BWceC.js} +1 -1
- package/assets/{CzoRlNMlpFz4iax3.js → TZnuVwhVjkOBax9F.js} +2 -2
- package/assets/{BEsnJS5jYwkHNcZd.js → TdDTOcC1TYhk6UuR.js} +1 -1
- package/assets/{CE5DhB5As59VJ-Ig.js → Xccc6oxtlSvJUDsC.js} +1 -1
- package/assets/{BPorbjbkH-VoV1M0.js → a2e_g9YI3J-lUD7-.js} +1 -1
- package/assets/{MzfM7zDcnyOFK1lK.js → b8yACuWy67eIj_j2.js} +1 -1
- package/assets/{CpyybSV2kR6b-SIB.js → bv3fZLUPzd14I58C.js} +263 -263
- package/assets/{DAliB9N1z6qnw4NO.js → doqBmhonQlHp-1Ud.js} +1 -1
- package/assets/{CCBQDcCHI47PZ0YQ.js → fEfisM0E2fUYKIyU.js} +5 -5
- package/assets/{q1rCdlJA6Z7tA6om.js → flby0g5gyZ9P2Wu2.js} +1 -1
- package/assets/{DKKLWACR9GsidnkS.js → g2Nu44uuSJFMzxEV.js} +2 -2
- package/assets/{Bz08KxFupjbdsoFx.js → mZt9BTEejCJZ4YK4.js} +1 -1
- package/assets/{Dol52NFQzLCbObuC.js → qc7rA-Z3a4rkVQPx.js} +225 -225
- package/assets/{DL7_uGw6KiZhlvR8.js → sJVPCrgeh0U6LbAK.js} +1 -1
- package/assets/{CHG4ZuzhyjGRuKBg.js → suLYEZBtGUhSYeB7.js} +1 -1
- package/assets/{qjyVXZeVSr_qZfX5.js → tWO-mE87mAuj1qih.js} +2 -2
- package/assets/{PiFW6uPRJABzK3V1.js → xD41vsQY6h60lCqz.js} +14 -14
- package/assets/{CeVCLRwjkH3_OXJu.js → yz2PTfYm_8EGJPM5.js} +1 -1
- package/index.js +191 -191
- package/lib.js +1 -1
- package/licenses/dependencies.txt +114 -114
- package/package.json +2 -2
- package/screenshot-page/assets/{Ce8b0lOBuWKlfLzJ.js → B-0-chiwq4MIUQy9.js} +1 -1
- package/screenshot-page/assets/{C9a-cNha8mBw5q-l.js → B7pXfEVkcbaMBMhc.js} +1 -1
- package/screenshot-page/assets/{CAQ7QWes7j7Fq8o5.js → BDRMUi2BsnBqytIq.js} +1 -1
- package/screenshot-page/assets/{DrnzLCa7NIirMxno.js → BEjJHVSbtlsNtoq7.js} +3 -3
- package/screenshot-page/assets/{JM0_BaBZ3yF6lnHC.js → BIuMiduMHSsTGacU.js} +2 -2
- package/screenshot-page/assets/{DvRXbyteeo_8sy8T.js → BKwDvElKinpn1IK0.js} +1 -1
- package/screenshot-page/assets/{Cbbl3H042tb0krfe.js → BTJ1NNUzHotNDiDe.js} +2 -2
- package/screenshot-page/assets/BbT5KRhoeAKLzy54.js +2 -0
- package/screenshot-page/assets/{BAxPBeFudRJ3OqIC.js → BcZPWw18bdj_ZvA9.js} +1 -1
- package/screenshot-page/assets/{B2PWru6Ty7ODc2Ie.js → Bfq6-treWd_rRiWl.js} +1 -1
- package/screenshot-page/assets/{Bml69dFBVggmVWda.js → Bg9UyX4yrB2mSdJt.js} +23 -23
- package/screenshot-page/assets/Bxq4FCQhyPbVhhaR.js +2 -0
- package/screenshot-page/assets/{DEAD_MduPNVoT_T6.js → CNB6WmYfGVZjlCKV.js} +1 -1
- package/screenshot-page/assets/{DtQFcMvZesaQ4xRf.js → CSFFMEKyxEFaykqL.js} +1 -1
- package/screenshot-page/assets/{DXbOBAxx4_2rt5KM.js → CXeJV1BW2CVemhPE.js} +1 -1
- package/screenshot-page/assets/{DMbFr7oWja7Qpsm6.js → C_YKEkTsGB_5gFNg.js} +2 -2
- package/screenshot-page/assets/{D7Y0npF3FMsGUjgO.js → CkxmJxdtjBIxYoMq.js} +1 -1
- package/screenshot-page/assets/CtiTwHzd_ZSzd3W2.js +1 -0
- package/screenshot-page/assets/{ONNSfQ8RDOqBDsvw.js → CwCu_r0BW41uLt3P.js} +2 -2
- package/screenshot-page/assets/{CEL5lzj2NDYwJ-HC.js → Cx9eq2x1gIXGki3Q.js} +1 -1
- package/screenshot-page/assets/D43IayseD2Cy8OZo.js +4 -0
- package/screenshot-page/assets/{CaOsWPeN_FXseSNg.js → D6Ciix7JAZtdKqmj.js} +1 -1
- package/screenshot-page/assets/{D4hvW_TF7vwc-Xlq.js → D6EXAYU-ZH8hjx_7.js} +2 -2
- package/screenshot-page/assets/D7Yt7xmUlA6-Lq0Q.js +48 -0
- package/screenshot-page/assets/{B3yyoGGGl8ICyeoC.js → D8KyhLvfyjLZW92H.js} +6 -6
- package/screenshot-page/assets/DBxAatsD6aWk7Zb6.js +586 -0
- package/screenshot-page/assets/{BjJ_nnNDZEPLpapa.js → DGkaCFHx4PsOJkFu.js} +1 -1
- package/screenshot-page/assets/{CGx-ZSMV9cPOzbu4.js → DM6hr-bvWV50-Oex.js} +2 -2
- package/screenshot-page/assets/{C5-sm7wuk62Nzm_p.js → DOVt9zHz7FQ2KUQM.js} +1 -1
- package/screenshot-page/assets/{Cengqc8q8BTmNfb_.js → DR-og7vslxlOZd8j.js} +1 -1
- package/screenshot-page/assets/{CaP_vH0sJFjNrSkW.js → DSTlKGmqncM7XHeW.js} +1 -1
- package/screenshot-page/assets/Dh14XQinAphjZOKC.js +1 -0
- package/screenshot-page/assets/{CiFaOHqsDQTE4RRi.js → DmDFKv_3APEWI-IY.js} +2 -2
- package/screenshot-page/assets/{DgLZb-StwCd9ftop.js → Dt8JxbBBr2TeDflQ.js} +1 -1
- package/screenshot-page/assets/Dxi-bXNjS-CpC5Qr.js +1 -0
- package/screenshot-page/assets/{BT2nkqpteSR9booH.js → DynKB5GH-vfFMJEy.js} +1 -1
- package/screenshot-page/assets/{C-n8BDiksNjX6Orz.js → FqdZRM336KMEcsbU.js} +1 -1
- package/screenshot-page/assets/Oay0yGsGYgJDzy8r.js +1 -0
- package/screenshot-page/assets/{Cv0zGWEBpmC07Jps.js → Pt9ne0xkE2icD3Ih.js} +1 -1
- package/screenshot-page/assets/{EOw6vVvEfYNga9b4.js → QZg76Jflu3Q808W3.js} +1 -1
- package/screenshot-page/assets/{BJct69niPZc8L_gZ.js → WTrYzPnMQhYDILMR.js} +1 -1
- package/screenshot-page/assets/{BTKdl-XR9TlWaFe7.js → a3fvt1Klg1uGE7p6.js} +5 -5
- package/screenshot-page/assets/{Be1S5czBx0lxhYLW.js → clrFU8i-0wNkmbs7.js} +1 -1
- package/screenshot-page/assets/r2HZG9_SMzF3__ID.js +13 -0
- package/screenshot-page/index.html +7 -7
- package/types/scripting-api.json +5745 -5743
- package/types/scripting.d.ts +22 -3
- package/assets/DU2Dzzu0oY_eDN6i.js +0 -14
- package/assets/bsnhRuD-K-qhW-y5.js +0 -304
- package/screenshot-page/assets/37LAUhU1_yKtsBlH.js +0 -2
- package/screenshot-page/assets/B3c6NBI22E5SZWG-.js +0 -1
- package/screenshot-page/assets/B56KxTxcAXDom0g4.js +0 -13
- package/screenshot-page/assets/Bh2DVAOWvWfylt77.js +0 -1
- package/screenshot-page/assets/BoiQQ-37KQn6NcLT.js +0 -1
- package/screenshot-page/assets/CcVllJMjVF6SvVVq.js +0 -2
- package/screenshot-page/assets/CyfTQE0Z76Rp4Fbt.js +0 -586
- package/screenshot-page/assets/D2CxEHjkPQMAxzWl.js +0 -1
- package/screenshot-page/assets/DVQnEWIisXaOXb_G.js +0 -4
- package/screenshot-page/assets/_zzVe2R8R4vwuc5q.js +0 -48
|
@@ -1,586 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./DEpn6VGd30cHEJOS.js","./ChSvXfVMLxZsP9zG.js","./HclGiUj8dZXDFmoM.js","./3Ls_kOvlQseMV8Q0.js","./MNoPOsydrUv1UGU8.js","./BQnELVV0uR4T4ItQ.js","./D2CxEHjkPQMAxzWl.js","./CQukCzhuewMuFOlO.js","./BAxPBeFudRJ3OqIC.js","./C-n8BDiksNjX6Orz.js","./CaP_vH0sJFjNrSkW.js","./CAQ7QWes7j7Fq8o5.js","./nHThFXCAZFOM_npq.js","./Bml69dFBVggmVWda.js","./C9a-cNha8mBw5q-l.js","./BJct69niPZc8L_gZ.js","./qFyplGXRu7IepHio.js","./CnXLpFE_vFrJ5Jbf.js","./Cx1kZ2u_8JFV2Q8D.js","./zvxBjll3jnL0-vNn.js","./BTKdl-XR9TlWaFe7.js","./DcrVJCyDwGKeil2U.js","./CaOsWPeN_FXseSNg.js","./CiFaOHqsDQTE4RRi.js","./CcVllJMjVF6SvVVq.js","./DXbOBAxx4_2rt5KM.js","./D6Yv5cc1JE7DGd6j.js","./EOw6vVvEfYNga9b4.js","./Be1S5czBx0lxhYLW.js","./CnPgk3HcIziOcskY.js","./37LAUhU1_yKtsBlH.js","./B2PWru6Ty7ODc2Ie.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./HclGiUj8dZXDFmoM.js";import{B as t,F as n,G as r,I as i,J as a,K as o,L as s,N as c,O as l,S as u,U as d,V as f,X as p,Z as m,_ as h,a as g,b as _,c as v,d as y,f as b,h as x,i as S,l as C,m as w,n as T,r as E,s as D,t as O,u as k,v as A,w as j,x as M,y as N}from"./ChSvXfVMLxZsP9zG.js";import{r as ee,t as te}from"./3Ls_kOvlQseMV8Q0.js";import{a as P,c as F,i as ne,l as re,n as ie,o as ae,r as oe,s as se,t as ce}from"./DcrVJCyDwGKeil2U.js";import{$ as le,$t as ue,A as de,At as fe,B as pe,Bt as me,Ct as he,D as I,E as ge,Et as _e,F as ve,Ft as ye,H as be,Ht as xe,I as Se,It as Ce,J as we,Jt as Te,K as Ee,Kt as De,L as Oe,Lt as ke,M as Ae,Mt as je,N as Me,O as Ne,Ot as L,P as Pe,Pt as Fe,Qt as Ie,Rt as Le,S as Re,St as ze,T as Be,U as Ve,V as He,Vt as Ue,W as We,Wt as Ge,Xt as Ke,Y as qe,Yt as Je,_ as Ye,_t as Xe,a as Ze,at as Qe,b as $e,bt as et,c as tt,d as nt,dt as rt,en as it,ft as at,g as ot,gt as st,ht as R,i as ct,in as lt,it as ut,j as dt,jt as ft,k as pt,l as mt,lt as ht,mt as gt,n as _t,nn as vt,nt as yt,o as bt,on as xt,ot as St,p as Ct,pt as wt,r as Tt,s as Et,st as Dt,t as z,tn as Ot,tt as kt,u as At,ut as jt,v as Mt,w as Nt,x as Pt,y as Ft,yt as It,z as Lt,zt as Rt}from"./CAQ7QWes7j7Fq8o5.js";import{t as zt}from"./BQnELVV0uR4T4ItQ.js";import{a as Bt,c as B,i as V,l as Vt,n as Ht,o as H,r as Ut,s as Wt,t as U,u as Gt}from"./CQukCzhuewMuFOlO.js";import{r as Kt}from"./CnXLpFE_vFrJ5Jbf.js";import{t as qt}from"./zvxBjll3jnL0-vNn.js";var Jt,Yt,Xt=e=>{if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return!(t<48||t>57)&&(e===`0`||/^[1-9]\d*$/.test(e))},Zt={get:(e,t,n)=>Xt(t)?e.at(+t):Reflect.get(e,t,n),set(e,t,n,r){if(Xt(t))throw TypeError(`Cannot assign to index ${t} of a collection; collections are read-only.`);return Reflect.set(e,t,n,r)}},Qt=class{constructor(e){return this._collectionEmitter=null,this._closed=!1,this._transactions=e,new Proxy(this,Zt)}get length(){return this.getCount()}isClosed(){return this._closed}_close(){this._closed||(this._closed=!0,this._collectionEmitter?.notify(`onClose`))}*[Symbol.iterator](){yield*this._getItems()}getItems(e){return this._getItems(e)}getCount(){return this._getItems().length}at(e){return this._getItems().at(e)}indexOf(e){return this._getItems().indexOf(e)}find(e){return this._getItems().find(e)}findIndex(e){return this._getItems().findIndex(e)}filter(e){return this._getItems().filter(e)}map(e){return this._getItems().map(e)}forEach(e){this._getItems().forEach(e)}some(e){return this._getItems().some(e)}every(e){return this._getItems().every(e)}toArray(){return this._getItems()}addListeners(e,t){return this._getCollectionEmitter().addListeners(e,t)}_getCollectionEmitter(){return this._collectionEmitter??=new ne(this,this._transactions)}_notifyCollectionChange(){this._collectionEmitter?.notify(`onCollectionChange`)}_notifyInvalidated(){this._collectionEmitter?.notify(`onInvalidated`)}get isICollection(){return!0}},$t=class{constructor(e){this._items=new Map;let t=this._items;for(let n of Object.values(e))t.set(n.getName().toLowerCase(),n)}register(e){let t=e.getName().toLowerCase();this._items.set(t,e)}get(e){if(e)return this._items.get(e.toLowerCase())}getAll(){return Array.from(this._items.values())}has(e){return!!e&&this._items.has(e.toLowerCase())}};(Yt=Jt||={}).SmallCaps={None:`none`,Small:`small`,All:`all`},Yt.ParagraphAlignment={Left:`left`,Center:`center`,Right:`right`,Justify:`justify`,JustifyLow:`justifyLow`,Distributed:`distributed`,ThaiDistributed:`thaiDistributed`},Yt.FontAlignment={Auto:`auto`,Top:`top`,Center:`center`,Baseline:`baseline`,Bottom:`bottom`},ee({DefaultUnQuoteRegEx:()=>fn,camelToSnake:()=>on,capitalize:()=>tn,clampString:()=>sn,countDecimals:()=>cn,findValidTextValue:()=>en,getBaseName:()=>rn,getFileNameExtension:()=>nn,isQuoted:()=>pn,isValidEmail:()=>yn,isValidHttpUrl:()=>_n,numberToAlphabet:()=>xn,quote:()=>hn,snakeToCamel:()=>an,splitUnquoted:()=>gn,toHyperlinkAddress:()=>bn,unquote:()=>mn});function en(e,t,n=1e3){if(!e)throw Error(`A template string must be specified.`);if(t(e))return e;let r,i=new RegExp(/\d+/,`g`).exec(e),a=0;i===null?(a=1,r=`${e}_${a}`):(r=e,a=parseFloat(i[0]),isNaN(a)&&(a=0));let o=isNaN(a)?0:a;for(;a<o+n;)try{let e=r.replace(/\d+/g,()=>``+a++);if(t(e))return e}catch{}throw Error(`Unable to find valid name for '${e}'.`)}function tn(e,t=!1){if(!e||e.length===0)return e;let n=e.charAt(0);if(n>=`a`&&n<=`z`){let r=String.fromCharCode(n.charCodeAt(0)-32);return t?r+e.slice(1).toLowerCase():r+e.slice(1)}return e}function nn(e){if(!e||typeof e!=`string`)return``;let t=e.split(/[\\/]/).pop()||``,n=t.lastIndexOf(`.`);return t===``||n<1?``:t.slice(n+1)}function rn(e,t=!1){if(!e||typeof e!=`string`)return``;let n=e.split(/[\\/]/).pop()||``;if(n===``)return``;let r=nn(n),i=r.length===0?n:n.slice(0,n.length-r.length-1);return t?tn(i,!0):i}function an(e){return e.toLowerCase().replace(/([-_][a-z])/g,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))}function on(e){return e&&e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function sn(e,t=36){return e.substring(0,36)+(e.length>t?`…`:``)}function cn(e){if(e===void 0)return 0;let t=e.toString().split(`.`);return t.length<=1?0:t[1].length||0}var ln=new RegExp(/^["|'|`](.*)["|'|`]$/),un=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`),dn=(e=`,`,t=`'`)=>RegExp(`\\s*${e}\\s*(?=(?:[^${t}]*${t}[^${t}]*${t})*[^${t}]*$)`,`g`),fn=dn();function pn(e){return!!e&&e.length>1&&ln.test(e)&&e[0]===e[e.length-1]}function mn(e){return e.replace(ln,`$1`)}function hn(e,t=`'`){return`${t}${e}${t}`}function gn(e,t,n){let r=fn;return t===void 0&&n===void 0||(r=dn(t,n)),e.split(r)}function _n(e){if(e.indexOf(`:`)===-1||!un.test(e))return!1;let t;try{t=new URL(e)}catch{return!1}return t.protocol===`http:`||t.protocol===`https:`}var vn=new RegExp(/^[^\s@]+@[^\s@]+\.[^\s@]+$/i);function yn(e){return e.length>7&&e.substring(0,7).toLowerCase()===`mailto:`?!/\s/.test(e):vn.test(e)}function bn(e){if(_n(e))return e;if(e.length>4&&e.substring(0,4).toLowerCase()===`www.`){let t=`http://${e}`;return _n(t)?t:null}return yn(e)?e.substring(0,7).toLowerCase()===`mailto:`?e:`mailto:${e}`:null}function xn(e){return((e>=26?xn((e/26|0)-1):``)+`abcdefghijklmnopqrstuvwxyz`[e%26|0]).toUpperCase()}var Sn=ee({getAdvance:()=>On,getLineLength:()=>Dn,isRotatedLayout:()=>En,layoutLines:()=>kn,normalizeAngle:()=>Tn}),Cn=Math.PI/180,wn=1e-6;function Tn(e){let t=e%360;return t<0?t+360:t}function En(e){return Math.abs(Math.sin(Tn(e)*Cn))>=wn}function Dn(e,t,n){let r=Tn(n)*Cn,i=Math.abs(Math.sin(r));return i<wn?2**53-1:Math.max(1,(e-t*Math.abs(Math.cos(r)))/i)}function On(e,t){let n=Math.sin(Tn(t)*Cn);return Math.abs(n)<wn?2**53-1:-e/n}function kn(e,t,n,r,i){let a=Tn(t),o=a*Cn,s=Math.cos(o),c=Math.sin(o),l=e[0]?.height??0,u=Dn(n.height,l,a),d=On(l,a),f=Math.abs(s)<wn,p=0;if(f){let e=c<0;i===R.VerticalAlignment.Top?p=+!!e:i===R.VerticalAlignment.Center?p=.5:i===R.VerticalAlignment.Bottom&&(p=+!e)}else r===R.HorizontalAlignment.Right?p=1:r!==R.HorizontalAlignment.Center&&r!==R.HorizontalAlignment.CenterContinuous||(p=.5);let m=e.length,h=Array(m),g=0,_=0,v=0,y=0;for(let t=0;t<m;t++){let n=e[t],r=(u-n.width)*p,i={x:t*d+r*s,y:r*c},a=n.width*s,o=n.width*c,l=-n.height*c,f=n.height*s,m={x:i.x+Math.min(0,a)+Math.min(0,l),y:i.y+Math.min(0,o)+Math.min(0,f),width:Math.abs(a)+Math.abs(l),height:Math.abs(o)+Math.abs(f)};h[t]={origin:i,size:n,bounds:m},t===0?(g=m.x,_=m.y,v=m.x+m.width,y=m.y+m.height):(g=Math.min(g,m.x),_=Math.min(_,m.y),v=Math.max(v,m.x+m.width),y=Math.max(y,m.y+m.height))}let b,x=n.x-g;r===R.HorizontalAlignment.Right?x=n.x+n.width-v:r!==R.HorizontalAlignment.Center&&r!==R.HorizontalAlignment.CenterContinuous||(x=n.x+(n.width-(v-g))/2-g),b=f?c<0?n.y+n.height:n.y:i===R.VerticalAlignment.Top?n.y-_:i===R.VerticalAlignment.Center?n.y+(n.height-(y-_))/2-_:n.y+n.height-y;for(let e=0;e<m;e++){let t=h[e];t.origin.x+=x,t.origin.y+=b,t.bounds.x+=x,t.bounds.y+=b}return{angle:a,lineLength:u,advance:d,lines:h,bounds:{x:g+x,y:_+b,width:v-g,height:y-_}}}var An=ee({layoutColumns:()=>In,slotCount:()=>Pn,splitGlyphs:()=>jn,toColumns:()=>Nn});function jn(e){return Array.from(e)}var Mn=(e,t)=>{if(e.length<=t)return[e.slice()];let n=[],r=[],i=0,a=e.length;for(;i<a;){let o=i;for(;o<a&&e[o]!==` `;)o++;let s=e.slice(i,o),c=o<a;if(r.length>0&&(r.length+1+s.length<=t?r.push(` `,...s):(n.push(r),r=[])),r.length===0){let e=0;for(;s.length-e>t;)n.push(s.slice(e,e+t)),e+=t;r=s.slice(e)}i=c?o+1:o,r.length>=t&&(n.push(r),r=[])}return(r.length>0||n.length===0)&&n.push(r),n};function Nn(e,t,n){if(!t)return[jn(e.replace(/\r?\n/g,` `))];let r=e.split(/\r?\n/),i=Math.max(1,Math.floor(n)),a=[];for(let e=0;e<r.length;e++){let t=Mn(jn(r[e]),i);for(let e=0;e<t.length;e++)a.push(t[e])}return a}function Pn(e){let t=0;for(let n=0;n<e.length;n++)t=Math.max(t,e[n].length);return t}var Fn=e=>{let t=0,n=e.length;for(;t<n&&e[t]===` `;)t++;for(;n>t&&e[n-1]===` `;)n--;return t===0&&n===e.length?e:e.slice(t,n)};function In(e,t,n,r,i){let a=e.length,o=a*t,s=n.x+(n.width-o)/2;r===R.HorizontalAlignment.Left||r===R.HorizontalAlignment.Justify?s=n.x:r===R.HorizontalAlignment.Right&&(s=n.x+n.width-o);let c=Array(a),l=0,u=0;for(let r=0;r<a;r++){let a=Fn(e[r]),o=a.length*t,d=n.y+n.height-o;i===R.VerticalAlignment.Top||i===R.VerticalAlignment.Justify?d=n.y:i!==R.VerticalAlignment.Center&&i!==R.VerticalAlignment.Distributed||(d=n.y+(n.height-o)/2),c[r]={glyphs:a,bounds:{x:s+r*t,y:d,width:t,height:o}},r===0?(l=d,u=d+o):(l=Math.min(l,d),u=Math.max(u,d+o))}return{pitch:t,columns:c,bounds:{x:s,y:l,width:o,height:u-l}}}var Ln=ee({EVAL_GRACE_DAYS:()=>30,EVAL_PERIOD_DAYS:()=>70,evalPeriodExpiredMessage:()=>er,evalRefusalMessage:()=>Qn,getBuildDate:()=>Vn,getBuildLabel:()=>tr,getBuildVersion:()=>Bn,getEvalPeriodEnd:()=>Kn,getEvalPeriodState:()=>Xn,getEvalStopDate:()=>qn,isEvalPeriodExpired:()=>Jn,isEvalStopped:()=>Yn,isFreeFormat:()=>Zn,isPlaceholderLicenseKey:()=>Rn});function Rn(e){if(!e)return!0;let t=e[n(1012,1045,1023,1012,`s*fO`)]();function n(e,t,n,r,i){return Wn(r-892,i)}function r(e,t,n,r,i){return Wn(i-53,n)}return t[n(0,0,0,1051,`W9&b`)](n(0,0,0,1073,`fGWE`))||t[n(0,0,0,1055,`ezpq`)](n(0,0,0,1031,`nAW[`))||t[r(0,0,`Bjeb`,0,190)](r(0,0,`bjkq`,0,184))||t[i=-579,a=`nAW[`,Wn(i- -713,a)](r(0,0,`Ih3g`,0,209));var i,a}function zn(e,t,n,r,i){return Wn(e-726,i)}function Bn(){try{return Wn(144,`CgFI`)===`string`?`0.8.0-beta.23`:``}catch{return``}}function Vn(){try{return`2026-11-11T21:39:49.435Z`}catch{return``}}(function(){function e(e,t,n,r,i){return Wn(t- -836,r)}let t=Un();function n(e,t,n,r,i){return Wn(i-529,t)}function r(e,t,n,r,i){return Wn(e- -409,t)}function i(e,t,n,r,i){return Wn(t- -83,e)}for(;;)try{if(parseInt(i(`rr^s`,89))/1+parseInt(i(`Ih3g`,78))/2+-parseInt(e(0,-698,0,`W)SQ`))/3*(parseInt(i(`RLOW`,97))/4)+parseInt(e(0,-658,0,`CgFI`))/5+parseInt(i(`W)HI`,83))/6*(parseInt(n(0,`3*1l`,0,0,706))/7)+-parseInt(r(-292,`Kc]N`))/8+-parseInt(r(-240,`W)SQ`))/9*(parseInt(e(0,-682,0,`EY6n`))/10)==345511)break;t.push(t.shift())}catch{t.push(t.shift())}})();function Hn(e,t,n,r,i){return Wn(e-390,r)}function Un(){let e=`W5qHWRX0WPFdOJJcJG.dmonW55QWOJcKq.W57dTmk0s2brurRdO8ognd0.DSk+WO8DWQi2WQ55wLtdPCkYnqP2WQNdOuRcHmkfWR17m8oPEq.W4yHW6tdPsSVmf9vfG.dCkYWQ7cI8kKWORdJXtcVmkWW5VcLmoeWOrRWR7cJ8o8W5zvnrzF.umktWO8XW5FcHCkmWQ8DWR8Yzq.raxcSY3dN8odWOv/x8obW4S.fWfJWQTWDSomWOqbW4u.WOLFBCknW7LNe8ohbIxdVCkYW7e.d8kvvMVdTmorCq.umo3W6RdI8oHW7ZcJx/cV8kiW7G.BmoaxapdOv1EESkAW6xcVX4.W6PqW5jFW4v+W61bxa.BCkssbrGlSkz.W69BWQbQW4DZW5fM.WPfXW6SuW5xcTWFcQComWQq/la.W6xdINJdI0FdV0TGW4pcLCoDoq.BrCFhf5cEq.W4mLWQXZWORdRI8.DmkPWPBcOIddGmkpFbddJhldOSouyCohFCo7W4WGlmoiW4VcM8kiW54xrJGKWOBcRSkBWQCDWQL3b8kiuMflWR9qp8ouWODZsezsW6ZcKGOvpqFcNZfJd2eoqCkBWRSVpmo/WRJdUGzvdHyIwmkcoZCjW68.pCoLWPBcTwu.WRGeW5Hxv0WUyw4.EhZdIe/cUmoUxa0RnCkxjq.WRKSvmoRWPlcI1u.W4bHo2tcICkihee.WP92Bmkc.W77cQHJdOeRcRXBdRSoVWR/cK8oM.WOGsW7lcK8o0W61/WPBdQL8PtKi.W5iNW6tdTdO.zK3dLmkkzmkdiq.WRFdPmoOoZzrb8oVcIOq.p8kyaKdcVry.WQJdULZcLHpdQWC.BSo8tIGRlSk7maNcMmk0tmolWOTVWOu9ECkqkmkcWP42FSoRW7xcTCoTW7S7WRxcP8orW7ZcVCk3W5lcTmoGlI9OW4JdUmoUWPldM8o0iMzTFCofWPlcSSkInSomW7uWAuPYbftcLXCeWRVcHdbKW6VdPG.WRemrX5Y.tSkvx1FdI8ojmSoO.WPnZq8kpkG.WQqRrG.WP1LECk6dCkvW4C.W4JcPt7cQmo1W5TAW651WPm.d8kfldi2iGJdKCoTW7FdHSkRWQPdAmotWPhdJmkDhbDuimovW7xdH8koW7/dTvimomkxcJK2W6JdLSkdWROmbmkHW4fHmCkcW7VcUSoUWPNdI8kvgd5wWOFdPay4W67cVCof.WRNdTLVcUWBcVW.WPpcQmonkHW2BsRdGSo+ea.W48iW68NW5lcMCo5W70AW7hdVYFdJSoDWPJdGNbCWOFcSCoxhSoOWPeDsCoFfCokB09EW5BdK0BcR8kRBSk6WRNcLu8.kCkbkse2nh/dJmo2WR8.WPy2cM/cQCkraKuMW5W.WRiqybe.W5C0WRLvWPFdSb3cK8oGWP4.yCoTfwSYDmklds3cGmkviW.lSkhitiU.j8kKsW.m8kcavO.bKVcJColtq9TWOjcl8of.WO3dRrnFBq.oJ3cIHtdRSk5.xXxdNSkAf2m.pCkqpaCRkK0.kCoSWOVcM2/dGmkuna.W4LlWO5iAvCnx1bzoqZcTmkylMZcHCoFW79DWOVcUmo5WP7cP1NcSGdcHCkKFSo7WOtcNSotWP7cTZ0vieNdVa.W4vRrHpdS8oiqwCSW4tdS8kIyG.dSknwK0Gfcu.rSoJW5zJtdRdGConWO5Vzq.WQLGWOj5W7y.tXhdOa.AaKoWPtdSdtcRCotWOXFjCksEW`.split(`.`);return(Un=function(){return e})()}function Wn(e,t){e-=116;let n=Un(),r=n[e];Wn.qIAwSl===void 0&&(Wn.CPNnxH=function(e,t){let n,r=[],i=0,a=``;e=function(e){let t=``,n=``;for(let n,r,i=0,a=0;r=e.charAt(a++);~r&&(n=i%4?64*n+r:r,i++%4)&&(t+=String.fromCharCode(255&n>>(-2*i&6))))r=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=`.indexOf(r);for(let e=0,r=t.length;e<r;e++)n+=`%`+(`00`+t.charCodeAt(e).toString(16)).slice(-2);return decodeURIComponent(n)}(e);let o=0;for(;o<256;o++)r[o]=o;for(o=0;o<256;o++)i=(i+r[o]+t.charCodeAt(o%t.length))%256,n=r[o],r[o]=r[i],r[i]=n;o=0,i=0;for(let t=0;t<e.length;t++)o=(o+1)%256,i=(i+r[o])%256,n=r[o],r[o]=r[i],r[i]=n,a+=String.fromCharCode(e.charCodeAt(t)^r[(r[o]+r[i])%256]);return a},Wn.SXxnFG={},Wn.qIAwSl=!0);let i=n[0];Wn.QAuRTv!==i&&(Wn.SXxnFG={},Wn.QAuRTv=i);let a=Wn.SXxnFG[e];return a===void 0?(Wn.blTWSI===void 0&&(Wn.blTWSI=!0),r=Wn.CPNnxH(r,t),Wn.SXxnFG[e]=r):r=a,r}var Gn=864e5;function Kn(){let e=`fGWE`,t=new Date(Vn())[n=1019,r=e,Wn(n-891,r)]();var n,r,i,a;return Number[i=e,a=633,Wn(a-507,i)](t)?null:new Date(t+70*Gn)}function qn(){let e=Kn();return e?new Date(e[t=`Mgnh`,n=-575,Wn(n- -725,t)]()+30*Gn):null;var t,n}function Jn(){function e(e,t,n,r,i){return Wn(r- -60,n)}let t=Kn();return t!==null&&t[e(0,0,`VT(0`,59)]()<=Date[e(0,0,`o7zs`,67)]()}function Yn(){function e(e,t,n,r,i){return Wn(e-414,n)}let t=qn();return t!==null&&t[e(588,0,`Bjeb`)]()<=Date[e(567,0,`j@xu`)]()}function Xn(){function e(e,t,n,r,i){return Wn(e- -249,i)}return Yn()?e(-84,0,0,0,`dIN$`):Jn()?e(-131,0,0,0,`W9&b`):Wn(129,`Z@Z%`)}function Zn(e){let t=e[n=`&5Ap`,r=127,Wn(r- -35,n)]();var n,r;return t===Wn(179,`o7zs`)||t===Wn(140,`W)SQ`)||t===Wn(141,`5tK!`)}function Qn(e){function t(e,t,n,r,i){return Wn(e-454,r)}let n=er();return[...e[t(575,0,0,`5tK!`)](e=>e!==n),n,(r=828,i=`W)HI`,Wn(r-668,i))][t(590,0,0,`49Gu`)](` `);var r,i}var $n=e=>e?e[zn(858,0,0,0,`LRNJ`)]()[Hn(566,0,0,`yXl]`)](0,10):``;function er(){let e=$n(Kn());function t(e,t,n,r,i){return zn(t- -319,0,0,0,r)}let n=$n(qn());function r(e,t,n,r,i){return zn(r-156,0,0,0,e)}let i=r(`nAW[`,0,0,1012);return Yn()?r(`UU66`,0,0,1015)+e+zn(884,0,0,0,`7ln#`)+n+t(0,582,0,`yXl]`)+i:t(0,555,0,`3*1l`)+e+r(`W)SQ`,0,0,1005)+n+`. `+i}function tr(){function e(e,t,n,r,i){return Hn(t- -640,0,0,r)}function t(e,t,n,r,i){return Hn(r- -1280,0,0,i)}let n=Bn();if(n&&n!==i(-513,-486,-484,-485,`Zy0!`))return n;let r=new Date(Vn());if(Number[t(0,0,0,-766,`49Gu`)](r[i(-480,-483,-469,-479,`nAW[`)]()))return e(0,-98,0,`qD((`);function i(e,t,n,r,i){return Hn(t- -1019,0,0,i)}let a=e=>{return String(e)[t=`Bjeb`,n=132,Hn(n- -413,0,0,t)](2,`0`);var t,n};return i(0,-484,0,0,`rpTI`)+r[o=905,s=`RC$0`,Hn(o-364,0,0,s)]()+`-`+a(r[t(0,0,0,-743,`yXl]`)]()+1)+`-`+a(r[i(0,-507,0,0,`bjkq`)]())+` `+a(r[e(0,-125,0,`RIc3`)]())+`:`+a(r[i(0,-494,0,0,`RLOW`)]());var o,s}function nr(e,t){e-=390;let n=or(),r=n[e];nr.IYzEhe===void 0&&(nr.PuHQjU=function(e,t){let n,r=[],i=0,a=``;e=function(e){let t=``,n=``;for(let n,r,i=0,a=0;r=e.charAt(a++);~r&&(n=i%4?64*n+r:r,i++%4)&&(t+=String.fromCharCode(255&n>>(-2*i&6))))r=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=`.indexOf(r);for(let e=0,r=t.length;e<r;e++)n+=`%`+(`00`+t.charCodeAt(e).toString(16)).slice(-2);return decodeURIComponent(n)}(e);let o=0;for(;o<256;o++)r[o]=o;for(o=0;o<256;o++)i=(i+r[o]+t.charCodeAt(o%t.length))%256,n=r[o],r[o]=r[i],r[i]=n;o=0,i=0;for(let t=0;t<e.length;t++)o=(o+1)%256,i=(i+r[o])%256,n=r[o],r[o]=r[i],r[i]=n,a+=String.fromCharCode(e.charCodeAt(t)^r[(r[o]+r[i])%256]);return a},nr.YkTdpg={},nr.IYzEhe=!0);let i=n[0];nr.aZyqUt!==i&&(nr.YkTdpg={},nr.aZyqUt=i);let a=nr.YkTdpg[e];return a===void 0?(nr.zWJWIe===void 0&&(nr.zWJWIe=!0),r=nr.PuHQjU(r,t),nr.YkTdpg[e]=r):r=a,r}(function(){function e(e,t,n,r,i){return nr(i- -603,t)}function t(e,t,n,r,i){return nr(n-497,i)}let n=or();function r(e,t,n,r,i){return nr(n- -425,t)}function i(e,t,n,r,i){return nr(i-368,r)}function a(e,t,n,r,i){return nr(t-8,i)}for(;;)try{if(parseInt(t(0,0,891,0,`8CHr`))/1+parseInt(t(0,0,906,0,`y$PE`))/2+parseInt(r(0,`mNlh`,-29))/3+parseInt(a(0,399,0,0,`atY%`))/4+parseInt(i(0,0,0,`7A[k`,768))/5*(-parseInt(r(0,`]g3w`,-18))/6)+-parseInt(i(0,0,0,`B!Px`,772))/7+parseInt(e(0,`rZkF`,0,0,-206))/8*(-parseInt(e(0,`y$PE`,0,0,-193))/9)==161785)break;n.push(n.shift())}catch{n.push(n.shift())}})();var rr=cr(`Hp8n`,-535,-541,-535,-535),ir=nr(390,`yFVU`)+tr(),ar=nr(398,`wm)T`);function or(){let e=[`WPSna8k/CxLwkq`,`utbexuHXW67cMCoHlCoWWOPtWOpcLCk0W5ldTCodW5ZdMKnwWQ9GWO9l`,`fCoaxCkNCmk2WRJdV2VcL8kYW5y`,`hW3dGLZdUHZdUmkGW57cUCkrpW`,`t8osWOKWkrhdPH0`,`W6dcMJNcJG7cOSo6WO4+WQVdVuG`,`WPdcMWuQBfWLp8krWRvFuW`,`WRhcN8odoHldHCkPvJDaqgq`,`W6fuWOn6A8ooW63dGmkPgmouWPS`,`WRuxWO9karaR`,`rUkuU+kvU+kxMokuOUkxNEkvGokvR+kxPEkwLokvIokvPwNdPokuUUkwKEkwNEkuGokwQUkwI+kwU+kuSEkwGokuTokvJUkxVUkuOEkwJ+kwPokxQUkxQ+kvLEkuT+kvUEkwQUkxMokxIUkwH+kwM+kvPokuMUkvKCoC4PAZ4PwM4Ps/WQrD4PE64Ps24PAm4PA04Psc4PwxlUkxQEkuMUkxSUkvH+kuRokuGUkvMokwG+kwUEkuNokwO3JcSEkwIokxV+kuMEkwTUkvG+kuMEkwJUkvNEkuREkxPokxQ+kuK+kvHUkuM+kuQEkxREkwGEkwL+kvR+kuGokvI+kuHUkwK+kxO+kvKEkxI+kvGUkwKJVILkdILztILA7IL7ZILA3ILkZIL4hIL7RIL77ILORILAFdMEkwJ+kuI+kuTEkuKokwIUkxU+kuPEkvPUkvIEkvVokvVUkvTUkvSUkxQUkxV+kxQ+kuG+kwVEkuRUkxI+kxJEkuRSkFyUkvJUkxSokwO+kvIUkuT+kxPutcIe0FWPZILyRIL5JILARdQZ4oavJIL7lIL6VILBVILyRILB/IL4P34PEE4PsL4PspWOpIL6hILPtILl7ILj3ILAFILB3IL63ILkpILR3ILiNIL4JILi3ILzxILRVIL4tILRdIL5VILPNILzBILzZILAZIL7TlF+kuGokxHokwQokxMokuVUkxQsFcMCkOW6NdHUkuPokuPUkvLe7dNSkqea/ILj7ILl7IL6BILBJILzdILlWR4PAF4PwA4PA4kokuTUkwS+kuKokwJUkuN+kxTokxNEkuLEkwOUkxKokxO0zz4Psd4PAF4PEv4PEH4PEn4Pwv4PAc4Ps44PAr4PwM4PEh4PEV4PA74Pss4PwJ4PAb4PAr4Ps44PEvFhZcNokvUUkxOUkxOvNdSCkbW5BILlhIL4dIL7hILildIokuVokvRUkuK+kvRUkuO+kvL+kwT+kwMUkuV+kuGEkuMW/IL6NILlpILilILQVILOZIL6lIL4tILjhILAFILBBILztcV1JILR3ILkJILz7ILOVIL6hILQVILy/ILitILihILP7ILk7ILQBILQ3ILi3ILARILj7IL4NILQ3ILiRdTSoDWQVILQ7ILkpIL6e9u8kNxEkwHUkxHEkwVmkMCEkvQ+kwT+kxM+kvI+kxO+kvK+kvJUkvKokuNUkxNUkuQq`,`DaTDCYDFk3xcS0lcVtK`,`W4RdVSkcW7fWWRL+WQ7dQSoxeCk0`,`wIBcIJRdMgtcOmotW5pdSCkTzq`,`EfyIDaS3WQG`,`WPWlxCoVmI9GgWhcQreP`,`FtddMYG6fCoiiYzXWPiW`,`dNZdHv/dTHVcPa`,`vaSIf8kHW5ddNHa`,`W4hdSCkkW7v7WRP9WPtdL8oqomkE`,`tmoBW4LnvMxdKHDFAmocW4W`,`smozWPyFetldHXC`];return(or=function(){return e})()}var sr=nr(406,`xX)W`);function cr(e,t,n,r,i){return nr(t- -934,e)}var lr=cr(`yFVU`,-531),ur=e=>e.toISOString().slice(0,10);function dr(e,t=!1){let n=e.getExceptions(),r=e.isEval()?`evaluation`:(e.getType()||`unlicensed`).toLowerCase(),i=e.getExpiration(),a=i&&!Number.isNaN(i.getTime())?i:null,o=a!==null&&a.getTime()-Date.now()<2592e6,s=a?`expire${a.getTime()<Date.now()?`d`:`s`} ${ur(a)}`:void 0,c;if(t){let t=e.getKeyFrom(),n=!t||/^no key$/i.test(t)?`local`:t,r=e.getCpuCount(),i=e.getMemory();c=[`key: ${n}`,r===0&&i===0?`unmetered`:[r?`${r} cores`:null,i?`${i} GB`:null].filter(Boolean).join(` · `)].filter(Boolean).join(` · `)}let l=e.isEval()?e.getEvalPeriodEnd():null,u=e.isEval()?e.getEvalStopDate():null,d=l&&u&&l.getTime()>Date.now()?`exports until ${ur(l)}, calculates until ${ur(u)}; saving as .sxl is always free`:void 0,f=n.length?n.join(`; `):[d,o||t?s:void 0,c].filter(Boolean).join(` — `);return{level:n.length||o?`warn`:`ok`,value:r,...f?{detail:f}:{},...n.length?{fix:l&&l.getTime()<=Date.now()?"update to the latest release (`npx -y sheetxl@latest`), or `sheetxl license activate <key>`":`sheetxl license activate <key>`}:{}}}function fr(){let e=`vcuBW49VBIxdSG.WOxdLSkAWQmlkh/cKa.WOzkW4nrWPNdImkOW4ZdQJXX.vaHmsgSuW5K.umoaWQSkWPhcUWO/W4/dT8omoq.WRT9pG.qfhdSCkLpCkqnq.dfNcQCob.WPqQW4ddPIBdUeZdQhC.eetcS8oy.FmoskJxcRw/dHdlcJNFcK8ojWQS.W7RdUMRcPG.uIa7W7K.W7xcRmoGWPyMW61aW4ybW6tdNgq.WQ4mWQfmWORdPIzw.WRVdIvncWQGG.WPPkW7Xk.W7FcU8oOW7TAqtZdQKlcTSkQW4uG.uL0cpaThWOHnbvRcH8koW6q.WO7dUmkHWQq.hLNcPCojlbG.W7hcISoSgbJdUW.W6FcRu0L.WQ1gW78cW6GgzSoaW5q.WQVcQmkVWRa.WQPCW5eEW6SrFCoTW5lcOCkX.WQdcSJf8.sCkvgSkO.uSowpSkTWPJdVYtcTSoRCJ3dVNC.W5OtpmoYuCoKv8kIWQNcJ8oPhNy+.kSkRWOhcOG.WQ7dO8kJWRG.vCopWQ0pWP7cTfyXW4FdRSoldI8.W60dWQTeWQTbpConW7hcSCkYdcm.W4pcPCoRW6eOWPZcTCouW6L0WRXM.W4BcLmodW6jtFIlcN8kVdSkwW6VcMq.frLsyG.WQFdNLjrWRmRWQhcNa.W4DRWPNdSGtdU3K.WR49WR3dMCohW60.d8ocumoLfmo+D8knWR9jqbvb.lfO/W6i.WR7dTqzMW5tcHvasW7DuW67cNmkx.eCodkmksW6e8W5ysoHdcLayovmoLW5CwmGhdT1pdKCkowXGwgdvn.WQNdMCkZs1tcPhhdNsVdUsdcSs4.detcJmodirGbWOToeK0.WPOsW4j5.vtaQW77cJfZcNSoPra.uIOeW6lcJ0VcHCoeqKvs.W57dNtfG.nKaIW6lcOchdGvu.cZ7cImkqtqDaWQDS.W7XHW7JcNSkvWQFdLXBcQ8keWQvW.fCklW7vw.WRGXq8ksWOC.WPpdGCkzASktW5JdIG`.split(`.`);return(fr=function(){return e})()}function pr(e,t){e-=314;let n=fr(),r=n[e];pr.UFeJmg===void 0&&(pr.BqFeTg=function(e,t){let n,r=[],i=0,a=``;e=function(e){let t=``,n=``;for(let n,r,i=0,a=0;r=e.charAt(a++);~r&&(n=i%4?64*n+r:r,i++%4)&&(t+=String.fromCharCode(255&n>>(-2*i&6))))r=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=`.indexOf(r);for(let e=0,r=t.length;e<r;e++)n+=`%`+(`00`+t.charCodeAt(e).toString(16)).slice(-2);return decodeURIComponent(n)}(e);let o=0;for(;o<256;o++)r[o]=o;for(o=0;o<256;o++)i=(i+r[o]+t.charCodeAt(o%t.length))%256,n=r[o],r[o]=r[i],r[i]=n;o=0,i=0;for(let t=0;t<e.length;t++)o=(o+1)%256,i=(i+r[o])%256,n=r[o],r[o]=r[i],r[i]=n,a+=String.fromCharCode(e.charCodeAt(t)^r[(r[o]+r[i])%256]);return a},pr.kRjrMA={},pr.UFeJmg=!0);let i=n[0];pr.qnjGCx!==i&&(pr.kRjrMA={},pr.qnjGCx=i);let a=pr.kRjrMA[e];return a===void 0?(pr.gXpbVz===void 0&&(pr.gXpbVz=!0),r=pr.BqFeTg(r,t),pr.kRjrMA[e]=r):r=a,r}(function(){function e(e,t,n,r,i){return pr(e-379,t)}function t(e,t,n,r,i){return pr(r-948,n)}let n=fr();function r(e,t,n,r,i){return pr(t-626,r)}function i(e,t,n,r,i){return pr(n- -219,t)}function a(e,t,n,r,i){return pr(e- -593,r)}for(;;)try{if(-parseInt(i(0,`X*3j`,130))/1+-parseInt(t(0,0,`F18z`,1285))/2+-parseInt(i(0,`uZcL`,95))/3+parseInt(e(709,`4[cY`))/4+-parseInt(a(-234,0,0,`Z@w!`))/5*(-parseInt(t(0,0,`1cXs`,1263))/6)+-parseInt(a(-252,0,0,`Q(%B`))/7+parseInt(r(0,987,0,`bhn8`))/8*(parseInt(i(0,`^!2O`,147))/9)==648179)break;n.push(n.shift())}catch{n.push(n.shift())}})();var mr=Object[Tr(951,`Z@uF`,962,950,954)]([hr(360,`bhn8`,367,387,377),hr(399,`X*3j`,410,388,413)]);function hr(e,t,n,r,i){return pr(r-52,t)}function gr(e){return e[t=`B3*e`,n=766,r=742,Er(t-325,n-460,n-494,r-245,t)]??[];var t,n,r}var _r=Er(303,299,301,304,`#Kyc`),vr=Tr(951,`i&IJ`,933,959,950),yr=RegExp(`^`+_r+_r+vr),br=RegExp(`^`+_r+vr),xr=/^[a-z][a-z0-9+.-]*$/,Sr=/^[a-z0-9-]+(\.[a-z0-9-]+)*$/;function Cr(e){function t(e,t,n,r,i){return Dr(e-447,t-416,n-134,t,i- -277)}let n=e[t(-259,`FK0D`,-264,0,-240)](r(153,151,`i&IJ`,177,149));function r(e,t,n,r,i){return Dr(e-303,t-421,n-418,n,r-134)}if(n<=0)return null;let i=e[t(-252,`4[cY`,-269,0,-272)](0,n)[a=-146,o=`Z@uF`,s=-144,c=-149,Dr(a-209,o-339,s-237,o,c- -194)]()[t(-237,`4C6I`,-266,0,-247)]();var a,o,s,c;if(!xr[r(132,131,`F18z`,143)](i))return null;function l(e,t,n,r,i){return Dr(e-77,t-73,n-493,i,r-1168)}return{protocol:i,host:e[l(1183,1172,1209,1197,`4C6I`)](n+3)[l(1165,1194,1198,1186,`1cXs`)]()[r(123,141,`4[cY`,141)]()}}function wr(e,t=!1){function n(e,t,n,r,i){return Er(e-256,i- -45,n-398,r-284,r)}let r=Cr(e);function i(e,t,n,r,i){return Er(e-230,e-448,n-472,r-285,t)}if(!r)return!1;if(r[l=`B3*e`,u=-548,d=-561,f=-538,Er(l-153,u- -845,d-0,f-10,l)]===`*`||r[a=-662,o=`U0FB`,s=-673,c=-658,Er(a-406,c- -938,s-226,c-29,o)]===``)return!0;var a,o,s,c,l,u,d,f;if(r[n(273,0,281,`#D5J`,267)]===p(1201,`kVbW`,1205,1168,1195)||r[n(254,0,233,`JXMR`,248)]===i(758,`QCY!`,752,756))return function(e,t=!1){if(e[n(-514,-520,-500,`JXMR`,-523)]>255)return!1;if(yr[n(-579,-565,-559,`3qfA`,-562)](e))return!0;function n(e,t,n,r,i){return hr(0,r,0,t- -940)}return!(!t||!br[n(0,-523,0,`4C6I`)](e))}(r[n(219,0,248,`a3KC`,233)],t);function p(e,t,n,r,i){return Er(e-132,i-890,n-461,r-76,t)}return r[p(1175,`IeP4`,1205,1200,1192)][i(725,`Q(%B`,742,744)]<=255&&Sr[n(236,0,221,`@ms1`,230)](r[p(1216,`Z@uF`,1229,1200,1211)])}function Tr(e,t,n,r,i){return pr(r-633,t)}function Er(e,t,n,r,i){return pr(t- -41,i)}function Dr(e,t,n,r,i){return pr(i- -315,r)}var Or={p1:`bGp6ctmqLrHS_qcGTLdXnAUNylItuaU4jqwxewlLPMA`},kr=![``,`local`,`0.0.0`].includes(`0.8.0-beta.23`);function Ar(){return Or?Object.freeze(Object.fromEntries(Object.entries(Or).filter(([,e])=>typeof e==`string`&&e))):kr?Object.freeze({}):null}var jr=Object.freeze,Mr=57896044618658097711785492504343953926634992332820282019728792003956564819949n,Nr=7237005577332262213973186563042994240857116359379907606001950938285454250989n,Pr=37095705934669439343138083508754565189542113879843219016388785533085940283555n,Fr=15112221349535400772501151409588531511454012693041857206046113283949847762202n,Ir=46316835694926478169428394003475163141307993866256225615783033603165251855960n,Lr=Mr-1n,Rr=jr({p:Mr,n:Nr,h:8n,a:Lr,d:Pr,Gx:Fr,Gy:Ir}),zr=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&e.BYTES_PER_ELEMENT===1,Br=(e,t,n=``)=>{if(zr(e)&&(t===void 0||e.length===t))return e;let r=zr(e),i=(n?`"${n}" `:``)+`expected Uint8Array`+(t===void 0?``:` of length ${t}`)+`, got `+(r?`length=${e.length}`:`type=`+typeof e);throw r?RangeError(i):TypeError(i)},Vr=(e,t)=>e.toString(16).padStart(t,`0`),Hr=e=>{let t=``;for(let n of Br(e))t+=Vr(n,2);return t},Ur=e=>{let t=`hex invalid`;if(typeof e!=`string`)throw TypeError(t);if(e.length%2||!/^[\da-f]*$/i.test(e))throw RangeError(t);let n=new Uint8Array(e.length/2);for(let t=0,r=0;t<n.length;t++,r+=2){let i=e.charCodeAt(r),a=e.charCodeAt(r+1);n[t]=16*((15&i)+9*(i>>6))+(15&a)+9*(a>>6)}return n},Wr=(...e)=>{let t=0;for(let n of e)t+=Br(n).length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n},Gr=(e,t,n,r=`bad number: out of range`)=>{if(typeof e!=`bigint`)throw TypeError(r);if(t<=e&&e<n)return e;throw RangeError(r)},Kr=(e,t=Mr)=>(e%=t)>=0n?e:t+e,qr=(1n<<255n)-1n,W=e=>{if(e<0n)throw RangeError(`negative coordinate`);let t=19n*(e>>255n)+(e&qr);return t=19n*(t>>255n)+(t&qr),t%Mr},Jr=(e,...t)=>Br((e=>{let t=ci[e];if(typeof t!=`function`)throw Error(`hashes.`+e+` not set`);return t})(e)(Wr(...t)),64,`digest`),Yr=e=>{if(e instanceof Zr)return e;throw TypeError(`Point expected`)},Xr=2n**256n,Zr=class e{static BASE;static ZERO;X;Y;Z;T;constructor(e,t,n,r){let i=Xr;this.X=Gr(e,0n,i),this.Y=Gr(t,0n,i),this.Z=Gr(n,1n,i),this.T=Gr(r,0n,i),jr(this)}static CURVE(){return Rr}static fromAffine(t){return new e(t.x,t.y,1n,W(t.x*t.y))}static fromBytes(t,n=!1){let r=((e,t=``,n)=>Uint8Array.from(Br(e,n,t)))(t,`point`,32),i=r[31];r[31]=-129&i;let a=ti(r);n||Gr(a,0n,Mr);let o=W(a*a),{isValid:s,value:c}=ii(Kr(o-1n),W(Pr*o+1n));if(!s)throw Error(`bad point: y not sqrt`);let l=!!(128&i);if(!n&&c===0n&&l)throw Error(`bad point: x==0, isLastByteOdd`);return l!==!!(1n&c)&&(c=Kr(-c)),new e(c,a,1n,W(c*a))}static fromHex(t,n){return e.fromBytes(Ur(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){let e=Lr,t=Pr;if(this.is0())throw Error(`bad point: ZERO`);let{X:n,Y:r,Z:i,T:a}=this,o=W(n*n),s=W(r*r),c=W(i*i),l=W(c*c);if(W(c*(W(o*e)+s))!==Kr(l+W(t*W(o*s))))throw Error(`bad point: equation left != right (1)`);if(W(n*r)!==W(i*a))throw Error(`bad point: equation left != right (2)`);return this}equals(e){let{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:o}=Yr(e);return W(t*o)===W(i*r)&&W(n*o)===W(a*r)}is0(){return this.equals($r)}negate(){return new e(Kr(-this.X),this.Y,this.Z,Kr(-this.T))}double(){let{X:t,Y:n,Z:r}=this,i=Lr,a=W(t*t),o=W(n*n),s=W(2n*r*r),c=W(i*a),l=Kr(t+n),u=Kr(W(l*l)-a-o),d=Kr(c+o),f=Kr(d-s),p=Kr(c-o),m=W(u*f),h=W(d*p),g=W(u*p),_=W(f*d);return new e(m,h,_,g)}add(t){let{X:n,Y:r,Z:i,T:a}=this,{X:o,Y:s,Z:c,T:l}=Yr(t),u=Lr,d=Pr,f=W(n*o),p=W(r*s),m=W(W(a*d)*l),h=W(i*c),g=Kr(W(Kr(n+r)*Kr(o+s))-f-p),_=Kr(h-m),v=Kr(h+m),y=Kr(p-W(u*f)),b=W(g*_),x=W(v*y),S=W(g*y),C=W(_*v);return new e(b,x,C,S)}subtract(e){return this.add(Yr(e).negate())}multiply(e,t=!0){if(!t&&e===0n||(Gr(e,1n,Nr),!t&&this.is0()))return $r;if(e===1n)return this;if(this.equals(Qr))return di(e).p;let n=$r,r=Qr,i=this;for(let a=0;t?a<256:e>0n;a++)1n&e?n=n.add(i):t&&(r=r.add(i)),i=i.double(),e>>=1n;return n}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){let{X:e,Y:t,Z:n}=this;if(this.equals($r))return{x:0n,y:1n};let r=((e,t)=>{if(e===0n)throw Error(`invert: expected non-zero number`);if(t<=1n)throw Error(`invert: expected modulus > 1, got `+t);let n=Kr(e,t),r=t,i=0n,a=1n;for(;n!==0n;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==1n)throw Error(`invert: does not exist`);return Kr(i,t)})(n,Mr);if(W(n*r)!==1n)throw Error(`invalid inverse`);return{x:W(e*r),y:W(t*r)}}toBytes(){let{x:e,y:t}=this.toAffine(),n=ei(t);return n[31]|=1n&e?128:0,n}toHex(){return Hr(this.toBytes())}clearCofactor(){return this.multiply(8n,!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return this.multiply(Nr/2n,!1).double().add(this).is0()}},Qr=new Zr(Fr,Ir,1n,Kr(Fr*Ir)),$r=new Zr(0n,1n,1n,0n);Zr.BASE=Qr,Zr.ZERO=$r;var ei=e=>Ur(Vr(Gr(e,0n,Xr),64)).reverse(),ti=e=>BigInt(`0x`+Hr(Uint8Array.from(Br(e)).reverse())),ni=(e,t)=>{let n=e;for(;t-->0;)n=W(n*n);return n},ri=19681161376707505956807079304988542015446066515923890162744021073123829784752n,ii=(e,t)=>{let n=W(t*W(t*t)),r=W(e*W(n*(e=>{let t=W(W(e*e)*e),n=W(ni(W(ni(t,2)*t),1)*e),r=W(ni(n,5)*n),i=W(ni(r,10)*r),a=W(ni(i,20)*i),o=W(ni(a,40)*a);return W(ni(W(ni(W(ni(W(ni(o,80)*o),80)*o),10)*r),2)*e)})(W(e*W(W(n*n)*t))))),i=W(t*W(r*r)),a=r,o=W(r*ri),s=i===e,c=i===Kr(-e),l=i===Kr(-e*ri);return s&&(r=a),(c||l)&&(r=o),(1n&Kr(r))==1n&&(r=Kr(-r)),{isValid:s||c,value:r}},ai=e=>{return t=ti(e),Kr(t,Nr);var t},oi=(e,t,n,r)=>{e=Br(e,64,`signature`),t=Br(t,void 0,`message`),n=Br(n,32,`publicKey`);let i=(e=>{if(typeof e!=`object`||!e)throw TypeError(`expected valid options object`);return e.zip215??!0})(r),a=e.subarray(0,32),o=ti(e.subarray(32,64)),s,c,l,u=Uint8Array.of(),d=!1;try{s=Zr.fromBytes(n,i),c=Zr.fromBytes(a,i),l=Qr.multiply(o,!1),u=Wr(a,n,t),d=!0}catch{}return[u,e=>{if(!d||!i&&s.isSmallOrder())return!1;let t=ai(e);return c.add(s.multiply(t,!1)).subtract(l).clearCofactor().is0()}]},si=(e,t,n,r={})=>{return(i=oi(e,t,n,r))[1](Jr(`sha512`,i[0]));var i},ci={sha512Async:async e=>{let t=globalThis?.crypto?.subtle;if(!t)throw Error(`crypto.subtle must be defined, consider polyfill`);return new Uint8Array(await t.digest(`SHA-512`,Wr(e)))},sha512:void 0},li=void 0,ui=(e,t)=>{let n=t.negate();return e?n:t},di=e=>{let t=li||=(()=>{let e=[],t,n=Qr;for(let r=0;r<33;r++){t=n,e.push(t);for(let r=1;r<128;r++)t=t.add(n),e.push(t);n=t.double()}return e})(),n=$r,r=Qr;for(let i=0;i<33;i++){let a=Number(255n&e);e>>=8n,a>128&&(a-=256,e+=1n);let o=128*i,s=o+Math.abs(a)-1,c=i%2!=0,l=a<0;a===0?r=r.add(ui(c,t[o])):n=n.add(ui(l,t[s]))}if(e!==0n)throw Error(`invalid wnaf`);return{p:n,f:r}},fi=BigInt(2**32-1),pi=BigInt(32);function mi(e,t=!1){return t?{h:Number(e&fi),l:Number(e>>pi&fi)}:{h:0|Number(e>>pi&fi),l:0|Number(e&fi)}}var hi=(e,t,n)=>e>>>n,gi=(e,t,n)=>e<<32-n|t>>>n,_i=(e,t,n)=>e>>>n|t<<32-n,vi=(e,t,n)=>e<<32-n|t>>>n,yi=(e,t,n)=>e<<64-n|t>>>n-32,bi=(e,t,n)=>e>>>n-32|t<<64-n;function xi(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:0|i}}var Si=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ci=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,wi=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Ti=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,Ei=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),Di=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0;function Oi(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var ki=e=>e?`"${e}" `:``;function Ai(e,t,n=``){if(Oi(e)&&(t===void 0||e.length===t))return e;t!==void 0&&function(e,t=``){if(typeof e!=`number`)throw TypeError(ki(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(ki(t)+`expected integer >= 0, got `+e)}(t,`length`);let r=Oi(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=`+typeof e,o=ki(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}var ji=(e,t)=>{((e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)})(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,`__proto__`))throw TypeError(`"${t}.__proto__" is not allowed`)};function Mi(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function Ni(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Pi(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Fi(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=function(e,t,n=`opts`){return ji(e,`defaults`),t!==void 0&&ji(t,n),Object.assign(Object.create(null),e,t)}({},t,`info`);let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}var Ii=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])}),Li=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Pi(this.buffer)}update(e){Mi(this),Ai(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;o<i;){let s=Math.min(r-this.pos,i-o);if(s===r){let t=Pi(e);for(;r<=i-o;o+=r)this.process(t,o);a=!0}else n.set(o===0&&s===i?e:e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0,a=!0)}return this.length+=e.length,a&&this.roundClean(),this}digestInto(e){Mi(this),function(e,t){Ai(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,t.fill(0,a),this.padOffset>r-a&&(this.process(n,0),t.fill(0)),function(e,t,n,r){let i=(e=>e/2**32|0)(n),a=(e=>e>>>0)(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}(n,r-8,8*this.length,i),this.process(n,0),this.roundClean();let o=e===t?n:Pi(e),s=this.outputLen,c=s/4,l=this.get();if(s%4||c>l.length)throw Error(`invalid outputLen`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,a&&e.buffer.set(t),e}clone(){return this._cloneInto()}},Ri=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),zi=function(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=mi(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),Bi=zi[0],Vi=zi[1],Hi=new Uint32Array(80),Ui=new Uint32Array(80),Wi=class extends Li{Ah=0;Al=0;Bh=0;Bl=0;Ch=0;Cl=0;Dh=0;Dl=0;Eh=0;El=0;Fh=0;Fl=0;Gh=0;Gl=0;Hh=0;Hl=0;constructor(e,t){super(128,e,16,!1),this.Ah=0|t[0],this.Al=0|t[1],this.Bh=0|t[2],this.Bl=0|t[3],this.Ch=0|t[4],this.Cl=0|t[5],this.Dh=0|t[6],this.Dl=0|t[7],this.Eh=0|t[8],this.El=0|t[9],this.Fh=0|t[10],this.Fl=0|t[11],this.Gh=0|t[12],this.Gl=0|t[13],this.Hh=0|t[14],this.Hl=0|t[15]}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|a,this.Dh=0|o,this.Dl=0|s,this.Eh=0|c,this.El=0|l,this.Fh=0|u,this.Fl=0|d,this.Gh=0|f,this.Gl=0|p,this.Hh=0|m,this.Hl=0|h}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)Hi[n]=e.getUint32(t),Ui[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=0|Hi[e-15],n=0|Ui[e-15],r=_i(t,n,1)^_i(t,n,8)^hi(t,0,7),i=vi(t,n,1)^vi(t,n,8)^gi(t,n,7),a=0|Hi[e-2],o=0|Ui[e-2],s=_i(a,o,19)^yi(a,o,61)^hi(a,0,6),c=wi(i,vi(a,o,19)^bi(a,o,61)^gi(a,o,6),Ui[e-7],Ui[e-16]),l=Ti(c,r,s,Hi[e-7],Hi[e-16]);Hi[e]=0|l,Ui[e]=0|c}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=_i(u,d,14)^_i(u,d,18)^yi(u,d,41),v=vi(u,d,14)^vi(u,d,18)^bi(u,d,41),y=u&f^~u&m,b=Ei(_,v,d&p^~d&h,Vi[e],Ui[e]),x=Di(b,g,t,y,Bi[e],Hi[e]),S=0|b,C=_i(n,r,28)^yi(n,r,34)^yi(n,r,39),w=vi(n,r,28)^bi(n,r,34)^bi(n,r,39),T=n&i^n&o^i&o,E=r&a^r&s^a&s;g=0|m,_=0|h,m=0|f,h=0|p,f=0|u,p=0|d,{h:u,l:d}=xi(0|c,0|l,0|x,0|S),c=0|o,l=0|s,o=0|i,s=0|a,i=0|n,a=0|r;let D=Si(S,w,E);n=Ci(D,x,C,T),r=0|D}({h:n,l:r}=xi(0|this.Ah,0|this.Al,0|n,0|r)),{h:i,l:a}=xi(0|this.Bh,0|this.Bl,0|i,0|a),{h:o,l:s}=xi(0|this.Ch,0|this.Cl,0|o,0|s),{h:c,l}=xi(0|this.Dh,0|this.Dl,0|c,0|l),{h:u,l:d}=xi(0|this.Eh,0|this.El,0|u,0|d),{h:f,l:p}=xi(0|this.Fh,0|this.Fl,0|f,0|p),{h:m,l:h}=xi(0|this.Gh,0|this.Gl,0|m,0|h),{h:g,l:_}=xi(0|this.Hh,0|this.Hl,0|g,0|_),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){Ni(Hi,Ui)}destroy(){this.destroyed=!0,Ni(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Gi=class extends Wi{constructor(){super(64,Ri)}};ci.sha512=Fi(()=>new Gi,Ii(3));var Ki=class extends Error{constructor(e){super(e),this.name=`LicenseTokenError`}},qi=/^[A-Za-z0-9_-]+$/;function Ji(e){if(!qi.test(e))throw new Ki(`Malformed license key`);let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=globalThis.atob(t+`=`.repeat((4-t.length%4)%4));return Uint8Array.from(n,e=>e.charCodeAt(0))}var Yi=e=>typeof e==`number`&&Number.isFinite(e),Xi=e=>e===void 0||Yi(e);function Zi(e){let t=e.trim().split(`.`);if(t.length!==3||t[0]!==`sxl1`)throw new Ki(`Not a SheetXL license key`);let n;try{n=JSON.parse(new TextDecoder(`utf-8`,{fatal:!0}).decode(Ji(t[1])))}catch(e){throw e instanceof Ki?e:new Ki(`Malformed license key`)}if(!n||typeof n!=`object`||typeof n.kid!=`string`)throw new Ki(`Invalid license key: bad 'kid'`);return(e=>{let t=e,n=e=>{throw new Ki(`Invalid license key: bad '${e}'`)};t&&typeof t==`object`&&!Array.isArray(t)||n(`payload`),typeof t.lid==`string`&&t.lid||n(`lid`),typeof t.l==`string`&&t.l||n(`l`),typeof t.t==`string`&&t.t||n(`t`);let r=t.r;return Array.isArray(r)&&r.length!==0&&r.every(e=>mr.includes(e))||n(`r`),t.d===void 0||Array.isArray(t.d)&&t.d.every(e=>typeof e==`string`)||n(`d`),Xi(t.dc)||n(`dc`),Xi(t.cc)||n(`cc`),Xi(t.m)||n(`m`),t.n!==void 0&&typeof t.n!=`string`&&n(`n`),t.f===void 0||typeof t.f==`object`&&t.f!==null&&!Array.isArray(t.f)||n(`f`),Yi(t.iat)||n(`iat`),Yi(t.exp)||n(`exp`),t})(n)}function Qi(e,t){e-=398;let n=$i(),r=n[e];Qi.ZIMJrc===void 0&&(Qi.odvhEY=function(e,t){let n,r=[],i=0,a=``;e=function(e){let t=``,n=``;for(let n,r,i=0,a=0;r=e.charAt(a++);~r&&(n=i%4?64*n+r:r,i++%4)&&(t+=String.fromCharCode(255&n>>(-2*i&6))))r=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=`.indexOf(r);for(let e=0,r=t.length;e<r;e++)n+=`%`+(`00`+t.charCodeAt(e).toString(16)).slice(-2);return decodeURIComponent(n)}(e);let o=0;for(;o<256;o++)r[o]=o;for(o=0;o<256;o++)i=(i+r[o]+t.charCodeAt(o%t.length))%256,n=r[o],r[o]=r[i],r[i]=n;o=0,i=0;for(let t=0;t<e.length;t++)o=(o+1)%256,i=(i+r[o])%256,n=r[o],r[o]=r[i],r[i]=n,a+=String.fromCharCode(e.charCodeAt(t)^r[(r[o]+r[i])%256]);return a},Qi.dpAgyv={},Qi.ZIMJrc=!0);let i=n[0];Qi.wFOfzn!==i&&(Qi.dpAgyv={},Qi.wFOfzn=i);let a=Qi.dpAgyv[e];return a===void 0?(Qi.FmbNfs===void 0&&(Qi.FmbNfs=!0),r=Qi.odvhEY(r,t),Qi.dpAgyv[e]=r):r=a,r}function $i(){let e=`WRpcNa9qW5mxcmohvcBcT2DLW4xdI8kiWOFcL8keWRNdSW.ECoeWQXG.WRDBWO9n.WRldUeNdRmoVW50.hSknW6b8W4ZcMZab.mHiCi2nFumouW5ldMmoyW6q.WOBdMdTRfNvFW7K.WRddIKmC.cKPjuSkHpeSnxCo0cmkjWOifzq.y8kDgIj/qq.W6DWdcJdR8oOySoBva7dLKpcMHC.rSoAWRONWO/dMZegWPj6WPddQa.tCkRWQThra/dVvpdJh8.uuldJtLyW4NdQCkpkmk4.iSoCW6L/WOVdKXhdOW.W7HiW5XbWOvaWOxcQK/cPmkrcZJcG8kgWRLnafZcNq.WRDAW4ZdGamSW5fXbbZdTW.W6rRW7S4WQS4.emkyW7HG.ECkYW4FdGmkmd8oYW5SKwI3cIG.v8oLpmkBW6ZcQCknpmkMCLbV.x8oNpCkFW6RcRmoXmCkkx1nvWPm.dKhdMauCWPu.iuzECSk5lKj+tmoJcmkKWPeuzaxcSmk7hW.WP/dGYTV.W6xdTYddMW.W4P+tIm.k0RdGameWPryoN4gyNRcSg7dVwtcL8kmWOvKW6JdUs4NW4LEW78.W7ZdVCk5WP3dJCknqW.W5JdOcBdN8oew8kLCfZdMuCncmkTW5S6W5hdVq.W7xdOt3dN8obxmkY.eHfAW7i.vb7cIfHFW5hdSq.iCoduSoS.wKfMW5THW7C.AZRdK31NWOyDfG.mmoFWQLKWPHnuq.W4tcHaddKSoQeYRcSmkJW4OGWPO.a0rnW7/cV8o6AXG/tmkCW6/cRSkAW6FdM8kqE316W5KUWQLfBZpcHCkqWOSEWPz2sCkVWRZdImkPW7BdJJfcWOBcUCo2bCkBWOvCvSkpW4BcI3D8rJFcK281W4ldPCo/WRJdLaNcGqrwj8ouWQTcWPtdGbVdS8kmW5qtW7f3W6hcImkBq8o+qmokvSo9.yHCfFSoNuG.gJxdSmoc.WOBdLvxcIW.WRaIWR9JW6H4WOldO2JcPhuvW5n7.rCkkbYz4vJupbW.WQldJv8dWQFdR8kQ.W5nFWOXmWPHu.FWCBEq.kNFcJCotWP7dMmkJcG.r8oyqSo0W5LqW50.WQlcVJFdImoMr8kIiW.WROKvN3cQSk5.W5zUuYZcKIy.rHWECmo5qHFcL8kzrmoOmN9/.hM1BW697.WRpdR1JdJmoJW5LIyMZdSSkkz8oifZW.WQDoWOHiWQtcPa.WQShWORdGa.qSoDWRWHWOZdK0ChWQ9+WRhdVSka.WRlcS8kJemkcbCkisq.tSosqSo6W4jh.W4hcSmk7i8kRW5ZdVL7cGYtdPCkECmk2hW.jYNdR8ooW64nFqRcSmkLqbRdIsHlW5fRWQtdP1e.WPJcVxFcVrmV.W64lWPlcNuKb.tSotWQpdLCoBWPqhWRalcYe.W51UsqNcKYFdIJNcLxHWcG.WQpdNZTIdwjFWQP3W5OTnCkdr3RcPSowv8kqw8oyACoW.rCoEqCoYW5vmW57dPXxcOCoQ.qSobWQmVeMpcK8o4.W6D6W6u2WRWZW4dcOuJcP2a.qSogWR8Z.WR/dISkoW77dSmk5yfG.eMa0DCkxwmkItG.auPtCmkJnq.WPPHW40Q.z8oXW7ZcNmoWWPRdUW.WPRcLLTIW5qremomysZcQtr/W5RdGa.DSkccSk1gxHolCkiWRzMW4y.cKPjuSkHpeSotmoPeCkIWOC0BKe.BX8dW6iKW7C.oxbnqN0Z.nmotx8oS.oSobWQP2.W4xdNhm4W7pdTwOhodzEAa.gCo7WP7dHCoZW4NcHSooWP7cMmkID3K+.WO7cH05cW40D.DSkqgsm.ggW2zmkmwCkIwa.zsrNsh8Dy8oJ.yhHsDwONza.WRldO0ddVCoWW4O.iCotx8o0vdHfgq.tdHHj8oigmoXqZLLW6v3hG.W4tdI2iFW7ZdUq.gwWJvCkpsSkREYvuW4bpdSotkwm.WQFdPuhdRa.W4jiWRbkWOLmWOJcPMxcTSofhrVcKSkxWRLfdG.WPldOCo8u8oMW6hdOMpcVWldGW.DvmWiIqtt3/dKJRcG8oDW7G.WRFdULNdISo6W41Grq.oNVcKaK5W4bfcSozW6SrWRvD.kCoeWQXT.W4BcGfpcKCkCvcFcHa`.split(`.`);return($i=function(){return e})()}(function(){function e(e,t,n,r,i){return Qi(i-598,e)}function t(e,t,n,r,i){return Qi(i- -269,n)}function n(e,t,n,r,i){return Qi(t- -922,r)}function r(e,t,n,r,i){return Qi(t- -139,n)}let i=$i();for(;;)try{if(-parseInt(n(0,-472,0,`y@@0`))/1*(-parseInt(r(0,324,`Yzq1`))/2)+-parseInt(n(0,-471,0,`tUCh`))/3+-parseInt(n(0,-502,0,`*k3E`))/4+-parseInt(t(0,0,`EL$X`,0,161))/5*(-parseInt(n(0,-517,0,`5bTV`))/6)+-parseInt(e(`[gzp`,0,0,0,1086))/7+-parseInt(t(0,0,`YI2Q`,0,178))/8*(parseInt(e(`H0f7`,0,0,0,1041))/9)+-parseInt(r(0,334,`Da!t`))/10*(-parseInt(t(0,0,`P*^C`,0,147))/11)==534379)break;i.push(i.shift())}catch{i.push(i.shift())}})();var ea=(e,t,n)=>{let r=`Xaox`,i=`[gzp`,a=`#0gD`,o=[];function s(e,t,n,r,i){return Qi(e-829,i)}let c=e[l(734,719,`Da!t`,732,741)]?new Date(e[l(774,747,`2)lv`,779,723)]):null;function l(e,t,n,r,i){return Qi(t-271,n)}function u(e,t,n,r,i){return Qi(i-292,n)}if(c?isNaN(c)?o[l(743,709,`!F(h`,689,709)](u(716,799,`jc[P`,758,752)):c<new Date&&o[s(1306,0,0,0,`7fw]`)](s(1283,0,0,0,`2Cy5`)+c[u(741,725,`2)lv`,703,716)]()):o[l(736,726,`KHM1`,677,772)](l(665,697,`S9cV`,712,670)),n)return o;let d=t[l(0,704,`yVYo`)]==null?s(1304,0,0,0,`!F(h`):p(-106,-108,-95,-148,`yVYo`);function f(e,t,n,r,i){return Qi(r-445,n)}function p(e,t,n,r,i){return Qi(t- -594,i)}if(!gr(e)[p(0,-157,0,0,`KHM1`)](d))return o[s(1258,0,0,0,r)](l(0,768,`KHM1`)+d+l(0,703,r)),o;if(t[p(0,-145,0,0,i)]!=null){let n=e=>{return e?e[r=`iDJf`,i=1307,f(0,0,r,i-391)]()[t=1491,n=`OrND`,f(0,0,n,t-551)]():null;var t,n,r,i},r=n(e[u(0,0,`9UjX`,0,790)]);if(r){let e=t[p(0,-94,0,0,`Da!t`)],i=e&&n(e[s(1242,0,0,0,`4X**`)])===r,c=e&&n(e[l(0,735,`5bTV`)])===r;!i&&!c&&o[u(0,0,a,0,749)](p(0,-102,0,0,`iDJf`))}(e[u(0,0,`T3uW`,0,770)]??0)>0&&t[f(0,0,`Xaox`,855)]>e[p(0,-128,0,0,`dX#0`)]&&o[f(0,0,a,902)](t[l(0,758,`Waoo`)]+`/`+e[f(0,0,`oZGU`,844)]+f(0,0,`e44Y`,929)),(e[f(0,0,`YI2Q`,939)]??0)>0&&t[s(1264,0,0,0,i)]>e[s(1319,0,0,0,`9UjX`)]&&o[u(0,0,`CG*#`,0,706)](t[u(0,0,`!41%`,0,781)]+`/`+e[u(0,0,`7fw]`,0,762)]+s(1288,0,0,0,`oZGU`))}if(t[p(0,-129,0,0,`e44Y`)]!=null){let n=e[l(0,732,`jc[P`)],r=!0===e[u(0,0,`*k3E`,0,707)]?.[l(0,764,`jp8!`)];if(n&&n[f(0,0,`rh0#`,926)]!==0){let e=t[l(0,770,`gjKg`)]??``,i=t[l(0,736,`e44Y`)],a=n[s(1247,0,0,0,`s(D)`)](e=>Cr(e)!==null);a[u(0,0,`#0gD`,0,774)]===0?o[u(0,0,`VO#0`,0,694)](s(1260,0,0,0,`4X**`)):!a[s(1252,0,0,0,`s(D)`)](t=>wr(t,r)&&function(e,t,n){function r(e,t,n,r,i){return Dr(0,0,0,i,e-76)}let i=Cr(e);if(!i||i[r(115,0,0,0,`dwJ0`)]!==t[u(1343,1342,1335,`aMOG`,1341)]()[r(116,0,0,0,`wmLV`)]())return!1;if(i[u(1338,1364,1366,`wmLV`,1360)]===`*`)return!0;let a=n[r(125,0,0,0,`B7mn`)]()[o=315,s=`Z@uF`,Dr(0,0,0,s,o-288)]();var o,s,c,l;if(i[u(1307,1337,1339,`uZcL`,1319)]===``)return a===``;function u(e,t,n,r,i){return Dr(0,0,0,r,i-1306)}return a===i[r(123,0,0,0,`Z@uF`)]||a[u(0,0,0,`KK@v`,1358)](`.`+i[c=`LDqo`,l=-535,Dr(0,0,0,c,l- -547)])}(t,e,i))&&o[l(0,669,`gjKg`)](l(0,754,`7fw]`))}else o[f(0,0,`@J%(`,907)](u(0,0,`2)lv`,0,738))}return o},ta=e=>{let{type:t,keyFrom:n,exceptions:r,validFor:i,isEval:a=!1,licensee:o=null,developerCount:s=0}=e;function c(e,t,n,r,i){return Qi(e- -694,r)}function l(e,t,n,r,i){return Qi(r-711,i)}let u=Object[p=`5bTV`,m=-6,Qi(m- -415,p)]({getLicensee:()=>o,getExpiration:()=>null,getRuntimes:()=>[],getDomains:()=>[],getDeveloperCount:()=>s,getCpuCount:()=>0,getMemory:()=>0,getType:()=>t,isEval:()=>a,getExceptions:()=>[...r],hasExceptions:()=>r[l(0,0,0,1164,`$la2`)]>0,isValidFor:e=>i,isValid:()=>!1,getFeatures:()=>{return Object[e=-3,t=`s(D)`,Qi(e- -437,t)]({});var e,t},getKeyFrom:()=>n,getBuildVersion:Ln[c(-290,0,0,`4X**`)],getBuildDate:Ln[c(-198,0,0,`#0gD`)],getEvalPeriodEnd:Ln[d=-64,f=`*k3E`,Qi(d- -486,f)],getEvalStopDate:Ln[l(0,0,0,1150,`2Cy5`)],getSummary:e=>dr(u,e)});var d,f,p,m;return u},na=(e,t,n,r)=>{let i;function a(e,t,n,r,i){return Qi(r- -431,t)}try{let e=Ar();if(!e&&!r)throw new Ki(a(0,`@J%(`,0,38));i=function(e,t=Ar()){let n=Zi(e);if(t){let r=t[n.kid];if(!r)throw new Ki(`License key signed with an unknown key '${n.kid}'`);let[,i,a]=e.trim().split(`.`),o=Ji(a),s=!1;try{s=o.length===64&&si(o,new TextEncoder().encode(i),Ji(r))}catch{s=!1}if(!s)throw new Ki(`License key signature is not valid`)}return{keyId:n.kid,licenseId:n.lid,licensee:n.l,type:n.t,runtimes:[...n.r],domains:n.d?[...n.d]:[],developerCount:n.dc??1,cpuCount:n.cc??0,memory:n.m??0,fingerprint:n.n??null,features:n.f??{},issuedAt:1e3*n.iat,expiry:1e3*n.exp}}(t,e)}catch(t){let n=t instanceof Ki?`: `+t[c=`3iLJ`,l=86,Qi(l- -317,c)]:``;return ta({type:a(0,`Xaox`,0,36),keyFrom:e,exceptions:[(o=163,s=`$la2`,Qi(o- -295,s)+e+`'`+n)],validFor:!1})}var o,s,c,l;return((e,t,n)=>{let r=Object[c(`EL$X`,-426,-428,-473,-428)]({getLicensee:()=>e[c(`*k3E`,-521,-549,-545,-503)]??null,getExpiration:()=>new Date(e[i(`CG*#`,-202,-158,-188,-110)]),getRuntimes:()=>gr(e),getDomains:()=>e[i(`9UjX`,-137,-119,-113,-123)]??[],getDeveloperCount:()=>e[a(256,234,240,`u@)c`,195)]??1,getCpuCount:()=>e[c(`s(D)`,-547,-535,-518,-554)]??0,getMemory:()=>e[o(1156,1166,1128,`P*^C`,1156)]??0,getType:()=>e[i(`jc[P`,-164,-142,-141,-181)]??i(`CG*#`,-159,-124,-121,-151),getExceptions:()=>t,hasExceptions(){return!!t&&t[e=-268,n=-199,r=`2Cy5`,i=-216,s(e-240,r,n-241,i- -628,i-113)]>0;var e,n,r,i},isValidFor:e=>{return!(t?.[n=925,r=`a303`,i=975,o=932,a(n-45,r-484,i-740,r,o-313)]>0);var n,r,i,o},isValid:()=>!0,isEval:()=>!1,getFeatures:()=>Object[o(1169,1119,1208,`jO)*`,1126)]({...e[s(406,`5bTV`,398,430,460)]??{}}),getKeyFrom:()=>n,getBuildVersion:Ln[i(`h2%z`,-98,-107,-139,-68)],getBuildDate:Ln[o(1159,1210,1114,`jO)*`,1152)],getEvalPeriodEnd:Ln[i(`2Cy5`,-180,-192,-226,-156)],getEvalStopDate:Ln[a(338,295,313,`s(D)`,330)],getSummary:e=>dr(r,e)});function i(e,t,n,r,i){return Qi(n- -598,e)}function a(e,t,n,r,i){return Qi(n- -172,r)}function o(e,t,n,r,i){return Qi(e-748,r)}function s(e,t,n,r,i){return Qi(r-11,t)}function c(e,t,n,r,i){return Qi(r- -945,e)}return r})(i,ea(i,n,r),e)},ra=ee({claimFullLicensePrint:()=>ka,getEvalLicense:()=>Ca,getEvalState:()=>xa,getHostDetails:()=>da,getKey:()=>Da,getLicense:()=>wa,isDevEnv:()=>pa,isWatermarked:()=>Sa,isWebPage:()=>fa,printBanner:()=>Oa,printDetails:()=>ja,printLicenseNotice:()=>Aa,readLicenseKey:()=>ya,setKey:()=>Ta});function ia(e,t,n,r,i){return ca(i- -806,n)}function aa(e,t,n,r,i){return ca(t- -681,e)}function oa(){let e=`du3dQSkFymoetmk7.WRNcOCkeySoty13cNmoFWOm6mhRcNCoh.WQa3ySk7WRKbwCoVWPhdLW0B.WP7dJSkVWQaeALNcMmo7W4ldKSo0.W4NdJbjv.W4zFBmobWPqLW7tcQeDZWRu.W57dHCkas8kFWQW.W50MamoxW44m.cCobW4LQC8k/WOldGImqWOnKW6ddRSo3W643W7pcVwBcS8oKW7FdHCkUkSkfxx0EBtumW7ufjmosW5S.m8otWRhcHGqpW45Jbmo6fq.nSouWR/cHYiN.W6/cOCkaW7RdJmk+xgRcJW.W4SIW5XqW6W.WRxcR07cRHZdUmoVWOLvW6xcSCopdhhcG2i.W6yOFsC.qSksa8k0W7pdJCkzW6ldKteWqa.WRZdJSoSWO0bwKJcMCo6W4BcLCoAW4qd.W5v3WPldUsZcTSkNW4BcS3BdISkP.W6xcRfG.gmoeW73dTSoVomk3W6r2eSkXs8kqsmkEWPqtu13dV8oQWOpdQSoa.x1pcSbNcVSom.WOhdLCkTWRuDsG.WPZdMMTTxWdcReddS34DWQr0W5mfW7RcOCo8W7C5gmkYWOvgW4tcRSkVgCkRWPvkW5LnxSk6WO7dMG8FxCoUkCo3W6rgWQVdQYewWPJcVW.kSk4CZa.W6qTiSoen1/dVSo6.W60oW47cQN3dUSkiW4ZcMaBcHmo2.hCowrmoYWRm.yJ7dPSkqeCocpq.W6xcVmkmW7y.WQRcS8kjnCktxe3dIa.WRTPbM/cTc/dHG1vBc4.W4dcMmo7W7DyDMhcV8oXW5ddHa.cNFdVZVcNq.W6C6oCo5lfNdVa.W7P2jCo7.WPmdl8kZW4ShW5NcIvfZ.W6iKWONdNKifx8oTW6OhWO1HWQa.WROuimkeeSozwCo9gCkjW7i.WPipnCkt.fmkIyYWDWPmdW5O.W4VcJrRdSH7dKCkzWP5cza.W67cQmkiBCotj0hcMW.nSovWQJdHGW.W68OEJ3dNYTwDMi8W5tcVq.W7PWnmoT.WRhdKuVcSSkspmo6EbGRWObYW7q/W5q.t8oRW5P6BSo2W4C.WRddU8oqWQ7cLSoNbLpcKSkjmspdHW.W6RdICkLomktkq.W6CRlmocle/dHSo/nvy.WP7dJSkR.W4VdGryvWRy.uL7cPa.W7hdImotySkyWRT6oCoNBmoLW5/cILO.WQtdRSkkFbbPvqiCWP/dR8o2.qG3cSXlcL27cQCkthZZcIGi.W5NdVCorpCo6.WOFcK8olhCoiW6SRd8oJxmkwW7FcNG.W4CHjmovW5Ot.dgNdOtFcImohDLZdM8kmDW.WRmuimkWdCoECCkYcCkvW7tdN0u.W4K3fCoVW5iCW70/W77cOru.AxvHWPPpWRm.WQtdRSol.W7KyAcPXWQNcMCkiqebz.W4yZeSoMW4mCW70HW7NcRr9cCa.imoBWQNdGaywW5DJ.W4O3dCogW48A.mCoeWQpcJW.imoEW4TJ.ymktaW.WRujWRe.jCouWQ/dJqKuW5jNa8o+aW.naXQtCoZWOdcVmoOWQyZ.cmkICIujWPqoW4JdHqxcQa.W7vNjCooW7fAESo6WQddTaWnaa.hSovW73dHaeuW59OeSo3rSkcirfnWRLSWR1AD8oLW5xdKdxdIa.W6qZydK.W6hcQmkhy8ovDa.W6ldOSkQEGe2.cCkJtc8FWPiuW6RdHHRcQa.WRlcGXZdR8oFiSk9sruBW6KGWRC.W6BcVuZcRa.W53dLGjixGdcO0C.eWDRs8oMWOdcM8oVWQy6.WQ7cQmkpnG.WRhcPhTZWQjJWR7cH08crtm.W57dNbu.h2JdVsBdHmocF1ddKmkmA3xdImkUwmoHWPb2W5pdV1GOCNW7W41YWRa.WR8nWRxcKu0cWONdG2xdKG.cmkIytyjWP4kW4JdHqxcQa.WQXpWPZdQdNcSCkzW4dcQsq.b8ohq8oTWQZcG8ky.a0ZdPK3dLW.W5FdImkawSkFWRLYmG.lCk+EshdUaa+bJBcMgS5WPv1W7TGnHtdIsOSigBdON4J.W7dcMmkgj3iwae57fvG.fwldVtxcNCom.nM7cOCoSu8kwzCkTuu4NWR7dRa.iCk8fSkwbmk6C8oPWPFcSSkszbmwv8k2WR1MW5FdJ8kVimk4WOqFveRcRmkEAs5ujdBcHY4jdSoCWOn/na3dJ2H7WQ9C.cCk+As0.pmoFWRpdJXWF.W6aIEI7dJI0.qNtcQfBdHd/cNr0.W68OEcBdIh8.nCoDW5LN.W6OIycRdKM0f.WRnuWP7dUZNcQ8kHW4C.W6OUWPpdNqarvCkGW6yzWOy0WR/dQx9+mSotW6zBDNv+n8ojx8o1W6C.W64GWO7dJhGLFq.W7dcL8kmm1unavb7fq.W5S8e8ogW5OCW7aWW6/cQbu.W48anmkzW5bhW4VcIuvLW754WQm5WR8.ewBdObFcKCohE03dJCkjFshdLG.Eh9UWPPpWRevW6vrASoiaCkTDxRcK8kvWQfp.cqhdSeRdO8kaa8k9wwyjBG.omoiWRJdJG.WRpdVbLnwHFcQedcRh4.nmoxWQ/cIIL7W4y.W6eOzq.ng/cPSoGxmkFbmk2qearWR0.WRxcH8otdG.dJNdJMVdScjzW49J.fmk/vIeeWP4c.W4BcJW/dRHG.WRCNWPldH1LAr8kKW7uqW4u/W6ddTMKQ.WRldVmouWRxcKmo4aZFdIG.WPWCW580.g1lcHGRcSCoueSknB0S1reddNMCmW6W.W6NdJSkHoSkenq.B8keeNO.WPX0WPfPW6LtuCoGoa.sSkFWQxcOmkKoSkrW5bQFSkTAG.W6JcPLtcRGW.WPiunmkA.W7ddOsmXW6mG.ivHumZLJsCkyW4NdOwm.lqX+.WRWtj8kIdmoy.xx7cVW.f8oeW7ldUmoXuCkXW65GsmkWqq.W6ldTHrRW53cPHdcNCo1omk6W6ul.mmouuCoUWRxcLmkjW5RdVbTdsfRdVSk5ymo1W7a.W4u5W51o.W4O9dmocW5ir.a1ddTSkg.W53cJXRdQH7dGW.WQOnWQxcR0SE.fqfIr8oXWR3cUCk84OoxFSoFW6WXt2xcMmkCoSkYdNiSy8kTy8kTwsKCW7exj8k7ACkfWRVdG8kqbJzxaSkTpq5tWOSBW7hdHSknySoDW7HHW7edWQi7mdRdL8o0WOvWW4qpWOxcLmkpomozWR/dIq.aeNdUuW.W43dGSkdqSkqWRT6.WR4hWRtcTeW.W6ZdOdzpW4NcVX3cQCo7pG.W7PNmmoVW6XlBa.WQRcTCkn.lLXt.WONcP8kcleaxoeO1xq.Dmk5CI12cG.ww/cG1ldTq.WOJcTSkqmvGscG.jWT0r8oRWPe.WOycBcRdNZvwmNKRW5FdOSoEwfa.W4lcLbJdVWFdO8kzWPHFA3RcRW.W7BdMCk4nW.cCkJtc8lWPykW4ZdOWJcUCoSnHddJSk2WPq6.W6eXp8ovov/dUCo3i1ldGG`.split(`.`);return(oa=function(){return e})()}function sa(e,t,n,r,i){return ca(r-465,n)}function ca(e,t){e-=312;let n=oa(),r=n[e];ca.zOodws===void 0&&(ca.XKBaIZ=function(e,t){let n,r=[],i=0,a=``;e=function(e){let t=``,n=``;for(let n,r,i=0,a=0;r=e.charAt(a++);~r&&(n=i%4?64*n+r:r,i++%4)&&(t+=String.fromCharCode(255&n>>(-2*i&6))))r=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=`.indexOf(r);for(let e=0,r=t.length;e<r;e++)n+=`%`+(`00`+t.charCodeAt(e).toString(16)).slice(-2);return decodeURIComponent(n)}(e);let o=0;for(;o<256;o++)r[o]=o;for(o=0;o<256;o++)i=(i+r[o]+t.charCodeAt(o%t.length))%256,n=r[o],r[o]=r[i],r[i]=n;o=0,i=0;for(let t=0;t<e.length;t++)o=(o+1)%256,i=(i+r[o])%256,n=r[o],r[o]=r[i],r[i]=n,a+=String.fromCharCode(e.charCodeAt(t)^r[(r[o]+r[i])%256]);return a},ca.jqjVnO={},ca.zOodws=!0);let i=n[0];ca.Uphbwm!==i&&(ca.jqjVnO={},ca.Uphbwm=i);let a=ca.jqjVnO[e];return a===void 0?(ca.opxUIx===void 0&&(ca.opxUIx=!0),r=ca.XKBaIZ(r,t),ca.jqjVnO[e]=r):r=a,r}(function(){let e=`GQ%Q`;function t(e,t,n,r,i){return ca(e-186,t)}let n=oa();function r(e,t,n,r,i){return ca(t-183,e)}function i(e,t,n,r,i){return ca(i-300,r)}function a(e,t,n,r,i){return ca(r- -217,i)}function o(e,t,n,r,i){return ca(n-6,t)}for(;;)try{if(-parseInt(o(0,`Embu`,373))/1+-parseInt(o(0,e,378))/2+parseInt(r(`uz9U`,557))/3*(-parseInt(r(`t(#o`,606))/4)+parseInt(i(0,0,0,e,650))/5+parseInt(t(661,`Ry%x`))/6+parseInt(a(0,0,0,203,`dl6M`))/7+-parseInt(a(0,0,0,121,`o5]3`))/8==862624)break;n.push(n.shift())}catch{n.push(n.shift())}})();var la=new Set([ia(0,0,`zwWV`,0,-377),sa(0,0,`zwWV`,843),aa(`dnVz`,-207)]),ua=aa(`Yy!8`,-334);async function da(){function e(e,t,n,r,i){return sa(0,0,r,n- -1405)}let t=globalThis[i(-517,-546,`314#`,-543,-586)];if(!t)return{protocol:null,domain:null};function n(e,t,n,r,i){return sa(0,0,t,r-15)}let r=t[i(-473,-435,`5]B7`,-456,-503)][e(0,0,-538,`Ry%x`)](/:$/,``)[e(0,0,-608,`mO4t`)]();function i(e,t,n,r,i){return sa(0,0,n,r- -1363)}let a=t[n(0,`Ry%x`,0,826)][o=`UkB*`,s=918,sa(0,0,o,s-137)]();var o,s;return{protocol:r,domain:r!==n(0,`SrSC`,0,809)&&r!==i(0,0,`Td&1`,-522)||!la[n(0,`aZ9G`,0,887)](a)?a:null}}async function fa(){let{protocol:e,domain:t}=await da();function n(e,t,n,r,i){return ia(0,0,i,0,e- -7)}return(e!==n(-418,0,0,0,`Av$7`)||t!==ua)&&(e===null||e===ia(0,0,`dl6M`,0,-354)||e===n(-369,0,0,0,`60zl`))}async function pa(){return(await da())[e=`b(JS`,t=172,aa(e,t-457)]===null;var e,t}function ma(e,t,n,r,i){return ca(r-467,t)}var ha=ma(0,`i]Tp`,0,894)[ma(0,`s)sw`,0,812)](``)[ma(0,`gJmf`,0,866)]((e,t)=>t+e,``),ga=()=>{let e=`./`+ha,t=globalThis[a(-175,`%&42`,-179,-218,-263)]?.[a(-132,`bbz^`,-243,-192,-212)]??globalThis[o(265,202,274,251,`PDTH`)]?.[s(-85,-153,`Nfxm`,-73,-92)];function n(e,t,n,r,i){return ia(0,0,i,0,t-177)}function r(e,t,n,r,i){return ia(0,0,r,0,t-165)}if(!t)return[e];let i;try{i=new URL(e,t)}catch{return[e]}function a(e,t,n,r,i){return ia(0,0,t,0,r-253)}function o(e,t,n,r,i){return ia(0,0,i,0,e-712)}function s(e,t,n,r,i){return ia(0,0,n,0,t-274)}let c=[i[n(0,-167,0,0,`dl6M`)]];if(!i[n(0,-311,0,0,`i]Tp`)][s(0,-65,`5]B7`)](`/`))return c;for(;;){let e=new URL(r(0,-270,0,`^bUd`)+ha,i);if(e[o(274,0,0,0,`i]Tp`)]===i[a(0,`Vm1O`,0,-171)])return c;c[a(0,`Fi6)`,0,-138)](e[a(0,`H6dM`,0,-216)]),i=e}},_a={get(e){try{return globalThis[r=`AZrg`,i=348,ia(0,0,r,0,i-762)]?.[t=`GQ%Q`,n=846,ia(0,0,t,0,n-1207)](ha+`:`+e)??null}catch{return null}var t,n,r,i},set(e,t){try{globalThis[i=`JxRU`,a=976,ma(0,i,0,a-88)]?.[n=355,r=`5]B7`,ma(0,r,0,n- -563)](ha+`:`+e,t)}catch{}var n,r,i,a},delete(e){function t(e,t,n,r,i){return ia(0,0,n,0,i-466)}try{globalThis[t(0,0,`Td&1`,0,74)]?.[t(0,0,`sY8x`,0,-15)](ha+`:`+e)}catch{}}},va=async e=>{let t=`6gnZ`,n;function r(e,t,n,r,i){return aa(r,i-270)}try{n=await fetch(e)}catch{return{status:u(-294,-269,`5]B7`,-342,-325),from:e,reason:u(-493,-468,`8QfH`,-447,-519)}}let i=n[s(-292,-391,`JxRU`,-283,-362)];if(i>=500||i===408||i===429)return{status:r(0,0,0,`i]Tp`,-87),from:e,reason:u(-361,-229,`o5]3`,-290,-216)+i};if(!n.ok)return{status:l(165,88,82,`sY8x`,151),from:e};if(n[u(-291,-397,`dl6M`,-354,-426)][s(-523,-421,`Vm1O`,-544,-479)](s(-299,-331,`SrSC`,-268,-340))?.[c(-431,-420,-457,`^bUd`,-458)]()[l(124,133,176,`mO4t`,112)](r(0,0,0,t,-77)))return{status:s(-353,-367,`8QfH`,-372,-411),from:e};let a;try{a=await n[r(0,0,0,`Yy!8`,30)]()}catch{return{status:u(-293,-200,`G!Dh`,-282,-338),from:e,reason:s(-316,-290,`bbz^`,-328,-347)}}let o=a[u(-277,-385,`G!Dh`,-309,-328)](`
|
|
3
|
-
`)[l(18,-1,23,`gJmf`,13)](e=>e[u(-417,-397,`mO4t`,-407,-401)]())[r(0,0,0,`t(#o`,45)](e=>e[l(38,29,33,`i]Tp`,-25)]>0&&!e[s(-390,-451,`PDTH`,-425,-458)](`#`));function s(e,t,n,r,i){return aa(n,i- -120)}function c(e,t,n,r,i){return aa(r,t- -187)}function l(e,t,n,r,i){return aa(r,t-357)}function u(e,t,n,r,i){return aa(n,r- -78)}return!o||o[r(0,0,0,`sYRT`,-3)](`<`)?{status:c(0,-440,0,`E1v)`),from:e}:{status:r(0,0,0,t,-26),key:o,from:s(0,0,`SrSC`,0,-443)+e+`')`}};async function ya(){function e(e,t,n,r,i){return Ea(r,i- -1228,n-448,r-412,i-61)}function t(e,t,n,r,i){return Ea(t,e- -1161,n-109,r-490,i-464)}let n=ga();function r(e,t,n,r,i){return Ea(i,t- -766,n-197,r-126,i-158)}for(let a of n){let o=await va(a);if(o[i(663,`o5]3`,640,673,705)]===i(736,`uz9U`,727,752,728))return _a[e(0,0,-372,`314#`,-344)](a,o[t(-232,`6gnZ`,-277,-279,-306)]),o;if(o[t(-259,`uzqo`,-331,-200,-182)]===i(601,`mO4t`,644,609,644)){for(let e of n){let n=_a[i(720,`%&42`,657,640,657)](e);if(n)return{status:r(0,130,85,137,`gJmf`),key:n,from:t(-298,`E1v)`,-286,-234,-254)+e+`')`}}return o}_a[e(0,0,-474,`b(JS`,-416)](a)}function i(e,t,n,r,i){return Ea(t,i- -175,n-259,r-383,i-500)}return{status:i(0,`Embu`,790,676,756),from:n[0]}}var ba=async(e,t)=>{let n=Jn()?[...t,er()]:t;function r(e,t,n,r,i){return aa(r,t-330)}return ta({type:(i=`uVS%`,a=1218,aa(i,a-1578)),isEval:!0,licensee:r(0,43,0,`60zl`),developerCount:1,keyFrom:e,exceptions:n,validFor:!await fa()||n[r(0,115,0,`Fi6)`)]===0&&await pa()});var i,a};async function xa(e){if(e[t(`mO4t`,331,370,373,299)]()&&!e[t(`G!Dh`,321,299,241,366)]())return sa(0,0,`H6dM`,912);if(await fa())return t(`Td&1`,414,440,445,346);function t(e,t,n,r,i){return sa(0,0,e,t- -509)}return Xn()}async function Sa(e){return await fa()&&!e[t=1365,n=`*kEO`,aa(n,t-1642)](``);var t,n}async function Ca(e){return ba(e,[])}async function wa(){let e=`zwWV`;function t(e,t,n,r,i){return sa(0,0,i,e- -415)}let n=await ya();function r(e,t,n,r,i){return sa(0,0,i,r- -516)}function i(e,t,n,r,i){return sa(0,0,n,t- -684)}if(n[t(448,0,0,0,`Td&1`)]!==o(-378,-438,-371,`Av$7`,-368)&&!await fa())return ba(o(-397,-351,-401,`Ry%x`,-327),[]);function a(e,t,n,r,i){return sa(0,0,n,i- -532)}function o(e,t,n,r,i){return sa(0,0,r,i- -1263)}switch(n[t(475,0,0,0,`b(JS`)]){case t(510,0,0,0,`i]Tp`):return na(n[i(0,101,`E1v)`)],n[o(0,0,0,`sY8x`,-409)],await da(),await pa());case r(0,0,0,312,`b(JS`):return ta({type:r(0,0,0,291,`mO4t`),keyFrom:n[a(0,0,`j*G$`,0,330)],exceptions:[i(0,207,`uVS%`)+n[r(0,0,0,335,`t(#o`)]+o(0,0,0,e,-483)+n[i(0,95,`b^TO`)]+`)`],validFor:await pa()});case a(0,0,`Ry%x`,0,357):{let t=await pa()?[]:[o(0,0,0,`i]Tp`,-470)+n[r(0,0,0,395,e)]+`'`];return ba(a(0,0,`JxRU`,0,367),t)}}}async function Ta(e,t=!1){}function Ea(e,t,n,r,i){return ca(t-493,e)}async function Da(){throw Error(sa(0,0,`OZhE`,816))}async function Oa(e){let t=e?console[n=1402,r=`JxRU`,aa(r,n-1615)]:i[s(729,698,730,`b^TO`,683)];var n,r,a,o;function s(e,t,n,r,i){return aa(r,i-998)}return await t(`%c`+rr+ir+(a=211,o=`Ry%x`,aa(o,a-519)),s(0,0,0,`G!Dh`,657)+ar+s(0,0,0,`bbz^`,694)),Promise[s(0,0,0,`sYRT`,728)]()}async function ka(){return!0}async function Aa(){function e(e,t,n,r,i){return sa(0,0,e,n-227)}console[e(`H6dM`,0,1098)](e(`sY8x`,0,1092))}async function ja(e,t=!1,n=!1,r=!1){let i=`%&42`,a=`SrSC`;function o(e,t,n,r,i){return aa(e,i-67)}let s,c=console[o(`Embu`,0,0,0,-144)],l=[u(`dnVz`,51,101,98,120)+ar+u(`dnVz`,242,197,187,149)];if(e[p(-350,`b(JS`,-318,-386,-456)]())l[o(`%&42`,0,0,0,-192)](f(530,613,669,624,`bbz^`)+ar+p(-449,`6gnZ`,-352,-431,-360)),s=p(-437,`Embu`,-555,-482,-526),l[0]=p(-505,`SrSC`,-475,-506,-499)+sr+p(-422,`!uew`,-391,-399,-350),s+=u(i,150,256,208,143);else{s=d(137,147,166,`qui)`,161)+(e[f(494,566,619,639,`b(JS`)]()??d(-52,92,57,`sY8x`,25));let t=e[o(`*kEO`,0,0,0,-221)]()?.[u(`mO4t`,232,119,184,209)]();t&&(s+=u(i,120,108,137,69)+t);let n=e[d(65,134,207,`t(#o`,142)]();n&&n[u(`SrSC`,95,88,122,200)]>0&&(s+=d(2,68,30,`sYRT`,51)+n[u(a,135,167,200,240)](`, `));let r=e[f(743,708,699,750,`8QfH`)]();r>0&&(s+=p(-382,`uVS%`,-373,-398,-379)+r)}if(!r&&e[f(649,570,613,500,`b(JS`)]()){l[d(54,16,53,`uVS%`,46)](p(-457,`AZrg`,-474,-425,-465)),s+=f(720,666,676,629,a);let t=e[o(`dl6M`,0,0,0,-287)](),n=t[d(72,34,44,`G!Dh`,38)];for(let e=0;e<n;e++)s+=` `+t[e]}function u(e,t,n,r,i){return aa(e,r-449)}if(n){l[d(47,151,170,`s)sw`,90)](d(69,19,72,`qui)`,20)+lr+u(`t(#o`,0,0,132)),s+=`%c`,s+=d(148,163,74,`PDTH`,124)+Ma()+`'`;let t=e[f(661,594,543,517,`gJmf`)]();t&&(s+=p(-522,`sYRT`,-533,-514,-503)+t+`'`)}function d(e,t,n,r,i){return aa(r,i-370)}function f(e,t,n,r,i){return aa(i,t-934)}function p(e,t,n,r,i){return aa(t,r- -181)}return await c(``+s,...l),Promise[p(0,`60zl`,0,-518)]()}var Ma=()=>{function e(e,t,n,r,i){return ia(0,0,r,0,i-1094)}return typeof window===e(0,0,0,`Fi6)`,669)?window[r=`dnVz`,a=1252,ia(0,0,r,0,a-1599)][t=`j*G$`,n=-212,ia(0,0,t,0,n-176)]:i[e(0,0,0,`aZ9G`,676)]();var t,n,r,a};function Na(e,t,n,r,i){return Pa(e-92,r)}function Pa(e,t){e-=385;let n=Ra(),r=n[e];Pa.oUbtbh===void 0&&(Pa.EBnLTU=function(e,t){let n,r=[],i=0,a=``;e=function(e){let t=``,n=``;for(let n,r,i=0,a=0;r=e.charAt(a++);~r&&(n=i%4?64*n+r:r,i++%4)&&(t+=String.fromCharCode(255&n>>(-2*i&6))))r=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=`.indexOf(r);for(let e=0,r=t.length;e<r;e++)n+=`%`+(`00`+t.charCodeAt(e).toString(16)).slice(-2);return decodeURIComponent(n)}(e);let o=0;for(;o<256;o++)r[o]=o;for(o=0;o<256;o++)i=(i+r[o]+t.charCodeAt(o%t.length))%256,n=r[o],r[o]=r[i],r[i]=n;o=0,i=0;for(let t=0;t<e.length;t++)o=(o+1)%256,i=(i+r[o])%256,n=r[o],r[o]=r[i],r[i]=n,a+=String.fromCharCode(e.charCodeAt(t)^r[(r[o]+r[i])%256]);return a},Pa.UQJbJp={},Pa.oUbtbh=!0);let i=n[0];Pa.mbKhjw!==i&&(Pa.UQJbJp={},Pa.mbKhjw=i);let a=Pa.UQJbJp[e];return a===void 0?(Pa.OwTIAO===void 0&&(Pa.OwTIAO=!0),r=Pa.EBnLTU(r,t),Pa.UQJbJp[e]=r):r=a,r}(function(){function e(e,t,n,r,i){return Pa(i-345,n)}function t(e,t,n,r,i){return Pa(n- -990,i)}function n(e,t,n,r,i){return Pa(t-368,n)}function r(e,t,n,r,i){return Pa(n-666,r)}let i=Ra();function a(e,t,n,r,i){return Pa(r- -677,e)}for(;;)try{if(-parseInt(r(0,0,1078,`QcZ$`))/1+parseInt(r(0,0,1202,`rZHZ`))/2*(-parseInt(t(0,0,-505,0,`Opud`))/3)+-parseInt(e(0,0,`p^sB`,0,877))/4*(-parseInt(r(0,0,1154,`F6Jt`))/5)+parseInt(e(0,0,`SIbO`,0,734))/6*(parseInt(t(0,0,-537,0,`6s^9`))/7)+parseInt(a(`TsmP`,0,0,-143))/8+parseInt(a(`Opud`,0,0,-223))/9+-parseInt(r(0,0,1084,`)P6K`))/10*(parseInt(n(0,824,`p^sB`))/11)==574787)break;i.push(i.shift())}catch{i.push(i.shift())}})();var Fa=async e=>{if(Ia[t(`KSTG`,725,757,679,674)]&&Ia[t(`Vcsc`,691,704,695,670)])return!1;function t(e,t,n,r,i){return Pa(r-221,e)}return!!(e[o=`!t76`,s=1325,Pa(s-858,o)]()||e[t(`w)pE`,0,0,656)]()||e[i=469,a=`Ls3t`,Pa(i- -48,a)]()?.pb||await ra[n=`50ti`,r=1236,Pa(r-724,n)]());var n,r,i,a,o,s},Ia={promise:null,printNeeded:!1,details:null,bannerPrinted:!1,detailsPrinted:!1,licenseKey:null,keyFrom:null};function La(e,t,n,r,i){return Pa(e- -548,n)}function Ra(){let e=`pCo4W6nTyCol.WQ3cRSotWO/cJmoo.WO3cVqTbCmoeW4xdHsyxWQOrn8of.W6JdQNVdJb/dO25lW44.W5qaWQNdRmofWRy.W5pdUw7dGr/dQ3XVW5KSWPlcMSo+bG.WRLOW7NcLNhdT8kJsmo+W50ZW7xcOG.W59UqIDkACodW5eLWQ/dJW.W73cIWRcPbvBms3dUuz6hW.WQLOWQ7cSdVdRq/cIGtdQ8oHxa.wYVdQcOEpSo5.W6VdQCkUWRhdLhJdPa.WOeLfN0E.u8kiWRPkWP5iECkvnJflfCkG.WRXSW6pcTh3dPSkwvmoKW5y.qtirW4efWOtdTMWukf9NWPe.zs4eWOxdIxTxzW.B8kHWPXdWR03f8kh.W7K9W6ldG3JcULFcVHVdQmopuSkY.umooW6bfW53cPe/cLe3cTa.WOBdPv5jWP3cRMNdHZyTWPhcIa.FdyrW4KpWOtdHxS.WOJcUrfPFmoyW7ldKJ0jWQWDpq.xthdOZ8imSoZWRnv.WPNdRSo+WQpdUSkbWPxcMtFcIXPzWOi.WOhcVCogWQJcGmotyCosWOG.C8ofhWNdO8o2dsSrW6GFWRtdQq.W7pdUmk4WOFdLNldRq.luZdTmkTFxfN.A8oNoCkrChBcIMddSmk8.ASotWOddQmogW6jJpSogdq.rCogkbBdRmoU.WPZcTwldSSoOW7BcOCoGWOa.WQ7dUCoSWORdQ8kgWPhcNsy.W4hcKrW7m0BcJehIG5hcOq.ySoFWPFdRmobW711.m8k4WQOOW5BdRXS.pCoCW5a2W7NdKCkbW44vBmkNfmkv.W4dcG8ofqCoEp8kigCokW7nCnuvy.tZOCW4OoWOxdG1uypW.W5ZcTCkAW5RcSf0HW6FdRa.kCkBWQS.kCoCW5iTW7NdPCkN.DSoiWORdO8oCW59JemohewO.WQBdVqtdN8o8DIO.WPyLhNap.W5dcPqyDW4W.WOjpW6tdS2LMW5pcHCowtN7dGG.nSk8WRirW5RdIGG7CaRcSConhq.W7C0W6/dJhZdTGFcQr7dQCoz.pSo1WPHSWQGTcmkfodaAWQ4R.W7xcNa0.gXZcQJlcNmoGW6BcMXRdO8oPoW.W6hcJrGQmM0.CGRcMSo4jYa7fSoYWQlcU8o3tG.W6fTeCo8FCot.WQddRmk1WQFdOSk9eI/dL8kOFqJcUePuWQNdG8ohW7bJ.dIaorZ4UkHdcQue.WObqW7BdV3zuW7pcMSoByhVdHdFdQCouWR7cGxFcN8oGW7e.WRxcRH5RCmooW4pdLde.WPddH8ofr8kggSkMAmoWBa0.tSouaW7dQmoWgtWmW6CcWR3dVG.W414f8ozESoef8kVmHLNqeu.W5eAWO/dV8okWQLFfConDq.ESooW6OOtSoIW6HmjWZcIhu.bCkLESoiFgW.cSoKWOONWOzIFh4.WOZdNmoptmkCk8kItCo7Ca.kSkNz8omE2VcQW.zWPyuCkfWOasu2X+qYBdICkH.og3dPSkJW6vuyG.wNnwW7xdPePyaZmbmu3dRW.kSkfW5TXwSoKW7pdHg5bsH7dKG.pmoZWQabWPvN.WO/cOa9OA8oEW5e.W6NdU8kFW7ldNmkbnmobWOBcG1pdHaW.j8o/W4zQE8oRagK.qmokW6zV.eCo8W7bMy8oAkNRcVSo7Avmp.zaPyDCkAWO0nugP2wtC.CCojgv3dUa5e.WOeYa1GECSotW5q5WQNdSa.iwZdJmk4W61l.u8ofW4hdSHVdQSkeW68xWOT6W5SWWQu.vCokW7PVW53cON7cJ0JcQtWgma.WRpcSwRdSmo1W5BcPCoGWOr4Bgi.zaPyDmkjWPGaANjK.W7VcGSoECmofoSkvpq.WPTExtlcKr9VuCoypslcSCoBeq.oSolW580W47dHSk3W4Kpy8k/pmkuWRldImkDWO5Z.xSotW6pdSH7dR8kt.tZRdSXyhomo4WRHcgdGQWQG.W6lcIXyZlM3cPq.o3RdVq.kSkNyCopzLRcR2pdTCkbwG.W7VcUCobuSoyj8kufSoN.WOxdPYenW57dRMxdJq.kSkdW4H0xCo0W5BdLx8.W6JdVSkFW7ddN8kpomo1WOVcRh/dUGi.cmoCWQnoWPzdu8kv.dSoDWQb3WObVzCki.j8k4WQGZW5BdMZ0NAGhcJSonaa.BHpcNejbWP7dTmkfWQ4e.W4FdRCkZWQJdIMK.W4JcUCk6W5lcTCoxWRFcQJxcGYfY.aZOEsZCZ.WOWTjCoMzmosbmkT.WRpcSwZdS8oOW6hcPq.BCkqBgmYgSoFWRtdPw0PWPe.p8obCv4Ip8okWOO.W4dcVCk0W5hcTSoxWORcJWdcQWbX.qsZdGIWpnW.W77cJbpcUHn6jYRdIf1/aSoP.A8oMpCkuiIRdTLZdQSkLA17dMG.mSkmWRT+dSkyW5DImYxcJgbGW7DLW5HylG.EqtcGwHqWQtdSmkjWQysW50.ymotWO3dQSonW6n2b8okgNO.rtWkW4ee.nmkFWR5Lh8ksW4G.r8osW5ZdVqBdISkEW5WaWOXNW4OBWQ4ZlmkxeG.WQvOWQpcSZ/dOW4.xtGkWRBdNG.WRpcSwRdSmo1W5ZcPCoXWOf0za.cZNdP8ojW5HuW55mWO7cPCkeW5LDW4a.W4FcPq4qW53dMxldJXSbWPy.W6hcNa0slN3cPq/cTSoKW5uoWPi.WOPpW5pdS21xW6JcGa.DWNdSmkMm25zWO05W6RcUwldUSkdmCk5.WO/cRH5RsCopW5ddItSdWP0akCoyx8oHWQv5W6JdTmo2W6BcQmo7.W5pdUw7dGr/dQ3W.AmooW7PNW5FcOK3cMa.jL7dJmkIDgPtn8o9WOhcUCohqa.CSoph0pdVcLbWPGdfhW.WO8Kj3iACmocW4KKWQddP17dN8oGs8k8wCkQcmk/zKnm.WRhcPMldUSonW7VcO8oXWOTIzvRcRaq.tmkiWRPFWPrcCSkrjZW.W7xcQexcOCk6lXhcRxaiW5tcLW.W6JcOqysW4ddV3ldLra.W5lcIrhcOW9R.wH7dOSkpA0fvWP4OW63cPwNcQq.WPNdSmkQWQJdUSkAe2RdN8kKEG.hCkiWRn8e8kWW591mW.D2b/W4SJW4OgDqtdVq.W6tcIJtcQXv6jJtdUv19cCo5.W6NcNbFcQWHZjW.WQtcPNFdM8o3W7pcRmoyWOXYzx/cUHG.W6NcNbFcQWHZjWNdQKz4gmo4Fq.W40bWOpdT8onWQLF.W7VcLSodsCozjW.CaPyE8kjWPu.pmoZWQesWOjoFhW.WOxdVCoKWOS.WOBdPfjlWPNcQsVdSaqLWQFcJ8o7.s8ohdapdQa.u8ofW4hdSHVdQSke.W4FdRNxdJr/dTgO.WOFdKmoyBmkko8kIDSoQybauWQ8.vrRdPCkcFffeWQO5W7dcQ27cTSk7.w8ocW7DKW5BcO0VcTKtcVG.hCkuW5PDtmoZW5ldKw5jtbZdKG`.split(`.`);return(Ra=function(){return e})()}function za(e,t,n,r,i){return Pa(e- -841,i)}var Ba=null,Va=e=>{function t(e,t,n,r,i){return Pa(e- -918,n)}function n(e,t,n,r,i){return Pa(i-363,n)}e!==Ba&&(Ba=e,e!==n(0,0,`Ls3t`,0,811)&&e!==n(0,0,`9C6A`,0,809)||console[t(-405,0,`lGF[`)](n(0,0,`Ju8v`,0,833)+Ln[t(-514,0,`KSTG`)]()))};function Ha(e,t,n,r,i){return Pa(t-797,n)}var Ua=new Map;function Wa(e,t,n,r,i){return Pa(i-164,n)}var Ga=!1,Ka=!1,qa=new class{constructor(){function e(e,t,n,r,i){return Pa(n- -724,r)}this[e(0,0,-193,`Vcsc`)][e(0,0,-330,`t^ro`)]=null}async[za(-357,0,0,0,`25fa`)](e,t=!1){if(e=e?.[a(1012,1007,`DCg*`,958,1061)](),Ln[a(958,989,`Ls3t`,1002,1061)](e))return Ga=!0,await ra[c(646,`wYCE`,689,726,631)](e,t),Ia[s(480,484,504,466,`@MIg`)]=null,Ia[o(-564,-596,-620,-503,`Opud`)]=c(719,`1ms6`,685,780,677),Ia[a(967,985,`R33G`,960,963)]=null,Ia[r(374,347,`&Gzk`,404,344)]=null,await this[r(371,258,`&Gzk`,329,329)](!0);if(!t&&Ia[o(-467,-500,-500,-466,`[R61`)]){let e=await this[c(716,`KSTG`,641,708,698)]();if(e[o(-496,-546,-491,-458,`woF]`)]()&&!e[s(453,504,398,431,`iboC`)]())return e}let n={...Ia,setEval:Ga};function r(e,t,n,r,i){return za(r-702,0,0,0,n)}Ga=!1,Ia[a(1124,1079,`iboC`,1020,1072)]=e,Ia[a(1061,1060,`QcZ$`,1113,999)]=o(-559,-533,-517,-556,`Ju8v`),Ia[c(651,`70Uj`,593,605,678)]=null,Ia[s(441,521,444,495,`SIbO`)]=null;let i=await this[s(587,603,448,524,`w)pE`)]();if(!i[c(747,`70Uj`,714,739,765)]()){let{setEval:e,...t}=n;throw Object[c(762,`[R61`,722,725,726)](Ia,t),Ga=e,await this[c(635,`odJS`,637,648,684)](i,!0),Error(s(539,546,421,483,`ASoM`))}function a(e,t,n,r,i){return za(t-1421,0,0,0,n)}function o(e,t,n,r,i){return za(e- -119,0,0,0,i)}function s(e,t,n,r,i){return za(r-832,0,0,0,i)}function c(e,t,n,r,i){return za(e-1062,0,0,0,t)}return await ra[a(957,1017,`TsmP`,970,977)](e,t),i}async[za(-424,0,0,0,`t^ro`)](e=!1){let t=`jVEW`;if(Ia[i(171,216,`Ju8v`,216,288)]){if(!e)return Ia[i(197,194,`kldQ`,173,245)];let t=await Ia[a(-617,-583,`iboC`,-545,-542)];return!Ia[s(934,918,`ASoM`,1006,937)]&&await Fa(t)&&(Ia[a(-516,-607,`7Sth`,-577,-633)]=!0,await this[i(276,211,`Vcsc`,160,222)](t)),t}!this[c(154,198,89,`Vcsc`,80)][o(823,815,`25fa`,854,868)]&&(this[s(1033,962,`4vu!`,1020,997)][c(101,63,123,`#Vi7`,134)]=Error(`FV`));let n,r=null;function i(e,t,n,r,i){return za(t-529,0,0,0,n)}function a(e,t,n,r,i){return za(r- -127,0,0,0,n)}function o(e,t,n,r,i){return za(r-1223,0,0,0,n)}function s(e,t,n,r,i){return za(i-1362,0,0,0,n)}function c(e,t,n,r,i){return za(e-464,0,0,0,r)}return Ia[s(935,1030,`R33G`,910,952)]=new Promise(e=>{r=e}),n=Ga?await ra[i(0,109,`&Gzk`)](a(0,0,`cgmJ`,-565)):Ia[o(929,830,`[R61`,875,911)]?na(Ia[a(0,0,`9Lx4`,-505)],Ia[o(902,808,`rA4F`,885,893)],await ra[s(939,997,`cgmJ`,921,954)](),await ra[o(822,854,`reGd`,808,747)]()):await ra[s(1015,1006,`Q9k6`,892,971)](),Ia[o(0,0,t,853)]=n,Ia[a(0,0,t,-489)]=e&&await Fa(n),r(n),Ia[s(0,0,`&Gzk`,0,919)]&&await this[c(75,0,0,`KGk*`)](n),Ia[a(0,0,`odJS`,-548)]}async[za(-379,0,0,0,`!t76`)](e,t=!1,n=!1,r=!1){function i(e,t,n,r,i){return za(r-602,0,0,0,e)}function a(e,t,n,r,i){return za(e-1672,0,0,0,t)}let o=e[i(`rZHZ`,0,0,210)]();if(!t&&!Ia[i(`6s^9`,0,0,247)]&&(e[s=1151,c=`kldQ`,za(s-1474,0,0,0,c)]()||o))return Ia[i(`woF]`,0,0,168)]=!0,void await ra[a(1239,`DwPq`)](!1);var s,c,l,u,d,f;(t||!t&&(o||!await ra[d=`ErIn`,f=806,za(f-1245,0,0,0,d)]())&&!Ia[a(1350,`70Uj`)])&&(Ia[i(`wYCE`,0,0,266)]=!0,await ra[l=-150,u=`&Gzk`,za(l-170,0,0,0,u)](e,t,n,r))}async[Wa(0,0,`reGd`,0,666)](e){function t(e,t,n,r,i){return Wa(0,0,n,0,e- -788)}if(await Fa(e)){if(Ka)return t(-165,0,`9C6A`),void setTimeout(()=>{var n,r;this[n=`Vcsc`,r=465,t(r-665,0,n)](e,!1,!1)},8e3);await this[t(-85,0,`9Lx4`)](e,!1,!1)}}async[La(-47,0,`SIbO`)](e,t,n,r=!1){if(!t&&Ia[s(-268,-233,`#Vi7`,-348,-260)]&&Ia[o(749,`R33G`,807,766,812)])return;function i(e,t,n,r,i){return za(n-545,0,0,0,e)}let a=e[o(778,`9C6A`,814,770,758)]()||e[o(815,`cgmJ`,810,753,786)]();if(!t&&a&&!await ra[u(370,417,381,`ErIn`,428)]())return Ia[i(`Q9k6`,0,146)]=!0,Ia[s(-342,-350,`n20z`,-317,-277)]=!0,ra[u(241,318,286,`70Uj`,252)]();function o(e,t,n,r,i){return za(i-1212,0,0,0,t)}function s(e,t,n,r,i){return za(e-100,0,0,0,n)}var c,l;function u(e,t,n,r,i){return za(t-764,0,0,0,r)}(!Ia[i(`!t76`,0,201)]||t)&&(Ia[i(`lGF[`,0,224)]=!0,await ra[s(-341,-393,`p^sB`,-313,-390)](!1)),t||!e[c=`reGd`,l=176,za(l-508,0,0,0,c)]()||e[u(353,383,410,`DCg*`,373)]()?await this[s(-233,0,`w)pE`)](e,t,n,r):Ia[o(0,`odJS`,0,0,793)]=!0,!t&&a&&await ra[s(-351,0,`t^ro`)]()}[Na(614,0,0,`wYCE`)](){return this[e=`R33G`,t=698,Wa(0,0,e,0,t-95)]();var e,t}async[Ha(0,1280,`ErIn`)](e,t=1){let n=await this[r(868,912,`DCg*`,920,901)](!0);function r(e,t,n,r,i){return Wa(0,0,n,0,t-279)}var i,a;function o(e,t,n,r,i){return Wa(0,0,t,0,i- -252)}return await this[o(353,`@MIg`,417,294,369)](n,e===r(0,953,`KSTG`)?r(0,872,`!t76`):o(287,`9Lx4`,416,432,359)),e&&t>0&&Ua[o(440,`kldQ`,411,433,441)](e,(Ua[i=849,a=`Ju8v`,Wa(0,0,a,0,i-198)](e)??0)+t),n}async[Wa(0,0,`Opud`,0,609)](){function e(e,t,n,r,i){return Na(t- -206,0,0,r)}let t=await this[e(0,299,0,`p^sB`)](),n=await ra[e(0,401,0,`wYCE`)](t);return Va(n),n}async[Ha(0,1216,`odJS`)](){function e(e,t,n,r,i){return Na(n- -816,0,0,t)}return ra[e(0,`S[wT`,-217)](await this[e(0,`TsmP`,-263)]())}async[La(-142,0,`lGF[`)](e,t){let n=await ra[r=`Be(Y`,i=-174,Na(i- -810,0,0,r)](e);var r,i,a,o;function s(e,t,n,r,i){return Na(n-29,0,0,t)}function c(e,t,n,r,i){return Na(e- -374,0,0,t)}if(Va(n),n===s(0,`DwPq`,637)||t===s(0,`KGk*`,518)&&n===c(200,`p^sB`))throw Error(Ln[c(243,`#Vi7`)](e[a=900,o=`rA4F`,Na(a-376,0,0,o)]()))}async[Ha(0,1324,`9C6A`)](){function e(e,t,n,r,i){return Wa(0,0,t,0,r-554)}if(Ga)return null;if(Ia[r=`lGF[`,i=1286,Wa(0,0,r,0,i-688)])return Ia[t=`jVEW`,n=-160,Wa(0,0,t,0,n- -790)];var t,n,r,i;let a=await ra[e(0,`&Gzk`,0,1128)]();return a[e(0,`Ju8v`,0,1207)]===Wa(0,0,`@MIg`,0,557)?a[o=`t^ro`,s=158,Wa(0,0,o,0,s- -483)]:null;var o,s}async[Ha(0,1278,`Ls3t`)](e){function t(e,t,n,r,i){return za(e-1491,0,0,0,i)}let n=await this[t(1105,0,0,0,`lGF[`)]();return this[t(1141,0,0,0,`1ms6`)](n,!0,e)}[Na(503,0,0,`rZHZ`)](){return Ia[n=-329,r=`@MIg`,za(n-61,0,0,0,r)]||Ia[e=1137,t=`wYCE`,za(e-1473,0,0,0,t)];var e,t,n,r}[Na(480,0,0,`odJS`)](e){Ka=!0}async[Ha(0,1327,`SIbO`)](){var e,t,n,r;Ia[e=123,t=`25fa`,Ha(0,e- -1211,t)]=!0,await ra[n=-44,r=`rA4F`,Ha(0,n- -1337,r)](!0)}async[Ha(0,1241,`odJS`)](e,t){let n=await this[r(`7Sth`,950,968,894,919)]();function r(e,t,n,r,i){return La(i-929,0,e)}return await this[r(`50ti`,845,964,975,895)](n,!0,e,t),n}async[Wa(0,0,`KSTG`,0,602)](){let e=await ra[t=255,n=`e9k3`,Wa(0,0,n,0,t- -433)]();var t,n,r,i,a,o;return e[a=`jVEW`,o=-186,Wa(0,0,a,0,o- -742)]?.[r=-487,i=`50ti`,Wa(0,0,i,0,r- -1087)]??``}},Ja=null,Ya=()=>Ja||=Intl.DateTimeFormat().resolvedOptions().locale??`en-US`,Xa=null,Za=()=>{let e=j.getActive();if(!e)return null;let t=Xa;if(t!==null&&t.active===e)return t.locale;let n;try{let t=new Intl.Locale(e).maximize();n=t.region?`${t.language}-${t.region}`:t.baseName}catch{n=null}return Xa={active:e,locale:n},n},Qa=class{constructor(e=`SheetXL Runtime`,t,n){this._description=e,this._options={isDate1904:()=>!1,...t},this._license=n}getDescription(){return this._description}getLocale(){return this._options.getLocale?.()??Ya()}getNow(){return this._options.getNow?.()??Date.now()}getRandom(){return this._options.getRandom?.()??Math.random()}getLocaleProfile(){return ht(this.getLocale(),this._options.getLocaleOverrides?.())}isDate1904(){return this._options.isDate1904()??!1}isR1C1(){return this._options.isR1C1?.()??!1}getLocation(){return globalThis.window?.location?.href??`/`}getVersion(){try{let e=`0.8.0-beta.23`;if(e.indexOf(`.env.`)===-1)return`${e}`}catch{return`local`}return`local`}getOS(){return i.getPlatform()}getUser(){return this._license?.getLicensee?.()??null}};function $a(e,t){if(t===null)return null;let n=i.isObject(t);return e!=null&&n?i.mergeContentful(e,t):n?i.cloneObject(t):t}function eo(e,t,n){return e==null||typeof e==`object`&&Object.keys(e).length===0}function to(e,t,n,r){if(e===t)return e??null}function no(e){return e==null}function ro(e,t,n=1,r){if(n===0)return{preceding:e?[...e]:[],modified:[],trailing:[]};let a=function(e,t,n=1){let r=i.findEqualOrGreater(e,t,e=>e.max),a=e.slice(0,r),o=[],s=[];if(!e[r])return{preceding:a,modified:o,trailing:s};for(let i=r;i<e.length;i++)t+n<e[i].min?s.push({...e[i],min:e[i].min-n,max:e[i].max-n}):t>=e[i].min?Math.max(t,e[i].max+1-n)>e[i].min&&o.push({...e[i],max:Math.max(t-1,e[i].max-n)}):t<e[i].min&&t+n<=e[i].max&&o.push({...e[i],min:Math.max(t,e[i].min-n),max:e[i].max-n});return{preceding:a,modified:o,trailing:s}}(e,t,n),o=a.preceding,s=a.trailing,c=[];return o.length>0&&c.push(o.pop()),c=c.concat(a.modified),s.length>0&&c.push(s.shift()),{preceding:o,modified:oo(c,{onMerge:r?.onMerge??to}).modified,trailing:s}}function io(e,t,n){if(!e)throw Error(`runs can not be null`);if(!t)return{preceding:[],modified:e?[...e]:[],trailing:[]};let r=function(e,t,n,r,a=!1){if(!t)return{preceding:[],modified:e?[...e]:[],trailing:[]};let o,s=i.findEqualOrGreater(e,t.min,e=>e.max),c=e.slice(0,s),l=e.slice(s),u=[],d={...t},f=l[0]||{min:t.min,max:t.max,value:void 0};for(o=a?(e,t,n)=>{let i=(r||$a)(t,n,e);i===void 0?delete e.value:e.value=i,u.push(e)}:(e,t,n)=>{let i=(r||$a)(t??null,n,e);i===void 0?delete e.value:e.value=i,u.push(e)};l.length>=0&&d.max-d.min>=0;){if(d.min<f.min)o({min:d.min,max:Math.min(d.max,f.min-1)},void 0,d.value),d={min:f.min,max:d.max,value:d.value},f={min:d.min,max:f.max,value:f.value};else if(d.min>f.min){let e=f.value!==void 0&&n?n(f,d.min):[f.value,f.value];u.push({min:f.min,max:Math.min(d.min,f.max)-1,value:e[0]}),d={min:Math.min(d.min,f.max),max:d.max,value:d.value},f={min:d.min,max:f.max,value:e[1]}}else{let e=f.value!==void 0&&n?n(f,d.min):[f.value,f.value];o({min:f.min,max:Math.min(d.max,f.max)},e[0],d.value),d={min:Math.min(d.max,f.max)+1,max:d.max,value:d.value},f={min:Math.min(d.max,f.max)+1,max:f.max,value:e[1]}}f.min<=f.max?l[0]=f:(l=l.slice(1),f=l[0]||{min:f.min,max:d.max})}return{preceding:c,modified:u,trailing:l}}(e,t,n?.onSplit,n?.onUpdate,n?.inPlace),a=[];r.preceding.length>0&&a.push(r.preceding.pop()),a=a.concat(r.modified),r.trailing.length>0&&a.push(r.trailing.shift());let o=function(e,t){if(!e||e.length===0)return{preceding:[],modified:e?[...e]:[],trailing:[]};let n=Math.min(e.length-1,t?.startOffset??0),r=Math.min(e.length,t?.endOffset??e.length),i=t?.cull??no,a=e.slice(0,n),o=e.slice(r),s=[];for(let t=n;t<r;t++)!0!==i(e[t].value,e[t].min,e[t].max)&&s.push(e[t]);return{preceding:a,modified:s,trailing:o}}(oo(a,{onMerge:n?.onMerge??to}).modified,{cull:n?.isCull||eo});return{preceding:r.preceding,modified:o.modified,trailing:r.trailing}}function ao(e){return[...e.preceding,...e.modified,...e.trailing]}function oo(e,t){if(!e||e.length===0)return{preceding:[],modified:e?[...e]:[],trailing:[]};let n=Math.min(e.length-1,t?.startOffset??0),r=Math.min(e.length,t?.endOffset??e.length),i=t?.onMerge??to,a=e.slice(0,n),o=e.slice(r),s=[],c={...e[n]},l=e[n]?.max||0;for(let t=n+1;t<=r;t++){let n=e[t],r=!1;if(n&&n.min<=e[t-1].max+1){if(c.value===void 0&&n.value===void 0)r=!0;else{let e=i(c.value,n.value,c.max-c.min+1,n.max-n.min+1);e!==void 0&&(r=!0,c.value=e)}}r?c.max=Math.max(l,n.max):(s.push(c),c={...e[t]},n&&(c.max=Math.max(l,n.max))),c&&(l=c.max)}return{preceding:a,modified:s,trailing:o}}function so(e){return e&&e.sort((e,t)=>{let n=e.min-t.min;return n===0&&(n=e.max-t.max),n})}function co(e,t=!1){if(!e||e.length===0)return i.EmptyArray;let n=t?e:e.sort(),r=[],a=null;for(let e=0;e<n.length;e++){let t=n[e];a?a.max===t-1?a.max=t:(r.push(a),a={min:t,max:t}):a={min:t,max:t}}return a&&r.push(a),r}function lo(e,t){return e?t?e||t?e.min>t.max||e.max<t.min?null:{min:Math.max(e.min,t.min),max:Math.min(e.max,t.max)}:null:{...e}:{...t}}function uo(e){let t=e.length===0;return{runs:e,run:{min:t?-(2**53-1):2**53-1,max:t?2**53-1:-(2**53-1),value:null},index:2**53-1}}function fo(e,t){let n=t.run,r=n.min,a=n.max;if(e>=r&&e<=a)return n.value;let o=t.index,s=t.runs;if(o<s.length-1&&e>a){o++;let r=s[o],i=r.min,a=r.max;if(e>=i&&e<=a)return t.index=o,n.min=i,n.max=a,n.value=r.value,n.value}if(o!==2**53-1&&o>0&&e<r){o--;let r=s[o],i=r.min,a=r.max;if(e>=i&&e<=a)return t.index=o,n.min=i,n.max=a,n.value=r.value,n.value}if(o=i.findEqualOrGreater(s,e,e=>e.max),o===s.length)return o=s.length,t.index=o,n.min=s[o-1].max+1,n.max=2**53-1,n.value=null,null;let c=s[o],l=c.min,u=c.max;if(e>=l&&e<=u){t.index=o,n.min=l,n.max=u;let e=c.value;return n.value=e,e}return o--,t.index=o,n.min=o>=0?s[o].max+1:-(2**53-1),n.max=l-1,n.value=null,null}function po(e,t,n,r){if(e.length===0){if(n!=null||r!=null){let e=t({min:n??r,max:r??n});if(e&&e.break)return e}return}let a=n??e[0].min,o=r??e[e.length-1].max,s=a-1,c=i.findEqualOrGreater(e,a,e=>e.max),l=e[c];for(;l&&l.min<=o;){if(s<l.min-1){let e=t({min:Math.max(s+1,a),max:Math.min(l.min-1,o)});if(e&&e.break)return e}let n=t({...l,min:Math.max(l.min,a),max:Math.min(l.max,o)});if(n&&n.break)return n;s=l.max,l=e[++c]}if(s<o){let e=t({min:Math.min(s+1,o),max:o});if(e&&e.break)return e}}function mo(e,t=!1){if(!e||e.length===0)return i.EmptyArray;let n=[],r=null,a=e.slice().sort((e,t)=>e.min-t.min),o=a.length;for(let e=0;e<o;e++){let i=a[e];r&&i.min<=r.max+1?t?r.max=Math.max(r.max,i.max):(r={min:r.max+1,max:i.max},n.push(r)):(r={min:i.min,max:i.max},n.push(r))}return n}function ho(e,t,n,r){let i;for(r&&(t=t.bind(r));!(i=e.next()).done;)try{t(i.value[1],i.value[0],n)}catch(t){if(typeof e.throw!=`function`)throw t;e.throw(t)}typeof e.return==`function`&&e.return()}function go(e){let t=e.next.bind(e),n={next:e=>{let n=t(e);return n.done?yo:{done:n.done,value:n.value[1]}},[Symbol.iterator]:()=>n,...e.return&&{return:e.return.bind(e)},...e.throw&&{throw:e.throw.bind(e)}};return n}function _o(e){if(!e||e.length===0)return null;let t=!1,n=2**53-1,r=-1,a=null;return(o,s=!1)=>{if(s!==t&&(t=s,n=2**53-1),o===n)return o;o!==n+(s?-1:1)&&(r=function(e,t,n=!0){if(!e||e.length===0)return null;let r,a=-1;return n?(a=i.findEqualOrGreater(e,t,e=>e.max),r=e[a]):(a=i.findEqualOrLesser(e,t,e=>e.min),r=e[a]),r?(n?t>r.max&&(a+=1,r=e[a]):t<r.min&&(--a,r=e[a]),r?a:-1):-1}(e,o,!s),a=e[r]);let c=o;if(s)for(;a&&c<=a.max;)c=a.min-1,a=e[--r];else for(;a&&c>=a.min;)c=a.max+1,a=e[++r];return n=c,c}}var vo,yo=Object.freeze({done:!0,value:void 0}),bo=Object.freeze({next:()=>yo,[Symbol.iterator]:()=>bo});Object.seal({done:!1,value:void 0}),function(e){e.isList=function(e){return!!e&&!!e.isIList},e.isListLike=function(e){return!!e&&typeof e.length==`number`&&typeof e.at==`function`},e.fromArray=function(e,n,r,i){return new t(e,n,r,i)};class t{constructor(e,t,n,r){this.g=t,this.s=n;let a=e??r;if(n&&e&&!r){r=Array(e.length);for(let t=0;t<e.length;t++){let i=e[t];r[t]=n(i,t)}a=r}this.a=a??i.EmptyArray,t&&(this.at=e=>{e<0&&(e=a.length+e);let n=a[e];if(n!==void 0)return t(n,e)})}at(e){let t=this.a;return e<0&&(e=t.length+e),t[e]}fromArray(e){return new t(e,this.g,this.s)}get length(){return this.a.length}get isIList(){return!0}}e.ArrayList=t}(vo||={});var xo=class e{constructor(t){if(this._single=null,this._runs=null,this._length=0,this._runCache=null,this._uniform=void 0,t instanceof e)return this._single=t._single,this._runs=t._runs,this._length=t._length,void(this._uniform=t._uniform);if(t&&t.length>0){let e=Array.isArray(t)?new vo.ArrayList(t):t;this._single=e,this._length=t.length}}at(e){let t=this._single;if(t)return t.at(e);let n=this._runCache;if(n&&n.min<=e&&n.max>=e){let t=n.value;return t.list.at(e-n.min+t.start)}let r=this._runs,a=r[i.findEqualOrGreater(r,e,e=>e.max)];if(!a)return;let o=a.value;return this._runCache=a,o.list.at(e-a.min+o.start)}toArray(e=2**53-1){let t=[],n=this.entries(Eo),r=n.next();for(;!r.done&&t.length<e;)t.push(r.value[1]),r=n.next();return t}entries(e){let t=this.length;if(t===0)return bo;let n,r,a,o=!0,s=0,c=t-1;if(e){o=!e.reverse;let t=e.bounds;t&&(s=Math.max(t.min??s,s),c=Math.min(t.max??c,c)),n=e.reuseResult??null,r=e.processSkip}let l=o?1:-1,u=(o?s:c)-l,d=this._single;if(d)a=e=>{if(!(e<s||e>c))return d.at(e)};else{let e=this._runs,t=o?0:e.length-1,n=e[t],r=(r,i)=>{let a=r===t?n:e[r];if(a&&i>=a.min&&i<=a.max)return t=r,n=a,a};a=n=>{if(n<s||n>c)return;let a=r(t,n);if(a||=r(t+l,n),!a){let t=i.findEqualOrGreater(e,n,e=>e.max);a=r(t,n)}if(!a)return;let o=a.value;return o.list.at(n-a.min+o.start)}}let f={next:e=>{let i,d=u+l;return e!==void 0&&(e<0&&(e=t+e),d=e),d<s||d>c||r&&(d=r(d,!o),d<s||d>c)?yo:(i=a(d),u=d,n?(n.done=!1,n.value[0]=d,n.value[1]=i,n):{done:!1,value:[u,i]})},[Symbol.iterator]:()=>f};return f}slice(t,n){let r=this._runs??Co(this._single);if(!r)return wo;let i=this.length;if(t=Math.min(Math.max(0,t),i),(n=Math.min(Math.max(0,n??i),i))-t<=0)return wo;if(t<=0&&n>=i)return this;let a=t,o=n-1,s=[],c=0;for(let e=0;e<r.length;e++){let t=r[e],n=t.max;if(a===0&&n<=o){s.push(t);continue}let i=t.min;if(i>o){e=r.length;continue}if(n<a){c=n+1;continue}let l=Math.max(0,a-i),u=Math.max(0,n-o),d=u+l,f=t.value;s.push({min:i-c,max:n-d-c,value:{start:f.start+l,end:f.end-u,list:f.list}}),c+=d}let l=new e;return l._runs=s,l._length=o-a+1,l}concat(t){if(!t)return this;if(!vo.isListLike(t))throw Error(`Value must be IListLike`);let n=this._length;if(n===0)return t.isIReadableList?t:t.length===0?wo:new e(t);let r=t,i=t.length;if(i===0)return this;let a=this._runs??Co(this._single),o=a.slice(0,a.length-1),s=a[a.length-1],c=s?s.min:0,l=s?s.max:0,u=s?s.value:null,d=u?u.list:null,f=u?u.end-u.start:0,p=e=>{let t=e.start,n=e.end,r=n-t;if(r+f<Do&&d&&d.fromArray){let r=e.list,i=[],a=u.start,o=u.end;for(let e=a;e<=o;e++)i.push(d.at(e));for(let e=t;e<=n;e++)i.push(r.at(e));let p=d.fromArray(i);if(p)return r=p,f=r.length-1,u={start:0,end:f,list:r},s={min:c,max:c+f,value:u},l=c+f,void(d=r)}o.push(s);let i=l+1,a=i+r;s={min:i,max:a,value:e},c=i,l=a,u=s?s.value:null,d=u?u.list:null,f=u?u.end-u.start:0};if(t instanceof e){let e=t._single;if(e)p({start:0,end:e.length-1,list:e});else{let e=t._runs;for(let t=0;t<e.length;t++)p(e[t].value)}}else p({start:0,end:i-1,list:r});o.push(s);let m=new e,h=n+i;return o.length===1&&o[0].min===0&&o[0].max===h-1?m._single=o[0].value.list:m._runs=o,m._length=h,m}get length(){return this._length}[Symbol.iterator](){return go(this.entries())}getUniformRuns(){let e=this._uniform;if(e===void 0){let t=null,n=this._single;if(n)So(n)&&(t=[[0,this._length-1,n.at(0)]]);else{let e=this._runs;if(e)for(let n=0;n<e.length;n++){let r=e[n],i=r.value;So(i.list)&&(t??=[]).push([r.min,r.max,i.list.at(i.start)])}}e=t,this._uniform=e}return e}static forEachLeaf(t,n,r=0,i=t.length-1){e._forEachLeaf(t,Math.max(0,r),Math.min(i,t.length-1),0,n)}static _forEachLeaf(t,n,r,a,o){if(n>r)return;if(!(t instanceof e))return void o(t,n,n+a,r+a);let s=t._single;if(s)return void e._forEachLeaf(s,n,r,a,o);let c=t._runs,l=c.length;for(let t=i.findEqualOrGreater(c,n,e=>e.max);t<l;t++){let i=c[t];if(i.min>r)break;let s=i.value,l=Math.max(n,i.min),u=Math.min(r,i.max),d=s.start+l-i.min;e._forEachLeaf(s.list,d,d+u-l,a+l-d,o)}}get isIReadableList(){return!0}get isIList(){return!0}get[Symbol.toStringTag](){return`[ImmutableList]`}toString(){let e=this.length;if(e===0)return``;let t=``;for(let n=0;n<e;n++){n>0&&(t+=`,`);let e=this.at(n);t+=e==null?``:String(e)}return t}},So=e=>!0===e.isIRepeatingList&&e.getPeriod()===1,Co=e=>[{min:0,max:e.length-1,value:{start:0,end:e.length-1,list:e}}],wo=new xo,To=Object.seal({done:!1,value:[-1,null]}),Eo=Object.freeze({reverse:!1,bounds:{min:0,max:2**53-1},skipRuns:null,reuseResult:To}),Do=64,Oo=class e{constructor(t,n,r){this._root=Po,this._size=0,this._maxNodeSize=r>=4?Math.min(r,256):32,this._compare=n||e.defaultComparator,t&&this.setPairs(t)}get size(){return this._size}get length(){return this._size}isEmpty(){return this._size===0}clear(){this._root=Po,this._size=0}forEach(e,t){return t!==void 0&&(e=e.bind(t)),this.forEachPair((t,n)=>e(n,t,this))}forEachPair(e,t){let 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());let r=this._root.set(e,t,n,this);return!0===r||!1===r?r:(this._root=new jo([this._root,r]),!0)}has(e){return this.forRange(e,e,!0,void 0)!==0}delete(t){return this.editRange(t,t,!0,e.DeleteRange)!==0}filter(t,n){let r=this.greedyClone(),i;return r.editAll((n,r,a)=>{if(!t(n,r,a))return i=e.DeleteValue}),!i&&n?this:r}mapValues(e){let t={},n=this.greedyClone();return n.editAll((n,r,i)=>(t.value=e(r,n,i),t)),n}reduce(e,t){let n,r=0,i=t,a=this.entries(this.minKey());for(;!(n=a.next()).done;)i=e(i,n.value,r++);return i}entries(e,t){let n=this.findPath(e);if(n===void 0)return ko();let{nodeQueue:r,nodeIndex:i,leaf:a}=n,o=t===void 0?0:1,s=e===void 0?-1:a.indexOf(e,0,this._compare)-1;return ko(()=>{t:for(;;)switch(o){case 0:if(++s<a.keys.length)return{done:!1,value:[a.keys[s],a.values[s]]};o=2;continue;case 1:if(++s<a.keys.length){let e=a.keys[s],n=a.values[s];return t?(t.done=!1,t.value[0]=e,t.value[1]=n,t):{done:!1,value:[e,n]}}o=2;case 2:for(var e=-1;;){if(++e>=r.length){o=3;continue t}if(++i[e]<r[e].length)break}for(;e>0;e--)r[e-1]=r[e][i[e]].children,i[e-1]=0;a=r[0][i[0]],s=-1,o=t===void 0?0:1;continue;case 3:return No}})}entriesReversed(e,t,n){if(e===void 0&&(n=void 0,(e=this.maxKey())===void 0))return ko();let{nodeQueue:r,nodeIndex:i,leaf:a}=this.findPath(e)||this.findPath(this.maxKey());Io(!r[0]||a===r[0][i[0]],`wat!`);let o=a.indexOf(e,0,this._compare);!n&&o<a.keys.length&&this._compare(a.keys[o],e)<=0&&o++;let s=t===void 0?0:1;return ko(()=>{t:for(;;)switch(s){case 0:if(--o>=0)return{done:!1,value:[a.keys[o],a.values[o]]};s=2;continue;case 1:if(--o>=0){let e=a.keys[o],n=a.values[o];return t?(t.done=!1,t.value[0]=e,t.value[1]=n,t):{done:!1,value:[e,n]}}s=2;case 2:for(var e=-1;;){if(++e>=r.length){s=3;continue t}if(--i[e]>=0)break}for(;e>0;e--)r[e-1]=r[e][i[e]].children,i[e-1]=r[e-1].length-1;a=r[0][i[0]],o=a.keys.length,s=t===void 0?0:1;continue;case 3:return No}})}findPath(e){let t,n,r=this._root;if(r.isLeaf)t=Fo,n=Fo;else{t=[],n=[];for(let i=0;!r.isLeaf;i++){if(t[i]=r.children,n[i]=e===void 0?0:r.indexOf(e,0,this._compare),n[i]>=t[i].length)return;r=t[i][n[i]]}t.reverse(),n.reverse()}return{nodeQueue:t,nodeIndex:n,leaf:r}}diffAgainst(t,n,r,i){if(t._compare!==this._compare)throw Error(`SortedMap: Comparators are not the same.`);if(this.isEmpty()||t.isEmpty())return this.isEmpty()&&t.isEmpty()?void 0:this.isEmpty()?r===void 0?void 0:e.stepToEnd(e.makeDiffCursor(t),r):n===void 0?void 0:e.stepToEnd(e.makeDiffCursor(this),n);let{_compare:a}=this,o=e.makeDiffCursor(this),s=e.makeDiffCursor(t),c=!0,l=!0,u=e.compare(o,s,a);for(;c&&l;){let t=e.compare(o,s,a),{leaf:d,internalSpine:f,levelIndices:p}=o,{leaf:m,internalSpine:h,levelIndices:g}=s;if(d||m){if(u!==0){if(t===0){if(d&&m&&i){let e=d.values[p[p.length-1]],t=m.values[g[g.length-1]];if(!Object.is(e,t)){let n=i(o.currentKey,e,t);if(n&&n.break)return n.break}}}else if(t>0){if(m&&r){let e=m.values[g[g.length-1]],t=r(s.currentKey,e);if(t&&t.break)return t.break}}else if(n&&d&&u!==0){let e=d.values[p[p.length-1]],t=n(o.currentKey,e);if(t&&t.break)return t.break}}}else if(!d&&!m&&t===0){let t=f.length-1,n=h.length-1,r=f[t][p[t]];if(h[n][g[n]]===r){u=0,c=e.step(o,!0),l=e.step(s,!0);continue}}u=t,t<0?c=e.step(o):l=e.step(s)}return c&&n?e.finishCursorWalk(o,s,a,n):l&&r?e.finishCursorWalk(s,o,a,r):void 0}static finishCursorWalk(t,n,r,i){let a=e.compare(t,n,r);if(a===0){if(!e.step(t))return}else a<0&&Io(!1,`cursor walk terminated early`);return e.stepToEnd(t,i)}static stepToEnd(t,n){let r=!0;for(;r;){let{leaf:i,levelIndices:a,currentKey:o}=t;if(i){let e=n(o,i.values[a[a.length-1]]);if(e&&e.break)return e.break}r=e.step(t)}}static makeDiffCursor(e){let t=e._root;return{height:e.getHeight(),internalSpine:[[t]],levelIndices:[0],leaf:void 0,currentKey:t.maxKey()}}static step(e,t){let{internalSpine:n,levelIndices:r,leaf:i}=e;if(!0===t||i){let a=r.length;if(!0===t||r[a-1]===0){let t=n.length;if(t===0)return!1;let i=t-1,o=i;for(;o>=0;){if(r[o]>0)return o<a-1&&(e.leaf=void 0,r.pop()),o<i&&(e.internalSpine=n.slice(0,o+1)),e.currentKey=n[o][--r[o]].maxKey(),!0;o--}return!1}{let t=--r[a-1];return e.currentKey=i.keys[t],!0}}{let t=n.length,i=t-1,a=n[i][r[i]];if(a.isLeaf){e.leaf=a;let n=r[t]=a.values.length-1;e.currentKey=a.keys[n]}else{let i=a.children;n[t]=i;let o=i.length-1;r[t]=o,e.currentKey=i[o].maxKey()}return!0}}static compare(e,t,n){let{height:r,currentKey:i,levelIndices:a}=e,{height:o,currentKey:s,levelIndices:c}=t,l=n(s,i);if(l!==0)return l;let u=r<o?r:o;return a.length-(r-u)-(c.length-(o-u))}keys(e,t){let n=this.entries(e,t);return ko(()=>{let e=n.next();return e.value&&=e.value[0],e})}values(e,t){let n=this.entries(e,t);return ko(()=>{let e=n.next();return e.value&&=e.value[1],e})}getMaxNodeSize(){return this._maxNodeSize}minKey(){return this._root.minKey()}maxKey(){return this._root.maxKey()}clone(){this._root.isShared=!0;let t=new e(void 0,this._compare,this._maxNodeSize);return t._root=this._root,t._size=this._size,t}greedyClone(t){let n=new e(void 0,this._compare,this._maxNodeSize);return n._root=this._root.greedyClone(t),n._size=this._size,n}toArray(e=2147483647){let t=this.minKey(),n=this.maxKey();return t===void 0?[]:this.getRange(t,n,!0,e)}keysArray(){let e=[];return this._root.forRange(this.minKey(),this.maxKey(),!0,!1,this,0,(t,n)=>{e.push(t)}),e}valuesArray(){let 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){let 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){let 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,(e,n)=>({value:t}))!==0}getRange(t,n,r,i=67108863){let a=[];return this._root.forRange(t,n,r,!1,this,0,(t,n)=>(a.push([t,n]),a.length>i?e.Break:void 0)),a}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,i){let a=this._root.forRange(e,t,n,!1,this,i||0,r);return typeof a==`number`?a:a.break}editRange(e,t,n,r,i){let a=this._root;a.isShared&&(this._root=a=a.clone());try{let o=a.forRange(e,t,n,!0,this,i||0,r);return typeof o==`number`?o:o.break}finally{let e;for(;a.keys.length<=1&&!a.isLeaf;)e||=a.isShared,this._root=a=a.keys.length===0?Po:a.children[0];e&&(a.isShared=!0)}}editAll(e,t){return this.editRange(this.minKey(),this.maxKey(),!0,e,t)}deleteRange(t,n,r){return this.editRange(t,n,r,e.DeleteRange)}deleteKeys(e){let t=0;for(let n=0;n<e.length;n++)this.delete(e[n])&&t++;return t}getHeight(){let e=this._root,t=-1;for(;e;)t++,e=e.isLeaf?void 0:e.children[0];return t}freeze(){let e=this;e.clear=e.set=e.editRange=function(){throw Error(`SortedMap: Attempted to modify when frozen.`)}}unfreeze(){delete this.clear,delete this.set,delete this.editRange}isFrozen(){return this.hasOwnProperty(`editRange`)}checkValid(){let e=this._root.checkValid(0,this,0);Io(e===this.size,`size mismatch: counted `,e,`but stored`,this.size)}};function ko(e=()=>No){let t={next:e};return Symbol&&Symbol.iterator&&(t[Symbol.iterator]=function(){return this}),t}Symbol&&Symbol.iterator&&(Oo.prototype[Symbol.iterator]=Oo.prototype.entries),Oo.prototype.where=Oo.prototype.filter,Oo.prototype.setRange=Oo.prototype.setPairs,Oo.prototype.add=Oo.prototype.set;var Ao=class e{constructor(e,t=[],n){this.keys=t,this.values=n||Mo,this.isShared=void 0,this.isLeaf=e}maxKey(){return this.keys[this.keys.length-1]}indexOf(e,t,n){let r=this.keys,i=0,a=r.length,o=a>>1;for(;i<a;){let t=n(r[o],e);if(t<0)i=o+1;else{if(!(t>0)){if(t===0)return o;if(e==e)return r.length;throw Error(`SortedMap: NaN was used as a key.`)}a=o}o=i+a>>1}return o^t}minKey(){return this.keys[0]}minPair(e){if(this.keys.length!==0)return(e??=[null,null])[0]=this.keys[0],e[1]=this.values[0],e}maxPair(e){if(this.keys.length===0)return;let t=this.keys.length-1;return(e??=[null,null])[0]=this.keys[t],e[1]=this.values[t],e}clone(){let t=this.values,n=t===Mo?t:t.slice(0),r=this.keys.slice(0);return new e(!0,r,n)}greedyClone(e){return this.isShared&&!e?this:this.clone()}get(e,t,n){let r=this.indexOf(e,-1,n._compare);return r<0?t:this.values[r]}getPairOrNextLower(e,t,n,r){let i=this.indexOf(e,-1,t),a=i<0?~i-1:n?i:i-1;if(a>=0){let e=this.keys[a],t=this.values[a];return r?(r[0]=e,r[1]=t,r):[e,t]}}getPairOrNextHigher(e,t,n,r){let i=this.indexOf(e,-1,t),a=i<0?~i:n?i:i+1,o=this.keys;if(a<o.length){let e=o[a],t=this.values[a];return r?(r[0]=e,r[1]=t,r):[e,t]}}checkValid(e,t,n){let r=this.keys.length,i=this.values.length;return Io(this.values===Mo?r<=i:r===i,`keys/values length mismatch: depth`,e,`with lengths`,r,i,`and baseIndex`,n),Io(e===0||r>0,`empty leaf at depth`,e,`and baseIndex`,n),r}set(e,t,n,r){let i=this.indexOf(e,-1,r._compare);if(i<0){if(i=~i,r._size++,this.keys.length<r._maxNodeSize)return this.insertInLeaf(i,e,t,n,r);{let a=this.splitOffRightSide(),o=this;return i>this.keys.length&&(i-=this.keys.length,o=a),o.insertInLeaf(i,e,t,n,r),a}}if(!1!==n){t!==void 0&&this.reifyValues(),this.keys[i]=e;let r=t;if(typeof n==`function`){let a=n(this.values[i],e,t);a!==void 0&&(r=a)}this.values[i]=r}return!1}reifyValues(){return this.values===Mo?this.values=this.values.slice(0,this.keys.length):this.values}insertInLeaf(e,t,n,r,i){if(this.keys.splice(e,0,t),this.values===Mo){for(;Mo.length<i._maxNodeSize;)Mo.push(void 0);if(n===void 0)return!0;this.values=Mo.slice(0,this.keys.length-1)}let a=n;if(typeof r==`function`){let e=r(void 0,t,n);e!==void 0&&(a=e)}return this.values.splice(e,0,a),!0}takeFromRight(e){let t=this.values;e.values===Mo?t!==Mo&&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===Mo?t!==Mo&&t.unshift(void 0):(t=this.reifyValues(),t.unshift(e.values.pop())),this.keys.unshift(e.keys.pop())}splitOffRightSide(){let t=this.keys.length>>1,n=this.keys.splice(t),r=this.values===Mo?Mo:this.values.splice(t);return new e(!0,n,r)}forRange(e,t,n,r,i,a,o){let s=i._compare,c,l;if(t===e){if(!n||(l=(c=this.indexOf(e,-1,s))+1,c<0))return a}else c=this.indexOf(e,0,s),l=this.indexOf(t,-1,s),l<0?l=~l:!0===n&&l++;let u=this.keys,d=this.values;if(o!==void 0)for(let e=c;e<l;e++){let t=u[e],n=o(t,d[e],a++);if(n!==void 0){if(n.break!==void 0)return n;if(!0===r){if(t!==u[e]&&i._compare(t,u[e])!==0||!0===this.isShared)throw Error(`SortedMap: illegally changed or cloned in editRange.`);n.delete?(this.keys.splice(e,1),this.values!==Mo&&this.values.splice(e,1),i._size--,e--,l--):n.hasOwnProperty(`value`)&&(d[e]=n.value)}}}else a+=l-c;return a}mergeSibling(e,t){if(this.keys.push.apply(this.keys,e.keys),this.values===Mo){if(e.values===Mo)return;this.values=this.values.slice(0,this.keys.length)}this.values.push.apply(this.values,e.reifyValues())}},jo=class e extends Ao{constructor(e,t){if(!t){t=[];let n=e.length;for(let r=0;r<n;r++)t[r]=e[r].maxKey()}super(!1,t),this.children=e}clone(){let t=this.children.slice(0),n=t.length;for(let e=0;e<n;e++)t[e].isShared=!0;return new e(t,this.keys.slice(0))}greedyClone(t){if(this.isShared&&!t)return this;let n=new e(this.children.slice(0),this.keys.slice(0)),r=n.children,i=r.length;for(let e=0;e<i;e++)r[e]=r[e].greedyClone(t);return n}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){let r=this.indexOf(e,0,n._compare),i=this.children;return r<i.length?i[r].get(e,t,n):void 0}getPairOrNextLower(e,t,n,r){let i=this.indexOf(e,0,t),a=this.children;if(i>=a.length)return this.maxPair(r);let o=a[i].getPairOrNextLower(e,t,n,r);return o===void 0&&i>0?a[i-1].maxPair(r):o}getPairOrNextHigher(e,t,n,r){let i=this.indexOf(e,0,t),a=this.children,o=a.length;if(i>=o)return;let s=a[i].getPairOrNextHigher(e,t,n,r);return s===void 0&&i<o-1?a[i+1].minPair(r):s}checkValid(e,t,n){let r=this.keys.length,i=this.children.length;Io(r===i,`keys/children length mismatch: depth`,e,`lengths`,r,i,`baseIndex`,n),Io(r>1||e>0,`internal node has length`,r,`at depth`,e,`baseIndex`,n);let a=0,o=this.children,s=this.keys,c=0;for(let r=0;r<i;r++)a+=o[r].checkValid(e+1,t,n+a),c+=o[r].keys.length,Io(a>=c,`wtf`,n),Io(r===0||o[r-1].constructor===o[r].constructor,`type mismatch, baseIndex:`,n),o[r].maxKey()!==s[r]&&Io(!1,`keys[`,r,`] =`,s[r],`is wrong, should be `,o[r].maxKey(),`at depth`,e,`baseIndex`,n),r===0||t._compare(s[r-1],s[r])<0||Io(!1,`sort violation at depth`,e,`index`,r,`keys`,s[r-1],s[r]);let l=c===0;return(l||c>t.getMaxNodeSize()*i)&&Io(!1,l?`too few`:`too many`,`children (`,c,a,`) at depth`,e,`maxNodeSize:`,t.getMaxNodeSize(),`children.length:`,i,`baseIndex:`,n),a}set(e,t,n,r){let i=this.children,a=r._maxNodeSize,o=r._compare,s=Math.min(this.indexOf(e,0,o),i.length-1),c=i[s];if(c.isShared&&(i[s]=c=c.clone()),c.keys.length>=a){let t;s>0&&(t=i[s-1]).keys.length<a&&o(c.keys[0],e)<0?(t.isShared&&(i[s-1]=t=t.clone()),t.takeFromRight(c),this.keys[s-1]=t.maxKey()):(t=i[s+1])!==void 0&&t.keys.length<a&&o(c.maxKey(),e)<0&&(t.isShared&&(i[s+1]=t=t.clone()),t.takeFromLeft(c),this.keys[s]=i[s].maxKey())}let l=c.set(e,t,n,r);if(!1===l)return!1;if(this.keys[s]=c.maxKey(),!0===l)return!0;if(this.keys.length<a)return this.insert(s+1,l),!0;{let e=this.splitOffRightSide(),t=this;return o(l.maxKey(),this.maxKey())>0&&(t=e,s-=this.keys.length),t.insert(s+1,l),e}}insert(e,t){this.children.splice(e,0,t),this.keys.splice(e,0,t.maxKey())}splitOffRightSide(){let t=this.children.length>>1;return new e(this.children.splice(t),this.keys.splice(t))}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,i,a,o){let s=i._compare,c=this.keys,l=this.children,u=this.indexOf(e,0,s),d=u,f=Math.min(t===e?u:this.indexOf(t,0,s),c.length-1);if(r){if(d<=f)try{for(;d<=f;d++){l[d].isShared&&(l[d]=l[d].clone());let s=l[d].forRange(e,t,n,r,i,a,o);if(c[d]=l[d].maxKey(),typeof s!=`number`)return s;a=s}}finally{let e=i._maxNodeSize>>1;for(u>0&&u--,d=f;d>=u;d--)l[d].keys.length<=e&&(l[d].keys.length===0?(c.splice(d,1),l.splice(d,1)):this.tryMerge(d,i._maxNodeSize));l.length!==0&&l[0].keys.length===0&&Io(!1,`emptiness bug`)}}else for(;d<=f;d++){let s=l[d].forRange(e,t,n,r,i,a,o);if(typeof s!=`number`)return s;a=s}return a}tryMerge(e,t){let n=this.children,r=n.length;return e>=0&&e+1<r&&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){let n=this.keys.length;this.keys.push.apply(this.keys,e.keys);let r=e.children;if(this.children.push.apply(this.children,r),e.isShared&&!this.isShared)for(let e=0;e<r.length;e++)r[e].isShared=!0;this.tryMerge(n-1,t)}},Mo=[],No=Object.freeze({done:!0,value:void 0}),Po=function(){let e=new Ao(!0);return e.isShared=!0,e}(),Fo=[],Io=(e,...t)=>{if(!e)throw t.unshift(`SortedMap:`),Error(t.join(` `))};(function(e){let t=e.DeleteValue=Object.freeze({delete:!0});e.Break=Object.freeze({break:!0}),e.DeleteRange=()=>t,e.EmptySortedMap=(()=>{let e=new Oo;return e.freeze(),e})(),e.defaultComparator=function(e,t){if(Number.isFinite(e)&&Number.isFinite(t))return e-t;let n=typeof e,r=typeof t;if(n!==r)return n<r?-1:1;if(n===`object`){if(e===null)return t===null?0:-1;if(t===null)return 1;if(n=typeof(e=e.valueOf()),r=typeof(t=t.valueOf()),n!==r)return n<r?-1:1}return e<t?-1:e>t?1:e===t?0:Number.isNaN(e)?Number.isNaN(t)?0:-1:Number.isNaN(t)?1:Array.isArray(e)?0:NaN},e.simpleComparator=function(e,t){return e>t?1:e<t?-1:0}})(Oo||={});var Lo,Ro=class{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;let t=e%this._u.length;return this._u.at(t)}toArray(e){let t=[],n=this._u,r=n.length,i=Math.min(e??this._l,this._l);for(let e=0;e<i;e++){let i=e%r;t.push(n.at(i))}return t}get length(){return this._l}getPeriod(){return this._u?.length??0}get[Symbol.toStringTag](){return`[RepeatingList]`}get isIList(){return!0}get isIRepeatingList(){return!0}};(function(e){e.Hint={Blank:1,False:2,True:4,Int32:8,Float64:16,String:32,Object:128,KindMask:255,NotUniform:256,NotFinite:512};let t=e.hintOf=e=>typeof e==`number`?(0|e)===e?Ho:e-e===0?Uo:Uo|qo:typeof e==`string`?Wo:e==null?zo:!0===e?Vo:!1===e?Bo:Go,n=(e,t,n=-1)=>{let r=e.length-1;if(r<0)return;if(e[r][0]>t){let n=0,i=r-1;for(r=-1;n<=i;){let a=n+i>>>1;e[a][0]<=t?(r=a,n=a+1):i=a-1}if(r<0)return}let i=e[r],a=t-i[0],o=i[1];return a>=(n>=0&&r===e.length-1?n:o.length)?void 0:Array.isArray(o)?o[a]:o.at(a)};e.Builder=class{constructor(e,t=0,n=0,r=!1){this._tuples=[],this._minors=null,this._values=null,this._minorMin=2**53-1,this._minorMax=0,this._majorIndex=-(2**53-1),this._minorIndex=-(2**53-1),this._lastMajor=-(2**53-1),this._lastMinor=-(2**53-1),this._readIndex=0,this._run=null,this._runMinors=null,this._scratch=[],this._filled=0,this._offsetMajor=0,this._offsetMinor=0,this._absentValue=void 0,this._gaps=null,this._skips=null,this._blanks=null,this._createList=e??void 0,this._track=e!=null,this._offsetMajor=t,this._offsetMinor=n,this._trackAbsent=r}setAbsentValue(e){if(this._absentValue!==void 0&&this._absentValue!==e)throw Error(`The absent value is already set.`);return this._absentValue=e,this}pushAbsentAt(e,t,n){return n<=0||(e+=this._offsetMajor,t+=this._offsetMinor,this._advance(e,t,t+n-1),this._gaps=Jo(this._gaps,e,t,n)),this}pushMultipleAt(e,n,r){if(r&&r.isIList)return this.pushAt(e,n,r);let i=Array.isArray(r)?r:[r],a=i.length;if(this._trackAbsent){for(let t=0;t<a;t++)this.pushAt(e,n+t,i[t]);return this}if(this.pushAt(e,n,i[0]),this._track){let e=this._run,n=this._scratch,r=n[0],o=this._filled,s=e[2];for(let e=1;e<a;e++){let a=i[e];n[o++]=a,s|=t(a)|(a===r?0:Ko)}this._filled=o,e[2]=s}else{let e=this._values;for(let t=1;t<a;t++)e.push(i[t])}return this._minorIndex+=a-1,this._lastMinor=this._minorIndex,this}pushAt(e,n,r){e+=this._offsetMajor,n+=this._offsetMinor;let i=!!r&&!0===r.isIList,a=i?r.length:1;if(this._advance(e,n,n+a-1),this._trackAbsent&&a>0){let t=i?!0===r.isIRepeatingList?r.at(0):void 0:r;if(t===null)return this._blanks=Jo(this._blanks,e,n,a),this;if(t!==void 0&&t===this._absentValue)return this._skips=Jo(this._skips,e,n,a),this}let o=this._minors,s=e===this._majorIndex&&n===this._minorIndex+1;if(e!==this._majorIndex){if(o){this._run&&this._closeRun(),this._minorMin=Math.min(this._minorMin,o[0][0]);let e=o[o.length-1];this._minorMax=Math.max(this._minorMax,e[0]+e[1].length-1)}this._minors=o=[],this._tuples.push([e,o]),this._majorIndex=e}if(i)this._run&&this._closeRun(),o.push([n,r]),this._values=null;else if(this._track){let e=this._filled;if(this._run===null||!s){this._run&&this._closeRun();let t=[n,this._scratch,0];o.push(t),this._run=t,this._runMinors=o,e=0}let i=this._scratch;i[e]=r,this._filled=e+1,this._run[2]|=t(r)|(r===i[0]?0:Ko)}else{let e=this._values;e&&s||(this._values=e=[],o.push([n,e])),e.push(r)}return this._minorIndex=n+a-1,this}_closeRun(){let e=this._run,t=this._runMinors;t[t.length-1]=[e[0],this._createList(e[1],this._filled,e[2])],this._run=null,this._filled=0}getAt(e,t){if(e+=this._offsetMajor,t+=this._offsetMinor,e===this._majorIndex)return n(this._minors,t,this._run?this._filled:-1);let r=this._tuples,i=r.length,a=0,o=i-1,s=this._readIndex;if(s<i){let c=r[s][0];if(c===e)return n(r[s][1],t);if(c>e)o=s-1;else if(a=s+1,a<i){let i=r[a][0];if(i===e)return this._readIndex=a,n(r[a][1],t);if(i>e)return;a++}}for(;a<=o;){let i=a+o>>>1,s=r[i][0];if(s===e)return this._readIndex=i,n(r[i][1],t);s<e?a=i+1:o=i-1}this._readIndex=o<0?0:o}_advance(e,t,n){let i=this._lastMajor,a=this._lastMinor;if(e<i||e===i&&t<=a)throw new r(`major: ${e}, minor: ${t}, prevMajor: ${i}, prevMinor: ${a}`);this._lastMajor=e,this._lastMinor=n}build(){if(this._trackAbsent)return this._buildTracked();let e=this._tuples;if(e.length===0)return null;this._run&&this._closeRun();let t=this._minors;this._minorMin=Math.min(this._minorMin,t[0][0]);let n=t[t.length-1];return this._minorMax=Math.max(this._minorMax,n[0]+n[1].length-1),this._values=null,{tuples:e,bounds:{majorStart:e[0][0],minorStart:this._minorMin,majorEnd:e[e.length-1][0],minorEnd:this._minorMax}}}_buildTracked(){this._run&&this._closeRun(),this._values=null;let e=this._tuples,t=this._blanks??[],n,r=this._absentValue??null;if(r!==null&&t.length>0){let i=(this._gaps??[]).concat(this._skips??[]).sort(Yo);e=Xo(e,i,r),r=null,n=t}else n=this._skips?t.concat(this._skips):t;return{tuples:e,bounds:Zo(e),absentValue:r,clears:n}}},e.TransposedBuilder=class{constructor(e,t=0,n=0){this._lines=[],this._base=0,this._majorMin=2**53-1,this._majorMax=0,this._majorIndex=-(2**53-1),this._minorIndex=-(2**53-1),this._offsetMajor=0,this._offsetMinor=0,this._createList=e??void 0,this._track=e!=null,this._offsetMajor=t,this._offsetMinor=n}pushMultipleAt(e,t,n){if(n&&n.isIList){let r=n,i=r.length;for(let n=0;n<i;n++)this.pushAt(e,t+n,r.at(n));return this}let r=Array.isArray(n)?n:[n],i=r.length;for(let n=0;n<i;n++)this.pushAt(e,t+n,r[n]);return this}pushAt(e,n,i){e+=this._offsetMajor,n+=this._offsetMinor;let a=this._majorIndex;if(e!==a){if(e<a)throw new r(`major: ${e}, minor: ${n}, prevMajor: ${a}, prevMinor: ${this._minorIndex}`);this._majorIndex=e,a===-(2**53-1)&&(this._majorMin=e,this._base=n)}else if(n<=this._minorIndex)throw new r(`major: ${e}, minor: ${n}, prevMajor: ${a}, prevMinor: ${this._minorIndex}`);this._minorIndex=n,this._majorMax=e,n<this._base&&this._rebase(n);let o=this._lines,s=n-this._base,c,l=o[s];if(l===void 0)c=this._track?[e,[],0]:[e,[]],o[s]=l=[n,[c]];else{let t=l[1];c=t[t.length-1],c[0]+c[1].length!==e&&(c=this._track?[e,[],0]:[e,[]],t.push(c))}let u=c[1];return u.push(i),this._track&&(c[2]|=t(i)|(i===u[0]?0:Ko)),this}_rebase(e){let t=this._base-e,n=this._lines,r=Array(n.length+t);for(let e=0;e<n.length;e++)r[e+t]=n[e];this._lines=r,this._base=e}getAt(e,t){let r=this._lines[t+this._offsetMinor-this._base];return r?n(r[1],e+this._offsetMajor):void 0}build(){let e=[],t=this._createList,n=this._lines,r=n.length;for(let i=0;i<r;i++){let r=n[i];if(r!==void 0){if(t){let e=r[1],n=e.length;for(let r=0;r<n;r++){let n=e[r];Array.isArray(n[1])&&(e[r]=[n[0],t(n[1],n[1].length,n[2])])}}e.push(r)}}return e.length===0?null:{tuples:e,bounds:{majorStart:e[0][0],minorStart:this._majorMin,majorEnd:e[e.length-1][0],minorEnd:this._majorMax}}}};class r extends v{constructor(e=`Out of order`,t=null){super(e,t),this.name=`OutOfOrderError`}}e.OutOfOrderError=r})(Lo||={});var zo=Lo.Hint.Blank,Bo=Lo.Hint.False,Vo=Lo.Hint.True,Ho=Lo.Hint.Int32,Uo=Lo.Hint.Float64,Wo=Lo.Hint.String,Go=Lo.Hint.Object,Ko=Lo.Hint.NotUniform,qo=Lo.Hint.NotFinite;Lo.hintOf;var Jo=(e,t,n,r)=>{if(!e)return[[t,n,r]];let i=e[e.length-1];return i[0]===t&&i[1]+i[2]===n?i[2]+=r:e.push([t,n,r]),e},Yo=(e,t)=>e[0]-t[0]||e[1]-t[1],Xo=(e,t,n)=>{let r=[],i=0,a=0;for(;i<e.length||a<t.length;){let o=i<e.length?e[i][0]:2**53-1,s=a<t.length?t[a][0]:2**53-1;if(o<s){r.push(e[i++]);continue}let c=[];for(;a<t.length&&t[a][0]===s;)c.push([t[a][1],new Ro([n],t[a][2])]),a++;if(o!==s){r.push([s,c]);continue}let l=e[i++][1],u=[],d=0,f=0;for(;d<l.length||f<c.length;)f>=c.length||d<l.length&&l[d][0]<c[f][0]?u.push(l[d++]):u.push(c[f++]);r.push([s,u])}return r},Zo=e=>{if(e.length===0)return{majorStart:0,minorStart:0,majorEnd:-1,minorEnd:-1};let t=2**53-1,n=-(2**53-1);for(let r=0;r<e.length;r++){let i=e[r][1];t=Math.min(t,i[0][0]);let a=i[i.length-1];n=Math.max(n,a[0]+a[1].length-1)}return{majorStart:e[0][0],minorStart:t,majorEnd:e[e.length-1][0],minorEnd:n}};function Qo(e,t=S.Right,n=null){if(!e)return e;if(e.length===0)return[];let r=t===S.Right,i=t===S.Left,a=t===S.Up,o=t===S.Down;return e.sort((e,t)=>{if(!e&&!t)return 0;if(e&&!t)return-1;if(t&&!e)return 1;let s=n?.(e,t)??0;return s===0?r?e.rowStart===t.rowStart?e.colStart-t.colStart:e.rowStart-t.rowStart:o?e.colStart===t.colStart?e.rowStart-t.rowStart:e.colStart-t.colStart:i?e.rowStart===t.rowStart?t.colStart-e.colStart:t.rowStart-e.rowStart:a?e.colStart===t.colStart?t.rowStart-e.rowStart:t.colStart-e.colStart:0:s})}function $o(e,t){let n=t.min,r=e.min;if(t.max===2**53-1){let i=n,a=e.max;return r<=i&&i<=a?0:a<i?-1:r>i?1:(console.warn(`coords are not inserted correctly`,e,t),0)}return r-n}var es=class e{constructor(e){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 Oo(void 0,$o,e?.nodeSize),this._reuseRunsIterator={done:!1,value:[null,null]},this._reuseRunsEntry=[null,null]}_validateBounds(e=-(2**53-1),t=2**53-1){let n=this._maxCoords,r=n?.min??-(2**53-1),i=n?.max??2**53-1;if(e<r||t>i)throw new w}entries(e){let t,n,r=-(2**53-1),i=2**53-1,a=!0;e&&(e?.bounds&&(r=e.bounds?.min??-(2**53-1),i=e.bounds?.max??2**53-1,this._validateBounds(r,i)),a=!e.reverse,t=ts(e.reuseResult),n=e.processSkip);let o=this._dataCoords;if(!o)return bo;r=Math.max(o.min,r),i=Math.min(o.max,i);let s=null,c=null,l=2**53-1,u=-(2**53-1);if(n){let e=n;n=(t,n)=>e(t+l,n)-l}let d=e=>{let t;e!==-(2**53-1)&&e!==2**53-1&&(us.min=e,t=us),s=a?this._runs.entries(t,this._reuseRunsIterator):this._runs.entriesReversed(t,this._reuseRunsIterator),l=2**53-1,u=-(2**53-1),c=null},f=e=>{if(e!==void 0){if(e<l||e>u)return void(c=void 0);e-=l}if(!c)return;let n=c.next(e);if(!c)return;let r=n.value,i=r?.[1];if(!n.done)return ns(r[0]+l,i,t);c=void 0},p=e=>{let o;return o=f(e),o||(o=(e=>{let o;do{if(e!==void 0&&d(e),!s)return;if(o=s.next(),o.done)return void(s=void 0);let p=o.value,m=p[0],h=p[1],g=m.min,_=m.max,v=Math.max(g,r)-g,y=Math.max(v,Math.min(_,i))-g;cs.bounds.min=v,cs.bounds.max=y,cs.reverse=!a,cs.processSkip=n,cs.reuseResult=t,l=g,u=_,c=h.entries(cs);let b=f(e);if(b)return b;e=void 0}while(!o.done);s=void 0})(e),o||yo)};return d(a?r:i),{next(e){if(e!==void 0&&(e<0||e>i))throw new w;return p(e)},return:e=>yo,throw:e=>yo}}runs(e){let t,n=-(2**53-1),r=2**53-1,i=!0,a=!1;e&&(e.bounds&&(n=e.bounds?.min??-(2**53-1),r=e.bounds?.max??2**53-1,this._validateBounds(n,r),e.overflowRun&&(a=!0)),i=!e.reverse,t=rs(e.reuseResult));let o=this._dataCoords;if(!o)return bo;n=Math.max(o.min,n),r=Math.min(o.max,r);let s=null,c=e=>{let t;e!==-(2**53-1)&&e!==2**53-1&&(us.min=e,t=us),s=i?this._runs.entries(t,this._reuseRunsIterator):this._runs.entriesReversed(t,this._reuseRunsIterator)};return c(i?n:r),{next(e){if(e!==void 0){if(e<n||e>r)throw new w;c(e)}if(!s)return yo;let o=s.next();if(o.done)return s=void 0,yo;let l=o.value,u=l[0],d=u,f=d.min,p=d.max;if(i&&f>r||!i&&p<n)return yo;let m=l[1];return a||(p>r&&(m=m.slice(0,m.length-(p-r)),d={...d},d.max=r),f<n&&(m=m.slice(n-f),d===u&&(d={...d}),d.min=n)),is(d,m,t)},return:e=>yo,throw:e=>yo}}slice(t,n){let r=this._runs;if(this._count===0)return this.clone();let i=r.minKey().min,a=r.maxKey().max;if(n===void 0&&(n=a+1),t<=i&&n-1>=a)return this.clone();let o=Math.max(i,t),s=Math.min(a,n-1),c=s-o,l=[],u=0;ps.bounds.min=o,ps.bounds.max=s;let d=this.runs(ps),f=d.next();for(;!f.done;){let e=f.value,t=e[0],n=e[1];t={min:t.min-o,max:t.max-o},t.min<0&&(n=n.slice(-t.min),t.min=0),t.max>=c&&(n=n.slice(0,n.length-(t.max-c)),t.max=c),u+=n.length,l.push([t,n]),f=d.next()}let p=new e(this._options);return p._runs.setPairs(l),p._updateCount(u),p}concat(e){let t=this.clone();if(!e||e.length===0)return t;let n=this._runs;if(this._count===0){let n=[],r=0;if(e.isISparseList){let t=e.runs(),i=t.next();for(;!i.done;){let e=i.value;n.push([{min:e[0].min,max:e[0].max},e[1]]),r+=e[1].length,i=t.next()}}else n.push([{min:0,max:e.length-1},e]),r+=e.length;return t._runs.setPairs(n),t._updateCount(r),t}let r=n.nextLowerPair(void 0,this._reuseRunsEntry),i=r[0],a=r[1],o=i.max+1,s=!1,c=0,l=[];if(e.isISparseList){let t=e.runs(),n=t.next();for(;!n.done;){let e=n.value,r=e[0],u={min:r.min+o,max:r.max+o},d=e[1];if(r.min===0){s=!0,c-=a.length,d=a.concat(d);let e=i.min;u.min=e,u.max=d.length-1+e}c+=d.length,l.push([u,d]),n=t.next()}}else{let t=e.length,n={min:i.min,max:t-1+o};e=a.concat(e),s=!0,c+=t,l.push([n,e])}return s&&t._runs.delete(i),t._runs.setPairs(l),t._updateCount(c),t}toArray(e=2**53-1,t=!0){if(this.length===0)return i.EmptyArray;let n=t?0:-(2**53-1),r=Math.min(this._runs.maxKey().max,e);return ls.bounds.min=-(2**53-1),ls.bounds.max=r,as(this.entries(ls),t,r,n)}get isIReadableList(){return!0}get length(){return this._length}getCoords(){return this._dataCoords}clear(){this._runs.clear(),this._dataCoords=null,this._lastRunsRead=void 0,this._lastListRead=void 0,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){let e=this._runs,t=Object.freeze({min:e.minKey().min,max:e.maxKey().max});this._dataCoords=t,this._length=t.max+1}else this._dataCoords=null,this._length=0}_update(e,t,n=null,r=void 0){let i=e,a=i+t-1,o=0,s=a,c=a,l=null,u=null;us.min=i,ds.min=a,(n||r)&&(--us.min,ds.min+=1);let d=this._runs,f=!1;if(d.editRange(us,ds,!0,(e,t,n)=>{let r=e.min,d=e.max;return r<i&&d+1>=i&&(s=r,l=t),r-1<=a&&d>a&&(c=r,u=t),o-=d-r+1,f=!0,Oo.DeleteValue}),n||r===void 0||(n=new xo([r])),n){let e=n;f=!0;let t=i;l&&(l=l.slice(0,i-s),e=l.concat(e),t=s),u&&(u=u.slice(a+1-c),e=e.concat(u)),o+=e.length,d.set({min:t,max:t+e.length-1},e)}else l&&(l=l.slice(0,i-s),o+=l.length,d.set({min:s,max:s+l.length-1},l)),u&&(u=u.slice(a+1-c),o+=u.length,d.set({min:a+1,max:a+u.length},u));return this._updateCount(o),f}setAt(e,t){if(e===void 0)throw new y;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 y;let n=t.length;return this._validateBounds(e,e+n-1),this._update(e,n,t)}delete(e,t){if(t===void 0){let n=this.getCoords();if(!n)return!1;t=Math.max(n.max-e+1,0)}return!(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);let i=this._runs;if(this._count===0)return!1;let a=i.maxKey();if(t<0&&r>=a.max&&n<=i.minKey().min)return this._runs.clear(),this._dataCoords=null,this._count=0,this._length=0,!0;let o=0,s=n,c=r,l=null,u=null;us.min=s,ds.min=a.min,t<0&&(--us.min,ds.min+=1);let d=!1,f=[];if(i.editRange(us,ds,!0,(e,i,a)=>{let p=e.min,m=e.max;return p<n&&m+1>=n&&(s=p,l=i),(p<n||t<0)&&p-1<=r&&e.max>r&&(c=p,u=i),t>0&&p>=n||t<0&&p-1>r?f.push([{min:p+t,max:m+t},i]):o-=m-p+1,d=!0,Oo.DeleteValue}),t>0){let r=l||u;r&&(l=r.slice(0,n-s),c=e+t,u=r.slice(n-s))}else l&&=l.slice(0,n-s),u&&(u=u.slice(r+1-c),c=e),l&&u&&s+l.length===c&&(l=l.concat(u),u=null);return l&&l.length>0&&(o+=l.length,i.set({min:s,max:s+l.length-1},l)),u&&(o+=u.length,i.set({min:c,max:c+u.length-1},u)),f.length>0&&i.setPairs(f),this._updateCount(o),d}at(e){us.min=e;let t=this._lastRunsRead;if(t){let n=t.min;if(n<=e&&t.max>=e)return this._lastListRead.at(e-n)}let n,r,i=this._runs.getPairOrNextHigher(us,fs);if(i&&(n=i[0],r=i[1]),this._lastRunsRead=n,this._lastListRead=r,!(!n||e<n.min||e>n.max))return r.at(e-n.min)}[Symbol.iterator](){return go(this.entries())}clone(){let t=new e(this._options);return t._runs=this._runs.clone(),t._count=this._count,t._dataCoords=this._dataCoords,t._length=this._length,t}getMaxCoords(){return this._maxCoords||null}getCount(){return this._count}getRunsCount(){return this._runs.size}get[Symbol.toStringTag](){return`[SparseList]`}};es||={};var ts=e=>typeof e==`boolean`?!0===e?ss:void 0:(e&&!e.value&&(e.value=[-1,null]),e),ns=(e,t,n)=>{let r=n??{done:!1,value:[-1,null]},i=r.value;return i[0]=e,i[1]=t,r},rs=e=>typeof e==`boolean`?!0===e?os:void 0:(e&&!e.value&&(e.value=[null,null]),e),is=(e,t,n)=>{let r=n??{done:!1,value:[null,null]},i=r.value;return i[0]=e,i[1]=t,r},as=(e,t=!1,n=-(2**53-1),r=2**53-1)=>{let i=[],a=e.next(),o=Math.max(r,0)-1;for(;!a.done;){if(t){let e=a.value[0];for(let t=o;t<e-1;t++)i.push(void 0);o=e}i.push(a.value[1]),a=e.next()}if(t)for(let e=o;e<n;e++)i.push(void 0);return i},os=Object.seal({done:!1,value:[{min:-(2**53-1),max:2**53-1},null]}),ss=Object.seal({done:!1,value:[-1,null]}),cs={reverse:!1,bounds:{min:-(2**53-1),max:2**53-1},processSkip:null,reuseResult:ss},ls=Object.freeze({reverse:!1,bounds:{min:-(2**53-1),max:2**53-1},processSkip:null,reuseResult:ss}),us={min:0,max:2**53-1},ds={min:0,max:2**53-1},fs=[null,null],ps={bounds:{min:0,max:0},overflowRun:!0},ms=class{constructor(e=9){this._arena=ks,this._owner=0,this._root=hs,this._size=0,this._nodes=0,this._colStart=0,this._rowStart=0,this._colEnd=0,this._rowEnd=0,this._maxEntries=Math.min(vs,Math.max(4,e)),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries))}size(){return this._size}all(e){return this._root===hs?e??i.EmptyArray:this._all(this._root,e??[])}search(e,t){if(this._root===hs||!this._rootIntersects(e))return t??i.EmptyArray;let n=t??[],r=e.colStart,a=e.rowStart,o=e.colEnd,s=e.rowEnd,c=this._arena,l=c.boxes,u=c.meta,d=c.payload,f=rc,p=0;for(f[p++]=this._root;p>0;){let e=f[--p],t=e*ys,i=e*Cs,c=u[i+ws],m=u[i+Ts]===0;for(let e=0;e<c;e++){let c=l[t+e];if(c>o)continue;let h=l[t+bs+e];if(h>s)continue;let g=l[t+xs+e];if(g<r)continue;let _=l[t+Ss+e];if(_<a)continue;let v=u[i+e];m?n.push(d[v]):r<=c&&a<=h&&g<=o&&_<=s?this._all(v,n):f[p++]=v}}return n}collides(e){if(this._root===hs||!this._rootIntersects(e))return!1;let t=e.colStart,n=e.rowStart,r=e.colEnd,i=e.rowEnd,a=this._arena,o=a.boxes,s=a.meta,c=rc,l=0;for(c[l++]=this._root;l>0;){let e=c[--l],a=e*ys,u=e*Cs,d=s[u+ws],f=s[u+Ts]===0;for(let e=0;e<d;e++){let d=o[a+e];if(d>r)continue;let p=o[a+bs+e];if(p>i)continue;let m=o[a+xs+e];if(m<t)continue;let h=o[a+Ss+e];if(!(h<n)){if(f||t<=d&&n<=p&&m<=r&&h<=i)return!0;c[l++]=s[u+e]}}}return!1}isEmpty(){return this._root===hs}getBoundingRange(){return this._root===hs?null:{colStart:this._colStart,rowStart:this._rowStart,colEnd:this._colEnd,rowEnd:this._rowEnd}}load(e){if(!e||!e.length)return this;let t=e.length;if(t<this._minEntries){for(let n=0;n<t;n++)this.insert(e[n]);return this}let n=this._writableArena(),r=n.payload.length;if(r===0)n.payload=e.slice();else{let r=n.payload;for(let n=0;n<t;n++)r.push(e[n])}let i=new Float64Array(4*t),a=new Int32Array(t);for(let n=0;n<t;n++){let t=e[n],r=4*n;i[r]=t.colStart,i[r+1]=t.rowStart,i[r+2]=t.colEnd,i[r+3]=t.rowEnd,a[n]=n}let o=n.top;n.reserve(o+Math.ceil(t/(this._maxEntries-1))+16);let s=this._build(a,i,r,0,t-1,0),c=Ps,l=As,u=js,d=Ms,f=Ns;if(this._nodes+=n.top-o,this._size+=t,this._root===hs)this._root=s,this._setRootBox();else{let e=n.meta[this._root*Cs+Ts];if(e===c)this._splitRoot(s);else if(e<c){let t=this._root,n=this._colStart,r=this._rowStart,i=this._colEnd,a=this._rowEnd;this._root=s,this._setRootBox(),this._insertEntry(t,n,r,i,a,e+1)}else this._insertEntry(s,l,u,d,f,c+1)}return this._maybeCompact(),this}removeAll(e,t){let n=e?e.length:0;if(n===0||this._root===hs)return this;let r,i=1/0,a=1/0,o=-1/0,s=-1/0;for(let t=0;t<n;t++){let n=e[t];n.colStart<i&&(i=n.colStart),n.rowStart<a&&(a=n.rowStart),n.colEnd>o&&(o=n.colEnd),n.rowEnd>s&&(s=n.rowEnd)}if(t)r=r=>{for(let i=0;i<n;i++)if(t(r,e[i]))return!0;return!1};else{let t=new Set(e);r=e=>t.has(e)}let c=this._removeWithin(this._root,r,i,a,o,s);return c===_s?this.clear():c!==gs&&(this._root=c,this._setRootBox(),this._maybeCompact()),this}clear(){return this._arena=ks,this._owner=0,this._root=hs,this._size=0,this._nodes=0,this}clone(){this._arena.owners>=Ds&&this._detach();let e=new this.constructor(this._maxEntries),t=this._arena;return e._arena=t,e._root=this._root,e._size=this._size,e._nodes=this._nodes,e._colStart=this._colStart,e._rowStart=this._rowStart,e._colEnd=this._colEnd,e._rowEnd=this._rowEnd,t!==ks&&(this._owner=t.nextOwner(),e._owner=t.nextOwner()),e}insert(e){if(!e)return this;let t=this._writableArena(),n=t.payload.length;return t.payload.push(e),this._insertEntry(n,e.colStart,e.rowStart,e.colEnd,e.rowEnd,0),this._size++,this._maybeCompact(),this}remove(e,t){if(!e||this._root===hs)return this;let n=this._root;if(this._arena.meta[n*Cs+Ts]>0&&!(this._colStart<=e.colStart&&this._rowStart<=e.rowStart&&e.colEnd<=this._colEnd&&e.rowEnd<=this._rowEnd)||!this._findItem(n,0,e,t))return this;let r=uc,i=lc,a=sc,o=cc;a[0]=this._own(a[0],hs,0);for(let e=1;e<=r;e++)a[e]=this._own(a[e],a[e-1],o[e-1]);let s=this._arena;Rs(s,a[r],i),this._size--;for(let e=r;e>0;e--){let t=a[e];s.meta[t*Cs+ws]===0?(Rs(s,a[e-1],o[e-1]),this._nodes--):(Fs(s,t),Is(s,a[e-1],o[e-1]))}return s.meta[a[0]*Cs+ws]===0?this.clear():(this._setRootBox(),this._maybeCompact()),this}_rootIntersects(e){return this._colStart<=e.colEnd&&this._rowStart<=e.rowEnd&&this._colEnd>=e.colStart&&this._rowEnd>=e.rowStart}_setRootBox(){Fs(this._arena,this._root),this._colStart=As,this._rowStart=js,this._colEnd=Ms,this._rowEnd=Ns}_writableArena(){let e=this._arena;return e===ks&&(e=new Os(4),this._arena=e,this._owner=e.nextOwner()),e}_ownDetached(e){let t=this._arena;if(t.meta[e*Cs+Es]===this._owner)return e;let n=t.alloc(this._owner);return function(e,t,n){e.boxes.copyWithin(n*ys,t*ys,t*ys+ys),e.meta.copyWithin(n*Cs,t*Cs,t*Cs+Cs)}(t,e,n),t.meta[n*Cs+Es]=this._owner,n}_own(e,t,n){let r=this._ownDetached(e);return r!==e&&(t===hs?this._root=r:this._arena.meta[t*Cs+n]=r),r}_all(e,t){let n=this._arena,r=n.meta,i=n.payload,a=ic,o=0;for(a[o++]=e;o>0;){let e=a[--o]*Cs,n=r[e+ws];if(r[e+Ts]===0)for(let a=0;a<n;a++)t.push(i[r[e+a]]);else for(let t=0;t<n;t++)a[o++]=r[e+t]}return t}_build(e,t,n,r,i,a){let o=this._arena,s=i-r+1,c=this._maxEntries,l=o.alloc(this._owner),u=l*ys,d=l*Cs;if(s<=c){let i=o.boxes,a=o.meta;for(let o=0;o<s;o++){let s=e[r+o],c=4*s;i[u+o]=t[c],i[u+bs+o]=t[c+1],i[u+xs+o]=t[c+2],i[u+Ss+o]=t[c+3],a[d+o]=n+s}return a[d+ws]=s,a[d+Ts]=0,Fs(o,l),Ps=0,l}a||(a=Math.ceil(Math.log(s)/Math.log(c)),c=Math.ceil(s/c**(a-1)));let f=Math.ceil(s/c),p=f*Math.ceil(Math.sqrt(c)),m=0,h=0;ec(e,t,0,r,i,p);for(let s=r;s<=i;s+=p){let r=Math.min(s+p-1,i);ec(e,t,1,s,r,f);for(let i=s;i<=r;i+=f){let s=this._build(e,t,n,i,Math.min(i+f-1,r),a-1);h=Ps,o.meta[d+m]=s,Is(o,l,m),m++}}return o.meta[d+ws]=m,o.meta[d+Ts]=h+1,Fs(o,l),Ps=h+1,l}_insertEntry(e,t,n,r,i,a){let o=this._arena;if(this._root===hs){let e=o.alloc(this._owner);o.meta[e*Cs+ws]=0,o.meta[e*Cs+Ts]=0,this._root=e,this._nodes=1}let s=ac,c=oc,l=this._own(this._root,hs,0),u=0;for(;o.meta[l*Cs+Ts]>a;){let e=Bs(o,l,t,n,r,i);s[u]=l,c[u]=e,u++,l=this._own(o.meta[l*Cs+e],l,e)}s[u]=l;let d=this._addEntry(l,e,t,n,r,i);for(let e=u-1;e>=0;e--){let t=s[e];Fs(o,s[e+1]),Is(o,t,c[e]),d!==hs&&(Fs(o,d),d=this._addEntry(t,d,As,js,Ms,Ns))}d===hs?this._setRootBox():this._splitRoot(d)}_addEntry(e,t,n,r,i,a){let o=this._arena,s=e*Cs,c=o.meta[s+ws];if(c<this._maxEntries)return Ls(o,e,c,t,n,r,i,a),o.meta[s+ws]=c+1,hs;let l=c+1,u=e*ys,d=o.boxes;for(let e=0;e<c;e++)Vs[e]=d[u+e],Hs[e]=d[u+bs+e],Us[e]=d[u+xs+e],Ws[e]=d[u+Ss+e],Gs[e]=o.meta[s+e],Ks[e]=e;Vs[c]=n,Hs[c]=r,Us[c]=i,Ws[c]=a,Gs[c]=t,Ks[c]=c;let f=this._minEntries;$s(Vs,l,f)<$s(Hs,l,f)&&Zs(Vs,l);let p=function(e,t){let n=-1,r=1/0,i=1/0;for(let a=t;a<=e-t;a++){Qs(0,a);let t=qs,o=Js,s=Ys,c=Xs;Qs(a,e);let l=(s<Ys?s:Ys)-(t>qs?t:qs)+1,u=(c<Xs?c:Xs)-(o>Js?o:Js)+1,d=l>0&&u>0?l*u:0,f=(s-t+1)*(c-o+1)+(Ys-qs+1)*(Xs-Js+1);d<r?(r=d,n=a,i=f<i?f:i):d===r&&f<i&&(i=f,n=a)}return n>0?n:e-t}(l,f),m=o.alloc(this._owner);for(let t=0;t<p;t++){let n=Ks[t];Ls(o,e,t,Gs[n],Vs[n],Hs[n],Us[n],Ws[n])}for(let e=p;e<l;e++){let t=Ks[e];Ls(o,m,e-p,Gs[t],Vs[t],Hs[t],Us[t],Ws[t])}let h=o.meta;return h[s+ws]=p,h[m*Cs+ws]=l-p,h[m*Cs+Ts]=h[s+Ts],this._nodes++,m}_splitRoot(e){let t=this._arena,n=this._root,r=t.alloc(this._owner);Fs(t,n),Ls(t,r,0,n,As,js,Ms,Ns),Fs(t,e),Ls(t,r,1,e,As,js,Ms,Ns),t.meta[r*Cs+ws]=2,t.meta[r*Cs+Ts]=t.meta[n*Cs+Ts]+1,this._root=r,this._nodes++,this._setRootBox()}_findItem(e,t,n,r){let i=this._arena,a=e*Cs,o=i.meta[a+ws],s=i.meta[a+Ts];if(s===0){for(let s=0;s<o;s++){let o=i.payload[i.meta[a+s]];if(r?r(n,o):n===o)return sc[t]=e,lc=s,uc=t,!0}return!1}let c=e*ys;for(let l=0;l<o;l++){if(s>1){let e=i.boxes;if(!(e[c+l]<=n.colStart&&e[c+bs+l]<=n.rowStart&&n.colEnd<=e[c+xs+l]&&n.rowEnd<=e[c+Ss+l]))continue}if(this._findItem(i.meta[a+l],t+1,n,r))return sc[t]=e,cc[t]=l,!0}return!1}_removeWithin(e,t,n,r,i,a){let o=this._arena,s=e*Cs,c=o.meta[s+ws];if(o.meta[s+Ts]===0){let n=c-1;for(;n>=0&&!t(o.payload[o.meta[s+n]]);)n--;if(n<0)return gs;let r=this._ownDetached(e);Rs(o,r,n),this._size--;for(let e=n-1;e>=0;e--)t(o.payload[o.meta[r*Cs+e]])&&(Rs(o,r,e),this._size--);return o.meta[r*Cs+ws]===0?_s:r}let l=gs;for(let s=c-1;s>=0;s--){let c=l===gs?e:l,u=c*ys,d=o.boxes;if(d[u+s]>i||d[u+bs+s]>a||d[u+xs+s]<n||d[u+Ss+s]<r)continue;let f=this._removeWithin(o.meta[c*Cs+s],t,n,r,i,a);f!==gs&&(l===gs&&(l=this._ownDetached(e)),f===_s?(Rs(o,l,s),this._nodes--):(o.meta[l*Cs+s]=f,Fs(o,f),Is(o,l,s)))}return l===gs?gs:o.meta[l*Cs+ws]===0?_s:l}_maybeCompact(){let e=this._arena;(e.top-this._nodes>this._nodes+(this._size>>2)+64||e.payload.length>2*this._size+64)&&this._detach()}_detach(){let e=this._arena;if(e===ks)return;let t=new Os(this._nodes),n=t.nextOwner();this._root!==hs&&(this._root=zs(e,t,this._root,n)),this._arena=t,this._owner=n}_validate(){let e=e=>{throw Error(`RTree invalid: ${e}`)};if(this._root===hs)return void(this._size===0&&this._nodes===0||e(`empty with size ${this._size}, nodes ${this._nodes}`));let t=this._arena,n=0,r=0,i=(a,o)=>{r++;let s=a*Cs,c=a*ys,l=t.meta[s+ws],u=t.meta[s+Ts];(l>this._maxEntries||l<1&&!o)&&e(`node ${a} has ${l} entries`);for(let r=0;r<l;r++){let o=t.meta[s+r];if(u===0){n++;let i=t.payload[o];t.boxes[c+r]===i.colStart&&t.boxes[c+bs+r]===i.rowStart&&t.boxes[c+xs+r]===i.colEnd&&t.boxes[c+Ss+r]===i.rowEnd||e(`leaf ${a} slot ${r} box differs from its item`)}else{let n=i(o,!1);n!==u-1&&e(`node ${a} of height ${u} has a child of height ${n}`),Fs(t,o),t.boxes[c+r]===As&&t.boxes[c+bs+r]===js&&t.boxes[c+xs+r]===Ms&&t.boxes[c+Ss+r]===Ns||e(`node ${a} slot ${r} box differs from its child's`)}}return u};i(this._root,!0),n!==this._size&&e(`holds ${n} items, size says ${this._size}`),r!==this._nodes&&e(`reaches ${r} nodes, count says ${this._nodes}`),Fs(t,this._root),this._colStart===As&&this._rowStart===js&&this._colEnd===Ms&&this._rowEnd===Ns||e(`root box differs from its entries`)}},hs=-1,gs=-2,_s=-3,vs=12,ys=48,bs=12,xs=24,Ss=36,Cs=16,ws=12,Ts=13,Es=14,Ds=2147483632,Os=class{constructor(e){this.top=0,this.payload=[],this.owners=0,this.boxes=new Float64Array(e*ys),this.meta=new Int32Array(e*Cs)}alloc(e){let t=this.top;return(t+1)*Cs>this.meta.length&&this.reserve(Math.max(4,2*t)),this.meta[t*Cs+Es]=e,this.top=t+1,t}reserve(e){if(e*Cs<=this.meta.length)return;let t=new Float64Array(e*ys);t.set(this.boxes),this.boxes=t;let n=new Int32Array(e*Cs);n.set(this.meta),this.meta=n}nextOwner(){return++this.owners}},ks=new Os(0),As=0,js=0,Ms=0,Ns=0,Ps=0;function Fs(e,t){let n=e.boxes,r=t*ys,i=e.meta[t*Cs+ws],a=1/0,o=1/0,s=-1/0,c=-1/0;for(let e=0;e<i;e++){let t=n[r+e],i=n[r+bs+e],l=n[r+xs+e],u=n[r+Ss+e];t<a&&(a=t),i<o&&(o=i),l>s&&(s=l),u>c&&(c=u)}As=a,js=o,Ms=s,Ns=c}function Is(e,t,n){let r=e.boxes,i=t*ys;r[i+n]=As,r[i+bs+n]=js,r[i+xs+n]=Ms,r[i+Ss+n]=Ns}function Ls(e,t,n,r,i,a,o,s){let c=e.boxes,l=t*ys;c[l+n]=i,c[l+bs+n]=a,c[l+xs+n]=o,c[l+Ss+n]=s,e.meta[t*Cs+n]=r}function Rs(e,t,n){let r=e.boxes,i=e.meta,a=t*ys,o=t*Cs,s=i[o+ws]-1;for(let e=n;e<s;e++)r[a+e]=r[a+e+1],r[a+bs+e]=r[a+bs+e+1],r[a+xs+e]=r[a+xs+e+1],r[a+Ss+e]=r[a+Ss+e+1],i[o+e]=i[o+e+1];i[o+ws]=s}function zs(e,t,n,r){let i=t.alloc(r);t.boxes.set(e.boxes.subarray(n*ys,n*ys+ys),i*ys);let a=n*Cs,o=e.meta[a+ws],s=e.meta[a+Ts],c=i*Cs;t.meta[c+ws]=o,t.meta[c+Ts]=s;for(let n=0;n<o;n++){let i=e.meta[a+n];if(s===0)t.meta[c+n]=t.payload.length,t.payload.push(e.payload[i]);else{let a=zs(e,t,i,r);t.meta[c+n]=a}}return i}function Bs(e,t,n,r,i,a){let o=e.boxes,s=t*ys,c=e.meta[t*Cs+ws],l=1/0,u=1/0,d=0;for(let e=0;e<c;e++){let t=o[s+e],c=o[s+bs+e],f=o[s+xs+e],p=o[s+Ss+e],m=(f-t+1)*(p-c+1),h=((f>i?f:i)-(t<n?t:n)+1)*((p>a?p:a)-(c<r?c:r)+1)-m;h<u?(u=h,l=m<l?m:l,d=e):h===u&&m<l&&(l=m,d=e)}return d}var Vs=new Float64Array(13),Hs=new Float64Array(13),Us=new Float64Array(13),Ws=new Float64Array(13),Gs=new Int32Array(13),Ks=new Int32Array(13),qs=0,Js=0,Ys=0,Xs=0;function Zs(e,t){for(let n=1;n<t;n++){let t=Ks[n],r=e[t],i=n-1;for(;i>=0&&e[Ks[i]]>r;)Ks[i+1]=Ks[i],i--;Ks[i+1]=t}}function Qs(e,t){let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let o=e;o<t;o++){let e=Ks[o];Vs[e]<n&&(n=Vs[e]),Hs[e]<r&&(r=Hs[e]),Us[e]>i&&(i=Us[e]),Ws[e]>a&&(a=Ws[e])}qs=n,Js=r,Ys=i,Xs=a}function $s(e,t,n){Zs(e,t),Qs(0,n);let r=qs,i=Js,a=Ys,o=Xs;Qs(t-n,t);let s=qs,c=Js,l=Ys,u=Xs,d=a-r+1+(o-i+1)+(l-s+1)+(u-c+1);for(let e=n;e<t-n;e++){let t=Ks[e];Vs[t]<r&&(r=Vs[t]),Hs[t]<i&&(i=Hs[t]),Us[t]>a&&(a=Us[t]),Ws[t]>o&&(o=Ws[t]),d+=a-r+1+(o-i+1)}for(let e=t-n-1;e>=n;e--){let t=Ks[e];Vs[t]<s&&(s=Vs[t]),Hs[t]<c&&(c=Hs[t]),Us[t]>l&&(l=Us[t]),Ws[t]>u&&(u=Ws[t]),d+=l-s+1+(u-c+1)}return d}function ec(e,t,n,r,i,a){let o=dc,s=0;for(o[s++]=r,o[s++]=i;s>0;){if((i=o[--s])-(r=o[--s])<=a)continue;let c=r+Math.ceil((i-r)/a/2)*a;tc(e,t,n,c,r,i),o[s++]=r,o[s++]=c,o[s++]=c,o[s++]=i}}function tc(e,t,n,r,i,a){let o=i,s=a;for(;s>o;){if(s-o>600){let i=s-o+1,a=r-o+1,c=Math.log(i),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(i-l)/i)*(a-i/2<0?-1:1),d=Math.floor(r-a*l/i+u),f=d>o?d:o,p=Math.floor(r+(i-a)*l/i+u);tc(e,t,n,r,f,p<s?p:s)}let i=t[4*e[r]+n],a=o,c=s;for(nc(e,o,r),t[4*e[s]+n]>i&&nc(e,o,s);a<c;){for(nc(e,a,c),a++,c--;t[4*e[a]+n]<i;)a++;for(;t[4*e[c]+n]>i;)c--}t[4*e[o]+n]===i?nc(e,o,c):(c++,nc(e,c,s)),c<=r&&(o=c+1),r<=c&&(s=c-1)}}function nc(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}var rc=new Int32Array(1024),ic=new Int32Array(1024),ac=new Int32Array(64),oc=new Int32Array(64),sc=new Int32Array(64),cc=new Int32Array(64),lc=0,uc=0,dc=new Int32Array(256),fc=class e{constructor(e){this._cloneKey=null,this._lastMiss={colStart:2**53-1,rowStart:0,colEnd:0,rowEnd:0},this._lastSingle={colStart:2**53-1,rowStart:0,colEnd:0,rowEnd:0},this._lastSingleResult=null,this._options=e,this._rTree=new pc(e?.maxNodeEntries??16)}visitRanges(e,t,n=null){let r,i=this.search(e);n&&(i=Qo(i,n));let a=[],o=null,s=i.length;for(let e=0;!o&&e<s;e++){let n=i[e],s=t?.(n);s&&(!0===s.delete?a.push(n):s.update!==void 0&&(a.push(n),r||=[],r.push(s.update)),s&&!0===s.break&&(o=s))}return a.length>0&&this._getWritableTree().removeAll(a),r&&this.load(r),this._onModified(),o}getBoundingRange(){return this._getReadTree().getBoundingRange()}size(){return this._getReadTree().size()}isEmpty(){return this._getReadTree().isEmpty()}search(e,t=!1,n=!1,r){let a=this._getReadTree();if(a.isEmpty())return i.EmptyArray;let o=!t&&!n&&!r;if(o){let t=this._lastMiss;if(t.colStart!==2**53-1&&h.isRangeWithinRange(e,t))return i.EmptyArray;let n=this._lastSingle;if(n.colStart!==2**53-1&&n.colStart===e.colStart&&n.colEnd===e.colEnd&&n.rowStart===e.rowStart&&n.rowEnd===e.rowEnd)return this._lastSingleResult;if(n.colStart!==2**53-1&&this._lastSingleResult?.length===1&&h.isRangeWithinRange(e,n)){let n=this._lastSingleResult[0];return n.colStart<=e.colEnd&&n.colEnd>=e.colStart&&n.rowStart<=e.rowEnd&&n.rowEnd>=e.rowStart?this._lastSingleResult:(t.colStart=e.colStart,t.rowStart=e.rowStart,t.colEnd=e.colEnd,t.rowEnd=e.rowEnd,i.EmptyArray)}}let s=a.searchRange(e,t,r);return o&&(s.length===0?(this._lastMiss.colStart=e.colStart,this._lastMiss.rowStart=e.rowStart,this._lastMiss.colEnd=e.colEnd,this._lastMiss.rowEnd=e.rowEnd,this._lastSingle.colStart=2**53-1,this._lastSingleResult=null):(this._lastMiss.colStart=2**53-1,this._lastSingle.colStart=e.colStart,this._lastSingle.rowStart=e.rowStart,this._lastSingle.colEnd=e.colEnd,this._lastSingle.rowEnd=e.rowEnd,this._lastSingleResult=s)),n&&s.sort(h.columnFirstRangeComparator),s}has(e){return this._getReadTree().collides(e)}all(e){return this._getReadTree().all(e)}shift(e){let t=e.range,n=e.direction,r=e.cloneIfUpdate??!1,a=e.coordValidator??null,o=e.onShift??null,c=n===S.Left||n===S.Right,l=c?s.Column:s.Row,u=n===S.Up||n===S.Left?-1:1,d=(c?t.colEnd-t.colStart+1:t.rowEnd-t.rowStart+1)*u,p=[],m=[],g=null,_=this.getBoundingRange();if(!_)return this;let v=n===S.Up||n===S.Left?S.Right:S.Left,y=this._options?.updateEntryOptions,b=y?.isMergeOnShift??!1,x=y?.isSplittable??!0,C=x&&(y?.isSplitOnExpand??!1),w=y?.isTrailingEdge??!1,T=n===S.Left||n===S.Up,E=y?.getSplit??Cc,D=y?.getShifted,O=y?.onShifted,k=y?.onRemoved,A=y?.onMerged,j=y?.onUpdated,M=O?[]:null,N=k?[]:null,ee=j?[]:null,te;this.visitRanges({colStart:t.colStart-+!!c,rowStart:t.rowStart-+!c,colEnd:c?_.colEnd:t.colEnd,rowEnd:c?t.rowEnd:_.rowEnd},e=>{if((c?e.colEnd<t.colStart:e.rowEnd<t.rowStart)&&!w)return;let r=x&&Ec(t,e,c?f.Column:f.Row);if(T&&t.colStart<=e.colStart&&t.rowStart<=e.rowStart&&t.colEnd>=e.colEnd&&t.rowEnd>=e.rowEnd){let n=Dc(e,null,{after:null,before:e,intersect:t,isSplit:r,axis:l,amount:d},D,E,o,!1);if(n===void 0)return;if(n===null)return g=h.unionRanges(g,e),N&&N.push(e),void p.push(e)}let i={...e};n===S.Right?(t.colStart<=i.colStart&&(i.colStart+=d),i.colEnd+=d):n===S.Left?t.colStart<i.colStart?(i.colStart=Math.max(i.colStart+d,t.colStart),i.colEnd=Math.max(i.colEnd+d,i.colStart-1)):i.colEnd+=Math.max(d,t.colStart-i.colEnd-1):n===S.Down?(t.rowStart<=i.rowStart&&(i.rowStart+=d),i.rowEnd+=d):n===S.Up&&(t.rowStart<i.rowStart?(i.rowStart=Math.max(i.rowStart+d,t.rowStart),i.rowEnd=Math.max(i.rowEnd+d,t.rowStart-1)):i.rowEnd+=Math.max(d,t.rowStart-i.rowEnd-1)),(i.colEnd<i.colStart||i.rowEnd<i.rowStart)&&(i=null);let s=Dc(e,i,{after:i,before:e,intersect:t,isSplit:r,axis:l,amount:d},D,E,o,C&&d>0);if(s===void 0)return;let u=s===null?[]:s,_=u.length;if(u[0]!==e||_!==1){if(a)for(let e=0;e<_;e++){let t=u[e];t&&a(t)}p.push(e);for(let t=0;t<_;t++){let n=u[t];g=h.unionRanges(g,n),m.push(n),M&&M.push(n),ee&&ee.push(e)}}},v),te=r&&(p.length>0||m.length>0)?this.clone():this,te._updateNodes(m,p),e?.onUpdates&&e.onUpdates(m,p,te);let P=i.EmptyArray;if(b&&_&&g){let e=!0;if(d>0&&(e=c?t.rowStart>_.rowStart||t.rowEnd<_.rowEnd:t.colStart>_.colStart||t.colEnd<_.colEnd),e){let e=mc(g,h.unionRanges(_,g),+!c,+!!c);A&&(P=te._mergeNodes(e,!1))}}return j&&ee.length>0&&j(ee),O&&M.length>0&&O(M),A&&P.length>0&&A(P),k&&N.length>0&&k(N),this._onModified(),te}insertNonOverlapping(e,t){return this._insertOneNonOverlapping(e,t)&&this._mergeAdjacent(e,t),this._onModified(),this}insertAllNonOverlapping(e,t){let n=e.length;if(n===0)return this;if(n===1)return this.insertNonOverlapping(e[0],t);let r=e[0],i={colStart:r.colStart,rowStart:r.rowStart,colEnd:r.colEnd,rowEnd:r.rowEnd,scope:r.scope},a=this._insertOneNonOverlapping(r,t);for(let r=1;r<n;r++){let n=e[r];this._insertOneNonOverlapping(n,t)&&(a=!0),n.colStart<i.colStart&&(i.colStart=n.colStart),n.rowStart<i.rowStart&&(i.rowStart=n.rowStart),n.colEnd>i.colEnd&&(i.colEnd=n.colEnd),n.rowEnd>i.rowEnd&&(i.rowEnd=n.rowEnd)}return a&&this._mergeAdjacent(i,t),this._onModified(),this}_insertOneNonOverlapping(e,t){let n=t?.onIntersect??((e,t)=>({...e,value:t.value})),r=this.search(e),a=this._options?.updateEntryOptions,o=a?.onUpdated,s=a?.onRemoved,c=a?.getSplit,l=a?.getIntersect,u=a?.getUpdate,d=null,f=null,p=r;if(!(e.value!==null||t?.onIntersect||l||u||s)){let t=null,n=r.length;for(let i=0;i<n;i++){let n=r[i];h.isRangeWithinRange(n,e)?n.value?.onRemove?.(n):(t??=[]).push(n)}p=t??i.EmptyArray}let m=bc(p,e,{getSplit:(e,t,n,r)=>{let i;return c?(i=c(e,t,n,r),i):(i=Cc(e,t,n,r),i)},getIntersect:(e,t)=>{l&&(t=l(e,t));let r=n(e,t);return r===void 0||r!==null&&r.value!==null||e.value?.onRemove?.(e),r},getUpdate:e=>{let t=e;if(u&&(t=u(e)),t&&t.value!==null)o&&(d||=[],d.push(t));else if(s&&!f){f=[];let n=t&&t.value===null?t:{...e,value:null};f.push(n)}return t}}),g=this.getBoundingRange()===null;return this._updateNodes(m,r,t?.onUpdates),d&&o(d),f&&s(f),(m.length>0||r.length>0)&&!g&&!a?.noMerge&&!t?.noMerge}_mergeAdjacent(e,t){let n=this.getBoundingRange();if(!n)return;let r=this._options?.updateEntryOptions,i=mc(e,h.unionRanges(n,e)),a=this.search(i);if(a.length<=1)return;let o=r?.getMerged??wc,c=a;if(c=xc(c,s.Column,1,o),c=xc(c,s.Row,1,o),a.length===c.length)return;this._updateNodes(c,a,t?.onUpdates);let l=r?.onMerged;l&&c.length>0&&l(c)}createCopiedEntries(e,t,n,r,a){let o=this._options?.updateEntryOptions;return function(e,t,n,r,a,o,c){let l=n.colEnd-n.colStart+1,u=n.rowEnd-n.rowStart+1,d=n.colStart-t.colStart,f=n.rowStart-t.rowStart,p=r?.transpose??!1,m=1,g=1;p?(m=t.rowEnd-t.rowStart+1,g=t.colEnd-t.colStart+1):(m=t.colEnd-t.colStart+1,g=t.rowEnd-t.rowStart+1);let _=Math.ceil(l/m),v=Math.ceil(u/g),y=n.scope,b=a??[],x=o??i.EmptyArray,C=n.colEnd,w=n.rowEnd;return e.visitRanges(t,e=>{let i=e.value;if(!i.copyTo)return;let a=e;if(!h.isRangeWithinRange(a,t)){if(!c)return;let e=vc(a,t,c);a=e[e.length-1]}i=a.value;let o=a.colEnd-a.colStart+1,x=a.rowEnd-a.rowStart+1,S=d+a.colStart,T=f+a.rowStart;if(p){S=a.rowStart-t.rowStart+n.colStart,T=a.colStart-t.colStart+n.rowStart;let e=o;o=x,x=e}let E=_,D=v,O=l<=E*o,k=u<=D*x;if(O||k){let e=i?.canTile?.({colStart:S,rowStart:T,colEnd:Math.min(S+(O?l:o)-1,C),rowEnd:Math.min(T+(k?u:x)-1,w)},r);!O||!0!==e&&e!==s.Column||(o=l,E=1),!k||!0!==e&&e!==s.Row||(x=u,D=1)}for(let e=0;e<E;e++){let t=S+e*m;for(let e=0;e<D;e++){let n=T+e*g,a=Math.min(t+o-1,C),s=Math.min(n+x-1,w),c={colStart:t,rowStart:n,colEnd:a,rowEnd:s,scope:y};if(t>a||n>s)continue;let l=i.copyTo(c,r);l&&b.push(l)}}},S.Right),{inserts:b,removes:x}}(this,e,t,n,r,a,o?.isSplittable??1?o?.getSplit??Cc:null)}remove(e,t){return e&&(this._getWritableTree().remove(e,t??_c),this._onModified()),this}removeAll(e,t){return e&&e.length>0&&this._getWritableTree().removeAll(e,t),this._onModified(),this}insert(e){return e&&this._getWritableTree().insert(e),this._onModified(),this}load(e){return e&&e.length>0&&this._getWritableTree(e),this._onModified(),this}clear(){return this.isEmpty()||this._getWritableTree().clear(),this._onModified(),this}delete(e){if(this.isEmpty())return this;if(!e)return this.clear();let t=this.search(e);return t.length===0||(this._getWritableTree().removeAll(t),this._onModified()),this}clone(e=null){if(e!==null&&this._cloneKey===e)return this;let t=this._createClone(this._options);return t._rTree=this._rTree.clone(),t._cloneKey=e,t}_updateNodes(e,t,n){if(!(e&&e.length!==0||t&&t.length!==0))return;let r=this._getWritableTree();if(t){let e=t.length;for(let n=0;n<e;n++){let e=t[n],r=e.value;r&&r.onRemove&&r.onRemove(e)}e===1?r.remove(t[0]):e>1&&r.removeAll(t)}e.length>0&&r.load(e),n?.(e,t,this),this._options?.updateEntryOptions?.onUpdates?.(e,t,this)}_mergeNodes(e,t){let n=this.search(e,t),r=i.EmptyArray;if(n.length>1){let e=this._options?.updateEntryOptions?.getMerged??wc,t=n;t.length>1&&(t=xc(t,s.Column,1,e)),t.length>1&&(t=xc(t,s.Row,1,e)),n.length!==t.length&&(r=t,this._updateNodes(t,n))}return r}_getReadTree(){return this._rTree}_getWritableTree(e){return this._lastMiss.colStart=2**53-1,this._lastSingle.colStart=2**53-1,this._lastSingleResult=null,e&&this._rTree.load(e),this._rTree}_onModified(){}_createClone(t){return new e(t)}},pc=class extends ms{isEmpty(){return super.isEmpty()}searchRange(e,t=!1,n){if(this.isEmpty())return i.EmptyArray;let r=this.search(e,n);return t?r.filter(t=>t.colStart>=e.colStart&&t.rowStart>=e.rowStart&&t.colEnd<=e.colEnd&&t.rowEnd<=e.rowEnd):r}};function mc(e,t=e,n=1,r=1){return{...e,colStart:Math.max(e.colStart-n,t.colStart),rowStart:Math.max(e.rowStart-r,t.rowStart),colEnd:Math.min(e.colEnd+n,t.colEnd),rowEnd:Math.min(e.rowEnd+r,t.rowEnd)}}function hc(e,t,n,r){return[{...t[0],value:e.value},{...t[0],value:e.value}]}function gc(e,t){return{...e}}function _c(e,t){return e===t||!(!e||!t)&&e.rowStart===t.rowStart&&e.rowEnd===t.rowEnd&&e.colStart===t.colStart&&e.colEnd===t.colEnd}function vc(e,t,n=null){if(_c(e,t))return[{...e}];let r=h.intersectRanges(e,t,Ac);if(!r)return null;let a=[],o=e.uuid,c=e;if(c.rowStart<r.rowStart){let e={...c,colStart:c.colStart,rowStart:c.rowStart,colEnd:c.colEnd,rowEnd:r.rowStart-1};o&&(e.uuid=i.uuidV4());let t={...c,colStart:c.colStart,rowStart:r.rowStart,colEnd:c.colEnd,rowEnd:c.rowEnd};o&&(t.uuid=i.uuidV4());let l=t.rowStart-e.rowStart;kc[0]=e,kc[1]=t;let u=n(c,kc,s.Row,l);u!==void 0&&(a.push(u[0]),c=u[1])}if(c.rowEnd>r.rowEnd){let e={...c,colStart:c.colStart,rowStart:c.rowStart,colEnd:c.colEnd,rowEnd:r.rowEnd};o&&(e.uuid=i.uuidV4());let t={...c,colStart:c.colStart,rowStart:r.rowEnd+1,colEnd:c.colEnd,rowEnd:c.rowEnd};o&&(t.uuid=i.uuidV4());let l=t.rowStart-e.rowStart;kc[0]=e,kc[1]=t;let u=n(c,kc,s.Row,l);u!==void 0&&(a.push(u[1]),c=u[0])}if(c.colStart<r.colStart){let e={...c,colStart:c.colStart,rowStart:c.rowStart,colEnd:r.colStart-1,rowEnd:c.rowEnd};o&&(e.uuid=i.uuidV4());let t={...c,colStart:r.colStart,rowStart:c.rowStart,colEnd:c.colEnd,rowEnd:c.rowEnd};o&&(t.uuid=i.uuidV4());let l=t.colStart-e.colStart;kc[0]=e,kc[1]=t;let u=n(c,kc,s.Column,l);u!==void 0&&(a.push(u[0]),c=u[1])}if(c.colEnd>r.colEnd){let e={...c,colStart:c.colStart,rowStart:c.rowStart,colEnd:r.colEnd,rowEnd:c.rowEnd};o&&(e.uuid=i.uuidV4());let t={...c,colStart:r.colEnd+1,rowStart:c.rowStart,colEnd:c.colEnd,rowEnd:c.rowEnd};o&&(t.uuid=i.uuidV4());let l=t.colStart-e.colStart;kc[0]=e,kc[1]=t;let u=n(c,kc,s.Column,l);u!==void 0&&(a.push(u[1]),c=u[0])}return c===e&&(c={...e}),a.push(c),a}function yc(e){return e.value===null?null:e}function bc(e,t,n){let r=n?.getIntersect??gc,a=n?.getUpdate??yc;if(e.length===0){let e=t;if(r){let n=r({...t,value:null},t);e=n&&n.value!==null?{...n}:null}if(a){let t=a(e);t!==void 0&&(e=t)}return e?[e]:i.EmptyArray}let o=n?.getSplit??hc,s=(e,t)=>{let n=t.search(e),r=n.length;for(let i=0;i<r;i++){let r=n[i];if(_c(r,e))continue;t?.remove(r);let a=vc(r,e,o);for(let e=0;e<a.length;e++){let n=a[e];t.insert(n),s(n,t)}}},c=new fc;c.load(e),s(t,c);let l=new fc;l.load([t]);let u=c.search(t);for(let e=0;e<u.length;e++)s(u[e],l);let d=(e,t,n)=>{let i=t.search(e);console.assert(i.length<=1,`intersecting incorrect ranges`);let a=i[0]??{...e,value:null};if(_c(a,e)){let i=r(a,e);t.remove(a),n.insert(i)}else{t.remove(a);let i=vc(a,e,o),s=i.length;for(let a=0;a<s;a++){let o=i[a];if(_c(o,e)){let t=r(o,e);n.insert(t)}else t.insert(o)}}},f=new fc,p=l.all([]),m=p.length;for(let e=0;e<m;e++)d(p[e],c,f);let h=c.all([]);return((e,t)=>{let n=e.all([]),r=n.length;for(let e=0;e<r;e++){let r=n[e];if(a){let e=a(r);e!==void 0&&(r=e)}r!==null&&r.value!==null&&t.push(r)}})(f,h),h}function xc(e,t=s.Column,n=2,r,i){let a=[...e];if(n<=0||e.length<=1)return a;let o=t===s.Column,c=0,l=0;do{let e=a.sort(h.createRangeComparator(o?s.Row:s.Column));a=[];let t=!1;a.push(e[0]);let n=e.length;for(let c=1;c<n;c++){let n=e[c],l=a[a.length-1],u=!1;if(u=o?l&&l.rowStart===n.rowStart&&l.rowEnd===n.rowEnd&&l.colEnd+1===n.colStart&&l.scope===n.scope:l&&l.colStart===n.colStart&&l.colEnd===n.colEnd&&l.rowEnd+1===n.rowStart&&l.scope===n.scope,u){let e={...l};if(e.colEnd=o?n.colEnd:l.colEnd,e.rowEnd=o?l.rowEnd:n.rowEnd,r){let t=i??[null,null];t[0]=l,t[1]=n,e=r(t,e,o?s.Column:s.Row)}if(e){a[a.length-1]=e,t=!0;continue}}a.push(n)}l=t?0:l+1,c++,o=!o}while(c<n&&l<2&&a.length>1);return a}function Sc(e,t=2,n=s.Row,i,a,o){if(e.length<=1)return[...e];let c=function(e){let t=e[0]?.scope??null,n=!1;for(let r=1;r<e.length;r++)if((e[r]?.scope??null)!==t){n=!0;break}if(!n)return null;let r=new Map;for(let t=0;t<e.length;t++){let n=e[t],i=n?.scope??null,a=r.get(i);a?a.push(n):r.set(i,[n])}return Array.from(r.values())}(e);if(c){let e=[];for(let r=0;r<c.length;r++){let s=Sc(c[r],t,n,i,a,o);for(let t=0;t<s.length;t++)e.push(s[t])}return e}let l=e[0]?.scope??void 0,u=[],d=n===s.Column,f=new r.IteratorInstance(e,{axis:d?s.Row:s.Column}),p=f.next();for(;!p.done;){let e=p.value;p=f.next();let n=e.range;if(a&&e.overlaps.length>1&&a(n,e.overlaps),t>0){let e=u[u.length-1],t=!1;if(t=d?e&&e.rowStart===n.rowStart&&e.rowEnd===n.rowEnd&&e.colEnd+1===n.colStart:e&&e.colStart===n.colStart&&e.colEnd===n.colEnd&&e.rowEnd+1===n.rowStart,t){let t={...e,colEnd:d?n.colEnd:e.colEnd,rowEnd:d?e.rowEnd:n.rowEnd};if(i){let r=o??[null,null];r[0]=e,r[1]=n,t=i(r,t,d?s.Column:s.Row)}if(t){u[u.length-1]=t;continue}}}u.push(n)}if(t>1&&(u=xc(u,d?s.Row:s.Column,t,i,o)),l!==void 0)for(let e=0;e<u.length;e++)u[e].scope===void 0&&(u[e]={...u[e],scope:l});return u}function Cc(e,t,n,r){let i=e.value;if(i?.getSplit){let e=i.getSplit(t,n,r);if(e===void 0)return;t[0].value=e[0],t[1].value=e[1]}return t}function wc(e,t,n){let r=e[0].value,i=e[1].value;if(i){let a;if(r?.getMerged?a=r.getMerged(e[1].value,h.sanitizeRange(t),n):r&&(a=r===i?i:void 0),a===void 0)return;t.value=a}return t}function Tc(e,t,n,r){let i=t,a=!0;for(;a;){a=!1;for(let t=0;t<4&&!a;t++){let o=t<2,c=t%2==0,l=o?{colStart:i.colStart,colEnd:i.colEnd,rowStart:c?i.rowStart-1:i.rowEnd+1,rowEnd:c?i.rowStart-1:i.rowEnd+1,scope:i.scope}:{rowStart:i.rowStart,rowEnd:i.rowEnd,colStart:c?i.colStart-1:i.colEnd+1,colEnd:c?i.colStart-1:i.colEnd+1,scope:i.scope};if(l.rowStart<0||l.colStart<0)continue;let u=e(l);if(u.length!==1)continue;let d=u[0];if(!(o?d.colStart===i.colStart&&d.colEnd===i.colEnd:d.rowStart===i.rowStart&&d.rowEnd===i.rowEnd)||d.value===i.value)continue;let f=c?d:i,p=c?i:d,m={colStart:f.colStart,rowStart:f.rowStart,colEnd:p.colEnd,rowEnd:p.rowEnd,scope:i.scope},h=n(f,p,m,o?s.Row:s.Column);if(h===void 0)continue;let g={...m,value:h};r([i,d],g),i=g,a=!0}}return i}function Ec(e,t,n=f.Both){let r=n=>n?e.rowStart>t.rowStart&&e.rowStart<=t.rowEnd||e.rowEnd<t.rowEnd&&e.rowEnd>=t.rowStart:e.colStart>t.colStart&&e.colStart<=t.colEnd||e.colEnd<t.colEnd&&e.colEnd>=t.colStart,i=n===f.Column,a=n===f.Row;return n===f.Both&&(i=a=!0),!(!i||!r(!0))||!(!a||!r(!1))}function Dc(e,t,n,r,a,o,c){let l=n.axis===s.Column,u=n.intersect,d=(t,s)=>{let d=t.value,f=null,p=s.after;if(c){let n=null,r=0,o=0;if(l&&u.colStart>t.colStart?(n={...t,colEnd:u.colStart-1},o=s.amount):!l&&u.rowStart>t.rowStart&&(n={...t,rowEnd:u.rowStart-1},r=s.amount),n){let t=vc(e,n,a);if(t.length>1)for(let e=0;e<t.length;e++){let a=t[e];_c(a,n)?(f??=[],f.push(a)):(p=a,d=a.value,s={...s,after:{...a,colStart:a.colStart+o,rowStart:a.rowStart+r,colEnd:a.colEnd+o,rowEnd:a.rowEnd+r,uuid:i.uuidV4()},before:a,isSplit:!0})}}}if(r?p=r(s.before,s.after,s):d&&d.getShifted?p=d.getShifted(s):s.after&&(p={...s.after,value:t.value}),p!==void 0)return o&&(p!==s.after&&(s={...s,after:p}),o(s)),p=(t=>{if(!t){let t=e.value;return t.onRemove&&t.onRemove(n.before),null}return t})(p),p&&(f??=[],f.push(p)),f};if(n.isSplit){let r;r=l?{...e,rowStart:Math.max(u.rowStart,n.before.rowStart),rowEnd:Math.min(u.rowEnd,n.before.rowEnd)}:{...e,colStart:Math.max(u.colStart,n.before.colStart),colEnd:Math.min(u.colEnd,n.before.colEnd)};let i=vc(e,r,a),o=[];for(let e=0;e<i.length;e++){let a=i[e];if(_c(a,r)){let e=null;t&&(e=l?{colStart:t.colStart,rowStart:r.rowStart,colEnd:t.colEnd,rowEnd:r.rowEnd,value:a.value}:{colStart:r.colStart,rowStart:t.rowStart,colEnd:r.colEnd,rowEnd:t.rowEnd,value:a.value});let i=d(a,{...n,before:a,after:e});if(i)for(let e=0;e<i.length;e++)o.push(i[e])}else o.push(a)}return o}return d(e,n)}function Oc(e,t){let n=e=>`${e.scope??``}!${e.rowStart},${e.colStart},${e.rowEnd},${e.colEnd}`,r=new Set,i=[],a=Sc(t(e),2,s.Row);for(;a.length>0;){let e=[];for(let o of a){let a=n(o);r.has(a)||(r.add(a),i.push(o),e.push(...t(o)))}a=Sc(e,2,s.Row)}return Sc(i,2,s.Row)}var kc=[null,null],Ac={colStart:0,rowStart:0,colEnd:0,rowEnd:0};function jc(e=-(2**53-1),t=-(2**53-1),n=2**53-1,r=2**53-1,i,a,o){if(a&&(e!==-(2**53-1)&&e<a.colStart||t!==-(2**53-1)&&t<a.rowStart||n!==2**53-1&&n>a.colEnd||r!==2**53-1&&r>a.rowEnd))throw new w;return o&&(e=Math.max(o.colStart,e),t=Math.max(o.rowStart,t),n=Math.min(o.colEnd,n),r=Math.min(o.rowEnd,r),n<e||r<t)?null:(Fc.majorStart=i?e:t,Fc.majorEnd=i?n:r,Fc.minorStart=i?t:e,Fc.minorEnd=i?r:n,Fc)}function Mc(e,t,n){let r=n??{colStart:0,rowStart:0,colEnd:0,rowEnd:0};return r.colStart=t?e.majorStart:e.minorStart,r.rowStart=t?e.minorStart:e.majorStart,r.colEnd=t?e.majorEnd:e.minorEnd,r.rowEnd=t?e.minorEnd:e.majorEnd,r}function Nc(e,t,n,r,i){let a=i??{done:!1,value:[{colIndex:-1,rowIndex:-1},null]},o=a.value,s=o[0];return s.colIndex=r?e:t,s.rowIndex=r?t:e,o[1]=n,a}function Pc(e){if(typeof e==`boolean`){if(!0===e)return{done:!1,value:[{colIndex:-1,rowIndex:-1},null]}}else if(e)return e}var Fc={majorStart:0,majorEnd:0,minorStart:0,minorEnd:0};function Ic(e,t){return e[0]-t[0]}var Lc=class{constructor(e,t){this._isColumn=!0,this._isReverse=!1,this._skipMajors=!1,this._majorMin=2**53-1,this._majorMax=-(2**53-1),this._minorMin=2**53-1,this._minorMax=-(2**53-1),this._majorIndex=-(2**53-1),this._minorIndex=-(2**53-1),this._delegateMajorIndex=-(2**53-1),this._delegateMinorIndex=-(2**53-1),this._delegate=e;let n=(t.axis??s.Column)===s.Column;this._isColumn=n,this._isReverse=t.reverse??!1,this._skipMajors=t.skipMajors??!1;let r=t.bounds,i=r.colStart,a=r.rowStart,o=r.colEnd,c=r.rowEnd;this._majorMin=n?i:a,this._majorMax=n?o:c,this._minorMin=n?a:i,this._minorMax=n?c:o,this._processMajorSkip=n?t.processColumnSkip:t.processRowSkip,this._processMinorSkip=n?t.processRowSkip:t.processColumnSkip;let l=e.next();this._delegateResult=l,this._initialize()}_initialize(){let e=this._isColumn,t=this._isReverse,n=t?-1:1,r=t?this._majorMax:this._majorMin,i=(t?this._minorMax:this._minorMin)-n,a=this._processMinorSkip;a&&(i=a(i,t));let o=this._processMajorSkip;o&&(r=o(r,t)),this._majorIndex=r,this._minorIndex=i;let s=this._delegateResult;if(s.done)this._delegateMajorIndex=this._majorMax,this._delegateMinorIndex=this._minorMax+n;else{let t=s.value[0];this._delegateMajorIndex=e?t.colIndex:t.rowIndex,this._delegateMinorIndex=e?t.rowIndex:t.colIndex}}next(e){e!==void 0&&(this._delegateResult=this._delegate.next(e),this._initialize());let t=this._isReverse,n=this._isColumn,r=this._majorMin,i=this._majorMax,a=this._majorIndex,o=this._minorIndex;if(a>i||a<r)return yo;let s=this._delegateMajorIndex,c=this._delegateMinorIndex,l=this._delegateResult.done;if(a===s&&o===c){let e=this._delegate.next();if(this._delegateResult=e,l=e.done,l)s=t?r:i,s=t?this._minorMin:this._minorMax;else{let t=e.value[0];s=n?t.colIndex:t.rowIndex,c=n?t.rowIndex:t.colIndex}this._delegateMajorIndex=s,this._delegateMinorIndex=c}let u=t?-1:1;if(this._minorIndex=o+=u,a===s&&o===c&&!l)return this._delegateResult;let d=this._processMinorSkip;if(d&&(o=d(o,t)),o>this._minorMax||o<this._minorMin){a+=u;let e=this._processMajorSkip;e&&(a=e(a,t)),this._skipMajors&&(!t&&a<s||t&&a>s)&&(a=s),this._majorIndex=a,o=t?this._minorMax:this._minorMin}return this._minorIndex=o,a!==s||o!==c||l?a>i||a<r?yo:{done:!1,value:[{colIndex:n?a:o,rowIndex:n?o:a},void 0]}:this._delegateResult}return(e){return yo}throw(e){return yo}[Symbol.iterator](){return this}},Rc=class{constructor(e){this._isColumn=!0,this._majorSize=2**53-1,this._minorSize=2**53-1,this._majorMin=2**53-1,this._majorMax=-(2**53-1),this._minorMin=2**53-1,this._minorMax=-(2**53-1),this._majorIndex=2**53-1,this._minorIndex=2**53-1,this._minorOffset=0,this._minorRepeat=0,this._majorOffset=-1,this._majorRepeat=1,this._pattern=[];let t=e.delegate;this._delegate=t;let n=(e.axis??s.Column)===s.Column;this._isColumn=n;let r=e.dims,i=e.bounds,a=i.colStart,o=i.rowStart,c=i.colEnd,l=i.rowEnd;if(this._majorSize=1+(n?c-a:l-o),this._minorSize=1+(n?l-o:c-a),this._majorMin=n?a:o,this._minorMin=n?o:a,this._majorMax=(n?a+r.major:o+r.major)-1,this._minorMax=(n?o+r.minor:a+r.minor)-1,this._majorSize>this._majorMax+1||this._minorSize>this._minorMax+1)throw Error(`The dimensions must be larger than the bounds.`);let u=t.next();this._nextDelegateResult=u,this._initialize()}_initialize(){let e=this._isColumn,t=this._nextDelegateResult;if(t.done)this._nextResult=yo;else{let n=t.value[0],r=e?n.colIndex:n.rowIndex,i=e?n.rowIndex:n.colIndex,a=[[i,t.value[1]]];this._minorSpan=a,this._majorIndex=r,this._minorIndex=i,this._pattern.push([r,a]),this._nextResult=t}}next(e){if(e!==void 0)throw new p;let t=this._nextResult,n=this._isColumn,r=this._majorIndex,i=this._nextDelegateResult;if(!i.done){let e=i.value[0];if((n?e.colIndex:e.rowIndex)===r&&(i=this._delegate.next(),this._nextDelegateResult=i,!i.done)){let e=i.value,a=e[0],o=n?a.colIndex:a.rowIndex,s=n?a.rowIndex:a.colIndex;if(o===r)return this._minorSpan.push([s,e[1]]),this._minorOffset=this._minorSpan.length-1,this._minorIndex=s,this._nextResult=i,t}}let a=this._minorMax,o=this._minorIndex;if(o<a){let e=this._minorOffset;e++;let i=this._minorSpan;e>=i.length&&(e=0,this._minorRepeat++);let s=i[e],c=this._minorMin;if(o=c+(s[0]-c+this._minorSize*this._minorRepeat),this._minorIndex=o,this._minorOffset=e,o<=a){let e=[{colIndex:n?r:o,rowIndex:n?o:r},s[1]];return this._nextResult={done:!1,value:e},t}}if(!i.done){let e=i.value,r=e[0],a=n?r.colIndex:r.rowIndex,o=n?r.rowIndex:r.colIndex,s=[[o,e[1]]];return this._pattern.push([a,s]),this._majorIndex=a,this._minorSpan=s,this._minorOffset=0,this._minorIndex=o,this._minorRepeat=0,this._nextResult=i,t}let s=this._majorMax;if(r<s){let e=this._majorOffset;e++;let i=this._pattern;e>=i.length&&(e=0,this._majorRepeat++);let a=i[e],c=a[1],l=c[0],u=this._majorMin;if(r=u+(a[0]-u+this._majorSize*this._majorRepeat),this._majorIndex=r,this._majorOffset=e,r<=s){this._minorSpan=c,this._minorOffset=0,o=l[0],this._minorIndex=o,this._minorRepeat=0;let e=[{colIndex:n?r:o,rowIndex:n?o:r},l[1]];return this._nextResult={done:!1,value:e},t}}return t.done||(this._nextResult=yo),t}return(e){return yo}throw(e){return yo}[Symbol.iterator](){return this}},zc=class{constructor(e,t,n){this._comparator=e?.comparator??h.createCellComparator(e.axis??s.Column,e.reverse??!1),this._iterator1=t,this._iterator2=n;let r=t.next();this._nextResult1=r;let i=n.next();this._nextResult2=i,e?.reuseResult&&(this._reuseResult=!0===e.reuseResult?{done:!1,value:[void 0,void 0,void 0,void 0]}:e.reuseResult)}next(e){let t=this._nextResult1,n=this._nextResult2;if(t.done&&n.done)return t;if(t.done){let e=n;this._nextResult2=this._iterator2.next();let t=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};t.done=!1;let r=t.value,i=e.value;return r[2]=i[0],r[3]=i[1],r[0]=void 0,r[1]=void 0,t}if(n.done){let e=t;this._nextResult1=this._iterator1.next();let n=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};n.done=!1;let r=n.value,i=e.value;return r[0]=i[0],r[1]=i[1],r[2]=void 0,r[3]=void 0,n}let r=(0,this._comparator)(t.value[0],n.value[0]);if(r<0){let e=t;this._nextResult1=this._iterator1.next();let n=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};n.done=!1;let r=n.value,i=e.value;return r[0]=i[0],r[1]=i[1],r[2]=void 0,r[3]=void 0,n}if(r>0){let e=n;this._nextResult2=this._iterator2.next();let t=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};t.done=!1;let r=t.value,i=e.value;return r[2]=i[0],r[3]=i[1],r[0]=void 0,r[1]=void 0,t}this._nextResult1=this._iterator1.next(),this._nextResult2=this._iterator2.next();let i=this._reuseResult??{done:!1,value:[void 0,void 0,void 0,void 0]};i.done=!1;let a=i.value;return a[0]=t.value[0],a[1]=t.value[1],a[2]=n.value[0],a[3]=n.value[1],i}return(e){return yo}throw(e){return yo}[Symbol.iterator](){return this}},Bc=`Must be an array of arrays.`;function Vc(e,t,n){let r=t.majorStart,i=t.minorStart,a=t.majorEnd,o=[],s=t.minorEnd-i+1,c=typeof e==`function`;for(let t=r;t<=a;t++){let r;if(c){if(r=[],n){let n=i;for(let i=0;i<s;i++)r.push(e(n++,t))}else{let n=i;for(let i=0;i<s;i++)r.push(e(t,n++))}}else s<=Jc?(r=Array(s),r.fill(e,0,s)):r=new Ro([e],s);let a=[[i,r]];o.push([t,a])}return{tuples:o,bounds:t}}function Hc(e,t=!1,n=null,r=!1){let i=0,a=0,o=2**53-1,s=2**53-1;if(n&&(i=n.majorStart??0,a=n.minorStart??0,o=(n.majorEnd??2**53-1)-i+1,s=(n.minorEnd??2**53-1)-a+1),t){let e=i;i=a,a=e;let t=o;o=s,s=t}if(!Array.isArray(e))throw Error(Bc);if(e.length>o)throw new w;if(t)return Uc(e,i,a,s,r);let c=new Lo.Builder;for(let t=0;t<e.length;t++){let n=e[t];if(n!=null&&n.length!==0){if(!Array.isArray(n))throw Error(Bc);if(n.length>s)throw new w;if(r){let e=-1;for(let r=0;r<n.length;r++)n[r]==null?e!==-1&&(c.pushMultipleAt(t+i,a+e,n.slice(e,r)),e=-1):e===-1&&(e=r);e!==-1&&c.pushMultipleAt(t+i,a+e,n.slice(e))}else c.pushMultipleAt(t+i,a,n)}}return c.build()}var Uc=(e,t,n,r,i)=>{let a=e.length,o=-1,s=!i;for(let t=0;t<a;t++){let n=e[t];if(n!=null&&n.length!==0){if(!Array.isArray(n))throw Error(Bc);if(n.length>r)throw new w;o===-1?o=n.length:n.length!==o&&(s=!1)}else s=!1}if(o===-1)return null;if(s){let r=Array(o);for(let i=0;i<o;i++){let o=Array(a);for(let t=0;t<a;t++)o[t]=e[t][i];r[i]=[n+i,[[t,o]]]}return{tuples:r,bounds:{majorStart:n,minorStart:t,majorEnd:n+o-1,minorEnd:t+a-1}}}let c=[],l=[],u=[],d=-1,f=-1;for(let n=0;n<a;n++){let r=e[n];if(r==null)continue;let a=r.length;for(let e=0;e<a;e++){let a=r[e];if(i&&a==null)continue;let o=c[e];if(o===void 0||l[e]!==n-1){c[e]=o=[];let r=[t+n,o],i=u[e];i?i.push(r):u[e]=[r],d===-1&&(d=n)}o.push(a),l[e]=n,f=n}}let p=[];for(let e=0;e<u.length;e++){let t=u[e];t&&p.push([n+e,t])}return p.length===0?null:{tuples:p,bounds:{majorStart:p[0][0],minorStart:t+d,majorEnd:p[p.length-1][0],minorEnd:t+f}}},Wc=(e,t,n)=>{if(e===t)return t},Gc=(e,t,n)=>{if(e[0].value===e[1].value)return t},Kc=[null,null];function qc(e=!0,t=Wc,n){let r=[],i,a,o=-(2**53-1),c=-(2**53-1),l=0,u=(t,n,r)=>{let i=e?t.colStart:t.rowStart;return n===i?r<(e?t.rowStart:t.colStart)?-1:+(r>(e?t.rowEnd:t.colEnd)):n<i?-1:1};return{append:(s,l,u)=>{if(n&&i&&s===o&&l===c){let t=n(a,u);(e?i.rowStart===l:i.colStart===l)?i.value=t:(e?i.rowEnd=l-1:i.colEnd=l-1,r.push(i),i=e?{colStart:s,rowStart:l,colEnd:s,rowEnd:l,value:t}:{colStart:l,rowStart:s,colEnd:l,rowEnd:s,value:t}),a=t;return}let d,f=!0;if(u!==void 0&&(d=a===void 0?u:t(a,u,e),d===void 0&&(f=!1)),f&&l===c+1&&s===o)return u!==void 0&&(u=d),e?i.rowEnd=l:i.colEnd=l,c=l,void(a=u);i&&r.push(i);let p=e?s:l,m=e?l:s;i={colStart:p,rowStart:m,colEnd:p,rowEnd:m,value:u},o=s,c=l,a=u},done:(t=!1)=>(i&&=(r.push(i),null),t?xc(r,e?s.Column:s.Row,2,Gc,Kc):r),find:(e,t)=>{if(i){let n=u(i,e,t);if(n===0)return i;if(n>0)return}let n=r.length,a=0,o=n-1;if(l<n){let i=u(r[l],e,t);if(i===0)return r[l];if(i<0)o=l-1;else if(a=l+1,a<n){let n=u(r[a],e,t);if(n===0)return l=a,r[a];if(n<0)return;a++}}for(;a<=o;){let n=a+o>>>1,i=u(r[n],e,t);if(i===0)return l=n,r[n];i<0?o=n-1:a=n+1}l=o<0?0:o}}}var Jc=4;function Yc(e){let t=[],n=null,r=e.getRuns(),i=r.next();for(;!i.done;){let[e,a,o]=i.value;i=r.next(),n&&n[0]===e||(n=[e,[]],t.push(n)),n[1].push([a,o])}return t}var Xc=class e{constructor(e){this._dataCoords=null,this._count=0,this._isColumn=!0,this._lastMajor=-(2**53-1),this._lastMinorSpan=null,this._maxCoords=void 0,this._isShared=!1,this._options={axis:s.Row,...e},this._isColumn=(this._options?.axis??s.Column)===s.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(2**53-1,e.maxCoords.colEnd??2**53-1),rowEnd:Math.min(2**53-1,e.maxCoords.rowEnd??2**53-1)})),this._createRun=e?.createRun??(e=>new xo(e)),this._optionsMinor={},this._major=new es({nodeSize:Zc})}getRuns(e){let t=this._isColumn,n=this._maxCoords,r=this.getCoords();if(!r)return bo;let i=e?.bounds,a={reuseResult:{done:!1,value:[-1,null]}},o={reuseResult:{done:!1,value:[null,null]}};if(i){let s=jc(i?.colStart??-(2**53-1),i?.rowStart??-(2**53-1),i?.colEnd??2**53-1,i?.rowEnd??2**53-1,t,n,r);if(!s)return bo;a.bounds={min:s.majorStart,max:s.majorEnd},o.bounds={min:s.minorStart,max:s.minorEnd},o.overflowRun=e?.overflowRun}let s,c=e?.reuseResult;!0===c?s={done:!1,value:[-1,-1,null]}:c&&(s=c,s.value||(s.value=[-1,-1,null]));let l=this._major.entries(a),u,d,f,p;do{if(u=l.next(),u.done)return bo;d=u.value[1],f=d.runs(o),p=f.next()}while(p.done);let m=u.value[0],h=p.value[0].min,g=p.value[1];return{[Symbol.iterator](){return this},next(){if(u.done)return yo;let e;if(s){e=s,e.done=!1;let t=e.value;t[0]=m,t[1]=h,t[2]=g}else e={done:!1,value:[m,h,g]};for(p=f.next();p.done&&!u.done;)u=l.next(),u.done||(m=u.value[0],d=u.value[1],f=d.runs(o),p=f.next());return p.done||(h=p.value[0].min,g=p.value[1]),e},return:e=>yo}}getAxis(){return this._isColumn?s.Column:s.Row}entries(e){let t=this._isColumn,n=t,r=!0,i=this._maxCoords,a=this.getCoords(),o=jc(-(2**53-1),-(2**53-1),2**53-1,2**53-1,t,i,a??void 0);if(!o)return bo;let c,l,u,d=o.majorStart,f=o.majorEnd,m=o.minorStart,h=o.minorEnd,g=!1;if(e){e?.axis&&(n=e?.axis===s.Column,r=t===n);let o=e?.bounds;if(o){let e=jc(o.colStart,o.rowStart,o.colEnd,o.rowEnd,t,i,a??void 0);if(!e)return bo;d=e.majorStart,f=e.majorEnd,m=e.minorStart,h=e.minorEnd}g=e.reverse??!1,u=Pc(e.reuseResult),c=t?e.processColumnSkip:e.processRowSkip,c&&(g?f=c(f,g):d=c(d,g)),l=t?e.processRowSkip:e.processColumnSkip,l&&(g?h=l(h,g):m=l(m,g))}if(!a)return bo;r||d!==f||(r=!0);let _=this._major.entries(rl(nl,d,f,g,c,el)),v=il(),y=e=>{if(!e.nextActive)return;let t,n=e.minorIterator;if(n){let r=n.next();r.done?e.minorIterator=null:t=r.value}let r=e.nextMinorIndex,i=e.nextMinorValue,a=e.nextActive;return t?(e.nextMinorIndex=t[0],e.nextMinorValue=t[1],e.nextActive=!0):(e.nextActive=!1,e.nextMinorIndex=g?-(2**53-1):2**53-1,e.nextMinorValue=null),e.value=i,e.minorIndex=r,e.active=a,Qc[0]=e.majorIndex,Qc[1]=r,Qc[2]=i,Qc},b=e=>{if(_)for(;;){let t=_.next();if(t.done)return void(_=void 0);let n=t.value,r=n[1];e.majorIndex=n[0],e.active=!0,e.nextActive=!1;let i=r.entries(rl(tl,m,h,g,l,$c)),a=i.next();if(!a.done){let t=a.value;return e.nextMinorIndex=t[0],e.nextMinorValue=t[1],e.minorIterator=i,e.nextActive=!0,y(e)}}},x=null;if(r){let e=g?-1:1,n={bounds:{min:m,max:h},reverse:g,overflowRun:!0,reuseResult:{done:!1,value:[null,null]}},r,i,a=-1,o=0,s=0,c=0,d=()=>{for(;;){if(r){let e=r.next();if(!e.done){let t=e.value[0];return i=e.value[1],o=t.min,g?(s=Math.min(t.max,h),c=Math.max(t.min,m)):(s=Math.max(t.min,m),c=Math.min(t.max,h)),!0}r=void 0}if(!_)return!1;let e=_.next();if(e.done)return _=void 0,!1;a=e.value[0],r=e.value[1].runs(n)}};return{next(n){if(n)throw new p(`Iterator with next argument is not supported.`);for(;;){if(!i&&!d())return yo;if(g?s<c:s>c){i=void 0;continue}if(l){let e=l(s,g);if(e!==s){s=e;continue}}let n=s;return s+=e,Nc(a,n,i.at(n-o),t,u)}},[Symbol.iterator](){return this},return:e=>yo,throw:e=>yo}}{let e=g?h:m,t=g?m:h,n,r=e,i=t,a=!0,o=()=>{let e=v.nextMajorCursor;if(e)return v=e,v;v=n,(r<m||r>h||r===i)&&(v=null),r=i,i=t};x=()=>{for(;v;){let s=null;if(a){let t=n?il():v;if(s=b(t),s){n?(t.prevMajorCursor=v,v.nextMajorCursor=t,v=t):n=v,i=g?Math.max(i,v.nextMinorIndex):Math.min(i,v.nextMinorIndex);let r=v.minorIndex;r!==e&&(i=g?Math.max(i,r):Math.min(i,r),s=null)}else a=!1,o()}else{let e=v.minorIndex,a=v.nextMinorIndex;e===r?(Qc[0]=v.majorIndex,Qc[1]=e,Qc[2]=v.value,s=Qc):!g&&e>r||g&&e<r?i=g?Math.max(i,e):Math.min(i,e):!g&&a>r||g&&a<r?i=g?Math.max(i,a):Math.min(i,a):s=y(v),v.active&&(i=g?Math.max(i,v.nextMinorIndex):Math.min(i,v.nextMinorIndex)),t===r||v.active||(v.prevMajorCursor?v.prevMajorCursor.nextMajorCursor=v.nextMajorCursor:n=v.nextMajorCursor,v.nextMajorCursor&&(v.nextMajorCursor.prevMajorCursor=v.prevMajorCursor)),o()}if(s)return s}}}return{next(e){if(e)throw new p(`Iterator with next argument is not supported.`);let n=x();return n?Nc(n[0],n[1],n[2],t,u):yo},[Symbol.iterator](){return this},return:e=>yo,throw:e=>yo}}values(e){let t=this._entriesPrivateResult(e),n;return e?.reuseResult&&(n=!0===e.reuseResult?{done:!1,value:null}:e.reuseResult),{next(e){let r=t.next(e);return r.done?yo:n?(n.value=r.value[1],n):{done:!1,value:r.value[1]}},[Symbol.iterator](){return this},return:e=>yo,throw:e=>yo}}keys(e){let t=this._entriesPrivateResult(e),n;return e?.reuseResult&&(n=!0===e.reuseResult?{done:!1,value:null}:e.reuseResult),{next(e){let r=t.next(e);if(r.done)return yo;let i=r.value[0];return n?(n.value=i,n):{done:!1,value:{colIndex:i.colIndex,rowIndex:i.rowIndex}}},[Symbol.iterator](){return this},return:e=>yo,throw:e=>yo}}_entriesPrivateResult(e){return this.entries({...e,reuseResult:!0})}_updateMajorSpan(e,t=!1){if(!e||e.length===0)return;t&&e.sort((e,t)=>e[0]-t[0]);let n=this._major,r=e[0],i=r[0],a=i,o=[r[1]];for(let t=1;t<e.length;t++){let r=e[t],s=r[0],c=r[1];s===a+1?o.push(c):(n.setRunAt(i,new xo(o)),i=s,o=[c]),a=s}o.length>0&&n.setRunAt(i,new xo(o))}setValues(e){if(!e)throw new y;if(e.length===0)return this;let t=(e=e.sort(Ic))[0][0],n=e[e.length-1][0],r=-(2**53-1),i=2**53-1,a=this._isColumn,o=this._maxCoords;if(o){let e=a?o.colStart:o.rowStart,s=a?o.colEnd:o.rowEnd;if(t<e||n>s)throw new w;r=a?o.rowStart:o.colStart,i=a?o.rowEnd:o.colEnd}if(!e||e.length===0)return this;let s=2**53-1,c=-(2**53-1),l=0,u=t-1,d=[],f=(e,t,n)=>{if(u===n)throw new Lo.OutOfOrderError(`Duplicate major Indices: {${n}}.`);u=n,t=t.sort(Ic),e=e.clone();let a=-(2**53-1),o=t.length;for(let u=0;u<o;u++){let o=t[u],d=o[0],f=o[1],m=d+f.length-1;if(a>=d)throw new Lo.OutOfOrderError(`Overlapping minor Indices: {${n}, ${d}}.`);if(d<r||m>i)throw new w;if(f&&f.length>0){let t=e.getCount();e.setRunAt(d,p(f));let n=e.getCount();l+=n-t,s=Math.min(s,e.getCoords().min),c=Math.max(c,e.getCoords().max)}a=m}h++,d.push([n,e])},p=this._createRun,m=this._optionsMinor,h=0,g=()=>{let t=e[h],n=t[0],r=t[1],i=new es(m);f(i,r,n)},_=this._major.entries(rl(nl,t,n,!1,void 0,el)),v=_.next();for(;!v.done;){let t=v.value,n=t[0],r=e[h],i=r[0];if(i>n)v=_.next();else{for(;i<n;)g(),r=e[h],i=r[0];if(i===n){let e=r[1],i=t[1];f(i,e,n)}v=_.next()}}for(;e[h];)g();return this._updateMajorSpan(d),this._updateCountAndCoords(l,t,s,n,c),this}getValues(e){let t=this.getRuns(e?{bounds:e}:void 0),n=t.next();if(n.done)return null;let r=new Lo.Builder;for(;!n.done;){let e=n.value[0],i=n.value[1],a=n.value[2];r.pushMultipleAt(e,i,a),n=t.next()}return r.build()}_updateCountAndCoords(e,t,n,r,i,a=!1){let o=this._count+e;if(this._count=o,this._lastMajor=-(2**53-1),!this._dataCoords)return;let s=this._isColumn,c=s?t:n,l=s?n:t,u=s?r:i,d=s?i:r;if(o===0)this._dataCoords=null;else{let e=this._dataCoords;e&&(c=(a?Math.max:Math.min)(c,e.colStart),l=(a?Math.max:Math.min)(l,e.rowStart),u=(a?Math.min:Math.max)(u,e.colEnd),d=(a?Math.min:Math.max)(d,e.rowEnd));let t={colStart:c,rowStart:l,colEnd:u,rowEnd:d};this._dataCoords=t}}clear(){this._major.clear(),this._dataCoords=null,this._count=0,this._lastMajor=-(2**53-1)}delete(e){let t=this._count;if(!e)return this.clear(),t>0;let n=this._isColumn,r=this._maxCoords,i=this.getCoords(),a=jc(e.colStart,e.rowStart,e.colEnd,e.rowEnd,n,r,i);if(!a||t===0)return!1;if(h.isRangeWithinRange(i,e))return this.clear(),t>0;let o=a.majorStart,s=a.majorEnd,c=a.minorStart,l=a.minorEnd,u=n?i.colStart:i.rowStart,d=n?i.colEnd:i.rowEnd,f=n?i.rowStart:i.colStart,p=n?i.rowEnd:i.colEnd,m=!1,g=0,_=this._major;if(this._lastMajor=-(2**53-1),c<=f&&l>=p){let e=_.entries(rl(nl,o,s,!1,void 0,el)),t=e.next();for(;!t.done;)g-=t.value[1].getCount(),t=e.next();return _.delete(o,s-o+1),this._count+=g,this._dataCoords=null,g!==0}let v=[],y=this._isShared,b=[],x=_.entries(rl(nl,o,s,!1,void 0,el)),S=x.next();for(;!S.done;){let e=S.value,t=e[0],n=e[1],r=n.getCoords(),i=r.min,a=r.max;if(c<=a&&l>=i){if((i===f&&c<=f||a===p&&l>=p)&&(m=!0),i>=c&&a<=l)v.push(t),g-=n.getCount();else{let e=n.getCount();y&&(n=n.clone(),b.push([t,n])),n.delete(c,l-c+1),g+=n.getCount()-e}}S=x.next()}this._updateMajorSpan(b);let C=v.length;if(C>0){let e=co(v,!0);for(let t=0;t<e.length;t++){let n=e[t];_.delete(n.min,n.max-n.min+1)}let t=_.getCoords();if(!t)return this.clear(),!0;u=t.min,d=t.max}return m?(this._count+=g,this._dataCoords=null,!0):C===0?(this._count+=g,g!==0):(this._updateCountAndCoords(g,u,f,d,p,!0),g!==0)}shift(e,t){if(!e||!t)throw new y;let n=this._isColumn,r=this._maxCoords,i=t===S.Right||t===S.Down,a=t===S.Left||t===S.Right,o=jc(e.colStart,e.rowStart,e.colEnd,e.rowEnd,n,r,e);if(!o)return!1;let s=o.majorStart,c=o.majorEnd,l=o.minorStart,u=o.minorEnd,d=this.getCoords();if(!d)return!1;let f=n?d.colStart:d.rowStart,p=n?d.colEnd:d.rowEnd,m=n?d.rowStart:d.colStart,g=n?d.rowEnd:d.colEnd,_=l<=m&&u>=g,v=n===a;if((v&&_||!v&&s<=f&&c>=p)&&!jc(d.colStart,d.rowStart,d.colEnd+(i&&a?e.colEnd-e.colStart+1:0),d.rowEnd+(i&&!a?e.rowEnd-e.rowStart+1:0),n,r)||v&&s>p||!v&&l>g)return!1;let b=v?c-s+1:u-l+1;if(!i&&(b*=-1,h.isRangeWithinRange(d,e)))return this.clear(),!0;let x=0,C=this._major,T=[];if(v&&_){if(!i){let e=C.entries(rl(nl,s,c,!1,void 0,el)),t=e.next();for(;!t.done;)x-=t.value[1].getCount(),t=e.next()}C.shift(s,b);let e=C.getCoords();return this._dataCoords=null,this._updateCountAndCoords(x,e?.min??0,m,e?.max??0,g),!0}let E=n?d.colStart:d.rowStart,D=n?d.colEnd:d.rowEnd,O=n?d.rowStart:d.colStart,k=n?d.rowEnd:d.colEnd;i||(O=2**53-1,k=-(2**53-1));let A=2**53-1;r&&(A=a?r.colEnd:r.rowEnd);let j=new Set,M=v?new Map:null,N=[],ee=C.entries(rl(nl,s,v?2**53-1:c,!1,void 0,el)),te={bounds:{min:l,max:u}},P=ee.next();for(;!P.done;){let e=P.value,t=e[0],n=e[1].clone(),r=n.getCoords(),i=r.min,a=r.max;if(v&&M.set(t,n),l<=a){let e=n.getCount();v?(t>=s-b&&ho(n.runs(te),(e,n)=>{let r=n.min,i=n.max,a=e;r-1<=u&&i>u&&(a=a.slice(0,u+1-r)),r<l&&i+1>=l&&(a=a.slice(l-r)),N.push({majorIndex:t+b,minorIndex:Math.max(r,l),run:a})}),n.delete(l,u-l+1)):n.shift(l,b);let r=n.getCount();if(r===0)j.add(t),O=Math.min(O,a),k=Math.max(k,i);else{let e=n.getCoords();if(O=Math.min(O,e.min),k=Math.max(k,e.max),k>A)throw new w}x+=r-e,T.push([t,n])}P=ee.next()}let F=this._optionsMinor,ne=!1;for(let e=0;e<N.length;e++){let t=N[e],n=t.majorIndex,r=t.run,i=M.get(n);i||(i=new es(F),M.set(n,i),T.push([n,i]),ne=!0),i.setRunAt(t.minorIndex,r),x+=r.length,E=Math.min(E,n),D=Math.max(D,n),j&&j.delete(n)}if(this._updateMajorSpan(T,ne),j&&j.size>0){let e=co(Array.from(j.values()));for(let t=0;t<e.length;t++){let n=e[t];C.delete(n.min,n.max-n.min+1)}let t=C.getCoords();if(!t)return this.clear(),!0;E=t.min,D=t.max}if(this._lastMajor=-(2**53-1),k!==g||O!==m)return this._count+=x,this._dataCoords=null,!0;{let e=this._count+x;this._count=e,this._dataCoords=e===0?null:Object.freeze({colStart:n?E:O,rowStart:n?O:E,colEnd:n?D:k,rowEnd:n?k:D})}return x!==0||!h.isEqualRanges(d,this.getCoords())}getCount(){return this._count}getValueAt(e,t){let n=this._isColumn,r=n?t:e,i=n?e:t,a=this._lastMajor,o;if(a===r&&a!==-(2**53-1)?o=this._lastMinorSpan:(o=this._major.at(r),this._lastMajor=r,this._lastMinorSpan=o),o)return o.at(i)}setValueAt(e,t,n){let r=this._isColumn,i=[r?t:e,[[r?e:t,[n]]]];this.setValues([i])}copyTo(e,t,n){if(this.getCount()===0)return;let r=this.getAxis(),i=e.getAxis(),a=this.getRuns({bounds:n}),o=a.next(),c=h.cellToRange(t);c.colEnd=n.colEnd-n.colStart+t.colIndex,c.rowEnd=n.rowEnd-n.rowStart+t.rowIndex;let l=this._isColumn,u=this._maxCoords,d=this.getCoords(),f=jc(n.colStart??-(2**53-1),n.rowStart??-(2**53-1),n.colEnd??2**53-1,n.rowEnd??2**53-1,l,u,d);f={...f};let p=i!==s.Row,m=e.getMaxCoords()??void 0,g=jc(c?.colStart??-(2**53-1),c?.rowStart??-(2**53-1),c?.colEnd??2**53-1,c?.rowEnd??2**53-1,p,m);g={...g};let _=l?n.colStart:n.rowStart,v=l?n.rowStart:n.colStart,y=l===p,b=y?g.majorStart:g.minorStart,x=y?g.minorStart:g.majorStart,S=b-(_??f.majorStart),C=x-(v??f.minorStart),w=r===i?new Lo.Builder:new Lo.TransposedBuilder;for(;!o.done;){let e=o.value[0],t=o.value[1],n=o.value[2];t+n.length>f.minorEnd&&(n=n.slice(0,f.minorEnd-t+1)),t<f.minorStart&&(n=n.slice(f.minorStart-t),t=f.minorStart),w.pushMultipleAt(e+S,t+C,n),o=a.next()}let T=w.build();e.delete(c),T&&e.setValues(T.tuples)}getCoords(){if(this._dataCoords)return this._dataCoords;if(this._major.getCount()===0)return null;let e=2**53-1,t=-(2**53-1),n=2**53-1,r=-(2**53-1),i=this._major.entries(),a=i.next();for(;!a.done;){let o=a.value,s=o[0];e=Math.min(s,e),t=Math.max(s,t);let c=o[1].getCoords();n=Math.min(c.min,n),r=Math.max(c.max,r),a=i.next()}let o=this._isColumn,s=Object.freeze({colStart:o?e:n,rowStart:o?n:e,colEnd:o?t:r,rowEnd:o?r:t});return this._dataCoords=s,s}clone(t){this._isShared=!0;let n=new e(this._options);return n._isShared=!0,n._major=this._major.clone(),n._dataCoords=this._dataCoords,n._count=this._count,n}cloneEmpty(t){return new e(this._options)}getMaxCoords(){return this._maxCoords||null}get[Symbol.toStringTag](){let e=``,t=this.getCoords();if(t){let 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}]`}};Xc||={};var Zc=12,Qc=[-1,-1,null],$c=Object.seal({done:!1,value:[-1,null]}),el=Object.seal({done:!1,value:[-1,null]}),tl={bounds:{min:-1,max:-1},reverse:!1,processSkip:null,reuseResult:$c},nl={bounds:{min:-1,max:-1},reverse:!1,processSkip:null,reuseResult:el},rl=(e,t,n,r,i,a)=>(e.bounds.min=t,e.bounds.max=n,e.reverse=r,e.processSkip=i,e.reuseResult=a,e),il=()=>({majorIndex:-1,minorIndex:-1,value:null,active:!1,nextMinorIndex:-1,nextActive:!1,nextMinorValue:null,minorIterator:null,nextMajorCursor:null,prevMajorCursor:null}),al=[`blank`,`false`,`true`,`int32`,`float64`,`string`,`error`,`rich`],ol=n.isLittleEndian,sl=n.isSharedArrayBufferSupported,cl=class e{constructor(e,t=null){this._v=null;let n=e.length,r=e.width,i=e.hasTypes,a=e.defaultType,o=e.buffer,s=e.byteOffset??0,c=i?e.hasSlots:!(7>>>a&1),l=+(r===8);this._l=n,this._w=r,this._sh=l,this._lo=l!==1||ol?0:1,this._dt=a,this._m=i?e.typeMask:1<<a,this._buf=o,this._o=s,this._vi=new Int32Array(o,s,c?n<<l:0),this._vf=c&&l===1?new Float64Array(o,s,n):null,this._t=i?new Uint8Array(o,s+(c?n*r:0),n):null,this._c=t,i||(this.at=dl[a])}at(e){if(!(e>>>0>=this._l))switch(this._t[e]){case 3:return this._vi[(e<<this._sh)+this._lo];case 4:return this._vf[e];case 5:return this._c.decodeString(this._vi[(e<<this._sh)+this._lo]);case 0:return null;case 2:return!0;case 1:return!1;case 6:return this._c.decodeError(this._vi[(e<<this._sh)+this._lo]);case 7:return this._c.decodeRich(this._vi[(e<<this._sh)+this._lo])}}typeAt(e){if(e>>>0>=this._l)return-1;let t=this._t;return t?t[e]:this._dt}get typeMask(){return this._m}getViews(){return this._v??=Object.freeze({types:this._t,defaultType:this._dt,ints:this._vi,doubles:this._vf,intShift:this._sh,intOffset:this._lo})}get length(){return this._l}get isIList(){return!0}fromArray(e){return new vo.ArrayList(e)}get width(){return this._w}get codec(){return this._c}get isShared(){return sl&&this._buf instanceof SharedArrayBuffer}toArray(e=2**53-1){let t=Math.min(e,this._l),n=Array(t);for(let e=0;e<t;e++)n[e]=this.at(e);return n}getHandle(){return{buffer:this._buf,...this._o===0?null:{byteOffset:this._o},length:this._l,width:this._w,defaultType:this._dt,typeMask:this._m,hasTypes:this._t!==null,hasSlots:this._vi.length>0}}get[Symbol.toStringTag](){return`[MixedTypedArrayList]`}toString(){return`{${8*this._w}${this._t?``:`:${al[this._dt]}`}${this.isShared?`:shared`:``}}:${this._l}`}static get isSharedSupported(){return sl}static fromArray(t,n=null,r){let i=r?.length??t.length,a=r?.seen??0,o=null;if(a===0){o=new Uint8Array(i);for(let e=0;e<i;e++){let r=ul(t[e],n);o[e]=r,a|=1<<r}}if(i===0&&(a=1),256&a||n===null&&224&a||128&a&&!n.encodeRich)return null;let s=16&a?8:4,c=+(s===8),l=c!==1||ol?0:1,u=!(a&a-1),d=u?31-Math.clz32(a):0,f=!u,p=!!(-8&a),m=p?i*s:0,h=ll(m+(f?i:0),!0===r?.shared),g=new Int32Array(h,0,p?i<<c:0),_=p&&c===1?new Float64Array(h,0,i):null;if(u)switch(d){case 3:for(let e=0;e<i;e++)g[(e<<c)+l]=t[e];break;case 4:for(let e=0;e<i;e++)_[e]=t[e];break;case 5:for(let e=0;e<i;e++)g[(e<<c)+l]=n.encodeString(t[e]);break;case 6:for(let e=0;e<i;e++)g[(e<<c)+l]=n.encodeError(t[e]);break;case 7:for(let e=0;e<i;e++)g[(e<<c)+l]=n.encodeRich(t[e])}else{let e=new Uint8Array(h,m,i);o&&e.set(o);for(let r=0;r<i;r++){let i=t[r];switch(o?e[r]:e[r]=ul(i,n)){case 3:g[(r<<c)+l]=i;break;case 4:_[r]=i;break;case 5:g[(r<<c)+l]=n.encodeString(i);break;case 6:g[(r<<c)+l]=n.encodeError(i);break;case 7:g[(r<<c)+l]=n.encodeRich(i)}}}return new e({buffer:h,length:i,width:s,defaultType:d,typeMask:a,hasTypes:f,hasSlots:p},n)}static fromEncoded(t,n,r=null,i){let a=i?.length??t.length,o=i?.seen??0;if(o===0)for(let e=0;e<a;e++)o|=1<<t[e];a===0&&(o=1);let s=16&o?8:4,c=+(s===8),l=c!==1||ol?0:1,u=!(o&o-1),d=u?31-Math.clz32(o):0,f=!u,p=!!(-8&o),m=p?a*s:0,h=ll(m+(f?a:0),!0===i?.shared);if(f&&new Uint8Array(h,m,a).set(t.length===a?t:t.subarray(0,a)),p){let e=new Int32Array(h,0,a<<c);if(c===1){let r=new Float64Array(h,0,a);for(let i=0;i<a;i++)t[i]===4?r[i]=n[i]:e[(i<<1)+l]=n[i]}else for(let t=0;t<a;t++)e[t]=n[t]}return new e({buffer:h,length:a,width:s,defaultType:d,typeMask:o,hasTypes:f,hasSlots:p},r)}};(cl||={}).Type={Blank:0,False:1,True:2,Int32:3,Float64:4,String:5,Error:6,Rich:7};var ll=(e,t)=>t&&sl?new SharedArrayBuffer(e):new ArrayBuffer(e),ul=(e,t)=>typeof e==`number`?(0|e)===e?3:4:typeof e==`string`?5:e==null?0:!0===e?2:!1===e?1:typeof e==`object`&&t!==null&&t.isError(e)?6:typeof e==`object`&&t?.isRich?.(e)?7:8,dl=[function(e){return e>>>0<this._l?null:void 0},function(e){return!(e>>>0<this._l)&&void 0},function(e){return e>>>0<this._l||void 0},function(e){return e>>>0<this._l?this._vi[(e<<this._sh)+this._lo]:void 0},function(e){return e>>>0<this._l?this._vf[e]:void 0},function(e){return e>>>0<this._l?this._c.decodeString(this._vi[(e<<this._sh)+this._lo]):void 0},function(e){return e>>>0<this._l?this._c.decodeError(this._vi[(e<<this._sh)+this._lo]):void 0},function(e){return e>>>0<this._l?this._c.decodeRich(this._vi[(e<<this._sh)+this._lo]):void 0}];function fl(e){let t=e??j.getActive(),n=j.getPacks(e).filter(vl),r=yl.get(t);if(r&&function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(r.packs,n))return r.merged;let i=function(e,t){if(t.length===0)return;let n={},r={},i,a,o=[],s=!1,c=!1;for(let e of t)e.functions&&(Object.assign(n,e.functions),s=!0),e.errors&&(Object.assign(r,e.errors),c=!0),e.booleans&&(i={...i??{},...e.booleans}),e.specifiers&&(a={...a??{},...e.specifiers}),e.functionHelp&&o.push(e.functionHelp);let l={tag:e};return s&&(l.functions=n),c&&(l.errors=r),i&&(l.booleans=i),a&&(l.specifiers=a),o.length===1?l.functionHelp=o[0]:o.length>1&&(l.functionHelp=()=>Promise.all(o.map(e=>e())).then(e=>{let t=e=>e&&typeof e==`object`&&`default`in e;return{default:Object.assign({},...e.map(e=>t(e)?e.default:e)),enums:Object.assign({},...e.map(e=>t(e)?e.enums:void 0))}})),l}(t,n);return yl.set(t,{packs:n,merged:i}),i}var pl={};for(let[e,t]of Object.entries(V.Code))pl[t]=e;function ml(e,t){let n=fl(t)?.booleans;return e?n?.true??`TRUE`:n?.false??`FALSE`}function hl(e,t){let n=e?.getLabel?.()??V.Label.Unknown,r=e?.getCode?.(),i=r===void 0?void 0:pl[r];return(i&&fl(t)?.errors?.[i])??n}function gl(e,t){let n=e.toUpperCase();if(n===`TRUE`)return!0;if(n===`FALSE`)return!1;let r=fl(t)?.booleans;if(r){if(r.true&&n===r.true.toUpperCase())return!0;if(r.false&&n===r.false.toUpperCase())return!1}}function _l(e,t){let n=e.toUpperCase(),r=V.getBuiltInByLabel(n);if(r)return r;let i=fl(t)?.errors;if(i){for(let e in i)if(i[e]?.toUpperCase()===n)return V.BuiltIn[e]}}function vl(e){return!!(e.functions&&Object.keys(e.functions).length>0||e.errors&&Object.keys(e.errors).length>0||e.booleans||e.specifiers||e.functionHelp)}var yl=new Map,bl={"chart.renderingNotSupported":`''{type}'' rendering is not supported yet.`,"chart.waterfall.decrease":`Decrease`,"chart.waterfall.increase":`Increase`,"chart.waterfall.total":`Total`,"condition.anySelector":`Any`,"condition.error.boundsRequired":`Enter both a minimum and a maximum`,"condition.error.boundsReversed":`The maximum must be greater than or equal to the minimum`,"condition.error.dateRequired":`Enter a date`,"condition.error.formulaInvalid":`The formula is not valid`,"condition.error.formulaRequired":`Enter a formula`,"condition.error.listRequired":`Enter the list items or a range`,"condition.error.numberRequired":`Enter a number`,"condition.error.operandRequired":`Enter a value`,"condition.error.periodRequired":`Choose a time period`,"condition.error.stdDevs":`Enter a whole number of standard deviations, 0 or more`,"condition.error.textLength":`Enter a whole number of characters, 0 or more`,"condition.error.textRequired":`Enter the text to look for`,"condition.error.timeRequired":`Enter a time`,"condition.error.topNItems":`Enter a number of items from 1 to 1000`,"condition.error.topNPercent":`Enter a percent from 1 to 100`,"condition.error.wholeNumber":`Enter a whole number`,"condition.operator.after.title":`After`,"condition.operator.afterEqualTo.title":`After or On`,"condition.operator.and.desc":`Checks if all params are met`,"condition.operator.and.title":`And`,"condition.operator.average.desc":`Check if value is above or below the average`,"condition.operator.average.title":`Average`,"condition.operator.average.toString":`{dir, select, above{{eq, select, yes{Above or Equal} other{Above}}} other{{eq, select, yes{Below or Equal} other{Below}}}} Average{stdDevs, plural, =0{} one{ (# Std Dev)} other{ (# Std Devs)}}`,"condition.operator.before.title":`Before`,"condition.operator.beforeEqualTo.title":`Before or On`,"condition.operator.between.desc":`Check if value is between 2 numbers`,"condition.operator.between.title":`Between`,"condition.operator.between.toString":`Between {from} and {to}`,"condition.operator.blank.title":`Blank`,"condition.operator.color.desc":`Check if value has a specific color`,"condition.operator.color.title":`Color`,"condition.operator.equalTo.title":`Equal To`,"condition.operator.error.title":`Error`,"condition.operator.expression.desc":`Evaluates a formula expression against the value of the cell`,"condition.operator.expression.title":`Formula`,"condition.operator.greaterThan.title":`Greater Than`,"condition.operator.greaterThanEqualTo.title":`Greater Than or Equal To`,"condition.operator.icon.desc":`Check if value has a matching icon`,"condition.operator.icon.title":`Icon`,"condition.operator.inSet.dateGroups":`{title} {count, plural, one{# Date Group} other{# Date Groups}}`,"condition.operator.inSet.desc":`Check if value is any of a set of values`,"condition.operator.inSet.items":`{title} {count, plural, one{# Item} other{# Items}}`,"condition.operator.inSet.title":`List`,"condition.operator.lessThan.title":`Less Than`,"condition.operator.lessThanEqualTo.title":`Less Than Or Equal To`,"condition.operator.not.desc":`Check if value does not meet a condition`,"condition.operator.not.title":`Not`,"condition.operator.not.toString":`{title} {condition}`,"condition.operator.or.desc":`Checks if any params are met`,"condition.operator.or.title":`Or`,"condition.operator.textContains.title":`Contains`,"condition.operator.textEmail.title":`Is Email`,"condition.operator.textEndsWith.title":`Ends With`,"condition.operator.textIsUrl.title":`Is URL`,"condition.operator.textMatches.title":`Matches`,"condition.operator.textStartsWith.title":`Starts With`,"condition.operator.timePeriod.desc":`Check if value falls within a time period`,"condition.operator.timePeriod.title":`Time Period`,"condition.operator.timePeriod.toString":`{title} {period}`,"condition.operator.titleWithParam":`{title} {param}`,"condition.operator.topN.desc":`Check if value is in the top or bottom N`,"condition.operator.topN.title":`Top N`,"condition.operator.topN.toString":`{edge, select, top{Top} other{Bottom}} {limit} {unit, select, percent{Percent} sum{Sum} other{Items}}`,"condition.operator.unique.desc":`Check if value is unique`,"condition.operator.unique.title":`Unique`,"condition.selector.date.desc":`The date portion of a date time`,"condition.selector.date.title":`Date`,"condition.selector.dateTime.desc":`DateTime`,"condition.selector.dateTime.title":`Date Time`,"condition.selector.display.desc":`The text a cell shows`,"condition.selector.display.title":`Display`,"condition.selector.logical.desc":`Logical`,"condition.selector.logical.title":`Logical`,"condition.selector.number.desc":`Number`,"condition.selector.number.title":`Number`,"condition.selector.ruleDescription":`{title} Rule`,"condition.selector.text.desc":`Text`,"condition.selector.text.title":`Text`,"condition.selector.textLength.desc":`The length of text`,"condition.selector.textLength.title":`Text Length`,"condition.selector.time.desc":`The time portion of a date time`,"condition.selector.time.title":`Time`,"condition.selector.whole.desc":`The whole portion of a number`,"condition.selector.whole.title":`Whole`,"condition.selectorWithOperator":`{selector}: {operator}`,"copy.columnCopy":`Column Copy`,"copy.columnHeaders":`Column Headers`,"copy.drawings":`Drawings`,"copy.rowCopy":`Row Copy`,"copy.rowHeaders":`Row Headers`,"error.address.externalReference":`External references are not supported in a range address.`,"error.address.invalidAddress":`Invalid cell address: {address}`,"error.address.invalidAddressCoords":`Invalid cell address: invalid coords`,"error.address.invalidArguments":`Invalid arguments.`,"error.address.invalidCell":`Invalid cell.`,"error.address.invalidRange":`Invalid range. The Range must be at a size of at least 1x1.`,"error.address.invalidRangeAddress":`Invalid address. Can not parse ''{address}'' as an address or named item.`,"error.address.invalidRangeAddressAny":`Invalid address. Can not parse as an address or named item.`,"error.address.invalidRangeCoords":`Invalid range. All points must be valid integers.`,"error.address.invalidRangeEmpty":`Invalid range.`,"error.address.invalidRangeHeader":`Invalid header range.`,"error.address.invalidRangeInverted":`Invalid range. The Range must be specified as '{ TOP_LEFT:BOTTOM_RIGHT }'.`,"error.address.invalidRangeRelative":`Invalid address. Relative ranges as not allowed: {address}`,"error.address.noAddress":`Must specify an address.`,"error.address.noRange":`Must specify a range.`,"error.address.noTableAtActiveCell":`''{address}'' names no table and the active cell is not in one.`,"error.address.notAnAddress":`Invalid address ''{address}''. An address is an A1 string like ''A1:C3'', or rowStart, colStart, rowEnd and colEnd, zero-based.`,"error.address.removeDuplicatesColumn":`Invalid column ''{column}''. The column must be within the range.`,"error.address.removeDuplicatesNoData":`Can not remove duplicates. The range does not contain any data.`,"error.address.singleCellOnly":`Only a single cell is allowed.`,"error.address.singleRangeOnly":`Only a single range is allowed for this operation.`,"error.address.singleRangeOnlyAlt":`Only a single range is allowed for this operation. Use ''getRanges'' instead.`,"error.address.tableColumnNotFound":`Table ''{table}'' has no column ''{column}''.`,"error.address.tableNotFound":`No table is named ''{name}''.`,"error.address.tableSectionHidden":`''{address}'' refers to a header or total row that table ''{table}'' does not show.`,"error.address.textToColumnsMulti":`The range must be a single column range.`,"error.address.textToColumnsOverwrite":`The destination range has data.`,"error.address.thisRowNotInTable":`''{address}'' needs the active cell in a data row of table ''{table}''.`,"error.anchor.protected":`Unable to {description}. The item is protected.`,"error.cellControl.noType":`A cell control needs a type, such as checkbox.`,"error.chart.noData":`The selection holds no cells to chart.`,"error.chart.notValidForType":`''{type}'' is not valid here for this chart.`,"error.chart.pivotNotEditable":`A pivot chart changes with its pivot table and cannot be edited directly yet.`,"error.chart.stockSeries":`A ''{type}'' chart is made of {count} series: {order}, in that order.`,"error.chart.typeNotEditable":`A chart of type ''{type}'' cannot be edited yet.`,"error.chart.typeNotSupported":`A new chart of type ''{type}'' is not supported yet.`,"error.comment.addOnSheet":`Comments are added on a sheet, not on the workbook.`,"error.comment.cellHasComment":`The cell already has a comment.`,"error.comment.replyDeleted":`The reply has been deleted.`,"error.comment.singleCell":`A comment is added to a single cell.`,"error.condition.unsupportedOperator":`The ''{operator}'' operator can not be evaluated.`,"error.function.builtInName":`''{name}'' is a built-in function. Choose a different name.`,"error.hyperlink.fromValue":`The link is the cell's value; change its formula to remove it.`,"error.hyperlink.invalidHyperlink":`Invalid hyperlink`,"error.hyperlink.notAttached":`The hyperlink is not attached to a cell`,"error.io.encryptionUnavailable":`Password protection is not available, so this workbook cannot be saved with a password.`,"error.io.openElsewhere":`Unable to save to ''{name}'' — it is open in another workbook. Close it there first, or save under a different name.`,"error.io.passwordIncorrect":`The password is incorrect.`,"error.io.passwordRequired":`''{name}'' is password protected. A password is required to open it.`,"error.io.passwordRequiredSave":`''{name}'' is password protected. Supply the password to save it, or save it without protection.`,"error.io.passwordRequiredSaveUnnamed":`This file is password protected. Supply the password to save it, or save it without protection.`,"error.io.passwordRequiredUnnamed":`This file is password protected. A password is required to open it.`,"error.io.readFailed":`Unable to read {format} — {reason}`,"error.io.readFormatUnavailable":`Unable to open ''{format}'' — that file type is not supported.`,"error.io.writeFailed":`Unable to save the workbook — {reason}`,"error.io.writeFormatMismatch":`Unable to save ''{file}'' as ''{format}'' — its extension is for a different file type. Save a copy with a new file name instead.`,"error.io.writeFormatUnavailable":`Unable to save as ''{format}'' — that file type is not supported.`,"error.io.writeFormatUnresolved":`Unable to determine the file type to save as. Choose a file type, or use a file name with a known extension.`,"error.model.modelClosed":`Model has been closed. No further operations are allowed.`,"error.model.nameRequired":`Name is required`,"error.movable.groupNotHere":`Only drawings of this sheet can be grouped together.`,"error.movable.groupNotSameGroup":`Only drawings of the same group can be grouped together.`,"error.movable.groupTooFew":`Select two or more drawings to group.`,"error.movable.groupWholeGroup":`These drawings are already a group.`,"error.named.containsSpaces":`Name must not contain any spaces.`,"error.named.invalidFirstChar":`First letter must be either a letter, an underscore, or a backslash.`,"error.named.invalidInvalidCellAddress":`Name can not be an address.`,"error.named.invalidSpecialRC":`Name can not be 'r' or 'c'.`,"error.named.invalidTrailingChar":`Name must be either letters, numbers, periods or underscores.`,"error.named.nameEmpty":`Name must be a non-empty string`,"error.named.nameExists":`''{name}'' already exists.`,"error.named.nameExistsInScope":`''{name}'' already exists in ''{scope}''.`,"error.named.nameMaxLength":`Name must not exceed 255 characters.`,"error.named.nameReadonly":`Names are read-only.`,"error.named.templateRequired":`A template string must be specified.`,"error.outline.axisRequired":`Specify whether to use rows or columns: the range is neither entire rows nor entire columns.`,"error.outline.cannotCreate":`Cannot create an outline: no formula totals the cells beside it.`,"error.outline.invalidSummaryDirection":`{direction} is not a summary direction for {axis}s.`,"error.outline.sheetProtected":`The sheet is protected. Unprotect it to change its outline.`,"error.outline.tooDeep":`Groups can be nested no more than {max} levels deep.`,"error.pageLayout.breakBeforeFirstColumn":`A page break cannot come before the first column.`,"error.pageLayout.breakBeforeFirstRow":`A page break cannot come before the first row.`,"error.pageLayout.invalidFitToPages":`The pages to fit to must be between 0 and 32767, not {pages}.`,"error.pageLayout.invalidMargin":`The {margin} margin cannot be {value}.`,"error.pageLayout.invalidPaperSize":`{paperSize} is not a paper size.`,"error.pageLayout.invalidScale":`The print scale must be between 10 and 400, not {scale}.`,"error.pageLayout.titleColumnsNotEntire":`Print title columns must be entire columns.`,"error.pageLayout.titleRowsNotEntire":`Print title rows must be entire rows.`,"error.pageLayout.zoomScaleAndFit":`Set either a print scale or the pages to fit to, not both.`,"error.pivotTable.addOnSheet":`Add a PivotTable to a sheet's PivotTables.`,"error.pivotTable.changePart":`Can't change this part of a PivotTable.`,"error.pivotTable.clearPart":`Can't clear part of a PivotTable. Clear all of it to delete it.`,"error.pivotTable.destinationOccupied":`Can't place a PivotTable over cells that hold values.`,"error.pivotTable.fieldNameExists":`A PivotTable field with this name already exists.`,"error.pivotTable.fieldNotPlaceable":`The field you are moving cannot be placed in that PivotTable area.`,"error.pivotTable.fieldPosition":`That position is not on the field's axis.`,"error.pivotTable.filterNotOnAxis":`Only a row or column field can be filtered by label, date or value.`,"error.pivotTable.formula":`Can't enter a formula in a PivotTable.`,"error.pivotTable.hideAllItems":`A field must show at least one item.`,"error.pivotTable.itemNameExists":`An item of this field already has this name.`,"error.pivotTable.itemNotPlaced":`Only an item that shows, of a field on the PivotTable, can be moved.`,"error.pivotTable.itemPosition":`That position is not among the field's items that show.`,"error.pivotTable.labelAndDateFilter":`A field takes a label filter or a date filter, not both.`,"error.pivotTable.moveToSheet":`Moving a PivotTable to another sheet is not supported yet.`,"error.pivotTable.nameExists":`A PivotTable with this name is already on this sheet.`,"error.pivotTable.nameInvalid":`A PivotTable name must be 1 to 255 characters long.`,"error.pivotTable.notADataField":`''{name}'' is not a value field of this PivotTable.`,"error.pivotTable.notAField":`''{name}'' is not a field of this PivotTable's source.`,"error.pivotTable.notAForm":`''{form}'' is not a PivotTable layout.`,"error.pivotTable.notAFunction":`''{name}'' is not a function a PivotTable value can use.`,"error.pivotTable.notAnItem":`''{name}'' is not an item of this field.`,"error.pivotTable.notANumberFormat":`''{name}'' is not a number format.`,"error.pivotTable.notAShowAs":`''{name}'' is not a way to show a PivotTable value.`,"error.pivotTable.notASubtotal":`''{name}'' is not a subtotal a PivotTable field can show.`,"error.pivotTable.notExpandable":`Only the items of a row or column field can be expanded or collapsed, and a whole field only when another field is inside it.`,"error.pivotTable.notModeled":`This PivotTable cannot be refreshed yet.`,"error.pivotTable.notPageField":`This field is not a filter of the PivotTable.`,"error.pivotTable.notSortable":`Only a row or column field can be sorted.`,"error.pivotTable.numberFormatOnText":`Only a PivotTable field of numbers or dates takes a number format.`,"error.pivotTable.optionsNotModeled":`This PivotTable's options can't be changed yet.`,"error.pivotTable.overlapsPivot":`There's already a PivotTable here. Make space and try again.`,"error.pivotTable.overlapsTable":`A PivotTable can't overlap a table.`,"error.pivotTable.refreshSourceTooSmall":`This command requires at least two rows of source data.`,"error.pivotTable.refreshSourceUnsupported":`This PivotTable cannot be refreshed from its source: the source is not in this workbook, or the cache has calculated fields. Refresh it from its cache with source: false.`,"error.pivotTable.shiftPartial":`This change would move part of a PivotTable. Move the PivotTable and try again.`,"error.pivotTable.sortScope":`A sort's scope must name a line of the other axis that shows.`,"error.pivotTable.sourceNotFound":`This PivotTable's source is not a range, table or name in this workbook.`,"error.pivotTable.sourceOverlapsTable":`A PivotTable can't summarize its own cells.`,"error.pivotTable.sourceSharedSlicer":`The data source of a PivotTable connected to slicers that are also connected to other PivotTables can't be changed. Disconnect the slicers from this PivotTable or from the others first.`,"error.pivotTable.styleNotModeled":`This PivotTable's style can't be changed yet.`,"error.pivotTable.subtotalsOnCalculatedField":`A calculated field has no subtotals.`,"error.pivotTable.subtotalsOnCalculatedItems":`Calculated items do not work with custom subtotals.`,"error.pivotTable.topNNeedsDataField":`A top or bottom filter needs a value field.`,"error.pivotTable.valuePosition":`That position is not among the PivotTable's values.`,"error.pivotTable.valuesNotAnAxis":`Add a value field to summarize a field in the values.`,"error.protectedRange.noName":`Protected range must have a name.`,"error.protectedRange.uniqueName":`A protected range named ''{name}'' already exists.`,"error.sheet.addressInvalidScope":`When using addresses directly from the sheet do not include the sheet name.`,"error.sheet.arrayFixedFormula":`An array formula must be a single formula.`,"error.sheet.autofillInvalidDestination":`AutoFill destination ({destination}) must extend or shrink the source range ({template}) in a single direction.`,"error.sheet.autofillMultiple":`When filling with merged cells the amount to fill must be a multiple of the input range [{modulus}].`,"error.sheet.autofillOverlapMerge":`Unable to partially fill over merged cells.`,"error.sheet.changePartOfArray":`You can't change part of an array.`,"error.sheet.clearUnsupported":`Unsupported clear type: {type}`,"error.sheet.copyInvalidSource":`Unable to determine source.`,"error.sheet.copyMissingArgs":`Both a source and a destination are required to copy.`,"error.sheet.copyMultipleRanges":`Multiple selection ranges can not be copied.`,"error.sheet.copyNoSource":`The source has no range.`,"error.sheet.deleteOob":`We can't delete these cells because the change would move something outside the worksheet.`,"error.sheet.deleteOverlapping":`We can't delete cells with overlapping selections.`,"error.sheet.emptyView":`View can not be empty.`,"error.sheet.insertCopyMultipleRanges":`Only a single selection is supported when using 'Insert Copy'.`,"error.sheet.insertCutInside":`We can't paste the cut cells inside the cut area itself.`,"error.sheet.insertCutOverlap":`We can't paste here because the insert would move only part of the cut area. Line the two areas up, or paste clear of the cut area.`,"error.sheet.insertItemOob":`We can't insert cells because this would push items off the end of the worksheet.`,"error.sheet.insertItemProtected":`We can't insert items. The sheet is protected.`,"error.sheet.insertMergeThrough":`We can't insert through merges. Unmerge and try again.`,"error.sheet.insertOob":`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.`,"error.sheet.insertOobFreeze":`We can't insert cells because this would push the frozen panes off the end of the worksheet. Unfreeze the panes and try again.`,"error.sheet.insertOverlapping":`We can't insert cells with overlapping selections.`,"error.sheet.invalidCellType":`Invalid cell type: {type}. See documentation for information on valid built in cell types and creating custom cell types.`,"error.sheet.invalidScopedRangeAddress":`Invalid sheet address. Can not parse ''{address}'' as a sheet address or items scope to ''{scope}''. Sheet address must not include the sheet name.`,"error.sheet.invalidScopedRangeArguments":`Invalid sheet address. Can not parse arguments as a sheet address or items scope to ''{scope}''. Sheet address must not include the sheet name.`,"error.sheet.itemOverlapping":`We can't create a {type} that overlaps with another table or merge.`,"error.sheet.iteratorClosed":`IteratorContext can only be used during visit.`,"error.sheet.listenerNull":`Listener can not be null`,"error.sheet.maxValues":`{address} is {count} cells; a read returns at most {max}. Work on it inside the engine instead of copying it out: return the range itself for a profiled summary, ''getRegions()'' to split it into its blocks, ''getValuesRange()'' to filter, sort or compute over it as an IRange (''setComputedValues(fn)'' writes the result back), or ''forEach(callback)'' to visit each cell without building an array. The sheetxl skill covers these in references/reading.md and references/vector.md. Last resort: a larger maxSize option on getValues copies more out.`,"error.sheet.mergeMultipleValues":`Merging cells would cause some values to be discarded. Use 'discardMultipleValues' option if desired.`,"error.sheet.mergeOob":`We can't merge outside of the maximum cell location.`,"error.sheet.mergeOverlapping":`Overlapping ranges can not be merged.`,"error.sheet.modelClosed":`Sheet has been closed. No further operations are allowed.`,"error.sheet.modelDelete":`Unable to delete.`,"error.sheet.noImageProvided":`An image must be provided as a string or a resource option.`,"error.sheet.oobCell":`The cell is outside of the bounds of the range.`,"error.sheet.oobRange":`The range is outside of the bounds of the sheet.`,"error.sheet.paste":`Unable to paste: {message}`,"error.sheet.pasteMergePartial":`We can't do that to a merged cell.`,"error.sheet.pasteOob":`We can't paste outside of the sheet bounds.`,"error.sheet.previewRange":`This range is an autoFill preview and cannot be modified. Run 'autoFill' without 'preview' to apply it.`,"error.sheet.promiseCellValue":"Invalid cell value: got a Promise — did you forget `await`? (e.g. `await wb.evaluate('=…')`)","error.sheet.protectedField":`Unable to {description}, this sheet is protected. To make a change, unprotect the sheet. You might be requested to enter a password.`,"error.sheet.protectedRangeLocked":`This range is protected with a password. Enter the password to make a change.`,"error.sheet.protectedSheet":`This sheet is protected. To make a change, unprotect the sheet. You might be requested to enter a password.`,"error.sheet.readonlyRange":`Readonly sheet`,"error.sheet.readonlySheet":`Unable to {description}, this sheet is readonly.`,"error.sheet.setValuesType":`'setValues' expects a 2d array; when working with a single value use 'setValue'.`,"error.sheet.setValueType":`'setValue' expects a single value; when working with an array use 'setValues'.`,"error.sheet.snapshotDone":`Unable to use a snapshot multiple times.`,"error.sheet.sortMergeSize":`Unable to sort merged cells unless they are all the same size.`,"error.sheet.table1By1":`A table must have a least two rows; one for the table header and one for data.`,"error.sheet.tableEmpty":`An autotable must have data to be created.`,"error.sheet.uniqueName":`Name must be unique: ''{name}'' is already in use.`,"error.sheet.unmergeOverlapping":`We can't unmerge intersecting ranges.`,"error.sheet.unmergePartial":`We can't unmerge partial cells.`,"error.sheet.unsupportedFloatingType":`Unsupported float type: {type}`,"error.sheetHeader.protectedColumns":`The columns are protected. To make a change, unprotect the sheet. You might be requested to enter a password.`,"error.sheetHeader.protectedRows":`The rows are protected. To make a change, unprotect the sheet. You might be requested to enter a password.`,"error.slicer.nameTaken":`A slicer named ''{name}'' already exists.`,"error.slicer.noColumn":`The table has no column ''{name}''.`,"error.slicer.noField":`The PivotTable has no field ''{name}''.`,"error.slicer.pivotSortOrder":`A slicer on a PivotTable can't list its items in data source order.`,"error.sort.sortOobRange":`The sort offset is outside of the bounds of the sort.`,"error.sparkline.count":`The data must have one row, or one column, for each sparkline.`,"error.sparkline.data":`The sparkline data is not a valid range.`,"error.sparkline.data2D":`A single sparkline needs data in one row or one column.`,"error.sparkline.location":`Sparklines go in one cell, or in one row or one column of cells.`,"error.sparkline.location2D":`Sparklines go in one cell, or in one row or one column of cells.`,"error.sparkline.property":`''{value}'' is not a valid value for the sparkline property ''{name}''.`,"error.sparkline.structured":`Sparkline data cannot be a table reference. Use the cells it names.`,"error.sparkline.transposed":`A row of sparklines needs a column of data for each, and a column of sparklines a row for each.`,"error.sparkline.union":`Sparkline data must be one range of cells.`,"error.table.autoTableInvalidOperation":`That operation is not valid for an AutoTable.`,"error.table.columnValuesNotArray":`Column values must be a one-dimensional array.`,"error.table.columnValuesOverflow":`{count} values were provided but the table has only {max} rows.`,"error.table.convertToRangeLimit":`The table has {count} cells, which is more than the limit of {max}.`,"error.table.tableBodyRows":`Select rows within the table body.`,"error.table.tableNoBody":`A table must have a least one row and one column for the data.`,"error.table.tableNoName":`Table must have a name.`,"error.table.tableRemoveHeader":`We can not remove rows that contain table headers. Remove the table header.`,"error.table.tableResizeInvalidBounds":`The top of the table must not change and the new table location must overlap with the original table.`,"error.table.tableSplit":`We can not partially insert or remove cells as this would split a table.`,"error.workbook.deleteKey":`Invalid reference for delete: {key}`,"error.workbook.invalidId":`Invalid id: {id}`,"error.workbook.invalidLocale":`Invalid locale: ''{locale}''. Expected a BCP 47 tag such as ''de-DE''.`,"error.workbook.invalidSheetKey":`Invalid SheetKey: {key}`,"error.workbook.modelClosed":`Workbook has been closed. No further operations are allowed.`,"error.workbook.nameDuplicate":`The sheet name ''{sheetName}'' already exist in workbook.`,"error.workbook.nameTaken":`That name is already taken. Try a different one.`,"error.workbook.notSetValue":`A value must be provided.`,"error.workbook.noVisibleRefs":`Internal error no visible sheetRefs`,"error.workbook.noWorksheet":`The workbook has no worksheet.`,"error.workbook.protection":`This workbook structure is protected. To make a change, unprotect the workbook. You might be requested to enter a password.`,"error.workbook.selectedIsChart":`The active sheet ''{sheetName}'' is a chart sheet, not a worksheet. Name a worksheet, or select one first.`,"error.workbook.selectedIsDialog":`The active sheet ''{sheetName}'' is a dialog sheet, not a worksheet. Name a worksheet, or select one first.`,"error.workbook.selectedIsMacro":`The active sheet ''{sheetName}'' is an Excel 4.0 macro sheet, not a worksheet. Name a worksheet, or select one first.`,"error.workbook.sheetIndexNotFound":`No sheet found at {index}.`,"error.workbook.sheetIsChart":`''{sheetName}'' is a chart sheet, not a worksheet. It has no cells.`,"error.workbook.sheetIsDialog":`''{sheetName}'' is a dialog sheet, not a worksheet. It has no cells.`,"error.workbook.sheetIsMacro":`''{sheetName}'' is an Excel 4.0 macro sheet, not a worksheet. Its cells are not loaded.`,"error.workbook.sheetNameBlank":`A sheet name can not be blank.`,"error.workbook.sheetNameInvalidChars":`A sheet name can not contain any of the following characters '\\ , / , * , ? , : , [ , ]'.`,"error.workbook.sheetNameInvalidCharsNamed":`''{sheetName}'' can not contain any of the following characters '\\ , / , * , ? , : , [ , ]'.`,"error.workbook.sheetNameNotFound":`''{sheetName}'' not found.`,"error.workbook.sheetNameNotProvided":`Sheet name not provided. If you are trying to reference the active sheet, use getSelectedWorksheet() instead.`,"error.workbook.sheetNameQuotes":`A sheet name can not begin or end with a "'" (single quote).`,"error.workbook.sheetNameTooLong":`A sheet name can not be longer than 31 characters.`,"error.workbook.sheetNotDuplicable":`''{sheetName}'' can not be duplicated. Only worksheets can.`,"error.workbook.sheetOne":`A workbook must contain at least one visible sheet.`,"error.workbook.sheetPartMissing":`''{sheetName}'' has no content to carry.`,"movable.copySuffix":`{name} (Copy)`,"name.dataValidation":`Data Validation`,"op.addChartTrendline":`Add Trendline`,"op.addColumns":`Add Columns`,"op.addComment":`Add Comment`,"op.addCommentReply":`Reply to Comment`,"op.addDataValidation":`Add Data Validation`,"op.addExternalBook":`Add Link to ''{name}''`,"op.addNamedFormulaNamed":`Add Named Formula ''{name}''`,"op.addPivotDataField":`Add PivotTable Value`,"op.addPivotTable":`Add PivotTable`,"op.addProtectedRange":`Add Protected Range`,"op.addScript":`Add Script`,"op.addSeries":`Add Series`,"op.addSheet":`Add Sheet`,"op.addSheetNamed":`Add Sheet ''{name}''`,"op.addTable":`Add Table`,"op.addTableColumn":`Add Table Column`,"op.addTableColumns":`Add Table Columns`,"op.addTableRow":`Add Table Row`,"op.addTableRows":`Add Table Rows`,"op.applyFilters":`Apply Filters`,"op.applySort":`Apply Sort`,"op.autoFill":`Auto Fill`,"op.autofit":`Autofit`,"op.autofitAll":`Autofit All`,"op.autofitColumns":`Autofit Columns`,"op.autofitRows":`Autofit Rows`,"op.autoOutline":`Auto Outline`,"op.breakExternalLink":`Break Link to ''{name}''`,"op.breakExternalLinks":`Break All Links`,"op.changePivotFieldSettings":`Change PivotTable Field Settings`,"op.changePivotLayout":`Change PivotTable Layout`,"op.changePivotOptions":`Change PivotTable Options`,"op.changePivotSource":`Change PivotTable Data Source`,"op.clear":`Clear`,"op.clearAll":`Clear All`,"op.clearColumnHeaders":`Clear Column Headers`,"op.clearComments":`Clear Comments`,"op.clearDataValidations":`Clear Data Validation`,"op.clearFormats":`Clear Formats`,"op.clearFormulas":`Clear Formulas`,"op.clearHyperlinks":`Clear Hyperlinks`,"op.clearNotes":`Clear Notes`,"op.clearOutline":`Clear Outline`,"op.clearPivotFilters":`Clear PivotTable Filters`,"op.clearRowHeaders":`Clear Row Headers`,"op.clearShapeStyle":`Reset Shape Format`,"op.clearSort":`Clear Sort`,"op.clearSparklines":`Clear Sparklines`,"op.clearStyle":`Clear Style`,"op.clearTables":`Clear Tables`,"op.clearValues":`Clear Values`,"op.collapsePivotItems":`Collapse PivotTable Items`,"op.connectShape":`Connect Shape`,"op.convertToRange":`Convert to Range`,"op.copyImageFromClipboard":`Copy Image from Clipboard`,"op.copyMovable":`Copy Movable`,"op.copyNamed":`Copy {name}`,"op.createAnchoredItem":`Create Anchored Item`,"op.createItem":`Create Item`,"op.createItemNamed":`Create Item ''{name}''`,"op.cutNamed":`Cut {name}`,"op.darkerPercent":`Darker {percent}%`,"op.delete":`Delete`,"op.deleteCellControl":`Delete Cell Control`,"op.deleteCells":`Delete Cells`,"op.deleteChartSeries":`Delete Series`,"op.deleteChartTrendline":`Delete Trendline`,"op.deleteColumnNamed":`Delete Column ''{name}''`,"op.deleteColumns":`Delete Columns`,"op.deleteComment":`Delete Comment`,"op.deleteCommentReply":`Delete Reply`,"op.deleteConditionalFormat":`Delete Conditional Format`,"op.deleteConditionalFormatNamed":`Delete Conditional Format ''{name}''`,"op.deleteDataValidation":`Delete Data Validation`,"op.deleteDataValidationNamed":`Delete Data Validation ''{name}''`,"op.deleteDrawing":`Delete Drawing`,"op.deleteFilter":`Delete Filter`,"op.deleteFilters":`Delete Filters`,"op.deleteModule":`Delete Module`,"op.deleteNamedItem":`Delete Named Item ''{name}''`,"op.deletePicture":`Delete Picture`,"op.deletePivotTable":`Delete PivotTable`,"op.deleteProtectedRange":`Delete Protected Range`,"op.deleteProtectedRangeNamed":`Delete Protected Range ''{name}''`,"op.deleteRows":`Delete Rows`,"op.deleteSheet":`Delete Sheet ''{name}''`,"op.deleteSorts":`Delete Sorts`,"op.deleteSortsAndFilters":`Delete Sorts and Filters`,"op.deleteSparklineGroup":`Delete Sparkline Group`,"op.deleteTableColumn":`Delete Table Column`,"op.deleteTableColumns":`Delete Table Columns`,"op.deleteTableNamed":`Delete Table ''{name}''`,"op.deleteTableRow":`Delete Table Row`,"op.deleteTableRows":`Delete Table Rows`,"op.duplicateNamed":`Duplicate ''{name}''`,"op.editSparklineGroup":`Edit Sparklines`,"op.expandPivotItems":`Expand PivotTable Items`,"op.filter":`Filter`,"op.filterColumn":`Filter {name}`,"op.filterPivotTable":`Filter PivotTable`,"op.filterTable":`Filter Table`,"op.formatPivotDataField":`Format PivotTable Value`,"op.formatPivotStyle":`Change PivotTable Style`,"op.group":`Group`,"op.groupColumns":`Group Columns`,"op.groupDrawings":`Group Drawings`,"op.groupRows":`Group Rows`,"op.hideBandedColumns":`Hide Banded Columns`,"op.hideBandedRows":`Hide Banded Rows`,"op.hideColumns":`Hide Columns`,"op.hideDetail":`Hide Detail`,"op.hideHeaders":`Hide Headers`,"op.hideHighlightFirstColumn":`Hide Highlight First Column`,"op.hideHighlightLastColumn":`Hide Highlight Last Column`,"op.hideRows":`Hide Rows`,"op.hideSheet":`Hide Sheet`,"op.hideTotals":`Hide Totals`,"op.ignoreError":`Ignore Error`,"op.initialize":`Initialize`,"op.initializeCellControl":`Initialize Cell Control`,"op.initializeComment":`Initialize Comment`,"op.initializeConditionalFormat":`Initialize Conditional Format`,"op.initializeDataValidation":`Initialize Data Validation`,"op.initializeProtectedRange":`Initialize Protected Range`,"op.initializeSparklineGroup":`Initialize Sparkline Group`,"op.initializeTable":`Initialize Table`,"op.insertAutoTable":`Insert AutoTable`,"op.insertCellControl":`Insert Cell Control`,"op.insertCells":`Insert Cells`,"op.insertChart":`Insert Chart`,"op.insertColumns":`Insert Columns`,"op.insertConditionalFormat":`Insert Conditional Format`,"op.insertCopiedCells":`Insert Copied Cells`,"op.insertDataValidation":`Insert Data Validation`,"op.insertDrawing":`Insert Drawing`,"op.insertImage":`Insert Image`,"op.insertProtectedRange":`Insert Protected Range`,"op.insertRows":`Insert Rows`,"op.insertSlicer":`Insert Slicer`,"op.insertSparklines":`Insert Sparklines`,"op.insertTable":`Insert Table`,"op.lighterPercent":`Lighter {percent}%`,"op.loadMovable":`Load Movable`,"op.loadSheet":`Load Sheet`,"op.merge":`Merge`,"op.moveBackwards":`Move Backwards`,"op.moveForward":`Move Forward`,"op.movePivotDataField":`Move PivotTable Value`,"op.movePivotField":`Move PivotTable Field`,"op.movePivotItem":`Move PivotTable Item`,"op.movePivotTable":`Move PivotTable`,"op.movePivotValues":`Move PivotTable Values`,"op.moveSheetNamed":`Move Sheet ''{name}''`,"op.moveToBack":`Move to Back`,"op.moveToFront":`Move to Front`,"op.newSheet":`New Sheet`,"op.newWorkbook":`New Workbook`,"op.openWorkbook":`Open Workbook`,"op.paste":`Paste`,"op.pasteNamed":`Paste {name}`,"op.range":`Range`,"op.rangesUpdate":`Ranges Update`,"op.rangeUpdate":`Range Update`,"op.refreshExternalLink":`Refresh Link to ''{name}''`,"op.refreshPivotTable":`Refresh PivotTable`,"op.refreshPivotTables":`Refresh All PivotTables`,"op.refreshSortsAndFilters":`Refresh Sorts and Filters`,"op.removeCellControl":`Remove Cell Control`,"op.removeDuplicates":`Remove Duplicates`,"op.removeExternalBook":`Remove Link to ''{name}''`,"op.removeNamedFormula":`Remove Named Formula`,"op.removePicture":`Remove Picture`,"op.removePivotDataField":`Remove PivotTable Value`,"op.removeScript":`Remove Script`,"op.removeUnusedNames":`Remove {count, plural, one{# Unused Name} other{# Unused Names}}`,"op.renamePivotDataField":`Rename PivotTable Value`,"op.renamePivotField":`Rename PivotTable Field`,"op.renamePivotItem":`Rename PivotTable Item`,"op.renamePivotTable":`Rename PivotTable`,"op.renamePivotValues":`Rename PivotTable Values`,"op.renameSheet":`Rename Sheet`,"op.reopenComment":`Reopen Comment`,"op.reorderConditionalFormat":`Reorder Conditional Format`,"op.reorderDataValidations":`Reorder Data Validations`,"op.reorderProtectedRange":`Reorder Protected Range`,"op.replace":`Replace`,"op.replaceAll":`Replace All`,"op.replaceAllWith":`Replace All with ''{value}''`,"op.replaceAt":`Replace {address}`,"op.replaceAtWith":`Replace {address} with ''{value}''`,"op.replaceWith":`Replace with ''{value}''`,"op.resizeColumns":`Resize Columns`,"op.resizeRows":`Resize Rows`,"op.resizeTable":`Resize Table`,"op.resolveComment":`Resolve Comment`,"op.saveScripts":`Save Scripts`,"op.selectSlicerItems":`Select Slicer Items`,"op.setAlertMessage":`Set Alert Message`,"op.setAlertStyle":`Set Alert Style`,"op.setAlertTitle":`Set Alert Title`,"op.setAlignment":`Set Alignment`,"op.setAlwaysUnlocked":`Set Always Unlocked`,"op.setAngle":`Set Angle`,"op.setAutoExpand":`Set Auto Expand`,"op.setBackgroundColor":`Set Background Color`,"op.setBorders":`Set Borders`,"op.setBottomBorder":`Set Bottom Border`,"op.setBottomBorderColor":`Set Bottom Border Color`,"op.setBottomBorderStyle":`Set Bottom Border Style`,"op.setCellAddress":`Set Cell {address}`,"op.setCellControl":`Set Cell Control`,"op.setChartArea":`Format Chart Area`,"op.setChartAxis":`Format Axis`,"op.setChartAxisTitle":`Format Axis Title`,"op.setChartBlanks":`Hidden and Empty Cells`,"op.setChartCategoryNames":`Edit Axis Labels`,"op.setChartData":`Change Chart Data`,"op.setChartDataLabels":`Format Data Labels`,"op.setChartDataTable":`Format Data Table`,"op.setChartDropLines":`Format Drop Lines`,"op.setChartElement":`Add Chart Element`,"op.setChartErrorBars":`Format Error Bars`,"op.setChartFont":`Set Chart Font`,"op.setChartGridlines":`Format Gridlines`,"op.setChartHiLoLines":`Format High-Low Lines`,"op.setChartLegend":`Format Legend`,"op.setChartLegendEntry":`Format Legend Entry`,"op.setChartMarker":`Format Marker`,"op.setChartPlotArea":`Format Plot Area`,"op.setChartPlotBy":`Switch Row/Column`,"op.setChartPlotVisibleOnly":`Hidden and Empty Cells`,"op.setChartPoint":`Format Data Point`,"op.setChartSeriesAxisGroup":`Change Series Axis`,"op.setChartSeriesData":`Edit Series`,"op.setChartSeriesLines":`Format Series Lines`,"op.setChartSeriesOptions":`Format Series Options`,"op.setChartSeriesOrder":`Move Series`,"op.setChartSeriesStyle":`Format Data Series`,"op.setChartSeriesType":`Change Series Chart Type`,"op.setChartTitle":`Format Chart Title`,"op.setChartTrendline":`Format Trendline`,"op.setChartType":`Change Chart Type`,"op.setChartUpDownBars":`Format Up/Down Bars`,"op.setColumnName":`Set Column Name`,"op.setComment":`Set Comment`,"op.setCommentContent":`Edit Comment`,"op.setComments":`Set Comments`,"op.setComputedValues":`Set Computed Values`,"op.setCondition":`Set Condition`,"op.setControlCaption":`Set Control Caption`,"op.setControlItems":`Set Control Items`,"op.setControlLink":`Set Control Linked Cell`,"op.setControlMacro":`Set Control Macro`,"op.setControlRange":`Set Control Range`,"op.setControlValue":`Set Control Value`,"op.setDiagonalDownBorder":`Set Diagonal Down Border`,"op.setDiagonalDownBorderColor":`Set Diagonal Down Border Color`,"op.setDiagonalDownBorderStyle":`Set Diagonal Down Border Style`,"op.setDiagonalUpBorder":`Set Diagonal Up Border`,"op.setDiagonalUpBorderColor":`Set Diagonal Up Border Color`,"op.setDiagonalUpBorderStyle":`Set Diagonal Up Border Style`,"op.setDisabledColumnFill":`Set Disabled Column Fill`,"op.setEntireSize":`Set Entire Size`,"op.setFill":`Set Fill`,"op.setFillColor":`Set Fill Color`,"op.setFillGradient":`Set Fill Gradient`,"op.setFillNone":`Set Fill None`,"op.setFillPattern":`Set Fill Pattern`,"op.setFillSolid":`Set Fill Solid`,"op.setFocus":`Set Focus`,"op.setFont":`Set Font`,"op.setFontBaseline":`Set Font Baseline`,"op.setFontBold":`Set Font Bold`,"op.setFontColor":`Set Font Color`,"op.setFontFallbacks":`Set Font Fallbacks`,"op.setFontFamily":`Set Font Family`,"op.setFontItalic":`Set Font Italic`,"op.setFontLetterSpacing":`Set Font Letter Spacing`,"op.setFontSize":`Set Font Size`,"op.setFontStrike":`Set Font Strike`,"op.setFontUnderline":`Set Font Underline`,"op.setFontWeight":`Set Font Weight`,"op.setForegroundColor":`Set Foreground Color`,"op.setFormulaBelow":`Set Formula Below`,"op.setGradientType":`Set Gradient Type`,"op.setHidden":`Set Hidden`,"op.setHiddenButtons":`Set Hidden Buttons`,"op.setHiddenDecorations":`Set Hidden Decorations`,"op.setHideDropdown":`Set Hide Dropdown`,"op.setHorizontalAlignment":`Set Horizontal Alignment`,"op.setHorizontalBorder":`Set Horizontal Border`,"op.setHorizontalBorderColor":`Set Horizontal Border Color`,"op.setHorizontalBorderStyle":`Set Horizontal Border Style`,"op.setHyperlink":`Set Hyperlink`,"op.setIncludeBlanks":`Set Include Blanks`,"op.setIndent":`Set Indent`,"op.setIndex":`Set Index`,"op.setJustifyLastLine":`Set Justify Last Line`,"op.setLeftBorder":`Set Left Border`,"op.setLeftBorderColor":`Set Left Border Color`,"op.setLeftBorderStyle":`Set Left Border Style`,"op.setLineEnds":`Set Line Ends`,"op.setLockAspectRatio":`Set Lock Aspect Ratio`,"op.setMovableBounds":`Set Movable Bounds`,"op.setMovableDescription":`Set Movable Description`,"op.setMovableFlip":`Set Movable Flip`,"op.setMovableName":`Set Movable Name`,"op.setMovableResizeBehavior":`Set Movable Resize Behavior`,"op.setMovableRotation":`Set Movable Rotation`,"op.setMovableVisibility":`Set Movable Visibility`,"op.setName":`Set Name`,"op.setNamedStyle":`Set Named Style`,"op.setNumberFormat":`Set Number Format`,"op.setOutlineBorder":`Set Outline Border`,"op.setOverflow":`Set Overflow`,"op.setPatternType":`Set Pattern Type`,"op.setPicture":`Set Picture`,"op.setPictureCrop":`Crop Picture`,"op.setPictureHyperlink":`Link Picture`,"op.setPictureResource":`Change Picture`,"op.setPictureShapeType":`Crop to Shape`,"op.setPictureStyle":`Format Picture`,"op.setPrintObject":`Set Print Object`,"op.setPromptMessage":`Set Prompt Message`,"op.setPromptTitle":`Set Prompt Title`,"op.setProtectedRangeName":`Set Protected Range Name`,"op.setProtectedRangePassword":`Set Protected Range Password`,"op.setProtectedRangePermissions":`Set Protected Range Permissions`,"op.setProtection":`Set Protection`,"op.setQuotePrefix":`Set Quote Prefix`,"op.setRangeAddress":`Set Range {address}`,"op.setRanges":`Set Ranges`,"op.setReadingDirection":`Set Reading Direction`,"op.setRelativeIndent":`Set Relative Indent`,"op.setRightBorder":`Set Right Border`,"op.setRightBorderColor":`Set Right Border Color`,"op.setRightBorderStyle":`Set Right Border Style`,"op.setRotation":`Set Rotation`,"op.setShapeAdjustments":`Set Shape Adjust Values`,"op.setShapeFill":`Set Shape Fill`,"op.setShapeStroke":`Set Shape Outline`,"op.setShapeStyle":`Format Shape`,"op.setShapeType":`Change Shape`,"op.setShowErrorMessage":`Set Show Error Message`,"op.setShowFormulas":`Set Show Formulas`,"op.setShowPromptMessage":`Set Show Prompt Message`,"op.setSlicerCaption":`Set Slicer Caption`,"op.setSlicerLayout":`Set Slicer Layout`,"op.setSlicerSort":`Set Slicer Sort`,"op.setSlicerStyle":`Set Slicer Style`,"op.setStacked":`Set Stacked`,"op.setStopFalse":`Clear Stop If True`,"op.setStops":`Set Stops`,"op.setStopTrue":`Set Stop If True`,"op.setStroke":`Set Outline`,"op.setStrokeColor":`Set Outline Color`,"op.setStrokeDash":`Set Outline Dash`,"op.setStrokeWidth":`Set Outline Width`,"op.setTableDescription":`Set Table Description`,"op.setTableName":`Set Table Name`,"op.setTableNameNamed":`Set Table Name ''{name}''`,"op.setTopBorder":`Set Top Border`,"op.setTopBorderColor":`Set Top Border Color`,"op.setTopBorderStyle":`Set Top Border Style`,"op.setTotalsRowFormula":`Set Totals Row Formula`,"op.setTotalsRowLabel":`Set Totals Row Label`,"op.setValue":`Set Value`,"op.setValueAddress":`Set Value {address}`,"op.setValuesAddress":`Set Values {address}`,"op.setVerticalAlignment":`Set Vertical Alignment`,"op.setVerticalBorder":`Set Vertical Border`,"op.setVerticalBorderColor":`Set Vertical Border Color`,"op.setVerticalBorderStyle":`Set Vertical Border Style`,"op.shiftingMovableBounds":`Shifting Movable Bounds`,"op.showBandedColumns":`Show Banded Columns`,"op.showBandedRows":`Show Banded Rows`,"op.showDetail":`Show Detail`,"op.showError":`Show Error`,"op.showHeaders":`Show Headers`,"op.showHighlightFirstColumn":`Show Highlight First Column`,"op.showHighlightLastColumn":`Show Highlight Last Column`,"op.showOutlineLevels":`Show Outline Level`,"op.showPivotItemsWithNoData":`Show PivotTable Items with No Data`,"op.showPivotValueAs":`Show PivotTable Value As`,"op.showTotals":`Show Totals`,"op.sortAscending":`Sort Ascending`,"op.sortColumn":`Sort {name}`,"op.sortDescending":`Sort Descending`,"op.sortPivotField":`Sort PivotTable Field`,"op.sortTable":`Sort Table`,"op.summarizePivotDataField":`Summarize PivotTable Value By`,"op.syncColumnsFromSheet":`Sync Columns From Sheet`,"op.syncColumnsToSheet":`Sync Columns To Sheet`,"op.tableAutoExpansion":`Table Auto Expansion`,"op.tableColumnFill":`Fill`,"op.textToColumns":`Text to Columns`,"op.togglePivotDrillIndicators":`Show or Hide PivotTable +/- Buttons`,"op.togglePivotFieldHeaders":`Show or Hide PivotTable Field Headers`,"op.ungroup":`Ungroup`,"op.ungroupColumns":`Ungroup Columns`,"op.ungroupDrawings":`Ungroup Drawings`,"op.ungroupRows":`Ungroup Rows`,"op.unhideColumns":`Unhide Columns`,"op.unhideRows":`Unhide Rows`,"op.unhideSheet":`Unhide Sheet`,"op.unmerge":`Unmerge`,"op.update":`Update`,"op.updateAnchor":`Update Anchor`,"op.updateCalculations":`Update Calculations`,"op.updateCellControl":`Update Cell Control`,"op.updateCells":`Update Cells`,"op.updateChart":`Format Chart`,"op.updateColumnNamed":`Update Column ''{name}''`,"op.updateColumns":`Update Columns`,"op.updateColumnsFromSheet":`Update Columns From Sheet`,"op.updateColumnsRange":`Update Columns {range}`,"op.updateComment":`Update Comment`,"op.updateConditionalFormat":`Update Conditional Format`,"op.updateConditionalFormatListener":`Update Conditional Format Listener`,"op.updateDataValidation":`Update Data Validation`,"op.updateDataValidationListener":`Update Data Validation Listener`,"op.updateDataValidations":`Update Data Validations`,"op.updateDrawing":`Update Drawing`,"op.updateFormulaAt":`Update Formula at {address}`,"op.updateHeader":`Update Header`,"op.updateListener":`Update Listener`,"op.updateMovableBounds":`Update Movable Bounds`,"op.updateMovables":`Update Movables`,"op.updateNamed":`Update Named ''{name}''`,"op.updateOutline":`Outline Settings`,"op.updatePageBreaks":`Page Breaks`,"op.updatePageLayout":`Page Layout`,"op.updateProtectedRange":`Update Protected Range`,"op.updateProtectedRanges":`Update Protected Ranges`,"op.updateReferenceStyle":`Update Reference Style`,"op.updateReferenceStyleAt":`Update Reference Style at {address}`,"op.updateRows":`Update Rows`,"op.updateRowsRange":`Update Rows {range}`,"op.updateSheet":`Update Sheet`,"op.updateSparklineGroup":`Update Sparkline Group`,"op.updateStyle":`Update Style`,"op.updateStyleInfo":`Update Style Info`,"op.updateWorkbook":`Update Workbook`,"op.updatingMovableBounds":`Updating Movable Bounds`,"op.veryHideSheet":`Very Hide Sheet`,"richData.placeholder":`Rich Object`,"slicer.blankItem":`(blank)`,"style.builtin.accent":`Accent{n}`,"style.builtin.accentTint":`{pct}% - Accent{n}`,"style.builtin.bad":`Bad`,"style.builtin.calculation":`Calculation`,"style.builtin.checkCell":`Check Cell`,"style.builtin.comma":`Comma`,"style.builtin.comma0":`Comma [0]`,"style.builtin.currency":`Currency`,"style.builtin.currency0":`Currency [0]`,"style.builtin.explanatoryText":`Explanatory Text`,"style.builtin.followedHyperlink":`Followed Hyperlink`,"style.builtin.good":`Good`,"style.builtin.heading":`Heading {n}`,"style.builtin.hyperlink":`Hyperlink`,"style.builtin.input":`Input`,"style.builtin.linkedCell":`Linked Cell`,"style.builtin.neutral":`Neutral`,"style.builtin.normal":`Normal`,"style.builtin.note":`Note`,"style.builtin.output":`Output`,"style.builtin.percent":`Percent`,"style.builtin.title":`Title`,"style.builtin.total":`Total`,"style.builtin.warningText":`Warning Text`,"table.autoTableDescription":`AutoTable created for filtering and sorting`,"table.autoTableName":`AutoTable`,"table.defaultName":`Table{n}`,"table.emptyColumnName":`Column`,"table.totalsRowLabel":`Total`,"workbook.defaultName":`Workbook`,"workbook.defaultSheetName":`Sheet{n}`};function xl(){return c(`@sheetxl/sdk`,import.meta.url,bl)}var Sl=class{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}},Cl=`{
|
|
4
|
-
"format": "sheetxl-font-metrics/1",
|
|
5
|
-
"family": "Arial",
|
|
6
|
-
"weight": 700,
|
|
7
|
-
"italic": false,
|
|
8
|
-
"source": { "family": "Liberation Sans", "version": "Version 2.1.5", "license": "OFL-1.1", "notice": "Licensed under the SIL Open Font License, Version 1.1" },
|
|
9
|
-
"unitsPerEm": 2048,
|
|
10
|
-
"winAscent": 1854,
|
|
11
|
-
"winDescent": 434,
|
|
12
|
-
"underline": [-2, 215],
|
|
13
|
-
"strikeout": [530, 102],
|
|
14
|
-
"advances": [
|
|
15
|
-
[32, [569,682,971,1139,1139,1821,1479,487,682,682,797,1196,569,682,569,569,1139,1139,1139,1139,1139,1139,1139,1139,1139,1139,682,682,1196,1196,1196,1251,1997,1479,1479,1479,1479,1366,1251,1593,1479,569,1139,1479,1251,1706,1479,1593,1366,1593,1479,1366,1251,1479,1366,1933,1366,1366,1251,682,569,682,1196,1139,682,1139,1251,1139,1251,1139,682,1251,1251,569,569,1139,569,1821,1251,1251,1251,1251,797,1139,682,1251,1139,1593,1139,1139,1024,797,573,797,1196]],
|
|
16
|
-
[160, [569,682,1139,1139,1139,1139,573,1139,682,1509,758,1139,1196,682,1509,1131,819,1124,682,682,682,1180,1139,682,682,682,748,1139,1708,1708,1708,1251,1479,1479,1479,1479,1479,1479,2048,1479,1366,1366,1366,1366,569,569,569,569,1479,1479,1593,1593,1593,1593,1593,1196,1593,1479,1479,1479,1479,1366,1366,1251,1139,1139,1139,1139,1139,1139,1821,1139,1139,1139,1139,1139,569,569,569,569,1251,1251,1251,1251,1251,1251,1251,1124,1251,1251,1251,1251,1251,1139,1251,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1472,1479,1251,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1593,1251,1593,1251,1593,1251,1593,1251,1479,1251,1479,1251,569,569,569,569,569,569,569,569,569,569,1607,1139,1139,569,1479,1139,1139,1251,569,1251,569,1251,789,1251,981,1251,569,1479,1251,1479,1251,1479,1251,1451,1481,1251,1593,1251,1593,1251,1593,1251,2048,1933,1479,797,1479,797,1479,797,1366,1139,1366,1139,1366,1139,1366,1139,1251,682,1251,981,1251,682,1479,1251,1479,1251,1479,1251,1479,1251,1479,1251,1479,1251,1933,1593,1366,1139,1366,1251,1024,1251,1024,1251,1024,569,1251,1713,1472,1251,1472,1251,1479,1479,1139,1479,1715,1472,1251,1242,1366,1487,1283,1251,1139,1593,1304,1906,569,569,1479,1139,569,1139,2031,1479,1251,1593,1747,1456,1816,1523,1601,1251,1366,1366,1139,1229,737,682,1251,682,1251,1699,1483,1642,1479,1577,1139,1251,1024,1251,1251,1078,1078,1139,1139,1018,1186,1251,573,1019,1197,682,2730,2503,2275,2390,1820,1138,2618,2048,1820,1479,1139,569,569,1593,1251,1479,1251,1479,1251,1479,1251,1479,1251,1479,1251,1139,1479,1139,1479,1139,2048,1821,1593,1251,1593,1251,1479,1139,1593,1251,1593,1251,1251,1078,569,2730,2503,2275,1593,1251,2115,1362,1479,1251,1479,1139,2048,1821,1593,1251,1479,1139,1479,1139,1366,1139,1366,1139,569,569,569,569,1593,1251,1593,1251,1479,797,1479,797,1479,1251,1479,1251,1366,1139,1251,682,1182,1065,1479,1251,1439,1715,1292,1292,1251,1024,1479,1139,1366,1139,1593,1251,1593,1251,1593,1251,1593,1251,1366,1139,1022,1707,1036,569,1953,1953,1479,1479,1139,1251,1251,1139,1024,1321,991,1479,1479,1366,1366,1139,1139,569,1587,1251,1479,797,1366,1139,1139,1251,1251,1251,1139,1139,1251,1251,1139,1139,1601,1018,1018,1415,1162,682,1251,1251,1200,1139,1230,1251,1251,1251,569,569,830,680,729,569,1236,1821,1821,1821,1251,1251,1259,1251,1707,1730,1535,797,797,797,797,797,797,797,1195,1195,1139,682,682,682,1105,682,682,1251,1272,1192,1139,1593,1139,1169,1024,1392,1078,1078,1139,1139,1139,1139,1593,1259,1162,1200,1237,939,1139,926,1251,1139,1139,2111,1929,2479,1666,1094,1688,1780,1589,1418,1093,1154,1494,1494,753,753,398,516,516,516,768,1071,738,487,971,569,569,569,682,682,768,768,1196,1196,1196,1196,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,682,749,289,770,750,768,784,784,784,784,784,682,682,682,682,1024,682,682,682,682,682,682,682,682,682,682,682,682,682,682,814,814,682,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],
|
|
17
|
-
[884, [682,682]],
|
|
18
|
-
[890, [682,1139,1139,1139,682]],
|
|
19
|
-
[900, [682,952,1479,682,1747,1855,970]],
|
|
20
|
-
[908, [1689]],
|
|
21
|
-
[910, [1899,1716,569,1479,1479,1231,1472,1366,1251,1479,1593,569,1479,1366,1706,1479,1318,1593,1479,1366]],
|
|
22
|
-
[931, [1229,1251,1366,1681,1366,1657,1642,569,1366,1259,924,1251,569,1192,1259,1250,1139,1242,972,943,1251,1107,569,1142,1139,1253,1139,912,1251,1568,1267,1065,1401,914,1192,1465,1179,1543,1730,569,1192,1251,1192,1730]],
|
|
23
|
-
[976, [1250,1192,1577,2050,1577,1535,1730,1385,1593,1251,1479,1139,1251,926,1539,1084,1647,1250,2031,1821,1439,1251,1439,1239,1366,1366,1316,1236,1505,1184,1038,900,1385,1265,1139,569,1593,980,980,1366,1251,1479,1706,1515,1267,1479,1479,1479,1366,1370,1813,1161,1457,1366,569,565,1139,2240,2176,1792,1250,1472,1274,1472,1479,1472,1479,1161,1459,1366,1851,1283,1472,1472,1250,1437,1706,1479,1593,1472,1366,1479,1251,1274,1748,1366,1496,1439,2058,2087,1781,2005,1472,1457,2112,1472,1139,1265,1259,853,1300,1139,1452,1018,1259,1259,1025,1301,1515,1237,1251,1237,1251,1139,1003,1139,1792,1139,1259,1189,1707,1728,1493,1749,1259,1131,1749,1195,1139,1139,1251,853,1131,1139,569,576,569,1984,1856,1251,1025,1259,1139,1237,2621,1594,1780,1439,1998,1630,1366,1139,1896,1639,1657,1543,2206,2008,1283,1018,1657,1543,1593,1251,1669,1324,1669,1324,2294,1995,1668,1306,2621,1845,2621,1594,1479,1139,1196,0,0,0,0,0,0,0,1472,1259,1472,1259,1366,1251,997,915,1161,853,1439,1225,1851,1452,1283,1018,1250,1025,1250,1025,1250,1025,1559,1276,1479,1237,1801,1462,2306,1887,1479,1183,1479,1139,1251,1003,1139,1139,1139,1139,1366,1139,1746,1411,1439,1189,1439,1189,1439,1251,1754,1389,1754,1389,569,1851,1452,1437,1224,1437,1301,1479,1237,1479,1237,1439,1189,1706,1515,569,1479,1139,1479,1139,2048,1821,1366,1139,1487,1139,1487,1139,1851,1452,1283,1018,1283,1078,1472,1259,1472,1259,1593,1251,1593,1251,1593,1251,1457,1131,1274,1139,1274,1139,1274,1139,1439,1189,1161,853,2005,1749,1161,853,1366,1139,1366,1139,1472,1251,2110,1914,1965,1732,1347,1098,2074,1957,2115,1894,1593,1200,1568,1435,1283,1018,1437,1301]],
|
|
24
|
-
[1306, [1593,1251,1933,1593]],
|
|
25
|
-
[1425, [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,915,0,613,0,0,682,0,0,790,0]],
|
|
26
|
-
[1488, [1193,1179,935,1126,1258,559,846,1261,1283,559,1068,1005,1016,1251,1290,559,790,1256,1113,1216,1202,1023,1048,1173,1068,1464,1379]],
|
|
27
|
-
[1520, [1118,1118,1118,566,1033]],
|
|
28
|
-
[7424, [1205,1589,1821,1259,1139,1177,1177,1025,1018,569,1039,1142,926,1515,1259,1251,1139,1265,1265,1265,1933,1170,1251,1251,1257,1195,1195,1003,1192,1251,1572,1248,1139,1593,1024,991,1010,1260,853,1139,1237,1257,1543,1301,995,1425,930,930,931,853,853,1027,892,370,734,944,798,1058,887,888,1062,890,859,940,887,891,1300,773,773,801,1206,801,801,770,770,719,719,800,289,714,1156,754,840,778,841,841,800,444,754,834,1156,745,844,795,745,835,986,776,289,516,754,745,795,745,834,986,776,1888,1251,1251,682,1821,1251,1251,797,797,1139,682,1024,1251,752,1244,1787,569,569,1251,1192,1272,1251,1251,682,1573,1139,569,1821,1251,1251,797,1139,954,1139,1139,1024,1139,1251,1251,1139,1018,1018,1342,569,1139,682,1251,1078,801,778,778,840,719,496,496,800,753,372,289,289,372,630,398,336,585,1156,1156,863,863,762,840,1027,770,569,444,832,862,746,746,745,740,740,958,778,744,0,0,0,0,0,0,0,0,0,0,0]],
|
|
29
|
-
[7678, [0,0,1479,1139,1479,1251,1479,1251,1479,1251,1479,1139,1479,1251,1479,1251,1479,1251,1479,1251,1479,1251,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1251,682,1593,1251,1479,1251,1479,1251,1479,1251,1479,1251,1479,1251,569,569,569,569,1479,1139,1479,1139,1479,1139,1251,569,1251,569,1251,569,1251,569,1706,1821,1706,1821,1706,1821,1479,1251,1479,1251,1479,1251,1479,1251,1593,1251,1593,1251,1593,1251,1593,1251,1366,1251,1366,1251,1479,797,1479,797,1479,797,1479,797,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1251,682,1251,682,1251,682,1251,682,1479,1251,1479,1251,1479,1251,1479,1251,1479,1251,1366,1139,1366,1139,1933,1593,1933,1593,1933,1593,1933,1593,1933,1593,1366,1139,1366,1139,1366,1139,1251,1024,1251,1024,1251,1024,1251,682,1593,1139,1139,569]],
|
|
30
|
-
[7838, [1465]],
|
|
31
|
-
[7840, [1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,569,569,569,569,1593,1251,1593,1251,1593,1251,1593,1251,1593,1251,1593,1251,1593,1251,1747,1456,1747,1456,1747,1456,1747,1456,1747,1456,1479,1251,1479,1251,1699,1483,1699,1483,1699,1483,1699,1483,1699,1483,1366,1139,1366,1139,1366,1139,1366,1139]],
|
|
32
|
-
[7936, [1259,1259,1259,1259,1259,1259,1259,1259,1479,1479,1779,1779,1779,1779,1779,1779,972,972,972,972,972,972]],
|
|
33
|
-
[7960, [1566,1566,1966,1966,1966,1966]],
|
|
34
|
-
[7968, [1251,1251,1251,1251,1251,1251,1251,1251,1679,1679,2079,2079,2079,2079,2079,2079,569,569,569,569,569,569,569,569,769,769,1169,1169,1169,1169,1169,1169,1251,1251,1251,1251,1251,1251]],
|
|
35
|
-
[8008, [1693,1693,2133,2133,1993,1993]],
|
|
36
|
-
[8016, [1192,1192,1192,1192,1192,1192,1192,1192]],
|
|
37
|
-
[8025, [1666]],
|
|
38
|
-
[8027, [2046]],
|
|
39
|
-
[8029, [2146]],
|
|
40
|
-
[8031, [1966,1730,1730,1730,1730,1730,1730,1730,1730,1742,1742,2182,2182,2042,2042,2042,2042,1259,1259,972,972,1251,1251,569,569,1251,1251,1192,1192,1730,1730]],
|
|
41
|
-
[8064, [1259,1259,1259,1259,1259,1259,1259,1259,1479,1479,1779,1779,1779,1779,1779,1779,1251,1251,1251,1251,1251,1251,1251,1251,1679,1679,2079,2079,2079,2079,2079,2079,1730,1730,1730,1730,1730,1730,1730,1730,1742,1742,2182,2182,2042,2042,2042,2042,1259,1259,1259,1259,1259]],
|
|
42
|
-
[8118, [1259,1259,1479,1479,1479,1479,1479,682,682,682,682,682,1251,1251,1251]],
|
|
43
|
-
[8134, [1251,1251,1766,1766,1879,1879,1479,682,682,682,569,569,569,569]],
|
|
44
|
-
[8150, [569,569,569,569,969,969]],
|
|
45
|
-
[8157, [682,682,682,1192,1192,1192,1192,1267,1267,1192,1192,1366,1366,1766,1866,1566,952,952,682]],
|
|
46
|
-
[8178, [1730,1730,1730]],
|
|
47
|
-
[8182, [1730,1730,1893,1693,1942,1742,1642,682,682]],
|
|
48
|
-
[8192, [1024,2048,1024,2048,683,512,341,1139,569,410,171,0,0,0,0,0,682]],
|
|
49
|
-
[8210, [1139,1139,2048,2048,1019,1131,569,569,569,569,1024,1024,1024,1024,1139,1139,717]],
|
|
50
|
-
[8230, [2048]],
|
|
51
|
-
[8234, [0,0,0,0,0,410,2048]],
|
|
52
|
-
[8242, [491,981,981]],
|
|
53
|
-
[8249, [682,682]],
|
|
54
|
-
[8252, [1237]],
|
|
55
|
-
[8254, [682]],
|
|
56
|
-
[8260, [342]],
|
|
57
|
-
[8286, [682]],
|
|
58
|
-
[8298, [0,0,0,0,0,0]],
|
|
59
|
-
[8308, [682,682,682,682,682,682]],
|
|
60
|
-
[8319, [811,923,847,910,947,976,939,930,819,959,922]],
|
|
61
|
-
[8336, [773,770,840,750,770]],
|
|
62
|
-
[8352, [1139,1479,1479,1139,1139,1821,1479,2240,2509,1933,1675,1051,1139,1479,1251,2224,1139,1366,1593,1479,1366,1479]],
|
|
63
|
-
[8383, [1479]],
|
|
64
|
-
[8432, [0]],
|
|
65
|
-
[8453, [1813]],
|
|
66
|
-
[8467, [1001]],
|
|
67
|
-
[8470, [2283,1509]],
|
|
68
|
-
[8482, [2048]],
|
|
69
|
-
[8486, [1573]],
|
|
70
|
-
[8494, [1229]],
|
|
71
|
-
[8525, [2048,1025]],
|
|
72
|
-
[8531, [1708,1708]],
|
|
73
|
-
[8539, [1708,1708,1708,1708]],
|
|
74
|
-
[8580, [1139]],
|
|
75
|
-
[8592, [2048,1024,2048,1024,2048,1024]],
|
|
76
|
-
[8616, [1024]],
|
|
77
|
-
[8660, [2048]],
|
|
78
|
-
[8706, [1012]],
|
|
79
|
-
[8710, [1253]],
|
|
80
|
-
[8719, [1686]],
|
|
81
|
-
[8721, [1460,1196]],
|
|
82
|
-
[8725, [342]],
|
|
83
|
-
[8729, [569,1124]],
|
|
84
|
-
[8734, [1460,2005]],
|
|
85
|
-
[8745, [1479]],
|
|
86
|
-
[8747, [561]],
|
|
87
|
-
[8776, [1124]],
|
|
88
|
-
[8800, [1124,1195,2048]],
|
|
89
|
-
[8804, [1124,1124]],
|
|
90
|
-
[8962, [1237]],
|
|
91
|
-
[8976, [1196]],
|
|
92
|
-
[8992, [1237,1237]],
|
|
93
|
-
[9472, [1451]],
|
|
94
|
-
[9474, [1280]],
|
|
95
|
-
[9484, [1451]],
|
|
96
|
-
[9488, [1451]],
|
|
97
|
-
[9492, [1451]],
|
|
98
|
-
[9496, [1451]],
|
|
99
|
-
[9500, [1451]],
|
|
100
|
-
[9508, [1451]],
|
|
101
|
-
[9516, [1451]],
|
|
102
|
-
[9524, [1451]],
|
|
103
|
-
[9532, [1451]],
|
|
104
|
-
[9552, [1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451]],
|
|
105
|
-
[9600, [1451]],
|
|
106
|
-
[9604, [1451]],
|
|
107
|
-
[9608, [1451]],
|
|
108
|
-
[9612, [1451]],
|
|
109
|
-
[9616, [1451,1451,1451,1493]],
|
|
110
|
-
[9632, [1237,1237]],
|
|
111
|
-
[9642, [726,726,2048]],
|
|
112
|
-
[9650, [2027]],
|
|
113
|
-
[9658, [2027]],
|
|
114
|
-
[9660, [2027]],
|
|
115
|
-
[9668, [2027]],
|
|
116
|
-
[9674, [1012,1237,1217]],
|
|
117
|
-
[9679, [1237,1237,1237,1237,1237,1237,1237,1237,1237,1237,1237]],
|
|
118
|
-
[9702, [726]],
|
|
119
|
-
[9786, [2091,2155,1877]],
|
|
120
|
-
[9791, [1536,1536,1536,1536,1536,1536,1536,1536,1536]],
|
|
121
|
-
[9824, [1088]],
|
|
122
|
-
[9827, [1344]],
|
|
123
|
-
[9829, [1216,1045]],
|
|
124
|
-
[9833, [2048,1024,1536,2048]],
|
|
125
|
-
[9839, [1024]],
|
|
126
|
-
[11360, [1251,569,1251,1366,1479,1139,682,1479,1251,1479,1139,1251,1024,1563]],
|
|
127
|
-
[11377, [1241,2139,1758,1139,1108,892,1465]],
|
|
128
|
-
[11799, [682]],
|
|
129
|
-
[42775, [0,0,0,0,1024,1024,682,682,682,0,0]],
|
|
130
|
-
[42888, [682,682,796,487,487]],
|
|
131
|
-
[64257, [1251,1251]],
|
|
132
|
-
[64285, [559,0,1118,1145,1480,1426,1558,1305,1316,1551,1368,1679,1196,1464,1464,1464,1464,1193,1193,1193,1179,930,1126,1258,661,897]],
|
|
133
|
-
[64312, [1283,661,1068,1005,1016]],
|
|
134
|
-
[64318, [1290]],
|
|
135
|
-
[64320, [790,1256]],
|
|
136
|
-
[64323, [1216,1202]],
|
|
137
|
-
[64326, [1048,1173,1068,1464,1379,559,1179,1005,1202,1243]],
|
|
138
|
-
[65056, [0,0,0,0]],
|
|
139
|
-
[65532, [2048]]
|
|
140
|
-
]
|
|
141
|
-
}
|
|
142
|
-
`,wl=`{
|
|
143
|
-
"format": "sheetxl-font-metrics/1",
|
|
144
|
-
"family": "Arial",
|
|
145
|
-
"weight": 400,
|
|
146
|
-
"italic": false,
|
|
147
|
-
"source": { "family": "Liberation Sans", "version": "Version 2.1.5", "license": "OFL-1.1", "notice": "Licensed under the SIL Open Font License, Version 1.1" },
|
|
148
|
-
"unitsPerEm": 2048,
|
|
149
|
-
"winAscent": 1854,
|
|
150
|
-
"winDescent": 434,
|
|
151
|
-
"underline": [-67, 150],
|
|
152
|
-
"strikeout": [530, 102],
|
|
153
|
-
"advances": [
|
|
154
|
-
[32, [569,569,727,1139,1139,1821,1366,391,682,682,797,1196,569,682,569,569,1139,1139,1139,1139,1139,1139,1139,1139,1139,1139,569,569,1196,1196,1196,1139,2079,1366,1366,1479,1479,1366,1251,1593,1479,569,1024,1366,1139,1706,1479,1593,1366,1593,1479,1366,1251,1479,1366,1933,1366,1366,1251,569,569,569,961,1139,682,1139,1139,1024,1139,1139,569,1139,1139,455,455,1024,455,1706,1139,1139,1139,1139,682,1024,569,1139,1024,1479,1024,1024,1024,684,532,684,1196]],
|
|
155
|
-
[160, [569,682,1139,1139,1139,1139,532,1139,682,1509,758,1139,1196,682,1509,1131,819,1124,682,682,682,1180,1100,682,682,682,748,1139,1708,1708,1708,1251,1366,1366,1366,1366,1366,1366,2048,1479,1366,1366,1366,1366,569,569,569,569,1479,1479,1593,1593,1593,1593,1593,1196,1593,1479,1479,1479,1479,1366,1366,1251,1139,1139,1139,1139,1139,1139,1821,1024,1139,1139,1139,1139,569,569,569,569,1139,1139,1139,1139,1139,1139,1139,1124,1251,1139,1139,1139,1139,1024,1139,1024,1366,1139,1366,1139,1366,1139,1479,1024,1479,1024,1479,1024,1479,1024,1479,1259,1479,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1593,1139,1593,1139,1593,1139,1593,1139,1479,1139,1479,1139,569,569,569,569,569,569,569,455,569,569,1505,909,1024,455,1366,1024,1024,1139,455,1139,455,1139,597,1139,684,1139,455,1479,1139,1479,1139,1479,1139,1237,1481,1139,1593,1139,1593,1139,1593,1139,2048,1933,1479,682,1479,682,1479,682,1366,1024,1366,1024,1366,1024,1366,1024,1251,569,1251,768,1251,569,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1933,1479,1366,1024,1366,1251,1024,1251,1024,1251,1024,455,1139,1553,1344,1139,1344,1139,1479,1479,1024,1479,1658,1344,1139,1140,1366,1541,1237,1251,1139,1593,1278,1804,455,569,1366,1024,455,1024,1824,1479,1139,1593,1756,1343,1778,1367,1545,1139,1366,1366,1024,1266,779,569,1251,569,1251,1749,1371,1531,1479,1582,1024,1251,1024,1251,1251,1116,1116,1139,1139,939,997,1139,532,846,1196,569,2730,2503,2148,2175,1706,924,2503,1934,1579,1366,1139,569,455,1593,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1139,1366,1139,1366,1139,2048,1821,1593,1139,1593,1139,1366,1024,1593,1139,1593,1139,1251,1116,455,2730,2503,2148,1593,1139,2118,1266,1479,1139,1366,1139,2048,1821,1593,1251,1366,1139,1366,1139,1366,1139,1366,1139,569,569,569,569,1593,1139,1593,1139,1479,682,1479,682,1479,1139,1479,1139,1366,1024,1251,569,1116,894,1479,1139,1446,1396,1238,1158,1251,1024,1366,1139,1366,1139,1593,1139,1593,1139,1593,1139,1593,1139,1366,1024,715,1402,752,455,1816,1816,1366,1479,1024,1139,1251,1024,1024,1189,928,1366,1479,1368,1366,1139,1024,455,1510,1139,1479,682,1366,1024,1139,1139,1139,1139,1024,1024,1139,1139,1139,1139,1513,939,939,1293,1039,569,1139,1139,1144,1026,1263,1139,1139,1139,455,455,729,670,622,455,1171,1706,1706,1706,1139,1139,1132,1139,1619,1599,1126,682,682,682,682,682,682,682,1109,1109,1024,455,532,455,715,569,569,1139,1164,1120,1024,1479,1024,1064,1024,1108,1116,1116,1024,1024,1024,1024,1593,1088,1039,1144,1131,814,1024,827,1139,1024,1024,1975,1856,2059,1459,879,1472,1564,1354,1295,994,1080,1407,1407,785,785,326,491,491,491,746,985,657,391,727,455,455,455,682,682,714,714,1196,1196,1196,1196,682,682,682,682,682,682,682,682,682,682,569,569,682,682,682,682,682,682,682,682,682,682,682,682,682,682,660,322,696,672,714,784,784,784,784,784,682,682,682,682,682,682,682,682,682,682,682,682,682,682,569,682,682,682,682,814,814,682,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],
|
|
156
|
-
[884, [682,682]],
|
|
157
|
-
[890, [682,1024,1024,1024,569]],
|
|
158
|
-
[900, [682,682,1367,569,1606,1716,786]],
|
|
159
|
-
[908, [1586]],
|
|
160
|
-
[910, [1752,1541,455,1366,1366,1128,1368,1366,1251,1479,1593,569,1366,1368,1706,1479,1331,1593,1479,1366]],
|
|
161
|
-
[931, [1266,1251,1366,1634,1366,1711,1531,569,1366,1184,913,1139,455,1120,1184,1178,1024,1140,913,903,1139,1139,455,1024,1024,1180,1024,917,1139,1413,1165,987,1264,809,1120,1328,1075,1460,1599,455,1120,1139,1120,1599]],
|
|
162
|
-
[976, [1178,1120,1582,1962,1582,1147,1599,1231,1593,1139,1479,1024,1251,827,1279,1084,1549,1181,1824,1706,1381,1139,1380,1024,1366,1366,1248,1221,1509,1134,950,839,1231,1173,1024,455,1593,905,905,1366,1139,1479,1706,1408,1165,1479,1479,1479,1366,1367,1771,1109,1472,1366,569,569,1024,2165,2069,1749,1193,1472,1301,1472,1366,1344,1366,1109,1387,1366,1891,1237,1472,1472,1193,1344,1706,1479,1593,1472,1366,1479,1251,1301,1557,1366,1515,1365,1877,1920,1621,1813,1344,1472,2069,1479,1139,1173,1088,747,1195,1139,1370,939,1144,1144,896,1195,1408,1131,1139,1109,1139,1024,938,1024,1685,1024,1173,1067,1643,1685,1280,1472,1067,1045,1536,1109,1139,1139,1139,747,1045,1024,455,569,455,1856,1664,1139,896,1144,1024,1131,2740,1278,1593,1255,1945,1461,1368,1024,1838,1424,1697,1403,2157,1776,1237,939,1631,1410,1593,1139,1645,1292,1645,1292,2200,1836,1706,1254,2439,1744,2740,1278,1479,1024,1031,0,0,0,0,0,0,0,1472,1144,1344,1067,1366,1139,1001,842,1109,747,1373,1124,1891,1370,1237,939,1193,896,1193,896,1193,896,1519,1097,1479,1131,1801,1327,2328,1782,1542,1067,1479,1024,1251,938,1139,1024,1139,1024,1366,1024,1895,1415,1365,1067,1365,1067,1365,1139,1764,1364,1764,1364,569,1891,1370,1367,1128,1344,1195,1479,1131,1479,1131,1365,1067,1706,1408,455,1366,1139,1366,1139,2048,1821,1366,1139,1541,1139,1541,1139,1891,1370,1237,939,1237,1116,1472,1144,1472,1144,1593,1139,1593,1139,1593,1139,1472,1045,1301,1024,1301,1024,1301,1024,1365,1067,1109,747,1813,1472,1109,747,1366,1024,1366,1024,1344,1139,1983,1795,1958,1670,1357,1043,1987,1863,2118,1799,1593,1144,1529,1363,1237,939,1344,1195]],
|
|
163
|
-
[1306, [1593,1139,1933,1479]],
|
|
164
|
-
[1425, [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,784,0,563,0,0,569,0,0,722,0]],
|
|
165
|
-
[1488, [1153,1110,817,1041,1233,505,783,1226,1208,505,1043,944,948,1226,1231,505,722,1176,1084,1160,1119,945,980,1126,1043,1422,1316]],
|
|
166
|
-
[1520, [1010,1010,1010,483,854]],
|
|
167
|
-
[7424, [1016,1531,1821,1088,1024,1129,1129,1003,939,455,865,1024,822,1408,1144,1139,1024,1246,1246,1246,1933,936,1139,1139,1067,1109,1109,938,1120,1222,1502,1222,1024,1479,1024,939,875,1243,747,1024,1109,1067,1460,1195,928,1359,849,849,920,840,840,1016,878,342,644,870,720,1045,881,879,1048,783,857,924,886,879,1275,762,762,772,1228,773,773,761,761,652,652,772,322,694,1173,783,773,725,773,773,774,450,783,834,1173,658,800,789,658,774,901,703,322,491,783,658,789,658,777,901,703,1860,1139,1139,569,1706,1139,1139,682,682,1024,569,1024,1139,779,1140,1609,455,455,1139,1120,1164,1139,1139,569,1460,1024,455,1706,1139,1139,682,1024,792,1024,1024,1024,1139,1139,1139,1139,939,939,1332,455,1024,455,1139,1116,772,725,713,764,652,469,469,772,785,322,322,322,322,554,322,322,563,1171,1171,783,783,782,773,768,696,322,450,783,794,774,724,658,734,734,734,756,746,0,0,0,0,0,0,0,0,0,0,0]],
|
|
168
|
-
[7678, [0,0,1366,1139,1366,1139,1366,1139,1366,1139,1479,1024,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1251,569,1593,1139,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,569,455,569,569,1366,1024,1366,1024,1366,1024,1139,455,1139,455,1139,455,1139,455,1706,1706,1706,1706,1706,1706,1479,1139,1479,1139,1479,1139,1479,1139,1593,1139,1593,1139,1593,1139,1593,1139,1366,1139,1366,1139,1479,682,1479,682,1479,682,1479,682,1366,1024,1366,1024,1366,1024,1366,1024,1366,1024,1251,569,1251,569,1251,569,1251,569,1479,1139,1479,1139,1479,1139,1479,1139,1479,1139,1366,1024,1366,1024,1933,1479,1933,1479,1933,1479,1933,1479,1933,1479,1366,1024,1366,1024,1366,1024,1251,1024,1251,1024,1251,1024,1139,569,1479,1024,1139,455]],
|
|
169
|
-
[7838, [1439]],
|
|
170
|
-
[7840, [1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,1366,1139,569,455,569,455,1593,1139,1593,1139,1593,1139,1593,1139,1593,1139,1593,1139,1593,1139,1756,1343,1756,1343,1756,1343,1756,1343,1756,1343,1479,1139,1479,1139,1749,1371,1749,1371,1749,1371,1749,1371,1749,1371,1366,1024,1366,1024,1366,1024,1366,1024]],
|
|
171
|
-
[7936, [1184,1184,1184,1184,1184,1184,1184,1184,1366,1366,1666,1666,1666,1666,1666,1666,913,913,913,913,913,913]],
|
|
172
|
-
[7960, [1566,1566,1900,1900,1900,1900]],
|
|
173
|
-
[7968, [1139,1139,1139,1139,1139,1139,1139,1139,1679,1679,2079,2079,2079,2079,2079,2079,455,455,455,455,455,455,455,455,769,769,1169,1169,1169,1169,1169,1169,1139,1139,1139,1139,1139,1139]],
|
|
174
|
-
[8008, [1693,1693,2093,2093,1993,1993]],
|
|
175
|
-
[8016, [1120,1120,1120,1120,1120,1120,1120,1120]],
|
|
176
|
-
[8025, [1666]],
|
|
177
|
-
[8027, [1966]],
|
|
178
|
-
[8029, [2066]],
|
|
179
|
-
[8031, [1966,1599,1599,1599,1599,1599,1599,1599,1599,1631,1631,2031,2031,1931,1931,1931,1931,1184,1184,913,913,1139,1139,455,455,1139,1139,1120,1120,1599,1599]],
|
|
180
|
-
[8064, [1184,1184,1184,1184,1184,1184,1184,1184,1366,1366,1666,1666,1666,1666,1666,1666,1139,1139,1139,1139,1139,1139,1139,1139,1679,1679,2079,2079,2079,2079,2079,2079,1599,1599,1599,1599,1599,1599,1599,1599,1631,1631,2031,2031,1931,1931,1931,1931,1184,1184,1184,1184,1184]],
|
|
181
|
-
[8118, [1184,1184,1366,1366,1366,1366,1366,682,682,682,682,682,1139,1139,1139]],
|
|
182
|
-
[8134, [1139,1139,1666,1666,1779,1779,1479,682,682,682,455,455,455,455]],
|
|
183
|
-
[8150, [455,455,569,569,869,869]],
|
|
184
|
-
[8157, [682,682,682,1120,1120,1120,1120,1165,1165,1120,1120,1366,1366,1766,1816,1566,682,682,682]],
|
|
185
|
-
[8178, [1599,1599,1599]],
|
|
186
|
-
[8182, [1599,1599,1893,1693,1831,1631,1531,682,682]],
|
|
187
|
-
[8192, [1024,2048,1024,2048,683,512,341,1139,569,410,171,0,0,0,0,0,682]],
|
|
188
|
-
[8210, [1139,1139,2048,2048,846,1131,455,455,455,455,682,682,682,682,1139,1139,717]],
|
|
189
|
-
[8230, [2048]],
|
|
190
|
-
[8234, [0,0,0,0,0,410,2048]],
|
|
191
|
-
[8242, [384,725,725]],
|
|
192
|
-
[8249, [682,682]],
|
|
193
|
-
[8252, [1024]],
|
|
194
|
-
[8254, [682]],
|
|
195
|
-
[8260, [342]],
|
|
196
|
-
[8286, [569]],
|
|
197
|
-
[8298, [0,0,0,0,0,0]],
|
|
198
|
-
[8308, [682,682,682,682,682,682]],
|
|
199
|
-
[8319, [747,850,691,795,834,836,825,826,704,849,812]],
|
|
200
|
-
[8336, [762,761,773,672,761]],
|
|
201
|
-
[8352, [1139,1479,1479,1139,1139,1706,1479,2240,2384,1933,1670,1051,1139,1366,1251,2048,1067,1366,1593,1366,1139,1479]],
|
|
202
|
-
[8383, [1366]],
|
|
203
|
-
[8432, [0]],
|
|
204
|
-
[8453, [1813]],
|
|
205
|
-
[8467, [662]],
|
|
206
|
-
[8470, [2197,1509]],
|
|
207
|
-
[8482, [2048]],
|
|
208
|
-
[8486, [1573]],
|
|
209
|
-
[8494, [1229]],
|
|
210
|
-
[8525, [1931,1003]],
|
|
211
|
-
[8531, [1708,1708]],
|
|
212
|
-
[8539, [1708,1708,1708,1708]],
|
|
213
|
-
[8580, [1024]],
|
|
214
|
-
[8592, [2048,1024,2048,1024,2048,1024]],
|
|
215
|
-
[8616, [1024]],
|
|
216
|
-
[8660, [2048]],
|
|
217
|
-
[8706, [1012]],
|
|
218
|
-
[8710, [1253]],
|
|
219
|
-
[8719, [1686]],
|
|
220
|
-
[8721, [1460,1196]],
|
|
221
|
-
[8725, [342]],
|
|
222
|
-
[8729, [569,1124]],
|
|
223
|
-
[8734, [1460,2005]],
|
|
224
|
-
[8745, [1472]],
|
|
225
|
-
[8747, [561]],
|
|
226
|
-
[8776, [1124]],
|
|
227
|
-
[8800, [1124,1195,2048]],
|
|
228
|
-
[8804, [1124,1124]],
|
|
229
|
-
[8962, [1237]],
|
|
230
|
-
[8976, [1196]],
|
|
231
|
-
[8992, [1237,1237]],
|
|
232
|
-
[9472, [1451]],
|
|
233
|
-
[9474, [1280]],
|
|
234
|
-
[9484, [1451]],
|
|
235
|
-
[9488, [1451]],
|
|
236
|
-
[9492, [1451]],
|
|
237
|
-
[9496, [1451]],
|
|
238
|
-
[9500, [1451]],
|
|
239
|
-
[9508, [1451]],
|
|
240
|
-
[9516, [1451]],
|
|
241
|
-
[9524, [1451]],
|
|
242
|
-
[9532, [1451]],
|
|
243
|
-
[9552, [1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451,1451]],
|
|
244
|
-
[9600, [1451]],
|
|
245
|
-
[9604, [1451]],
|
|
246
|
-
[9608, [1451]],
|
|
247
|
-
[9612, [1451]],
|
|
248
|
-
[9616, [1451,1451,1451,1493]],
|
|
249
|
-
[9632, [1237,1237]],
|
|
250
|
-
[9642, [726,726,2048]],
|
|
251
|
-
[9650, [2027]],
|
|
252
|
-
[9658, [2027]],
|
|
253
|
-
[9660, [2027]],
|
|
254
|
-
[9668, [2027]],
|
|
255
|
-
[9674, [1012,1237,1217]],
|
|
256
|
-
[9679, [1237,1237,1237,1237,1237,1237,1237,1237,1237,1237,1237]],
|
|
257
|
-
[9702, [726]],
|
|
258
|
-
[9786, [2091,2155,1877]],
|
|
259
|
-
[9791, [1536,1536,1536,1536,1536,1536,1536,1536,1536]],
|
|
260
|
-
[9824, [1088]],
|
|
261
|
-
[9827, [1344]],
|
|
262
|
-
[9829, [1216,1045]],
|
|
263
|
-
[9833, [2048,1024,1536,2048]],
|
|
264
|
-
[9839, [1024]],
|
|
265
|
-
[11360, [1139,455,1139,1366,1479,1139,569,1479,1139,1366,1024,1251,1024,1500]],
|
|
266
|
-
[11377, [1222,2124,1722,1024,1182,871,1328]],
|
|
267
|
-
[11799, [682]],
|
|
268
|
-
[42775, [0,0,0,0,1024,1024,569,569,569,0,0]],
|
|
269
|
-
[42888, [682,569,896,391,391]],
|
|
270
|
-
[64257, [1024,1024]],
|
|
271
|
-
[64285, [505,0,1010,1096,1453,1341,1533,1244,1248,1526,1343,1616,1196,1422,1422,1422,1422,1153,1153,1153,1110,817,1041,1233,587,842]],
|
|
272
|
-
[64312, [1208,587,1043,944,948]],
|
|
273
|
-
[64318, [1231]],
|
|
274
|
-
[64320, [722,1176]],
|
|
275
|
-
[64323, [1160,1119]],
|
|
276
|
-
[64326, [980,1126,1043,1422,1316,505,1110,944,1119,1179]],
|
|
277
|
-
[65056, [0,0,0,0]],
|
|
278
|
-
[65532, [2048]]
|
|
279
|
-
]
|
|
280
|
-
}
|
|
281
|
-
`,Tl=`{
|
|
282
|
-
"format": "sheetxl-font-metrics/1",
|
|
283
|
-
"family": "Calibri",
|
|
284
|
-
"weight": 700,
|
|
285
|
-
"italic": false,
|
|
286
|
-
"source": { "family": "Carlito", "version": "Version 1.103", "license": "OFL-1.1", "notice": "Copyright (c) 2010-2013 by tyPoland Lukasz Dziedzic (http://www.typoland.com/) with Reserved Font Name \\"Carlito\\". Licensed under the SIL Open Font License, Version 1.1 (http://scripts.sil.org/OFL)." },
|
|
287
|
-
"unitsPerEm": 2048,
|
|
288
|
-
"winAscent": 1950,
|
|
289
|
-
"winDescent": 550,
|
|
290
|
-
"underline": [-103, 194],
|
|
291
|
-
"strikeout": [512, 134],
|
|
292
|
-
"advances": [
|
|
293
|
-
[0, [0]],
|
|
294
|
-
[13, [0]],
|
|
295
|
-
[32, [463,667,898,1020,1038,1493,1443,478,638,638,1020,1020,528,627,547,880,1038,1038,1038,1038,1038,1038,1038,1038,1038,1038,565,565,1020,1020,1020,949,1840,1241,1148,1084,1291,999,940,1305,1292,546,678,1120,866,1790,1349,1385,1090,1405,1153,968,1014,1337,1211,1856,1128,1064,979,665,880,665,1020,1020,615,1011,1099,857,1099,1031,648,971,1099,503,523,983,503,1666,1099,1101,1099,1099,728,817,710,1099,969,1526,941,970,814,704,973,704,1020]],
|
|
296
|
-
[161, [667,1020,1038,1020,1038,1020,1020,849,1709,852,1103,1020]],
|
|
297
|
-
[174, [1038,799,701,1020,692,688,616,1154,1224,548,621,517,891,1103,1347,1415,1437,949,1241,1241,1241,1241,1241,1241,1588,1084,999,999,999,999,546,546,546,546,1309,1349,1385,1385,1385,1385,1385,1020,1394,1337,1337,1337,1337,1064,1090,1136,1011,1011,1011,1011,1011,1011,1587,857,1031,1031,1031,1031,503,503,503,503,1099,1099,1101,1101,1101,1101,1101,1020,1114,1099,1099,1099,1099,970,1099,970,1241,1011,1241,1011,1241,1011,1084,857,1084,857,1084,857,1084,857,1291,1222,1309,1165,999,1031,999,1031,999,1031,999,1031,999,1031,1305,971,1305,971,1305,971,1305,971,1292,1099,1347,1121,546,503,546,503,546,503,546,503,546,503,1225,1027,678,523,1120,983,983,866,503,866,503,881,627,1150,865,886,540,1349,1099,1349,1099,1349,1099,1274,1313,1099,1385,1101,1385,1101,1385,1101,1790,1726,1153,728,1153,728,1153,728,968,817,968,817,968,817,968,817,1014,710,1014,744,1014,726,1337,1099,1337,1099,1337,1099,1337,1099,1337,1099,1337,1099,1856,1526,1064,970,1064,979,814,979,814,979,814,529,1170,1368,1138,1099,1171,1119,1075,1243,950,1309,1511,1138,1099,1091,999,1347,1009,940,648,1395,1210,1646,614,616,1124,983,641,996,1820,1349,1099,1385,1566,1296,1642,1415,1310,1099,1153,975,826,962,913,749,1116,710,1014,1559,1326,1394,1337,1125,1052,979,814,1003,1009,981,884,1038,1038,866,805,1099,541,985,1203,667,2270,2105,1913,1577,1389,1026,2027,1872,1622,1241,1011,546,503,1385,1101,1337,1099,1337,1099,1337,1099,1337,1099,1337,1099,1031,1241,1011,1241,1011,1588,1587,1321,1140,1305,971,1120,983,1385,1101,1385,1101,1003,937,523,2245,2105,1913,1305,971,1812,1254,1349,1099,1241,1011,1588,1587,1394,1114,1241,1011,1241,1011,999,1031,999,1031,546,503,546,503,1385,1101,1385,1101,1153,728,1153,728,1337,1099,1337,1099,968,817,1014,710,1003,937,1292,1099,1315,1243,1081,1055,1004,826,1241,1011,999,1031,1385,1101,1385,1101,1385,1101,1385,1101,1064,970,676,1276,719,523,1693,1695,1241,1094,866,901,1034,817,814,898,890,1174,1374,1216,1000,1019,707,608,1295,1099,1181,776,1204,1010,1011,1099,1100,1099,867,904,1099,1121,1031,1031,1316,874,874,1103,1079,597,1118,1098,1098,980,992,1099,1099,1099,619,586,670,807,824,516,1195,1666,1666,1666,1099,1099,1128,1097,1473,1447,1432,728,728,729,728,728,672,672,1002,1002,817,494,582,494,671,710,710,1201,1197,1089,969,1526,970,948,824,981,937,942,898,898,898,857,1325,1013,1079,1108,1117,676,983,828,1120,898,898,1716,1789,1883,1314,1030,1439,1634,1268,1214,1075,1007,1117,1118,763,763,388,512,502,524,692,1051,678,439]],
|
|
298
|
-
[699, [528,528,528,462,462,665,665,1020,1020,1099,1099,822,822,593]],
|
|
299
|
-
[715, [615,593,807,615,616,569,569,462,462,682,682,682,682,788,482,671,646,910,995,682,682,682,374,570,681,665,784,784,784,784,784,682,682,822,1178,891,682,682,682,682,671]],
|
|
300
|
-
[757, [961]],
|
|
301
|
-
[759, [910,565,682,682,682,682,1088,1088,770]],
|
|
302
|
-
[773, [0]],
|
|
303
|
-
[781, [0,0,0,0,0]],
|
|
304
|
-
[787, [0,0,508]],
|
|
305
|
-
[792, [0,0,0,682,0,0,0,0,0,0,0]],
|
|
306
|
-
[805, [0]],
|
|
307
|
-
[809, [0,0,0]],
|
|
308
|
-
[815, [0]],
|
|
309
|
-
[818, [0,0]],
|
|
310
|
-
[822, [0]],
|
|
311
|
-
[825, [0,0,0,0,0,0,0]],
|
|
312
|
-
[835, [0]],
|
|
313
|
-
[838, [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],
|
|
314
|
-
[857, [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],
|
|
315
|
-
[884, [528,528]],
|
|
316
|
-
[890, [562,867,857,867,565]],
|
|
317
|
-
[900, [649,1012,1241,548,999,1292,546]],
|
|
318
|
-
[908, [1385]],
|
|
319
|
-
[910, [1064,1394,586,1241,1148,839,1183,999,979,1292,1385,546,1120,1216,1790,1349,1008,1385,1292,1090]],
|
|
320
|
-
[931, [962,1014,1064,1641,1128,1654,1394,546,1064,1210,937,1114,586,1123,1210,1117,957,1091,937,746,1114,1116,586,983,996,1154,965,789,1101,1186,1086,833,1115,804,1123,1432,923,1511,1470,586,1123,1101,1123,1470]],
|
|
321
|
-
[976, [1098,1208,1071,1071,1071,1441,1733,1252,1385,1101,1075,839,940,914,1131,967,1228,1232,1809,1666,1117,1081,1148,1067,1038,860,1190,974,1368,1105,1031,826,1239,1082,857,523,1385,916,916,1090,1119,1084,1470,1262,1086,1110,1084,1110,999,999,1302,885,1103,968,546,546,678,1834,1836,1295,1153,1335,1121,1287,1241,1138,1148,885,1378,999,1705,987,1335,1335,1153,1288,1790,1292,1385,1290,1090,1084,1014,1121,1482,1128,1347,1166,1837,1898,1309,1635,1133,1103,1871,1176,1011,1090,1013,726,1192,1031,1509,874,1140,1140,1013,1077,1461,1117,1101,1094,1099,857,798,970,1383,941,1151,1000,1563,1616,1143,1458,1013,895,1542,1020,1031,1031,1133,726,896,817,503,503,523,1590,1626,1121,1013,1140,970,1100,1938,1473,1306,1089,1599,1337,1333,1173,1832,1615,1490,1282,1960,1722,1010,870,1654,1511,1385,1097,1253,1017]],
|
|
322
|
-
[1143, [1017,2250,1960,1465,1200,1938,1628,1938,1473,1060,834,1248,0,0,0,0]],
|
|
323
|
-
[1160, [2018,1944,1416,1206,1163,1031,1090,1099,889,752,903,774,1135,935,1818,1598,987,874,1268,1099,1203,1083,1180,1047,1323,1165,1378,1172,1490,1269,1880,1524,1351,1155,1084,857,1014,797,1064,975,1064,975,1239,1026,1541,1254,1227,1086,1166,1030,1166,1030,1597,1285,1597,1285,546,1705,1509,1196,1040,1368,1143,1292,1116,1373,1182,1166,1030,1871,1505,546,1241,1011,1241,1011,1588,1587,999,1031,1347,1031,1347,1031,1705,1509,987,874,1003,937,1335,1140,1335,1140,1385,1101,1385,1101,1385,1101,1103,895,1121,970,1121,970,1121,970,1166,1000,874,726,1635,1458,903,774,1223,1022,1128,941,1133,1099,1673,1595,1536,1395,1078,970,1808,1584,1812,1623,1318,1117,1299,1157,1009,874,1348,1134]],
|
|
324
|
-
[3647, [1038]],
|
|
325
|
-
[7424, [1063,1399,1587,1061,955,1122,1122,864]],
|
|
326
|
-
[7433, [503,621,994,762,1461,1140,1192,955,1162,1161,1320,1726,953,1101,1101,987,1014,1014,853,1158,1135,1507,1175,1033,1595,878,860,817,1012,780,1003,1141,987,1444,1098,787,1047,778,807,875,695,695,892,871,432,517,756,615,1178,914,909,929,761,756,781,688,888,1185,703,684,757,1068,757,757,711,696,635,631,668,378,704,1132,761,757,580,742,742,757,506,763]],
|
|
327
|
-
[7514, [1132,677,679,754,638,732,977,706,378,512,763,677,754,638,749,977,706,1691,1247,1242,813,1907,1362,1212,870,829,1004,813,880,971,813,994,1711,620,669,1140,1250,1236,1099,1198,680,1461,1131,583,1751,1184,1099,728,941,876,979,1070,850,1208,1234,1130,1041,904,874,1041,630,867,494,1224,907,741,580,622,736,631,464,449,668,763,503,434,378,504,557,444,435,584,1132,1132,812,812,802,757,951,570,522,531,855,816,747,740,705,570,670,714,674,790,0,0,0,0,0,0,0,0,0,0,0]],
|
|
328
|
-
[7678, [0,0,1241,1011,1148,1099,1148,1099,1148,1099,1084,857,1291,1099,1291,1099,1291,1099,1291,1099,1291,1099,999,1031,999,1031,999,1031,999,1031,999,1031,940,648,1305,971,1292,1099,1292,1099,1292,1099,1292,1099,1292,1099,546,503,546,503,1120,983,1120,983,1120,983,866,503,866,503,866,503,866,503,1790,1666,1790,1666,1790,1666,1349,1099,1349,1099,1349,1099,1349,1099,1385,1101,1385,1101,1385,1101,1385,1101,1090,1099,1090,1099,1153,728,1153,728,1153,728,1153,728,968,817,968,817,968,817,968,817,968,817,1014,710,1014,710,1014,710,1014,710,1337,1099,1337,1099,1337,1099,1337,1099,1337,1099,1211,969,1211,969,1856,1526,1856,1526,1856,1526,1856,1526,1856,1526,1128,941,1128,941,1064,970,979,814,979,814,979,814,1099,710,1526,970,1011,529]],
|
|
329
|
-
[7838, [1173]],
|
|
330
|
-
[7840, [1241,1011,1241,1011,1241,1011,1241,1011,1241,1011,1241,1011,1241,1011,1241,1011,1241,1011,1241,1011,1241,1011,1241,1011,999,1031,999,1031,999,1031,999,1031,999,1031,999,1031,999,1031,999,1031,546,503,546,503,1385,1101,1385,1101,1385,1101,1385,1101,1385,1101,1385,1101,1385,1101,1428,1296,1428,1296,1428,1296,1428,1296,1428,1296,1337,1099,1337,1099,1559,1326,1559,1326,1559,1326,1559,1326,1559,1326,1064,970,1064,970,1064,970,1064,970]],
|
|
331
|
-
[7936, [1210,1210,1210,1210,1210,1210,1210,1210,1241,1241,1241,1241,1241,1241,1241,1241,937,937,937,937,937,937]],
|
|
332
|
-
[7960, [999,999,1258,1258,1258,1258]],
|
|
333
|
-
[7968, [1114,1114,1114,1114,1114,1114,1114,1114,1292,1292,1551,1551,1551,1551,1479,1479,586,586,586,586,586,586,586,586,546,546,805,805,805,805,733,546,1101,1101,1101,1101,1101,1101]],
|
|
334
|
-
[8008, [1385,1385,1590,1590,1590,1590]],
|
|
335
|
-
[8016, [1123,1123,1123,1123,1123,1123,1123,1123]],
|
|
336
|
-
[8025, [1064]],
|
|
337
|
-
[8027, [1425]],
|
|
338
|
-
[8029, [1425]],
|
|
339
|
-
[8031, [1425,1470,1470,1470,1470,1470,1470,1470,1470,1394,1394,1598,1598,1598,1598,1523,1530,1210,1210,937,937,1114,1114,586,586,1101,1101,1123,1123,1470,1470]],
|
|
340
|
-
[8064, [1210,1210,1210,1210,1210,1210,1210,1210,1241,1241,1241,1241,1241,1241,1241,1241,1114,1114,1114,1114,1114,1114,1114,1114,1292,1292,1551,1551,1551,1551,1479,1479,1470,1470,1470,1470,1470,1470,1470,1470,1394,1394,1598,1598,1598,1598,1530,1530,1210,1210,1210,1210,1210]],
|
|
341
|
-
[8118, [1210,1210,1241,1241,1241,1241,1241,473]],
|
|
342
|
-
[8127, [473,922,804,1114,1114,1114]],
|
|
343
|
-
[8134, [1114,1114,999,999,1292,1292,1292,809,809,804,586,586,586,586]],
|
|
344
|
-
[8150, [586,586,546,546,546,546]],
|
|
345
|
-
[8157, [809,809,804,1123,1123,1123,1123,1086,1086,1123,1123,1064,1064,1064,1064,1090,1012,1012,649]],
|
|
346
|
-
[8178, [1470,1470,1470]],
|
|
347
|
-
[8182, [1470,1470,1385,1385,1394,1394,1394,649,473]],
|
|
348
|
-
[8192, [1024,2048,1024,2048,687,512,341,1038,444,409,256,0,0,0,0,0]],
|
|
349
|
-
[8210, [1038,1020,1854,1854,985,1022,528,528,528,528,891,891,891,891,1020,1020,1020]],
|
|
350
|
-
[8230, [1457]],
|
|
351
|
-
[8239, [463,2174]],
|
|
352
|
-
[8243, [835,1221]],
|
|
353
|
-
[8249, [705,705]],
|
|
354
|
-
[8252, [1202,1034,1020]],
|
|
355
|
-
[8260, [728]],
|
|
356
|
-
[8286, [601,455]],
|
|
357
|
-
[8304, [815,378]],
|
|
358
|
-
[8308, [749,690,740,669,749,740,727,720,711,455,455,761,815,517,692,688,749,690,740,669,749,740,727,720,711,455,455,652,703,696,757,681,711]],
|
|
359
|
-
[8352, [1323,1114,1084,950,1038,1666,1411,1884,1563,1945,1565,1165,1038,1148,1014,2286,1149,1211,1249,1274,1063,1084]],
|
|
360
|
-
[8376, [1038,1038]],
|
|
361
|
-
[8413, [2036]],
|
|
362
|
-
[8453, [1589]],
|
|
363
|
-
[8467, [1081]],
|
|
364
|
-
[8470, [2142,1709]],
|
|
365
|
-
[8480, [1497]],
|
|
366
|
-
[8482, [1475]],
|
|
367
|
-
[8486, [1394]],
|
|
368
|
-
[8494, [1513]],
|
|
369
|
-
[8498, [940]],
|
|
370
|
-
[8525, [1569,750]],
|
|
371
|
-
[8531, [1428,1530,1428,1530,1515,1543,1370,1457,1426,1512,1512,1392,812]],
|
|
372
|
-
[8579, [1084,867]],
|
|
373
|
-
[8592, [1854,1854,1854,1854,2683,1574,1719,1719,1719,1719]],
|
|
374
|
-
[8616, [967]],
|
|
375
|
-
[8706, [1100]],
|
|
376
|
-
[8710, [1183]],
|
|
377
|
-
[8719, [1602]],
|
|
378
|
-
[8721, [1127,1020]],
|
|
379
|
-
[8725, [780]],
|
|
380
|
-
[8730, [1020]],
|
|
381
|
-
[8734, [1716,1400]],
|
|
382
|
-
[8745, [1437]],
|
|
383
|
-
[8747, [769]],
|
|
384
|
-
[8776, [1020]],
|
|
385
|
-
[8800, [1020,1020]],
|
|
386
|
-
[8804, [1020,1020]],
|
|
387
|
-
[8962, [1793]],
|
|
388
|
-
[8976, [1020]],
|
|
389
|
-
[8992, [1106,1106]],
|
|
390
|
-
[9312, [2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720]],
|
|
391
|
-
[9450, [2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720]],
|
|
392
|
-
[9471, [2720,1024]],
|
|
393
|
-
[9474, [1024]],
|
|
394
|
-
[9484, [1024]],
|
|
395
|
-
[9488, [1024]],
|
|
396
|
-
[9492, [1024]],
|
|
397
|
-
[9496, [1024]],
|
|
398
|
-
[9633, [1237]],
|
|
399
|
-
[9642, [725,725]],
|
|
400
|
-
[9674, [1093,1126,1217]],
|
|
401
|
-
[9679, [1237]],
|
|
402
|
-
[9702, [725]],
|
|
403
|
-
[9728, [1506]],
|
|
404
|
-
[9788, [1506]],
|
|
405
|
-
[9833, [0]],
|
|
406
|
-
[10102, [2720,2720,2720,2720,2720,2720,2720,2720,2720,2720]],
|
|
407
|
-
[11360, [912,656,996,1123,1153,1011,761,1378,1160,1228,1069,1013,829]],
|
|
408
|
-
[11380, [1012,1001,846,1433]],
|
|
409
|
-
[11799, [656]],
|
|
410
|
-
[42775, [807,807,804,682]],
|
|
411
|
-
[42784, [1810,1810]],
|
|
412
|
-
[63743, [1522]],
|
|
413
|
-
[64256, [1230,1135,1135,1718,1718]],
|
|
414
|
-
[65056, [0,0,0,0]],
|
|
415
|
-
[65279, [0]]
|
|
416
|
-
]
|
|
417
|
-
}
|
|
418
|
-
`,El=`{
|
|
419
|
-
"format": "sheetxl-font-metrics/1",
|
|
420
|
-
"family": "Calibri",
|
|
421
|
-
"weight": 400,
|
|
422
|
-
"italic": false,
|
|
423
|
-
"source": { "family": "Carlito", "version": "Version 1.103", "license": "OFL-1.1", "notice": "Copyright (c) 2010-2013 by tyPoland Lukasz Dziedzic (http://www.typoland.com/) with Reserved Font Name \\"Carlito\\". Licensed under the SIL Open Font License, Version 1.1 (http://scripts.sil.org/OFL)." },
|
|
424
|
-
"unitsPerEm": 2048,
|
|
425
|
-
"winAscent": 1950,
|
|
426
|
-
"winDescent": 550,
|
|
427
|
-
"underline": [-103, 194],
|
|
428
|
-
"strikeout": [512, 134],
|
|
429
|
-
"advances": [
|
|
430
|
-
[0, [0]],
|
|
431
|
-
[13, [0]],
|
|
432
|
-
[32, [463,667,821,1020,1038,1464,1397,452,621,621,1020,1020,511,627,517,791,1038,1038,1038,1038,1038,1038,1038,1038,1038,1038,548,548,1020,1020,1020,949,1831,1185,1114,1092,1260,1000,941,1292,1276,516,653,1064,861,1751,1322,1356,1058,1378,1112,941,998,1314,1162,1822,1063,998,959,628,791,628,1020,1020,596,981,1076,866,1076,1019,625,964,1076,470,490,931,470,1636,1076,1080,1076,1076,714,801,686,1076,925,1464,887,927,809,644,943,644,1020]],
|
|
433
|
-
[161, [667,1020,1038,1020,1038,1020,1020,804,1709,824,1049,1020]],
|
|
434
|
-
[174, [1038,807,694,1020,688,685,598,1126,1200,517,629,504,865,1049,1303,1375,1383,949,1185,1185,1185,1185,1185,1185,1563,1092,1000,1000,1000,1000,516,516,516,516,1279,1322,1356,1356,1356,1356,1356,1020,1359,1314,1314,1314,1314,998,1058,1080,981,981,981,981,981,981,1583,866,1019,1019,1019,1019,470,470,470,470,1076,1076,1080,1080,1080,1080,1080,1020,1084,1076,1076,1076,1076,927,1076,927,1185,981,1185,981,1185,981,1092,866,1092,866,1092,866,1092,866,1260,1164,1279,1130,1000,1019,1000,1019,1000,1019,1000,1019,1000,1019,1292,964,1292,964,1292,964,1292,964,1276,1076,1344,1091,516,470,516,470,516,470,516,470,516,470,1170,960,653,490,1064,931,931,861,470,861,470,866,540,1118,765,880,507,1322,1076,1322,1076,1322,1076,1186,1287,1076,1356,1080,1356,1080,1356,1080,1775,1740,1112,714,1112,714,1112,714,941,801,941,801,941,801,941,801,998,686,998,708,998,700,1314,1076,1314,1076,1314,1076,1314,1076,1314,1076,1314,1076,1822,1464,998,927,998,959,809,959,809,959,809,497,1130,1260,1101,1076,1088,1076,1122,1181,947,1279,1406,1101,1076,1072,1000,1317,970,941,625,1294,1162,1603,592,550,1064,931,577,948,1801,1322,1100,1356,1428,1184,1583,1342,1252,1076,1112,941,801,939,882,736,1087,686,998,1478,1234,1360,1314,1090,1020,959,809,970,970,970,870,1038,1038,872,801,1076,499,809,1175,667,2219,2069,1885,1539,1351,960,1975,1812,1566,1185,981,516,470,1356,1080,1314,1076,1314,1076,1314,1076,1314,1076,1314,1076,1019,1185,981,1185,981,1563,1583,1292,1100,1292,964,1064,931,1356,1080,1356,1080,970,970,490,2197,2069,1885,1292,964,1832,1236,1322,1076,1185,981,1563,1583,1359,1084,1185,981,1185,981,1000,1019,1000,1019,516,470,516,470,1356,1080,1356,1080,1112,714,1112,714,1314,1076,1314,1076,941,801,998,686,970,970,1276,1076,1316,1229,1038,1038,1007,844,1185,981,1000,1019,1356,1080,1356,1080,1356,1080,1356,1080,998,927,649,1259,686,490,1683,1682,1185,1092,866,861,998,801,809,916,916,1131,1349,1173,1000,1019,673,576,1290,1076,1129,767,1184,994,981,1076,1076,1076,866,923,1076,1076,1019,1019,1307,866,866,1077,1083,577,1076,1076,1105,925,976,1075,1076,1076,577,562,615,743,761,470,1158,1635,1635,1636,1076,1076,1107,1080,1459,1426,1334,714,714,714,714,714,654,654,920,920,801,490,578,490,650,686,686,1188,1142,1109,925,1464,927,849,809,979,956,955,916,916,916,866,1287,981,1083,1131,1095,650,931,793,1076,916,916,1647,1748,1817,1267,964,1402,1548,1198,1129,1007,1007,1076,1101,745,745,365,502,502,515,651,1007,646,452]],
|
|
435
|
-
[699, [511,511,511,462,462,665,665,1020,1020,1099,1099,809,809,593]],
|
|
436
|
-
[715, [596,593,807,596,598,569,569,462,462,682,682,682,682,780,462,657,639,922,961,682,682,609,350,560,638,665,784,784,784,784,784,682,682,809,1178,857,682,682,682,682,657]],
|
|
437
|
-
[757, [961]],
|
|
438
|
-
[759, [922,548,682,682,682,682,1088,1088,770]],
|
|
439
|
-
[773, [0]],
|
|
440
|
-
[781, [0,0,0,0,0]],
|
|
441
|
-
[787, [0,0,511]],
|
|
442
|
-
[792, [0,0,0,682,0,0,0,0,0,0,0]],
|
|
443
|
-
[805, [0]],
|
|
444
|
-
[809, [0,0,0]],
|
|
445
|
-
[815, [0]],
|
|
446
|
-
[818, [0,0]],
|
|
447
|
-
[822, [0]],
|
|
448
|
-
[825, [0,0,0,0,0,0,0]],
|
|
449
|
-
[835, [0]],
|
|
450
|
-
[838, [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],
|
|
451
|
-
[857, [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],
|
|
452
|
-
[884, [511,511]],
|
|
453
|
-
[890, [562,866,866,866,548]],
|
|
454
|
-
[900, [649,1012,1185,517,1000,1276,516]],
|
|
455
|
-
[908, [1356]],
|
|
456
|
-
[910, [998,1360,562,1185,1114,851,1156,1000,959,1276,1356,516,1064,1173,1751,1322,1007,1356,1276,1058]],
|
|
457
|
-
[931, [939,998,998,1555,1063,1536,1360,516,998,1162,933,1100,562,1109,1162,1088,914,1072,933,712,1100,1089,562,931,948,1126,919,770,1080,1132,1042,841,1089,793,1109,1334,873,1449,1426,562,1109,1080,1109,1426]],
|
|
458
|
-
[976, [1074,1144,998,1110,998,1339,1668,1239,1356,1080,1092,841,941,888,1117,921,1186,1186,1801,1636,1116,1071,1138,1048,1092,858,1232,1035,1378,1089,969,806,1239,1042,866,490,1356,885,885,1058,1142,1092,1431,1221,1042,1092,1092,1092,1000,1000,1279,880,1121,941,516,516,653,1786,1795,1266,1112,1314,1080,1269,1185,1101,1114,880,1319,1000,1640,970,1314,1314,1112,1251,1751,1276,1356,1273,1058,1092,998,1080,1428,1063,1308,1138,1778,1822,1259,1560,1088,1122,1800,1137,981,1091,981,708,1143,1019,1411,866,1107,1107,950,1045,1385,1095,1080,1066,1076,866,793,927,1278,887,1109,960,1492,1534,1098,1364,962,907,1478,971,1019,1019,1107,708,909,801,470,470,490,1538,1576,1091,950,1107,927,1075,1900,1386,1284,1063,1601,1332,1291,1075,1703,1455,1480,1152,1855,1547,970,846,1536,1449,1356,1073,1208,978]],
|
|
459
|
-
[1143, [978,2140,1861,1356,1180,1900,1602,1900,1386,1092,866,1248,0,0,0,0]],
|
|
460
|
-
[1160, [2018,1944,1358,1119,1088,991,1058,1076,886,725,870,761,1089,927,1714,1472,970,866,1189,1012,1112,950,1130,1003,1292,1095,1316,1137,1457,1240,1848,1521,1323,1135,1092,866,998,793,998,925,998,925,1142,946,1490,1221,1178,1002,1138,960,1138,960,1526,1224,1526,1224,516,1640,1411,1119,975,1294,1057,1276,1095,1276,1108,1138,960,1799,1462,516,1185,981,1185,981,1563,1583,1000,1019,1317,1019,1317,1019,1640,1411,970,866,970,956,1314,1107,1314,1107,1356,1080,1356,1073,1356,1073,1122,907,1080,927,1080,927,1080,927,1138,960,851,708,1560,1364,870,761,1157,945,1063,887,1088,1076,1629,1621,1565,1435,1050,954,1807,1567,1832,1616,1301,1093,1313,1153,970,866,1289,1067]],
|
|
461
|
-
[3647, [1038]],
|
|
462
|
-
[7424, [982,1295,1583,1042,971,1092,1113,831]],
|
|
463
|
-
[7433, [470,551,913,752,1385,1107,1140,971,1193,1192,1320,1740,872,1080,1080,936,975,975,831,1130,1125,1479,1636,990,1550,847,815,801,976,754,990,1104,936,1327,1038,757,1009,743,763,843,680,680,836,859,422,459,736,603,1133,885,885,885,690,728,667,599,788,1093,684,684,741,1067,741,741,696,696,631,631,663,355,663,1110,742,742,590,742,742,741,483,745]],
|
|
464
|
-
[7514, [1110,645,586,702,582,643,869,607,355,502,745,645,702,582,741,869,607,1684,1211,1213,778,1692,1204,1214,850,794,925,783,809,964,772,964,1672,577,617,1128,1243,1220,1076,1105,625,1356,1054,496,1663,1105,1076,714,891,762,925,1005,828,1148,1240,1076,1019,866,866,1019,470,866,563,1240,886,741,590,622,690,631,449,449,663,745,402,426,355,402,485,404,379,548,1110,1110,795,796,772,742,822,560,365,484,745,696,742,742,645,567,660,678,626,742,0,0,0,0,0,0,0,0,0,0,0]],
|
|
465
|
-
[7678, [0,0,1185,981,1114,1076,1114,1076,1114,1076,1092,866,1260,1076,1260,1076,1260,1076,1260,1076,1260,1076,1000,1019,1000,1019,1000,1019,1000,1019,1000,1019,941,625,1292,964,1276,1076,1276,1076,1276,1076,1276,1076,1276,1076,516,470,516,470,1064,931,1064,931,1064,931,861,470,861,470,861,470,861,470,1751,1636,1751,1636,1751,1636,1322,1076,1322,1076,1322,1076,1322,1076,1356,1080,1356,1080,1356,1080,1356,1080,1058,1076,1058,1076,1112,714,1112,714,1112,714,1112,714,941,801,941,801,941,801,941,801,941,801,998,686,998,686,998,686,998,686,1314,1076,1314,1076,1314,1076,1314,1076,1314,1076,1162,925,1162,925,1822,1464,1822,1464,1822,1464,1822,1464,1822,1464,1063,887,1063,887,998,927,959,809,959,809,959,809,1076,686,1464,927,981,497]],
|
|
466
|
-
[7838, [1149]],
|
|
467
|
-
[7840, [1185,981,1185,981,1185,981,1185,981,1185,981,1185,981,1185,981,1185,981,1185,981,1185,981,1185,981,1185,981,1000,1019,1000,1019,1000,1019,1000,1019,1000,1019,1000,1019,1000,1019,1000,1019,516,470,516,470,1356,1080,1356,1080,1356,1080,1356,1080,1356,1080,1356,1080,1356,1080,1428,1184,1428,1184,1428,1184,1428,1184,1428,1184,1314,1076,1314,1076,1478,1234,1478,1234,1478,1234,1478,1234,1478,1234,998,927,998,927,998,927,998,927]],
|
|
468
|
-
[7936, [1162,1162,1162,1162,1162,1162,1162,1162,1185,1185,1185,1185,1185,1185,1185,1185,933,933,933,933,933,933]],
|
|
469
|
-
[7960, [1000,1000,1213,1213,1213,1217]],
|
|
470
|
-
[7968, [1100,1100,1100,1100,1100,1100,1100,1100,1276,1276,1489,1489,1489,1489,1369,1369,562,562,562,562,562,562,562,562,516,516,729,729,729,729,609,609,1080,1080,1080,1080,1080,1080]],
|
|
471
|
-
[8008, [1356,1356,1548,1541,1525,1522]],
|
|
472
|
-
[8016, [1109,1109,1109,1109,1109,1109,1109,1109]],
|
|
473
|
-
[8025, [998]],
|
|
474
|
-
[8027, [1299]],
|
|
475
|
-
[8029, [1303]],
|
|
476
|
-
[8031, [1183,1426,1426,1426,1426,1426,1426,1426,1426,1360,1360,1549,1553,1522,1522,1433,1433,1162,1162,933,933,1100,1100,562,562,1080,1080,1109,1109,1426,1426]],
|
|
477
|
-
[8064, [1162,1162,1162,1162,1162,1162,1162,1162,1185,1185,1185,1185,1185,1185,1185,1185,1100,1100,1100,1100,1100,1100,1100,1100,1276,1276,1489,1489,1489,1489,1369,1369,1426,1426,1426,1426,1426,1426,1426,1426,1360,1360,1549,1553,1522,1522,1433,1433,1162,1162,1162,1162,1162]],
|
|
478
|
-
[8118, [1162,1162,1185,1185,1185,1185,1185,473]],
|
|
479
|
-
[8127, [473,922,804,1100,1100,1100]],
|
|
480
|
-
[8134, [1100,1100,1000,1000,1276,1276,1276,809,809,804,562,562,562,562]],
|
|
481
|
-
[8150, [562,562,516,516,516,516]],
|
|
482
|
-
[8157, [809,809,804,1109,1109,1109,1109,1042,1042,1109,1109,998,998,998,998,1058,1012,1012,649]],
|
|
483
|
-
[8178, [1426,1426,1426]],
|
|
484
|
-
[8182, [1426,1426,1356,1356,1360,1360,1360,649,473]],
|
|
485
|
-
[8192, [1024,2048,1024,2048,687,512,341,1104,444,409,256,0,0,0,0,0]],
|
|
486
|
-
[8210, [1038,1020,1854,1854,809,1020,511,511,511,511,857,857,857,856,1020,1020,1020]],
|
|
487
|
-
[8230, [1414]],
|
|
488
|
-
[8239, [463,2126]],
|
|
489
|
-
[8243, [820,1188]],
|
|
490
|
-
[8249, [694,694]],
|
|
491
|
-
[8252, [1142,990,1020]],
|
|
492
|
-
[8260, [689]],
|
|
493
|
-
[8286, [548,455]],
|
|
494
|
-
[8304, [801,355]],
|
|
495
|
-
[8308, [731,678,735,657,737,735,746,735,720,444,444,742,801,504,688,685,731,678,735,657,737,735,746,735,720,444,444,631,684,696,742,638,696]],
|
|
496
|
-
[8352, [1262,1092,1092,941,1038,1636,1322,1888,1608,1822,1525,1130,1038,1064,998,2216,1082,1154,1202,1173,941,1092]],
|
|
497
|
-
[8376, [1038,1038]],
|
|
498
|
-
[8413, [2036]],
|
|
499
|
-
[8453, [1569]],
|
|
500
|
-
[8467, [1029]],
|
|
501
|
-
[8470, [2099,1709]],
|
|
502
|
-
[8480, [1452]],
|
|
503
|
-
[8482, [1444]],
|
|
504
|
-
[8486, [1360]],
|
|
505
|
-
[8494, [1513]],
|
|
506
|
-
[8498, [941]],
|
|
507
|
-
[8525, [1569,750]],
|
|
508
|
-
[8531, [1385,1481,1385,1481,1463,1485,1326,1405,1363,1442,1442,1322,787]],
|
|
509
|
-
[8579, [1092,866]],
|
|
510
|
-
[8592, [1854,1854,1854,1854,2638,1592,1806,1806,1806,1806]],
|
|
511
|
-
[8616, [967]],
|
|
512
|
-
[8706, [1091]],
|
|
513
|
-
[8710, [1156]],
|
|
514
|
-
[8719, [1637]],
|
|
515
|
-
[8721, [1108,1020]],
|
|
516
|
-
[8725, [689]],
|
|
517
|
-
[8730, [1020]],
|
|
518
|
-
[8734, [1747,1400]],
|
|
519
|
-
[8745, [1437]],
|
|
520
|
-
[8747, [749]],
|
|
521
|
-
[8776, [1020]],
|
|
522
|
-
[8800, [1020,1020]],
|
|
523
|
-
[8804, [1020,1020]],
|
|
524
|
-
[8962, [1793]],
|
|
525
|
-
[8976, [1020]],
|
|
526
|
-
[8992, [1106,1106]],
|
|
527
|
-
[9312, [2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720]],
|
|
528
|
-
[9450, [2720,2720,2720,2720,2720,2720,2720,2720,2720,2720,2720]],
|
|
529
|
-
[9471, [2720,1024]],
|
|
530
|
-
[9474, [1024]],
|
|
531
|
-
[9484, [1024]],
|
|
532
|
-
[9488, [1024]],
|
|
533
|
-
[9492, [1024]],
|
|
534
|
-
[9496, [1024]],
|
|
535
|
-
[9633, [1237]],
|
|
536
|
-
[9642, [725,725]],
|
|
537
|
-
[9674, [1046,1126,1217]],
|
|
538
|
-
[9679, [1237]],
|
|
539
|
-
[9702, [725]],
|
|
540
|
-
[9728, [1500]],
|
|
541
|
-
[9788, [1500]],
|
|
542
|
-
[9833, [0]],
|
|
543
|
-
[10102, [2720,2720,2720,2720,2720,2720,2720,2720,2720,2720]],
|
|
544
|
-
[11360, [861,577,962,1075,1112,981,686,1316,1123,1137,987,994,836]],
|
|
545
|
-
[11380, [962,949,793,1339]],
|
|
546
|
-
[11799, [627]],
|
|
547
|
-
[42775, [807,807,804,682]],
|
|
548
|
-
[42784, [1810,1810]],
|
|
549
|
-
[63743, [1522]],
|
|
550
|
-
[64256, [1195,1084,1084,1654,1654]],
|
|
551
|
-
[65056, [0,0,0,0]],
|
|
552
|
-
[65279, [0]]
|
|
553
|
-
]
|
|
554
|
-
}
|
|
555
|
-
`,Dl=t(`sdk:wasm`,()=>e(()=>import(`./DEpn6VGd30cHEJOS.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)),Ol={load:()=>(async()=>(await Dl.load()).wasm)(),peek:()=>Dl.peek()?.wasm},kl=t(`sdk:text-fallback`,()=>e(()=>import(`./MNoPOsydrUv1UGU8.js`),__vite__mapDeps([4,3,5]),import.meta.url),{prefetch:!1}),Al=null,jl={load:()=>jl.isLoaded()?Promise.resolve():(Al??=(async()=>{try{await Ol.load()}catch{await kl.load()}})().finally(()=>{Al=null}),Al),loadFallback:()=>kl.load(),isLoaded:()=>Ol.peek()!==void 0||kl.peek()!==void 0,peekWasm:()=>Ol.peek(),peekFallback:()=>kl.peek()},Ml=new Map,Nl=e=>`${e.family.trim().toLowerCase()}|${e.weight>=600?`bold`:``}|${e.italic?`italic`:``}`;function Pl(e){if(e?.format!==`sheetxl-font-rows/1`)throw Error(`Not a font rows table: format '${e?.format}', expected 'sheetxl-font-rows/1'.`);if(!(e.pitches?.length>=2))throw Error(`A rows table lists at least two sizes.`);Ml.set(Nl(e),{first:e.firstPpem,pitches:e.pitches})}var Fl=(e,t)=>{let{ascent:n,descent:r}=e.metrics(t);return function(e,t){if(!e||t<e.first)return;let n=t-e.first,r=e.pitches;if(n<r.length)return r[n];let i=r.length-1,a=Math.min(40,i),o=(r[i]-r[i-a])/a;return Math.round(r[i]+o*(n-i))}(Ml.get(Nl(e)),(i=t,Math.max(0,Math.floor(i+.5))||0))??n+r+2;var i};function Il(e,t){return zt(e,t,Fl)}var Ll,Rl,zl=[`Arial`,`Arial Black`,`Brush Script MT`,`Calibri`,`Cambria`,`Comic Sans MS`,`Courier New`,`Garamond`,`Georgia`,`Impact`,`Palatino Linotype`,`Tahoma`,`Times New Roman`,`Trebuchet MS`,`Verdana`],Bl=new Map([[I.GenericName.Serif,[`Times New Roman`]],[I.GenericName.SanSerif,[`Calibri`]],[I.GenericName.MonoSpace,[`Courier New`]],[I.GenericName.Cursive,[`Comic Sans MS`]],[I.GenericName.Fantasy,[`Impact`]],[I.GenericName.UISystem,[`Arial`]],[I.GenericName.UISerif,[`Times New Roman`]],[I.GenericName.UISanSerif,[`Arial`]],[I.GenericName.UIMonoSpace,[`Courier New`]],[I.GenericName.UIRounded,[`Arial`]],[I.GenericName.Math,[]],[I.GenericName.Emoji,[]],[I.GenericName.Fangsong,[]]]),Vl=700,Hl=e=>e.split(`,`).map(e=>e.trim().replace(/^(["'])(.*)\1$/,`$2`).trim()).filter(Boolean),Ul=e=>e.trim().replace(/\s+/g,` `).toLowerCase(),Wl=(e,t,n)=>`${Ul(e)}|${t?`b`:``}${n?`i`:``}`,Gl=class e{static{this._shared=null}static getShared(){return e._shared??=new e([new St(null,{".rows.json":Pl}),...Ne.getAdvanceBuilders()]),e._shared}constructor(e){this._entries=new Map,this._resolutions=new Map,this._paints=new Map,this._loading=new Set,this._fontList=[],this._fontsByFamily=new Map,this._bestMatches=new Map,this._loadingAnswers=0,this._builders=e,this._emitter=new ne(this),this._seedBuiltins(),this.setFontList(null),this._loadNative()}_loadNative(){if(jl.isLoaded())return;let e=()=>{this._loading.delete(t)},t=jl.load().then(e,e);this._loading.add(t)}getByName(e,t){let n=t?.bold??!1,r=t?.italic??!1,i=t?.fallbacks,a=i?.length?`${Wl(e,n,r)}|${i.join(`,`)}`:Wl(e,n,r),o=this._resolutions.get(a);if(o)return this._answer(o);let s=[...Hl(e),...(i??[]).flatMap(Hl)],c=s.length<=1?this._resolve(s[0]??e,n,r):this._resolveFirst(s,n,r),l=this._withPaint(c,Fe(s.length>0?s:[e]),n,r);return this._resolutions.set(a,l),this._answer(l)}_answer(e){return e.status===`loading`&&this._loadingAnswers++,e}get loadingAnswers(){return this._loadingAnswers}load(e){let t=e.map(e=>{let t=typeof e==`string`?{family:e}:e,n=Ul(t.family);return this._ensure(n,t.bold??!1,t.italic??!1).done});return Promise.all(t).then(()=>{})}async whenReady(){for(;this._loading.size>0;)await Promise.all(this._loading)}isLoading(){return this._loading.size>0}setAdvanceBuilders(e){this._builders=e;for(let e of this._entries.values())e.table?.release();this._entries.clear(),this._paints.clear(),this._seedBuiltins(),this.setFontList(this._fontList.map(e=>e.fontRef)),this._changed()}getFontList(){return this._fontList}setFontList(e){let t=[];this._fontsByFamily.clear(),this._bestMatches.clear();for(let n of e??zl){let e=typeof n==`string`?new Sl(n):n,r={fontRef:e,loaded:this._isInstalled(e.getFamily())};t.push(r),this._fontsByFamily.set(e.getFamily(),r)}this._fontList=Object.freeze(t)}findBestMatch(e,t){let n=this._bestMatches.get(e);if(n)return n.fontRef?n:null;let r=null;for(let n of[e,...t?.fallbacks??[]]){r=this._fontsByFamily.get(n)??null;for(let e of r?[]:Bl.get(n)??[])if(r=this._fontsByFamily.get(e)??null,r)break;if(r)break}return this._bestMatches.set(e,r??{fontRef:null,loaded:!1}),r}addListeners(e,t){return this._emitter.addListeners(e,t)}get isIFontCollection(){return!0}_isInstalled(e){for(let t of this._builders){let n=t.isInstalled?.(e);if(n!==void 0)return n}return!0}_seedBuiltins(){for(let e of[El,Tl,wl,Cl].map(e=>Ie.fromJSON(JSON.parse(e)))){this._measureMissing(e);let t=Wl(e.family,e.weight>=Vl,e.italic);this._entries.set(t,{state:`loaded`,table:e,kind:`table`,done:Promise.resolve(),builtin:!0})}}_refine(e,t){if(!t.builtin||t.refining!==void 0)return;let n=this._builders.filter(e=>e.hint),r=this._builders.filter(e=>e.kind===`exact`);if(n.length===0&&r.length===0)return void(t.refining=!1);t.refining=!0;let i=t.table,a=(async()=>{for(let e of n)try{if(await e.hint(i))return}catch{}let e={family:i.family,weight:i.weight,italic:i.italic};for(let n of r)try{let r=await n.build(e);if(r)return i.release(),t.table=r,void(t.kind=n.kind)}catch{}})().finally(()=>{t.refining=!1,this._loading.delete(a),this._entries.get(e)!==t&&this._loading.size!==0||this._changed()});this._loading.add(a)}_resolve(e,t,n){let r={family:e,weight:t?Vl:400,italic:n},i=Ul(e),a=this._ensure(i,t,n);if(a.state===`loaded`)return{table:a.table,kind:a.kind,status:a.refining?`loading`:`loaded`,requested:r};let o=a.state===`loading`,s=st.get(i);if(s){let e=this._ensure(s,t,n);if(e.state===`loaded`)return o||=!0===e.refining,{table:e.table,kind:`classified`,status:o?`loading`:`loaded`,requested:r};o||=e.state===`loading`}let c=s===`arial`||i===`arial`?`arial`:`calibri`,l=this._ensure(c,t,!1);o||=!0===l.refining;let u=o?`loading`:a.state===`error`?`error`:`loaded`;return{table:l.table,kind:`generic`,status:u,requested:r}}_resolveFirst(e,t,n){let r=this._resolve(e[0],t,n);if(r.kind!==`generic`)return r;let i=r.status===`loading`;for(let a=1;a<e.length;a++){let o=this._resolve(e[a],t,n);if(o.kind!==`generic`)return{...o,kind:`classified`,status:i?`loading`:o.status,requested:r.requested};i||=o.status===`loading`}return i?{...r,status:`loading`}:r}_ensure(e,t,n){let r=Wl(e,t,n),i=this._entries.get(r);if(i)return this._refine(r,i),i;let a={state:`loading`,done:Promise.resolve()},o={family:e,weight:t?Vl:400,italic:n},s=this._builders,c=(async()=>{try{for(let e of s){let t=await e.build(o);if(t)return e.kind===`table`&&this._measureMissing(t),a.table=t,a.kind=e.kind,void(a.state=`loaded`)}a.state=`missing`}catch{a.state=`error`}})().finally(()=>{this._loading.delete(c),this._entries.get(r)!==a&&this._loading.size!==0||this._changed()});return a.done=c,this._entries.set(r,a),this._loading.add(c),a}_measureMissing(e){let t={family:e.family,weight:e.weight,italic:e.italic};for(let n of this._builders){let r=n.measureMissing?.(t);if(r)return void e.setMeasureMissing(r)}}_changed(){this._resolutions.clear(),this._emitter.notify(`onCollectionChange`)}_withPaint(e,t,n,r){if(e.kind===`exact`)return e;let i=this._builders.filter(e=>e.paint);if(i.length===0)return e;let a=`${t.map(Ul).join(`,`)}|${n?`b`:``}${r?`i`:``}`,o=this._paints.get(a);if(!o){let e={state:`loading`,done:Promise.resolve()},s={family:t[0],weight:n?Vl:400,italic:r},c=(async()=>{try{for(let n of i){let r=await n.paint(s,t);if(r)return e.table=r,void(e.state=`loaded`)}}catch{}e.state=`missing`})().finally(()=>{this._loading.delete(c),this._paints.get(a)===e&&this._changed()});e.done=c,this._paints.set(a,e),this._loading.add(c),o=e}return o.state===`loading`?e.status===`error`?e:{...e,status:`loading`}:o.table?{...e,paint:o.table}:e}};(Rl=Ll||={}).getShared=function(){return Gl.getShared()},Rl.ResolutionKind={Table:`table`,Exact:`exact`,Classified:`classified`,Generic:`generic`},Rl.FontStatus={Loading:`loading`,Loaded:`loaded`,Error:`error`};var Kl=Object.freeze({ß:`ss`,ẞ:`SS`,æ:`ae`,Æ:`AE`,œ:`oe`,Œ:`OE`,þ:`th`,Þ:`TH`,ij:`ij`,IJ:`IJ`,ff:`ff`,fi:`fi`,fl:`fl`,ffi:`ffi`,ffl:`ffl`,st:`st`,LJ:`LJ`,Lj:`Lj`,lj:`lj`,NJ:`NJ`,Nj:`Nj`,nj:`nj`,DZ:`DZ`,Dz:`Dz`,dz:`dz`,ȸ:`db`}),ql=/[ßẞæÆœŒþÞijIJff-fflstLJ-njDZ-dzȸ]/g;function Jl(e,t=!0){let n=e.replace(ql,e=>Kl[e]);return t?n.toLowerCase():n}function Yl(e){return Jl(e.normalize(`NFC`),!0)}function Xl(e){return e.toLowerCase()}var Zl,Ql,$l={Options:Object.freeze({sensitivity:`variant`,numeric:!1,ignorePunctuation:!1}),isCaseInsensitive:e=>{let t=e?.sensitivity;return t===void 0||t===`accent`||t===`base`},collator:e=>{let t=eu.get(e);return t||(t=new Intl.Collator(e.tag,$l.Options),eu.set(e,t)),t},collatorFor:(e,t)=>{let n=`${e}|${t?.numeric??``}|${t?.caseFirst??``}|${t?.ignorePunctuation??``}`,r=tu.get(n);return r||(r=new Intl.Collator(e,{...$l.Options,...t,sensitivity:`variant`}),tu.set(n,r)),r},compareTextWith:(e,t,n,r=!0)=>{if(e===t)return 0;let i=Jl(e,r),a=Jl(t,r),o=ru(i),s=ru(a);if(o===i&&s===a)return iu(i,a,n);let c=iu(o,s,n);return c===0?mu(i,a,n):c},compare:(e,t,n,r)=>{if(e==null){if(t==null)return 0;e=gu(t)}else t??=gu(e);let i=hu(e),a=hu(t);if(i!==a)return i<a?-1:1;switch(i){case 0:return _u(e,t);case 1:return $l.compareTextWith(e,t,r?$l.collatorFor(n.tag,r):$l.collator(n),$l.isCaseInsensitive(r));case 2:return e===t?0:e?1:-1;case 3:{let n=e.getCode(),r=t.getCode();return n===r?0:n<r?-1:1}default:return 0}}},eu=new WeakMap,tu=new Map,nu=new Map([[39,1],[65287,2],[45,3],[65123,3],[65293,5],[8722,6],[8208,7],[8209,8],[8210,9],[8211,10],[8212,11],[65112,11],[8213,13],[700,14]]),ru=e=>{let t=e.length,n=0;for(;n<t&&!nu.has(e.charCodeAt(n));)n++;if(n===t)return e;let r=e.slice(0,n);for(;n<t;n++)nu.has(e.charCodeAt(n))||(r+=e[n]);return r},iu=(e,t,n)=>{let r=e.length<t.length?e.length:t.length,i=0;for(;i<r&&e.charCodeAt(i)===t.charCodeAt(i);)i++;if(i===r)return n.compare(e,t);let a=e.codePointAt(i),o=t.codePointAt(i);if(fu(a)||fu(o))return n.compare(e,t);let s=cu(a),c=cu(o);return s===c?s===2?n.compare(e,t):a<o?-1:1:s<c?-1:1},au=new Set([43,60,61,62]),ou=/[\p{P}\p{S}\p{Z}]/u,su=/\p{Cf}/u,cu=e=>{if(e<128){let t=uu[e];return t===void 0&&(t=uu[e]=lu(e)),t}let t=du.get(e);return t===void 0&&(t=lu(e),du.set(e,t)),t},lu=e=>au.has(e)?1:ou.test(String.fromCodePoint(e))?0:2,uu=Array(128),du=new Map,fu=e=>{let t=pu.get(e);return t===void 0&&(t=e>=128&&su.test(String.fromCodePoint(e)),pu.set(e,t)),t},pu=new Map,mu=(e,t,n)=>{let r=0,i=0;for(;r<e.length&&i<t.length;){let n=e.charCodeAt(r),a=t.charCodeAt(i),o=nu.get(n),s=nu.get(a);if(o===void 0!=(s===void 0))return o===void 0?-1:1;if(o!==void 0&&o!==s)return o<s?-1:1;r++,i++}return r<e.length?1:i<t.length?-1:0},hu=e=>{switch(typeof e){case`number`:return 0;case`string`:return 1;case`boolean`:return 2;default:return V.isError(e)?3:4}},gu=e=>{switch(typeof e){case`string`:return``;case`boolean`:return!1;default:return 0}},_u=(e,t)=>{if(e===t)return 0;if(!Number.isFinite(e)||!Number.isFinite(t))return e<t?-1:+(e>t);let n=e-t;if(Math.abs(n)>1e-14*Math.max(Math.abs(e),Math.abs(t)))return n<0?-1:1;let r=vu(e),i=vu(t);return r===i?0:r<i?-1:1},vu=e=>Number(e.toPrecision(15));(Ql=Zl||={}).DetachedContext=Object.freeze({resources:null,strings:null}),Ql.create=function(e){let{name:t,fromJSON:n}=e;if(!t)throw Error(`A rich data kind needs a name.`);let r=e.label??t,i=Object.freeze([...e.properties??[]]),a=new Map(i.map(e=>[e.name,e])),o=e.displayProperty??null,s=e.meta??null;return Object.freeze({getName:()=>t,getLabel:()=>r,getProperties:()=>i,getProperty:e=>a.get(e)??null,getDisplayProperty:()=>o,getMeta:()=>s,fromJSON:n})};var yu=class e{static{this.Type=`richText`}constructor(e){let t=[],n=``;for(let r=0;r<e.length;r++){let i=e[r],a=typeof i?.text==`string`?i.text:``;if(a.length===0)continue;n+=a;let o=xu(i.font);t.push(Object.freeze(o?{text:a,font:o}:{text:a}))}this._runs=Object.freeze(t),this._text=n}static from(t){return t instanceof e?t:typeof t==`string`?new e([{text:t}]):Array.isArray(t)?new e(t):new e(t?.runs??[])}static fromJSON(t){return new e(t?.data?.runs??[])}getKind(){return bu}getRuns(){return this._runs}getText(){return this._text}isFormatted(){let e=this._runs;for(let t=0;t<e.length;t++)if(e[t].font)return!0;return!1}getProperty(e){return null}toString(){return this._text}toPrimitive(){return this._text}toJSON(){let t=this._runs,n=Array(t.length);for(let e=0;e<t.length;e++){let r=t[e];n[e]=r.font?{text:r.text,font:{...r.font}}:{text:r.text}}return{type:e.Type,data:{runs:n}}}get isIRichData(){return!0}},bu=Zl.create({name:yu.Type,fromJSON:yu.fromJSON});function xu(e){if(!e)return null;let t=!1,n={};for(let r of Object.keys(e)){let i=e[r];if(i==null)continue;let a=r;switch(r){case`bold`:a=`weight`,i=i?700:400;break;case`italic`:a=`style`,i=i?I.Style.Italic:I.Style.Normal;break;case`weight`:if(typeof i==`string`){let e=i.toLowerCase();if(i=e===`bold`||e===`bolder`?700:e===`normal`||e===`lighter`?400:parseInt(e,10),!Number.isFinite(i))continue}break;case`underline`:!0===i?i=I.UnderlineStyle.Single:!1===i&&(i=I.UnderlineStyle.None)}(a!==`weight`&&a!==`style`||a===r||n[a]===void 0)&&(n[a]=Array.isArray(i)?Object.freeze([...i]):i,t=!0)}return t?Object.freeze(n):null}var Su=class e{static{this.Type=`hyperlink`}constructor(e,t){this._address=e,this._friendly=t??null}static fromJSON(t){let n=t?.data,r=n?.address;return new e(r==null?null:``+r,n?.friendly)}getKind(){return Cu}getAddress(){return this._address}getFriendlyName(){return this._friendly}getProperty(e){return null}toString(){return``+(this._friendly??this._address??``)}toPrimitive(){return this._friendly??this._address??``}toJSON(){let t={address:this._address};return this._friendly!==null&&(t.friendly=this._friendly),{type:e.Type,data:t}}get isIRichData(){return!0}},Cu=Zl.create({name:Su.Type,fromJSON:Su.fromJSON}),wu=class e{static{this.Type=`image`}constructor(t,n){this._source=t,this._altText=n?.altText??null,this._sizing=n?.sizing??e.Sizing.Fit,this._height=n?.height??null,this._width=n?.width??null,this._resource=n?.resource??null}getKind(){return Ou}getSource(){return this._source}getAltText(){return this._altText}getSizing(){return this._sizing}getHeight(){return this._height}getWidth(){return this._width}getProperty(e){return null}toString(){return this._altText??``}getResource(){return this._resource}toJSON(t){let n={source:this._source};this._altText!==null&&(n.altText=this._altText),this._sizing!==e.Sizing.Fit&&(n.sizing=this._sizing),this._height!==null&&(n.height=this._height),this._width!==null&&(n.width=this._width);let r=this._resource&&!this._resource.isClosed()?t?.(this._resource)??null:null;return r!==null&&(n.resId=r),{type:e.Type,data:n}}get isIRichData(){return!0}};(wu||={}).Sizing={Fit:0,Fill:1,Original:2,Custom:3};var Tu,Eu,Du=e=>typeof e==`number`&&Number.isFinite(e)?e:null,Ou=Zl.create({name:wu.Type,label:`Image`,fromJSON(e,t){let n=e?.data,r=!0===n?.resource?.isIResource?n.resource:typeof n?.resId==`number`?t?.fromResourceId?.(n.resId)??null:null,i=n?.source?``+n.source:``,a=Du(n?.sizing);return new wu(i,{altText:typeof n?.altText==`string`?n.altText:null,sizing:a!==null&&a>=0&&a<=3?a:wu.Sizing.Fit,height:Du(n?.height),width:Du(n?.width),resource:r})}});(Eu=Tu||={}).toJSON=function(e,t){if(e==null)return null;if(V.isError(e))return{e:e.getCode()};if(!0===e.isIRichData){let n=e.toJSON?.(t);return n&&typeof n.then!=`function`?n:null}return e},Eu.fromJSON=function(e,t){if(e==null)return null;switch(typeof e){case`string`:case`number`:case`boolean`:return e}return typeof e!=`object`||typeof e.e!=`number`||`type`in e?ku.isJSON(e)?ku.fromJSON(e,t):null:V.getBuiltInByCode(e.e)??V.BuiltIn.Value},Eu.forEachRich=function e(t,n){if(typeof t!=`object`||!t||!0!==t.isIRichData||V.isError(t))return;let r=t;n(r);let i=r.getNestedValues?.();if(i)for(let t of i)e(t,n)};var ku,Au,ju=class e{static{this.Type=`array`}constructor(e){this._elements=Object.freeze(e.map(e=>Object.freeze([...e])))}static fromJSON(t,n){let r=t?.data?.elements;return Array.isArray(r)?new e(r.map(e=>Array.isArray(e)?e.map(e=>Tu.fromJSON(e,n)):[])):new e([])}getKind(){return Mu}getElements(){return this._elements}getNestedValues(){return this._elements.flat()}getProperty(e){return null}toArray(){return this._elements.map(e=>[...e])}toString(){return this._elements.map(e=>e.map(e=>``+(e??``)).join(`, `)).join(`; `)}toJSON(t){return{type:e.Type,data:{elements:this._elements.map(e=>e.map(e=>Tu.toJSON(e,t)))}}}get isIRichData(){return!0}},Mu=Zl.create({name:ju.Type,label:`Array`,fromJSON:ju.fromJSON}),Nu=new Map,Pu=new WeakMap,Fu=new Map,Iu=e=>n.JSONStableStringify(e)??``,Lu=e=>{let t=2166136261,n=-1623754710;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,16777619),n=Math.imul(n^i,16777619)^n>>>15}return(t>>>0).toString(16).padStart(8,`0`)+(n>>>0).toString(16).padStart(8,`0`)},Ru=e=>{let t=Iu(e),n=Fu.get(t);return n||(n=Object.freeze({...e}),Fu.set(t,n)),n},zu=class{constructor(e,t,n){this._kind=e,this._values=Object.freeze({...t});let r=null;if(n)for(let[e,t]of Object.entries(n))t&&((r??={})[e]=Ru(t));this._meta=r?Object.freeze(r):null}getKind(){return this._kind}getProperty(e){let t=this._values[e];return t===void 0?this._kind.getProperty(e)?.defaultValue??null:t}getPropertyMeta(e){return this._meta?.[e]??this._kind.getProperty(e)?.meta??null}getValues(){return this._values}getOwnMeta(){return this._meta}getNestedValues(){return Object.values(this._values)}toString(){let e=this._kind.getDisplayProperty(),t=e?this.getProperty(e):null;return t!==null&&typeof t!=`object`?``+t:`(${this._kind.getLabel()})`}toJSON(e){let t={};for(let[n,r]of Object.entries(this._values))t[n]=Tu.toJSON(r,e);let n={type:this._kind.getName(),data:t};return this._meta&&(n.meta=this._meta),n}get isIRichData(){return!0}};(function(e){e.defineKind=function(e,n){let r={label:n.label??e,properties:(n.properties??[]).map(e=>e.meta?{...e,meta:Ru(e.meta)}:e),displayProperty:n.displayProperty??null,...n.meta?{meta:Ru(n.meta)}:{}};return t({name:`${e}:${Lu(Iu(r))}`,...r})},e.kindFromJSON=function(e){return t(e)},e.getDefinedKind=function(e){return Nu.get(e)??null},e.toKindJSON=function(e){return Pu.get(e)??null};let t=e=>{let t=Nu.get(e.name);return t||(t=Zl.create({name:e.name,label:e.label,properties:e.properties,displayProperty:e.displayProperty,meta:e.meta,fromJSON:(e,n)=>{let r={},i=e?.data;if(i&&typeof i==`object`&&!Array.isArray(i))for(let[e,t]of Object.entries(i))r[e]=Tu.fromJSON(t,n);return new zu(t,r,e?.meta)}}),Nu.set(e.name,t),Pu.set(t,Object.freeze({...e})),t)}})(zu||={}),function(e){let t=new Map,n=!1,r=()=>{n||(n=!0,t.set(bu.getName(),bu),t.set(Cu.getName(),Cu),t.set(Ou.getName(),Ou),t.set(Mu.getName(),Mu))};function i(e){return r(),t.get(e)??zu.getDefinedKind(e)}function a(e){let t=e.toPrimitive?.();return t===null?void 0:t}function o(e){let t=e.getKind().getDisplayProperty();if(!t)return null;let n=e.getProperty(t);switch(typeof n){case`string`:return n;case`number`:case`boolean`:return``+n}return null}function s(e){let t=a(e);switch(typeof t){case`string`:return U.String;case`number`:return U.Number;case`boolean`:return U.Boolean}return V.isError(t)?U.Error:U.RichData}e.register=function(e){let n=e?.getName?.();if(!n)throw Error(`A rich data kind needs a name.`);r(),t.set(n,e)},e.get=i,e.kindOf=function(e){r();let n=e.getKind().getName();return t.get(n)??zu.getDefinedKind(n)},e.getTypes=function(){return r(),[...t.keys()]},e.fromJSON=function(e,t=Zl.DetachedContext){let n=e?.type?i(e.type):null;return n?n.fromJSON(e,t):new l(e)},e.isJSON=function(e){return!(!e||typeof e!=`object`||Array.isArray(e))&&!0!==e.isIRichData&&typeof e.type==`string`&&e.type.length>0},e.toPrimitive=a,e.toDisplayText=o,e.toPlaceholderText=function(e){let t=o(e);if(t!==null)return t;let n=e.getKind(),r=n.getLabel();return`(${r===n.getName()?N(`richData.placeholder`):r})`},e.layoutTypeOf=function(e){let t=s(e);return t===U.RichData?o(e)===null?U.RichData:U.String:t},e.primitiveTypeOf=s,e.toArray=function(e){return e.toArray?.()??null};let c=e=>typeof e==`number`?`number`:typeof e==`boolean`?`boolean`:!0===e?.isIRichData?`rich`:Array.isArray(e)?`array`:`string`;class l{constructor(e){this._kind=null,this._json=Object.freeze({type:e?.type??`unknown`,data:e?.data})}getKind(){if(!this._kind){let e=this._json.data,t=[];if(e&&typeof e==`object`&&!Array.isArray(e))for(let[n,r]of Object.entries(e))t.push({name:n,valueType:c(r)});this._kind=Zl.create({name:this._json.type,properties:t,fromJSON:e=>new l(e)})}return this._kind}getProperty(e){let t=this._json.data,n=t&&typeof t==`object`?t[e]:void 0;return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:null}toString(){return`(${this._json.type})`}toJSON(){return this._json}get isIRichData(){return!0}}e.Unmodeled=l}(ku||={}),function(e){e.CaseInsensitiveOptions={sensitivity:`accent`},e.CaseSensitiveOptions={sensitivity:`variant`};let t=e.NumberCollator=Object.freeze({type:U.Number,compare:(e,t,n)=>e===t?0:e<t?-1:1}),n=e.StringCollator=Object.freeze({type:U.String,compare:(e,t,n)=>$l.compareTextWith(e,t,$l.collatorFor(n?.locale??`en`,n),$l.isCaseInsensitive(n)),defaultOptions:Au.CaseInsensitiveOptions}),r=e.ErrorCollator=Object.freeze({type:U.Error,compare:(e,t,n)=>e.getCode()-t.getCode()}),i=e.NullCollator=Object.freeze({type:U.Null,compare:(e,t,n)=>0}),a=e.RichDataCollator=Object.freeze({type:U.RichData,compare:(e,t,n)=>{let r=e.getKind().getName().localeCompare(t.getKind().getName(),n?.locale??`en`);if(r!==0)return r;let i=ku.toPrimitive(e),a=ku.toPrimitive(t);return typeof i==`string`&&typeof a==`string`?i.localeCompare(a,n?.locale??`en`,n):typeof i==`number`&&typeof a==`number`?i-a:r}}),o=e.BooleanCollator=Object.freeze({type:U.Boolean,compare:(e,t,n)=>e===t?0:e?1:-1});e.DefaultRangeOptions=Object.freeze({hasHeader:!1,reverse:!1,includeHidden:!1,collatorOptions:Au.CaseInsensitiveOptions,axis:B.Axis.Row}),e.DefaultCollators=Object.freeze([t,n,o,a,r,i])}(Au||={});var Bu={},Vu={};function Hu(e,t,n=1){if(e){let r=e[0],i=e.slice(1);r===`!`?Hu(i,t,4):r===`?`?Hu(i,t,2):(t[r]=t[r]||{},Hu(i,t[r],n))}else t.$=n}function Uu(e,t){Hu(e,t),Hu(e+` x`,t),Hu(e+` l`,t),Hu(e+` l x`,t),Hu(`l `+e,t),Hu(`l `+e+` x`,t),Hu(e+` D`,t),Hu(e+` D x`,t),Hu(`D `+e,t),Hu(`D `+e+` x`,t)}`!d-m-y.!d-m-Y.!j-m-y.!j-m-Y.!d-n-y.!d-n-Y.!j-n-y.!j-n-Y.?m-d-y.?m-d-Y.?m-j-y.?m-j-Y.?n-d-y.?n-d-Y.?n-j-y.?n-j-Y.d-M-y.d-M-Y.j-M-y.j-M-Y.M-d-y.M-d-Y.M-j-y.M-j-Y.d-F-y.d-F-Y.F-d-y.F-d-Y.F-j-y.F-j-Y.j-F-y.j-F-Y.y-F-d.y-F-j.y-M-d.y-M-j.Y-F-d.Y-F-j.Y-M-d.Y-m-d.Y-M-j.Y-m-j.Y-n-d.Y-n-j.j-F.j-M.d-F.d-M.n-d.n-j.n-Y.m-d.m-j.m-Y.M-Y.M-y.F-y.F-Y.Y-M.Y-n.Y-m.Y-F.Y-M`.split(`.`).forEach(e=>{e.startsWith(`?`)||Uu(e,Bu),e.startsWith(`!`)||Uu(e,Vu)}),new Date().getUTCFullYear();var Wu=` `,Gu=`\xA0`,Ku=` `,qu=`'`,Ju=`٬`,Yu={".":[`,`,Gu,Ku,qu,Ju],",":[`.`,Gu,Ku,qu,Ju],"٫":[`.`,Gu,Ku,qu,Ju]},Xu=e=>e?.length===1&&e>=`0`&&e<=`9`;function Zu(e,t={}){let n=Me(t.locale||``)||tt,r=n.decimal,i=[...Yu[r]||[qu,Ju]];i.includes(n.group)||n.group===Wu||n.group===r||i.push(n.group);let a=``,o=``,s=1,c=``,l=!1,u=!1,d=!1,f=!1,p=!1,m=null,h=!1,g=0,_=[Wu,Gu,Ku,`+`,`%`,`(`,`-`].concat(gt);for(;_.includes(e[g]);){let t=e[g];if(t===`-`){if(l||u)return null;l=!0,s=-1}else if(it.test(t)){if(p)return null;p=!0,m=t}else if(t===`(`){if(u||l)return null;u=!0,s=-1}else if(t===`%`){if(f)return null;f=!0}g++}let v,y=!1;if(e[g]===r||Xu(e[g]))for(;g<e.length;){let t=e[g];if(!v&&i.includes(t))v=t;else if(!(v&&v===t)){if(t===r){if(y)break;a+=`.`,y=!0}else{if(!Xu(t))break;a+=t}}g++}if(e[g]===`e`||e[g]===`E`){o+=e[g],g++,e[g]!==`+`&&e[g]!==`-`||(o+=e[g],g++);let t=g;for(;Xu(e[g]);)o+=e[g],g++;if(t===g)return null}let b=[Wu,Gu,Ku,`%`,`$`,`)`].concat(gt);for(;b.includes(e[g]);){let t=e[g];if(it.test(t)){if(p)return null;p=!0,m=t,h=!0}else if(t===`)`){if(d||!u)return null;d=!0}else if(t===`%`){if(f)return null;f=!0}g++}if(g!==e.length)return null;let x=parseFloat(a+o);if(!isFinite(x))return null;if(o){if(f||p)return null;c=`0.00E+00`}else if(f){if(p)return null;c=a.includes(`.`)?`0.00%`:`0%`,x*=.01}else if(p){let e=a.includes(`.`)?`#,##0.00`:`#,##0`;c=h?e+m:m+e}else v&&(c=a.includes(`.`)?`#,##0.00`:`#,##0`);let S={v:x*s};return c&&(S.z=c),S}var Qu,$u,ed=ee({DateUnit:()=>td,nowWithPrecision:()=>nd}),td={Day:`d`,Weekday:`wd`,Month:`m`,Year:`y`};function nd(e=6e4){return new Date(Math.floor(Date.now()/e)*e)}($u=Qu||={}).Kind={Worksheet:`worksheet`,Chart:`chart`,Macro:`macro`,Dialog:`dialog`},$u.Visibility={Visible:`visible`,Hidden:`hidden`,VeryHidden:`veryHidden`};var rd=null;function id(e){if(e<128||e>65535||e>=55296&&e<=57343)return!1;if(!rd){rd=new Uint8Array(8192);for(let e of`80-A0 A2-A3 A5-A6 A9 AB-AC AE BB 378-379 37E-383 387 38B 38D 3A2 524-530 557-558 55A-560 588-590 5BE 5C0 5C3 5C6 5C8-5CF 5EB-5EF 5F3-5FF 604-605 609-60A 60C-60D 61B-61E 620 65F 66A-66D 6D4 700-70E 74B-74C 7B2-7BF 7F7-7F9 7FB-900 93A-93B 94E-94F 955-957 964-965 970 973-97A 980 984 98D-98E 991-992 9A9 9B1 9B3-9B5 9BA-9BB 9C5-9C6 9C9-9CA 9CF-9D6 9D8-9DB 9DE 9E4-9E5 9FB-A00 A04 A0B-A0E A11-A12 A29 A31 A34 A37 A3A-A3B A3D A43-A46 A49-A4A A4E-A50 A52-A58 A5D A5F-A65 A76-A80 A84 A8E A92 AA9 AB1 AB4 ABA-ABB AC6 ACA ACE-ACF AD1-ADF AE4-AE5 AF0 AF2-B00 B04 B0D-B0E B11-B12 B29 B31 B34 B3A-B3B B45-B46 B49-B4A B4E-B55 B58-B5B B5E B64-B65 B72-B81 B84 B8B-B8D B91 B96-B98 B9B B9D BA0-BA2 BA5-BA7 BAB-BAD BBA-BBD BC3-BC5 BC9 BCE-BCF BD1-BD6 BD8-BE5 BFB-C00 C04 C0D C11 C29 C34 C3A-C3C C45 C49 C4E-C54 C57 C5A-C5F C64-C65 C70-C77 C80-C81 C84 C8D C91 CA9 CB4 CBA-CBB CC5 CC9 CCE-CD4 CD7-CDD CDF CE4-CE5 CF0 CF3-D01 D04 D0D D11 D29 D3A-D3C D45 D49 D4E-D56 D58-D5F D64-D65 D76-D78 D80-D81 D84 D97-D99 DB2 DBC DBE-DBF DC7-DC9 DCB-DCE DD5 DD7 DE0-DF1 DF4-E00 E3B-E3E E4F E5A-E80 E83 E85-E86 E89 E8B-E8C E8E-E93 E98 EA0 EA4 EA6 EA8-EA9 EAC EBA EBE-EBF EC5 EC7 ECE-ECF EDA-EDB EDE-EFF F04-F12 F3A-F3D F48 F6D-F70 F85 F8C-F8F F98 FBD FCD FD0-FFF 104A-104F 109A-109D 10C6-10CF 10FB 10FD-10FF 115A-115E 11A3-11A7 11FA-11FF 1249 124E-124F 1257 1259 125E-125F 1289 128E-128F 12B1 12B6-12B7 12BF 12C1 12C6-12C7 12D7 1311 1316-1317 135B-135E 1361-1368 137D-137F 139A-139F 13F5-1400 166D-166E 1677-167F 169B-169F 16EB-16ED 16F1-16FF 170D 1715-171F 1735-173F 1754-175F 176D 1771 1774-177F 17D4-17D6 17D8-17DA 17DE-17DF 17EA-17EF 17FA-180A 180F 181A-181F 1878-187F 18AB-18FF 191D-191F 192C-192F 193C-193F 1941-1945 196E-196F 1975-197F 19AA-19AF 19CA-19CF 19DA-19DF 1A1C-1AFF 1B4C-1B4F 1B5A-1B60 1B7D-1B7F 1BAB-1BAD 1BBA-1BFF 1C38-1C3F 1C4A-1C4C 1C7E-1CFF 1DE7-1DFD 1F16-1F17 1F1E-1F1F 1F46-1F47 1F4E-1F4F 1F58 1F5A 1F5C 1F5E 1F7E-1F7F 1FB5 1FC5 1FD4-1FD5 1FDC 1FF0-1FF1 1FF5 1FFF 2011-2012 2017 201A-201B 201E-201F 2022-2024 2031 2034 2036-203A 203C-2043 2045-2051 2053-205E 2065-2069 2072-2073 207D-207E 208D-208F 2095-209F 20B6-20CF 20F1-20FF 2150-2152 2189-218F 2329-232A 23E8-23FF 2427-243F 244B-245F 269E-269F 26BD-26BF 26C4-2700 2705 270A-270B 2728 274C 274E 2753-2755 2757 275F-2760 2768-2775 2795-2797 27B0 27BF 27C5-27C6 27CB 27CD-27CF 27E6-27EF 2983-2998 29D8-29DB 29FC-29FD 2B4D-2B4F 2B55-2BFF 2C2F 2C5F 2C70 2C7E-2C7F 2CEB-2CFC 2CFE-2CFF 2D26-2D2F 2D66-2D6E 2D70-2D7F 2D97-2D9F 2DA7 2DAF 2DB7 2DBF 2DC7 2DCF 2DD7 2DDF 2E00-2E2E 2E30-2E7F 2E9A 2EF4-2EFF 2FE0-2FEF 3018-301C 3030 303D 3040 3097-3098 30A0 3100-3104 312E-3130 318F 31B8-31BF 31E4-31EF 321F 3244-324F 32FF A48D-A48F A4C7-A4FF A60D-A60F A62C-A63F A660-A661 A673-A67B A67E A698-A6FF A78D-A7FA A82C-A83F A874-A87F A8C5-A8CF A8DA-A8FF A92F A954-A9FF AA37-AA3F AA4E-AA4F AA5A-ABFF D7A4-D7FF FA2E-FA2F FA6B-FA6F FADA-FAFF FB07-FB12 FB18-FB1C FB37 FB3D FB3F FB42 FB45 FBB2-FBD2 FD3E-FD4F FD90-FD91 FDC8-FDEF FDFE-FDFF FE10-FE1F FE27-FE2F FE32 FE45-FE48 FE53 FE58 FE67 FE6C-FE6F FE75 FEFD-FEFE FF00 FF5F-FF60 FFBF-FFC1 FFC8-FFC9 FFD0-FFD1 FFD8-FFD9 FFDD-FFDF FFE7 FFEF-FFF8 FFFE-FFFF`.split(` `)){let t=e.indexOf(`-`),n=parseInt(t<0?e:e.slice(0,t),16),r=t<0?n:parseInt(e.slice(t+1),16);for(let e=n;e<=r;e++)rd[e>>3]|=1<<(7&e)}}return!!(rd[e>>3]&1<<(7&e))}var ad,od,sd,cd,ld=new RegExp(/^([$]?[a-zA-Z]*[$]?[0-9]*)(?::([$]?[a-zA-Z]*[$]?[0-9]*))?$/),ud=new RegExp(/^(R(?:\[?[-+]?\d+\]?|\d+)?C(?:\[?[-+]?\d+\]?|\d+)?)(?::(R(?:\[?[-+]?\d+\]?|\d+)?C(?:\[?[-+]?\d+\]?|\d+)?))?$/,`i`),dd=new RegExp(/^(R?)(\[?[-+]?\d+\]?|\d+)?(C?)(\[?[-+]?\d+\]?|\d+)?$/,`i`),fd=RegExp(`(?:(?:'(?:[^']|'')+'|\\[[^\\]]+\\][A-Za-z0-9_.]*(?::[A-Za-z0-9_.]+)?|[A-Za-z0-9_.]+(?::[A-Za-z0-9_.]+)?)!)?(\\$?[A-Za-z]+\\$?\\d+(?::\\$?[A-Za-z]+\\$?\\d+)?|\\$?[A-Za-z]+:\\$?[A-Za-z]+|\\$?\\d+:\\$?\\d+)`,`g`),pd=/\s+/g,md=/"(?:[^"]|"")*"|\[[^[\]]+\](?![A-Za-z0-9_.]*(?::[A-Za-z0-9_.]+)?!)/g,hd=/[\uE000-\uF8FF]/g,gd=`#REF!`,_d=2**14,vd=2**20,yd=_d,bd=vd;function xd(e){return ad===e?od:(ad=e,od=``+(e+1))}function Sd(e){if(sd===e)return cd;sd=e,e<0&&console.warn(`invalid column `+e);let t=``;for(++e;e;e=Math.floor((e-1)/26))t=String.fromCharCode((e-1)%26+65)+t;return cd=t}var Cd=/[^A-Za-z_.\d\u007F-\uFFFF[\]:]/,wd=/^\d/,Td=/^([A-Za-z]{1,3})(\d{1,7})$/,Ed=/^(?:[Rr](?:\[-?\d+\]|\d+)?(?:[Cc](?:\[-?\d+\]|\d+)?)?|[Cc](?:\[-?\d+\]|\d+)?)$/,Dd=/^(?:TRUE|FALSE)$/i,Od=/^[Rr](\d+)[Cc](\d*)./,kd=/^(?:[Rr](\d+)|[Rr]?[Cc](\d+))[^.]/,Ad=1048576,jd=e=>{let t=Number(e);return t>=1&&t<=Ad},Md=e=>{let t=Number(e);return t>=1&&t<=16384};function Nd(e){if(e.charCodeAt(0)===46)return!0;for(let t=0;t<e.length;t++)if(id(e.charCodeAt(t)))return!0;let t=Od.exec(e);if(t)return jd(t[1])&&(t[2]===``||Md(t[2]));let n=kd.exec(e);return!!n&&(n[1]===void 0?Md(n[2]):jd(n[1]))}var Pd=/^\[[^\]]*\]/;function Fd(e){return e?Sd(e.colIndex)+xd(e.rowIndex):null}function Id(e){if(!e)return gd;let t=Sd(e.colIndex),n=xd(e.rowIndex);return(e.$colIndex?`$`+t:t)+(e.$rowIndex?`$`+n:n)}function Ld(e,t){let n=e??t;if(n){n=mn(n),n=n.replace(/'/g,`''`);let e=Cd.test(n);if(!e){let t=n.replace(Pd,``).split(`:`);for(let n=0;n<t.length&&!e;n++)e=wd.test(t[n])||Nd(t[n]);e||t.length!==1||(e=function(e){let t=Td.exec(e);if(t){let e=t[1].toUpperCase(),n=0;for(let t=0;t<e.length;t++)n=26*n+(e.charCodeAt(t)-64);let r=Number(t[2]);if(n<=16384&&r>=1&&r<=Ad)return!0}return Ed.test(e)||Dd.test(e)}(t[0]))}e&&(n=hn(n))}return n}function Rd(e,t){return e?e+(e.endsWith(`!`)?``:`!`)+t:gd}function zd(e,t,n=Fd){if(!e)return null;if(typeof e==`string`)return e;if(V.isError(e))return e.toString();let r=e,i=r.colStart,a=r.rowStart,o=r.colEnd,s=r.rowEnd;if(i===o&&a===s)return n({colIndex:i,rowIndex:a});t&&(r={...t,...r});let c=i===-(2**53-1)||t&&i<=t.colStart&&o>=t.colEnd,l=a===-(2**53-1)||t&&a<=t.rowStart&&s>=t.rowEnd,u,d;return u=l?Sd(i):c?xd(a):n({colIndex:i,rowIndex:a}),d=l?Sd(o):c?xd(s):n({colIndex:o,rowIndex:s}),u+`:`+d}function Bd(e,t){if(!e||!t)return null;let n=e.rowStart===-(2**53-1)||e.rowStart<=t.rowStart&&e.rowEnd>=t.rowEnd,r=e.colStart===-(2**53-1)||e.colStart<=t.colStart&&e.colEnd>=t.colEnd;return n&&!r?(e.$colStart?`$`:``)+Sd(e.colStart)+`:`+((e.$colEnd?`$`:``)+Sd(e.colEnd)):r&&!n?(e.$rowStart?`$`:``)+xd(e.rowStart)+`:`+((e.$rowEnd?`$`:``)+xd(e.rowEnd)):null}function Vd(e,t,n=!1){return(n?vf({colIndex:e.colStart,rowIndex:e.rowStart,$colIndex:e.$colStart,$rowIndex:e.$rowStart,scope:e.scope},t):Ud({colIndex:e.colStart,rowIndex:e.rowStart,$colIndex:e.$colStart,$rowIndex:e.$rowStart,scope:e.scope},t))+`:`+(n?vf({colIndex:e.colEnd,rowIndex:e.rowEnd,$colIndex:e.$colEnd,$rowIndex:e.$rowEnd},null):Ud({colIndex:e.colEnd,rowIndex:e.rowEnd,$colIndex:e.$colEnd,$rowIndex:e.$rowEnd},null))}function Hd(e,t,n=!1){return n?vf(e,t):Ud(e,t)}function Ud(e,t,n=Id){if(!e)return gd;let r=e.colIndex,i=e.rowIndex,a=r===-(2**53-1),o;return i===-(2**53-1)?(o=Sd(r),e.$colIndex&&(o=`$`+o)):a?(o=xd(i),e.$rowIndex&&(o=`$`+o)):o=n(e),(e.scope||t)&&(o=Rd(Ld(e.scope,t),o)),o}function Wd(e,t,n=Id,r){if(!e)return gd;let i=e.rowStart!==void 0&&e.rowStart===e.rowEnd,a=e.colStart!==void 0&&e.colStart===e.colEnd&&i;if(!r&&a)return n({colIndex:e.colStart,rowIndex:e.rowStart,$colIndex:e.$colStart,$rowIndex:e.$rowStart});e={...t,...e};let o=!r&&t&&e.rowStart<=t.rowStart&&e.rowEnd>=t.rowEnd,s=!r&&t&&e.colStart<=t.colStart&&e.colEnd>=t.colEnd,c,l;return o?(c=Sd(e.colStart),c=e.$colStart?`$`+c:c):s?(c=xd(e.rowStart),c=e.$rowStart?`$`+c:c):c=n({colIndex:e.colStart,rowIndex:e.rowStart,$colIndex:e.$colStart,$rowIndex:e.$rowStart}),o?(l=Sd(e.colEnd),l=e.$colEnd?`$`+l:l):s?(l=xd(e.rowEnd),l=e.$rowEnd?`$`+l:l):l=n({colIndex:e.colEnd,rowIndex:e.rowEnd,$colIndex:e.$colEnd,$rowIndex:e.$rowEnd}),c+`:`+l}function Gd(e,t,n=Id){let r=Wd(e,t,n),i=Ld(e?.scope,t?.scope);return i?Rd(i,r):r}function Kd(e,t=!1){if(!e)return null;let n=0,r=0,i=!1,a=!1,o=e.length;for(let s=0;s<o;++s){let o=e.charCodeAt(s);if(o>=48&&o<=57){if(r=10*r+(o-48),n===0&&!t)return}else if(o>=65&&o<=90){if(n=26*n+(o-64),r!==0)return}else if(o>=97&&o<=122){if(n=26*n+(o-96),r!==0)return}else{if(o!==36)return;if(n!==0||i){if(r!==0||a)return;a=!0}else i=!0}}let s={};return t||r!==0&&n!==0?(n>0&&(s.colIndex=n-1,i&&(s.$colIndex=i)),r>0&&(s.rowIndex=r-1,(a||t&&n===0&&i)&&(s.$rowIndex=!0)),s):null}var qd=e=>{let t=e.lastIndexOf(`!`);if(t===-1)return null;let n=e.slice(0,t);return n=mn(n),n=n.replace(/''/g,`'`),[n,e.slice(t+1)]};function Jd(e,t=lB,n=!1){if(!e)return null;let r=df(e.toUpperCase(),n),i=null,a=null;if(r?.[1]){let e=!!r[2],t=n?sf:Kd;i=t(r[1],e),a=t(r[2]??r[1],e)}if(!i&&!a||i&&a&&(i.rowIndex===void 0&&a.rowIndex!==void 0||i.rowIndex!==void 0&&a.rowIndex===void 0||i.colIndex===void 0&&a.colIndex!==void 0||i.colIndex!==void 0&&a.colIndex===void 0))return null;let o={};return i&&(i.colIndex!==void 0&&(o.colStart=i.colIndex),i.rowIndex!==void 0&&(o.rowStart=i.rowIndex),i.$colIndex!==void 0&&(o.$colStart=i.$colIndex),i.$rowIndex!==void 0&&(o.$rowStart=i.$rowIndex),o?.colStart!==void 0&&o?.colStart>t?.colEnd)?null:(a&&(a.colIndex!==void 0&&(o.colEnd=a.colIndex),a.rowIndex!==void 0&&(o.rowEnd=a.rowIndex),a.$colIndex!==void 0&&(o.$colEnd=a.$colIndex),a.$rowIndex!==void 0&&(o.$rowEnd=a.$rowIndex)),o.colStart===void 0&&(o.colStart=t.colStart),o.colEnd===void 0&&(o.colEnd=t.colEnd),o.rowStart===void 0&&(o.rowStart=t.rowStart),o.rowEnd===void 0&&(o.rowEnd=t.rowEnd),t.scope&&(o.scope=t.scope),o)}function Yd(e,t,n=!1){let r,i=qd(e);if(i){let a=e.lastIndexOf(`!`),o=e.indexOf(`:`);if(o!==-1&&o<a){let t=e.indexOf(`!`),n=e.indexOf(`:`,t),r=qd(e.slice(0,n)),a=qd(e.slice(n+1));if(!r||!a||r[0].toUpperCase()!==a[0].toUpperCase())return null;i=[r[0],`${r[1]}:${a[1]}`]}if(r=Jd(i[1],t,n),!r)return null;r.scope=i[0]}else r=Jd(e,t,n);return r||null}function Xd(e){let t=[],n=e.length,r=0,i=0,a=!1;for(let o=0;o<n;o++){let s=e.charCodeAt(o);if(i>0){if(s===39){let t=e.charCodeAt(o+1);t!==91&&t!==93&&t!==35&&t!==39||o++}else s===91?i++:s===93&&i--}else if(a)s===39&&(a=!1);else if(s===39)a=!0;else if(s===91)i++;else if(s===44){for(t.push(e.substring(r,o).trimEnd()),r=o+1;r<n&&/\s/.test(e.charAt(r));)r++;o=r-1}}return t.push(e.substring(r)),t}function Zd(e,t,n=Wd,r=Id,i=!1){if(!e||e.length===0)return null;let a=[],o=e.length;for(let i=0;i<o;i++){let o=e[i],s=null;o?o.rowIndex!==void 0||o.colIndex!==void 0?s=r(o):o.rowStart!==void 0||o.colStart!==void 0?s=n(o,t,r):typeof o==`string`?s=o:`nameId`in o?s=o.nameId:V.isError(o)&&(s=o.toString()):s=gd,s&&a.push(s)}return a}function Qd(e,t,n=Gd,r=Id,i=!1){let a=Zd(e,t,n,r,i);return a?a.join(`,`):gd}var $d=e=>e!==void 0&&e!==-(2**53-1)&&e!==2**53-1,ef=(e,t)=>{if(!e||e.scope)return e;let n=t.getWorksheet?.()?.getName();return n?{...e,scope:n}:e},tf=e=>new k(N(`error.address.notAnAddress`,{address:typeof e==`object`?JSON.stringify(e):String(e)}));function nf(e){let[t,n,r,i]=Array.from(e);if(!(e.length===4&&Array.from(e).every(e=>Number.isInteger(e)&&e>=0)&&r>=t&&i>=n))throw tf(Array.from(e).join(`,`));return{rowStart:t,colStart:n,rowEnd:r,colEnd:i}}var rf=(e,t,n,r=Yd,i,a=!1)=>{if(t!==null){if(typeof t==`string`){let o=r(t,n,a);if(!o){let o=i?.(t);if(o){let t=o.length;for(let s=0;s<t;s++){let t=o[s];rf(e,t,n,r,i,a)}}return}t=o}else t.isICellRange?t=ef(t.getCoords(),t):t.isICell&&(t=ef(h.cellToRange(t.getCoords()),t));if(t!==null){if(t.rowStart!==void 0||t.colStart!==void 0||t.colEnd!==void 0||t.rowEnd!==void 0){let r=t;e.push({...n,...r,colStart:$d(r.colStart)?r.colStart:n.colStart,rowStart:$d(r.rowStart)?r.rowStart:n.rowStart,colEnd:$d(r.colEnd)?r.colEnd:n.colEnd,rowEnd:$d(r.rowEnd)?r.rowEnd:n.rowEnd})}else if(t.rowIndex!==void 0||t.colIndex!==void 0){let r=t,i={...n,...r,colStart:r.colIndex,rowStart:r.rowIndex,colEnd:r.colIndex,rowEnd:r.rowIndex};i.scope===null&&n.scope&&(i.scope=n.scope),delete i.colIndex,delete i.rowIndex,e.push(i)}else if(!V.isError(t))throw tf(t)}else e.push(null)}else e.push(null)};function af(e,t,n=Yd,r,i=!1){if(e==null)return[t];if(e===``)throw tf(e);let a;if(typeof e==`string`)a=Xd(e);else if(e.isICellRanges){let t=e;a=t.getCoords().map(e=>ef(e,t))}else a=e.isIReferenceRange?[e.getCoords()]:Array.isArray(e)?e:[e];let o=[],s=a.length;for(let e=0;e<s;e++){let s=a[e];rf(o,s,t,n,r,i)}return o}function of(e,t){let n=0,r=0,i=e.length;for(let t=0;t<i;++t){let i=e.charCodeAt(t);if(i>=48&&i<=57){if(n=10*n+(i-48),r===0)return}else if(i>=65&&i<=90){if(r=26*r+(i-64),n!==0)return}else if(!(i>=97&&i<=122)||(r=26*r+(i-96),n!==0))return}return t?(t.colIndex=r-1,t.rowIndex=n-1,t):{colIndex:r-1,rowIndex:n-1}}function sf(e,t=!1,n){n?(n.colIndex=-(2**53-1),n.rowIndex=-(2**53-1),n.$colIndex=!1,n.$rowIndex=!1):n={colIndex:-(2**53-1),rowIndex:-(2**53-1),$colIndex:!1,$rowIndex:!1};let r=dd.exec(e);if(!r)return null;let i=r[1],a=r[3];if(!(t||i&&a))return null;if(i){let e=r[2];e?e&&(e.startsWith(`[`)?(n.rowIndex=parseInt(e.slice(1,-1)),n.$rowIndex=!1):(n.rowIndex=parseInt(e)-1,n.$rowIndex=!0)):(n.rowIndex=0,n.$rowIndex=!1)}if(a){let e=r[4];e?e.startsWith(`[`)?(n.colIndex=parseInt(e.slice(1,-1)),n.$colIndex=!1):(n.colIndex=parseInt(e)-1,n.$colIndex=!0):(n.colIndex=0,n.$colIndex=!1)}return n}function cf(e,t){let n=0,r=0,i=!1,a=!1,o=e.length;for(let t=0;t<o;++t){let o=e.charCodeAt(t);o>=48&&o<=57?n=10*n+(o-48):o>=65&&o<=90?r=26*r+(o-64):o>=97&&o<=122?r=26*r+(o-96):o===36&&(t===0?i=!0:a=!0)}return r--,n--,t.colIndex=r,t.rowIndex=n,n===-1?(t.$colIndex=i,t.$rowIndex=!1,t):r===-1?(t.$colIndex=!1,t.$rowIndex=i,t):(t.$colIndex=i,t.$rowIndex=a,t)}function lf(e){let t=0,n=e.length;for(let r=0;r<n;++r){let n=e.charCodeAt(r);if(n>=65&&n<=90)t=26*t+(n-64);else{if(!(n>=97&&n<=122))return t-1;t=26*t+(n-96)}}return t-1}function uf(e,t){let n=t;n?(n.rowStart=0,n.colStart=0,n.rowEnd=0,n.colEnd=0):n={rowStart:0,colStart:0,rowEnd:0,colEnd:0};let r=0,i=0,a=0,o=e.length;for(r=0;i<o;++i){if(a=e.charCodeAt(i),a>96&&a<123&&(a-=32),a<65||a>91){if(a===36)continue;break}r=26*r+(a-64)}for(n.colStart=--r,r=0;i<o;++i){let t=e.charCodeAt(i)-48;if(t<0||t>9)break;r=10*r+t}if(n.rowStart=--r,i===o||e.charCodeAt(++i)===58)return n.colEnd=n.colStart,n.rowEnd=n.rowStart,n;for(r=0;i!==o;++i){if(a=e.charCodeAt(i),a>96&&a<123&&(a-=32),a<65||a>91){if(a===36)continue;break}r=26*r+(a-64)}for(n.colEnd=--r,r=0;i!==o;++i){let t=e.charCodeAt(i)-48;if(t<0||t>9)break;r=10*r+t}return n.rowEnd=--r,n}function df(e,t=!1){let n=e.match(t?ud:ld);return e.endsWith(`:`)?null:n}var ff={rowIndex:-1,colIndex:-1,$colIndex:!1,$rowIndex:!1};function pf(e,t,n,r=_d){let i=e,a,o=e.lastIndexOf(`!`),s=``;o!==-1&&(s=e.slice(0,o)+`!`,e=e.slice(o+1));let c=()=>{let e=``,r=a.rowIndex;if(r!==-1){if(a.$rowIndex)e+=`R${r+1}`;else{let n=r-t;e+=n===0?`R`:`R[${n}]`}}let i=``,o=a.colIndex;if(o!==-1){if(a.$colIndex)i+=`C${o+1}`;else{let e=o-n;i+=e===0?`C`:`C[${e}]`}}s+=e+i};o=e.lastIndexOf(`:`);let l=o!==-1;if(l){let t=e.slice(0,o);e=e.slice(o+1),a=cf(t,ff),a.colIndex!==-1&&a.rowIndex!==-1&&(c(),s+=`:`)}return a=cf(e,ff),!l&&a.colIndex>r?i:(c(),s)}var mf=[],hf=e=>(mf.push(e),String.fromCharCode(57344+mf.length-1)),gf=e=>mf[e.charCodeAt(0)-57344];function _f(e,t,n){let r=``,i=e.length;for(let a=0;a<i;a++){let i=e[a];r+=typeof i==`string`?i:yf(i,t,n)}return r}function vf(e,t){let n=``,r=e.rowIndex;r!==-(2**53-1)&&(e.$rowIndex?n+=`R${r+1}`:n+=r===0?`R`:`R[${r}]`);let i=``,a=e.colIndex;return a!==-(2**53-1)&&(e.$colIndex?i+=`C${a+1}`:i+=a===0?`C`:`C[${a}]`),e.scope&&(n=Ld(e.scope,t)+`!`+n),n+i}function yf(e,t,n){let r,i=e.scope;r=i?Ld(i)+`!`:``;let a=e.colIndex;a!==-(2**53-1)&&(e.$colIndex?r+=`$`+Sd(a):r+=Sd(a+n));let o=e.rowIndex;return o!==-(2**53-1)&&(e.$rowIndex?r+=`$`+xd(o):r+=xd(o+t)),r}function bf(e,t,n,r){let i=e.colStart,a=e.rowStart,o=e.colEnd,s=e.rowEnd,c=e.$colStart??!1,l=e.$rowStart??!1,u=e.$colEnd??!1,d=e.$rowEnd??!1;if(c||i===-(2**53-1)||(i+=n),l||a===-(2**53-1)||(a+=t),u||o===2**53-1||(o+=n),d||s===2**53-1||(s+=t),i>o){let e=i;i=o,o=e}if(a>s){let e=a;a=s,s=e}let f;return r?(f=r,f.colStart=i,f.rowStart=a,f.colEnd=o,f.rowEnd=s,f.$colStart=c,f.$rowStart=l,f.$colEnd=u,f.$rowEnd=d):f={colStart:i,rowStart:a,colEnd:o,rowEnd:s,$colStart:c,$rowStart:l,$colEnd:u,$rowEnd:d},e.scope?f.scope=e.scope:f.scope&&(f.scope=null),f}function xf(e,t,n){let r=e.$colStart??!1,i=e.$rowStart??!1,a=e.$colEnd??!1,o=e.$rowEnd??!1,s={colStart:r?e.colStart:e.colStart-n,rowStart:i?e.rowStart:e.rowStart-t,colEnd:a?e.colEnd:e.colEnd-n,rowEnd:o?e.rowEnd:e.rowEnd-t,$colStart:r,$rowStart:i,$colEnd:a,$rowEnd:o};return e.scope&&(s.scope=e.scope),s}function Sf(e,t,n){let r=e.$colIndex??!1,i=e.$rowIndex??!1,a={colIndex:r?e.colIndex:e.colIndex-n,rowIndex:i?e.rowIndex:e.rowIndex-t,$colIndex:r,$rowIndex:i};return e.scope&&(a.scope=e.scope),a}function Cf(e,t,n,r){mf.length=0;let i=e.replace(md,hf),a=0,o=i.replace(fd,(e,o,s)=>{let c=pf(e,t,n);if(r){if(s>a){let e=i.slice(a,s);r.push(e.replace(hd,gf))}let o,l=e,u=l.lastIndexOf(`!`);u!==-1&&(o=l.slice(0,u).replace(hd,gf),l=l.slice(u+1));let d=l.lastIndexOf(`:`),f;if(d!==-1){let e=l.slice(0,d),i=l.slice(d+1),a=pf(e,t,n),o=pf(i,t,n);f=sf(a,!0),r.push(f??a),r.push(`:`),r.push(sf(o,!0)??o)}else f=sf(pf(l,t,n),!0),r.push(f??c.replace(hd,gf));o&&f&&(f.scope=o)}return a=s+e.length,c});if(r&&a<i.length){let e=i.slice(a);r.push(e.replace(hd,gf))}return o=o.toUpperCase().replace(pd,``),o.replace(hd,gf)}function wf(e,t){let n,r,i;return Array.isArray(e)?(n=e[0],r=e[1]):e.r===void 0?n=e:(n=e.r,r=e.v),Array.isArray(n)&&(n=n[0]),i=typeof n==`string`?Jd(n,t):h.sanitizeRange(n,t),r!==void 0&&i&&(i.value=r),i}function Tf(e,t){let n,r;Array.isArray(e)?(n=e[0],r=e[1]):e.r===void 0?n=e:(n=e.r,r=e.v);let i=[],a=e=>{let n=typeof e==`string`?Jd(e,t):h.sanitizeRange(e,t);n&&i.push(n)};if(typeof n==`string`){let e=gn(n),t=e.length;for(let n=0;n<t;n++)a(e[n])}else if(Array.isArray(n)){let e=n.length;for(let t=0;t<e;t++)a(n[t])}else a(n);return i.length===0?null:{coords:i,value:r}}var Ef=/^\$?([A-Z]+)(?::\$?([A-Z]+))?$/,Df=/^\$?(\d+)(?::\$?(\d+))?$/;function Of(e,t,n){let r=n?Sd:xd,i=r(e);return e===t?`${i}:${i}`:`${i}:${r(t)}`}function kf(e,t){if(!e)return null;let n=e.trim().toUpperCase(),r,i,a=Ef.exec(n);if(a)r=lf(a[1]),i=a[2]===void 0?r:lf(a[2]);else if(a=Df.exec(n))r=parseInt(a[1])-1,i=a[2]===void 0?r:parseInt(a[2])-1;else{let e=Jd(n);if(!e)return null;r=t?e.colStart:e.rowStart,i=t?e.colEnd:e.rowEnd}return r===void 0||i===void 0||Number.isNaN(r)||Number.isNaN(i)?null:r<=i?{min:r,max:i}:{min:i,max:r}}function Af(e,t){return{r:Of(e.min,e.max,t),v:e.value}}function jf(e,t){let n,r;Array.isArray(e)?(n=e[0],r=e[1]):(n=e?.r,r=e?.v),Array.isArray(n)&&(n=n[0]);let i=null;if(typeof n==`string`)i=kf(n,t);else if(n){let e=n,r=t?e.colStart:e.rowStart,a=t?e.colEnd:e.rowEnd;r!==void 0&&a!==void 0&&(i=r<=a?{min:r,max:a}:{min:a,max:r})}return i?(i.value=r,i):null}function Mf(e,t){let n=e?e.length:0,r=Array(n);for(let i=0;i<n;i++)r[i]=Af(e[i],t);return r}function Nf(e,t){let n=e?e.length:0,r=[];for(let i=0;i<n;i++){let n=jf(e[i],t);n&&r.push(n)}return r}function Pf(e,t,n=Fd){let r=e?e.length:0;if(r===0)return null;let i=[];for(let a=0;a<r;a++){let r=zd(e[a],t,n);r&&i.push(r)}return i.length===0?null:i.join(`,`)}function Ff(e,t){return typeof e==`string`?Jd(e,t):h.sanitizeRange(e,t)}function If(e,t){return typeof e==`string`?e:Wd(e,t)}function Lf(e,t,n){let r=h.intersectRanges(e,t,n);if(!r)return null;let i=e.scope,a=t.scope;if(i&&a){if(i!==a)return V.BuiltIn.Value;r.scope=i}else i||a?r.scope=i||a:r.scope&&=null;return r}function Rf(e,t,n){let r=h.unionRanges(e,t,n);if(!r)return null;let i=e.scope,a=t.scope;if(i&&a){if(i!==a)return V.BuiltIn.Value;r.scope=i}else i||a?r.scope=i||a:r.scope&&=null;return r}var G,zf=Object.freeze({break:!0});(G||={}).Type={BorderStyle:`borderStyle`,FillStyle:`fillStyle`,ContentStyle:`contentStyle`,Continuous:`continuous`,DateFormat:`dateFormat`,Table:`table`,AutoTable:`autoTable`,Pivot:`pivot`,DataValidations:`dataValidations`,Merge:`merge`,Hyperlink:`hyperlink`,IgnoredErrors:`ignoredErrors`,Comments:`comments`,Unlock:`unlock`,Contentful:`contentful`,Conditionals:`conditionals`,CellControls:`cellControls`,Sparklines:`sparklineGroups`,Formula:`formula`,Spills:`spills`,CalcStatus:`calcStatus`,CalcError:`calcError`,Circular:`circular`,Error:`error`,Anomalies:`anomalies`,Kind:`kind`,Role:`role`,Validation:`dataValidation`};var Bf=Object.freeze({contentful:G.Type.Contentful,kind:G.Type.Kind,role:G.Type.Role,dateFormat:G.Type.DateFormat,error:G.Type.Error,formula:G.Type.Formula,spills:G.Type.Spills,calcError:G.Type.CalcError,calcStatus:G.Type.CalcStatus,circular:G.Type.Circular,fill:G.Type.FillStyle,borders:G.Type.BorderStyle,numberFormat:G.Type.ContentStyle,alignment:G.Type.ContentStyle,font:G.Type.ContentStyle,protection:G.Type.ContentStyle,merge:G.Type.Merge,table:G.Type.Table,autoTable:G.Type.AutoTable,pivot:G.Type.Pivot,hyperlink:G.Type.Hyperlink,ignoredErrors:G.Type.IgnoredErrors,comments:G.Type.Comments,unlock:G.Type.Unlock,conditionals:G.Type.Conditionals,dataValidations:G.Type.DataValidations,cellControl:G.Type.CellControls,sparkline:G.Type.Sparklines,anomalies:G.Type.Anomalies});function Vf(e){let t=function(e){if(e===void 0)return!0;let t=typeof e==`string`?[e]:e;if(t.length===0)return!1;let n={};for(let e=0;e<t.length;e++){let r=Bf[t[e]];r&&(n[r]=!1)}return n}(e);if(typeof t==`boolean`)return t;let n={...t};return delete n[G.Type.Contentful],n[G.Type.ContentStyle]!==void 0&&(n[G.Type.Continuous]=!1),n[G.Type.Formula]===void 0&&n[G.Type.CalcError]===void 0||(n[G.Type.CalcStatus]=!1),n}function Hf(e,t,n){switch(n){case`contentful`:case`kind`:case`role`:case`error`:case`anomalies`:return null;case`borders`:return e.borderSpatial.getContentfulCoords();case`fill`:return e.fillSpatial.getContentfulCoords();case`numberFormat`:case`alignment`:case`font`:case`protection`:return e.contentSpatial.getContentfulCoords();case`dateFormat`:return e.dateFormatSpatial.getBoundingRange();case`merge`:return e.mergeSpatial.getContentfulCoords();case`formula`:return t.getFormulas().getBoundingRange();case`calcError`:return t.getCalcErrors().getBoundingRange();case`calcStatus`:return t.getCalcStatus().getBoundingRange();case`circular`:return t.getCirculars().getBoundingRange();case`spills`:return t.getSpills().getBoundingRange();case`table`:return e.tables.getBoundingRange();case`autoTable`:return e.autoTables.getBoundingRange();case`pivot`:return e.pivotTables.getBoundingRange();case`hyperlink`:return e.hyperlinkSpatial.getBoundingRange();case`ignoredErrors`:return e.ignoredErrors.getMap()?.getBoundingRange()??null;case`comments`:return e.comments.getBoundingRange();case`unlock`:{let t=e.protectedRanges.getBoundingRange(),n=e.contentSpatial.getContentfulCoords();return t&&n?{colStart:Math.min(t.colStart,n.colStart),rowStart:Math.min(t.rowStart,n.rowStart),colEnd:Math.max(t.colEnd,n.colEnd),rowEnd:Math.max(t.rowEnd,n.rowEnd)}:t??n}case`conditionals`:return e.conditionalFormats.getBoundingRange();case`dataValidations`:return e.dataValidations.getBoundingRange();case`cellControl`:return e.cellControls.getBoundingRange();case`sparkline`:return e.sparklineGroups.getBoundingRange()}}var Uf,Wf=Object.freeze({[G.Type.BorderStyle]:!1,[G.Type.FillStyle]:!1,[G.Type.ContentStyle]:!1,[G.Type.DateFormat]:!1,[G.Type.AutoTable]:!1,[G.Type.Table]:!1,[G.Type.Pivot]:!1,[G.Type.Merge]:!1,[G.Type.Hyperlink]:!1,[G.Type.IgnoredErrors]:!1,[G.Type.Comments]:!1,[G.Type.Unlock]:!1,[G.Type.Formula]:!1,[G.Type.Spills]:!1,[G.Type.CalcStatus]:!1,[G.Type.CalcError]:!1,[G.Type.Circular]:!1,[G.Type.Contentful]:!1,[G.Type.DataValidations]:!1,[G.Type.Conditionals]:!1,[G.Type.CellControls]:!1,[G.Type.Sparklines]:!1,[G.Type.Continuous]:!1}),Gf=Object.freeze({[G.Type.BorderStyle]:!1,[G.Type.FillStyle]:!1,[G.Type.ContentStyle]:!1,[G.Type.DateFormat]:!1,[G.Type.AutoTable]:!1,[G.Type.Table]:!1,[G.Type.Pivot]:!1,[G.Type.Merge]:!1,[G.Type.Hyperlink]:!1,[G.Type.IgnoredErrors]:!1,[G.Type.Comments]:!1,[G.Type.Unlock]:!1,[G.Type.Formula]:!1,[G.Type.Spills]:!1,[G.Type.CalcStatus]:!1,[G.Type.CalcError]:!1,[G.Type.Circular]:!1,[G.Type.DataValidations]:!1,[G.Type.Conditionals]:!1,[G.Type.CellControls]:!1,[G.Type.Sparklines]:!1,[G.Type.Continuous]:!1}),Kf=Object.freeze({[G.Type.BorderStyle]:!1,[G.Type.FillStyle]:!1,[G.Type.ContentStyle]:!1,[G.Type.DateFormat]:!1,[G.Type.Table]:!0,[G.Type.Pivot]:!1,[G.Type.DataValidations]:!1,[G.Type.Merge]:!1,[G.Type.Hyperlink]:!1,[G.Type.Comments]:!1,[G.Type.Unlock]:!1,[G.Type.Formula]:!1}),qf=(Object.freeze({[G.Type.BorderStyle]:!1,[G.Type.FillStyle]:!1,[G.Type.ContentStyle]:!1,[G.Type.DateFormat]:!1,[G.Type.Table]:!1,[G.Type.AutoTable]:!1,[G.Type.Pivot]:!1,[G.Type.DataValidations]:!1,[G.Type.Hyperlink]:!1,[G.Type.Comments]:!1,[G.Type.Unlock]:!1,[G.Type.Contentful]:!1,[G.Type.Formula]:!1}),Object.freeze({[G.Type.BorderStyle]:!1,[G.Type.FillStyle]:!1,[G.Type.ContentStyle]:!1,[G.Type.Hyperlink]:!1,[G.Type.Continuous]:!1,[G.Type.Merge]:!1,[G.Type.Contentful]:!1}));(Uf||={}).BuiltInFilterType={BuiltIn:`builtIn`,All:`all`,Custom:`custom`};var Jf,Yf,Xf,Zf,Qf=Object.freeze({latin:`Calibri Light`,panose:`020F0302020204030204`,scripts:Object.freeze({Jpan:`游ゴシック Light`,Hang:`맑은 고딕`,Hans:`等线 Light`,Hant:`新細明體`,Arab:`Times New Roman`,Hebr:`Times New Roman`,Thai:`Tahoma`,Ethi:`Nyala`,Beng:`Vrinda`,Gujr:`Shruti`,Khmr:`MoolBoran`,Knda:`Tunga`,Guru:`Raavi`,Cans:`Euphemia`,Cher:`Plantagenet Cherokee`,Yiii:`Microsoft Yi Baiti`,Tibt:`Microsoft Himalaya`,Thaa:`MV Boli`,Deva:`Mangal`,Telu:`Gautami`,Taml:`Latha`,Syrc:`Estrangelo Edessa`,Orya:`Kalinga`,Mlym:`Kartika`,Laoo:`DokChampa`,Sinh:`Iskoola Pota`,Mong:`Mongolian Baiti`,Viet:`Times New Roman`,Uigh:`Microsoft Uighur`,Geor:`Sylfaen`,Armn:`Arial`,Bugi:`Leelawadee UI`,Bopo:`Microsoft JhengHei`,Java:`Javanese Text`,Lisu:`Segoe UI`,Mymr:`Myanmar Text`,Nkoo:`Ebrima`,Olck:`Nirmala UI`,Osma:`Ebrima`,Phag:`Phagspa`,Syrn:`Estrangelo Edessa`,Syrj:`Estrangelo Edessa`,Syre:`Estrangelo Edessa`,Sora:`Nirmala UI`,Tale:`Microsoft Tai Le`,Talu:`Microsoft New Tai Lue`,Tfng:`Ebrima`})}),$f=Object.freeze({latin:`Calibri`,panose:`020F0502020204030204`,scripts:Object.freeze({Jpan:`游ゴシック`,Hang:`맑은 고딕`,Hans:`等线`,Hant:`新細明體`,Arab:`Arial`,Hebr:`Arial`,Thai:`Tahoma`,Ethi:`Nyala`,Beng:`Vrinda`,Gujr:`Shruti`,Khmr:`DaunPenh`,Knda:`Tunga`,Guru:`Raavi`,Cans:`Euphemia`,Cher:`Plantagenet Cherokee`,Yiii:`Microsoft Yi Baiti`,Tibt:`Microsoft Himalaya`,Thaa:`MV Boli`,Deva:`Mangal`,Telu:`Gautami`,Taml:`Latha`,Syrc:`Estrangelo Edessa`,Orya:`Kalinga`,Mlym:`Kartika`,Laoo:`DokChampa`,Sinh:`Iskoola Pota`,Mong:`Mongolian Baiti`,Viet:`Arial`,Uigh:`Microsoft Uighur`,Geor:`Sylfaen`,Armn:`Arial`,Bugi:`Leelawadee UI`,Bopo:`Microsoft JhengHei`,Java:`Javanese Text`,Lisu:`Segoe UI`,Mymr:`Myanmar Text`,Nkoo:`Ebrima`,Olck:`Nirmala UI`,Osma:`Ebrima`,Phag:`Phagspa`,Syrn:`Estrangelo Edessa`,Syrj:`Estrangelo Edessa`,Syre:`Estrangelo Edessa`,Sora:`Nirmala UI`,Tale:`Microsoft Tai Le`,Talu:`Microsoft New Tai Lue`,Tfng:`Ebrima`})}),ep=[[`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`]],tp=[[`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`]],np=[[`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`]],rp=`Themes is readonly. To make modifications create a new DocsThemes instance.`,ip={[Mt.Scheme.Bg1]:`lt1`,[Mt.Scheme.Bg2]:`lt2`,[Mt.Scheme.Tx1]:`dk1`,[Mt.Scheme.Tx2]:`dk2`,[Mt.Scheme.Accent1]:`accent1`,[Mt.Scheme.Accent2]:`accent2`,[Mt.Scheme.Accent3]:`accent3`,[Mt.Scheme.Accent4]:`accent4`,[Mt.Scheme.Accent5]:`accent5`,[Mt.Scheme.Accent6]:`accent6`,[Mt.Scheme.Hlink]:`hlink`,[Mt.Scheme.FolHlink]:`folHlink`},ap=`Office`,op=[ap,`windowText`,`window`,`0E2841`,`E8E8E8`,`156082`,`E97132`,`196B24`,`0F9ED5`,`A02B93`,`4EA72E`,`467886`,`96607D`],sp=[ap,`Calibri Light`,`Calibri`],cp=Object.freeze({line:{style:{stroke:{index:2,color:`accent1`},fill:{index:0,color:`accent1`},effect:{index:1,color:`accent1`},font:{index:I.Scheme.Minor,color:`tx1`}}}}),lp=new Set([ap,`Office 2013-2022`]),up=[`dk1`,`lt1`,`dk2`,`lt2`,`accent1`,`accent2`,`accent3`,`accent4`,`accent5`,`accent6`,`hlink`,`folHlink`],dp=e=>{let t={},n=e.length;for(let r=0;r<n;r++){let n=e[r],i=n[0],a={name:i};t[i]=a;let o=up.length;for(let e=0;e<o;e++){let t=up[e],r=n[e+1];if(!r)continue;let i=De.parse(r);i&&(a[t]=i.toString())}}return t},fp=e=>{let t={},n=e.length;for(let r=0;r<n;r++){let n=e[r],i=n[0],a={name:i};t[i]=a;let o=n[1]??sp[1],s=n[2]??sp[2],c=lp.has(i);a.major=c&&o===Qf.latin?Qf:{latin:o},a.minor=c&&s===$f.latin?$f:{latin:s}}return t},pp=dp([op]),mp=fp([sp]),hp=pp[ap],gp=mp[ap],_p=null,vp=e=>e.panose?[I.getPanoseFallback(e.panose)]:i.EmptyArray,yp=new class{constructor(){this._colors={};let e=up.length;for(let t=0;t<e;t++){let e=up[t],n=De.parse(hp[e]);this._colors[e]=n}}getName(){return hp.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}},bp=class{constructor(e,t=yp){this._delegate=t,this._fromJSON(e)}_fromJSON(e){if(this._overrides={},!e)return;let t=Object.keys(e),n=t.length;if(n!==0)for(let r=0;r<n;r++){let n=t[r];this._overrides[n]=n===`name`?e[n]:De.parse(e[n])}}_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(){let e=i.toSafeJSON(this._overrides),t=this.getName();return t&&(e.name=t),e}},xp=new class{constructor(){this._colors={};let e=up.length;for(let t=0;t<e;t++){let e=up[t],n=De.parse(hp[e]);this._colors[e]=n}}getName(){return gp.name}getMajorFont(){return this.getMajor().latin}getMinorFont(){return this.getMinor().latin}getMajorFallbacks(){return vp(this.getMajor())}getMinorFallbacks(){return vp(this.getMinor())}getMajor(){return gp.major}getMinor(){return gp.minor}},Sp=class{constructor(e,t=xp){this._delegate=t,this._fromJSON(e)}_fromJSON(e){if(this._overrides={},!e)return;let t=Object.keys(e),n=t.length;if(n!==0)for(let r=0;r<n;r++){let n=t[r];this._overrides[n]=e[n]}}_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.getMajor().latin??this._delegate.getMajorFont()}getMinorFont(){return this.getMinor().latin??this._delegate.getMinorFont()}getMajorFallbacks(){return vp(this.getMajor())}getMinorFallbacks(){return vp(this.getMinor())}getMajor(){return this._value(`major`,`getMajor`)}getMinor(){return this._value(`minor`,`getMinor`)}toJSON(){let e=i.toSafeJSON(this._overrides),t=this.getName();return t&&(e.name=t),e}},Cp=class{constructor(e,t=null,n=null){if(this._formatScheme=null,this._cacheColors=new Map,this._cacheEpoch=De.getSystemEpoch(),!t&&e?.name){let n=_p?_p.get(e.name.toLowerCase()):null;n&&(t=n)}!t&&_p&&(t=_p.get(ap.toLowerCase())??null),this._name=e?.name??t?.getName(),this._builtInID=n,this._delegate=t,this._formatSchemeXml=e?.formatSchemeXml,this._fillStyleLst=e?.fillStyleLst,this._lnStyleLst=e?.lnStyleLst,this._effectStyleLst=e?.effectStyleLst,this._bgFillStyleLst=e?.bgFillStyleLst,this._objectDefaults=e?.objectDefaults,this._customColors=e?.customColors,this._family=e?.family,this._colors=new bp(e?.colors,this._delegate?.getColorScheme()),this._fonts=new Sp(e?.fonts,this._delegate?.getFontScheme());let r=ip,i={},a=Object.keys(r),o=a.length;for(let e=0;e<o;e++){let t=a[e];i[t]=`get${tn(r[t])}`}i.dk1=`getDk1`,i.dk2=`getDk2`,i.lt1=`getLt1`,i.lt2=`getLt2`,i.folhlink=`getFolHlink`,this._colorMap=i;let s=this;this._schemeLookup=e=>{let t=De.getSystemEpoch();s._cacheEpoch!==t&&(s._cacheColors=new Map,s._cacheEpoch=t);let n=s._cacheColors.get(e);if(n)return n;e===`phClr`&&(e=Mt.Scheme.Tx1);let r=s._colorMap[e];if(!r)throw Error(`Invalid color scheme key: ${e}`);let i=s.getColorScheme(),a=i[r].bind(i)();return a||=hp[ip[e]??e],n=new De(a),s._cacheColors.set(e,n),n}}get builtInID(){return this._builtInID??null}getName(){return(this._name??this._delegate?.getName())||`Custom`}isCustom(){return this._builtInID!==null&&this._builtInID!==void 0}getColorScheme(){return this._colors}getFontScheme(){return this._fonts}getFormatScheme(){if(!this._formatScheme){let e=this._delegate?.getFormatScheme()??me;this._formatScheme={fillStyleLst:this._fillStyleLst??e.fillStyleLst,lnStyleLst:this._lnStyleLst??e.lnStyleLst,effectStyleLst:this._effectStyleLst??e.effectStyleLst,bgFillStyleLst:this._bgFillStyleLst??e.bgFillStyleLst}}return this._formatScheme}getObjectDefaults(){return this._objectDefaults?this._objectDefaults:this._delegate?this._delegate.getObjectDefaults():cp}schemeLookup(){return this._schemeLookup}parseColor(e){return De.parse(e,this._schemeLookup)}toJSON(){let e={name:this.getName()},t=this._colors.toJSON();t&&(Object.keys(t).length>1||t.name&&t.name!==e.name)&&(e.colors=t);let n=this._fonts.toJSON();return n&&(Object.keys(n).length>1||n.name&&n.name!==e.name)&&(e.fonts=n),this._fillStyleLst&&(e.fillStyleLst=this._fillStyleLst),this._lnStyleLst&&(e.lnStyleLst=this._lnStyleLst),this._effectStyleLst&&(e.effectStyleLst=this._effectStyleLst),this._bgFillStyleLst&&(e.bgFillStyleLst=this._bgFillStyleLst),this._formatSchemeXml&&(e.formatSchemeXml=this._formatSchemeXml),this._objectDefaults&&(e.objectDefaults=this._objectDefaults),this._customColors&&(e.customColors=this._customColors),this._family&&(e.family=this._family),Object.keys(e).length===1&&e.name===ap?null:e}get isITheme(){return!0}},wp=()=>{if(_p)return _p;let e=((e,t,n)=>{let r=[],a=e.length;for(let o=0;o<a;o++){let a=e[o],s=a[0],c={name:s,colors:t[a[1]]??hp,fonts:n[a[2]]??gp};c.objectDefaults=s===ap?cp:i.EmptyObject,r.push(c)}return r})(np,dp(ep),fp(tp)),t=new Map,n=e.length;for(let r=0;r<n;r++){let n=new Cp(null,new Cp(e[r]),r+1);t.set(n.getName().toLowerCase(),n)}return _p=t,t},Tp=class extends Qt{constructor(e=null,t=!1){super(),wp(),this._isReadOnly=t,this._customMap=new Map,this._defaultTheme=this.getByName(`Office`)}getDefaultTheme(){return this._defaultTheme}setDefaultTheme(e){if(this._isReadOnly)throw Error(rp);if(!e)throw Error(`Theme cannot be null.`);let 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)||(_p.get(e)??null)}_getItems(e){let t=e?.type??Uf.BuiltInFilterType.All,n=new Map;return t!==Uf.BuiltInFilterType.BuiltIn&&t!==Uf.BuiltInFilterType.All||_p.forEach((e,t)=>n.set(t,e)),t!==Uf.BuiltInFilterType.Custom&&t!==Uf.BuiltInFilterType.All||this._customMap.forEach((e,t)=>n.set(t,e)),e?.selected&&n.set(e.selected.getName().toLowerCase(),e.selected),(e=>{let t=[...e];return t.sort((e,t)=>i.isDefined(e.builtInID)&&!i.isDefined(t.builtInID)?1:!i.isDefined(e.builtInID)&&i.isDefined(t.builtInID)?-1:i.isDefined(e.builtInID)&&i.isDefined(t.builtInID)?e.builtInID-t.builtInID:e.getName().localeCompare(t.getName())),t})(Array.from(n.values()))}setCustomTheme(e){if(this._isReadOnly)throw Error(rp);let t=e.getName().toLowerCase(),n=this._customMap.get(t);return this._customMap.set(t,e),this._notifyCollectionChange(),n??null}deleteCustomTheme(e){if(this._isReadOnly)throw Error(rp);let t=null;t=typeof e==`string`?e.toLowerCase():e.getName().toLowerCase();let n=this._customMap.get(t);return n?(this._customMap.delete(t),this._notifyCollectionChange(),n):null}get isIThemeCollection(){return!0}};(Yf=Jf||={}).AutoExpand={Both:`both`,Rows:`rows`,Columns:`columns`,None:`none`},Yf.FormulaBelow={TotalsRow:`totalsRow`,InsideTable:`insideTable`,BelowTable:`belowTable`},(Zf=Xf||={}).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`},Zf.PivotElementType={FirstSubtotalColumn:`firstSubtotalColumn`,SecondSubtotalColumn:`secondSubtotalColumn`,ThirdSubtotalColumn:`thirdSubtotalColumn`,FirstSubtotalRow:`firstSubtotalRow`,SecondSubtotalRow:`secondSubtotalRow`,ThirdSubtotalRow:`thirdSubtotalRow`,BlankRow:`blankRow`,FirstColumnSubheading:`firstColumnSubheading`,SecondColumnSubheading:`secondColumnSubheading`,ThirdColumnSubheading:`thirdColumnSubheading`,FirstRowSubheading:`firstRowSubheading`,SecondRowSubheading:`secondRowSubheading`,ThirdRowSubheading:`thirdRowSubheading`,PageFieldLabels:`pageFieldLabels`,PageFieldValues:`pageFieldValues`},(Xf||={}).Empty=class{constructor(e){this._normalStyle=e}getName(){return`None`}isShownInTableStyles(){return!1}isShownInPivotStyles(){return!1}getRanged(e){return null}getProperties(){return i.EmptyObject}isBuiltIn(){return!0}delete(){}toJSON(){return null}get isITableStyle(){return!0}};var Ep,Dp=(e,t)=>{let n=e.getName().toLowerCase(),r=t.getName().toLowerCase();return n<r?-1:+(n>r)},Op=class extends Qt{constructor(e){super(),this._host=e}_getItems(e){let t=e?.type??Uf.BuiltInFilterType.All,n=e?.includeHidden??!1,r=this._host.builtIns(),i=this._host.customs(),a=[];if(t!==Uf.BuiltInFilterType.Custom&&r.forEach((e,t)=>{let r=i.get(t)??e;!n&&r.isHidden()||a.push(r)}),t!==Uf.BuiltInFilterType.BuiltIn){let e=[];i.forEach((i,a)=>{t===Uf.BuiltInFilterType.All&&r.has(a)||!n&&i.isHidden()||e.push(i)}),e.sort(Dp),a.push(...e)}return a}getByName(e){if(typeof e!=`string`||!e)return null;let t=e.toLowerCase();return this._host.customs().get(t)??this._host.builtIns().get(t)??null}set(e,t=!1){let n=this._host.set(e,t);return this._notifyCollectionChange(),n}_announceChange(){this._notifyCollectionChange()}get isINamedStyleCollection(){return!0}},kp=(e,t)=>{let n=e.getName().toLowerCase(),r=t.getName().toLowerCase();return n<r?-1:+(n>r)},Ap=class extends Qt{constructor(e){super(),this._host=e}_getItems(e){let t=e?.type??Uf.BuiltInFilterType.All,n=e?.shownIn,r=e=>n===`table`?e.isShownInTableStyles():n!==`pivot`||e.isShownInPivotStyles(),i=this._host.builtIns(),a=this._host.customs(),o=[];if(t!==Uf.BuiltInFilterType.Custom&&i.forEach((e,t)=>{let n=a.get(t)??e;r(n)&&o.push(n)}),t!==Uf.BuiltInFilterType.BuiltIn){let e=[];a.forEach((n,a)=>{t===Uf.BuiltInFilterType.All&&i.has(a)||r(n)&&e.push(n)}),e.sort(kp),o.push(...e)}return o}getByName(e){if(typeof e!=`string`||!e)return null;let t=e.toLowerCase();return this._host.customs().get(t)??this._host.builtIns().get(t)??null}set(e,t){let n=this._host.set(e,t);return this._notifyCollectionChange(),n}getDefault(){return this._host.getDefault()}setDefault(e){let t=this._host.setDefault(e);return this._notifyCollectionChange(),t}getNone(){return this._host.getNone()}_announceChange(){this._notifyCollectionChange()}get isITableStyleCollection(){return!0}},jp=(e,t)=>{let n=e.getName().toLowerCase(),r=t.getName().toLowerCase();return n<r?-1:+(n>r)},Mp=class extends Qt{constructor(e){super(),this._host=e}_getItems(e){let t=e?.type??Uf.BuiltInFilterType.All,n=this._host.builtIns(),r=this._host.customs(),i=[];if(t!==Uf.BuiltInFilterType.Custom&&n.forEach((e,n)=>{i.push(t===Uf.BuiltInFilterType.BuiltIn?e:r.get(n)??e)}),t!==Uf.BuiltInFilterType.BuiltIn){let e=[];r.forEach((r,i)=>{t===Uf.BuiltInFilterType.All&&n.has(i)||e.push(r)}),e.sort(jp),i.push(...e)}return i}getByName(e){if(typeof e!=`string`||!e)return null;let t=e.toLowerCase();return this._host.customs().get(t)??this._host.builtIns().get(t)??null}set(e,t){let n=this._host.set(e,t);return this._notifyCollectionChange(),n}getDefault(){return this._host.getDefault()}setDefault(e){let t=this._host.setDefault(e);return this._notifyCollectionChange(),t}_announceChange(){this._notifyCollectionChange()}get isISlicerStyleCollection(){return!0}};(Ep||={}).ElementType={WholeTable:`wholeTable`,HeaderRow:`headerRow`,UnselectedItemWithData:`unselectedItemWithData`,SelectedItemWithData:`selectedItemWithData`,UnselectedItemWithNoData:`unselectedItemWithNoData`,SelectedItemWithNoData:`selectedItemWithNoData`,HoveredUnselectedItemWithData:`hoveredUnselectedItemWithData`,HoveredSelectedItemWithData:`hoveredSelectedItemWithData`,HoveredUnselectedItemWithNoData:`hoveredUnselectedItemWithNoData`,HoveredSelectedItemWithNoData:`hoveredSelectedItemWithNoData`};var Np=Object.values(Ep.ElementType),Pp=class{constructor(e,t,n,r){this._isBuiltIn=n,this._doDelete=r;let o={name:t.name};for(let n of Np){let r=t[n];r&&i.isObject(r)&&(o[n]=a.resolveTypedUpdates(Object.freeze(r),yt,e))}this._properties=i.deepFreeze(o)}getName(){return this._properties.name}isBuiltIn(){return this._isBuiltIn}delete(){this._doDelete?.(this._properties.name)}getProperties(){return this._properties}toJSON(){return i.cloneObject(this._properties)}get isISlicerStyle(){return!0}},Fp=`SlicerStyleLight1`,Ip=e=>({type:`pattern`,patternType:`solid`,foreground:e,background:e}),Lp=(e,t)=>({type:`gradient`,angle:180,stops:[{offset:0,color:e},{offset:1,color:t}]}),Rp=e=>({left:{style:`thin`,color:e},right:{style:`thin`,color:e},top:{style:`thin`,color:e},bottom:{style:`thin`,color:e}}),zp=(e,t,n)=>({font:{color:e},fill:t,borders:Rp(n)}),Bp=(e,t=e)=>({wholeTable:{font:{color:`dk1`},borders:Rp(e)},headerRow:{font:{color:`dk1`,weight:700},borders:{bottom:{style:`thin`,color:t}}}}),Vp=e=>({hoveredUnselectedItemWithData:e,hoveredSelectedItemWithData:e,hoveredUnselectedItemWithNoData:e,hoveredSelectedItemWithNoData:e}),Hp=zp(`#000000`,Lp(`#F8E162`,`#FCF7E0`),`#999999`),Up=e=>{let t=`accent${e}`;return{name:`SlicerStyleLight${e}`,...Bp(t),unselectedItemWithData:zp(`#000000`,Ip(`#FFFFFF`),`#CCCCCC`),selectedItemWithData:zp(`#000000`,Ip(`${t} eTint 0.6`),`#999999`),unselectedItemWithNoData:zp(`#828282`,Ip(`#FFFFFF`),`#E0E0E0`),selectedItemWithNoData:zp(`#828282`,Ip(`${t} eTint 0.8`),`#CCCCCC`),...Vp(Hp)}},Wp=e=>{let t=`accent${e}`;return{name:`SlicerStyleDark${e}`,...Bp(t),unselectedItemWithData:zp(`#000000`,Ip(`#C0C0C0`),`#C0C0C0`),selectedItemWithData:zp(`lt1`,Ip(t),t),unselectedItemWithNoData:zp(`#959595`,Ip(`#DFDFDF`),`#DFDFDF`),selectedItemWithNoData:zp(`${t} eTint -0.25`,Ip(`${t} eTint 0.6`),`${t} eTint 0.6`),...Vp(Hp)}},Gp=null,Kp=Object.freeze({fallbacks:i.EmptyArray,weight:400,style:I.Style.Normal,color:Mt.Scheme.Tx1,letterSpacing:null,underline:I.UnderlineStyle.None,strike:I.StrikeStyle.None,baseline:0,shadow:!1,outline:!1}),qp=Object.freeze({style:L.StrokeStyle.None,color:Mt.Scheme.Tx1}),Jp=Object.freeze({[L.Edge.Top]:qp,[L.Edge.Left]:qp,[L.Edge.Bottom]:qp,[L.Edge.Right]:qp,[L.Edge.Horizontal]:qp,[L.Edge.Vertical]:qp,[L.Edge.DiagonalUp]:qp,[L.Edge.DiagonalDown]:qp}),Yp=Object.freeze({horizontal:R.HorizontalAlignment.General,vertical:R.VerticalAlignment.Bottom,indent:0,relativeIndent:0,overflow:R.Overflow.Visible,rotation:0,stacked:!1,justifyLastLine:!1,readingDirection:R.ReadingDirection.Auto}),Xp=Object.freeze({alwaysUnlocked:!1,showFormulas:!1}),Zp=Object.freeze({fill:Object.freeze({type:Ee.Type.None}),numberFormat:`General`,alignment:Yp,font:Kp,borders:Jp,protection:Xp,quotePrefix:!1,namedStyle:null}),Qp=(()=>{let e=[{named:z.BuiltInName.Normal},{named:z.BuiltInName.RowLevel},{named:z.BuiltInName.ColLevel},{named:z.BuiltInName.Comma,numberFormat:`_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)`},{named:z.BuiltInName.Currency,numberFormat:`_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)`},{named:z.BuiltInName.Percent,numberFormat:`0%`},{named:z.BuiltInName.Comma0,numberFormat:`_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)`},{named:z.BuiltInName.Currency0,numberFormat:`_($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)`},{named:z.BuiltInName.Hyperlink,font:{color:Mt.Scheme.Hlink,underline:I.UnderlineStyle.Single}},{named:z.BuiltInName.FollowedHyperlink,font:{color:Mt.Scheme.FolHlink,underline:I.UnderlineStyle.Single}},{named:z.BuiltInName.Note,fill:`FFFFFFCC`,font:{style:I.Style.Normal,color:Mt.Scheme.Tx1},borders:{left:{style:L.StrokeStyle.Thin,color:`FFB2B2B2`},top:{style:L.StrokeStyle.Thin,color:`FFB2B2B2`},right:{style:L.StrokeStyle.Thin,color:`FFB2B2B2`},bottom:{style:L.StrokeStyle.Thin,color:`FFB2B2B2`}}},{named:z.BuiltInName.WarningText,font:{color:`FFFF0000`}},{named:z.BuiltInName.Unknown12},{named:z.BuiltInName.Unknown13},{named:z.BuiltInName.Unknown14},{named:z.BuiltInName.Title,font:{size:18,color:Mt.Scheme.Tx2}},{named:z.BuiltInName.Heading1,font:{size:15,weight:700,color:Mt.Scheme.Tx2},borders:{bottom:{style:L.StrokeStyle.Thick,color:Mt.Scheme.Accent1}}},{named:z.BuiltInName.Heading2,font:{size:13,weight:700,color:Mt.Scheme.Tx2},borders:{bottom:{style:L.StrokeStyle.Thick,color:`accent1 lumMod 40 lumOff 60`}}},{named:z.BuiltInName.Heading3,font:{weight:700,color:Mt.Scheme.Tx2},borders:{bottom:{style:L.StrokeStyle.Medium,color:`accent1 lumMod 40 lumOff 60`}}},{named:z.BuiltInName.Heading4,font:{weight:700,color:Mt.Scheme.Tx2}},{named:z.BuiltInName.Input,fill:`FFFFCC99`,font:{color:`FF3F3F76`},borders:{left:{style:L.StrokeStyle.Thin,color:`FF7F7F7F`},top:{style:L.StrokeStyle.Thin,color:`FF7F7F7F`},right:{style:L.StrokeStyle.Thin,color:`FF7F7F7F`},bottom:{style:L.StrokeStyle.Thin,color:`FF7F7F7F`}}},{named:z.BuiltInName.Output,fill:`FFF2F2F2`,font:{color:`FF3F3F3F`},borders:{left:{style:L.StrokeStyle.Thin,color:`FF3F3F3F`},top:{style:L.StrokeStyle.Thin,color:`FF3F3F3F`},right:{style:L.StrokeStyle.Thin,color:`FF3F3F3F`},bottom:{style:L.StrokeStyle.Thin,color:`FF3F3F3F`}}},{named:z.BuiltInName.Calculation,fill:`FFF2F2F2`,font:{color:`FFFA7D00`},borders:{left:{style:L.StrokeStyle.Thin,color:`FF7F7F7F`},top:{style:L.StrokeStyle.Thin,color:`FF7F7F7F`},right:{style:L.StrokeStyle.Thin,color:`FF7F7F7F`},bottom:{style:L.StrokeStyle.Thin,color:`FF7F7F7F`}}},{named:z.BuiltInName.CheckCell,fill:`FFA5A5A5`,font:{color:Mt.Scheme.Bg1},borders:{left:{style:L.StrokeStyle.Double,color:`FF3F3F3F`},top:{style:L.StrokeStyle.Double,color:`FF3F3F3F`},right:{style:L.StrokeStyle.Double,color:`FF3F3F3F`},bottom:{style:L.StrokeStyle.Double,color:`FF3F3F3F`}}},{named:z.BuiltInName.LinkedCell,font:{color:`FFFA7D00`},borders:{bottom:{style:L.StrokeStyle.Double,color:`FFFF8001`}}},{named:z.BuiltInName.Total,font:{weight:700,color:Mt.Scheme.Tx1},borders:{top:{style:L.StrokeStyle.Thin,color:Mt.Scheme.Accent1},bottom:{style:L.StrokeStyle.Double,color:Mt.Scheme.Accent1}}},{named:z.BuiltInName.Good,fill:`FFC6EFCE`,font:{color:`FF006100`}},{named:z.BuiltInName.Bad,fill:`FFFFC7CE`,font:{color:`FF9C0006`}},{named:z.BuiltInName.Neutral,fill:`FFFFEB9C`,font:{color:`FF9C5700`}},{named:z.BuiltInName.Accent1},{named:z.BuiltInName.Accent1_20},{named:z.BuiltInName.Accent1_40},{named:z.BuiltInName.Accent1_60},{named:z.BuiltInName.Accent2},{named:z.BuiltInName.Accent2_20},{named:z.BuiltInName.Accent2_40},{named:z.BuiltInName.Accent2_60},{named:z.BuiltInName.Accent3},{named:z.BuiltInName.Accent3_20},{named:z.BuiltInName.Accent3_40},{named:z.BuiltInName.Accent3_60},{named:z.BuiltInName.Accent4},{named:z.BuiltInName.Accent4_20},{named:z.BuiltInName.Accent4_40},{named:z.BuiltInName.Accent4_60},{named:z.BuiltInName.Accent5},{named:z.BuiltInName.Accent5_20},{named:z.BuiltInName.Accent5_40},{named:z.BuiltInName.Accent5_60},{named:z.BuiltInName.Accent6},{named:z.BuiltInName.Accent6_20},{named:z.BuiltInName.Accent6_40},{named:z.BuiltInName.Accent6_60},{named:z.BuiltInName.ExplanatoryText,font:{style:I.Style.Italic,color:`FF7F7F7F`}}];for(let t=29;t<=52;t++){let n=(t-29)%4,r=Math.floor((t-29)/4),i=``;n===1?i=` lumMod 20 lumOff 80`:n===2?i=` lumMod 40 lumOff 60`:n===3&&(i=` lumMod 60 lumOff 40`),e[t].fill=`accent${r+1}${i}`,e[t].font={color:n===0?Mt.Scheme.Bg1:Mt.Scheme.Tx1}}return i.deepFreeze(e)})(),$p=null,em=()=>{if($p)return $p;let e=new Map;$p=e;let t=(e,t)=>{if(t===0)return`TableStyleNone`;let n=`Custom`;return e===`l`?n=`Light`:e===`m`?n=`Medium`:e===`d`&&(n=`Dark`),`TableStyle${n}${t}`},n=(e,t=0)=>t>0?`${e} lumMod ${100-t} lumOff ${t}`:t<0?`${e} lumMod ${100+t}`:e,r=e=>({type:Ee.Type.Pattern,patternType:Ee.BuiltInSheetPattern.Solid,foreground:e,background:e}),i=(e,t=!1)=>{let n={color:e};return t&&(n.weight=700),n},a=(e,t=L.StrokeStyle.Thin)=>({style:t,color:e}),o=(e,t)=>{for(let n=0;n<7;n++)e.push(t(`accent${n+1}`))},s=0,c=[];c.push([`dk1`,n(`bg1`,-15),`dk1`]),o(c,e=>[n(e,-25),n(e,80),e]),s=1;for(let n=0;n<7;n++){let o=t(`l`,n+s),l=c[n][0],u=c[n][1]??l,d=c[n][2]??l;e.set(o.toLocaleLowerCase(),Object.freeze({name:o,wholeTable:{font:i(l),borders:{top:a(d),bottom:a(d)}},headerRow:{font:i(l,!0),borders:{bottom:a(d)}},totalRow:{font:i(l,!0),borders:{top:a(d)}},firstColumn:{font:i(l,!0)},lastColumn:{font:i(l,!0)},firstRowStripe:{fill:r(u)},firstColumnStripe:{fill:r(u)}}))}s+=7,c=[],c.push([`dk1`,`dk1`,`lt1`]),o(c,e=>[`dk1`,e,`lt1`]);for(let n=0;n<7;n++){let o=t(`l`,n+s),l=c[n][0],u=c[n][1],d=c[n][2];e.set(o.toLocaleLowerCase(),Object.freeze({name:o,wholeTable:{font:i(l),borders:{left:a(u),right:a(u),top:a(u),bottom:a(u)}},headerRow:{font:i(d,!0),fill:r(u)},totalRow:{font:i(l,!0),borders:{top:a(u,L.StrokeStyle.Double)}},firstColumn:{font:i(l,!0)},lastColumn:{font:i(l,!0)},firstRowStripe:{borders:{top:a(u)}},secondRowStripe:{borders:{top:a(u)}},firstColumnStripe:{borders:{left:a(u)}},secondColumnStripe:{borders:{left:a(u)}}}))}s+=7,c=[],c.push([`dk1`,n(`bg1`,-15)]),o(c,e=>[e,n(e,80)]);for(let n=0;n<7;n++){let o=t(`l`,n+s),l=c[n][0],u=c[n][1];e.set(o.toLocaleLowerCase(),Object.freeze({name:o,wholeTable:{font:i(`dk1`),borders:{left:a(l),right:a(l),top:a(l),bottom:a(l),horizontal:a(l),vertical:a(l)}},headerRow:{font:i(`dk1`,!0)},totalRow:{font:i(`dk1`,!0),borders:{top:a(l,L.StrokeStyle.Double)}},firstColumn:{font:i(`dk1`,!0)},lastColumn:{font:i(`dk1`,!0)},firstRowStripe:{fill:r(u)},firstColumnStripe:{fill:r(u)}}))}s=1,c=[],c.push([`dk1`,`dk1`,n(`bg1`,-15)]),o(c,e=>[e,n(e,40),n(e,80)]);for(let n=0;n<7;n++){let o=t(`m`,n+s),l=c[n][0],u=c[n][1],d=c[n][2];e.set(o.toLocaleLowerCase(),Object.freeze({name:o,wholeTable:{font:i(`dk1`),borders:{left:a(u),right:a(u),top:a(u),bottom:a(u),horizontal:a(u)}},headerRow:{font:i(`lt1`,!0),fill:r(l)},totalRow:{font:i(`dk1`,!0),borders:{top:a(l,L.StrokeStyle.Double)}},firstColumn:{font:i(`dk1`,!0)},lastColumn:{font:i(`dk1`,!0)},firstRowStripe:{fill:r(d)},firstColumnStripe:{fill:r(d)}}))}s+=7,c=[],c.push([`dk1`,n(`bg1`,-15),n(`bg1`,-35)]),o(c,e=>[e,n(e,80),n(e,60)]);for(let n=0;n<7;n++){let o=t(`m`,n+s),l=c[n][0],u=c[n][1],d=c[n][2];e.set(o.toLocaleLowerCase(),Object.freeze({name:o,wholeTable:{font:i(`dk1`),fill:r(u),borders:{horizontal:a(`lt1`),vertical:a(`lt1`)}},headerRow:{font:i(`lt1`,!0),fill:r(l),borders:{bottom:a(`lt1`,L.StrokeStyle.Thick)}},totalRow:{font:i(`lt1`,!0),fill:r(l),borders:{top:a(`lt1`,L.StrokeStyle.Thick)}},firstColumn:{font:i(`lt1`,!0),fill:r(l)},lastColumn:{font:i(`lt1`,!0),fill:r(l)},firstRowStripe:{fill:r(d)},firstColumnStripe:{fill:r(d)}}))}s+=7,c=[],c.push([`dk1`,n(`bg1`,-15),n(`bg1`,-35)]),o(c,e=>[e,n(e,80),n(e,60)]);for(let o=0;o<7;o++){let l=t(`m`,o+s),u=c[o][0],d=n(`bg1`,-15);e.set(l.toLocaleLowerCase(),Object.freeze({name:l,wholeTable:{font:i(`dk1`),borders:{top:a(`dk1`,L.StrokeStyle.Medium),bottom:a(`dk1`,L.StrokeStyle.Medium),left:o===0?a(`dk1`,L.StrokeStyle.Thin):void 0,right:o===0?a(`dk1`,L.StrokeStyle.Thin):void 0,horizontal:o===0?a(`dk1`,L.StrokeStyle.Thin):void 0,vertical:o===0?a(`dk1`,L.StrokeStyle.Thin):void 0}},headerRow:{font:i(`lt1`,!0),fill:r(u),borders:{bottom:a(`dk1`,L.StrokeStyle.Medium)}},totalRow:{borders:{top:a(`dk1`,L.StrokeStyle.Double)}},firstColumn:{font:i(`lt1`,!0),fill:r(u)},lastColumn:{font:i(`lt1`,!0),fill:r(u)},firstRowStripe:{fill:r(d)},firstColumnStripe:{fill:r(d)}}))}s+=7,c=[],c.push([`dk1`,n(`bg1`,-15),n(`bg1`,-35),`dk1`]),o(c,e=>[e,n(e,80),n(e,60),n(e,40)]);for(let n=0;n<7;n++){let o=t(`m`,n+s),l=c[n][0],u=c[n][1],d=c[n][2],f=c[n][3];e.set(o.toLocaleLowerCase(),Object.freeze({name:o,wholeTable:{font:i(`dk1`),fill:r(u),borders:{top:a(f),right:a(f),left:a(f),bottom:a(f),vertical:a(f),horizontal:a(f)}},headerRow:{font:i(`dk1`),fill:r(u)},totalRow:{font:i(`dk1`),borders:{top:a(l,L.StrokeStyle.Medium)}},firstColumn:{font:i(`dk1`,!0)},lastColumn:{font:i(`dk1`,!0)},firstRowStripe:{fill:r(d)},firstColumnStripe:{fill:r(d)}}))}s=1,c=[],c.push([`dk1`,n(`dk1`,15),n(`dk1`,25),n(`dk1`,50)]),o(c,e=>[`dk1`,n(e,-50),n(e,-25),e]);for(let n=0;n<7;n++){let o=t(`d`,n+s),l=c[n][0],u=c[n][1],d=c[n][2],f=c[n][3];e.set(o.toLocaleLowerCase(),Object.freeze({name:o,wholeTable:{font:i(`lt1`),fill:r(f)},headerRow:{font:i(`lt1`,!0),fill:r(l),borders:{bottom:a(`lt1`,L.StrokeStyle.Medium)}},totalRow:{font:i(`lt1`,!0),fill:r(u),borders:{top:a(`lt1`,L.StrokeStyle.Medium)}},firstColumn:{font:i(`lt1`,!0),fill:r(d),borders:{right:a(`lt1`,L.StrokeStyle.Medium)}},lastColumn:{font:i(`lt1`,!0),fill:r(d),borders:{left:a(`lt1`,L.StrokeStyle.Medium)}},firstRowStripe:{fill:r(d)},firstColumnStripe:{fill:r(d)}}))}s+=7,c=[],c.push([n(`bg1`,-15),`dk1`,n(`bg1`,-35)]),c.push([n(`accent1`,80),`accent2`,n(`accent1`,60)]),c.push([n(`accent3`,80),`accent4`,n(`accent3`,60)]),c.push([n(`accent5`,80),`accent6`,n(`accent5`,60)]);for(let n=0;n<4;n++){let o=t(`d`,n+s),l=c[n][0],u=c[n][1],d=c[n][2];e.set(o.toLocaleLowerCase(),Object.freeze({name:o,wholeTable:{font:i(`dk1`),fill:r(l)},headerRow:{font:i(`lt1`,!0),fill:r(u)},totalRow:{font:i(`dk1`,!0),borders:{top:a(`dk1`,L.StrokeStyle.Double)}},firstColumn:{font:i(`dk1`,!0)},lastColumn:{font:i(`dk1`,!0)},firstRowStripe:{fill:r(d)},firstColumnStripe:{fill:r(d)}}))}return e},tm=`TableStyleMedium2`,K=(e,t)=>t>0?`${e} lumMod ${100-t} lumOff ${t}`:`${e} lumMod ${100+t}`,q=e=>({type:Ee.Type.Pattern,patternType:Ee.BuiltInSheetPattern.Solid,foreground:e,background:e}),J=(e,t=!1)=>t?{color:e,weight:700}:{color:e},Y=(e,t=L.StrokeStyle.Thin)=>({style:t,color:e}),nm={style:L.StrokeStyle.None},rm=L.StrokeStyle.Medium,im=L.StrokeStyle.Double,am=[[`Light`,1,{wholeTable:{font:J(`dk1`),borders:{horizontal:Y(K(`lt1`,-15))}},headerRow:{font:J(`dk1`,!0),borders:{top:Y(K(`dk1`,50)),bottom:Y(K(`dk1`,50))}},totalRow:{font:J(`dk1`,!0),fill:q(`lt1`),borders:{top:Y(K(`dk1`,50)),bottom:Y(K(`dk1`,50))}},firstRowStripe:{fill:q(K(`lt1`,-15)),borders:{top:Y(K(`lt1`,-35)),bottom:Y(K(`lt1`,-35))}},firstColumnStripe:{fill:q(K(`lt1`,-15)),borders:{left:Y(K(`lt1`,-35)),right:Y(K(`lt1`,-35)),top:Y(K(`lt1`,-35)),bottom:Y(K(`lt1`,-35)),vertical:Y(K(`lt1`,-35)),horizontal:Y(K(`lt1`,-35))}},firstSubtotalRow:{font:J(`dk1`,!0)},secondSubtotalRow:{font:J(K(`dk1`,50),!0)},firstRowSubheading:{font:J(`dk1`,!0)},secondRowSubheading:{font:J(K(`dk1`,50),!0)},pageFieldLabels:{borders:{top:Y(K(`dk1`,50)),bottom:Y(K(`dk1`,50))}},pageFieldValues:{borders:{top:Y(K(`dk1`,50)),bottom:Y(K(`dk1`,50))}}},e=>({wholeTable:{font:J(`dk1`),borders:{horizontal:Y(K(e,80))}},headerRow:{font:J(`dk1`,!0),borders:{top:Y(e),bottom:Y(e)}},totalRow:{font:J(`dk1`,!0),fill:q(`lt1`),borders:{top:Y(e),bottom:Y(e)}},firstRowStripe:{fill:q(K(e,80)),borders:{top:Y(K(e,60)),bottom:Y(K(e,60))}},firstColumnStripe:{fill:q(K(e,80)),borders:{left:Y(K(e,60)),right:Y(K(e,60)),top:Y(K(e,60)),bottom:Y(K(e,60)),vertical:Y(K(e,60)),horizontal:Y(K(e,60))}},firstSubtotalRow:{font:J(`dk1`,!0)},secondSubtotalRow:{font:J(e,!0)},firstRowSubheading:{font:J(`dk1`,!0)},secondRowSubheading:{font:J(e,!0)},pageFieldLabels:{borders:{top:Y(e),bottom:Y(e)}},pageFieldValues:{borders:{top:Y(e),bottom:Y(e)}}})],[`Light`,8,{wholeTable:{font:J(`dk1`),borders:{horizontal:Y(K(`lt1`,-15))}},headerRow:{font:J(`dk1`,!0),borders:{left:Y(K(`dk1`,50),rm),right:Y(K(`dk1`,50),rm),top:Y(K(`dk1`,50),rm),bottom:Y(K(`dk1`,50),rm),horizontal:Y(`lt1`)}},totalRow:{font:J(`dk1`,!0),borders:{left:Y(K(`dk1`,50),rm),right:Y(K(`dk1`,50),rm),top:Y(K(`dk1`,50),rm),bottom:Y(K(`dk1`,50),rm)}},firstColumn:{borders:{right:Y(K(`dk1`,50))}},firstRowStripe:{borders:{left:Y(K(`lt1`,-35)),right:Y(K(`lt1`,-35)),top:Y(K(`lt1`,-35)),bottom:Y(K(`lt1`,-35))}},firstColumnStripe:{borders:{left:Y(K(`lt1`,-45)),right:Y(K(`lt1`,-45)),top:Y(K(`lt1`,-45)),bottom:Y(K(`lt1`,-45))}},firstSubtotalRow:{font:J(`dk1`,!0),fill:q(K(`lt1`,-15)),borders:{top:Y(K(`lt1`,-35)),bottom:Y(K(`lt1`,-35))}},secondSubtotalRow:{font:J(`dk1`,!0)},secondColumnSubheading:{borders:{top:Y(K(`lt1`,-35))}},firstRowSubheading:{font:J(`dk1`,!0),fill:q(K(`lt1`,-15)),borders:{bottom:Y(`lt1`)}},secondRowSubheading:{font:J(`dk1`,!0)}},e=>({wholeTable:{font:J(K(e,-25)),borders:{horizontal:Y(K(e,80))}},headerRow:{font:J(`dk1`,!0),borders:{left:Y(e,rm),right:Y(e,rm),top:Y(e,rm),bottom:Y(e,rm),horizontal:Y(`lt1`)}},totalRow:{font:J(`dk1`,!0),borders:{left:Y(e,rm),right:Y(e,rm),top:Y(e,rm),bottom:Y(e,rm)}},firstColumn:{borders:{right:Y(e)}},firstRowStripe:{borders:{left:Y(K(e,60)),right:Y(K(e,60)),top:Y(K(e,60)),bottom:Y(K(e,60))}},firstColumnStripe:{borders:{left:Y(e),right:Y(e),top:Y(e),bottom:Y(e)}},firstSubtotalRow:{font:J(`dk1`,!0),fill:q(K(e,80)),borders:{top:Y(K(e,60)),bottom:Y(K(e,60))}},secondSubtotalRow:{font:J(`dk1`,!0)},secondColumnSubheading:{borders:{top:Y(K(e,80))}},thirdColumnSubheading:{borders:{top:Y(K(e,80))}},firstRowSubheading:{font:J(`dk1`,!0),fill:q(K(e,80)),borders:{bottom:Y(`lt1`)}},secondRowSubheading:{font:J(`dk1`,!0)}})],[`Light`,15,{headerRow:{font:J(`dk1`,!0),fill:q(K(`lt1`,-15)),borders:{bottom:Y(K(`lt1`,-35))}},totalRow:{font:J(`dk1`,!0),fill:q(K(`lt1`,-15)),borders:{top:Y(K(`lt1`,-35))}},firstRowStripe:{fill:q(K(`lt1`,-15))},firstColumnStripe:{fill:q(K(`lt1`,-15)),borders:{left:Y(K(`lt1`,-25)),right:Y(K(`lt1`,-25))}},firstSubtotalColumn:{fill:q(K(`lt1`,-15))},firstSubtotalRow:{font:J(`dk1`,!0),borders:{top:Y(K(`dk1`,50)),bottom:Y(K(`dk1`,50))}},secondSubtotalRow:{font:J(`dk1`,!0)},firstRowSubheading:{font:J(`dk1`,!0),borders:{bottom:Y(K(`lt1`,-35))}},secondRowSubheading:{font:J(`dk1`,!0)},pageFieldLabels:{fill:q(K(`lt1`,-15)),borders:{bottom:Y(K(`lt1`,-35))}},pageFieldValues:{fill:q(K(`lt1`,-15)),borders:{bottom:Y(K(`lt1`,-35))}}},e=>({headerRow:{font:J(`dk1`,!0),fill:q(K(e,80)),borders:{bottom:Y(K(e,40))}},totalRow:{font:J(`dk1`,!0),fill:q(K(e,80)),borders:{top:Y(K(e,40))}},firstRowStripe:{fill:q(K(`lt1`,-15))},firstColumnStripe:{fill:q(K(`lt1`,-15)),borders:{left:Y(K(`lt1`,-25)),right:Y(K(`lt1`,-25))}},firstSubtotalColumn:{fill:q(K(`lt1`,-15))},firstSubtotalRow:{font:J(`dk1`,!0),borders:{top:Y(e),bottom:Y(e)}},secondSubtotalRow:{font:J(`dk1`,!0)},firstRowSubheading:{font:J(`dk1`,!0),borders:{bottom:Y(K(e,40))}},secondRowSubheading:{font:J(`dk1`,!0)},pageFieldLabels:{fill:q(K(e,80)),borders:{bottom:Y(K(e,40))}},pageFieldValues:{fill:q(K(e,80)),borders:{bottom:Y(K(e,40))}}})],[`Light`,22,{wholeTable:{font:J(`dk1`),borders:{left:Y(K(`dk1`,50)),right:Y(K(`dk1`,50)),top:Y(K(`dk1`,50)),bottom:Y(K(`dk1`,50)),vertical:Y(K(`dk1`,50))}},headerRow:{font:J(`dk1`,!0),borders:{bottom:Y(K(`dk1`,50))}},totalRow:{font:J(`dk1`,!0),borders:{top:Y(K(`dk1`,50))}},firstColumn:{font:J(`dk1`,!0)},firstRowStripe:{fill:q(K(`lt1`,-15)),borders:{top:Y(K(`dk1`,50)),bottom:Y(K(`dk1`,50))}},firstColumnStripe:{fill:q(K(`lt1`,-15))},firstSubtotalColumn:{font:J(`dk1`,!0),borders:{left:Y(K(`lt1`,-35)),right:Y(K(`lt1`,-35))}},firstSubtotalRow:{font:J(`dk1`,!0)},secondSubtotalRow:{font:J(`dk1`,!0)},pageFieldLabels:{font:J(`dk1`,!0)}},e=>({wholeTable:{font:J(K(e,-25)),borders:{left:Y(e),right:Y(e),top:Y(e),bottom:Y(e),vertical:Y(e)}},headerRow:{font:J(K(e,-25)),borders:{bottom:Y(e)}},totalRow:{font:J(K(e,-25)),borders:{top:Y(e)}},firstColumn:{font:J(K(e,-25))},firstRowStripe:{fill:q(K(e,80)),borders:{top:Y(K(`dk1`,50)),bottom:Y(K(`dk1`,50))}},firstColumnStripe:{fill:q(K(e,80))},firstSubtotalColumn:{font:J(K(e,-25))},firstSubtotalRow:{font:J(K(e,-25))},secondSubtotalRow:{font:J(K(e,-25))},pageFieldLabels:{font:J(K(e,-25))}})],[`Medium`,1,{wholeTable:{font:J(`dk1`),borders:{horizontal:Y(K(`lt1`,-15))}},headerRow:{font:J(`lt1`),fill:q(K(`dk1`,50)),borders:{horizontal:Y(K(`dk1`,50))}},totalRow:{font:J(`dk1`,!0),borders:{top:Y(K(`dk1`,50),im)}},firstRowStripe:{borders:{top:Y(K(`dk1`,50)),bottom:Y(K(`dk1`,50)),horizontal:Y(K(`dk1`,50))}},firstColumnStripe:{borders:{left:Y(K(`dk1`,50)),right:Y(K(`dk1`,50))}},firstHeaderCell:{font:J(`lt1`,!0)},firstSubtotalRow:{font:J(`lt1`,!0),fill:q(K(`lt1`,-35))},secondSubtotalRow:{font:J(`dk1`,!0),fill:q(K(`lt1`,-15))},firstColumnSubheading:{borders:{bottom:Y(K(`lt1`,-15))}},firstRowSubheading:{font:J(`lt1`),fill:q(K(`lt1`,-35)),borders:{bottom:Y(K(`lt1`,-15)),horizontal:Y(K(`lt1`,-15))}},secondRowSubheading:{fill:q(K(`lt1`,-15)),borders:{bottom:Y(K(`lt1`,-15))}},pageFieldLabels:{borders:{top:Y(K(`lt1`,-15)),bottom:Y(K(`lt1`,-15))}},pageFieldValues:{borders:{top:Y(K(`lt1`,-15)),bottom:Y(K(`lt1`,-15))}}},e=>({wholeTable:{font:J(`dk1`),borders:{horizontal:Y(K(e,80))}},headerRow:{font:J(`lt1`),fill:q(K(e,-25)),borders:{horizontal:Y(K(e,-25))}},totalRow:{font:J(`dk1`,!0),borders:{top:Y(K(e,-25),im)}},firstRowStripe:{borders:{top:Y(K(e,-25)),bottom:Y(K(e,-25)),horizontal:Y(K(e,-25))}},firstColumnStripe:{borders:{left:Y(K(e,-25)),right:Y(K(e,-25))}},firstHeaderCell:{font:J(`lt1`,!0)},firstSubtotalRow:{font:J(`lt1`,!0),fill:q(K(e,40))},secondSubtotalRow:{font:J(`dk1`,!0),fill:q(K(`lt1`,-15))},firstColumnSubheading:{borders:{bottom:Y(K(e,60))}},firstRowSubheading:{font:J(`lt1`),fill:q(K(e,40)),borders:{bottom:Y(K(e,80)),horizontal:Y(K(e,40))}},secondRowSubheading:{fill:q(K(e,80)),borders:{bottom:Y(e)}},pageFieldLabels:{borders:{top:Y(K(e,80)),bottom:Y(K(e,80))}},pageFieldValues:{borders:{top:Y(K(e,80)),bottom:Y(K(e,80))}}})],[`Medium`,8,{wholeTable:{font:J(`dk1`)},headerRow:{font:J(`lt1`,!0),fill:q(K(`dk1`,50)),borders:{top:Y(K(`dk1`,50),rm)}},totalRow:{font:J(`dk1`,!0),borders:{top:Y(`dk1`),bottom:Y(K(`dk1`,50),rm)}},firstRowStripe:{borders:{top:Y(K(`lt1`,-25)),bottom:Y(K(`lt1`,-25)),horizontal:Y(K(`lt1`,-25))}},firstColumnStripe:{borders:{left:Y(K(`lt1`,-15),rm),right:Y(K(`lt1`,-15),rm)}},firstSubtotalColumn:{font:J(`dk1`,!0),borders:{left:Y(K(`lt1`,-25),rm),right:Y(K(`lt1`,-25),rm),top:Y(K(`lt1`,-25),rm),bottom:Y(K(`lt1`,-25),rm)}},firstSubtotalRow:{font:J(`dk1`,!0),fill:q(K(`lt1`,-25))},secondSubtotalRow:{font:J(`dk1`,!0)},firstRowSubheading:{font:J(`dk1`,!0),fill:q(K(`lt1`,-15))},secondRowSubheading:{font:J(`dk1`,!0)},pageFieldLabels:{fill:q(K(`lt1`,-15))},pageFieldValues:{fill:q(K(`lt1`,-15))}},e=>({wholeTable:{font:J(`dk1`)},headerRow:{font:J(`lt1`,!0),fill:q(e),borders:{top:Y(K(e,-25),rm)}},totalRow:{font:J(`dk1`,!0),borders:{top:Y(K(e,-25)),bottom:Y(K(e,-25),rm)}},firstRowStripe:{borders:{top:Y(K(e,40)),bottom:Y(K(e,40)),horizontal:Y(K(e,40))}},firstColumnStripe:{borders:{left:Y(K(e,40)),right:Y(K(e,40))}},firstSubtotalColumn:{font:J(`dk1`,!0),borders:{left:Y(K(e,60),rm),right:Y(K(e,60),rm),top:Y(K(e,60),rm),bottom:Y(K(e,60),rm)}},firstSubtotalRow:{font:J(`dk1`,!0),fill:q(K(e,60))},secondSubtotalRow:{font:J(`dk1`,!0)},firstRowSubheading:{font:J(`dk1`,!0),fill:q(K(e,80))},secondRowSubheading:{font:J(`dk1`,!0)},pageFieldLabels:{fill:q(K(e,80))},pageFieldValues:{fill:q(K(e,80))}})],[`Medium`,15,{wholeTable:{font:J(`dk1`),fill:q(K(`lt1`,-5)),borders:{left:Y(K(`lt1`,-15)),right:Y(K(`lt1`,-15)),vertical:Y(K(`lt1`,-15))}},headerRow:{font:J(`lt1`),fill:q(`dk1`),borders:{left:nm,right:nm,vertical:nm}},totalRow:{font:J(`lt1`),fill:q(`dk1`),borders:{left:nm,right:nm,vertical:nm}},firstRowStripe:{fill:q(K(`lt1`,-15)),borders:{top:Y(K(`lt1`,-25)),bottom:Y(K(`lt1`,-25))}},firstColumnStripe:{fill:q(K(`lt1`,-15)),borders:{left:Y(K(`lt1`,-25)),right:Y(K(`lt1`,-25))}},firstSubtotalColumn:{font:J(`dk1`),fill:q(K(`lt1`,-25)),borders:{left:Y(K(`lt1`,-35)),right:Y(K(`lt1`,-35)),top:Y(K(`lt1`,-35))}},firstSubtotalRow:{font:J(`dk1`,!0),borders:{bottom:Y(K(`lt1`,-25))}},secondSubtotalRow:{font:J(K(`dk1`,50),!0)},firstRowSubheading:{font:J(`dk1`,!0)},secondRowSubheading:{font:J(K(`dk1`,50),!0)},thirdRowSubheading:{font:J(`dk1`,!0)},pageFieldLabels:{borders:{top:Y(`dk1`),bottom:Y(`dk1`)}},pageFieldValues:{borders:{top:Y(`dk1`),bottom:Y(`dk1`)}}},e=>({wholeTable:{font:J(`dk1`),fill:q(K(e,80)),borders:{left:Y(K(e,60)),right:Y(K(e,60)),vertical:Y(K(e,60))}},headerRow:{font:J(`lt1`),fill:q(`dk1`),borders:{left:nm,right:nm,vertical:nm}},totalRow:{font:J(`lt1`),fill:q(`dk1`),borders:{left:nm,right:nm,vertical:nm}},firstRowStripe:{fill:q(K(e,80)),borders:{top:Y(K(e,60)),bottom:Y(K(e,60))}},firstColumnStripe:{fill:q(K(e,80)),borders:{left:Y(K(e,60)),right:Y(K(e,60))}},firstSubtotalColumn:{font:J(`dk1`),fill:q(K(e,60)),borders:{left:Y(K(e,40)),right:Y(K(e,40)),top:Y(K(e,40))}},firstSubtotalRow:{font:J(`dk1`,!0),borders:{bottom:Y(K(e,60))}},secondSubtotalRow:{font:J(K(`dk1`,50),!0)},firstRowSubheading:{font:J(`dk1`,!0)},secondRowSubheading:{font:J(K(`dk1`,50),!0)},thirdRowSubheading:{font:J(`dk1`,!0)},pageFieldLabels:{borders:{top:Y(`dk1`),bottom:Y(`dk1`)}},pageFieldValues:{borders:{top:Y(`dk1`),bottom:Y(`dk1`)}}})],[`Medium`,22,{wholeTable:{font:J(K(`dk1`,50)),fill:q(K(`lt1`,-15)),borders:{vertical:Y(`lt1`)}},headerRow:{font:J(K(`dk1`,50),!0),borders:{bottom:Y(`lt1`)}},totalRow:{font:J(K(`dk1`,50),!0)},firstColumn:{font:J(K(`dk1`,50),!0),fill:q(K(`lt1`,-25))},secondRowStripe:{fill:q(K(`lt1`,-25))},secondColumnStripe:{fill:q(K(`lt1`,-25))},firstSubtotalRow:{font:J(`dk1`,!0)},secondSubtotalRow:{font:J(`dk1`,!0)},firstRowSubheading:{font:J(`dk1`,!0)},pageFieldLabels:{font:J(K(`dk1`,50),!0),fill:q(K(`lt1`,-25))}},e=>({wholeTable:{font:J(K(e,-25)),fill:q(K(e,80)),borders:{vertical:Y(`lt1`)}},headerRow:{font:J(K(e,-25),!0),borders:{bottom:Y(`lt1`)}},totalRow:{font:J(K(e,-25),!0)},firstColumn:{font:J(K(e,-25),!0),fill:q(K(e,60))},secondRowStripe:{fill:q(K(e,60))},secondColumnStripe:{fill:q(K(e,60))},firstSubtotalRow:{font:J(`dk1`,!0)},secondSubtotalRow:{font:J(`dk1`,!0)},firstRowSubheading:{font:J(`dk1`,!0)},pageFieldLabels:{font:J(K(e,-25),!0),fill:q(K(e,60))}})],[`Dark`,1,{wholeTable:{font:J(`dk1`),fill:q(K(`lt1`,-25)),borders:{horizontal:Y(K(`lt1`,-15))}},headerRow:{font:J(`lt1`,!0),fill:q(K(`dk1`,50)),borders:{bottom:Y(`lt1`),horizontal:Y(K(`dk1`,50))}},totalRow:{font:J(`lt1`,!0),fill:q(K(`dk1`,50))},secondRowStripe:{fill:q(K(`lt1`,-35))},secondColumnStripe:{borders:{left:Y(K(`lt1`,-15)),right:Y(K(`lt1`,-15))}},firstSubtotalRow:{font:J(`dk1`,!0),borders:{bottom:Y(K(`lt1`,-35))}},firstRowSubheading:{font:J(`dk1`,!0),fill:q(K(`lt1`,-15)),borders:{top:Y(K(`lt1`,-35)),bottom:Y(K(`lt1`,-35))}},secondRowSubheading:{font:J(`dk1`,!0)},pageFieldLabels:{font:J(`lt1`,!0),fill:q(K(`dk1`,50)),borders:{horizontal:Y(K(`dk1`,50))}},pageFieldValues:{font:J(`lt1`),fill:q(K(`dk1`,50)),borders:{horizontal:Y(K(`dk1`,50))}}},e=>({wholeTable:{font:J(`dk1`),fill:q(K(e,60)),borders:{horizontal:Y(K(e,80))}},headerRow:{font:J(`lt1`,!0),fill:q(K(e,-50)),borders:{bottom:Y(e),horizontal:Y(K(e,-50))}},totalRow:{font:J(`lt1`,!0),fill:q(K(e,-50))},secondRowStripe:{fill:q(K(e,40))},secondColumnStripe:{borders:{left:Y(K(e,80)),right:Y(K(e,80))}},firstSubtotalRow:{font:J(`dk1`,!0),borders:{bottom:Y(K(e,80))}},firstRowSubheading:{font:J(`dk1`,!0),fill:q(K(e,80)),borders:{top:Y(K(e,40)),bottom:Y(K(e,40))}},secondRowSubheading:{font:J(`dk1`,!0)},pageFieldLabels:{font:J(`lt1`,!0),fill:q(K(e,-50)),borders:{horizontal:Y(K(e,-50))}},pageFieldValues:{font:J(`lt1`),fill:q(K(e,-50)),borders:{horizontal:Y(K(e,-50))}}})],[`Dark`,8,{wholeTable:{font:J(`dk1`),fill:q(K(`lt1`,-15)),borders:{left:Y(K(`dk1`,50),rm),right:Y(K(`dk1`,50),rm),top:Y(K(`dk1`,50),rm),bottom:Y(K(`dk1`,50),rm)}},headerRow:{font:J(`lt1`,!0),fill:q(K(`dk1`,25))},totalRow:{font:J(`lt1`,!0),fill:q(K(`dk1`,25))},secondRowStripe:{borders:{top:Y(K(`lt1`,-25)),bottom:Y(K(`lt1`,-25))}},firstColumnStripe:{borders:{left:Y(K(`lt1`,-45)),right:Y(K(`lt1`,-45))}},secondColumnStripe:{borders:{left:Y(K(`lt1`,-45)),right:Y(K(`lt1`,-45))}},firstSubtotalRow:{font:J(`dk1`,!0),fill:q(K(`lt1`,-25))},secondColumnSubheading:{borders:{top:Y(K(`lt1`,-25),rm)}},thirdColumnSubheading:{borders:{top:Y(K(`lt1`,-25),rm)}},firstRowSubheading:{font:J(`dk1`,!0),fill:q(K(`lt1`,-25)),borders:{bottom:Y(K(`lt1`,-15),rm)}},secondRowSubheading:{font:J(`dk1`,!0)},pageFieldLabels:{borders:{left:Y(K(`dk1`,50),rm),top:Y(K(`dk1`,50),rm),bottom:Y(K(`dk1`,50),rm)}},pageFieldValues:{borders:{right:Y(K(`dk1`,50),rm),top:Y(K(`dk1`,50),rm),bottom:Y(K(`dk1`,50),rm)}}},e=>({wholeTable:{font:J(`dk1`),fill:q(K(e,80)),borders:{left:Y(K(`dk1`,50),rm),right:Y(K(`dk1`,50),rm),top:Y(K(`dk1`,50),rm),bottom:Y(K(`dk1`,50),rm)}},headerRow:{font:J(`lt1`,!0),fill:q(K(`dk1`,25))},totalRow:{font:J(`lt1`,!0),fill:q(K(`dk1`,25))},secondRowStripe:{borders:{top:Y(K(e,60)),bottom:Y(K(e,60))}},firstColumnStripe:{borders:{left:Y(K(e,40)),right:Y(K(e,40))}},secondColumnStripe:{borders:{left:Y(K(e,40)),right:Y(K(e,40))}},firstSubtotalRow:{font:J(`dk1`,!0),fill:q(K(e,60))},secondColumnSubheading:{borders:{top:Y(K(e,80),rm)}},thirdColumnSubheading:{borders:{top:Y(K(e,80),rm)}},firstRowSubheading:{font:J(`dk1`,!0),fill:q(K(e,60)),borders:{bottom:Y(K(e,80),rm)}},secondRowSubheading:{font:J(`dk1`,!0)},pageFieldLabels:{borders:{left:Y(K(`dk1`,50),rm),top:Y(K(`dk1`,50),rm),bottom:Y(K(`dk1`,50),rm)}},pageFieldValues:{borders:{right:Y(K(`dk1`,50),rm),top:Y(K(`dk1`,50),rm),bottom:Y(K(`dk1`,50),rm)}}})],[`Dark`,15,{wholeTable:{font:J(K(`lt1`,-15)),fill:q(K(`lt1`,-45))},headerRow:{font:J(`lt1`,!0),fill:q(`dk1`)},totalRow:{font:J(`lt1`,!0),fill:q(`dk1`)},firstRowStripe:{borders:{top:Y(K(`lt1`,-35)),bottom:Y(K(`lt1`,-35))}},firstColumnStripe:{borders:{left:Y(K(`lt1`,-25)),right:Y(K(`lt1`,-25))}},firstSubtotalColumn:{fill:q(K(`dk1`,50)),borders:{left:Y(K(`lt1`,-35)),right:Y(K(`lt1`,-35)),top:Y(K(`lt1`,-35)),bottom:Y(K(`lt1`,-35))}},firstSubtotalRow:{font:J(`lt1`,!0)},firstColumnSubheading:{borders:{bottom:Y(K(`lt1`,-35))}},firstRowSubheading:{font:J(`lt1`,!0),fill:q(K(`dk1`,50)),borders:{bottom:Y(K(`accent1`,80))}},secondRowSubheading:{font:J(`lt1`,!0)},pageFieldLabels:{font:J(`lt1`,!0)}},e=>({wholeTable:{font:J(K(e,80)),fill:q(e)},headerRow:{font:J(`lt1`,!0),fill:q(`dk1`)},totalRow:{font:J(`lt1`,!0),fill:q(`dk1`)},firstRowStripe:{borders:{top:Y(K(e,40)),bottom:Y(K(e,40))}},firstColumnStripe:{borders:{left:Y(K(e,40)),right:Y(K(e,40))}},firstSubtotalColumn:{fill:q(K(e,-25)),borders:{left:Y(K(e,40)),right:Y(K(e,40)),top:Y(K(e,40)),bottom:Y(K(e,40))}},firstSubtotalRow:{font:J(`lt1`,!0)},firstColumnSubheading:{borders:{bottom:Y(K(e,40))}},firstRowSubheading:{font:J(`lt1`,!0),fill:q(K(e,-25))},secondRowSubheading:{font:J(`lt1`,!0)},pageFieldLabels:{font:J(`lt1`,!0)}})],[`Dark`,22,{wholeTable:{font:J(K(`lt1`,-15)),fill:q(K(`lt1`,-50)),borders:{vertical:Y(`lt1`)}},headerRow:{fill:q(K(`dk1`,50)),borders:{bottom:Y(`lt1`,rm)}},totalRow:{font:J(`lt1`,!0),borders:{top:Y(`lt1`,rm)}},firstColumn:{fill:q(K(`dk1`,50))},secondRowStripe:{fill:q(K(`lt1`,-45))},secondColumnStripe:{fill:q(K(`lt1`,-45))},firstHeaderCell:{font:J(`lt1`,!0)},firstSubtotalRow:{font:J(K(`lt1`,-15),!0)},secondSubtotalRow:{font:J(`dk1`,!0)},firstRowSubheading:{font:J(`lt1`,!0)},secondRowSubheading:{font:J(`lt1`,!0)},pageFieldLabels:{fill:q(K(`dk1`,50))}},e=>({wholeTable:{font:J(K(e,80)),fill:q(e),borders:{vertical:Y(`lt1`)}},headerRow:{fill:q(K(e,-25)),borders:{bottom:Y(`lt1`,rm)}},totalRow:{font:J(`lt1`,!0),borders:{top:Y(`lt1`,rm)}},firstColumn:{fill:q(K(e,-25))},secondRowStripe:{fill:q(K(e,40))},secondColumnStripe:{fill:q(K(e,40))},firstHeaderCell:{font:J(`lt1`,!0)},firstSubtotalRow:{font:J(K(e,80))},secondSubtotalRow:{font:J(`lt1`,!0)},firstRowSubheading:{font:J(`lt1`,!0)},secondRowSubheading:{font:J(`lt1`,!0)},pageFieldLabels:{fill:q(K(e,-25))}})]],om={PivotStyleLight2:e=>({secondSubtotalRow:{font:J(e)},secondRowSubheading:{font:J(e)}})},sm=null,cm=()=>{if(sm)return sm;let e=new Map;for(let[t,n,r,i]of am)for(let a=0;a<7;a++){let o=`PivotStyle${t}${n+a}`,s=`accent${a}`,c=a===0?r:{...i(s),...om[o]?.(s)};e.set(o.toLowerCase(),Object.freeze({name:o,table:!1,pivot:!0,...c}))}return sm=e,e},lm=(e,t,n)=>{let r=e.borders;if(!r)return e;let i=((e,t,n)=>{if(!e)return e;let r=null;return(e.top||e.horizontal)&&(t.rowIndex!==n.rowStart||t.colIndex<n.colStart||t.colIndex>n.colEnd)&&(r??={...e},delete r.top,e.horizontal&&(r.top=e.horizontal)),(e.bottom||e.horizontal)&&(t.rowIndex!==n.rowEnd||t.colIndex<n.colStart||t.colIndex>n.colEnd)&&(r??={...e},delete r.bottom,e.horizontal&&(r.bottom=e.horizontal)),(e.left||e.vertical)&&(t.colIndex!==n.colStart||t.rowIndex<n.rowStart||t.rowIndex>n.rowEnd)&&(r??={...e},delete r.left,e.vertical&&(r.left=e.vertical)),(e.right||e.vertical)&&(t.colIndex!==n.colEnd||t.rowIndex<n.rowStart||t.rowIndex>n.rowEnd)&&(r??={...e},delete r.right,e.vertical&&(r.right=e.vertical)),e.horizontal&&(r??={...e},delete r.horizontal),e.vertical&&(r??={...e},delete r.vertical),r??e})(r,t,n),a=e;return i!==e.borders&&(a={...e},Object.keys(i).length>0?a.borders=i:delete a.borders),a},um=class{constructor(e,t,n){this._permCache=null,this._table=e,this._styles=t,this._properties=n}_resolveProperties(e){let t={name:e.name},n=this._styles,r=[...Object.values(Xf.ElementType),...Object.values(Xf.PivotElementType)],o=r.length;for(let s=0;s<o;s++){let o=r[s],c=e[o];c&&i.isObject(c)&&(t[o]=a.resolveTypedUpdates(Object.freeze(c),yt,n))}return Object.freeze(t)}getCoords(){return this._table.getRange().getCoords()}getPropertiesAt(e,t){let n=this._table,r=this._styles,i=this._properties;fm.rowIndex=e,fm.colIndex=t;let o=n.getVisibleCellCoords(fm),s=n.getVisibleRefRangeCoords();if(!s)return null;let c=Math.max(0,s.colEnd-s.colStart)+1,l=Math.max(0,s.rowEnd-s.rowStart)+1,u=Math.max(0,o.rowIndex-s.rowStart),d=Math.max(0,o.colIndex-s.colStart),f=n.getStyleOptions(),p=!1,m=0;n.isHeaderVisible()&&(m=+!!n.isShowHeaders(),p=m>u);let h=!1,g=0;n.isTotalVisible()&&(g=+!!n.isShowTotals(),h=l-g<=u);let _=d===c-1&&f.showLastColumn;n.isLastColumnVisible()||(_=!1);let v=d===0&&f.showFirstColumn;n.isFirstColumnVisible()||(v=!1);let y=!p&&!h,b=y&&f.showColumnStripes,x=0,S=0,C=0,w=!1,T=0;b&&(x=i.firstColumnStripe?.size??1,S=i.secondColumnStripe?.size??1,C=d%(x+S),w=C<x,w||(C-=x),T=Math.min(c-d,w?x:S));let E=y&&f.showRowStripes,D=0,O=0,k=0,A=!1,j=0;E&&(D=i.firstRowStripe?.size??1,O=i.secondRowStripe?.size??1,k=(u-m)%(D+O),A=k<D,A||(k-=D),j=Math.min(l-u,A?D:O));let M=!1;if(p&&i.headerRow){let e=n.getColumnAt(d);M=!!e&&!e.isHiddenButton()}let N=0;p&&(N|=1),h&&(N|=2),v&&(N|=4),_&&(N|=8),u===0&&(N|=16),u===l-1&&(N|=32),d===0&&(N|=64),d===c-1&&(N|=128),u===m&&(N|=256),u===l-g-1&&(N|=512),M&&(N|=1024),m>0&&(N|=2048),g>0&&(N|=4096);let ee=`${N}`+(b?`|c${w?`f`:`s`}${C},${T}`:``)+(E?`|r${A?`f`:`s`}${k},${j}`:``),te=this._permCache?.get(ee);if(te!==void 0)return te;let P={rowIndex:u,colIndex:d},F={};if(i.wholeTable&&(F=i.wholeTable,F.borders&&(F=lm(F,P,{rowStart:0,rowEnd:l-1,colStart:0,colEnd:c-1}))),b){let e=w?i.firstColumnStripe:i.secondColumnStripe;if(e){let t=e,n=e.borders;n&&(t=lm(t,{rowIndex:u,colIndex:C},{rowStart:m,rowEnd:l-g-1,colStart:0,colEnd:T}),w&&C===0&&d>0&&n?.left&&i.secondColumnStripe?.borders?.right&&(n={...t.borders},t.borders=n,n.left=null),w&&C===x-1&&d<c-1&&n?.right&&i.secondColumnStripe?.borders?.left&&(n={...t.borders},t.borders=n,n.right=null)),F=a.resolveTypedUpdates(t,yt,r,F)}}if(E){let e=m,t=l-g-1,n=A?i.firstRowStripe:i.secondRowStripe;if(n){let o=n,s=n.borders;if(s){o=lm(o,{colIndex:d,rowIndex:k},{colStart:0,colEnd:c-1,rowStart:0,rowEnd:j}),A&&k===0&&u>=e&&n.borders?.top&&i.secondRowStripe?.borders?.bottom&&(s={...o.borders},o.borders=s,s.top=null);let r=n.borders?.bottom;(r&&A&&k===D-1&&u<t&&i.secondRowStripe?.borders?.top||r&&u===t)&&(s={...o.borders},o.borders=s,s.bottom=null)}F=a.resolveTypedUpdates(o,yt,r,F)}}if(_&&i.lastColumn){let e=i.lastColumn;e.borders&&(e=lm(e,P,{rowStart:0,rowEnd:l-1,colStart:c-1,colEnd:c-1})),F=a.resolveTypedUpdates(e,yt,r,F)}if(v&&i.firstColumn){let e=i.firstColumn;e.borders&&(e=lm(e,P,{rowStart:0,rowEnd:l-1,colStart:0,colEnd:0})),F=a.resolveTypedUpdates(e,yt,r,F)}if(p&&i.headerRow){let e=i.headerRow;e.borders&&(e=lm(e,P,{rowStart:0,rowEnd:m-1,colStart:0,colEnd:c-1})),F=a.resolveTypedUpdates(e,yt,r,F)}if(h&&i.totalRow){let e=i.totalRow;e.borders&&(e=lm(e,P,{rowStart:l-g,rowEnd:l-1,colStart:0,colEnd:c-1})),F=a.resolveTypedUpdates(e,yt,r,F)}if(p&&v&&i.firstHeaderCell){let e=i.firstHeaderCell;e.borders&&(e=lm(e,P,{rowStart:0,rowEnd:m-1,colStart:0,colEnd:0})),F=a.resolveTypedUpdates(e,yt,r,F)}if(p&&_&&i.lastHeaderCell){let e=i.lastHeaderCell;e.borders&&(e=lm(e,P,{rowStart:0,rowEnd:m-1,colStart:c-1,colEnd:c-1})),F=a.resolveTypedUpdates(e,yt,r,F)}if(h&&v&&i.firstTotalCell){let e=i.firstTotalCell;e.borders&&(e=lm(e,P,{rowStart:l-g,rowEnd:l-1,colStart:0,colEnd:0})),F=a.resolveTypedUpdates(e,yt,r,F)}if(h&&_&&i.lastTotalCell){let e=i.lastTotalCell;e.borders&&(e=lm(e,P,{rowStart:l-g,rowEnd:l-1,colStart:c-1,colEnd:c-1})),F=a.resolveTypedUpdates(e,yt,r,F)}M&&(F.insets={right:15});let ne=this._permCache;return ne||=this._permCache=new Map,ne.set(ee,Object.freeze(F)),F}},dm=class{constructor(e,t,n,r){this._styles=e,this._isBuiltIn=n,this._doDelete=r,this._properties=i.deepFreeze(this._resolveProperties(t)),this.isShownInTableStyles()}_resolveProperties(e){let t={name:e.name};e.table!==void 0&&(t.table=e.table),e.pivot!==void 0&&(t.pivot=e.pivot);let n=this._styles,r=[...Object.values(Xf.ElementType),...Object.values(Xf.PivotElementType)],o=r.length;for(let s=0;s<o;s++){let o=r[s],c=e[o];c&&i.isObject(c)&&(t[o]=a.resolveTypedUpdates(Object.freeze(c),yt,n))}return Object.freeze(t)}delete(){if(!this._doDelete)throw Error(`Not able to delete builtin style.`);this._doDelete(this._properties.name)}getRanged(e){return new um(e,this._styles,this._properties)}getProperties(){return this._properties}getName(){return this._properties.name}isShownInTableStyles(){return!1!==this._properties.table}isShownInPivotStyles(){return this._properties.pivot??!1}isBuiltIn(){return this._isBuiltIn}toJSON(){let e=i.cloneObject(this._properties);return e.name=this._properties.name,e}get isITableStyle(){return!0}},fm={rowIndex:0,colIndex:0};function pm(e,t){if(!t||t.rowStart>e.rowEnd||t.rowEnd<e.rowStart||t.colStart>e.colEnd||t.colEnd<e.colStart)return[{...e}];let n=[];t.rowStart>e.rowStart&&n.push({colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colEnd,rowEnd:t.rowStart-1}),t.rowEnd<e.rowEnd&&n.push({colStart:e.colStart,rowStart:t.rowEnd+1,colEnd:e.colEnd,rowEnd:e.rowEnd});let r=Math.max(e.rowStart,t.rowStart),i=Math.min(e.rowEnd,t.rowEnd);return t.colStart>e.colStart&&n.push({colStart:e.colStart,rowStart:r,colEnd:t.colStart-1,rowEnd:i}),t.colEnd<e.colEnd&&n.push({colStart:t.colEnd+1,rowStart:r,colEnd:e.colEnd,rowEnd:i}),n}function mm(e,t){if(!t||t.length===0)return e.map(e=>({...e}));let n=e;for(let e=0;e<t.length&&n.length>0;e++){let r=[];for(let i=0;i<n.length;i++)r.push(...pm(n[i],t[e]));n=r}return n}function hm(e,t){return e.colStart<=t.colStart&&e.colEnd>=t.colEnd&&e.rowStart<=t.rowStart&&e.rowEnd>=t.rowEnd?{...e}:t.colStart<=e.colStart&&t.colEnd>=e.colEnd&&t.rowStart<=e.rowStart&&t.rowEnd>=e.rowEnd?{...t}:e.colStart===t.colStart&&e.colEnd===t.colEnd&&e.rowStart<=t.rowEnd+1&&t.rowStart<=e.rowEnd+1?{colStart:e.colStart,rowStart:Math.min(e.rowStart,t.rowStart),colEnd:e.colEnd,rowEnd:Math.max(e.rowEnd,t.rowEnd)}:e.rowStart===t.rowStart&&e.rowEnd===t.rowEnd&&e.colStart<=t.colEnd+1&&t.colStart<=e.colEnd+1?{colStart:Math.min(e.colStart,t.colStart),rowStart:e.rowStart,colEnd:Math.max(e.colEnd,t.colEnd),rowEnd:e.rowEnd}:null}var gm=(e,t)=>e-t;function _m(e,t){return e.rowStart<=t.rowEnd&&t.rowStart<=e.rowEnd&&e.colStart<=t.colEnd&&t.colStart<=e.colEnd}var vm=class{constructor(){this._bands=new Map,this._tall=[],this._isTall=[],this._all=[],this._isKnown=[],this._overlapping=!1}isOverlapping(){return this._overlapping}markOverlapping(){this._overlapping=!0}add(e,t){this._isKnown[e]||(this._isKnown[e]=!0,this._all.push(e));let n=t.rowStart>>5,r=t.rowEnd>>5;if(r-n>64)return void(this._isTall[e]||(this._isTall[e]=!0,this._tall.push(e)));let i=this._bands;for(let t=n;t<=r;t++){let n=i.get(t);n===void 0&&i.set(t,n=[]),n.push(e)}}collectRows(e,t,n,r,i){let a=this._tall;for(let e=0;e<a.length;e++){let t=a[e];n[t]!==r&&(n[t]=r,i.push(t))}let o=e>>5,s=t>>5;if(s-o>64){let e=this._all;for(let t=0;t<e.length;t++){let a=e[t];n[a]!==r&&(n[a]=r,i.push(a))}return}let c=this._bands;for(let e=o;e<=s;e++){let t=c.get(e);if(t!==void 0)for(let e=0;e<t.length;e++){let a=t[e];n[a]!==r&&(n[a]=r,i.push(a))}}}collectNeighbors(e,t,n,r){this.collectRows(e.rowStart-1,e.rowStart-1,t,n,r),this.collectRows(e.rowEnd+1,e.rowEnd+1,t,n,r),(e.rowEnd>>5)-(e.rowStart>>5)>64&&!this._overlapping||this.collectRows(e.rowStart,e.rowEnd,t,n,r)}},ym=class{constructor(){this._keys=[]}getSize(){return this._keys.length}push(e){let t=this._keys;t.push(e);let n=t.length-1;for(;n>0;){let e=n-1>>1;if(t[e]<=t[n])break;let r=t[e];t[e]=t[n],t[n]=r,n=e}}pop(){let e=this._keys,t=e[0],n=e.pop(),r=e.length;if(r>0){e[0]=n;let t=0;for(;;){let n=2*t+1;if(n>=r)break;let i=n+1,a=i<r&&e[i]<e[n]?i:n;if(e[t]<=e[a])break;let o=e[t];e[t]=e[a],e[a]=o,t=a}}return t}};function bm(e,t){let n=e.map(e=>({...e})),r=Array(n.length).fill(!1),i=n.length+t.length;return i*i<=256?(function(e,t,n){for(let r=0;r<n.length;r++){let i=[n[r]];for(let t=0;t<e.length&&i.length>0;t++){let n=[];for(let r=0;r<i.length;r++)n.push(...pm(i[r],e[t]));i=n}for(let n=0;n<i.length;n++)e.push(i[n]),t.push(!0)}let r=!0;for(;r;){r=!1;for(let n=0;n<e.length&&!r;n++)for(let i=n+1;i<e.length&&!r;i++){if(!t[n]&&!t[i])continue;let a=hm(e[n],e[i]);a&&(e[n]=a,t[n]=!0,e.splice(i,1),t.splice(i,1),r=!0)}}}(n,r,t),n):function(e,t,n){let r=e.length,i=Array(r).fill(!0),a=Array(r).fill(-1),o=new ym,s=[],c=0,l=l=>{s.length=0,n.collectNeighbors(e[l],a,c++,s);for(let n=0;n<s.length;n++){let a=s[n];if(a===l||!i[a]||!t[l]&&!t[a]||!hm(e[l],e[a]))continue;let c=a<l?a:l,u=a<l?l:a;o.push(c*r+u)}};for(let e=0;e<r;e++)l(e);for(;o.getSize()>0;){let a=o.pop(),s=Math.floor(a/r),c=a-s*r;if(!i[s]||!i[c]||!t[s]&&!t[c])continue;let u=hm(e[s],e[c]);u&&(e[s]=u,t[s]=!0,i[c]=!1,n.add(s,u),l(s))}let u=[];for(let t=0;t<r;t++)i[t]&&u.push(e[t]);return u}(n,r,function(e,t,n){let r=new vm,i=[],a=[],o=e.length;for(let t=0;t<o;t++){if(i.push(-1),!r.isOverlapping()){a.length=0,r.collectRows(e[t].rowStart,e[t].rowEnd,i,-2-t,a);for(let n=0;n<a.length;n++)if(_m(e[t],e[a[n]])){r.markOverlapping();break}}r.add(t,e[t])}for(let o=0;o<n.length;o++){a.length=0,r.collectRows(n[o].rowStart,n[o].rowEnd,i,o,a),a.sort(gm);let s=[n[o]];for(let t=0;t<a.length&&s.length>0;t++){let r=e[a[t]];if(!_m(n[o],r))continue;let i=[];for(let e=0;e<s.length;e++)i.push(...pm(s[e],r));s=i}for(let n=0;n<s.length;n++){let a=e.length;e.push(s[n]),t.push(!0),i.push(-1),r.add(a,s[n])}}return r}(n,r,t))}function xm(e,t){let n=t?.protection?.alwaysUnlocked;if(n!==void 0)return n;let r=t?.named;if(r){let t=e.getNamedStyles().getByName(r)?.getRanged().getPropertiesAt(0,0,null)?.protection?.alwaysUnlocked;if(t!==void 0)return t}return e.getNormal().getProtection().isAlwaysUnlocked()}function Sm(e,t){let n=t?.protection?.showFormulas;if(n!==void 0)return n;let r=t?.named;if(r){let t=e.getNamedStyles().getByName(r)?.getRanged().getPropertiesAt(0,0,null)?.protection?.showFormulas;if(t!==void 0)return t}return e.getNormal().getProtection().isShowFormulas()}function Cm(e,t){let n=t?.numberFormat;if(n!=null)return typeof n==`number`?Ce(n):n;let r=t?.named;if(!r)return;let i=e.getNamedStyles().getByName(r)?.getRanged().getPropertiesAt(0,0,null)?.numberFormat,a=typeof i==`number`?Ce(i):i;return a&&a!==`General`?a:void 0}function wm(e,t,n,r,i){let a=e.search(n,!1);if(a.length===0||!r?.isLocked()||r.isShowFormulasAllowed())return a;let o=i.getNormal().getProtection().isShowFormulas(),s=[],c=t.search(n,!1);for(let e=0;e<c.length;e++)Sm(i,c[e].value?.getPropertiesAt(0,0,null))!==o&&s.push(c[e]);if(o&&s.length===0)return a;let l=[];for(let e=0;e<a.length;e++){let t=a[e],n;if(o)n=mm([t],s);else{n=[];for(let e=0;e<s.length;e++){let r=h.intersectRanges(t,s[e]);r&&n.push(r)}}for(let e=0;e<n.length;e++){let r=n[e];l.push({colStart:r.colStart,rowStart:r.rowStart,colEnd:r.colEnd,rowEnd:r.rowEnd,value:t.value})}}return l}function Tm(e,t){if(!e||!t)return e===t;if(e===t)return!0;if(e.style!==t.style)return!1;if(e.color===t.color)return!0;let n=e.color;e.color?.isIColor&&(n=e.color.toString());let r=t.color;return t.color?.isIColor&&(r=t.color.toString()),n===r}function Em(e,t,n,r){let i=r?L.Edge.Left:L.Edge.Top,a=r?L.Edge.Right:L.Edge.Bottom,o=r?L.Edge.Vertical:L.Edge.Horizontal,s=r?t.colStart:t.rowStart,c=r?t.colEnd:t.rowEnd,l=r?n.colStart:n.rowStart,u=r?n.colEnd:n.rowEnd,d=s===l,f=c===u,p={...e};return d&&f?e:(delete p[i],delete p[a],delete p[o],d?e[i]!==void 0&&(p[i]=e[i]):e[o]!==void 0&&(p[i]=e[o]),f?e[a]!==void 0&&(p[a]=e[a]):e[o]!==void 0&&(p[a]=e[o]),u-l>0&&e[o]!==void 0&&(p[o]=e[o]),Object.keys(p).length===0?null:p)}function Dm(e,t){let n=e.before,r=e.after;if(n&&t){let i=e.amount,a=e.axis===B.Axis.Column,o=a?`colStart`:`rowStart`,s=a?`colEnd`:`rowEnd`,c=t[o],l=t[s],u=n[o]<=c,d=n[s]>=l,f=r?r[o]:-1;if(u&&d)return n;if(d){if(i>0){if(f>l)throw new w(``);r={...r},r[s]=l}else r?(r={...r},r[s]=l):(r={...n},r[o]=e.intersect[o])}}if(!r)return null;if(t&&!h.isRangeWithinRange(r,t))throw new w(``);return h.sanitizeRange(r)}var Om=e=>{if(e==null)return null;let t,n=Object.keys(e),r=n.length;for(let i=0;i<r;i++){let r=n[i],a=e[r],o=a;if(a===null)o=void 0;else if(a&&typeof a==`object`&&!Array.isArray(a)){let e=Om(a);o=e===null?void 0:e}if(o!==a){if(t===void 0){t={};for(let r=0;r<i;r++)t[n[r]]=e[n[r]]}o!==void 0&&(t[r]=o)}else t!==void 0&&(t[r]=a)}return t===void 0?r===0?null:e:Object.keys(t).length===0?null:t},km=(e,t)=>{if(!e.diagonalUp&&!e.diagonalDown)return t;let n=t??{};return e.diagonalUp&&(n.diagonalUp=e.diagonalUp),e.diagonalDown&&(n.diagonalDown=e.diagonalDown),n},Am=class e{constructor(e,t,n,r,i){this._c=e,this._getEntireRange=t,this._r=n,this._p=r??null,this._t=i??null,this._e=this._p===null||Object.keys(this._p).length===1&&this._p.named===z.BuiltInName.Normal}isEmpty(){return this._e}getProperties(){return this._p}getCoords(){return this._r}getUpdateProperties(){return this._u}getMeasureKey(){let e=this._mk;if(e===void 0){let t=this._p;if(t){let n=t.alignment;e=JSON.stringify([t.named??null,t.numberFormat??null,t.font??null,n?[n.overflow??null,n.rotation??null,n.indent??null,n.stacked??null,n.vertical??null]:null,t.insets??null])}else e=``;this._mk=e}return e}static{this.BorderKeys=[`borders`]}static{this.FillKeys=[`fill`]}static{this.ContentKeys=[`font`,`numberFormat`,`alignment`,`quotePrefix`,`protection`,`named`,`insets`]}splitByFeature(){let t=(e,t)=>{if(!e)return;let n;for(let r=0;r<t.length;r++){let i=t[r];e[i]!==void 0&&((n??={})[i]=e[i])}return n},n=n=>{let r=t(this._p,n),i=t(this._u,n);if(r===void 0&&i===void 0)return null;let a=new e(this._c,this._getEntireRange,this._r,r??null,this._t);return i!==void 0&&(a._u=i),a};return{border:n(e.BorderKeys),fill:n(e.FillKeys),content:n(e.ContentKeys)}}static compose(t,n,r){if(!t&&!n&&!r)return null;if(t&&!n&&!r)return t;if(!t&&n&&!r)return n;if(!t&&!n&&r)return r;let i=t??r??n,a={...r?r._p:null,...n?n._p:null,...t?t._p:null};return new e(i._c,i._getEntireRange,i._r,a,i._t)}static mergeOverlay(t,n){if(!t)return n??null;if(!n)return t;let r=n._p?.borders?n:t,i={...t._p,...n._p};return new e(r._c,r._getEntireRange,r._r,i,r._t)}cloneWithUpdate(t,n=!1){if(t===void 0)return this;let r=this._c,i=this._r,o=this._p,s=a.resolveTypedUpdates(t,Ot,r,o,n);if(n){let t=Om(s),n=new e(r,this._getEntireRange,i,t,this._t);return t!==s&&(n._u=s),n}return new e(r,this._getEntireRange,i,s,this._t)}copyTo(t,n){let r=this._c,i=this._r,a=t.rowStart-i.rowStart,o=t.colStart-i.colStart,s=h.translateRange(this._t??i,a,o);return h.isEqualRanges(s,t)&&(s=null),{...t,value:new e(r,this._getEntireRange,t,this._p,s)}}canTile(e,t){return!(this._u??this._p)?.borders}_createShifted(t){return new e(this._c,this._getEntireRange,t,this._p,this._t)}getShifted(e){let t=this._getEntireRange?.(),n=Dm(e,t);return n?{...n,value:this._createShifted(n)}:null}getSplit(t,n){let r=this._c,i=this._u,a=i??this._p,o=this._r,s=a,c=t[0],l=a,u=t[1],d=a?a.borders:null;if(d){let e=n===B.Axis.Column;if(e?d.left!==void 0||d.right!==void 0||d.vertical!==void 0:d.top!==void 0||d.bottom!==void 0||d.horizontal!==void 0){s={...s};let t=Em(d,o,c,e);t?s.borders=t:t===null&&delete s.borders,l={...l};let n=Em(d,o,u,e);n?l.borders=n:n===null&&delete l.borders}}let f=this._t,p=this._getEntireRange;if(i){let n=new e(r,p,t[0],Om(s),f);n._u=s;let i=new e(r,p,t[1],Om(l),f);return i._u=l,[n,i]}return[new e(r,p,t[0],s,f),new e(r,p,t[1],l,f)]}getMerged(t,n,r){let o=r===B.Axis.Column,s=this._p,c=t._p;if(s&&!c||c&&!s||!s&&!c)return;let l=Object.keys(s),u=Object.keys(c),d=l.length;if(d!==u.length)return;for(let e=0;e<d;e++){let t=l[e];if(t===`borders`)continue;let n=s[t],r=c[t];if(!i.deepEqual(n,r))return}let f=s.borders,p=c.borders;if(f&&!p||p&&!f)return;let m=this._c;if(f||p){let r=o?L.Edge.Top:L.Edge.Left,i=o?L.Edge.Bottom:L.Edge.Right;if(!Tm(f[r],p[r])||!Tm(f[i],p[i]))return;let c=this._r,l=t._r,u=1+(o?c.rowEnd-c.rowStart:c.colEnd-c.colStart),d=1+(o?c.colEnd-c.colStart:c.rowEnd-c.rowStart),h=1+(o?l.colEnd-l.colStart:l.rowEnd-l.rowStart),g=o?L.Edge.Horizontal:L.Edge.Vertical;if(u>1&&!Tm(f[g],p[g]))return;let _=o?L.Edge.Right:L.Edge.Bottom,v=o?L.Edge.Left:L.Edge.Top;if(!Tm(f[_],p[v]))return;let y=o?L.Edge.Vertical:L.Edge.Horizontal,b=f[_];if(d>1&&!Tm(b,f[y]))return;let x=h===1?p[v]:p[y];if(h>1&&!Tm(x,p[y])||!Tm(b,x)||!Tm(f.diagonalUp,p.diagonalUp)||!Tm(f.diagonalDown,p.diagonalDown))return;let S=e=>e??null,C={borders:{[r]:S(f[r]),[i]:S(f[i]),[g]:S(f[g]),[y]:S(b),[v]:S(f[v]),[_]:S(p[_])}},w=a.resolveTypedUpdates(C,yt,m,s);return new e(m,this._getEntireRange,n,w,this._t)}return new e(m,this._getEntireRange,n,this._p,this._t)}hasTrailingEdge(){return!0}isMergeOnShift(){return!0}getInnerBorder(e){let t=this._p?.borders;if(!t)return null;let n=this._t??this._r;if(!n||!h.isRangeWithinRange(e,n))return null;let r=this._localizeBorderRange(t,n,e);return r?r.horizontal===void 0&&r.vertical===void 0?null:r:null}_localizeBorderRange(e,t,n){if(!e)return;let r=null,i=t.rowStart,a=t.rowEnd,o=n.rowStart,s=n.rowEnd;e.top&&o===i&&(r??={},r.top=e.top),e.bottom&&s===a&&(r??={},r.bottom=e.bottom),e.horizontal&&(s-o>0&&(r??={},r.horizontal=e.horizontal),o>i&&(r??={},r.top=e.horizontal),s<a&&(r??={},r.bottom=e.horizontal));let c=t.colStart,l=t.colEnd,u=n.colStart,d=n.colEnd;return e.left&&u===c&&(r??={},r.left=e.left),e.right&&d===l&&(r??={},r.right=e.right),e.vertical&&(d-u>0&&(r??={},r.vertical=e.vertical),u>c&&(r??={},r.left=e.vertical),d<l&&(r??={},r.right=e.vertical)),km(e,r)}_localizeBorder(e,t,n,r){if(!e)return;let i=null,a=t.rowStart,o=t.rowEnd;e.top&&n===a&&(i??={},i.top=e.top),e.bottom&&n===o&&(i??={},i.bottom=e.bottom),e.horizontal&&(n>a&&(i??={},i.top=e.horizontal),n<o&&(i??={},i.bottom=e.horizontal));let s=t.colStart,c=t.colEnd;return e.left&&r===s&&(i??={},i.left=e.left),e.right&&r===c&&(i??={},i.right=e.right),e.vertical&&(r>s&&(i??={},i.left=e.vertical),r<c&&(i??={},i.right=e.vertical)),km(e,i)}getPropertiesAt(e,t,n){let r=this._p,i=r,a=this._t;if(a){let n=this._r,r=a.colEnd-a.colStart+1,i=a.rowEnd-a.rowStart+1;t=n.colStart+(t-n.colStart+(a.colStart-n.colStart))%r,e=n.rowStart+(e-n.rowStart+(a.rowStart-n.rowStart))%i}let o=i?.borders;if(o&&i){let n=a??this._r,s=this._localizeBorder(o,n,e,t);s!==void 0&&(i===r&&(i={...i}),s===null?delete i.borders:i.borders=s)}return i}toJSON(){let e=i.toSafeJSON(this._p);if(!e)return e;let t=e.border;return t&&(t.top?.style===L.StrokeStyle.None&&delete t.top,t.bottom?.style===L.StrokeStyle.None&&delete t.bottom,t.left?.style===L.StrokeStyle.None&&delete t.left,t.right?.style===L.StrokeStyle.None&&delete t.right,t.horizontal?.style===L.StrokeStyle.None&&delete t.horizontal,t.vertical?.style===L.StrokeStyle.None&&delete t.vertical,Object.keys(t).length===0&&delete e.borders),e}},jm=class extends Am{constructor(e,t){super(e,null,h.EmptyRange,t)}isEmpty(){return this._p===null}getCoords(){return this._r}cloneWithUpdate(e){if(e===void 0)return this;let t=this._c,n=this._r;return new Am(t,null,n,a.resolveTypedUpdates(e,yt,t,this._p))}_createShifted(e){return new Am(this._c,null,e,this._p)}getShifted(e){return e.after?{...e.after,value:this._createShifted(h.sanitizeRange(e.after))}:null}getSplit(e,t){let n=this._c,r=this._p;return[new Am(n,null,e[0],r),new Am(n,null,e[1],r)]}getMerged(e,t,n){let r=this._p,a=e._p;if(r&&!a||a&&!r||!r&&!a)return;let o=Object.keys(r),s=Object.keys(a);if(r.named===z.BuiltInName.Normal&&(o=o.filter(e=>e.toLowerCase()!==z.BuiltInName.Normal)),a.named===z.BuiltInName.Normal&&(s=s.filter(e=>e.toLowerCase()!==z.BuiltInName.Normal)),o.length!==s.length)return;for(let e=0;e<o.length;e++){let t=o[e],n=r[t],s=a[t];if(!i.deepEqual(n,s))return}let c=this._c;return new Am(c,null,t,this._p)}getPropertiesAt(e,t){return this._p}toJSON(){return i.toSafeJSON(this._p)}},Mm=class{constructor(e,t,n,r=null){this._name=t.name,this._properties=t,this._rangeStyle=new jm(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}isCustomized(){return this._builtInID!==null&&(this._properties.customized??!1)}delete(){this._doDelete?.(this)}toJSON(){return this._properties?i.toSafeJSON(this._properties):null}get isINamed(){return!0}},Nm=class{constructor(e,t,r,i,a){this._state=e,this._normalJSON=t??{},this._toJSONInternal=r,this._fromJSONInternal=i,this._onLastEnd=a,this._state.openScopes.add(this),this._isClosed=!1,this._state.byJSONs.set(n.JSONStableStringify(this._normalJSON),0),this._state.byIds.set(0,this._normalJSON)}endPersist(){if(!this._state.openScopes.delete(this))throw Error(`PersistScope is closed.`);this._isClosed=!0,this._state.openScopes.size===0&&this._onLastEnd()}getElementID(e){if(this._isClosed)throw Error(`PersistScope is closed.`);e??={};let t=n.JSONStableStringify(e),r=this._state.byJSONs.get(t);return r!==void 0||(r=this._state.byJSONs.size,this._state.byJSONs.set(t,r),this._state.byIds.set(r,e)),r}getElementJSON(e){if(this._isClosed)throw Error(`PersistScope is closed.`);return this._state.byIds.get(e)??null}fromJSON(e){if(this._isClosed)throw Error(`PersistScope is closed.`);let t=JSON.parse(JSON.stringify(e||{}));this._fromJSONInternal(t);let r=t.direct,i=r?r.length:0;for(let e=0;e<i;e++){let t=e,i=r[e],a=n.JSONStableStringify(i);this._state.byIds.set(t,i),this._state.byJSONs.set(a,t)}}toJSON(){if(this._isClosed)throw Error(`PersistScope is closed.`);let e=[];return this._state.byIds.forEach((t,n)=>{e[n]=t}),e.length===1&&e.splice(0,1),this._toJSONInternal(e)}},Pm=class{constructor(e=null,t=null,n=11){this._builtInsCellStylesComplete=!1,this._builtInsTableStyles=null,this._defaultTableStyle=null,this._builtInSlicerStyles=null,this._defaultSlicerStyleName=Fp,this._theme=e??new Tp().getDefaultTheme(),this._defaultFontSize=n;let r=this;this._emitter=new ne(this),this._schemeLookup=e=>r._theme.schemeLookup()(e),this._indexedLookup=e=>this._customIndexedColors[e]??null,this._customCellStyles=new Map,this._customTableStyles=new Map,this._customSlicerStyles=new Map,this._builtInsCellStyles=new Map,this._mruColors=[],this._persistCache=null,this._customIndexedColors=this._fromJSONIndexedColors(t),this._initializeBuiltIns(),this._namedStyles=new Op({builtIns:()=>r._ensureBuiltInCellStyles(),customs:()=>r._customCellStyles,set:(e,t)=>r._setNamedStyle(e,t)}),this._tableStyles=new Ap({builtIns:()=>r._ensureBuiltInTableStyles(),customs:()=>r._customTableStyles,set:(e,t)=>r._setCustomTableStyleInternal(e,t),getDefault:()=>r._getDefaultTableStyle(),setDefault:e=>r._setDefaultTableStyle(e),getNone:()=>r._emptyTableStyle}),this._slicerStyles=new Mp({builtIns:()=>r._ensureBuiltInSlicerStyles(),customs:()=>r._customSlicerStyles,set:(e,t)=>r._setCustomSlicerStyleInternal(e,t),getDefault:()=>r._getDefaultSlicerStyle(),setDefault:e=>r._setDefaultSlicerStyle(e)}),this._slicerStyles.addListeners({onCollectionChange:()=>{r._emitter.notify(`onAnyChange`)}}),this._namedStyles.addListeners({onCollectionChange:()=>{r._emitter.notify(`onNamedStylesChange`),r._emitter.notify(`onAnyChange`)}}),this._tableStyles.addListeners({onCollectionChange:()=>{r._emitter.notify(`onTableStylesChange`),r._emitter.notify(`onAnyChange`)}})}getNamedStyles(){return this._namedStyles}getTableStyles(){return this._tableStyles}getSlicerStyles(){return this._slicerStyles}_ensureBuiltInSlicerStyles(){if(this._builtInSlicerStyles)return this._builtInSlicerStyles;let e=new Map;for(let t of Gp??=Object.freeze([...[1,2,3,4,5,6].map(Up),{name:`SlicerStyleOther1`,...Bp(`lt1 eTint -0.5`,`lt1 eTint -0.35`),unselectedItemWithData:zp(`#000000`,Ip(`lt1`),`#CCCCCC`),selectedItemWithData:zp(`#000000`,Ip(`lt1 eTint -0.25`),`#999999`),unselectedItemWithNoData:zp(`#959595`,Ip(`lt1`),`#E0E0E0`),selectedItemWithNoData:zp(`dk1`,Ip(`lt1 eTint -0.15`),`#CCCCCC`),...Vp(Hp)},{name:`SlicerStyleOther2`,...Bp(`#4F81BD`),unselectedItemWithData:zp(`#000000`,Lp(`#E8EBEE`,`#F8F8FA`),`#CCCCCC`),selectedItemWithData:zp(`#000000`,Lp(`#A3BBDF`,`#CADEF6`),`#999999`),unselectedItemWithNoData:zp(`#828282`,Lp(`#F2F4F6`,`#FEFEFE`),`#E0E0E0`),selectedItemWithNoData:zp(`#828282`,Lp(`#D1E0F5`,`#E9F2FB`),`#CCCCCC`),...Vp(zp(`dk1`,Lp(`#F8E162`,`#FCF7F4`),`#999999`))},...[1,2,3,4,5,6].map(Wp)]))e.set(t.name.toLowerCase(),new Pp(this,t,!0));return this._builtInSlicerStyles=e}_setCustomSlicerStyleInternal(e,t){let n=e.toLowerCase(),r=this._customSlicerStyles.get(n)??this._ensureBuiltInSlicerStyles().get(n);r&&(e=r.getName());let i=new Pp(this,{...t,name:e},!1,this._deleteCustomSlicerStyle.bind(this));return this._customSlicerStyles.set(n,i),i}_deleteCustomSlicerStyle(e){this._customSlicerStyles.delete(e.toLowerCase())&&this._slicerStyles._announceChange()}_setDefaultSlicerStyle(e){let t=this._getDefaultSlicerStyle(),n=typeof e==`string`?e:e?.getName?.();return this._defaultSlicerStyleName=(n?this._slicerStyles.getByName(n)?.getName():void 0)??`SlicerStyleLight1`,t}_getDefaultSlicerStyle(){return this._slicerStyles.getByName(this._defaultSlicerStyleName)??this._ensureBuiltInSlicerStyles().get(`slicerstylelight1`)}_initializeNamedStyles(e,t,n=0,r=2**53-1){let i=Math.min(e?e.length:0,r);for(let r=n;r<i;r++){let n=e[r],i={...n},o=n.named;delete i.named;let s=a.resolveTypedUpdates(i,yt,this),c=new Mm(this,{name:o,style:s},this._hideOrRemoveNamed.bind(this),r);o===z.BuiltInName.Normal&&(this._normalRanged=c.getRanged(),this._normalStyle=ch(void 0,this,null)),t.set(o.toLowerCase(),c)}}_initializeTableStyles(){let e=new Map;for(let t of[em(),cm()])t.forEach((t,n)=>{let r=t.name.toLowerCase(),i=new dm(this,t,!0);e.set(r,i)});return e}_initializeBuiltIns(){this._initializeNamedStyles(Qp,this._builtInsCellStyles,0,1),this._emptyTableStyle=new Xf.Empty(this._normalStyle)}_ensureBuiltInCellStyles(){return this._builtInsCellStylesComplete||(this._builtInsCellStylesComplete=!0,this._initializeNamedStyles(Qp,this._builtInsCellStyles,1)),this._builtInsCellStyles}_ensureBuiltInTableStyles(){return this._builtInsTableStyles??=this._initializeTableStyles()}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||={byIds:new Map,byJSONs:new Map,openScopes:new Set},new Nm(this._persistCache,{},this._toJSONInternal.bind(this),this._fromJSONInternal.bind(this),()=>{this._persistCache=null})}getNamed(e){return this._namedStyles.getByName(e)}getCustomNamed(){return this._namedStyles.getItems({type:Uf.BuiltInFilterType.Custom,includeHidden:!0})}setNamed(e,t=!1){return this._namedStyles.set(e,t)}_setNamedStyle(e,t=!1){if(!e||!e.name||!e.style)throw new y;return this.validateStyleName(e.name,!1),this._ensureBuiltInCellStyles().has(e.name.toLowerCase())&&(e={...e,customized:!0}),this._setCustomCellStyleInternal(e,t)}_setCustomCellStyleInternal(e,t=!1,n=0){let r=e.name.toLowerCase(),i=this._ensureBuiltInCellStyles().get(r),o=i?.getBuiltInID()??null,s=null;t&&(s=(this._customCellStyles.get(r)??i)?._properties??null);let c=Xm(e.style,this.getNormal());e={...e,style:c};let l=a.resolveTypedUpdates(e,jt,this,s),u=l.style,d=u?.named;if(typeof d==`string`&&d.toLowerCase()!==r){let e={...u};delete e.named;let t=d.toLowerCase()===z.BuiltInName.Normal.toLowerCase()?null:this.getNamed(d)?.getRanged().getPropertiesAt(0,0,null),n=t?a.resolveTypedUpdates(e,yt,this,t):e;l={...l,style:n}}let f=new Mm(this,l,this._hideOrRemoveNamed.bind(this),o);return l.name===z.BuiltInName.Normal&&(this._normalRanged=f.getRanged(),this._normalStyle=ch(void 0,this,null)),this._customCellStyles.set(r,f),f}_setCustomTableStyleInternal(e,t){let n=e.toLowerCase(),r=this._customTableStyles.get(n)??this._ensureBuiltInTableStyles().get(n);r&&(e=r.getName());let i=new dm(this,{...t,name:e},!1,this._deleteCustomTableStyle.bind(this));return this._customTableStyles.set(n,i),i}_hideOrRemoveNamed(e){let t=null;if(t=typeof e==`string`?e:e?.getName?.(),!t||(t=t.toLowerCase(),t===z.BuiltInName.Normal.toLowerCase()))return!1;let n=this._ensureBuiltInCellStyles().get(t);if(n&&!n.isHidden())return this._namedStyles.set({...n.toJSON(),hidden:!0}),!0;let r=this._customCellStyles.delete(t);return r&&this._namedStyles._announceChange(),r}getTableStyle(e){return e?this._tableStyles.getByName(e):this._emptyTableStyle}getCustomTableStyles(){return this._tableStyles.getItems({type:Uf.BuiltInFilterType.Custom})}setDefaultTableStyle(e){this._tableStyles.setDefault(e)}getDefaultTableStyle(){return this._tableStyles.getDefault()}setCustomTableStyle(e,t){return this._tableStyles.set(e,t)}_setDefaultTableStyle(e){let t=this._getDefaultTableStyle(),n=(typeof e==`string`?e:e?.getName())?.toLowerCase(),r=this._ensureBuiltInTableStyles();return this._defaultTableStyle=(n?this._customTableStyles.get(n)??r.get(n):void 0)??r.get(`tablestylemedium2`),t}_getDefaultTableStyle(){return this._defaultTableStyle||=this._ensureBuiltInTableStyles().get(tm.toLowerCase()),this._defaultTableStyle}_deleteCustomTableStyle(e){let t=this._customTableStyles.get(e?.toLowerCase());return!!t&&(this._customTableStyles.delete(e.toLowerCase()),this._defaultTableStyle?.getName()===t.getName()&&(this._defaultTableStyle=this._ensureBuiltInTableStyles().get(tm.toLowerCase())),this._tableStyles._announceChange(),!0)}validateStyleName(e,t=!1){if(!e||e.trim().length===0)throw Error(`Style name cannot be empty.`);if(t&&this.getNamed(e)!==null)throw Error(`Style name is already taken.`)}normalize(e,t){if(!e)return null;let n=a.resolveTypedUpdates(e,yt,this);if(!n)return null;let r=null,o=t??n.named??z.BuiltInName.Normal;r=o===z.BuiltInName.Normal?this._normalRanged.getPropertiesAt(0,0,null):this.getNamed(o)?.getRanged().getPropertiesAt(0,0,null);let s=this.getTheme().getFontScheme(),c={font:{size:this.getDefaultFontSize(),family:s.getMinorFont(),fallbacks:s.getMinorFallbacks()}};return i.removeEqualValuesLayered(n,[r,c,Zp]),n}resolve(e,t){if(!e)return null;let n=t??e.named??z.BuiltInName.Normal,r=n===z.BuiltInName.Normal?this._normalRanged.getPropertiesAt(0,0,null):this.getNamed(n)?.getRanged().getPropertiesAt(0,0,null),i={...e};delete i.named;let o=a.resolveTypedUpdates(i,yt,this,r??void 0);return o?(typeof e.named==`string`&&(o.named=e.named),o):null}schemeLookup(){return this._schemeLookup}indexedLookup(){return this._indexedLookup}parseColor(e){return De.parse(e,this._schemeLookup,this._indexedLookup)}recentColors(){return this._mruColors}addRecentColor(e){if(!e)return this._mruColors;let t=this._mruColors,n=[],r=e.toString(),i=t.length;for(let e=0;e<i&&e<10;e++){let i=t[e];i.toString()!==r&&n.push(i)}return n.unshift(e),this._mruColors=Object.freeze(n),this._mruColors}clearRecentColors(){this._mruColors=i.EmptyArray}getCustomIndexedColors(){return this._customIndexedColors}setCustomIndexedColors(e){this._customIndexedColors=(e?.length??0)>0?[...e]:[]}getIndexedColors(){let e=this._customIndexedColors,t=Math.max(e?.length,66),n=[];for(let r=0;r<t;r++){let t=e[r];if(t!==null){if(t){n.push(t);continue}let e=Ae(r);if(e){n.push(new De(e));continue}let i=je(r);if(!i)continue;n.push(new De(i.toString()))}}return n}addListeners(e,t){return this._emitter.addListeners(e,t)}_toJSONInternal(e){let t={};e.length>0&&(t.direct=e);let n=this.getCustomNamed(),r=n.length,i=Array(r);for(let e=0;e<r;e++){let t=n[e].toJSON();i[e]=t}i.length>0&&(t.named=i);let a={};this._defaultTableStyle&&this._defaultTableStyle.getName()!==`TableStyleMedium2`&&(a.defaultTableStyle=this._defaultTableStyle.getName());let o={},s=this.getCustomTableStyles(),c=s.length;for(let e=0;e<c;e++){let t=s[e],n=t.toJSON();delete n.name,n&&Object.keys(n).length>0&&(o[t.getName()]=n)}Object.keys(o).length>0&&(a.styles=o),Object.keys(a).length>0&&(t.tables=a);let l={},u=this._getDefaultSlicerStyle().getName();u!==`SlicerStyleLight1`&&(l.defaultSlicerStyle=u);let d=this._slicerStyles.getItems({type:Uf.BuiltInFilterType.Custom});if(d.length>0){let e={};for(let t of d){let{name:n,...r}=t.toJSON();e[n]=r}l.styles=e}Object.keys(l).length>0&&(t.slicers=l);let f=this._customIndexedColors,p=f.length??0;if(p>0){let e=Array(p);for(let t=0;t<p;t++)e[t]=f[t].toString();t.indexedColors=e}let m=this._mruColors,h=m.length;if(h>0){let e=Array(h);for(let t=0;t<h;t++)e[t]=m[t].toString();t.mruColors=e}return Object.keys(t).length===0?null:t}_fromJSONIndexedColors(e){if(!e||e.length===0)return i.EmptyArray;let t=e.length,n=Array(t);if(t>0)for(let r=0;r<t;r++){let t=e[r];try{n[r]=this.parseColor(t)}catch{console.warn(`Unable to parse color: `+t)}}return n}_fromJSONInternal(e){this._customIndexedColors=this._fromJSONIndexedColors(e.indexedColors);let t=e.named,n=t?t.length:0;for(let e=0;e<n;e++)this._setCustomCellStyleInternal(t[e]);let r=this.getNormal().getFont().getSize();r>0&&r!==this._defaultFontSize&&this.setDefaultFontSize(r);let i=e.direct,a=i?i.length:0;for(let e=0;e<a;e++)i[e]=this.normalize(i[e])??{};let o=tm;if(this._defaultTableStyle=null,e.tables){e.tables.defaultTableStyle&&(o=e.tables.defaultTableStyle);let t=e.tables.styles,n=t?Object.keys(t):null,r=n?n.length:0;for(let e=0;e<r;e++){let r=n[e],i=t[r];this._setCustomTableStyleInternal(r,i)}}this._defaultTableStyle=this.getTableStyle(o);let s=e.slicers?.styles;if(s)for(let e of Object.keys(s))this._setCustomSlicerStyleInternal(e,s[e]);this._defaultSlicerStyleName=Fp,e.slicers?.defaultSlicerStyle&&this._setDefaultSlicerStyle(e.slicers.defaultSlicerStyle),n>0&&this._namedStyles._announceChange(),e.tables&&this._tableStyles._announceChange(),e.slicers&&this._slicerStyles._announceChange();let c=e.mruColors,l=c?c.length:0,u=Array(l);if(l>0)for(let e=0;e<l;e++){let t=c[e];try{u[e]=this.parseColor(t)}catch{console.warn(`Unable to parse color: `+t)}}this._mruColors=u}get isIStyleCollection(){return!0}},Fm=0,Im=!1;function Lm(){return Im||(Im=!0,Ll.getShared().addListeners({onCollectionChange:()=>{Fm++}})),Fm}var Rm=new WeakMap;function zm(e){let t=Lm(),n=Rm.get(e);if(n?.version===t)return n.width;let r=0;for(let t=0;t<=9;t++)r=Math.max(r,e.measureText(String(t)).width);return r=Math.round(r),Rm.set(e,{version:t,width:r}),r}var Bm=class e{constructor(e,t,n,r=null,a=null,o=null,s=null){this._private={wrapped:!0,insets:T.EmptyRect,orientation:R.Orientation.Horizontal,autoFit:R.Autofit.None,fontScale:1,vertical:!1,columnCount:1,columnSpacing:0,verticalAlignment:R.VerticalAlignment.Center,horizontalCentered:!1,lineReduction:0,isSpaceFirstLastPara:!1,presetTextWarp:null,paragraphs:i.EmptyArray},this._bounds=null,this._textBounds=null,this._lines=null,this._lastLayoutSize=void 0,this._lastLayout=void 0,this._lastLayoutFonts=-1,this._private=Object.assign(this._private,e||{}),this._defaultFont=t,this._alignment=n,this._lineHeight=s,this._lines=r,this._bounds=Object.freeze(a),this._textBounds=Object.freeze(o)}visitParas(e){e?.visitTextFrame?.(this);let t=this.paragraphs,n=t.length;for(let r=0;r<n;r++){let i=t[r];e?.visitTextParagraph?.(i,r,n);let a=i.runs,o=a.length;for(let t=0;t<o;t++)e?.visitTextRun?.(a[t],t,o)}}visitLines(e){e?.visitTextFrame?.(this);let t=this.lines,n=t.length;for(let r=0;r<n;r++){let i=t[r];e?.visitTextLine?.(i,r,n);let a=i.runs,o=a.length;for(let t=0;t<o;t++)e?.visitTextRun?.(a[t],t,o)}}layout(e=null){let t=Lm();return this._lastLayout&&this._lastLayoutFonts===t&&this._lastLayoutSize?.width===e?.width&&this._lastLayoutSize?.height===e?.height||(this._lastLayout=qm(this,this._defaultFont,this._alignment,e,this._lineHeight),this._lastLayoutSize=e,this._lastLayoutFonts=t),this._lastLayout}clone(t){let n=t?.visitTextFrame?.(this),r=Object.assign({},this._private,n||{});return delete r.bounds,new e(r,this._defaultFont,this._alignment,null,null,null,this._lineHeight)}equals(e){return i.deepEqual(this._private,e._private)}getText(){let e=this.paragraphs.map(e=>e.runs.map(e=>e.text).join(``)),t=0,n=e.length;for(;t<n&&e[t].trim()===``;)t++;for(;n>t&&e[n-1].trim()===``;)n--;return e.slice(t,n).join(`
|
|
556
|
-
`)}createTextFrame(e,t){return Ym(e,this._defaultFont,this._alignment,t??this._private.wrapped,!1,this._lineHeight)}get bounds(){if(this._bounds===null)throw Error(Vm);return this._bounds}get textBounds(){if(this._textBounds===null)throw Error(Vm);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??null}get paragraphs(){return this._private.paragraphs}get isITextFrame(){return!0}},Vm=`bounds can not be used until layout`,Hm=class{static{this.NL=`
|
|
557
|
-
`}static{this.DefaultLineSpacing=100}static{this.DefaultTabWidth=72}},Um=class e{constructor(e){this._private={defaultFontSize:11,defaultTabSize:Hm.DefaultTabWidth,tabOverrides:i.EmptyArray,spacingBefore:0,spacingAfter:0,lineSpacing:Hm.DefaultLineSpacing,align:R.HorizontalAlignment.Left,endParagraphSize:0,indentLevel:0,leadingIndent:0,hangingIndent:0,rightMargin:0,bullet:null},this._private=Object.assign(this._private,e||{})}clone(t){let n=t?.visitTextParagraph?.(this,0,1),r=Object.assign({},this._private,n||{});return delete r.bounds,new e(r)}equals(e){return i.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??null}get runs(){return this._private.runs}get isITextParagraph(){return!0}},Wm=class e{constructor(e,t=null){this._private={text:null,fontName:`Arial`,bold:!1,italic:!1,superSub:!1,fontSize:11,letterSpacing:0,kerningMin:10,smallCaps:Jt.SmallCaps.None,offset:0,strikeStyle:I.StrikeStyle.None},this._private={...this._private,...e},this._bounds=t}clone(t){let n=t?.visitTextRun?.(this,0,1),r=Object.assign({},this._private,n||{});return delete r.bounds,new e(r)}equals(e){return i.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}get isITextRun(){return!0}},Gm=class{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}get isITextLine(){return!0}},Km=class{constructor(e=Ll.getShared(),t){this._fonts=e,this._useNative=t?.native??!0}get isNative(){return this._useNative&&jl.peekWasm()!==void 0}wrap(e,t=null){let n=this._useNative?jl.peekWasm():void 0;if(n){let r=this._wrapNative(n,e,t);if(r)return r}let r=jl.peekFallback();if(!r)throw Error(`Text cannot be wrapped before the text engine has loaded: await IWorkbook.whenReady() (or IFontCollection.whenReady()) first.`);return new r.TextWrapperFallback(this._fonts).wrap(e,t)}_wrapNative(e,t,n){let r=this._fonts.getByName(n?.fontName??`Arial`,{bold:n?.bold??!1,italic:n?.italic??!1}).table;if(!(r instanceof Ie))return null;let i=n?.fontSize??12,a=r.native(e,t).wrap(t,i,zt(r,i,n?.lineHeight).lineHeight,n?.maxWidth??0,n?.maxHeight??0,n?.indent??0,n?.letterSpacing??0,n?.superSub??!1),o=function(e){let t=0,n=0;return r=>{for(;t<r&&n<e.length;){let r=e.codePointAt(n);t+=r<128?1:r<2048?2:r<65536?3:4,n+=r<65536?1:2}return n}}(t),s=[],c=0,l=0,u=0;for(let e=0;e<a.length;e+=8){let n=o(a[e]),r=o(a[e+1]),i={text:t.slice(n,r),startPosition:n,x:a[e+2],y:a[e+3],width:a[e+4],widthWhitespace:a[e+5],height:a[e+6],baseline:a[e+7]};c=Math.max(c,i.x+i.width),l=Math.max(l,i.x+i.widthWhitespace),u=Math.max(u,i.y+i.height),s.push(i)}return{bounds:{x:0,y:0,width:c,widthWhitespace:l,height:u},lines:s}}};function qm(e,t,n,r=null,i=null,a=Ll.getShared()){let o=``,s=null,c=null,l=e.paragraphs,u=l.length;for(let e=0;e<u;e++){let t=l[e].runs,n=t.length;for(let e=0;e<n;e++){let n=t[e];o+=n.text,e===0&&(s=n)}e===0&&(c=l[e])}let d=e.insets??T.EmptyRect,f=new Km(a),p=r?.width?r.width-d.right-d.left:r?.width,m=r?.height?r.height-d.bottom-d.top:void 0,h=f.wrap(o,{fontName:s.fontName,fontSize:s.fontSize*I.getDeviceScale(),bold:s.bold,italic:s.italic,superSub:s.superSub,letterSpacing:s.letterSpacing,maxWidth:e.wrapped&&p?p:void 0,maxHeight:m,lineHeight:i}),g=[],_=h.lines,v=_.length,y=Array(v);for(let e=0;e<v;e++){let t=_[e],n={x:t.x,y:t.y,width:t.width,height:t.height},r=new Wm({text:t.text,fontName:s.fontName,fontSize:s.fontSize,bold:s.bold,italic:s.italic,superSub:s.superSub,letterSpacing:s.letterSpacing},n);g.push(r),y[e]=new Gm(n,t.baseline,[r])}return new Bm({paragraphs:[new Um({runs:g,align:c.align})],wrapped:e.wrapped,verticalAlignment:e.verticalAlignment},t,n,y,{x:h.bounds.x,y:h.bounds.y,width:h.bounds.widthWhitespace,height:h.bounds.height},{x:h.bounds.x,y:h.bounds.y,width:h.bounds.width,height:h.bounds.height},i)}function Jm(e){let t=!1,n=!1;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);if(i>=65&&i<=90?t=!0:i>=97&&i<=122&&(n=!0),t&&n)return 0}return t?1:n?-1:0}function Ym(e,t,n,r,i=!1,a=null){if(e==null)return null;let o=new Wm({text:e,fontName:t.toCSS().fontFamily,fontSize:t.getSize(),bold:t.getWeight()>400,italic:t.getItalic(),superSub:!i&&t.getBaseline()!==0,letterSpacing:t.getLetterSpacing()}),s=i?R.HorizontalAlignment.Left:n.getHorizontal(),c=n.getVertical(),l=new Um({runs:[o],align:s}),u=[];return u.push(new Gm(null,t.getSize(),[o])),new Bm({paragraphs:[l],wrapped:r&&(n.getOverflow()===R.Overflow.Wrap||s===R.HorizontalAlignment.Justify||s===R.HorizontalAlignment.Distributed||c===R.VerticalAlignment.Justify||c===R.VerticalAlignment.Distributed),verticalAlignment:c},t,n,u,null,null,a)}function Xm(e,t){if(e===void 0)return;if(e===null)return null;if(e.isICellStyle)return e.getAuthoredProperties();let n;return n=typeof e==`function`?e(typeof t==`function`?t():t):e,n}var Zm=class{constructor(e){this._p=Object.freeze(Array.isArray(e)?e:[e??null])}value(e){let t=this._p;for(let n=t.length-1;n>=0;n--){let r=t[n];if(!r)continue;let i=r[e];if(i!==void 0)return i}}values(e){let t=this._p,n=t.length,r;for(let i=0;i<n;i++){let n=t[i];if(!n)continue;let a=n[e];a!==void 0&&(r===void 0&&(r=[]),r.push(a))}return r}getProperties(){let e=this._p;return e?e[e.length-1]:null}toJSON(){let e=this._p,t=e.length,n={};for(let r=0;r<t;r++){let t=e[r];n=i.deepMerge(n,t)}return n}},Qm=class{constructor(e,t){this._o=e,this._c=e.styles,this._p=Object.freeze(t)}_setValue(e,t){let n={[e]:t};this._o.updater(n)}_value(e){let t=this._p;for(let n=t.length-1;n>=0;n--){let r=t[n];if(!r)continue;let i=r[e];if(i!==void 0)return i}}_values(e){let t=this._p,n=t.length,r;for(let i=0;i<n;i++){let n=t[i];if(!n)continue;let a=n[e];a!==void 0&&(r===void 0&&(r=[]),r.push(a))}return r}getProperties(){let e=this._p;return e?e[e.length-1]:null}toJSON(){return null}},$m=e=>e.charAt(0).toLowerCase()+e.slice(1),eh=e=>{switch(e){case`top`:return m(`op.setTopBorderStyle`);case`right`:return m(`op.setRightBorderStyle`);case`bottom`:return m(`op.setBottomBorderStyle`);case`horizontal`:return m(`op.setHorizontalBorderStyle`);case`vertical`:return m(`op.setVerticalBorderStyle`);case`diagonalUp`:return m(`op.setDiagonalUpBorderStyle`);case`diagonalDown`:return m(`op.setDiagonalDownBorderStyle`);default:return m(`op.setLeftBorderStyle`)}},th=e=>{switch(e){case`top`:return m(`op.setTopBorderColor`);case`right`:return m(`op.setRightBorderColor`);case`bottom`:return m(`op.setBottomBorderColor`);case`horizontal`:return m(`op.setHorizontalBorderColor`);case`vertical`:return m(`op.setVerticalBorderColor`);case`diagonalUp`:return m(`op.setDiagonalUpBorderColor`);case`diagonalDown`:return m(`op.setDiagonalDownBorderColor`);default:return m(`op.setLeftBorderColor`)}},nh=class extends Qm{constructor(e,t,n){super(t,n),this._edge=e}getStyle(){return this._value(`style`)}setStyle(e,t){let n=this._edge,r=n.charAt(0).toUpperCase()+n.slice(1);return this._o.updater({borders:{[n]:{style:e}}},{description:eh(n),...t}).getBorders()[`get`+r]()}getColor(){let e=this._value(`color`);return e?this._c.parseColor(e):null}setColor(e,t){let n=this._edge,r=n.charAt(0).toUpperCase()+n.slice(1);return this._o.updater({borders:{[n]:{color:e}}},{description:th(n),...t}).getBorders()[`get`+r]()}isNone(){return this.getStyle()===L.StrokeStyle.None}toCSS(){let e=wt(this);switch(this._edge){case L.Edge.Left:return{borderLeft:e};case L.Edge.Right:return{borderRight:e};case L.Edge.Top:return{borderTop:e};case L.Edge.Bottom:return{borderBottom:e};case L.Edge.DiagonalUp:return{borderDiagonalUp:e};case L.Edge.DiagonalDown:return{borderDiagonalDown:e}}}get[Symbol.toStringTag](){return`[CellBorderStroke]`}toString(){return`[CellBorderStroke]`}get isIStroke(){return!0}},rh=class extends Qm{getLeft(){return this._left||=new nh(L.Edge.Left,this._o,this._values(L.Edge.Left)),this._left}setLeft(e,t){return this._o.updater({borders:{left:e}},{description:m(`op.setLeftBorder`),...t}).getBorders()}getRight(){return this._right||=new nh(L.Edge.Right,this._o,this._values(L.Edge.Right)),this._right}setRight(e,t){return this._o.updater({borders:{right:e}},{description:m(`op.setRightBorder`),...t}).getBorders()}getTop(){return this._top||=new nh(L.Edge.Top,this._o,this._values(L.Edge.Top)),this._top}setTop(e,t){return this._o.updater({borders:{top:e}},{description:m(`op.setTopBorder`),...t}).getBorders()}getBottom(){return this._bottom||=new nh(L.Edge.Bottom,this._o,this._values(L.Edge.Bottom)),this._bottom}setBottom(e,t){return this._o.updater({borders:{bottom:e}},{description:m(`op.setBottomBorder`),...t}).getBorders()}getHorizontal(){return this._inner(L.Edge.Horizontal)}getVertical(){return this._inner(L.Edge.Vertical)}_inner(e){let t=this._o.extent;if(!t)return null;let n=this._o.direct;if(!(n instanceof Am))return null;let r=n.getInnerBorder(t)?.[e];return r?new nh(e,this._o,[r]):null}getDiagonalUp(){return this._diagUp||=new nh(L.Edge.DiagonalUp,this._o,this._values(L.Edge.DiagonalUp)),this._diagUp}setDiagonalUp(e,t){return this._o.updater({borders:{diagonalUp:e}},{description:m(`op.setDiagonalUpBorder`),...t}).getBorders()}getDiagonalDown(){return this._diagDown||=new nh(L.Edge.DiagonalDown,this._o,this._values(L.Edge.DiagonalDown)),this._diagDown}setDiagonalDown(e,t){return this._o.updater({borders:{diagonalDown:e}},{description:m(`op.setDiagonalDownBorder`),...t}).getBorders()}setVertical(e,t){return this._o.updater({borders:{vertical:e}},{description:m(`op.setVerticalBorder`),...t}).getBorders()}setHorizontal(e,t){return this._o.updater({borders:{horizontal:e}},{description:m(`op.setHorizontalBorder`),...t}).getBorders()}setOutline(e,t){return this._o.updater({borders:{top:e,bottom:e,left:e,right:e}},{description:m(`op.setOutlineBorder`),...t}).getBorders()}_edgeStyleIsNone(e){let t=this._values(e);if(!t)return!0;for(let e=t.length-1;e>=0;e--){let n=t[e]?.style;if(n!==void 0)return n===L.StrokeStyle.None}return!0}isEmpty(){return this._isEmpty!==void 0||(this._isEmpty=this._edgeStyleIsNone(L.Edge.Top)&&this._edgeStyleIsNone(L.Edge.Bottom)&&this._edgeStyleIsNone(L.Edge.Left)&&this._edgeStyleIsNone(L.Edge.Right)&&this._edgeStyleIsNone(L.Edge.DiagonalUp)&&this._edgeStyleIsNone(L.Edge.DiagonalDown)),this._isEmpty}get[Symbol.toStringTag](){return`[CellBorder]`}toString(){return`[CellBorder]`}get isIBorders(){return!0}},ih=class extends Qm{getHorizontal(){return this._value(`horizontal`)}setHorizontal(e,t){return this._o.updater({alignment:{horizontal:e}},{description:m(`op.setHorizontalAlignment`),...t}).getAlignment()}getVertical(){return this._value(`vertical`)}setVertical(e,t){return this._o.updater({alignment:{vertical:e}},{description:m(`op.setVerticalAlignment`),...t}).getAlignment()}getIndent(){return this._value(`indent`)}setIndent(e,t){return this._o.updater({alignment:{indent:e}},{description:m(`op.setIndent`),...t}).getAlignment()}getRelativeIndent(){return this._value(`relativeIndent`)}setRelativeIndent(e,t){return this._o.updater({alignment:{relativeIndent:e}},{description:m(`op.setRelativeIndent`),...t}).getAlignment()}getOverflow(){return this._value(`overflow`)}setOverflow(e,t){return this._o.updater({alignment:{overflow:e}},{description:m(`op.setOverflow`),...t}).getAlignment()}getRotation(){return this._value(`rotation`)}setRotation(e,t){return this._o.updater({alignment:{rotation:e}},{description:m(`op.setRotation`),...t}).getAlignment()}getStacked(){return this._value(`stacked`)}setStacked(e,t){return this._o.updater({alignment:{stacked:e}},{description:m(`op.setStacked`),...t}).getAlignment()}getJustifyLastLine(){return this._value(`justifyLastLine`)}setJustifyLastLine(e,t){return this._o.updater({alignment:{justifyLastLine:e}},{description:m(`op.setJustifyLastLine`),...t}).getAlignment()}getReadingDirection(){return this._value(`readingDirection`)}setReadingDirection(e,t){return this._o.updater({alignment:{readingDirection:e}},{description:m(`op.setReadingDirection`),...t}).getAlignment()}get[Symbol.toStringTag](){return`[CellAlignment]`}toString(){return`[CellAlignment]`}get isITextBoxAlignment(){return!0}},ah=class extends Qm{isAlwaysUnlocked(){return this._value(`alwaysUnlocked`)}setAlwaysUnlocked(e,t){return this._o.updater({protection:{alwaysUnlocked:e}},{description:m(`op.setAlwaysUnlocked`),...t}).getProtection()}isShowFormulas(){return this._value(`showFormulas`)}setShowFormulas(e,t){return this._o.updater({protection:{showFormulas:e}},{description:m(`op.setShowFormulas`),...t}).getProtection()}get[Symbol.toStringTag](){return`[CellProtection]`}toString(){return`[CellProtection]`}get isICellProtection(){return!0}},oh=class extends Qm{_set(e,t,n){return this._o.updater({font:e},{description:t,...n}).getFont()}isEqualMeasure(e){return!!e&&this.getFamily()===e.getFamily()&&!!i.isEqualArrays(this.getFallbacks(),e.getFallbacks())&&this.getSize()===e.getSize()&&this.getWeight()===e.getWeight()&&this.getItalic()===e.getItalic()&&this.getStrike()===e.getStrike()&&this.getLetterSpacing()===e.getLetterSpacing()&&this.getBaseline()===e.getBaseline()}toCSS(e,t=1,n=!1){let r={fontFamily:ft(this.getFamily(),this.getFallbacks()),letterSpacing:`${this.getLetterSpacing()}px`,fontWeight:this.getWeight(),fontStyle:this.getItalic()?I.Style.Italic:I.Style.Normal,textDecoration:Ve(this.getUnderline(),this.getStrike()),color:this.getColor().toCSS(e),fontSize:`${i.roundAccurately(this.getSize()*I.getDeviceScale()*t,2)}px`,textRendering:`geometricPrecision`};if(n){let n=this._c.getNormal().getFont().toCSS(e,t,!1),a=r.textDecoration,o=r.fontWeight;i.removeEqualValues(r,n),a&&(r.textDecoration=a),o&&(r.fontWeight=o)}return r}getFamily(){let e=this._value(`family`),t=this._c.getTheme().getFontScheme();return e===We.ThemeFamily.Heading?t.getMajorFont():(e===We.ThemeFamily.Body?void 0:e)??t.getMinorFont()}setFamily(e,t){return this._set({family:e},m(`op.setFontFamily`),t)}getName(){return this.getFamily()}setName(e,t){return this.setFamily(e,t)}getThemeFamily(){let e=this._value(`family`);return e===void 0?We.ThemeFamily.Body:e===We.ThemeFamily.Heading||e===We.ThemeFamily.Body?e:null}getFallbacks(){return this._value(`fallbacks`)??this._c.getTheme().getFontScheme().getMinorFallbacks()??i.EmptyArray}setFallbacks(e,t){return this._set({fallbacks:e},m(`op.setFontFallbacks`),t)}getSize(){return this._value(`size`)??this._c.getDefaultFontSize()??11}setSize(e,t){return this._set({size:e},m(`op.setFontSize`),t)}getWeight(){return this._value(`weight`)??400}setWeight(e,t){return this._set({weight:e},m(`op.setFontWeight`),t)}getBold(){return this.getWeight()>400}setBold(e,t){return this._set({bold:e},m(`op.setFontBold`),t)}getItalic(){return this._value(`style`)===I.Style.Italic}setItalic(e,t){return this._set({italic:e},m(`op.setFontItalic`),t)}getColor(){let e=this._value(`color`);return this._c.parseColor(e??Mt.Scheme.Bg1)}setColor(e,t){return this._set({color:e},m(`op.setFontColor`),t)}getLetterSpacing(){return this._value(`letterSpacing`)??0}setLetterSpacing(e,t){return this._set({letterSpacing:e},m(`op.setFontLetterSpacing`),t)}getUnderline(){return this._value(`underline`)??I.UnderlineStyle.None}setUnderline(e,t){return this._set({underline:e},m(`op.setFontUnderline`),t)}getStrike(){return this._value(`strike`)??I.StrikeStyle.None}setStrike(e,t){return this._set({strike:e},m(`op.setFontStrike`),t)}getBaseline(){return this._value(`baseline`)??0}setBaseline(e,t){return this._set({baseline:e},m(`op.setFontBaseline`),t)}update(e,t){return this._set(e,m(`op.setFont`),t)}toJSON(){let e={};for(let t of this._p)t&&(e=i.deepMerge(e,t));return e}get[Symbol.toStringTag](){return`[FontStyle]`}toString(){return`[FontStyle]`}get isIFontStyle(){return!0}},sh=class{constructor(e){this._bestFitFonts=-1,this._insetsFonts=-1,this._o=e,this._p=new Zm(e.properties)}toJSON(){let e=this._p.toJSON(),t=e.namedStyle??z.BuiltInName.Normal;return delete e.namedStyle,e.named=t,e}hasVisibleStyling(){if(this._hasVisibleStyling!==void 0)return this._hasVisibleStyling;let e=this.getFill();return this._hasVisibleStyling=!e||e.getType()!==Ee.Type.None||!this.getBorders().isEmpty(),this._hasVisibleStyling}isNormal(){return!1}_getNormal(){return this.isNormal()?this:this._o.styles?.getNormal()??null}getAuthoredProperties(){let e=this._o,t=e.direct;if(!t)return null;let n=e.range,r=n?.rowStart??h.EmptyCell.rowIndex,i=n?.colStart??h.EmptyCell.colIndex;return t.getAuthoredPropertiesAt?t.getAuthoredPropertiesAt(r,i,null):t.getPropertiesAt(r,i,null)}createStyle(e){let t=this._o,n=Xm(e,this),r=t.range,i=t.direct.cloneWithUpdate(n);return ch(void 0,t.styles,i,r)}measureText(e,t=this.getFont().getSize(),n,r){let i=this.getFont(),a=r?.isBold??i.getWeight()>400,o=r?.isItalic??i.getItalic(),{table:s,paint:c}=Ll.getShared().getByName(n??i.getFamily(),{bold:a,italic:o,fallbacks:i.getFallbacks()}),l=t*I.getDeviceScale();return{...s.measure(e,l,{letterSpacing:r?.letterSpacing??i.getLetterSpacing(),paint:c}),...Il(s,l)}}createTextFrame(e,t=!1){return Ym(e,this.getFont(),this.getAlignment(),t,!1,Fl)}update(e,t){return this._o.updater(e,t)}clear(){return this._o.updater(null,{description:m(`op.clearStyle`)})}getBestFit(){let e=Lm();if(this._bestFit!==void 0&&this._bestFitFonts===e)return this._bestFit;let t=this.getInsets(),n=this.measureText(`My`);return this._bestFitFonts=e,this._bestFit={width:null,height:n.lineHeight+(t.top+t.bottom-2)},this._bestFit}getInsets(){let e=Lm();if(this._insets!==void 0&&this._insetsFonts===e)return this._insets;let t=this.getFont().getSize(),n=He(t),r=kt(zm(this)),i={top:n,left:r,bottom:n,right:r},a=this._p?.value(`insets`);return a&&(a.top!==void 0&&(i.top+=a.top),a.left!==void 0&&(i.left+=a.left),a.bottom!==void 0&&(i.bottom+=a.bottom),a.right!==void 0&&(i.right+=a.right)),this._insets=Object.freeze(i),this._insetsFonts=e,this._insets}getBorders(){return this._border||=new rh(this._o,this._p.values(`borders`)),this._border}setBorders(e,t){return this._o.updater({borders:e},{description:m(`op.setBorders`),...t})}getFont(){return this._font||=new oh(this._o,this._p.values(`font`)),this._font}setFont(e,t){return this._o.updater({font:e},{description:m(`op.setFont`),...t})}getFill(){if(this._fill)return this._fill;let e=this._p.values(`fill`),t=this._o,n={parseColor:e=>t.styles.parseColor(e),getBaseFill:()=>t.styles?.getNormal()?.getFill()??null,updateFill:(e,n)=>t.updater({fill:e},n).getFill()};return this._fill=Pe(n,e)}setFill(e,t){return this._o.updater({fill:e},{description:m(`op.setFill`),...t})}setFillSolid(e){return this._o.updater({fill:{type:Ee.Type.Solid}},{description:m(`op.setFillSolid`),...e}).getFill()}setFillGradient(e){return this._o.updater({fill:{type:Ee.Type.Gradient}},{description:m(`op.setFillGradient`),...e}).getFill()}setFillPattern(e){return this._o.updater({fill:{type:Ee.Type.Pattern}},{description:m(`op.setFillPattern`),...e}).getFill()}setFillNone(e){return this._o.updater({fill:{type:Ee.Type.None}},{description:m(`op.setFillNone`),...e}).getFill()}getAlignment(){return this._alignment||=new ih(this._o,this._p.values(`alignment`)),this._alignment}setAlignment(e,t){return this._o.updater({alignment:e},{description:m(`op.setAlignment`),...t})}getHorizontalAlignment(){return this.getAlignment().getHorizontal()}getVerticalAlignment(){return this.getAlignment().getVertical()}setHorizontalAlignment(e){let t=/^centerAcrossSelection$/i.test(e)?`centerContinuous`:$m(e);return this.setAlignment({horizontal:t})}setVerticalAlignment(e){let t=$m(e);return this.setAlignment({vertical:t})}getNumberFormat(){let e=this._p.value(`numberFormat`);return typeof e==`number`?Ce(e):e}getNumberFormatRef(){return this._p.value(`numberFormat`)}setNumberFormat(e,t){return this._o.updater({numberFormat:e},{description:m(`op.setNumberFormat`),...t})}getQuotePrefix(){return this._p.value(`quotePrefix`)}setQuotePrefix(e,t){return this._o.updater({quotePrefix:e},{description:m(`op.setQuotePrefix`),...t})}getProtection(){return this._protection||=new ah(this._o,this._p.values(`protection`)),this._protection}setProtection(e,t){return this._o.updater({protection:e},{description:m(`op.setProtection`),...t})}getNamed(){let e=this._p.value(`named`)??z.BuiltInName.Normal;return this._o.styles.getNamedStyles().getByName(e)}setNamed(e,t){let n=e==null?null:typeof e==`string`?e:e.getName();return this._o.updater({named:n},{description:m(`op.setNamedStyle`),...t})}get[Symbol.toStringTag](){return`[SheetCellStyle]`}toString(){return`Style: ${zd(this._o.range)}`}get isICellStyle(){return!0}};function ch(e,t,n,r,i=uh,a){let o=r?.rowStart??h.EmptyCell.rowIndex,s=r?.colStart??h.EmptyCell.colIndex,c=[Zp],l=t.getNormalRanged(),u=l.getPropertiesAt(o,s,e);u&&c.push(u);let d=(e,t)=>i(e,t,r);if(!n)return new lh({styles:t,range:r,properties:c,direct:l,extent:a,updater:d});let f=n.getPropertiesAt(o,s,e);if(!f)return new lh({styles:t,range:r,properties:c,direct:l,extent:a,updater:d});let p=f.named;if(p&&p!==z.BuiltInName.Normal&&!n.getAuthoredPropertiesAt){let n=t.getNamedStyles().getByName(p)?.getRanged().getPropertiesAt(o,s,e);n&&c.push(n)}return c.push(f),new sh({styles:t,range:r,properties:c,direct:n,extent:a,updater:d})}var lh=class extends sh{isNormal(){return!0}getAuthoredProperties(){return null}};function uh(e){throw Error(`Style is read-only and cannot be updated`)}async function dh(){return globalThis.crypto}var fh=async(e,t,...n)=>{let r=ph(...n);return e.subtle.digest(t,r)},ph=(...e)=>{let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;return e.forEach(e=>{n.set(new Uint8Array(e),r),r+=e.byteLength}),n.buffer},mh=e=>{let t=new Uint8Array(e),n=``,r=t.byteLength;for(let e=0;e<r;e++)n+=String.fromCharCode(t[e]);return btoa(n)},hh=new Map([[8364,128],[8218,130],[402,131],[8222,132],[8230,133],[8224,134],[8225,135],[710,136],[8240,137],[352,138],[8249,139],[338,140],[381,142],[8216,145],[8217,146],[8220,147],[8221,148],[8226,149],[8211,150],[8212,151],[732,152],[8482,153],[353,154],[8250,155],[339,156],[382,158],[376,159]]),gh=class e{static{this.DefaultAlgo=`SHA-512`}static{this.DefaultSpinCount=1e5}static async generateSaltAndHash(t,n=e.DefaultAlgo,r=e.DefaultSpinCount){if(!t)return null;let i=mh((await dh()).getRandomValues(new Uint8Array(16)).buffer);return{salt:i,hash:await e._convertPasswordToHash(t,i,n,r)}}static async verifyPassword(t,n,r=e.DefaultAlgo,i=e.DefaultSpinCount){if(!t||!n)throw new y;return((e,t)=>{let n=e.length,r=t.length,i=n===r?0:1,a=Math.max(n,r);for(let o=0;o<a;o++)i|=e.charCodeAt(o%n)^t.charCodeAt(o%r);return i===0})(await e._convertPasswordToHash(t,n.salt,r,i),n.hash)}static verifyLegacyPassword(e,t){return!!/^[0-9A-Fa-f]{1,4}$/.test(t)&&(e=>{let t=[];for(let n of e){let e=n.codePointAt(0),r=e<128||e>=160&&e<=255;t.push(r?e:hh.get(e)??63)}let n=0;for(let e=t.length;e>=0;e--)n=(n>>14&1|n<<1&32767)^(e===0?t.length:t[e-1]);return 52811^n})(e)===parseInt(t,16)}static async verifyStoredPassword(t,n){return n.hash?e.verifyPassword(t,{salt:n.salt,hash:n.hash},n.algorithm,n.spinCount):!n.legacyHash||e.verifyLegacyPassword(t,n.legacyHash)}static async _convertPasswordToHash(e,t,n,r){let i=await dh();n=n.toUpperCase();let a=(e=>{let t=e.length,n=new ArrayBuffer(2*t),r=new DataView(n);for(let n=0;n<t;n++)r.setUint16(2*n,e.charCodeAt(n),!0);return new Uint8Array(n)})(e),o=(e=>{let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r.buffer})(t),s=await fh(i,n,o,a.buffer);for(let e=0;e<r;e++){let t=new Uint32Array([e]).buffer;s=await fh(i,n,s,t)}return mh(s)}},_h=class{constructor(e,t=!1){this._isPaused=!1,this._isDisabled=!1,this._password=null,this._identities=null,this._properties=null,this._emitter=new ne(this),this.fromJSON(e),this._isReadOnly=t}async lock(e,t,n,r){if(this._isReadOnly)return this;if(this._properties!==null&&!this._isDisabled)throw Error(`Cannot lock an already locked object. Use unlock first.`);try{this._validatePassword()}catch{throw Error(`A password is already set. Unlock first to change.`)}let i;if(t){let e=await gh.generateSaltAndHash(t,n,r);i={salt:e.salt,hash:e.hash},n&&(i.algorithm=n),r&&(i.spinCount=r)}else i=null;return e=e??this._properties??{},this._updateProperties(e),this._properties=e,this._password=i,this._isDisabled=!1,this._emitter.notify(`onLockChange`),this._emitter.notify(`onChange`),this}async unlock(e){if(this._isReadOnly)throw Error(`Cannot unlock a readonly workbook.`);return await this._validatePassword(e),this._isDisabled=this._properties!==null,this._password=null,this._identities=null,this._isPaused=!1,this._emitter.notify(`onLockChange`),this._emitter.notify(`onChange`),this}checkPassword(e){return this._validatePassword(e)}hasPassword(){return this._password!==null}async pause(e){if(this._isPaused)return this;if(this._properties===null||this._isDisabled)throw Error(`Cannot pause an object that is not locked.`);return await this._validatePassword(e),this._isPaused=!0,this._emitter.notify(`onLockChange`),this._emitter.notify(`onChange`),this}resume(){return this._isPaused&&(this._isPaused=!1,this._emitter.notify(`onLockChange`),this._emitter.notify(`onChange`)),this}async setProperties(e){if(this._isReadOnly)throw Error(`Cannot change the properties of a readonly object.`);if(this.isLocked())throw Error(`Cannot change the properties of a locked object. Use unlock first.`);let t=this._properties===null||this._isDisabled;return this._clearProperties(),this._updateProperties(e??{}),this._isDisabled=t,this._emitter.notify(`onChange`),this}isPaused(){return this._isPaused}isLocked(){return this._properties!==null&&!this._isDisabled&&!this._isPaused}isReadOnly(){return this._isReadOnly}async _validatePassword(e){let t=this._password;if(!t||!t.hash&&!t.legacyHash)return!0;if(!e||e.length===0)throw Error(`Password is required.`);if(!await gh.verifyStoredPassword(e,t))throw Error(`Invalid password.`);return!0}getProperties(){return this._properties}_isPropertyAllowed(e){if(this._isReadOnly)return!1;if(!this.isLocked())return!0;let 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){if(this._password=null,this._identities=null,this._isPaused=!1,this._isDisabled=!1,this._properties=null,!e)return void this._fromJSON(null);let{password:t,identities:n,...r}=e,i=this._getAllowedKey();this._isDisabled=!0===r[i],delete r[i],this._fromJSON(r),t&&!this._isDisabled&&(this._password=t),n&&(this._identities=n)}_fromJSON(e){}_toJSON(e){return e}toJSON(){if(!this._properties)return null;let e={};return e=this._toJSON(e)??{},this._isDisabled?Object.keys(e).length===0?null:(e[this._getAllowedKey()]=!0,e):(this._password&&(e.password=this._password),this._identities&&(e.identities=this._identities),e)}get isIProtection(){return!0}},vh=Object.freeze({selectLockedCells:!0,selectUnlockedCells:!0,showFormulas:!0,autoTable:!1,deleteColumns:!1,deleteRows:!1,formatCells:!1,formatColumns:!1,formatRows:!1,insertColumns:!1,insertHyperlinks:!1,insertRows:!1,objects:!1,pivotTables:!1,scenarios:!1,sort:!1}),yh=class extends _h{isAutoTableAllowed(){return this._isPropertyAllowed(`autoTable`)}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`)}isShowFormulasAllowed(){return this._isPropertyAllowedByDefault(`showFormulas`)}isSelectLockedCellsAllowed(){return this._isPropertyAllowedByDefault(`selectLockedCells`)}isSelectUnlockedCellsAllowed(){return this._isPropertyAllowedByDefault(`selectUnlockedCells`)}_isPropertyAllowedByDefault(e){return!this.isLocked()||!1!==this._properties[e]}_getAllowedKey(){return`sheet`}_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){let n=Object.keys(t);for(let r=0;r<n.length;r++){let i=t[n[r]];i!=null&&i!==vh[n[r]]&&(e[n[r]]=i)}}return super._toJSON(e)}get[Symbol.toStringTag](){return`[WorksheetProtection]`}toString(){return null}get isIWorksheetProtection(){return!0}},bh=e=>typeof e==`string`?N(`error.address.invalidRangeAddress`,{address:e}):N(`error.address.invalidRangeAddressAny`),X=()=>{throw Error(N(`error.address.invalidRangeEmpty`))},xh={hasSubscribers:!1},Sh=xh,Ch=xh,wh=typeof performance==`object`&&performance&&typeof performance.now==`function`?performance:Date,Th=()=>Sh.hasSubscribers||Ch.hasSubscribers,Eh=new Set,Dh=typeof process==`object`&&process?process:{},Oh=e=>!!e&&e===Math.floor(e)&&e>0&&isFinite(e),kh=e=>Oh(e)?e<=256?Uint8Array:e<=2**16?Uint16Array:e<=2**32?Uint32Array:e<=2**53-1?Ah:null:null,Ah=class extends Array{constructor(e){super(e),this.fill(0)}},jh=class e{heap;length;static#e=!1;static create(t){let n=kh(t);if(!n)return[];e.#e=!0;let r=new e(t,n);return e.#e=!1,r}constructor(t,n){if(!e.#e)throw TypeError(`instantiate Stack using Stack.create(n)`);this.heap=new n(t),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Mh=class e{#e;#t;#n;#r;#i;#a;#o;#s;get perf(){return this.#s}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;backgroundFetchSize;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;#x;#S;#C;#w;#T;#E;static unsafeExposeInternals(e){return{starts:e.#b,ttls:e.#x,autopurgeTimers:e.#S,sizes:e.#y,keyMap:e.#u,keyList:e.#d,valList:e.#f,next:e.#p,prev:e.#m,get head(){return e.#h},get tail(){return e.#g},free:e.#_,isBackgroundFetch:t=>e.#W(t),backgroundFetch:(t,n,r,i)=>e.#U(t,n,r,i),moveToTail:t=>e.#X(t),indexes:t=>e.#I(t),rindexes:t=>e.#L(t),isStale:t=>e.#j(t)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#l}get size(){return this.#c}get fetchMethod(){return this.#a}get memoMethod(){return this.#o}get dispose(){return this.#n}get onInsert(){return this.#r}get disposeAfter(){return this.#i}constructor(t){let{max:n=0,ttl:r,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:s,allowStale:c,dispose:l,onInsert:u,disposeAfter:d,noDisposeOnSet:f,noUpdateTTL:p,maxSize:m=0,maxEntrySize:h=0,sizeCalculation:g,fetchMethod:_,memoMethod:v,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:S,ignoreFetchAbort:C,backgroundFetchSize:w=1,perf:T}=t;if(this.backgroundFetchSize=w,T!==void 0&&typeof T?.now!=`function`)throw TypeError(`perf option must have a now() method if specified`);if(this.#s=T??wh,n!==0&&!Oh(n))throw TypeError(`max option must be a nonnegative integer`);let E=n?kh(n):Array;if(!E)throw Error(`invalid max value: `+n);if(this.#e=n,this.#t=m,this.maxEntrySize=h||this.#t,this.sizeCalculation=g,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw TypeError(`cannot set sizeCalculation without setting maxSize or maxEntrySize`);if(typeof this.sizeCalculation!=`function`)throw TypeError(`sizeCalculation set to non-function`)}if(v!==void 0&&typeof v!=`function`)throw TypeError(`memoMethod must be a function if defined`);if(this.#o=v,_!==void 0&&typeof _!=`function`)throw TypeError(`fetchMethod must be a function if specified`);if(this.#a=_,this.#w=!!_,this.#u=new Map,this.#d=Array.from({length:n}).fill(void 0),this.#f=Array.from({length:n}).fill(void 0),this.#p=new E(n),this.#m=new E(n),this.#h=0,this.#g=0,this.#_=jh.create(n),this.#c=0,this.#l=0,typeof l==`function`&&(this.#n=l),typeof u==`function`&&(this.#r=u),typeof d==`function`?(this.#i=d,this.#v=[]):(this.#i=void 0,this.#v=void 0),this.#C=!!this.#n,this.#E=!!this.#r,this.#T=!!this.#i,this.noDisposeOnSet=!!f,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!S,this.ignoreFetchAbort=!!C,this.maxEntrySize!==0){if(this.#t!==0&&!Oh(this.#t))throw TypeError(`maxSize must be a positive integer if specified`);if(!Oh(this.maxEntrySize))throw TypeError(`maxEntrySize must be a positive integer if specified`);this.#M()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!s,this.ttlResolution=Oh(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=r||0,this.ttl){if(!Oh(this.ttl))throw TypeError(`ttl must be a positive integer if specified`);this.#D()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw TypeError(`At least one of max, maxSize, or ttl is required`);if(!this.ttlAutopurge&&!this.#e&&!this.#t){let t=`LRU_CACHE_UNBOUNDED`;(e=>!Eh.has(e))(t)&&(Eh.add(t),((e,t,n,r)=>{typeof Dh.emitWarning==`function`?Dh.emitWarning(e,t,n,r):console.error(`[${n}] ${t}: ${e}`)})(`TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.`,`UnboundedCacheWarning`,t,e))}}getRemainingTTL(e){return this.#u.has(e)?1/0:0}#D(){let e=new Ah(this.#e),t=new Ah(this.#e);this.#x=e,this.#b=t;let n=this.ttlAutopurge?Array.from({length:this.#e}):void 0;this.#S=n,this.#A=(n,i,a=this.#s.now())=>{t[n]=i===0?0:a,e[n]=i,r(n,i)},this.#O=n=>{t[n]=e[n]===0?0:this.#s.now(),r(n,e[n])};let r=this.ttlAutopurge?(e,t)=>{if(n?.[e]&&(clearTimeout(n[e]),n[e]=void 0),t&&t!==0&&n){let i=setTimeout(()=>{this.#j(e)?(this.#Z(this.#d[e],`expire`),n[e]=void 0):r(e,o(e))},t+1);i.unref&&i.unref(),n[e]=i}}:()=>{};this.#k=(n,r)=>{if(e[r]){let o=e[r],s=t[r];if(!o||!s)return;n.ttl=o,n.start=s,n.now=i||a(),n.remainingTTL=o-(n.now-s)}};let i=0,a=()=>{let e=this.#s.now();if(this.ttlResolution>0){i=e;let t=setTimeout(()=>i=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=e=>{let t=this.#u.get(e);return t===void 0?0:o(t)};let o=n=>{let r=e[n],o=t[n];return r&&o?r-((i||a())-o):1/0};this.#j=n=>{let r=t[n],o=e[n];return!!o&&!!r&&(i||a())-r>o}}#O=()=>{};#k=()=>{};#A=()=>{};#j=()=>!1;#M(){let e=new Ah(this.#e);this.#l=0,this.#y=e,this.#N=t=>{this.#l-=e[t],e[t]=0},this.#F=(e,t,n,r)=>{if(!Oh(n)){if(this.#W(t))return this.backgroundFetchSize;if(!r)throw TypeError(`invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.`);if(typeof r!=`function`)throw TypeError(`sizeCalculation must be a function`);if(n=r(t,e),!Oh(n))throw TypeError(`sizeCalculation return invalid (expect positive integer)`)}return n},this.#P=(t,n,r)=>{if(e[t]=n,this.#t){let n=this.#t-e[t];for(;this.#l>n;)this.#B(!0)}this.#l+=e[t],r&&(r.entrySize=n,r.totalCalculatedSize=this.#l)}}#N=e=>{};#P=(e,t,n)=>{};#F=(e,t,n,r)=>{if(n||r)throw TypeError(`cannot set size without setting maxSize or maxEntrySize on cache`);return 0};*#I({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#g;this.#R(t)&&((e||!this.#j(t))&&(yield t),t!==this.#h);)t=this.#m[t]}*#L({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#h;this.#R(t)&&((e||!this.#j(t))&&(yield t),t!==this.#g);)t=this.#p[t]}#R(e){return e!==void 0&&this.#u.get(this.#d[e])===e}*entries(){for(let e of this.#I())this.#f[e]!==void 0&&this.#d[e]!==void 0&&!this.#W(this.#f[e])&&(yield[this.#d[e],this.#f[e]])}*rentries(){for(let e of this.#L())this.#f[e]!==void 0&&this.#d[e]!==void 0&&!this.#W(this.#f[e])&&(yield[this.#d[e],this.#f[e]])}*keys(){for(let e of this.#I()){let t=this.#d[e];t!==void 0&&!this.#W(this.#f[e])&&(yield t)}}*rkeys(){for(let e of this.#L()){let t=this.#d[e];t!==void 0&&!this.#W(this.#f[e])&&(yield t)}}*values(){for(let e of this.#I())this.#f[e]!==void 0&&!this.#W(this.#f[e])&&(yield this.#f[e])}*rvalues(){for(let e of this.#L())this.#f[e]!==void 0&&!this.#W(this.#f[e])&&(yield this.#f[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]=`LRUCache`;find(e,t={}){for(let n of this.#I()){let r=this.#f[n],i=this.#W(r)?r.__staleWhileFetching:r;if(i!==void 0&&e(i,this.#d[n],this))return this.#J(this.#d[n],t)}}forEach(e,t=this){for(let n of this.#I()){let r=this.#f[n],i=this.#W(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#d[n],this)}}rforEach(e,t=this){for(let n of this.#L()){let r=this.#f[n],i=this.#W(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#d[n],this)}}purgeStale(){let e=!1;for(let t of this.#L({allowStale:!0}))this.#j(t)&&(this.#Z(this.#d[t],`expire`),e=!0);return e}info(e){let t=this.#u.get(e);if(t===void 0)return;let n=this.#f[t],r=this.#W(n)?n.__staleWhileFetching:n;if(r===void 0)return;let i={value:r};if(this.#x&&this.#b){let e=this.#x[t],n=this.#b[t];e&&n&&(i.ttl=e-(this.#s.now()-n),i.start=Date.now())}return this.#y&&(i.size=this.#y[t]),i}dump(){let e=[];for(let t of this.#I({allowStale:!0})){let n=this.#d[t],r=this.#f[t],i=this.#W(r)?r.__staleWhileFetching:r;if(i===void 0||n===void 0)continue;let a={value:i};if(this.#x&&this.#b){a.ttl=this.#x[t];let e=this.#s.now()-this.#b[t];a.start=Math.floor(Date.now()-e)}this.#y&&(a.size=this.#y[t]),e.unshift([n,a])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let e=Date.now()-n.start;n.start=this.#s.now()-e}this.#z(t,n.value,n)}}set(e,t,n={}){let{status:r=Sh.hasSubscribers?{}:void 0}=n;n.status=r,r&&(r.op=`set`,r.key=e,t!==void 0&&(r.value=t),r.cache=this);let i=this.#z(e,t,n);return r&&Sh.hasSubscribers&&Sh.publish(r),i}#z(e,t,n,r){let{ttl:i=this.ttl,start:a,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:c}=n,l=this.#W(t);if(t===void 0)return c&&(c.set=`deleted`),this.delete(e),this;let{noUpdateTTL:u=this.noUpdateTTL}=n;c&&!l&&(c.value=t);let d=this.#F(e,t,n.size||0,s,c);if(this.maxEntrySize&&d>this.maxEntrySize)return this.#Z(e,`set`),c&&(c.set=`miss`,c.maxEntrySizeExceeded=!0),this;let f=this.#c===0?void 0:this.#u.get(e);if(f===void 0)f=this.#c===0?this.#g:this.#_.length===0?this.#c===this.#e?this.#B(!1):this.#c:this.#_.pop(),this.#d[f]=e,this.#f[f]=t,this.#u.set(e,f),this.#p[this.#g]=f,this.#m[f]=this.#g,this.#g=f,this.#c++,this.#P(f,d,c),c&&(c.set=`add`),u=!1,this.#E&&!l&&this.#r?.(t,e,`add`);else{this.#X(f);let n=this.#f[f];if(t!==n){if(!o){if(this.#W(n)){n!==r&&n.__abortController.abort(Error(`replaced`));let{__staleWhileFetching:i}=n;i!==void 0&&i!==t&&(this.#C&&this.#n?.(i,e,`set`),this.#T&&this.#v?.push([i,e,`set`]))}else this.#C&&this.#n?.(n,e,`set`),this.#T&&this.#v?.push([n,e,`set`])}if(this.#N(f),this.#P(f,d,c),this.#f[f]=t,!l){let r=n&&this.#W(n)?n.__staleWhileFetching:n,i=r===void 0?`add`:t===r?`update`:`replace`;c&&(c.set=i,r!==void 0&&(c.oldValue=r)),this.#E&&this.onInsert?.(t,e,i)}}else l||(c&&(c.set=`update`),this.#E&&this.onInsert?.(t,e,`update`))}if(i!==0&&!this.#x&&this.#D(),this.#x&&(u||this.#A(f,i,a),c&&this.#k(c,f)),!o&&this.#T&&this.#v){let e,t=this.#v;for(;e=t?.shift();)this.#i?.(...e)}return this}pop(){try{for(;this.#c;){let e=this.#f[this.#h];if(this.#B(!0),this.#W(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#T&&this.#v){let e,t=this.#v;for(;e=t?.shift();)this.#i?.(...e)}}}#B(e){let t=this.#h,n=this.#d[t],r=this.#f[t],i=this.#W(r);i&&r.__abortController.abort(Error(`evicted`));let a=i?r.__staleWhileFetching:r;return(this.#C||this.#T)&&a!==void 0&&(this.#C&&this.#n?.(a,n,`evict`),this.#T&&this.#v?.push([a,n,`evict`])),this.#N(t),this.#S?.[t]&&(clearTimeout(this.#S[t]),this.#S[t]=void 0),e&&(this.#d[t]=void 0,this.#f[t]=void 0,this.#_.push(t)),this.#c===1?(this.#h=this.#g=0,this.#_.length=0):this.#h=this.#p[t],this.#u.delete(n),this.#c--,t}has(e,t={}){let{status:n=Sh.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op=`has`,n.key=e,n.cache=this);let r=this.#V(e,t);return Sh.hasSubscribers&&Sh.publish(n),r}#V(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=t,i=this.#u.get(e);if(i!==void 0){let e=this.#f[i];if(this.#W(e)&&e.__staleWhileFetching===void 0)return!1;if(!this.#j(i))return n&&this.#O(i),r&&(r.has=`hit`,this.#k(r,i)),!0;r&&(r.has=`stale`,this.#k(r,i))}else r&&(r.has=`miss`);return!1}peek(e,t={}){let{status:n=Th()?{}:void 0}=t;n&&(n.op=`peek`,n.key=e,n.cache=this),t.status=n;let r=this.#H(e,t);return Sh.hasSubscribers&&Sh.publish(n),r}#H(e,t){let{status:n,allowStale:r=this.allowStale}=t,i=this.#u.get(e);if(i===void 0||!r&&this.#j(i))return void(n&&(n.peek=i===void 0?`miss`:`stale`));let a=this.#f[i],o=this.#W(a)?a.__staleWhileFetching:a;return n&&(o===void 0?n.peek=`miss`:(n.peek=`hit`,n.value=o)),o}#U(e,t,n,r){let i=t===void 0?void 0:this.#f[t];if(this.#W(i))return i;let a=new AbortController,{signal:o}=n;o?.addEventListener(`abort`,()=>a.abort(o.reason),{signal:a.signal});let s={signal:a.signal,options:n,context:r},c=(r,i=!1)=>{let{aborted:o}=a.signal,c=n.ignoreFetchAbort&&r!==void 0,d=n.ignoreFetchAbort||!(!n.allowStaleOnFetchAbort||r===void 0);if(n.status&&(o&&!i?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,c&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),o&&!c&&!i)return l(a.signal.reason,d);let f=u,p=this.#f[t];return(p===u||p===void 0&&c&&i)&&(r===void 0?f.__staleWhileFetching===void 0?this.#Z(e,`fetch`):this.#f[t]=f.__staleWhileFetching:(n.status&&(n.status.fetchUpdated=!0),this.#z(e,r,s.options,f))),r},l=(r,i)=>{let{aborted:o}=a.signal,s=o&&n.allowStaleOnFetchAbort,c=s||n.allowStaleOnFetchRejection,l=c||n.noDeleteOnFetchRejection,d=u;if(this.#f[t]===u&&(!l||!i&&d.__staleWhileFetching===void 0?this.#Z(e,`fetch`):s||(this.#f[t]=d.__staleWhileFetching)),c)return n.status&&d.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),d.__staleWhileFetching;if(d.__returned===d)throw r};n.status&&(n.status.fetchDispatched=!0);let u=new Promise((t,r)=>{let o=this.#a?.(e,i,s);a.signal.addEventListener(`abort`,()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>c(e,!0)))}),o&&o instanceof Promise?o.then(e=>t(e===void 0?void 0:e),r):o!==void 0&&t(o)}).then(c,e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),l(e,!1))),d=Object.assign(u,{__abortController:a,__staleWhileFetching:i,__returned:void 0});return t===void 0?(this.#z(e,d,{...s.options,status:void 0}),t=this.#u.get(e)):this.#f[t]=d,d}#W(e){if(!this.#w)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty(`__staleWhileFetching`)&&t.__abortController instanceof AbortController}fetch(e,t={}){let n=Ch.hasSubscribers,{status:r=Th()?{}:void 0}=t;t.status=r,r&&t.context&&(r.context=t.context);let i=this.#G(e,t);return r&&n&&(r.trace=!0,Ch.tracePromise(()=>i,r).catch(()=>{})),i}async#G(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:s=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:h=!1,status:g,signal:_}=t;if(g&&(g.op=`fetch`,g.key=e,h&&(g.forceRefresh=!0),g.cache=this),!this.#w)return g&&(g.fetch=`get`),this.#J(e,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:g});let v={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:a,noDisposeOnSet:o,size:s,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:p,ignoreFetchAbort:f,status:g,signal:_},y=this.#u.get(e);if(y===void 0){g&&(g.fetch=`miss`);let t=this.#U(e,y,v,m);return t.__returned=t}{let t=this.#f[y];if(this.#W(t)){let e=n&&t.__staleWhileFetching!==void 0;return g&&(g.fetch=`inflight`,e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let i=this.#j(y);if(!h&&!i)return g&&(g.fetch=`hit`),this.#X(y),r&&this.#O(y),g&&this.#k(g,y),t;let a=this.#U(e,y,v,m),o=a.__staleWhileFetching!==void 0&&n;return g&&(g.fetch=i?`stale`:`refresh`,o&&i&&(g.returnedStale=!0)),o?a.__staleWhileFetching:a.__returned=a}}forceFetch(e,t={}){let n=Ch.hasSubscribers,{status:r=Th()?{}:void 0}=t;t.status=r,r&&t.context&&(r.context=t.context);let i=this.#K(e,t);return r&&n&&(r.trace=!0,Ch.tracePromise(()=>i,r).catch(()=>{})),i}async#K(e,t={}){let n=await this.#G(e,t);if(n===void 0)throw Error(`fetch() returned undefined`);return n}memo(e,t={}){let{status:n=Sh.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op=`memo`,n.key=e,t.context&&(n.context=t.context),n.cache=this);let r=this.#q(e,t);return n&&(n.value=r),Sh.hasSubscribers&&Sh.publish(n),r}#q(e,t={}){let n=this.#o;if(!n)throw Error(`no memoMethod provided to constructor`);let{context:r,status:i,forceRefresh:a,...o}=t;i&&a&&(i.forceRefresh=!0);let s=this.#J(e,o),c=a||s===void 0;if(i&&(i.memo=c?`miss`:`hit`,c||(i.value=s)),!c)return s;let l=n(e,s,{options:o,context:r});return i&&(i.value=l),this.#z(e,l,o),l}get(e,t={}){let{status:n=Sh.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op=`get`,n.key=e,n.cache=this);let r=this.#J(e,t);return n&&(r!==void 0&&(n.value=r),Sh.hasSubscribers&&Sh.publish(n)),r}#J(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:a}=t,o=this.#u.get(e);if(o===void 0)return void(a&&(a.get=`miss`));let s=this.#f[o],c=this.#W(s);return a&&this.#k(a,o),this.#j(o)?c?(a&&(a.get=`stale-fetching`),n&&s.__staleWhileFetching!==void 0?(a&&(a.returnedStale=!0),s.__staleWhileFetching):void 0):(i||this.#Z(e,`expire`),a&&(a.get=`stale`),n?(a&&(a.returnedStale=!0),s):void 0):(a&&(a.get=c?`fetching`:`hit`),this.#X(o),r&&this.#O(o),c?s.__staleWhileFetching:s)}#Y(e,t){this.#m[t]=e,this.#p[e]=t}#X(e){e!==this.#g&&(e===this.#h?this.#h=this.#p[e]:this.#Y(this.#m[e],this.#p[e]),this.#Y(this.#g,e),this.#g=e)}delete(e){return this.#Z(e,`delete`)}#Z(e,t){Sh.hasSubscribers&&Sh.publish({op:`delete`,delete:t,key:e,cache:this});let n=!1;if(this.#c!==0){let r=this.#u.get(e);if(r!==void 0){if(this.#S?.[r]&&(clearTimeout(this.#S[r]),this.#S[r]=void 0),n=!0,this.#c===1)this.#Q(t);else{this.#N(r);let n=this.#f[r];if(this.#W(n)?n.__abortController.abort(Error(`deleted`)):(this.#C||this.#T)&&(this.#C&&this.#n?.(n,e,t),this.#T&&this.#v?.push([n,e,t])),this.#u.delete(e),this.#d[r]=void 0,this.#f[r]=void 0,r===this.#g)this.#g=this.#m[r];else if(r===this.#h)this.#h=this.#p[r];else{let e=this.#m[r];this.#p[e]=this.#p[r];let t=this.#p[r];this.#m[t]=this.#m[r]}this.#c--,this.#_.push(r)}}}if(this.#T&&this.#v?.length){let e,t=this.#v;for(;e=t?.shift();)this.#i?.(...e)}return n}clear(){return this.#Q(`delete`)}#Q(e){for(let t of this.#L({allowStale:!0})){let n=this.#f[t];if(this.#W(n))n.__abortController.abort(Error(`deleted`));else{let r=this.#d[t];this.#C&&this.#n?.(n,r,e),this.#T&&this.#v?.push([n,r,e])}}if(this.#u.clear(),this.#f.fill(void 0),this.#d.fill(void 0),this.#x&&this.#b){this.#x.fill(0),this.#b.fill(0);for(let e of this.#S??[])e!==void 0&&clearTimeout(e);this.#S?.fill(void 0)}if(this.#y&&this.#y.fill(0),this.#h=0,this.#g=0,this.#_.length=0,this.#l=0,this.#c=0,this.#T&&this.#v){let e,t=this.#v;for(;e=t?.shift();)this.#i?.(...e)}}},Nh=`Resource is closed.`,Ph=class{constructor(e){if(this._listeners=new Set,this._arrayBuffer=null,this._type=null,this._sourceResolved=null,this._externalURI=null,this._name=e?.name??null,this._fetchedFrom=e?.fetchedFrom??null,this._source=e.source,!e.source)throw Error(`Source undefined`);this._refs=new Set,this._isClosed=!1}async _resolveSource(){let e=this._sourceResolved;return e||(e=this._source,typeof e==`function`&&(e=e()),e&&typeof e==`object`&&typeof e.then==`function`&&(e=await Promise.resolve(e)),this._sourceResolved=e,e)}async _resolveArrayBuffer(){let e=await this._resolveSource();if(e.base64){let t=e.base64;return n.base64ToArrayBuffer(t)}if(e.fetch||e.external){let t=e.fetch??e.external,n,r,i;if(typeof t==`string`)n=t;else{let e=t;n=e.input,r=e.init,i=e.timeout}let a=i||3e4,o=new AbortController,s=setTimeout(()=>o.abort(),a);try{let e=await fetch(n,{...r,signal:o.signal});if(!e.ok)throw Error(`${e.status} ${e.statusText}`.trim());let t=await e.arrayBuffer(),i=e.headers.get(`Content-Type`);if(i){let e=await Fh(t);e&&(this._type={mime:i,ext:e.ext},e.mime!==i&&console.warn(`Resource fetch detected mime type ${e.mime} does not match response mime type ${i}. Using response mime type.`))}return t}catch(e){let t=e?.name===`AbortError`?`Timed out after ${a}ms`:e.message;throw Error(`Unable to fetch '${n}'`,{cause:t})}finally{clearTimeout(s)}}if(e.buffer)return e.buffer;if(e.file)return await e.file.arrayBuffer();throw Error(`BinaryResource must have an initial data value.`)}getName(){return this._name}getFetchedFrom(){return this._fetchedFrom}async toJSONAsync(){let e={},t=await this.getExternalURI();if(t)e.uri=t;else{let t=await this.toBuffer();e.base64=n.arrayBufferToBase64(t)}return this._name&&(e.name=this._name),this._fetchedFrom&&(e.fetchedFrom=this._fetchedFrom),e}async toBuffer(){if(this._arrayBuffer)return this._arrayBuffer;try{this._arrayBuffer=this._resolveArrayBuffer()}catch(e){throw e}return this._arrayBuffer}async getType(){if(this._type)return this._type;let e=await Fh(await this.toBuffer());return this._type=e,e}async getExternalURI(){if(this._externalURI)return this._externalURI;let e=await this._resolveSource(),t=Promise.resolve(null),n=e.external;if(n){if(typeof n==`string`)t=Promise.resolve(n);else{let e=n.input;typeof e==`string`?t=Promise.resolve(e):e instanceof URL?t=Promise.resolve(e.href):e instanceof Request&&(t=Promise.resolve(e.url))}}return this._externalURI=t,t}addReference(e){if(this._isClosed)throw Error(Nh);this._refs.add(e)}deleteReference(e){if(this._isClosed)throw Error(Nh);if(this._refs.size===0||!this._refs.has(e))return;this._refs.delete(e);let t=this;if(this._refs.size===0){let e=this._listeners;e.forEach(n=>{n.onUnload?.(t),e.delete(n)}),this._arrayBuffer=null,this._isClosed=!0}}addUnloadListener(e){if(this._isClosed)throw Error(Nh);this._listeners.add(e)}get isIResource(){return!0}isClosed(){return this._isClosed}};async function Fh(e){return function(e){let t=e instanceof ArrayBuffer?new Uint8Array(e):e;if(t.length<4)return null;if(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71)return{mime:`image/png`,ext:`png`};if(t[0]===255&&t[1]===216&&t[2]===255)return{mime:`image/jpeg`,ext:`jpeg`};if(t[0]===71&&t[1]===73&&t[2]===70&&t[3]===56)return{mime:`image/gif`,ext:`gif`};if(t[0]===66&&t[1]===77)return{mime:`image/bmp`,ext:`bmp`};if(t[0]===73&&t[1]===73&&t[2]===42&&t[3]===0||t[0]===77&&t[1]===77&&t[2]===0&&t[3]===42)return{mime:`image/tiff`,ext:`tif`};if(t.length>=44&&t[0]===1&&t[1]===0&&t[2]===0&&t[3]===0&&t[40]===32&&t[41]===69&&t[42]===77&&t[43]===70)return{mime:`image/x-emf`,ext:`emf`};if(t[0]===215&&t[1]===205&&t[2]===198&&t[3]===154||t[0]===1&&t[1]===0&&t[2]===9&&t[3]===0)return{mime:`image/x-wmf`,ext:`wmf`};if(t.length>=12&&t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80)return{mime:`image/webp`,ext:`webp`};if(t.length>=6&&t[0]===0&&t[1]===0&&t[2]===1&&t[3]===0&&(t[4]!==0||t[5]!==0))return{mime:`image/x-icon`,ext:`ico`};if(t.length>=100){let e=new TextDecoder(`utf-8`,{fatal:!1}).decode(t.slice(0,100));if(e.includes(`<svg`)||e.includes(`<?xml`)&&e.includes(`svg`))return{mime:`image/svg+xml`,ext:`svg`}}return null}(e)||null}var Ih,Lh=class{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 Error(`PersistScope is closed.`);this._isClosed=!0,this._state.openScopes.size===0&&this._onLastEnd()}toResourceId(e){if(this._isClosed)throw 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}fromResourceId(e){return this._state.byIds.get(e)??null}fromJSON(e){if(this._isClosed)throw Error(`PersistScope is closed.`);if(!e||e.length===0)return;let t=this._state.byRefs.size;for(let n=0;n<e.length;n++){let r=e[n],i=this._fromJSON(r);this._state.byRefs.set(i,t+n),this._state.byIds.set(t+n,i)}}async toJSONAsync(e){if(this._isClosed)throw Error(`PersistScope is closed.`);let t=[];this._state.byRefs.forEach((n,r)=>{t[n]=e?e(r,n):r.toJSONAsync()});let n=await Promise.all(t);if(!e)return n;let r=!1;for(let e=0;e<n.length;e++)if(n[e]){r=!0;break}return r?n.map(e=>e??{}):[]}},Rh=class extends Qt{constructor(){super(),this._persistOpen=null,this._resources=new Set}add(e){if(typeof e==`string`){let t=!1;this._resources.forEach(n=>{n.getName()===e&&(t=!0,e=n)}),t||(e=new Ph({name:e,source:{fetch:e}}))}let t;t=e instanceof Ph?e:new Ph({...e});let n=this;return this._resources.has(t)||(t.addUnloadListener({onUnload:e=>{n._resources.delete(t)&&n._notifyCollectionChange()}}),this._resources.add(t),this._notifyCollectionChange()),t}_getItems(e){return Array.from(this._resources)}getCount(){return this._resources.size}beginPersist(){this._persistOpen||={byRefs:new Map,byIds:new Map,openScopes:new Set};let e={},t=new Set,n=this;return new Lh(this._persistOpen,r=>{let i=r.base64,a=r.uri,o={};i?o.base64=i:a&&(o.external=a);let s=n.add({name:r.name,fetchedFrom:r.fetchedFrom,source:o});return s.addReference(e),t.add(s),s},()=>{t.forEach(t=>{t.deleteReference(e)}),n._persistOpen=null})}get isIResourceCollection(){return!0}},zh=class extends Qt{constructor(){super(),this._persistOpen=null,this._nextId=0,this._lastReadId=-1,this._lastReadValue=null,this._stringsByText=new Map,this._stringsById=new Map}addMultiple(e,t=!1){let n=this._stringsByText,r=this._stringsById,i=e.length,a=this._nextId;for(let o=0;o<i;o++){let i=e[o];n.get(i)!==void 0&&t||(n.set(i,a),r.set(a,i),a++)}this._lastReadId=-1,a!==this._nextId&&(this._nextId=a,this._notifyCollectionChange())}add(e){let t=this._stringsByText,n=t.get(e);if(n!==void 0)return n;let r=this._nextId++;return t.set(e,r),this._stringsById.set(r,e),this._lastReadId=-1,this._notifyCollectionChange(),r}_getItems(e){if(e?.id!==void 0){let t=this.getById(e.id);return t?[t]:[]}return Array.from(this._stringsById.values())}getById(e){if(this._lastReadId===e)return this._lastReadValue;let t=this._stringsById.get(e)??null;return this._lastReadId=e,this._lastReadValue=t,t}getCount(){return this._stringsById.size}beginPersist(){this._persistOpen||={byRefs:new Map,byIds:new Map,openScopes:new Set};let e=this;return new Bh(this._persistOpen,t=>(Array.isArray(t)?e.addMultiple(t):e.add(t),t),()=>{e._persistOpen=null})}get isIStringCollection(){return!0}},Bh=class{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 Error(`PersistScope is closed.`);this._isClosed=!0,this._state.openScopes.size===0&&this._onLastEnd()}add(e){if(this._isClosed)throw 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 Error(`PersistScope is closed.`);e&&e.length!==0&&this._fromJSON(e)}toJSONAsync(){if(this._isClosed)throw Error(`PersistScope is closed.`);let e=[];return this._state.byRefs.forEach((t,n)=>{e[t]=Promise.resolve(n.toJSONAsync?n.toJSONAsync():n)}),Promise.all(e)}},Vh=/^(mailto|tel|sms):/i,Hh=e=>Vh.test(e),Uh=class{constructor(e,t,n,r,i=!1){if(!n)throw new y;if(typeof n==`string`&&(n={address:n}),typeof n.address!=`string`)throw Error(N(`error.hyperlink.invalidHyperlink`));this._t=e,this._r=t,this._p=n,this._d=r,this._readOnly=i}isReadOnly(){return this._readOnly}delete(e){if(this._readOnly)throw Error(N(`error.hyperlink.fromValue`));if(!this._d)throw Error(N(`error.hyperlink.notAttached`));this._d(e)}open(e,t){return this._r(this.getAddress(),null,e??this.getTarget(),t)}getTarget(){let e=this._p.target;if(e)return e;let t=this._p.address;return t.startsWith(`#`)||Hh(t)?`_self`:`_blank`}getTextToDisplay(){return this._t()||this.getAddress()}getAddress(){return this._p.address??``}getScreenTip(){return this._p.screenTip??null}get isIHyperlink(){return!0}};(Ih||={}).Type={Absolute:`absolute`,OneCell:`oneCell`,TwoCell:`twoCell`};var Wh,Gh=class e{constructor(e){this._cacheSearchRange={colStart:0,rowStart:0,colEnd:0,rowEnd:0},this._cacheSearchFullyContained=!1,this._cacheSearchResults=null,this._init(e)}_init(e){this._options=Object.freeze({getEntireCoords:uB,...e}),this._isEmpty=!0;let t=e.shiftEntry,n=e.isSplittable??!0;this._spatial=new fc(t||!n?{updateEntryOptions:{isSplittable:n,getShifted:t?(e,n,r)=>{let i=t(e.value.model,r);return i===void 0?n:i===null?null:{...n??e,...i}}:void 0}}:void 0),this._mapModelToEntries=new Map,this._setIndexToModel([]),this._mapNameToModel=new Map,this._nextOrder=0,this._createEntry=null,this._mapModelToMeta=new Map}_allocateOrder(){let e=this._nextOrder;return this._nextOrder=e+qh,e}_createSpatialEntry(e,t){let n=(this._createEntry??ng)(e,t);return n.order=this._allocateOrder(),n.orderSpan=qh,n.getSplit||=Xh,n.copyTo||=Zh,{colStart:t.colStart,rowStart:t.rowStart,colEnd:t.colEnd,rowEnd:t.rowEnd,value:n}}_entriesOf(e){return this._mapModelToEntries.get(e)??i.EmptyArray}all(){return this._indexToModel}_setIndexToModel(e){this._indexToModel=Object.freeze(e)}search(e,t=!1,n,r){if(this._isEmpty)return r??i.EmptyArray;let a=this._cacheSearchRange,o=this._cacheSearchResults;if(o!==null&&h.isEqualRanges(e,a)&&t===this._cacheSearchFullyContained||(this._cacheSearchFullyContained=t,a.colStart=e.colStart,a.rowStart=e.rowStart,a.colEnd=e.colEnd,a.rowEnd=e.rowEnd,o=this._searchModels(e,t),this._cacheSearchResults=o),!r)return o;let s=o.length;for(let e=0;e<s;e++)r.push(o[e]);return r}_searchModels(e,t){let n=this._spatial.search(e,t),r=n.length;if(r===0)return i.EmptyArray;let a=this._mapModelToMeta,o=r>1?[...n].sort((e,t)=>{let n=a.get(e.value.model).index,r=a.get(t.value.model).index;return n===r?e.value.order-t.value.order:n-r}):n,s=Array(r);for(let e=0;e<r;e++){let t=o[e];s[e]={...t,value:t.value.model}}return s}getByName(e){if(this._isEmpty)return null;let t=e.toLocaleLowerCase();return this._mapNameToModel.get(t)??null}setName(e,t){let n=this._mapModelToMeta,r=n.get(e);if(!r)return this;let i=new Map(n),a=new Map(this._mapNameToModel),o=r?.name;o&&a.delete(o.toLocaleLowerCase());let s={...r};s.name=t,i.set(e,s);let c=t.toLocaleLowerCase();a.set(c,e);let l=this._shallowClone();return l._mapNameToModel=a,l._mapModelToMeta=i,l}getByIndex(e){return this._isEmpty?null:this._indexToModel[e]||null}setIndex(e,t){let n=this._indexToModel,r=n.length;t<0?t=0:t>r-1&&(t=r-1);let i=this._mapModelToMeta,a=i.get(e);if(a.index===t)return this;let o=[...n],s=new Map(i),c=a.index;o.splice(c,1),o.splice(t,0,e);let l=Math.min(c,t);this._reIndexMeta(o,s,l);let u=this._shallowClone();return u._mapModelToMeta=s,u._setIndexToModel(o),u}getIndex(e){let t=this._mapModelToMeta.get(e);return t?t.index:-1}getCoords(e){let t=this._entriesOf(e);return t.length===0?null:h.sanitizeRangeArray(t)}setCoords(e,t){let n=this._mapModelToEntries,r=this._entriesOf(e);if(r.length===0)return this;let i=t?t.length:0;if(i===0)return this.deleteModel(e);let a=this._spatial.clone(),o=r.length;for(let e=0;e<o;e++)a.remove(r[e],Jh);let s=this._shallowClone(),c=Array(i);for(let n=0;n<i;n++)c[n]=s._createSpatialEntry(e,t[n]);a.load(c);let l=new Map(n);l.set(e,c),s._spatial=a,s._mapModelToEntries=l;let u=h.sanitizeRangeArray(r),d=h.sanitizeRangeArray(c);return tg(u,d)||this._mapModelToMeta.get(e)?.callbacks?.processAfterShift?.(u,d),s}clone(){let t=new e(i.EmptyObject);return t._options=this._options,t._spatial=this._spatial.clone(),t._mapModelToEntries=new Map(this._mapModelToEntries),t._mapModelToMeta=new Map(this._mapModelToMeta),t._mapNameToModel=new Map(this._mapNameToModel),t._setIndexToModel([...this._indexToModel]),t._isEmpty=this._isEmpty,t._nextOrder=this._nextOrder,t._createEntry=this._createEntry,t}size(){return this._mapModelToEntries.size}isEmpty(){return this._isEmpty}has(e){return!this._isEmpty&&this._spatial.has(e)}shift(e){if(this._isEmpty)return this;let t=e?.ranges,n=e?.direction,r=e?.coordValidator,a=t.length,o=this._spatial,s=o,c=this._mapModelToEntries,l=c,u=this._mapModelToMeta,d=u,f=this._mapNameToModel,p=f,m=new Set,h=new Map,g=e=>{let t=h.get(e);return t||(t=[...c.get(e)??i.EmptyArray],h.set(e,t)),t},_=(e,t)=>{let n=t?t.length:0;for(let e=0;e<n;e++){let n=t[e],r=n.value.model;m.add(r);let i=g(r),a=i.indexOf(n);a>=0&&i.splice(a,1)}let r=e?e.length:0;for(let t=0;t<r;t++){let n=e[t],r=n.value.model;m.add(r),g(r).push(n)}},v=e=>{let t=e.before.value.model;m.add(t),u.get(t)?.callbacks?.processShift?.(e)};for(let e=0;e<a;e++){let i=t[e];s=s.shift({range:i,direction:n,cloneIfUpdate:s===o,coordValidator:r,onShift:v,onUpdates:_})}if(m.size===0)return this;l=new Map(c),d=new Map(u),p=new Map(f);let y=[...this._indexToModel];this._applyEntryDeltas(h,c,l,d,p,y);let b=this._shallowClone();return b._spatial=s,b._mapModelToEntries=l,b._mapNameToModel=p,b._setIndexToModel(y),b._mapModelToMeta=d,b._isEmpty=l.size===0,b}copyTo(e,t,n){if(this._isEmpty||e.colIndex===t.colStart&&e.rowIndex===t.rowStart)return this;let r={colStart:e.colIndex,rowStart:e.rowIndex,colEnd:e.colIndex+(t.colEnd-t.colStart),rowEnd:e.rowIndex+(t.rowEnd-t.rowStart)},a=this._spatial.createCopiedEntries(t,r).inserts;if(a.length===0)return this;let o=this._mapModelToEntries,s=new Map,c=e=>{let t=s.get(e);return t||(t=[...o.get(e)??i.EmptyArray],s.set(e,t)),t},l=e=>{let t=c(e.value.model),n=t.indexOf(e);n>=0&&t.splice(n,1)},u=this._shallowClone(),d=this._spatial.clone();if(n){if(this._options.isSplittable??1)d.insertNonOverlapping({...t,value:null},{onUpdates:(e,t)=>{let n=t?t.length:0;for(let e=0;e<n;e++)l(t[e]);let r=e?e.length:0;for(let t=0;t<r;t++)c(e[t].value.model).push(e[t])}});else{let e=new Set;for(let t=0;t<a.length;t++)e.add(a[t].value);let n=this._spatial.search(t);for(let t=0;t<n.length;t++){let r=n[t];e.has(r.value)&&(d.remove(r,Jh),l(r))}}}for(let e=0;e<a.length;e++){let t=a[e];n||(t={...t,value:{...t.value,order:u._allocateOrder(),orderSpan:qh}},a[e]=t),c(t.value.model).push(t)}d.load(a);let f=new Map(o),p=new Map(this._mapModelToMeta),m=new Map(this._mapNameToModel),h=[...this._indexToModel];return this._applyEntryDeltas(s,o,f,p,m,h),u._spatial=d,u._mapModelToEntries=f,u._mapNameToModel=m,u._setIndexToModel(h),u._mapModelToMeta=p,u._isEmpty=f.size===0,u}_applyEntryDeltas(e,t,n,r,i,a){let o=2**53-1;e.forEach((e,s)=>{let c=r.get(s);if(!c)return;let l=t.get(s),u=l?h.sanitizeRangeArray(l):null,d;if(e.length===0){d=null,n.delete(s),r.delete(s);let e=c.name;e&&i.delete(e.toLocaleLowerCase()),o=Math.min(o,c.index),a[c.index]=null}else e.sort(Yh),n.set(s,e),d=h.sanitizeRangeArray(e);tg(u,d)||c.callbacks.processAfterShift?.(u,d),d||c.callbacks.processDelete?.()}),o!==2**53-1&&this._reIndexMeta(a,r,o,!0)}deleteRanges(e,t=!1){if(this._isEmpty)return this;let n=this._spatial,r=e.length,i=[];for(let a=0;a<r;a++){let r=e[a];n.search(r,t,!1,i)}if(i.length===0)return this;let a=this._shallowClone(),o=this._spatial.clone(),s=this._mapModelToEntries,c=new Map(s),l=new Map(this._mapNameToModel),u=new Map(this._mapModelToMeta),d=[...this._indexToModel],f=new Map,p=i.length;for(let e=0;e<p;e++){let t=i[e],n=t.value.model,r=f.get(n);r||(r=new Set,f.set(n,r)),r.add(t),o.remove(t,Jh)}let m=new Map;return f.forEach((e,t)=>{let n=s.get(t);n&&m.set(t,n.filter(t=>!e.has(t)))}),this._applyEntryDeltas(m,s,c,u,l,d),a._spatial=o,a._mapModelToEntries=c,a._mapNameToModel=l,a._setIndexToModel(d),a._mapModelToMeta=u,a._isEmpty=c.size===0,a}_reIndexMeta(e,t,n=0,r=!1){if(r)for(let t=e.length-1;t>=n;t--)e[t]||e.splice(t,1);let i=e.length;for(let r=n;r<i;r++){let n=e[r],i=t.get(n);if(i.index===r)continue;let a={...i};a.index=r,t.set(n,a)}}deleteModel(e){if(this._isEmpty)return this;let t=new Map(this._mapModelToEntries),n=this._mapNameToModel,r=new Map(this._mapModelToMeta),i=r.get(e);i.callbacks.processDelete?.();let a=i?.name;a&&(n=new Map(n),n.delete(a.toLocaleLowerCase()));let o=t.get(e),s=o?o.length:0,c=this._spatial;if(o&&s>0){c=this._spatial.clone();for(let e=0;e<s;e++){let t=o[e];c.remove(t,Jh)}}r.delete(e),t.delete(e);let l=[...this._indexToModel],u=i.index;l[u]=null,this._reIndexMeta(l,r,u,!0);let d=this._shallowClone();return d._spatial=c,d._mapModelToEntries=t,d._mapNameToModel=n,d._mapModelToMeta=r,d._setIndexToModel(l),d._isEmpty=t.size===0,d}_onLoadFailure(e,t){let n=t?.message??(t?String(t):void 0);if(Kh)throw Error(n?`${e} ${n}`:e);O.warn(e,{meta:{type:`error`,detail:n}})}load(e,t){let n=e?e.length:0;if(n===0)return this;let r=this._options.getRanges,a=this._options.getEntireRange,o=t.createModel,s=t.addListeners,c=t.setContainerCoords,l=t.setContainerName,u=t.setContainerIndex,d=t.getContainerIndex,f=t.deleteFromContainer,p=t.invalidate,m=new Map(this._mapModelToEntries),h=new Map(this._mapModelToMeta),g=new Map(this._mapNameToModel),_=[],v=this._shallowClone();v._createEntry=t.createEntry??this._createEntry;let y=(e,t,n)=>{let m={model:null,callbacks:i.EmptyObject,name:null,index:t},h,g=null,_=e,y=!1,b={getRanges:r,getEntireRange:a,invalidate:p,setContainerCallbacks:e=>{if(g)throw Error(`Cannot set container callbacks after model creation.`);m.callbacks={...m.callbacks,...e}},setContainerCoords:(e,t)=>{let n=r(e).getCoords();if(g)return c?.(g,n,t),n;_=[...n]},setContainerName:(e,t)=>{g?l?.(g,e,t):m.name=e},setContainerIndex:(e,t)=>{if(!g)throw Error(`Cannot set container index curring initializations.`);u?.(g,e,t)},getContainerIndex:()=>g?d?.(g):m.index,deleteFromContainer:e=>{g?(f?.(g,e),h?.()):y=!0},coords:e,json:n};if(y)return null;if(g=o(b),m.model=g,!m.name){let e=g.getName?.();e&&(m.name=e)}m.index;let x=[],S=_.length;for(let e=0;e<S;e++)x.push(v._createSpatialEntry(g,_[e]));return s&&(h=s(g)),{entries:x,meta:m}},b=[...this._indexToModel],x=b.length,S=a().getCoords();for(let t=0;t<n;t++){let n=e[t],r=Tf(n,S);if(!r){this._onLoadFailure(`Invalid ref '${n?.r}'.`,null);continue}let i;try{i=y(r.coords,t+x,r.value)}catch(e){this._onLoadFailure(`Unable to load anchored item at '${n?.r}'.`,e)}if(!i)continue;let a=i.entries,o=i.meta,s=o.model;m.set(s,a);let c=o.name;c&&g.set(c.toLocaleLowerCase(),s),h.set(s,o),b.push(s);let l=a.length;for(let e=0;e<l;e++)_.push(a[e])}let C=this._spatial.clone();return C.load(_),v._spatial=C,v._mapModelToEntries=m,v._mapNameToModel=g,v._mapModelToMeta=h,v._setIndexToModel(b),v._isEmpty=m.size===0,v}getBoundingRange(){return this._spatial.getBoundingRange()}toJSON(){let e=this.all(),t=e.length;if(t===0)return null;let n=this._options.getEntireRange().getCoords(),r=[];for(let i=0;i<t;i++){let t=e[i];if(t.toJSON===void 0)continue;let a=this._entriesOf(t);if(a.length===0)continue;let o=t.toJSON();r.push({r:Pf(a,n),v:o})}return r}processCallbacks(e){this._mapModelToMeta.forEach((t,n)=>{e(n,t.callbacks)})}close(){let e=this._mapModelToMeta.keys();for(let t of e)t.close()}_shallowClone(){let t=new e(i.EmptyObject);return t._options=this._options,t._spatial=this._spatial,t._mapModelToEntries=this._mapModelToEntries,t._mapModelToMeta=this._mapModelToMeta,t._mapNameToModel=this._mapNameToModel,t._indexToModel=this._indexToModel,t._isEmpty=this._isEmpty,t._nextOrder=this._nextOrder,t._createEntry=this._createEntry,t}},Kh=!1;(Wh=Gh||={}).setStrictLoad=function(e){Kh=e},Wh.isStrictLoad=function(){return Kh};var qh=1024,Jh=(e,t)=>{let n=e.value,r=t.value;return n.model===r.model&&n.order===r.order},Yh=(e,t)=>e.value.order-t.value.order;function Xh(e,t,n){let r=this.order,i=this.orderSpan,a=i/2>0?i/2:0;return[{...this,order:r,orderSpan:a},{...this,order:r+a,orderSpan:i-a}]}function Zh(e){return{colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colEnd,rowEnd:e.rowEnd,value:this}}var Qh,$h,Z,eg,tg=(e,t)=>{let n=e?e.length:0;if(n!==(t?t.length:0))return!1;for(let r=0;r<n;r++)if(!h.isEqualRanges(e[r],t[r]))return!1;return!0},ng=(e,t)=>({model:e,order:0,orderSpan:qh}),rg=class{constructor(e){this._subscriptions=[],this._getSheets=e.getSheets,this._addSheetsListener=e.addSheetsListener??null}getItems(){this._syncSubscriptions();let e=this._getSheets()??i.EmptyArray,t=e.length;if(t===0)return i.EmptyArray;let n=null;for(let r=0;r<t;r++){let t=e[r]?.getTables().getItems()??i.EmptyArray,a=t.length;for(let e=0;e<a;e++){let r=t[e]?.getNamed?.();r&&(n||=[],n.push(r))}}return n??i.EmptyArray}addListeners(e,t){let n=()=>{e.onCollectionChange?.()},r={notify:n,notifyInvalidated:()=>{e.onInvalidated?.()},sheets:i.EmptyArray,removes:[],options:t};this._subscriptions.push(r),this._syncSubscription(r);let a=this._addSheetsListener?.(()=>{this._syncSubscription(r),n()},t);return()=>{for(let e=0;e<r.removes.length;e++)r.removes[e]?.();r.removes=[],r.sheets=i.EmptyArray,this._subscriptions=this._subscriptions.filter(e=>e!==r),a?.()}}_syncSubscription(e){let t=this._getSheets()??i.EmptyArray,n=e.sheets;if(t.length===n.length){let e=!0;for(let r=0;r<t.length;r++)if(t[r]!==n[r]){e=!1;break}if(e)return}for(let t=0;t<e.removes.length;t++)e.removes[t]?.();e.removes=[],e.sheets=t;for(let n=0;n<t.length;n++){let r=t[n];r&&e.removes.push(r.addListeners({onTablesChange:e.notify,onInvalidated:e.notifyInvalidated},e.options))}}_syncSubscriptions(){for(let e=0;e<this._subscriptions.length;e++)this._syncSubscription(this._subscriptions[e])}};($h=Qh||={}).Feature={Contentful:`contentful`,Kind:`kind`,Role:`role`,DateFormat:`dateFormat`,Error:`error`,Formula:`formula`,Spills:`spills`,CalcError:`calcError`,CalcStatus:`calcStatus`,Circular:`circular`,Fill:`fill`,Borders:`borders`,NumberFormat:`numberFormat`,Alignment:`alignment`,Font:`font`,Protection:`protection`,Merge:`merge`,Table:`table`,AutoTable:`autoTable`,Pivot:`pivot`,Hyperlink:`hyperlink`,IgnoredErrors:`ignoredErrors`,Comments:`comments`,Unlock:`unlock`,Conditionals:`conditionals`,DataValidations:`dataValidations`,CellControl:`cellControl`,Sparkline:`sparkline`,Anomalies:`anomalies`},$h.AnomalyFocus={DoubleCounting:`doubleCounting`,EmbeddedHardcode:`embeddedHardcode`,ColorCoding:`colorCoding`,Average:`average`,CrossSheetReference:`crossSheetReference`,SignConvention:`signConvention`,Lookup:`lookup`,ReferenceAnchoring:`referenceAnchoring`,UnitMismatch:`unitMismatch`,DeletedRows:`deletedRows`},(eg=Z||={}).NotApplicable=Symbol(`NotApplicable`),eg.BuiltInSelectorNames={Logical:`logical`,Date:`date`,DateTime:`dateTime`,Time:`time`,Text:`text`,TextLength:`textLength`,Display:`display`,Number:`number`,Whole:`wholeNumber`},eg.BuiltInOperatorNames={And:`and`,Average:`average`,Between:`between`,Color:`color`,EqualTo:`equalTo`,GreaterThan:`greaterThan`,GreaterThanEqualTo:`greaterThanEqualTo`,LessThan:`lessThan`,LessThanEqualTo:`lessThanEqualTo`,After:`after`,AfterEqualTo:`afterEqualTo`,Before:`before`,BeforeEqualTo:`beforeEqualTo`,Unique:`unique`,Blank:`blank`,Error:`error`,InSet:`inSet`,Icon:`icon`,Not:`not`,TextEmail:`textEmail`,TextIsUrl:`textUrl`,TextStartsWith:`textStartsWith`,TextEndsWith:`textEndsWith`,TextContains:`textContains`,TextMatches:`textMatches`,Expression:`expression`,TimePeriod:`timePeriod`,TopN:`topN`,Or:`or`},eg.AverageType={Above:`above`,Below:`below`,AboveOrEqual:`aboveOrEqual`,BelowOrEqual:`belowOrEqual`},eg.TimePeriodType={Last7Days:`last7Days`,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`,NextYear:`nextYear`,Null:`null`,Q1:`Q1`,Q2:`Q2`,Q3:`Q3`,Q4:`Q4`,ThisMonth:`thisMonth`,ThisQuarter:`thisQuarter`,ThisWeek:`thisWeek`,ThisYear:`thisYear`,Today:`today`,Tomorrow:`tomorrow`,YearToDate:`yearToDate`,Yesterday:`yesterday`},eg.DateItemGroupingType={Day:`day`,Hour:`hour`,Minute:`minute`,Month:`month`,Second:`second`,Year:`year`},xl();var ig=class{constructor(e){this._name=e.name,this._title=e.title,this._description=e.description,this._acceptTypes=e.acceptTypes&&e.acceptTypes.length>0?Object.freeze([...e.acceptTypes]):null,this._paramType=e.paramType}getName(){return this._name}getAcceptsTypes(){return this._acceptTypes}getParamType(e){if(this._paramType!==void 0)return this._paramType;if(e)return e.getName();let t=this._acceptTypes;if(!t)return null;for(let e of t)switch(e){case H.Number:return`number`;case H.String:return`text`;case H.Date:return`dateTime`;case H.Boolean:return`logical`}return null}isCombinator(){return!1}createDefaultParam(e,t){return null}getTitle(){return this._title?N(this._title):i.camelToPrettyCase(this.getName())}getDescription(){return this._description?N(this._description):null}doBatch(e,t,n){return null}async _resolveOperand(e,t){let n;if(e?.isIFormula)n=e;else{if(typeof e!=`string`||!e.startsWith(`=`))return()=>e;n=e.slice(1)}let r=typeof n==`string`?n:n.getExpression(),i=await t.watchFormula(n);if(!i)return null;let a=t.getCoords(),o=!1,s=this.getName();return e=>{let t=e.getPosition(),n;try{n=i.getValueAt(t.rowIndex-a.rowStart,t.colIndex-a.colStart)}catch(e){if(!V.isError(e))throw e;n=e}return V.isError(n)&&!o&&(o=!0,O.warn(`Condition operand '=${r}' resolves to ${n.getLabel()}; '${s}' matches nothing there.`,{onceKey:`condition.operand.error.${r}`,meta:{type:`condition`}})),n}}_isMissingOperand(e){return e==null||typeof e==`string`&&e.trim().length===0}_validateOperand(e,t,n=!1){if(n?e==null:this._isMissingOperand(e))return m(`condition.error.operandRequired`);if(e?.isIFormula)return e.isValid()?null:m(`condition.error.formulaInvalid`);if(typeof e==`string`&&e.startsWith(`=`)||!t||V.isError(e))return null;let r=t.getName(),i=Z.BuiltInSelectorNames,a=r===i.Date||r===i.DateTime||r===i.Time;return t.getSelectType()!==H.Number&&t.getSelectType()!==H.Date?null:typeof e==`number`?r!==i.Whole||Number.isInteger(e)?r===i.TextLength&&(!Number.isInteger(e)||e<0)?m(`condition.error.textLength`):r===i.Time&&(e<0||e>=1)?m(`condition.error.timeRequired`):a&&e<0?m(`condition.error.dateRequired`):null:m(`condition.error.wholeNumber`):r===i.Time?m(`condition.error.timeRequired`):m(a?`condition.error.dateRequired`:`condition.error.numberRequired`)}async _createComparePredicate(e,t,n){if(this._isMissingOperand(e))return null;let r=await this._resolveOperand(e,t);return r?(e,t)=>{let i=r(t);return!V.isError(i)&&n(e,i)}:null}_createDisplayComparePredicate(e,t,n,r){if(this._isMissingOperand(e))return null;if(typeof e!=`string`||e.startsWith(`=`))return this._createComparePredicate(e,t,r);let i=t.getLocaleProfile?.(),a=i?$l.collator(i):$l.collatorFor(`en-US`),o=Vt.isWildCard(e)?Vt.toRegex(e,`i`,!0):null,s=o?e.replace(/~([*?~])/g,`$1`):e;return e=>typeof e==`string`&&n(o?.test(e)?0:$l.compareTextWith(e,s,a))}_operandText(e,t){if(typeof e!=`number`||!t)return e;let n=Z.BuiltInSelectorNames;switch(t.getName()){case n.Date:return mt(`m/d/yyyy`,e);case n.Time:return mt(`h:mm:ss AM/PM`,e);case n.DateTime:return mt(`m/d/yyyy h:mm`,e);default:return e}}toString(e,t){let n=this.getTitle(),r=e;return r==null?n:N(`condition.operator.titleWithParam`,{title:n,param:this._operandText(r,t)})}},ag=()=>!1,og=!1,sg=()=>og,cg=0,lg=()=>cg,ug=()=>{cg++},dg=class{constructor(e,t,n){this.value=e,this.calls=t,this.direct=n,og=!0}get isAsyncValue(){return!0}},fg=e=>typeof e==`object`&&!!e&&!0===e.isAsyncValue,pg=e=>{if(typeof e!=`object`||!e||!0!==e.isAsyncValue)return e;let t=e;if(!t.direct)return t.value;let n=t.calls[0].latest;return n===void 0?t.value:n===null?0:n},mg=class e{constructor(e,t,n,r,i,a,o){this._groups=e,this._keyFn=t,this._compareFn=n,this._reverseBuild=r,this._visitedCount=i,this._totalCount=a,this._truncated=o}*getUniqueValues(){let e=this._groups,t=this._getValueOrderAscending();if(this._reverseBuild)for(let n=t.length-1;n>=0;n--)yield e.get(t[n]).value;else for(let n=0;n<t.length;n++)yield e.get(t[n]).value}getFrequency(e){return this._groups.get(this._keyFn(e))?.count??0}*getValueCounts(e){let t=this._groups,n=e?.sortBy??`frequency`,r=e?.descending??!0,i;if(n===`value`)i=this._getValueOrderAscending().slice(),r&&i.reverse();else{let e=r?-1:1;i=Array.from(t.keys()),i.sort((n,r)=>e*(t.get(n).count-t.get(r).count))}for(let e=0;e<i.length;e++){let n=t.get(i[e]);yield[n.value,n.count]}}getUniqueCount(){return this._groups.size}getVisitedCount(){return this._visitedCount}getTotalCount(){return this._totalCount}isTruncated(){return this._truncated}getExtent(e){let t=this._groups.get(this._keyFn(e))?.extent;return t?{...t}:null}_getValueOrderAscending(){let e=this._valueOrderAscending;if(!e){let t=this._groups,n=this._compareFn,r=Array.from(t.keys());r.sort((e,r)=>n(t.get(e).value,t.get(r).value)),e=Object.freeze(r),this._valueOrderAscending=e}return e}static fromGrid(t,n,r,i,a,o,s,c){let l=i?.keyFn??hg,u=i?.filterFn,d=i?.limit,f=new Map,p=0,m=!1;if(t.getCount()!==0){let e=t.getAxis()===B.Axis.Column,i=n.length,a=KB(r,e,c),o=a?.major??null,s=a?.minor??null,h=r?{..._g,...r}:_g,g=h.bounds;t:for(let r=0;r<i;r++){let i=n[r];if(!i)continue;let a=e?i.colStart:i.rowStart,c=e?i.rowStart:i.colStart,_=e?i.colEnd:i.rowEnd,v=e?i.rowEnd:i.colEnd;g.colStart=e?a:c,g.rowStart=e?c:a,g.colEnd=e?_:v,g.rowEnd=e?v:_;let y=t.getRuns(h),b=y.next();for(;!b.done;){let[t,n,r]=b.value;if(b=y.next(),o&&qB(o,t))continue;let i=r.length,a=Math.max(0,c-n),h=Math.min(i-1,v-n);if(!(a>h))for(let i=a;i<=h;i++){if(s){let e=JB(s,n+i)-n;if(e!==i){e>i&&(i=e-1);continue}}let a=pg(r.at(i));if(u&&!u(a))continue;let o=n+i,c=e?o:t,h=e?t:o,g=l(a),_=f.get(g);if(_){_.count++;let e=_.extent;c<e.rowStart?e.rowStart=c:c>e.rowEnd&&(e.rowEnd=c),h<e.colStart?e.colStart=h:h>e.colEnd&&(e.colEnd=h)}else{if(d!==void 0&&f.size>=d){m=!0;break t}f.set(g,{value:a,count:1,extent:{rowStart:c,colStart:h,rowEnd:c,colEnd:h}})}p++}}}}return o>0&&f.set(l(null),{value:null,count:o}),new e(f,l,i?.compareFn??a,i?.reverse??!1,p,s??p+o,m)}static fromGroups(t,n,r,i,a,o,s){return new e(t,n,r?.compareFn??i,r?.reverse??!1,a,o,s)}};function hg(e){if(e===null)return`\0`;let t=typeof e;return t===`number`?``+e.toString():t===`string`?``+Yl(e):t===`boolean`?``+(e?`1`:`0`):V.isError(e)?``+e.getCode():``+String(e)}var Q,gg,_g={bounds:{colStart:0,rowStart:0,colEnd:0,rowEnd:0},overflowRun:!0,reuseResult:!0};(gg=Q||={}).MAX_EXPRESSION_LENGTH=8192,gg.Status={Running:`running`,Error:`error`,Starting:`starting`,Stopping:`stopping`,Off:`off`},gg.CalculationState={Done:`done`,Calculating:`calculating`,Pending:`pending`},gg.CalculationMode={Automatic:`auto`,Manual:`manual`,AutomaticExceptTables:`automaticExceptTables`},gg.ResultStatus={Ready:`ready`,Stale:`stale`,Pending:`pending`,Waiting:`waiting`};var vg={Unparsed:`unparsed`,Paren:`paren`,Infix:`infix`,Prefix:`prefix`,Postfix:`postfix`,Function:`function`,Call:`call`,Error:`error`,Number:`number`,Boolean:`boolean`,String:`string`,Separator:`separator`,List:`list`,Type:`type`,Array:`array`,Row:`row`,Cell:`cell`,Named:`named`,Parameter:`parameter`,TableReference:`tableReference`,TableSpecifier:`tableSpecifier`,TableColumn:`tableColumn`,ExternalReference:`externalReference`,Empty:`empty`,Whitespace:`whitespace`},yg={separatorFunction:`,`,separatorColumn:`,`,separatorRow:`;`,separatorDecimal:`.`};function bg(e){return e===`,`?{separatorDecimal:`,`,separatorFunction:`;`,separatorColumn:`;`,separatorRow:`|`}:yg}var xg=[[`All`,`all`],[`Data`,`data`],[`Headers`,`headers`],[`Totals`,`totals`],[`This Row`,`thisRow`]];function Sg(e,t){let n=e.trim().toUpperCase();for(let[e,r]of xg)if(e.toUpperCase()===n||t?.[r]?.trim().toUpperCase()===n)return e}var Cg={separators:yg,booleanTrue:`TRUE`,booleanFalse:`FALSE`,errorLiterals:[],errorRefs:[],parseBoolean:e=>{let t=e.toUpperCase();return t===`TRUE`||t!==`FALSE`&&void 0},parseError:e=>V.getBuiltInByLabel(e.toUpperCase())??void 0,parseSpecifier:e=>Sg(e),localizeBoolean:e=>e?`TRUE`:`FALSE`,localizeError:e=>e?.getLabel?.()??String(e),localizeSpecifier:e=>e};function wg(e=yg,t){let n=fl(t),r=n?.booleans?.true??`TRUE`,i=n?.booleans?.false??`FALSE`,a=[],o=[],s=n?.errors;if(s)for(let e in s)(e===`Ref`||e===`Name`?o:a).push(s[e]);let c=n?.specifiers;return{separators:e,booleanTrue:r,booleanFalse:i,errorLiterals:a,errorRefs:o,specifiers:c,parseBoolean:e=>gl(e,t),parseError:e=>_l(e,t),parseSpecifier:e=>Sg(e,c),localizeBoolean:e=>e?r:i,localizeError:e=>hl(e,t),localizeSpecifier:e=>function(e,t){if(!t)return e;let n=e.trim().toUpperCase();for(let[r,i]of xg)if(r.toUpperCase()===n)return t[i]?.trim()||e;return e}(e,c)}}function Tg(e){let t=(e=e.toUpperCase()).length,n=0;for(let r=0;r<t;r++){let i=e.charCodeAt(r);isNaN(i)||(n+=(i-64)*26**(t-r-1))}return n}function Eg(e,t,n){let r=e.match(/([$]?)([A-Za-z]{1,3})([$]?)([0-9]+)/),i=Tg(r[2])-1,a=r[1].length===1,o=r[4]-1,s=r[3].length===1;return a||i===-(2**53-1)||(i-=n),s||o===-(2**53-1)||(o-=t),{type:vg.Cell,value:{colIndex:i,rowIndex:o,$colIndex:a,$rowIndex:s,scope:null},inputs:null,isReference:!0}}function Dg(e){return{type:vg.Cell,value:{colIndex:e.colIndex,rowIndex:e.rowIndex,$colIndex:e.$colIndex||!1,$rowIndex:e.$rowIndex||!1,scope:e.scope??null},inputs:null,isReference:!0}}function Og(e,t){let n=e.startsWith(`$`);n&&(e=e.substring(1));let r=Tg(e)-1;return n||r===-(2**53-1)||(r-=t),{type:vg.Cell,value:{colIndex:r,rowIndex:-(2**53-1),$colIndex:n,$rowIndex:!1,scope:null},inputs:null,isReference:!0}}function kg(e,t){let n=e.startsWith(`$`);n&&(e=e.substring(1));let r=parseInt(e)-1;return n||r===-(2**53-1)||(r-=t),{type:vg.Cell,value:{colIndex:-(2**53-1),$colIndex:!1,rowIndex:r,$rowIndex:n,scope:null},inputs:null,isReference:!0}}function Ag(e,t){return{type:vg.Function,value:e,inputs:t}}function jg(e,t){return{type:vg.Call,value:null,inputs:t&&t.length>0?[e,...t]:[e]}}function Mg(e){return e.inputs?.[0]}function Ng(e){let t=e.inputs;return t&&t.length>1?t.slice(1):[]}function Pg(e,t){return{type:vg.TableReference,value:e,inputs:t,isReference:!0}}function Fg(e,t=Cg){let n=e.startsWith(`[`)?e.slice(1,-1):e;if(n.startsWith(`#`)&&t.parseSpecifier){let e=t.parseSpecifier(n.slice(1));e&&(n=`#`+e)}return{type:vg.TableSpecifier,value:n,inputs:null,isReference:!0}}var Ig=[`All`,`Data`,`Headers`,`Totals`,`This Row`];function Lg(e,t,n,r){return e?1:t&&n?4:r&&n?5:t?2:r?3:0}var Rg=/['#[\]]/g,zg=/'(['#[\]])/g;function Bg(e){return e.replace(Rg,`'$&`)}function Vg(e){return e.indexOf(`'`)===-1?e:e.replace(zg,`$1`)}function Hg(e,t){let n=t;if(e.charCodeAt(n)===91){let t=e.indexOf(`]`,n+1);if(t===-1||e.charCodeAt(t+1)!==33)return null;n=t+2}let r=e.charCodeAt(n);if(!(r>=65&&r<=90||r>=97&&r<=122||r===95||r>=127&&r<=65535))return null;let i=n+1;for(;i<e.length;){let t=e.charCodeAt(i);if(!(t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||t===95||t===46||t>=127&&t<=65535))break;i++}if(i>=e.length||e.charCodeAt(i)!==91)return null;let a=0;for(;i<e.length;){let n=e.charCodeAt(i);if(n===39&&Ug(e,i))i+=2;else{if(n===91)a++;else if(n===93&&(a--,a===0))return[e.substring(t,i+1)];i++}}return null}function Ug(e,t){let n=e.charCodeAt(t+1);return n===91||n===93||n===35||n===39}function Wg(e,t){if(e.charCodeAt(t)!==91)return null;let n=0,r=t;for(;r<e.length;){let i=e.charCodeAt(r);if(i===39&&Ug(e,r))r+=2;else{if(i===91)n++;else if(i===93&&(n--,n===0))return[e.substring(t,r+1)];r++}}return null}function Gg(e){let t=e;return t=e.startsWith(`[`)&&e.endsWith(`]`)?Vg(e.slice(1,-1)):e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,-1).replace(/''/g,`'`):Vg(e),{type:vg.TableColumn,value:t,inputs:null,isReference:!0}}function Kg(e,t,n,r=!1){let i={type:vg.Infix,value:e,inputs:[t,n]};return r&&(i.isReference=!0),i}function qg(e,t,n=!1){let r={type:vg.Postfix,value:e,inputs:t?[t]:null};return n&&(r.isReference=!0),r}function Jg(e,t,n=!1){let r={type:vg.Prefix,value:e,inputs:t?[t]:null};return n&&(r.isReference=!0),r}function Yg(e,t){return{type:vg.Prefix,value:e,inputs:[t]}}function Xg(e){return{type:vg.Named,value:{nameId:e,scope:null},inputs:null,isReference:!0}}function Zg(e,t=Cg){let n=t.separators.separatorDecimal,r=e;n!==`.`&&(r=r.split(n).join(`.`)),r.includes(`**`)&&(r=r.replace(`**`,`e`));let i=Number(Ut.truncateNumberText(r));if(!(i>=-999999999999999e293&&i<=999999999999999e293&&Ut.isNumberTextInRange(r)))throw new V.Parse(`Number out of range: ${e}`);return{type:vg.Number,value:Ut.flushSubnormal(i),image:e,isLiteral:!0}}function Qg(e){return{type:vg.String,value:e.length>1?e.substring(1,e.length-1).replace(/""/g,`"`):e,isLiteral:!0}}function $g(e){return{type:vg.Array,value:[e],isLiteral:!0}}function e_(){return{type:vg.Row,value:[],isLiteral:!0}}function t_(e,t=Cg){return{type:vg.Boolean,value:t.parseBoolean(e)??!1,image:e,isLiteral:!0}}function n_(e,t=Cg){return{type:vg.Error,value:t.parseError(e)??V.getBuiltInByLabel(e.toUpperCase()),image:e,isLiteral:!0}}function r_(e,t=Cg,n){let r=e?t.parseError(e)??V.getBuiltInByLabel(e.toUpperCase()):V.BuiltIn.Ref;return{type:vg.Error,value:n?{error:r,scope:n}:{error:r},image:e,inputs:null,isReference:!0}}function i_(e){return V.isError(e)?e:e?.error}function a_(e){if(V.isError(e))return e.getLabel();let t=e;if(!t?.error)return;let n=t.error.getLabel();return t.scope?{error:n,scope:t.scope}:{error:n}}function o_(e){let t=typeof e==`string`?e:e?.error;return typeof t==`string`?V.getBuiltInByLabel(t):void 0}function s_(e){return e.indexOf(`#`)>0}function c_(){return{type:vg.Empty,value:void 0,isLiteral:!0}}function l_(e,t){return e&&function e(n,r,i=[]){let a=n.inputs,o;if(a){let t=a.length;for(let r=0;r<t;r++){let t=a[r];if(t===void 0)continue;i.push(n);let s=e(t,n,i);i.pop(),s!==void 0&&s!==t&&(o||=[...a],o[r]=s)}}let s=n;if(o&&(s={...n},s.inputs=o),s===void 0)return s;let c=t(s,r,i);return c===void 0?s:c}(e,void 0,[])}function u_(e,t){return t.wsBefore&&(e.wsBefore=t.wsBefore),t.wsAfter&&(e.wsAfter=t.wsAfter),t.image&&(e.image=t.image),e}var d_,f_=Object.freeze([[`^`],[`*`,`/`],[`+`,`-`],[`&`],[`<`,`>`,`=`,`<>`,`<=`,`>=`]]),p_=(Object.freeze([`:`,`.:.`,`.:`,`:.`]),Object.freeze([`:`,` `,`.:.`,`.:`,`:.`])),m_=Object.freeze([`@`]),h_=Object.freeze([`#`]),g_=(Object.freeze(p_.concat(h_)),Object.freeze(p_.concat(m_).concat(h_))),__=t(`sdk:formula-toolkit`,()=>e(()=>import(`./D2CxEHjkPQMAxzWl.js`),__vite__mapDeps([6,7,8,9,1,2,10,11,3,12,13,14]),import.meta.url));function v_(e,t,n){if(!n)return e;let r=d_.parse(e,{anchor:t});if(!r)return e;let i=d_.transform(r,n);return i===r?e:d_.image(i,{at:t})}function y_(e){let t=e.toUpperCase();return e=>{if(e.type!==`cell`)return;let n=e.value?.scope;if(typeof n!=`string`||(n.length>1&&n.startsWith(`'`)&&n.endsWith(`'`)?n.slice(1,-1).replace(/''/g,`'`):n).toUpperCase()!==t)return;let{scope:r,...i}=e.value;return{...e,value:i}}}function b_(e,t,n){if(e.getStatus()!==Q.Status.Running)return null;try{return e.createFormula(t,n??void 0)}catch{return null}}(function(e){function t(e,t){let n=__.peek();if(!n)throw Error(`FormulaText is not loaded; await FormulaText.load() first.`);return n.imager(e,t)}e.load=async function(){await __.load()},e.isLoaded=function(){return __.peek()!==void 0},e.parse=function(e,t){return __.peek()?.parse(e,t)??null},e.transform=function(e,t){return __.peek()?.transform(e,t)??e},e.structuredReference=function(e,t){return`${e}[${Bg(t)}]`},e.image=function(e,n){return t(e,n)(n?.at)},e.imager=t})(d_||={});var x_=class{constructor(e,t){this._host=null,this._binding=null,this._compiled=null,this._text=e.startsWith(`=`)?e.substring(1):e,this._marked=t}isMarked(){return this._marked}bind(e){this._binding=e}bindHost(e){!e&&this._host&&(this._text=this._readHost(this._host)??this._text),this._host=e}_readHost(e){let t=e.getView(),n=e.getCoords();if(!t||!n)return null;let r=this._binding?.getScope()??null,i=this._binding?.getAnchor()??null,a={rowIndex:i?.rowIndex??n.rowStart,colIndex:i?.colIndex??n.colStart};return v_(t.getTextAt(a.rowIndex,a.colIndex),a,this._readTransform(r))}_readTransform(e){return e?y_(e):void 0}getText(){let e=this._host;return(e?this._readHost(e):null)??this._text}_formula(){let e=this._binding?.getCalculation()??null;if(!e)return null;let t=this._binding.getAnchor(),n=this.getText(),r=`${t?.rowIndex??``}:${t?.colIndex??``}|${n}`;if(this._compiled?.key===r)return this._compiled.formula;let i=b_(e,n,t);return this._compiled=i?{key:r,formula:i}:null,i}evaluate(e){let t=this._formula();return t?t.evaluate(e):Promise.reject(Error(`A condition formula has no calculation to evaluate with.`))}getCalculationStatus(){return this._formula()?.getCalculationStatus()??Q.ResultStatus.Pending}isCompiled(){return this._formula()?.isCompiled()??!1}getExpression(e){return e&&(e.target===`display`||e.r1c1||e.cell||e.evalIndex!==void 0)?this._formula()?.getExpression(e)??this.getText():this.getText()}getAnchor(){return this._binding?.getAnchor()??null}shift(e){return this._formula()?.shift(e)??null}getReferences(){return this._formula()?.getReferences()??null}hasRefError(){return this._formula()?.hasRefError()??!1}setReferenceAt(e,t,n){return Promise.reject(Error(`A condition formula is changed by setting the condition.`))}setReferenceModeAt(e,t,n,r){return Promise.reject(Error(`A condition formula is changed by setting the condition.`))}isReferenceOnly(){return this._formula()?.isReferenceOnly()??!1}isVolatile(){return this._formula()?.isVolatile()??Promise.resolve(!1)}getTokens(e){return this._formula()?.getTokens(e)??[]}isValid(){return this._formula()?.isValid()??!0}autoCorrect(){return this._formula()?.autoCorrect()??null}toJSON(){let e=this.getText();return this._marked?`=`+e:e}toString(){let e=this.getExpression();return this._marked?`=`+e:e}get[Symbol.toStringTag](){return`[ConditionFormula]`}get isIFormula(){return!0}},S_=class extends x_{constructor(e){super(e,!1)}getCheckExpression(e){return this.isValid()?`ISNUMBER(MATCH(${Fd(e)},${this.getText()},0))`:`FALSE`}bindHost(e){e&&!this.isValid()||super.bindHost(e)}_readTransform(e){let t=e?y_(e):void 0;return(e,n)=>n?t?.(e,n):(e.inputs?.[0])?.inputs?.[1]||void 0}get[Symbol.toStringTag](){return`[ListSourceFormula]`}},C_=class{constructor(e){this._delegate=e,this._types=e.getAcceptsTypes?e.getAcceptsTypes():null,G_(e)&&(this.createDisplayPredicate=(t,n)=>e.createDisplayPredicate(t,n))}getName(){return this._delegate.getName()}createPredicate(e,t){return this._delegate.createPredicate(e,t)}getAcceptsTypes(){return this._types?this._types:null}getParamType(e){return e?e.getName():null}isCombinator(){return!1}getTitle(){return this._delegate.getTitle?.()}getDescription(){return this._delegate.getDescription?.()??null}createDefaultParam(e,t){return this._delegate.createDefaultParam?.(e,t)}validateParam(e,t){return this._delegate.validateParam?.(e,t)??null}doBatch(e,t,n){return this._delegate.doBatch?.(e,t,n)}toString(e,t){return this._delegate.toString?.(e,t)}get[Symbol.toStringTag](){return`[Condition]: ${this.getName()}`}};function w_(e){if(V.isError(e))return{t:`e`,v:e.getCode()};if(e instanceof x_)return e.toJSON();if(!e||typeof e!=`object`)return e;if(e.isICondition)return e.toJSON();if(Array.isArray(e)){let t=!1,n=e.map(e=>{let n=E_(e);return n!==e&&(t=!0),n});return t?n:e}if(typeof e.operator==`string`)return E_(e);if(e.source instanceof x_)return{...e,source:e.source.toJSON()};let t=T_(e.from),n=T_(e.to);return t!==e.from||n!==e.to?{...e,from:t,to:n}:e}function T_(e){return V.isError(e)?{t:`e`,v:e.getCode()}:e instanceof x_?e.toJSON():e}function E_(e){if(!e||typeof e!=`object`)return e;if(e.isICondition){let{includeBlanks:t,...n}=e.toJSON();return n}let t=w_(e.param);if(t===e.param&&e.includeBlanks===void 0)return e;let{includeBlanks:n,...r}=e;return{...r,param:t}}function D_(e){if(e&&typeof e==`object`&&e.t===`e`&&typeof e.v==`number`)return V.getBuiltInByCode(e.v)}var O_=new Set([Z.BuiltInOperatorNames.EqualTo,Z.BuiltInOperatorNames.GreaterThan,Z.BuiltInOperatorNames.GreaterThanEqualTo,Z.BuiltInOperatorNames.LessThan,Z.BuiltInOperatorNames.LessThanEqualTo,Z.BuiltInOperatorNames.After,Z.BuiltInOperatorNames.AfterEqualTo,Z.BuiltInOperatorNames.Before,Z.BuiltInOperatorNames.BeforeEqualTo]);function k_(e,t){let n=Z.BuiltInOperatorNames;switch(e){case n.Expression:return N_(t,!1)??t;case n.Between:{if(!t||typeof t!=`object`||Array.isArray(t))return t;let e=N_(t.from,!0)??t.from,n=N_(t.to,!0)??t.to;return e===t.from&&n===t.to?t:{...t,from:e,to:n}}case n.InSet:{let e=j_(t),n=e?.source;if(n==null||n instanceof S_)return e;let r=A_(n);if(typeof r!=`string`||!r.trim()){let{source:t,...n}=e;return n}return{...e,source:new S_(r)}}case n.Not:return M_(t);case n.And:case n.Or:return Array.isArray(t)?t.map(M_):t;default:return e&&O_.has(e)?N_(t,!0)??t:t}}function A_(e){return e instanceof x_?e.getText():e?.isIFormula?e.getExpression():e}function j_(e){if(typeof e==`string`&&(e={items:e}),!e||typeof e!=`object`)return e;if(e.byDisplay!==void 0){let{byDisplay:t,...n}=e;e=n}let t=e.items;if(t===void 0||Array.isArray(t))return e;let{items:n,...r}=e,i=A_(t);if(typeof i!=`string`||!i.trim())return r;let a=P_(i);return a?r.additions=r.additions?[...a,...r.additions]:a:r.source!==void 0&&r.source!==null||(r.source=t),r}function M_(e){if(!e||typeof e!=`object`||e.isICondition)return e;let t=e.operator,n=k_(typeof t==`string`?t:t?.getName?.(),e.param);return n===e.param?e:{...e,param:n}}function N_(e,t){return e instanceof x_?e.isMarked()===t?e:new x_(e.getText(),t):e?.isIFormula?new x_(e.getExpression(),t):typeof e==`string`?t?e.startsWith(`=`)?new x_(e,!0):null:new x_(e,!1):null}function P_(e){if(!function(e){let t=e.trim();if(t.length<2||t[0]!==`"`||t[t.length-1]!==`"`)return!1;let n=t.slice(1,-1);for(let e=0;e<n.length;e++)if(n[e]===`"`){if(n[e+1]!==`"`)return!1;e++}return!0}(e))return null;let t=e.trim().slice(1,-1).replace(/""/g,`"`);return t===``?[]:t.split(`,`)}function F_(e){for(let t=0;t<e.length;t++)if(e[t].includes(`,`))return null;return`"`+e.join(`,`).replace(/"/g,`""`)+`"`}function I_(e,t){e&&L_(e.getParam(),t)}function L_(e,t){if(e&&typeof e==`object`){if(e instanceof x_)t(e);else if(Array.isArray(e))for(let n=0;n<e.length;n++)L_(e[n],t);else e.isICondition?L_(e.getParam(),t):e.operator===void 0?(L_(e.source,t),L_(e.from,t),L_(e.to,t)):L_(e.param,t)}}var R_=new Map([[`list`,Z.BuiltInOperatorNames.InSet]]);function z_(e){if(!e)return null;if(e.isICondition)return e;if(typeof e==`function`){let t=e;return new Nv(null,new C_({getName:()=>`Predicate`,createPredicate:e=>t}))}if(typeof e==`string`){let t=e.trim(),n=/^(<=|>=|<>|=|<|>)(.*)$/i.exec(t);if(n){let[,e,t]=n,r=t.trim(),i=r===``?NaN:Number(r),a=Number.isFinite(i)?i:r.startsWith(`=`)?new x_(r,!0):r,o={"<":Z.BuiltInOperatorNames.LessThan,"<=":Z.BuiltInOperatorNames.LessThanEqualTo,">":Z.BuiltInOperatorNames.GreaterThan,">=":Z.BuiltInOperatorNames.GreaterThanEqualTo,"=":Z.BuiltInOperatorNames.EqualTo},s=e===`<>`,c=s?Z.BuiltInOperatorNames.Not:o[e],l=Nv.Operators.get(c);if(!l)throw Error(`Unknown operator for shorthand: ${e}`);return new Nv(null,l,s?{operator:Z.BuiltInOperatorNames.EqualTo,param:a}:a)}}if(typeof e==`object`){let t,n={...e},r=null,i=n.selector;if(i){if(typeof i==`string`){if(r=Nv.Selectors.get(i)??null,!r&&(t=R_.get(i.toLowerCase()),!t))throw Error(`Unknown selector name: ${i}`)}else r=i}let a=n.operator??t,o=n.param;if(!i){let e=function(e,t){if(e===`displayEqualTo`&&!Nv.Operators.get(`displayEqualTo`))return{selector:Z.BuiltInSelectorNames.Display,operator:Z.BuiltInOperatorNames.EqualTo,param:t};let n=typeof e==`string`?e:e?.getName?.();if(n!==Z.BuiltInOperatorNames.InSet&&n!==Z.BuiltInOperatorNames.Blank||!t||typeof t!=`object`||!0!==t.byDisplay)return null;let{byDisplay:r,...i}=t;return{selector:Z.BuiltInSelectorNames.Display,param:Object.keys(i).length>0?i:void 0}}(a,o);e&&(r=Nv.Selectors.get(e.selector)??null,e.operator!==void 0&&(a=e.operator),`param`in e&&(o=e.param))}if(typeof a==`function`&&(a=a()),typeof a==`string`){let e=Nv.Operators.get(a);if(!e)throw Error(`Unknown operator name: ${a}`);a=e}let s=n.includeBlanks,c=k_(a?.getName?.(),function(e){let t=D_(e);if(t)return t;if(!e||typeof e!=`object`||Array.isArray(e))return e;let n=D_(e.from),r=D_(e.to);return n||r?{...e,from:n??e.from,to:r??e.to}:e}(o));if(a||r||s!==void 0)return new Nv(r,a,c,s)}return null}var B_=class{constructor(e,t){this._resolved=null,this._json={...e},this._reason=t}resolve(){let e=this._resolved;if(e)return e;try{e=z_(this._json)}catch(e){return this._reason=e?.message??this._reason,null}return this._resolved=e,e}getUnresolvedReason(){return this._reason}getSelector(){return this.resolve()?.getSelector()??null}getOperator(){return this.resolve()?.getOperator()??null}getParam(){return this._json.param??null}isIncludeBlanks(){return this._json.includeBlanks??!1}validate(){return this.resolve()?.validate()??null}toString(){return this.resolve()?.toString()??this._reason}toJSON(){let e=this._resolved;return e?e.toJSON():{...this._json}}get isICondition(){return!0}};function V_(e){if(!e)return null;try{return z_(e)}catch(t){let n=t?.message??`Unresolvable condition.`;return O.debug(`Condition kept unresolved: ${n}`,{onceKey:`condition.unresolved.${n}`,meta:{type:`condition`}}),new B_(e,n)}}function H_(e){return e.getOperator()?.getName()===Z.BuiltInOperatorNames.Expression||U_(e.getParam())}function U_(e){return!!e?.isIFormula||(typeof e==`string`?e.startsWith(`=`):!(!e||typeof e!=`object`)&&(Array.isArray(e)?e.some(W_):e.isICondition||e.operator!==void 0?W_(e):!(!e.from?.isIFormula&&!e.to?.isIFormula)||!(typeof e.from!=`string`||!e.from.startsWith(`=`))||!(typeof e.to!=`string`||!e.to.startsWith(`=`))))}function W_(e){if(!e||typeof e!=`object`)return!1;if(e.isICondition)return H_(e);let t=e.operator;return(typeof t==`string`?t:t?.getName?.())===Z.BuiltInOperatorNames.Expression||U_(e.param)}var G_=e=>typeof e?.createDisplayPredicate==`function`,K_=e=>e.getSelector()?.getName()===Z.BuiltInSelectorNames.Display&&G_(e.getOperator());function q_(e,t){let n=e.getOperator();return n?K_(e)?n.createDisplayPredicate(e.getParam(),t):n.createPredicate(e.getParam(),t):null}function J_(e,t,n){return t!==null&&e?e(t,n):t}function Y_(e){if(e===null)return!0;if(typeof e!=`string`)return!1;for(let t=0;t<e.length;t++)if(e.charCodeAt(t)!==32)return!1;return!0}function X_(e){return e===null||e===``}function Z_(e){return function(e){return typeof e==`string`?e:e?.getName?.()??null}(e)===Z.BuiltInSelectorNames.Display}function Q_(e){let t=e=>{if(!e||typeof e!=`object`)return!1;if(Array.isArray(e))return e.some(t);let n=e.isICondition?e.toJSON():e;if(Z_(n.selector))return!0;let r=n.operator,i=n.param;return r===`displayEqualTo`||(r===Z.BuiltInOperatorNames.InSet||r===Z.BuiltInOperatorNames.Blank?!0===i?.byDisplay:(r===Z.BuiltInOperatorNames.Not||r===Z.BuiltInOperatorNames.And||r===Z.BuiltInOperatorNames.Or)&&t(i))};return t(e)}async function $_(e,t){let n=t.coords,r=t.values,i=t.cellValuesOptions,a=r.entries(i),o={position:null,value:null},s=new sv(t.runtime,o,t.values,n,t.calculation??null,t.visibleCoords);s.setWatchFormula(t.watchFormula??null);let c=await ev(e,s,o,t.getDisplayText??null);if(!c)return;let{judge:l,resolveBlank:u,settleDeferred:d}=c,f=t.onBlank;f&&f(u);let p=t.onTrue,m=t.onFalse,h=t.onBlankValue,g=t.blankRule===`value`?X_:Y_,_=[],v=a.next();for(;!v.done;){let e=v.value;v=a.next();let t=e[1],n=e[0];if(h&&g(t)){h(n,t,u);continue}let r=l(n,t);r===null?_.push([n,t]):r?p&&p(n,t):m&&m(n,t)}if(_.length>0){let e=await d();for(let[t,n]of _)e(t)?p&&p(t,n):m&&m(t,n)}}async function ev(e,t,n,r){let i=e.getSelector()?.getName()??null;i!==null&&i!==Z.BuiltInSelectorNames.Display||t.setGetDisplayText(r);let a=e.getSelector(),o=a?await a.createTransformer(t):null,s=a?.getInputType()??null,c=a?.getSelectType()??null,l=e.getOperator(),u=K_(e)?null:l?.getAcceptsTypes?.()??null,d=await q_(e,t);if(!d)return null;t.setBatchCapable(typeof l?.doBatch==`function`);let f=e.isIncludeBlanks(),p={rowIndex:0,colIndex:0};return{judge:(e,r)=>{if(s!==null&&(i=s,a=pB(r),i!==a&&(i!==H.Date||a!==H.Number)))return!1;var i,a;n.position=e,n.value=r,t.beginPredicateCall();let l=o?o(r,t):r;if(l===Z.NotApplicable)return!1;let f=l;if(u!==null){let e=c??pB(f);if(!u.includes(e))return!1}let p=d(f,t);return t.wasDeferred()?null:!0===p},resolveBlank:(e,r)=>{if(f)return!0;p.rowIndex=e,p.colIndex=r,n.position=p,n.value=null,t.beginPredicateCall();let i=d(null,t);return!t.wasDeferred()&&!0===i},settleDeferred:async()=>{let n=await l.doBatch(t.getDeferredKeys(),e.getParam(),t),r=t.getCoords();return e=>{let t;try{t=n?.getValueAt(e.rowIndex-r.rowStart,e.colIndex-r.colStart)??null}catch(e){if(!V.isError(e))throw e;t=e}return!V.isError(t)&&!!t}}}}function tv(e){return Math.floor(Dt(new Date(e.getNow()),e.isDate1904()))}function nv(e,t){let n=e,r=n?.param;return n?.operator===Z.BuiltInOperatorNames.TimePeriod&&r?.type?/^[QM]\d{1,2}$/.test(r.type)||r.anchorDate===t?e:{...n,param:{...r,anchorDate:t}}:e}async function rv(e){let t=e.coords,n={bounds:t,axis:e.axis??B.Axis.Column},r=e.getHiddenRuns;if(r){let t=e.includeHidden;!0!==t&&t!==B.Axis.Row&&(n.processRowSkip=_o(r(B.Axis.Row))),!0!==t&&t!==B.Axis.Column&&(n.processColumnSkip=_o(r(B.Axis.Column)))}let i=e.conditions[0];if(!i)return;let a=Nv.resolveInput(i);if(!a)return void O.debug(`No condition to evaluate.`,{onceKey:`condition.none`,meta:{type:`condition`}});let o=e.calculation;if(o&&H_(a)){let e=o._whenCanCompile;e?await e.call(o):await o.ready()}await $_(a,{runtime:e.runtime,values:e.values,coords:t,cellValuesOptions:n,calculation:e.calculation,watchFormula:e.watchFormula,onTrue:e.onTrue,onFalse:e.onFalse,onBlank:e.onBlank,onBlankValue:e.spacesAreBlank?(t,n,r)=>{let i=r(t.rowIndex,t.colIndex)?e.onTrue:e.onFalse;i&&i(t,n)}:void 0})}function iv(e){return e?function(e){let t=e.conditions;if(!t)return e;let n=null;for(let e=0;e<t.length;e++){let r=t[e];if(!r||typeof r!=`object`)continue;let i=r.isICondition?r.toJSON():r;if(i.operator!==Z.BuiltInOperatorNames.InSet)continue;let a=i.param;if(!a)continue;let o=e=>typeof e==`string`&&Y_(e),s=Array.isArray(a.items)?a.items:null;(Z_(i.selector)||!0===a.byDisplay)&&s&&s.some(o)&&(n||=t.slice(),n[e]={...r.isICondition?{index:r.index}:r,...i,param:{...a,items:s.filter(e=>!o(e)),blank:!0}})}return n?{...e,conditions:n}:e}(typeof e==`object`&&Array.isArray(e.conditions)?e:{conditions:[e]}):{conditions:[]}}function av(e,t,n){if(t>n)return[];let r=so(e.map(e=>({min:e.min,max:e.max,value:!0}))),i=[];return po(r,e=>{!0!==e.value&&i.push({min:e.min,max:e.max})},t,n),i}function ov(...e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(let e=0;e<r.length;e++)t.push({min:r[e].min,max:r[e].max})}return t.length===0?[]:ao(oo(so(t)))}var sv=class{constructor(e,t,n,r,i=null,a,o){this._coords=null,this._values=null,this._range=null,this._watchFormula=null,this._getDisplayText=null,this._text=null,this._textRead=!1,this._batchCapable=!1,this._deferredCall=!1,this._deferredKeys=null,this._anchor=o??{rowIndex:r.rowStart,colIndex:r.colStart},this._runtime=e,this._scope=t,this._values=n,this._coords=Object.freeze(r),this._calculation=i,this._visibleCoords=a}setBatchCapable(e){this._batchCapable=e,this._deferredKeys=null}beginPredicateCall(){this._deferredCall=!1,this._textRead=!1}wasDeferred(){return this._deferredCall}getDeferredKeys(){return this._deferredKeys??new Set}getLocaleProfile(){return this._runtime.getLocaleProfile()}getType(e){return pB(e)}getPosition(){return this._scope.position}getValue(){return this._scope.value}getCoords(){return this._coords}getRange(){let e=this._range;if(!e){let t=this._visibleCoords;e=t?new RV(this._runtime,this._values,this._coords,t):new LV(this._runtime,this._values,this._coords),this._range=e}return e}toType(e,t){return OB(this._runtime,e,pB(e),t,!1)}setGetDisplayText(e){this._getDisplayText=e}getDisplayText(){let e=this._getDisplayText;if(!e)return null;if(!this._textRead){let t=this._scope,n=t.position;this._text=e(n.rowIndex,n.colIndex,t.value),this._textRead=!0}return this._text}async resolveInput(e){return Nv.resolveInput(e)}fromSerialDate(e){return he(e,this._runtime.isDate1904())}getDateParts(e,t){return Te(e,this._runtime.isDate1904(),t)}toSerialDate(e){return Dt(e,this._runtime.isDate1904())}getNow(){return Dt(new Date(this._runtime.getNow()),this._runtime.isDate1904())}deferBatch(e){if(!this._batchCapable)throw Error(`ICondition.IContext.deferBatch was called but the active operator does not implement doBatch.`);this._deferredCall=!0,(this._deferredKeys??=new Set).add(e)}setWatchFormula(e){this._watchFormula=e}async watchFormula(e){let t=typeof e==`string`?e:e.getExpression();if(!t||!t.trim())return null;let n=this._watchFormula;if(n){let t=n(e);if(t!==void 0)return t}let r=typeof e==`string`?this.createFormula(e):this._createStored(e instanceof S_?e.getCheckExpression(this._anchor):t);if(!r)return null;let i={rowIndex:this._coords.rowStart,colIndex:this._coords.colStart},a=i.rowIndex===this._anchor.rowIndex&&i.colIndex===this._anchor.colIndex?r:r.shift(i);return a?await a.evaluate({block:this._coords,arrayFirstCell:!0,alwaysReturnRange:!0}):null}createFormula(e,t){return this._calculation?this._calculation.createFormula(e,t??this._anchor):null}_createStored(e){return this._calculation?b_(this._calculation,e,this._anchor):null}},cv=()=>!1,lv=(e,t)=>{let n=[],r=Array.isArray(e.items)?e.items:null;if(r)for(let e=0;e<r.length;e++)n.push(r[e]);if(t)for(let e=0;e<t.length;e++)n.push(t[e]);let i=e.additions;if(i)for(let e=0;e<i.length;e++)n.push(i[e]);let a=e.subtractions;if(!a||a.length===0)return n;let o=new Set(a.map(hg));return n.filter(e=>!o.has(hg(e)))},uv=(e,t,n,r,i)=>{let a=r!==null&&!t&&!n,o=i!==null&&i.has(hg(null));return(s,c)=>s===null||s===``?!o&&(a?!(s!==null||!e)||r(s,c):e):!!(t?.(s,c)||n?.(s,c)||r?.(s,c))&&(i===null||!i.has(hg(s)))},dv=(e,t)=>{let n=Array.isArray(e.items)?e.items:[],r=e.dateGroups??[],i=r.length;if(n.length===0&&i===0)return null;let a=n.length>0?new Set(n.map(hg)):void 0,o=i>0?{year:0,month:0,day:0,hour:0,minute:0,second:0,millis:0,dow:0,serial:0}:void 0;return(e,n)=>{if(a?.has(hg(e)))return!0;if(i>0){let e=n.getValue();if(typeof e!=`number`)return!1;let a=t.getDateParts(e,o);for(let e=0;e<i;e++)if(mv(a,r[e]))return!0}return!1}},fv=async(e,t)=>{let n=await t.watchFormula(e);if(!n)return null;let r=t.getCoords();return(e,t)=>{let i=t.getPosition();return!0===n.getValueAt(i.rowIndex-r.rowStart,i.colIndex-r.colStart)}},pv=(e,t)=>{if(!e||e.length===0)return null;let n=function(e){let t=new Set;for(let n=0;n<e.length;n++)t.add(e[n].replace(/^ +/,``));return e=>t.has(e.replace(/^ +| +$/g,``))}(e);return e=>{if(V.isError(e))return!1;let r=typeof e==`string`?e:t.toType(e,H.String);return typeof r==`string`&&n(r)}},mv=(e,t)=>(t.year===void 0||t.year===e.year)&&(t.month===void 0||t.month===e.month)&&(t.day===void 0||t.day===e.day)&&(t.hour===void 0||t.hour===e.hour)&&(t.minute===void 0||t.minute===e.minute)&&(t.second===void 0||t.second===e.second),hv=(e,t,n)=>{let r=e.getSortedNumbers(),i=e.getAggregates().numericalCount??0,a=0;for(let e=1;e<=i;e++){let i=t?r.getLarge(e):r.getSmall(e);if(i===null)break;if(a+=i,a>=n)return t?e=>e>=i:e=>e<=i}return _v},gv=()=>!1,_v=()=>!0,vv={Blank:new class extends ig{constructor(e){super({name:Z.BuiltInOperatorNames.Blank,title:m(`condition.operator.blank.title`),acceptTypes:[H.Null],paramType:null,...e})}createPredicate(e,t){return e=>e===null}},Error:new class extends ig{constructor(e){super({name:Z.BuiltInOperatorNames.Error,title:m(`condition.operator.error.title`),acceptTypes:[H.Error],paramType:null,...e})}createPredicate(e,t){return e=>e&&V.isError(e)}},Average:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.Average,title:m(`condition.operator.average.title`),acceptTypes:[H.Number],paramType:`average`,description:m(`condition.operator.average.desc`)})}async createPredicate(e,t){let n=t.getRange().getStats().getAggregates(),r=n.average,i=n.stdDev;if(r==null)return ag;let a=Z.AverageType.Above,o=e.type??a,s=e.stdDevs??0,c=s!==0&&i!=null?r+s*i*(o===a?1:-1):r;if(o===a||o===Z.AverageType.AboveOrEqual){let e=o===Z.AverageType.AboveOrEqual;return t=>e?t>=c:t>c}{let e=o===Z.AverageType.BelowOrEqual;return t=>e?t<=c:t<c}}validateParam(e,t){let n=e?.stdDevs??0;return Number.isInteger(n)&&n>=0?null:m(`condition.error.stdDevs`)}createDefaultParam(e){return{type:Z.AverageType.Above,stdDevs:0}}toString(e,t){let n={...this.createDefaultParam(t),...e},r=n.type===Z.AverageType.Above||n.type===Z.AverageType.AboveOrEqual,i=n.type===Z.AverageType.AboveOrEqual||n.type===Z.AverageType.BelowOrEqual;return N(`condition.operator.average.toString`,{dir:r?`above`:`below`,eq:i?`yes`:`no`,stdDevs:n.stdDevs??0})}},Between:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.Between,title:m(`condition.operator.between.title`),acceptTypes:[H.Number,H.Date],paramType:`between`,description:m(`condition.operator.between.desc`)})}async createPredicate(e,t){if(this._isMissingOperand(e?.from)||this._isMissingOperand(e?.to))return null;let n=await this._resolveOperand(e.from,t),r=await this._resolveOperand(e.to,t);return n&&r?(e,t)=>{let i=n(t),a=r(t);return V.isError(i)||V.isError(a)?!1:e>=(i??0)&&e<=(a??0)}:null}createDefaultParam(e){return{from:null,to:null}}validateParam(e,t){let n=e?.from,r=e?.to;return this._isMissingOperand(n)||this._isMissingOperand(r)?m(`condition.error.boundsRequired`):(this._validateOperand(n,t)??this._validateOperand(r,t))||(typeof n==`number`&&typeof r==`number`&&n>r?m(`condition.error.boundsReversed`):null)}toString(e,t){let n=this._isMissingOperand(e?.from),r=this._isMissingOperand(e?.to);return n&&r?this.getTitle():N(`condition.operator.between.toString`,{from:n?`…`:this._operandText(e.from,t),to:r?`…`:this._operandText(e.to,t)})}},EqualTo:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.EqualTo,acceptTypes:[H.String,H.Number,H.Date,H.Boolean],title:m(`condition.operator.equalTo.title`)})}async createPredicate(e,t){if(!(e?.isIFormula||typeof e==`string`&&e.startsWith(`=`))){if(typeof e==`string`){let t=Xl(e);return e=>e===null?t===``:typeof e==`string`&&Xl(e)===t}return t=>t===e||t===null&&e===0}let n=await this._resolveOperand(e,t);return n?(e,t)=>{let r=n(t);return!V.isError(r)&&(typeof r==`string`?e===null?r===``:typeof e==`string`&&Xl(e)===Xl(r):e===r||e===null&&r===0)}:null}validateParam(e,t){return this._validateOperand(e,t,!0)}createDefaultParam(e){return e?e.getSelectType()===H.String?``:e.getSelectType()===H.Number?null:e.getSelectType()===H.Boolean||(e.getSelectType()===H.Date?null:void 0):null}},GreaterThan:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.GreaterThan,acceptTypes:[H.Number],title:m(`condition.operator.greaterThan.title`)})}createPredicate(e,t){return this._createComparePredicate(e,t,(e,t)=>e>t)}createDisplayPredicate(e,t){return this._createDisplayComparePredicate(e,t,e=>e>0,(e,t)=>e>t)}validateParam(e,t){return this._validateOperand(e,t)}},GreaterThanEqualTo:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.GreaterThanEqualTo,acceptTypes:[H.Number],title:m(`condition.operator.greaterThanEqualTo.title`)})}createPredicate(e,t){return this._createComparePredicate(e,t,(e,t)=>e>=t)}createDisplayPredicate(e,t){return this._createDisplayComparePredicate(e,t,e=>e>=0,(e,t)=>e>=t)}validateParam(e,t){return this._validateOperand(e,t)}},LessThan:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.LessThan,acceptTypes:[H.Number],title:m(`condition.operator.lessThan.title`)})}createPredicate(e,t){return this._createComparePredicate(e,t,(e,t)=>e<t)}createDisplayPredicate(e,t){return this._createDisplayComparePredicate(e,t,e=>e<0,(e,t)=>e<t)}validateParam(e,t){return this._validateOperand(e,t)}},LessThanEqualTo:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.LessThanEqualTo,acceptTypes:[H.Number],title:m(`condition.operator.lessThanEqualTo.title`)})}createPredicate(e,t){return this._createComparePredicate(e,t,(e,t)=>e<=t)}createDisplayPredicate(e,t){return this._createDisplayComparePredicate(e,t,e=>e<=0,(e,t)=>e<=t)}validateParam(e,t){return this._validateOperand(e,t)}},After:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.After,acceptTypes:[H.Date],title:m(`condition.operator.after.title`)})}createPredicate(e,t){return this._createComparePredicate(e,t,(e,t)=>e>t)}validateParam(e,t){return this._validateOperand(e,t)}},AfterOrEqualTo:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.AfterEqualTo,acceptTypes:[H.Date],title:m(`condition.operator.afterEqualTo.title`)})}createPredicate(e,t){return this._createComparePredicate(e,t,(e,t)=>e>=t)}validateParam(e,t){return this._validateOperand(e,t)}},Before:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.Before,acceptTypes:[H.Date],title:m(`condition.operator.before.title`)})}createPredicate(e,t){return this._createComparePredicate(e,t,(e,t)=>e<t)}validateParam(e,t){return this._validateOperand(e,t)}},BeforeOrEqualTo:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.BeforeEqualTo,acceptTypes:[H.Date],title:m(`condition.operator.beforeEqualTo.title`)})}createPredicate(e,t){return this._createComparePredicate(e,t,(e,t)=>e<=t)}validateParam(e,t){return this._validateOperand(e,t)}},Unique:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.Unique,title:m(`condition.operator.unique.title`),paramType:null,acceptTypes:null,description:m(`condition.operator.unique.desc`)})}async createPredicate(e,t){let n=t.getRange().getStats().getFrequencies();return e=>n.getFrequency(e)===1}},Expression:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.Expression,title:m(`condition.operator.expression.title`),paramType:Z.BuiltInOperatorNames.Expression,description:m(`condition.operator.expression.desc`)})}validateParam(e,t){if(e?.isIFormula){let t=e;return t.getExpression().trim().length===0?m(`condition.error.formulaRequired`):t.isValid()?null:m(`condition.error.formulaInvalid`)}return typeof e!=`string`||e.trim().length===0?m(`condition.error.formulaRequired`):null}createDefaultParam(e){return``}async createPredicate(e,t){let n=await t.watchFormula(e);if(!n)return null;let r=t.getCoords();return(e,t)=>{let i=t.getPosition(),a=n.getValueAt(i.rowIndex-r.rowStart,i.colIndex-r.colStart);return!0===a||typeof a==`number`&&a!==0}}},InSet:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.InSet,title:m(`condition.operator.inSet.title`),description:m(`condition.operator.inSet.desc`),paramType:Z.BuiltInOperatorNames.InSet})}createPredicate(e,t){let n=j_(e)??{},r=n.blank??!1,i=dv(n,t),a=pv(n.additions,t),o=(n.subtractions?.length??0)>0?new Set(n.subtractions.map(hg)):null,s=n.source;return s instanceof S_?fv(s,t).then(e=>e?uv(r,i,a,e,o):null):i||a||r?uv(r,i,a,null,o):cv}validateParam(e,t){let n=j_(e)??null,r=n?.source;return r instanceof S_?r.isValid()?null:m(`condition.error.formulaInvalid`):typeof r==`string`&&r.trim().length>0||(n?.additions?.length??0)>0||(n?.items?.length??0)>0||(n?.dateGroups?.length??0)>0||n?.blank?null:m(`condition.error.listRequired`)}getCandidates(e,t){let n=j_(e)??{},r=n.source;if(!(t&&r instanceof S_))return lv(n,null);let i=t.getPosition(),a=t.createFormula(r.getText(),i);return a?a.evaluate({alwaysReturnRange:!0}).then(e=>{let t=[];if(e?.isIRange)for(let n of e.entries({axis:B.Axis.Row})){let e=n.value;e===null||e===``||V.isError(e)||t.push(e)}return lv(n,t)},()=>lv(n,null)):lv(n,null)}createDefaultParam(e,t){let n=t?.ranges;if(!n||n.isInvalid())return{items:[]};let r=n.getStats().getFrequencies({limit:65,filterFn:e=>typeof e==`string`&&e!==``||typeof e==`number`||typeof e==`boolean`});if(r.isTruncated()||r.getUniqueCount()>64)return{items:[]};let i=[];for(let[e]of r.getValueCounts({sortBy:`value`,descending:!1}))i.push(e);return{items:i}}toString(e,t){let n=this.getTitle(),r=j_(e)??{},i=r.source;if(i!=null){let e=typeof i==`string`?i:i.getExpression();return N(`condition.operator.titleWithParam`,{title:n,param:e})}let a=r.items?.length??0,o=r.additions??[];if(a===0&&o.length>0)return N(`condition.operator.titleWithParam`,{title:n,param:o.join(`, `)});let s=r.dateGroups?.length??0;return a===0&&s>0?N(`condition.operator.inSet.dateGroups`,{title:n,count:s}):N(`condition.operator.inSet.items`,{title:n,count:a+o.length})}},Icon:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.Icon,title:m(`condition.operator.icon.title`),description:m(`condition.operator.icon.desc`)})}createPredicate(e,t){throw new k(N(`error.condition.unsupportedOperator`,{operator:this.getName()}))}},Color:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.Color,title:m(`condition.operator.color.title`),description:m(`condition.operator.color.desc`)})}createPredicate(e,t){throw new k(N(`error.condition.unsupportedOperator`,{operator:this.getName()}))}},TextStartsWith:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.TextStartsWith,acceptTypes:[H.String],title:m(`condition.operator.textStartsWith.title`)})}createPredicate(e,t){let n=Xl(e);return e=>typeof e==`string`&&Xl(e).startsWith(n)}validateParam(e,t){return typeof e==`string`&&e.length>0?null:m(`condition.error.textRequired`)}},TextEndsWith:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.TextEndsWith,acceptTypes:[H.String],title:m(`condition.operator.textEndsWith.title`)})}createPredicate(e,t){let n=Xl(e);return e=>typeof e==`string`&&Xl(e).endsWith(n)}validateParam(e,t){return typeof e==`string`&&e.length>0?null:m(`condition.error.textRequired`)}},TextContains:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.TextContains,acceptTypes:[H.String],title:m(`condition.operator.textContains.title`)})}createPredicate(e,t){let n=Xl(e);return e=>typeof e==`string`&&Xl(e).includes(n)}validateParam(e,t){return typeof e==`string`&&e.length>0?null:m(`condition.error.textRequired`)}},TextMatches:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.TextMatches,acceptTypes:[H.String],title:m(`condition.operator.textMatches.title`)})}createPredicate(e,t){let n=Vt.toRegex(Xl(e),void 0,!0);return e=>typeof e==`string`&&n.test(Xl(e))}validateParam(e,t){return typeof e==`string`&&e.length>0?null:m(`condition.error.textRequired`)}},TextEmail:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.TextEmail,acceptTypes:[H.String],paramType:null,title:m(`condition.operator.textEmail.title`)})}createPredicate(e,t){return e=>typeof e==`string`&&yn(e)}},TextIsUrl:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.TextIsUrl,acceptTypes:[H.String],paramType:null,title:m(`condition.operator.textIsUrl.title`)})}createPredicate(e,t){return e=>typeof e==`string`&&_n(e)}},TimePeriod:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.TimePeriod,acceptTypes:[H.Date,H.Number],title:m(`condition.operator.timePeriod.title`),paramType:`timePeriod`,description:m(`condition.operator.timePeriod.desc`)})}async createPredicate(e,t){let n=this._monthsOf(e.type);if(n)return e=>typeof e==`number`&&n.has(t.fromSerialDate(Math.floor(e)).getMonth());let{min:r,max:i}=this._computeRange(e,t);return e=>{if(typeof e!=`number`)return!1;let t=Math.floor(e);return t>=r&&t<=i}}validateParam(e,t){let n=e?.type,r=Object.values(Z.TimePeriodType);return n&&r.includes(n)?null:m(`condition.error.periodRequired`)}createDefaultParam(e){return{type:Z.TimePeriodType.Today}}toString(e,t){let n={...this.createDefaultParam(t),...e};return N(`condition.operator.timePeriod.toString`,{title:this.getTitle(),period:i.camelToPrettyCase(n.type)})}_computeRange(e,t){let n=e.type??Z.TimePeriodType.Today,r=e.anchorDate??t.getNow(),i=Math.floor(r),a=t.fromSerialDate(i),o=a.getFullYear(),s=a.getMonth(),c=a.getDay();switch(n){case`today`:return{min:i,max:i};case`yesterday`:return{min:i-1,max:i-1};case`tomorrow`:return{min:i+1,max:i+1};case`last7Days`:return{min:i-6,max:i};case`thisWeek`:{let e=new Date(a);e.setDate(a.getDate()-c);let n=new Date(e);return n.setDate(e.getDate()+6),{min:t.toSerialDate(e),max:t.toSerialDate(n)}}case`lastWeek`:{let e=new Date(a);e.setDate(a.getDate()-c-7);let n=new Date(e);return n.setDate(e.getDate()+6),{min:t.toSerialDate(e),max:t.toSerialDate(n)}}case`nextWeek`:{let e=new Date(a);e.setDate(a.getDate()-c+7);let n=new Date(e);return n.setDate(e.getDate()+6),{min:t.toSerialDate(e),max:t.toSerialDate(n)}}case`thisMonth`:return{min:t.toSerialDate(new Date(o,s,1)),max:t.toSerialDate(new Date(o,s+1,0))};case`lastMonth`:return{min:t.toSerialDate(new Date(o,s-1,1)),max:t.toSerialDate(new Date(o,s,0))};case`nextMonth`:return{min:t.toSerialDate(new Date(o,s+1,1)),max:t.toSerialDate(new Date(o,s+2,0))};case`thisQuarter`:{let e=Math.floor(s/3);return this._quarterRange(t,o,e)}case`lastQuarter`:{let e=Math.floor(s/3)-1,n=e<0?o-1:o,r=e<0?3:e;return this._quarterRange(t,n,r)}case`nextQuarter`:{let e=Math.floor(s/3)+1,n=e>3?o+1:o,r=e>3?0:e;return this._quarterRange(t,n,r)}case`thisYear`:return{min:t.toSerialDate(new Date(o,0,1)),max:t.toSerialDate(new Date(o,11,31))};case`nextYear`:return{min:t.toSerialDate(new Date(o+1,0,1)),max:t.toSerialDate(new Date(o+1,11,31))};case`lastYear`:return{min:t.toSerialDate(new Date(o-1,0,1)),max:t.toSerialDate(new Date(o-1,11,31))};case`yearToDate`:return{min:t.toSerialDate(new Date(o,0,1)),max:i};default:return{min:1/0,max:-1/0}}}_monthsOf(e){let t=/^([QM])(\d{1,2})$/.exec(e??``);if(!t)return null;let n=parseInt(t[2],10);return t[1]===`Q`?n>=1&&n<=4?new Set([3*n-3,3*n-2,3*n-1]):null:n>=1&&n<=12?new Set([n-1]):null}_quarterRange(e,t,n){let r=3*n;return{min:e.toSerialDate(new Date(t,r,1)),max:e.toSerialDate(new Date(t,r+3,0))}}},TopN:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.TopN,title:m(`condition.operator.topN.title`),acceptTypes:[H.Number],paramType:`topN`,description:m(`condition.operator.topN.desc`)})}createPredicate(e,t){let n=t.getRange().getStats(),r=e?.top??!0,i=e?.limit??10;if(e?.sum)return hv(n,r,e.percent?(n.getAggregates().sum??0)*(i/100):i);if(e?.percent){let e=n.getAggregates().numericalCount;if(!e)return gv;i=Math.max(1,Math.floor(i/100*e))}else if(i<1)return gv;let a=n.getSortedNumbers(),o=r?a.getLarge(i):a.getSmall(i);return o===null?_v:r?e=>e>=o:e=>e<=o}validateParam(e,t){let n=e?.limit??10;return e?.sum?e.percent?Number.isFinite(n)&&n>0&&n<=100?null:m(`condition.error.topNPercent`):Number.isFinite(n)?null:m(`condition.error.topNItems`):e?.percent?Number.isInteger(n)&&n>=1&&n<=100?null:m(`condition.error.topNPercent`):Number.isInteger(n)&&n>=1&&n<=1e3?null:m(`condition.error.topNItems`)}createDefaultParam(e){return{top:!0,limit:10,percent:!1}}toString(e,t){let n={...this.createDefaultParam(t),...e};return N(`condition.operator.topN.toString`,{edge:n.top?`top`:`bottom`,limit:n.limit??10,unit:n.percent?`percent`:n.sum?`sum`:`items`})}},And:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.And,title:m(`condition.operator.and.title`),description:m(`condition.operator.and.desc`)})}isCombinator(){return!0}async createPredicate(e,t){let n=e?e.length:0,r=[],i=[];for(let a=0;a<n;a++){let n=e[a],o=await t.resolveInput(n),s=await q_(o,t);s&&(r.push(await o.getSelector()?.createTransformer(t)??null),i.push(s))}let a=i.length;return n>0&&a===0?null:e=>{for(let n=0;n<a;n++){let a=J_(r[n],e,t);if(a===Z.NotApplicable||!0!==i[n](a,t))return!1}return!0}}validateParam(e,t){for(let t of e??[]){let e=Nv.resolveInput(t)?.validate()??null;if(e)return e}return null}toString(e,t){let n=this.getTitle();if(!e)return n;let r=``,i=e.length,a=n.toLowerCase();for(let t=0;t<i;t++){let n=e[t],i=Nv.resolveInput(n),o=i.getOperator(),s=o.toString(i.getParam(),i.getSelector())??o.getTitle?.()??``;r.length>0&&(r+=` ${a} `),r+=`${s}`}return r}},Or:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.Or,title:m(`condition.operator.or.title`),description:m(`condition.operator.or.desc`)})}isCombinator(){return!0}async createPredicate(e,t){let n=e?e.length:0,r=[],i=[];for(let a=0;a<n;a++){let n=e[a],o=await t.resolveInput(n),s=await q_(o,t);s&&(r.push(await o.getSelector()?.createTransformer(t)??null),i.push(s))}let a=i.length;return n>0&&a===0?null:e=>{for(let n=0;n<a;n++){let a=J_(r[n],e,t);if(a!==Z.NotApplicable&&!0===i[n](a,t))return!0}return!1}}validateParam(e,t){for(let t of e??[]){let e=Nv.resolveInput(t)?.validate()??null;if(e)return e}return null}toString(e,t){let n=this.getTitle();if(!e)return n;let r=``,i=e.length,a=n.toLowerCase();for(let t=0;t<i;t++){let n=e[t],i=Nv.resolveInput(n),o=i.getOperator(),s=o.toString(i.getParam(),i.getSelector())??o.getTitle?.()??``;r.length>0&&(r+=` ${a} `),r+=`${s}`}return r}},Not:new class extends ig{constructor(){super({name:Z.BuiltInOperatorNames.Not,title:m(`condition.operator.not.title`),description:m(`condition.operator.not.desc`)})}isCombinator(){return!0}async createPredicate(e,t){let n=await t.resolveInput(e),r=await n.getSelector()?.createTransformer(t),i=await q_(n,t);return i?e=>{let n=J_(r,e,t);if(n===Z.NotApplicable)return Z.NotApplicable;let a=i(n,t);return a===Z.NotApplicable?Z.NotApplicable:!a}:null}validateParam(e,t){return e?Nv.resolveInput(e)?.validate()??null:null}toString(e,t){let n=this.getTitle();if(!e)return n;let r=Nv.resolveInput(e),i=r.getOperator(),a=i.toString(r.getParam(),r.getSelector())??i.getTitle?.()??n;return N(`condition.operator.not.toString`,{title:n,condition:a})}}};xl();var yv=class{constructor(e){this._name=e.name,this._title=e.title,this._description=e.description,this._type=e.type??null,this._inputType=e.inputType===void 0?this._type:e.inputType,this._gate=e.gate??null,this._defaultCondition=e.defaultCondition??null}createTransformer(e){let t=this._gate;return t?e=>t(e)?e:Z.NotApplicable:null}getName(){return this._name}getSelectType(){return this._type}getInputType(){return this._inputType}getTitle(){return this._title?N(this._title):i.camelToPrettyCase(this.getName())}getDescription(){return this._description?N(this._description):N(`condition.selector.ruleDescription`,{title:this.getTitle()})}getDefaultCondition(e){let t=this._defaultCondition;return t?t.param===void 0?{operator:t.operator}:{operator:t.operator,param:structuredClone(t.param)}:null}},bv=e=>typeof e==`number`,xv=new Mh({max:16}),Sv=null,Cv=!1,wv=void 0,Tv=null;function Ev(e,t,n,r,i){let a=function(e,t,n){if(Tv!==null&&e===Sv&&t===Cv&&n===wv)return Tv;let r=`${+!!t}|${n??``}|${typeof e==`number`?`#`+e:e}`,i=xv.get(r);return i||(i=new Mh({max:1024}),xv.set(r,i)),Sv=e,Cv=t,wv=n,Tv=i,i}(t,r,i),o=a.get(n);if(o)return o;let s=e.format(t,n,{date1904:r,locale:i,placeholders:!0});return a.set(n,s),s}function Dv(e,t,n){if(t==null)return``;if(!0===t.isIRichData){let e=ku.toPrimitive(t);if(e===void 0)return ku.toPlaceholderText(t);t=e}let r=typeof t;if(r===`boolean`)return ml(t);if(r!==`number`&&r!==`string`)return V.isError(t)?hl(t):`(${N(`richData.placeholder`)})`;if(!n)return``;if(n===`General`){if(r===`string`)return t;if(Number.isInteger(t)&&t>-1e11&&t<1e11)return String(t)}let i=``;try{i=Ev(ve(),n,t,e?.isDate1904()??!1,e?.getLocale()??void 0).text}catch{return``}return i===null?`#####`:r===`string`?i:i.replaceAll(`\xA0`,` `)}var Ov=Object.freeze({displayText:``,conditionalColor:null,repeatChars:i.EmptyArray,spacingChars:i.EmptyArray,errorPlaceholder:null,formattedRuns:Object.freeze({runs:i.EmptyArray,length:0,width:0,lastRepeatIndex:-1}),canWrap:!1,asDate:null,isDateFormat:!1,isTimeFormat:!1});function kv(e,t,n,r,a,o){if(t==null)return Ov;if(r===U.RichData){let e=ku.toPrimitive(t);e!==void 0&&(r=ku.primitiveTypeOf(t),t=e)}let s=``,c=null,l=null,u=null,d=null,f=ve();if(r===U.Error)s=hl(t);else if(r===U.RichData)s=ku.toPlaceholderText(t);else if(r===U.Boolean)s=ml(t);else if(a)try{let n=Ev(f,a,t,e?.isDate1904()??!1,e?.getLocale()??void 0);s=n.text,l=n.fills??null,u=n.skips??null,d=n.color}catch(e){console.warn(`Invalid formatCode: `+s,a,e)}let p=f.isDateFormat(a),m=f.isTimeFormat(a),h=p||m?he(t,e?.isDate1904()??!1):null;s===null&&(c=`#`,s=c.repeat(5));let g=null,_=n.getAlignment(),v=_.getHorizontal(),y=_.getVertical(),b=_.getOverflow(),x=!(r!==U.String||v===R.HorizontalAlignment.Fill||l!==null&&l.length!==0||b!==R.Overflow.Wrap&&v!==R.HorizontalAlignment.Justify&&v!==R.HorizontalAlignment.Distributed&&y!==R.VerticalAlignment.Justify&&y!==R.VerticalAlignment.Distributed),S=s;x||r!==U.String||(S=S.replaceAll(/[\r\n]/g,``));let C=u?u.length:0,w=l?l.length:0,T=C>0||w>0;if(b!==R.Overflow.Wrap||T){let e=n.getFont(),t=e.getSize();e.getBaseline()!==0&&(t*=Ze(e.getFamily(),t,e.getBaseline()));let r=[];for(let e=0;e<C;e++){let i=u[e],a=n.measureText(i.char,t).width;r.push({...i,type:`spacing`,width:a})}if(w>0){let e=l[w-1],i=n.measureText(e.char,t).width;r.push({...e,type:`repeat`,width:i})}r=r.sort((e,t)=>e.offset-t.offset);let i=[],a=0,o=0,s=-1,c=-1,d=e=>{let r=n.measureText(e,t),s={type:`text`,width:r.width,text:e,letterSpacing:r.renderLetterSpacing};i.push(s),o+=s.width,a+=e.length},f=r.length;for(let e=0;e<f;e++){let t=r[e];if(c!==t.offset){let e=S.substring(a,t.offset);e&&d(e)}let n={type:t.type,width:t.width,text:t.char};t.type===`repeat`?s=i.length:o+=n.width,i.push(n),c=t.offset}if(a<S.length){let e=S.substring(a,S.length);e&&d(e)}g={runs:Object.freeze(i),length:a,width:o,lastRepeatIndex:s}}let E={displayText:s??``,conditionalColor:d?o(d):null,repeatChars:l??i.EmptyArray,spacingChars:u??i.EmptyArray,errorPlaceholder:c,formattedRuns:g,canWrap:x,asDate:h,isDateFormat:p,isTimeFormat:m};return Object.freeze(E)}function Av(e){let t=typeof e==`number`?Number(e.toPrecision(15)):e,n=i.castToString(t),r=n.indexOf(`e`);if(r===-1)return n;let a=n.substring(r+2);return`${n.substring(0,r)}E${n[r+1]}${a.length<2?`0`+a:a}`}function jv(e,t){if(e==null)return``;switch(t){case U.Number:return Av(e);case U.Boolean:return ml(e);case U.Error:{let t=e;return typeof t?.getLabel==`function`?hl(t):V.Label.Unknown}}return``+e}var Mv={Logical:new yv({name:Z.BuiltInSelectorNames.Logical,title:m(`condition.selector.logical.title`),type:H.Boolean,description:m(`condition.selector.logical.desc`),gate:e=>typeof e==`boolean`,defaultCondition:{operator:Z.BuiltInOperatorNames.EqualTo,param:!0}}),DateTime:new yv({name:Z.BuiltInSelectorNames.DateTime,title:m(`condition.selector.dateTime.title`),type:H.Date,description:m(`condition.selector.dateTime.desc`),gate:bv,defaultCondition:{operator:Z.BuiltInOperatorNames.Between}}),Date:new class extends yv{constructor(){super({name:Z.BuiltInSelectorNames.Date,title:m(`condition.selector.date.title`),type:H.Date,inputType:H.Date,description:m(`condition.selector.date.desc`),gate:bv,defaultCondition:{operator:Z.BuiltInOperatorNames.Between}})}},Time:new class extends yv{constructor(){super({name:Z.BuiltInSelectorNames.Time,title:m(`condition.selector.time.title`),type:H.Date,inputType:H.Date,description:m(`condition.selector.time.desc`),gate:bv,defaultCondition:{operator:Z.BuiltInOperatorNames.Between}})}},Text:new yv({name:Z.BuiltInSelectorNames.Text,title:m(`condition.selector.text.title`),type:H.String,description:m(`condition.selector.text.desc`),gate:e=>typeof e==`string`,defaultCondition:{operator:Z.BuiltInOperatorNames.TextContains}}),TextLength:new class extends yv{constructor(){super({name:Z.BuiltInSelectorNames.TextLength,title:m(`condition.selector.textLength.title`),type:H.Number,inputType:null,description:m(`condition.selector.textLength.desc`),defaultCondition:{operator:Z.BuiltInOperatorNames.Between}})}createTransformer(e){return e=>typeof e==`string`?e.length:V.isError(e)?Z.NotApplicable:jv(e,pB(e)).length}},Display:new class extends yv{constructor(){super({name:Z.BuiltInSelectorNames.Display,title:m(`condition.selector.display.title`),type:H.String,inputType:null,description:m(`condition.selector.display.desc`),defaultCondition:{operator:Z.BuiltInOperatorNames.InSet}})}createTransformer(e){return(e,t)=>{let n=t.getDisplayText();return n===null?typeof e==`string`?e:jv(e,pB(e)):n}}},Number:new yv({name:Z.BuiltInSelectorNames.Number,title:m(`condition.selector.number.title`),type:H.Number,description:m(`condition.selector.number.desc`),gate:bv,defaultCondition:{operator:Z.BuiltInOperatorNames.Between}}),Whole:new class extends yv{constructor(){super({name:Z.BuiltInSelectorNames.Whole,title:m(`condition.selector.whole.title`),type:H.Number,inputType:H.Number,description:m(`condition.selector.whole.desc`),gate:e=>typeof e==`number`&&Number.isInteger(e),defaultCondition:{operator:Z.BuiltInOperatorNames.Between}})}}},Nv=class{constructor(e,t,n=void 0,r=!1){this._selector=e,this._operator=t,this._param=n,this._includeBlanks=r}getSelector(){return this._selector}getOperator(){return this._operator}getParam(){return this._param??null}isIncludeBlanks(){return this._includeBlanks}validate(){return this._operator?.validateParam?.(this.getParam(),this._selector)??null}toString(){let e=this._selector,t=this._operator,n;if(t&&(n=t.toString?.(this.getParam(),e)??t.getTitle?.()??i.camelToPrettyCase(t.getName())),!e)return n??N(`condition.anySelector`);let r=e.getTitle();return n?N(`condition.selectorWithOperator`,{selector:r,operator:n}):r}toJSON(){let e=this.getOperator(),t=this.getSelector(),n=this.getParam(),r={};return t&&(r.selector=t.getName()),e&&(r.operator=e.getName()),n!=null&&(typeof n.toJSON==`function`&&(n=n.toJSON()),r.param=w_(n)),this.isIncludeBlanks()&&(r.includeBlanks=!0),r}get isICondition(){return!0}};function Pv(e,t,n,r){let i=d_.parse(e,{anchor:t});if(!i)return e;let a=d_.transform(i,function(e,t){let n=e.toLowerCase();return e=>{if(e.type===`tableReference`&&typeof e.value==`string`&&e.value.toLowerCase()===n)return{...e,value:t}}}(n,r));return a===i?e:d_.image(a,{at:t})}(function(e){let t=e.BuiltInSelectors=Mv,n=e.BuiltInOperators=vv;e.parseListLiteral=P_,e.formatListLiteral=F_,e.Selectors=new $t(t),e.Operators=new $t(n),e.resolveInput=z_,e.fromJSON=V_})(Nv||={});var Fv=/^([^[\]!'"]+)\[(.*)\]$/;function Iv(e){if(!e)return null;let t=Fv.exec(e.startsWith(`=`)?e.substring(1):e);if(!t)return null;let n=t[2];return n.startsWith(`[`)&&n.endsWith(`]`)&&(n=n.slice(1,-1)),!n||/^#|[^']\]|[^'][[]/.test(n)?null:{table:t[1],column:Vg(n)}}function Lv(e,t){if(!e)return null;let n=e.getWorksheets().getItems();for(let e=0;e<n.length;e++){let r=n[e].getTables().getByName(t);if(r&&!r.isDeleted())return r}return null}function Rv(e){let t=[];if(!e)return t;let n=e.getWorksheets().getItems();for(let e=0;e<n.length;e++){let r=n[e].getMovables().getItems();for(let e=0;e<r.length;e++){let n=r[e].getContent();n?.isISlicer&&!n.isDeleted()&&t.push(n)}}return t}function zv(e,t,n){let r=new Set,i=Rv(e);for(let e=0;e<i.length;e++){if(i[e]===n)continue;let t=i[e].getName?.();t&&r.add(t.toLowerCase())}if(!r.has(t.toLowerCase()))return t;for(let e=1;;e++){let n=`${t} ${e}`;if(!r.has(n.toLowerCase()))return n}}function Bv(e){return`Slicer_${e.replace(/[^\p{L}\p{N}_]/gu,`_`)}`}function Vv(e){let t=new Map,n=new Set,r=Rv(e);for(let e=0;e<r.length;e++){let i=r[e].toJSON()?.cacheName;i&&(t.set(r[e],i),n.add(i.toLowerCase()))}for(let e=0;e<r.length;e++){if(t.has(r[e]))continue;let i=r[e],a=Bv(i._getColumnName?.()??i.getColumn()?.getName()??``),o=a;for(let e=1;n.has(o.toLowerCase());e++)o=`${a}${e}`;t.set(r[e],o),n.add(o.toLowerCase())}return t}var Hv=class{constructor(e){this._closed=!1,this._range=null,this._ranges=null,this._rangeAnchor=void 0,this._rangesAnchor=void 0,this._options=e,e=this._initializeOptions(e),this._options=e;let t=this;this._transactions=this._options.transactions??new se({transient:!0}),this._id=this._transactions.create(),this._emitter=new ne(this,this._transactions);let n=this._options.coords;n=Array.isArray(n)?h.sanitizeRangeArray(n):h.sanitizeRange(n),this._options.setContainerCallbacks?.({processShift:e=>t._processContainerShift(e),processAfterShift:(e,n)=>t._processAfterContainerShift(e,n),processDelete(){t._processContainerDelete()},processLayout(){t._processContainerLayout()},processProtection(){t._processContainerProtection()}}),this._transactionsRemoveListener=this._transactions.addStateListener(this._id,{onBeforeCommitStart(e,n){t._processBeforeCommitStart(e,n)},onAfterStateChange(e,n,r,i){t._processAfterStateChange(e,n,r,i)},onRestoreOrRevert(e,n){t._processRestoreOrRevert(e,n)}}),this._updateState({isDeleted:!1,anchorCoords:n},m(`op.createAnchoredItem`)),this._initialize(e)}_initializeOptions(e){if(!e)throw Error(`Anchored.ConstructorOptions is required`);if(!(e={...e}).coords)throw Error(`coords is required`);return e}_initialize(e){}_getEmitter(){return this._emitter}delete(e){this._delete()}isProtected(){return this._options.isProtected?.()??!1}getAnchorCoords(){let e=this._getState()?.anchorCoords;return e?Array.isArray(e)?e.length===0?null:e:[e]:null}getFirstAnchorCoords(){let e=this._getState()?.anchorCoords;return e?Array.isArray(e)?e[0]??null:e:null}_invalidateRangeCache(){this._range=null,this._ranges=null}_isAnchorAbsolute(){return!1}getRanges(e){if(!e&&this._ranges&&(this._closed||this._rangesAnchor===this._getState()?.anchorCoords))return this._ranges;let t=this._getState()?.anchorCoords,n=t?this._options.getRanges(t,e):new _z(null);return t&&this._isAnchorAbsolute()&&(n=n.getFixed(!0)),e||(this._ranges=n,this._rangesAnchor=t),n}getRange(e){if(!e&&this._range&&(this._closed||this._rangeAnchor===this._getState()?.anchorCoords))return this._range;let t=this.getRanges(e),n=t.isInvalid()?gz:t.at(0);return e||(this._range=n,this._rangeAnchor=this._rangesAnchor),n}_setAnchorRanges(e,t){let n=this._options.getRanges(e).getCoords();if(n.length===0)throw new k(N(`error.address.noAddress`));let r=this._options.setContainerCoords;return r?(r(e,t),this):(this._updateState({anchorCoords:[...n]},{description:m(`op.setRanges`),...t}),this._processAnchorCoords(),this._emitter.notify(`onAnchorCoordsChange`),this)}getAnchorType(){return this._getState()?.anchorType??Ih.Type.TwoCell}getId(){return this._id}getVersionId(){return this._transactions.getVersionId(this._id)}beginCommit(e){return this._beginCommit(e)}doBatch(e,t){let n=this;return this._transactions.doBatch(e,typeof t==`string`?{description:t}:t,e=>{n._processTransactionDone(e)})}_processTransactionDone(e){}_getState(){if(this._closed)throw Error(ce);return this._transactions.getState(this._id)}_beginCommit(e){return this._transactions.beginCommit(typeof e==`string`?{description:e}:e)}_getTransactions(){return this._transactions}_updateState(e,t,n,r=!1){if(this._closed)throw Error(ce);if(!e)return;if(typeof t==`string`&&(t={description:t}),!r&&this.isProtected())throw new b(ie(t?.description));let i=this._beginCommit(t?.description);e&&`anchorCoords`in e&&this._invalidateRangeCache();try{let t=this._getState(),r=i.updateState(this._id,e);this._notify(n??void 0),this._processUpdateState(t,r),i.commit()}catch(e){throw i.rollback(),e}return this}_notify(e){if(!e)return;Array.isArray(e)||(Uv[0]=e,e=Uv);let t=e?e.length:0;if(t===0)return;let n=this._isAnyChangeFromState();for(let n=0;n<t;n++){let t=e[n];t!==`onAnyChange`&&this._emitter.notify(t)}n||this._emitter.notify(`onAnyChange`)}_isAnyChangeFromState(){return!1}_processAfterContainerShift(e,t){let n=t?t.length:0;if(!Wv(this._getState()?.anchorCoords,t)){let e=null,r={anchorCoords:n===0?null:t};n===0&&(r.isDeleted=!0,e=[`onDelete`]),this._updateState(r,{description:m(`op.updateAnchor`)},e,!0),this._processAnchorCoords()}this._emitter.notify(`onAnchorCoordsChange`)}_processContainerShift(e){let t=this._getState()?.anchorCoords;if(Array.isArray(t)&&t.length>1)return e.after;let n=null,r={anchorCoords:e.after};return e.after||(r.isDeleted=!0,n=[`onDelete`]),this._updateState(r,{description:m(`op.updateAnchor`)},n,!0),this._processAnchorCoords(),e.after}_processBeforeCommitStart(e,t){}_processAfterStateChange(e,t,n=!1,r=!1){}_processUpdateState(e,t){}_processRestoreOrRevert(e,t){this._invalidateRangeCache(),this._emitter.notify(`onInvalidated`)}_processAnchorCoords(){this._invalidateRangeCache()}_processContainerLayout(){}_getActionDescription(e){return null}_delete(){if(this._getState().isDeleted)return;let e={description:this._getActionDescription(`delete`)??m(`op.delete`)},t=this._beginCommit(e?.description);try{this._processDelete(),this._updateState({isDeleted:!0}),this._options.deleteFromContainer?.(e),t.commit()}catch(e){throw t.rollback(),e}}_processContainerDelete(){this._processAnchorCoords(),this._processDelete()}_processDelete(){this._invalidateRangeCache(),this._emitter.notify(`onDelete`)}_processContainerProtection(){this._emitter.notify(`onProtectedChange`)}addListeners(e,t){return this._emitter.addListeners(e,t)}isClosed(){return this._closed}isDeleted(){return this._closed||(this._getState()?.isDeleted??!1)}_processClose(){this._closed=!0,this._invalidateRangeCache(),this._emitter.notify(`onClose`),this._transactionsRemoveListener?.(),this._transactions.remove(this._id)}close(){this._closed||this._processClose()}get isIAnchored(){return!0}},Uv=[null],Wv=(e,t)=>{let n=t?t.length:0;if(!e)return n===0;let r=Array.isArray(e)?e:[e];if(r.length!==n)return!1;for(let e=0;e<n;e++)if(!h.isEqualRanges(r[e],t[e]))return!1;return!0};function Gv(e,t,n){let r=N(e,n);return r===e?t:r}function Kv(e=1){return Gv(m(`table.defaultName`),`Table${e}`,{n:e})}function qv(){return Gv(m(`table.emptyColumnName`),`Column`)}function Jv(e,t){return`${e}${t+1}`}function Yv(e){return e?e.toLocaleLowerCase():null}var Xv=Object.freeze({showRowStripes:!0,showColumnStripes:!1,showFirstColumn:!1,showLastColumn:!1}),Zv=new Map([[`average`,101],[`countnums`,102],[`count`,103],[`max`,104],[`min`,105],[`product`,106],[`stddev`,107],[`stddevp`,108],[`sum`,109],[`var`,110]]);function Qv(e){if(e==null)return;if(typeof e==`number`)return Number.isInteger(e)?e:void 0;let t=e.trim();if(t.startsWith(`=`)&&(t=t.substring(1).trim()),!t)return;let n=t.toLowerCase();return n!==`none`&&n!==`custom`?Zv.get(n)??t:void 0}function $v(e){return Bg(e)}function ey(e,t,n){let r=ty.exec(e);if(!r)return null;let i=parseInt(r[1]);if(!(typeof(a=i)==`number`&&Number.isInteger(a)&&a>=101&&a<=110))return null;var a;let o=r[2].trim().toLocaleLowerCase(),s=new Set([`[${$v(n)}]`.toLocaleLowerCase(),`[${n}]`.toLocaleLowerCase()]);for(let e of s)if(o===e||o===t.toLocaleLowerCase()+e)return i;return null}var ty=/^\s*SUBTOTAL\(\s*(\d{3})\s*,(.+)\)\s*$/i;function ny(e){if(!e)return i.EmptyArray;let t=e.length,n=e;for(let r=0;r<t;r++){let t=e[r];if(typeof t==`string`){n===e&&(n=[...e]),n[r]={name:t};continue}let i=t?.totalsRowFormula;if(i===void 0)continue;let a=Qv(i);if(a===i)continue;n===e&&(n=[...e]);let o={...t};a===void 0?delete o.totalsRowFormula:o.totalsRowFormula=a,n[r]=o}return n}var ry=(e,t=qv(),n=Jv)=>{let r=new Set,i=e.length;for(let t=0;t<i;t++){let n=e[t]?.name;if(!n)continue;let i=Yv(n);r.add(i)}let a=-1,o=Yv(t);return()=>{let e;do a++,e=n(o,a);while(r.has(e));return a}};function iy(e,t,n=0,r,i=qv(),a=Jv){let o=e?e.length:0,s=ny(e),c=t?t.length:0,l=ny(t),u=Math.max(c,o),d=Array(u);for(let e=0;e<u;e++){let t=e>=n?l[e-n]:void 0;t===void 0&&(t=s[e]),d[e]=t}let f=0,p=0,m=0,h=0,g=!0,_=ry(d,i),v=new Map;for(let e=0;e<n;e++){let t=d[e]?.name,n=Yv(t);n&&v.set(n,1)}let y,b,x=n+c;for(let e=n;e<u;e++){let t=d[e],n=t?.name,o=n,c=Yv(o);if(c)h++,y=c,b=n,g=!1;else{if(e>=x&&(h=0,m=0),g||(m=h),r||m<=1){let t=_();o=a(i,t),o!==s[e]?.name&&(p=t+1),c=Yv(o)}else f++,c=y,o=b;h=0,g=!0}let l=v.get(c)??0;l===1&&(l+=Math.max(0,Math.max(p+f,m)-1)),l>0&&(o=a(o,l)),l++,v.set(c,l),o!==n&&(d[e]={...t,name:o})}return d}function ay(e,t){return i.isEqualArrays(e,t,(e,t)=>i.deepEqual(e,t))}var oy=class{constructor(e,t,n,r,i,a,o){this._table=e,this._id=t,this._getProps=n,this._updateProps=r,this._deleteSelf=i,this._getTotals=a,this._getCalculated=o}_totals(){return this._getTotals?.(this._id)??this._getProps(this._id)}getTable(){return this._table}getName(){return this._getProps(this._id).name??null}setName(e){return this._updateProps(this._id,{name:e},m(`op.setColumnName`)),this}getId(){return this._getProps(this._id).id??null}getIndex(){return this._getProps(this._id).index??-1}setTotalsRowLabel(e){return this._updateProps(this._id,{totalsRowLabel:e},m(`op.setTotalsRowLabel`)),this}getTotalsRowLabel(){return this._totals().totalsRowLabel||null}setTotalsRowFormula(e){return this._updateProps(this._id,{totalsRowFormula:e},m(`op.setTotalsRowFormula`)),this}getTotalsRowFormula(){return this._totals().totalsRowFormula??null}getCalculatedFormula(){return this._getCalculated?this._getCalculated(this._id):this._getProps(this._id).calculatedColumnFormula??null}getSort(){return this._table.getSortAt(this._getProps(this._id).index)}getFilter(){return this._table.getFilterAt(this._getProps(this._id).index)}isHiddenButton(){return this._table.isHiddenButtonAt(this._getProps(this._id).index)}setHiddenButton(e){return this._table.setHiddenButtonAt(this._getProps(this._id).index,e),this}getRange(){let e=this._table.getRange(),t=e?.getCoords(),n=this._getProps(this._id).index;return e.getIntersect({colStart:t.colStart+n,rowStart:t.rowStart,colEnd:t.colStart+n,rowEnd:t.rowEnd})}delete(e){this._deleteSelf(this._id,e)}toJSON(){let e=i.cloneObject(this._getProps(this._id));delete e.index,delete e.sortProps,delete e.filterProps,delete e.totalsRowLabel,delete e.totalsRowFormula;let t=this._totals();t.totalsRowLabel&&(e.totalsRowLabel=t.totalsRowLabel),t.totalsRowFormula!==void 0&&(e.totalsRowFormula=t.totalsRowFormula),delete e.calculatedColumnFormula;let n=this.getCalculatedFormula();return n&&(e.calculatedColumnFormula=n),e}get[Symbol.toStringTag](){return`[TableColumn]`}toString(){return this.getName()??``}get isIColumn(){return!0}},sy=class extends oe{_fromJSON(e){let t={};if(t.name=e?.name??null,!t.name)throw Error(N(`error.model.nameRequired`));t.comment=e?.comment??null,t.hidden=e?.hidden??!1,t.scope=e?.scope??null,this._updateState(t,{description:t.name?N(`op.createItemNamed`,{name:t.name}):m(`op.createItem`)})}_toJSON(){let 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),e.scope&&(t.scope=e.scope),t}getName(){return this._getState().name}setName(e,t){if(!e)throw Error(N(`error.model.nameRequired`));return this._updateState({name:e},{description:N(`op.updateNamed`,{name:e}),...t})}getComment(){return this._getState().comment}setComment(e,t){return this._updateState({comment:e},{description:m(`op.setComment`),...t})}isHidden(){return this._getState().hidden}getScope(){return this._getState().scope}get isINamed(){return!0}},cy=class extends sy{constructor(e,t,n){super({...n,type:`namedTable`}),this._sheet=e,this._table=t;let r=this;this._table.addListeners({onDelete:()=>{r._options.deleteFromContainer?r._options.deleteFromContainer?.():r._delete()},onAnyChange:()=>{r._emitter.notify(`onAnyChange`)},onAnchorCoordsChange:()=>{r._emitter.notify(`onAnyChange`)}},{transactional:!0})}async select(e){return await this._table.select(e),this}getRanges(){let e=this._table;return(this._sheet.getWorkbook()??this._sheet).getRanges(e.getDataRange()).getFixed(!0)}getPartReference(e,t){if(e?.length!==1)return null;let n=e[0],r=this._table,i=r.getName(),a=this._sheet.getName();if(n.scope&&n.scope!==a)return null;let o=r.getRange().getCoords(),s=!!t&&(!t.scope||t.scope===a)&&t.rowIndex>=o.rowStart&&t.rowIndex<=o.rowEnd&&t.colIndex>=o.colStart&&t.colIndex<=o.colEnd;if(t&&n.rowStart===t.rowIndex&&n.rowEnd===t.rowIndex){let e=r.getDataRange().getCoords(),t=n.rowStart>=e.rowStart&&n.rowEnd<=e.rowEnd?this._columnSpan(n):null;if(t?.kind===`all`)return`${i}[@]`;if(t?.kind===`one`)return`${s?``:i}[@${$v(t.name)}]`;if(t?.kind===`span`)return`${i}[@[${$v(t.first)}]:[${$v(t.last)}]]`}let c=this._rowBand(n);if(!c)return null;let l=this._columnSpan(n);if(!l||l.kind===`all`&&c.length===1&&c[0]===`#Data`)return null;let u=l.kind!==`all`&&c.length===1&&c[0]===`#Data`?[]:c,d=null,f=null;l.kind===`one`?(d=$v(l.name),f=`[${d}]`):l.kind===`span`&&(d=f=`[${$v(l.first)}]:[${$v(l.last)}]`);let p=u.map(e=>`[${e}]`);return f&&p.push(f),p.length===1?u.length===1?`${i}[${u[0]}]`:`${s&&l.kind===`one`?``:i}[${d}]`:`${i}[${p.join(this._listSeparator())}]`}_rowBand(e){let t=this._table,n=e=>e?.getCoords()??null,r=t=>{let r=n(t);return!!r&&r.rowStart===e.rowStart&&r.rowEnd===e.rowEnd};if(r(t.getDataRange()))return[`#Data`];if(t.isShowHeaders()&&r(t.getHeaderRowRange()))return[`#Headers`];if(t.isShowTotals()&&r(t.getTotalRowRange()))return[`#Totals`];if(r(t.getRange()))return[`#All`];let i=n(t.getDataRange()),a=t.isShowHeaders()?n(t.getHeaderRowRange()):null,o=t.isShowTotals()?n(t.getTotalRowRange()):null;return i&&a&&e.rowStart===a.rowStart&&e.rowEnd===i.rowEnd?[`#Headers`,`#Data`]:i&&o&&e.rowStart===i.rowStart&&e.rowEnd===o.rowEnd?[`#Data`,`#Totals`]:null}_columnSpan(e){let t=this._table,n=t.getRange()?.getCoords();if(n&&e.colStart===n.colStart&&e.colEnd===n.colEnd)return{kind:`all`};let r=t.getColumns(),i=null,a=null;for(let t=0;t<r.length;t++){let n=r[t].getRange()?.getCoords();n&&(n.colStart===e.colStart&&(i=r[t]),n.colEnd===e.colEnd&&(a=r[t]))}return i&&a?i===a?{kind:`one`,name:i.getName()}:{kind:`span`,first:i.getName(),last:a.getName()}:null}_listSeparator(){let e=this._sheet.getWorkbook()?.getLocale()??`en`;return ht(e).listSeparator}getScope(){return null}getType(){return`table`}getName(){return this._table.getName()}setName(e,t){return this._table.setName(e,t),this}getValue(){return this._table}},ly=class{constructor(e,t,n,r){this._table=e,this._id=t,this._getProps=n,this._getColumnProps=r}sort(e){this.setCriteria({reverse:e??!1},!1)}getCriteria(){return this._getProps(this._id).criteria??null}setCriteria(e,t,n){let r,i={};if(e&&(e.reverse!==void 0&&(i.reverse=e.reverse),e.collatorOptions!==void 0&&(i.collatorOptions=e.collatorOptions),e.sortOn!==void 0&&(i.sortOn=e.sortOn),e.iconSet!==void 0&&(i.iconSet=e.iconSet),e.iconId!==void 0&&(i.iconId=e.iconId),e.style!==void 0&&(i.style=e.style),e.customList!==void 0&&(i.customList=e.customList)),t){let t=this._table.getActiveSorts(),a=t.length,o=this.getIndex(),s=!1,c=[];for(let e=0;e<a;e++){let n=t[e],r=n.getIndex(),i=r===o;s||=i,i||(c[e]={index:r,criteria:n.getCriteria()})}e!==null&&c.push({index:this.getIndex(),criteria:i}),r={sorts:c,description:N(`op.sortColumn`,{name:this._getColumnProps(this._id).name}),...n}}else r={sorts:[{index:this.getIndex(),criteria:i}],description:N(`op.sortColumn`,{name:this._getColumnProps(this._id).name}),...n};this._table.sort(r)}apply(){this._table.applySorts()}getIndex(){return this._getColumnProps(this._id).index}getRange(){let e=this._table,t=e.getRange(),n=t.getCoords(),r=e.isShowTotals(),i=n.colStart+this.getIndex();return t.getIntersect({colStart:i,rowStart:n.rowStart,colEnd:i,rowEnd:n.rowEnd-+!!r})}getLevel(){return this._getProps(this._id).level??-1}delete(e){this.getLevel()!==-1&&this.setCriteria(null,!0,{description:m(`op.clearSort`),...e})}get isISort(){return!0}};function uy(e,t){let n=t.colStart,r=e.getRange({rowStart:t.rowStart,rowEnd:t.rowEnd,colStart:n,colEnd:n}),i=[];for(let e of r.getRegions(Qh.Feature.NumberFormat)){let n=e.getCoords(),r=Math.max(n.rowStart,t.rowStart),a=Math.min(n.rowEnd,t.rowEnd);r<=a&&i.push({rowStart:r,rowEnd:a})}i.sort((e,t)=>e.rowStart-t.rowStart);let a=[],o=(t,r)=>{let i=(t=>{let r=e.getRange({rowStart:t,rowEnd:t,colStart:n,colEnd:n}).getCell().getStyle();return r.getNumberFormatRef?.()??r.getNumberFormat()})(t),o=a[a.length-1];o&&o.format===i&&o.rowEnd===t-1?o.rowEnd=r:a.push({rowStart:t,rowEnd:r,format:i})},s=t.rowStart;for(let e=0;e<i.length;e++){let t=i[e];t.rowEnd<s||(t.rowStart>s&&o(s,t.rowStart-1),o(Math.max(t.rowStart,s),t.rowEnd),s=t.rowEnd+1)}return s<=t.rowEnd&&o(s,t.rowEnd),a}function dy(e,t){let n=e.getRuntime(),r=new Map;return(i,a,o)=>{let s=r.get(a);s||(s={runs:uy(e,{...t,colStart:a,colEnd:a}),last:0},r.set(a,s));let c=s.runs,l=s.last;if(i<c[l].rowStart||i>c[l].rowEnd){let e=0,t=c.length-1;for(;e<t;){let n=e+t>>>1;c[n].rowEnd<i?e=n+1:t=n}l=e,s.last=l}return Dv(n,o,c[l].format)}}async function fy(e,t,n){let r=iv(n),i=r.axis??B.Axis.Row,a=[],o=[];return await async function(e){let t=e.coords,n=e.axis??B.Axis.Row,r=n===B.Axis.Row,i=r?t.rowStart:t.colStart,a=r?t.rowEnd:t.colEnd;e.hasHeader&&(i+=1);let o=e.conditions,s=o?o.length:0,c=e.getDisplayText??null,l=[],u=e.getHiddenRuns;if(u){let t=e.includeHidden??!0;!0!==t&&t!==n&&(l=u(n).slice())}if(i<=a)for(let n=0;n<s;n++){let s=o[n],u=Nv.resolveInput(s);if(!u)continue;let d=s?.index,f=typeof d==`number`?d:n,p=(r?t.colStart:t.rowStart)+f,m=r?{rowStart:i,rowEnd:a,colStart:p,colEnd:p}:{rowStart:p,rowEnd:p,colStart:i,colEnd:a},h=av(l,i,a).map(e=>r?{rowStart:e.min,rowEnd:e.max,colStart:p,colEnd:p}:{rowStart:p,rowEnd:p,colStart:e.min,colEnd:e.max}),g={bounds:m,axis:r?B.Axis.Column:B.Axis.Row};if(l.length>0){let e=_o(l);r?g.processRowSkip=e:g.processColumnSkip=e}let _=[],v=[],y=(e,t)=>{let n=r?e.rowIndex:e.colIndex;_.push(n),t&&v.push(n)},b={resolve:null};await $_(u,{runtime:e.runtime,values:e.values,coords:m,cellValuesOptions:g,calculation:e.calculation,visibleCoords:h,getDisplayText:c,onTrue:e=>y(e,!1),onFalse:e=>y(e,!0),onBlank:e=>{b.resolve=e},blankRule:Q_(u)?`display`:`value`,onBlankValue:()=>{}});let x=co(v,!0);if(u.isIncludeBlanks())l=ov(l,x);else{let e=av(ov(l,co(_,!0)),i,a),t=e,n=b.resolve;if(n&&e.length>0){let i=e=>r?n(e,p):n(p,e);if(H_(u)){let n=[];for(let t=0;t<e.length;t++){let r=e[t];for(let e=r.min;e<=r.max;e++)i(e)||n.push(e)}t=co(n,!0)}else t=i(e[0].min)?[]:e}l=ov(l,x,t)}}if(i<=a){let t=e.onHiddenRun;if(t)for(let e=0;e<l.length;e++)t(l[e]);let n=e.onVisibleRun;if(n){let e=av(l,i,a);for(let t=0;t<e.length;t++)n(e[t])}}}({runtime:e.getRuntime(),calculation:e._calculation,values:e._calcGrid.getValues(),coords:t,conditions:r.conditions,axis:i,hasHeader:r.hasHeader,includeHidden:r.includeHidden,getDisplayText:dy(e,t),getHiddenRuns:t=>Bz(t===B.Axis.Row?e._rowHeaders:e._colHeaders),onVisibleRun:e=>{a.push({...e})},onHiddenRun:e=>{o.push({...e})}}),{axis:i,visibleRuns:a,hiddenRuns:o}}function py(e,t,n){let r=n?.description??m(`op.filter`),i=t.axis===B.Axis.Row?e._rowHeaders:e._colHeaders;t.visibleRuns.length>0&&i._setHidden(t.visibleRuns,!1,{description:r}),t.hiddenRuns.length>0&&i._setHidden(t.hiddenRuns,!0,{description:r})}var my=[`year`,`month`,`day`,`hour`,`minute`,`second`],hy,gy,_y=class{constructor(e,t,n,r,i){this._getHiddenByLevels=i,this._table=e,this._id=t,this._getProps=n,this._getColumnProps=r}filter(e,t){return this.setCondition(e,void 0,t)}getCondition(){return this._getProps(this._id).condition??null}async setCondition(e,t,n){let r=this.getIndex(),i=Nv.resolveInput(e),a=i===null?null:{index:r,...i.toJSON()},o=[],s=!1;if(!t){let e=this._table.getActiveFilters(),t=e.length;for(let n=0;n<t;n++){let t=e[n],i=t.getIndex();if(i===r){a&&o.push(a),s=!0;continue}let c=t.getCondition();c&&o.push({index:i,...c.toJSON()})}}return a&&!s&&o.push(a),await this._table.filter({conditions:o},{description:N(`op.filterColumn`,{name:this._getColumnProps(this._id).name}),...n}),this}async apply(e){return await this._table.applyFilters(e),this}getIndex(){return this._getColumnProps(this._id).index}getRange(){let e=this._table.getDataRange(),t=e.getCoords(),n=t.colStart+this.getIndex();return e.getIntersect({...t,colStart:n,colEnd:n})}async getItems(e){let t=e?.limit??1e4,n=e?.selector??null,r=typeof n==`string`?n:n?.getName()??null,i=r===Z.BuiltInSelectorNames.Display,a=this.getRange(),o=a.getWorksheet(),s=o.getRuntime(),c=e=>e.length>0?{processRowSkip:_o(e)}:void 0,l,u,d,f=this.getCondition()!==null,p=e?.scope===`column`;p?(l=void 0,u=c(await this._getHiddenByLevels(null)),d=f?c(await this._getHiddenByLevels(this.getIndex())):u):f?(l=c(await this._getHiddenByLevels(this.getIndex())),u=c(await this._getHiddenByLevels(null))):(l={ignoreHidden:B.Axis.Row},u=l);let m=a.getCoords(),h=new Map,g=uy(o,m);for(let e=0;e<g.length;e++){let t=g[e],n=h.get(t.format);n||(n=[],h.set(t.format,n)),n.push({...m,rowStart:t.rowStart,rowEnd:t.rowEnd})}let _=new Map,v=[],y=[],b=ve(),x=s.isDate1904(),S=!1,C=!1,w=!1,T=!1,E=0;for(let[e,n]of h){let r=b.isDateFormat(e),a=!r&&b.isTimeFormat(e),c=o.getRanges(n),f=c.getStats(l),h=f.getFrequencies({includeBlanks:!0,limit:t}),g=e=>e===l?h:c.getStats(e).getFrequencies(h.isTruncated()?{includeBlanks:!0,filterFn:e=>h.getFrequency(e)>0}:{includeBlanks:!0}),D=g(u),O=p?d===u?D:g(d):null;T||=h.isTruncated(),E+=f.getSize();for(let t of h.getUniqueValues()){let n=D.getFrequency(t)>0,o=O?O.getFrequency(t)>0:void 0;if(i?Y_(t):X_(t)){S=!0,C||=n,w||=!0===o;continue}let c=r&&typeof t==`number`,l=Dv(s,t,i||c||a&&typeof t==`number`?e:`General`),u=i?l:hg(t),d=h.getFrequency(t),f=h.getExtent(t)?.rowStart??m.rowStart,p=_.get(u);if(p){p.count+=d,p.checked=p.checked||n,o!==void 0&&(p.passesOthers=p.passesOthers||o),f<p.firstRow&&(p.firstRow=f);continue}let g={text:l,value:t,count:d,checked:n,firstRow:f};o!==void 0&&(g.passesOthers=o),_.set(u,g);let b=c?Te(t,x,!0):null;b?v.push({item:g,year:b.year,month:b.month,day:b.day,hour:b.hour,minute:b.minute,second:b.second}):y.push(g)}}if(v.sort((e,t)=>t.year-e.year||e.item.value-t.item.value),h.size>1){let e=s.getLocaleProfile();y.sort((t,n)=>$l.compare(t.value,n.value,e)||$l.compare(t.text,n.text,e))}let D=v.map(e=>e.item);for(let e=0;e<y.length;e++)D.push(y[e]);D.length>t&&(D.length=t,T=!0);let O={items:D,hasBlanks:S,blanksChecked:C,truncated:T,total:E,selector:i?r:null};p&&(O.blanksPassOthers=w);let k=Math.min(v.length,D.length);return k>0&&(O.dates=function(e,t){let n=!1;for(let r=0;r<t&&!n;r++){let t=e[r];n=t.hour!==0||t.minute!==0||t.second!==0}let r=n?my.length:3,i=[];for(let n=0;n<r;n++){let r=my[n],a=[],o=null;for(let i=0;i<t;i++){let t=e[i],s=o!==null;for(let r=0;s&&r<=n;r++){let n=my[r];s=e[i-1][n]===t[n]}if(s){o.max=i;continue}let c={group:r};for(let e=0;e<=n;e++){let n=my[e];c[n]=t[n]}o={min:i,max:i,value:c},a.push(o)}i.push({group:r,runs:a})}return i}(v,k)),O}getDisplayTexts(e){let t=[];if(e.length===0)return t;let n=this.getRange(),r=n.getWorksheet(),i=r.getRuntime(),a=n.getCoords(),o=new Set,s=uy(r,a);for(let n=0;n<s.length;n++){let c=s[n],l=r.getRange({...a,rowStart:c.rowStart,rowEnd:c.rowEnd}).getStats().getFrequencies({includeBlanks:!1});for(let n=0;n<e.length;n++){let r=e[n];if(r===null||l.getFrequency(r)===0)continue;let a=Dv(i,r,c.format);o.has(a)||(o.add(a),t.push(a))}}return t}getLevel(){return this._getProps(this._id).level??-1}async delete(e){return this.getLevel()===-1?this:this.setCondition(null,void 0,{description:m(`op.deleteFilter`),...e})}get isIFilter(){return!0}},vy=`table.ownWrites`,yy=class extends Hv{constructor(e){super(e)}_initializeOptions(e){let t=e?.coords;return Array.isArray(t)&&(e={...e,coords:t[0]}),super._initializeOptions(e)}initializeColumnCreator(e,t,n,r,i,a){return o=>new oy(e,o,t,n,r,i,a)}initializeSortCreator(e,t,n){return r=>new ly(e,r,t,n)}initializeFilterCreator(e,t,n){return r=>new _y(e,r,t,n,e=>this._hiddenByLevels(e))}async _hiddenByLevels(e){let t=this._filterLevels().filter(t=>t.index!==e);return t.length===0?[]:(await this._evalFilter({conditions:t}))?.hiddenRuns??[]}_initialize(e){super._initialize(e),this._emptyColumnName=qv(),this._emptyColumnNamer=Jv,this._styles=e.styles??e?.sheet?.getStyles()??new Pm,this._names=e?.names,this._sheet=e?.sheet,this._processTableUpdate=e?.processTableUpdate,this._symbolsChanged=e?.symbolsChanged,this._filteredChanged=e?.filteredChanged,this._setContainerName=e?.setContainerName,this._releaseReferences=e?.releaseReferences,this._refitBodyRows=e?.refitBodyRows,this._fillCalculated=e?.fillCalculated,this._colHeadersSizeUnlistener=null,this._rowHeadersSizeUnlistener=null,this._headerListenerCoords=null,this._expandListenerCoords=null,this._heldTotals=new Map,this._heldCalculated=new Map,this._columnFacades=new Map,this._sortFacades=new Map,this._filterFacades=new Map,this._columnViews=null,this._visibleRange=null,this._isHeaderVisible=!0,this._isTotalVisible=!0,this._isFirstColumnVisible=!0,this._isLastColumnVisible=!0,this._styleCache=null,this._stylePropsCache=null,this._stylesRemoveListener=this._styles.getTableStyles().addListeners({onCollectionChange:()=>{this._onTableStylesChange()}});let t=e=>this._columnPropsOf(e);this._createColumn=this.initializeColumnCreator(this,t,(e,t,n)=>{this._updateColumnProps(e,t,n)},(e,t)=>{this._deleteColumn(e,t)},e=>this._totalsOf(e),e=>this._calculatedOf(e)),this._createSort=this.initializeSortCreator(this,e=>this._sortPropsOf(e),t),this._createFilter=this.initializeFilterCreator(this,e=>this._filterPropsOf(e),t),this._updateState({name:Kv(),headerRowCount:1,totalsRowCount:0,totalsRowShown:!1,orderedColumnsProps:i.EmptyArray,mapHiddenButtons:Ny,lastColId:0,description:``},m(`op.initializeTable`));let n=e?.sheet;if(n&&e?.syncSheet){let t=this._getState(),n=t.anchorCoords,r=t.headerRowCount,i=t.totalsRowCount;this._ensureHeightForHeaderTotals(n,r,i,e?.json?.headerRowCount||void 0,e?.hasTotals?void 0:e?.json?.totalsRowCount)}try{this._fromJSON(e?.json)}catch(e){throw console.error(`Error creating Table from JSON`,e),e}if(n){e?.syncSheet&&this._syncHeader({from:`sheet`,keepNameOnBlank:!0}),this._processExpandListener(),this._columnListener=e=>{e.isUndo()||e.getTrigger()===`data`&&this._getLiveState()&&this._notOwnWrites(e.getRanges().getCoords(),e.getCommit()?.getId()??null).length!==0&&this._syncHeader({from:`sheet`})},this._processHeaderListener(),this._syncHeldTotals(),this._syncHeldCalculated();let t={onMetricsChange:()=>{this._calcVisible()}};this._colHeadersSizeUnlistener=n.getColumnHeaders().addListeners(t,{transactional:!1}),this._rowHeadersSizeUnlistener=n.getRowHeaders().addListeners(t,{transactional:!1}),this._calcVisible()}if(this._names){let t=this._createNamed();t&&e.setContainerName?.(t.getName()),this._namedItem=t,e.symbolsChanged?.(this)}}getNamed(){return this._namedItem??null}_columnPropsOf(e){return this._views().byId.get(e)??Fy}_views(){let e=this._getState()?.orderedColumnsProps??i.EmptyArray,t=this._columnViews;if(t&&t.props===e)return t;let n=e.length,r=new Map,a=Array(n),o=new Map,s=new Map,c=[],l=[];for(let t=0;t<n;t++){let n=e[t];if(!n)continue;let i=n.id;r.set(i,n);let u=this._columnOf(i);a[t]=u,o.set(i,u),s.set(n.name.toLocaleLowerCase(),u),n.sortProps&&c.push(n),n.filterProps&&l.push(n)}c.sort((e,t)=>e.sortProps.level-t.sortProps.level),l.sort((e,t)=>e.filterProps.level-t.filterProps.level);let u={props:e,byId:r,columns:Object.freeze(a),columnsById:o,columnsByName:s,sorts:c.length===0?i.EmptyArray:Object.freeze(c.map(e=>this._sortOf(e.id))),filters:l.length===0?i.EmptyArray:Object.freeze(l.map(e=>this._filterOf(e.id)))};return this._columnViews=u,u}_columnOf(e){let t=this._columnFacades.get(e);return t||(t=this._createColumn(e),this._columnFacades.set(e,t)),t}_sortOf(e){let t=this._sortFacades.get(e);return t||(t=this._createSort(e),this._sortFacades.set(e,t)),t}_filterOf(e){let t=this._filterFacades.get(e);return t||(t=this._createFilter(e),this._filterFacades.set(e,t)),t}_sortPropsOf(e){return this._columnPropsOf(e).sortProps??Ly}_filterPropsOf(e){return this._columnPropsOf(e).filterProps??Ry}_onTableStylesChange(){this._styleCache=null,this._stylePropsCache=null,this._emitter.notify(`onStyleChange`),this._emitter.notify(`onAnyChange`)}_ensureVisible(){this._calcVisible()}_calcVisible(){let e=this.getFirstAnchorCoords(),t=this._sheet,n=0,r=0;e&&t&&(n=t.getColumnHeaders().getMetrics().getVisibleIndex(e.colEnd).min,r=t.getRowHeaders().getMetrics().getVisibleIndex(e.rowEnd).min);let i=this.isShowHeaders(),a=this.isShowTotals();if(e&&t&&(n<e.colEnd||r<e.rowEnd)){let o=t.getColumnHeaders(),s=t.getRowHeaders(),c=o.getMetrics().getVisibleIndex(e.colStart).max,l=s.getMetrics().getVisibleIndex(e.rowStart).max;this._visibleRange={colStart:c,colEnd:n,rowStart:l,rowEnd:r},this._isHeaderVisible=i&&!s.at(e.rowStart).isHidden(),this._isTotalVisible=a&&!s.at(e.rowEnd).isHidden(),this._isFirstColumnVisible=!o.at(e.colStart).isHidden(),this._isLastColumnVisible=!o.at(e.colEnd).isHidden()}else this._visibleRange=null,this._isFirstColumnVisible=!0,this._isLastColumnVisible=!0,this._isHeaderVisible=i,this._isTotalVisible=a}getSnapshot(e){let t=this.toJSON(),n=this.getFirstAnchorCoords(),r=this.getName(),i={...t},a=this,o=Object.freeze({...e}),s=!1;return{copyTo(e,t){let c=e.tables,l=e.range,u={...o,...t},d={colStart:l.colStart,rowStart:l.rowStart,colEnd:n.colEnd-n.colStart+l.colStart,rowEnd:n.rowEnd-n.rowStart+l.rowStart};if(u.isCut&&!s&&!a.isDeleted()&&c===a._sheet?.getTables()){let e=c.getItems({address:d});if(e.length===0||e.length===1&&e[0]===a)return a._moveTo(d),d}return u.isCut&&!s&&(a.isDeleted()||a._remove(),s=!0),c.add(d,{properties:i,disabledAutofit:!0,hasHeader:!0,hasTotals:!0})._adoptPaste(r),d},getCoords:()=>n,getSource:()=>a,getName:()=>r,getMarkOptions:()=>o,isISnapshot:!0}}_adoptPaste(e){let t=this._sheet;t&&this._ownWrite(t.getEntireRange().getCoords(),()=>{this._retargetCopiedFormulas(e)})}_retargetCopiedFormulas(e){let t=this._sheet,n=this.getFirstAnchorCoords(),r=this.getName();if(!t||!n||r.toLowerCase()===e.toLowerCase())return;let i=[];for(let a of t.getRange(n).getRegions(Qh.Feature.Formula)){let t=a.getCoords(),n=a.getCell().getFormulaText();if(!n)continue;let o=n.startsWith(`=`)?n.substring(1):n,s=Pv(o,{rowIndex:t.rowStart,colIndex:t.colStart},e,r);s!==o&&i.push({coords:{...t},text:s})}for(let e=0;e<i.length;e++){let n=i[e];t.getRange(n.coords).setFormula(`=`+n.text)}}getAnchorType(){return Ih.Type.TwoCell}getStyle(){if(this._styleCache)return this._styleCache;let e=this._getState(),t=this._styles.getTableStyles();if(!e)return t.getNone();let n=e.style.name;return this._styleCache=n?t.getByName(n)??t.getDefault():t.getNone(),this._styleCache}addRow(e,t){return this.addRows(e??2**53-1,1,t)}_ensureHeightForHeaderTotals(e,t,n,r,i){let a=this._sheet;if(!a)return!1;let o=e,s=r??t,c=s-t;if(s>t){let e=a.getEntireRange().getCoords().rowStart,t=o.rowStart-c,n={colStart:o.colStart,rowStart:t,colEnd:o.colEnd,rowEnd:o.rowStart-1};if(t<e){let r=e-t;n.rowStart=e,n.rowEnd=r-1,a.getRange(n).insert(B.Axis.Row),n.rowEnd=o.rowEnd+r,o=n}else{let e=a.getRange(n);if(o=h.unionRanges(n,o),e.isContentful()){let t=e.getOffsetBy(c,0);t.insert(B.Axis.Row),n=t.getCoords(),o.rowStart+=c,o.rowEnd+=c}}}else if(c!==0){let e={...o};e.rowEnd=o.rowStart+c+1,this._ownWrite(e,()=>{a.getRange(e).clear()}),o={...o},o.rowStart-=c}let l=i??n,u=l-n;if(l>n){let e={colStart:o.colStart,rowStart:o.rowEnd+1,colEnd:o.colEnd,rowEnd:o.rowEnd+u},t=a.getRange(e);t.isContentful()&&t.insert(B.Axis.Row),o=h.unionRanges(e,o)}else if(u!==0){let e={...o};e.rowStart=o.rowEnd+u+1,this._ownWrite(e,()=>{a.getRange(e).clear()}),o={...o},o.rowEnd+=u}let d=!h.isEqualRanges(o,e);return d&&(this._updateState({anchorCoords:o}),this._options.setContainerCoords?.(o),this._calcVisible(),this._styleCache=null),c!==0&&this._processHeaderListener(),d||c!==0||u!==0}addRows(e,t=1,n){this._requireLive();let r=this._getState(),i={...r.anchorCoords},a=this._sheet,o=i.rowEnd,s=r.headerRowCount,c=r.totalsRowCount,l=o-i.rowStart+1-s-c;e=e==null||e<0?l:Math.min(e,l);let u=i.rowStart+s+e,d=m(t>1?`op.addTableRows`:`op.addTableRow`),f=this._beginCommit({description:d,...n});try{if(a){let r={colStart:i.colStart,rowStart:u,colEnd:i.colEnd,rowEnd:u+t-1};a.getRange(r).insert(B.Axis.Row),e===0&&s===0&&this._setAnchor({...this._getState().anchorCoords,rowStart:i.rowStart},n,d)}(!a||u>o)&&this._resize({colStart:i.colStart,rowStart:i.rowStart,colEnd:i.colEnd,rowEnd:i.rowEnd+t},n,void 0,!!a),f.commit()}catch(e){throw f.rollback(),e}return this}deleteRowsAt(e,t=1,n){this._requireLive();let r=this._getState(),i={...r.anchorCoords},a=this._sheet,o=r.headerRowCount,s=i.rowStart+o+e,c=i.rowEnd-s+1;if(o>0&&c<0)throw new k(N(`error.table.tableNoBody`));t=Math.max(1,Math.min(t,c));let l=this._beginCommit({description:m(t>1?`op.deleteTableRows`:`op.deleteTableRow`),...n});try{if(a){let e={colStart:i.colStart,rowStart:s,colEnd:i.colEnd,rowEnd:s+t-1};a.getRange(e).delete(B.Axis.Row)}else this._resize({colStart:i.colStart,rowStart:i.rowStart,colEnd:i.colEnd,rowEnd:i.rowEnd-t},n);l.commit()}catch(e){throw l.rollback(),e}return this}_updateColumnProps(e,t,n){this._requireLive();let r=this._getState(),i=this._views().byId.get(e),a;if(n=typeof n==`string`?{description:n}:{description:N(`op.updateColumnNamed`,{name:i.name}),...n},t===null)a={id:i.id,index:i.index,name:i.name,sortProps:null,filterProps:null};else{if(t.id!==void 0&&t.id!==i.id)throw Error(`Table column ID is immutable and can not be changed.`);if(a={...i,...t},`totalsRowLabel`in t&&(t.totalsRowLabel?delete a.totalsRowFormula:delete a.totalsRowLabel),`totalsRowFormula`in t){let e=Qv(t.totalsRowFormula);e===void 0?delete a.totalsRowFormula:(a.totalsRowFormula=typeof e==`string`?this._qualified(e,i.index):e,delete a.totalsRowLabel)}}let o=null;if(this._isTotalsOnSheet()){if(t===null||`totalsRowLabel`in t||`totalsRowFormula`in t){let t={};a.totalsRowLabel&&(t.totalsRowLabel=a.totalsRowLabel),a.totalsRowFormula!==void 0&&(t.totalsRowFormula=a.totalsRowFormula),Oy(this._totalsOf(e),t)||(o=t)}delete a.totalsRowLabel,delete a.totalsRowFormula}let s=!xy(i,a);if(!s&&!o)return;let c=a.name!==i.name,l=this._beginCommit(n);try{if(s){let e=r.orderedColumnsProps,t=[...e];t[i.index]=a,c&&(t=iy(e,t,0,!0,this._emptyColumnName,this._emptyColumnNamer)),this._updateColumnsState(t)}c&&this._syncHeader({from:`table`}),o&&this._writeTotalsCellAt(i.index,o),this._syncHeldTotals(),this._syncHeldCalculated(),l.commit()}catch(e){throw l.rollback(),e}}_qualified(e,t){return e.indexOf(`[`)===-1?e:this._storedText(e,t)}_storedText(e,t=0){let n=this._sheet,r=n?this._getUsedCoords():null;if(!r||n.getCalculation().getStatus()!==Q.Status.Running)return e;let i=Math.min(r.colStart+t,r.colEnd);try{return n.getCalculation()._toStoredText(e,{rowIndex:r.rowStart,colIndex:i,scope:n.getId()})||e}catch{return e}}_isTotalsOnSheet(){return!!this._sheet&&this._getTotalCoords()!==null}_totalsOf(e){let t=this._columnPropsOf(e),n=this._sheet?this._getTotalCoords():null;if(!n||t.index===void 0){let n=this._readHeldTotal(e);return n===null?t:{totalsRowFormula:n}}let r=this._totalsCellAt(n,t.index).getCell();return this._readTotalsCell(r,t.name)??Iy}_totalsCellAt(e,t){let n=e.colStart+t;return this._sheet.getRange({colStart:n,rowStart:e.rowStart,colEnd:n,rowEnd:e.rowStart})}_readTotalsCell(e,t){if(e.isFormulaHidden()&&e.getValue()!==null)return null;let n=e.getFormula()?.getExpression()??null;if(n)return{totalsRowFormula:ey(n,this.getName(),t)??n};let r=e.getValue();return r===null?Iy:{totalsRowLabel:typeof r==`string`?r:e.getText()}}_writeTotalsCellAt(e,t){let n=this._sheet?this._getTotalCoords():null;if(!n)return;let r=this._totalsCellAt(n,e),i=t.totalsRowFormula;this._ownWrite(r.getCoords(),()=>{if(i!==void 0){let t=this._getState().orderedColumnsProps[e].name;r.setFormula(`=`+(typeof i==`number`?(n=i,a=t,`SUBTOTAL(${n},[${$v(a)}])`):i))}else{var n,a;r.setValue(t.totalsRowLabel??null,{textParser:!1})}})}_holdTotalsFromCells(){let e=this._sheet?this._getTotalCoords():null;if(!e)return;let t=this._getState().orderedColumnsProps,n=t.length,r=[...t],i=!1;for(let a=0;a<n;a++){let n=t[a];if(!n)continue;let o=this._readTotalsCell(this._totalsCellAt(e,a).getCell(),n.name);if(!o||Oy(n,o))continue;let{totalsRowLabel:s,totalsRowFormula:c,...l}=n;r[a]={...l,...o},i=!0}i&&this._updateColumnsState(r,m(`op.updateColumnsFromSheet`))}_syncHeldTotals(){let e=this._heldTotals,t=this._sheet,n=t?this._getLiveState():null,r=-1;if(n&&n.totalsRowCount===0&&t.getCalculation().getStatus()!==Q.Status.Off){let e=n.anchorCoords.rowEnd+1;e<=t.getEntireRange().getCoords().rowEnd&&(r=e)}let i=null;if(r!==-1){let a=n.orderedColumnsProps,o=a.length;for(let s=0;s<o;s++){let o=a[s],c=o?.totalsRowFormula;if(typeof c!=`string`)continue;let l=o.id;(i??=new Set).add(l);let u=e.get(l),d=u?.text===c;if(u&&d){let e=u.host?u.host.getCoords():u.coords;if(e&&e.rowStart===r)continue}let f=(d?this._readHeldTotal(l):null)??c;u?.remove();let p=n.anchorCoords.colStart+s,m={colStart:p,rowStart:r,colEnd:p,rowEnd:r},h={text:c,coords:m,host:null,remove:null};h.remove=t.getRange(m)._addWatch(f,{onRegistered:e=>{h.host=e}}),e.set(l,h)}}if(e.size!==0)for(let[t,n]of[...e])i?.has(t)||(n.remove(),e.delete(t))}_readHeldTotal(e){let t=this._heldTotals.get(e)?.host,n=t?.getView(),r=t?.getCoords();if(!n||!r)return null;let i={rowIndex:r.rowStart,colIndex:r.colStart};return v_(n.getTextAt(i.rowIndex,i.colIndex),i,y_(this._sheet.getName()))||null}_removeHeldTotals(){for(let e of this._heldTotals.values())e.remove();this._heldTotals.clear()}_syncHeldCalculated(){let e=this._heldCalculated,t=this._sheet,n=t?this._getLiveState():null,r=n?this._getUsedCoords():null,i=null;if(r&&t.getCalculation().getStatus()!==Q.Status.Off){let a=n.orderedColumnsProps,o=a.length;for(let n=0;n<o;n++){let o=a[n],s=o?.calculatedColumnFormula;if(!s)continue;let c=o.id;(i??=new Set).add(c);let l=r.colStart+n,u=e.get(c),d=u?.text===s;if(u&&d){let e=u.host?u.host.getCoords():u.coords;if(e&&e.colStart===l&&e.rowStart>=r.rowStart&&e.rowStart<=r.rowEnd)continue}let f=(d?this._readHeldCalculated(c):null)??s;u?.remove();let p={colStart:l,rowStart:r.rowStart,colEnd:l,rowEnd:r.rowStart},m={text:s,coords:p,host:null,remove:null};m.remove=t.getRange(p)._addWatch(f,{onRegistered:e=>{m.host=e}}),e.set(c,m)}}if(e.size!==0)for(let[t,n]of[...e])i?.has(t)||(n.remove(),e.delete(t))}_readHeldCalculated(e){let t=this._heldCalculated.get(e)?.host,n=t?.getView(),r=t?.getCoords(),i=this._getUsedCoords();if(!n||!r||!i)return null;let a={rowIndex:i.rowStart,colIndex:r.colStart};return v_(n.getTextAt(a.rowIndex,a.colIndex),a,y_(this._sheet.getName()))||null}_removeHeldCalculated(){for(let e of this._heldCalculated.values())e.remove();this._heldCalculated.clear()}_calculatedOf(e){let t=this._columnPropsOf(e).calculatedColumnFormula;return t?this._readHeldCalculated(e)??t:null}_calculatedTextAt(e,t){let n=this._sheet,r=this._getUsedCoords(),i=this._getLiveState()?.orderedColumnsProps[e],a=i?this._calculatedOf(i.id):null;if(!n||!r||!a)return null;if(t===r.rowStart)return a;let o={rowIndex:r.rowStart,colIndex:r.colStart+e};try{return n.getRange({colStart:o.colIndex,rowStart:o.rowIndex,colEnd:o.colIndex,rowEnd:o.rowIndex}).createFormula(a).shift({rowIndex:t,colIndex:o.colIndex})?.getExpression()??null}catch{return null}}_holdFirstShowTotals(){let e=this._sheet,t=this._getState(),n=this._getUsedCoords(),r=t.orderedColumnsProps,i=r.length-1,a=r[i];if(this._updateState({totalsRowShown:!0}),!e||!n||!a||a.totalsRowLabel||a.totalsRowFormula!==void 0)return;let o=!1,s=e.getRange({...n,colStart:n.colEnd}).forEach((e,t)=>{if(e!==null)return t.getInteropType()===H.Number?void(o=!0):{break:!0}}),c=[...r];c[i]={...a,totalsRowFormula:o&&!s?109:103},this._updateColumnsState(c,m(`op.syncColumnsToSheet`))}_getTraverseRegion(e,t,n){if(t!==B.Axis.Row)return null;let r=this.getDataRange().getCoords(),i=this._sheet;if(n||!i)return r;let a=this.getAutoExpand();if(a!==Jf.AutoExpand.Both&&a!==Jf.AutoExpand.Rows)return r;let o=r.rowEnd-i.getRowHeaders().getMetrics().hiddenHeadersAt(r.rowEnd,!0),s=r.colEnd-i.getColumnHeaders().getMetrics().hiddenHeadersAt(r.colEnd,!0);if(e.rowIndex!==o||e.colIndex!==s)return r;try{this.addRow()}catch(e){if(!(e instanceof k))throw e;return r}return this.getDataRange().getCoords()}_showTotalsFromProps(){let e=this._sheet?this._getTotalCoords():null;if(!e)return;this._getState().totalsRowShown||this._holdFirstShowTotals();let t=this._getState().orderedColumnsProps,n=t.length,r=null;for(let e=0;e<n;e++){let n=t[e];if(!n||!n.totalsRowLabel&&n.totalsRowFormula===void 0)continue;r??=[...t];let{totalsRowLabel:i,totalsRowFormula:a,...o}=n;r[e]=o}if(!r)return;let i=this._beginCommit(m(`op.syncColumnsToSheet`));try{for(let i=0;i<n;i++){if(r[i]===t[i])continue;let n=this._totalsCellAt(e,i).getCell();if(n.getValue()!==null||n.getFormulaText())continue;let a=t[i];this._writeTotalsCellAt(i,a.totalsRowFormula===void 0?{totalsRowLabel:a.totalsRowLabel}:{totalsRowFormula:this._readHeldTotal(a.id)??a.totalsRowFormula})}this._updateColumnsState(r,m(`op.syncColumnsToSheet`)),i.commit()}catch(e){throw i.rollback(),e}}_deleteColumn(e,t){this._requireLive();let n=this._getState(),r=this._views().byId.get(e);if(!r)return;let i=this._beginCommit({description:N(`op.deleteColumnNamed`,{name:r.name}),...t});try{let a=r.index,o=this._sheet;if(o){let e=n.anchorCoords,t=e.colStart+a,r={colStart:t,rowStart:e.rowStart,colEnd:t,rowEnd:e.rowEnd};o.getRange(r).delete(B.Axis.Column)}let s=this._views().byId.get(e);if(s){let e=this._getState().orderedColumnsProps,n=[...e.slice(0,s.index),...e.slice(s.index+1)];this._updateColumnsState(n,t)}i.commit()}catch(e){throw i.rollback(),e}}addColumn(e=-1,t,n,r){this._requireLive();let i=this._getState().anchorCoords,a=e,o=i.colEnd-i.colStart+1;a===-1&&(a=o),a=Math.min(Math.max(0,a),o);let s=this._beginCommit({description:m(`op.addTableColumn`),...r});try{let e=i.colStart+a,r=i.rowStart,c=i.rowEnd,l={colStart:e,rowStart:r,colEnd:e,rowEnd:c},u=this._sheet;if(u&&u.getRange(l).insert(B.Axis.Column),(!u||a===0||a>=o)&&this._resize({colStart:i.colStart,rowStart:i.rowStart,colEnd:i.colEnd+1,rowEnd:i.rowEnd}),n!==void 0){let e=this._getState().orderedColumnsProps,t=[...e];t[a]={...e[a],name:n},t=iy(e,t,0,!0,this._emptyColumnName,this._emptyColumnNamer),this._updateColumnsState(t),this._syncHeader({from:`table`})}if(u&&t&&t.length>0){if(!Array.isArray(t))throw new k(N(`error.table.columnValuesNotArray`));let n=c-r+1;if(t.length>n)throw new k(N(`error.table.columnValuesOverflow`,{count:t.length,max:n}));let i={colStart:e,rowStart:r,colEnd:e,rowEnd:r+t.length-1};this._ownWrite(i,()=>{u.getRange(i).setValues([t],{axis:B.Axis.Column})})}s.commit()}catch(e){throw s.rollback(),e}return this.getColumnAt(a)}getColumns(){return this._views().columns}getColumn(e){let t=this.getColumnByName(e);return t===null?this.getColumnById(e):t}getColumnById(e){return this._views().columnsById.get(e)??null}getColumnByName(e){return this._views().columnsByName.get(e?.toLocaleLowerCase())??null}delete(e){if(this.isDeleted())return;let t=this.getFirstAnchorCoords();this.doBatch(()=>{this._remove(`error`),this._sheet&&t&&this._sheet.getRange(t).clear()},{description:N(`op.deleteTableNamed`,{name:this.getName()}),...e})}_remove(e=null){this.isDeleted()||(e&&this._releaseReferences?.(this,e),this._delete())}convertToRange(e=2**53-1,t){return this._requireLive(),this.doBatch(()=>{if(this._sheet){let t=this.getFirstAnchorCoords(),n=(t.colEnd-t.colStart+1)*(t.rowEnd-t.rowStart+1);if(n>e)throw new k(N(`error.table.convertToRangeLimit`,{count:n,max:e}));let r=this._sheet.getRange(t),i=r.createSparseBuilder({axis:B.Axis.Column});r.forEach((e,t)=>{let n=t.getCoords(),r=t.getCell();i.pushAt(n.rowIndex,n.colIndex,{style:r.getStyle(!1)})},{includeEmpty:!0,axis:B.Axis.Column}),i.apply()}this._remove(`address`)},{description:m(`op.convertToRange`),...t}),this._requireSheet().getRange(this._getState().anchorCoords)}resizeTo(e,t,n){let r=this._getState().anchorCoords,i=r.colStart,a=r.rowStart;return this._resize({colStart:i,rowStart:a,colEnd:i+t-1,rowEnd:a+e-1},n)}resize(e,t){let n=this._getLiveState(),r=this._sheet;if(r&&n&&n.totalsRowCount>0){let i=r.getRange(e).getCoords();if(i&&i.rowEnd<n.anchorCoords.rowEnd)return this._resize({...i,rowEnd:i.rowEnd+n.totalsRowCount},t)}return this._resize(e,t)}_resize(e,t,n=m(`op.resizeTable`),r=!1){this._requireLive();let i=this._requireSheet().getRange(e).getCoords();if(!i)throw Error(bh(e));let a=this._getState(),o=a.anchorCoords,s=a.headerRowCount,c=a.totalsRowCount;if(o.rowStart!==i.rowStart||i.colEnd<o.colStart||i.colStart>o.colEnd||i.rowEnd<o.rowStart+s+c)throw new k(N(`error.table.tableResizeInvalidBounds`));let l=this._beginCommit({description:n,...t,operation:{name:`table.resize`}});try{h.isEqualRanges(i,o)||this._setAnchor(i,t,n,r),l.commit()}catch(e){throw l.rollback(),e}return this._sheet.getRange(i)}getName(){return this._getState()?.name??``}setName(e,t){return this._setProps({name:e},t,N(`op.setTableNameNamed`,{name:e}))}getDescription(){return this._getState()?.description??``}setDescription(e,t){return this._setProps({description:e},t,m(`op.setTableDescription`))}select(e){return this.getDataRange().select(e)}_processRestoreOrRevert(e,t){this._styleCache=null,super._processRestoreOrRevert(e,t),this._syncListenersToAnchor()}_syncListenersToAnchor(){if(this._sheet&&this._columnListener){if(this.isClosed()||this.isDeleted())return this._removeHeaderListener(),this._removeExpandListener(),this._removeHeldTotals(),void this._removeHeldCalculated();this._syncHeldTotals(),this._syncHeldCalculated(),ky(this._getHeaderListenerCoords(),this._headerListenerCoords)||this._processHeaderListener(),ky(this._getExpandListenerCoords(),this._expandListenerCoords)||this._processExpandListener()}}_moveTo(e){let t=this._getLiveState();t&&!h.isEqualRanges(t.anchorCoords,e)&&(this._updateState({anchorCoords:e}),this._options.setContainerCoords?.(e),this._calcVisible(),this._styleCache=null,this._syncListenersToAnchor())}_processAnchorCoords(){this._styleCache=null,super._processAnchorCoords()}_processAfterContainerShift(e,t){let n=this._getState(),r=t?.length===1?t[0]:null;n&&r&&!h.isEqualRanges(n.anchorCoords,r)&&(this._updateState({anchorCoords:r},{description:m(`op.updateAnchor`)},null,!0),this._processAnchorCoords()),super._processAfterContainerShift(e,t)}getDataRange(){let e=this._getUsedCoords();return e&&this._sheet?this._sheet.getRange(e):gz}_getUsedCoords(){let e=this._getState();if(!e)return null;let t=e.headerRowCount,n=e.totalsRowCount,r=e.anchorCoords;if(!r)return null;let i={...r,rowStart:r.rowStart+t,rowEnd:r.rowEnd-n};return i.rowEnd<i.rowStart||i.colEnd<i.colStart?null:i}getHeaderRowRange(){let e=this._getHeaderCoords();return e&&this._sheet?this._sheet.getRange(e):gz}_getHeaderCoords(){let e=this._getState();if(!e)return null;let t=e.headerRowCount;if(t<1)return null;let n=e.anchorCoords;return n?{...n,rowEnd:n.rowStart+t-1}:null}getTotalRowRange(){let e=this._getTotalCoords();return e&&this._sheet?this._sheet.getRange(e):gz}_getTotalCoords(){let e=this._getState();if(!e)return null;let t=e.totalsRowCount;if(t<1)return null;let n=e.anchorCoords;return n?{...n,rowStart:n.rowEnd-t+1}:null}getStyleOptions(){return this.isDeleted()?Xv:this._getState()?.style}updateStyleOptions(e,t=m(`op.updateStyleInfo`)){let n=this.getStyleOptions(),r=e?{...n,...e}:Xv;return this._setProps({style:r},void 0,t)}getRangedStyle(){let e=this._stylePropsCache;return e||(e=this.getStyle().getRanged(this),this._stylePropsCache=e),e}getStyleAt(e,t){return ch(void 0,this._styles,this.getRangedStyle(),{rowStart:e,colStart:t,rowEnd:e,colEnd:t})}isShowTotals(){return this._getState()?.totalsRowCount>0}setShowTotals(e,t){return this._setBands(void 0,+!!e,t,m(e?`op.showTotals`:`op.hideTotals`))}isShowHeaders(){return this._getState()?.headerRowCount>0}setShowHeaders(e,t){return this._setBands(+!!e,void 0,t,m(e?`op.showHeaders`:`op.hideHeaders`))}isShowHighlightFirstColumn(){return this._getState()?.style?.showFirstColumn??!1}setShowHighlightFirstColumn(e,t){return this._setProps({style:{...this._getState().style,showFirstColumn:e}},t,m(e?`op.showHighlightFirstColumn`:`op.hideHighlightFirstColumn`))}isShowHighlightLastColumn(){return this._getState()?.style?.showLastColumn??!1}setShowHighlightLastColumn(e,t){return this._setProps({style:{...this._getState().style,showLastColumn:e}},t,m(e?`op.showHighlightLastColumn`:`op.hideHighlightLastColumn`))}isShowBandedColumns(){return this._getState()?.style?.showColumnStripes??!1}setShowBandedColumns(e,t){return this._setProps({style:{...this._getState().style,showColumnStripes:e}},t,m(e?`op.showBandedColumns`:`op.hideBandedColumns`))}isShowBandedRows(){return this._getState()?.style?.showRowStripes??!1}setShowBandedRows(e,t){return this._setProps({style:{...this._getState().style,showRowStripes:e}},t,m(e?`op.showBandedRows`:`op.hideBandedRows`))}_getExpandListenerCoords(){let e=this._sheet;if(!e||this.getAutoExpand()===Jf.AutoExpand.None&&this.isDisabledColumnFill())return null;let t=this._getLiveState()?.anchorCoords;if(!t)return null;let n=e.getEntireRange().getCoords();return{...t,colEnd:Math.min(t.colEnd+1,n.colEnd),rowEnd:Math.min(t.rowEnd+1,n.rowEnd)}}_removeExpandListener(){this._expandRemoveListener?.(),this._expandRemoveListener=void 0,this._expandListenerCoords=null}_processExpandListener(){this._removeExpandListener();let e=this._sheet;if(!e)return;let t=this._getExpandListenerCoords();t&&(this._expandRemoveListener=e.getRange(t).addListener(e=>{this._onExpandListenerEvent(e)},{transactional:!1}),this._expandListenerCoords=t)}_onExpandListenerEvent(e){if(!this._getLiveState())return;if(e.getTrigger()!==`data`){let t=this._getExpandListenerCoords(),n=e.getSource();ky(t,n.isInvalid()?null:n.getCoords())||this._processExpandListener();return}if(e.isUndo())return;let t=e.getCommit()?.getId()??null;if(!t)return;let n=this._notOwnWrites(e.getRanges().getCoords(),t);if(n.length===0)return;let r=this._getTransactions();if(r.getCurrentCommit(!1).getId()!==r.getTipCommit().getId())return;let i=this._getUsedCoords(),a=this._getAutoExpandCoords(n),o=this._getLiveState().anchorCoords;if(a&&a.rowEnd>o.rowEnd&&this._sheet.getRange({...a,rowStart:o.rowEnd+1}).isContentful(Qh.Feature.Formula)){let e=this.getFormulaBelow();if(e===Jf.FormulaBelow.BelowTable)a=a.colEnd>o.colEnd?{...a,rowEnd:o.rowEnd}:null;else if(e===Jf.FormulaBelow.TotalsRow&&a.rowEnd===o.rowEnd+1&&a.colEnd===o.colEnd){a=null;try{this._takeRowBelowAsTotals()}catch(e){console.warn(`Unable to AutoExpand`,e);return}}}if(a)try{this._resize(a,void 0,m(`op.tableAutoExpansion`))}catch(e){console.warn(`Unable to AutoExpand`,e);return}if(i)try{this._processBodyWrite(n,i,t)}catch(e){console.warn(`Unable to fill the column`,e)}}_takeRowBelowAsTotals(){let e=this._requireLive(),t=this._beginCommit({description:m(`op.tableAutoExpansion`),operation:{name:`table.autoTotals`}});try{if(!e.totalsRowShown){let t=e.orderedColumnsProps,n=t.length,r=null;for(let e=0;e<n;e++){let n=t[e];if(!n||!n.totalsRowLabel&&n.totalsRowFormula===void 0)continue;r??=[...t];let{totalsRowLabel:i,totalsRowFormula:a,...o}=n;r[e]=o}r&&this._updateColumnsState(r,m(`op.tableAutoExpansion`))}let n={...e.anchorCoords,rowEnd:e.anchorCoords.rowEnd+1};this._updateState({totalsRowCount:1,totalsRowShown:!0,anchorCoords:n}),this._options.setContainerCoords?.(n),this._calcVisible(),this._styleCache=null,this._showTotalsFromProps(),this._syncListenersToAnchor(),t.commit()}catch(e){throw t.rollback(),e}}_processBodyWrite(e,t,n){let r=this._sheet,i=this._getLiveState(),a=this._getUsedCoords();if(!r||!i||!a)return;let o={...a,rowEnd:Math.min(a.rowEnd,t.rowEnd)};if(o.rowEnd<o.rowStart)return;let s=a.rowEnd-a.rowStart+1,c=new Map,l=e.length;for(let t=0;t<l;t++){let n=h.intersectRanges(o,e[t]);if(n)for(let e=n.colStart;e<=n.colEnd;e++){let t=c.get(e);t?(t.rows.push([n.rowStart,n.rowEnd]),t.range=n):c.set(e,{rows:[[n.rowStart,n.rowEnd]],range:n})}}if(c.size===0)return;let u=new Map;for(let[e,t]of c)u.set(e,{count:wy(t.rows),range:t.range});let d=!this.isDisabledColumnFill(),f=null;for(let[e,t]of u){let n=e-a.colStart,o=i.orderedColumnsProps[n];if(!o)continue;let c={...a,colStart:e,colEnd:e},l=!!o.calculatedColumnFormula;if(t.count===1&&s>1){let i={...t.range,colStart:e,colEnd:e},a=r.getRange(i).getCell().getFormulaText({r1c1:!0});if(a!==null&&d){let e=Ty(c,i),t=!0;for(let n=0;t&&n<e.length;n++)t=!r.getRange(e[n]).isContentful();if(!t&&l){let n=Dy(r,e);t=n!==null&&n!==a}if(t&&this._fillColumn(n,i))continue}}else if(t.count>=s&&Dy(r,[c])!==null){let e=r.getRange(c).getCell().getFormula()?.getExpression()??null;e&&e!==this._calculatedOf(o.id)&&(f??=new Map).set(n,e);continue}l&&!r.getRange(c).isContentful(Qh.Feature.Formula)&&(f??=new Map).set(n,null)}if(!f)return;let p=f,m=this._getTransactions(),g=m.getCurrentCommit(!1).getId()===n;m.amend(n,()=>{this._rememberCalculated(p,g)})}_detectCalculatedColumns(){let e=this._sheet,t=this._getUsedCoords();if(!e||!t)return;let n=Math.max(t.rowStart,t.rowEnd-4);if(!e.getRange({...t,rowStart:n}).isContentful(Qh.Feature.Formula))return;let r=(t,n)=>e.getRange({colStart:n,rowStart:t,colEnd:n,rowEnd:t}).getCell(),i=this._getState().orderedColumnsProps,a=i.length,o=null;for(let e=0;e<a;e++){if(!i[e]||i[e].calculatedColumnFormula)continue;let a=t.colStart+e,s=r(t.rowEnd,a),c=s.getFormulaText({r1c1:!0});if(c===null)continue;let l=0;for(let e=n;l<=1&&e<t.rowEnd;e++)r(e,a).getFormulaText({r1c1:!0})!==c&&l++;if(l>1)continue;let u=this._firstRowTextOf(s.getFormula(),a,t);u&&(o??=new Map).set(e,u)}o&&this._rememberCalculated(o)}_calculatedTextsAt(e){let t=this._getLiveState()?.orderedColumnsProps;if(!t||!this._sheet)return null;let n=null,r=t.length;for(let i=0;i<r;i++){if(!t[i]?.calculatedColumnFormula)continue;let r=this._calculatedTextAt(i,e);r&&(n??=new Map).set(i,r)}return n}_writeCalculatedRows(e,t,n){let r=this._sheet,i=this._getUsedCoords();if(r&&i&&!(t<e))for(let[a,o]of n){let n=i.colStart+a;if(n>i.colEnd)continue;let s=r.getRange({colStart:n,rowStart:e,colEnd:n,rowEnd:t});if(s.isContentful())continue;let c=this._fillCalculated;this._ownWrite(s.getCoords(),()=>{c?c(s.getCoords(),`=`+o):s.setFormula(`=`+o)})}}_firstRowTextOf(e,t,n){let r=e?.getAnchor();if(!e||!r)return null;let i=e.getExpression({cell:{rowIndex:n.rowStart,colIndex:t}});return i&&r.rowIndex!==n.rowStart?Cf(e.getExpression(),r.rowIndex,r.colIndex)===Cf(i,n.rowStart,t)?i:null:i||null}_fillColumn(e,t){let n=this._sheet,r=this._getUsedCoords(),i=r.colStart+e,a=this._firstRowTextOf(n.getRange(t).getCell().getFormula(),i,r);if(!a)return!1;let o=this._beginCommit({description:m(`op.tableColumnFill`),operation:{name:`table.columnFill`}});try{let t={...r,colStart:i,colEnd:i};return this._ownWrite(t,()=>{n.getRange(t).setFormula(`=`+a)}),this._rememberCalculated(new Map([[e,a]])),o.commit(),!0}catch(e){throw o.rollback(),e}}_rememberCalculated(e,t=!0){let n=this._getState().orderedColumnsProps,r=[...n];for(let[i,a]of e){let e=n[i];if(!e)continue;let{calculatedColumnFormula:o,...s}=e;if(r[i]=a?{...s,calculatedColumnFormula:this._qualified(a,i)}:s,!t)continue;let c=this._heldCalculated.get(e.id);c&&(c.remove(),this._heldCalculated.delete(e.id))}this._updateColumnsState(r,m(`op.tableColumnFill`)),t&&this._syncHeldCalculated()}_getAutoExpandCoords(e){let t=this._sheet,n=this._getLiveState();if(!t||!n)return null;let r=this._getTransactions();if(r.getCurrentCommit(!1).getId()!==r.getTipCommit().getId())return null;let i=n.anchorCoords,a=t.getEntireRange().getCoords(),o=i.colEnd+1,s=i.rowEnd+1,c=this.getAutoExpand(),l=n.totalsRowCount===0&&(c===Jf.AutoExpand.Both||c===Jf.AutoExpand.Rows),u=c===Jf.AutoExpand.Both||c===Jf.AutoExpand.Columns,d=i.colEnd,f=i.rowEnd,p=e.length;for(let t=0;t<p;t++){let n=e[t];if(n.rowStart>=i.rowStart&&n.rowEnd<=i.rowEnd){if(!u||n.colStart<i.colStart||n.colStart>o)continue;d=Math.max(d,Math.min(n.colEnd,a.colEnd))}else if(l&&n.colStart>=i.colStart&&n.colEnd<=i.colEnd){if(n.rowStart<i.rowStart||n.rowStart>s)continue;f=Math.max(f,Math.min(n.rowEnd,a.rowEnd))}}if(d>i.colEnd&&!Ey(t,{...i,colStart:o,colEnd:d},e)&&(d=i.colEnd),f>i.rowEnd&&!Ey(t,{...i,rowStart:s,rowEnd:f},e)&&(f=i.rowEnd),d===i.colEnd&&f===i.rowEnd)return null;let m={...i,colEnd:d,rowEnd:f};return t.getRange(m).getMerges().length>0||t.getTables().getItems({address:m}).length!==1?null:m}setAutoExpand(e,t){return this._setProps({autoExpand:e},t,m(`op.setAutoExpand`))}getAutoExpand(){return this._sheet?this._getState()?.autoExpand??Jf.AutoExpand.Both:Jf.AutoExpand.None}setFormulaBelow(e,t){return this._setProps({formulaBelow:e},t,m(`op.setFormulaBelow`))}getFormulaBelow(){return this._getState()?.formulaBelow??Jf.FormulaBelow.TotalsRow}setDisabledColumnFill(e,t){return this._setProps({disabledColumnFill:e},t,m(`op.setDisabledColumnFill`))}isDisabledColumnFill(){return(this._getState()?.disabledColumnFill||!this._sheet)??!1}_filterLevels(){let e=this._views().filters,t=e.length,n=[];for(let r=0;r<t;r++){let t=e[r],i=t.getCondition();i&&n.push({index:t.getIndex(),...i.toJSON()})}return n}_anchoredToday(e){let t=this._sheet;if(!t)return e;let n=tv(t.getRuntime()),r=e.map(e=>nv(e,n));return r.some((t,n)=>t!==e[n])?r:e}async _evalReapply(){let e=this._filterLevels();if(e.length===0)return null;let t=this._anchoredToday(e);return{levels:t===e?null:t,runs:await this._evalFilter({conditions:t})}}async applyFilters(e){this._requireLive();let t=await this._evalReapply();if(!t)return this;let n=this._beginCommit({description:m(`op.applyFilters`),...e});try{t.levels?this._writeFilters(t.levels,t.runs):this._applyFilterRuns(t.runs),n.commit()}catch(e){throw n.rollback(),e}return this}deleteFilters(e){return this.filter({conditions:[]},{description:m(`op.deleteFilters`),...e})}getActiveFilters(){return this._views().filters}getFilterAt(e){let t=this._getState()?.orderedColumnsProps[e];return t?this._filterOf(t.id):null}async addSlicer(e,t){let n=typeof e==`string`?this.getColumnByName(e):e;if(!n||n.getTable()!==this)throw new k(N(`error.slicer.noColumn`,{name:typeof e==`string`?e:e.getName()}));let r=t?.sheet??this._sheet;if(!r)throw new k(N(`error.slicer.noColumn`,{name:n.getName()}));let{sheet:i,caption:a,style:o,columnCount:s,...c}=t??{},l=r.getWorkbook(),u=c.name??zv(l,n.getName());if(zv(l,u)!==u)throw new k(N(`error.slicer.nameTaken`,{name:u}));let d={source:this._storedText((f=this.getName(),p=n.getName(),d_.structuredReference(f,p)))};var f,p;a&&(d.caption=a);let h=o||this._styles.getSlicerStyles().getDefault().getName();h!==`SlicerStyleLight1`&&(d.style=h),s!==void 0&&s>1&&(d.columnCount=Math.trunc(s));let g=(await r.getMovables().add({autoPlace:`viewport`,description:m(`op.insertSlicer`),...c,type:`slicer`,json:d,name:u,bounds:{width:Ay,height:jy,...c.bounds}})).getContent();return g._attach?.(),g}_updateSorts(e,t){let n=t.length;for(let e=0;e<n;e++){let n=t[e];if(!n||!n.sortProps)continue;let r={...n};delete r.sortProps,t[e]=r}let r=e?e.length:0;for(let n=0;n<r;n++){let r=e[n],a=r.index??n,o=t[a];if(!o)continue;let s={...o};if(t[a]=s,r.criteria===null){s.sortProps=null;continue}let c=i.cloneObject({...r});delete c.index,s.sortProps={level:n,...c}}}_updateFilters(e,t,n=!1){let r=t.length;for(let e=0;e<r;e++){let n=t[e];if(!n||!n.filterProps)continue;let r={...n};delete r.filterProps,t[e]=r}let i=e?e.length:0,a=0;for(let r=0;r<i;r++){let i=e[r],o=n?Nv.fromJSON(i):Nv.resolveInput(i),s=i?.index??r,c=t[s];if(!c)continue;let l={...c};t[s]=l,l.filterProps=o===null?null:{level:a++,condition:o}}}async filter(e,t){this._requireLive();let n=iv(e),r=n.conditions?{...n,conditions:this._anchoredToday(n.conditions)}:n,i=await this._evalFilter(r),a=this._beginCommit({description:m(`op.filterTable`),...t});try{this._writeFilters(r.conditions,i),a.commit()}catch(e){throw a.rollback(),e}return this}sort(e){this._requireLive();let t=this._beginCommit({description:m(`op.sortTable`),...e});try{let n=[...this._getState().orderedColumnsProps];this._updateSorts(e?.sorts,n),this._writeColumnProps(n),this._clearSortExtent(),e&&e.sorts&&e.sorts.length===0||this._applySorts(e),this._processTableUpdate?.(),this._notify(`onSortChange`),t.commit()}catch(e){throw t.rollback(),e}return this}applySorts(e){this._requireLive();let t=this._views().sorts,n=t.length;if(n===0)return this;let r=Array(n);for(let e=0;e<n;e++){let n=t[e];r[e]={index:n.getIndex(),criteria:n.getCriteria()}}let i={description:m(`op.applySort`),...e,sorts:r,hasHeader:this._getState().headerRowCount>0,axis:B.Axis.Row};return this._applySorts(i,!0),this}deleteSorts(e){return this.sort({description:m(`op.deleteSorts`),...e,sorts:[]})}async applySortsAndFilters(e){this._requireLive();let t=await this._evalReapply(),n=this._beginCommit({description:m(`op.refreshSortsAndFilters`),...e});try{t?.levels?this._writeFilters(t.levels,t.runs):t?.runs&&this._applyFilterRuns(t.runs),this.applySorts(),n.commit()}catch(e){throw n.rollback(),e}return this}async deleteSortsAndFilters(e){this._requireLive();let t=await this._evalFilter({conditions:[]}),n=this._beginCommit({description:m(`op.deleteSortsAndFilters`),...e});try{this.deleteSorts(),this._writeFilters([],t),n.commit()}catch(e){throw n.rollback(),e}return this}getActiveSorts(){return this._views().sorts}getSortAt(e){let t=this._getState()?.orderedColumnsProps[e];return t?this._sortOf(t.id):null}setHiddenButtonAt(e,t){if(this._requireLive(),this.isHiddenButtonAt(e)===t)return this;let n=this._getState(),r=new Map(n.mapHiddenButtons);return t===(n.hiddenButtons??!1)?r.delete(e):r.set(e,t),this._updateState({mapHiddenButtons:r},m(`op.setHiddenButtons`),[`onHiddenButtonsChange`]),this}isHiddenButtonAt(e){let t=this._getState();return!t||(t.mapHiddenButtons.get(e)??t.hiddenButtons??!1)}setHiddenButtons(e){this._requireLive();let t=this._getState();return(t.hiddenButtons??!1)===e&&t.mapHiddenButtons.size===0||this._updateState({hiddenButtons:e,mapHiddenButtons:My},m(`op.setHiddenButtons`),[`onHiddenButtonsChange`]),this}isHiddenButtons(){let e=this._getState();return!e||!0===e.hiddenButtons&&e.mapHiddenButtons.size===0}setHiddenDecorations(e){return this._requireLive(),this.isHiddenDecorations()===e||this._updateState({hiddenDecorations:e},m(`op.setHiddenDecorations`),[`onAnyChange`]),this}isHiddenDecorations(){return this._getState()?.hiddenDecorations??!1}_evalFilter(e){let t=this._sheet;if(!t)return Promise.resolve(null);let n=this._getState(),r=n.anchorCoords,i={...r,rowEnd:r.rowEnd-n.totalsRowCount};return Py(t).evalFilter(i,{...e,hasHeader:n.headerRowCount>0,axis:B.Axis.Row})}_applyFilterRuns(e){e&&Py(this._sheet).applyFilterRuns(e),this._processTableUpdate?.(),this._notify(`onFilterChange`)}_writeFilters(e,t){let n=[...this._getState().orderedColumnsProps];this._updateFilters(e,n),this._writeColumnProps(n),this._applyFilterRuns(t)}_carryFilters(e){this._writeFilters(e,null)}_clearSortExtent(){this._getState().sortExtent&&this._updateState({sortExtent:null},m(`op.sortTable`))}_applySorts(e,t=!1){this._clearSortExtent(),this.getRange().sort({...e,hasHeader:this._getState().headerRowCount>0,axis:B.Axis.Row}),t&&(this._processTableUpdate?.(),this._notify(`onSortChange`))}getColumnAt(e){return this._views().columns[e]??null}_updateColumnsState(e,t){let n=this._getState().lastColId,r=e.length;if(r===0&&!this._sheet)throw Error(N(`error.table.tableNoBody`));let i=Array(r),a,o;for(let t=0;t<r;t++){let r={...e[t]};i[t]=r,r.index=t,a=null,r.id!==void 0&&(o=parseInt(r.id),Number.isInteger(o)&&(n=Math.max(n,o),a=r.id)),a===null&&(n++,a=n+``),r.id=a}return this._writeColumnProps(i,t,n),this._views().columns}_writeColumnProps(e,t,n){Sy(e);let r={orderedColumnsProps:Object.freeze(e)};n!==void 0&&(r.lastColId=n);let i=this._views().filters.length>0;this._updateState(r,t),this._symbolsChanged?.(this),this._views().filters.length>0!==i&&this._filteredChanged?.(this)}getVisibleRefRangeCoords(){return this._ensureVisible(),this._visibleRange?this._visibleRange:this.getFirstAnchorCoords()}getVisibleCellCoords(e){return this._ensureVisible(),e&&this._visibleRange?{colIndex:Math.min(this._visibleRange.colEnd,Math.max(this._visibleRange.colStart,this._sheet.getColumnHeaders().getMetrics().getVisibleIndex(e.colIndex).min)),rowIndex:Math.min(this._visibleRange.rowEnd,Math.max(this._visibleRange.rowStart,this._sheet.getRowHeaders().getMetrics().getVisibleIndex(e.rowIndex).min))}:e}isHeaderVisible(){return this._ensureVisible(),this._isHeaderVisible}isTotalVisible(){return this._ensureVisible(),this._isTotalVisible}isFirstColumnVisible(){return this._ensureVisible(),this._isFirstColumnVisible}isLastColumnVisible(){return this._ensureVisible(),this._isLastColumnVisible}_syncHeader(e){if(e.from===`table`)return void this._writeHeader();let t=this._readHeader(e.keepNameOnBlank??!1);t&&(!t.converted&&ay(t.columns,this._getState().orderedColumnsProps)||(this._updateColumnsState(t.columns,e.description??m(`op.updateColumnsFromSheet`)),t.converted&&(e.write??1)&&this._writeHeader()))}_readHeader(e){let t=this._sheet;if(!t)return null;let n=this._getState().orderedColumnsProps,r=this.getFirstAnchorCoords();if(!r)return null;let i=this._getHeaderCoords();if(!i)return null;let a=r.colEnd-r.colStart+1,o=Array(a).fill(null),s=!1;if(i){let r=0;t.getRange({...i,rowEnd:i.rowStart}).forEach((t,i)=>{let a,c=n[r];t===null?e?(a=c?.name,s=!0):a=null:typeof t==`string`?a=t:(a=i.getCell().getText(),s=!0),o[r]={...c,name:a},r++},{includeEmpty:!0})}let c=iy(n,o,0,!0,this._emptyColumnName,this._emptyColumnNamer);return s||=!ay(o,c),{columns:c,converted:s}}_writeHeader(){let e=this._sheet;if(!e)return;let t=this._getState().orderedColumnsProps,n=this._getHeaderCoords();if(!n)return;let r=m(`op.syncColumnsToSheet`),i=this._beginCommit(r);try{let r=e.getEntireRange().createSparseBuilder({axis:B.Axis.Row}),a=t.length,o=n.rowStart,s=n.colStart;for(let e=0;e<a;e++){let n=t[e].name;n&&r.pushAt(o,s+e,n)}this._ownWrite(n,()=>{r.apply({textParser:!1})}),i.commit()}catch(e){throw i.rollback(),e}}_processDelete(){this._removeHeaderListener(),this._removeHeldTotals(),this._removeHeldCalculated(),this._removeExpandListener();let e=this._namedItem;e&&e.delete(),super._processDelete()}_ownWrite(e,t){let n=this.getId(),r={colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colEnd,rowEnd:e.rowEnd},i=this._getTransactions().beginCommit();try{i.setIntent(vy,e=>({...e,[n]:[...e?.[n]??[],r]})),t(),i.commit()}catch(e){throw i.rollback(),e}}_notOwnWrites(e,t){if(!t)return e;let n=this._getTransactions(),r=n.getCurrentCommit(!0);if(r.getId()!==t)try{r=n.getLog(t,1)[0]??null}catch{r=null}let i=r?.getIntents()[vy]?.[this.getId()];return i&&i.length!==0?e.filter(e=>!i.some(t=>h.isRangeWithinRange(e,t))):e}_refitBody(e,t,n,r,i){let a=r.rowStart,o=r.rowEnd;this._refitBodyRows?.(e,t,n,r,i,()=>{if(!this._getLiveState())return!1;let e=this._getUsedCoords();return!!e&&e.rowStart===a&&e.rowEnd===o})}_processContainerShift(e){if(e.isSplit)throw new k(N(`error.table.tableSplit`));let t=this._getState(),n=e.after,r=e.intersect;if(n&&n.rowStart+t.headerRowCount>=n.rowEnd+1)throw new k(N(`error.table.tableNoBody`));let i=e.axis===B.Axis.Column;if(e.amount<0&&n&&!i){let e=this._getHeaderCoords();if(e&&r.rowStart<=e.rowEnd&&r.rowEnd>=e.rowStart)throw new k(N(`error.table.tableRemoveHeader`));let t=this._getTotalCoords();t&&r.rowStart<=t.rowEnd&&r.rowEnd>=t.rowStart&&this.setShowTotals(!1)}let a=null;if(!i&&e.amount>0&&n){let t=e.before,i=this._getUsedCoords(),o=n.rowStart===t.rowStart&&n.rowEnd===t.rowEnd+e.amount;if(i&&o&&r.rowStart>=i.rowStart){let t=this._calculatedTextsAt(r.rowStart);t&&(a={rowStart:r.rowStart,rowEnd:r.rowStart+e.amount-1,texts:t})}}let o=null;if(!i&&e.amount>0&&n){let i=e.before,a=this._getUsedCoords(),s=n.rowStart===i.rowStart&&n.rowEnd===i.rowEnd+e.amount;a&&s&&r.rowStart===a.rowStart?o={match:{rowStart:a.rowStart+e.amount,rowEnd:a.rowEnd+e.amount},headerRow:null,afterShift:!0}:a&&s&&r.rowStart>a.rowEnd&&(o={match:{rowStart:a.rowStart,rowEnd:a.rowEnd},headerRow:t.headerRowCount>0?i.rowStart:null,afterShift:!1})}let s=super._processContainerShift(e);if(a&&this._writeCalculatedRows(a.rowStart,a.rowEnd,a.texts),o){let e=this._getUsedCoords();e&&this._refitBody(e,o.match,o.headerRow,e,o.afterShift)}if(i){let t=e.amount,n=r.colStart-e.before.colStart,i=t>0;if(n<=0&&i)return s;n<0&&(t-=n,n=0);let a=[...this._getState().orderedColumnsProps];i?a=function(e,t,n,r=qv(),i=Jv){let a=Array(n),o=e.length;t<0&&(t=o),e.splice(t,0,...a);let s=ry(e,r)(),c=s!==0&&s<o,l=0;if(s===0){let t=new Set,n=e.length;for(let r=0;r<n;r++){let n=e[r]?.name;if(!n)continue;let i=Yv(n);t.add(i)}for(let e=0;s===0&&e<n;e++){let n=Yv(i(r,e));t.has(n)&&(s=e)}s===0&&(s=o-1)}let u=c?null:e[t-1]?.name;(c||s>=o)&&(l=s);for(let e=0;e<n;e++){let t;c||l<s?(t=i(r,l),u=t,l++):t=u,a[e]={...a[e],name:t}}return iy(e,a,t,!1,r,i)}(a,n,t):a.splice(n,-t),this._updateColumnsState(a,m(i?`op.addColumns`:`op.deleteColumns`)),i&&this._syncHeader({from:`table`})}else n||this._updateColumnsState([],m(`op.deleteColumns`));return n||this._delete(),this._processAnchorCoords(),s}_setProps(e,t,n){let r=by(this._requireLive(),e);if(!r)return this;let i=[];r.style!==void 0&&i.push(`onStyleChange`);let a=this._beginCommit(Cy(t,n));try{if(this._updateState(r,t),r.name!==void 0){if(!r.name)throw Error(N(`error.table.tableNoName`));this._setContainerName?.(r.name)}r.style!==void 0&&(this._styleCache=null,this._stylePropsCache=null),r.autoExpand===void 0&&r.disabledColumnFill===void 0||this._syncListenersToAnchor(),a.commit()}catch(e){throw a.rollback(),e}return this._notify(i),this}_setBands(e,t,n,r){let i=this._requireLive(),a=by(i,{headerRowCount:e,totalsRowCount:t});if(!a)return this;let o=i.headerRowCount,s=i.totalsRowCount,c=a.totalsRowCount??s,l=this._beginCommit(Cy(n,r));try{c<s&&this._holdTotalsFromCells(),this._updateState(a,n),this._ensureHeightForHeaderTotals(i.anchorCoords,o,s,a.headerRowCount,a.totalsRowCount)&&(this._syncHeader({from:`table`}),c>s&&this._showTotalsFromProps()),this._syncListenersToAnchor(),l.commit()}catch(e){throw l.rollback(),e}return this}_setAnchor(e,t,n,r=!1){let i=this._requireLive().anchorCoords;if(h.isEqualRanges(e,i))return this;let a=!!this._sheet&&e.rowEnd!==i.rowEnd&&this._getTotalCoords()!==null,o=this._getUsedCoords(),s=o&&e.rowEnd>i.rowEnd&&e.rowStart===i.rowStart&&e.colStart===i.colStart?this._calculatedTextsAt(o.rowEnd+1):null,c=this._beginCommit(Cy(t,n));try{if(a&&this._moveTotalsRow(i,e.rowEnd),this._updateState({anchorCoords:e},t,null,r),!this._getUsedCoords())throw Error(N(`error.table.tableNoBody`));let n=this._spliceColumnsToAnchor(i,e);e.rowStart===i.rowStart&&e.rowEnd===i.rowEnd||this._calcVisible(),this._syncHeader({from:`sheet`,keepNameOnBlank:!0,description:m(`op.syncColumnsFromSheet`),write:!1}),this._options.setContainerCoords?.(e),n&&this._syncHeader({from:`table`}),s&&this._writeCalculatedRows(o.rowEnd+1,this._getUsedCoords().rowEnd,s);let l=this._getUsedCoords();if(o&&l&&l.rowStart===o.rowStart&&l.rowEnd!==o.rowEnd){let t={colStart:Math.max(l.colStart,o.colStart),colEnd:Math.min(l.colEnd,o.colEnd)},n=this._getState().headerRowCount>0?e.rowStart:null;t.colStart<=t.colEnd&&this._refitBody(t,o,n,l,!1)}this._syncListenersToAnchor(),c.commit()}catch(e){throw c.rollback(),e}return this}_moveTotalsRow(e,t){let n=this._sheet,r=this._getState().totalsRowCount,i=t>e.rowEnd,a={...e,rowEnd:Math.min(e.rowEnd,t)-r};this._updateState({anchorCoords:a,totalsRowCount:0}),this._options.setContainerCoords?.(a);let o=t=>({...e,rowStart:t,rowEnd:t});if(i){let i=t-e.rowEnd,a=n.getRange({...e,rowStart:e.rowEnd+1,rowEnd:t}),o=t+i;if(o<=n.getEntireRange().getCoords().rowEnd&&!a.isContentful()&&a.getMerges().length===0)return n.getRange({...e,rowStart:e.rowEnd,rowEnd:t-1}).insert(B.Axis.Row),n.getRange({...e,rowStart:t+1,rowEnd:o}).delete(B.Axis.Row),void this._updateState({totalsRowCount:r})}n.getRange(o(i?t+1:t)).insert(B.Axis.Row);let s=i?e.rowEnd:e.rowEnd+1,c=i?t+1:t,l=n.getEntireRange().createSparseBuilder({axis:B.Axis.Row}),u=e.colEnd-e.colStart+1,d=Array(u);for(let t=0;t<u;t++){let n=this._totalsCellAt(o(s),t).getCell();d[t]=n,l.pushAt(c,e.colStart+t,{style:n.getStyle(!0)})}this._ownWrite(o(c),()=>{l.apply();for(let e=0;e<u;e++){let t=d[e],n=this._totalsCellAt(o(c),e),r=t.getFormulaText();if(r){n.setFormula(r);continue}let i=t.getValue();i!==null&&n.setValue(i,{textParser:!1})}}),n.getRange(o(s)).delete(B.Axis.Row),this._updateState({totalsRowCount:r})}_spliceColumnsToAnchor(e,t){if(t.colStart===e.colStart&&t.colEnd===e.colEnd)return!1;let n=this._getState().orderedColumnsProps;if(t.colEnd-t.colStart+1===n.length)return!1;let r=[...n];if(t.colEnd>e.colEnd)r.splice(r.length,0,...Array(t.colEnd-e.colEnd)),r=iy(null,r,0,!0,this._emptyColumnName,this._emptyColumnNamer);else if(t.colEnd<e.colEnd){let n=e.colEnd-t.colEnd;r.splice(r.length-n,n)}return t.colStart<e.colStart?(r.splice(0,0,...Array(e.colStart-t.colStart)),r=iy(null,r,0,!0,this._emptyColumnName,this._emptyColumnNamer)):t.colStart>e.colStart&&r.splice(0,t.colStart-e.colStart),this._updateColumnsState(r,m(`op.updateColumns`)),!0}addListeners(e,t){return this._getEmitter().addListeners(e,t)}_processAfterStateChange(e,t){super._processAfterStateChange(e,t),this._styleCache=null,this._stylePropsCache=null,e&&this._processTableUpdate?.(),this._emitter.notify(`onAnyChange`)}_isAnyChangeFromState(){return!0}_getHeaderListenerCoords(){let e=this._getHeaderCoords();if(e)return e;let t=this._getUsedCoords();return t?{...t,rowEnd:t.rowStart}:null}_removeHeaderListener(){this._headerRemoveListener?.(),this._headerRemoveListener=void 0,this._headerListenerCoords=null}_processHeaderListener(){this._removeHeaderListener();let e=this._sheet;if(!e)return;let t=this._getHeaderListenerCoords();t&&(this._headerRemoveListener=e.getRange(t).addListener(this._columnListener,{transactional:!0}),this._headerListenerCoords=t)}get[Symbol.toStringTag](){return`[Table]`}toString(){return this.getName()??``}toJSON(){let e={},t=this._getState();if(!t)return null;t.name&&(e.name=t.name),t.description&&(e.description=t.description),t.headerRowCount!==1&&(e.headerRowCount=t.headerRowCount),t.totalsRowCount!==0&&(e.totalsRowCount=t.totalsRowCount),t.totalsRowShown&&(e.totalsRowShown=!0),t.autoExpand!==Jf.AutoExpand.Both&&(e.autoExpand=t.autoExpand),t.formulaBelow!==Jf.FormulaBelow.TotalsRow&&(e.formulaBelow=t.formulaBelow),t.disabledColumnFill&&(e.disabledColumnFill=t.disabledColumnFill);let n=this._views().columns;if(n){let t=n.length,r=Array(t);for(let e=0;e<t;e++){let t=n[e]?.toJSON();t&&(r[e]=t)}e.columns=r}if(t.style){let n=i.diffValues(t.style,{...Xv,name:null});n&&(e.style=n)}let r=this._views().sorts,a=r.length;if(a>0){let n=t.orderedColumnsProps,i=Array(a);for(let e=0;e<a;e++){let t=r[e]?.getIndex(),a=n[t];if(!a)continue;let o={...a.sortProps,index:t};delete o.level,i[e]=o}e.sort={sorts:i},t.sortExtent&&(e.sort.extent=t.sortExtent)}let o=this._views().filters,s=o.length;if(s>0){let n=t.orderedColumnsProps,r=[];for(let e=0;e<s;e++){let t=o[e]?.getIndex(),i=n[t];if(!i)continue;let a=i.filterProps?.condition;if(!a)continue;let s=a.toJSON();s.index=t,r.push(s)}e.filter={conditions:r}}let c=t.mapHiddenButtons;if(!0===t.hiddenButtons&&c.size===0)e.hiddenButtons=!0;else if(!0===t.hiddenButtons||c.size>0){let n=[],r=t.orderedColumnsProps.length;for(let e=0;e<r;e++)this.isHiddenButtonAt(e)&&n.push(e);n.length>0&&(e.hiddenButtons=n)}return t.hiddenDecorations&&(e.hiddenDecorations=!0),e}getWorksheet(){return this._sheet??null}_createNamed(){return this._names?new cy(this._sheet,this,{transactions:this._getTransactions(),json:{name:this.getName()}}):null}_fromJSON(e){let t=e??{},n=m(`op.addTable`),r=this.getFirstAnchorCoords(),i=r.colEnd-r.colStart+1,a=function(e,t=qv(),n=Jv){let r=Array(e);for(let i=0;i<e;i++)r[i]={name:n(t,i)};return r}(i);i>1&&(a[0].totalsRowLabel=Gv(m(`table.totalsRowLabel`),`Total`));let o=t.columns;o&&(o.length>i&&(o=o.slice(0,i)),a=ny(o));let s=this._options,c=!!this._sheet&&(!s.syncSheet||!!s.hasTotals)&&(t.totalsRowCount??0)>0,l=t.name??``,u=t.name??this._getState().name;this._names&&(u=this._names.findValidName(u));let d=l!==``&&l.toLowerCase()!==u.toLowerCase(),f=(e,t)=>d?Pv(e,{rowIndex:r.rowStart,colIndex:r.colStart+t},l,u):e;a=a.map((e,t)=>{if(!e||e.totalsRowLabel===void 0&&e.totalsRowFormula===void 0)return e;if(c){let{totalsRowLabel:t,totalsRowFormula:n,...r}=e;return r}let n=e.totalsRowFormula;if(typeof n!=`string`)return e;let r=ey(n,l,e.name);return{...e,totalsRowFormula:r??f(n,t)}}),a=a.map((e,t)=>{let n=e?.calculatedColumnFormula;if(typeof n!=`string`)return e;let r=f(n.startsWith(`=`)?n.substring(1):n,t);return r===n?e:{...e,calculatedColumnFormula:r}}),this._updateColumnsState(a,n);let p=this._getState(),h={};u!==p.name&&(h.name=u);let g=t.description??p.description;g&&(h.description=g.trim()),h.headerRowCount=t.headerRowCount??1,h.totalsRowCount=t.totalsRowCount??0,h.totalsRowShown=t.totalsRowShown??c,h.autoExpand=t.autoExpand??Jf.AutoExpand.Both,h.formulaBelow=t.formulaBelow??Jf.FormulaBelow.TotalsRow,h.disabledColumnFill=t.disabledColumnFill??!1;let _=t.style;typeof _==`string`&&(_={name:_}),h.style={...Xv,..._};let v=t.sort,y=t.filter;if(v||y){let e=[...p.orderedColumnsProps];v&&(this._updateSorts(v.sorts,e),h.sortExtent=v.extent??null),y&&this._updateFilters(y.conditions,e,!0),Sy(e),h.orderedColumnsProps=Object.freeze(e)}let b=t.hiddenButtons;if(b!==void 0){if(Array.isArray(b)){h.hiddenButtons=!1;let e=b.length,t=new Map;for(let n=0;n<e;n++){let e=b[n];t.set(e,!0)}h.mapHiddenButtons=t}else h.hiddenButtons=b,h.mapHiddenButtons=My}t.hiddenDecorations&&(h.hiddenDecorations=!0),this._updateState(h,n)}close(){super.close(),this.isClosed()||(this._removeExpandListener(),this._removeHeaderListener(),this._removeHeldTotals(),this._removeHeldCalculated(),this._stylesRemoveListener?.(),this._colHeadersSizeUnlistener?.(),this._rowHeadersSizeUnlistener?.())}isDeleted(){if(this.isClosed())return!0;let e=this._getState();return!e||e.isDeleted}_getLiveState(){if(this.isClosed())return null;let e=this._getState();return e&&!e.isDeleted?e:null}_requireLive(){let e=this._getLiveState();if(!e)throw Error(`Table has been deleted. No further operations are allowed.`);return e}_requireSheet(){let e=this._sheet;if(!e)throw Error(`Table is not on a sheet. A preview table has no cells to operate on.`);return e}get isITable(){return!0}},by=(e,t)=>{let n=null,r=Object.keys(t);for(let a=0;a<r.length;a++){let o=r[a],s=t[o];if(s===void 0)continue;let c=e[o],l=c===s;l||o!==`anchorCoords`?!l&&o===`style`&&c&&s&&(l=i.diffValues(s,c)===null&&i.diffValues(c,s)===null):l=ky(c,s),l||(n??={},n[o]=s)}return n},xy=(e,t)=>{let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n)if((e[r]??null)!==(t[r]??null))return!1;return!0},Sy=e=>{let t=[],n=[],r=e.length;for(let i=0;i<r;i++){let r=e[i];r&&(r.sortProps&&t.push(i),r.filterProps&&n.push(i))}t.sort((t,n)=>e[t].sortProps.level-e[n].sortProps.level),n.sort((t,n)=>e[t].filterProps.level-e[n].filterProps.level);for(let n=0;n<t.length;n++){let r=e[t[n]];r.sortProps.level!==n&&(e[t[n]]={...r,sortProps:{...r.sortProps,level:n}})}for(let t=0;t<n.length;t++){let r=e[n[t]];r.filterProps.level!==t&&(e[n[t]]={...r,filterProps:{...r.filterProps,level:t}})}},Cy=(e,t)=>e?.description?e:{...e,description:t},wy=e=>{e.sort((e,t)=>e[0]-t[0]);let t=0,n=-1,r=e.length;for(let i=0;i<r;i++){let[r,a]=e[i];a<=n||(t+=a-Math.max(r,n+1)+1,n=a)}return t},Ty=(e,t)=>{let n=h.intersectRanges(e,t);if(!n)return[e];let r=[];return n.rowStart>e.rowStart&&r.push({...e,rowEnd:n.rowStart-1}),n.rowEnd<e.rowEnd&&r.push({...e,rowStart:n.rowEnd+1}),n.colStart>e.colStart&&r.push({...n,colStart:e.colStart,colEnd:n.colStart-1}),n.colEnd<e.colEnd&&r.push({...n,colStart:n.colEnd+1,colEnd:e.colEnd}),r},Ey=(e,t,n)=>{let r=[t],i=!1,a=n.length;for(let o=0;o<a;o++){let a=h.intersectRanges(t,n[o]);if(!a)continue;!i&&e.getRange(a).isContentful()&&(i=!0);let s=[];for(let e=0;e<r.length;e++){let t=Ty(r[e],a);for(let e=0;e<t.length;e++)s.push(t[e])}r=s}if(!i)return!1;for(let t=0;t<r.length;t++)if(e.getRange(r[t]).isContentful())return!1;return!0},Dy=(e,t)=>{let n=null;for(let r=0;r<t.length;r++){let i=t[r],a=e.getRange(i),o=(i.rowEnd-i.rowStart+1)*(i.colEnd-i.colStart+1);if(a.getCounts(Qh.Feature.Formula)[Qh.Feature.Formula]!==o)return null;for(let e of a.getRegions(Qh.Feature.Formula)){let t=e.getCell().getFormulaText({r1c1:!0});if(t===null||n!==null&&n!==t)return null;n=t}}return n},Oy=(e,t)=>(e.totalsRowLabel||void 0)===(t.totalsRowLabel||void 0)&&e.totalsRowFormula===t.totalsRowFormula,ky=(e,t)=>e&&t?h.isEqualRanges(e,t):e===t,Ay=192,jy=280,My=new Map,Ny=new Map,Py=e=>e._getInternal(),Fy=Object.freeze({}),Iy=Object.freeze({}),Ly=Object.freeze({criteria:null,level:-1}),Ry=Object.freeze({condition:null,level:-1}),zy=class extends oy{getName(){let e,t=this.getIndex(),n=this.getTable(),r=n.getWorksheet();if(r){let i=n.getRange().getCoords().colStart;e=r.getColumnHeaders().getTextAt(i+t)}return e||=`Column ${t+1}`,e}setName(e){throw Error(N(`error.table.autoTableInvalidOperation`))}getId(){return this._getProps(this._id).id??null}getIndex(){return this._getProps(this._id).index??-1}setTotalsRowLabel(e){throw Error(N(`error.table.autoTableInvalidOperation`))}getTotalsRowLabel(){return null}setTotalsRowFormula(e){throw Error(N(`error.table.autoTableInvalidOperation`))}getTotalsRowFormula(){return null}delete(e){throw Error(N(`error.table.autoTableInvalidOperation`))}get[Symbol.toStringTag](){return`[AutoTableColumn]`}toJSON(){return null}},By=class extends yy{_initialize(e){let t={...e.json};e={...e,json:t},t.autoExpand=Jf.AutoExpand.None,t.disabledColumnFill=!0,t.name=Gv(m(`table.autoTableName`),`AutoTable`),t.description=Gv(m(`table.autoTableDescription`),`AutoTable created for filtering and sorting`),e.names=null,e.styles=new Pm,e.setContainerName=e=>{throw Error(N(`error.table.autoTableInvalidOperation`))},super._initialize(e)}initializeColumnCreator(e,t,n,r){return i=>new zy(e,i,t,n,r)}_processHeaderListener(){}_syncHeader(){}_calcVisible(){}isShowHeaders(){return!1}addRows(e,t=1,n){throw Error(N(`error.table.autoTableInvalidOperation`))}addColumn(e=-1,t,n,r){throw Error(N(`error.table.autoTableInvalidOperation`))}deleteRowsAt(e,t=1,n){throw Error(N(`error.table.autoTableInvalidOperation`))}getColumnByName(e){throw Error(N(`error.table.autoTableInvalidOperation`))}convertToRange(e=2**53-1,t){throw Error(N(`error.table.autoTableInvalidOperation`))}delete(e){this._remove()}setName(e,t){throw Error(N(`error.table.autoTableInvalidOperation`))}async addSlicer(e,t){throw Error(N(`error.table.autoTableInvalidOperation`))}setDescription(e,t){throw Error(N(`error.table.autoTableInvalidOperation`))}updateStyleOptions(e,t=m(`op.updateStyleInfo`)){throw Error(N(`error.table.autoTableInvalidOperation`))}setShowTotals(e,t){throw Error(N(`error.table.autoTableInvalidOperation`))}setShowHeaders(e,t){throw Error(N(`error.table.autoTableInvalidOperation`))}setShowHighlightFirstColumn(e,t){throw Error(N(`error.table.autoTableInvalidOperation`))}setShowHighlightLastColumn(e,t){throw Error(N(`error.table.autoTableInvalidOperation`))}setShowBandedColumns(e,t){throw Error(N(`error.table.autoTableInvalidOperation`))}setShowBandedRows(e,t){throw Error(N(`error.table.autoTableInvalidOperation`))}_resize(e,t,n=m(`op.resizeTable`)){throw Error(N(`error.table.autoTableInvalidOperation`))}get[Symbol.toStringTag](){return`[AutoTable]`}toString(){return this.getRange().toString()}toJSON(){let e=super.toJSON();return e?(delete e.name,delete e.description,delete e.style,delete e.columns,delete e.autoExpand,delete e.formulaBelow,delete e.disabledColumnFill,delete e.totalsRowCount,delete e.headerRowCount,e):null}},Vy=class extends Qt{constructor(e){super(e.transactions),this._options={...e};let t=this;this._transactions=this._options.transactions??new se({transient:!0}),this._stateId=this._transactions.create(),this._transactionsRemoveListener=this._transactions.addStateListener(this._stateId,{onAfterStateChange(e,n){t._notifyCollectionChange()}}),this._initState(e?.initial)}add(e,t,n){let r=this;this._assertWritable(),t&&(t._setBeforeDelete?.(()=>r._assertWritable()),t.addListeners({onDelete:t=>{r._updateState(t=>{if(!t.modules[e])return;let n=t.modules[e];if(n){let i={...t};return r._options.onRemove?.(e,n),r._notifyCollectionChange(),delete i.modules[e],i}return t},m(`op.deleteModule`))}},{once:!0}));let i=this._getState()?.modules,a=i?.[e],o=n?.replace??!1;if(a&&!o)throw Error(`Already existing '${e}'`);let s={...i};t?(s[e]=t,r._options.onAdd?.(e,t),this._updateState({modules:s},m(o?`op.saveScripts`:`op.addScript`))):(delete s[e],r._options.onRemove?.(e,null),this._updateState({modules:s},m(`op.removeScript`))),r._notifyCollectionChange()}_getItems(e){let t=this._getState();if(!t)return i.EmptyArray;let n=t.modules,r=Object.keys(n),a=r.length;if(a===0)return i.EmptyArray;let o=[],s=e?.name?e.name.toUpperCase():null,c=e&&`language`in e?e.language===null?null:String(e.language).toUpperCase():`TYPESCRIPT`;for(let e=0;e<a;e++){let t=r[e],i=n[t],a=!0;s&&s!==t.toUpperCase()&&(a=!1),a&&c&&i.getLanguage().toUpperCase()!==c&&(a=!1),a&&o.push(i)}return o??i.EmptyArray}getByName(e){if(!e)return null;let t=this._getState();if(!t)return null;let n=e.toUpperCase(),r=t.modules,i=Object.keys(r),a=i.length;for(let e=0;e<a;e++){let t=i[e];if(n===t.toUpperCase())return r[t]}return null}beginCommit(e){return this._beginCommit(e)}_assertWritable(){if(this._options.isReadOnly?.())throw new b(N(`error.workbook.protection`))}_getState(){if(this.isClosed())throw Error(N(`error.model.modelClosed`));return this._transactions.getState(this._stateId)}_beginCommit(e){return this._transactions.beginCommit(typeof e==`string`?{description:e}:e)}_updateState(e,t=m(`op.update`),n){if(!e)return;let r=this._beginCommit(t);try{r.updateState(this._stateId,e),r.commit(n)}catch(e){throw r.rollback(),e}}_initState(e){let t=e??{},n=this._beginCommit(m(`op.initialize`));try{n.updateState(this._stateId,{modules:t}),n.amend()}catch(e){throw n.rollback(),e}let r=this._options.onAdd;if(r){let e=Object.keys(t),n=e.length;for(let i=0;i<n;i++){let n=e[i];r(n,t[n])}}}addListeners(e,t){return super.addListeners(e,t)}toJSON(){let e=this._getState();if(!e)return i.EmptyArray;let t=e.modules,n=Object.keys(t),r=n.length,a={};for(let e=0;e<r;e++){let r=n[e];a[r]=t[r].toJSON()}return a}close(){this.isClosed()||(this._close(),this._transactionsRemoveListener?.())}get isFunctionCollection(){return!0}get isIModuleCollection(){return!0}};(hy||={}).Context={Workbook:`workbook`,Sheet:`sheet`,Ranges:`ranges`,Range:`range`,Script:`script`,Calculation:`calculation`};var Hy={FormulaContext:gy,ScalarType:U,IRange:B,FormulaError:V,Observable:Gt,checkRun:qt.check},Uy=()=>(gy||(gy=Bt,Hy.FormulaContext=gy),gy),Wy=[];function Gy(e){Wy.push(e),Uy()._setScope(e)}function Ky(){Wy.length>0&&Wy.pop();let e=Wy.length;Uy()._setScope(e>0?Wy[e-1]??null:null)}var qy=class{constructor(){this.isCalcSignal=!0}},Jy=e=>!0===e?.isCalcSignal,Yy=e=>typeof e==`object`&&!!e&&!0===e.isFunctionValue,Xy=class e{constructor(){this.isLazy=!0,this._value=void 0,this._forced=!1,this._owner=null,this._node=null,this._regs=null,this._frame=null,this._row=-1,this._col=-1}static{this._pool=[]}static{this._depth=0}static enter(){return e._depth++}static leave(t){e._depth=t}static deferred(t,n,r,i,a,o,s,c){let l=e._pool,u=l[t];u===void 0&&(u=l[t]=[]);let d=u[n];return d===void 0&&(d=u[n]=new e),d._owner=r,d._node=i,d._regs=a,d._frame=o,d._row=s,d._col=c,d._forced=!1,d._value=void 0,d}static of(t){let n=new e;return n._value=t,n._forced=!0,n}_fill(e){this._value=e,this._forced=!0}_force(){return this._forced||(this._forced=!0,this._value=this._owner._valueOfLazy(this._node,this._regs,this._frame,this._row,this._col)),this._value}getValue(){return this._force()}get[Symbol.toStringTag](){return`[LazyValue(${this._forced?`filled`:`deferred`})]`}},Zy=null,Qy=()=>Zy??=class extends vb{constructor(e){super({name:``,parameters:e.params.map(e=>e.optional?{name:e.name,optional:!0}:{name:e.name})},()=>V.BuiltIn.Calc,()=>null),this._apply=e.makeCallable()}isLambda(){return!0}execute(...e){let t;try{t=this._apply(...e)}catch(e){if(Jy(e)||!V.isError(e))throw e;return e}return Array.isArray(t)&&(t=t.length===1?t[0]:V.BuiltIn.Value),Yy(t)?V.BuiltIn.Calc:!0===t?.isIReferenceRange&&t.size===1?t.getValueAt(0,0):t??null}},$y=e=>new(Qy())(e),eb=class e{constructor(){this._params=null,this._volatile=!1,this._args=tb,this._start=0,this._end=0,this._variadic=-1,this._suffix=0,this._period=1,this._values=null,this._child=null,this._deferCount=0,this._deferServed=null}_bind(e,t,n,r,i,a){this._params=e??null,this._volatile=a,this._args=r,this._start=0,this._end=i,this._variadic=t,this._suffix=n,this._period=1,this._values=null,this._deferCount=0,this._deferServed=null}_noteServed(e){this._deferCount++,this._deferServed=e}_takeServed(){let e=this._deferCount,t=this._deferServed;if(this._deferCount=0,this._deferServed=null,e===1&&t!==null)return t.latest}_bindNested(e,t,n,r,i){this._params=e,this._args=t,this._start=n,this._end=r,this._variadic=-1,this._suffix=0,this._period=e.length||1,this._values=i}_setLiftValues(e){this._values=e}_setPrivateArgs(e){this._args=e}_groupEnd(){return this._end-this._suffix}_paramAt(e){let t=this._params;return t?this._period>1?t[e%this._period]??null:t[e]??null:null}_argAt(e){if(e<0)return-1;let t=this._variadic,n;return n=t<0||e<t?this._start+e:e===t?this._start+t:this._groupEnd()+(e-t-1),n>=this._start&&n<this._end?n:-1}_valueAt(e){let t=this._values;return t!==null&&e<t.length?t[e]:this._args[e]}getLength(){let e=this._end-this._start,t=this._variadic;return t<0||e<=t?e:t+ +(this._groupEnd()-this._start-t>0)+this._suffix}getRawAt(e){if(e===this._variadic){let t=this._start+e,n=this._groupEnd(),r=[];for(let e=t;e<n;e++)r.push(rb(this._valueAt(e)));return r}let t=this._argAt(e);if(!(t<0))return rb(this._valueAt(t))}getRepeatingArgsAt(t){if(t!==this._variadic||!this._params)return nb;let n=this._params[t],r=n.repeating??[n],i=this._child??=new e;return i._bindNested(r,this._args,this._start+t,this._groupEnd(),this._values),i}getKindAt(e){let t=this._argAt(e);return t<0||this._args[t]===void 0?Wt.Omitted:ib(this._valueAt(t))}getAreaCountAt(e){let t=this._argAt(e);if(t<0)return 0;let n=this._valueAt(t);return AB(n)?n.length:+(ib(n)===Wt.Reference)}getFunctionsAt(e){let t=this._argAt(e);return t<0?null:(e=>{if(Yy(e))return[e];if(!0!==e?.isIRange)return null;let t=e,n=[];for(let e of t.entries()){let t=e.value;if(!Yy(t))return null;n.push(t)}return n.length===0||n.length!==t.size?null:n})(this._valueAt(t))}isDirectAt(e){let t=this.getKindAt(e);return t!==Wt.Reference&&t!==Wt.Array&&t!==Wt.Lambda&&t!==Wt.Omitted}},tb=[],nb=new eb,rb=e=>{if(e!==void 0){if(typeof e==`object`&&e&&!0!==e.isIRange&&e.colStart!==void 0)return Bt.getReference(e);if(AB(e)){let t=e.map(rb);return e.isSheetSpan&&(t.isSheetSpan=!0),t}if(!0===e?.isIRange&&!0===e._isDirectScalarBox?.())return e.getValueAt(0,0);if(typeof e!=`symbol`)return e}},ib=e=>{if(e===void 0)return Wt.Omitted;if(e===null)return Wt.Null;let t=typeof e;return t===`number`?Wt.Number:t===`string`?Wt.String:t===`boolean`?Wt.Boolean:t===`symbol`?Wt.Omitted:t===`function`||Yy(e)?Wt.Lambda:V.isError(e)?Wt.Error:!0===e.isIRange?!0===e.isIReferenceRange?Wt.Reference:!0===e._isDirectScalarBox?.()?ib(e.getValueAt(0,0)):Wt.Array:e.colStart===void 0?Array.isArray(e)?AB(e)?Wt.Reference:Wt.Array:Wt.RichData:Wt.Reference},ab=[],ob=0,sb=()=>ob>0?ab[ob-1]._params:null,cb=()=>ob>0&&ab[ob-1]._volatile,lb=e=>{ob>0&&ab[ob-1]._noteServed(e)};Bt._setArgsProvider(()=>ob>0?ab[ob-1]:null);var ub,db=(e,t)=>e.acceptError?`accept`:t===U.Error?null:`reject`,fb=(e,t,n,r)=>{if(n&&r!==0)for(let i=0;i<t;i++){if(!0!==n[i<r?i:r-1]?.lazy)continue;let t=e[i];Ht(t)||(e[i]=Xy.of(t))}},pb=e=>{let t=e.checkArity,n=typeof t==`function`,r=(...r)=>{if(n&&!t(r.length))throw V.BuiltIn.Value;return(e=>{let t=e;if(Array.isArray(t)){if(t.length!==1)throw V.BuiltIn.Calc;t=t[0]}if(!0===t?.isIRange){if(t.size!==1)throw V.BuiltIn.Calc;t=t.getValueAt(0,0)}else if(t!==null&&t?.colStart!==void 0){let e=t;if(e.rowStart!==e.rowEnd||e.colStart!==e.colEnd)throw V.BuiltIn.Calc;try{t=Bt.getValueAt(e.rowStart,e.colStart,e.scope??void 0)}catch(e){if(!V.isError(e))throw e;t=e}}return Yy(t)?V.BuiltIn.Calc:t??null})(e(...r))};return r.isLambdaCallable=e.isLambdaCallable,r.checkArity=t,r.paramCount=e.paramCount,r},mb=Symbol(`enumRefused`),hb=e=>{if(e.type===U.String){let t=new Map;for(let[,n]of e.members)t.set(n.toLowerCase(),n);return{numbers:null,strings:t}}let t=new Set;for(let[,n]of e.members)t.add(n);return{numbers:t,strings:null}},gb=(e,t)=>typeof t==`number`?e.numbers?.has(t)?t:mb:typeof t==`string`?e.strings?.get(t.toLowerCase())??mb:t===void 0||V.isError(t)?t:mb,_b=e=>{let t=e?.length??0,n=Array(t);for(let r=0;r<t;r++){let t=e[r],i=t.scalar??null;i!==U.Null&&i!==`*`||(i=null);let a=t.range===`*`,o=a?`r`:t.range??null,s=t.rest??!1,c=t.lambda!=null,l=!0===t.lazy,u=(t.arrayDepth??0)>0,d=!0===t.acceptError,f=db(t,i),p=(i===null||i===U.Error||f===`accept`)&&f!==`reject`,m=!(s||t.range||c||u),h=!t.enum||!0===t.reportType||t.scalar===`*`||t.range&&!0!==t.valueOrRange?null:hb(t.enum);n[r]={scalarType:i,isAny:a,rangeType:o,rest:s,optional:t.optional??!1,isLambda:c,lazy:l,flatten:u,liftTrigger:m,acceptError:d,policy:f,allowError:p,valueOrRange:!0===t.valueOrRange,reportType:!0===t.reportType,wholeReference:m&&!0===t.noLift&&!0===t.reportType,enumGate:h,simple:m&&h===null}}return n},vb=class e{constructor(e,t,n,r=null,i=!1){this._ct=hy.Context.Calculation,this._builtIn=!1,this._lc=!1,this._rlc=!1,this._nl=!1,this._lz=!1,this._nmf=!1,this._rs=null,this._rref=!0,this._rkScalar=!1,this._pj=null,this._gi=-1,this._va=-1,this._vol=!1,this._gc=null,this._mx=Ob,this._json=e,this._n=e.name,this._d=new kb(e),this._vol=!0===this._d.getReturnType()?.isVolatile(),this._mx=this._d.getMaxArguments(),this._ct=e.context??hy.Context.Calculation;let a=e.parameters,o;this._pj=a,this._ps=_b(a),t||=(console.log(`TypeFunction '${e.name}' was not provided a function implementation.`),()=>{}),this._fn=t.bind(this),this._cf=n??bb,this._builtIn=i,this._cfp={argsValues:null,argsLength:0},o=r?typeof r==`function`?r:()=>Promise.resolve(r):yb(e),this._descFn=o;let s=a?.length??0,c=!1,l=!1,u=(e,t)=>{let n=e.repeating;if(n){let e=n.length===1;for(let t=0;t<n.length;t++)u(n[t],e)}else t||e.range||e.lambda!=null||(e.arrayDepth??0)!==0||(c=!0),e.range===`p`&&(l=!0)};for(let e=0;e<s;e++){let t=a[e];t.repeating&&(this._gi=e),u(t,t.rest??!1)}this._lc=c,this._rlc=l;let d=this._gi;d<0&&s>0&&a[s-1].rest&&(d=s-1),this._va=d,this._nl=!0===e.parameters?.some(e=>!0===e.noLift),this._nmf=!0===e.parameters?.some(e=>!0===e.noFilter||!0===e.repeating?.some(e=>!0===e.noFilter)),this._lz=!0===e.parameters?.some(e=>!0===e.lazy||e.repeating?.some(e=>!0===e.lazy));let f=e.returnType?.scalar;f!==U.Null&&f!==`*`||(f=null),this._rs=f??null;let p=e.returnType,m=Eb(p);this._rref=!p||m===Wt.Reference,this._rkScalar=m!==null&&m!==Wt.Reference&&m!==Wt.Array&&m!==Wt.Lambda&&m!==Wt.Omitted}execute(...e){let t=e,n=t.length,r=this._cfp;if(r.argsLength>0)t=r.argsValues,n=r.argsLength,r.argsValues=null,r.argsLength=0;else for(let e=0;e<n;e++){let n=t[e];if(n==null)continue;let r;if(n.colStart!==void 0)r=n;else if(n.getCoords&&(r=n.getCoords(),r&&r.scope===void 0&&typeof n.getWorksheet==`function`)){let e=n.getWorksheet()?.getName?.();e&&(r={...r,scope:e})}r&&(t[e]=r)}let i=this._exec(t,n);if(!0===i?.isIRange){if(!0===i._isDirectScalarBox?.())return i.getValueAt(0,0);if(!this._rref&&!0===i.isIReferenceRange)return i.size===1?i.getValueAt(0,0):i._toValueRange()}return i}_plan(e){let t=this._gc;if(t){if(t.has(e))return t.get(e)}else t=this._gc=new Map;let n=this._pj,r=this._gi,i=n[r].repeating,a=i.length,o=r,s=n.length-r-1,c=s;for(;c>0&&!0===n[r+c].optional;)c--;let l=!0===i[a-1].optional,u=!0===n[r].optional?0:1,d=-1,f=!1,p=s;for(let t=c;t<=s;t++){let n=e-o-t,r=-1,i=!1;if(n>=0&&n%a===0?r=n/a:l&&n===a-1&&(r=1,i=!0),r>=u){d=r,f=i,p=t;break}}if(d<u)return t.set(e,null),null;let m=[];for(let e=0;e<o;e++)m.push(n[e]);if(a===1)m.push(i[0].rest?i[0]:{...i[0],rest:!0});else for(let e=0;e<d;e++){let t=f&&e===d-1?a-1:a;for(let e=0;e<t;e++)m.push(i[e])}for(let e=0;e<p;e++)m.push(n[r+1+e]);let h={params:m,specs:_b(m),prefix:o,period:a,n:d,short:f,tuples:a>1,suffix:p};return t.set(e,h),h}_regroup(e,t,n){let{prefix:r,period:i,n:a,short:o,tuples:s}=n,c=[],l=0;for(;l<r;l++)c.push(e[l]);if(s){let t=Array(a);for(let n=0;n<a;n++){let r=o&&n===a-1?i-1:i,s=Array(r);for(let t=0;t<r;t++)s[t]=e[l++];t[n]=s}c.push(t)}else{let i=t-(n.params.length-r-1),a=[];for(;l<i;)a.push(e[l++]);c.push(a)}for(;l<t;)c.push(e[l++]);return c}_gateDelivered(e,t,n){let r=e.enumGate,i=t.values;for(let a=n;a<t.length;a++){let t=i[a];if(typeof t==`object`&&t&&!0===t.isIRange)continue;let n=gb(r,t);if(n!==mb)i[a]=n;else{if(!e.allowError)return V.BuiltIn.Value;i[a]=V.BuiltIn.Value}}return null}_exec(e,t){if(t>this._mx)throw jb.ARGS_PAST_MAX(this._mx,t,this._n);let n=null;if(this._gi>=0&&(n=this._plan(t),!n)){let e=this._pj,n=e[this._gi].repeating;throw jb.ARGS_REPEAT(e.length-1,n.length,t,this._n)}let r=n?n.params:this._pj,a=n?n.specs:this._ps;Mb.length=0;let o=Mb,s=this._cf?.();Gy(s);let c=s!=null&&!0===s._takeFirstCell?.(),l=null,u=null,d=-1,f=!1,p=r?.length??0,m=this._lc,h=!1,g=p>0&&a[p-1].rest;if(!n&&!g&&t>p)throw jb.ARGS_TOO_MANY(p,t,this._n);if(this._nl&&this._refusesReferenceLift(r,p,e,t,n))return Ky(),V.BuiltIn.Value;if(this._rlc&&p>0){let n=null;for(let a=0;a<t;a++){if(r[a<p?a:p-1].range!==`p`)continue;let t=e[a],o=Vb(t);if(o){(n??=[]).push({argIndex:a,collapsed:t,elements:o.elements,rows:o.rows,cols:o.cols});continue}let s=t;!0===s?.isIRange&&!s.isIReferenceRange&&s.size>1&&(n??=[]).push({argIndex:a,collapsed:s,elements:i.EmptyArray,rows:s.getRowCount(),cols:s.getColumnCount()})}if(n)try{return this._refLift(s,e,t,n,c)}finally{Ky()}}if(m){let n=!1,r=Math.min(t,p);for(let t=0;t<r;t++){if(!a[t].liftTrigger)continue;let r=e[t];if(typeof r==`object`&&r&&(!a[t].wholeReference||!Pb(r))&&Lb(r)){n=!0;break}}m=n}let _=((e,t,n,r,i,a=!1)=>{let o=ab[ob];return o===void 0&&(o=ab[ob]=new eb),o._bind(e,t,n,r,i,a),ob++,o})(this._pj,this._va,n?n.suffix:0,e,t,this._vol),v,y=!1;try{for(let n=0;!y&&n<p;n++){let i=r[n],c=a[n],p=c.scalarType,g=o.length,_=c.isAny,v=c.rangeType,b=c.rest,x=c.optional,S=e[n];S=s._expandSheetSpan?.(S)??S;let C=n>=t;if(S===void 0||C){if(C){if(!x&&!b)throw jb.PARAM_MISSING(i.name,this._n);if(c.lazy&&i.defaultValue!==void 0){o.values[o.length++]=Xy.of(i.defaultValue);continue}y=!0;continue}if(i.omittable){o.values[o.length++]=i.omittedValue;continue}S=null}if(typeof S==`symbol`){o.values[o.length++]=c.lazy&&!b?Xy.of(S):c.scalarType!==null||c.rangeType?void 0:S;continue}if(c.lazy&&!b&&Ht(S)){o.values[o.length++]=S;continue}if(c.isLambda){let e=i.range!=null||i.scalar!=null&&i.scalar!==`l`,n=Yy(S)||typeof S==`function`;if(!e||n){if(V.isError(S)){l=V.BuiltIn.Value,y=!0;continue}if(typeof S==`object`&&S&&!Yy(S)&&!Array.isArray(S)){let e=S,t=S,n=0,r=0;if(!0===e.isIRange?(n=e.getRowCount(),r=e.getColumnCount()):t.colStart!==void 0&&(n=t.rowEnd-t.rowStart+1,r=t.colEnd-t.colStart+1),n*r>1)return s.createRange(n,r,V.BuiltIn.Value)}if(S!==null){let e=null;if(Yy(S)?e=S.makeCallable():typeof S==`function`&&(e=S),e===null){l=V.BuiltIn.Value,y=!0;continue}let n=i.lambdaArity??(i.rest?t-1:null),r=e.checkArity;if(n!==null&&typeof r==`function`&&!r(n)){l=V.BuiltIn.Value,y=!0;continue}h=!0,o.values[o.length++]=i.lambda===`raw`?e:pb(e);continue}l=V.BuiltIn.Value,y=!0;continue}if(S!==null&&xb(S)&&(typeof S==`number`||typeof S==`string`||typeof S==`boolean`)){l=V.BuiltIn.Value,y=!0;continue}}if(c.wholeReference&&Fb(S)){o.values[o.length++]=!0===S?.isIRange?S:s.getReference(S);continue}if(c.simple&&!m){let e=S,t=!0,n=!0;if(typeof e==`object`&&e){let r=e;r.colStart!==void 0&&r.colStart===r.colEnd&&r.rowStart===r.rowEnd?(e=s.getValueAt(r.rowStart,r.colStart,r.scope??void 0),t=!1):n=!1}if(n){l=PB(s,o,e,t,p,c.allowError,c.policy),y=!!l,y&&(f=!0);continue}}let w=xb(S),T=c.policy,E=c.allowError;if(Yy(S)&&!c.isLambda&&!b){if(_||!i.range&&!p){o.values[o.length++]=S;continue}i.range&&(S=s.getRange(S,null,!0))}if(!b&&_&&this._rref&&AB(S))o.values[o.length++]=S;else{if(!b&&c.reportType&&AB(S)){let e=S.map(e=>!0===e?.isIRange?e:s.getReference(e));S.isSheetSpan&&(e.isSheetSpan=!0),o.values[o.length++]=e;continue}if(!b&&!c.flatten&&!c.isLambda&&!m&&AB(S)){if(!c.acceptError){l=V.BuiltIn.Value,y=!0;continue}S=V.BuiltIn.Value}if(!b&&c.flatten&&S?.isSheetSpan){if(!c.acceptError){l=V.BuiltIn.Value,y=!0;continue}S=V.BuiltIn.Value}if(!b&&c.valueOrRange&&S!==void 0){let e=S,t=!0,n=!0;if(typeof e==`object`&&e){let r=e;r.colStart!==void 0&&r.colStart===r.colEnd&&r.rowStart===r.rowEnd?(e=s.getValueAt(r.rowStart,r.colStart,r.scope??void 0),n=!1):t=V.isError(e)}if(t){let t=o.length;l=PB(s,o,e,n,c.scalarType,c.allowError,c.policy),!l&&c.enumGate&&(l=this._gateDelivered(c,o,t)),y=!!l,y&&(f=!0);continue}}if(b)for(;n<t&&!l;){if(S===void 0&&(S=null),Yy(S)&&(c.isLambda?n<t-1:!_&&i.range!=null)&&(S=s.getRange(S,null,!0)),c.isLambda&&(Yy(S)||typeof S==`function`)){let e=typeof S==`function`?S:Yy(S)?S.makeCallable():null;if(e===null)l=V.BuiltIn.Value;else{let n=i.lambdaArity??t-1,r=e.checkArity;typeof r!=`function`||r(n)?(h=!0,o.values[o.length++]=i.lambda===`raw`?e:pb(e)):l=V.BuiltIn.Value}}else c.isLambda&&S!==null&&xb(S)&&(typeof S==`number`||typeof S==`string`||typeof S==`boolean`)?l=V.BuiltIn.Value:c.lazy&&Ht(S)?o.values[o.length++]=S:Yy(S)&&!c.isLambda?_||!i.range&&!p?o.values[o.length++]=S:l=V.BuiltIn.Value:v===`p`&&S?.isSheetSpan?l=V.BuiltIn.Value:_&&this._rref&&AB(S)?o.values[o.length++]=S:l=NB(s,o,S,xb(S),v,p,E,!0,T,this._nmf);S=e[++n],S=s._expandSheetSpan?.(S)??S}else{let e=c.flatten,t=T,n=Ib(S),r=p;!m||i.range||e||n||(v=`r`,e=!1,S!=null&&(S.isIRange||S.colStart!==void 0||Array.isArray(S))&&(t=null,r=null));let a=o,h=!!i.range||e,g=o.length;if(S===void 0||_&&S===null)o.values[o.length++]=null;else if(e){let t=[];(S!==null||v)&&(a=t,l=NB(s,a,S,w,v,p,E,e,T)),t.length===0&&x?o.values[o.length++]=void 0:o.values[o.length++]=t}else l=NB(s,a,S,w,v,r,E,e,t);l&&(h&&!w?(u??(u=l,d=g),l=null):h||(f=!0))}!l&&c.enumGate&&(l=this._gateDelivered(c,o,g),l&&(f=!0)),y=!!l}}if(l||u){if(!f){let e=l?o.length:d;for(let t=0;t<e;t++){let e=o.values[t];if(e==null||!0!==e.isIRange)continue;let n=e._optionsIterator;if(n?.type!==void 0&&(n.onError??`throw`)===`throw`&&e.hasError())return e.firstError()}}return l??u}let i=this._fn,g=o.length,x=h?o.values.slice(0,g):o.values;h&&_._setPrivateArgs(e.slice(0,t));let S=n?(e,t)=>i(...this._regroup(e,t,n)):null;if(m){let e=[null],t=(t,n)=>{let r=null;t&&(r=OB(s.getRuntime(),r,U.Null,t,!1));try{let t=a[0].enumGate;if(t&&(r=gb(t,r))===mb)throw V.BuiltIn.Value;e[0]=r,r=S?S(e,1):i(r),Ht(r)&&(r=r.getValue())}catch(e){if(!V.isError(e))throw e;r=e}return n=n.fillEmpty(LB(r,s)??0)};if(c){let e=e=>r[e<p?e:p-1],t=e=>a[e<p?e:p-1],n=Array(g);_._setLiftValues(n);let o=s.getRuntime(),c;for(let r=0;r<g;r++){let i=e(r),a=i.range??null,s=x[r],l=!0===i.lazy;if(!(i.rest?a===`*`&&(i.arrayDepth??0)<=1:(a===null||a===`*`)&&(i.arrayDepth??0)===0)||!0!==s?.isIRange||t(r).wholeReference&&Fb(s)){n[r]=l&&!Ht(s)?Xy.of(s):s;continue}s=s.getValueAt(0,0)??null;let u=i.scalar,d=null;if(g===1?u!==U.Null&&u!==`*`&&(d=u??null):u!==U.Boolean&&u!==U.Number&&u!==U.String&&u!==U.Error||(d=u),V.isError(s)){if(d!==null&&d!==U.Error||db(i,d)===`reject`){c=s;break}}else if(d!==null){let e=pB(s,!0);if(e!==d&&(s=OB(o,s,e,d,!0),V.isError(s))){c=s;break}}let f=t(r).enumGate;if(f&&(s=gb(f,s),s===mb)){c=V.BuiltIn.Value;break}n[r]=l?Xy.of(s):s}if(c!==void 0)v=c;else{let e;try{e=S?S(n,g):i(...n),Ht(e)&&(e=e.getValue()),e=Array.isArray(e)||e?.isIRange?LB(Hb(e),s):LB(e,s)??0}catch(t){if(Jy(t))throw t;e=LB(t,s)??0}v=e}}else if(g===1){let n=x[0],o=r[0],c=o.scalar;c!==U.Null&&c!==`*`||(c=null);let l=0,u=a[0].enumGate,d=db(o,c),f=(c===null||c===U.Error)&&d!==`reject`,p=s.getRuntime();_._setLiftValues(e),v=n.map(t=>{if(l++,V.isError(t)){if(!f)return t}else if(c!==null){let e=pB(t,!0);if(e!==c&&(t=OB(p,t,e,c,!0),V.isError(t)))return t}if(u&&(t=gb(u,t))===mb)return V.BuiltIn.Value;let n=t;try{e[0]=n,n=S?S(e,1):i(n);let t=_._takeServed();if(t!==void 0&&(n=t),Ht(n)&&(n=n.getValue()),Array.isArray(n)||n?.isIRange)return LB(Hb(n),s)}catch(e){if(Jy(e))throw e;n=e}return LB(n,s)??0}),l<n.size&&(v=t(c,v)),this._rs&&(v=v.toType({type:this._rs,onError:`value`}))}else{let e=1,t=1,n=Array(g),o=Array(g),c=[],l=[],u=e=>r[e<p?e:p-1],d=e=>a[e<p?e:p-1];for(let r=0;r<g;r++){let i=u(r),a=i.range??null;if(n[r]=(i.rest?a===`*`&&(i.arrayDepth??0)<=1:(a===null||a===`*`)&&(i.arrayDepth??0)===0)&&!0===x[r]?.isIRange&&!(d(r).wholeReference&&Fb(x[r])),n[r]){let n=x[r];o[r]=n,c.push(r);let i=n.getRowCount(),a=n.getColumnCount();(i>1||a>1)&&l.push(r),i>e&&(e=i),a>t&&(t=a)}}let f=Array(g);_._setLiftValues(f);let m=Array(g),h=Array(g),y=Array(g);for(let e=0;e<g;e++){y[e]=!0===u(e).lazy,n[e]?y[e]&&(f[e]=Xy.of(null)):f[e]=y[e]&&!Ht(x[e])?Xy.of(x[e]):x[e];let t=u(e).scalar,r=null;t!==U.Boolean&&t!==U.Number&&t!==U.String&&t!==U.String&&t!==U.Error||(r=t),m[e]=r;let i=db(u(e),r);h[e]=(r===null||r===U.Error)&&i!==`reject`}let b=s.getRuntime(),C=null,w=(e,t)=>{if(V.isError(t)){if(!h[e])return t}else if(m[e]!==null){let n=pB(t,!0);if(n!==m[e]&&(t=OB(b,t,n,m[e],!0),V.isError(t)))return t}let n=d(e).enumGate;if(n&&(t=gb(n,t))===mb)return V.BuiltIn.Value;y[e]?f[e]._fill(t):f[e]=t},T=(n,r,a)=>{let o;try{o=S?S(f,g):i(...f);let c=_._takeServed();if(c!==void 0&&(o=c),Ht(o)&&(o=o.getValue()),Array.isArray(o)||o?.isIRange)return a?((C??=Array(e*t))[n*t+r]=o,LB(Hb(o),s)):Rb}catch(e){if(Jy(e))throw e;o=e}return LB(o,s)??0},E=l;for(let e=0;e<c.length;e++){let t=c[e],n=o[t];if(!(n.getRowCount()>1||n.getColumnCount()>1)&&w(t,n.getValueAt(0,0)??null)!==void 0){E=c;break}}let D=null;if(E===l&&l.length===1){let e=l[0],t=o[e],n=!1;D=t.map((t,r)=>{let i=w(e,t??null);if(i!==void 0)return i;if(r.rowIndex<0){let e=T(0,0,!1);return e===Rb?(n=!0,null):e}return T(r.rowIndex,r.colIndex,!0)},zb),n&&(D=null)}if(D===null){if(C=null,E.length===0)D=s.createRange(1,1,()=>T(0,0,!0));else{let e=o[E[0]],t=E.slice(1).map(e=>o[e]),n=!1,r=r=>e.zip(t,(e,t)=>{for(let t=0;t<E.length;t++){let n=w(E[t],e[t]??null);if(n!==void 0)return n}if(t.rowIndex<0){let e=T(0,0,!1);return e===Rb?(n=!0,null):e}return T(t.rowIndex,t.colIndex,!0)},{type:null,misalignValue:V.BuiltIn.NA,blankRegions:r});D=r(`once`),n&&(C=null,D=r(`each`))}}v=D,C!==null&&Bb(v,C,e,t)}}else if(S)this._lz&&fb(x,g,r,p),v=S(x,g);else if(this._lz&&fb(x,g,r,p),g<=6)switch(g){case 0:v=i();break;case 1:v=i(x[0]);break;case 2:v=i(x[0],x[1]);break;case 3:v=i(x[0],x[1],x[2]);break;case 4:v=i(x[0],x[1],x[2],x[3]);break;case 5:v=i(x[0],x[1],x[2],x[3],x[4]);break;case 6:v=i(x[0],x[1],x[2],x[3],x[4],x[5])}else{let e=[];for(let t=0;t<g;t++)e.push(x[t]);v=i(...e)}Ht(v)&&(v=typeof(b=v)._force==`function`?b._force():b.getValue()),v=LB(v,s),!m&&this._rkScalar&&!0===v?.isIRange&&v.size===1&&!0!==v.isIReferenceRange&&(v=v.getValueAt(0,0)),s.isValidDate(v,!0)&&(s.formatResults(`Short Date`),v=s.toSerialDate(v))}catch(e){throw e}finally{ob>0&&ob--,Ky()}var b;return v}_refusesReferenceLift(e,t,n,r,i){let a=i?i.prefix:-1,o=i?i.params.length-i.suffix:-1,s=Math.min(r,t);for(let t=0;t<s;t++){if(i&&t>=a&&t<o)continue;let r=e[t];if(!r.rest&&!r.range&&r.lambda==null&&(r.arrayDepth??0)===0&&!0===r.noLift&&!0!==r.reportType&&Pb(n[t]))return!0}return!1}_refLift(e,t,n,r,i=!1){let a=r.length;if(i){let i=t.slice(0,n);for(let e=0;e<a;e++){let t=r[e],n=t.elements[0];n===void 0&&(n=t.collapsed.getValueAt(0,0)??null),i[t.argIndex]=n}let o;try{o=this._exec(i,n)}catch(e){if(!V.isError(e))throw e;o=e}return Array.isArray(o)||o?.isIRange?LB(Hb(o),e):LB(o,e)??0}let o=1,s=1;for(let e=0;e<a;e++){let t=r[e];t.rows>o&&(o=t.rows),t.cols>s&&(s=t.cols)}let c=t.slice(0,n),l=null,u=e.createRange(o,s,(t,i)=>{let u=i.rowIndex,d=i.colIndex;for(let e=0;e<a;e++){let t=r[e],n=t.rows===1?0:u<t.rows?u:-1,i=t.cols===1?0:d<t.cols?d:-1;if(n<0||i<0){c[t.argIndex]=V.BuiltIn.NA;continue}let a=t.elements[n*t.cols+i];a===void 0&&(a=t.collapsed.getValueAt(n,i)??null),c[t.argIndex]=a}let f;try{f=this._exec(c,n)}catch(e){if(!V.isError(e))throw e;f=e}return Array.isArray(f)||f?.isIRange?((l??=Array(o*s))[u*s+d]=f,LB(Hb(f),e)):LB(f,e)??0});return l!==null&&Bb(u,l,o,s),u}_withContext(t){return new e(this._json,this._fn,t,this._descFn,this._builtIn)}getName(){return this._n}getDeclaration(){return this._d}async getDescriptor(e){let t=e??j.getActive();if(this._desc&&this._descLanguage===t)return this._desc;let n=await Promise.resolve(this._descFn(e));return this._desc=new Ab(this,n),this._descLanguage=t,this._desc}isBuiltIn(){return this._builtIn}isLambda(){return!1}getContext(){let e=this._ct;if(e===`sheet`||e===`workbook`||e===`ranges`||e===`range`||e===`script`){let e=this._json;return e&&e.behavior&&e.behavior.default?`autoRun`:`macro`}return`formula`}get[Symbol.toStringTag](){return`[TypedFunction]`}toString(){let e=this._json,t=e.parameters,n=``;if(t.length>0){let e=t=>{let n=t.name;t.rest&&(n=`...`+n),t.optional&&(n+=`?`);let r=t.repeating;return r?`${n}: Repeating<${r.length===1?gB(r[0]):`[${r.map(e).join(`, `)}]`}>`:(n+=`: `+gB(t),n)};n=t.map(e).join(`, `)}let r=`${this.getName()}(${n})`,i=e?.returnType;return i?`${r}: ${gB(i)}`:r}get isIFunction(){return!0}get isITypedFunction(){return!0}},yb=e=>async t=>{let n={},r=e.parameters;for(let e=0;e<r.length;e++)n[r[e].name]={description:i.camelToPrettyCase(r[e].description)};return{summary:i.camelToPrettyCase(e.name),parameters:n,category:`User Defined`}},bb=()=>null,xb=e=>typeof e!=`object`||!e||e.colStart===void 0&&(!e.isIRange||!0===e._isLiteralArray?.()),Sb=class{constructor(e){this._s=e.scalar??null,this._r=e.range??null,this._d=e.arrayDepth??0,this._l=e.lambda??null}getScalarType(){return this._s}getRangeType(){return this._r}getLambda(){return this._l}getArrayDepth(){return this._d}},Cb=class e extends Sb{constructor(t){super(t),this._n=t.name,this._o=t.optional??!1,this._dv=t.defaultValue,this._rest=t.rest??!1,this._e=t.enum?Tb.of(t.enum):null,this._ae=!0===t.acceptError,this._nl=!0===t.noLift,this._nf=!0===t.noFilter,this._lz=!0===t.lazy,this._vr=!0===t.valueOrRange,this._g=t.repeating?Object.freeze(t.repeating.map(t=>new e(t))):null}getName(){return this._n}isAcceptError(){return this._ae}isNoFilter(){return this._nf}isNoLift(){return this._nl}isLazy(){return this._lz}isValueOrRange(){return this._vr}isOptional(){return this._o}getDefaultValue(){return this._dv}isRest(){return this._rest}getRepeatingTypes(){return this._g}getEnum(){return this._e}},wb=class{constructor(e,t,n){this._n=e,this._v=t,this._dp=n??!1}getName(){return this._n}getValue(){return this._v}isDeprecated(){return this._dp}},Tb=class e{static{this._byJSON=new WeakMap}static of(t){let n=e._byJSON.get(t);return n||(n=new e(t),e._byJSON.set(t,n)),n}constructor(e){this._id=e.id,this._t=e.type,this._m=Object.freeze(e.members.map(([e,t,n])=>new wb(e,t,n)))}getId(){return this._id}getScalarType(){return this._t}getMembers(){return this._m}},Eb=e=>{if(!e)return null;if(e.kind)return e.kind;if(e.lambda!=null)return Wt.Lambda;let t=e.range;if(t===`p`)return Wt.Reference;if(t===`r`||t===`m`)return Wt.Array;let n=e.scalar;return n==null||n===U.Null||n===`*`?null:n},Db=class extends Sb{constructor(e){super(e),this._vol=e.volatile??!1,this._kind=Eb(e)}getKind(){return this._kind}isVolatile(){return this._vol}},Ob=255,kb=class{constructor(e){if(this._n=e.name,this._mx=e.maxArguments??Ob,this._h=e.hidden??!1,e.parameters){let t=e.parameters.length,n=Array(t);for(let r=0;r<t;r++)n[r]=new Cb(e.parameters[r]);this._p=Object.freeze(n)}else this._p=i.EmptyArray;this._r=e.returnType?new Db(e.returnType):new Db({scalar:null,arrayDepth:0,range:null})}getName(){return this._n}getParameters(){return this._p}getMaxArguments(){return this._mx}getReturnType(){return this._r}isHidden(){return this._h}},Ab=class{constructor(e,t){if(this._n=t.name??e?.getName(),this._nl=t.nameLocal??this._n,this._fn=e,this._s=t.summary??i.camelToPrettyCase(this._n),this._c=t.category??`Uncategorized`,this._h=t.deprecated??!1,t.links&&t.links.length>0){let e=t.links.length,n=Array(e);for(let r=0;r<e;r++)n[r]=Object.freeze([t.links[r][0],t.links[r][1]]);this._l=Object.freeze(n)}else this._l=i.EmptyArray;if(t.parameters){let n={};for(let r in t.parameters)if(Object.prototype.hasOwnProperty.call(t.parameters,r)){let i=t.parameters[r].description,a=t.parameters[r].example,o=t.parameters[r].defaultValue??e?.getDeclaration?.()?.getParameters?.().find(e=>e.getName()===r)?.getDefaultValue(),s={};i&&(s.description=i),a&&(s.example=a),o!==void 0&&(s.defaultValue=o),n[r]=Object.freeze(s)}this._p=Object.freeze(n)}else this._p=i.EmptyObject;let n=null;for(let r of e?.getDeclaration?.()?.getParameters?.()??i.EmptyArray)for(let e of[r,...r.getRepeatingTypes()??[]]){let r=e.getEnum();if(!r||n?.[r.getId()])continue;let i=t.enums?.[r.getId()],a={};for(let e of r.getMembers()){let t=i?.members?.[e.getName()];a[e.getName()]=Object.freeze({nameLocal:t?.nameLocal??e.getName(),...t?.description?{description:t.description}:null})}(n??={})[r.getId()]=Object.freeze({nameLocal:i?.nameLocal??r.getId(),...i?.summary?{summary:i.summary}:null,members:Object.freeze(a)})}this._e=n?Object.freeze(n):i.EmptyObject}getEnums(){return this._e}getName(){return this._n}getNameLocal(){return this._nl}getSummary(){return this._s}getCategory(){return this._c}isDeprecated(){return this._h}getLinks(){return this._l}getParameters(){return this._p}get[Symbol.toStringTag](){return`[Descriptor]`}toString(){let e=this._fn;return`${this.getSummary()}: ${e}`}},jb={PARAM_MISSING:(e,t)=>new V.Parse(`Parameter ${e} is missing${t?` for ${t}`:``}.`),ARGS_TOO_FEW:(e,t)=>new V.Parse(`Argument type ${e.join(`, `)} is missing${t?` for ${t}`:``}.`),ARGS_TOO_MANY:(e,t,n)=>new V.Parse(`Too many arguments${n?` for ${n}`:``}. Expected ${e}, but got ${t}.`),ARGS_PAST_MAX:(e,t,n)=>new V.Parse(`Too many arguments${n?` for ${n}`:``}. The most it accepts is ${e}, but got ${t}.`),ARGS_REPEAT:(e,t,n,r)=>t===1?new V.Parse(`Too few arguments${r?` for ${r}`:``}. Expected at least ${e+1}, but got ${n}.`):new V.Parse(`Wrong number of arguments${r?` for ${r}`:``}. Expected ${e} plus a multiple of ${t}, but got ${n}.`)},Mb={values:zB(255),length:0},Nb=`_liftedFnResults`,Pb=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return t.colStart===void 0?!0===e.isIRange&&!0===e.isIReferenceRange&&e.size>1:t.colStart!==t.colEnd||t.rowStart!==t.rowEnd},Fb=e=>typeof e==`object`&&!!e&&(e.colStart!==void 0||!0===e.isIReferenceRange),Ib=e=>typeof e==`object`&&!!e&&!0===e.isIRange&&!0===e.isIReferenceRange&&e.size===1,Lb=e=>!AB(e)&&(!function(e){let t=e;for(;Array.isArray(t);){if(t.length>1)return!1;t=t[0]}if(!t)return!0;if(t.isIRange&&t.size!==1)return!1;if(t.colStart!==void 0){let e=t;if(e.colStart!==e.colEnd||e.rowStart!==e.rowEnd)return!1}return!0}(e)||typeof e==`object`&&!!e&&!0===e.isIRange&&!0!==e.isIReferenceRange),Rb=Symbol(`lift.arrayResult`),zb=Object.freeze({blankRegions:`once`}),Bb=(e,t,n,r)=>{Object.defineProperty(e,Nb,{value:{elements:t,rows:n,cols:r},enumerable:!1,configurable:!0})},Vb=e=>e&&!0===e.isIRange?e[Nb]??null:null,Hb=e=>{let t=e;for(;Array.isArray(t);)t=t[0];return t?.isIRange&&(t=t.getValueAt(0,0)),t??null},Ub=`SheetXL`;function Wb(){return ub||=async function(){return(await e(async()=>{let{loadEnumManifest:e}=await import(`./BJct69niPZc8L_gZ.js`);return{loadEnumManifest:e}},__vite__mapDeps([15,2]),import.meta.url)).loadEnumManifest()}().then(e=>i.deepFreeze(e)).catch(e=>{throw ub=void 0,e}),ub}var Gb=void 0;async function Kb(){let e=await Wb();Gb=globalThis[Ub],globalThis[Ub]=e}function qb(){Gb?(globalThis[Ub]=Gb,Gb=void 0):delete globalThis[Ub]}var Jb,Yb={debug:e=>console.debug(e),log:e=>console.log(e),info:e=>console.info(e),warn:e=>console.warn(e),error:e=>console.error(e instanceof Error?e.stack??e.message:e)},Xb=class extends vb{constructor(e,t,n,r=null,i=!1,a){super(e,a?()=>{}:t,n,r,i),this._fnLoader=a}async _ensureLoaded(){if(!this._fnLoader)return;let e=await this._fnLoader();this._fn=e.bind(this),this._fnLoader=void 0}execute(...e){let t=e[0];if(!t||!t.isIWorkbook)throw Error(`Macro '${this.getName()}' must be called with a valid workbook as the first argument.`);let n=e[1],r=_(n?.logger??Yb,{render:n?.render}),a={wb:t,log:r.log,warn:r.warn,error:r.error,args:n?.args},o=this._ct;try{let e=[];switch(o){case hy.Context.Script:break;case hy.Context.Workbook:e.push(t);break;case hy.Context.Sheet:e.push(t.getWorksheet());break;case hy.Context.Ranges:e.push(t.getSelectedRanges());break;case hy.Context.Range:e.push(t.getSelectedRange());break;default:throw Error(`Function '${this.getName()}' is not a valid macro function.`)}let s=async(e,t)=>{let n=await t;if(n!==void 0){if(n!==null){if(Array.isArray(n)){if(pB(n[0]?.[0]))return void e.setValues(n,{skipBoundsCheck:!0})}else if(pB(n))return void e.setValues([[n]]);n.isICell?e.updateCells(n):n.isICellRange&&await e.copyFrom(n)}else e.clear()}},c,l;return(async()=>{await this._ensureLoaded();let o=(await Promise.resolve(this._descFn()))?.summary,u={...n,description:n?.description??o??n?.defaultDescription??i.camelToPrettyCase(this.getName())};try{await t.doBatch(async(r,i)=>{l=r.getId();let o=F.of(i),u=e.map(e=>o.wrap(e)),d={...a,wb:i};try{let e=t.getSelectedRange(),r=this._cf();r||=new Proxy({},{set:(e,t,n)=>(console.log(`Adding property "${t}" with value:`,n),e[t]=n,!0),deleteProperty:(e,t)=>(console.log(`Deleting property "${t}"`),delete e[t])});try{Gy({getRow:()=>e.getCell().getCoords().rowIndex,getColumn:()=>e.getCell().getCoords().colIndex}),await Kb(),c=await this._fn.call(r,...u,d),qb()}catch(e){throw e}finally{Ky()}n?.applyResult&&await s(e,c)}catch(e){throw e}},u),l!==void 0&&t.getTransactions().getCurrentCommit().getId()!==l&&(l=void 0)}finally{await r.flush({timeoutMs:D(n?.logTimeoutMs)})}return{params:e,results:c,commitId:l}})()}catch(e){throw e}}};(Jb||={}).DEFAULT_MODULE=`main.ts`;var Zb=1/0,Qb=(e,t)=>e===t?0:e.startsWith(t)?2:e.includes(t)?4:Zb,$b=(e,t)=>{let n=Qb(e.name,t);if(n===0)return 0;let r=e.nameLocal===e.name?Zb:Qb(e.nameLocal,t),i=Math.min(n,r===Zb?Zb:r+1);return i===Zb?e.summary.includes(t)?6:Zb:i},ex=(e,t)=>e.score===t.score?e.name<t.name?-1:+(e.name>t.name):e.score-t.score,tx=(e,t)=>{let n=new Map;for(let r=0;r<e.length;r++){let i=e[r];n.set(i,Qb(i.getName().toUpperCase(),t))}return e.sort((e,t)=>{let r=n.get(e),i=n.get(t);return r===i?0:r<i?-1:1})},nx=(e,t)=>{let n=e.getName().toUpperCase(),r=t?.getCategory()??`Uncategorized`;return{fn:e,name:n,nameLocal:t?.getNameLocal()?.toUpperCase()??n,summary:t?.getSummary()?.toUpperCase()??``,category:r,categoryUpper:r.toUpperCase(),hidden:e.getDeclaration().isHidden()}},rx=class{constructor(e){this._entries=null,this._language=null,this._building=null,this._source=e}invalidate(){this._entries=null,this._building=null}entries(){let e=j.getActive();if(this._language===e){if(this._entries)return Promise.resolve(this._entries);if(this._building)return this._building}this._language=e;let t=this._build().then(n=>(this._language===e&&this._building===t&&(this._entries=n,this._building=null),n));return this._building=t,t}async _build(){let e=Array.from(this._source()),t=await Promise.all(e.map(e=>e.getDescriptor().catch(()=>null))),n=[],r=new Set;for(let i=0;i<e.length;i++){let a=e[i],o=a.getName().toUpperCase();r.has(o)||(r.add(o),n.push(nx(a,t[i])))}return Object.freeze(n)}},ix=(e,t)=>{let n=e.getName().toUpperCase(),r=t.getName().toUpperCase();return n<r?-1:+(n>r)},ax=1,ox=class extends Qt{constructor(e){super(e.transactions??void 0),this._readonly=null,this._named=null,this._sorted=null,this._stamp=ax++,this._options={...e};let t=this;this._transactions=this._options.transactions??new se({transient:!0}),this._stateId=this._transactions.create(),this._index=new rx(function*(){let e=t._readonly;e&&(yield*e.values());let n=t.isClosed()?null:t._getState();n&&(yield*n.itemsByKey.values())}),this._transactionsRemoveListener=this._transactions.addStateListener(this._stateId,{onAfterStateChange(e,n){t._invalidate(),t._notifyCollectionChange()}}),this._readonly=e?.readonlyFunctions,this._initState()}_getItems(e){let t=this._getState();if(!t)return i.EmptyArray;let n=this._sorted;if(!n){let e=new Map(this._readonly??[]);t.itemsByKey.forEach((t,n)=>{e.has(n)||e.set(n,t)}),n=Array.from(e.values()).sort(ix),this._sorted=n}let r=this._namedFunctions();r.length>0&&(n=[...n,...r].sort(ix));let a=e?.type??null,o=e?.name?e.name.toUpperCase():null,s=e?.includeHidden??!1;return n.filter(e=>!(!s&&e.getDeclaration().isHidden())&&(!a||e.getContext()===a)&&(!o||e.getName().toUpperCase()===o))}getCount(e){return this._getItems(e).length}getByName(e,t){if(!e)return null;let n=this._getState();if(!n)return null;if(!n)return i.EmptyArray;let r=e.toUpperCase(),a=this._readonly,o=a?.size?a.get(r):void 0;if(o||=n.itemsByKey.get(r),!o)return this._named?.getByName(e,t?.sheet)??null;let s=t?.sheet;if(s!==void 0){let e=this._options.createScopedContext;if(!e)throw Error(`This collection cannot vend sheet-scoped functions (no scoped-context factory).`);if(o instanceof Xb||!(o instanceof vb))throw Error(`This function cannot be sheet-scoped.`);let t=e(s);if(!t)throw Error(`Unknown sheet for function scope. ('${s}')`);return o._withContext(()=>t)}return o}_setNamedSource(e){this._named=e}_namedFunctions(){let e=this._named?.getItems();if(!e?.length)return i.EmptyArray;let t=this._getState(),n=this._readonly;return e.filter(e=>{let r=e.getName().toUpperCase();return!n?.has(r)&&!t?.itemsByKey.has(r)})}async _entries(){let e=await this._index.entries(),t=this._namedFunctions();if(t.length===0)return e;let n=await Promise.all(t.map(e=>e.getDescriptor().catch(()=>null)));return[...e,...t.map((e,t)=>nx(e,n[t]))]}async search(e){let t=await this.searchScored(e),n=t.length;if(n===0)return i.EmptyArray;let r=Array(n);for(let e=0;e<n;e++)r[e]=t[e].fn;return r}async searchScored(e){if(!this._getState())return i.EmptyArray;let t=e?.name?e.name.toUpperCase():null,n=e?.type?e.type:null,r=e?.category?e.category.toUpperCase():null,a=e?.text?e.text.trim().toUpperCase():null,o=e?.includeHidden??!1,s=e?.limit;if(s!==void 0&&s<=0)return i.EmptyArray;let c=[];if(!a&&!r){let t=this._getItems({name:e?.name,type:e?.type,includeHidden:o}),n=s===void 0?t.length:Math.min(s,t.length);for(let e=0;e<n;e++)c.push({fn:t[e],score:0,name:t[e].getName().toUpperCase()});return c}let l=await this._entries(),u=l.length;for(let e=0;e<u;e++){let i=l[e];if(t&&i.name!==t||n&&i.fn.getContext()!==n||r&&i.categoryUpper!==r||!o&&i.hidden)continue;let s=0;a&&(s=$b(i,a),s===Zb)||c.push({fn:i.fn,score:s,name:i.name})}return c.sort(ex),s!==void 0&&c.length>s?c.slice(0,s):c}async getCategories(e){this._getState();let t=e?.type?e.type:null,n=e?.includeHidden??!1,r=await this._entries(),i=new Map,a=r.length;for(let e=0;e<a;e++){let a=r[e];if(t&&a.fn.getContext()!==t||!n&&a.hidden)continue;let o=i.get(a.categoryUpper);o?o.count++:i.set(a.categoryUpper,{name:a.category,count:1})}let o=Array.from(i.values());return o.sort((e,t)=>e.name.localeCompare(t.name)),o}validateName(e){return this._validateName(e)}_validateName(e,t=!1){if(this.isClosed())throw Error(N(`error.model.modelClosed`))}async add(e){if(this.isClosed())throw Error(N(`error.model.modelClosed`));if(!e)throw Error(`Item must be specified.`);return typeof e==`string`?this._addFromSource(e):this._addFunction(e)}async _addFromSource(t){let n=await(await e(async()=>{let{ScriptCompiler:e}=await import(`./qFyplGXRu7IepHio.js`);return{ScriptCompiler:e}},__vite__mapDeps([16,17,18,1,2,7,19]),import.meta.url)).ScriptCompiler.compile({source:t,builtInNames:this._readonly?Array.from(this._readonly.keys()):void 0});if(!n.module)throw Error(`The script did not compile to a module.`);let r=n.diagnostics.filter(e=>e.severity===`error`);if(r.length>0){let e=Error(`The script has ${r.length} compile error${r.length===1?``:`s`}: `+r.map(e=>`${e.code}: ${e.message}`).join(`; `));throw e.diagnostics=r,e}let{jsonToModule:i}=cx,a=(await i(Jb.DEFAULT_MODULE,n.module,!1,n.diagnostics)).getFunctions().getItems({includeHidden:!0});if(a.length===0)throw Error(`The script did not define any exported functions.`);for(let e=0;e<a.length;e++){let t=a[e].getName();if(this._readonly?.has(t.toUpperCase()))throw Error(N(`error.function.builtInName`,{name:t}))}let o=null;for(let e=0;e<a.length;e++){let t=this._addFunction(a[e]);o||=t}return o}_addFunction(e){let t;if(e.isIFunction){let n=e,r=n._json;t=new(r.context&&r.context!==hy.Context.Calculation?Xb:vb)(r,n._fn,()=>this._options.context,n._descFn)}else{let n=e;t=new vb(n.declaration,n.execute,()=>this._options.context,n.descriptor)}let n=this._getState(),r=t.getName().toUpperCase();if(this._readonly?.has(r))throw Error(N(`error.function.builtInName`,{name:t.getName()}));return n.itemsByKey.set(r,t),this._invalidate(),t}beginCommit(e){return this._beginCommit(e)}_invalidate(){this._index.invalidate(),this._sorted=null,this._stamp=ax++}_getStamp(){return this._stamp}_getState(){if(this.isClosed())throw Error(N(`error.model.modelClosed`));return this._transactions.getState(this._stateId)}_beginCommit(e){return this._transactions.beginCommit(typeof e==`string`?{description:e}:e)}_updateState(e,t=m(`op.update`),n){if(!e)return;let r=this._beginCommit(t);try{r.updateState(this._stateId,e),r.commit(n)}catch(e){throw r.rollback(),e}}_initState(){let e=this._beginCommit(m(`op.initialize`));try{e.updateState(this._stateId,e=>({...e,itemsByKey:new Map})),e.amend()}catch(t){throw e.rollback(),t}}addListeners(e,t){return super.addListeners(e,t)}close(){this.isClosed()||(this._close(),this._transactionsRemoveListener?.())}get isFunctionCollection(){return!0}get isIFunctionCollection(){return!0}},sx=class{constructor(e){this._beforeDelete=null;let t=e.json;if(this._json=t,!this._json)throw Error(`Module JSON is required.`);this._diagnostics=e.diagnostics??[],this._name=e.name??null;let n=e.scope??null;this._scope=typeof n==`function`?n:()=>n,this._emitter=new ne(this),this._functions=new ox({transactions:null,readonlyFunctions:e.readonlyFunctions})}getName(){return this._name}getFunctions(){return this._functions}getSource(){return this._json.source??null}getLanguage(){return this._json.language||`typescript`}getScope(){return this._scope()}getErrors(){return this._diagnostics.filter(e=>e.severity===`error`)}getDiagnostics(){return this._diagnostics}delete(){this._beforeDelete?.(),this._emitter.notify(`onDelete`)}_setBeforeDelete(e){this._beforeDelete=e}addListeners(e,t){return this._emitter.addListeners(e,t)}toJSON(){return this._json}get isIModule(){return!0}},cx=ee({jsonToModule:()=>fx,jsonToModuleSync:()=>px,runAsyncGenerator:()=>mx}),lx=async(t,n,r)=>{let i=null;try{(function(){Uy();let e=globalThis;e[Kt.GLOBAL_CONTEXT_VARIABLE]!==Hy&&(e[Kt.GLOBAL_CONTEXT_VARIABLE]=Hy)})(),Gy(null)}catch(e){console.warn(`Error setting global scope`,e)}try{let n=t.compiled;n=n.replaceAll(Kt.GLOBAL_CONTEXT_VARIABLE,`globalThis.`+Kt.GLOBAL_CONTEXT_VARIABLE);let{loadCompiledModule:r}=await e(async()=>{let{loadCompiledModule:e}=await import(`./qFyplGXRu7IepHio.js`);return{loadCompiledModule:e}},__vite__mapDeps([16,17,18,1,2,7,19]),import.meta.url);i=await r(n,{sourceMap:t.sourceMap})}catch(e){throw Error(`Invalid Javascript module.`,{cause:e})}finally{Ky()}if(!n)throw Error(`No function available for '${r}'.`);let a=n.name,o=i[a];if(!o&&n.behavior.default&&(o=i.default),!o)throw Error(`Found the descriptor for '${a}' but not the function. The descriptor manifest must be corrupt.`);return o},ux=(e,t,n)=>{let r=t?.name;return!n&&r&&r!==e.name?{...e,name:r}:e};function dx(e){let t=new Map,n=e?.functions;if(!n)return t;for(let e=0;e<n.length;e++){let r=n[e],i=r[0],a=r[1],o=!!i.context&&i.context!==hy.Context.Calculation,s=ux(i,a,o),c=o?new Xb(s,()=>{},()=>null,a,!1,void 0):new vb(s,()=>{},()=>null,a);t.set(s.name.toUpperCase(),c)}return t}async function fx(e,t,n=!1,r=[],i){let a=t?.functions,o=r.some(e=>e.severity===`error`)||!t?.compiled;if(n||o)return new sx({json:t,readonlyFunctions:dx(t),name:e,diagnostics:r,scope:i});let s=new Map;if(a)for(let n=0;n<a.length;n++){let r=a[n],i=r[0],o=r[1],c=!!i.context&&i.context!==hy.Context.Calculation,l=ux(i,o,c),u;u=c?new Xb(l,()=>{},()=>null,o,!1,()=>lx(t,i,e)):new vb(l,await lx(t,i,e),()=>null,o),s.set(l.name.toUpperCase(),u)}return new sx({json:t,readonlyFunctions:s,name:e,diagnostics:r,scope:i})}function px(e,t,n,r=[]){return new sx({json:t,readonlyFunctions:dx(t),name:e,diagnostics:r,scope:n})}async function mx(e){let t=await e.next();for(;!t.done;){let n=t.value;try{let r=n instanceof Promise?await n:n;t=await e.next(r)}catch(n){t=await e.throw?.(n)??{done:!0,value:void 0}}}return t.value}var hx,gx=/^(line|lineInv|straightConnector\d|bentConnector\d|curvedConnector\d)$/,_x=class extends P{constructor(e){let t;if(super(e),this._detailsSource=null,this._style=null,this._getStyles=e.getStyles??null,e.resource)t=e.resource;else{if(!e.json)throw Error(`Resource is required to create Picture.`);t=e.fromResourceId(e.json.resId)}let n=vx(e.json);this._updateState(n?{resource:t,data:n}:{resource:t})}getType(){return`picture`}toJSON(e){let t={},n=this._getState(),r=e?.(n.resource);return r!==null&&(t.resId=r),n?.data&&Object.assign(t,n.data),t}getTypeDescription(){return`Picture`}getShapeType(){let e=this._getState()?.data?.geometry;return typeof e==`string`?e:e?`custom`:`rect`}setShapeType(e,t){let n=t?.description??m(`op.setPictureShapeType`);if(this._protectionCheck(n),!e||typeof e!=`string`||e===`custom`)throw new k(`Invalid shape type: ${e}.`);if(gx.test(e))throw new k(`A picture cannot be cropped to a line: ${e}.`);if(e===this.getShapeType())return this;let{geometry:r,adjustments:i,...a}=this._getState()?.data??{},o=e===`rect`?a:{...a,geometry:e};return this._updateState({data:o},{...t,description:n},[`onAnyChange`]),this}async getGeometry(e,t){if(e===void 0||t===void 0){let n=this.getMovable()?.getBounds();if(!n)return null;e??=n.width,t??=n.height}return de({...this._getState()?.data,style:null},null,e,t)}getCrop(){return{...this._getState()?.data?.image?.sourceRect}}setCrop(e,t){let n=t?.description??m(`op.setPictureCrop`);this._protectionCheck(n);let r={};for(let t of[`left`,`top`,`right`,`bottom`]){let n=e?.[t]??0;if(!Number.isFinite(n))throw new k(`Invalid crop: ${t} is ${n}.`);n!==0&&(r[t]=n)}if((r.left??0)+(r.right??0)>=100||(r.top??0)+(r.bottom??0)>=100)throw new k(`A crop must leave part of the image to show.`);let{image:i,...a}=this._getState()?.data??{},{sourceRect:o,...s}=i??{},c=Object.keys(r).length>0?{...s,sourceRect:r}:s,l=Object.keys(c).length>0?{...a,image:c}:a;return this._updateState({data:l},{...t,description:n},[`onAnyChange`]),this}getHyperlink(){let e=this._getState()?.data?.hyperlink;return e&&(typeof e==`string`||e.address)?new Uh(()=>this.getDescription()??``,(e,t,n,r)=>{let i=this.getMovable()?.getRange().getCell();return i?i._openAddress(e,t,n,r):Promise.resolve(!1)},e,e=>{this.setHyperlink(null,e)}):null}setHyperlink(e,t){let n=t?.description??m(`op.setPictureHyperlink`);this._protectionCheck(n);let{hyperlink:r,...i}=this._getState()?.data??{},a=i;if(e){let t=e,n=typeof e==`string`?{address:e}:t.isIHyperlink?{address:t.getAddress(),screenTip:t.getScreenTip()??void 0}:e;if(!n.address)throw new k(`A hyperlink requires an address.`);let{textToDisplay:o,...s}=n,c=typeof r==`object`?r:void 0;a={...i,hyperlink:{...c,...s,address:bn(n.address)??n.address}}}return this._updateState({data:a},{...t,description:n},[`onAnyChange`]),this}getStyle(){return this._style?this._style:this._style=new bt({getData:()=>({...this._getState()?.data,style:null}),getStyles:()=>this._getStyles?.()??null,getTheme:()=>{try{return this._getStyles?.()?.getTheme()?.toJSON()??null}catch{return null}},getMovable:()=>this.getMovable(),getResource:()=>null,write:(e,t)=>this._writeStyle(e,t)})}_writeStyle(e,t){let n=t.description??m(`op.setPictureStyle`);this._protectionCheck(n);let r={...this._getState()?.data??{}};for(let t of Object.keys(e)){let n=e[t];n===void 0?delete r[t]:r[t]=n}this._updateState({data:r},{...t,description:n},[`onAnyChange`])}acceptRotation(e){return e}acceptFlip(e){return e}getDefaultAnchorType(){return Ih.Type.OneCell}isDefaultLockAspectRatio(){return!0}async _asDataUrl(){if(this._readFrom(),this._dataUrl)return this._dataUrl;let e=await this.getDetails(),t=await l.getImageDataUrl(e.asUrl());return this._dataUrl=t.dataUrl,this._dataUrl}toHtml(){return null}async toImage(){let e=await this.toArrayBuffer();return new Blob([e],{type:E.Png})}async toArrayBuffer(){let e=(await this._asDataUrl()).substring(l.DATA_URL_PNG_PREFIX.length);return n.base64ToArrayBuffer(e)}getResource(){return this._getState().resource}setResource(e,t){let n=t?.description??m(`op.setPictureResource`);if(this._protectionCheck(n),!e)throw new k(`A picture is required.`);let r;if(e.isIResource)r=e;else{let t=this.getMovable()?.getRange().getWorksheet()??null;if(!t)throw new k(`A picture that is not on a sheet takes a resource.`);r=t.getResources().add(e)}if(r.isClosed())throw new k(`The resource is closed.`);return r===this._getState().resource||(r.addReference(this),this._updateState({resource:r},{...t,description:n},[`onAnyChange`])),this}_readFrom(){let e=this.getResource();return this._detailsSource!==e&&(this._detailsSource=e,this._details=void 0,this._dataUrl=void 0),e}async getDetails(){let e=this._readFrom();return this._details||=new Promise(async(t,n)=>{try{let n=await e.toBuffer(),r=await e.getType(),i=await l.loadImageDetails(n,r?.mime);t({getNaturalSize:()=>i.naturalSize,asUrl:()=>i.asUrl,asSVGText:()=>i.asSVGText})}catch(e){n(e)}}),this._details}_getActionDescription(e){return m(`op.deletePicture`)}_fromDrawingJSON(e,t){let n=t?.(e.resId);n.addReference(this);let r=vx(e);this._updateState(r?{resource:n,data:r}:{resource:n})}_toDrawingJSON(e){return this.toJSON(e)}_processDelete(){super._processDelete()}get isIPicture(){return!0}},vx=e=>{if(!e)return;let{resId:t,...n}=e;return Object.keys(n).length>0?n:void 0},yx=class extends P{constructor(e){super(e),e.json&&this._updateState({data:e.json,type:e.type})}getType(){return this._getState()?.type??`custom`}toJSON(e){let t=this._getState(),n=null;return t&&t.data&&(n=t.data),n}getTypeDescription(){return`CustomElement`}};(function(n){let r=new Map,i=new Map,a=!1,o=()=>{a||(a=!0,function(t){t(`picture`,e=>new _x(e)),t(`chart`,{load:()=>e(()=>import(`./BTKdl-XR9TlWaFe7.js`),__vite__mapDeps([20,1,2,21,11,3,12,7,22]),import.meta.url),select:e=>t=>new e.Chart(t)}),t(`shape`,{load:()=>e(()=>import(`./CiFaOHqsDQTE4RRi.js`),__vite__mapDeps([23,1,2,21,11,3,12]),import.meta.url),select:e=>t=>new e.Shape(t)}),t(`group`,{load:()=>e(()=>import(`./CcVllJMjVF6SvVVq.js`),__vite__mapDeps([24,1,2,21,11,3,12]),import.meta.url),select:e=>t=>new e.Group(t)}),t(`relIds`,e=>new yx({...e,type:`smartArt`})),t(`slicer`,{load:()=>e(()=>import(`./DXbOBAxx4_2rt5KM.js`),__vite__mapDeps([25,1,2,21]),import.meta.url),select:e=>t=>new e.Slicer(t)}),t(`graphicFrame`,e=>new yx(e));let n=t=>({load:()=>e(()=>import(`./D6Yv5cc1JE7DGd6j.js`),__vite__mapDeps([26,1,2,21,7]),import.meta.url),select:e=>n=>t(e,n)});t(`button`,n((e,t)=>new e.Button(t))),t(`checkBox`,n((e,t)=>new e.CheckBox(t))),t(`optionButton`,n((e,t)=>new e.OptionButton(t))),t(`listBox`,n((e,t)=>new e.ListBox(t))),t(`dropDown`,n((e,t)=>new e.DropDown(t))),t(`scrollBar`,n((e,t)=>new e.ScrollBar(t))),t(`spinner`,n((e,t)=>new e.Spinner(t))),t(`groupBox`,n((e,t)=>new e.GroupBox(t))),t(`label`,n((e,t)=>new e.Label(t))),t(`editBox`,n((e,t)=>new e.FormControl({...t,type:`editBox`,typeDescription:`Edit Box`}))),t(`dialog`,n((e,t)=>new e.FormControl({...t,type:`dialog`,typeDescription:`Dialog`}))),t(`formControl`,n((e,t)=>new e.FormControl({...t,type:`formControl`})))}(s))};function s(e,n){let a=i.get(e);if(a&&C.remove(a),typeof n==`function`)return r.set(e,n),i.delete(e),()=>{r.get(e)===n&&r.delete(e)};let o=t(`movable-content:${e}`,n.load,{select:n.select??(e=>e),prefetch:n.prefetch});return i.set(e,o),r.delete(e),()=>{i.get(e)===o&&(i.delete(e),C.remove(o))}}n.register=function(e,t){return o(),s(e,t)},n.get=function(e){return o(),r.get(e)??i.get(e)?.peek()},n.has=function(e){return o(),r.has(e)||i.has(e)},n.load=function(e){o();let t=r.get(e);if(t)return Promise.resolve(t);let n=i.get(e);return n?n.load():Promise.resolve(void 0)},n.getTypes=function(){return o(),[...r.keys(),...i.keys()]}})(hx||={});var bx=class extends yx{constructor(e){super({...e,json:e.json??{}}),this._error=e.error,this._originalType=e.type}getType(){return`error`}getError(){return this._error}getOriginalType(){return this._originalType}_getSavedType(){return this._originalType}isReadOnly(){return!0}getTypeDescription(){return`Error`}get isIErrorContent(){return!0}},xx=class extends yx{constructor(e){super({...e,json:e.json??{}})}isReadOnly(){return!0}getTypeDescription(){return`Loading`}},Sx=new Set;async function Cx(){for(;Sx.size>0;)await Promise.allSettled(Array.from(Sx))}var wx=(e=m(`op.update`))=>N(`error.sheet.protectedField`,{description:N(e)}),Tx=e=>N(`error.sheet.unsupportedFloatingType`,{type:e}),Ex=e=>N(`error.sheet.itemOverlapping`,{type:e}),Dx=(e,t,n)=>N(`error.sheet.maxValues`,{max:e,count:t,address:n});async function Ox(e){if(!e?.type)return;await hx.load(e.type).catch(()=>{});let t=e.json?.members;if(Array.isArray(t))for(let e of t)await Ox(e?.content)}function kx(e,t,n){let r=hx.get(e);if(r)try{return r(t)}catch(n){return Ax(e,t,n)}if(hx.has(e)){let r=new xx(t);return function(e){let t=e.finally(()=>{Sx.delete(t)});Sx.add(t)}(hx.load(e).then(i=>{let a=n.getMovable();!i||!a||n.isClosed()||a.isDeleted()||r.isDeleted()||a.getContent()!==r?a?._replaceContent(null):a._replaceContent(n.amend(()=>{try{return i(t)}catch(n){return Ax(e,t,n)}}))},i=>{console.warn(`The '${e}' content could not be loaded; it is kept as it was read.`,i);let a=n.getMovable();!a||n.isClosed()||a.isDeleted()||a.getContent()!==r?a?._replaceContent(null):a._replaceContent(n.amend(()=>new bx({...t,type:e,error:i})))})),r}return console.warn(Tx(e)),new yx(t)}function Ax(e,t,n){return console.warn(`The '${e}' content could not be created; it is kept as it was read.`,n),new bx({...t,type:e,error:n})}var jx=()=>{},Mx=class e extends Hv{constructor(e){if(super(e),this._contentLoaded=null,!e.content)throw Error(`Content type is required`);this._content=e.content,this._optionsMovable=e;let t=this;this._optionsMovable.setContainerCallbacks?.({processZIndex:()=>t._processZIndex(),processSelection:(e,n)=>t._processContainerSelect(e,n)}),e.json&&this._fromJSON(e.json)}getContent(){return this._content}getReferences(){return this._content.getReferences()}isContentLoaded(){return!(this._content instanceof xx)}_savedType(){return this._content._getSavedType?.()??this._content.getType()}whenContentLoaded(){if(this.isContentLoaded())return Promise.resolve(this._content);if(!this._contentLoaded){let e,t=new Promise(t=>{e=t});this._contentLoaded={promise:t,resolve:e}}return this._contentLoaded.promise}_replaceContent(e){e&&(this._content=e,this._getEmitter().notify(`onAnyChange`));let t=this._contentLoaded;this._contentLoaded=null,t?.resolve(this._content)}delete(e){this._content.delete(e)}_deleteFromContent(){this._delete()}_processAfterStateChange(e,t){super._processAfterStateChange(e,t),xt(),this._getEmitter().notify(`onBoundsChange`),this._getEmitter().notify(`onAnyChange`),this._forwardLayout()}_forwardLayout(){let e=this._content?this.getMovables():null;if(e)for(let t of e.getItems())t._processContainerLayout?.()}_notifyPlacementChange(e=!1){let t=this._optionsMovable.onPlacementChange;t?t(this,e):this.getParent()?._notifyPlacementChange(e)}_processZIndex(){this._getEmitter().notify(`onAnyChange`)}_processContainerSelect(e,t){this._getEmitter().notify(`onSelectionChange`)}_processSelection(e,t){return this._processContainerSelect(e,t)}_viewSelection(){return this.isDeleted()?null:this.getRange()?.getWorksheet()?.getView()?.getMovableSelection()??null}isSelected(){let e=this._optionsMovable.isSelected;return e?e():this._viewSelection()?.isSelected(this)??!1}async scrollIntoView(e){let t=this._optionsMovable.scrollIntoView;return t?t(e):this.getParent()?.scrollIntoView(e)??!1}async select(e){let t=this._viewSelection();if(!t)return!1;try{t.select([this],{add:e?.addToSelection})}catch(e){return console.warn(e),!1}let n=await this.scrollIntoView(e?.scrollIntoView);if(e?.scrollIntoView&&!1===n)return!1;if(!1!==e?.autoFocus){let e=await this._getEmitter().notify(`onRequestFocus`,{async:!0});if(!e)return!1;let t=e.length;for(let n=0;n<t;n++)if(!1===e[n])return!1}return!0}unselect(){let e=this._viewSelection();return!!e?.isSelected(this)&&(e.unselect([this]),!0)}_clone(){let t=this.isSelected(),n=this.getZIndex(),r=this._optionsMovable.getMaxBounds,i=this._content,a={beginPersistResource:this._optionsMovable.beginPersistResource,getBoundsAtCoords:this._optionsMovable.getBoundsAtCoords,getCoordsAtBounds:this._optionsMovable.getCoordsAtBounds,isSelected:()=>t,getZIndex:()=>n,getContainerIndex:()=>n,getMaxBounds:r,getRanges:e=>this._optionsMovable.getRanges(e),getEntireRange:()=>this._optionsMovable.getEntireRange(),transactions:new se({transient:!0}),json:this.toJSON(),coords:this.getFirstAnchorCoords(),content:i},o=new e(a),s=this._getState();return o._updateState({...s}),o}getSnapshot(e,t){let n=this._optionsMovable.getCoordsAtBounds(e),r=this._getState().offsets,i=this.getFirstAnchorCoords();if((r.br.x>0||r.br.y>0)&&(i={...i},i.colEnd-=+(r.br.x>0),i.rowEnd-=+(r.br.y>0)),!h.isRangeWithinRange(i,n))return null;let a=this,o=a._clone(),s=Object.freeze({...t}),c=!1;return{prepare:()=>Ox({type:o._savedType(),json:o._content.toJSON(()=>null)}),copyTo(e,t){let n={...s,...t};return o._doCopy(e,n),n.isCut&&!c&&(a._content.delete(),c=!0),e.bounds},getCoords:()=>o.getBounds(),getSource:()=>o,getName:()=>o._content.getName?.()??``,getMarkOptions:()=>s,toText:()=>o._toText(),toHtml:()=>o._toHtml(),toImage:()=>o._toImage(),isISnapshot:!0}}_doCopy(e,t){let n=this._optionsMovable.beginPersistResource(),r=this.toJSON(n.toResourceId.bind(n)),i=this._content.getName?.()??null,a;if(i){let e=N(m(`movable.copySuffix`),{name:i});a=e===`movable.copySuffix`?`${i} (Copy)`:e}let o=r.content.json,s=r.content.description;delete r.content;let c=e.movables;if(!c)throw Error(`Movables is required`);let l=e.bounds??this.getBounds();try{c._insertNow({...r,anchorType:this.getAnchorType(),...t,fromResourceId:n.fromResourceId.bind(n),bounds:l,type:this._savedType(),json:o,name:a,altText:s,description:m(`op.copyMovable`)})}finally{n.endPersist()}}_toText(){return this.getContent().toText?.()}_toHtml(){return this.getContent().toHtml?.()}_toImage(){return this.getContent().toImage?.()}setHidden(e=!1){return!!e===this.isHidden()||(this._updateState({hidden:!!e},{description:m(`op.setMovableVisibility`)}),this._options.invalidate?.()),this}isHidden(){return this._getState()?.hidden??!1}setLockAspectRatio(e){return this._updateState({lockAspectRatio:e},{description:m(`op.setLockAspectRatio`)}),this}isLockAspectRatio(){return this._getState()?.lockAspectRatio??this._isDefaultLockAspectRatio()}setPrintObject(e){return!!e===this.isPrintObject()||this._updateState({noPrint:!e},{description:m(`op.setPrintObject`)}),this}isPrintObject(){return!this._getState()?.noPrint}_isDefaultLockAspectRatio(){return this._content?.isDefaultLockAspectRatio?.()??!1}getConnectionSites(e){return Lt(this,e??Rt(this),jx)?.map(({index:e,x:t,y:n})=>({index:e,x:t,y:n}))??null}getGluedConnectors(){let e=this.getRange().getWorksheet();return e?ye(e,ze([this])):[]}setRotation(e=0){let t=this._acceptRotation(e);if(t===null)return this;e=t;let n=this.getRotation();if(e===n)return this;let r=_e(e)===_e(n)?null:this.getBounds(),i=this._beginCommit(m(`op.setMovableRotation`));try{this._updateState({rotation:e},{description:m(`op.setMovableRotation`)}),r&&this._setAnchorBounds(Nt(r,e)),this._notifyPlacementChange(),i.commit()}catch(e){throw i.rollback(),e}return this}getRotation(){return this._getState()?.rotation??0}setFlip(e,t){let n=this.getFlip(),r=this._acceptFlip({horizontal:e.horizontal??n.horizontal,vertical:e.vertical??n.vertical});if(!r)return this;let i=r.horizontal,a=r.vertical;if(i===n.horizontal&&a===n.vertical)return this;let o=t?.description??m(`op.setMovableFlip`),s=this._beginCommit(o);try{this._updateState({flipH:i,flipV:a},{description:o}),this._notifyPlacementChange(),s.commit()}catch(e){throw s.rollback(),e}return this}_acceptRotation(e){let t=this._content;return t?.acceptRotation?t.acceptRotation(e):null}_acceptFlip(e){let t=this._content;return t?.acceptFlip?t.acceptFlip(e):null}getFlip(){let e=this._getState();return{horizontal:e?.flipH??!1,vertical:e?.flipV??!1}}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(n.width<0||n.height<0)throw new w;let r=this.getBounds(),i=r.width===n.width&&r.height===n.height&&(r.x!==n.x||r.y!==n.y),a=this._beginCommit(t?.description??m(`op.setMovableBounds`));try{this._setAnchorBounds(Nt(n,this.getRotation())),this._notifyPlacementChange(i),a.commit()}catch(e){throw a.rollback(),e}return this}_setAnchorBounds(e){let t=e;if(this._optionsMovable.getMaxBounds&&(t={x:Math.max(t.x,this._optionsMovable.getMaxBounds().x),y:Math.max(t.y,this._optionsMovable.getMaxBounds().y),width:Math.min(t.width,this._optionsMovable.getMaxBounds().width),height:Math.min(t.height,this._optionsMovable.getMaxBounds().height)}),t.width<0||t.height<0)throw new w;let n=this._updateMovableLocation({bounds:t,anchorType:Ih.Type.Absolute});this._updateState({offsets:n.offsets,anchorCoords:n.anchorCoords,pixelBounds:this.getAnchorType()===Ih.Type.TwoCell?null:t},{description:m(`op.updateMovableBounds`)},[`onBoundsChange`]),this._options.setContainerCoords(n.anchorCoords)}_updateMovableLocation(e){let t=e.offsets??Nx(),n=e.anchorCoords??this.getFirstAnchorCoords(),r=e.anchorType??this.getAnchorType();if(r===Ih.Type.TwoCell)return n?{anchorCoords:n,offsets:t}:void 0;let i=e.bounds??this._getAnchorBounds();if(i){if(r===Ih.Type.Absolute){n=this._optionsMovable.getCoordsAtBounds(i);let e=this._optionsMovable.getBoundsAtCoords(n);t={...t,tl:{x:i.x-e.x,y:i.y-e.y}}}if(r===Ih.Type.Absolute||r===Ih.Type.OneCell){let e=this._optionsMovable.getBoundsAtCoords({colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colStart,rowEnd:n.rowStart}),r=this._optionsMovable.getCoordsAtBounds({x:e.x,y:e.y,width:i.width+Math.min(e.width,t.tl.x),height:i.height+Math.min(e.height,t.tl.y)});n={colStart:n.colStart,rowStart:n.rowStart,colEnd:r.colEnd,rowEnd:r.rowEnd};let a=this._optionsMovable.getBoundsAtCoords({colStart:n.colEnd,rowStart:n.rowEnd,colEnd:n.colEnd,rowEnd:n.rowEnd}),o=i.width-(a.x-e.x-Math.min(t?.tl.x??0,e.width)),s=i.height-(a.y-e.y-Math.min(t?.tl.y??0,e.height));t={...t,br:{x:o,y:s}}}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--)),{anchorCoords:n,offsets:t}}}_calcAbsoluteBounds(e,t=Nx()){if(!e)return null;let n=this._optionsMovable.getBoundsAtCoords({rowStart:e.rowStart,colStart:e.colStart,colEnd:e.colStart,rowEnd:e.rowStart}),r=+!t.br.x,i=+!t.br.y,a=this._optionsMovable.getBoundsAtCoords({colStart:e.colEnd+r,rowStart:e.rowEnd+i,colEnd:e.colEnd+r,rowEnd:e.rowEnd+i}),o=Math.min(n.x+(t?.tl.x??0),n.x+n.width),s=Math.min(n.y+(t?.tl.y??0),n.y+n.height);return{x:o,y:s,width:Math.min(a.x+(t?.br.x??0),a.x+a.width)-o,height:Math.min(a.y+(t?.br.y??0),a.y+a.height)-s}}getBounds(){let e=this._getAnchorBounds();return e?Nt(e,this.getRotation()):null}getParent(){return null}getMovables(){return this._content.getMovables?.()??null}_getDrawnBounds(e){let t=this._getAnchorBounds();if(!t)return null;let n=this.getRotation(),r=Nt(t,n),i=this._content,a=Be(i)?i._getDrawnRect(r.width,r.height,e):null;return a||n?{anchor:t,drawn:Se(r,a,n,this.getFlip())}:{anchor:t,drawn:t}}_getAnchorBounds(){let e=this._getState(),t=this.getFirstAnchorCoords();if(!e||!t)return null;let n=e.pixelBounds,r=this.getAnchorType();if(n&&r===Ih.Type.Absolute)return n;let i=this._calcAbsoluteBounds(t,e.offsets);return n&&r===Ih.Type.OneCell&&(i.width=n.width,i.height=n.height),i}setAnchorType(e){return i.validEnumValue(Ih.Type,e),this._updateState({anchorType:e,pixelBounds:e===Ih.Type.TwoCell?null:this._getAnchorBounds()},{description:m(`op.setMovableResizeBehavior`)},[`onAnchorTypeChange`]),this}_processContainerShift(e){let t=this.getAnchorType(),n=this._getState()?.offsets,r=n,i=!1,a=e.before,o=e.axis===B.Axis.Column,s=e.intersect,c=e.amount,l=e.after;if(t!==Ih.Type.Absolute){let e=o?s.colStart:s.rowStart,n=o?a.colStart:a.rowStart;t===Ih.Type.TwoCell&&(n=o?a.colEnd:a.rowEnd),i=e<=n}if(i&&(t!==Ih.Type.OneCell||l)||(l=a),i&&l&&c<0&&(o?(s.colStart<=a.colStart&&s.colEnd>=a.colStart&&(r={...r,tl:{...r.tl,x:0}}),r.br.x>0&&s.colStart<=a.colEnd&&s.colEnd>=a.colEnd&&(r={...r,br:{...r.br,x:0}},l={...l,colEnd:l.colEnd+1})):(s.rowStart<=a.rowStart&&s.rowEnd>=a.rowStart&&(r={...r,tl:{...r.tl,y:0}}),r.br.y>0&&s.rowStart<=a.rowEnd&&s.rowEnd>=a.rowEnd&&(r={...r,br:{...r.br,y:0}},l={...l,rowEnd:l.rowEnd+1}))),l===null&&!this._content.isDeleted()){let e=this._processContainerRemoved();if(e){let t=this._locationFromAnchor(e);r=t.offsets,l=t.anchorCoords}}if(l!==null){let{offsets:e,anchorCoords:t}=this._updateMovableLocation({anchorCoords:l,offsets:r});r=e,l=t}let u=null,d=this._beginCommit(m(`op.shiftingMovableBounds`));try{if(n!==r||!h.isEqualRanges(a,l)){let e={offsets:r,anchorCoords:l};this._updateState(e)}u=super._processContainerShift({...e,after:l}),l||this._content.isDeleted()||this._content.delete(),d.commit()}catch(e){throw d.rollback(),e}return u}_processContainerRemoved(){return null}_locationFromAnchor(e){let t=e.tl,n=e.br,r={tl:{x:t.x??0,y:t.y??0},br:{x:n.x??0,y:n.y??0}},i=t.c??0,a=t.r??0;return{offsets:r,anchorCoords:{colStart:i,rowStart:a,colEnd:Math.max(i,(n.c??0)+(r.br.x>0?0:-1)),rowEnd:Math.max(a,(n.r??0)+(r.br.y>0?0:-1))}}}_processContainerLayout(){let e=this.getFirstAnchorCoords();if(e){if(this.getAnchorType()!==Ih.Type.TwoCell){let t=this._getState()?.offsets,n=this._updateMovableLocation({anchorCoords:e,offsets:t});if(n&&(!h.isEqualRanges(e,n.anchorCoords)||!Px(t,n.offsets))){let e=this._beginCommit(m(`op.updatingMovableBounds`));try{this._updateState({offsets:n.offsets,anchorCoords:n.anchorCoords},null,null,!0),e.amend()}catch(t){throw e.rollback(),t}}}super._processContainerLayout(),this._getEmitter().notify(`onBoundsChange`),this._forwardLayout()}}_processAnchorCoords(){super._processAnchorCoords()}enrichOffset(e,t,n){if(e.r!==void 0&&e.c!==void 0)return e;let r=(e?.x??0)+t,a=(e?.y??0)+n,o=this._optionsMovable.getCoordsAtBounds({x:r,y:a,width:0,height:0}),s=this._optionsMovable.getBoundsAtCoords(o);return(e={...e}).c===void 0&&(e.c=o.colStart,e.x=i.roundAccurately(r-s.x,1)),e.r===void 0&&(e.r=o.rowStart,e.y=i.roundAccurately(a-s.y,1)),e}_fromJSON(e){let t=Nx(),n={...h.EmptyRange},r=e.anchor,a=r?.tl??i.EmptyObject,o=r?.br??i.EmptyObject,s={c:a.c,r:a.r,x:a.x,y:a.y},c={c:o.c,r:o.r,x:o.x,y:o.y},l=e.anchorType;s.r!=null&&s.c!=null||(l??=Ih.Type.Absolute);let u=s.x=s.x??0,d=s.y=s.y??0;if(s=this.enrichOffset(s,0,0),c.x=c.x??0,c.y=c.y??0,c.r==null||c.c==null){l??=Ih.Type.OneCell;let e=this._optionsMovable.getBoundsAtCoords({rowStart:s.r,colStart:s.c,colEnd:s.c,rowEnd:s.r}),t=this.enrichOffset(c,e.x+s.x,e.y+s.y);c.r??(c.r=t.r,c.y=t.y),c.c??(c.c=t.c,c.x=t.x)}c=this.enrichOffset(c,u,d),t.tl=s,t.br=c,n.colStart=s.c,n.rowStart=s.r,n.colEnd=Math.max(n.colStart,c.c+(t.br.x>0?0:-1)),n.rowEnd=Math.max(n.rowStart,c.r+(t.br.y>0?0:-1));let f=this._beginCommit(m(`op.loadMovable`));l??=Ih.Type.TwoCell;let p={anchorCoords:n,offsets:t,hidden:e.hidden??!1,rotation:e.rotation??0,flipH:e.flipH??!1,flipV:e.flipV??!1,lockAspectRatio:e.lockAspect??null,locks:e.locks??null,noPrint:e.noPrint??!1,unlocked:e.unlocked??!1,anchorType:l};l!==Ih.Type.TwoCell&&(p.pixelBounds=this._calcAbsoluteBounds(n,t)),this._updateState(p,{description:m(`op.loadMovable`)}),this._optionsMovable.setContainerCoords?.(n),f.commit()}_getAnchorJSON(){let e=this._getState(),t=e.anchorCoords,n=e.offsets,r={tl:{c:t.colStart,r:t.rowStart},br:{c:t.colEnd+ +!n?.br?.x,r:t.rowEnd+ +!n?.br?.y}};return n&&(n.tl?.x&&(r.tl.x=i.roundAccurately(n.tl.x,1)),n.tl?.y&&(r.tl.y=i.roundAccurately(n.tl.y,1)),n.br?.x&&(r.br.x=i.roundAccurately(n.br.x,1)),n.br?.y&&(r.br.y=i.roundAccurately(n.br.y,1))),r}toJSON(e){let t=this._getState(),n=this._content.toJSON(e)??{},r={anchor:this._getAnchorJSON(),content:{type:this._savedType(),json:n}},a=this._content.getName?.();a&&(r.content.name=a);let o=this._content.getDescription();o&&(r.content.description=o);let s=t.anchorType;return s&&s!==Ih.Type.TwoCell&&(r.anchorType=this.getAnchorType()),t.hidden&&(r.hidden=t.hidden),t.rotation!==void 0&&t.rotation!==0&&(r.rotation=t.rotation),t.flipH&&(r.flipH=!0),t.flipV&&(r.flipV=!0),i.isDefined(t.lockAspectRatio)&&t.lockAspectRatio!==this._isDefaultLockAspectRatio()&&(r.lockAspect=t.lockAspectRatio),t.locks&&(r.locks=t.locks),t.noPrint&&(r.noPrint=!0),t.unlocked&&(r.unlocked=!0),r}get isIMovable(){return!0}},Nx=()=>({tl:{x:0,y:0},br:{x:0,y:0}}),Px=(e,t)=>e===t||!(!e||!t)&&e.tl.x===t.tl.x&&e.tl.y===t.tl.y&&e.br.x===t.br.x&&e.br.y===t.br.y,Fx=class extends Qt{constructor(e,t,n,r,i,a,o,s){super(),this._group=s,this._prepareDelegate=e,this._preparePictureDelegate=t,this._insert=n,this._getItemsDelegate=r,this._getCount=i,this._updateSelected=a,this._addListeners=o}async add(e){return this._insert(await this._prepareDelegate(e))}_prepare(e){return this._prepareDelegate(e)}_preparePicture(e,t){return this._preparePictureDelegate(e,t)}_insertNow(e){return this._insert(e)}_getItems(e){return this._getItemsDelegate(e)}getCount(){return this._getCount()}updateSelected(e,t){return this._updateSelected(e,t)}addListeners(e,t){return this._addListeners(e,t)}async addPicture(e,t){return this._insert(await this._preparePictureDelegate(e,t))}group(e,t){return this._group(e,t)}get isIMovableCollection(){return!0}},Ix={type:`chart`},Lx=class extends Qt{constructor(e,t=null){super(),this._movables=e,this._sheet=t}async add(t,n){let{type:r,seriesBy:i,bounds:a,...o}=n??{},{createModelFromSource:s,newChartType:c,customKindOf:l,setCustomKind:u}=await e(async()=>{let{createModelFromSource:e,newChartType:t,customKindOf:n,setCustomKind:r}=await import(`./BTKdl-XR9TlWaFe7.js`);return{createModelFromSource:e,newChartType:t,customKindOf:n,setCustomKind:r}},__vite__mapDeps([20,1,2,21,11,3,12,7,22]),import.meta.url);if(!this._sheet)throw Error(`A chart is added to a sheet.`);let d=l(r),f=s(d?`columnClustered`:c(r),t,this._sheet,i);return d&&(f=u(d)(f)),(await this._movables.add({autoPlace:`viewport`,description:m(`op.insertChart`),...o,type:`chart`,json:{model:f},bounds:{width:480,height:288,...a}})).getContent()}_getItems(){return this._movables.getItems(Ix).map(e=>e.getContent())}getByName(e){if(typeof e!=`string`)return null;let t=e.toLocaleLowerCase(),n=this._movables.getItems(Ix),r=n.length;for(let e=0;e<r;e++){let r=n[e].getContent();if(r.getName?.()?.toLocaleLowerCase()===t)return r}return null}addListeners(e,t){let n=this,r=e.onCollectionChange,i=e.onInvalidated;return this._movables.addListeners({onCollectionChange:r?()=>{r(n)}:void 0,onInvalidated:i?()=>{i(n)}:void 0},t)}get isIChartCollection(){return!0}},Rx=/^[^\p{L}_\\]+$/u,zx=/[^\p{L}\p{M}\p{N}_.?\\]/u,Bx=class extends Qt{constructor(e){super(e.transactions),this._lastLookup=i.EmptyArray,this._lastLookupAddress=null,this._lastLookupType=null,this._lastIncludeHidden=!1,this._lastAllowExtrudes=!1,this._lastLookupName=void 0,this._lastLookupScope=void 0,this._lastLookupHasScope=!1,this._sources=i.EmptyArray,this._sourcesRemoveListeners=[],this._options={...e},this._getSources=e.getSources??null,this._transactions=this._options.transactions??new se({transient:!0})}_resolveSources(){if(!this._getSources||this.isClosed())return this._sources;let e=this._getSources()??i.EmptyArray,t=this._sources;if(e.length===t.length){let n=!0;for(let r=0;r<e.length;r++)if(e[r]!==t[r]){n=!1;break}if(n)return t}let n=this,r=this._sourcesRemoveListeners.length;for(let e=0;e<r;e++)this._sourcesRemoveListeners[e]?.();this._sourcesRemoveListeners=[],this._sources=e;let a=e.length;for(let t=0;t<a;t++)this._sourcesRemoveListeners.push(e[t].addListeners({onCollectionChange:()=>{n.isClosed()||(n._invalidateLookup(),n._notifyCollectionChange())},onInvalidated:()=>{n.isClosed()||(n._invalidateLookup(),n._notifyInvalidated())}},{transactional:!1}));return this._invalidateLookup(),e}_getOwningSource(){let e=this._resolveSources(),t=e.length;for(let n=0;n<t;n++)if(e[n].add)return e[n];return null}_getItems(e){if(this.isClosed())return i.EmptyArray;let t,n,r,a,o,s=null,c=!1;if(e&&(s=e.address??null,t=e.allowExtrudes??void 0,n=e.type??void 0,r=e.includeHidden??void 0,a=e.name??void 0,c=`scope`in e,o=c?e.scope??null:void 0,s===this._lastLookupAddress&&n===this._lastLookupType&&r===this._lastIncludeHidden&&t===this._lastAllowExtrudes&&a===this._lastLookupName&&o===this._lastLookupScope&&c===this._lastLookupHasScope))return this._lastLookup;this._lastLookupAddress=s,this._lastLookupType=n,this._lastIncludeHidden=r,this._lastAllowExtrudes=t??void 0,this._lastLookupName=a,this._lastLookupScope=o,this._lastLookupHasScope=c;let l=null;if(s){let e=this._options.addressToRanges(s);if(!e)return O.debug(`Invalid range`,{meta:{type:`error`,address:s}}),this._lastLookup=null,null;l=e.getCoords()}let u=this._collectCandidates(l,t);if(u.length===0)return this._lastLookup=i.EmptyArray,i.EmptyArray;let d=a?.toLowerCase(),f=[],p=u.length;for(let e=0;e<p;e++){let t=u[e];n&&t.getType()!==n||!r&&t.isHidden()||d&&t.getName().toLowerCase()!==d||c&&t.getScope()!==o||f.push(t)}return f=f.sort((e,t)=>{let n=e.getType().localeCompare(t.getType());return n===0?e.getName().localeCompare(t.getName()):n}),this._lastLookup=f,f}getByRanges(e,t){return this._getByRanges(e,t,null)}_getByRanges(e,t,n){if(this.isClosed())return i.EmptyArray;let r=this._qualifyCoords(e,n);if(!r)return i.EmptyArray;let a=this.getItems(t),o=a?a.length:0;if(o===0)return i.EmptyArray;let s=this._resolveSources();for(let e=0;e<s.length;e++)s[e].prepareRanges?.(a);let c=[],l=[];for(let e=0;e<o;e++){let n=a[e],i=null;try{i=n.getRanges?.()?.getCoords()??null}catch{}if(i&&h.isEqualRangesArrays(i.slice().sort(h.rowFirstRangeComparator),r)){c.push(n.getName());continue}if(!t?.includeParts)continue;let o=n.getPartReference?.(r,t?.home??null)??null;o&&l.push(o)}for(let e=0;e<l.length;e++)c.push(l[e]);return c}_qualifyCoords(e,t){let n=null;try{n=(t?t.getRanges(e):this._options.addressToRanges(e))?.getCoords()??null}catch{return null}if(!n||n.length===0)return null;let r=t?t.getName():this._currentScope();return n.map(e=>e.scope?e:{...e,scope:r}).sort(h.rowFirstRangeComparator)}_collectCandidates(e,t){let n=this._resolveSources(),r=n.length;if(r===0)return i.EmptyArray;let a=[];for(let i=0;i<r;i++){let r=n[i].getItems();e&&n[i].prepareRanges?.(r);let o=r.length;for(let n=0;n<o;n++){let i=r[n];i&&(e&&!this._matchesCoords(i,e,t)||a.push(i))}}return a}_matchesCoords(e,t,n){let r=null;try{r=e.getRanges?.()?.getCoords()??null}catch{return!1}if(!r||r.length===0)return!1;let i=t.length,a=r.length;for(let e=0;e<i;e++){let i=t[e],o=i.scope;for(let e=0;e<a;e++){let t=r[e];if(t&&(!o||!t.scope||t.scope===o)){if(n){if(h.isRangesIntersect(t,i))return!0}else if(h.isRangeWithinRange(t,i))return!0}}}return!1}getByName(e,t=!1){return this._getByName(e,t,this._currentScope())}_getByName(e,t=!1,n=null){if(!e||this.isClosed()||typeof e!=`string`)return null;let r=e.toLowerCase();return this._findInSources(e=>e.getName().toLowerCase()===r,t?void 0:n??void 0)}_currentScope(){return this._options.getCurrentScope?.()??null}_scopedTo(e){let t=this,n=new Map;return new Proxy(t,{get:(r,i)=>{if(i===`getItems`)return n=>((e,t)=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i].getScope();a?a===t&&n.push(e[i]):r.push(e[i])}if(n.length===0)return r.slice();let i=new Map;for(let e=0;e<r.length;e++)i.set(r[e].getName().toLowerCase(),r[e]);for(let e=0;e<n.length;e++)i.set(n[e].getName().toLowerCase(),n[e]);return Array.from(i.values())})(t.getItems(n),e.getName());if(i===`getByName`)return(n,r)=>t._getByName(n,r,e.getName());if(i===`getByRanges`)return(n,r)=>t._getByRanges(n,r,e);if(i===`removeUnused`)return n=>t._removeUnused(n,e.getName());if(i===`addFormula`)return(n,r,i)=>t._addFormula(n,r,i,e.getName());let a=Reflect.get(t,i,t);if(typeof a!=`function`)return a;let o=n.get(i);return o||(o=a.bind(t),n.set(i,o)),o}})}getById(e){if(!e||this.isClosed())return null;let t=this._resolveSources();for(let n=0;n<t.length;n++){let r=t[n].getById;if(typeof r!=`function`)continue;let i=r.call(t[n],e);if(i)return i}return this._findInSources(t=>t.getId()===e)}_findInSources(e,t){let n=t?.toLowerCase(),r=null,i=this._resolveSources(),a=i.length;for(let t=0;t<a;t++){let a=i[t].getItems(),o=a.length;for(let t=0;t<o;t++){let i=a[t];if(!i||!e(i))continue;let o=i.getScope();if(o){if(n&&o.toLowerCase()===n)return i}else r||=i}}return r}_findInSourcesByKey(e,t){let n=e.toLowerCase().trim(),r=t?t.toLowerCase():null,i=this._resolveSources(),a=i.length;for(let e=0;e<a;e++){let t=i[e].getItems(),a=t.length;for(let e=0;e<a;e++){let i=t[e];if(!i||i.getName().toLowerCase().trim()!==n)continue;let a=i.getScope();if((a?a.toLowerCase():null)===r)return i}}return null}findValidName(e,t=null,n=!1){if(!e)throw Error(N(`error.named.templateRequired`));let r=this,i=e=>{try{return r._validateName(e,t,n),!0}catch{}return!1};return i(e)?e:en(e,i)}validateName(e,t=null,n=!1){return this._validateName(e,t,n)}_validateName(e,t,n=!1){if(this.isClosed())throw Error(N(`error.model.modelClosed`));if(!e||e.length===0)throw Error(N(`error.named.nameEmpty`));if(e.length>255)throw Error(N(`error.named.nameMaxLength`));if(e.indexOf(` `)!==-1)throw Error(N(`error.named.containsSpaces`));let r=e.trim().toLowerCase(),i=r.substring(1);if(new RegExp(Rx).test(r[0]))throw Error(N(`error.named.invalidFirstChar`));if(new RegExp(zx).test(i))throw Error(N(`error.named.invalidTrailingChar`));if(r.length===1&&(r[0]===`r`||r[0]===`c`))throw Error(N(`error.named.invalidSpecialRC`));if(function(e,t=vd,n=_d,r=!1){let i=df(e,r);if(!i||i[2]||!i[1])return!1;let a=cf(e,ff);if(!a)return!1;let o=a.rowIndex;if(o<0||o>t)return!1;let s=a.colIndex;return!(s<0||s>=n)}(e))throw Error(N(`error.named.invalidInvalidCellAddress`));let a=e.toLowerCase()?.trim();t&&(a=a+`:`+t.toLowerCase());let o=this._findInSourcesByKey(e,t);if(o){let r=o.getRanges?.()??null;if(!n||r&&r.getCount()>0)throw Error(t?N(`error.named.nameExistsInScope`,{name:e,scope:t}):N(`error.named.nameExists`,{name:e}))}}addFormula(e,t,n=!1){return this._addFormula(e,t,n,null)}removeUnused(e){return this._removeUnused(e,void 0)}_removeUnused(e,t){let n=this._getOwningSource();return n?.removeUnused?!e?.dryRun&&this._options.isReadOnly?.()?Promise.reject(Error(N(`error.named.nameReadonly`))):n.removeUnused({...e,scope:t}):Promise.resolve(0)}_addFormula(e,t,n=!1,r=null){let i=this._getOwningSource();if(!i?.add)throw Error(`Cannot define '${e}': no calculation engine is attached to these names.`);if(this._options.isReadOnly?.())throw Error(N(`error.named.nameReadonly`));return this._validateName(e,r,n),i.add({name:e,expression:t,replaceExisting:n,scope:r})}beginCommit(e){return this._transactions.beginCommit(typeof e==`string`?{description:e}:e)}_invalidateLookup(){this._lastLookup=i.EmptyArray,this._lastLookupAddress=null,this._lastLookupType=null,this._lastLookupName=void 0,this._lastLookupScope=void 0,this._lastLookupHasScope=!1}addListeners(e,t){return this._resolveSources(),super.addListeners(e,t)}close(){if(this.isClosed())return;this._close();let e=this._sourcesRemoveListeners.length;for(let t=0;t<e;t++)this._sourcesRemoveListeners[t]?.();this._sourcesRemoveListeners=[]}get isINamedCollection(){return!0}};function Vx(e){return/^[A-Za-z]+:[A-Za-z]+$/.test(e)||/^\d+:\d+$/.test(e)?e.split(`:`).map(e=>`$${e}`).join(`:`):e.replace(/\$?([A-Za-z]+)\$?(\d+)/g,`$$$1$$$2`)}function Hx(e){return e.replace(/\$/g,``)}function Ux(e){let t=e?.location;if(!t||t.includes(`#REF!`))return null;let n=Yd(t);if(!n)return null;let{colStart:r,rowStart:i,colEnd:a,rowEnd:o}=n;return r===void 0||i===void 0||a===void 0||o===void 0?null:{colStart:r,rowStart:i,colEnd:a,rowEnd:o}}function Wx(e){let t=e.pageFields?.length??0;if(t===0)return{rows:0,columns:0,wrap:0};let n=e.pageWrap&&e.pageWrap>0?e.pageWrap:t,r=Math.min(n,t),i=Math.ceil(t/n);return e.pageOverThenDown?{rows:i,columns:r,wrap:n}:{rows:r,columns:i,wrap:n}}var Gx;(Gx||={}).Axis={Row:`row`,Column:`column`,Page:`page`,Values:`values`};var Kx,qx=`(blank)`,Jx=(e,t)=>{let n=[];for(let e=0;e<t;e++)n.push([]);for(let[t,r]of e??[]){let e=n[t];if(e)for(let[t,n]of r){let r=n.length;for(let i=0;i<r;i++)e[t+i]=n.at(i)}}return n},Yx=e=>!!e?.group&&(e.group.range!==void 0||e.group.discrete!==void 0),Xx=(e,t)=>[...e.filter(e=>e.item!==void 0),...(t??[`default`]).map(e=>({type:e}))],Zx=(e,t)=>t===`row`?e.rowFields??[]:t===`column`?e.columnFields??[]:t===`page`?(e.pageFields??[]).map(e=>e.field):[],Qx=e=>e?.formula!==void 0,$x=(e,t)=>!!t?.some(e=>(e.calculatedItems?.length??0)>0)||!!e.dataFields?.some(e=>Qx(t?.[e.field])),eS=(e,t)=>(e.filters?.length??0)>0||$x(e,t),tS=e=>{let t=e.fields??[],n=Jx(e.items,t.length);return t.forEach((e,t)=>{Yx(e)&&(n[t]=e.group.items)}),n},nS=new WeakMap,rS=e=>Yx(e)?e.group.dateItems:e?.dateItems,iS=(e,t)=>{let n=rS(e);if(!n||t===void 0)return!1;let r=nS.get(n);return r||nS.set(n,r=new Set(n)),r.has(t)},aS=(e,t)=>{let n=Yx(e)&&t!==void 0?e.group.items[t]:void 0;return typeof n!=`number`||Number.isInteger(n)?14:22},oS=e=>e==null?null:typeof e==`object`?e.t===`e`?V.getBuiltInByCode(e.v)??V.BuiltIn.NA:null:e,sS=(e,t)=>{if(Qx(e))return`number`;let n=null;for(let r=0;r<t.length;r++){let i=oS(t[r]);if(i===null)continue;let a=typeof i==`number`?e?.dates||iS(e,r)?`date`:`number`:`text`;if(n&&n!==a)return`mixed`;n=a}return n??`blank`},cS=e=>typeof e==`boolean`?e?`TRUE`:`FALSE`:V.isError(e)?e.getLabel():String(e),lS=e=>e.dataField===void 0,uS=e=>e.dataField===void 0?Q_(e.condition)?`label`:`date`:`value`,dS=(e,t,n,r=[])=>{let i=e.filters??[],a=i.filter(e=>e.field!==t||!n(uS(e)));if(a.length===i.length&&r.length===0)return e;let o=Math.max(a.length,...a.map(e=>e.id??0)),s={...e,filters:[...a,...r.map(e=>({...e,id:++o}))]};return s.filters.length===0&&delete s.filters,s},fS=(e,t)=>e.toLocaleLowerCase()===t.toLocaleLowerCase(),pS=(e,t,n)=>e.fields?.[n]?.name??t.fields?.[n]?.name??``,mS=e=>e.item!==void 0&&e.type===void 0,hS=(e,t)=>e.name===void 0?oS(t[e.item]):e.name,gS=(e,t,n)=>{let r=e.fields?.[n]?.items??[],i=t.fields?.[n],a=Yx(i)?i.group.items:((e,t)=>{let n=[];for(let[r,i]of e.items??[])if(r===t)for(let[e,t]of i){let r=t.length;for(let i=0;i<r;i++)n[e+i]=t.at(i)}return n})(t,n);return r.map(e=>{if(!mS(e))return null;if(e.name!==void 0)return e.name;let t=oS(a[e.item]);return t===null?qx:cS(t)})},_S=(e,t)=>{let n=e.fields?.[t]?.axis,r=n===Gx.Axis.Row?e.rowFields:n===Gx.Axis.Column?e.columnFields:null;return r?r.filter(e=>e>=0):null},vS=(e,t,n,r)=>{let i=e.fields,a=!1,o=i.map((e,i)=>{if(i!==t)return e;let o=e.items?.map((e,t)=>{let r=mS(e)?n(e,t):e;return r!==e&&(a=!0),r}),s=r?r(e):e;return s!==e&&(a=!0),a?o?{...s,items:o}:s:e});return a?{...e,fields:o}:e},yS=(e,t,n)=>{if(!!e[t]===n)return e;if(n)return{...e,[t]:!0};let{[t]:r,...i}=e;return i},bS=(e,t,n,r)=>{if(r===void 0?!((e,t)=>{let n=_S(e,t);return!!n&&n.includes(t)&&n[n.length-1]!==t})(e,t):!((e,t)=>_S(e,t)?.includes(t)??!1)(e,t))throw new k(N(`error.pivotTable.notExpandable`));return vS(e,t,(e,t)=>r===void 0||t===r?yS(e,`collapsed`,!n):e)},xS=(e,t,n)=>{let r=e.fields?.[t]?.items??[];if(n&&!r.some((e,t)=>mS(e)&&n.has(t)))throw new k(N(`error.pivotTable.hideAllItems`));let i=e.pageFields??[],a=i.findIndex(e=>e.field===t),o=a>=0&&!!n,s=CS(vS(e,t,(e,t)=>yS(e,`hidden`,!!n&&!n.has(t)),e=>o&&!e.multipleItemSelection?{...e,multipleItemSelection:!0}:e));if(a<0||i[a].item===void 0)return s;let{item:c,...l}=i[a];return{...s,pageFields:i.map((e,t)=>t===a?l:e)}},SS=(e,t)=>{if(!t||t.length===0)return e;let n=new Set([...e.rowFields??[],...e.columnFields??[],...(e.pageFields??[]).map(e=>e.field)]),r=t.filter(t=>!n.has(t)&&(e.fields?.[t]?.items?.some(e=>mS(e)&&e.hidden)||e.filters?.some(e=>e.field===t&&e.dataField===void 0)));return r.length===0?e:{...e,pageFields:[...e.pageFields??[],...r.map(e=>({field:e,slicer:!0}))]}},CS=e=>{let t=e.fields;if(!t)return e;let n=!1,r=t.map(e=>{if(!e.sort?.scope?.items.some(e=>((e,n)=>!!t[e]?.items?.[n]?.hidden)(e.field,e.item)))return e;n=!0;let{sort:r,...i}=e;return i});return n?{...e,fields:r}:e},wS=new Set([`percentOfParent`,`runTotal`,`percentOfRunningTotal`,`rankAscending`,`rankDescending`,`difference`,`percent`,`percentDiff`]),TS=new Set([`difference`,`percent`,`percentDiff`]),ES=`(previous)`,DS=`(next)`,OS=e=>e===void 0?`General`:typeof e==`number`?Oe(e)??`General`:e,kS={sum:`Sum`,count:`Count`,average:`Average`,max:`Max`,min:`Min`,product:`Product`,countNums:`Count`,stdDev:`StdDev`,stdDevp:`StdDevp`,var:`Var`,varp:`Varp`},AS=(e,t,n,r)=>{let i=n=>(t.fields??[]).some((r,i)=>fS(pS(e,t,i),n))||(e.dataFields??[]).some((e,t)=>t!==r&&fS(e.name,n))||fS(e.valuesCaption??`Values`,n),a=n;for(let e=2;i(a);e++)a=`${n}${e}`;return a},jS=(e,t,n,r)=>{let i=kS[r];if(!i)throw new k(N(`error.pivotTable.notAFunction`,{name:r}));let a=e.dataFields[n];if((a.subtotal??`sum`)===r)return a.name;let o=a.name.search(/ of /i);return AS(e,t,o>=0?`${i}${a.name.slice(o)}`:`${i} of ${pS(e,t,a.field)}`,n)},MS=-2,NS={rows:18,columns:3},PS={style:`thin`,color:`ffababab`},FS={style:`thin`,color:`index65`},IS=[0,1,2].map(e=>[0,1,2].map(t=>({borders:{left:t===0?PS:FS,top:e===0?PS:FS,...t===2?{right:PS}:{},...e===2?{bottom:PS}:{}}}))),LS=(e,t,n)=>{if(!e.empty)return null;let{rows:r,columns:i}=NS;if(t<0||t>=r||n<0||n>=i)return null;let a=(e,t)=>e===0?0:e===t-1?2:1;return IS[a(t,r)][a(n,i)]},RS=e=>!(e.rowFields?.length||e.columnFields?.length||e.pageFields?.length||e.dataFields?.length),zS=[`wholeTable`,`pageFieldLabels`,`pageFieldValues`,`firstColumnStripe`,`secondColumnStripe`,`firstRowStripe`,`secondRowStripe`,`firstColumn`,`headerRow`,`firstHeaderCell`,`firstSubtotalColumn`,`secondSubtotalColumn`,`thirdSubtotalColumn`,`blankRow`,`firstSubtotalRow`,`secondSubtotalRow`,`thirdSubtotalRow`,`firstColumnSubheading`,`secondColumnSubheading`,`thirdColumnSubheading`,`firstRowSubheading`,`secondRowSubheading`,`thirdRowSubheading`,`lastColumn`,`totalRow`],BS=new Map(zS.map((e,t)=>[e,t])),VS=[`firstSubtotalColumn`,`secondSubtotalColumn`,`thirdSubtotalColumn`],HS=[`firstSubtotalRow`,`secondSubtotalRow`,`thirdSubtotalRow`],US=[`firstColumnSubheading`,`secondColumnSubheading`,`thirdColumnSubheading`],WS=[`firstRowSubheading`,`secondRowSubheading`,`thirdRowSubheading`],GS=e=>{let t=[];return e.map((e,n)=>{let r=(i=e.type)===void 0?`item`:i===`grand`?`grand`:i===`blank`?`blank`:`subtotal`;var i;let a=e.repeat??0,o=r===`grand`?[]:[...t.slice(0,a),...e.items];return(r===`item`||o.includes(1048832))&&(t=o),{kind:r,index:n,path:o,repeat:a,data:e.dataField??null}})},KS=e=>(e.form??`compact`)===`compact`||[...e.rowFields??[],...e.columnFields??[]].some(t=>t!==MS&&!e.fields?.[t]?.form),qS=(e,t)=>{let n=e.fields??[],r=e.form??`compact`;return(t??[]).map(e=>{let t=e===MS?r:n[e]?.form??`compact`;return{field:e,ownColumn:t!==`compact`,tabular:t===`tabular`,repeatLabels:e!==MS&&!0===n[e]?.repeatLabels}})},JS=e=>{let t=[];return e.forEach((n,r)=>{t.push(r===0?0:t[r-1]+ +!!e[r-1].ownColumn)}),t},YS=e=>{let t=qS(e,e.rowFields),n=qS(e,e.columnFields),r=JS(t),i=n.length===1&&n[0].field===MS,a=e.dataFields?.length===1&&t.length>0&&!t.some(e=>e.field===MS)&&!n.some(e=>e.field===MS),o=e.hiddenFieldHeaders&&!a?0:1;return{firstHeaderRow:i?0:o,firstDataRow:n.length===0||i?1:o+n.length,firstDataCol:t.length>0?r[r.length-1]+1:n.length>0&&e.dataFields?.length&&!n.some(e=>e.field===MS)?1:0}},XS=e=>{if(e.fields&&RS(e)){let t=e=>Array.from({length:e},(e,t)=>({kind:`header`,index:t}));return{rows:t(NS.rows),columns:t(NS.columns),top:0,rowSlots:[],columnSlots:[],labelColumns:[],labelRow:0,headerRows:NS.rows,headerColumns:NS.columns,dataCount:0,compact:(e.form??`compact`)===`compact`,hiddenFieldHeaders:!0===e.hiddenFieldHeaders,pages:[],empty:!0}}let t=e.header,n=!e.rowFields?.length&&!e.columnFields?.length&&!e.dataFields?.length,r=e.rowLines??(n?[]:void 0),i=e.columnLines??(n?[]:void 0);if(!t||!r||!i)return null;let a=qS(e,e.rowFields),o=qS(e,e.columnFields),s=JS(a),c=Wx(e),l=c.rows>0?c.rows+1:0,u=!0===e.pageOverThenDown,d=(e.pageFields??[]).map((e,t)=>({field:e.field,row:u?Math.floor(t/c.wrap):t%c.wrap,column:3*(u?t%c.wrap:Math.floor(t/c.wrap)),selected:e.item!==void 0})),f=[];for(let e=0;e<c.rows;e++)f.push({kind:`page`,index:e});l>0&&f.push({kind:`gap`});let p=t.firstDataRow;for(let e=0;e<p;e++)f.push({kind:`header`,index:e});let m=(e.dataFields?.length??0)>0;(m||a.length>0)&&f.push(...GS(r));let h=[],g=t.firstDataCol;for(let e=0;e<g;e++)h.push({kind:`header`,index:e});return(m||o.length>0)&&h.push(...GS(i)),{rows:f,columns:h,top:l,rowSlots:a,columnSlots:o,labelColumns:s,labelRow:p-o.length,headerRows:p,headerColumns:g,dataCount:e.dataFields?.length??0,compact:KS(e),hiddenFieldHeaders:!0===e.hiddenFieldHeaders,pages:d}},ZS=(e,t)=>{let n=e.pages.reduce((e,t)=>Math.max(e,t.column+2),0);return{rowStart:t.rowIndex,colStart:t.colIndex,rowEnd:t.rowIndex+e.rows.length-1,colEnd:t.colIndex+Math.max(e.columns.length,n)-1}},QS=(e,t)=>{let n=[],{rowIndex:r,colIndex:i}=t,a=e.pages.reduce((e,t)=>Math.max(e,t.column+2),0),o=e.top>0?e.top-1:0;o>0&&a>0&&n.push({rowStart:r,colStart:i,rowEnd:r+o-1,colEnd:i+a-1});let s=e.rows.length-e.top,c=e.columns.length;if(s>0&&c>0){let t=r+e.top;n.push({rowStart:t,colStart:i,rowEnd:t+s-1,colEnd:i+c-1})}return n},$S=e=>!!e&&e.kind!==`page`&&e.kind!==`gap`&&e.kind!==`header`,eC=(e,t,n)=>{let r=t&&t>0?t:1;return e%(r+(n&&n>0?n:1))<r},tC=(e,t,n)=>{let r=e.rows[t];if(!r||r.kind===`gap`||e.empty)return null;if(r.kind===`page`){let t=e.pages.findIndex(e=>e.row===r.index&&(e.column===n||e.column+1===n));return t<0?null:{kind:e.pages[t].column===n?`pageCaption`:`pageItem`,page:t}}let i=e.columns[n];if(!i)return null;let{labelRow:a,labelColumns:o,rowSlots:s,columnSlots:c,headerRows:l,headerColumns:u}=e,d=e.dataCount===1&&!s.some(e=>e.field===MS)&&!c.some(e=>e.field===MS),f=c.length===1&&c[0].field===MS;if(r.kind===`header`){let t=r.index;if($S(i)){let r=t-a;if(r>=0){let e=i.path.length;return i.kind===`item`?r<e&&(r>=i.repeat||c[r].repeatLabels)?{kind:`label`,axis:`column`,level:r,line:i}:null:i.kind===`blank`?null:r===(i.kind===`grand`?0:e-1)?{kind:`total`,axis:`column`,line:i}:r<e&&c[r].repeatLabels?{kind:`label`,axis:`column`,level:r,line:i}:null}let o=n-u;return t!==0||o<0?null:c.length>0&&!f?e.hiddenFieldHeaders?null:e.compact?o===0?{kind:`columnHeader`}:null:o<c.length?{kind:`fieldCaption`,axis:`column`,level:o}:null:o===0&&c.length===0&&d?{kind:`dataCaption`,data:0}:null}if(t===l-1&&s.length>0){let t=o.indexOf(n);return t<0||e.hiddenFieldHeaders?null:e.compact&&n===0?{kind:`rowHeader`}:{kind:`fieldCaption`,axis:`row`,level:t}}return t===0&&n===0&&c.length>0&&!f&&d&&s.length>0?{kind:`dataCaption`,data:0}:null}let p=r;if($S(i))return{kind:`value`,row:p,column:i};let m=p.path.length;if(p.kind===`item`){if(s.length===0)return n===0&&d?{kind:`dataCaption`,data:0}:null;for(let e=m-1;e>=0;e--)if(o[e]===n&&(e>=p.repeat||s[e].repeatLabels))return{kind:`label`,axis:`row`,level:e,line:p};return null}if(p.kind===`blank`||s.length===0)return null;if(o[p.kind===`grand`?0:m-1]===n)return{kind:`total`,axis:`row`,line:p};for(let e=m-2;e>=0;e--)if(o[e]===n&&s[e].repeatLabels)return{kind:`label`,axis:`row`,level:e,line:p};return null},nC=(e,t,n)=>{let r=tC(e,t,n);if(!r)return null;switch(r.kind){case`pageCaption`:case`pageItem`:return e.pages[r.page]?.field??null;case`fieldCaption`:case`label`:return(i=(r.axis===`row`?e.rowSlots:e.columnSlots)[r.level])&&i.field!==MS?i.field:null;case`rowHeader`:case`columnHeader`:{let t=(r.kind===`rowHeader`?e.rowSlots:e.columnSlots).filter(e=>e.field!==MS);return t.length===1?t[0].field:null}default:return null}var i},rC=(e,t,n,r,i)=>{let a=e=>e===void 0||e===MS?void 0:t.fields?.[e]?.numberFormat??i?.[e]?.numberFormat,o=(e,n)=>{let r=a(e);if(r!==void 0||e===void 0||e===MS||n===void 0)return r;let o=t.fields?.[e]?.items?.[n]?.item;return iS(i?.[e],o)?aS(i?.[e],o):void 0},s=t=>t===`row`?e.rowSlots:e.columnSlots,c=tC(e,n,r);if(!c){let t=e.rows[n];if(!$S(t)||t.kind!==`blank`||e.columns[r]?.kind!==`header`)return;let i=t.path.length;return i>0&&e.labelColumns[i-1]===r?a(e.rowSlots[i-1].field):void 0}switch(c.kind){case`pageItem`:{let n=e.pages[c.page];return n.selected?o(n.field,t.pageFields?.[c.page]?.item):void 0}case`label`:return o(s(c.axis)[c.level].field,c.line.path[c.level]);case`total`:{let e=c.line.kind===`grand`?0:c.line.path.length-1;return a(s(c.axis)[e]?.field)}case`value`:return t.dataFields?.[c.row.data??c.column.data??0]?.numberFormat;default:return}},iC=(e,t)=>{if(typeof e==`string`)return e;let n=e??0;return ge(n,t.getLocale()??void 0)??Ye(n)},aC=new Map(zS.map((e,t)=>[e,t])),oC={hair:0,dotted:1,dashDotDot:1,dashDot:1,dashed:1,thin:2,mediumDashDotDot:3,slantDashDot:3,mediumDashDot:3,mediumDashed:3,medium:4,double:4,thick:5},sC=[{side:`top`,opposite:`bottom`,inside:`horizontal`,row:-1,column:0},{side:`bottom`,opposite:`top`,inside:`horizontal`,row:1,column:0},{side:`left`,opposite:`right`,inside:`vertical`,row:0,column:-1},{side:`right`,opposite:`left`,inside:`vertical`,row:0,column:1}],cC=class{constructor(e,t,n){this._permCache=new Map,this._luminances=new Map,this._styles=e,this._properties=t,this._coords=n}getCoords(){return this._coords}_elementsAt(e,t){let n=this._properties;return this._coveringAt(e,t).filter(e=>n[e]!==void 0)}_ownLine(e,t,n,r){let i=this._properties,a=null;for(let o of e){let e=t.has(o)?r:n;i[o]?.borders?.[e]&&(a={element:o,line:e})}return a?i[a.element].borders[a.line].style===L.StrokeStyle.None?null:a:null}_shownLine(e,t){if(!e||!t)return e??t;let n=aC.get(e.element),r=aC.get(t.element);if(n!==r)return n>r?e:t;let i=this._properties,a=i[e.element].borders[e.line],o=i[t.element].borders[t.line],s=oC[a.style??`thin`]??2,c=oC[o.style??`thin`]??2;return s===c?this._luminance(o.color)<this._luminance(a.color)?t:e:s>c?e:t}_luminance(e){if(typeof e!=`string`)return 0;let t=this._luminances.get(e);if(t===void 0){let n=this._styles.parseColor(e).toRGBA();t=.2126*n.red+.7152*n.green+.0722*n.blue,this._luminances.set(e,t)}return t}getPropertiesAt(e,t,n){let r=e-this._coords.rowStart,i=t-this._coords.colStart,o=this._properties,s=this._elementsAt(r,i),c=new Set(s),l=[];for(let{side:e,opposite:t,inside:n,row:a,column:o}of sC){let u=this._elementsAt(r+a,i+o),d=new Set(u.filter(e=>c.has(e)&&this._bandOf(r,i,e)===this._bandOf(r+a,i+o,e))),f=this._ownLine(s,d,e,n),p=this._ownLine(u,d,t,n),m=this._shownLine(f,p);m&&l.push({side:e,...m,mine:m===f})}if(s.length===0&&l.length===0)return null;let u=s.join(`|`);for(let{side:e,element:t,line:n,mine:r}of l)u+=`|${e}=${r?``:`~`}${t}.${n}`;let d=this._permCache.get(u);if(d!==void 0)return d;let f=this._styles,p=null;for(let e of s){let{size:t,borders:n,...r}=o[e];p=p?a.resolveTypedUpdates(r,yt,f,p):r}let m=p;if(l.length>0){let e={};for(let{side:t,element:n,line:r}of l)e[t]=o[n].borders[r];m={...p??{},borders:e}}let h=m?Object.freeze(m):null;return this._permCache.set(u,h),h}},lC=class extends cC{constructor(e,t,n,r,i){super(e,t,ZS(n,r)),this._structure=n,this._options=i,this._stripes={firstRowStripe:t.firstRowStripe?.size,secondRowStripe:t.secondRowStripe?.size,firstColumnStripe:t.firstColumnStripe?.size,secondColumnStripe:t.secondColumnStripe?.size}}_coveringAt(e,t){return((e,t,n,r,i)=>{let a=e.rows[t];if(!a||a.kind===`gap`||e.empty)return[];if(a.kind===`page`){let t=((e,t,n)=>{for(let r of e.pages)if(r.row===t){if(r.column===n)return{...r,caption:!0};if(r.column+1===n)return{...r,caption:!1}}return null})(e,a.index,n);return t?[`wholeTable`,t.caption?`pageFieldLabels`:`pageFieldValues`]:[]}let o=e.columns[n];if(!o)return[];let s=[`wholeTable`],c=(e,t=!0)=>{e&&t&&s.push(e)},l=!0===r.showRowHeaders,u=!0===r.showColumnHeaders,d=!0===r.showRowStripes,f=!0===r.showColumnStripes,p=!0===r.showLastColumn,m=o.kind===`header`,{labelRow:h,labelColumns:g,rowSlots:_,columnSlots:v}=e,y=$S(o)?o:null,b=!!y&&(y.kind===`grand`||v.length===0);if(a.kind===`header`){let t=a.index;if(c(`headerRow`,u),m)c(`firstColumn`,l),c(`firstHeaderCell`,l&&u&&t<e.headerRows-1);else if(y){b&&t>=(v.length>0?h:0)&&c(`lastColumn`,p),y.kind===`subtotal`&&t>=h+y.path.length-1&&c(VS[y.path.length-1]);let e=t-h;e>=0&&(y.kind===`item`||y.kind===`subtotal`)&&y.path.length>e&&c(US[e],u)}}else{let e=a,t=e.path.length;if(c(eC(e.index,i?.firstRowStripe,i?.secondRowStripe)?`firstRowStripe`:`secondRowStripe`,d),m?c(`firstColumn`,l):y&&(c(eC(y.index,i?.firstColumnStripe,i?.secondColumnStripe)?`firstColumnStripe`:`secondColumnStripe`,f),b&&c(`lastColumn`,p),y.kind===`subtotal`&&c(VS[y.path.length-1])),e.kind===`subtotal`&&n>=g[t-1]&&c(HS[t-1]),e.kind===`blank`&&c(`blankRow`),e.kind===`grand`&&c(`totalRow`),e.kind===`item`||e.kind===`subtotal`)for(let r=0;r<_.length-1&&r<t;r++){let i=_[r],a=e.kind===`item`&&t===r+1;(i.tabular?(t>r+1||a)&&n===g[r]:a&&n>=g[r])&&c(WS[r],l)}}return s.sort((e,t)=>BS.get(e)-BS.get(t))})(this._structure,e,t,this._options,this._stripes)}_bandOf(e,t,n){return((e,t,n,r)=>{let i=e.rows[t],a=e.columns[n],o=$S(i)?i:null,s=$S(a)?a:null,c=WS.indexOf(r);return c>=0?o?.path.slice(0,c+1).join()??``:(c=US.indexOf(r),c>=0?s?`${s.path.slice(0,c+1).join()}${s.kind===`subtotal`?`T`:``}`:``:HS.includes(r)?`${o?.index??``}`:VS.includes(r)?`${s?.index??``}`:r===`blankRow`?`${o?.index??``}${a?.kind===`header`?`L`:`D`}`:``)})(this._structure,e,t,n)}};(function(e){let t=e.fromJSON=(e,n)=>{if(!e?.id)return null;let r={id:e.id,type:e.type};if(e.xml!==void 0&&(r.xml=e.xml),e.contentType!==void 0&&(r.contentType=e.contentType),e.name!==void 0&&(r.name=e.name),e.resId!==void 0){let t=n?.(e.resId);t&&(r.resource=t)}let i=e.parts;if(i){let e=[];for(let r=0;r<i.length;r++){let a=t(i[r],n);a&&e.push(a)}e.length>0&&(r.parts=e)}return r},n=e.toJSON=(e,t)=>{if(!e)return null;let r={id:e.id,type:e.type};if(e.xml!==void 0&&(r.xml=e.xml),e.contentType!==void 0&&(r.contentType=e.contentType),e.name!==void 0&&(r.name=e.name),e.resource){let n=t?.(e.resource);n!=null&&(r.resId=n)}let i=e.parts;return i&&i.length>0&&(r.parts=i.map(e=>n(e,t))),r}})(Kx||={});var uC=(e,t)=>e?.fields?.findIndex(e=>fS(e.name,t))??-1,dC=(e,t,n,r,i,a)=>{let o=t.fields?.[n];if(!o)return[];let s=tS(t)[n]??[],c=new Map,l=new Set;for(let t of e.fields?.[n]?.items??[])mS(t)&&(t.name!==void 0&&c.set(t.item,t.name),t.hidden&&l.add(t.item));let u=fC(e,t,n,s.length),d=new Set(o.unused),f=[];for(let e=0;e<s.length;e++){let t=oS(s[e]),n=t===null,r=c.get(e)??(n?``:cS(t));f.push({id:e,key:r,name:n&&!c.has(e)?N(`slicer.blankItem`):r,value:t,hasData:u(e),isSelected:!l.has(e),missing:d.has(e)})}if(!Yx(o)){let e=r===`descending`?-1:1;f.sort((t,n)=>t.value===null==(n.value===null)?e*($l.compare(t.value,n.value,a)||$l.compare(t.key,n.key,a)):e*(t.value===null?1:-1))}return i===`showItemsWithDataAtTop`?[...f.filter(e=>e.hasData),...f.filter(e=>!e.hasData)]:f},fC=(e,t,n,r)=>{let i=t.fields??[],a=new Set(i[n]?.unused),o=t.records&&!Yx(i[n])?Jx(t.records,i.length):null,s=o?.[n];if(!s||s.length===0)return e=>!a.has(e);let c=[];for(let t=0;t<i.length;t++){if(t===n||Yx(i[t])||!o[t]?.length)continue;let r=new Set;for(let n of e.fields?.[t]?.items??[])mS(n)&&n.hidden&&r.add(n.item);r.size>0&&c.push({column:o[t],hidden:r})}let l=Array(r).fill(!1);for(let e=0;e<s.length;e++){let t=s[e];t===void 0||l[t]||c.every(t=>!t.hidden.has(t.column[e]))&&(l[t]=!0)}return e=>l[e]&&!a.has(e)},pC=Z.BuiltInSelectorNames.Date,mC=Z.BuiltInOperatorNames,hC=(e,t)=>{let n=e.filters?.find(e=>e.field===t&&e.dataField===void 0)?.condition;if(n?.operator!==mC.And||!Array.isArray(n.param)||n.param.length!==2)return null;let[r,i]=n.param;return r.selector!==pC||r.operator!==mC.AfterEqualTo||typeof r.param!=`number`||i.selector!==pC||i.operator!==mC.BeforeEqualTo||typeof i.param!=`number`?null:{start:r.param,end:i.param}},gC=(e,t)=>{let n=tS(e)[t]??[],r=1/0,i=-1/0;for(let e=0;e<n.length;e++){let t=oS(n[e]);typeof t==`number`&&(t<r&&(r=t),t>i&&(i=t))}return r<=i?{start:r,end:i}:null},_C=(e,t)=>{let n=[],r=e._getSheetRefs(Qu.Visibility.VeryHidden);for(let e=0;e<r.length;e++){let i=r[e].sheet?.getMovables?.()?.getItems()??[];for(let e=0;e<i.length;e++){let r=i[e].getContent();r?.isISlicer&&!r.isDeleted()&&r.getPivotTables().includes(t)&&n.push(r)}}return n},vC=t(`sdk:pivot`,async()=>{let[t]=await Promise.all([e(()=>import(`./EOw6vVvEfYNga9b4.js`),__vite__mapDeps([27,1,2,11,3,12,7,28]),import.meta.url),Ol.load()]);return t}),yC={sum:`sum`,count:`countA`,average:`avg`,max:`max`,min:`min`,product:`product`,countNums:`count`,stdDev:`stdDev`,stdDevp:`stdDevP`,var:`var`,varp:`varP`},bC=(e,t)=>{if((e=>{let t=Z.BuiltInOperatorNames;return e===t.And||e===t.Or||e===t.Not})(e.operator)){let{selector:n,...r}=e,i=typeof n==`string`?n:n?.getName?.()??t,a=e.param;return{...r,param:Array.isArray(a)?a.map(e=>bC(e,i)):bC(a,i)}}let n=e.selector||Q_(e)?e:{...e,selector:t};return(typeof n.selector==`string`?n.selector:n.selector?.getName?.())===Z.BuiltInSelectorNames.Display&&typeof n.param==`number`?{...n,param:String(n.param)}:n},xC=(e,t)=>{let n=Nv.resolveInput(e).toJSON(),r=Z.BuiltInSelectorNames;return t===`value`||n.operator===Z.BuiltInOperatorNames.TimePeriod?n:bC(n,t===`label`?r.Display:r.Date)},SC=class{constructor(e,t){this._table=e,this._index=t}getName(){let e=this._table._getModel(),t=this._table._getCache();return e&&t?pS(e,t,this._index):``}getDataType(){let e=this._table._getCache();return e?sS(e.fields?.[this._index],tS(e)[this._index]??[]):`blank`}getAxis(){return this._table._getModel()?.fields?.[this._index]?.axis??null}async setAxis(e,t,n){await this._table._moveField(this._index,e,t,n)}getPosition(){let e=this.getAxis(),t=this._table._getModel(),n=e&&t?Zx(t,e).indexOf(this._index):-1;return n<0?null:n+1}async setPosition(e,t){if(this.getPosition()===null)throw new k(N(`error.pivotTable.fieldPosition`));await this._table._moveField(this._index,this.getAxis(),e,t)}_editField(e,t,n){return this._table._editFieldSetting(this._index,e,t,n)}_json(){return this._table._getModel()?.fields?.[this._index]??{}}getSubtotals(){let e=this._json().subtotals;return!e||e.includes(`default`)?[`automatic`]:Object.keys(yC).filter(t=>e.includes(yC[t]))}async setSubtotals(e,t){for(let t of e)if(t!==`automatic`&&!yC[t])throw new k(N(`error.pivotTable.notASubtotal`,{name:t}));let n=this._table._getCache()?.fields?.[this._index];if(Qx(n))throw new k(N(`error.pivotTable.subtotalsOnCalculatedField`));let r=e.includes(`automatic`);if(!r&&e.length>0&&(n?.calculatedItems?.length??0)>0)throw new k(N(`error.pivotTable.subtotalsOnCalculatedItems`));let i=Object.keys(yC).filter(t=>e.includes(t)).map(e=>yC[e]),a=r?void 0:i,o=this._json().subtotals;JSON.stringify(o?.includes(`default`)?void 0:o)!==JSON.stringify(a)&&await this._table._editField(this._index,e=>{let{subtotals:t,...n}=e;return{...n,...a?{subtotals:a}:{},...e.items?{items:Xx(e.items,a)}:{}}},t)}getForm(){return this._json().form??`compact`}async setForm(e,t){if(e!==`compact`&&e!==`outline`&&e!==`tabular`)throw new k(N(`error.pivotTable.notAForm`,{form:e}));await this._editField(`form`,e===`compact`?void 0:e,t)}getRepeatLabels(){return!0===this._json().repeatLabels}async setRepeatLabels(e,t){await this._editField(`repeatLabels`,!!e||void 0,t)}getBlankRowAfter(){return!0===this._json().blankRowAfter}async setBlankRowAfter(e,t){await this._editField(`blankRowAfter`,!!e||void 0,t)}getSubtotalsOnTop(){return!1!==this._json().subtotalsOnTop}async setSubtotalsOnTop(e,t){await this._editField(`subtotalsOnTop`,!!e&&void 0,t)}_holdsOnlyNumbers(){let e=this._table._getCache();return!!e&&(tS(e)[this._index]??[]).every(e=>{let t=oS(e);return t===null||typeof t==`number`})}getNumberFormat(){return this._holdsOnlyNumbers()?OS(this._json().numberFormat??this._table._getCache()?.fields?.[this._index]?.numberFormat):``}async setNumberFormat(e,t){if((await vC.load()).assertNumberFormat(e),!this._holdsOnlyNumbers())throw new k(N(`error.pivotTable.numberFormatOnText`));await this._editField(`numberFormat`,e,t)}getPivotTable(){return this._table}_getCaptions(){let e=this._table._getModel(),t=this._table._getCache();return e&&t?gS(e,t,this._index):[]}_itemAt(e){let t=this._json().items?.[e];return t&&mS(t)?new CC(this,t.item):null}getItems(){return this._getCaptions().flatMap((e,t)=>e===null?[]:[this._itemAt(t)])}getItem(e){let t=this._getCaptions().findIndex(t=>t!==null&&fS(t,e));return t<0?null:this._itemAt(t)}_ranksOf(e){let t=this._getCaptions(),n=new Set;for(let r of e){let e=t.findIndex(e=>e!==null&&fS(e,r));if(e<0)throw new k(N(`error.pivotTable.notAnItem`,{name:r}));n.add(e)}return n}async setExpanded(e,t){await this._table._editModel(t=>bS(t,this._index,e),m(e?`op.expandPivotItems`:`op.collapsePivotItems`),t)}async setVisibleItems(e,t){await this._table._editModel(t=>xS(t,this._index,e?this._ranksOf(e):null),m(`op.filterPivotTable`),t)}getCurrentPage(){let e=this._table._getModel()?.pageFields?.find(e=>e.field===this._index);return e?.item===void 0?null:this._itemAt(e.item)}async setCurrentPage(e,t){await this._table._editModel(t=>{if(!t.pageFields?.some(e=>e.field===this._index))throw new k(N(`error.pivotTable.notPageField`));let n=e===null?null:[...this._ranksOf([e])][0];return((e,t,n)=>{let r=e.pageFields??[],i=r.findIndex(e=>e.field===t);if(i<0)throw new k(N(`error.pivotTable.notPageField`));let a=vS(e,t,e=>yS(e,`hidden`,!1),e=>{if(!e.multipleItemSelection)return e;let{multipleItemSelection:t,...n}=e;return n}),o=r[i];if((o.item??null)===n)return a;let{item:s,...c}=o,l=n===null?c:{...o,item:n};return{...a,pageFields:r.map((e,t)=>t===i?l:e)}})(t,this._index,n)},m(`op.filterPivotTable`),t)}_field(e){return e.fields?.[this._index]??{}}_isOnRowsOrColumns(e){let t=this._field(e).axis;return t===Gx.Axis.Row||t===Gx.Axis.Column}_dataFieldName(e,t){let n=e.dataFields?.[t];return n?.name??(n?this._table._getCache()?.fields?.[n.field]?.name??``:``)}_dataFieldOf(e,t){let n=(e.dataFields??[]).findIndex((n,r)=>fS(this._dataFieldName(e,r),t));if(n<0)throw new k(N(`error.pivotTable.notADataField`,{name:t}));return n}_shownByHand(e){let t=this._getCaptions(),n=e.pageFields?.find(e=>e.field===this._index);if(n?.item!==void 0)return[t[n.item]??``];let r=this._field(e).items??[];return r.some(e=>mS(e)&&e.hidden)?r.flatMap((e,n)=>mS(e)&&!e.hidden&&t[n]!==null?[t[n]]:[]):null}getFilters(){let e=this._table._getModel(),t={};if(!e)return t;for(let n of e.filters??[]){if(n.field!==this._index)continue;let r=uS(n);r===`value`?t.value={condition:n.condition,dataField:this._dataFieldName(e,n.dataField)}:t[r]=n.condition}let n=this._shownByHand(e);return n&&(t.manual=n),t}isFiltered(e){let t=this.getFilters();return e?t[e]!==void 0:Object.keys(t).length>0}async applyFilter(e,t){await this._table._editModel(t=>{let n=t,r=e.label??e.date;if(r!==void 0||e.value!==void 0){if(!this._isOnRowsOrColumns(t))throw new k(N(`error.pivotTable.filterNotOnAxis`));if(e.label!==void 0&&e.date!==void 0)throw new k(N(`error.pivotTable.labelAndDateFilter`));let i=[];if(r!==void 0){let t=xC(r,e.label===void 0?`date`:`label`);if(t.operator===Z.BuiltInOperatorNames.TopN)throw new k(N(`error.pivotTable.topNNeedsDataField`));i.push({field:this._index,condition:t})}e.value&&i.push({field:this._index,dataField:this._dataFieldOf(t,e.value.dataField),condition:xC(e.value.condition,`value`)}),n=dS(n,this._index,t=>t===`value`?e.value!==void 0:r!==void 0,i)}return e.manual!==void 0&&(n=xS(n,this._index,e.manual?this._ranksOf(e.manual):null)),n},m(`op.filterPivotTable`),t)}async clearFilter(e,t){await this._table._editModel(t=>e===`manual`?xS(t,this._index,null):dS(t,this._index,t=>t===e),m(`op.clearPivotFilters`),t)}async clearAllFilters(e){await this._table._editModel(e=>xS(dS(e,this._index,()=>!0),this._index,null),m(`op.clearPivotFilters`),e)}getSort(){let e=this._table._getModel(),t=this._table._getCache(),n=e?this._field(e).sort:void 0;if(!e||!n)return null;let r={order:n.order};return n.dataField!==void 0&&(r.dataField=this._dataFieldName(e,n.dataField)),n.scope&&t&&(r.scope=n.scope.items.map(n=>gS(e,t,n.field)[n.item]??``)),r}async sortByLabels(e,t){let n=await vC.load();await this._table._editModel(t=>{let r=this._table._getCache();if(!this._isOnRowsOrColumns(t))throw new k(N(`error.pivotTable.notSortable`));if(!r)throw new k(N(`error.pivotTable.notModeled`));return n.sortPivotItemsByLabel(t,r,this._index,e)},m(`op.sortPivotField`),t)}async sortByValues(e,t,n,r){await this._table._editModel(r=>{let i=this._table._getCache();if(!this._isOnRowsOrColumns(r))throw new k(N(`error.pivotTable.notSortable`));if(!i)throw new k(N(`error.pivotTable.notModeled`));let a={order:e,dataField:this._dataFieldOf(r,t)};if(n&&n.length>0){let e=((this._field(r).axis===Gx.Axis.Row?r.columnFields:r.rowFields)??[]).filter(e=>e!==-2);if(n.length>e.length)throw new k(N(`error.pivotTable.sortScope`));let t=n.map((t,n)=>{let a=e[n],o=gS(r,i,a).findIndex(e=>e!==null&&fS(e,t));if(o<0||r.fields?.[a]?.items?.[o]?.hidden)throw new k(N(`error.pivotTable.sortScope`));return{field:a,item:o}});a.scope=n.length<e.length?{items:t,subtotal:!0}:{items:t}}return{...r,fields:(r.fields??[]).map((e,t)=>t===this._index?{...e,sort:a}:e)}},m(`op.sortPivotField`),r)}getShowAllItems(){let e=this._table._getModel();return!!e&&!0===this._field(e).showItemsWithNoData}async setShowAllItems(e,t){await this._table._editModel(t=>{let n=this._field(t);if(!!n.showItemsWithNoData===e)return t;let{showItemsWithNoData:r,...i}=n,a=e?{...i,showItemsWithNoData:!0}:i;return{...t,fields:(t.fields??[]).map((e,t)=>t===this._index?a:e)}},m(`op.showPivotItemsWithNoData`),t)}async setName(e,t){let n=await vC.load();await this._table._editModel(t=>{let r=this._table._getCache();if(!r)throw new k(N(`error.pivotTable.notModeled`));let i={...t,cacheId:this._table.getCacheId(),location:``},{cacheId:a,location:o,...s}=n.typeOverPivot(i,r,{kind:`fieldCaption`,field:this._index},e);return s},m(`op.renamePivotField`),t)}get isIPivotField(){return!0}},CC=class{constructor(e,t){this._field=e,this._index=t}_rank(e=this._field._table._getModel()){return(e?.fields?.[this._field._index]?.items??[]).findIndex(e=>mS(e)&&e.item===this._index)}_item(){let e=this._field._table._getModel(),t=this._rank(e);return t<0?void 0:e.fields[this._field._index].items[t]}getName(){let e=this._rank();return e<0?``:this._field._getCaptions()[e]??``}getField(){return this._field}isVisible(){return!this._item()?.hidden}async setVisible(e,t){let n=this._field;await n._table._editModel(t=>{let r=t.fields?.[n._index]?.items??[],i=n._getCaptions(),a=this._rank(t),o=new Set;r.forEach((t,n)=>{i[n]!==null&&(n===a?e:!t.hidden)&&o.add(n)});let s=i.every((e,t)=>e===null||o.has(t));return xS(t,n._index,s?null:o)},m(`op.filterPivotTable`),t)}isExpanded(){return!this._item()?.collapsed}async setExpanded(e,t){await this._field._table._editModel(t=>bS(t,this._field._index,e,this._rank(t)),m(e?`op.expandPivotItems`:`op.collapsePivotItems`),t)}getPosition(){let e=this._field._table._getModel(),t=this._rank(e);if(t<0||!e?.fields?.[this._field._index]?.axis)return null;let n=e.fields[this._field._index].items;if(n[t].hidden)return null;let r=0;for(let e=0;e<=t;e++)mS(n[e])&&!n[e].hidden&&r++;return r}async setPosition(e,t){let n=await vC.load(),r=this._field;await r._table._editModel(t=>{let i=this._rank(t),a=t.fields?.[r._index]?.items??[];if(i<0||!t.fields?.[r._index]?.axis||a[i].hidden)throw new k(N(`error.pivotTable.itemNotPlaced`));let o=a.filter((e,t)=>t!==i),s=o.flatMap((e,t)=>mS(e)&&!e.hidden?[t]:[]);if(!Number.isInteger(e)||e<1||e>s.length+1)throw new k(N(`error.pivotTable.itemPosition`));let c=e-1<s.length?s[e-1]:(e=>{let t=e.findIndex(e=>!mS(e));return t<0?e.length:t})(o);return n.movePivotItem(t,r._index,i,c)},m(`op.movePivotItem`),t)}async setName(e,t){let n=await vC.load(),r=this._field;await r._table._editModel(t=>{let i=r._table._getCache(),a=this._rank(t);if(!i||a<0)throw new k(N(`error.pivotTable.notModeled`));return n.renamePivotItem(t,i,r._index,a,e)},m(`op.renamePivotItem`),t)}get isIPivotItem(){return!0}},wC=class{constructor(e,t){this._table=e,this._name=t}_indexIn(e){let t=(e?.dataFields??[]).findIndex(e=>fS(e.name,this._name));if(t<0)throw new k(N(`error.pivotTable.notADataField`,{name:this._name}));return t}_json(){let e=this._table._getModel();return e.dataFields[this._indexIn(e)]}async _edit(e,t,n,r){let i=-1;await this._table._editModel(t=>{let n=this._table._getCache();if(!n)throw new k(N(`error.pivotTable.notModeled`));return i=this._indexIn(t),e(t,i,n)},t,n),r&&(this._name=this._table._getModel().dataFields[i].name)}getName(){return this._json().name}async setName(e,t){let n=await vC.load();await this._edit((t,r,i)=>{if(t.dataFields[r].name===e)return t;let a={...t,cacheId:this._table.getCacheId(),location:``},{cacheId:o,location:s,...c}=n.typeOverPivot(a,i,{kind:`dataCaption`,data:r},e);return c},m(`op.renamePivotDataField`),t,!0)}getField(){return new SC(this._table,this._json().field)}getFunction(){return this._json().subtotal??`sum`}async setFunction(e,t){let n=await vC.load();await this._edit((t,r,i)=>n.setPivotDataFunction(t,i,r,e),m(`op.summarizePivotDataField`),t,!0)}getCaptionFor(e){let t=this._table._getModel(),n=this._table._getCache();if(!t||!n)throw new k(N(`error.pivotTable.notModeled`));return jS(t,n,this._indexIn(t),e)}getShowAs(){let e=this._table._getModel(),t=this._indexIn(e);return((e,t,n)=>{let r=e.dataFields[n],i=r.showDataAs;if(!i||i===`normal`)return null;let a={kind:i};if(wS.has(i)&&(a.baseField=pS(e,t,r.baseField??0)),TS.has(i)){let n=r.baseItem??0;if(n===`previous`)a.baseItem=ES;else if(n===`next`)a.baseItem=DS;else{let i=e.fields?.[r.baseField??0]?.items?.[n],o=i&&mS(i)?gS(e,t,r.baseField??0)[n]:null;o!==null&&(a.baseItem=o)}}return a})(e,this._table._getCache(),t)}async setShowAs(e,t){let n=await vC.load();await this._edit((t,r,i)=>n.setPivotDataShowAs(t,i,r,e),m(`op.showPivotValueAs`),t)}getNumberFormat(){return OS(this._json().numberFormat)}async setNumberFormat(e,t){let n=await vC.load();await this._edit((t,r)=>n.setPivotDataNumberFormat(t,r,e),m(`op.formatPivotDataField`),t)}getPosition(){return this._indexIn(this._table._getModel())+1}async setPosition(e,t){let n=await vC.load();await this._edit((t,r)=>n.movePivotDataField(t,r,e),m(`op.movePivotDataField`),t)}async delete(e){let t=await vC.load();await this._edit((e,n)=>t.removePivotDataField(e,n),m(`op.removePivotDataField`),e)}getPivotTable(){return this._table}get isIPivotDataField(){return!0}},TC=class{constructor(e){this._table=e}getName(){return this._table._getModel()?.valuesCaption??`Values`}async setName(e,t){let n=await vC.load();await this._table._editModel(t=>{let r=this._table._getCache();if(!r)throw new k(N(`error.pivotTable.notModeled`));return n.renamePivotValues(t,r,e)},m(`op.renamePivotValues`),t)}getAxis(){let e=this._table._getModel();return e?.rowFields?.includes(-2)?Gx.Axis.Row:e?.columnFields?.includes(-2)?Gx.Axis.Column:null}async setAxis(e,t,n){let r=await vC.load();await this._table._editModel(n=>r.movePivotValues(n,e,t),m(e===null?`op.removePivotDataField`:`op.movePivotValues`),n)}getPosition(){let e=this.getAxis(),t=this._table._getModel();return e&&t?Zx(t,e).indexOf(-2)+1:null}async setPosition(e,t){let n=this.getAxis();if(!n)throw new k(N(`error.pivotTable.fieldPosition`));await this.setAxis(n,e,t)}getPivotTable(){return this._table}get isIPivotValuesField(){return!0}},EC=-2,DC=(e,t,n=t.length)=>{let r=new Map;for(let i=0;i<n;i++){let n=e[i]?.field;n!==void 0&&n!==EC&&r.set(n,t[i])}return r},OC=(e,t,n,r)=>{let i=tC(e,n,r),a=e.rows[n];if(!i)return a?.kind===`header`?r<e.headerColumns?a.index<e.headerRows-+(e.rowSlots.length>0)?{kind:`origin`}:null:a.index<e.labelRow&&e.columns[r]?{kind:`topRight`}:null:null;let{rowSlots:o,columnSlots:s}=e;switch(i.kind){case`pageCaption`:return{kind:`button`,axis:`page`,field:e.pages[i.page].field};case`pageItem`:{let n=t.pageFields?.[i.page],r=e.pages[i.page].field;return{kind:`label`,field:r,items:new Map([[r,n?.item]]),subtotal:!1,grandRow:!1,grandCol:!1}}case`dataCaption`:return{kind:`origin`};case`rowHeader`:return o[0]?{kind:`button`,axis:`row`,field:o[0].field}:null;case`columnHeader`:return s[0]?{kind:`button`,axis:`column`,field:s[0].field}:null;case`fieldCaption`:{let e=(i.axis===`row`?o:s)[i.level];return e?{kind:`button`,axis:i.axis,field:e.field}:null}case`label`:{let e=i.axis===`row`?o:s,t=DC(e,i.line.path,i.level+1),n=e[i.level].field;return n===EC&&t.set(EC,i.line.path[i.level]),{kind:`label`,field:n,items:t,subtotal:!1,grandRow:!1,grandCol:!1}}case`total`:{let e=i.line.kind===`grand`,t=i.axis===`row`?o:s,n=i.line.path.length;return{kind:`label`,field:e?void 0:t[n-1]?.field,items:DC(t,i.line.path),subtotal:!e,grandRow:e&&i.axis===`row`,grandCol:e&&i.axis===`column`}}case`value`:return i.row.kind===`blank`||i.column.kind===`blank`?null:{kind:`value`,row:i.row,column:i.column,data:i.row.data??i.column.data??0}}},kC=(e,t)=>!e.items||e.items.length===0||t!==void 0&&e.items.includes(t),AC=new WeakMap,jC=e=>{let t=new Set;for(let n of e)n.kind===`subtotal`&&t.add(n.path.join(`,`));return t},MC=(e,t,n,r)=>{let i=n.filter(t=>t.field!==EC&&e.some(e=>e.field===t.field));if(i.length===0)return!0;if(t.kind===`grand`||t.kind===`item`&&r.size>0&&r.has(t.path.join(`,`)))return!1;let a=DC(e,t.path);return a.size===i.length&&i.every(e=>a.has(e.field)&&kC(e,a.get(e.field)))},NC=(e,t,n,r,i)=>{let a=n.type??`normal`;if(a===`all`)return!1===n.dataOnly?FC(e,r,i):OC(e,t,r,i)?.kind===`value`;let o=OC(e,t,r,i);if(!o)return!1;if(a===`origin`||a===`topRight`)return o.kind===a;if(a===`button`)return o.kind===`button`&&o.field===n.field&&(n.axis===void 0||o.axis===n.axis);if(a!==`normal`)return!1;let s=n.references??[];if(s.some(e=>e.byPosition||e.relative))return!1;if(o.kind===`label`){if(!0!==n.labelOnly&&!1!==n.dataOnly||!!n.grandRow!==o.grandRow||!!n.grandCol!==o.grandCol)return!1;if(o.grandRow||o.grandCol)return s.length===0;let e=s.filter(e=>!1!==e.selected),t=e[e.length-1]??s[s.length-1];return!(!t||t.field!==o.field)&&o.subtotal===s.some(e=>!!e.subtotals?.length)&&s.every(e=>o.items.has(e.field)&&kC(e,o.items.get(e.field)))}if(o.kind!==`value`||!0===n.labelOnly||n.grandRow&&o.row.kind!==`grand`||n.grandCol&&o.column.kind!==`grand`)return!1;let c=s.find(e=>e.field===EC);if(c&&!kC(c,o.data))return!1;let l=new Set([...e.rowSlots,...e.columnSlots].map(e=>e.field));if(s.some(e=>e.field!==EC&&!l.has(e.field)))return!1;let u=(e=>{let t=AC.get(e);return t||AC.set(e,t={rows:jC(e.rows),columns:jC(e.columns)}),t})(e);return MC(e.rowSlots,o.row,s,u.rows)&&MC(e.columnSlots,o.column,s,u.columns)},PC=(e,t,n)=>{if(t.every(e=>e.kind===`grand`))return{references:[],grand:!0};if(t.some(e=>e.kind===`grand`))return{references:[],grand:!1};let r=t.map(t=>DC(e,t.path)),i=[...r[0].keys()];return i.length===0||r.some(e=>e.size!==i.length||i.some(t=>!e.has(t)))?{references:[],grand:!1}:{references:i.map((e,t)=>({field:e,...new Set(r.map(t=>t.get(e))).size===1?{items:[r[0].get(e)]}:{},...n&&t===i.length-1?{}:{selected:!1}})),grand:!1}},FC=(e,t,n)=>{let r=e.rows[t];return!(!r||r.kind===`gap`)&&(r.kind===`page`?e.pages.some(e=>e.row===r.index&&(e.column===n||e.column+1===n)):n<e.columns.length)},IC=(e,t,n,r)=>{let a=t.formats;if(!a||a.length===0)return null;let o=null;for(let s of a)s.action!==`blank`&&NC(e,t,s.area,n,r)&&(o=o?i.deepMerge(o,s.style):s.style);return o},LC=new WeakMap;function RC(e){return e._getNormal?.()??e}function zC(e){let t=RC(e),n=Lm(),r=LC.get(t);if(r?.version===n)return r.width;let i=3*Math.round(t.measureText(` `).width);return LC.set(t,{version:n,width:i}),i}var BC=-2,VC=(e,t)=>{for(let n=t+1;n<e.length;n++)if(e[n].field!==BC)return!0;return!1},HC=e=>{let t=[],{rowSlots:n,columnSlots:r,labelColumns:i,top:a,headerRows:o,headerColumns:s}=e;for(let n of e.pages)t.push({kind:`dropdown`,row:n.row,column:n.column+1,fields:[n.field]});if(e.hiddenFieldHeaders)return t;let c=a+o-1;for(let e=0;e<s;e++){let r=n.flatMap((t,n)=>i[n]===e&&t.field!==BC?[t.field]:[]);r.length>0&&t.push({kind:`dropdown`,row:c,column:e,fields:r})}let l=r.flatMap(e=>e.field===BC?[]:[e]);return l.length>0&&(l.every(e=>!e.ownColumn)?t.push({kind:`dropdown`,row:a,column:s,fields:l.map(e=>e.field)}):r.forEach((e,n)=>{e.field!==BC&&t.push({kind:`dropdown`,row:a,column:s+n,fields:[e.field]})})),t},UC=(e,t,n)=>{let r=[];if(e.hiddenDrillIndicators)return r;let i=e.fields??[],{rowSlots:a,columnSlots:o,top:s,headerRows:c,headerColumns:l,labelRow:u}=t,d=(e,t,n,a,o)=>{let s=n[a].field;s!==BC&&VC(n,a)&&r.push({kind:`toggle`,row:e,column:t,field:s,item:o,expanded:!i[s]?.items?.[o]?.collapsed})},f=Math.min(n.rowEnd,t.rows.length-1),p=Math.min(n.colEnd,l-1);for(let e=Math.max(n.rowStart,s+c);e<=f;e++)for(let r=Math.max(n.colStart,0);r<=p;r++){let n=tC(t,e,r);n?.kind===`label`&&d(e,r,a,n.level,n.line.path[n.level])}let m=Math.min(n.rowEnd,s+c-1),h=Math.min(n.colEnd,t.columns.length-1);for(let e=Math.max(n.rowStart,s+u);e<=m;e++)for(let r=Math.max(n.colStart,l);r<=h;r++){let n=tC(t,e,r);n?.kind===`label`&&d(e,r,o,n.level,n.line.path[n.level])}return r},WC=(e,t,n,r)=>{let i=tC(t,n,r);if(!i)return null;let{rowSlots:a,columnSlots:o}=t;if(i.kind===`label`&&i.axis===`column`)return{level:0,step:0,indent:0,gutter:!e.hiddenDrillIndicators&&VC(o,i.level)};let s,c=!1;if(i.kind===`label`&&i.axis===`row`){s=i.level;let n=t.labelColumns[s];c=!e.hiddenDrillIndicators&&a.some((e,r)=>t.labelColumns[r]===n&&e.field!==BC&&VC(a,r))}else{if(i.kind!==`total`||i.axis!==`row`)return null;s=i.line.kind===`grand`?0:i.line.path.length-1}let l=((e,t)=>t-e.labelColumns.indexOf(e.labelColumns[t]))(t,s),u=(e=>{let t=e.indent??0;return t===127?0:t+1})(e);return{level:l,step:u,indent:l*u,gutter:c}},GC=(e,t,n,r,i)=>{if(t.rows[n]?.kind===`page`){let e=tC(t,n,r);return e?.kind!==`pageItem`||!t.pages[e.page].selected||i!==void 0&&typeof i!=`number`?null:0}if(!$S(t.rows[n]))return null;let a=t.columns[r];return!a||$S(a)?null:t.compact&&t.labelColumns.includes(r)?WC(e,t,n,r)?.indent??0:null},KC=(e,t)=>{let n=e.fields?XS(e):null;if(!n)return null;let r=n.pages.reduce((e,t)=>Math.max(e,t.column+2),0);return{rows:n.rows.length,columns:Math.max(n.columns.length,r),top:n.top,empty:!0===n.empty,formatAt:(r,i)=>({numberFormat:rC(n,e,r,i,t),labelIndent:GC(e,n,r,i),user:LS(n,r,i)??IC(n,e,r,i)})}},qC=(e,t)=>e._getControlsIn(t),JC=(e,t,n)=>e._getFieldAt(t,n),YC=(e,t)=>{let n=e.getInsets().left,r=RC(e),i=zC(e),a=t.level===0||t.step===0?i:Math.max(t.step*i,i+2*kt(zm(r)))/t.step,o=e.getAlignment().getIndent()*a;if(!t.gutter)return{boxLeft:n+o,boxSize:0,textLeft:n+o};let s=Math.max(7,1|Math.round(.8*r.getFont().getSize())),c=2*n+o;return{boxLeft:c,boxSize:s,textLeft:c+s+n}},XC=e=>{let t=e._pivotLabel?.();if(!t?.gutter)return null;let n=YC(e.getStyle(),t);return{left:n.boxLeft,size:n.boxSize}},ZC=(e,t,n)=>{if(e[t]===n)return e;if(n!==void 0)return{...e,[t]:n};let{[t]:r,...i}=e;return i},QC=class e extends Hv{constructor(e){super(e),this._settling=!1,this._ranged=null,this._placement=null,this._layer=null,this._dates=null,this._filtered=null,this._anchored=null,this._filtering=null}_initialize(t){super._initialize(t),this._sheet=t.sheet;let n=t.json,r=Ux(n),i=r?{rows:r.rowEnd-r.rowStart+1,columns:r.colEnd-r.colStart+1}:{rows:1,columns:1},a=n?e.modelOf(n):null;this._updateState({cacheId:n?.cacheId??0,name:n?.name??null,model:a,part:Kx.fromJSON(n?.part,t.fromResourceId),partFormats:!a&&n?.partFormats?n.partFormats:null,ref:n?.location??null,buttons:n?.buttons&&n.buttons.length>0?[...n.buttons]:null,size:i,blocked:e.isSavedBlocked(a,i)},m(`op.createAnchoredItem`))}getName(){return this._getState().name??``}async setName(e,t){if(this._sheet._assertPivotName(e,this),e!==this.getName()){if(!this._getState().model||this.isDeleted())throw new k(N(`error.pivotTable.notModeled`));await this.doBatch(()=>{this._updateState({name:e,part:null})},{description:m(`op.renamePivotTable`),...t})}}getWorksheet(){return this._sheet}getRange(e){let t=this._getLocation();return t?this._sheet.getRange(t,e):super.getRange(e)}getPageRange(e){return this._rangeOfPart(`page`,e)}getBodyAndTotalRange(e){return this._rangeOfPart(`body`,e)}getRowLabelRange(e){return this._rangeOfPart(`rows`,e)}getColumnLabelRange(e){return this._rangeOfPart(`columns`,e)}_rangeOfPart(e,t){let n=this._getPlacement();if(!n)return null;let{structure:r,origin:i,cells:a}=n,o;if(e===`page`)o=r.top>0?a[0]??null:null;else{let t=i.rowIndex+r.top,n=i.colIndex,a=i.rowIndex+r.rows.length-1,s=n+r.columns.length-1,c=r.empty?1:r.headerRows,l=r.empty?0:r.headerColumns;o=e===`body`?{rowStart:t+c,colStart:Math.min(n+l,s),rowEnd:a,colEnd:s}:e===`rows`?r.rowSlots.length>0?{rowStart:t+Math.max(c-1,0),colStart:n,rowEnd:a,colEnd:n+l-1}:null:r.columnSlots.length>0?{rowStart:t+Math.max(r.labelRow-1,0),colStart:n+l,rowEnd:t+c-1,colEnd:s}:null}return!o||o.rowStart>o.rowEnd||o.colStart>o.colEnd?null:this._sheet.getRange(o,t)}async moveTo(e,t){if(this._sheet.getProtection().isLocked())throw new b(N(`error.sheet.protectedSheet`));let n=await vC.load();if(!this._getState().model||this.isDeleted())throw new k(N(`error.pivotTable.notModeled`));let r=this._sheet,i=Math.max((this._getWanted()?.structure.top??0)-1,0),a=r._pivotAnchorAt(e,i,this),o=this._getLocation();o?.rowStart===a.rowStart&&o.colStart===a.colStart||(await this._prepareFilters(n),await this.doBatch(()=>{let e=this._getOwnCells();this._refreshFrom(n,e,{discardValues:t?.discardValues??!1},a)},{description:m(`op.movePivotTable`),...t}))}getSource(){let e=this._sheet.getWorkbook()?._getPivotCache(this.getCacheId())?._getSource();if(!e)return null;let t=e.name??e.ref;return t?e.sheet?Rd(e.sheet,t):t:null}async setSource(e,t){if(this._assertRefreshAllowed(),!this._getState().model||this.isDeleted())throw new k(N(`error.pivotTable.notModeled`));let n=this._sheet.getWorkbook(),r=n?_C(n,this):[];if(r.some(e=>e.getPivotTables().length>1))throw new k(N(`error.pivotTable.sourceSharedSlicer`));let i=this._sheet.getWorkbook(),a=i._pivotSourceOf(e,this._sheet),o=a?await i._pivotSourceRangeOf(a):null;if(!a||!o)throw new k(N(`error.pivotTable.sourceNotFound`));if(o.getRowCount()<2)throw new k(N(`error.pivotTable.refreshSourceTooSmall`));if(o.getWorksheet().getName()===this._sheet.getName()){let e=o.getCoords();if(this._getOwnCells().some(t=>h.isRangesIntersect(t,e)))throw new k(N(`error.pivotTable.sourceOverlapsTable`))}let s=i._getPivotCache(this.getCacheId())?.toJSON();if(!s?.fields)throw new k(N(`error.pivotTable.refreshSourceUnsupported`));let c=await vC.load();o.getWorksheet()._cellBuffer?.release();let{model:l,remap:u}=c.refreshPivotCache(s,c.readPivotSource(o),a,this._sheet.getRuntime().isDate1904());await i.doBatch(async()=>{let e=i._addPivotCache(l);this._updateState({cacheId:e.cacheId}),this._remapCache(u,c),await this._prepareRelayout(c),this._refresh(c);for(let e of r)uC(this._getCache(),e.getSourceName())<0&&e.delete()},{description:m(`op.changePivotSource`),...t})}async addSlicer(e,t){let n=typeof e==`string`?this.getField(e):e;if(!n||n.getPivotTable()!==this)throw new k(N(`error.slicer.noField`,{name:typeof e==`string`?e:e.getName()}));let r=n._index,i=this._getCache()?.fields?.[r],a=t?.sheet??this._sheet,o=a.getWorkbook();if(!this._getState().model||!i||!o||this.isDeleted())throw new k(N(`error.pivotTable.notModeled`));let{sheet:s,caption:c,style:l,columnCount:u,...d}=t??{},f=o,p=i.name,h=d.name??zv(o,p);if(zv(o,h)!==h)throw new k(N(`error.slicer.nameTaken`,{name:h}));let g={pivot:{sourceName:p,tables:[{sheet:this._sheet.getName(),name:this.getName()}],cacheId:this.getCacheId(),tabular:{},body:``}},_=c??n.getName();_!==p&&(g.caption=_);let v=l||o.getStyles().getSlicerStyles().getDefault().getName();v!==`SlicerStyleLight1`&&(g.style=v),u!==void 0&&u>1&&(g.columnCount=Math.trunc(u));let y=await vC.load(),b=f._getPivotCache(this.getCacheId()),x=null;return await f.doBatch(async()=>{let e=b?._getData().model,t=e&&y.withListedFields(e,[r]);t&&t!==e&&b._restate(t),x=(await a.getMovables().add({autoPlace:`viewport`,...d,type:`slicer`,json:g,name:h,bounds:{width:192,height:280,...d.bounds}})).getContent(),await this._prepareFilters(y),this._refreshFrom(y)},{description:m(`op.insertSlicer`)}),x}async _setDateRange(e,t,n){await this._editModel(r=>((e,t,n,r)=>dS(e,t,e=>e!==`value`,r?[{field:t,condition:{operator:mC.And,param:[{selector:pC,operator:mC.AfterEqualTo,param:Math.floor(Math.min(r.start,r.end))},{selector:pC,operator:mC.BeforeEqualTo,param:Math.floor(Math.max(r.start,r.end))}]},name:n,useWholeDay:!0}]:[]))(r,e,t,n),m(`op.filterPivotTable`))}async _showSlicerItems(e,t){let n=await vC.load(),r=this._getCache();if(!r)throw new k(N(`error.pivotTable.notModeled`));await this._editModel(i=>((e,t,n,r)=>{let i=e.fields;if(!i?.[t])return e;let a=e;if(!i[t].items){if(!r)return e;let o=n();a={...e,fields:i.map((e,n)=>n===t?{...e,items:o}:e)}}let o=a.fields[t].items,s=r?new Set(o.flatMap((e,t)=>mS(e)&&r.has(e.item)?[t]:[])):null;return xS(a,t,s)})(i,e,()=>n.listedItemsOf(r,e),t),m(`op.selectSlicerItems`))}_getLocation(){let e=this._locationCell();if(!e||this._getState().blocked)return e;let{rowStart:t,colStart:n}=e,r=this._view?.size??this._getState().size;return{rowStart:t,colStart:n,rowEnd:t+r.rows-1,colEnd:n+r.columns-1}}_locationCell(){let e=this.isDeleted()?null:this.getFirstAnchorCoords();if(!e)return null;let{blocked:t,size:n}=this._getState(),r=t?e.rowStart:e.rowEnd-n.rows+1;return{rowStart:r,colStart:e.colStart,rowEnd:r,colEnd:e.colStart}}_holdLocation(){if(this._getState().blocked)return;let t=this._getLocation();if(!t)return;let n={rows:t.rowEnd-t.rowStart+1,columns:t.colEnd-t.colStart+1},r=this._getState().size;if(r.rows===n.rows&&r.columns===n.columns)return;let i=e.heldOf(this._getWanted()?.structure??null,t,!1);this._updateState({size:n,anchorCoords:i})}isStale(){return this._sheet.getWorkbook()?._getPivotCache(this._getState().cacheId)?._isStale()??!1}_isModeled(){return this._getState().model!==null}_getPivotView(e){let t=this._getState();if(!t.model)return null;let n=this._locationCell();if(!n)return null;if(this._view===void 0){let r=this.toJSON(),{rowStart:i,colStart:a}=n,o={rowStart:i,colStart:a,rowEnd:i+t.size.rows-1,colEnd:a+t.size.columns-1};this._view=r?e(r,o,t.blocked):null}return this._view?.view??null}_processAnchorCoords(){this._view=void 0,super._processAnchorCoords()}_getRangedStyle(){let e=this._getPlacement(),t=this._getState().model?.style?.name;if(!e||!t)return null;let n=this._sheet.getStyles(),r=n.getTableStyles().getByName(t);if(!r)return null;let i=this._ranged;if(i&&i.placement===e&&i.style===r)return i.ranged;let a=new lC(n,r.getProperties(),e.structure,e.origin,this._getState().model.style);return this._ranged={placement:e,style:r,ranged:a},a}_getPlacement(){return this._getState().blocked?null:this._getWanted()}_getWanted(){let e=this._getState().model,t=e?this._locationCell():null;if(!e||!t)return null;let n=this._placement;if(n&&n.model===e&&n.row===t.rowStart&&n.column===t.colStart)return n.placement;let r=XS(e),i=null;if(r){let e={rowIndex:t.rowStart-r.top,colIndex:t.colStart};i={structure:r,origin:e,extent:ZS(r,e),cells:QS(r,e)}}return this._placement={model:e,row:t.rowStart,column:t.colStart,placement:i},i}_setSettling(e){this._settling=e}_isSettling(){return this._settling}_isBlocked(){return this._getState().blocked}_getOwnCells(){let e=this._locationCell();if(!e)return[];let{rowStart:t,colStart:n}=e,{blocked:r,size:i}=this._getState();if(r)return[e];let a=this._getWanted();return a?[...a.cells.filter(e=>e.rowEnd<t),{rowStart:t,colStart:n,rowEnd:t+i.rows-1,colEnd:n+i.columns-1}]:[]}_getControlsIn(e){let t=this._getPlacement(),n=this._getState().model;if(!t||!n||!h.isRangesIntersect(t.extent,e))return[];let{rowIndex:r,colIndex:i}=t.origin,a={rowStart:e.rowStart-r,rowEnd:e.rowEnd-r,colStart:e.colStart-i,colEnd:e.colEnd-i},o=[],s=this._getCache(),c=new Map,l=(e,t)=>{let r=c.get(e);return r||c.set(e,r=s?gS(n,s,e):[]),r[t]??``};for(let s of[...HC(t.structure),...UC(n,t.structure,a)]){let t=s.row+r,n=s.column+i;t<e.rowStart||t>e.rowEnd||n<e.colStart||n>e.colEnd||o.push(s.kind===`toggle`?{...s,row:t,column:n,name:l(s.field,s.item)}:{...s,row:t,column:n})}return o}_getFieldAt(e,t){let n=this._getPlacement();if(!n)return null;let r=nC(n.structure,e-n.origin.rowIndex,t-n.origin.colIndex);return r===null?null:this.getFields()[r]??null}_getLabelInsetAt(e,t){let n=this._getPlacement(),r=this._getState().model;return n&&r?WC(r,n.structure,e-n.origin.rowIndex,t-n.origin.colIndex):null}getStyleOptions(){return this._getState().model?.style??{}}updateStyleOptions(e,t){let n=this._getState().model;if(!n)throw new k(N(`error.pivotTable.styleNotModeled`));let{name:r,...i}={...n.style,...e},a=r?{name:r,...i}:i,o=n.style??{},s=new Set([...Object.keys(o),...Object.keys(a)]),c=!1;for(let e of s)o[e]!==a[e]&&(c=!0);return c&&this._updateState({model:{...n,style:a},part:null},{description:m(`op.formatPivotStyle`),...t}),this}setHiddenDrillIndicators(e,t){let n=this._getState().model;if(!n)throw new k(N(`error.pivotTable.optionsNotModeled`));if(!!n.hiddenDrillIndicators===e)return this;let{hiddenDrillIndicators:r,...i}=n,a=e?{...i,hiddenDrillIndicators:!0}:i;return this._updateState({model:a,part:null},{description:m(`op.togglePivotDrillIndicators`),...t}),this}isHiddenDrillIndicators(){return!0===this._getState().model?.hiddenDrillIndicators}async setHiddenFieldHeaders(e,t){if(!this._getState().model)throw new k(N(`error.pivotTable.optionsNotModeled`));return await this._editModel(t=>{if(!!t.hiddenFieldHeaders===e)return t;let{hiddenFieldHeaders:n,...r}=t;return e?{...r,hiddenFieldHeaders:!0}:r},m(`op.togglePivotFieldHeaders`),t),this}isHiddenFieldHeaders(){return!0===this._getState().model?.hiddenFieldHeaders}_axisFieldsAgree(e,t){let n=this._getState().model,r=[...n?.rowFields??[],...n?.columnFields??[]].filter(e=>e>=0);if(r.length===0)return t;let i=e(n?.fields?.[r[0]]??{});return r.every(t=>e(n?.fields?.[t]??{})===i)?i:null}async _editSetting(e,t,n){if(!this._getState().model)throw new k(N(`error.pivotTable.optionsNotModeled`));return await this._editModel(e,t,n),this}_editEveryField(e,t,n){let r=n.fields;return r?.some(n=>n[e]!==t)?{...n,fields:r.map(n=>ZC(n,e,t))}:n}_editField(e,t,n){return this._editSetting(n=>{let r=n.fields?.[e];if(!r)return n;let i=t(r);return i===r?n:{...n,fields:n.fields.map((t,n)=>n===e?i:t)}},m(`op.changePivotFieldSettings`),n)}async _editFieldSetting(e,t,n,r){await this._editField(e,e=>ZC(e,t,n),r)}getForm(){let e=this._getState().model;return this._axisFieldsAgree(e=>e.form??`compact`,e?.form??`compact`)}async setForm(e,t){if(e!==`compact`&&e!==`outline`&&e!==`tabular`)throw new k(N(`error.pivotTable.notAForm`,{form:e}));let n=e===`compact`?void 0:e;return this._editSetting(e=>this._editEveryField(`form`,n,ZC(e,`form`,n)),m(`op.changePivotLayout`),t)}getRepeatLabels(){return this._axisFieldsAgree(e=>!0===e.repeatLabels,!1)}setRepeatLabels(e,t){return this._editSetting(t=>this._editEveryField(`repeatLabels`,!!e||void 0,t),m(`op.changePivotLayout`),t)}getBlankRowAfterItems(){return this._axisFieldsAgree(e=>!0===e.blankRowAfter,!1)}setBlankRowAfterItems(e,t){return this._editSetting(t=>this._editEveryField(`blankRowAfter`,!!e||void 0,t),m(`op.changePivotLayout`),t)}getSubtotalsOnTop(){return this._axisFieldsAgree(e=>!1!==e.subtotalsOnTop,!0)}setSubtotalsOnTop(e,t){return this._editSetting(t=>this._editEveryField(`subtotalsOnTop`,!!e&&void 0,t),m(`op.changePivotLayout`),t)}isShowRowGrandTotals(){return!1!==this._getState().model?.columnGrandTotals}setShowRowGrandTotals(e,t){return this._editSetting(t=>ZC(t,`columnGrandTotals`,!!e&&void 0),m(`op.changePivotLayout`),t)}isShowColumnGrandTotals(){return!1!==this._getState().model?.rowGrandTotals}setShowColumnGrandTotals(e,t){return this._editSetting(t=>ZC(t,`rowGrandTotals`,!!e&&void 0),m(`op.changePivotLayout`),t)}getEmptyCaption(){let e=this._getState().model;return!1===e?.showEmpty?null:e?.emptyCaption??``}setEmptyCaption(e,t){return this._editSetting(t=>ZC(ZC(t,`emptyCaption`,e||void 0),`showEmpty`,e!==null&&void 0),m(`op.changePivotOptions`),t)}getErrorCaption(){let e=this._getState().model;return e?.showError?e.errorCaption??``:null}setErrorCaption(e,t){return this._editSetting(t=>ZC(ZC(t,`errorCaption`,e||void 0),`showError`,e!==null||void 0),m(`op.changePivotOptions`),t)}isPreserveFormatting(){return!1!==this._getState().model?.preserveFormatting}setPreserveFormatting(e,t){let n=this._getState().model;if(!n)throw new k(N(`error.pivotTable.optionsNotModeled`));if(!1!==n.preserveFormatting===e)return this;let{preserveFormatting:r,...i}=n,a=i;if(!e){let{formats:e,...t}=i;a={...t,preserveFormatting:!1}}return this._updateState({model:a,part:null},{description:m(`op.changePivotOptions`),...t}),this}isAutoFitColumns(){return!1!==this._getState().model?.autoFitColumns}setAutoFitColumns(e,t){let n=this._getState().model;if(!n)throw new k(N(`error.pivotTable.optionsNotModeled`));return!1!==n.autoFitColumns===e||this._updateState({model:ZC(n,`autoFitColumns`,!!e&&void 0),part:null},{description:m(`op.changePivotOptions`),...t}),this}isMultipleFiltersPerField(){return!0===this._getState().model?.multipleFiltersPerField}async setMultipleFiltersPerField(e,t){let n=this._getState().model;if(!n)throw new k(N(`error.pivotTable.optionsNotModeled`));if(!0===n.multipleFiltersPerField===e)return this;let r=m(`op.changePivotOptions`),i=ZC(n,`multipleFiltersPerField`,!!e||void 0),a=new Map;for(let e of n.filters??[])a.set(e.field,(a.get(e.field)??0)+1);let o=e?n.filters:n.filters?.filter(e=>a.get(e.field)===1);return o?.length===n.filters?.length?(this._updateState({model:i,part:null},{description:r,...t}),this):this._editSetting(()=>o?.length?{...i,filters:o}:ZC(i,`filters`,void 0),r,t)}getStyle(){let e=this._getState().model?.style?.name;return e?this._sheet.getStyles().getTableStyles().getByName(e)??null:null}getStyleAt(e,t){return ch(this._sheet._getScalar(e,t),this._sheet.getStyles(),this._getCellLayer(),{rowStart:e,colStart:t,rowEnd:e,colEnd:t})}_getCellLayer(){let e=this._getRangedStyle(),t=this._getPlacement(),n=this._getCacheFields(),r=this._layer;if(r&&r.placement===t&&r.ranged===e&&r.fields===n)return r.layer;let a=this._getState().model,o=e?.getCoords()??t?.extent??h.EmptyRange,s=new Set;if(t&&!t.structure.empty)for(let e of HC(t.structure))s.add(e.row+`:`+e.column);let c={getCoords:()=>o,getPropertiesAt:(r,o,c)=>{if(t?.structure.empty)return LS(t.structure,r-t.origin.rowIndex,o-t.origin.colIndex)??{};let l=e?.getPropertiesAt(r,o,c)??{};if(!t||!a)return l;let u=r-t.origin.rowIndex,d=o-t.origin.colIndex,f=rC(t.structure,a,u,d,n),p=GC(a,t.structure,u,d,c),m=IC(t.structure,a,u,d),h=s.size>0&&s.has(u+`:`+d);if(f===void 0&&p===null&&!m&&!h)return l;let g={...l};return f!==void 0&&(g.numberFormat=f),p!==null&&(g.alignment={...l.alignment,horizontal:`left`,...p>0?{indent:p}:{}}),h&&(g.insets={...l.insets,right:(l.insets?.right??0)+16}),m&&(g=i.deepMerge(g,m)),g}};return this._layer={placement:t,ranged:e,fields:n,layer:c},c}_formatCells(e,t){let n=this._getPlacement(),r=this._getState().model;if(!n||!r)return!1;let{rowIndex:a,colIndex:o}=n.origin,s=[];for(let t of e)for(let e of n.cells){let n=h.intersectRanges(t,e);if(n)for(let e=n.rowStart;e<=n.rowEnd;e++)for(let t=n.colStart;t<=n.colEnd;t++)s.push({row:e-a,column:t-o})}let c=((e,t,n)=>{let r=new Set,i=n.filter(({row:e,column:t})=>{let n=`${e},${t}`;return!r.has(n)&&(r.add(n),!0)}),a=(e.rows.length-e.top)*e.columns.length,o=0;for(let{row:t,column:n}of i)t>=e.top&&n<e.columns.length&&o++;if(a>0&&o===a)return[{type:`all`,dataOnly:!1,outline:!1}];let s=new Map;for(let{row:n,column:r}of i){let i=OC(e,t,n,r);if(!i)continue;let a;switch(i.kind){case`button`:a=`button|${i.axis}|${i.field}`;break;case`label`:a=i.grandRow?`grandRow`:i.grandCol?`grandCol`:`label|${i.field}|${i.subtotal}`;break;default:a=i.kind}let o=s.get(a);o||s.set(a,o=[]),o.push(i)}let c=[];for(let t of s.values()){let n=t[0];switch(n.kind){case`origin`:case`topRight`:c.push({type:n.kind,dataOnly:!1,labelOnly:!0,outline:!1});break;case`button`:c.push({type:`button`,field:n.field,dataOnly:!1,labelOnly:!0,outline:!1,axis:n.axis});break;case`label`:{if(n.grandRow||n.grandCol){c.push({dataOnly:!1,labelOnly:!0,...n.grandRow?{grandRow:!0}:{grandCol:!0},outline:!1});break}let e=t,r=[...n.items.keys()].map(t=>{let r=new Set(e.map(e=>e.items.get(t))),i=n.items.get(t);return{field:t,...r.size===1&&i!==void 0?{items:[i]}:{},...t===n.field?{}:{selected:!1},...t===n.field&&n.subtotal?{subtotals:[`defaultSubtotal`]}:{}}});c.push({dataOnly:!1,labelOnly:!0,references:r});break}case`value`:{let r=t,i=PC(e.rowSlots,r.map(e=>e.row),!0),a=PC(e.columnSlots,r.map(e=>e.column),!1),o=[...i.references,...a.references];if(e.dataCount>1){let e=new Set(r.map(e=>e.data));o.push({field:EC,...e.size===1?{items:[n.data]}:{},selected:!1})}c.push({...i.grand?{grandRow:!0}:{},...a.grand?{grandCol:!0}:{},collapsedLevelsAreSubtotals:!0,...o.length>0?{references:o}:{}});break}}}return c})(n.structure,r,s);if(c.length===0)return!1;let l=[...r.formats??[]];for(let e of c){let n=JSON.stringify(e),r=l.findIndex(e=>e.action===void 0&&JSON.stringify(e.area)===n);r>=0?l[r]={...l[r],style:i.deepMerge(l[r].style,t)}:l.push({style:t,area:e})}return this._updateState({model:{...r,formats:l},part:null}),!0}_getDateFormatsIn(e){let t=this._getPlacement(),n=this._getState().model;if(!t||!n||!h.isRangesIntersect(t.extent,e))return[];let r=this._getCacheFields(),i=this._dates;if(!i||i.placement!==t||i.fields!==r){let e=this._sheet.getRuntime(),a=t=>{let n=iC(t,e);return nt(n)||pt(n)?n:null},{rowIndex:o,colIndex:s}=t.origin,c=((e,t,n,r,i)=>{let a=new Map,o=e=>{if(e===void 0)return null;let t=a.get(e);return t===void 0&&a.set(e,t=r(e)),t},s=!!i&&(t.formats??[]).some(e=>e.action!==`blank`&&e.style?.numberFormat!==void 0),c=[...(t.dataFields??[]).map(e=>e.numberFormat),...(t.fields??[]).map((e,t)=>e.numberFormat??n?.[t]?.numberFormat??(rS(n?.[t])?14:void 0))];if(!s&&!c.some(e=>o(e)!==null))return[];let l=[],{rows:u,columns:d}=e,f=e.top+e.headerRows,p=e.headerColumns,m=e.pages.reduce((e,t)=>Math.max(e,t.column+2),0),h=new Map,g=(e,t,n)=>{let r=h.get(t);if(r&&r.rowEnd===e-1&&r.value===n)return void(r.rowEnd=e);let i={rowStart:e,rowEnd:e,colStart:t,colEnd:t,value:n};l.push(i),h.set(t,i)};if(s){for(let r=0;r<u.length;r++){let a=r<e.top?m:d.length;for(let s=0;s<a;s++){let a=o(i(r,s)??rC(e,t,r,s,n));a&&g(r,s,a)}}return l}let _=(e,t)=>{let n=[];for(let r=t;r<e.length;r++){let t=e[r],i=$S(t)?t.data:null,a=n[n.length-1];a&&a.data===i?a.end=r:n.push({start:r,end:r,data:i})}return n},v=_(d,p);for(let e of _(u,f))for(let n of v){let r=o(t.dataFields?.[e.data??n.data??0]?.numberFormat);r&&l.push({rowStart:e.start,rowEnd:e.end,colStart:n.start,colEnd:n.end,value:r})}for(let r=0;r<u.length;r++){let i=r<f?r<e.top?m:d.length:p;for(let a=0;a<i;a++){let i=o(rC(e,t,r,a,n));i&&g(r,a,i)}}return l})(t.structure,n,r,a,(e,r)=>IC(t.structure,n,e,r)?.numberFormat).map(e=>({rowStart:e.rowStart+o,rowEnd:e.rowEnd+o,colStart:e.colStart+s,colEnd:e.colEnd+s,value:e.value}));this._dates=i={placement:t,fields:r,regions:c}}let a=[];for(let t of i.regions)h.isRangesIntersect(t,e)&&a.push(t);return a}_getCacheData(){return this._sheet.getWorkbook()?._getPivotCache(this._getState().cacheId)?._getData()??null}_getFilterResult(e=this._getState().model){if(!e||!eS(e,this._getCacheFields()))return null;let t=this._filtered;return t&&t.filters===e.filters&&t.fields===e.fields&&t.data===this._getCacheData()&&t.pageFields===e.pageFields&&t.dataFields===e.dataFields&&t.slicers===this._slicerKey(e)?t.result:void 0}_slicerKey(e){return e.filters?.some(e=>e.dataField!==void 0)||e.fields?.some(e=>e.items?.some(e=>e.calculated))?this._slicerFields().join(`,`):``}_slicerFields(){let e=this._sheet?.getWorkbook(),t=this._getCache();if(!e||!t)return[];let n=new Set;for(let r of _C(e,this)){let e=uC(t,r.getSourceName());e>=0&&n.add(e)}return[...n].sort((e,t)=>e-t)}_relayForSlicers(){let e=vC.peek(),t=this._getState().model;e&&t&&!this.isDeleted()&&this._getFilterResult(t)!==void 0&&this._refreshFrom(e)}async _prepareFilters(e,t=this._getState().model){if(!t||this._getFilterResult(t)!==void 0)return;let n=this._getCache(),r=this._getCacheData();if(!n||!r)return;let{filters:i,fields:a,pageFields:o,dataFields:s}=t,c=SS(t,this._slicerFields()),l=await e.evaluatePivotFilters(c,n,this._sheet.getRuntime(),this._sheet.getCalculation());this._filtered={filters:i,fields:a,pageFields:o,dataFields:s,data:r,slicers:this._slicerKey(t),result:l}}_prepareRelayout(e){let t=this._getState().model;if(!t)return Promise.resolve();let n=this._anchoredToday(t,e);return this._anchored={model:t,anchored:n},this._prepareFilters(e,n)}_anchoredToday(e,t){return t.anchorPivotPeriods(e,tv(this._sheet.getRuntime()))}_prepareFiltersOnce(e){let t=this._getState().model,n=this._getCache();return t&&n&&$x(t,n.fields)&&this._sheet.getCalculation().getStatus()===Q.Status.Off?Promise.resolve():this._filtering??=this._prepareFilters(e).finally(()=>{this._filtering=null})}_getCacheFields(){let t=this._sheet.getWorkbook()?._getPivotCache(this._getState().cacheId);if(!t)return;let n=t._getData(),r=e._cacheFields.get(n);return r||e._cacheFields.set(n,r=t.toJSON().fields??[]),r}static{this._cacheFields=new WeakMap}getCacheId(){return this._getState().cacheId}async refresh(e){this._assertRefreshAllowed();let t=await vC.load(),n={description:m(`op.refreshPivotTable`),...e};if(!1===e?.source)return await this._prepareRelayout(t),void await this.doBatch(()=>this._refresh(t),n);let r=this._sheet.getWorkbook();await r.doBatch(()=>r._refreshPivotCaches(new Set([this.getCacheId()]),t),n)}_remapCache(e,t){let n=this._getState().model;if(!n)throw new k(N(`error.pivotTable.notModeled`));this._updateState({model:t.remapPivotTable(n,e),part:null,ref:null,buttons:null})}_refresh(e){let t=this._anchored;this._anchored=null,t&&t.model===this._getState().model&&t.anchored!==t.model&&this._updateState({model:t.anchored,part:null});let n=this._getState().model;if(!1===n?.preserveFormatting&&n.formats&&n.formats.length>0){let{formats:e,...t}=n;this._updateState({model:t,part:null})}this._refreshFrom(e)}_assertRefreshAllowed(){if(this._sheet.getProtection().isLocked())throw new b(N(`error.sheet.protectedSheet`))}_refreshFrom(t,n=this._getOwnCells(),r,i){let a=this._getState(),o=i??this._locationCell(),s=a.model,c=this._sheet,l=this._getCache(),u=s?this.toJSON():null,d=c,f=d._getPivotCellOrder(),p=this._getFilterResult(s),m=o&&u&&l?t.layOutPivot(u,l,c.getRuntime(),{cellOrder:f,filters:p,slicerFields:this._slicerFields()}):null;if(!o||!s||!m)throw new k(N(`error.pivotTable.notModeled`));if(m.rowPageCount>0&&o.rowStart<m.rowPageCount+1){let e=m.rowPageCount+1;o={rowStart:e,colStart:o.colStart,rowEnd:e,colEnd:o.colStart}}let g={...s,header:m.header,rowLines:m.rowLines,columnLines:m.columnLines},_={rows:m.rows,columns:m.columns},v=XS(g),y=QS(v,{rowIndex:o.rowStart-v.top,colIndex:o.colStart}),b=d._pivotObstructionOf(this,y,n);if(r&&b){if(b===`pivot`)throw new k(N(`error.pivotTable.overlapsPivot`));if(b===`array`||!r.discardValues)throw new k(N(`error.pivotTable.destinationOccupied`))}let x=!r&&b!==null,S={rowStart:o.rowStart,colStart:o.colStart,rowEnd:o.rowStart+_.rows-1,colEnd:o.colStart+_.columns-1},C=e.heldOf(v,S,x),w=this.getFirstAnchorCoords(),T=!w||!h.isEqualRanges(w,C);this._updateState({model:g,part:null,ref:null,buttons:null,size:_,blocked:x,...T?{anchorCoords:C}:null}),T?this._options.setContainerCoords(C):d._tellPivots();let E={row:o.rowStart,column:o.colStart};this._settling=!0;try{x?d._writePivotCells(n,[[0,[[0,[V.BuiltIn.Spill]]]]],E):d._writePivotCells([...n,...y],m.cells,E)}finally{this._settling=!1}let D=x||!1===g.autoFitColumns?null:this._getPlacement()?.extent;D&&d._autoFitPivotColumns(D)}_typeAt(t,n,r){let i=vC.peek(),a=this._locationCell(),o=this._sheet,s=this._getCache(),c=this._getState().model?this.toJSON():null,l=this._getFilterResult(),u=i&&a&&c&&s?i.layOutPivot(c,s,o.getRuntime(),{roles:!0,filters:l,slicerFields:this._slicerFields()}):null,d=a?u?.roles?.get(t-a.rowStart+`,`+(n-a.colStart)):void 0;if(!(i&&c&&s&&d))throw new k(N(`error.pivotTable.changePart`));let f=e.modelOf(i.typeOverPivot(c,s,d,r));l&&this._filtered&&f?.filters&&(this._filtered={...this._filtered,filters:f.filters,fields:f.fields}),this._updateState({model:f,part:null,ref:null,buttons:null}),this._refreshFrom(i)}getFields(){let e=this._getState().model?.fields?.length??0,t=[];for(let n=0;n<e;n++)t.push(new SC(this,n));return t}getField(e){let t=this._getState().model,n=this._getCache(),r=t?.fields?.length??0;for(let i=0;i<r;i++)if(fS(pS(t,n,i),e))return new SC(this,i);return null}getRowFields(){return this._fieldsOf(this._getState().model?.rowFields)}getColumnFields(){return this._fieldsOf(this._getState().model?.columnFields)}getPageFields(){return this._fieldsOf(this._getState().model?.pageFields?.map(e=>e.field))}_fieldsOf(e){return(e??[]).filter(e=>e>=0).map(e=>new SC(this,e))}getDataFields(){return(this._getState().model?.dataFields??[]).map(e=>new wC(this,e.name))}getDataField(e){let t=this._getState().model?.dataFields?.find(t=>fS(t.name,e));return t?new wC(this,t.name):null}async addDataField(e,t,n){let r=await vC.load(),i=typeof e==`string`?e:e.getName(),a=this.getFields().findIndex(e=>fS(e.getName(),i));if(a<0)throw new k(N(`error.pivotTable.notAField`,{name:i}));return await this._editModel(e=>r.addPivotDataField(e,this._getCache(),a,t),m(`op.addPivotDataField`),n),new wC(this,this._getState().model.dataFields.at(-1).name)}getValuesField(){return(this._getState().model?.dataFields?.length??0)<2?null:new TC(this)}_getModel(){return this._getState().model}_getCache(){return this._sheet.getWorkbook()?._getPivotCache(this._getState().cacheId)?.toJSON()??null}async _editModel(e,t,n){let r=await vC.load(),i=this._getState().model;if(!i||this.isDeleted())throw new k(N(`error.pivotTable.notModeled`));let a=e(i);if(a===i)return;let o=this._anchoredToday(a,r);await this._prepareFilters(r,o),await this.doBatch(()=>this._relayAs(o,r),{description:t,...n})}_relayAs(e,t){let n=this._getOwnCells();this._updateState({model:e,part:null,ref:null,buttons:null}),this._refreshFrom(t,n)}async _moveField(e,t,n,r){let i=await vC.load(),a=this._getState().model,o=this._getCache();if(!a||!o||this.isDeleted())throw new k(N(`error.pivotTable.notModeled`));let s=i.movePivotField(a,o,e,t,n);if(s===a)return;let c=m(`op.movePivotField`),l=this._sheet.getWorkbook(),u=l._getPivotCache(this.getCacheId()),d=u._getData().model,f=i.withListedFields(d,i.axisFieldsOf(s));if(f===d)return void await this._editModel(()=>s,c,r);let p=this._anchoredToday(s,i);await l.doBatch(async()=>{u._restate(f),await this._prepareFilters(i,p),this._relayAs(p,i)},{description:c,...r})}toJSON(e){let t=this._getState(),n=this._getLocation(),r=(n?zd(n):null)||t.ref||``,i={cacheId:this.getCacheId(),location:r},a=this.getName();a&&(i.name=a);let o=Kx.toJSON(t.part,e);o&&(i.part=o,t.partFormats&&(i.partFormats=t.partFormats)),t.model&&Object.assign(i,t.model);let s=t.model?.header?function(e){let t=e.header;if(!t)return null;let n=Wx(e),r=n.rows>0?n.rows+1:0,i=[],a=(e,t)=>{i.push(zd({rowStart:e,rowEnd:e,colStart:t,colEnd:t}))},o=!0===e.pageOverThenDown;if((e.pageFields??[]).forEach((e,t)=>{a(o?Math.floor(t/n.wrap):t%n.wrap,3*(o?t%n.wrap:Math.floor(t/n.wrap)))}),e.hiddenFieldHeaders)return i;let s=(e.rowFields??[]).filter(e=>e!==-2),c=(e.columnFields??[]).filter(e=>e!==-2);if(c.length>0){let n=r+t.firstHeaderRow-1;s.length>0&&e.dataFields?.length===1&&a(n,0);let i=c.every(t=>e.fields?.[t]?.form===void 0);for(let r=0;r<(i?1:e.columnFields.length);r++)a(n,t.firstDataCol+r)}if(s.length>0)for(let e=0;e<t.firstDataCol;e++)a(r+t.firstDataRow-1,e);return i}(i):t.buttons;return s&&s.length>0&&(i.buttons=[...s]),i}_processUpdateState(e,t){e?.model!==t?.model&&(this._view=void 0)}_processAfterStateChange(e,t,n,r){super._processAfterStateChange(e,t,n,r),this._emitter.notify(`onAnyChange`)}_isAnyChangeFromState(){return!0}_processRestoreOrRevert(e,t){this._view=void 0,super._processRestoreOrRevert(e,t)}_getActionDescription(e){return e===`delete`?m(`op.deletePivotTable`):super._getActionDescription(e)}get isIPivotTable(){return!0}};(function(e){let t=e.isSavedBlocked=(e,t)=>{if(t.rows!==1||t.columns!==1)return!1;let n=e?XS(e):null;return!!n&&(n.rows.length-n.top>1||n.columns.length>1)},n=e.heldOf=(e,t,n)=>{let{rowStart:r,colStart:i}=t;if(n)return{rowStart:r,colStart:i,rowEnd:r,colEnd:i};if(!e||e.top===0)return t;let a=t;for(let t of QS(e,{rowIndex:r-e.top,colIndex:i}))t.rowEnd<r&&(a=h.unionRanges(a,t));return a};e.anchorOf=e=>{let i=Ux(e);if(!i)return null;let a=r(e),o={rows:i.rowEnd-i.rowStart+1,columns:i.colEnd-i.colStart+1};return n(a?XS(a):null,i,t(a,o))};let r=e.modelOf=e=>{if(!e.fields)return null;let{name:t,cacheId:n,location:r,part:i,partFormats:a,buttons:o,...s}=e;return s}})(QC||={});var $,$C,ew=class extends Qt{constructor(e,t,n=null){super(),this._getItemsDelegate=e,this._doBatch=t,this._addDelegate=n}async add(e,t,n){if(!this._addDelegate)throw new k(N(`error.pivotTable.addOnSheet`));return this._addDelegate(e,t,n)}_getItems(){return this._getItemsDelegate()}getByName(e){if(typeof e!=`string`)return null;let t=e.toLocaleLowerCase(),n=this._getItemsDelegate(),r=n.length;for(let e=0;e<r;e++)if(n[e].getName().toLocaleLowerCase()===t)return n[e];return null}async refreshAll(e){let t=this._getItemsDelegate();if(t.length===0)return;for(let e of t)e._assertRefreshAllowed();let n=await vC.load(),r={description:m(`op.refreshPivotTables`),...e};if(!1===e?.source){for(let e of t)await e._prepareRelayout(n);await this._doBatch(()=>{for(let e of t)e._refresh(n)},r);return}let i=t[0].getWorksheet().getWorkbook(),a=new Set(t.map(e=>e.getCacheId()));await i.doBatch(()=>i._refreshPivotCaches(a,n),r)}get isIPivotTableCollection(){return!0}};($C=$||={}).Content={Values:`values`,Formats:`formats`,Formulas:`formulas`,Hyperlinks:`hyperlinks`,Tables:`tables`,Notes:`notes`,Comments:`comments`,DataValidations:`dataValidations`,Sparklines:`sparklines`},$C.Role={Label:`label`,Input:`input`,Link:`link`,Reference:`reference`,Computed:`computed`,Output:`output`},$C.ErrorCheck={EvaluatesToError:`evalError`,TextDate:`twoDigitTextYear`,NumberAsText:`numberStoredAsText`,InconsistentFormula:`formula`,OmittedCells:`formulaRange`,UnlockedFormula:`unlockedFormula`,EmptyCellReference:`emptyCellReference`,ListDataValidation:`listDataValidation`,InconsistentListFormula:`calculatedColumn`,HardcodeInRun:`hardcodeInRun`,StyleBreak:`styleBreak`,StyleRole:`styleRole`,RepeatedReference:`repeatedReference`,DegenerateCall:`degenerateCall`,SumIncludesSubtotal:`sumIncludesSubtotal`,MisalignedReference:`misalignedReference`,ApproximateMatch:`approximateMatch`,LookupShape:`lookupShape`,ExternalReference:`externalReference`,ErrorConstant:`errorConstant`,LinkLabelMismatch:`linkLabelMismatch`,KeyLabelMismatch:`keyLabelMismatch`,SignVsSiblings:`signVsSiblings`,LiteralMatchesInput:`literalMatchesInput`,TwinBlockDivergence:`twinBlockDivergence`,ScaleOutlier:`scaleOutlier`,UnreferencedInput:`unreferencedInput`,RowGap:`rowGap`,ConstantFrequency:`constantFrequency`};var tw=Object.values($.ErrorCheck),nw=new Map(tw.map((e,t)=>[e,t])),rw=new Map;function iw(e){let t=[...new Set(e)].filter(e=>nw.has(e)).sort((e,t)=>nw.get(e)-nw.get(t));if(t.length===0)return null;let n=t.join(`,`),r=rw.get(n);return r||(r=Object.freeze(t),rw.set(n,r)),r}var aw=(e,t)=>iw([...e??[],...t]),ow=(e,t)=>e?iw(e.filter(e=>e!==t)):null,sw=()=>new fc({updateEntryOptions:{isSplitOnExpand:!0,isMergeOnShift:!0}}),cw=class e{static{this.Empty=new e(null)}constructor(e){this._map=e&&!e.isEmpty()?e:null}static fromJSON(t,n){if(!t?.length)return e.Empty;let r=[];for(let e of t){let t=wf(e,n),i=Array.isArray(t?.value)?iw(t.value):null;t&&i&&r.push({...t,value:i})}if(r.length===0)return e.Empty;let i=sw();return i.insertAllNonOverlapping(r,{onIntersect:(e,t)=>({...t,value:aw(e.value??null,t.value)})}),new e(i)}isEmpty(){return this._map===null}getMap(){return this._map}getAt(e){return(this._map?.search({rowStart:e.rowIndex,colStart:e.colIndex,rowEnd:e.rowIndex,colEnd:e.colIndex}))?.[0]?.value??null}set(t,n,r){if(!nw.has(n)||!r&&this._map===null)return this;let i=this._map?this._map.clone():sw(),a=iw([n]),o=!1;for(let e=0;e<t.length;e++)i.insertNonOverlapping({...t[e],value:a},{onIntersect:(e,t)=>{let i=e.value??null,s=r?aw(i,a):ow(i,n);return s!==i&&(o=!0),s?{...t,value:s}:null}});return o?new e(i):this}shift(t,n,r){if(!this._map)return this;let i=this._map;for(let e=0;e<t.length;e++)i=i.shift({range:t[e],direction:n,cloneIfUpdate:i===this._map,coordValidator:r});return i===this._map?this:new e(i)}remove(...t){if(!this._map)return this;let n=this._map;for(let e of t)for(let t=0;t<e.length;t++)n.search(e[t]).length!==0&&(n===this._map&&(n=this._map.clone()),n.insertNonOverlapping({...e[t],value:tw},{onIntersect:()=>null}));return n===this._map?this:new e(n)}toJSON(e){if(!this._map)return null;let t=Qo(this._map.all()),n=Array(t.length);for(let r=0;r<t.length;r++)n[r]={r:zd(t[r],e),v:[...t[r].value]};return n}},lw=$.ErrorCheck,uw=new Set([`AVERAGE`,`AVERAGEA`,`MIN`,`MINA`,`MAX`,`MAXA`,`MEDIAN`]),dw=new Set([`SUM`,`AVERAGE`]);function fw(e,t,n,r){let i=Xw(t,r,e.own);if(!i)return null;let a=e.formulasOf(i.sheet);if(!a)return null;let o=i.sheet===e.own,s=a.index.search(i.rect);for(let c=0;c<s.length;c++){let l=s[c].value,u=tT(l.coords,i.rect,o?r:null);if(!u)continue;let d=Aw(a.sheet,l);if(!d)continue;let f=`${o?``:bw(a.sheet.getName()??``)}R${zw(u.rowIndex-r.rowIndex)}C${zw(u.colIndex-r.colIndex)}`;if(Vw(t)&&Sw(d)&&xw(a.sheet,l))return{kind:`ratio`,at:f};let p=Ew(d).filter(e=>e.sign>0&&e.node.type!==`named`);if(p.length!==0&&(p.length!==1||Vw(p[0].node))&&p.some(t=>{let a=Xw(t.node,u,i.sheet);return a!==null&&n.some(t=>{let n=Xw(t.node,r,e.own);return n!==null&&n.sheet===a.sheet&&Qw(n.rect,a.rect)})}))return{kind:`subtotal`,at:f}}return null}var pw={lineItem:1,outsideBlocks:.5,closingRow:.25,absolute:.25};function mw(e,t,n,r){return n?e.colStart===t.colIndex&&e.colEnd===t.colIndex&&e.rowStart>=r[0]&&e.rowEnd<=r[1]:e.rowStart===t.rowIndex&&e.rowEnd===t.rowIndex&&e.colStart>=r[0]&&e.colEnd<=r[1]}var hw=(e,t,n)=>t?e.rowStart<=n[1]&&e.rowEnd>=n[0]:e.colStart<=n[1]&&e.colEnd>=n[0],gw=(e,t,n)=>e?{rowStart:t[0],rowEnd:t[1],colStart:n.colIndex,colEnd:n.colIndex}:{rowStart:n.rowIndex,rowEnd:n.rowIndex,colStart:t[0],colEnd:t[1]};function _w(e,t,n,r,i,a){let o=Rw(t,r),s=vw(gw(i,a,r),r);if(function(e){let t=e.type===`cell`?[e]:Vw(e)?e.inputs:[];return t.length>0&&t.every(e=>e.value.$rowIndex&&e.value.$colIndex)}(t))return{term:o,block:s,targetRole:`absolute`};let c=e.around(i,i?n.colStart:n.rowStart,i?n.colEnd:n.rowEnd,i?n.rowEnd:n.colEnd);if(!c)return{term:o,block:s,targetRole:`outsideBlocks`};let l=vw(i?{rowStart:c[0],rowEnd:c[1],colStart:n.colStart,colEnd:n.colEnd}:{rowStart:n.rowStart,rowEnd:n.rowEnd,colStart:c[0],colEnd:c[1]},r),u=i?n.rowEnd:n.colEnd;return{term:o,block:s,landsAt:l,targetRole:c[1]>c[0]&&u===c[1]?`closingRow`:`lineItem`}}function vw(e,t){let n=(e,n)=>`R${zw(e-t.rowIndex)}C${zw(n-t.colIndex)}`,r=n(e.rowStart,e.colStart);return e.rowStart===e.rowEnd&&e.colStart===e.colEnd?r:`${r}:${n(e.rowEnd,e.colEnd)}`}var yw=class{constructor(e){this._source=e,this._runs=new Map}around(e,t,n,r){let i=this._runsOf(e,t,n),a=0,o=i.length-1;for(;a<=o;){let e=a+o>>1;if(i[e][1]<r)a=e+1;else{if(!(i[e][0]>r))return i[e];o=e-1}}return null}_runsOf(e,t,n){let r=`${e?`r`:`c`}${t}:${n}`,i=this._runs.get(r);if(i)return i;let a=this._source.bounds,o=e?{rowStart:a.rowStart,rowEnd:a.rowEnd,colStart:t,colEnd:n}:{rowStart:t,rowEnd:n,colStart:a.colStart,colEnd:a.colEnd},s=[...this._source.contentful.search(o),...this._source.formulas.search(o)].map(t=>e?[Math.max(t.rowStart,o.rowStart),Math.min(t.rowEnd,o.rowEnd)]:[Math.max(t.colStart,o.colStart),Math.min(t.colEnd,o.colEnd)]);s.sort((e,t)=>e[0]-t[0]),i=[];for(let e of s){let t=i[i.length-1];t&&e[0]<=t[1]+1?t[1]=Math.max(t[1],e[1]):i.push([e[0],e[1]])}return this._runs.set(r,i),i}},bw=e=>/^[A-Za-z_][A-Za-z0-9_.]*$/.test(e)?`${e}!`:`'${e.replace(/'/g,`''`)}'!`;function xw(e,t){let n=t.coords,r=e.getRange({rowStart:n.rowStart,rowEnd:n.rowStart,colStart:n.colStart,colEnd:n.colStart}).getCell().getStyle(!0).getNumberFormat();return!!r&&!0===ve().getFormatInfo(r)?.isPercent}function Sw(e){let t=Ww(e);return t.type===`infix`&&t.value===`/`&&t.inputs?.length===2&&[...Ow(t.inputs[1])].some(Bw)}function Cw(e){let t=Gw(e);return typeof t!=`number`||t===0?null:t>0?`1`:`-1`}function ww(e,t,n,r){let i=Xw(e,n,r),a=Xw(t,n,r);if(!i||!a)return!1;let o=a.rect.rowEnd>a.rect.rowStart;return o!==a.rect.colEnd>a.rect.colStart&&(o?i.rect.rowStart!==a.rect.rowStart||i.rect.rowEnd!==a.rect.rowEnd:i.rect.colStart!==a.rect.colStart||i.rect.colEnd!==a.rect.colEnd)}function Tw(e){let t=[],n=[e];for(;n.length>0;){let e=[];Dw(n.pop(),1,e,n)&&e.length>0&&t.push(e)}return t}function Ew(e){let t=[];return Dw(e,1,t,[])?t:[]}function Dw(e,t,n,r){if(Bw(e))return n.push({node:e,sign:t}),!1;let i=e.inputs??[],a=e=>e===1?-1:1,o=!1;if(e.type===`function`&&Fw(e)===`SUM`){for(let e=0;e<i.length;e++)Dw(i[e],t,n,r);o=!0}else if(e.type===`paren`)for(let e=0;e<i.length;e++)o=Dw(i[e],t,n,r)||o;else if(e.type!==`infix`||e.value!==`+`&&e.value!==`-`||i.length!==2){if(e.type!==`prefix`||e.value!==`+`&&e.value!==`-`||i.length!==1)for(let e=0;e<i.length;e++)r.push(i[e]);else o=Dw(i[0],e.value===`-`?a(t):t,n,r)}else Dw(i[0],t,n,r),Dw(i[1],e.value===`-`?a(t):t,n,r),o=!0;return o}function*Ow(e){let t=[e];for(;t.length>0;){let e=t.pop();if(yield e,e.inputs)for(let n=e.inputs.length-1;n>=0;n--)t.push(e.inputs[n])}}var kw=new WeakMap;function Aw(e,t){let n=kw.get(t);if(n!==void 0)return n;if(n=null,d_.isLoaded()){let r=t.coords,i=e.getRange({rowStart:r.rowStart,rowEnd:r.rowStart,colStart:r.colStart,colEnd:r.colStart}).getCell().getFormulaText();i&&(n=d_.parse(i.slice(1),{anchor:Iw(t)}))}return kw.set(t,n),n}var jw=class{constructor(e,t){this._source=e,this._formulas=new Map,this._sheets=new Map,this.own=Yw(e),this._sheets.set(this.own,e.sheet),this._formulas.set(this.own,Pw(e.sheet,t))}sheetOf(e){let t=this._sheets.get(e);if(t!==void 0)return t;t=null;try{t=this._source.sheet.getWorkbook()?.getWorksheet(e)??null}catch{}return this._sheets.set(e,t),t}formulasOf(e){let t=this._formulas.get(e);if(t!==void 0)return t;let n=this.sheetOf(e),r=n?.getUsedRange();return t=n&&r?Pw(n,function(e){let t=[];for(let n of e.getRegions(Qh.Feature.Formula)){let e=n.getCell().getFormulaText({r1c1:!0});e!==null&&t.push({coords:n.getCoords(),r1c1:e})}return t}(r)):null,this._formulas.set(e,t),t}},Mw=new WeakMap;function Nw(e,t){let n=Mw.get(e);return n||(n=new jw(e,t),Mw.set(e,n)),n}function Pw(e,t){let n=new fc;return n.load(t.map(e=>({...e.coords,value:e}))),{sheet:e,regions:t,index:n}}var Fw=e=>String(e.value).toUpperCase().replace(/^(_XLFN\.)?(_XLWS\.)?/,``),Iw=e=>({rowIndex:e.coords.rowStart,colIndex:e.coords.colStart});function Lw(e,t){let n=e.coords;return t(Iw(e))?n.rowStart===n.rowEnd&&n.colStart===n.colEnd||t({rowIndex:n.rowEnd,colIndex:n.colEnd})?n:{rowStart:n.rowStart,rowEnd:n.rowStart,colStart:n.colStart,colEnd:n.colStart}:null}var Rw=(e,t)=>d_.image(e,{at:t,r1c1:!0}),zw=e=>e===0?``:`[${e}]`,Bw=e=>e.type===`cell`||Vw(e)||e.type===`named`,Vw=e=>e.type===`infix`&&e.value===`:`&&e.inputs?.length===2&&e.inputs[0].type===`cell`&&e.inputs[1].type===`cell`,Hw=e=>e.type===`cell`||Vw(e);function Uw(e){if(e.type===`cell`)return!qw(e.value);if(!Vw(e))return!1;let[t,n]=[e.inputs[0].value,e.inputs[1].value];return!qw(t)&&t.rowIndex===n.rowIndex&&t.colIndex===n.colIndex&&t.$rowIndex===n.$rowIndex&&t.$colIndex===n.$colIndex}function Ww(e){let t=e;for(;t.type===`paren`&&t.inputs?.length===1;)t=t.inputs[0];return t}function Gw(e){let t=Ww(e);if(t.type===`number`)return Number(t.value);if(t.type===`boolean`)return+!!t.value;if(t.type===`prefix`&&t.inputs?.length===1&&(t.value===`-`||t.value===`+`)){let e=Gw(t.inputs[0]);return e===void 0?void 0:t.value===`-`?-e:e}}var Kw=2**52,qw=e=>Math.abs(e.rowIndex)>=Kw||Math.abs(e.colIndex)>=Kw,Jw=e=>e.value?.scope??null,Yw=e=>(e.sheet.getName()??``).toLowerCase();function Xw(e,t,n){let r=e.type===`cell`?[e,e]:Vw(e)?e.inputs:null;if(!r)return null;let i=Jw(r[0]),a=r.map(e=>Zw(e.value.rowIndex,e.value.$rowIndex,t.rowIndex)),o=r.map(e=>Zw(e.value.colIndex,e.value.$colIndex,t.colIndex)),s={rowStart:a.some(e=>e===null)?0:Math.min(a[0],a[1]),rowEnd:a.some(e=>e===null)?2**53-1:Math.max(a[0],a[1]),colStart:o.some(e=>e===null)?0:Math.min(o[0],o[1]),colEnd:o.some(e=>e===null)?2**53-1:Math.max(o[0],o[1])};return{sheet:i?i.toLowerCase():n,rect:s}}var Zw=(e,t,n)=>Math.abs(e)>=Kw?null:t?e:n+e,Qw=(e,t)=>e.rowStart<=t.rowEnd&&t.rowStart<=e.rowEnd&&e.colStart<=t.colEnd&&t.colStart<=e.colEnd;function $w(e,t,n,r){if(e.type===`named`||t.type===`named`)return e.type===t.type&&String(e.value?.name).toLowerCase()===String(t.value?.name).toLowerCase()&&String(e.value?.scope??``).toLowerCase()===String(t.value?.scope??``).toLowerCase();let i=Xw(e,n,r),a=Xw(t,n,r);return i!==null&&a!==null&&i.sheet===a.sheet&&Qw(i.rect,a.rect)}var eT=(e,t,n)=>{let r=Xw(e,t,n)?.rect;return r?(r.rowEnd-r.rowStart+1)*(r.colEnd-r.colStart+1):1};function tT(e,t,n){let r=Math.max(e.rowStart,t.rowStart),i=Math.min(e.rowEnd,t.rowEnd),a=Math.max(e.colStart,t.colStart),o=Math.min(e.colEnd,t.colEnd);return r>i||a>o?null:n&&r===n.rowIndex&&a===n.colIndex?a<o?{rowIndex:r,colIndex:a+1}:r<i?{rowIndex:r+1,colIndex:a}:null:{rowIndex:r,colIndex:a}}function nT(e,t,n){let{rowIndex:r,colIndex:i}=t,a=n===`row`,o=a?i:r;if(o===0)return null;let s=e.getRange({rowStart:r,rowEnd:r,colStart:i,colEnd:i}).getSurrounding({contentOnly:!0}).getCoords(),c=a?s.colStart:s.rowStart;if(c<o){let t=iT(e,a?r:c,a?c:i);if(t)return t}let l=a?e.getRange({rowStart:r,rowEnd:r,colStart:0,colEnd:i-1}):e.getRange({rowStart:0,rowEnd:r-1,colStart:i,colEnd:i}),u=[];for(let e of l.getRegions(Qh.Feature.Contentful)){let t=e.getCoords(),n=a?t.colStart:t.rowStart;n!==c&&u.push(n)}u.sort((e,t)=>t-e);for(let t=0;t<u.length;t++){let n=iT(e,a?r:u[t],a?u[t]:i);if(n)return n}return null}var rT=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,` `).trim();function iT(e,t,n){let r=e.getRange({rowStart:t,rowEnd:t,colStart:n,colEnd:n}).getCell();if(r.getType()!==U.String)return null;let i=r.getText({hideStringPrefix:!0});return i?{text:i,address:r.getAddress(),coords:{rowIndex:t,colIndex:n}}:null}var aT=$.ErrorCheck;function oT(e){let t=Ww(e),n=1;for(;;){if(t.type===`cell`)return{reference:t,sign:n};let e=t.inputs??[];if(t.type!==`prefix`||e.length!==1||t.value!==`-`&&t.value!==`+`){if(t.type!==`infix`||e.length!==2||t.value!==`*`&&t.value!==`/`)return null;{let r=Gw(e[1]),i=t.value===`*`?Gw(e[0]):void 0,a=r??i;if(a===void 0||a===0)return null;a<0&&(n=n===1?-1:1),t=Ww(r===void 0?e[1]:e[0])}}else t.value===`-`&&(n=n===1?-1:1),t=Ww(e[0])}}function sT(e,t){let n=`R${e.rowIndex+1}C${e.colIndex+1}`;if(!t)return n;let r=t.getName()??``;return(/^[A-Za-z_][A-Za-z0-9_.]*$/.test(r)?`${r}!`:`'${r.replace(/'/g,`''`)}'!`)+n}var cT=class{constructor(){this._labels=new Map}label(e,t,n){let r=`${e.getName()}\0${n}\0${t.rowIndex}\0${t.colIndex}`,i=this._labels.get(r);return i===void 0&&(i=nT(e,t,n),this._labels.set(r,i)),i}},lT=new WeakMap,uT=e=>{let t=lT.get(e);return t||(t=new cT,lT.set(e,t)),t},dT=new Set([`MATCH`,`XMATCH`,`VLOOKUP`,`HLOOKUP`,`XLOOKUP`]),fT=`number`,pT=`date`,mT=`text`,hT=`numberText`,gT=`boolean`,_T=`error`,vT=`richData`;function yT(e){let t=e.values,n=t.getAxis()===B.Axis.Column,r=new Map,i=t=>{if(t==null)return null;switch(typeof t){case`number`:return fT;case`boolean`:return gT;case`string`:{if(t===``)return null;let n=r.get(t);return n===void 0&&(n=e.parseNumber(t)!==null,r.set(t,n)),n?hT:mT}}return V.isError(t)?_T:vT},a=new Map,o=(e,t,r,i)=>{let o=a.get(e);o||a.set(e,o=[]),o.push(n?{rowStart:r,rowEnd:i,colStart:t,colEnd:t}:{rowStart:t,rowEnd:t,colStart:r,colEnd:i})},s=t.getRuns();for(let e=s.next();!e.done;e=s.next()){let[t,n,r]=e.value,a=null,s=0;for(let e=0;e<r.length;e++){let c=i(r.at(e));c!==a&&(a&&o(a,t,n+s,n+e-1),a=c,s=e)}a&&o(a,t,n+s,n+r.length-1)}let c=new fc,l=[];for(let[e,t]of a){let n=xc(t,B.Axis.Column,2**53-1);for(let t=0;t<n.length;t++)l.push({...xT(n[t]),value:e})}return c.load(l),function(e,t){if(e.isEmpty()||t.isEmpty())return;let n=e.getBoundingRange(),r=t.search(n),i=[];for(let t=0;t<r.length;t++){let n=r[t].value;if(!n||!nt(n)&&!pt(n))continue;let a=e.search(r[t]);for(let e=0;e<a.length;e++){if(a[e].value!==fT)continue;let n=bT(a[e],r[t]);n&&i.push({...n,value:pT})}}i.length>0&&e.insertAllNonOverlapping(i)}(c,e.dateFormats),c}var bT=(e,t)=>{let n={rowStart:Math.max(e.rowStart,t.rowStart),rowEnd:Math.min(e.rowEnd,t.rowEnd),colStart:Math.max(e.colStart,t.colStart),colEnd:Math.min(e.colEnd,t.colEnd)};return n.rowStart<=n.rowEnd&&n.colStart<=n.colEnd?n:null},xT=e=>({rowStart:e.rowStart,rowEnd:e.rowEnd,colStart:e.colStart,colEnd:e.colEnd}),ST=$.ErrorCheck,CT=new Set([12,24,30,31,52,60,100,360,365,366,1e3,1e4,1e5,1e6,1e9]),wT=e=>{let t=Math.abs(e);return Number.isInteger(t)&&t<=10||CT.has(t)},TT=e=>Math.abs(e).toPrecision(12);function ET(e){let t=[];for(let n of Ow(e))n.type===`number`&&t.push(n);return t}var DT=(e,t)=>Math.max(0,e.rowStart-t.rowIndex,t.rowIndex-e.rowEnd)+Math.max(0,e.colStart-t.colIndex,t.colIndex-e.colEnd),OT=(e,t)=>({rowIndex:Math.min(Math.max(t.rowIndex,e.rowStart),e.rowEnd),colIndex:Math.min(Math.max(t.colIndex,e.colStart),e.colEnd)});function kT(e,t,n){let r=new Map,i=new Set;for(let n=0;n<t.length;n++){let a=Aw(e.sheet,t[n]);if(!a)continue;let o=ET(a).filter(e=>!wT(Gw(e)));if(o.length!==0){r.set(t[n],o);for(let e of o)i.add(TT(Gw(e)))}}if(i.size===0)return;let a=function(e,t){let n=new Map,r=e.roles.search(e.bounds);for(let i=0;i<r.length;i++){if(r[i].value!==$.Role.Label)continue;let a=e.kinds.search(r[i]);for(let o=0;o<a.length;o++){if(a[o].value!==fT)continue;let s=zT(r[i],a[o]);if(!s)continue;let c=e.sheet.getRange(s).getStats().getFrequencies();for(let[e,r]of c.getValueCounts()){if(typeof e!=`number`)continue;let i=TT(e);if(!t.has(i))continue;let a=c.getExtent(e);if(!a)continue;let o=n.get(i);o||n.set(i,o=[]),o.push({rect:a,count:r})}}}return n}(e,i);if(a.size!==0)for(let[t,i]of r){let r=Iw(t);for(let o of i){let i=a.get(TT(Gw(o)));if(!i)continue;let s=i[0];for(let e=1;e<i.length;e++)DT(i[e].rect,r)<DT(s.rect,r)&&(s=i[e]);let c=OT(s.rect,r),l={literal:Rw(o,r),inputAt:RT(c),matches:i.length},u=nT(e.sheet,c,`row`)??nT(e.sheet,c,`column`);u&&Object.assign(l,{label:u.text,labelAt:RT(u.coords)}),n.add(ST.LiteralMatchesInput,l,t.coords,Math.round(n.weightOf(ST.LiteralMatchesInput)/i.length*1e3)/1e3)}}}function AT(e){return e.type===`number`?{kind:`number`,value:String(Math.abs(Gw(e)))}:e.type===`string`?{kind:`string`,value:String(e.value)}:e.type===`boolean`?{kind:`boolean`,value:e.value?`TRUE`:`FALSE`}:null}function jT(e){if(e.type===`number`)return`#`;if(e.type===`cell`||e.type===`named`||e.type===`externalReference`)return`R`;let t=e.inputs??[];if(e.type===`infix`&&e.value===`:`&&t.length===2)return`R`;if(e.type===`prefix`&&t.length===1&&(e.value===`-`||e.value===`+`))return jT(t[0]);let n=e.type===`function`?Fw(e):`${e.type}${e.value??``}`;return t.length===0?`${n}`:`${n}(${t.map(jT).join(`,`)})`}function MT(e){let t=[],n=(e,r)=>{let i=e.inputs??[];return e.type===`paren`&&i.length===1?n(i[0],r):e.type!==`prefix`||i.length!==1||e.value!==`-`&&e.value!==`+`?e.type!==`infix`||i.length!==2||e.value!==`+`&&e.value!==`-`?void t.push({shape:jT(e),sign:r*PT(e)}):(n(i[0],r),void n(i[1],e.value===`-`?NT(r):r)):n(i[0],e.value===`-`?NT(r):r)};return n(e,1),t}var NT=e=>e===1?-1:1;function PT(e){let t=e.inputs??[];return e.type===`paren`&&t.length===1?PT(t[0]):e.type!==`prefix`||t.length!==1||e.value!==`-`&&e.value!==`+`?e.type!==`infix`||t.length!==2||e.value!==`*`&&e.value!==`/`?1:PT(t[0])*PT(t[1]):e.value===`-`?NT(PT(t[0])):PT(t[0])}function FT(e,t){let n=e=>Number.isInteger(e)&&Math.abs(e)<=10,r=e=>CT.has(Math.abs(e));return r(e)&&(r(t)||n(t))||r(t)&&n(e)}function IT(e,t,n){let r=new Map;for(let n=0;n<t.length;n++){let i=Aw(e.sheet,t[n]);if(!i)continue;let a=ET(i).map(e=>Gw(e));if(a.length===0)continue;let o=jT(i),s=r.get(o);s||r.set(o,s=[]),s.push({region:t[n],literals:a})}for(let e of r.values()){if(e.length<2)continue;let t=e[0].literals.length;for(let r=0;r<t;r++){let t=new Map;for(let n of e){let e=n.literals[r],i=t.get(e);i?i.count++:t.set(e,{count:1,first:n.region})}if(t.size<2)continue;let i=[...t.entries()].sort((e,t)=>t[1].count-e[1].count);if(!(t.size>2&&i[0][1].count===i[1][1].count))for(let a of e){let e=a.literals[r],[o,s]=i[0][0]===e?i[1]:i[0];if(!FT(e,o))continue;let c=t.get(e).count;n.add(ST.TwinBlockDivergence,{part:`literal`,literal:String(e),expected:String(o),twins:s.count,twinAt:RT(Iw(s.first))},a.region.coords,Math.round(n.weightOf(ST.TwinBlockDivergence)*s.count/(s.count+c)*1e3)/1e3)}}}(function(e,t,n){let r=new Map;for(let n=0;n<t.length;n++){let i=Aw(e.sheet,t[n]);if(!i)continue;let a=MT(i),o=a.map(e=>e.shape).join(`\0`),s=r.get(o);s||r.set(o,s=[]),s.push({region:t[n],signs:a.map(e=>e.sign)})}for(let[e,t]of r){if(t.length<2)continue;let r=(e.match(/R/g)??[]).length,i=t[0].signs.length;for(let e=0;e<i;e++){let a=t.filter(t=>t.signs[e]<0);if(a.length===0||a.length===t.length)continue;let o=t.filter(t=>t.signs[e]>0);for(let[t,s,c]of[[a,o,`negative`],[o,a,`positive`]])for(let a of t)n.add(ST.TwinBlockDivergence,{part:`sign`,term:e+1,terms:i,references:r,sign:c,twins:s.length,twinAt:RT(Iw(s[0].region))},a.region.coords,Math.round(LT*n.weightOf(ST.TwinBlockDivergence)*s.length/(s.length+t.length)*1e3)/1e3)}}})(e,t,n)}var LT=.5,RT=e=>`R${e.rowIndex+1}C${e.colIndex+1}`,zT=(e,t)=>{let n={rowStart:Math.max(e.rowStart,t.rowStart),rowEnd:Math.min(e.rowEnd,t.rowEnd),colStart:Math.max(e.colStart,t.colStart),colEnd:Math.min(e.colEnd,t.colEnd)};return n.rowStart<=n.rowEnd&&n.colStart<=n.colEnd?n:null},BT=$.ErrorCheck;function VT(e,t){let n=function(e){let t=[],n=ve(),r=e.roles.search(e.bounds);for(let i=0;i<r.length;i++){if(r[i].value!==$.Role.Label&&r[i].value!==$.Role.Input)continue;let a=e.kinds.search(r[i]);for(let o=0;o<a.length;o++){if(a[o].value!==fT)continue;let s=UT(r[i],a[o]);if(s)for(let r of e.sheet.getRange(s).getRegions(Qh.Feature.NumberFormat)){let i=r.getCell().getStyle(!0).getNumberFormat();if(!i||!0!==n.getFormatInfo(i)?.isPercent)continue;let a=e.sheet.getRange(r.getCoords()).getStats().getSortedNumbers().getValues();a.length>0&&t.push({rect:r.getCoords(),values:a})}}}return t}(e),r=[];for(let e of n)for(let t of e.values)t!==0&&r.push(Math.abs(t));if(r.length<3)return;r.sort((e,t)=>e-t);let i=r[r.length>>1];if(i!==0)for(let a of n){let n=e.sheet.getRange(a.rect).getStats().getFrequencies();for(let[o,s]of n.getValueCounts()){if(typeof o!=`number`||o===0)continue;let c=10**Math.round(Math.log10(Math.abs(o)/i));if(c<100)continue;let l=t.weightOf(BT.ScaleOutlier),u={format:`percent`,times:c,typical:Number(i.toPrecision(3)),of:r.length};for(let r of HT(e,a.rect,o,n.getExtent(o),s))t.add(BT.ScaleOutlier,u,r,Math.round(1e3*l)/1e3)}}}function HT(e,t,n,r,i){if(!r||i===0)return[];if((r.rowEnd-r.rowStart+1)*(r.colEnd-r.colStart+1)===i)return[r];let a=r.rowEnd-r.rowStart>=r.colEnd-r.colStart,o=a?r.rowStart+r.rowEnd>>1:r.colStart+r.colEnd>>1,s=a?[{...r,rowEnd:o},{...r,rowStart:o+1}]:[{...r,colEnd:o},{...r,colStart:o+1}],c=[];for(let t of s){let r=e.sheet.getRange(t).getStats().getFrequencies();c.push(...HT(e,t,n,r.getExtent(n),r.getFrequency(n)))}return c}var UT=(e,t)=>{let n={rowStart:Math.max(e.rowStart,t.rowStart),rowEnd:Math.min(e.rowEnd,t.rowEnd),colStart:Math.max(e.colStart,t.colStart),colEnd:Math.min(e.colEnd,t.colEnd)};return n.rowStart<=n.rowEnd&&n.colStart<=n.colEnd?n:null},WT=$.ErrorCheck,GT=e=>`R${e.rowIndex+1}C${e.colIndex+1}`,KT=e=>(e.rowEnd-e.rowStart+1)*(e.colEnd-e.colStart+1);function qT(e,t){let n=KT(t);if(n<3||n>64||t.rowStart!==t.rowEnd&&t.colStart!==t.colEnd)return!1;let r=e.sheet.getRange(t).getValues().flat();if(r.length!==n||r.some(e=>typeof e!=`number`))return!1;let i=r,a=i[1]-i[0];for(let e=2;e<i.length;e++)if(Math.abs(i[e]-i[e-1]-a)>1e-9*Math.max(1,Math.abs(a)))return!1;return!0}function JT(e){let t=[...e].sort((e,t)=>e[0]-t[0]),n=[];for(let e=0;e<t.length;e++){let r=n[n.length-1];r&&t[e][0]<=r[1]+1?r[1]=Math.max(r[1],t[e][1]):n.push([t[e][0],t[e][1]])}return n}function YT(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r][0];for(let a=0;a<t.length&&i<=e[r][1];a++){let o=t[a];o[1]<i||o[0]>e[r][1]||(o[0]>i&&n.push([i,o[0]-1]),i=Math.max(i,o[1]+1))}i<=e[r][1]&&n.push([i,e[r][1]])}return n}var XT=(e,t)=>e.filter(e=>e[1]>=t).map(e=>[Math.max(e[0],t),e[1]]),ZT=e=>e.reduce((e,t)=>e+t[1]-t[0]+1,0);function QT(e,t,n){let r=e.sheet.getRange({rowStart:t,rowEnd:t,colStart:n,colEnd:n}).getCell();if(r.getType()!==U.String)return null;let i=r.getText({hideStringPrefix:!0});return i?{text:i,address:r.getAddress(),coords:{rowIndex:t,colIndex:n}}:null}function $T(e,t,n){let r=e.bounds,i=QE(e.contentful.search(r),r);if(i.length===0)return;let a=new Map;for(let e=0;e<i.length;e++){let t=i[e];for(let e=t.rowStart;e<=t.rowEnd;e++){let n=a.get(e);n||a.set(e,n=[]),n.push([t.colStart,t.colEnd])}}let o=[...a.keys()].sort((e,t)=>e-t);for(let[e,t]of a)a.set(e,JT(t));let s=n.weightOf(WT.RowGap),c=new Map,l=n=>{let r=c.get(n);return r===void 0&&(r=function(e,t,n,r){let i={rowStart:n,rowEnd:n,colStart:r,colEnd:r},a=e.contentStyles.search(i),o=a.length>0?a[0].value?.getPropertiesAt(n,r,null)??null:null;return t.keyOf(o,`font`)}(e,t,n,a.get(n)[0][0]),c.set(n,r)),r},u=new Map,d=t=>{let n=u.get(t);return n===void 0&&(n=function(e,t,n){let r=n[0][0],i=XT(n,r+1);if(ZT(i)<2)return!1;for(let n=0;n<i.length;n++){let r={rowStart:t,rowEnd:t,colStart:i[n][0],colEnd:i[n][1]};if(e.formulas.search(r).length>0)return!1;let a=e.kinds.search(r);for(let t=0;t<a.length;t++){let n=a[t].value;if(n!==mT&&n!==pT&&(n!==fT||i.length!==1||!qT(e,r)))return!1}}return!0}(e,t,a.get(t)),u.set(t,n)),n},f=[];for(let e=0;e<o.length;e++){let t=f[f.length-1];t&&o[e]-t[t.length-1]<=2?t.push(o[e]):f.push([o[e]])}for(let t of f)for(let r=0;r<t.length;r++){let i=t[r],c=a.get(i),u=c[0][0],f=QT(e,i,u);if(!f)continue;let p=[];for(let e=0;e<t.length;e++)e!==r&&(p=JT([...p,...XT(a.get(t[e]),u+1)]));let m=-1;for(let e=o.indexOf(i)-1;e>=0;e--)if(d(o[e])){m=o[e];break}if(m<0)continue;let h=XT(a.get(m),u+1),g=JT([...p,...h]);if(g.length===0)continue;let _=YT(g,c);if(_.length===0)continue;let v=ZT(g),y=ZT(_),b=y===v?`row`:`cells`,x=r>0?t[r-1]:null,S=r<t.length-1?t[r+1]:null,C=l(i),w=!(x!==null&&C===l(x)||S!==null&&C===l(S)||x===null&&S===null),T={label:f.text,labelAt:GT(f.coords),missing:y,of:v,kind:b},E=x===null?null:QT(e,x,a.get(x)[0][0]),D=S===null?null:QT(e,S,a.get(S)[0][0]);E&&Object.assign(T,{above:E.text,aboveAt:GT(E.coords)}),D&&Object.assign(T,{below:D.text,belowAt:GT(D.coords)}),w&&(T.labelFont=`own`);for(let t=0;t<_.length;t++){let r=_[t],a=p.some(e=>e[0]<=r[0]&&r[0]<=e[1]),o={...T};if(!a&&m>=0){let t=QT(e,m,r[0]),n=e.sheet.getRange({rowStart:m,rowEnd:m,colStart:r[0],colEnd:r[0]}).getCell();Object.assign(o,{header:t?t.text:n.getText(),headerAt:GT({rowIndex:m,colIndex:r[0]})})}let c=Math.round(s*(b===`row`?.5:1)*(w?1/3:1)*(a?1:2/3)*1e3)/1e3;n.add(WT.RowGap,o,{rowStart:i,rowEnd:i,colStart:r[0],colEnd:r[1]},c)}}}var eE=$.ErrorCheck,tE=[eE.InconsistentFormula,eE.OmittedCells,eE.NumberAsText,eE.EmptyCellReference,eE.UnlockedFormula,eE.HardcodeInRun,eE.StyleBreak,eE.StyleRole,eE.RepeatedReference,eE.DegenerateCall,eE.SumIncludesSubtotal,eE.MisalignedReference,eE.ApproximateMatch,eE.LookupShape,eE.ExternalReference,eE.ErrorConstant,eE.LinkLabelMismatch,eE.KeyLabelMismatch,eE.SignVsSiblings,eE.LiteralMatchesInput,eE.TwinBlockDivergence,eE.ScaleOutlier,eE.UnreferencedInput,eE.RowGap,eE.ConstantFrequency],nE=new Map(tE.map((e,t)=>[e,t])),rE={[eE.OmittedCells]:.8,[eE.EmptyCellReference]:.6,[eE.NumberAsText]:.05,[eE.UnlockedFormula]:.1,[eE.RepeatedReference]:1,[eE.LookupShape]:1,[eE.ApproximateMatch]:.9,[eE.ExternalReference]:.9,[eE.ErrorConstant]:.9,[eE.DegenerateCall]:.8,[eE.KeyLabelMismatch]:.4,[eE.SumIncludesSubtotal]:.6,[eE.MisalignedReference]:.8,[eE.LinkLabelMismatch]:.4,[eE.SignVsSiblings]:.1,[eE.LiteralMatchesInput]:.8,[eE.TwinBlockDivergence]:.8,[eE.ScaleOutlier]:.8,[eE.UnreferencedInput]:.5,[eE.RowGap]:.6,[eE.ConstantFrequency]:.1},iE=new Set([eE.InconsistentFormula,eE.HardcodeInRun,eE.StyleBreak,eE.StyleRole,eE.ConstantFrequency]),aE={entries:[],repeats:new Map};function oE(e){if(!e.bounds)return aE;let t=new lE,n=dE(e),r=new vE(e.styles);return function(e,t){for(let n of e){if(!n.regions||!n.finding)continue;let r=e.filter(e=>e!==n&&!mE(n.name,e.name)),i=r.reduce((e,t)=>e+fE[t.name],0);FE(n,(e,a,o,s,c)=>{let l=a?{rowStart:o.from,rowEnd:o.to,colStart:e.coords.colStart,colEnd:e.coords.colEnd}:{rowStart:e.coords.rowStart,rowEnd:e.coords.rowEnd,colStart:o.from,colEnd:o.to},u=[],d=0;for(let e of r)zE(e.index,l,a)&&(u.push(e.name),d+=fE[e.name]);let f=i>0?d/i:0,p=fE[n.name]*(1/s)*(c/Math.max(ME,s))*(1-f),{check:m,evidence:h}=n.finding(e.key,o.key,{axis:a?`row`:`column`,thickness:s,flanks:c,corroborated:u});t.add(m,h,l,Math.round(1e3*p)/1e3)})}}(function(e,t,n){let r=e.bounds,i=QE(e.contentful.search(r),r),a=t.map(e=>({coords:e.coords,key:e.r1c1})),o=e=>({axis:e.axis,thickness:e.thickness,flanks:e.flanks,corroborated:e.corroborated}),s=new fc;s.load(i.map(e=>({...e,value:_E})));let c=QE(e.formulas.search(r),r);c.length>0&&s.insertAllNonOverlapping(c.map(e=>({...e,value:gE})));let l=(e,t)=>{let a=SE(i,t,r,t=>n.keyOf(t,e));return{name:e,index:a,regions:CE(a),finding:(t,n,r)=>({check:eE.StyleBreak,evidence:{layer:e,axis:r.axis,expected:n,actual:t,thickness:r.thickness,flanks:r.flanks,corroborated:r.corroborated}})}};return[{name:`formulaShape`,index:wE(a),regions:a,finding:(e,t,n)=>({check:eE.InconsistentFormula,evidence:{...o(n),expected:t}})},{name:`hasFormula`,index:s,regions:CE(s),fires:e=>e===_E,finding:(e,t,n)=>({check:eE.HardcodeInRun,evidence:{...o(n),expected:t}})},{name:`kind`,index:e.kinds},l(`font`,e.contentStyles),l(`fill`,e.fillStyles),l(`numberFormat`,e.contentStyles),l(`alignment`,e.contentStyles)]}(e,n,r),t),function(e,t,n){let r=e.roles.search(e.bounds);if(r.length===0)return;let i=AE(e,t),a=jE(r,i),o=new Set(e.workbookRoleColors());for(let e of a.values())o.add(e.color);for(let t=0;t<r.length;t++){let s=r[t].value,c=TE.has(s)?a.get(s):void 0;if(!c||s===$.Role.Input&&!DE(e.sheet,r[t]))continue;let l=i.search(r[t]);for(let e=0;e<l.length;e++){let i=l[e].value;if(i===c.color||!o.has(i))continue;let a=ZE(l[e],r[t]);if(!a)continue;let u=Math.round((EE[s]??0)*(c.majority/c.of)*1e3)/1e3;n.add(eE.StyleRole,{part:`fontColor`,role:s,expected:c.color,actual:i,majority:c.majority,of:c.of},a,u)}}}(e,r,t),function(e,t,n){for(let r=0;r<t.length;r++){let i=t[r],a=i.coords,o=[a.rowStart,a.rowEnd],s=[a.colStart,a.colEnd],c=VE(e.sheet,i);for(let t=0;t<c.length;t++){let r=c[t],i=JE(r,a);WE(e,a,r,o,s,i,n),GE(e,r,o,s,i,n)}}}(e,n,t),function(e,t){let n=[],r=e.kinds.search(e.bounds);for(let e=0;e<r.length;e++)r[e].value===hT&&n.push($E(r[e]));if(n.length===0)return;let i=[];for(let t=0;t<n.length;t++)i.push(...e.formulas.search(n[t]));let a=KE(n,i);for(let e=0;e<a.length;e++)t.add(eE.NumberAsText,{},a[e])}(e,t),function(e,t){if(e.isProtected)return;let n=e.sheet.getRange(e.bounds);for(let e of n.getRegions([Qh.Feature.Formula,Qh.Feature.Protection])){let n=e.getCell();n.getFormulaText()!==null&&n.getProtection().isAlwaysUnlocked()&&t.add(eE.UnlockedFormula,{},e.getCoords())}}(e,t),function(e,t,n){let r=Yw(e);for(let i=0;i<t.length;i++){let a=t[i],o=Aw(e.sheet,a);if(!o)continue;let s=Iw(a);for(let e of Tw(o))for(let t=0;t<e.length;t++)for(let i=t+1;i<e.length;i++){if(e[t].sign!==e[i].sign)continue;let o=Lw(a,n=>$w(e[t].node,e[i].node,n,r));if(!o)continue;let[c,l]=eT(e[i].node,s,r)<=eT(e[t].node,s,r)?[e[i].node,e[t].node]:[e[t].node,e[i].node],u=Rw(c,s),d=Rw(l,s);n.add(lw.RepeatedReference,d===u?{reference:u}:{reference:u,overlaps:d},o)}}}(e,n,t),function(e,t,n){for(let r=0;r<t.length;r++){let i=t[r],a=Aw(e.sheet,i);if(!a)continue;let o=Iw(i);for(let e of Ow(a)){if(e.type!==`function`)continue;let t=Fw(e),r=e.inputs??[];r.length===1&&uw.has(t)&&Uw(r[0])?n.add(lw.DegenerateCall,{function:t,reference:Rw(r[0],o)},i.coords):r.length>0&&dw.has(t)&&r.every(e=>typeof Gw(e)==`number`)&&n.add(lw.DegenerateCall,{function:t,literals:r.map(e=>Rw(e,o)).join(`, `)},i.coords)}}}(e,n,t),function(e,t,n){let r=Nw(e,t);for(let i=0;i<t.length;i++){let a=t[i],o=Aw(e.sheet,a);if(!o)continue;let s=Iw(a);for(let e of Tw(o)){let t=e.filter(e=>e.sign>0&&e.node.type!==`named`);if(t.length!==0&&(t.length!==1||Vw(t[0].node)))for(let e=0;e<t.length;e++){let i=t[e].node,o=e=>fw(r,i,t,e),c=o(s);if(!c)continue;let l=Lw(a,e=>o(e)?.kind===c.kind);n.add(lw.SumIncludesSubtotal,{reference:Rw(i,s),[c.kind]:c.at},l)}}}}(e,n,t),function(e,t,n){let r=Yw(e),i=new yw(e);for(let a=0;a<t.length;a++){let o=t[a],s=o.coords,c=Aw(e.sheet,o);if(!c)continue;let l=Iw(o),u=Tw(c).filter(e=>e.length>1);if(u.length!==0)for(let e of[!0,!1]){if(e?s.rowStart!==s.rowEnd:s.colStart!==s.colEnd)continue;let t=i.around(e,e?s.colStart:s.rowStart,e?s.colEnd:s.rowEnd,e?s.rowStart:s.colStart);if(!t)continue;let a=e?s.rowStart:s.colStart;if(a!==t[0]&&a!==t[1])continue;let c=!1;for(let a of u){let s=a.filter(e=>e.node.type!==`named`),u=(n,i)=>{let a=Xw(i.node,n,r);return a!==null&&a.sheet===r&&mw(a.rect,n,e,t)},d=new Set(s.filter(e=>u(l,e)).map(e=>e.sign));if(d.size!==0)for(let a of s){if(!d.has(a.sign))continue;let s=Xw(a.node,l,r);if(!s||s.sheet!==r||hw(s.rect,e,t))continue;let u=_w(i,a.node,s.rect,l,e,t),f=Lw(o,n=>{let o=Xw(a.node,n,r);return o!==null&&!hw(o.rect,e,t)&&_w(i,a.node,o.rect,n,e,t).targetRole===u.targetRole});f&&(n.add(lw.MisalignedReference,u,f,n.weightOf(lw.MisalignedReference)*pw[u.targetRole]),c=!0)}}if(c)break}}}(e,n,t),function(e,t,n){for(let r=0;r<t.length;r++){let i=t[r],a=Aw(e.sheet,i);if(a)for(let e of Ow(a)){if(e.type!==`function`)continue;let t=Fw(e),r=e.inputs??[],a=null;if(t===`MATCH`)a=r.length<3?`omitted`:Cw(r[2]);else if(t===`VLOOKUP`||t===`HLOOKUP`)a=r.length<4?`omitted`:Cw(r[3])===null?null:`TRUE`;else if(t===`XMATCH`||t===`XLOOKUP`){let e=t===`XMATCH`?r[2]:r[4],n=e?Cw(e):null;a=n!==null&&Math.abs(Gw(e))===1?n:null}a!==null&&n.add(lw.ApproximateMatch,{function:t,matchType:a},i.coords)}}}(e,n,t),function(e,t,n){let r=Yw(e);for(let i=0;i<t.length;i++){let a=t[i],o=Aw(e.sheet,a);if(!o)continue;let s=Iw(a);for(let e of Ow(o)){if(e.type!==`function`)continue;let t=Fw(e),i=e.inputs??[],o=[];if(t===`INDEX`&&i.length>=2&&Hw(i[0]))for(let e=1;e<i.length&&e<3;e++){let t=Ww(i[e]);if(t.type!==`function`)continue;let n=Fw(t);(n===`MATCH`||n===`XMATCH`)&&t.inputs&&t.inputs.length>=2&&Hw(t.inputs[1])&&o.push([i[0],t.inputs[1]])}else t===`XLOOKUP`&&i.length>=3&&Hw(i[1])&&Hw(i[2])&&o.push([i[2],i[1]]);for(let[e,t]of o){let i=Lw(a,n=>ww(e,t,n,r));i&&n.add(lw.LookupShape,{array:Rw(e,s),vector:Rw(t,s)},i)}}}}(e,n,t),function(e,t,n){for(let r=0;r<t.length;r++){let i=t[r],a=Aw(e.sheet,i);if(!a)continue;let o=Iw(i),s=[a];for(;s.length>0;){let e=s.pop(),t=Vw(e)?Jw(e.inputs[0]):e.type===`cell`?Jw(e):null;if(t&&t.startsWith(`[`)||e.type===`externalReference`)n.add(lw.ExternalReference,{kind:`workbook`,reference:Rw(e,o)},i.coords);else if(t&&t.includes(`#REF!`)||e.type===`error`&&Rw(e,o)===`#REF!`)n.add(lw.ExternalReference,{kind:`deleted`,reference:`#REF!`},i.coords);else if(e.type===`function`&&String(e.value).toUpperCase().startsWith(`_XLUDF.`)&&n.add(lw.ExternalReference,{kind:`udf`,function:String(e.value).slice(7)},i.coords),e.inputs)for(let t=0;t<e.inputs.length;t++)s.push(e.inputs[t])}}}(e,n,t),function(e,t,n){let r=[],i=[];for(let n=0;n<t.length;n++){let a=t[n],o=Aw(e.sheet,a);if(!o)continue;let s=Ww(o),c=Iw(a);if(s.type===`error`)r.push({region:a,error:Rw(s,c)});else if(s.type===`function`&&Fw(s)===`TABLE`){let e=Gw(s.inputs?.[2]??s),t=Gw(s.inputs?.[3]??s);if(!(e>0&&t>0))continue;i.push({at:c,spill:{rowStart:c.rowIndex,rowEnd:c.rowIndex+Math.trunc(e)-1,colStart:c.colIndex,colEnd:c.colIndex+Math.trunc(t)-1}})}}if(r.length===0)return;let a=e=>i.findIndex(({at:t})=>{let n=e.rowStart-t.rowIndex,r=e.colStart-t.colIndex;return n>=0&&n<=1&&r>=0&&r<=1&&n+r>0}),o=new Map;for(let{region:e}of r){let t=a(e.coords);if(t<0)continue;let n=o.get(t)??i[t].spill,r=e.coords;o.set(t,{rowStart:Math.min(n.rowStart,r.rowStart),rowEnd:Math.max(n.rowEnd,r.rowEnd),colStart:Math.min(n.colStart,r.colStart),colEnd:Math.max(n.colEnd,r.colEnd)})}let s=(e,t)=>`R${e+1}C${t+1}`;for(let{region:e,error:t}of r){let r=a(e.coords),c=r>=0?o.get(r):null,l=r>=0?i[r].spill:null,u=c&&l&&(c.rowEnd>l.rowEnd||c.colEnd>l.colEnd);n.add(lw.ErrorConstant,u?{error:t,dataTable:s(i[r].at.rowIndex,i[r].at.colIndex),extent:`${s(c.rowStart,c.colStart)}:${s(c.rowEnd,c.colEnd)}`}:{error:t},e.coords)}}(e,n,t),function(e,t,n){let r=Nw(e,t),i=uT(r);for(let a=0;a<t.length;a++){let o=t[a],s=Aw(e.sheet,o),c=s?oT(s):null,l=c?.reference.value?.scope;if(!c||!l||l.toLowerCase()===r.own)continue;let u=r.sheetOf(l.toLowerCase());if(!u)continue;let d=t=>{let n=Xw(c.reference,t,r.own);if(!n)return null;let a={rowIndex:n.rect.rowStart,colIndex:n.rect.colStart},o=i.label(e.sheet,t,`row`),s=i.label(u,a,`row`);return o&&s&&rT(o.text)!==rT(s.text)?{label:o.text,labelAt:sT(o.coords,null),target:s.text,targetAt:sT(s.coords,u)}:null},f=d(Iw(o));f&&n.add(aT.LinkLabelMismatch,f,Lw(o,e=>d(e)!==null))}}(e,n,t),function(e,t,n){let r=uT(Nw(e,t));for(let i=0;i<t.length;i++){let a=t[i],o=Aw(e.sheet,a);if(o)for(let t of Ow(o)){if(t.type!==`function`||!dT.has(Fw(t)))continue;let i=t.inputs?.[0]?Ww(t.inputs[0]):null;if(i?.type!==`string`)continue;let o=String(i.value),s=n=>{let i=r.label(e.sheet,n,`row`),a=r.label(e.sheet,n,`column`);if(!i&&!a)return null;let s=rT(o);if(i&&rT(i.text)===s||a&&rT(a.text)===s)return null;let c={function:Fw(t),key:o};return i&&Object.assign(c,{rowLabel:i.text,rowLabelAt:sT(i.coords,null)}),a&&Object.assign(c,{columnLabel:a.text,columnLabelAt:sT(a.coords,null)}),c},c=s(Iw(a));c&&n.add(aT.KeyLabelMismatch,c,Lw(a,e=>s(e)!==null))}}}(e,n,t),function(e,t,n){let r=Nw(e,t),i=new Map;for(let n=0;n<t.length;n++){let a=t[n],o=Aw(e.sheet,a),s=o?oT(o):null;if(!s)continue;let c=Xw(s.reference,Iw(a),r.own);if(!c)continue;let l=`${c.sheet}\0${c.rect.rowStart}`,u=i.get(l);u||i.set(l,u=[]),u.push({region:a,sign:s.sign,reference:s.reference})}for(let e of i.values()){if(e.length<3)continue;let t=e.filter(e=>e.sign<0),r=t.length===1?t:t.length===e.length-1?e.filter(e=>e.sign>0):[];if(r.length!==1)continue;let{region:i,sign:a,reference:o}=r[0],s=Iw(i),c=e.find(e=>e!==r[0]);n.add(aT.SignVsSiblings,{reference:Rw(o,s),sign:a<0?`negative`:`positive`,siblings:e.length-1,siblingAt:sT(Iw(c.region),null)},i.coords)}}(e,n,t),kT(e,n,t),IT(e,n,t),VT(e,t),function(e,t){let n=e.bounds,r=e.roles.search(n);if(r.length===0)return;let i=[],a=[];for(let t=0;t<r.length;t++){let n=r[t];if(n.value===$.Role.Input){a.push(n);continue}if(n.value!==$.Role.Label)continue;let o=e.kinds.search(n);for(let e=0;e<o.length;e++){if(o[e].value!==fT&&o[e].value!==pT)continue;let t=ZE(n,o[e]);t&&i.push(t)}}if(i.length===0)return;let o=QE(e.workbookReads().search(n),n),s=o.length>0?KE(i,o):i;if(s.length===0)return;let c=new fc,l=[...o,...a].map(e=>({...e,value:!0}));l.length>0&&c.insertAllNonOverlapping(l);let u=t=>{let n=c.search(t);for(let r=0;r<n.length;r++){let i=ZE(n[r],t);if(!i)continue;let a=e.kinds.search(i);for(let e=0;e<a.length;e++)if(a[e].value===fT||a[e].value===pT)return!0}return!1},d=t.weightOf(WT.UnreferencedInput),f=new fc;for(let r of[`row`,`column`]){let i=r===`row`,a=new Map;for(let e=0;e<s.length;e++){let t=s[e],n=i?[]:KE([t],f.search(t)),r=i?[t]:n;for(let e=0;e<r.length;e++){let t=r[e],n=i?t.rowStart:t.colStart,o=i?t.rowEnd:t.colEnd;for(let e=n;e<=o;e++){let n=i?{rowStart:e,rowEnd:e,colStart:t.colStart,colEnd:t.colEnd}:{rowStart:t.rowStart,rowEnd:t.rowEnd,colStart:e,colEnd:e},r=a.get(e);r||a.set(e,r=[]),r.push(n)}}}for(let[o,s]of a){s.sort((e,t)=>i?e.colStart-t.colStart:e.rowStart-t.rowStart);let a=[];for(let e=0;e<s.length;e++){let t=a[a.length-1],n=s[e];t&&(i?n.colStart<=t.colEnd+1:n.rowStart<=t.rowEnd+1)?a[a.length-1]=i?{...t,colEnd:Math.max(t.colEnd,n.colEnd)}:{...t,rowEnd:Math.max(t.rowEnd,n.rowEnd)}:a.push({...n})}let c=i?{rowStart:o,rowEnd:o,colStart:n.colStart,colEnd:n.colEnd}:{rowStart:n.rowStart,rowEnd:n.rowEnd,colStart:o,colEnd:o},l={rowIndex:a[0].rowStart,colIndex:a[0].colStart},p=nT(e.sheet,l,r);if(!p||(f.insertAllNonOverlapping(a.map(e=>({...e,value:!0}))),u(c)))continue;let m=a.reduce((e,t)=>e+KT(t),0);if(a.length===1&&qT(e,a[0]))continue;let h={label:p.text,labelAt:GT(p.coords),cells:m};m===1&&(h.value=e.sheet.getRange(a[0]).getCell().getText());let g=Math.round(d/m*1e3)/1e3;for(let e=0;e<a.length;e++)t.add(WT.UnreferencedInput,h,a[e],g)}}}(e,t),$T(e,r,t),function(e,t,n){for(let r=0;r<t.length;r++){let i=Aw(e.sheet,t[r]);if(!i)continue;let a=new Set;for(let e of Ow(i)){let i=AT(e);if(!i)continue;let o=`${i.kind}\0${i.value}`;a.has(o)||(a.add(o),n.add(ST.ConstantFrequency,i,t[r].coords))}}}(e,n,t),t.result()}function sE(e,t,n){let r=new fc;if(e.entries.length===0)return r;let i=new Map,a=function(e){let t=`${eE.ConstantFrequency}\0`,n=0;for(let[r,i]of e)r.startsWith(t)&&(n+=i);return n}(t),o=n=>{let r=e.repeats.get(n);if(!r)return n;let o=i.get(n);if(!o){let e=t.get(r.key)??r.count;if(n.check===eE.ConstantFrequency){let t=Math.max(a,e),r=n.rank/e*(t/(t+cE));o=Object.freeze({...n,evidence:Object.freeze({...n.evidence,uses:e,of:t}),rank:Math.round(1e3*r)/1e3})}else o=e>1?Object.freeze({...n,rank:Math.round(n.rank/e*1e3)/1e3}):n;i.set(n,o)}return o},s=new uE;return r.insertAllNonOverlapping(e.entries.map(e=>({...e,value:s.of([o(e.value)])})),{onIntersect:(e,t)=>({...t,value:s.of([...e.value??[],...t.value])})}),function(e,t,n){let r=t.getMap();if(!r||e.isEmpty())return;let i=r.all();for(let t=0;t<i.length;t++){let r=i[t].value;e.search(i[t]).length!==0&&e.insertNonOverlapping({...$E(i[t]),value:[]},{onIntersect:(e,t)=>{if(!e.value)return null;let i=e.value.filter(e=>!r.includes(e.check));return i.length>0?{...t,value:n.of(i)}:null}})}}(r,n,s),r}var cE=10,lE=class{constructor(){this._groups=new Map}weightOf(e){return rE[e]??0}add(e,t,r,i=rE[e]??0){if(r.rowStart>r.rowEnd||r.colStart>r.colEnd)return;let a=`${e}\0${n.JSONStableStringify(t)}`,o=this._groups.get(a);o||(o={anomaly:Object.freeze({check:e,evidence:Object.freeze({...t}),rank:i}),rects:[]},this._groups.set(a,o)),o.rects.push(r)}result(){let e=[],t=new Map;for(let[n,{anomaly:r,rects:i}]of this._groups){let a=new fc;a.insertAllNonOverlapping(i.map(e=>({...e,value:!0})));let o=xc(a.all().map($E),B.Axis.Column,2**53-1);for(let t=0;t<o.length;t++)e.push({...o[t],value:r});iE.has(r.check)&&t.set(r,{key:n,count:o.length})}return{entries:e,repeats:t}}},uE=class{constructor(){this._sets=new Map,this._keys=new Map}of(e){let t=[...new Set(e)];t.sort((e,t)=>t.rank-e.rank||(nE.get(e.check)??0)-(nE.get(t.check)??0)||(this._keyOf(e)<this._keyOf(t)?-1:1));let n=t.map(e=>this._keyOf(e)).join(``),r=this._sets.get(n);return r||(r=Object.freeze(t),this._sets.set(n,r)),r}_keyOf(e){let t=this._keys.get(e);return t===void 0&&(t=`${e.check}\0${n.JSONStableStringify(e.evidence)}`,this._keys.set(e,t)),t}};function dE(e){let t=[],n=e.sheet.getRange(e.bounds);for(let e of n.getRegions(Qh.Feature.Formula)){let n=e.getCell().getFormulaText({r1c1:!0});n!==null&&t.push({coords:e.getCoords(),r1c1:n})}return t}var fE={formulaShape:1,hasFormula:.4,kind:.6,font:.3,numberFormat:.5,fill:.1,alignment:.05},pE=[[`formulaShape`,`hasFormula`]],mE=(e,t)=>pE.some(([n,r])=>n===e&&r===t||n===t&&r===e),hE=`normal`,gE=`formula`,_E=`value`,vE=class{constructor(e){this._styles=e,this._named=new Map,this._hex=new Map,this._normal=e.getNormalRanged().getPropertiesAt(0,0,null)??null}keyOf(e,t){if(!e)return hE;let r=yE(this._normal,t),i,a=e.named;if(a&&a!==z.BuiltInName.Normal){let e=yE(this._namedProps(a),t);e==null||xE(e,r)||(i=e)}let o=yE(e,t);if(o!=null&&(i=bE(i)&&bE(o)?{...i,...o}:o,i===o&&xE(o,r)))return`authored-normal`;if(bE(i)&&`fallbacks`in i){let{fallbacks:e,...t}=i;i=Object.keys(t).length>0?t:void 0}return i===void 0?hE:n.JSONStableStringify(i)}fontColorOf(e){let t=e?.font?.color,r=e?.named;t==null&&r&&r!==z.BuiltInName.Normal&&(t=this._namedProps(r)?.font?.color),t??=this._normal?.font?.color;let i=typeof t==`string`?t:n.JSONStableStringify(t??null),a=this._hex.get(i);return a===void 0&&(a=this._toHex(t),this._hex.set(i,a)),a}_toHex(e){try{return this._styles.parseColor(e??`windowText`)?.toHex().toString(!1).toUpperCase()??String(e)}catch{return String(e)}}_namedProps(e){let t=this._named.get(e);return t===void 0&&(t=this._styles.getNamedStyles().getByName(e)?.getRanged().getPropertiesAt(0,0,null)??null,this._named.set(e,t)),t}};function yE(e,t){let n=e?.[t];if(t!==`numberFormat`||n==null)return n;let r=Ge(n);return typeof r==`number`?Ce(r)??String(r):r}var bE=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function xE(e,t){if(!bE(e)||!bE(t))return n.JSONStableStringify(e)===n.JSONStableStringify(t);for(let r of Object.keys(e))if(n.JSONStableStringify(e[r])!==n.JSONStableStringify(t[r]))return!1;return!0}function SE(e,t,n,r,i=hE){let a=new fc;if(a.load(e.map(e=>({...e,value:i}))),e.length===0)return a;let o=new Map,s=[],c=t.search(n);for(let e=0;e<c.length;e++){let t=c[e],n=t.value;if(!n)continue;let l=o.get(n);if(l===void 0&&(l=r(n.getPropertiesAt(t.rowStart,t.colStart,null)??null),o.set(n,l)),l===i)continue;let u=a.search(t);for(let e=0;e<u.length;e++){let n=ZE(u[e],t);n&&s.push({...n,value:l})}}return s.length>0&&a.insertAllNonOverlapping(s),a}function CE(e){let t=new Map;for(let n of e.all()){let e=t.get(n.value);e||t.set(n.value,e=[]),e.push($E(n))}let n=[];for(let[e,r]of t)for(let t of xc(r,B.Axis.Column,2**53-1))n.push({coords:$E(t),key:e});return n}function wE(e){let t=new fc;return t.load(e.map(e=>({...e.coords,value:e.key}))),t}var TE=new Set([$.Role.Link,$.Role.Reference,$.Role.Computed,$.Role.Input]),EE={link:.6,reference:.4,input:.3,computed:.2};function DE(e,t){let n={rowIndex:t.rowStart,colIndex:t.colStart};return nT(e,n,`row`)!==null||nT(e,n,`column`)!==null}function OE(e,t,n){let r=e.getRange({rowStart:t,rowEnd:t,colStart:n,colEnd:n}).getCell().getFormula();if(r&&!r.isCompiled()){if(e.getCalculation().getStatus()!==Q.Status.Running)return null;r=e.getCalculation().createFormula(r.getExpression(),{rowIndex:t,colIndex:n,scope:e.getName()})}let i=r?.getReferences();if(!i)return null;let a=[];for(let e=0;e<i.length;e++){let t=i.at(e),n=null;try{n=t.getWorksheet()}catch{}let r=n?t.getCoords():null;a.push({sheet:n,coords:r?$E(r):null})}return a}function kE(e,t,n){let r=Aw(e,t);if(!r)return null;for(let e of Ow(r))if(e.type===`externalReference`||e.type===`function`&&Fw(e)===`INDIRECT`)return $.Role.Link;let i=function(e){let t=Ww(e),n=!1,r=e=>Ww(e).type===`named`||Gw(e)!==void 0;for(;;){if(t.type===`cell`)return{cell:t,scaled:n};let e=t.inputs??[];if(t.type!==`prefix`||e.length!==1||t.value!==`-`&&t.value!==`+`){if(t.type!==`infix`||e.length!==2||t.value!==`*`&&t.value!==`/`||!r(e[1])){if(t.type!==`infix`||e.length!==2||t.value!==`*`||!r(e[0]))return null;t=Ww(e[1]),n=!0}else t=Ww(e[0]),n=!0}else t=Ww(e[0])}}(r);if(!i)return $.Role.Computed;let a=i.cell.value?.scope;return a&&a.toLowerCase()!==n?$.Role.Link:i.scaled?$.Role.Computed:$.Role.Reference}function AE(e,t){let n=e.bounds;return SE(QE(e.contentful.search(n),n),e.contentStyles,n,e=>t.fontColorOf(e),t.fontColorOf(null))}function jE(e,t){let n=new Map;for(let r=0;r<e.length;r++){let i=e[r],a=n.get(i.value);a||n.set(i.value,a=new Map);let o=t.search(i);for(let e=0;e<o.length;e++){let t=ZE(o[e],i);if(!t)continue;let n=o[e].value;a.set(n,(a.get(n)??0)+(t.rowEnd-t.rowStart+1)*(t.colEnd-t.colStart+1))}}let r=new Map;for(let[e,t]of n){let n=null,i=0,a=!1,o=0;for(let[e,r]of t)o+=r,r>i?(n=e,i=r,a=!1):r===i&&(a=!0);n===null||a||r.set(e,{color:n,majority:i,of:o})}return r}var ME=2;function NE(e,t,n,r,i){if(n){let n=r?t.colStart-i:t.colEnd+i;return n<0?[]:PE(e,{...t,colStart:n,colEnd:n},!0)}let a=r?t.rowStart-i:t.rowEnd+i;return a<0?[]:PE(e,{...t,rowStart:a,rowEnd:a},!1)}function PE(e,t,n){let r=e.search(t),i=Array(r.length);for(let e=0;e<r.length;e++)i[e]=n?{from:Math.max(r[e].rowStart,t.rowStart),to:Math.min(r[e].rowEnd,t.rowEnd),key:r[e].value}:{from:Math.max(r[e].colStart,t.colStart),to:Math.min(r[e].colEnd,t.colEnd),key:r[e].value};return i}function FE(e,t){let n=e.regions;if(n.length<3)return;let r=e.index;for(let i=0;i<n.length;i++){let a=n[i];if(e.fires&&!e.fires(a.key))continue;let o=a.coords;for(let e of[!0,!1]){let n=e?o.colEnd-o.colStart+1:o.rowEnd-o.rowStart+1,i=IE(NE(r,o,e,!0,1),NE(r,o,e,!1,1),a.key),s=Math.max(ME,n);for(let c=2;c<=s&&i.length>0;c++){let s=NE(r,o,e,!0,c),l=NE(r,o,e,!1,c),u=LE(LE(i,s),l);if(c===2&&n===1){let r=[...s,...l].filter(e=>e.key===a.key);for(let o of RE(RE(i,u),r))t(a,e,o,n,1)}i=u}for(let r of i)t(a,e,r,n,s)}}}function IE(e,t,n){let r=[];for(let i=0;i<e.length;i++)e[i].key!==n&&r.push(...LE([e[i]],t));return r}function LE(e,t){let n=[];for(let r=0;r<e.length;r++)for(let i=0;i<t.length;i++){if(t[i].key!==e[r].key)continue;let a=Math.max(e[r].from,t[i].from),o=Math.min(e[r].to,t[i].to);a<=o&&n.push({from:a,to:o,key:e[r].key})}return n}function RE(e,t){let n=[...t].sort((e,t)=>e.from-t.from),r=[];for(let t=0;t<e.length;t++){let i=e[t].from;for(let a=0;a<n.length&&i<=e[t].to;a++){let o=n[a];o.to<i||o.from>e[t].to||(o.from>i&&r.push({from:i,to:o.from-1,key:e[t].key}),i=Math.max(i,o.to+1))}i<=e[t].to&&r.push({from:i,to:e[t].to,key:e[t].key})}return r}function zE(e,t,n){let r=r=>n?r<0?[]:PE(e,{...t,colStart:r,colEnd:r},!0):r<0?[]:PE(e,{...t,rowStart:r,rowEnd:r},!1),i=n?t.rowStart:t.colStart,a=n?t.rowEnd:t.colEnd,o=n?t.colStart:t.rowStart,s=n?t.colEnd:t.rowEnd;return BE(r(o-1),r(o),i,a)&&BE(r(s),r(s+1),i,a)}function BE(e,t,n,r){let i=new Set([n]);for(let a of[...e,...t])a.from>n&&a.from<=r&&i.add(a.from),a.to+1>n&&a.to+1<=r&&i.add(a.to+1);let a=(e,t)=>{for(let n=0;n<e.length;n++)if(e[n].from<=t&&t<=e[n].to)return e[n].key;return null};for(let n of i)if(a(e,n)!==a(t,n))return!0;return!1}function VE(e,t){let n=t.coords,r=(t,n)=>{let r=OE(e,t,n);return r?r.map(t=>t.sheet===e&&t.coords?t.coords:HE):null},i=r(n.rowStart,n.colStart);if(!i)return[];let a=n.rowEnd>n.rowStart?r(n.rowStart+1,n.colStart):null,o=n.colEnd>n.colStart?r(n.rowStart,n.colStart+1):null,s=(e,t,n)=>e&&e.length===i.length&&e[t]!==HE&&e[t][n]===i[t][n]?0:1,c=[];for(let e=0;e<i.length;e++)i[e]!==HE&&c.push({at:i[e],rowStart:s(a,e,`rowStart`),rowEnd:s(a,e,`rowEnd`),colStart:s(o,e,`colStart`),colEnd:s(o,e,`colEnd`)});return c}var HE=Object.freeze({rowStart:-1,rowEnd:-1,colStart:-1,colEnd:-1});function UE(e,t,n,r,i){return n===0?t>=r&&t<=i?[e[0],e[1]]:[1,0]:[Math.max(e[0],e[0]+r-t),Math.min(e[1],e[0]+i-t)]}function WE(e,t,n,r,i,a,o){let s=n.at,c=s.colStart===s.colEnd&&s.rowEnd>s.rowStart&&n.colStart===n.colEnd,l=s.rowStart===s.rowEnd&&s.colEnd>s.colStart&&n.rowStart===n.rowEnd;if(!c&&!l)return;let u=c?[{base:s.rowStart,moves:n.rowStart,step:-1},{base:s.rowEnd,moves:n.rowEnd,step:1}]:[{base:s.colStart,moves:n.colStart,step:-1},{base:s.colEnd,moves:n.colEnd,step:1}],d=r[1]-r[0],f=i[1]-i[0];for(let l of u){let u=l.base+l.step;if(u<0)continue;let p=qE(e,c?{rowStart:u,rowEnd:u+l.moves*d,colStart:s.colStart,colEnd:s.colStart+n.colStart*f}:{rowStart:s.rowStart,rowEnd:s.rowStart+n.rowStart*d,colStart:u,colEnd:u+l.moves*f}),m=c?YE(u,l.moves,t)+XE(s.colStart,n.colStart,t):YE(s.rowStart,n.rowStart,t)+XE(u,l.moves,t);for(let e=0;e<p.length;e++){let t=p[e],d=c?UE(r,u,l.moves,t.rowStart,t.rowEnd):UE(r,s.rowStart,n.rowStart,t.rowStart,t.rowEnd),f=c?UE(i,s.colStart,n.colStart,t.colStart,t.colEnd):UE(i,u,l.moves,t.colStart,t.colEnd);o.add(eE.OmittedCells,{reference:a,omitted:m},{rowStart:d[0],rowEnd:d[1],colStart:f[0],colEnd:f[1]})}}}function GE(e,t,n,r,i,a){let o=t.at,s=n[1]-n[0],c=r[1]-r[0],l={rowStart:o.rowStart,rowEnd:o.rowEnd+t.rowEnd*s,colStart:o.colStart,colEnd:o.colEnd+t.colEnd*c},u=KE([l],[...e.contentful.search(l),...e.formulas.search(l)]);for(let e=0;e<u.length;e++){let s=u[e],c=UE(n,o.rowStart,t.rowStart,-1,s.rowEnd),l=UE(n,o.rowEnd,t.rowEnd,s.rowStart,2**53-1),d=UE(r,o.colStart,t.colStart,-1,s.colEnd),f=UE(r,o.colEnd,t.colEnd,s.colStart,2**53-1);a.add(eE.EmptyCellReference,{reference:i},{rowStart:Math.max(c[0],l[0]),rowEnd:Math.min(c[1],l[1]),colStart:Math.max(d[0],f[0]),colEnd:Math.min(d[1],f[1])})}}function KE(e,t){let n=new fc;n.load(e.map(e=>({...$E(e),value:!0})));for(let e=0;e<t.length;e++)n.search(t[e]).length!==0&&n.insertNonOverlapping({...$E(t[e]),value:!0},{onIntersect:()=>null});return n.all().map($E)}function qE(e,t){let n=[],r=e.kinds.search(t);for(let e=0;e<r.length;e++){if(r[e].value!==fT&&r[e].value!==pT)continue;let i=ZE(r[e],t);i&&n.push(i)}return n.length>0?KE(n,e.formulas.search(t)):n}function JE(e,t){let n=e.at,r=YE(n.rowStart,e.rowStart,t)+XE(n.colStart,e.colStart,t);return n.rowStart===n.rowEnd&&n.colStart===n.colEnd&&e.rowStart===e.rowEnd&&e.colStart===e.colEnd?r:`${r}:${YE(n.rowEnd,e.rowEnd,t)}${XE(n.colEnd,e.colEnd,t)}`}var YE=(e,t,n)=>t?e===n.rowStart?`R`:`R[${e-n.rowStart}]`:`R${e+1}`,XE=(e,t,n)=>t?e===n.colStart?`C`:`C[${e-n.colStart}]`:`C${e+1}`,ZE=(e,t)=>{let n={rowStart:Math.max(e.rowStart,t.rowStart),rowEnd:Math.min(e.rowEnd,t.rowEnd),colStart:Math.max(e.colStart,t.colStart),colEnd:Math.min(e.colEnd,t.colEnd)};return n.rowStart<=n.rowEnd&&n.colStart<=n.colEnd?n:null},QE=(e,t)=>{let n=[];for(let r=0;r<e.length;r++){let i=ZE(e[r],t);i&&n.push(i)}return n},$E=e=>({rowStart:e.rowStart,rowEnd:e.rowEnd,colStart:e.colStart,colEnd:e.colEnd}),eD=e=>{let t=e;if(t._isSettling())return null;if(t._isBlocked()){let e=t._getOwnCells();return e.length>0?{extent:e[0],cells:e,isBlocked:!0}:null}let n=t._getPlacement(),r=t._getOwnCells();return n&&r.length!==0?{extent:h.sanitizeRange(n.extent),cells:r,isBlocked:!1}:null},tD=e=>e._getPlacement()!==null,nD=(e,t)=>{let n=e.search(t);for(let e=0;e<n.length;e++)if(!tD(n[e].value))return n.filter(e=>tD(e.value));return n},rD=(e,t,n)=>{if(t.isEmpty())return e;let r=(e,t,r)=>{let i=null;for(let t of n.search(e))t.value?.getProperties()?.numberFormat!=null&&(i??=[]).push(t);if(i)for(let n of mm([e],i))h.isRangesIntersect(n,t)&&r.push({...n,value:e.value});else r.push(e)},i=()=>{let e=null,n=t.all();for(let t=0;t<n.length;t++){let r=n[t]._getPlacement()?.extent;if(r)for(let i of n[t]._getDateFormatsIn(r))e=e?h.unionRanges(e,i):{rowStart:i.rowStart,colStart:i.colStart,rowEnd:i.rowEnd,colEnd:i.colEnd}}return e};return{search:(n,i,a,o)=>{let s=e.search(n,i,a,o),c=(e=>{let n=null,i=t.search(e);for(let t=0;t<i.length;t++){let a=i[t].value._getDateFormatsIn(e);for(let t=0;t<a.length;t++)r(a[t],e,n??=[])}return n})(n);return c&&i&&(c=c.filter(e=>h.isRangeWithinRange(e,n))),c&&c.length!==0?o?(o.push(...c),o):[...s,...c]:s},getBoundingRange:()=>{let t=i();return t?e.isEmpty()?t:h.unionRanges(e.getBoundingRange(),t):e.getBoundingRange()},isEmpty:()=>e.isEmpty()&&i()===null}},iD=new WeakMap,aD=0,oD=e=>{let t=iD.get(e);return t===void 0&&(t=aD++,iD.set(e,t)),t},sD=class extends Qt{constructor(...e){super(...e),this._byId=[],this._byInstance=new WeakMap,this._byKey=new Map,this._persist=null}add(e){let t=this._byInstance.get(e);if(t!==void 0)return t;let n=(e=>{let t=e.toJSON?.(oD);return t&&typeof t.then!=`function`?JSON.stringify(t):null})(e);return n!==null&&(t=this._byKey.get(n)),t===void 0&&(t=this._byId.length,this._byId.push(e),n!==null&&this._byKey.set(n,t),this._notifyCollectionChange()),this._byInstance.set(e,t),t}getById(e){return this._byId[e]??null}getCount(){return this._byId.length}_getItems(){return this._byId.slice()}beginPersist(){let e=this._persist??={byValue:new Map,values:[],open:0};e.open++;let t=!1,n=()=>{if(t)throw Error(`PersistScope is closed.`);return e};return{add:e=>{let{byValue:t,values:r}=n(),i=t.get(e);return i===void 0&&(i=r.length,r.push(e),t.set(e,i)),i},at:e=>n().values[e]??null,fromJSON:(e,t,r)=>{let{byValue:i,values:a}=n();if(r)for(let e of r)zu.kindFromJSON(e);if(e)for(let n=0;n<e.length;n++){let r=ku.fromJSON(e[n],t);i.set(r,a.length),a.push(r)}},toJSONAsync:async e=>{let{values:t}=n(),r=Array(t.length);for(let n=0;n<t.length;n++){let i=t[n];r[n]=await i.toJSON?.(e)??{type:i.getKind().getName()}}return r},toKindsJSON:()=>{let{values:e}=n(),t=new Map;for(let n of e)Tu.forEachRich(n,e=>{let n=e.getKind(),r=zu.toKindJSON(n);r&&!t.has(r.name)&&t.set(r.name,r)});return[...t.values()]},endPersist:()=>{n(),t=!0,--e.open===0&&(this._persist=null)}}}get isIRichDataCollection(){return!0}};function cD(e,t,n=!0,r=!0){let i=0,a=0;if(!n&&!r)return{x:i,y:a};let o=!1,s=0;do{let s=t.x+i,c=t.y+a,l={x:s-8,y:c-8,width:16,height:16};o=e.getItems({bounds:l}).some(e=>{let t=e.getBounds();return!!t&&Math.abs(t.x-s)<8&&Math.abs(t.y-c)<8}),o&&(i+=n?16:0,a+=r?16:0)}while(o&&++s<100);return{x:i,y:a}}function lD(e){if(!e||e.length<=1)return!1;if(e.length===2)return h.isRangesIntersect(e[0],e[1]);let t=new fc;t.load(e);let n=e.length;for(let r=0;r<n;r++)if(t.search(e[r]).length>1)return!0;return!1}function uD(e,t,n){let r=[];if(h.isRangesIntersect(e,t)){let a=i.subtractRect({top:e.rowStart,left:e.colStart,bottom:e.rowEnd+1,right:e.colEnd+1},{top:t.rowStart,left:t.colStart,bottom:t.rowEnd+1,right:t.colEnd+1},n===B.Axis.Column),o=a.length;for(let e=0;e<o;e++){let t={colStart:a[e].left,rowStart:a[e].top,colEnd:a[e].right-1,rowEnd:a[e].bottom-1};r.push(t)}}else r.push(e);return r}function dD(e,t,n){if(!t||!e?.[0])return;let r=e.length;for(let i=0;i<r;i++){let r=e[i];h.intersectRanges(r,t)&&n(r,!h.isRangeWithinRange(r,t),i)}}function fD(e){return e?{colIndex:e.colStart,rowIndex:e.rowStart}:null}function pD(e,t){let n=e.colStart,r=e.rowStart,i=t.colStart,a=t.rowStart;return(e,t)=>{let o=e.colIndex-n,s=t.colIndex-i;return o===s?e.rowIndex-r-(t.rowIndex-a):o-s}}function mD(e,t){let n=e.colStart,r=e.rowStart,i=t.colStart,a=t.rowStart;return(e,t)=>{let o=e.rowIndex-r,s=t.rowIndex-a;return o===s?e.colIndex-n-(t.colIndex-i):o-s}}function hD(e,t,n=!1,r=!1){t||={...e};let i=t.colEnd-t.colStart+1,a=t.rowEnd-t.rowStart+1;if(r){let e=i;i=a,a=e}let o={...e};if(o.colEnd=e.colStart+i-1,o.rowEnd=e.rowStart+a-1,n){if(!h.isSingleCell(e)){let t=e.colEnd-e.colStart,n=e.rowEnd-e.rowStart;o.colEnd=e.colStart+(r?n:t),o.rowEnd=e.rowStart+(r?t:n)}return o}let s=e.colEnd-e.colStart+1;if(s%i!==0)return o;let c=e.rowEnd-e.rowStart+1;return c%a!==0||(o.colEnd=e.colStart+s-1,o.rowEnd=e.rowStart+c-1),o}var gD,_D,vD=class extends Qt{constructor(e,t,n,r){super(),this._add=e,this._get=t,this._getByName=n,this._addListeners=r}add(e,t){if(!e)throw Error(N(`error.table.tableNoBody`));return this._add(e,t)}_getItems(e){let t;e?.address&&(t=e.address);let n=this._get(t,e?.ignoreHidden,e?.fullyContained);if(e?.name){let t=e.name.toLocaleLowerCase();for(let e=0;e<n.length;e++)if(n[e].getName().toLocaleLowerCase()===t)return[n[e]]}return n}getByName(e){if(typeof e!=`string`)throw Error(`Get by name must take a valid name.`);return this._getByName(e)}addListeners(e,t){return this._addListeners(e,t)}get isITableCollection(){return!0}};function yD(e,t,n){let r=[];t?.ranges&&t.ranges.length>0?r=t.ranges:t?.cell&&(r=[h.cellToRange(t.cell)]);let i=e===B.Axis.Column,a=i?n.rowStart:n.colStart,o=i?n.rowEnd:n.colEnd,s=[];for(let e=0;e<r.length;e++){let t=r[e],n=i?t.colStart:t.rowStart,c=i?t.colEnd:t.rowEnd,l=i?t.rowStart:t.colStart,u=i?t.rowEnd:t.colEnd;s=ao(io(s,{min:n,max:c,value:l<=a&&u>=o},{onUpdate:(e,t)=>!!e||!!t}))}return s}function bD(e,t,n){if(!e)return h.EmptySelection;let r=t.cell,i=n.colStart,a=n.rowStart,o=n.colEnd,s=n.rowEnd,c=e?.cell;!c||h.isEqualCells(r,c)&&c.scope===r?.scope||(r=Object.freeze({...c,colIndex:Math.max(i,Math.min(c.colIndex??t.cell?.colIndex??0,o)),rowIndex:Math.max(a,Math.min(c.rowIndex??t?.cell?.rowIndex??0,s))}));let l=e?.ranges?[...e.ranges]:[],u=!1,d=l.length,f=d===0;for(let e=0;e<d;e++){let t=l[e];t&&(l[e]=Object.freeze({...t,colStart:Math.max(i,Math.min(t.colStart,o)),rowStart:Math.max(a,Math.min(t.rowStart,s)),colEnd:Math.max(i,Math.min(t.colEnd,o)),rowEnd:Math.max(a,Math.min(t.rowEnd,s))}),f||=h.isCellWithinRange(r,t),u||=Object.keys(t).length>4)}let p=t?.ranges??[];!u&&h.isEqualRangesArrays(p,l)||(p=l);let m=e?.rangeIndex??t?.rangeIndex??h.EmptySelection.rangeIndex;if(m=Math.max(-1,Math.min(m,p.length-1)),!f&&m>=0&&p[m]){let e=p[m],t=r.rowIndex;t<e.rowStart?t=e.rowStart:t>e.rowEnd&&(t=e.rowEnd);let n=r.colIndex;n<e.colStart?n=e.colStart:n>e.colEnd&&(n=e.colEnd),r=Object.freeze({...r,colIndex:n,rowIndex:t})}return Object.freeze({cell:r,ranges:p,rangeIndex:m})}function xD(e){if(!e)return null;let t=[];if(e.ranges&&e.ranges.length>0){let n=Math.max(0,Math.min(e.rangeIndex??0,e.ranges.length));for(let r=n;r<e.ranges.length;r++)t.push(e.ranges[r]);for(let r=0;r<n;r++)t.push(e.ranges[r])}else e.cell&&t.push(h.cellToRange(e.cell));return t}function SD(e,t,n=-1){if(!e||e.length===0)return null;let r=e[0],a=e.length===1&&r.rowStart===r.rowEnd&&r.colStart===r.colEnd,o=n===-1?e.length-1:Math.min(Math.max(0,n),e.length-1);if(!t){let n=e[o];t={rowIndex:n.rowStart,colIndex:n.colStart}}return{cell:t,ranges:a?i.EmptyArray:[...e],rangeIndex:a?-1:o}}(_D=gD||={}).fastStringToCol=lf,_D.fastStringToCell=of,_D.fastStringToRange=uf,_D.rangeToString=(e,t,n)=>zd(e,t,n),_D.cellToString=Id,_D.normalizeA1ToR1C1=Cf,_D.resolveRelativeToA1=_f,_D.sheetNameToString=Ld,_D.sheetAndRangeToString=Rd,_D.runToString=Of,_D.stringToRun=kf,_D.runToRef=Af,_D.refToRun=jf,_D.runsToRefs=Mf,_D.splitAddressList=Xd,_D.refsToRuns=Nf;var CD,wD,TD=class extends Hv{constructor(...e){super(...e),this._conditionWatches=new Map,this._isContainerShifting=!1}_pagesWatches(){return!1}_requestWatchedCell(e,t,n){let r=!0;for(let i of this._conditionWatches.values()){let a=i.hosts[e];a&&!a.request(t,n)&&(r=!1)}return r}_initialize(e){super._initialize(e),this._getValueGrid=e.getGridValues,this._updateState({...kD,...this._getDefaultState(e)},this._getActionDescription(`initialize`)??m(`op.initialize`));try{this._fromJSON(e?.json)}catch(e){throw console.error(`Error creating anchored conditional from JSON`,e),e}let t=this;this._rangeListener=()=>{t._markValueUpdates()},this._processAnchorCoords()}_markValueUpdates(e=null){if(this._markedValueRange=this._markedValueRange===void 0?e:null,this._valueUpdatesScheduled)return;this._valueUpdatesScheduled=!0;let t=new Promise(e=>{queueMicrotask(()=>{this._valueUpdatesScheduled=!1;let t=this._markedValueRange;this._markedValueRange=void 0,t===void 0||this.isClosed()||this.isDeleted()?e():Promise.resolve(this._processValueUpdates(t)).then(e,e)})});this._options.getCalculation?.()?.waitUntil(t)}_watchConditionFormula(e,t,n,r){r.add(t);let i=e.toString(),a=this._conditionWatches.get(t);if(a&&a.areas!==i&&(this._removeConditionWatch(t,a),this._conditionWatches.delete(t),a=void 0),!a){if(e.getCount()===0)return null;let n=this;a={remove:()=>{},areas:i,values:[],pending:[],hosts:[]},this._conditionWatches.set(t,a);let r=a,o=(e,t)=>{r.values[t]=e;let i=r.pending[t];if(i&&i.length>0){r.pending[t]=[];for(let t=0;t<i.length;t++)i[t](e)}n._markValueUpdates(null)},s=e,c=()=>{n._conditionWatches.get(t)===r&&(n._conditionWatches.delete(t),r.remove=()=>{},n._removeConditionWatch(t,r),n._markValueUpdates(null))};if(t instanceof x_&&s._addWatch){let e=this._pagesWatches()?OD:DD;r.remove=s._addWatch(t,(n,i,a)=>n._addWatch(t instanceof S_?t.getCheckExpression(a):t,{onValues:e=>o(e,i),onRegistered:e=>{r.hosts[i]=e,i===0&&t.bindHost(e)},onRemoved:c},a,e))}else if(s._addWatch)r.remove=s._addWatch(t,(e,n,r)=>e._addWatch(t,{onValues:e=>o(e,n),onRemoved:c},r,DD));else if(t instanceof S_){let n=h.unionRangesArrays(e.getCoords());r.remove=e.addWatch(t.getCheckExpression({rowIndex:n.rowStart,colIndex:n.colStart}),o,DD)}else r.remove=e.addWatch(t,o,DD)}let o=a.values[n];if(o)return o;let s=a;return new Promise(e=>{(s.pending[n]??=[]).push(e)})}_pruneConditionWatches(e){for(let[t,n]of[...this._conditionWatches])e.has(t)||(this._removeConditionWatch(t,n),this._conditionWatches.delete(t))}_removeConditionWatches(){for(let[e,t]of this._conditionWatches)this._removeConditionWatch(e,t);this._conditionWatches.clear()}_removeConditionWatch(e,t){e instanceof x_&&e.bindHost(null),t.remove();for(let e=0;e<t.pending.length;e++){let n=t.pending[e];if(n)for(let e=0;e<n.length;e++)n[e](null)}t.pending.length=0}_processClose(){this._removeConditionWatches(),this._getState().removeListener?.(),super._processClose()}_processAfterStateChange(e,t,n=!1,r=!1){super._processAfterStateChange(e,t,n,r),(n||r)&&this._markValueUpdates(null)}_processAnchorCoords(){let e=this._getState();if(!e)return;let t=this._isContainerShifting;if(t||e.removeListener?.(),super._processAnchorCoords(),this._rangeListener){if(!t){let e=this.getRanges(),t=e.isInvalid()?void 0:e.addListener(this._rangeListener,AD);this._updateState({removeListener:t},this._getActionDescription(`updateListener`)??m(`op.updateListener`))}this._markValueUpdates(null)}}_processContainerDelete(){this._isContainerShifting=!0;try{super._processContainerDelete()}finally{this._isContainerShifting=!1}}_processContainerShift(e){this._isContainerShifting=!0;try{return this._doProcessContainerShift(e)}finally{this._isContainerShifting=!1}}_doProcessContainerShift(e){let t=super._processContainerShift(e);return e.after||this._getState().anchorCoords||this._delete(),this._processAnchorCoords(),t}_isAnchorAbsolute(){return!0}getCoords(){return this.getFirstAnchorCoords()}setRanges(e,t){return this._setAnchorRanges(e,t)}getIndex(){return this._options?.getContainerIndex?.()??-1}setIndex(e){return this._options?.setContainerIndex?.(e),this}getCondition(){let e=this._getState().condition??null;return this._bindConditionFormulas(e),e}_getFormulaBinding(){let e=this._formulaBinding;if(!e){let t=this._options;e={getCalculation:()=>t.getCalculation?.()??null,getAnchor:()=>{let e=this.getAnchorCoords(),t=e?h.unionRangesArrays(e):null;return t?{rowIndex:t.rowStart,colIndex:t.colStart}:null},getScope:()=>{try{return this.getRanges().getWorksheet()?.getName()??null}catch{return null}}},this._formulaBinding=e}return e}_bindConditionFormulas(e){if(!e)return;let t=this._getFormulaBinding();I_(e,e=>e.bind(t))}setCondition(e,t){let n=Nv.resolveInput(e);return this._updateState({condition:n},{description:m(`op.setCondition`),...t},[`onConditionChange`]),this._markValueUpdates(null),this}_rebaseAnchorFormulas(e,t){if(e.rowIndex===t.rowIndex&&e.colIndex===t.colIndex)return!0;let n=this._getState().condition;if(!n)return!0;let r=JSON.parse(JSON.stringify(n.toJSON())),i=this._rebaseConditionFormulas(r,e,t);return i!==null&&(i&&this.setCondition(r),!0)}_rebaseConditionFormulas(e,t,n){if(!e||typeof e!=`object`)return!1;let r=e.param;if(e.operator===Z.BuiltInOperatorNames.Expression){if(typeof r!=`string`||!r)return!1;let i=this._shiftFormulaText(r,t,n);return i===null?null:i!==r&&(e.param=i,!0)}if(typeof r==`string`){if(!r.startsWith(`=`)||!O_.has(e.operator))return!1;let i=this._shiftFormulaText(r.slice(1),t,n);return i===null?null:`=`+i!==r&&(e.param=`=`+i,!0)}if(!r||typeof r!=`object`)return!1;if(Array.isArray(r)){let e=!1;for(let i of r){let r=this._rebaseConditionFormulas(i,t,n);if(r===null)return null;e||=r}return e}if(typeof r.operator==`string`)return this._rebaseConditionFormulas(r,t,n);if(e.operator===Z.BuiltInOperatorNames.InSet){let e=r.source;if(typeof e!=`string`||!e.trim())return!1;let i=this._shiftFormulaText(e,t,n);return i===null?null:i!==e&&(r.source=i,!0)}if(e.operator!==Z.BuiltInOperatorNames.Between)return!1;let i=!1;for(let e of[`from`,`to`]){let a=r[e];if(typeof a!=`string`||!a.startsWith(`=`))continue;let o=this._shiftFormulaText(a.slice(1),t,n);if(o===null)return null;`=`+o!==a&&(r[e]=`=`+o,i=!0)}return i}_extendPastedRanges(e,t,n=!1){if(this.isDeleted()||this.getIndex()<0||JSON.stringify(this.toJSON())!==t)return!1;let r=this.getRanges().getCoords(),i=bm(r,e);if(!h.isEqualRangesArrays(r,i)){if(i.length!==1&&!n)return!1;let e=h.unionRangesArrays(r),t=h.unionRangesArrays(i);if(!e||!t||t.rowStart!==e.rowStart||t.colStart!==e.colStart)return!1}return this._extendRanges(e),!0}_rebaseClonedAnchor(e){let t=h.unionRangesArrays(this.getRanges().getCoords());t&&this._rebaseAnchorFormulas({rowIndex:e.rowStart,colIndex:e.colStart},{rowIndex:t.rowStart,colIndex:t.colStart})}_extendRanges(e){let t=this.getRanges().getCoords(),n=bm(t,e);if(h.isEqualRangesArrays(t,n))return;let r=h.unionRangesArrays(t),i=h.unionRangesArrays(n);if((i.rowStart!==r.rowStart||i.colStart!==r.colStart)&&!this._rebaseAnchorFormulas({rowIndex:r.rowStart,colIndex:r.colStart},{rowIndex:i.rowStart,colIndex:i.colStart})){let r=mm(e,t);if(r.length===0)return;n=t.concat(bm(h.EmptyRanges,r))}this.setRanges(n)}_shiftFormulaText(e,t,n){let r=this._options.getCalculation?.()??null;if(!r)return null;try{let i=b_(r,e,t),a=i?.shift(n);return i&&a?a.hasRefError()&&!i.hasRefError()?null:a.getExpression():null}catch{return null}}apply(){}async _evalConditionRanges(e){let t=this._getState().condition;if(!t)return;this._bindConditionFormulas(t);let n=this._options,r=n.getCalculation?.()??null,i=this._getValueGrid(),a=this.getRanges(),o=new Set,s=a.getCount();for(let c=0;c<s;c++){let s=a.at(c).getCoords();if(!s)continue;let l=c,u=e.onTrue,d=e.onFalse,f=e.onBlank;await rv({runtime:n.getRuntime?.(),calculation:r,conditions:[t],values:i,coords:s,watchFormula:e=>this._watchConditionFormula(a,e,l,o),onTrue:u?(e,t)=>u(e,t,s):void 0,onFalse:(e,t)=>{this._requestWatchedCell(l,e.rowIndex,e.colIndex),d?.(e,t,s)},onBlank:f?e=>f((t,n)=>this._requestWatchedCell(l,t,n)&&e(t,n),s):void 0,spacesAreBlank:e.spacesAreBlank})}this._pruneConditionWatches(o)}get[Symbol.toStringTag](){return`[${this._getType()}]`}toString(){let e=this._getState().condition,t=e?.getSelector()?.getName(),n=e?.getOperator()?.getName(),r=this.getRange()?.toString();return`${this._getType()}${t?`:${t}`:``}${n?`:${n}`:``}${r?`:${r}`:``}`}},ED=class{constructor(e){this._regions=[],this._builder=null,this._area=null,this._isColumn=e}push(e,t){t===this._area&&this._builder||(this._flush(),this._builder=new Lo.Builder,this._area=t);let n=this._isColumn?e.colIndex:e.rowIndex,r=this._isColumn?e.rowIndex:e.colIndex;this._builder.pushAt(n,r,!0)}build(e){this._flush();let t=this._regions;if(t.length===0)return null;let n=new Xc({axis:e});for(let e=0;e<t.length;e++)n.setValues(t[e]);return n}_flush(){let e=this._builder?.build();e&&this._regions.push(e.tuples),this._builder=null,this._area=null}},DD=Object.freeze({arrayFirstCell:!0}),OD=Object.freeze({arrayFirstCell:!0,paged:!0}),kD=Object.freeze({condition:null,removeListener:null}),AD=Object.freeze({transactional:!1});(wD=CD||={}).ScaleType={ColorScale:`colorScale`,DataBar:`dataBar`,IconSet:`iconSet`},wD.ColorStopType={AutoMin:`autoMin`,AutoMax:`autoMax`,Formula:`formula`,Max:`max`,Min:`min`,Num:`num`,Percent:`percent`,Percentile:`percentile`};var jD=class e{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)}getDecorationAt(e,t,n){return this._m.getDecorationAt(e,t,n)}getSplit(t){let n=this._m;return[new e(t[0],n),new e(t[1],n)]}},MD=class e extends TD{constructor(...e){super(...e),this._colorScale=null,this._dataBar=null,this._iconSet=null,this._matches=null,this._blankResolvers=null,this._stopValues=new Map,this._stopWatchRemoves=null,this._stopWatchFormulas=null,this._stopWatchKey=null,this._prepareGeneration=0}_initialize(e){if(!e.json)throw Error(`json is required`);this._styles=e.sheet?.getStyles()??new Pm,super._initialize(e),this._stylesRemoveListener=this._styles.addListeners({onThemeChange:()=>{this._markValueUpdates(null)}})}_getType(){return`ConditionalFormat`}_pagesWatches(){return!0}_getActionDescription(e){return m(e===`delete`?`op.deleteConditionalFormat`:e===`initialize`?`op.initializeConditionalFormat`:`op.updateConditionalFormatListener`)}_getDefaultState(e){return{...PD}}_processValueUpdates(e=null){let t=this._getState();if(!t)return Promise.resolve();let n=[],r=this._options,i=this,a=t.scale,o=this.getRanges();this._syncStopWatches(o,BD(a??null));let s=++this._prepareGeneration,c=a?.type===CD.ScaleType.ColorScale?a.stops:null;c?n.push((async()=>{let e=await i._prepareColorScale(o,c);s===i._prepareGeneration&&(i._colorScale=e,r.invalidate?.())})()):this._colorScale=null;let l=a?.type===CD.ScaleType.DataBar?a:null;l?n.push((async()=>{let e=await i._prepareDataBar(o,l);s===i._prepareGeneration&&(i._dataBar=e,r.invalidate?.())})().catch(()=>{s===i._prepareGeneration&&(i._dataBar=null)})):this._dataBar=null;let u=a?.type===CD.ScaleType.IconSet?a:null;return u?n.push((async()=>{let e=await i._prepareIconSet(o,u);s===i._prepareGeneration&&(i._iconSet=e,r.invalidate?.())})().catch(()=>{s===i._prepareGeneration&&(i._iconSet=null)})):this._iconSet=null,t.condition&&(t.style||t.stopIfTrue)?n.push((async()=>{let e=i._getValueGrid().getAxis(),t=new ED(e===B.Axis.Column),n=[];await i._evalConditionRanges({onTrue:(e,n,r)=>{t.push(e,r)},onBlank:(e,t)=>{n.push({area:t,resolve:e})},spacesAreBlank:!0}),s===i._prepareGeneration&&(i._matches=t.build(e)??new Xc({axis:e}),i._blankResolvers=n.length>0?n:null,r.invalidate?.())})().catch(()=>{s===i._prepareGeneration&&(i._matches=null,i._blankResolvers=null)})):(this._matches=null,this._blankResolvers=null),Promise.all(n).then(()=>{})}async _resolveStopValues(e,t){let n=null,r=null,i=null;if(t.some(e=>e.type===CD.ColorStopType.Min||e.type===CD.ColorStopType.Max||e.type===CD.ColorStopType.Percent||e.type===CD.ColorStopType.AutoMin||e.type===CD.ColorStopType.AutoMax)){n=e.getStats();let t=n.getAggregates();r=t.min??null,i=t.max??null}let a=[];for(let o of t){let t=null;switch(o.type??CD.ColorStopType.Num){case CD.ColorStopType.Min:t=r;break;case CD.ColorStopType.Max:t=i;break;case CD.ColorStopType.AutoMin:t=r===null?null:Math.min(0,r);break;case CD.ColorStopType.AutoMax:t=i===null?null:Math.max(0,i);break;case CD.ColorStopType.Num:t=Number(o.value)??0;break;case CD.ColorStopType.Percentile:n??=e.getStats(),t=n.getSortedNumbers().getPercentile((Number(o.value)??0)/100);break;case CD.ColorStopType.Percent:{let e=Math.max(0,Math.min(100,Number(o.value)??0));r!==null&&i!==null&&(t=r+e/100*(i-r));break}case CD.ColorStopType.Formula:{let e=o.value instanceof x_?this._stopValues.get(o.value):void 0;typeof e==`number`&&(t=e);break}default:t=Number(o.value)??0}a.push(t!==null&&Number.isFinite(t)?t:null)}return a}_formulaAnchor(e){let t=e.getCount()>0?h.unionRangesArrays(e.getCoords()):null;return t?{rowIndex:t.rowStart,colIndex:t.colStart}:null}_syncStopWatches(e,t){let n=[],r=t?t.length:0,i=this._getFormulaBinding();for(let e=0;e<r;e++){let r=t[e];if(r.type!==CD.ColorStopType.Formula)continue;let a=r.value;a instanceof x_&&!n.includes(a)&&(a.bind(i),a.getText().trim().length>0&&n.push(a))}let a=n.map(e=>``+function(e){let t=ID.get(e);return t===void 0&&(t=++LD,ID.set(e,t)),t}(e)),o=n.length>0?this._formulaAnchor(e):null,s=o?`${o.rowIndex}:${o.colIndex}|${a.join(`\0`)}`:null;if(s===this._stopWatchKey||(this._removeStopWatches(),this._stopWatchKey=s,!s||!o))return;let c=e.getWorksheet().getRange({rowStart:o.rowIndex,rowEnd:o.rowIndex,colStart:o.colIndex,colEnd:o.colIndex}),l=c,u=this,d=[];for(let e=0;e<n.length;e++){let t=n[e],r=e=>{let n=e.getValueAt(0,0),r=typeof n==`number`&&Number.isFinite(n)?n:null;u._stopValues.has(t)&&u._stopValues.get(t)===r||(u._stopValues.set(t,r),u._markValueUpdates(null))};d.push(l._addWatch?l._addWatch(t,{onValues:r,onRegistered:e=>t.bindHost(e),onRemoved:()=>{u._stopWatchKey===s&&(u._removeStopWatches(),u._stopWatchKey=null,u._markValueUpdates(null))}},void 0,FD):c.addWatch(t,r,FD))}this._stopWatchRemoves=d,this._stopWatchFormulas=n}_removeStopWatches(){let e=this._stopWatchRemoves;if(!e)return;let t=this._stopWatchFormulas;if(t)for(let e=0;e<t.length;e++)t[e].bindHost(null);for(let t=0;t<e.length;t++)e[t]();this._stopWatchRemoves=null,this._stopWatchFormulas=null,this._stopValues.clear()}_processClose(){this._removeStopWatches(),this._stopWatchKey=null,this._stylesRemoveListener?.(),this._stylesRemoveListener=null,super._processClose()}async _prepareColorScale(e,t){if(!t||t.length===0)return null;let n=await this._resolveStopValues(e,t),r=this._styles,i=[];for(let e=0;e<t.length;e++){let a=n[e];if(a===null)continue;let o=t[e],s=r.parseColor(o.color).toRGBA(),c=[s.red,s.green,s.blue];i.push({v:a,rgb:c,exclusive:o.exclusive??!1})}return i.length===0?null:(i.sort((e,t)=>e.v-t.v),{stops:i,colorFor:ZD(i)})}async _prepareDataBar(e,t){let[n,r]=await this._resolveStopValues(e,[t.minPoint??RD,t.maxPoint??zD]);if(n===null||r===null||r===n)return null;let i=t.axisPosition===`middle`,a;a=t.axisPosition===`none`?0:i?.5:YD((0-n)/(r-n));let o=YD((t.minLength??0)/100),s=YD((t.maxLength??100)/100),c=this._styles,l=e=>e===void 0?void 0:c.parseColor(e).toCSS(`adaptive`,!0),u={type:CD.ScaleType.DataBar,axis:a,color:l(t.color)??KD,negativeColor:l(t.negativeFillColor),borderColor:l(t.borderColor),negativeBorderColor:l(t.negativeBorderColor),axisColor:l(t.axisColor),solidFill:t.solidFill??!1,direction:t.direction===`rightToLeft`?`rightToLeft`:`leftToRight`,showValue:t.showValue??!0},d=Math.min(n,r),f=Math.max(n,r),p=Math.max(Math.abs(n),Math.abs(r));return{barFor:e=>{let t,c,l;if(i)t=Math.min(Math.max(e,d),f)/p,c=.5;else{let i=YD((e-n)/(r-n))-a;c=i>=0?1-a:a,t=c>0?i/c:0}if(c<=0)l=a;else{let e=o+Math.abs(t)*(s-o);l=a+(t>=0?1:-1)*e*c}return{...u,value:YD(l)}}}}async _prepareIconSet(e,t){let n=t.stops;if(!n||n.length===0)return null;let r=t.iconSet??z.IconSet.TrafficLights3,i=await this._resolveStopValues(e,n),a=n.length,o=t.icon,s=t.reverse??!1,c=t.showValue??!0;return{iconFor:e=>{let t=0;for(let r=1;r<a;r++){let a=i[r];if(a!==null){if(!(n[r].exclusive?e>a:e>=a))break;t=r}}s&&(t=a-1-t);let l=o?.[t];if(l){let e=qD(l.set);return l.id<0||l.id>=e?null:{type:CD.ScaleType.IconSet,index:l.id,set:l.set,count:e,showValue:c}}return{type:CD.ScaleType.IconSet,index:t,set:r,count:a,showValue:c}}}}setStopIfTrue(e,t){return this._updateState({stopIfTrue:e},{description:m(e?`op.setStopTrue`:`op.setStopFalse`),...t},[`onAnyChange`]),this}isStopIfTrue(){return this._getState().stopIfTrue??!1}getScale(){let e=this._getState().scale??null,t=BD(e);if(t.length>0){let e=this._getFormulaBinding();for(let n=0;n<t.length;n++){let r=t[n].value;r instanceof x_&&r.bind(e)}}return e}getStyle(){return this._getState().style??null}_rebaseAnchorFormulas(e,t){if(!super._rebaseAnchorFormulas(e,t))return!1;if(e.rowIndex===t.rowIndex&&e.colIndex===t.colIndex)return!0;let n=this._getState().scale;if(!n)return!0;let r=BD(n),i=new Map;for(let n=0;n<r.length;n++){let a=r[n];if(a.type!==CD.ColorStopType.Formula)continue;let o=a.value instanceof x_?a.value.getText():typeof a.value==`string`?a.value:``;if(!o)continue;let s=this._shiftFormulaText(o,e,t);if(s===null)return!1;s!==o&&i.set(a,{...a,value:s})}return i.size>0&&this.update({scale:VD(n,e=>i.get(e)??e)}),!0}getSnapshot(e){let t={...this.toJSON()},n=typeof t.pivotKey==`number`;delete t.pivotKey;let r=JSON.stringify(this.toJSON()),i=this.getRange().getCoords(),a=h.unionRangesArrays(this.getRanges().getCoords()),o=this,s=Object.freeze({...e});return{copyTo(e,i){let s=e.ranges??[e.range];return e.extend&&!n&&o._extendPastedRanges(s,r,!!i?.isCut)||e.conditionals.add(s,{...t,index:e.index})._rebaseClonedAnchor(a),h.unionRangesArrays(s)},getCoords:()=>i,getSource:()=>o,getName:()=>`Conditional Format`,getMarkOptions:()=>s,isISnapshot:!0}}_createSpatial(e){return new jD(e,this)}update(t,n){if(this.isDeleted())throw Error(`Table has been closed. No further operations are allowed.`);let r=t.isIConditionalFormat?e.replaceModifiers(t.toJSON()):t,i=this._getState(),a=this._beginCommit(n?.description??m(`op.updateConditionalFormat`));try{let{condition:e,stopIfTrue:t,...o}=r,s={...i,...o,...`stopIfTrue`in r?{stopIfTrue:t??!1}:null,...`condition`in r?{condition:Nv.fromJSON(e)}:null};`scale`in r&&(s.scale=GD(WD(s.scale??null))),`condition`in r&&s.condition&&!(`scale`in r)?s.scale=null:`scale`in r&&s.scale&&!(`condition`in r)&&(s.condition=null),this._updateState(s,n),this._getEmitter().notify(`onAnyChange`),a.commit()}catch(e){throw a.rollback(),e}return this._markValueUpdates(null),this}static replaceModifiers(e){return{condition:e?.condition??null,style:e?.style??null,scale:e?.scale??null,stopIfTrue:e?.stopIfTrue??!1}}toJSON(){let e={},t=this._getState();if(t===null)return null;if(t.condition){let n=t.condition.toJSON();n&&(e.condition=n)}return t.style&&(e.style=t.style),t.scale&&(e.scale=VD(t.scale,e=>e.value instanceof x_?{...e,value:e.value.toJSON()}:e)),t.stopIfTrue&&(e.stopIfTrue=t.stopIfTrue),typeof t.pivotKey==`number`&&(e.pivotKey=t.pivotKey),t.ext&&(e.ext=t.ext),e}_fromJSON(e){let t=e??{},n={...PD,style:t.style??null,scale:GD(WD(t.scale??null)),stopIfTrue:t.stopIfTrue??!1,pivotKey:t.pivotKey??null,ext:t.ext??null,condition:Nv.fromJSON(t.condition)};this._updateState(n,{description:m(`op.initializeConditionalFormat`)})}getPropertiesAt(e,t,n){let r=this._colorScale;if(r&&typeof n==`number`)return{fill:{type:`solid`,color:r.colorFor(n)}};let i=this._matches;if(i&&i.getValueAt(e,t))return this._getState().style??ND;let a=this._blankResolvers;if(a&&n==null)for(let n=0;n<a.length;n++){let{area:r,resolve:i}=a[n];if(!(e<r.rowStart||e>r.rowEnd||t<r.colStart||t>r.colEnd)&&i(e,t))return this._getState().style??ND}return null}getDecorationAt(e,t,n){if(typeof n!=`number`||!Number.isFinite(n))return null;let r=this._dataBar;if(r)return r.barFor(n);let i=this._iconSet;return i?i.iconFor(n):null}get isIConditionalFormat(){return!0}},ND=Object.freeze({}),PD=Object.freeze({condition:null,removeListener:null,style:null,scale:null,stopIfTrue:!1,pivotKey:null,ext:null}),FD=Object.freeze({arrayFirstCell:!0}),ID=new WeakMap,LD=0,RD=Object.freeze({type:CD.ColorStopType.Min}),zD=Object.freeze({type:CD.ColorStopType.Max});function BD(e){if(!e)return[];if(e.type===CD.ScaleType.DataBar){let t=[];return e.minPoint&&t.push(e.minPoint),e.maxPoint&&t.push(e.maxPoint),t}return e.stops??[]}function VD(e,t){if(e.type===CD.ScaleType.DataBar){let n=e.minPoint?t(e.minPoint):void 0,r=e.maxPoint?t(e.maxPoint):void 0;if(n===e.minPoint&&r===e.maxPoint)return e;let i={...e};return n&&(i.minPoint=n),r&&(i.maxPoint=r),i}let n=e.stops;if(!n||n.length===0)return e;let r=!1,i=n.map(e=>{let n=t(e);return n!==e&&(r=!0),n});return r?{...e,stops:i}:e}var HD=Object.freeze([Object.freeze({type:CD.ColorStopType.Min,color:`#F8696B`}),Object.freeze({type:CD.ColorStopType.Percentile,value:50,color:`#FFEB84`}),Object.freeze({type:CD.ColorStopType.Max,color:`#63BE7B`})]),UD=Object.freeze([Object.freeze({type:CD.ColorStopType.Min,color:`#FF7128`}),Object.freeze({type:CD.ColorStopType.Max,color:`#FFEF9C`})]);function WD(e){if(!e||e.type===CD.ScaleType.DataBar)return e;let t=e.stops??[];if(e.type===CD.ScaleType.ColorScale){let n=t;if(n.length>=2&&n.every(e=>!!e?.color))return e;let r=n.length>=2?n.length:HD.length,i=r===2?UD:HD;return{...e,stops:Array.from({length:r},(e,t)=>{let r=i[Math.min(t,i.length-1)],a=n[t];return a?{...a,color:a.color||r.color}:{...r}})}}if(t.length>=2)return e;let n=(e.iconSet?qD(e.iconSet):0)||e.icon?.length||3,r=Array.from({length:n},(e,t)=>({type:CD.ColorStopType.Percent,value:Math.round(100*t/n)}));return{...e,stops:r.map((e,n)=>t[n]??e)}}function GD(e){return e&&VD(e,e=>{if(e.type!==CD.ColorStopType.Formula)return e;let t=e.value;return t instanceof x_?e:t?.isIFormula?{...e,value:new x_(t.getExpression(),!1)}:typeof t==`string`?{...e,value:new x_(t,!1)}:e})}var KD=`rgb(99, 142, 198)`;function qD(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:0}function JD(e,t,n){return e+(t-e)*n}function YD(e){return e<0?0:e>1?1:e}function XD(e){return`rgb(${e[0]}, ${e[1]}, ${e[2]})`}function ZD(e){let t=e.length;if(t===0)return e=>``;let n=e[0],r=e[t-1];return i=>{if(!Number.isFinite(i))return``;if(i<=n.v)return XD(n.rgb);if(i>=r.v)return XD(r.rgb);let a=1;for(;a<t;){let t=e[a];if(i<t.v)break;if(i!==t.v)a++;else{if(!t.exclusive)break;a++}}if(a<=0)return XD(n.rgb);if(a>=e.length)return XD(r.rgb);let o=e[a-1],s=e[a],c=s.v-o.v;if(c===0)return XD((s.exclusive?o:s).rgb);let l=(i-o.v)/c;return XD(function(e,t,n){return n=YD(n),[Math.round(JD(e[0],t[0],n)),Math.round(JD(e[1],t[1],n)),Math.round(JD(e[2],t[2],n))]}(o.rgb,s.rgb,l))}}var QD,$D=class extends Qt{constructor(e,t,n,r){super(),this._add=e,this._get=t,this._createItem=n,this._addListeners=r}add(e,t){if(!e)throw Error(N(`error.address.noAddress`));return this._add(e,t)}_getItems(e){return this._get(e?.address,e?.ignoreHidden,e?.fullyContained)}createItem(e){return this._createItem(e)}addListeners(e,t){return this._addListeners(e,t)}get isIConditionalFormatCollection(){return!0}};(QD||={}).AlertStyle={Stop:`stop`,Warning:`warning`,Information:`information`};var eO,tO=class extends TD{constructor(...e){super(...e),this._results=null,this._blankAreas=null,this._blankPerCell=!1,this._blankPieces=null,this._alertCount=null,this._evalGeneration=0}_getType(){return`DataValidation`}_getActionDescription(e){return m(e===`delete`?`op.deleteDataValidation`:e===`initialize`?`op.initializeDataValidation`:`op.updateDataValidationListener`)}_getDefaultState(e){return{...sO}}_processValueUpdates(e=null){let t=this._getState();if(!t)return;let n=t.condition,r=++this._evalGeneration;if(!n)return void((this._results&&this._results.getCount()>0||this._blankAreas)&&(this._setResults(null,null),this._options.invalidate?.(this.getRange().getCoords())));let i=this._options;return(async()=>{let e=this._getValueGrid().getAxis(),t=new ED(e===B.Axis.Column),a=n.isIncludeBlanks()?null:[];if(await this._evalConditionRanges({onFalse:(e,n,r)=>{t.push(e,r)},onBlank:a?(e,t)=>{a.push({area:t,resolve:e,passes:null})}:void 0}),r!==this._evalGeneration)return;let o=t.build(e),s=(this._results?.getCount()??0)>0||!!this._blankAreas,c=!!a&&a.length>0;if(!o&&!s&&!c)return;let l=!1;I_(n,()=>{l=!0}),this._setResults(o??new Xc({axis:e}),c?a:null,l);let u=this.getRanges(),d=u.getCount();for(let e=0;e<d;e++){let t=u.at(e).getCoords();t&&i.invalidate?.(t)}})().catch(()=>{})}_setResults(e,t,n=!1){this._results=e,this._blankAreas=t,this._blankPerCell=n,this._blankPieces=null,this._alertCount=null}_isBlankFailing(e,t,n){for(let r=0;r<e.length;r++){let i=e[r],a=i.area;if(!(t<a.rowStart||t>a.rowEnd||n<a.colStart||n>a.colEnd)&&!this._isBlankPassing(i,t,n))return!0}return!1}_isBlankPassing(e,t,n){if(this._blankPerCell)return e.resolve(t,n);let r=e.passes;return r===null&&(r=e.passes=e.resolve(e.area.rowStart,e.area.colStart)),r}_getBlankPieces(){let e=this._blankPieces;if(e)return e;e=[];let t=this._blankAreas??[];for(let n=0;n<t.length;n++){let r=t[n],i=[],a=[r.area];for(let t=0;t<e.length;t++){let n=e[t],o=nO(n.coords,r.area);if(!o){i.push(n);continue}i.push({coords:o,areas:[...n.areas,r]});let s=rO(n.coords,o);for(let e=0;e<s.length;e++)i.push({coords:s[e],areas:n.areas});a=a.flatMap(e=>rO(e,o))}for(let e=0;e<a.length;e++)i.push({coords:a[e],areas:[r]});e=i}return this._blankPieces=e,e}_countValues(e){let t=this._getValueGrid(),n=0;for(let r of t.getRuns({bounds:e}))n+=r[2].length;return n}getAlertAt(e,t){if(this._results?.getValueAt(e,t))return!0;let n=this._blankAreas;return n?this._getValueGrid().getValueAt(e,t)==null&&this._isBlankFailing(n,e,t):!1}getAlertEntries(e){let t=this._results,n=e?.axis??this._getValueGrid().getAxis(),r=e?.reverse??!1;if(!this._blankAreas)return(t??new Xc({axis:n})).entries({axis:n,reverse:r});let i=this._getBlankPieces(),a=r?[...i].reverse():i;return this._pieceEntries(a,t,n,r)}*_pieceEntries(e,t,n,r){let i=this._getValueGrid(),a=n===B.Axis.Column;for(let o=0;o<e.length;o++){let s=e[o],c=s.coords,l=this._blankPerCell,u=!1;if(!l){for(let e=0;e<s.areas.length&&!u;e++)u=!this._isBlankPassing(s.areas[e],c.rowStart,c.colStart);if(!u){if(t){let e=t.entries({bounds:c,axis:n,reverse:r,reuseResult:!0});for(let t=e.next();!t.done;t=e.next()){let e=t.value[0];yield[{rowIndex:e.rowIndex,colIndex:e.colIndex},!0]}}continue}}let d=a?c.colStart:c.rowStart,f=a?c.rowStart:c.colStart,p=(a?c.rowEnd:c.colEnd)-f+1,m=((a?c.colEnd:c.rowEnd)-d+1)*p-1,h=e=>{let t=d+Math.floor(e/p),n=f+e%p;return a?{rowIndex:n,colIndex:t}:{rowIndex:t,colIndex:n}},g=r?-1:1,_=r?m:0,v=function*(e,t){for(;_!==t;_+=g){let t=h(_);l&&!e._isBlankFailing(s.areas,t.rowIndex,t.colIndex)||(yield[t,!0])}},y=i.entries({bounds:c,axis:n,reverse:r,reuseResult:!0});for(let e=y.next();!e.done;e=y.next()){let n=e.value[0],r=((a?n.colIndex:n.rowIndex)-d)*p+(a?n.rowIndex:n.colIndex)-f;yield*v(this,r),_=r+g,t?.getValueAt(n.rowIndex,n.colIndex)&&(yield[{rowIndex:n.rowIndex,colIndex:n.colIndex},!0])}yield*v(this,r?-1:m+1)}}getAlertCount(){let e=this._alertCount;if(e!==null)return e;if(e=this._results?.getCount()??0,this._blankAreas){let t=this._getBlankPieces();for(let n=0;n<t.length;n++){let r=t[n],i=r.coords;if(this._blankPerCell)for(let t of this._pieceEntries([r],null,this._getValueGrid().getAxis(),!1))t&&e++;else{let t=!1;for(let e=0;e<r.areas.length&&!t;e++)t=!this._isBlankPassing(r.areas[e],i.rowStart,i.colStart);t&&(e+=(i.rowEnd-i.rowStart+1)*(i.colEnd-i.colStart+1)-this._countValues(i))}}}return this._alertCount=e,e}async getListItemsAt(e,t){let n=this._getState().condition;if(n?.getOperator()?.getName()!==Z.BuiltInOperatorNames.InSet)return[];let r=j_(n.getParam());if(!r)return[];let a=[],o=r.items??i.EmptyArray;for(let e=0;e<o.length;e++)a.push({value:o[e],text:jv(o[e],pB(o[e]))});let s=!1;r.source instanceof S_&&(s=await this._listSourceItemsAt(n,r.source,e,t,a)),(s||r.blank)&&a.push({value:null,text:``});let c=r.additions??i.EmptyArray;for(let e=0;e<c.length;e++)a.push({value:c[e],text:c[e]});let l=r.subtractions;if(!l||l.length===0)return a;let u=new Set(l.map(hg));return a.filter(e=>!u.has(hg(e.value)))}async _listSourceItemsAt(e,t,n,r,i){this._bindConditionFormulas(e);let a=t.shift({rowIndex:n,colIndex:r});if(!a)return!1;let o,s=!1;if(a.isReferenceOnly()){let e=a.getReferences(),t=e?.getCount()??0;for(let n=0;n<t;n++){let t=e.at(n),r=0;t.forEach((e,t)=>{r++,e!==null&&e!==``?i.push({value:e,text:t.getCell().getText({hideStringPrefix:!0})}):s=!0});let a=t.getCoords();r<(a.rowEnd-a.rowStart+1)*(a.colEnd-a.colStart+1)&&(s=!0)}return s}try{o=await a.evaluate({alwaysReturnRange:!0})}catch{return!1}if(!o?.isIRange)return!1;for(let e of o.entries({axis:B.Axis.Row})){let t=e.value;V.isError(t)||(t!==null&&t!==``?i.push({value:t,text:jv(t,pB(t))}):s=!0)}return s}async validateInputAt(e,t,n){let r=this._getState().condition;if(!r)return!0;let i=this.getRanges(),a={rowIndex:t,colIndex:n},o=null,s=i.getCount();for(let e=0;e<s&&!o;e++){let t=i.at(e).getCoords();t&&h.isCellWithinRange(a,t)&&(o=t)}if(!o)return!0;let c=await this._resolveEntryAt(e,a);if(c===null)return!0;let l=this._options,u=l.getRuntime?.();return this._bindConditionFormulas(r),async function(e,t,n,r){let i={rowStart:n.rowIndex,colStart:n.colIndex,rowEnd:n.rowIndex,colEnd:n.colIndex},a=new Xc;t!==null&&a.setValueAt(n.rowIndex,n.colIndex,t);let o={position:null,value:null},s=new sv(r.runtime,o,a,i,r.calculation??null,void 0,r.anchor);s.setWatchFormula(r.watchFormula??null);let c=await ev(e,s,o,null);if(!c)return!0;if(t===null)return c.resolveBlank(n.rowIndex,n.colIndex);let l=c.judge(n,t);return l===null?(await c.settleDeferred())(n):l}(r,c,a,{runtime:u,calculation:l.getCalculation?.()??null,anchor:{rowIndex:o.rowStart,colIndex:o.colStart},watchFormula:e=>e instanceof S_?this._checkListEntryAt(e,c,a,u):void 0})}async _resolveEntryAt(e,t){if(typeof e!=`string`)return e??null;if(e===``)return null;let n,r=e.charAt(0)===`=`&&e.length>1?e.substring(1):null,i=e;if(!r){let t=this._options.getRuntime?.();if(!t)return e;i=zz(t,e,{}).value??null;let n=e.charAt(0);typeof i!=`string`||n!==`+`&&n!==`-`||!iO(e)||(r=e)}if(!r)return i;try{n=await this.getRanges().getWorksheet().evaluate(r,t)}catch{return e}return n?.isIRange?n.getValueAt(0,0)??null:n}async _checkListEntryAt(e,t,n,r){let i=this._options.getCalculation?.()??null;if(!i)return null;let a=!1,o=aO(t);if(o!==null&&e.isValid()){let t=e.getAnchor(),r=b_(i,`ISNUMBER(MATCH(${o},${e.getText()},0))`,t),s=r&&t?r.shift(n):r;try{a=!0===await s?.evaluate()}catch{a=!1}}let s=new Xc;return s.setValueAt(n.rowIndex,n.colIndex,a),new LV(r,s,{rowStart:n.rowIndex,colStart:n.colIndex,rowEnd:n.rowIndex,colEnd:n.colIndex})}setHideDropdown(e,t){return this._updateState({hideDropdown:e??!1},{description:m(`op.setHideDropdown`),...t},[`onConfigChange`])}isHideDropdown(){return this._getState().hideDropdown}setPromptMessage(e,t){return this._updateState({prompt:e??``},{description:m(`op.setPromptMessage`),...t},[`onConfigChange`])}getPromptMessage(){return this._getState().prompt}setPromptTitle(e,t){return this._updateState({promptTitle:e??``},{description:m(`op.setPromptTitle`),...t},[`onConfigChange`])}getPromptTitle(){return this._getState().promptTitle}setShowPromptMessage(e,t){return this._updateState({showPromptMessage:e??!1},{description:m(`op.setShowPromptMessage`),...t},[`onConfigChange`])}isShowPromptMessage(){return this._getState().showPromptMessage}setAlertMessage(e,t){return this._updateState({alert:e??``},{description:m(`op.setAlertMessage`),...t},[`onConfigChange`])}getAlertMessage(){return this._getState().alert}setAlertTitle(e,t){return this._updateState({alertTitle:e??``},{description:m(`op.setAlertTitle`),...t},[`onConfigChange`])}getAlertTitle(){return this._getState().alertTitle}setShowAlertMessage(e,t){return this._updateState({showAlertMessage:e??!1},{description:m(`op.setShowErrorMessage`),...t},[`onConfigChange`])}isShowAlertMessage(){return this._getState().showAlertMessage}setAlertStyle(e,t){return this._updateState({alertStyle:e??sO.alertStyle},{description:m(`op.setAlertStyle`),...t},[`onConfigChange`])}getAlertStyle(){return this._getState().alertStyle}setIncludeBlanks(e,t){let n=this._getState().condition;return n&&(this._updateState({condition:Nv.fromJSON({...n.toJSON(),includeBlanks:e??!1})},{description:m(`op.setIncludeBlanks`),...t},[`onConfigChange`]),this._markValueUpdates(null)),this}isIncludeBlanks(){return this._getState().condition?.isIncludeBlanks()??!1}getRenderHints(){let e=this._getState().condition;if(!e)return i.EmptyArray;let t=[],n=e.getOperator();n?.getCandidates&&n.getCandidates(e.getParam(),null)!==null&&t.push(`list`);let r=e.getSelector();return r?.getName()===Z.BuiltInSelectorNames.Time?t.push(`time`,`clock`):r?.getSelectType()===H.Date&&t.push(`date`,`calendar`),t.length>0?t:i.EmptyArray}update(e,t){let n=e&&`isIDataValidation`in e?{...oO,...e.toJSON()}:{...e};return this.doBatch(()=>{this._fromJSON(n),this._markValueUpdates(),this._notify([`onAnyChange`])},{description:m(`op.updateDataValidation`),...t}),this}getSnapshot(e){let t={...this.toJSON()},n=JSON.stringify(this.toJSON()),r=this.getFirstAnchorCoords(),i=h.unionRangesArrays(this.getRanges().getCoords()),a=N(`name.dataValidation`),o=this,s=Object.freeze({...e});return{copyTo(e,r){let a=e.ranges??[e.range];return e.extend&&o._extendPastedRanges(a,n,!!r?.isCut)||e.validations.add(a,{...t,index:e.index})._rebaseClonedAnchor(i),h.unionRangesArrays(a)},getCoords:()=>r,getSource:()=>o,getName:()=>a,getMarkOptions:()=>s,isISnapshot:!0}}addListeners(e,t){return this._getEmitter().addListeners(e,t)}toJSON(){let e={},t=this._getState();if(!t)return null;if(t.prompt&&(e.prompt=t.prompt),t.promptTitle&&(e.promptTitle=t.promptTitle),t.showPromptMessage&&(e.showPromptMessage=t.showPromptMessage),t.alert&&(e.alert=t.alert),t.alertTitle&&(e.alertTitle=t.alertTitle),t.showAlertMessage&&(e.showAlertMessage=t.showAlertMessage),t.alertStyle&&t.alertStyle!==sO.alertStyle&&(e.alertStyle=t.alertStyle),t.hideDropdown&&(e.hideDropdown=t.hideDropdown),t.imeMode&&(e.imeMode=t.imeMode),t.ext&&(e.ext=t.ext),t.condition){let n=t.condition.toJSON();n&&(e.condition=n)}return e}_fromJSON(e,t){let n=e??{},r={...this._getState()};n.prompt!==void 0&&(r.prompt=n.prompt),n.promptTitle!==void 0&&(r.promptTitle=n.promptTitle),n.showPromptMessage!==void 0&&(r.showPromptMessage=n.showPromptMessage),n.alert!==void 0&&(r.alert=n.alert),n.alertTitle!==void 0&&(r.alertTitle=n.alertTitle),n.showAlertMessage!==void 0&&(r.showAlertMessage=n.showAlertMessage),n.alertStyle!==void 0&&(r.alertStyle=n.alertStyle),n.hideDropdown!==void 0&&(r.hideDropdown=n.hideDropdown),n.imeMode!==void 0&&(r.imeMode=n.imeMode),n.ext!==void 0&&(r.ext=n.ext);let i=n.condition;i===null?r.condition=null:i!==void 0&&(r.condition=Nv.fromJSON(i)),this._updateState(r,{description:m(`op.addDataValidation`),...t})}get isIDataValidation(){return!0}},nO=(e,t)=>{let n=Math.max(e.rowStart,t.rowStart),r=Math.min(e.rowEnd,t.rowEnd),i=Math.max(e.colStart,t.colStart),a=Math.min(e.colEnd,t.colEnd);return n>r||i>a?null:{rowStart:n,rowEnd:r,colStart:i,colEnd:a}},rO=(e,t)=>{let n=nO(e,t);if(!n)return[e];let r=[];e.rowStart<n.rowStart&&r.push({...e,rowEnd:n.rowStart-1}),n.rowEnd<e.rowEnd&&r.push({...e,rowStart:n.rowEnd+1});let i={rowStart:n.rowStart,rowEnd:n.rowEnd};return e.colStart<n.colStart&&r.push({...i,colStart:e.colStart,colEnd:n.colStart-1}),n.colEnd<e.colEnd&&r.push({...i,colStart:n.colEnd+1,colEnd:e.colEnd}),r},iO=e=>{for(let t=0;t<e.length;t++){let n=e.charAt(t);if(n!==`+`&&n!==`-`&&n!==` `&&n!==` `)return!0}return!1},aO=e=>typeof e==`number`?Number.isFinite(e)?String(e).toUpperCase():null:typeof e==`boolean`?e?`TRUE`:`FALSE`:typeof e==`string`?`"${e.replace(/"/g,`""`)}"`:null,oO=Object.freeze({condition:null,prompt:``,promptTitle:``,showPromptMessage:!1,alert:``,alertTitle:``,showAlertMessage:!1,alertStyle:QD.AlertStyle.Stop,hideDropdown:!1,imeMode:null,ext:null}),sO=Object.freeze({condition:null,removeListener:null,alertStyle:QD.AlertStyle.Stop,hideDropdown:!1,imeMode:null,ext:null,prompt:``,promptTitle:``,showPromptMessage:!1,alert:``,alertTitle:``,showAlertMessage:!1}),cO=class extends Qt{constructor(e,t,n,r,i){super(),this._add=e,this._get=t,this._createItem=n,this._addListeners=r,this._getSettings=i}add(e,t){if(!e)throw Error(N(`error.address.invalidRange`));return this._add(e,t)}_getItems(e){return this._get(e?.address,e?.ignoreHidden,e?.fullyContained)}createItem(e){return this._createItem(e)}getSettings(){return this._getSettings()}addListeners(e,t){return this._addListeners(e,t)}get isIDataValidationCollection(){return!0}},lO=class extends Hv{constructor(...e){super(...e),this._sessionUnlocked=!1}_initialize(e){super._initialize(e),this._updateState({...uO},m(`op.initializeProtectedRange`)),this._fromJSON(e?.json);let t=this._getState().name;t&&this._options.setContainerName?.(t)}_getActionDescription(e){return e===`delete`?m(`op.deleteProtectedRange`):e===`initialize`?m(`op.initializeProtectedRange`):null}_isAnchorAbsolute(){return!0}_processContainerShift(e){let t=super._processContainerShift(e);return e.after||this._getState().anchorCoords||this._delete(),this._processAnchorCoords(),t}getName(){return this._getState().name}setName(e,t){if(!e)throw new k(N(`error.protectedRange.noName`));if(e===this._getState().name)return this;let n=t?.description??m(`op.setProtectedRangeName`);return this.doBatch(()=>{this._options.setContainerName?.(e,{...t,description:n}),this._updateState({name:e},{...t,description:n},[`onConfigChange`])},{...t,description:n}),this}getIndex(){return this._options?.getContainerIndex?.()??-1}setIndex(e){return this._options?.setContainerIndex?.(e),this}setRanges(e,t){return this._setAnchorRanges(e,t)}getSecurityDescriptor(){return this._getState().securityDescriptor}setSecurityDescriptor(e,t){return this._updateState({securityDescriptor:e||null},{description:m(`op.setProtectedRangePermissions`),...t},[`onConfigChange`])}hasPassword(){return this._getState().password!==null}getEncryptedPassword(){return this._getState().password}async setPassword(e,t){let n=null;if(e){let r=t?.algorithm,i=t?.spinCount,a=await gh.generateSaltAndHash(e,r,i);n={salt:a.salt,hash:a.hash},r&&(n.algorithm=r),i&&(n.spinCount=i)}return this.relock(),this._updateState({password:n},{description:m(`op.setProtectedRangePassword`),...t},[`onConfigChange`])}isUnlocked(){return!this.hasPassword()||this._sessionUnlocked}async unlock(e){return!this.hasPassword()||!!await this.checkPassword(e)&&(this._sessionUnlocked||(this._sessionUnlocked=!0,this._notify([`onUnlockChange`])),!0)}relock(){return this._sessionUnlocked&&(this._sessionUnlocked=!1,this._notify([`onUnlockChange`])),this}async checkPassword(e){let t=this._getState().password;return!t||!t.hash&&!t.legacyHash||!!e&&gh.verifyStoredPassword(e,t)}update(e,t){let n=e&&`isIProtectedRange`in e?e.toJSON()??{}:{...e};return this.doBatch(()=>{let e=n.name;e!==void 0&&e!==this._getState().name&&this.setName(e,t),this._fromJSON({...n,name:void 0},t),this._notify([`onConfigChange`])},{description:m(`op.updateProtectedRange`),...t}),this}addListeners(e,t){return this._getEmitter().addListeners(e,t)}toJSON(){let e=this._getState();if(!e)return null;let t={};return e.name&&(t.name=e.name),e.securityDescriptor&&(t.securityDescriptor=e.securityDescriptor),e.password&&(t.password={...e.password}),t}_fromJSON(e,t){let n=e??{},r={};n.name!==void 0&&(r.name=n.name),n.securityDescriptor!==void 0&&(r.securityDescriptor=n.securityDescriptor||null),n.password!==void 0&&(r.password=n.password??null),Object.keys(r).length!==0&&this._updateState(r,{description:m(`op.addProtectedRange`),...t})}get[Symbol.toStringTag](){return`[ProtectedRange]`}toString(){return`ProtectedRange:${this.getName()}:${this.getRanges()?.toString()}`}get isIProtectedRange(){return!0}},uO=Object.freeze({name:``,securityDescriptor:null,password:null}),dO=Object.freeze({type:`checkbox`,accepts:e=>e==null||typeof e==`boolean`});(function(e){let t=new Map,n=!1,r=()=>{n||(n=!0,t.set(dO.type,dO))};e.register=function(e){if(!e?.type)throw Error(`A cell control kind needs a type.`);r(),t.set(e.type,e)},e.get=function(e){return r(),t.get(e)??null},e.getTypes=function(){return r(),[...t.keys()]}})(eO||={});var fO,pO=class e extends Hv{_initialize(t){super._initialize(t),this._updateState({json:e.normalizeJSON(t?.json)},m(`op.initializeCellControl`))}_getActionDescription(e){return e===`delete`?m(`op.deleteCellControl`):e===`initialize`?m(`op.initializeCellControl`):null}_isAnchorAbsolute(){return!0}_processContainerShift(e){let t=super._processContainerShift(e);return e.after||this._getState().anchorCoords||this._delete(),this._processAnchorCoords(),t}getType(){return this._getState().json.type}isAccepted(e){return eO.get(this.getType())?.accepts(e)??!1}_extendRanges(e){let t=this.getRanges().getCoords(),n=bm(t,e);h.isEqualRangesArrays(t,n)||this._setAnchorRanges(n)}addListeners(e,t){return this._getEmitter().addListeners(e,t)}toJSON(){return{...this._getState().json}}get[Symbol.toStringTag](){return`[CellControl]`}toString(){return`CellControl:${this.getType()}:${this.getRanges()?.toString()}`}get isICellControl(){return!0}};(fO=pO||={}).normalizeJSON=function(e){let t=e?.type;if(typeof t!=`string`||!t)throw Error(`A cell control needs a type, not '${t}'.`);return Object.freeze({...e})},fO.isSameJSON=function(e,t){if(e===t)return!0;if(e.type!==t.type)return!1;let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r<n.length;r++){let i=n[r];if(JSON.stringify(e[i])!==JSON.stringify(t[i]))return!1}return!0};var mO,hO,gO=class extends Qt{constructor(e,t,n){super(),this._add=e,this._get=t,this._addListeners=n}add(e,t,n){if(!e)throw Error(N(`error.address.noAddress`));return this._add(e,t,n)}_getItems(e){return this._get(e?.address,e?.ignoreHidden,e?.fullyContained)}addListeners(e,t){return this._addListeners(e,t)}get isICellControlCollection(){return!0}},_O={colorSeries:`#376092`,colorNegative:`#D00000`,colorAxis:`#000000`,colorMarkers:`#D00000`,colorFirst:`#D00000`,colorLast:`#D00000`,colorHigh:`#D00000`,colorLow:`#D00000`},vO=96/72;function yO(e,t){let n=(t.displayEmptyCellsAs??`zero`)===`zero`,r=[],{values:i,dates:a}=e;for(let e=0;e<i.length;e++){let t=i[e],o=t!==null&&Number.isFinite(t)?t:n?0:null;r.push({index:e,value:o,date:a?.[e]??null})}return r}function bO(e,t){let n=1/0,r=-1/0;for(let i of yO(e,t))i.value!==null&&(i.value<n&&(n=i.value),i.value>r&&(r=i.value));return n<=r?{min:n,max:r}:null}function xO(e,t,n,r,i,a=!1,o=!1){if(r<0&&!a&&!o&&n<=e&&i>=t)return null;let s=e,c=t;return!a&&e>=n&&(s+=Math.max(r,n-e)),!o&&t>=n&&(c+=Math.max(r,n-1-t)),[s,c]}function SO(e,t,n,r=!1,i=!1){return[r?e:e+n,i?t:t+n]}function CO(e,t,n,r,i,a){let o=e<n&&n<=t&&t<=r;if(!(o||n<=e&&e<=r&&t>r))return null;if(a)return o?[e,n-1]:[r+1,t];if(i===0)return null;if(o){if(i>0)return[e,t+i];if(t+i<e)return null;let a=Math.max(n,r+i+1);return t>=a?[e,a-1]:null}if(i<0)return[e+i,t];if(e+i>t)return null;let s=Math.min(r,n+i-1);return e<=s?[s+1,t]:null}(hO=mO||={}).Type={Line:`line`,Column:`column`,WinLoss:`winLoss`},hO.AxisType={Individual:`individual`,Group:`group`,Custom:`custom`},hO.EmptyCellsAs={Gap:`gap`,Zero:`zero`,Span:`span`};var wO=1048575,TO=e=>e.offset!==void 0,EO=e=>e.rowEnd-e.rowStart+1,DO=e=>e.colEnd-e.colStart+1,OO=(e,t,n)=>({rowStart:e.rowStart+t,colStart:e.colStart+n,rowEnd:e.rowEnd+t,colEnd:e.colEnd+n}),kO=(e,t)=>({rowStart:e,colStart:t,rowEnd:e,colEnd:t});function AO(e){if(!e)return null;let t=e.trim();if(t.startsWith(`=`)&&(t=t.substring(1)),!t||t.includes(`#REF!`))return null;let n=(e=>{let t=!1,n=-1;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i===39?t=!t:i!==33||t||(n=r)}return n})(t),r=n===-1?``:t.substring(0,n+1),i=t.substring(n+1);if(!i||/[^A-Za-z0-9$:]/.test(i))return null;let a=Jd(i);return a&&a.rowStart!==void 0&&a.colStart!==void 0&&a.rowEnd!==void 0&&a.colEnd!==void 0?{prefix:r,coords:a}:null}function jO(e,t,n){let r=AO(e);if(!r){let t=e.trim();return{text:t.startsWith(`=`)?t.substring(1):t}}let i=function(e){if(!e)return null;let t=e.endsWith(`!`)?e.substring(0,e.length-1):e;return t.startsWith(`'`)&&t.endsWith(`'`)&&t.length>=2&&(t=t.substring(1,t.length-1).replace(/''/g,`'`)),t}(r.prefix),a=r.coords;return{sheet:i===null?null:n(i),offset:{rowStart:a.rowStart-t.rowIndex,rowEnd:a.rowEnd-t.rowIndex,colStart:a.colStart-t.colIndex,colEnd:a.colEnd-t.colIndex}}}function MO(e,t){let n=e.offset,r={rowStart:t.rowIndex+n.rowStart,rowEnd:t.rowIndex+n.rowEnd,colStart:t.colIndex+n.colStart,colEnd:t.colIndex+n.colEnd};return r.rowStart<0||r.colStart<0||r.rowEnd>wO||r.colEnd>16383?null:r}var NO=e=>{let t=e.sheet;return t?t.isDeleted?.()?null:Ld(t.getName())+`!`:``};function PO(e,t){if(!TO(e))return e.text;let n=NO(e);if(n===null)return`#REF!`;let r=MO(e,t);return r?n+Wd(r):n+`#REF!`}var FO=e=>({rowIndex:e.rowStart,colIndex:e.colStart});function IO(e){return PO(e.data,FO(e.location))}function LO(e){return EO(e)*DO(e)}function RO(e,t){let n=DO(e);return{rowIndex:e.rowStart+Math.floor(t/n),colIndex:e.colStart+t%n}}function zO(e,t){return(t.rowIndex-e.rowStart)*DO(e)+(t.colIndex-e.colStart)}function BO(e,t){return TO(e)?TO(t)&&h.isEqualRanges(e.offset,t.offset)&&((e,t)=>e===t||!!e&&!!t&&e.getName().toUpperCase()===t.getName().toUpperCase())(e.sheet,t.sheet):!TO(t)&&e.text===t.text}function VO(e,t){if(!BO(e.data,t.data))return null;let n=((e,t)=>e.colStart!==t.colStart||e.colEnd!==t.colEnd||e.rowEnd+1!==t.rowStart&&t.rowEnd+1!==e.rowStart?e.rowStart!==t.rowStart||e.rowEnd!==t.rowEnd||e.colEnd+1!==t.colStart&&t.colEnd+1!==e.colStart?null:{...e,colStart:Math.min(e.colStart,t.colStart),colEnd:Math.max(e.colEnd,t.colEnd)}:{...e,rowStart:Math.min(e.rowStart,t.rowStart),rowEnd:Math.max(e.rowEnd,t.rowEnd)})(e.location,t.location);return n?{location:n,data:e.data}:null}function HO(e){let t=[];for(let n=0;n<e.length;n++){let r=t.length>0?t[t.length-1]:null,i=r?VO(r,e[n]):null;i?t[t.length-1]=i:t.push(e[n])}return t}function UO(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e[r].location;if(h.isCellWithinRange(t,i))return n+zO(i,t);n+=LO(i)}return 1/0}function WO(e,t){let n=h.intersectRanges(e.location,t);return n?h.isEqualRanges(n,e.location)?e:{location:n,data:e.data}:null}var GO=(e,t,n,r,i)=>{if(r<=0)return[];if(t-e+1===i)return[[e+n*i,t+(n+r-1)*i]];let a=Array(r);for(let o=0;o<r;o++)a[o]=[e+(n+o)*i,t+(n+o)*i];return a};function KO(e,t,n,r,i){let a=e.location,o=i===`row`?GO(a.rowStart,a.rowEnd,t,n,r):GO(a.colStart,a.colEnd,t,n,r),s=Array(o.length);for(let t=0;t<o.length;t++){let n=i===`row`?{...a,rowStart:o[t][0],rowEnd:o[t][1]}:{...a,colStart:o[t][0],colEnd:o[t][1]};s[t]={location:n,data:e.data}}return s}var qO=(e,t,n)=>{let r=t.offset;return h.intersectRanges(e,{rowStart:n.rowStart-r.rowStart,rowEnd:n.rowEnd-r.rowEnd,colStart:n.colStart-r.colStart,colEnd:n.colEnd-r.colEnd})},JO=(e,t,n,r)=>{if(!t)return null;let{before:i,after:a}=((e,t)=>{let n=[],r=[];return t.rowStart>e.rowStart&&n.push({...e,rowEnd:t.rowStart-1}),t.colStart>e.colStart&&n.push({...e,rowStart:t.rowStart,rowEnd:t.rowEnd,colEnd:t.colStart-1}),t.colEnd<e.colEnd&&r.push({...e,rowStart:t.rowStart,rowEnd:t.rowEnd,colStart:t.colEnd+1}),t.rowEnd<e.rowEnd&&r.push({...e,rowStart:t.rowEnd+1}),{before:n,after:r}})(e,t),o=[];for(let e=0;e<i.length;e++)o.push({location:i[e],data:n});o.push({location:t,data:r});for(let e=0;e<a.length;e++)o.push({location:a[e],data:n});return o};function YO(e,t,n,r){let i=n.rowStart-t.rowStart,a=n.colStart-t.colStart,o=[];for(let s=0;s<e.length;s++){let c=e[s],l=c.data,u=TO(l)&&!l.sheet,d=u&&r.sourceSheet?{offset:l.offset,sheet:r.sourceSheet}:l;if(!r.isCut){let e=GO(c.location.rowStart+i,c.location.rowEnd+i,0,Math.max(1,Math.ceil(EO(n)/EO(t))),EO(t)),r=GO(c.location.colStart+a,c.location.colEnd+a,0,Math.max(1,Math.ceil(DO(n)/DO(t))),DO(t));for(let t=0;t<e.length;t++)for(let i=0;i<r.length;i++){let a=h.intersectRanges({rowStart:e[t][0],rowEnd:e[t][1],colStart:r[i][0],colEnd:r[i][1]},n);a&&o.push({location:a,data:d})}continue}let f=OO(c.location,i,a);if(!TO(l)){o.push({location:f,data:l});continue}let p={offset:OO(l.offset,-i,-a),sheet:u?r.sourceSheet:l.sheet},m=u?qO(c.location,l,t):null,g=JO(f,m?OO(m,i,a):null,p,{offset:l.offset,sheet:null});g?o.push(...g):o.push({location:f,data:p})}return o}function XO(e,t,n,r){let i=e.data;if(!TO(i))return null;let a={offset:OO(i.offset,n.rowStart-t.rowStart,n.colStart-t.colStart),sheet:r===void 0?i.sheet:r};return JO(e.location,qO(e.location,i,t),i,a)}function ZO(e,t){let n=t.range,r=t.direction===B.Direction.Left||t.direction===B.Direction.Right,i=t.direction===B.Direction.Down||t.direction===B.Direction.Right;if(r){if(e.rowEnd<n.rowStart||e.rowStart>n.rowEnd||e.colEnd<n.colStart)return e;let t=n.colEnd-n.colStart+1,r=xO(e.colStart,e.colEnd,n.colStart,i?t:-t,n.colEnd);return r?r[0]===e.colStart&&r[1]===e.colEnd?e:{...e,colStart:r[0],colEnd:r[1]}:null}if(e.colEnd<n.colStart||e.colStart>n.colEnd||e.rowEnd<n.rowStart)return e;let a=n.rowEnd-n.rowStart+1,o=xO(e.rowStart,e.rowEnd,n.rowStart,i?a:-a,n.rowEnd);return o?o[0]===e.rowStart&&o[1]===e.rowEnd?e:{...e,rowStart:o[0],rowEnd:o[1]}:null}var QO=(e,t,n)=>{let r=[];for(let i=0;i<n.length;i++)n[i]>e&&n[i]<=t&&r.push(n[i]);return r.sort((e,t)=>e-t),r},$O=(e,t,n)=>{let r=[],i=e;for(let e=0;e<n.length;e++)n[e]<=i||(r.push([i,n[e]-1]),i=n[e]);return r.push([i,t]),r},ek=e=>({text:(NO(e)??``)+`#REF!`}),tk=(e,t,n,r)=>{let i=r.cells?ZO(e,n):e;if(!i)return[];if(!TO(t))return[{location:i,data:t}];if(!r.data){let n=i.rowStart-e.rowStart,r=i.colStart-e.colStart;return[{location:i,data:n===0&&r===0?t:{offset:OO(t.offset,-n,-r),sheet:t.sheet}}]}let a=FO(e),o={rowIndex:e.rowEnd,colIndex:e.colEnd},s=kO(a.rowIndex,a.colIndex),c=kO(o.rowIndex,o.colIndex),l=r.cells?ZO(s,n):s,u=r.cells?ZO(c,n):c,d=MO(t,a),f=MO(t,o),p=d?ZO(d,n):null,m=f?ZO(f,n):null;if(!p&&!m)return[{location:i,data:ek(t)}];if(p&&m){let e=OO(p,-l.rowStart,-l.colStart),n=OO(m,-u.rowStart,-u.colStart);if(h.isEqualRanges(e,n))return[{location:i,data:{offset:e,sheet:t.sheet}}]}let g=[];if(EO(e)>1)for(let i=e.rowStart;i<=e.rowEnd;i++)g.push(...tk({...e,rowStart:i,rowEnd:i},t,n,r));else for(let i=e.colStart;i<=e.colEnd;i++)g.push(...tk({...e,colStart:i,colEnd:i},t,n,r));return g},nk=(e,t,n)=>{let r=e.location,i=e.data,a={cells:n.cells,data:n.data&&TO(i)},o=a.cells&&ZO(r,t)!==r,s=!1;if(a.data){let e=i.offset,n={rowStart:r.rowStart+e.rowStart,rowEnd:r.rowEnd+e.rowEnd,colStart:r.colStart+e.colStart,colEnd:r.colEnd+e.colEnd};s=ZO(n,t)!==n}if(!o&&!s)return null;let c=t.range,l=[],u=[];if(a.cells&&(l.push(c.rowStart,c.rowEnd+1),u.push(c.colStart,c.colEnd+1)),a.data){let e=i.offset;l.push(c.rowStart-e.rowStart,c.rowEnd+1-e.rowStart,c.rowStart-e.rowEnd,c.rowEnd+1-e.rowEnd),u.push(c.colStart-e.colStart,c.colEnd+1-e.colStart,c.colStart-e.colEnd,c.colEnd+1-e.colEnd)}let d=$O(r.rowStart,r.rowEnd,QO(r.rowStart,r.rowEnd,l)),f=$O(r.colStart,r.colEnd,QO(r.colStart,r.colEnd,u)),p=[];for(let e=0;e<d.length;e++)for(let n=0;n<f.length;n++){let r={rowStart:d[e][0],rowEnd:d[e][1],colStart:f[n][0],colEnd:f[n][1]};p.push(...tk(r,i,t,a))}let m=t.direction!==B.Direction.Down&&t.direction!==B.Direction.Right||!a.cells?null:ZO(r,t);if(m&&LO(m)>LO(r)&&p.length>0){let e=!0;for(let t=1;t<p.length&&e;t++)e=BO(p[0].data,p[t].data);if(e)return[{location:m,data:p[0].data}]}return p},rk=(e,t,n)=>{let r=[e],i=!1;for(let e=0;e<t.length;e++){let a=[];for(let o=0;o<r.length;o++){let s=nk(r[o],t[e],n);s?(i=!0,a.push(...s)):a.push(r[o])}r=a}return i?HO(r):null};function ik(e,t){let n=e.data;return rk(e,t,{cells:!0,data:TO(n)&&!n.sheet})}function ak(e,t){return rk(e,t,{cells:!1,data:!0})}function ok(e){let t=e.data;if(!TO(t))return null;let n=e.location,r=t.offset;return{rowStart:Math.max(0,n.rowStart+r.rowStart),rowEnd:Math.min(wO,n.rowEnd+r.rowEnd),colStart:Math.max(0,n.colStart+r.colStart),colEnd:Math.min(16383,n.colEnd+r.colEnd)}}function sk(e,t){for(let t=0;t<e.length;t++)if(EO(e[t])>1&&DO(e[t])>1)return{refused:`location2D`};if(e.length===0||t.length===0)return{refused:`count`};let n=0;for(let t=0;t<e.length;t++)n+=LO(e[t]);if(t.length===1)return ck(e,n,t[0]);let r=[];if(t.length===e.length){for(let n=0;n<e.length;n++){let i=ck([e[n]],LO(e[n]),t[n]);if(`refused`in i)return i;r.push({...i.pairs[0],dataIndex:n})}return{pairs:r}}if(t.length===n){let n=0;for(let i=0;i<e.length;i++){let a=e[i],o=LO(a);for(let e=0;e<o;e++){let i=t[n];if(EO(i)>1&&DO(i)>1)return{refused:`data2D`};let o=RO(a,e);r.push({location:kO(o.rowIndex,o.colIndex),first:i,dataIndex:n++})}}return{pairs:r}}return{refused:`count`}}var ck=(e,t,n)=>{let r=EO(n),i=DO(n);if(t===1)return r>1&&i>1?{refused:`data2D`}:{pairs:[{location:e[0],first:n,dataIndex:0}]};let a=r===t,o=!a&&i===t,s=!a&&!o&&i===1&&r>t,c=!a&&!o&&!s&&r===1&&i>t;if(!(a||o||s||c))return{refused:`count`};let l=a||s,u=s?r-t+1:c?i-t+1:1,d=[],f=0;for(let t=0;t<e.length;t++){let r=e[t];if(!(l?DO(r)===1:EO(r)===1))return{refused:`transposed`};let i=l?{...n,rowStart:n.rowStart+f,rowEnd:n.rowStart+f+u-1}:{...n,colStart:n.colStart+f,colEnd:n.colStart+f+u-1};d.push({location:r,first:i,dataIndex:0}),f+=LO(r)}return{pairs:d}},lk=Object.freeze({}),uk=class{constructor(e,t){this._name=e,this._resolve=t,this._sheet=null}_found(){return!this._sheet&&this._resolve&&(this._sheet=this._resolve(this._name)),this._sheet}getSheet(){return this._found()}getName(){return this._found()?.getName()??this._name}isDeleted(){let e=this._found();return!!e&&(e.isDeleted()||e.isClosed())}},dk=class e extends Hv{constructor(e){super(e),this._pendingMoves=null,this._plannedShift=null,this._dataListeners=new Map,this._lookedAgain=!1,this._layoutListeners=0,this._layoutSources=null,this._layoutCells=new Map,this._layoutSheets=new Map,this._layoutQueued=!1,this._extent=void 0,this._syncDataListeners()}_initialize(t){super._initialize(t);let n=t.json,{properties:r,data:i}=e.splitJSON(n),a=Array.isArray(t.coords)?t.coords:[t.coords],o=this._parseRanges(a,i,t),s=HO(o),c={json:r,ranges:s};if(s.length!==o.length){let t=e.locationsOf(s);c.anchorCoords=t,this._options.setContainerCoords?.(t)}this._updateState(c,m(`op.initializeSparklineGroup`),null,!0)}_parseRanges(e,t,n=this._options){if(e.length!==t.length)throw Error(`A sparkline group has ${e.length} ranges and ${t.length} data areas; they must pair.`);let r=n.getSheetName?.()?.toUpperCase()??null,i=new Map,a=e=>{let t=e.toUpperCase();if(t===r)return null;let a=i.get(t);return a||(a=new uk(e,n.resolveSheet??null),i.set(t,a)),a},o=Array(e.length);for(let n=0;n<e.length;n++){let r=h.sanitizeRange(e[n]);o[n]={location:r,data:jO(t[n],{rowIndex:r.rowStart,colIndex:r.colStart},a)}}return o}_restate(e,t){this.isDeleted()||this._setRanges(HO(this._parseRanges(e,t)),!0)}_getActionDescription(e){return e===`delete`?m(`op.deleteSparklineGroup`):e===`initialize`?m(`op.initializeSparklineGroup`):null}_isAnchorAbsolute(){return!0}get _sparklineRanges(){return this._getState()?.ranges??[]}get _properties(){return this._getState()?.json??lk}_setRanges(t,n){this._updateState({ranges:t},{description:m(`op.updateAnchor`)},null,!0),n&&this._setAnchorRanges(e.locationsOf(t)),this._syncDataListeners()}_worksheetOf(e){let t=e.data;return TO(t)&&t.sheet&&!t.sheet.isDeleted?.()?t.sheet instanceof uk?t.sheet.getSheet():t.sheet:null}_syncDataListeners(){let e=new Map,t=!1;if(!this.isDeleted()&&!this.isClosed()){let n=this._getState()?.ranges??[];for(let r=0;r<n.length;r++){let i=n[r].data;if(!TO(i)||!i.sheet)continue;let a=this._worksheetOf(n[r]),o=ok(n[r]);if(!a){i.sheet.isDeleted?.()||(t=!0);continue}if(!o)continue;let s=e.get(a);e.set(a,s?h.unionRanges(s,o):o)}}for(let[t,n]of this._dataListeners){let r=e.get(t);r&&h.isEqualRanges(r,n.coords)||(n.remove(),this._dataListeners.delete(t))}for(let[t,n]of e){if(this._dataListeners.has(t))continue;let e=t.getRange(n).addListener(e=>{e.getTrigger()===`address`&&this._onDataEdits(t,e.getEdits())},{transactional:!0,edits:!0,ignoreDataChanges:!0});this._dataListeners.set(t,{coords:n,remove:e})}t&&!this._lookedAgain&&(this._lookedAgain=!0,Promise.resolve().then(()=>this._syncDataListeners()))}_releaseDataListeners(){for(let e of this._dataListeners.values())e.remove();this._dataListeners.clear()}_onDataEdits(e,t){if(this.isDeleted()||t.length===0)return;let n=this._sparklineRanges,r=!1;for(let i=0;i<t.length;i++){let a=t[i],o=[];for(let t=0;t<n.length;t++){let i=this._worksheetOf(n[t])===e?a.type===`shift`?ak(n[t],[{range:a.range,direction:a.direction}]):XO(n[t],a.from,a.to,a.toSheet?this._dataSheetOf(a.toSheet):void 0):null;i&&(r=!0),o.push(...i??[n[t]])}n=o}r&&this._setRanges(HO(n),!0)}_watchLayout(e){if(this._layoutListeners+=e,this._layoutListeners>0&&!this._layoutSources&&!this.isClosed()){let e=this._options.getStyles?.(),t=[this._getEmitter().addListeners({onAnyChange:()=>{this._syncLayoutCells(),this._layoutChanged()}}),e?.addListeners({onThemeChange:()=>this._layoutChanged()})];this._layoutSources=t.filter(e=>!!e),this._syncLayoutCells()}else this._layoutListeners<=0&&this._layoutSources&&this._releaseLayoutSources()}_releaseLayoutSources(){for(let e of this._layoutSources??[])e();this._layoutSources=null;for(let e of this._layoutCells.values())e.remove();this._layoutCells.clear();for(let e of this._layoutSheets.values())e();this._layoutSheets.clear(),this._extent=void 0}_layoutChanged(){this._extent=void 0,this._layoutQueued||(this._layoutQueued=!0,queueMicrotask(()=>{this._layoutQueued=!1,!this.isClosed()&&this._layoutListeners>0&&this._getEmitter().notify(`onLayoutChange`)}))}_syncLayoutCells(){if(!this._layoutSources||this.isClosed())return;let e=new Map,t=(t,n)=>{if(!t||!n)return;let r=e.get(t);e.set(t,r?h.unionRanges(r,n):n)};if(!this.isDeleted()){let e=this._sparklineRanges;for(let n=0;n<e.length;n++){let r=ok(e[n]);r&&t(this._dataCells(e[n],r)?.getWorksheet(),r)}let n=this._properties.dateRange,r=n?this._resolve(n):null;r&&!r.isInvalid()&&t(r.getWorksheet(),r.getCoords())}let n=()=>this._layoutChanged();for(let[t,n]of this._layoutCells){let r=e.get(t);r&&h.isEqualRanges(r,n.coords)||(n.remove(),this._layoutCells.delete(t))}for(let[t,r]of e){if(this._layoutCells.has(t))continue;let e=t.getRange(r).addListener(n,{transactional:!1});this._layoutCells.set(t,{coords:r,remove:e})}for(let[t,n]of this._layoutSheets)e.has(t)||(n(),this._layoutSheets.delete(t));for(let t of e.keys())this._layoutSheets.has(t)||this._layoutSheets.set(t,t.addListeners({onRowsHiddenChange:n,onColumnsHiddenChange:n},{transactional:!1}))}_processDelete(){this._releaseDataListeners(),super._processDelete()}_processAfterStateChange(e,t,n=!1,r=!1){super._processAfterStateChange(e,t,n,r),this._emitter.notify(`onAnyChange`)}_isAnyChangeFromState(){return!0}_processRestoreOrRevert(e,t){super._processRestoreOrRevert(e,t),Promise.resolve().then(()=>this._syncDataListeners())}_processClose(){this._releaseDataListeners(),this._releaseLayoutSources(),super._processClose()}_processContainerShift(e){(this._pendingMoves??=[]).push({before:e.before,after:e.after});let t=super._processContainerShift(e);return e.after||this._getState()?.anchorCoords||(this._pendingMoves=null,this._delete()),this._processAnchorCoords(),t}_processAfterContainerShift(t,n){let r=this._pendingMoves;if(this._pendingMoves=null,!this.isDeleted()){let t=this._sparklineRanges,i=r?e.followShift(t,r,n??[]):e.followTrim(t,n??[]);i!==t&&this._setRanges(i,!1)}super._processAfterContainerShift(t,n)}_rangesWithin(e){return function(e,t){let n=[];for(let r=0;r<e.length;r++){let i=WO(e[r],t);i&&n.push(i)}return n}(this._sparklineRanges,e)}_addRanges(e){e.length===0||this.isDeleted()||this._setRanges(function(e,t){let n=e.slice();for(let e=0;e<t.length;e++){let r=t[e],i=-1;for(let e=n.length-1;e>=0&&i===-1;e--){let t=VO(n[e],r);t&&(r=t,i=e)}i===-1?n.push(r):n[i]=r}return n}(this._sparklineRanges,e),!0)}_rangesNow(){return this._sparklineRanges}_putBackCut(e,t,n,r){e.length===0||this.isDeleted()||this._setRanges(function(e,t,n,r,i){let a=e.map(e=>({range:e,key:UO(n,FO(e.location))}));for(let e=0;e<t.length;e++){let o=t[e],s=UO(n,{rowIndex:o.location.rowStart-r,colIndex:o.location.colStart-i}),c=a.length;for(let e=0;e<a.length;e++)if(a[e].key>s){c=e;break}a.splice(c,0,{range:o,key:s})}return HO(a.map(e=>e.range))}(this._sparklineRanges,e,t,n,r),!0)}_planShift(e){if(this._plannedShift=null,this.isDeleted())return;let t=this._sparklineRanges,n=null;for(let r=0;r<t.length;r++){let i=ik(t[r],e);i&&!n&&(n=t.slice(0,r)),n&&n.push(...i??[t[r]])}this._plannedShift=n?HO(n):null}_settleShift(){let t=this._plannedShift;return this._plannedShift=null,!t||this.isDeleted()?null:(this._setRanges(t,!1),e.locationsOf(t))}_dataSheetOf(e){let t=this._options.getSheetName?.();return t!==void 0&&e.getName().toUpperCase()===t.toUpperCase()?null:e}_moveData(e,t,n){if(this.isDeleted())return;let r=this._sparklineRanges,i=n?this._dataSheetOf(n):void 0,a=null;for(let n=0;n<r.length;n++){let o=r[n].data;if(!TO(o)||o.sheet){a&&a.push(r[n]);continue}let s=XO(r[n],e,t,i);s&&!a&&(a=r.slice(0,n)),a&&a.push(...s??[r[n]])}a&&this._setRanges(HO(a),!0)}getType(){return this._properties.type??mO.Type.Line}getProperties(){return this._properties}update(t,n){let r=e.applyModifiers(this._properties,t??{});return this._updateState({json:r},{description:m(`op.updateSparklineGroup`),...n})}getDataRange(){let e=this._sparklineRanges;return e.length>0?this._dataRangeOf(e[0]):gz}getDataRanges(){let e=this._sparklineRanges,t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=this._dataRangeOf(e[n]);return t}_dataRangeOf(e){let t=ok(e);return(t?this._dataCells(e,t):null)??gz}setDataRanges(e,t){return this._modify(null,e,t)}setRanges(e,t,n){return this._modify(e,t??null,n)}_modify(e,t,n){let r=this._options.modify;if(!r)throw Error(`A sparkline group that is not on a sheet cannot change its cells.`);return r(this,e,t,n),this}getSparklines(){let e=this._sparklineRanges,t=[];for(let n=0;n<e.length;n++){let r=LO(e[n].location);for(let i=0;i<r;i++)t.push(this._sparklineOf(e[n],RO(e[n].location,i)))}return t}getSparklineAt(e){if(!Number.isInteger(e)||e<0)return null;let t=this._sparklineRanges,n=e;for(let e=0;e<t.length;e++){let r=LO(t[e].location);if(n<r)return this._sparklineOf(t[e],RO(t[e].location,n));n-=r}return null}getSparkline(e){let t=this._options.getRanges(e).at(0)?.getCoords();if(!t)return null;let n={rowIndex:t.rowStart,colIndex:t.colStart},r=this._sparklineRanges;for(let e=0;e<r.length;e++)if(h.isCellWithinRange(n,r[e].location))return this._sparklineOf(r[e],n);return null}_sparklineOf(e,t){let n=this;return{getRange:()=>n._options.getRanges(h.cellToRange(t)).at(0),getDataRange:()=>{let r=e.data,i=PO(r,t);if(!AO(i))return gz;try{let e=n._options.resolveRange;return(TO(r)&&r.sheet&&e?e(i):n._options.getRanges(i).at(0))??gz}catch{return gz}},getLayout:r=>n._layoutOf(e,t,r),getGroup:()=>n,isISparkline:!0}}_dataCells(e,t){let n=e.data;return TO(n)?n.sheet?this._worksheetOf(e)?.getRange(t)??null:this._options.getRanges(t).at(0)??null:null}_resolve(e){try{return e.includes(`!`)?this._options.resolveRange?.(e)??null:this._options.getRanges(e).at(0)??null}catch{return null}}_groupExtent(t){let n=1/0,r=-1/0,i=this._sparklineRanges;for(let a=0;a<i.length;a++){let o=ok(i[a]),s=o?this._dataCells(i[a],o):null;if(!s)continue;let c=bO({values:e.readValues(s,t)},t);c&&(c.min<n&&(n=c.min),c.max>r&&(r=c.max))}return n<=r?{min:n,max:r}:null}_watchedExtent(e){return this._layoutSources?(this._extent===void 0&&(this._extent=this._groupExtent(e)),this._extent):this._groupExtent(e)}_layoutOf(t,n,r){let i=this._properties,a=this._sparklineOf(t,n).getDataRange(),o=a.isInvalid()?[]:e.readValues(a,i),s=null;if(i.dateAxis&&i.dateRange){let t=this._resolve(i.dateRange);t&&(s=e.readValues(t,i))}let c=i.minAxisType===`group`||i.maxAxisType===`group`,l=this._options.getStyles?.()??null;return function(e,t){let{width:n,height:r,properties:i}=t,a=i.type??`line`,o=e=>t.color(i[e]||_O[e]),s=Math.min(2,n/2),c=Math.max(n-2,s),l=Math.min(4,r/2),u=Math.max(r-3,l),d={x:s,y:l,width:c-s,height:u-l},f={width:n,height:r,type:a,plot:d,axis:null,line:null,columns:[],markers:[],min:null,max:null},p=yO(e,i),m=bO(e,i);if(p.length===0||!m)return f;let h=(e,t,n,r)=>e===`custom`&&t!==void 0&&Number.isFinite(t)?t:e===`group`&&r!==void 0?r:n,g=h(i.minAxisType,i.manualMin,m.min,t.groupExtent?.min),_=h(i.maxAxisType,i.manualMax,m.max,t.groupExtent?.max);f.min=g,f.max=_;let v=_-g,y=l+Math.min(.5,d.height/2),b=u-Math.min(.5,d.height/2),x=e=>{if(v<=0)return(y+b)/2;let t=y+(_-e)/v*(b-y);return Math.min(b,Math.max(y,t))},S=p.length,C=d.width/S,w=!0===i.rightToLeft,T=Array(S),E=1/0,D=-1/0;if(i.dateAxis)for(let e of p)e.date!==null&&(e.date<E&&(E=e.date),e.date>D&&(D=e.date));let O=E<D;for(let e=0;e<S;e++){let t;if(O){let n=p[e].date;t=n===null?NaN:C/2+(n-E)/(D-E)*(d.width-C)}else t=(e+.5)*C;T[e]=w?c-t:s+t}let k=-1,A=-1;for(let e=0;e<S;e++)p[e].value===null||Number.isNaN(T[e])||(k<0&&(k=e),A=e);let j=e=>{let t=p[e].value;if(t===null)return null;let n=null;return i.negative&&t<0&&(n=o(`colorNegative`)),i.first&&e===k&&(n=o(`colorFirst`)),i.last&&e===A&&(n=o(`colorLast`)),i.high&&t===m.max&&(n=o(`colorHigh`)),i.low&&t===m.min&&(n=o(`colorLow`)),n};if(a===`line`){let e=(i.lineWeight??.75)*vO,t=(i.displayEmptyCellsAs??`zero`)===`span`,n=[],r=[];for(let e=0;e<S;e++){let i=p[e].value;i===null||Number.isNaN(T[e])?!t&&r.length>0&&(n.push(r),r=[]):r.push({x:T[e],y:x(i)})}r.length>0&&n.push(r),f.line={runs:n,color:o(`colorSeries`),width:e};let a=1.5+e/2;for(let e=0;e<S;e++){let t=p[e].value;if(t===null||Number.isNaN(T[e]))continue;let n=j(e)??(i.markers?o(`colorMarkers`):null);n&&f.markers.push({index:p[e].index,center:{x:T[e],y:x(t)},radius:a,color:n})}}else{let e=a===`winLoss`,t=e?0:Math.min(_,Math.max(g,0)),n=l+d.height/2,r=e?n:v<=0?g>0?u:g<0?l:n:x(t),i=.72*C/2;for(let a=0;a<S;a++){let s=p[a].value;if(s===null||Number.isNaN(T[a]))continue;let c,d;if(e){if(s===0)continue;[c,d]=s>0?[l,n]:[n,u]}else{let e=x(s);[c,d]=s>t||s===t&&_>t?[e-.5,r]:[r,e+.5]}let m=Math.round(T[a]-i),h=Math.round(T[a]+i),g=Math.round(c),v=Math.round(d),y=j(a)??o(`colorSeries`);f.columns.push({index:p[a].index,rect:{x:m,y:g,width:Math.max(1,h-m),height:Math.max(1,v-g)},color:y})}}if(i.displayXAxis){let e=a===`winLoss`?l+d.height/2:g<=0&&_>=0&&v>0?x(0):null;if(e!==null){let t=Math.floor(e)+.5;f.axis={from:{x:s,y:t},to:{x:c,y:t},color:o(`colorAxis`),width:1}}}return f}({values:o,dates:s},{width:r.width,height:r.height,properties:i,color:t=>e.toColor(t,l),groupExtent:c?this._watchedExtent(i):null})}addListeners(e,t){let n=this._getEmitter().addListeners(e,t);if(!e.onLayoutChange)return n;this._watchLayout(1);let r=!1;return()=>{n(),r||(r=!0,this._watchLayout(-1))}}toJSON(){let e=this._properties,t=this._sparklineRanges,n=Array(t.length);for(let e=0;e<t.length;e++)n[e]=IO(t[e]);let r={...e,data:n.join(`,`)};return e.rest&&(r.rest={...e.rest}),r}get[Symbol.toStringTag](){return`[SparklineGroup]`}toString(){return`SparklineGroup:${this.getType()}:${this.getRanges()?.toString()}`}get isISparklineGroup(){return!0}};(function(e){function t(e){return typeof e==`number`?Number.isFinite(e)?e:null:e==null||e===``?null:typeof e==`boolean`?+!!e:!0===e.isFormulaError&&e.getCode()===V.Code.NA?null:0}e.readValues=function(e,n){let r;try{let t=e.getCoords(),i=(t.rowEnd-t.rowStart+1)*(t.colEnd-t.colStart+1);r=e.getValues({ignoreHidden:!0!==n.displayHidden,maxSize:i})}catch{return[]}let i=[];for(let e=0;e<r.length;e++){let n=r[e];for(let e=0;e<n.length;e++)i.push(t(n[e]))}return i},e.plotValue=t,e.freshProperties=function(e){let t={displayEmptyCellsAs:`gap`,colorSeries:`ff376092`,colorNegative:`ffd00000`,colorAxis:`ff000000`,colorMarkers:`ffd00000`,colorFirst:`ffd00000`,colorLast:`ffd00000`,colorHigh:`ffd00000`,colorLow:`ffd00000`};return e===`winLoss`&&(t.negative=!0),t};let n={type:Object.values(mO.Type),displayEmptyCellsAs:Object.values(mO.EmptyCellsAs),minAxisType:Object.values(mO.AxisType),maxAxisType:Object.values(mO.AxisType)},r=new Set([`lineWeight`,`manualMin`,`manualMax`]),i=new Set([`markers`,`high`,`low`,`first`,`last`,`negative`,`displayXAxis`,`displayHidden`,`rightToLeft`,`dateAxis`]);e.applyModifiers=function(e,t){let a={...e};for(let[e,o]of Object.entries(t)){if(o===void 0||e===`rest`||e===`data`)continue;if(o===null){delete a[e];continue}let t=n[e];if(!(t?t.includes(o):r.has(e)?typeof o==`number`&&Number.isFinite(o):i.has(e)?typeof o==`boolean`:e.startsWith(`color`)?typeof o==`string`||!0===o.isIColor:e===`dateRange`&&typeof o==`string`))throw new k(N(`error.sparkline.property`,{name:e,value:String(o)}));a[e]=e.startsWith(`color`)&&typeof o!=`string`?o.toString():o}return Object.freeze(a)},e.toColor=function(e,t){try{return t?t.parseColor(e):new De(e)}catch{return new De(`#000000`)}},e.splitJSON=function(e){let t=e?.data,n=typeof t==`string`?Xd(t):[];if(n.length===0)throw Error(`A sparkline group needs data.`);let{data:r,...i}=e;return i.rest&&=Object.freeze({...i.rest}),{properties:Object.freeze(i),data:n}},e.locationsOf=function(e){let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=e[n].location;return t},e.followTrim=function(e,t){if(fk(e,t))return e;let n=[];for(let r=0;r<t.length;r++){let i=h.sanitizeRange(t[r]);for(let t=0;t<e.length;t++)if(h.isRangeWithinRange(i,e[t].location)){n.push(h.isEqualRanges(i,e[t].location)?e[t]:{location:i,data:e[t].data});break}}return n},e.followShift=function(e,t,n){let r=null;if(t.length>0){r=[];for(let n=0;n<e.length;n++){let i=e[n],a=i.location;for(let e=0;e<t.length;e++)if(h.isEqualRanges(t[e].before,i.location)){a=t[e].after;break}a&&r.push(a===i.location?i:{...i,location:h.sanitizeRange(a)})}}let i=r??e;if(fk(i,n))return r??e;if(i.length===n.length){let e=Array(n.length);for(let t=0;t<n.length;t++)e[t]=h.isEqualRanges(i[t].location,n[t])?i[t]:{...i[t],location:h.sanitizeRange(n[t])};return e}return r??e}})(dk||={});var fk=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(!h.isEqualRanges(e[n].location,t[n]))return!1;return!0},pk=class extends Qt{constructor(e,t,n){super(),this._add=e,this._get=t,this._addListeners=n}add(e,t,n,r){return this._add(e,t,n,r)}_getItems(e){return this._get(e?.address,e?.ignoreHidden,e?.fullyContained)}addListeners(e,t){return this._addListeners(e,t)}get isISparklineGroupCollection(){return!0}},mk=class extends Qt{constructor(e,t,n,r,i){super(),this._add=e,this._get=t,this._getByName=n,this._createItem=r,this._addListeners=i}add(e,t){if(!e)throw Error(N(`error.address.noAddress`));return this._add(e,t)}_getItems(e){if(e?.name){let t=this._getByName(e.name);return t?[t]:[]}return this._get(e?.address,e?.ignoreHidden,e?.fullyContained)}createItem(e){return this._createItem(e)}addListeners(e,t){return this._addListeners(e,t)}get isIProtectedRangeCollection(){return!0}};function hk(e){return e==null?null:typeof e==`string`?{content:e}:{...e}}function gk(e){if(!e)return``;if(typeof e==`string`)return e;let t=e.runs;if(!t)return``;let n=``,r=t.length;for(let e=0;e<r;e++)n+=t[e]?.text??``;return n}function _k(e){if(!e)return``;if(typeof e==`string`)return e;let t=e.runs;if(!Array.isArray(t)||t.length===0)return``;let n=!0,r=Array(t.length);for(let e=0;e<t.length;e++){let i=vk(t[e]);i.font&&(n=!1),r[e]=i}return n?gk(e):{runs:r}}function vk(e){let t=typeof e?.text==`string`?e.text:``,n=e?.font;n!==void 0&&typeof n!=`string`||(n={},e?.font&&(n.family=e.font),e?.size!==void 0&&(n.size=e.size),e?.bold!==void 0&&(n.bold=e.bold),e?.italic!==void 0&&(n.italic=e.italic),e?.color!==void 0&&(n.color=e.color));let r=function(e){if(!e||typeof e!=`object`)return null;let{bold:t,italic:n,weight:r,underline:i,...a}=e,o={};for(let e in a){let t=a[e];t!=null&&(o[e]=Array.isArray(t)?[...t]:t)}if(r!=null){let e=typeof r==`number`?r:Tt(r);isNaN(e)||(o.weight=e)}else typeof t==`boolean`&&(o.weight=t?700:400);return o.style===void 0&&typeof n==`boolean`&&(o.style=n?I.Style.Italic:I.Style.Normal),!0===i?o.underline=I.UnderlineStyle.Single:typeof i==`string`&&(o.underline=i),Object.keys(o).length>0?o:null}(n);return r?{text:t,font:r}:{text:t}}function yk(e){return typeof e==`string`?e:{runs:e.runs.map(e=>function(e){if(!e.font)return{text:e.text};let t={...e.font};return t.fallbacks&&=[...t.fallbacks],{text:e.text,font:t}}(e))}}var bk=/<x:Anchor>([\s\d,-]*)<\/x:Anchor>/,xk=/<x:Row>\s*(-?\d+)\s*<\/x:Row>/,Sk=/<x:Column>\s*(-?\d+)\s*<\/x:Column>/,Ck=/<x:Visible\s*\/>/;function wk(e,t){return e&&typeof e==`object`&&e.isIPerson?e.getId():t?typeof e==`string`&&e?t.add(e).getId():t.getCurrent().getId():null}function Tk(e,t){return e(t)??{rowStart:t.rowIndex,colStart:t.colIndex,rowEnd:t.rowIndex,colEnd:t.colIndex}}function Ek(e,t){let n=t.getBoundsAtCoords(e),r=t.getMaxBounds(),i=n.x+n.width+15;i+144>r.x+r.width&&(i=Math.max(r.x,n.x-15-144));let a=n.y-10;return a+79>r.y+r.height&&(a=n.y+10-79),a=Math.max(r.y+2,a),{x:i,y:a,width:144,height:79}}function Dk(e,t){let n=t.getMaxBounds();return{x:n.x+e.x,y:n.y+e.y,width:e.width,height:e.height}}var Ok=(e,t,n)=>{let r=e.getCoordsAtBounds({x:t,y:n,width:0,height:0}),i=((e,t,n)=>e.getBoundsAtCoords({rowStart:t,colStart:n,rowEnd:t,colEnd:n}))(e,r.rowStart,r.colStart);return{c:r.colStart,r:r.rowStart,x:t-i.x,y:n-i.y}};function kk(e,t){return{tl:Ok(t,e.x,e.y),br:Ok(t,e.x+e.width,e.y+e.height)}}function Ak(e,t,n){let r=e=>({c:Math.min(n.colEnd,Math.max(n.colStart,t.colIndex+(e.c??0))),r:Math.min(n.rowEnd,Math.max(n.rowStart,t.rowIndex+(e.r??0))),x:e.x??0,y:e.y??0});return{tl:r(e.tl),br:r(e.br)}}var jk=class extends Hv{constructor(...e){super(...e),this._replies=new Map,this._style=null}_initialize(e){super._initialize(e),this._boxes=[],this._updateState({...Ik,commentId:i.uuidV4().toUpperCase()},m(`op.initializeComment`)),this._fromJSON(e?.json)}_getActionDescription(e){return e===`delete`?m(`op.deleteComment`):e===`initialize`?m(`op.initializeComment`):null}_isAnchorAbsolute(){return!0}_processContainerShift(e){let t=super._processContainerShift(e);return e.after||this._getState().anchorCoords||this._delete(),this._processAnchorCoords(),t}_processDelete(){super._processDelete(),this._removeBox()}getId(){return this._getState().commentId}getWorksheet(){return this.getRange().getWorksheet()}getRange(e){return super.getRange(e)}getContent(){return gk(this._getState().content)}setContent(e,t){return this._updateState({content:_k(e),mentions:null},{description:m(`op.setCommentContent`),...t},[`onContentChange`])}getRichContent(){let e=this._getState().content;return typeof e==`string`?null:yk(e)}getAuthor(){return this._resolvePerson(this._getState().personId)}getCreationDate(){return Nk(this._getState().dt)}isResolved(){return this._getState().done}setResolved(e,t){return!!e===this._getState().done?this:this._updateState({done:!!e},{description:m(e?`op.resolveComment`:`op.reopenComment`),...t},[`onResolvedChange`])}isNote(){return this._getState().asNote}getReplies(){let e=this._getState().replies,t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=this._replyFor(e[n].id);return t}getReply(e){return typeof e==`string`&&this._findReplyJSON(e)?this._replyFor(e):null}addReply(e,t){let{person:n,...r}=t??{},a={id:i.uuidV4().toUpperCase(),personId:wk(n,this._getPeople())??void 0,content:gk(e),dt:new Date().toISOString()},o=this._getState(),s=o.asNote,c=this._beginCommit({description:m(`op.addCommentReply`),...r});try{this._updateState({replies:[...o.replies,a],...s?Lk:null},{description:m(`op.addCommentReply`),...r},[`onRepliesChange`]),s&&this._removeBox(),c.commit()}catch(e){throw c.rollback(),e}return this._replyFor(a.id)}update(e,t){let n=e&&`isIComment`in e?function(e){let t={content:e.getRichContent()??e.getContent(),asNote:e.isNote(),resolved:e.isResolved()},n=e.getAuthor();return n&&(t.person=n),t}(e):{...e},r={},i=[];n.content!==void 0&&(r.content=_k(n.content),r.mentions=null,i.push(`onContentChange`)),n.person!==void 0&&(r.personId=wk(n.person,this._getPeople()),i.includes(`onContentChange`)||i.push(`onContentChange`));let a=this._getState().asNote,o=n.asNote===void 0?a:!!n.asNote;if(o!==a&&Object.assign(r,o?{asNote:!0}:Lk),n.resolved!==void 0&&(r.done=!!n.resolved,i.push(`onResolvedChange`)),Object.keys(r).length===0)return this;let s=this._beginCommit({description:m(`op.updateComment`),...t});try{this._updateState(r,{description:m(`op.updateComment`),...t},i),a&&!o?this._removeBox():o&&!a&&this._placeBox(null,!0),s.commit()}catch(e){throw s.rollback(),e}return this}getType(){return this.isNote()?`note`:`comment`}getTypeDescription(){return this.isNote()?`Note`:`Comment`}getReferences(){return null}getDescription(){return this._getState().description}setDescription(e){let t=e||null;return t===this._getState().description||this._updateState({description:t},{description:m(`op.setMovableDescription`)},[`onAnyChange`]),this}getMovable(){return this._getState()?.asNote?this._getBox():null}getStyle(){return this._getState()?.asNote?this._style?this._style:this._style=new bt({getData:()=>{let e=this._getState(),t={};return e?.boxFill&&(t.fill=e.boxFill),e?.boxStroke&&(t.stroke=e.boxStroke),t},getStyles:()=>this._options.getStyles?.()??null,getTheme:()=>null,getMovable:()=>this.getMovable(),getResource:()=>null,write:(e,t)=>{let n={};`fill`in e&&(n.boxFill=e.fill??null),`stroke`in e&&(n.boxStroke=e.stroke??null),this._updateState(n,t,[`onAnyChange`])},resolve:e=>({fill:e?.fill??Rk,stroke:e?.stroke?{...zk,...e.stroke,fill:e.stroke.fill??zk.fill}:zk})}):null}_getBox(){let e=this._boxes;for(let t=e.length-1;t>=0;t--)if(!e[t].isDeleted())return e[t];return null}_placeBox(e,t){let n=this._options.boxes;n&&!this._getBox()&&this._boxes.push(n.add(this,e,t))}_removeBox(){this._getBox()?._deleteFromContent()}addListeners(e,t){return this._getEmitter().addListeners(e,t)}toJSON(){let e=this._getState();if(!e)return null;let t={id:e.commentId};e.personId&&(t.personId=e.personId);let n=e.content;if(typeof n==`string`?n&&(t.content=n):t.content=yk(n),e.dt&&(t.dt=e.dt),e.done&&(t.done=!0),e.asNote&&(t.asNote=!0),e.mentions&&(t.mentions=e.mentions.map(e=>({...e}))),e.replies.length>0&&(t.replies=e.replies.map(e=>({...e}))),e.asNote){e.description&&(t.description=e.description);let n=this._getBox();n&&!n.isHidden()&&(t.shown=!0);let r=this._options.boxes,i=n&&r&&!r.isDefault(this,n)?n._getAnchorJSON():null;if(i||e.boxXml||e.boxFill||e.boxStroke){let n={};if(i){let e=this.getRange().getCoords();n.anchor=function(e,t){return{tl:{c:(e.tl.c??0)-t.colIndex,r:(e.tl.r??0)-t.rowIndex,x:e.tl.x??0,y:e.tl.y??0},br:{c:(e.br.c??0)-t.colIndex,r:(e.br.r??0)-t.rowIndex,x:e.br.x??0,y:e.br.y??0}}}(i,{rowIndex:e.rowStart,colIndex:e.colStart})}e.boxFill&&(n.fill=structuredClone(e.boxFill)),e.boxStroke&&(n.stroke=structuredClone(e.boxStroke)),e.boxXml&&(n.xml=e.boxXml),t.box=n}}return t}_fromJSON(e,t){if(!e)return;let n={};e.id&&(n.commentId=e.id),e.personId!==void 0&&(n.personId=e.personId||null),e.content!==void 0&&(n.content=_k(e.content)),e.dt!==void 0&&(n.dt=e.dt||null),e.done!==void 0&&(n.done=!!e.done),e.asNote!==void 0&&(n.asNote=!!e.asNote),e.mentions!==void 0&&(n.mentions=e.mentions?e.mentions.map(e=>({...e})):null),e.replies!==void 0&&(n.replies=(e.replies??[]).filter(e=>!!e).map(e=>({...e,id:e.id||i.uuidV4().toUpperCase(),content:_k(e.content)})));let r=null,a=null,o=!!e.shown;if(e.asNote){e.description!==void 0&&(n.description=e.description||null);let t=e.box;if(n.boxXml=t?.xml||null,n.boxFill=t?.fill?structuredClone(t.fill):null,n.boxStroke=t?.stroke?structuredClone(t.stroke):null,r=t?.anchor??null,!r&&t?.xml){let n=function(e){let t=xk.exec(e),n=Sk.exec(e),r=bk.exec(e);if(!t||!n||!r)return null;let i=r[1].split(`,`).map(e=>parseInt(e.trim(),10));if(i.length!==8||i.some(e=>isNaN(e)))return null;let a=parseInt(t[1],10),o=parseInt(n[1],10);return{anchor:{tl:{c:i[0]-o,x:i[1],r:i[2]-a,y:i[3]},br:{c:i[4]-o,x:i[5],r:i[6]-a,y:i[7]}},shown:Ck.test(e)}}(t.xml);n&&(r=n.anchor,e.shown===void 0&&(o=n.shown))}!r||r.tl&&r.br||(r=null),!r&&t?.bounds&&(a=t.bounds)}Object.keys(n).length>0&&this._updateState(n,{description:m(`op.addComment`),...t}),e.asNote&&this._placeBox(r?{anchor:{tl:{...r.tl},br:{...r.br}}}:a?{bounds:{...a}}:null,!o)}_getPeople(){return this._options.getPeople?.()??null}_resolvePerson(e){return e?this._getPeople()?.getById(e)??null:null}_findReplyJSON(e){let t=this._getState()?.replies;if(!t)return null;for(let n=0;n<t.length;n++)if(t[n].id===e)return t[n];return null}_replyFor(e){let t=this._replies.get(e);return t||(t=new Mk(this,e),this._replies.set(e,t)),t}_updateReply(e,t,n){let r=this._getState().replies,i=r.findIndex(t=>t.id===e);if(i<0)throw new k(N(`error.comment.replyDeleted`));let a=r.slice(),{mentions:o,...s}=r[i];a[i]={...s,content:gk(t)},this._updateState({replies:a},{description:m(`op.setCommentContent`),...n},[`onRepliesChange`])}_deleteReply(e,t){let n=this._getState().replies;n.some(t=>t.id===e)&&this._updateState({replies:n.filter(t=>t.id!==e)},{description:m(`op.deleteCommentReply`),...t},[`onRepliesChange`])}get[Symbol.toStringTag](){return`[Comment]`}toString(){return`Comment:${this.getRange()?.toString()}:${this.getContent()}`}get isIComment(){return!0}},Mk=class{constructor(e,t){this._parent=e,this._id=t}_json(){let e=this._parent._findReplyJSON(this._id);if(!e)throw new k(N(`error.comment.replyDeleted`));return e}getId(){return this._id}getParent(){return this._parent}getRange(e){return this._parent.getRange(e)}getContent(){return gk(this._json().content)}setContent(e,t){return this._parent._updateReply(this._id,e,t),this}getAuthor(){return this._parent._resolvePerson(this._json().personId)}getCreationDate(){return Nk(this._json().dt)}isResolved(){return this._parent.isResolved()}delete(e){this._parent._deleteReply(this._id,e)}isDeleted(){return this._parent.isDeleted()||this._parent._findReplyJSON(this._id)===null}toJSON(){return{...this._json()}}get[Symbol.toStringTag](){return`[CommentReply]`}get isICommentReply(){return!0}};function Nk(e){if(!e)return null;let t=new Date(e);return isNaN(t.getTime())?null:t}var Pk,Fk,Ik=Object.freeze({personId:null,content:``,dt:null,done:!1,asNote:!1,mentions:null,replies:Object.freeze([]),description:null,boxXml:null,boxFill:null,boxStroke:null}),Lk=Object.freeze({asNote:!1,description:null,boxXml:null,boxFill:null,boxStroke:null}),Rk=Object.freeze({type:`solid`,color:Mt.Named.InfoBk}),zk=Object.freeze({fill:Object.freeze({type:`solid`,color:Mt.Named.InfoText}),width:.75}),Bk=class extends Qt{constructor(e,t,n){super(),this._add=e,this._get=t,this._addListeners=n}add(e,t,n){if(!this._add)throw Error(N(`error.comment.addOnSheet`));if(!e)throw Error(N(`error.address.noAddress`));return this._add(e,t,n)}_getItems(e){let t=this._get(e?.address,e?.ignoreHidden,e?.fullyContained),n=e?.resolved,r=e?.notes;return n===void 0&&r===void 0||(t=t.filter(e=>(r===void 0||e.isNote()===r)&&(n===void 0||e.isResolved()===n))),t}getById(e){return typeof e==`string`?this._get(null).find(t=>t.getId()===e)??null:null}getAt(e){return e?this._get(e)[0]??null:null}getByReplyId(e){return typeof e==`string`?this._get(null).find(t=>t.getReply(e)!==null)??null:null}addListeners(e,t){return this._addListeners(e,t)}get isICommentCollection(){return!0}},Vk=class extends Mx{_processContainerRemoved(){let e=this.getContent();if(e.isDeleted())return null;let t=e.getRange().getCoords(),n=this._optionsMovable;if(!n.getMaxBounds)return null;let r={getBoundsAtCoords:n.getBoundsAtCoords,getCoordsAtBounds:n.getCoordsAtBounds,getMaxBounds:n.getMaxBounds};var i;return kk(Ek(Tk((i=e.getWorksheet(),e=>{let t=i.getCell(e),n=t.getSpans();return n.width>1||n.height>1?t.getRange().getCoords():null}),{rowIndex:t.rowStart,colIndex:t.colStart}),r),r)}getSnapshot(e,t){return null}get[Symbol.toStringTag](){return`[NoteMovable]`}};(Fk=Pk||={}).ViewMode={Normal:`normal`,PageBreakPreview:`pageBreakPreview`,PageLayout:`pageLayout`},Fk.HeaderTextStyle={A1:`a1`,Zero:`zero`,One:`one`},Fk.ColumnHeaderTableNames={Sticky:`sticky`,Hidden:`hidden`,None:`none`};var Hk=class e{static{this.TypedThreshold=64}constructor(t,n,r){this._codes=new Uint8Array,this._nums=new Float64Array,this.createList=(t,n=t.length,r)=>{if(r===void 0){r=0;let e=t[0];for(let i=0;i<n;i++){let n=t[i];r|=Lo.hintOf(n)|(n===e?0:Lo.Hint.NotUniform)}}if((r&Lo.Hint.NotFinite)!==0)throw Error(`A raw NaN or Infinity reached storage. Numbers are normalized to #NUM! at entry.`);if(n<e.TypedThreshold)return new vo.ArrayList(t.slice(0,n));if((r&Lo.Hint.NotUniform)===0)return new Ro([t[0]],n);let i=r&Lo.Hint.KindMask;return((i&Lo.Hint.Object)===0?cl.fromArray(t,this.codec,{seen:i,length:n}):cl.fromArray(t,this.codec,{length:n}))??new vo.ArrayList(t.slice(0,n))},this._strings=t,this._richData=n??(()=>Zl.DetachedContext),this._richValues=r??null,this.codec={isError:e=>!0===e.isFormulaError,encodeString:e=>t.add(e),decodeString:e=>t.getById(e),encodeError:e=>e.getCode(),decodeError:e=>V.getBuiltInByCode(e)??V.BuiltIn.Unknown},r&&(this.codec.isRich=e=>!0===e.isIRichData,this.codec.encodeRich=e=>r.add(e),this.codec.decodeRich=e=>r.getById(e))}fromJSONRun(e,t,n){let r=e.length,i=this._codes,a=this._nums;i.length<r&&(i=this._codes=new Uint8Array(r),a=this._nums=new Float64Array(r));let o=0,s=!0,c=null;for(let l=0;l<r;l++){let u=e[l],d=Uk,f=0,p=u?.t;if(p!==void 0){let e=u.v;switch(f=typeof e==`number`?e:0,p){case`e`:d=Yk,t?.(l);break;case`r`:{let t=typeof e==`number`?n?.(e)??null:ku.fromJSON(e,this._richData());if(!t)break;d=Xk,this._richValues?f=this._richValues.add(t):(c??=Array(r))[l]=t;break}case`n`:d=(0|f)===f?Kk:qk;break;case`s`:d=Jk;break;case`b`:d=f?Gk:Wk}}else switch(typeof u){case`number`:f=u,d=(0|f)===f?Kk:qk;break;case`string`:f=parseInt(u),d=Jk;break;case`boolean`:d=u?Gk:Wk}i[l]=d,a[l]=f,o|=1<<d,(d!==i[0]||d>=Kk&&f!==a[0])&&(s=!1)}if(c!==null){let e=Array(r);for(let t=0;t<r;t++)e[t]=i[t]===Xk?c[t]:this._decode(i[t],a[t]);return new vo.ArrayList(e)}return this._fromCodes(i,a,r,o,s)}static fromJSONValue(e,t,n){if(e==null)return null;if(typeof e!=`object`)return typeof e==`string`&&t?t(parseInt(e)):e;let r=e.v;switch(e.t){case`n`:return r;case`s`:return t?t(r):``+r;case`b`:return r!==0;case`e`:return V.getBuiltInByCode(r)??V.BuiltIn.Unknown;case`r`:return ku.fromJSON(r,n)}return null}static toJSONRun(t,n,r,i){let a=t.length,o=Array(a);for(let s=0;s<a;s++){let a=t.at(s),c=e.toJSONValue(a,n,r,i);c===void 0&&console.warn(`error`,a),o[s]=c}return o}static toJSONValue(e,t,n,r){let i=pB(e);if(i===U.Number||i===U.Boolean)return e;if(i===U.String)return``+t(e);if(i===U.Error)return{t:`e`,v:e.getCode()};if(i===U.RichData){if(r)return{t:`r`,v:r(e)};let t=e.toJSON?.(n);return t&&typeof t.then!=`function`?{t:`r`,v:t}:(console.warn(`Rich data of type '${e.getKind().getName()}' was not persisted.`),{t:`z`,v:0})}}fromEncoded(e,t){let n=e.length,r=0,i=!0,a=e[0],o=t[0];for(let s=0;s<n;s++){let n=e[s];r|=1<<n,(n!==a||n>=Kk&&t[s]!==o)&&(i=!1)}return this._fromCodes(e,t,n,r,i)}_fromCodes(t,n,r,i,a){if(r<e.TypedThreshold){let e=Array(r);for(let i=0;i<r;i++)e[i]=this._decode(t[i],n[i]);return new vo.ArrayList(e)}return a?new Ro([this._decode(t[0],n[0])],r):cl.fromEncoded(t,n,this.codec,{seen:i,length:r})}_decode(e,t){switch(e){case Kk:case qk:return t;case Jk:return this.codec.decodeString(t);case Yk:return this.codec.decodeError(t);case Xk:return this.codec.decodeRich?this.codec.decodeRich(t):null;case Gk:return!0;case Wk:return!1}return null}},Uk=cl.Type.Blank,Wk=cl.Type.False,Gk=cl.Type.True,Kk=cl.Type.Int32,qk=cl.Type.Float64,Jk=cl.Type.String,Yk=cl.Type.Error,Xk=cl.Type.Rich,Zk={doubleCounting:{prior:.00619,classes:{"repeatedReference//1":.29014,"repeatedReference//2-3":.29014,"misalignedReference/lineItem/1":.17669,"sumIncludesSubtotal//1":.15861,"emptyCellReference//11+":.11455,"formula//1":.08284,"misalignedReference/closingRow/2-3":.04683,"emptyCellReference//2-3":.04334,"emptyCellReference//1":.04248,"misalignedReference/lineItem/2-3":.03625,"formulaRange//1":.03211,"styleBreak/fill/2-3":.01985,"twinBlockDivergence/sign/2-3":.01699,"styleBreak/fill/1":.01583,"twinBlockDivergence/sign/1":.01499,"twinBlockDivergence/sign/4-10":.011,"styleBreak/numberFormat/1":.0105,"styleBreak/fill/4-10":.00977,"styleRole/fontColor/11+":.00843,"styleRole/fontColor/4-10":.00839,"styleBreak/font/1":.00631,"numberStoredAsText//1":.0059,"degenerateCall//1":.0059,"externalReference/deleted/1":.00563,"degenerateCall//2-3":.00563,"externalReference/udf/2-3":.00563,"scaleOutlier//2-3":.00563,"signVsSiblings//1":.00539,"twinBlockDivergence/literal/2-3":.00539,"scaleOutlier//1":.00539,"sumIncludesSubtotal//2-3":.00516,"literalMatchesInput//2-3":.00496,"literalMatchesInput//4-10":.00476,"misalignedReference/outsideBlocks/4-10":.00459,"literalMatchesInput//1":.00459,"misalignedReference/closingRow/1":.00442,"numberStoredAsText//4-10":.00442,"twinBlockDivergence/literal/4-10":.00344,"emptyCellReference//4-10":.00335,"formulaRange//4-10":.00326,"linkLabelMismatch//2-3":.00318,"keyLabelMismatch//1":.00318,"styleRole/fontColor/1":.00264,"formulaRange//2-3":.00258,"styleBreak/alignment/2-3":.00243,"hardcodeInRun//1":.00229,"constantFrequency/string/1":.00206,"constantFrequency/string/2-3":.002,"constantFrequency/string/4-10":.00197,"styleBreak/alignment/4-10":.00177,"hardcodeInRun//4-10":.0017,"hardcodeInRun//2-3":.0017,"styleBreak/alignment/1":.00153,"formula//2-3":.00149,"styleRole/fontColor/2-3":.00141,"styleBreak/numberFormat/2-3":.00129,"constantFrequency/number/2-3":.001,"hardcodeInRun//11+":94e-5,"constantFrequency/number/1":87e-5,"styleBreak/numberFormat/4-10":77e-5,"twinBlockDivergence/sign/11+":73e-5,"formula//4-10":7e-4,"styleBreak/font/2-3":6e-4,"styleBreak/alignment/11+":6e-4,"linkLabelMismatch//1":57e-5,"styleBreak/font/4-10":49e-5,"constantFrequency/number/4-10":44e-5,"formula//11+":38e-5,"styleBreak/fill/11+":34e-5,"styleBreak/numberFormat/11+":26e-5,"formulaRange//11+":25e-5,"styleBreak/font/11+":22e-5,"constantFrequency/string/11+":18e-5,"constantFrequency/number/11+":9e-5}},embeddedHardcode:{prior:.00845,classes:{"literalMatchesInput//1":.13028,"styleRole/fontColor/1":.11863,"hardcodeInRun//1":.0923,"constantFrequency/number/1":.08551,"styleRole/fontColor/2-3":.06231,"styleRole/fontColor/11+":.05026,"hardcodeInRun//11+":.04314,"hardcodeInRun//2-3":.04063,"styleBreak/numberFormat/1":.0379,"styleRole/fontColor/4-10":.03088,"formula//2-3":.02552,"styleBreak/numberFormat/2-3":.02332,"constantFrequency/number/2-3":.01721,"twinBlockDivergence/sign/1":.01538,"styleBreak/font/1":.01212,"numberStoredAsText//1":.00804,"degenerateCall//1":.00804,"sumIncludesSubtotal//1":.00768,"externalReference/deleted/1":.00768,"misalignedReference/closingRow/2-3":.00768,"degenerateCall//2-3":.00768,"externalReference/udf/2-3":.00768,"scaleOutlier//2-3":.00768,"signVsSiblings//1":.00734,"twinBlockDivergence/literal/2-3":.00734,"scaleOutlier//1":.00734,"styleBreak/numberFormat/4-10":.00731,"sumIncludesSubtotal//2-3":.00704,"literalMatchesInput//2-3":.00676,"literalMatchesInput//4-10":.0065,"misalignedReference/lineItem/1":.0065,"misalignedReference/outsideBlocks/4-10":.00626,"numberStoredAsText//4-10":.00603,"styleBreak/fill/11+":.00589,"misalignedReference/closingRow/1":.00582,"misalignedReference/lineItem/2-3":.00582,"formulaRange//1":.00483,"emptyCellReference//11+":.00469,"twinBlockDivergence/literal/4-10":.00469,"emptyCellReference//4-10":.00457,"styleBreak/numberFormat/11+":.00446,"keyLabelMismatch//1":.00445,"linkLabelMismatch//2-3":.00433,"formulaRange//4-10":.00433,"constantFrequency/number/4-10":.00412,"emptyCellReference//2-3":.00375,"formulaRange//2-3":.00359,"emptyCellReference//1":.00325,"styleBreak/alignment/2-3":.00325,"constantFrequency/string/1":.00282,"constantFrequency/string/2-3":.00282,"constantFrequency/string/4-10":.00268,"hardcodeInRun//4-10":.00248,"styleBreak/fill/1":.00241,"styleBreak/alignment/4-10":.00241,"constantFrequency/number/11+":.00235,"styleBreak/alignment/1":.00209,"formula//1":.00209,"styleBreak/fill/2-3":.00154,"styleBreak/fill/4-10":.00151,"twinBlockDivergence/sign/2-3":.00123,"formula//4-10":95e-5,"styleBreak/font/2-3":82e-5,"styleBreak/alignment/11+":81e-5,"linkLabelMismatch//1":79e-5,"styleBreak/font/4-10":67e-5,"formula//11+":52e-5,"twinBlockDivergence/sign/4-10":47e-5,"formulaRange//11+":34e-5,"styleBreak/font/11+":3e-4,"constantFrequency/string/11+":25e-5,"twinBlockDivergence/sign/11+":11e-5}},colorCoding:{prior:.0153,classes:{"styleRole/fontColor/1":.33289,"styleRole/fontColor/2-3":.23744,"linkLabelMismatch//2-3":.13605,"hardcodeInRun//1":.09148,"styleRole/fontColor/4-10":.06331,"keyLabelMismatch//1":.05913,"linkLabelMismatch//1":.0521,"styleBreak/numberFormat/1":.04959,"styleBreak/font/1":.04014,"constantFrequency/string/1":.03843,"formulaRange//1":.03732,"styleBreak/fill/1":.03159,"styleBreak/numberFormat/2-3":.02196,"styleBreak/font/2-3":.02101,"twinBlockDivergence/sign/11+":.01899,"twinBlockDivergence/sign/1":.01741,"formula//1":.01633,"numberStoredAsText//1":.01458,"degenerateCall//1":.01458,"sumIncludesSubtotal//1":.01391,"externalReference/deleted/1":.01391,"misalignedReference/closingRow/2-3":.01391,"degenerateCall//2-3":.01391,"externalReference/udf/2-3":.01391,"scaleOutlier//2-3":.01391,"styleRole/fontColor/11+":.01372,"signVsSiblings//1":.01331,"twinBlockDivergence/literal/2-3":.01331,"scaleOutlier//1":.01331,"sumIncludesSubtotal//2-3":.01275,"literalMatchesInput//2-3":.01224,"misalignedReference/lineItem/1":.01177,"misalignedReference/outsideBlocks/4-10":.01134,"literalMatchesInput//1":.01134,"numberStoredAsText//4-10":.01093,"literalMatchesInput//4-10":.01055,"misalignedReference/closingRow/1":.01055,"misalignedReference/lineItem/2-3":.01055,"twinBlockDivergence/sign/2-3":.00967,"constantFrequency/number/1":.0092,"twinBlockDivergence/sign/4-10":.00891,"emptyCellReference//11+":.0085,"twinBlockDivergence/literal/4-10":.0085,"emptyCellReference//4-10":.00827,"formulaRange//4-10":.00805,"emptyCellReference//2-3":.0068,"formulaRange//2-3":.00638,"styleBreak/alignment/2-3":.006,"emptyCellReference//1":.00589,"constantFrequency/string/2-3":.00494,"constantFrequency/string/4-10":.00486,"constantFrequency/number/11+":.00466,"constantFrequency/number/4-10":.00452,"hardcodeInRun//4-10":.0045,"styleBreak/alignment/4-10":.00437,"hardcodeInRun//2-3":.00408,"styleBreak/alignment/1":.00378,"formula//2-3":.00369,"styleBreak/fill/4-10":.00286,"styleBreak/fill/2-3":.00278,"styleBreak/numberFormat/11+":.00266,"constantFrequency/number/2-3":.00251,"hardcodeInRun//11+":.00232,"styleBreak/numberFormat/4-10":.00203,"formula//4-10":.00173,"styleBreak/alignment/11+":.00147,"styleBreak/font/4-10":.00122,"formula//11+":94e-5,"styleBreak/fill/11+":84e-5,"formulaRange//11+":62e-5,"styleBreak/font/11+":54e-5,"constantFrequency/string/11+":46e-5}},average:{prior:.00425,classes:{"formulaRange//2-3":.18336,"degenerateCall//1":.12854,"emptyCellReference//1":.05609,"formula//1":.04863,"constantFrequency/number/2-3":.03294,"formulaRange//1":.03014,"styleRole/fontColor/11+":.01359,"styleRole/fontColor/2-3":.01233,"constantFrequency/number/4-10":.01106,"styleBreak/fill/4-10":.00978,"styleRole/fontColor/4-10":.00792,"constantFrequency/number/1":.00764,"styleBreak/font/2-3":.00524,"numberStoredAsText//1":.00405,"sumIncludesSubtotal//1":.00387,"externalReference/deleted/1":.00387,"misalignedReference/closingRow/2-3":.00387,"externalReference/udf/2-3":.00387,"scaleOutlier//2-3":.00387,"signVsSiblings//1":.0037,"twinBlockDivergence/literal/2-3":.0037,"scaleOutlier//1":.0037,"sumIncludesSubtotal//2-3":.00354,"literalMatchesInput//2-3":.0034,"literalMatchesInput//4-10":.00327,"misalignedReference/lineItem/1":.00327,"misalignedReference/outsideBlocks/4-10":.00315,"literalMatchesInput//1":.00315,"numberStoredAsText//4-10":.00304,"styleBreak/fill/11+":.00296,"misalignedReference/closingRow/1":.00293,"misalignedReference/lineItem/2-3":.00293,"emptyCellReference//11+":.00236,"twinBlockDivergence/literal/4-10":.00236,"emptyCellReference//4-10":.0023,"constantFrequency/number/11+":.00229,"formulaRange//4-10":.00224,"linkLabelMismatch//2-3":.00218,"keyLabelMismatch//1":.00218,"emptyCellReference//2-3":.00189,"styleRole/fontColor/1":.00185,"styleBreak/alignment/2-3":.00167,"constantFrequency/string/11+":.00162,"hardcodeInRun//1":.00157,"constantFrequency/string/1":.00142,"constantFrequency/string/2-3":.00137,"constantFrequency/string/4-10":.00135,"styleBreak/fill/1":.00125,"styleBreak/alignment/4-10":.00121,"hardcodeInRun//4-10":.00116,"hardcodeInRun//2-3":.00116,"twinBlockDivergence/sign/1":.00112,"styleBreak/alignment/1":.00105,"formula//2-3":99e-5,"styleBreak/numberFormat/2-3":89e-5,"styleBreak/numberFormat/1":8e-4,"styleBreak/fill/2-3":77e-5,"hardcodeInRun//11+":64e-5,"twinBlockDivergence/sign/2-3":64e-5,"styleBreak/numberFormat/4-10":52e-5,"formula//4-10":49e-5,"styleBreak/font/1":47e-5,"styleBreak/alignment/11+":41e-5,"linkLabelMismatch//1":39e-5,"styleBreak/font/4-10":34e-5,"formula//11+":26e-5,"twinBlockDivergence/sign/4-10":23e-5,"styleBreak/numberFormat/11+":18e-5,"formulaRange//11+":17e-5,"styleBreak/font/11+":15e-5,"twinBlockDivergence/sign/11+":6e-5}},crossSheetReference:{prior:.00755,classes:{"linkLabelMismatch//1":.09933,"linkLabelMismatch//2-3":.0808,"twinBlockDivergence/sign/1":.04201,"formula//1":.0389,"styleRole/fontColor/2-3":.03581,"keyLabelMismatch//1":.02952,"styleRole/fontColor/1":.02449,"twinBlockDivergence/sign/2-3":.02334,"constantFrequency/string/1":.01918,"styleBreak/font/1":.0177,"styleRole/fontColor/4-10":.01515,"styleBreak/numberFormat/2-3":.01199,"twinBlockDivergence/sign/11+":.01185,"twinBlockDivergence/sign/4-10":.00845,"constantFrequency/number/1":.00811,"numberStoredAsText//1":.00719,"degenerateCall//1":.00719,"sumIncludesSubtotal//1":.00687,"externalReference/deleted/1":.00687,"misalignedReference/closingRow/2-3":.00687,"degenerateCall//2-3":.00687,"externalReference/udf/2-3":.00687,"signVsSiblings//1":.00687,"scaleOutlier//2-3":.00687,"twinBlockDivergence/literal/2-3":.00657,"scaleOutlier//1":.00657,"sumIncludesSubtotal//2-3":.0063,"literalMatchesInput//2-3":.00604,"literalMatchesInput//4-10":.00581,"misalignedReference/lineItem/1":.00581,"styleBreak/font/2-3":.00562,"misalignedReference/outsideBlocks/4-10":.0056,"literalMatchesInput//1":.0056,"numberStoredAsText//4-10":.0054,"misalignedReference/closingRow/1":.00521,"misalignedReference/lineItem/2-3":.00521,"formulaRange//1":.00432,"emptyCellReference//11+":.0042,"twinBlockDivergence/literal/4-10":.0042,"constantFrequency/number/4-10":.00411,"emptyCellReference//4-10":.00408,"formulaRange//4-10":.00398,"emptyCellReference//2-3":.00336,"formulaRange//2-3":.00315,"styleBreak/alignment/2-3":.00296,"emptyCellReference//1":.00291,"hardcodeInRun//1":.0028,"constantFrequency/string/2-3":.00244,"constantFrequency/string/4-10":.0024,"constantFrequency/number/11+":.00233,"styleBreak/alignment/4-10":.00216,"styleBreak/fill/1":.00213,"hardcodeInRun//4-10":.00207,"hardcodeInRun//2-3":.00207,"styleBreak/alignment/1":.00187,"formula//2-3":.00182,"styleBreak/numberFormat/1":.00143,"styleBreak/fill/2-3":.00139,"styleBreak/fill/4-10":.00136,"constantFrequency/number/2-3":.00122,"hardcodeInRun//11+":.00114,"styleBreak/numberFormat/4-10":93e-5,"formula//4-10":85e-5,"styleBreak/alignment/11+":73e-5,"styleRole/fontColor/11+":63e-5,"styleBreak/font/4-10":6e-4,"formula//11+":46e-5,"styleBreak/fill/11+":41e-5,"styleBreak/numberFormat/11+":31e-5,"formulaRange//11+":3e-4,"styleBreak/font/11+":27e-5,"constantFrequency/string/11+":23e-5}},signConvention:{prior:.00528,classes:{"twinBlockDivergence/sign/2-3":.06004,"formula//2-3":.03742,"twinBlockDivergence/sign/4-10":.03034,"linkLabelMismatch//2-3":.02835,"emptyCellReference//1":.02086,"constantFrequency/number/2-3":.01671,"twinBlockDivergence/sign/1":.01579,"formula//1":.01382,"styleBreak/alignment/1":.01365,"styleBreak/numberFormat/1":.01043,"styleBreak/fill/2-3":.00987,"linkLabelMismatch//1":.0097,"constantFrequency/number/4-10":.00755,"twinBlockDivergence/sign/11+":.00713,"styleBreak/numberFormat/4-10":.00691,"numberStoredAsText//1":.00503,"degenerateCall//1":.00503,"externalReference/deleted/1":.0048,"misalignedReference/closingRow/2-3":.0048,"degenerateCall//2-3":.0048,"externalReference/udf/2-3":.0048,"scaleOutlier//2-3":.0048,"sumIncludesSubtotal//1":.00459,"signVsSiblings//1":.00459,"twinBlockDivergence/literal/2-3":.00459,"scaleOutlier//1":.00459,"sumIncludesSubtotal//2-3":.0044,"literalMatchesInput//2-3":.00422,"literalMatchesInput//4-10":.00406,"misalignedReference/lineItem/1":.00406,"misalignedReference/outsideBlocks/4-10":.00391,"literalMatchesInput//1":.00391,"numberStoredAsText//4-10":.00377,"misalignedReference/closingRow/1":.00364,"misalignedReference/lineItem/2-3":.00364,"constantFrequency/number/11+":.00304,"formulaRange//1":.00302,"emptyCellReference//11+":.00293,"twinBlockDivergence/literal/4-10":.00293,"emptyCellReference//4-10":.00285,"formulaRange//4-10":.00278,"keyLabelMismatch//1":.00271,"emptyCellReference//2-3":.00235,"styleRole/fontColor/1":.00225,"formulaRange//2-3":.0022,"styleBreak/alignment/2-3":.00207,"hardcodeInRun//1":.00196,"constantFrequency/string/1":.00176,"constantFrequency/string/2-3":.0017,"constantFrequency/string/4-10":.00168,"styleBreak/alignment/4-10":.00151,"styleBreak/fill/1":.00149,"hardcodeInRun//4-10":.00145,"hardcodeInRun//2-3":.00145,"styleRole/fontColor/2-3":.0012,"styleBreak/numberFormat/2-3":.0011,"styleBreak/fill/4-10":.001,"hardcodeInRun//11+":8e-4,"constantFrequency/number/1":77e-5,"styleRole/fontColor/4-10":75e-5,"styleBreak/font/1":6e-4,"formula//4-10":6e-4,"styleBreak/font/2-3":52e-5,"styleBreak/alignment/11+":51e-5,"styleRole/fontColor/11+":44e-5,"styleBreak/font/4-10":42e-5,"formula//11+":33e-5,"styleBreak/fill/11+":29e-5,"styleBreak/numberFormat/11+":22e-5,"formulaRange//11+":21e-5,"styleBreak/font/11+":19e-5,"constantFrequency/string/11+":16e-5}},lookup:{prior:.01093,classes:{"keyLabelMismatch//1":.40049,"approximateMatch//1":.20875,"constantFrequency/string/1":.17807,"lookupShape//1":.17578,"approximateMatch//2-3":.13994,"constantFrequency/string/2-3":.08998,"externalReference/deleted/1":.05539,"styleRole/fontColor/4-10":.04379,"constantFrequency/number/4-10":.04087,"formula//1":.03878,"styleRole/fontColor/2-3":.03658,"styleBreak/numberFormat/1":.0298,"styleRole/fontColor/1":.02593,"constantFrequency/number/11+":.01871,"constantFrequency/number/1":.01562,"styleBreak/font/1":.01246,"styleBreak/numberFormat/2-3":.01219,"numberStoredAsText//1":.01041,"degenerateCall//1":.01041,"sumIncludesSubtotal//1":.00994,"misalignedReference/closingRow/2-3":.00994,"degenerateCall//2-3":.00994,"externalReference/udf/2-3":.00994,"scaleOutlier//2-3":.00994,"signVsSiblings//1":.00951,"twinBlockDivergence/literal/2-3":.00951,"scaleOutlier//1":.00951,"sumIncludesSubtotal//2-3":.00911,"numberStoredAsText//4-10":.00911,"literalMatchesInput//2-3":.00875,"misalignedReference/lineItem/1":.00841,"misalignedReference/outsideBlocks/4-10":.0081,"literalMatchesInput//1":.0081,"literalMatchesInput//4-10":.00754,"misalignedReference/closingRow/1":.00754,"misalignedReference/lineItem/2-3":.00754,"styleBreak/numberFormat/4-10":.00734,"formulaRange//1":.00625,"emptyCellReference//11+":.00607,"twinBlockDivergence/literal/4-10":.00607,"styleBreak/font/2-3":.006,"emptyCellReference//4-10":.00591,"formulaRange//4-10":.00575,"linkLabelMismatch//1":.00562,"linkLabelMismatch//2-3":.00533,"emptyCellReference//2-3":.00486,"styleBreak/font/4-10":.00476,"formulaRange//2-3":.00456,"emptyCellReference//1":.00429,"styleBreak/alignment/2-3":.00429,"hardcodeInRun//1":.00413,"constantFrequency/string/4-10":.00347,"styleBreak/fill/1":.00322,"styleBreak/alignment/4-10":.00312,"hardcodeInRun//2-3":.003,"hardcodeInRun//4-10":.00295,"twinBlockDivergence/sign/1":.00288,"styleBreak/alignment/1":.0027,"formula//2-3":.0027,"styleBreak/fill/2-3":.00197,"styleBreak/fill/4-10":.00197,"constantFrequency/number/2-3":.00179,"hardcodeInRun//11+":.00166,"twinBlockDivergence/sign/2-3":.00164,"formula//4-10":.00124,"styleBreak/alignment/11+":.00105,"styleRole/fontColor/11+":91e-5,"formula//11+":67e-5,"styleBreak/fill/11+":6e-4,"twinBlockDivergence/sign/4-10":59e-5,"styleBreak/numberFormat/11+":46e-5,"formulaRange//11+":44e-5,"styleBreak/font/11+":39e-5,"constantFrequency/string/11+":33e-5,"twinBlockDivergence/sign/11+":14e-5}},referenceAnchoring:{prior:.01156,classes:{"emptyCellReference//2-3":.30049,"emptyCellReference//1":.26044,"formula//2-3":.03551,"styleRole/fontColor/4-10":.03464,"formula//4-10":.03462,"styleRole/fontColor/2-3":.02535,"styleBreak/fill/4-10":.02448,"constantFrequency/number/4-10":.02156,"twinBlockDivergence/sign/4-10":.0177,"twinBlockDivergence/sign/1":.01664,"twinBlockDivergence/sign/2-3":.01641,"twinBlockDivergence/sign/11+":.01524,"constantFrequency/number/11+":.01263,"numberStoredAsText//1":.01101,"degenerateCall//1":.01101,"sumIncludesSubtotal//1":.0105,"externalReference/deleted/1":.0105,"misalignedReference/closingRow/2-3":.0105,"degenerateCall//2-3":.0105,"externalReference/udf/2-3":.0105,"scaleOutlier//2-3":.0105,"signVsSiblings//1":.01005,"twinBlockDivergence/literal/2-3":.01005,"scaleOutlier//1":.01005,"sumIncludesSubtotal//2-3":.00963,"literalMatchesInput//2-3":.00924,"literalMatchesInput//4-10":.00889,"misalignedReference/lineItem/1":.00889,"misalignedReference/outsideBlocks/4-10":.00856,"literalMatchesInput//1":.00856,"numberStoredAsText//4-10":.00825,"misalignedReference/closingRow/1":.00797,"misalignedReference/lineItem/2-3":.00797,"formulaRange//1":.0066,"emptyCellReference//11+":.00642,"twinBlockDivergence/literal/4-10":.00642,"emptyCellReference//4-10":.00625,"formulaRange//4-10":.00608,"linkLabelMismatch//2-3":.00593,"keyLabelMismatch//1":.00593,"styleRole/fontColor/1":.00492,"formulaRange//2-3":.00481,"styleBreak/alignment/2-3":.00453,"hardcodeInRun//1":.00405,"constantFrequency/string/1":.00385,"constantFrequency/string/2-3":.00373,"constantFrequency/string/4-10":.00367,"styleBreak/alignment/4-10":.0033,"hardcodeInRun//2-3":.00326,"styleBreak/fill/1":.00312,"hardcodeInRun//4-10":.00285,"styleBreak/alignment/1":.00285,"formula//1":.00285,"styleBreak/numberFormat/11+":.00255,"styleBreak/fill/2-3":.00236,"styleBreak/numberFormat/2-3":.00233,"styleBreak/numberFormat/1":.00216,"constantFrequency/number/2-3":.00193,"hardcodeInRun//11+":.00193,"constantFrequency/number/1":.00163,"styleBreak/numberFormat/4-10":.00146,"styleBreak/font/1":.00128,"styleBreak/font/2-3":.00114,"styleBreak/alignment/11+":.00111,"linkLabelMismatch//1":.00107,"styleRole/fontColor/11+":96e-5,"styleBreak/font/4-10":92e-5,"formula//11+":71e-5,"styleBreak/fill/11+":64e-5,"formulaRange//11+":47e-5,"styleBreak/font/11+":41e-5,"constantFrequency/string/11+":34e-5}},unitMismatch:{prior:.00497,classes:{"twinBlockDivergence/literal/1":.08748,"twinBlockDivergence/literal/2-3":.07776,"scaleOutlier//1":.04581,"constantFrequency/number/1":.04178,"constantFrequency/number/2-3":.03893,"formulaRange//1":.03054,"hardcodeInRun//4-10":.02837,"twinBlockDivergence/sign/1":.02762,"formulaRange//2-3":.02291,"hardcodeInRun//1":.02036,"styleBreak/fill/4-10":.01875,"linkLabelMismatch//1":.01428,"formula//2-3":.01325,"styleBreak/numberFormat/1":.01037,"styleBreak/font/2-3":.01029,"twinBlockDivergence/sign/2-3":.00833,"constantFrequency/number/4-10":.0078,"styleBreak/numberFormat/4-10":.00675,"formula//4-10":.00621,"styleBreak/font/1":.00614,"numberStoredAsText//1":.00474,"degenerateCall//1":.00474,"externalReference/deleted/1":.00452,"misalignedReference/closingRow/2-3":.00452,"degenerateCall//2-3":.00452,"sumIncludesSubtotal//2-3":.00452,"externalReference/udf/2-3":.00452,"scaleOutlier//2-3":.00452,"signVsSiblings//1":.00432,"sumIncludesSubtotal//1":.00414,"literalMatchesInput//2-3":.00398,"literalMatchesInput//4-10":.00383,"misalignedReference/lineItem/1":.00383,"constantFrequency/number/11+":.00381,"misalignedReference/outsideBlocks/4-10":.00368,"literalMatchesInput//1":.00368,"numberStoredAsText//4-10":.00355,"misalignedReference/closingRow/1":.00343,"misalignedReference/lineItem/2-3":.00343,"twinBlockDivergence/sign/11+":.00333,"emptyCellReference//11+":.00276,"twinBlockDivergence/literal/4-10":.00276,"emptyCellReference//4-10":.00269,"formulaRange//4-10":.00262,"linkLabelMismatch//2-3":.00255,"keyLabelMismatch//1":.00255,"emptyCellReference//2-3":.00221,"styleRole/fontColor/1":.00212,"styleBreak/alignment/2-3":.00195,"emptyCellReference//1":.00191,"constantFrequency/string/1":.00166,"constantFrequency/string/2-3":.0016,"constantFrequency/string/4-10":.00158,"styleBreak/alignment/4-10":.00142,"styleBreak/fill/1":.0014,"hardcodeInRun//2-3":.00136,"formula//1":.00124,"styleBreak/alignment/1":.00123,"styleRole/fontColor/2-3":.00109,"styleBreak/numberFormat/2-3":.00104,"styleBreak/fill/2-3":91e-5,"hardcodeInRun//11+":75e-5,"styleRole/fontColor/4-10":72e-5,"styleBreak/alignment/11+":48e-5,"styleRole/fontColor/11+":41e-5,"styleBreak/font/4-10":39e-5,"formula//11+":31e-5,"styleBreak/fill/11+":27e-5,"twinBlockDivergence/sign/4-10":27e-5,"styleBreak/numberFormat/11+":21e-5,"formulaRange//11+":2e-4,"styleBreak/font/11+":18e-5,"constantFrequency/string/11+":15e-5}},deletedRows:{prior:.42499,classes:{"externalReference/deleted/11+":.97655,"hardcodeInRun//11+":.85937,"externalReference/deleted/4-10":.76415,"emptyCellReference//11+":.68055,"styleRole/fontColor/11+":.63843,"twinBlockDivergence/sign/11+":.62368,"formula//2-3":.61585,"constantFrequency/number/4-10":.61388,"emptyCellReference//4-10":.59722,"twinBlockDivergence/literal/4-10":.56944,"misalignedReference/outsideBlocks/4-10":.53703,"literalMatchesInput//1":.53703,"emptyCellReference//2-3":.52127,"literalMatchesInput//2-3":.49999,"externalReference/workbook/1":.49999,"twinBlockDivergence/literal/2-3":.49999,"styleBreak/numberFormat/11+":.48646,"misalignedReference/lineItem/1":.48076,"constantFrequency/number/11+":.47824,"externalReference/udf/2-3":.47727,"externalReference/deleted/2-3":.47727,"misalignedReference/lineItem/2-3":.46551,"styleBreak/fill/11+":.46262,"externalReference/deleted/1":.45237,"degenerateCall//1":.45237,"formula//4-10":.44203,"styleBreak/numberFormat/4-10":.43581,"formulaRange//4-10":.43421,"degenerateCall//2-3":.43181,"signVsSiblings//1":.43181,"linkLabelMismatch//2-3":.42307,"formula//1":.41875,"numberStoredAsText//1":.40475,"hardcodeInRun//4-10":.39899,"formulaRange//1":.39705,"formula//11+":.39691,"styleBreak/fill/4-10":.39542,"styleRole/fontColor/2-3":.39444,"sumIncludesSubtotal//1":.38636,"misalignedReference/closingRow/2-3":.38636,"scaleOutlier//2-3":.38636,"styleBreak/font/4-10":.38627,"styleRole/fontColor/4-10":.38276,"styleBreak/font/11+":.37996,"scaleOutlier//1":.36956,"constantFrequency/string/2-3":.3629,"constantFrequency/number/2-3":.35887,"styleBreak/fill/1":.35811,"sumIncludesSubtotal//2-3":.35416,"emptyCellReference//1":.35,"keyLabelMismatch//1":.34722,"hardcodeInRun//2-3":.34507,"styleRole/fontColor/1":.34375,"constantFrequency/string/4-10":.34127,"twinBlockDivergence/sign/2-3":.33206,"styleBreak/fill/2-3":.33182,"misalignedReference/closingRow/1":.32758,"literalMatchesInput//4-10":.32692,"styleBreak/numberFormat/2-3":.32524,"formulaRange//2-3":.32291,"linkLabelMismatch//1":.30529,"numberStoredAsText//4-10":.30357,"hardcodeInRun//1":.30172,"styleBreak/font/1":.28385,"styleBreak/font/2-3":.28109,"constantFrequency/number/1":.27622,"styleBreak/alignment/1":.26875,"styleBreak/alignment/2-3":.2647,"styleBreak/alignment/4-10":.26428,"twinBlockDivergence/sign/1":.25694,"twinBlockDivergence/sign/4-10":.24929,"constantFrequency/string/1":.24107,"styleBreak/numberFormat/1":.23611,"styleBreak/alignment/11+":.07452,"constantFrequency/string/11+":.0291,"formulaRange//11+":.01714}}},Qk=Object.freeze([Qh.Feature.Contentful]),$k=e=>{if(e===void 0)return Qk;let t=typeof e==`string`?[e]:e,n=[];for(let e=0;e<t.length;e++){let r=String(t[e]).toLowerCase(),i=eA.get(r)??tA.get(r)??eA.get(r.replace(/s$/,``))??eA.get(`${r}s`);if(i===void 0)throw Error(`Unknown feature '${t[e]}'. Features: ${Object.values(Qh.Feature).join(`, `)}.`);n.push(i)}return Object.freeze(n)},eA=new Map(Object.values(Qh.Feature).map(e=>[e.toLowerCase(),e])),tA=new Map([[`values`,Qh.Feature.Contentful],[`value`,Qh.Feature.Contentful],[`content`,Qh.Feature.Contentful],[`contents`,Qh.Feature.Contentful],[`conditionalformat`,Qh.Feature.Conditionals],[`conditionalformats`,Qh.Feature.Conditionals],[`conditionalformatting`,Qh.Feature.Conditionals],[`control`,Qh.Feature.CellControl],[`controls`,Qh.Feature.CellControl],[`pivottable`,Qh.Feature.Pivot],[`pivottables`,Qh.Feature.Pivot]]),nA=class{constructor(e,t,n,r,i=!1){this._range=null,this._clipped=null,this._coords=Object.freeze(e),this._internal=t,this._features=n,this._bounds=r,this._qualified=i}getFeatures(){return this._features}getCoords(){return this._coords}getAddress(e){let t=this._internal.getSheet(),n=Wd(this._coords,t.getEntireCoords(),void 0);return this._qualified?`${Ld(t.getName())}!${n}`:n}getRowCount(){let e=this._coords;return e.rowEnd-e.rowStart+1}getColumnCount(){let e=this._coords;return e.colEnd-e.colStart+1}isClipped(){let e=this._clipped;return e===null&&(e=this._probeClipped(),this._clipped=e),e}_probeClipped(){let e=this._coords,t=this._bounds,n=this._internal.getSheet().getEntireCoords(),r=e=>{let t=new mA(e,this._internal).getCounts(this._features),n=this._features;for(let e=0;e<n.length;e++)if((t[n[e]]??0)>0)return!0;return!1};return!!(e.rowStart===t.rowStart&&t.rowStart>n.rowStart&&r({rowStart:t.rowStart-1,rowEnd:t.rowStart-1,colStart:e.colStart,colEnd:e.colEnd}))||!!(e.rowEnd===t.rowEnd&&t.rowEnd<n.rowEnd&&r({rowStart:t.rowEnd+1,rowEnd:t.rowEnd+1,colStart:e.colStart,colEnd:e.colEnd}))||!!(e.colStart===t.colStart&&t.colStart>n.colStart&&r({rowStart:e.rowStart,rowEnd:e.rowEnd,colStart:t.colStart-1,colEnd:t.colStart-1}))||!!(e.colEnd===t.colEnd&&t.colEnd<n.colEnd&&r({rowStart:e.rowStart,rowEnd:e.rowEnd,colStart:t.colEnd+1,colEnd:t.colEnd+1}))}getCell(){return this.getRange().getCell()}getRange(){let e=this._range;return e||(e=new mA(this._coords,this._internal),this._range=e),e}toString(){return this.getAddress()}get[Symbol.toStringTag](){return`[CellRegion: ${this.getAddress()}]`}get isICellRegion(){return!0}},rA=class{constructor(e,t,n,r){this._regions=null,this._range=null,this._bounds=e,this._internal=t,this._features=n,this._options=r}getFeatures(){return this._features}getRange(){let e=this._range;return e||(e=new mA(this._bounds,this._internal),this._range=e),e}getCount(){return this._materialize().length}*[Symbol.iterator](){yield*this._materialize()}_materialize(){let e=this._regions;if(!e){let t=this._internal,n=t.featureRegions(this._bounds,this._features,this._options),r=n.length;e=Array(r);for(let i=0;i<r;i++)e[i]=new nA(n[i],t,this._features,this._bounds);this._regions=e}return e}get[Symbol.toStringTag](){return`[CellRegions: ${this._features.join(`, `)}]`}get isICellRegions(){return!0}},iA=Object.freeze([Qh.Feature.Anomalies]),aA=new Set(Object.values($.ErrorCheck)),oA=new Set(Object.values(Qh.AnomalyFocus)),sA=e=>`${e.check}\0${n.JSONStableStringify(e.evidence)}`;function cA(e,t){let n=e.evidence,r=n.layer||n.part||n.role||n.targetRole||n.kind||``;return`${e.check}/${r}/${i=t,i===1?`1`:i<=3?`2-3`:i<=10?`4-10`:`11+`}`;var i}var lA=new Set([$.ErrorCheck.ErrorConstant]);function uA(e,t,n){if(e.some(e=>lA.has(e.check)))return 1;let r=0;for(let i=0;i<t.length;i++){let a=Zk[t[i]];if(a)for(let t=0;t<e.length;t++){let i=a.classes[cA(e[t],n.get(sA(e[t]))??1)]??a.prior;i>r&&(r=i)}}return r}var dA=e=>{for(let t of e?.checks??[])if(!aA.has(t))throw Error(`Unknown check '${t}'. Checks: ${[...aA].join(`, `)}.`);let t=e?.focus===void 0?void 0:typeof e.focus==`string`?[e.focus]:[...e.focus];for(let e of t??[])if(!oA.has(e))throw Error(`Unknown focus '${e}'. Focuses: ${[...oA].join(`, `)}.`);return Object.freeze({...e,checks:e?.checks?Object.freeze([...e.checks]):void 0,focus:t?Object.freeze(t):void 0})},fA=class{constructor(e,t,n){this._listed=null,this._extents=e,this._range=t,this._options=n}getFeatures(){return iA}getRange(){return this._range()}getCount(){return this._materialize().length}*[Symbol.iterator](){yield*this._materialize()}_materialize(){if(this._listed)return this._listed;let e=this._options.checks??[],t=this._options.focus??[],n=[];for(let{bounds:t,internal:r,qualified:i}of this._extents)for(let a of r.featureRegions(t,iA)){let o=new nA(a,r,iA,t,i),s=o.getCell().getAnomalies(),c=e.length,l=s[0]?.rank??0;for(let t=0;t<e.length;t++){let n=s.find(n=>n.check===e[t]);if(n){c=t,l=n.rank;break}}n.push({region:o,findings:s,group:c,weight:0,rank:l})}if(t.length>0){let e=new Map;for(let t of n)for(let n of t.findings){let t=sA(n);e.set(t,(e.get(t)??0)+1)}for(let r of n)r.weight=uA(r.findings,t,e)}n.sort((e,t)=>e.group-t.group||t.weight-e.weight||t.rank-e.rank);let r=Math.max(0,this._options.offset??0),i=this._options.limit===void 0?n.length:r+Math.max(0,this._options.limit);return this._listed=n.slice(r,i).map(e=>e.region),this._listed}get[Symbol.toStringTag](){let e=[...this._options.checks??[],...(this._options.focus??[]).map(e=>`focus ${e}`)];return`[AnomalyRegions: ${e.length>0?e.join(`, `):`by rank`}]`}get isICellRegions(){return!0}},pA=Object.freeze([]),mA=class e{constructor(e,t,n){this._coords=Object.freeze(e),this._internal=t,this._readOnly=n?.readOnly??null,this._options=n??void 0}_getStickyOptions(){return this._options?.getOptions}getCoords(){let e=this._coords,t=e?.scope;if(!t)return e;let n=this._internal.getSheet();if(n.isClosed())return e;let r=n.getName();return r&&t!==r?(this._coords=Object.freeze({...e,scope:r}),this._coords):e}_createRange(t,n){let r=this._internal;if(!t)return Tz(r.getSheet(),r.getSheet().getEntireCoords());if(t=this._scopeDerived(t),r.validateCoords(t),r.getSheet().isClosed())return Tz(null,r.getSheet().getEntireCoords(),t);let i=this._options;return n&&(i={...this._options,getOptions:Qz(this._options?.getOptions,n)}),new e(t,this._internal,i)}_scopeDerived(e){let t=this._coords.scope;return t&&e&&!e.scope?{...e,scope:t}:e}_createRanges(e,t){let n=this._options;return t&&(n={...this._options,getOptions:Qz(this._options?.getOptions,t)}),new tz(this._coords.scope?e?.map(e=>this._scopeDerived(e)):e,this._internal,n)}_deriveRanges(e,t){let n=this.getCoords(),r=n;return t&&(r=t(n),!r)?null:this._createRanges(r,e)}_deriveRange(e,t,n){if(!e)return this;let r=this._internal.rangeToCoords(e);if(!r)return this;let i=this.getCoords();if(qz(r,i))return this;if(n){let e=n(r,i);if(!e)return null;r={...i,...e}}return function(e,t){t&&(t.$colStart===void 0?delete e.$colStart:e.$colStart=t.$colStart,t.$rowStart===void 0?delete e.$rowStart:e.$rowStart=t.$rowStart,t.$colEnd===void 0?delete e.$colEnd:e.$colEnd=t.$colEnd,t.$rowEnd===void 0?delete e.$rowEnd:e.$rowEnd=t.$rowEnd)}(r,i),this._createRange(r,Qz(this._options?.getOptions,t))}_validateMaxSize(e=1e4){let t=this.getCoords(),n=this._internal,r=n.getUsedCoords(),i=Math.min(t.colEnd,r?.colEnd??t.colEnd),a=Math.min(t.rowEnd,r?.rowEnd??t.rowEnd),o=1;i>=t.colStart&&(o=n.getSheet().getColumnHeaders().getMetrics().getVisibleCount(t.colStart,i));let s=1;a>=t.rowStart&&(s=n.getSheet().getRowHeaders().getMetrics().getVisibleCount(t.rowStart,a));let c=s*o;if(c>e)throw new k(Dx(e,c,this.getAddress()))}_readSingleCell(e,t){let n=this.getCoords();if(n.rowStart!==n.rowEnd||n.colStart!==n.colEnd||e?.includeMergeOverflow||(e?.maxSize??1e4)<1)return;let r=e?.ignoreHidden;if(r){let e=this._internal.getSheet();if((!0===r||r===B.Axis.Row)&&e.getRowHeaders().getMetrics().getVisibleCount(n.rowStart,n.rowStart)===0||(!0===r||r===B.Axis.Column)&&e.getColumnHeaders().getMetrics().getVisibleCount(n.colStart,n.colStart)===0)return[]}return[[t(n.rowStart,n.colStart)]]}entries(e){let t=this.getCoords(),n=t,r=this._internal;if(e?.address){let i=r.rangeToCoords(e?.address);if(!i)throw new k(bh(e?.address));if(n=h.intersectRanges(i,t),!n)return bo}n.colEnd<n.colStart&&(n.colStart=t.colStart,n.colEnd=t.colEnd),n.rowEnd<n.rowStart&&(n.rowStart=t.rowStart,n.rowEnd=t.rowEnd);let i=this._getStickyOptions();return r.cellIterator({ignoreHidden:i?.ignoreHidden??!1,ignoreEmptyIntersections:(e?.features??i?.features)===void 0,...e,searchTypes:Vf(e?.features??i?.features),bounds:n})}[Symbol.iterator](){return this.values()}values(e){let t=this.entries({...e,features:pA});return{next(){let e=t.next();return e.done?yo:{done:!1,value:e.value.value}},[Symbol.iterator](){return this}}}forEach(e,t){if(!e)return;let n=this.entries(t),r=n.next();for(;!r.done;){let t=r.value,i=e(t.value,t.context);if(i)return i.break;r=n.next()}}_validateWrite(){let e=this._readOnly;if(e)throw new k(N(e))}updateCells(e,t,n){this._validateWrite();let r=this.getCoords();n||=r;let i=this._internal,a=i.isDataColumn(),o={majorStart:a?r.colStart:r.rowStart,majorEnd:a?r.colEnd:r.rowEnd,minorStart:a?r.rowStart:r.colStart,minorEnd:a?r.rowEnd:r.colEnd},s=(t?.axis??B.Axis.Row)===B.Axis.Column!==a,c=Hc(Array.isArray(e)?e:[[e]],s,o);return i.updateTuples(c,{description:t?.description??(h.isSingleCell(n)?N(`op.setCellAddress`,{address:Wd(n,i.getSheet().getEntireCoords())}):N(`op.setRangeAddress`,{address:Wd(n,i.getSheet().getEntireCoords())})),...t},null,{isCell:!0}),this}setValues(e,t){if(!e||!Array.isArray(e)&&!e.isIRange)throw new k(N(`error.sheet.setValuesType`));return this._setValueOrValues(e,t)}setValue(e,t){if(e&&(Array.isArray(e)||e.isIRange))throw new k(N(`error.sheet.setValueType`));return this._setValueOrValues(e,t)}setFormula(e,t){if(e&&(Array.isArray(e)||e.isIRange))throw new k(N(`error.sheet.setValueType`));return this._setValueOrValues(e,t)}_setValueOrValues(e,t){this._validateWrite();let n=this.getCoords(),r=this,i=this._internal,a=i.isDataColumn(),o=(t?.axis??B.Axis.Row)===B.Axis.Column,c=Array.isArray(e),l=!c&&e?.isIRange;if(t?.skipBoundsCheck??h.isSingleCell(n)){let t=o?n.colStart:n.rowStart,i=o?n.rowStart:n.colStart,a=0,s=0;if(c){let t=e;a=Math.max(0,t.length-1),s=0;for(let e=0;e<t.length;e++)s=Math.max(s,t[e].length-1)}else if(l){let t=e.getColumnCount(),n=e.getRowCount();a=o?t-1:n-1,s=o?n-1:t-1}let u={...n,colEnd:o?t+a:i+s,rowEnd:o?i+s:t+a};h.isEqualRanges(u,n)||(n=u,r=this._deriveRange(u)??this)}let u=a?n.colStart:n.rowStart,d=a?n.colEnd:n.rowEnd,f=a?n.rowStart:n.colStart,p={majorStart:u,majorEnd:d,minorStart:f,minorEnd:a?n.rowEnd:n.colEnd},m=null,g=!1,_=null;if(t?.arrayFixed){if(c||l||typeof e!=`string`||e.charAt(0)!==`=`)throw new k(N(`error.sheet.arrayFixedFormula`));let t=n.rowEnd-n.rowStart+1,r=n.colEnd-n.colStart+1,i=Array(t);for(let e=0;e<t;e++)i[e]=Array(r).fill(null);i[0][0]=e,m=Hc(i,a,p),_={colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colEnd,rowEnd:n.rowEnd}}else if(c){let t=o!==a;m=Hc(Array.isArray(e)?e:[[e]],t,p)}else if(l){let t=e._materializeEmpty?.()??e,r=t._values;if(r&&r.getValues&&r.getAxis&&r.getAxis()===(a?B.Axis.Column:B.Axis.Row)){let e=t._coords;if(m=r.getValues(e),m){let e=m.bounds;m=function(e,t,n){let r=e.tuples,i=e.bounds,a=t,o=n,s=[];for(let e of r){let t=e[0]+a,n=e[1],r=[];for(let e of n){let t=e[0]+o;r.push([t,e[1]])}s.push([t,r])}return{tuples:s,bounds:{majorStart:i.majorStart+a,minorStart:i.minorStart+o,majorEnd:i.majorEnd+a,minorEnd:i.minorEnd+o}}}(m,u-e.majorStart,f-e.minorStart)}}else{let e=a?B.Axis.Column:B.Axis.Row;m=function(e,t,n,r=null){let i=t!==s.Row,a=r?.colIndex??0,o=r?.rowIndex??0,c=i?a:o,l=i?o:a,u=e.next();for(;!u.done;){let t=u.value,r=t.coords,a=i?r.colIndex:r.rowIndex,o=i?r.rowIndex:r.colIndex;n.pushAt(c+a,l+o,t.value),u=e.next()}return n.build()}(t.entries({axis:e}),e,i.createTupleBuilder(),{colIndex:n.colStart,rowIndex:n.rowStart})}}else m=Vc(e,p,a),g=!0;return i.updateTuples(m,{description:t?.description??(h.isSingleCell(n)?N(`op.setValueAddress`,{address:Wd(n,i.getSheet().getEntireCoords())}):N(`op.setValuesAddress`,{address:Wd(n,i.getSheet().getEntireCoords())})),...t},null,_?{arrayFixed:_}:g?{isBroadcast:!0}:null),r}getValues(e){let t=this._internal,n=this._readSingleCell(e,(e,n)=>t.getScalar(e,n,!1));if(n)return n;this._validateMaxSize(e?.maxSize);let r=this.getCoords();return Gz(t.cellIterator,r,e,!1,!1)}getValuesRange(){let e=this._internal,t=e.getSheet();return new cH(t.getRuntime(),e.getCalcGrid().getValues(),this.getCoords(),void 0,t.getEntireCoords.bind(t),t.getName.bind(t))}setComputedValues(e,t){let n=this;return n._internal.getSheet().doBatch(()=>{let t=e(n.getValuesRange());n.setValues(t)},{description:m(`op.setComputedValues`),...t}),this}getInteropValues(e){let t=this._internal,n=this._readSingleCell(e,(e,n)=>t.getScalar(e,n,!0));if(n)return n;this._validateMaxSize(e?.maxSize);let r=this.getCoords();return Gz(t.cellIterator,r,e,!1,!0)}getValue(){let e=this.getCoords();return this._internal.getScalar(e.rowStart,e.colStart,!1)}getText(e){return this.getCell().getText(e)}getTexts(){return this.getCells().map(e=>e.map(e=>e?.getText()??``))}getInteropValue(){let e=this.getCoords();return this._internal.getScalar(e.rowStart,e.colStart,!0)}calculate(e){return this._internal.calculate([this.getCoords()],{full:e}),this}getCells(e){let t=this._internal,n=this._readSingleCell(e,(e,n)=>t.getCellAt(e,n));if(n)return n;this._validateMaxSize(e?.maxSize);let r=this.getCoords();return Gz(t.cellIterator,r,e,!0,!1)}_getCellAddress(e,t){if(typeof e!=`number`)return e;let n=this.getCoords();return{rowIndex:n.rowStart+e,colIndex:n.colStart+(t??0)}}getCell(e,t){let n=this._getCellAddress(e,t),r=this.getCoords(),i=r.colStart,a=r.rowStart,o=this._internal;if(n){let e=o.cellToCoords(n);if(!h.isCellWithinRange(e,r))throw new k(N(`error.sheet.oobCell`));i=e.colIndex,a=e.rowIndex}return o.getCellAt(a,i)}getFormula(e){return this.getCell(e).getFormula()}getFormulas(){let e=this.getCoords(),t=this._createDense(``);for(let n of this.getRegions(Qh.Feature.Formula)){let r=n.getRange().entries({features:Qh.Feature.Formula,ignoreHidden:!1});for(let n of r){let r=n.context.getCell().getFormulaText();if(!r)continue;let i=n.context.getCoords(),a=t[i.rowIndex-e.rowStart];!a||i.colIndex<e.colStart||i.colIndex>e.colEnd||(a[i.colIndex-e.colStart]=r)}}return t}setFormulas(e,t){return this.setValues(e,t)}getNumberFormat(){return this.getStyle().getNumberFormat()}getNumberFormats(){let e=this.getCoords(),t=this._createDense(this.getWorksheet().getStyles().getNormal().getNumberFormat());for(let n of this.getRegions(Qh.Feature.NumberFormat)){let r=h.intersectRanges(n.getCoords(),e);if(!r)continue;let i=n.getCell().getStyle().getNumberFormat(),a=r.colStart-e.colStart,o=r.colEnd-e.colStart+1;for(let n=r.rowStart;n<=r.rowEnd;n++)t[n-e.rowStart].fill(i,a,o)}return t}setNumberFormat(e,t){return this.getStyle().setNumberFormat(e,t),this}setNumberFormats(e,t){let n=e.map(e=>e.map(e=>({style:{numberFormat:e}})));return this.updateCells(n,t)}_validateDenseSize(){let e=this.getCoords(),t=(e.rowEnd-e.rowStart+1)*(e.colEnd-e.colStart+1);if(t>1e4)throw new k(Dx(1e4,t,this.getAddress()))}_createDense(e){this._validateDenseSize();let t=this.getCoords(),n=t.rowEnd-t.rowStart+1,r=t.colEnd-t.colStart+1,i=Array(n);for(let t=0;t<n;t++)i[t]=Array(r).fill(e);return i}createFormula(e,t){let n=this.getCoords();return this.getWorksheet().createFormula(e,{rowIndex:n.rowStart,colIndex:n.colStart},t)}addWatch(e,t,n){return this._addWatch(e,{onValues:t},void 0,n)}_addWatch(e,t,n,r){let i=this.getCoords();if(!n&&typeof e!=`string`){let t=e.getAnchor();if(t&&(t.rowIndex!==i.rowStart||t.colIndex!==i.colStart))throw Error(`ICellRange.addWatch was given a formula anchored outside the range; fill it with IFormula.shift first.`)}return this._internal.addWatch(i,e,t,n,r)}async select(e){let t=await this._internal.autoSelect(e??!0,SD([this.getCoords()]));return this._createRange(t[0])}find(e){return this._internal.find([this.getCoords()],e)}getFixed(e){return this._createRange(Yz(this.getCoords(),e))}getRangeAt(e,t,n,r,i){return this._createRange({rowStart:e,colStart:t,rowEnd:n??e,colEnd:r??t},i)}getRowAt(e,t){let n=this.getCoords();return this._createRange({colStart:n.colStart,rowStart:e,colEnd:n.colEnd,rowEnd:e},t)}getRowAfter(e){let t=this.getCoords();if(!t)return this;let n=t.rowEnd;return this._createRange({colStart:t.colStart,rowStart:n+1,colEnd:t.colEnd,rowEnd:n+1},e)}getRowBefore(e){let t=this.getCoords();if(!t)return this;let n=t.rowStart;return this._createRange({colStart:t.colStart,rowStart:n-1,colEnd:t.colEnd,rowEnd:n-1},e)}getRowBy(e,t){let n=this.getCoords(),r=n.rowStart+e;return this._createRange({colStart:n.colStart,rowStart:r,colEnd:n.colEnd,rowEnd:r},t)}getColumnAt(e,t){let n=this.getCoords();return this._createRange({colStart:e,rowStart:n.rowStart,colEnd:e,rowEnd:n.rowEnd},t)}getColumnAfter(e){let t=this.getCoords();if(!t)return this;let n=t.colEnd;return this._createRange({colStart:n+1,rowStart:t.rowStart,colEnd:n+1,rowEnd:t.rowEnd},e)}getColumnBefore(e){let t=this.getCoords();if(!t)return this;let n=t.colStart;return this._createRange({colStart:n-1,rowStart:t.rowStart,colEnd:n-1,rowEnd:t.rowEnd},e)}getColumnBy(e,t){let n=this.getCoords(),r=n.colStart+e;return this._createRange({colStart:r,rowStart:n.rowStart,colEnd:r,rowEnd:n.rowEnd},t)}getTopLeft(e){let t=this.getCoords();if(!t)return this;let n=t.colStart,r=t.rowStart;return this._createRange({colStart:n,rowStart:r,colEnd:n,rowEnd:r},e)}getBottomRight(e){let t=this.getCoords();if(!t)return this;let n=t.colEnd,r=t.rowEnd;return this._createRange({colStart:n,rowStart:r,colEnd:n,rowEnd:r},e)}getSurrounding(e){let t=this._internal;return this._createRange(t.surroundingRegion(this.getCoords(),e))}getExtended(e,t){let n=(t&&typeof t!=`string`&&!t.isICell&&t.rowIndex===void 0?t:void 0)??{cell:t};if(n.basis===`adjacent`)return this._extendedAdjacent(e);let r=null,i=this.getCoords();switch(e){case B.Direction.Up:r={colIndex:i.colStart,rowIndex:i.rowStart};break;case B.Direction.Down:r={colIndex:i.colStart,rowIndex:i.rowEnd};break;case B.Direction.Left:r={colIndex:i.colStart,rowIndex:i.rowStart};break;case B.Direction.Right:r={colIndex:i.colEnd,rowIndex:i.rowStart}}let a=this._internal,o=n.cell?a.cellToCoords(n.cell):r;if(!h.isCellWithinRange(o,i))throw new k(N(`error.address.invalidCell`));let s=a.extendRange(e,o);return n.fromBlank===`before`&&(s=this._restBeforeBlock(e,o,s)),s=h.unionRanges(i,s),this._createRange(s)}_restBeforeBlock(e,t,n){let r=e=>this._createRange(h.cellToRange(e)).isContentful(Qh.Feature.Contentful);if(r(t))return n;let i=e===B.Direction.Up||e===B.Direction.Down,a=e===B.Direction.Up||e===B.Direction.Left,o=i?{rowIndex:a?n.rowStart:n.rowEnd,colIndex:t.colIndex}:{rowIndex:t.rowIndex,colIndex:a?n.colStart:n.colEnd},s=i?o.rowIndex:o.colIndex;if(s===(i?t.rowIndex:t.colIndex)||!r(o))return n;let c=s+(a?1:-1);return i?{...n,...a?{rowStart:c}:{rowEnd:c}}:{...n,...a?{colStart:c}:{colEnd:c}}}_extendedAdjacent(e){let t=this.getCoords(),n=this._internal,r=n.getSheet().getEntireCoords(),i=e===B.Direction.Up||e===B.Direction.Down,a=e===B.Direction.Up||e===B.Direction.Left,o=i?t.rowStart:t.colStart,s=i?t.rowEnd:t.colEnd,c=i?t.colStart:t.rowStart,l=i?t.colEnd:t.rowEnd,u=i?r.rowEnd:r.colEnd,d=i?r.colEnd:r.rowEnd,f=(e,t)=>i?{rowIndex:e,colIndex:t}:{rowIndex:t,colIndex:e},p=e=>i?a?e.rowStart:e.rowEnd:a?e.colStart:e.colEnd,m=e=>i?a?e.rowEnd:e.rowStart:a?e.colEnd:e.colStart,g=(e,t)=>a?Math.max(e,t):Math.min(e,t),_=(e,t)=>a?Math.min(e,t):Math.max(e,t),v=a?o-1:s+1;if(v<0||v>u)return this;let y=null;for(let t of[c-1,l+1]){if(t<0||t>d)continue;let r=f(v,t),i=h.cellToRange(r);if(!this._createRange(i).isContentful(Qh.Feature.Contentful))continue;let a=p(n.extendRange(e,r));y=y===null?a:_(y,a)}if(y===null)return this;let b=a?0:v,x=a?v:u,S=i?{rowStart:b,rowEnd:x,colStart:c,colEnd:l}:{rowStart:c,rowEnd:l,colStart:b,colEnd:x};for(let e of this._createRange(S).entries({features:[Qh.Feature.Contentful],axis:i?B.Axis.Row:B.Axis.Column,reverse:a})){let t=h.cellToRange(e.context.getCoords());if(a){let e=this._createRange(t).getMerges();e.length>0&&(t=e[0])}y=g(y,m(t)+(a?1:-1));break}if(a?y>=o:y<=s)return this;let C=i?{...t,...a?{rowStart:y}:{rowEnd:y}}:{...t,...a?{colStart:y}:{colEnd:y}};return this._createRange(C)}getEntireRows(e,t){let n=this._internal;return this._createRange(vz([this.getCoords()],n.getSheet().getEntireCoords(),B.Axis.Column,e)[0],t)}getEntireRow(){return this.getEntireRows()}getEntireColumn(){return this.getEntireColumns()}getEntireColumns(e,t){let n=this._internal;return this._createRange(vz([this.getCoords()],n.getSheet().getEntireCoords(),B.Axis.Row,e)[0],t)}getRowHeaders(e){let t=this.getCoords();return this._internal.getSheet().getRowHeaders().getRange(t,e)}getColumnHeaders(e){let t=this.getCoords();return this._internal.getSheet().getColumnHeaders().getRange(t,e)}getDifferences(e,t){return this._deriveRanges(t,n=>{let r=this._internal,i=uD(n,r.rangeToCoords(e),B.Axis.Row);return r.getVisible(i,t)})}getIntersect(e,t){return this._deriveRange(e,t,(e,t)=>h.intersectRanges(e,t))}getUnion(e,t){return this._deriveRange(e,t,(e,t)=>h.unionRanges(e,t))}getResizeTo(e,t,n){if(t??=0,(e??=0)<0||t<0)throw new k(N(`error.address.invalidRange`));let 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??=0,t??=0;let 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){let r=this.getCoords(),i=t,a=e,o={colStart:i,rowStart:a,colEnd:r.colEnd-r.colStart+i,rowEnd:r.rowEnd-r.rowStart+a};return this._deriveRange(o,n)}getOffsetBy(e,t,n){let r=this.getCoords(),i=r.colStart+t,a=r.rowStart+e,o={colStart:i,rowStart:a,colEnd:r.colEnd-r.colStart+i,rowEnd:r.rowEnd-r.rowStart+a};return this._deriveRange(o,n)}getUsedRange(e){let t=this._internal.getUsedCoords(Qz(this._getStickyOptions(),e));if(!t)return null;let n=h.intersectRanges(t,this.getCoords());return n?this._deriveRange(n,e):null}isEmpty(){let e=this._internal.getUsedCoords();return!e||!h.intersectRanges(e,this.getCoords())}getColumnStart(){return this.getCoords().colStart}getRowStart(){return this.getCoords().rowStart}getColumnEnd(){return this.getCoords().colEnd}getRowEnd(){return this.getCoords().rowEnd}getColumnCount(){let e=this.getCoords();return e.colEnd-e.colStart+1}getRowCount(){let e=this.getCoords();return e.rowEnd-e.rowStart+1}getVisible(e){return this._deriveRanges(e,t=>this._internal.getVisible([t],e))}isContentful(e){let t=this._internal,n=this._getStickyOptions(),r=e??n?.features;if(r===void 0)return t.isContentful([this.getCoords()],n?.ignoreHidden??!1,n?.ignoreSpilled??!1);let i=t.featureCounts([this.getCoords()],r,n?.ignoreHidden??!1,n?.ignoreSpilled??!1),a=typeof r==`string`?[r]:r;for(let e=0;e<a.length;e++)if((i[a[e]]??0)>0)return!0;return!1}getStats(e){return this._internal.getRangeStats([this.getCoords()],e)}getCounts(e){let t=this._internal,n=this._getStickyOptions();return t.featureCounts([this.getCoords()],e??n?.features,n?.ignoreHidden??!1,n?.ignoreSpilled??!1)}getDirectPrecedents(){return this._internal.dependencyRanges(this.getCoords(),`precedents`,!0)}getDirectDependents(){return this._internal.dependencyRanges(this.getCoords(),`dependents`,!0)}getPrecedents(){return this._internal.dependencyRanges(this.getCoords(),`precedents`,!1)}getDependents(){return this._internal.dependencyRanges(this.getCoords(),`dependents`,!1)}getRegions(e,t){let n=this._getStickyOptions(),r=$k(e??t?.features??n?.features);return new rA(this.getCoords(),this._internal,r,{...t,ignoreHidden:t?.ignoreHidden??n?.ignoreHidden??!1})}getAnomalies(e){let t=dA(e);return new fA([{bounds:this.getCoords(),internal:this._internal,qualified:!1}],()=>this,t)}isEntireRows(){let e=this._internal;return bz([this.getCoords()],e.getSheet().getEntireCoords(),!0)}isEntireColumns(){let e=this._internal;return yz([this.getCoords()],e.getSheet().getEntireCoords(),!0)}isEntireRange(){let e=this.getCoords(),t=this._internal;return bz([e],t.getSheet().getEntireCoords(),!0)&&yz([e],t.getSheet().getEntireCoords(),!0)}isSingleCell(){let e=this.getCoords();return h.isSingleCell(e)}isEqual(e,t){let n=this._internal.rangeToCoords(e);return qz(this.getCoords(),n,this.getWorksheet().getName())}get size(){let e=this._coords;return e.colEnd-e.colStart+1*(e.rowEnd-e.rowStart+1)}getBounds(){return this._internal.getBoundsAtCoords(this.getCoords())}getBestFit(e){return this._internal.getBestFit(this.getCoords(),e)}isInvalid(){return!1}getDefaultShiftAxis(){return this._internal.getDefaultShiftAxis(this.getCoords())}getDefaultSortCriteria(e,t){return this._internal.getDefaultSortCriteria(this.getCoords(),e,t)}getDefaultAutoFillCriteria(e,t){let n=this._internal,r=t===void 0?void 0:n.rangeToCoords(t,()=>[],!0);return n.getDefaultAutoFillCriteria(this.getCoords(),e,r)}getMerges(){return this._internal.getMerges([this.getCoords()],this._getStickyOptions()?.ignoreHidden??!1)}_itemQuery(e){return{ignoreHidden:!!this._getStickyOptions()?.ignoreHidden,...e,address:this.getCoords()}}getUnlocked(e){return this._internal.getSheet().getProtectedRanges().getItems(this._itemQuery(e))}getConditionalFormats(e){return this._internal.getSheet().getConditionalFormats().getItems(this._itemQuery(e))}getControls(e){return this._internal.getSheet().getCellControls().getItems(this._itemQuery(e))}setControl(e,t){return this._validateWrite(),this._internal.setCellControl([this.getCoords()],e,t),this}getSparklineGroups(e){return this._internal.getSheet().getSparklineGroups().getItems(this._itemQuery(e))}setSparkline(e,t,n){return this._validateWrite(),e===null?(this.clear($.Content.Sparklines,n),null):this._internal.setSparkline([this.getCoords()],e,t,n)}getDataValidations(e){return this._internal.getSheet().getDataValidations().getItems(this._itemQuery(e))}getComments(e){return this._internal.getSheet().getComments().getItems(this._itemQuery(e))}getTables(e){return this._internal.getSheet().getTables().getItems(this._itemQuery(e))}getPivotTables(){let e=this.getCoords();return this._internal.getSheet().getPivotTables().getItems().filter(t=>{let n=t._getOwnCells();return(n.length>0?n:[t.getRange().getCoords()]).some(t=>h.isRangesIntersect(t,e))})}getMovables(e){return this._internal.getSheet().getMovables().getItems(this._itemQuery(e))}getSnapshot(e){return this._internal.getSnapshot([this.getCoords()],e)}isReadOnly(){return this._readOnly!==null}addListener(e,t){return this._internal.addListenerNode([this.getCoords()],e,t)}getWorksheet(){return this._internal.getSheet()}autoFill(e,t){t?.preview||this._validateWrite();let n=this._internal,r=n.rangeToCoords(e,null,!0);t?.snap&&(r=n.autoFillRange(this.getCoords(),r));let i=n.autoFill(this.getCoords(),r,t);return t?.preview?new hA(r,n,i,this._getStickyOptions()):i?this._createRange(r):this}autoFit(e){return this._validateWrite(),this._internal.autoFit([this.getCoords()],e),this}group(e,t){return this._validateWrite(),this._changeOutlineLevels(e,1,t),this}ungroup(e,t){return this._validateWrite(),this._changeOutlineLevels(e,-1,t),this}_changeOutlineLevels(e,t,n){let r=this._getOutline();if(!e){let t=this.isEntireRows();t!==this.isEntireColumns()&&(e=t?B.Axis.Row:B.Axis.Column)}e?r._changeLevels(e,this._getRun(e),t,n):(t>0&&(r._assertNotDeepest(B.Axis.Row,this._getRun(B.Axis.Row)),r._assertNotDeepest(B.Axis.Column,this._getRun(B.Axis.Column))),this.getWorksheet().doBatch(()=>{r._changeLevels(B.Axis.Row,this._getRun(B.Axis.Row),t),r._changeLevels(B.Axis.Column,this._getRun(B.Axis.Column),t)},{description:m(t>0?`op.group`:`op.ungroup`),...n}))}showGroupDetails(e,t){this._validateWrite();let n=this._resolveOutlineAxis(e);return this._getOutline()._setGroupDetails(n,this._getRun(n),!0,t),this}hideGroupDetails(e,t){this._validateWrite();let n=this._resolveOutlineAxis(e);return this._getOutline()._setGroupDetails(n,this._getRun(n),!1,t),this}clearGroups(e,t){this._validateWrite();let n=this._getOutline(),r=this.getCoords();if(r.rowStart===r.rowEnd&&r.colStart===r.colEnd)return n.clear(e,t),this;let i=e!==B.AxisSelection.Column,a=e!==B.AxisSelection.Row;return this.getWorksheet().doBatch(()=>{i&&n._clear(B.Axis.Row,this._getRun(B.Axis.Row)),a&&n._clear(B.Axis.Column,this._getRun(B.Axis.Column))},{description:m(`op.clearOutline`),...t}),this}_getOutline(){return this.getWorksheet().getOutline()}_getRun(e){let t=this.getCoords();return e===B.Axis.Column?{min:t.colStart,max:t.colEnd}:{min:t.rowStart,max:t.rowEnd}}_resolveOutlineAxis(e){if(e)return e;let t=this.isEntireRows(),n=this.isEntireColumns();if(t&&!n)return B.Axis.Row;if(n&&!t)return B.Axis.Column;throw Error(N(`error.outline.axisRequired`))}clear(e,t){return this._validateWrite(),this._internal.clear([this.getCoords()],e,t),this}setHyperlink(e,t){return this._validateWrite(),this._internal.setHyperlinks([this.getCoords()],e,t),this}setRichText(e,t){return this.setValue(yu.from(e),t)}setErrorIgnored(e,t=!0,n){return this._validateWrite(),this._internal.setErrorIgnored([this.getCoords()],e,t,n),this}setComments(e,t){return this._validateWrite(),this._internal.setComments([this.getCoords()],e,t),this}getStyle(){return this._internal.getStyle([this.getCoords()])}getFormat(){return this.getStyle()}setStyle(e,t){return this.getStyle().update(e,t),this}merge(e){return this._validateWrite(),this._internal.merge([this.getCoords()],e),this}unmerge(e){return this._validateWrite(),this._internal.unmerge([this.getCoords()],e),this}textToColumns(e){if(this._validateWrite(),this.getColumnCount()!==1)throw new k(N(`error.address.textToColumnsMulti`));typeof e==`string`&&(e={delimiter:e});let t=function(e,t){let n=t?.textQualifier===void 0?`"`:t.textQualifier,r=t?.preserveEmptyFields??!1,i=t?.delimiter,a=e.sparseBuilder(),o=1,s=e.entries({axis:B.Axis.Column,onError:`ignore`}),c=s.next();for(;!c.done;){let e=c.value.value,t=c.value.coords.rowIndex;c=s.next();let l=e,u=typeof e;if(u===`string`)i===void 0&&(i=oB(e,n));else{if(u!==`number`)continue;l=e.toString()}if(i===void 0)continue;let d=sB(l,i,n,r);for(let e=0;e<d.length;e++)d[e]!==null&&a.pushAt(t,e,d[e]);o=Math.max(o,d.length)}return o===1?e:a.build()}(this.getValuesRange(),e),n=t.getColumnCount(),r=this,i=!0;if(e?.destination&&(r=this._deriveRange(e.destination),i=r.getTopLeft().isEqual(this.getTopLeft())),n<=1&&i)return this;if(!e?.replaceExisting){let e=r.getCoords(),a=i?e.colStart+1:e.colStart,o=e.colStart+n-1;if(o>=a&&this.getRangeAt(e.rowStart,a,e.rowStart+t.getRowCount()-1,o).isContentful())throw new k(N(`error.address.textToColumnsOverwrite`))}let a=this._internal,o=a.beginCommit({description:e?.description??m(`op.textToColumns`),operation:{name:`textToColumns`}});try{let n=r.setValues(t,{description:m(`op.textToColumns`),...e,skipBoundsCheck:!0});return a.commitWithDirectives(o,SD([n.getCoords()]),{autoSelect:e?.autoSelect,autoSelectRestore:e?.autoSelectRestore},{undo:SD([this.getCoords()])}),n}catch(e){throw o.rollback(),e}}removeDuplicates(e){this._validateWrite();let t=this.getCoords(),n=this.getColumnCount(),r=this.getRowCount(),i=e?.hasHeader??!1,a;Array.isArray(e?.columns)&&(a=e.columns.map(e=>{let r=typeof e==`string`?lf(e)-t.colStart:e;if(!(r>=0&&r<n))throw new k(N(`error.address.removeDuplicatesColumn`,{column:e}));return r}));let o=function(e,t,n){let r=n?new Set(n):null,i=new Map,a=new Set,o=[],s=0,c=(e,t)=>{s+=t-e+1;let n=o[o.length-1];n&&n.rowEnd===e-1?n.rowEnd=t:o.push({rowStart:e,rowEnd:t})},l=(e,n)=>{t&&e===0||(a.has(n)?c(e,e):a.add(n))},u=(e,n)=>{t&&e===0&&(e+=1),e<n&&!a.has(``)&&(a.add(``),e+=1),e<n&&c(e,n-1)},d=-1,f=``,p=e.entries({axis:B.Axis.Row,includeEmpty:!1}),m=p.next();for(;!m.done;){let{value:e,coords:{rowIndex:n,colIndex:a}}=m.value;n!==d&&(d!==-1&&l(d,f),u(d+1,n),d=n,f=``),t&&n===0||r!==null&&!r.has(a)||(f+=cB(a,e,i)),m=p.next()}return d!==-1&&l(d,f),{runs:o,count:s,isEmpty:d===-1}}(this.getValuesRange(),i,a);if(o.isEmpty)throw new k(N(`error.address.removeDuplicatesNoData`));let s=this._internal,c=this.getResizeTo(r-o.count,n);if(o.count>0){let n=o.runs.map(e=>({colStart:t.colStart,colEnd:t.colEnd,rowStart:t.rowStart+e.rowStart,rowEnd:t.rowStart+e.rowEnd})),r={colStart:t.colStart,colEnd:t.colEnd,rowStart:t.rowEnd-o.count+1,rowEnd:t.rowEnd},i=s.beginCommit({description:m(`op.removeDuplicates`),...e,operation:{name:`removeDuplicates`}});try{s.deleteCells(n,B.Axis.Row),s.insertCells([r],B.Axis.Row),s.commitWithDirectives(i,SD([c.getCoords()]),e,{undo:SD([t])})}catch(e){throw i.rollback(),e}}return c}insert(e){return this._validateWrite(),typeof e==`object`&&e?.span?(this._spanShift(e,!0),this):(this._internal.insertCells([this.getCoords()],e),this)}_spanShift(e,t){let{span:n,...r}=e,i=this._internal.getSheet(),a=this.getCoords(),o=e.axis??this.getDefaultShiftAxis(),s=null,c=i.getTables().getItems();for(let e=0;e<c.length;e++){let t=c[e].getRange().getCoords();if(!(a.rowEnd<t.rowStart||a.rowStart>t.rowEnd||a.colEnd<t.colStart||a.colStart>t.colEnd)){if(!(a.rowStart>=t.rowStart&&a.rowEnd<=t.rowEnd&&a.colStart>=t.colStart&&a.colEnd<=t.colEnd))throw new k(N(`error.table.tableSplit`));s=c[e];break}}if(!s){let e=i.getEntireCoords(),n=o===B.Axis.Row?{...a,colStart:e.colStart,colEnd:e.colEnd}:{...a,rowStart:e.rowStart,rowEnd:e.rowEnd};t?this._internal.insertCells([n],{...r,axis:o}):this._internal.deleteCells([n],{...r,axis:o});return}if(o===B.Axis.Row){let e=s.getDataRange().getCoords();if(a.rowStart<e.rowStart||a.rowEnd>e.rowEnd)throw new k(N(`error.table.tableBodyRows`));let n=a.rowStart-e.rowStart,i=a.rowEnd-a.rowStart+1;t?s.addRows(n,i,r):s.deleteRowsAt(n,i,r);return}let l=s.getRange().getCoords(),u=a.colStart-l.colStart,d=a.colEnd-a.colStart+1,f=s,p=r.description??m(t?d>1?`op.addTableColumns`:`op.addTableColumn`:d>1?`op.deleteTableColumns`:`op.deleteTableColumn`);i.doBatch(()=>{if(t)for(let e=0;e<d;e++)f.addColumn(u);else{let e=[];for(let t=0;t<d;t++){let n=f.getColumnAt(u+t);n&&e.push(n)}for(let t=e.length-1;t>=0;t--)e[t].delete()}},{...r,description:p})}addAutoTable(e){return this._validateWrite(),this._internal.getSheet().addAutoTable(this.getCoords(),e)}addTable(e){return this._validateWrite(),this._internal.getSheet().getTables().add(this.getCoords(),e)}async insertFrom(e,t){this._validateWrite();let n=await this._internal.insertFrom([this.getCoords()],e,t);return n?this._createRange(n):null}canInsertFrom(e,t){return this._internal.canInsertFrom([this.getCoords()],e,t)}async copyFrom(e,t){this._validateWrite();let n=await this._internal.copyFrom(this.getCoords(),e,t);return n?this._createRange(n):null}delete(e){return this._validateWrite(),typeof e==`object`&&e?.span?(this._spanShift(e,!1),this):(this._internal.deleteCells([this.getCoords()],e),this)}sort(e){this._validateWrite();let t=this._internal,n=this.getCoords(),r=t.sort(n,e);return h.isEqualRanges(r,n)?this:this._createRange(r)}sortAt(e,t,n,r){return this.sort({sorts:[{index:e,criteria:{reverse:t,sortOn:n}}],...r})}async filter(e,t){this._validateWrite();let n=this._internal,r=this.getCoords(),i=await n.filter(r,e,t);return h.isEqualRanges(i,r)?this:this._createRange(i)}doBatch(e,t){return this._internal.getSheet().doBatch((t,n)=>e(t,F.of(n).wrap(this)),typeof t==`string`?t:{description:m(`op.rangeUpdate`),...t})}createSparseBuilder(e){return this._internal.createSparseBuilder(e,this)}getA1(){return this.getAddress()}getAddress(e){let t=this._internal;return Gd(this.getCoords(),t.getSheet().getEntireCoords())}toString(){return this.getAddress()}get[Symbol.toStringTag](){return`[SheetRange]`}get isICellRange(){return!0}},hA=class extends mA{constructor(e,t,n,r){super(e,t,{getOptions:r??{},readOnly:m(`error.sheet.previewRange`)}),this._projection=n}getCell(e,t){let n=this._getCellAddress(e,t),r=this.getCoords(),i=r.rowStart,a=r.colStart;if(n){let e=this._internal.cellToCoords(n);if(!h.isCellWithinRange(e,r))throw new k(N(`error.sheet.oobCell`));i=e.rowIndex,a=e.colIndex}return this._projection.getCellAt(i,a)}getCells(e){return this._validateMaxSize(e?.maxSize),this._projectRows(e=>e)}getValues(e){return this._validateMaxSize(e?.maxSize),this._projectRows(e=>e.getValue())}getInteropValues(e){return this._validateMaxSize(e?.maxSize),this._projectRows(e=>e.getInteropValue())}getFormulas(){return this._validateDenseSize(),this._projectRows(e=>e.getFormulaText()??``)}getNumberFormats(){return this._validateDenseSize(),this._projectRows(e=>e.getStyle().getNumberFormat())}getValuesRange(){return gA()}_projectRows(e){let t=this.getCoords(),n=this._projection,r=[];for(let i=t.rowStart;i<=t.rowEnd;i++){let a=[];for(let r=t.colStart;r<=t.colEnd;r++)a.push(e(n.getCellAt(i,r)));r.push(a)}return r}get[Symbol.toStringTag](){return`[PreviewSheetRange]`}},gA=()=>{throw new k(N(`error.sheet.previewRange`))},_A=class extends mA{constructor(e,t,n,r,i,a){super(n,r,i),this.isINamedRange=!0,this._id=e,this._name=t,this._rangesResolver=a??null}getCoords(){return this._coords}getId(){return this._id}getName(){return this._name}getRanges(){return this._rangesResolver?this._rangesResolver():new tz([this._coords],this._internal,this._options)}toString(){return`${this.getName()} => ${this.getAddress()}`}get[Symbol.toStringTag](){return`[NamedRange: ${this._name}]`}},vA=class extends _A{constructor(e,t,n,r){super(e.id,e.name,{rowStart:e.rowIndex,colStart:e.colIndex,rowEnd:e.rowIndex,colEnd:e.colIndex},n,r),this._info=e,this._namedFormulas=t}_named(){return this._namedFormulas?.getById(this._info.id)??null}getRanges(){return this._named()?.getRanges()??null}getDirectPrecedents(){return this._named()?.getDirectPrecedents()??Promise.resolve(null)}getPrecedents(){return this._named()?.getPrecedents()??Promise.resolve(null)}getDirectDependents(){return this._named()?.getDirectDependents()??Promise.resolve(null)}getDependents(){return this._named()?.getDependents()??Promise.resolve(null)}get[Symbol.toStringTag](){return`[NamedCellRange: ${this.getName()} @ ${this.getAddress()}]`}};function yA(e,t,n){let r=1,i=1,a=!1,o=e._getMerges([t]);if(o.length>0){a=!0;let e=o[0];if(r=e.colEnd-e.colStart+1,i=e.rowEnd-e.rowStart+1,(t.colEnd-t.colStart+1)%r!=0||(t.rowEnd-t.rowStart+1)%i!=0)throw new k(N(`error.sheet.sortMergeSize`));let n=o.length;for(let e=1;e<n;e++){let t=o[e];if(t.colEnd-t.colStart+1!==r||t.rowEnd-t.rowStart+1!==i)throw new k(N(`error.sheet.sortMergeSize`))}}let s=function(e,t,n,r){let i;typeof t==`boolean`?i={sorts:[{index:0,criteria:{reverse:t}}]}:Array.isArray(t)?i={sorts:t}:(i={...t},i.sorts&&i.sorts.length!==0||(i.sorts=[{index:0}]));let a=i?.axis??B.Axis.Row;i.axis=a,i.hasHeader=i.hasHeader??!1,i.reverse=i.reverse??Au.DefaultRangeOptions.reverse,i.collatorOptions=i.collatorOptions??Au.DefaultRangeOptions.collatorOptions,i.collators=i.collators??Au.DefaultCollators;let o=a===B.Axis.Row,s=e;i.hasHeader&&(s={...s},o?s.rowStart+=r:s.colStart+=n);let c=o?s.colEnd-s.colStart:s.rowEnd-s.rowStart,l=i.sorts?[...i.sorts]:[];l.length===0&&l.push({index:0});let u=l.length;for(let e=0;e<u;e++){let t=l[e]={index:e,...l[e]};if(t.index<0||t.index>c)throw new w(N(`error.sort.sortOobRange`));let n=t.criteria;n!==null&&(t.criteria={reverse:n?.reverse??i.reverse,collatorOptions:n?.collatorOptions??i.collatorOptions,...n},l[e]=t)}return i.sorts=l,i}(t,n,r,i),c=s.axis,l=c===B.Axis.Row,u=t;s?.hasHeader&&(u={...u},l?u.rowStart+=i:u.colStart+=r);let d=l?u.colStart:u.rowStart,f=s.sorts,p=f.length;for(let e=0;e<p;e++){let t=f[e];t.index+=d}let h=f[0].criteria,g=s?.description??m(h?.reverse?`op.sortDescending`:`op.sortAscending`);e._protectionCheck(()=>[`sort`],t,g);let _=[],v=[],y=null,b=null,x=null,S=-(2**53-1),C=Array(p),T=new Map;for(let e=0;e<p;e++)T.set(f[e],e);f.sort((e,t)=>e.index-t.index);for(let e=0;e<p;e++)C[T.get(f[e])]=e;let E=null,D=s?.includeHidden??!1;D||(E=_o(Bz(l?e._rowHeaders:e._colHeaders)));let O=e._cellIterator({bounds:u,axis:c,ignoreHidden:!D&&c,searchTypes:{[G.Type.FillStyle]:!1,[G.Type.ContentStyle]:!1,[G.Type.DateFormat]:!1,[G.Type.Continuous]:!1,[G.Type.Merge]:!1,[G.Type.Formula]:!1,[G.Type.CalcStatus]:!1,[G.Type.Hyperlink]:!1,[G.Type.Comments]:!1}}),A=l?i:r,j=(l?u.rowStart:u.colStart)-A,M=O.next();for(;!M.done;){let e=M.value.context,t=e.getCell();if(a&&!t.isTopLeft()){M=O.next();continue}let n=e.getCoords(),r=l?n.rowIndex:n.colIndex,i=l?n.colIndex:n.rowIndex;if(j!==r){for(j+=A,E&&(j=E(j));j<r;)_.push(null),v.push(j),j+=A,E&&(j=E(j));b=[],x=[],y={minorIndex:r,values:b,sortValues:x},_.push(y),v.push(r),j=r,S=f[0].index}for(;i>S;){let e=f[x.length];S=e?e.index:2**53-1,i>S&&x.push(null)}i===S&&x.push(t),b.push(t),M=O.next()}if(!y||_.length===0)return;let ee=new Map,te=new Map,P=s.collators,F=P.length;for(let e=0;e<F;e++){let t=P[e];ee.set(t.type,t.compare),te.set(t.type,e)}let ne=e.getRuntime().getLocaleProfile(),re=ne.tag,ie=Array(p),ae=(e,t)=>{let n=ie[e];n||(ie[e]=n=new Map);let r=n.get(t);if(!r){let i=te.get(t);r={...ne.collator,...P[i]?.defaultOptions,...f[e].criteria?.collatorOptions,locale:re},n.set(t,r)}return r},oe=_.length,se=Array(oe);for(let e=0;e<oe;e++)se[e]=_[e]===null;_.sort((e,t)=>{for(let n=0;n<p;n++){let r=C[n],i=e?e.sortValues[r]:null,a=t?t.sortValues[r]:null,o=i?i.getValue():null,s=a?a.getValue():null;if(o===s)continue;if(s===null)return-1;if(o===null)return 1;let c=i.getType(),l=a.getType();if(c===U.Error&&l===U.Error)return 0;let u;if(c!==l)u=te.get(c)-te.get(l);else{let e=ee.get(c);if(!e)continue;u=e(o,s,ae(r,c))}if(u!==0)return f[r].criteria?.reverse?-u:u}return 0});let ce=Array(oe),le=!1;for(let e=0;e<oe;e++){let t=_[e],n=t?t.minorIndex!==v[e]:!se[e];ce[e]=n,n&&(le=!0)}if(!le)return u;let ue=e._beginCommit({description:g}),de=e._getState().borderSpatial,fe=[],pe=-1,me=-1,he=()=>{pe!==-1&&fe.push(l?{rowStart:pe,rowEnd:me,colStart:u.colStart,colEnd:u.colEnd}:{rowStart:u.rowStart,rowEnd:u.rowEnd,colStart:pe,colEnd:me})};for(let e=0;e<oe;e++){if(!ce[e])continue;let t=v[e];pe!==-1&&t<=me+1?me=Math.max(me,t+A-1):(he(),pe=t,me=t+A-1)}he(),e._clear(fe,void 0,void 0,!0);let I=e._createSparseBuilder({axis:c});for(let e=0;e<oe;e++){if(!ce[e])continue;let t=_[e];if(!t)continue;let n=v[e],r=t.values,i=r.length;for(let e=0;e<i;e++){let t=r[e],i=t.getCoords(),a=l?n:i.rowIndex,o=l?i.colIndex:n;I.pushAt(a,o,t)}}return I.apply(),e._updateState({borderSpatial:de}),ue.commit(),u}function bA(e,t,n,r){return{x:e*r-t*n,y:e*n+t*r}}function xA(e){let t=0,n=0,r=0,i=0,a=0,o=0,s=0,c=e.length;if(c===0)return{m:0,b:0};if(c===1)return{m:1,b:e[0]};for(let l=0;l<c;l++)o=l+1,s=e[l],s==null||isNaN(s)||(t+=o,n+=s,i+=o*o,r+=o*s,a++);let l=(a*r-t*n)/(a*i-t*t);return{m:l,b:n/a-l*t/a}}var SA,CA=class{constructor(e,t){this._c=e,this._tvTl=t}tvTl(){return this._tvTl(this._c)}getCoords(){return this._c}},wA=class e{constructor(e,t,n){this._tokens=null,this._r1c1=null,this.a1=e,this.ref=t,this.block=n}isCompiled(){return this.block!==null}setBlock(e){if(this.block=e,!e)return;let t=this.imageBlock(e);t!==this.a1&&(this.a1=t,this._tokens=null,this._r1c1=null)}imageBlock(e){let t=this.ref;return e.getTextAt(t.rowStart,t.colStart)}imageAtAnchor(){let e=this.ref;return this.a1=this._emitTextAt(e.rowStart,e.colStart),this}relativeForm(){let e=this._r1c1;return e===null&&(this._tokens=[],e=this._r1c1=Cf(this.a1,this.ref.rowStart,this.ref.colStart,this._tokens)),e}_emitterTokens(){return this._tokens||this.relativeForm(),this._tokens}_emitTextAt(e,t,n){let r=this._emitterTokens(),i=r.length,a=r=>{let i=r.colIndex,a=r.rowIndex,o=i!==-(2**53-1)&&!r.$colIndex&&i+t<0||a!==-(2**53-1)&&!r.$rowIndex&&a+e<0;return o&&n&&(n.oob=!0),o},o=``;for(let n=0;n<i;n++){let i=r[n];if(typeof i==`string`){o+=i;continue}let s=r[n+1]===`:`?r[n+2]:void 0;s===void 0||typeof s==`string`?o+=a(i)?`#REF!`:yf(i,e,t):(n+=2,o+=a(i)||a(s)?`#REF!`:yf(i,e,t)+`:`+yf(s,e,t))}return o}getTextAt(e,t,n,r,i){let a=this.block;return a?a.getTextAt(e,t,n,r,i):n?this.relativeForm():this._emitTextAt(e,t)}getTokensAt(e,t,n){return this.block?.getTokensAt(e,t,n)??[]}isReferenceOnly(){let e=this.block;if(e)return e.isReferenceOnly();let t=this._emitterTokens(),n=0;for(let e=0;e<t.length;e++){let r=t[e];if(typeof r!=`string`){n++;continue}let i=r.trim();if(i!==``&&i!==`:`)return!1}return n>0}getError(){return this.block?.getError()??null}getReferencesAt(e,t){return this.block?.getReferencesAt(e,t)??[]}_pieceAt(t){let n=h.sanitizeRange(t),r=this.getTextAt(n.rowStart,n.colStart);return new e(r,n,this.block)}getSplit(e,t,n){return[this._pieceAt(e[0]),this._pieceAt(e[1])]}getMerged(t,n,r){if(this.relativeForm()!==t.relativeForm())return;let i=h.sanitizeRange(n),a=i.rowStart===this.ref.rowStart&&i.colStart===this.ref.colStart?this:t,o=new e(a.a1,i,a.block);return o._r1c1=a._r1c1,o._tokens=a._tokens,o}getShifted(t){let n=t.after;if(!n)return null;let r=h.sanitizeRange(n);return{...n,value:new e(this.a1,r,null)}}copyTo(t,n){let r=h.sanitizeRange(t),i;if(n?.cutFrom)i=new e(this.a1,r,null);else if(this.block)i=new e(this.block.getTextAt(r.rowStart,r.colStart),r,null);else{let t={oob:!1};i=new e(this._emitTextAt(r.rowStart,r.colStart,t),r,null),t.oob||(i._r1c1=this.relativeForm(),i._tokens=this._tokens)}return{colStart:r.colStart,rowStart:r.rowStart,colEnd:r.colEnd,rowEnd:r.rowEnd,value:i}}canTile(e,t){return!0}get[Symbol.toStringTag](){return`[FormulaEntry]`}toString(){return`${zd(this.ref)}: ${this.a1}${this.block?``:` (pending)`}`}},TA=class extends wA{constructor(e,t,n){super(e,t,null),this._made=null,this._isResolved=!1,this._resolve=n}_view(){if(this._isResolved)return this._made;let e=this._resolve();return e===void 0?null:(this._isResolved=!0,this._made=e)}isCompiled(){return this._view()?.isCompiled()??!1}getTextAt(e,t,n,r,i){let a=this._view();return a?a.getTextAt(e,t,n,r,i):super.getTextAt(e,t,n,r,i)}getTokensAt(e,t,n){return this._view()?.getTokensAt(e,t,n)??[]}isReferenceOnly(){let e=this._view();return e?e.isReferenceOnly():super.isReferenceOnly()}getError(){return this._view()?.getError()??null}};(SA||={}).CalcStatus={Working:1,Waiting:2};var EA=class{get _block(){return this._blockOwn}constructor(e,t,n,r){this._coords=e,this._blockOwn=t,this._options=n,this._isCompiled=r??null}isCompiled(){return!this._isCompiled||this._isCompiled()}getTokens(e){let t=this._coords??h.EmptyCell;return this._block.getTokensAt(t.rowIndex,t.colIndex,e)}isValid(){return!this._block.getError()}autoCorrect(){if(this.isValid())return null;let e=this.getExpression({target:this._options.inputTarget??`storage`});return this._options.autoCorrect?.(e,this._coords??void 0)??null}evaluate(e){let t=this._coords??h.EmptyCell,n=this._options.getCalcGrid?.();if(!n)return Promise.resolve(null);if(!this.isCompiled()){let e=this._options.getCalculationStatus?.();if(e===Q.Status.Off||e===Q.Status.Error||e===Q.Status.Stopping)return Promise.reject(Error(`The formula is not compiled and the calculation engine is not running.`))}return n.evaluateAt(t.rowIndex,t.colIndex,e)}getCalculationStatus(){return this.isCompiled()?Q.ResultStatus.Ready:Q.ResultStatus.Pending}getReferences(){return this._resolveReferences(this._referencesAt()??void 0)}hasRefError(){return OA(this._referencesAt())}_referencesAt(){let e=this._coords;return e?this._block.getReferencesAt(e.rowIndex,e.colIndex):null}_resolveReferences(e){if(!e?.length)return null;let t=this._options.resolveSheetScope,n=[];for(let r of e)if(r&&!V.isError(r)){if(`nameId`in r)n.push(r.nameId);else{let e=r;if(e.scope&&t){let n=t(e.scope);n&&(e={...e,scope:n})}else if(!e.scope){let t=this._options.getOwnScope?.();t&&(e={...e,scope:t})}n.push(e)}}else n.push(null);if(!n.some(e=>e!==null))return null;try{return this._options.getRanges(n)}catch{let e=n.map(e=>{if(e===null)return null;try{return this._options.getRanges([e]),e}catch{return null}});return e.some(e=>e!==null)?this._options.getRanges(e):null}}async setReferenceAt(e,t,n){let r=this._coords,i=this._options,a=i.getCalcGrid?.();if(!r||!a)return this;this._checkCompiled();let o=i.getRange(t),s=o?.isINamedRange?{nameId:o.getId()}:o.getCoords()??null;if(typeof t==`string`&&!t.includes(`:`)&&s?.colStart!==void 0){let e=s,t={colIndex:e.colStart,rowIndex:e.rowStart,$colIndex:e.$colStart??!1,$rowIndex:e.$rowStart??!1};e.scope&&(t.scope=e.scope),s=t}let c=i.getRange(r),l=N(`op.updateFormulaAt`,{address:c.getAddress()});n&&typeof n!=`string`&&!n.description&&((n={...n}).description=l);let u=null;return await i.doBatchCalcGrid(async t=>(u=await t.setReferenceAt(r.rowIndex,r.colIndex,e,s),h.cellToRange(r)),n??l),this._rewritten(u,r)}_rewritten(e,t){return e?this._options.getRange(t).getCell().getFormula()??this:this}async setReferenceModeAt(e,t=`self`,n,r){let i=this._coords??h.EmptyCell,a=this._options;this._checkCompiled();let o=a.getRange(i),s=o?N(`op.updateReferenceStyleAt`,{address:o.getAddress()}):m(`op.updateReferenceStyle`);r&&typeof r!=`string`&&!r.description&&((r={...r}).description=s);let c=null;return await a.doBatchCalcGrid(async r=>(c=await r.setReferenceModeAt(i.rowIndex,i.colIndex,e,t,n),h.cellToRange(i)),r??s),this._rewritten(c,i)}_checkCompiled(){if(!this.isCompiled())throw Error(`The formula is not compiled yet; its references cannot be edited.`)}isReferenceOnly(){return this._block.isReferenceOnly()}isVolatile(){let e=this._coords;return e?this._options.getCalcGrid?.()?.isVolatileAt(e.rowIndex,e.colIndex)??Promise.resolve(!1):Promise.resolve(!1)}getExpression(e){let t=e?.cell??this._coords??h.EmptyCell,n=e?.r1c1??!1,r=e?.target;return this._block.getTextAt(t.rowIndex,t.colIndex,n,e?.evalIndex,r)}getAnchor(){return this._coords}shift(e){let t=this.getExpression({cell:e,target:this._options.inputTarget??`storage`});return this._options.createAt?.(t,e)??null}get[Symbol.toStringTag](){return`[Formula]`}toString(){return this.getExpression()}toJSON(){return`=`+this.getExpression()}get isIFormula(){return!0}},DA=class e extends EA{get _block(){return super._block}constructor(e,t,n,r){super(e,t,n),this._doEval=r}evaluate(e){let t=this._block;return this._doEval(t,e)}hasRefError(){let e=this._coords??h.EmptyCell;return OA(this._block.getReferences(e.rowIndex,e.colIndex))}async setReferenceAt(t,n){let r=this._coords;if(!r)return this;let i=this._options.getRange(n),a=i?.isINamedRange?{nameId:i.getId()}:i.getCoords()??null,o=typeof n==`string`?n.includes(`!`):n?.colStart===void 0||!!n.scope;a?.scope&&!o&&(a={...a,scope:void 0});let s=a?.colStart===void 0?a:xf(a,r.rowIndex,r.colIndex);if(typeof n==`string`&&!n.includes(`:`)&&s?.colStart!==void 0){let e=s,t={colIndex:e.colStart,rowIndex:e.rowStart,$colIndex:e.$colStart??!1,$rowIndex:e.$rowStart??!1};e.scope&&(t.scope=e.scope),s=t}return new e(r,this._block.setReferenceAt(t,s),this._options,this._doEval)}async setReferenceModeAt(e,t=`self`,n,r){let i=this._coords;if(!i)return this;let a=this._block.getReferences(i.rowIndex,i.colIndex)?.[e];if(!a||`nameId`in a||a.colStart===void 0)return this;let o=a;if(o.scope&&this._options.resolveSheetScope){let e=this._options.resolveSheetScope(o.scope);e&&(a={...o,scope:e})}let s=bf(a,i.rowIndex,i.colIndex);return this.setReferenceAt(e,kA(s,t,n))}};function OA(e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){let n=e[t];if(!n||V.isError(n))return!0}return!1}var kA=(e,t=`self`,n)=>{let r=t===`right`,i=n;if(i===void 0){let t=r?e.$colEnd:e.$colStart,n=r?e.$rowEnd:e.$rowStart;i=t&&n?0:n&&!t?1:t&&!n?2:3}let a=i+1;(a>3||a<0)&&(a=0);let o=a===0||a===1,s=a===0||a===2,c={...e};return t===`self`?(c.$rowStart=o,c.$colStart=s,c.$rowEnd=o,c.$colEnd=s):t===`right`?(c.$rowEnd=o,c.$colEnd=s):(c.$rowStart=o,c.$colStart=s),c},AA={Sheet:`sheet`,NamedFormula:`namedFormula`,Table:`table`,TableColumn:`tableColumn`,Function:`function`},jA=class{constructor(){this._providers=new Map}registerProvider(e,t){this._providers.set(e,t)}bind(e,t,n={}){return this._providers.get(e)?.bind(t,n)??null}resolve(e,t,n={}){return this._providers.get(e)?.resolve(t,n)??null}},MA=class{constructor(e,t){this._base=e,this._overrides=t}registerProvider(e,t){this._base.registerProvider(e,t)}bind(e,t,n={}){let r=this._overrides.get(e);return r?r.bind(t,n):this._base.bind(e,t,n)}resolve(e,t,n={}){let r=this._overrides.get(e);return r?r.resolve(t,n):this._base.resolve(e,t,n)}};function NA(e){if(!e)return null;let t=e.indexOf(`[`);if(t===-1)return null;let n=e.indexOf(`]`,t+1);if(n===-1)return null;let r=e.substring(t+1,n);if(!r)return null;let i=e.substring(n+1);return{book:r,positional:/^\d+$/.test(r),dir:e.substring(0,t),sheetName:i===``?null:i}}function PA(e){return RA(e).file}function FA(e,t){let{dir:n,file:r}=RA(e);return(n||function(e){let t=e.getSources();for(let e=0;e<t.length;e++){let{dir:n,file:r}=zA(t[e]);if(n&&r)return n}return``}(e))+`[`+r+`]`+(t??``)}var IA=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath`;function LA(e){let t=e;return/^[A-Za-z]:[\\/]/.test(e)?t=`file:///`+encodeURI(e.replace(/\\/g,`/`)):e.startsWith(`\\\\`)&&(t=`file://`+encodeURI(e.substring(2).replace(/\\/g,`/`))),{type:IA,target:t,role:`book`}}function RA(e){return zA(e.getSources()[0])}function zA(e){let t=e?.target??``;if(!t)return{dir:``,file:``};let n=!1;if(t.startsWith(`file:///`)?(t=t.substring(8),n=!0):t.startsWith(`file://`)&&(t=`\\\\`+t.substring(7),n=!0),n){try{t=decodeURIComponent(t)}catch{}t=t.replace(/\//g,`\\`)}let r=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return r===-1?{dir:``,file:t}:{dir:t.substring(0,r+1),file:t.substring(r+1)}}var BA=`ext:`,VA=e=>typeof e==`string`&&e.startsWith(`ext:`);function HA(e){if(!VA(e))return null;let t=e.substring(4).split(`:`),n=t[0];if(!n||t.length>3)return null;if(t.length===1)return{bookId:n,sheetIndex:-1,sheetEnd:-1};let r=UA(t[1]),i=t.length===3?UA(t[2]):r;return r<0||i<0?null:{bookId:n,sheetIndex:r,sheetEnd:i}}var UA=e=>{let t=Number(e);return e!==``&&Number.isInteger(t)&&t>=0?t:-1},WA=(e,t,n=t)=>{if(t<0)return BA+e;let r=BA+e+`:`+t;return n===t?r:r+`:`+n},GA=WA;function KA(e,t,n,r){if(!e)return null;if(VA(t))return function(e,t){let n=HA(t);return!(!n||e._getIndexById(n.bookId)===-1)&&(n.sheetIndex<0||n.sheetEnd<(e.getById(n.bookId)?.getSheetNames().length??0))}(e,t)?t:null;let i=NA(t);if(r)return i?null:qA(e,r,t);if(!i)return null;let a=!n||i.positional||i.sheetName?.includes(`:`)?null:n,o=null;if(i.positional)o=e._getIdByIndex(Number(i.book));else{let t=function(e,t,n){let r=t.book.toLowerCase(),i=t.dir.toLowerCase(),a=null,o=0;for(let t of e.getItems())if(PA(t).toLowerCase()===r){if(i&&FA(t).toLowerCase().startsWith(i+`[`))return t.getId();a=t.getId(),o++}return o===0?null:o>1?i?null:`ambiguous`:i&&n?null:a}(e,i,a!=null);if(t===`ambiguous`)return null;o=t,o===null&&a&&(o=a.addBook(i))}if(o===null)return null;if(i.sheetName===null)return GA(o,-1);let s=qA(e,o,i.sheetName);if(s!==null)return s;if(a){let e=a.addSheet(o,i.sheetName);if(e>=0)return GA(o,e)}return null}function qA(e,t,n){let r=n.indexOf(`:`);if(r===-1){let r=JA(e,t,n);return r===-1?null:GA(t,r)}let i=JA(e,t,n.substring(0,r)),a=JA(e,t,n.substring(r+1));return i===-1||a===-1?null:GA(t,Math.min(i,a),Math.max(i,a))}function JA(e,t,n){let r=e.getById(t);if(!r)return-1;let i=r.getSheetNames(),a=n.toLowerCase();for(let e=0;e<i.length;e++)if(i[e]?.toLowerCase()===a)return e;return-1}function YA(e){return{stableId:e,toString:()=>V.BuiltIn.Ref.toString(),getName:()=>null,getEntireCoords:()=>null}}var XA=class{constructor(e,t,n,r){this._getId=e,this._getById=t,this._external=n,this._getIndexById=r}bind(e,t){let n=t;if(n?.book)return this._external?.bind(e,!1,n.book)??null;let r=this._getById(e);if(r!==null)return r.stableId;let i=this._getId(e);return i===null?ZA(e)?this._bindSpan(e):this._external?.bind(e,!0===n?.mint)??null:i}resolve(e,t){let n=this._getById(e);if(n!==null)return n;let r=QA(e);return r?this._resolveSpan(e,r[0],r[1]):this._external?.resolve(e,!0===t?.display)??null}_bindSpan(e){let t=e.indexOf(`:`),n=this._bindEndpoint(e.substring(0,t)),r=this._bindEndpoint(e.substring(t+1));if(n===null||r===null)return null;if(n===r)return n;let i=this._getIndexById?.(n)??-1,a=this._getIndexById?.(r)??-1;if(i>a&&a!==-1){let e=n;n=r,r=e}return n+`:`+r}_bindEndpoint(e){let t=this._getById(e);return t?.getName?t.stableId:this._getId(e)}_resolveSpan(e,t,n){let r=this._getById(t),i=this._getById(n);return r?.getName&&i?.getName?{stableId:e,toString:()=>r.toString()+`:`+i.toString(),getName:()=>{let e=r.getName(),t=i.getName();return e!==null&&t!==null?e+`:`+t:null},getEntireCoords:()=>r.getEntireCoords()}:function(e){return{stableId:e,toString:()=>V.BuiltIn.Ref.toString(),getName:()=>null,getEntireCoords:()=>null}}(e)}},ZA=e=>e.includes(`:`)&&!VA(e)&&!/[[\]\\/]/.test(e);function QA(e){if(typeof e!=`string`||VA(e))return null;let t=e.indexOf(`:`);if(t<=0||t===e.length-1)return null;let n=e.substring(0,t),r=e.substring(t+1);return ej.test(n)&&ej.test(r)?[n,r]:null}function $A(e,t,n,r){let i=QA(e);if(!i)return;let[a,o]=i,s=t.indexOf(a),c=t.indexOf(o);if(s===-1||c===-1)return;let l=t.slice(Math.min(s,c),Math.max(s,c)+1),u=e=>n.includes(e),d=!u(a),f=!u(o);if(!d&&!f&&r!==void 0&&n.indexOf(a)>n.indexOf(o)&&(r===a?d=!0:r===o&&(f=!0)),!d&&!f)return;let p=e=>u(e)&&!(e===a&&d)&&!(e===o&&f),m=d?l.find(p):a,h=f?[...l].reverse().find(p):o;return m!==void 0&&h!==void 0?m===h?m:n.indexOf(m)<=n.indexOf(h)?m+`:`+h:h+`:`+m:void 0}var ej=/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;function tj(e){if(typeof e!=`string`)return!1;if(VA(e)){let t=HA(e);return t!==null&&t.sheetEnd!==t.sheetIndex}return QA(e)!==null}var nj=class{constructor(e,t,n,r=null,a=null){this.fakeId=i.uuidV4(),this.lowerName=e,this.displayName=t,this.lowerScope=r,this.viewScope=a,this._real=n}},rj=(e,t)=>t?`${t}::${e}`:e,ij=e=>e?.getScope?.()?.toLowerCase()??null,aj=class{constructor(e,t,n=e=>e.getName()){this._getByName=e,this._getById=t,this._nameOf=n,this._byName=new Map,this._byId=new Map,this._byRealId=new Map}bind(e,t){let n=e.toLowerCase(),r=(t?.scope)?.toLowerCase()??null,i=!0===t?.own,a,o=null;if(i)a=r;else{if(o=this._getByName(n,r)??null,!o&&!0===t?.existing)return null;a=ij(o)}let s=rj(n,a),c=this._byName.get(s);if(c){c._real||this._adopt(c,o??this._getByName(n,r)??null);let e=c._real??this._getById(c.fakeId);if(!e||this._nameOf(e).toLowerCase()===c.lowerName&&ij(e)===c.lowerScope)return c.fakeId;this._adopt(c,e),this._rekey(c,this._nameOf(e).toLowerCase(),ij(e))}i&&(o=this._getByName(n,r)??null);let l=o&&!i?this._byId.get(o.getId())??this._byRealId.get(o.getId()):void 0;if(l)return this._adopt(l,o),this._rekey(l,n,a),l.fakeId;let u=new nj(n,e,o,a,r);return this._byName.set(s,u),this._byId.set(u.fakeId,u),o&&this._byRealId.set(o.getId(),u),u.fakeId}_adopt(e,t){e._real=t,t&&this._byRealId.set(t.getId(),e)}_rekey(e,t,n){let r=rj(t,n),i=rj(e.lowerName,e.lowerScope);r!==i&&(this._byName.get(i)===e&&this._byName.delete(i),e.lowerName=t,e.lowerScope=n,this._byName.set(r,e))}resolve(e,t){let n=this._byId.get(e);if(!n)return null;if(!n._real){let e=this._getByName(n.lowerName,n.viewScope)??null;e&&this._adopt(n,e)}return{stableId:n.fakeId,toString:()=>(n._real?this._nameOf(n._real):null)??n.displayName}}getRealById(e){let t=this._byId.get(e);if(!t)return null;if(!t._real){let e=this._getByName(t.lowerName,t.viewScope)??null;e&&this._adopt(t,e)}return t._real}reconcile(){let e=[];for(let t of this._byId.values())if(t._real!==null){let n=t._real.getId();if(this._getById(n)){let n=this._nameOf(t._real).toLowerCase(),r=ij(t._real);n===t.lowerName&&r===t.lowerScope||(this._rekey(t,n,r),e.push(t.fakeId))}else this._byRealId.get(n)===t&&this._byRealId.delete(n),t._real=null,e.push(t.fakeId)}else{let n=this._getById(t.fakeId)??this._getByName(t.lowerName,t.viewScope)??null;n&&(this._adopt(t,n),this._rekey(t,t.lowerName,ij(n)),e.push(t.fakeId))}return e}cloneMaps(){return{byName:new Map(this._byName),byId:new Map(this._byId),byRealId:new Map(this._byRealId)}}},oj=class{constructor(e,t){this._getId=e,this._getById=t}bind(e,t){let n=this._getById(e);if(n!==null)return n.stableId;let r=t?.tableName;return this._getId(e,r)}resolve(e,t){let n=this._getById(e);return n===null?null:n}},sj=new WeakMap;function cj(e){let t=fl(),n=t?.functions;if(!n)return;let r=sj.get(t);if(!r){r=new Map;for(let e in n)r.set(n[e].toUpperCase(),e);sj.set(t,r)}return r.get(e)}function lj(e){return cj(e.toUpperCase())}var uj=class{constructor(e){this._deadIds=new Map,this._getCollection=e}bind(e,t){if(this._deadIds.has(e))return e;let n=e.toUpperCase(),r=cj(n)??n,a=this._getCollection()?.getByName(r);if(a&&!a.isLambda())return a.getName();for(let[e,t]of this._deadIds)if(t===n)return e;let o=i.uuidV4();return this._deadIds.set(o,n),o}resolve(e,t){let n=this._getCollection()?.getByName(e);if(n&&!n.isLambda()){let r=n.getName();return t?.canonical?{stableId:e,toString:()=>r}:{stableId:e,toString:()=>{return e=r,fl()?.functions?.[e]??r;var e}}}let r=this._deadIds.get(e);return r?{stableId:e,toString:()=>r}:null}};function dj(e,t,n){let r=[...e];for(let e=0;e<r.length;e++){let i=r[e];i?.colStart!==void 0&&(r[e]=bf(i,t,n))}return r}function fj(e,t,n=!1,r=!1,i){if(!t)return e;let a,o=()=>(a===void 0&&(a=r&&i?.scope?t.bind(AA.Table,``,{at:i}):null),a),s=n?{canonical:!0}:void 0,c=e.length,l=[],u=r?{display:!0}:void 0,d=(e,t,n,i)=>{let a=Ld(n);if(r&&VA(t)){let t=a.indexOf(`]`,a.lastIndexOf(`[`));if(t!==-1)return l.push({...e,type:vg.ExternalReference,value:n,text:a.substring(0,t+1)}),void l.push({...e,text:a.substring(t+1)+`!`+i})}l.push({...e,text:a+`!`+i})};for(let n=0;n<c;n++){let r=e[n],a=r.type;if(a===vg.Cell){let e=r.value;if(e?.scope){let n=t.resolve(AA.Sheet,e.scope,u)?.toString()??e.scope,i={...r,value:{...e,scope:n}};r.text===void 0||r.text.includes(`!`)?l.push(i):d(i,e.scope,n,r.text);continue}l.push(r)}else if(a===vg.Named){let e=r.value,n=e.name,i=t.resolve(AA.NamedFormula,n)?.toString()??n,a=e.scope;if(a){let n=t.resolve(AA.Sheet,a,u)?.toString()??a,o={...r,value:{...e,name:i,scope:n}};r.text===void 0||r.text.includes(`!`)?l.push(o):d(o,a,n,r.text)}else l.push(i===n?r:{...r,value:{...e,name:i}})}else if(a===vg.Error){let e=r.value,n=e?.scope;if(n){let i=t.resolve(AA.Sheet,n,u)?.toString()??n,a={...r,value:{...e,scope:i}};r.text===void 0||s_(r.text)?l.push(a):d(a,n,i,r.text)}else l.push(r)}else if(a===vg.TableReference){let a=r.value;if(i&&a&&a===o()&&pj(e,n+1,a))continue;let s=t.resolve(AA.Table,a)?.toString()??a,c=r.text===a?s:r.text;l.push(s===a?r:{...r,value:s,text:c})}else if(a===vg.TableColumn||a===vg.TableSpecifier){let e=r.value;if(!e||typeof e!=`object`){l.push(r);continue}let n=e.table?t.resolve(AA.Table,e.table)?.toString()??e.table:``,i=a===vg.TableColumn?t.resolve(AA.TableColumn,e.name)?.toString()??e.name:e.name;l.push(n!==e.table||i!==e.name?{...r,value:{...e,table:n,name:i},text:r.text??i}:r)}else if(a===vg.Function){let e=r.value,n=t.resolve(AA.Function,e,s)?.toString()??t.resolve(AA.NamedFormula,e)?.toString()??e;l.push(n===e?r:{...r,value:n})}else l.push(r)}return function(e,t,n){let r,i=e.length;for(let a=0;a<i;a++){let i=e[a],o=i.context;if(!o)continue;r??=new Map;let s=r.get(o);if(s===void 0){let e=o.type===`table`?AA.Table:AA.Function,i=t.resolve(e,o.name,n)?.toString()??(e===AA.Function?t.resolve(AA.NamedFormula,o.name)?.toString():void 0)??o.name;s=i===o.name?o:{...o,name:i},r.set(o,s)}s!==o&&(e[a]={...i,context:s})}return e}(l,t,s)}function pj(e,t,n){let r=0;for(let i=t;i<e.length;i++){let t=e[i],a=t.context;if(a?.type!==`table`||a.name!==n)break;let o=t.type;if(o===vg.TableColumn)r++;else if(o!==vg.Paren&&o!==vg.Prefix&&o!==vg.Whitespace)return!1}return r===1}function mj(e,t,n=!1,r=0,i=0,a=Cg){let o=``,s=yf,c=vf,l=a.separators,u=e.length;for(let d=0;d<u;d++){let u=e[d],f=u.type;if(f===vg.Cell){let a=u.value;if(!n&&u.refSide===`left`&&!a.scope){let n=e[d+1],s=e[d+2];if(n&&n.value===`:`&&s&&s.type===vg.Cell&&s.referenceIndex===u.referenceIndex){let e=s.value,n=Bd(bf({colStart:a.colIndex,rowStart:a.rowIndex,colEnd:e.colIndex,rowEnd:e.rowIndex,$colStart:a.$colIndex,$rowStart:a.$rowIndex,$colEnd:e.$colIndex,$rowEnd:e.$rowIndex},r,i),t);if(n!==null){o+=n,d+=2;continue}}}let l=a.colIndex;if(!a.$colIndex&&l!==-(2**53-1)&&l!==2**53-1&&!n){let e=l+i;if(e<0||!a.scope&&t&&(e<t.colStart||e>t.colEnd)){o+=`#REF!`;continue}}let f=a.rowIndex;if(!a.$rowIndex&&f!==-(2**53-1)&&f!==2**53-1&&!n){let e=f+r;if(e<0||!a.scope&&t&&(e<t.rowStart||e>t.rowEnd)){o+=`#REF!`;continue}}o+=n?c(a):s(a,r,i)}else if(f===vg.Named||f===vg.Parameter){let e=u.value;e.scope&&(o+=Ld(e.scope)+`!`),o+=e.optional?`[${e.name}]`:e.name}else if(f===vg.TableReference)o+=u.value;else if(f===vg.TableColumn)o+=Bg(u.value.name);else if(f===vg.TableSpecifier)o+=yj(u.value.name,a);else if(f===vg.Empty)o+=``;else if(f===vg.Boolean)o+=a.localizeBoolean(u.value);else if(f===vg.Function)o+=u.value;else if(f===vg.Separator)o+=u.value===`;`?l.separatorRow:l.separatorFunction;else if(f!==vg.Prefix||u.value!==`-`&&u.value!==`+`||e[d+1]?.type!==vg.Number){if(f===vg.Number)o+=SB(u.value,l.separatorDecimal);else if(f===vg.Error){let e=u.value;e?.scope&&(o+=Ld(e.scope)+`!`);let t=o_(u.value);o+=t?a.localizeError(t):String(e?.error??u.value)}else f===vg.ExternalReference||(o+=u.value)}else{let t=e[d+1].value;o+=SB(u.value===`-`?-t:t,l.separatorDecimal),d++}}return o}function hj(e,t,n=Cg){return mj(e,t,!0,0,0,n)}function gj(e,t,n=0,r=0,i=Cg){return mj(e,t,!1,n,r,i)}function _j(e,t){let n=e.lastIndexOf(`!`)+1,r=e.endsWith(`#`),i=r?e.length-1:e.length,a=e.substring(n,i);if(!t.$colIndex&&t.colIndex!==-(2**53-1)&&t.colIndex<0||!t.$rowIndex&&t.rowIndex!==-(2**53-1)&&t.rowIndex<0)return`#REF!`;let o=yf({...t,scope:null},0,0);return o.toUpperCase()===a.toUpperCase()?e:e.substring(0,n)+o+(r?`#`:``)}function vj(e,t=0,n=0){let r=e.length,i=[];for(let a=0;a<r;a++){let r=e[a];if(r.type!==`cell`){i[a]=r;continue}let o={...r},s={...o.value};o.value=s,i[a]=o;let c=!1;s.colIndex===-(2**53-1)||s.$colIndex||(s.colIndex+=n,c||=n!==0),s.rowIndex===-(2**53-1)||s.$rowIndex||(s.rowIndex+=t,c||=t!==0),c&&o.text!==void 0&&(o.text=_j(o.text,s))}return i}function yj(e,t){if(!t.localizeSpecifier)return e;let n=e.startsWith(`[`)&&e.endsWith(`]`),r=n?e.slice(1,-1):e;if(!r.startsWith(`#`))return e;let i=`#`+t.localizeSpecifier(r.slice(1));return n?`[${i}]`:i}var bj=class{constructor(e,t){this._error=void 0,this.record=e,this._imager=t}getTextAt(e,t,n=!1,r,i){let a=this.record,o=this._imager,s=a.error;if(s?.unparsed)return s.input;let c=i===`display`,l=r===void 0?a.tokens:xj(a.tokens,r);l=fj(l,o.symbols,!c,c,c?{scope:o.gridId,rowIndex:e,colIndex:t}:null);let u=c?o.getDisplayLocale():Cg;return n?hj(l,o.getEntireCoords(),u):gj(l,o.getEntireCoords(),e,t,u)}getTokensAt(e,t,n){let r=this.record,i=n===void 0?r.tokens:xj(r.tokens,n);return i=fj(i,this._imager.symbols,!1,!0),vj(i,e,t)}isReferenceOnly(){return this.record.isReferenceOnly}getError(){let e=this._error;if(e===void 0){let t=this.record.error;e=this._error=t?new V.Parse(t.message,t.details):null}return e}getReferencesAt(e,t){let n=this.record.references;if(!n?.length)return[];let r=this._imager,i=Array(n.length);for(let t=0;t<n.length;t++){let a=n[t];if(a){if(`nameId`in a){let e=a.nameId;i[t]={nameId:r.symbols.resolve(AA.NamedFormula,e)?.toString()??e}}else if(`table`in a){let n=r.resolveTableReference?.(a.table,e)??null;i[t]=!n||V.isError(n)?null:{...n,tableId:a.table.tableId}}else i[t]={...a}}else i[t]=null}return dj(i,e,t)}get[Symbol.toStringTag](){return`[FormulaRecordView]`}};function xj(e,t){let n=-1,r=-1,i=e.length;for(let a=0;a<i;a++){let i=e[a];i.evalIndex===t&&i.type!==vg.Whitespace&&(n<0&&(n=a),r=a)}if(n<0)return[];let a=e=>e.evalIndex!==void 0&&e.evalIndex>=t;for(;n>0&&a(e[n-1]);)n--;for(;r<i-1&&a(e[r+1]);)r++;return e[n].type===vg.Whitespace&&n<r&&n++,e[r].type===vg.Whitespace&&r>n&&r--,e.slice(n,r+1)}var Sj,Cj=0x4000000000000,wj=(e,t)=>Math.abs(e)*Cj<=Math.abs(t)&&Number.isFinite(e)?0:e,Tj=e=>e.answer,Ej=(e,t)=>{let n=e.formulaInserts;if(!n)return e;let r=Array(n.length);for(let e=0;e<n.length;e++){let i=n[e];r[e]={...i,value:new bj(i.value,t)}}return{...e,formulaInserts:r}},Dj=e=>{switch(e.type){case`autoFill`:case`copyTo`:return e.commitId;case`create`:case`requestPass`:case`seed`:case`snapshot`:case`rollback`:case`calculate`:case`markDirty`:case`demand`:case`close`:case`setReference`:case`setReferenceMode`:case`toJSON`:case`evaluate`:case`graph`:case`nameGraph`:case`isVolatile`:case`setBody`:return;case`revert`:return e.options.commitId;default:return e.options?.commitId}},Oj=class{constructor(e){this._emitter=null,this._gridId=e.id,this._sendRequest=e.send,this._calculation=e.calculation??null}_landingId(e){let t=e?.commitId,n=e?.cloneKey;return n!==void 0&&n!==t?n:t===void 0?void 0:`${t}:0`}_send(e,t){return this._sendRequest(this._gridId,e,t)}getId(){return this._gridId}resize(e,t){this._send(this._landingId(t),{type:`resize`,entireCoords:{colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colEnd,rowEnd:e.rowEnd},options:t})}setHidden(e,t,n){this._send(this._landingId(n),{type:`hidden`,axis:e,runs:t,options:n})}setFiltered(e,t){this._send(this._landingId(t),{type:`filtered`,filtered:e,options:t})}setPivots(e,t){return this._send(this._landingId(t),{type:`pivots`,pivots:e,options:t})}addListeners(e,t){return this._emitter??=new ne(this),this._emitter.addListeners(e,t)}setInputs(e,t,n){return this._setInputs(e,t,void 0,n)}remove(e,t){return this._setInputs(null,[{...e,scope:this._gridId,value:null}],{...e,scope:this._gridId},t)}_setInputs(e,t,n,r){return this._send(this._landingId(r),{type:`setInputs`,values:e,formulas:t,deleteRange:n,options:r})}shift(e){return this._send(this._landingId(e),{type:`shift`,options:e})}autoFill(e,t,n){return typeof e==`string`&&(e=uf(e)),typeof t==`string`&&(t=uf(t)),this._send(this._landingId(n),{type:`autoFill`,template:e,destination:t,commitId:n?.commitId})}calculate(e){return this._send(void 0,{type:`calculate`,full:e}).then(()=>this._calculation?.getStatus()??Q.Status.Running)}requestPass(){this._send(void 0,{type:`requestPass`})}demand(e){this._send(void 0,{type:`demand`,rects:e})}markDirtyRegions(e){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];t[n]={colStart:r.colStart,rowStart:r.rowStart,colEnd:r.colEnd,rowEnd:r.rowEnd},r.scope!==void 0&&(t[n].scope=r.scope)}this._send(void 0,{type:`markDirty`,coords:t})}delete(e){this._send(this._landingId(e),{type:`delete`,options:e})}revert(e){return this._send(void 0,{type:`revert`,options:e})}close(){this._send(void 0,{type:`close`})}seed(e,t){return this._send(void 0,{type:`seed`,json:e,options:t})}async toJSON(e){return Tj(await this._send(void 0,{type:`toJSON`,options:e}))??null}getSnapshot(e){let t=this,n=`snap`+i.uuidV4(),r=this._calculation?.getStatus();r!==Q.Status.Running&&r!==Q.Status.Starting||this._send(void 0,{type:`snapshot`,snapshotId:n});let a=Object.freeze({...e}),o=a.range;return typeof o==`string`&&(o=uf(o)),o={...o},o.scope=t.getId(),{copyTo(e,r){let i=e.range;return typeof i==`string`&&(i=uf(i)),t._sendRequest(e.gridId,t._landingId(r),{type:`copyTo`,sourceGridId:t._gridId,snapshotId:n,coords:o,destination:i,isCut:r?.isCut??a.isCut,fitDestination:r?.fitDestination,transpose:r?.transpose,commitId:r?.commitId})},getCoords:()=>o,getSource:()=>t,getName:()=>`Calculation`,getMarkOptions:()=>a,isISnapshot:!0}}async getGraphNeighborsAt(e,t,n){let r={colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colEnd,rowEnd:e.rowEnd};return e.scope!==void 0&&(r.scope=e.scope),Tj(await this._send(void 0,{type:`graph`,kind:t,direct:n,coords:r}))??{cells:[],names:[]}}async isVolatileAt(e,t){return Tj(await this._send(void 0,{type:`isVolatile`,row:e,column:t}))??!1}async evaluateAt(e,t,n){await this._calculation?.ready();let r=typeof n==`number`?n:n?.evalIndex;return Tj(await this._send(void 0,{type:`evaluate`,row:e,column:t,evalIndex:r}))??null}async evaluateScalarAt(e,t,n){return await this._calculation?.ready(),Tj(await this._send(void 0,{type:`evaluate`,row:e,column:t,evalIndex:n,coerce:`scalar`}))??null}setBody(e){return this._send(void 0,{type:`setBody`,body:e})}setReferenceAt(e,t,n,r){let i=V.isError(r)?`#REF!`:r;return this._send(void 0,{type:`setReference`,row:e,column:t,index:n,precedent:i}).then(n=>kj(n,e,t))}setReferenceModeAt(e,t,n,r=`self`,i){return this._send(void 0,{type:`setReferenceMode`,row:e,column:t,index:n,side:r,mode:i}).then(n=>kj(n,e,t))}},kj=(e,t,n)=>{let r=e.formulaInserts;if(!r)return null;for(let e=0;e<r.length;e++){let i=r[e];if(t>=i.rowStart&&t<=i.rowEnd&&n>=i.colStart&&n<=i.colEnd)return i.value??null}return null},Aj=class e{constructor(e,t,n=`dynamic`,r=null,i=null,a=null){this._c=e,this._cycleId=t,this._k=n,this._a=!r||r.rows===0&&r.columns===0?null:r,this._h=i,this._b=a}getHolder(){return this._h}getAnchor(){let e=this._c,t=this._a;return t?{row:e.rowStart+t.rows,column:e.colStart+t.columns}:{row:e.rowStart,column:e.colStart}}getAnchorOffset(){return this._a}getGap(){return e.gapOf(this._c,this._k,this._a)}isAnchor(e,t){let n=this._c,r=this._a;return e===n.rowStart+(r?r.rows:0)&&t===n.colStart+(r?r.columns:0)}getCycleId(){return this._cycleId}getKind(){return this._k}getError(){return this._k===`error`}isFixed(){return this._k===`fixed`}getCoords(){return this._c}getBlockedCoords(){return this._b}_blockedAt(e){let t=this._b;if(!t)return null;let n=e.rowStart-this._c.rowStart,r=e.colStart-this._c.colStart;return{colStart:t.colStart+r,rowStart:t.rowStart+n,colEnd:t.colEnd+r,rowEnd:t.rowEnd+n,scope:e.scope}}setError(t,n,r=!1){let i=this._k===`fixed`?`fixed`:t?`error`:`dynamic`,a=this.getAnchor(),o=i===`error`&&!r,s=o?{colStart:a.column,rowStart:a.row,colEnd:a.column,rowEnd:a.row,scope:this._c.scope}:this._c;return{...s,value:new e(s,n,i,o?null:this._a,this._h,o?this._b??this._c:null)}}checkShift(e,t,n){if(this._k!==`fixed`&&this._k!==`pivot`)return;let r=this._c,i=t?r.colStart:r.rowStart,a=t?r.colEnd:r.rowEnd,o=t?e.colStart:e.rowStart,s=t?e.colEnd:e.rowEnd;if(a<o)return;let c=t?r.rowStart:r.colStart,l=t?r.rowEnd:r.colEnd,u=t?e.rowStart:e.colStart,d=t?e.rowEnd:e.colEnd;if(l<u||c>d)return;let f;if(f=!(c<u||l>d)&&(n?i>=o:i>s||i>=o&&a<=s),!f)throw new k(this._k===`pivot`?N(`error.pivotTable.shiftPartial`):N(`error.sheet.changePartOfArray`))}getTranslated(t,n){let r=this._c,i={colStart:r.colStart+n,rowStart:r.rowStart+t,colEnd:r.colEnd+n,rowEnd:r.rowEnd+t,scope:r.scope};return{...i,value:new e(i,this._cycleId,this._k,this._a,this._h,this._blockedAt(i))}}getShifted(t){this.checkShift(t.intersect,t.axis===B.Axis.Column,t.amount>0);let n=t.after;if(!n)return null;let r=h.sanitizeRange(n);return{...r,value:new e(r,this._cycleId,this._k,this._a,this._h,this._blockedAt(r))}}getMerged(e,t,n){}getSplit(e,t){if(this._k===`fixed`||this._k===`pivot`)throw new k(this._k===`pivot`?N(`error.pivotTable.shiftPartial`):N(`error.sheet.changePartOfArray`))}},jj=(e,t)=>{let n=e.search(t),r=n.length;for(let e=0;e<r;e++)if(n[e].value.getKind()===`pivot`)return n.filter(e=>e.value.getKind()!==`pivot`);return n};(Sj=Aj||={}).gapOf=(e,t,n)=>{if(t!==`pivot`||!n||n.rows<=0)return null;let r=e.rowStart+n.rows-1;return{rowStart:r,colStart:e.colStart,rowEnd:r,colEnd:e.colEnd,scope:e.scope}},Sj.cellsOf=(e,t)=>{if(!t)return[e];let n=[];return t.rowStart>e.rowStart&&n.push({...e,rowEnd:t.rowStart-1}),t.rowEnd<e.rowEnd&&n.push({...e,rowStart:t.rowEnd+1}),n},Sj.isInGap=(e,t)=>t!==null&&e.rowStart>=t.rowStart&&e.rowEnd<=t.rowEnd;var Mj,Nj={colStart:0,rowStart:0,colEnd:0,rowEnd:0},Pj=(e,t,n)=>{if(!e)return null;Nj.colStart=n,Nj.colEnd=n,Nj.rowStart=t,Nj.rowEnd=t;let r=e.search(Nj);for(let e=0;e<r.length;e++){let i=r[e];if(i.rowStart===t&&i.colStart===n)return i.value.getHolder()}return null},Fj=class e{constructor(e,t){this._c=e,this._a=t}getCoords(){return this._c}getAxis(){return this._a}getShifted(t){return t.after?{...t.after,value:new e(t.after,this._a)}:null}getMerged(t,n,r){let i=this._a;return new e(n,i)}getSplit(t,n){let r=this._a;return[new e(t[0],r),new e(t[1],r)]}getState(){return this._c}};function Ij(e,t,n){if(!e||e.length===0)return i.EmptyArray;let r=[],a=t?B.Axis.Column:B.Axis.Row;for(let i=0;i<e.length;i++){let o=e[i],s=o[0],c=o[1];for(let e=0;e<c.length;e++){let i=c[e],o=i[0],l=i[1].length-1,u={colStart:t?s:o,rowStart:t?o:s,colEnd:t?s:o+l,rowEnd:t?o+l:s},d={...u,value:new Fj({...u},a)};n!==void 0&&(d.scope=n),r.push(d)}}return r}function Lj(e,t){return e.colStart===t.colStart&&e.rowStart===t.rowStart}function Rj(e,t,n){return!!n&&e===n.rowStart&&t===n.colStart}function zj(e,t,n){if(!t)return;let r=t.length;for(let i=0;i<r;i++){let[r,a]=t[i],o=a.length;for(let t=0;t<o;t++){let[i,o]=a[t];Uj(e,Wj(r,i,i+o.length-1,n)),Gj(e,r,i,o,n)}}}(function(e){class t extends Error{constructor(e,t,n){super(`The calc clone boundary could not send ${e}: `+(t.length?t.map(e=>`${e.path} is a ${e.type}`).join(`, `):String(n?.message??n))),this.name=`CloneBoundaryError`,this.violations=t}}e.BoundaryError=t;let n=`off`,r=null,i=null;e.setMode=e=>{n=e===`audit`||e===`clone`?e:`off`,n===`off`&&(r=null)},e.getMode=()=>n,e.setListener=e=>{i=e},e.getViolations=()=>r?Array.from(r.values()):[],e.clearViolations=()=>{r=null},e.request=(e,t)=>n===`off`?e:a(e,`request:${t}`,`request`),e.results=(e,t)=>n===`off`?e:a(e,`results:${t}`,`results`);let a=(e,r,i)=>{if(e==null)return e;let a=[];if(s(e,i,r,a,new Set),n===`audit`)return e;try{return structuredClone(e)}catch(e){throw new t(r,a,e)}},o=(e,t,n,a,o)=>{let s=`${t}|${n}|${a}|${o}`,c=r??=new Map;if(c.has(s))return void e.push(c.get(s));let l={where:t,path:n,kind:a,type:o};c.set(s,l),e.push(l),i?.(l)},s=(e,t,n,r,i)=>{if(e==null)return;let a=typeof e;if(a===`function`)return o(r,n,t,`function`,`function`);if(a===`symbol`)return o(r,n,t,`function`,`symbol`);if(a!==`object`)return;let c=e;if(i.has(c))return;if(i.add(c),Array.isArray(c)){for(let e=0;e<c.length;e++)s(c[e],`${t}[]`,n,r,i);return}if(c instanceof Date||c instanceof RegExp||c instanceof ArrayBuffer||ArrayBuffer.isView(c))return;if(c instanceof Map){for(let[e,a]of c)s(e,`${t}<key>`,n,r,i),s(a,`${t}<value>`,n,r,i);return}if(c instanceof Set){for(let e of c)s(e,`${t}<entry>`,n,r,i);return}let l=Object.getPrototypeOf(c);if(l===Object.prototype||l===null){let e=Object.keys(c);for(let a=0;a<e.length;a++)s(c[e[a]],`${t}.${e[a]}`,n,r,i);return}let u=c.constructor?.name??`anonymous`;if(c instanceof Error)return o(r,n,t,`downgraded`,u);o(r,n,t,`live`,u)}})(Mj||={});var Bj=(e,t,n,r,i)=>{let a=-1,o=-2;Jj(r,(r,s)=>{r===o+1||(a!==-1&&e.push({...Wj(t,n+a,n+o,i),value:!0}),a=r),o=s}),a!==-1&&e.push({...Wj(t,n+a,n+o,i),value:!0})};function Vj(e,t){if(!e)return[];let n=[];for(let r=0;r<e.length;r++){let[i,a]=e[r];for(let e=0;e<a.length;e++)Bj(n,i,a[e][0],a[e][1],t)}return n}function Hj(e,t,n){Uj(e,n);let r=t.getAxis()===B.Axis.Column,i=t.getRuns({bounds:n}),a=i.next();for(;!a.done;){let[t,n,o]=a.value;a=i.next(),Gj(e,t,n,o,r)}}function Uj(e,t){e.isEmpty()||e.insertNonOverlapping({colStart:t.colStart,rowStart:t.rowStart,colEnd:t.colEnd,rowEnd:t.rowEnd,value:null})}var Wj=(e,t,n,r)=>r?{colStart:e,rowStart:t,colEnd:e,rowEnd:n}:{colStart:t,rowStart:e,colEnd:n,rowEnd:e},Gj=(e,t,n,r,i)=>{Jj(r,(r,a,o)=>{e.insertNonOverlapping({...Wj(t,n+r,n+a,i),value:o})})},Kj=cl.Type.Error,qj=1<<Kj,Jj=(e,t)=>{let n=-1,r=null;xo.forEachLeaf(e,(e,i,a,o)=>{if(!0===e.isIRepeatingList&&e.getPeriod()===1){let o=pg(e.at(i)),s=V.isError(o)?o.getLabel():null;s!==r&&(r!==null&&t(n,a-1,r),n=a,r=s);return}let s=e.typeMask;if(s!==void 0&&(s&qj)===0)return r!==null&&t(n,a-1,r),void(r=null);let c=s===void 0?null:e;for(let s=a;s<=o;s++){let o=i+s-a,l=null;if(c===null||c.typeAt(o)===Kj){let t=c===null?pg(e.at(o)):e.at(o);V.isError(t)&&(l=t.getLabel())}l!==r&&(r!==null&&t(n,s-1,r),n=s,r=l)}}),r!==null&&t(n,e.length-1,r)};function Yj(e,t,n,r,i,a,o,s,c,l,u,d,f=!1,p,m,g){let _,v,y=null,b=i.size();d===void 0&&(d=a.getAxis()===B.Axis.Column);let x=t?t.length:0,S=n?n.length:0,C,w=x+S;for(let l=0;l<w&&b>0;l++){let u=l<x?t[l]:n[l-x],d=i.search(u),f=d.length;for(let t=0;t<f;t++){let n=d[t];if(n.value.getKind()===`pivot`)continue;let l=n.value.getAnchor();if(!Rj(l.row,l.column,u)){if(n.value.getError()||n.value.isFixed())continue;C||=[],C.push(n)}i.remove(n,Lj);let f=n.value;if(e!==-1&&e===f.getCycleId()||c?.(null,n),!f.getError())for(let e of gM(n))a.delete(e),r.insertNonOverlapping({colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colEnd,rowEnd:e.rowEnd,value:null},{onIntersect:(e,t)=>{if(e.value!==null)return o?.(e.colStart,e.rowStart,e.colEnd,e.rowEnd),y=h.unionRanges(y,e),s?.insertNonOverlapping(e),y=h.unionRanges(y,e),t}});b--}}for(let e=0;e<x;e++){let n=t[e],i={colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colEnd,rowEnd:n.rowEnd,scope:n.scope,value:null};r.insertNonOverlapping(i,{onIntersect:(e,t)=>{if(e.value===null)return;let n=h.sanitizeRange(t);return f&&s?.insertNonOverlapping(n),l?.insertNonOverlapping({...t,value:!1}),o?.(n.colStart,n.rowStart,n.colEnd,n.rowEnd),y=h.unionRanges(y,n),t}}),p?.insertNonOverlapping(i),m?.insertNonOverlapping(i),u?.insertNonOverlapping(i,{onIntersect:(e,t)=>{if(e.value!==null)return o?.(t.colStart,t.rowStart,t.colEnd,t.rowEnd),y=h.unionRanges(y,t),t},onUpdates:(e,t,n)=>{v||=[];let r=e.length;for(let t=0;t<r;t++){let n=e[t];v.push(n)}_||=[];let i=t.length;for(let e=0;e<i;e++){let n=t[e],r=h.sanitizeRange(n);_.push(r)}}})}let T=d?B.Axis.Column:B.Axis.Row;if(C){let t=C.length,n=zB(t);for(let i=0;i<t;i++){let t=C[i],a=t.value.setError(!0,e,!!g);c?.(a,null),n[i]=a,y=h.unionRanges(y,t);let s=a.value.getAnchor(),l={colStart:s.column,rowStart:s.row,colEnd:s.column,rowEnd:s.row,scope:a.scope};r.insertNonOverlapping({...l,value:new Fj(l,T)}),o?.(t.colStart,t.rowStart,t.colEnd,t.rowEnd)}(g??i).load(n)}for(let e=0;e<S;e++){let t=h.sanitizeRange(n[e]);r.insertNonOverlapping({colStart:t.colStart,rowStart:t.rowStart,colEnd:t.colEnd,rowEnd:t.rowEnd,value:new Fj(t,T)}),f&&s?.insertNonOverlapping(t),o?.(t.colStart,t.rowStart,t.colEnd,t.rowEnd),y=h.unionRanges(y,t)}return y}function Xj(e,t,n,r){let i=t?.block;if(!i)return;let a=n?.scope??t.gridId,o,s,c,l;n?(o=n.colStart,s=n.rowStart,c=n.colEnd,l=n.rowEnd):(o=t.colIndex,s=t.rowIndex,c=t.colIndex,l=t.rowIndex);let u=e.get(i);u||(u=[],e.set(i,u));for(let e=0;e<u.length;e++){let t=u[e],n=t.value;if(n.index!==r||t.scope!==a)continue;o<t.colStart&&(t.colStart=o),s<t.rowStart&&(t.rowStart=s),c>t.colEnd&&(t.colEnd=c),l>t.rowEnd&&(t.rowEnd=l);let i=n.formulaEntry;i.colStart=t.colStart,i.rowStart=t.rowStart,i.colEnd=t.colEnd,i.rowEnd=t.rowEnd;return}let d=i.ref;u.push({colStart:o,rowStart:s,colEnd:c,rowEnd:l,scope:a,value:{formulaEntry:{colStart:o,rowStart:s,colEnd:c,rowEnd:l,scope:a,value:i},formulaBlockWidth:d.colEnd-d.colStart+1,formulaBlockHeight:d.rowEnd-d.rowStart+1,index:r,$absColStart:!1,$absColEnd:!1,$absRowStart:!1,$absRowEnd:!1}})}var Zj=(e,t,n,r=Qj)=>{if(r.$absColStart=r.$absColEnd=t,r.$absRowStart=r.$absRowEnd=n,!t&&!n||!e||V.isError(e)||`nameId`in e)return r;let i=e;return t&&(i.$colStart||i.$colEnd)&&(r.$absColStart=!!i.$colStart,r.$absColEnd=!!i.$colEnd),n&&(i.$rowStart||i.$rowEnd)&&(r.$absRowStart=!!i.$rowStart,r.$absRowEnd=!!i.$rowEnd),r},Qj={$absColStart:!1,$absColEnd:!1,$absRowStart:!1,$absRowEnd:!1};function $j(e,t,n=null){let r=e.colEnd-e.colStart,i=e.rowEnd-e.rowStart,a=e.value,o=a.formula,s=a.ref,c=s.rowStart,l=s.colStart,u=o.resolvedPrecedentsAt(c,l,!0,CM,wM),d=u.length,f=o.getReferences(c,l);for(let a=0;a<d;a++){let o=u[a];if(V.isError(o))continue;let s=Zj(f[a],wM[a],CM[a]),c=s.$absColEnd,l=s.$absRowEnd,d={colStart:o.colStart,rowStart:o.rowStart,colEnd:o.colEnd+(c?0:r),rowEnd:o.rowEnd+(l?0:i),scope:o.scope??e.scope,value:{formulaEntry:e,formulaBlockWidth:r+1,formulaBlockHeight:i+1,index:a,$absColStart:s.$absColStart,$absColEnd:c,$absRowStart:s.$absRowStart,$absRowEnd:l}};n&&n.push(o),t.push(d)}}var eM=(e,t,n)=>{let r=e.search(t),i=r.length;if(i===0)return null;let a=[],o=[],s=[],c=[],l=new Set;for(let e=0;e<i;e++){let i=r[e],u=i.value,d=u.formulaEntry;if(i.colEnd===i.colStart&&i.rowEnd===i.rowStart||u.index<0)continue;if(l.has(d)){a.push(i);continue}let f=d.colEnd-d.colStart,p=d.rowEnd-d.rowStart,m=i.colStart,h=i.rowStart,g=i.colEnd,_=i.rowEnd,v=n({precedentEntry:i,precedentValue:u,formulaEntry:d,fw:f,fh:p,nw:u.$absColEnd?g-m+1:g-m-f+1,nh:u.$absRowEnd?_-h+1:_-h-p+1},t);if(!v)continue;l.add(d),a.push(i),o.push(d);let y=v.length;for(let e=0;e<y;e++)c.push(v[e]),$j(v[e],s)}return a.length===0?null:{precedents:{inserts:s,removes:a},formulas:{inserts:c,removes:o}}},tM=(e,t,n)=>{n.sort((e,t)=>e-t),t.sort((e,t)=>e-t);let r=[e];if(t.length>0){r=[];let n=e;for(let i=0;i<t.length;i++){let a=e.rowStart+t[i];if(a<=n.rowStart||a>n.rowEnd)continue;let o=vc(n,{rowStart:a,colStart:n.colStart,rowEnd:n.rowEnd,colEnd:n.colEnd},Cc);o&&o.length===2&&(r.push(o[0]),n=o[o.length-1])}r.push(n)}if(n.length>0){let t=[];for(let i=0;i<r.length;i++){let a=r[i];for(let r=0;r<n.length;r++){let i=e.colStart+n[r];if(i<=a.colStart||i>a.colEnd)continue;let o=vc(a,{rowStart:a.rowStart,colStart:i,rowEnd:a.rowEnd,colEnd:a.colEnd},Cc);o&&o.length===2&&(t.push(o[0]),a=o[o.length-1])}t.push(a)}r=t}return r.length>1?r:null},nM=(e,t)=>{let{precedentEntry:n,precedentValue:r,formulaEntry:i,fw:a,fh:o,nw:s,nh:c}=e,l=[],u=[],d=(e,t,n)=>{t<=0||t>n||e.indexOf(t)===-1&&e.push(t)},f=r.$absColStart,p=r.$absColEnd,m=r.$absRowStart,h=r.$absRowEnd;return!(a>0)||f&&p||(d(l,t.colStart-i.colStart,a),f||d(l,t.colStart-n.colStart,a),p||d(l,t.colStart-n.colStart-s+1,a)),!(o>0)||m&&h||(d(u,t.rowStart-i.rowStart,o),m||d(u,t.rowStart-n.rowStart,o),h||d(u,t.rowStart-n.rowStart-c+1,o)),l.length===0&&u.length===0?null:tM(i,u,l)},rM=(e,t)=>{let{precedentEntry:n,precedentValue:r,formulaEntry:i,fw:a,fh:o,nh:s,nw:c}=e,l=n.rowStart,u=n.colStart,d=t.rowStart,f=t.rowEnd,p=t.colStart,m=t.colEnd,h=[];if(o>0&&(!r.$absRowStart||!r.$absRowEnd)){if(s>1){let e=Math.max(0,d-l-s+1),t=Math.min(o+1,Math.max(0,d-l)),n=Math.min(o+1,Math.max(0,f-l-s+2)),r=Math.min(o+1,Math.max(0,f-l+1));for(let n=e;n<=t;n++)n>0&&n<=o&&h.push(n);for(let e=n;e<=r;e++)e>0&&e<=o&&(h.length!==0&&h[h.length-1]===e||h.push(e))}else{let e=d-l;e>0&&e<=o&&h.push(e);let t=f-l+1;t>0&&t<=o&&t!==e&&h.push(t)}}let g=[];if(a>0&&(!r.$absColStart||!r.$absColEnd)){if(c>1){let e=Math.max(0,p-u-c+1),t=Math.min(a+1,Math.max(0,p-u)),n=Math.min(a+1,Math.max(0,m-u-c+2)),r=Math.min(a+1,Math.max(0,m-u+1));for(let n=e;n<=t;n++)n>0&&n<=a&&g.push(n);for(let e=n;e<=r;e++)e>0&&e<=a&&(g.length!==0&&g[g.length-1]===e||g.push(e))}else{let e=p-u;e>0&&e<=a&&g.push(e);let t=m-u+1;t>0&&t<=a&&t!==e&&g.push(t)}}if(h.length===0&&g.length===0)return null;let _=[i];if(h.length>0){_=[];let e=i;for(let t=0;t<h.length;t++){let n=i.rowStart+h[t];if(n<=e.rowStart||n>e.rowEnd)continue;let r=vc(e,{rowStart:n,colStart:e.colStart,rowEnd:e.rowEnd,colEnd:e.colEnd},Cc);r&&r.length===2&&(_.push(r[0]),e=r[r.length-1])}_.push(e)}if(g.length>0){let e=[];for(let t=0;t<_.length;t++){let n=_[t];for(let t=0;t<g.length;t++){let r=i.colStart+g[t];if(r<=n.colStart||r>n.colEnd)continue;let a=vc(n,{rowStart:n.rowStart,colStart:r,rowEnd:n.rowEnd,colEnd:n.colEnd},Cc);a&&a.length===2&&(e.push(a[0]),n=a[a.length-1])}e.push(n)}_=e}return _},iM=(e,t)=>{let{formulaEntry:n,fw:r,fh:i}=e;if(r===0&&i===0)return null;let a=aM(e,t);if(!a)return null;let[o,s,c,l]=a;if(o===0&&s===i&&c===0&&l===r)return null;let u=o>0?n.rowStart+o:-(2**53-1),d=s<i?n.rowStart+s:2**53-1,f=c>0?n.colStart+c:-(2**53-1),p=l<r?n.colStart+l:2**53-1;return bM.colStart=f,bM.rowStart=u,bM.colEnd=p,bM.rowEnd=d,vc(n,bM,Cc)},aM=(e,t)=>{let{precedentEntry:n,precedentValue:r,fw:i,fh:a,nw:o,nh:s}=e,c=n.colStart,l=n.rowStart,u=r.$absRowStart?l>=t.rowStart?0:a+1:Math.max(0,t.rowStart-l),d=r.$absRowEnd?n.rowEnd<=t.rowEnd?a:-1:Math.min(a,t.rowEnd-l-(s-1)),f=r.$absColStart?c>=t.colStart?0:i+1:Math.max(0,t.colStart-c),p=r.$absColEnd?n.colEnd<=t.colEnd?i:-1:Math.min(i,t.colEnd-c-(o-1));return u>d||f>p?null:[u,d,f,p]};function oM(e,t){return eM(e,t,nM)}function sM(e,t){return eM(e,t,rM)}function cM(e,t,n){let r=(n.scope??null)!==(t.scope??null),i=r||n.colStart===t.colStart&&n.rowStart!==t.rowStart,a=r||n.rowStart===t.rowStart&&n.colStart!==t.colStart;return eM(e,t,i||a?(e,t)=>{let{precedentEntry:n,precedentValue:r,formulaEntry:o,fw:s,fh:c,nw:l,nh:u}=e;if(s===0&&c===0)return null;let d=new Set,f=new Set,p={start:n.rowStart,end:n.rowEnd,absStart:!!r.$absRowStart,absEnd:!!r.$absRowEnd,natural:u,extent:c,cutStart:t.rowStart,cutEnd:t.rowEnd,offsets:d},m={start:n.colStart,end:n.colEnd,absStart:!!r.$absColStart,absEnd:!!r.$absColEnd,natural:l,extent:s,cutStart:t.colStart,cutEnd:t.colEnd,offsets:f};if(i&&dM(p,m),a&&dM(m,p),d.size===0&&f.size===0)return iM(e,t);let h=aM(e,t);return h&&(d.add(h[0]),d.add(h[1]+1),f.add(h[2]),f.add(h[3]+1)),tM(o,Array.from(d),Array.from(f))}:iM)}var lM=(e,t,n,r,i)=>{if(t===0)return n<=e&&e<=r?[0,i]:null;let a=Math.max(0,n-e),o=Math.min(i,r-e);return a<=o?[a,o]:null},uM=(e,t)=>{if(!e||!t)return null;let n=Math.max(e[0],t[0]),r=Math.min(e[1],t[1]);return n<=r?[n,r]:null},dM=(e,t)=>{let n=t.start,r=t.absEnd?t.end:t.start+t.natural-1,i=uM(lM(n,+!t.absStart,t.cutStart,2**53-1,t.extent),lM(r,+!t.absEnd,-(2**53-1),t.cutEnd,t.extent));if(!i)return;t.offsets.add(i[0]),t.offsets.add(i[1]+1);let a=e.start,o=e.absEnd?e.end:e.start+e.natural-1,s=+!e.absStart,c=+!e.absEnd,l=uM(lM(a,s,-(2**53-1),e.cutStart-1,e.extent),lM(o,c,e.cutStart,e.cutEnd,e.extent)),u=uM(lM(a,s,e.cutStart,e.cutEnd,e.extent),lM(o,c,e.cutEnd+1,2**53-1,e.extent));for(let t of[l,u])if(t)for(let n=t[0];n<=t[1]+1;n++)e.offsets.add(n)};function fM(e,t,n,r,i){let a=e(),o=a.search(n),s=o.length;if(s===0)return null;let c=n.colStart,l=n.rowStart,u=r.colIndex,d=r.rowIndex,f=r.scope,p=i?i.colEnd:n.colEnd,m=i?i.rowEnd:n.rowEnd,g=[],_=[],v=[],y=new Map,b=[];for(let e=0;e<s;e++){let t=o[e],r=t.value,i=r.formulaEntry,a=y.get(i)??i,s=a.value,x=s.ref,S=t.colStart,C=t.rowStart,w=t.colEnd,T=t.rowEnd,E=!1;if(r.index<0){b.push(t);continue}if((f===void 0||s.gridId===f)&&h.isRangeWithinRange(x,n))continue;let D=r.index,O=s.getReferences(x.rowStart,x.colStart),k=O.length>0?O[D]:null;if(!k||V.isError(k)||`nameId`in k)continue;let A=`tableId`in k,j=k,M=s.unanchored,N=M&&!j.$colStart,ee=M&&!j.$colEnd,te=M&&!j.$rowStart,P=M&&!j.$rowEnd,F=j;if(u!==0&&j.colStart!==-(2**53-1)){let e=j.$colStart?j.colStart:x.colStart+j.colStart,t=j.$colEnd?j.colEnd:x.colEnd+j.colEnd,n=xO(e,t,c,u,p,N,ee);n===null?F=null:(n[0]!==e&&(F=F===j?{...j}:F,F.colStart+=n[0]-e),n[1]!==t&&(F=F===j?{...j}:F,F.colEnd+=n[1]-t))}if(d!==0&&j.rowStart!==-(2**53-1)){let e=j.$rowStart?j.rowStart:x.rowStart+j.rowStart,t=j.$rowEnd?j.rowEnd:x.rowEnd+j.rowEnd,n=xO(e,t,l,d,m,te,P);n===null?F=null:(n[0]!==e&&(F=F===j?{...j}:F,F.rowStart+=n[0]-e),n[1]!==t&&(F=F===j?{...j}:F,F.rowEnd+=n[1]-t))}if(F!==j){if(F!==null&&(S=F.$colStart?F.colStart:x.colStart+F.colStart,C=F.$rowStart?F.rowStart:x.rowStart+F.rowStart,w=F.$colEnd?F.colEnd:x.colEnd+F.colEnd,T=F.$rowEnd?F.rowEnd:x.rowEnd+F.rowEnd,E=!0),s=A?s.remint():s.setReferenceAt(D,F),g.push(t),E){let e={...t};e.value={...r},e.value.formulaEntry=a,e.colStart=S,e.rowStart=C,e.colEnd=w,e.rowEnd=T,_.push(e),v.push(i)}a={...a},a.value=s,y.set(i,a)}}let x=b.length;if(x>0||y.size>0){let e=t();if(x>0){a.removeAll(b,TM);for(let t=0;t<x;t++){let n=b[t].value.formulaEntry.value,r=e.get(n);r&&(a.removeAll(r,TM),e.delete(n))}}for(let t of y.keys()){let n=t.value;if(!n)continue;let r=e.get(n);r&&(a.removeAll(r,TM),e.delete(n))}}for(let e=0;e<_.length;e++){let t=y.get(v[e]);t&&(_[e].value.formulaEntry=t)}let S=Array.from(y.keys()),C=Array.from(y.values()),w=[];for(let e=0;e<x;e++)w.push(b[e].value.formulaEntry);return{precedents:{inserts:_,removes:g},formulas:{inserts:C,removes:S},dynamicDependents:w}}function pM(e,t,n,r){let i=e,a=i.search(n),o=a.length;if(o===0)return null;let s=r.colStart-n.colStart,c=r.rowStart-n.rowStart,l=[],u=[],d=new Map,f=function(e,t,n,r){let i=[],a=(n.scope??null)!==(t.scope??null),o=n.rowStart-t.rowStart,s=n.colStart-t.colStart,c=a||s===0,l=a||o===0;if(!c&&!l)return i;for(let u=0;u<e.length;u++){let d=e[u].value;if(d.index<0)continue;let f=d.formulaEntry,p=r.get(f)??f,m=p.value,g=m.ref;if((g.scope??null)===(t.scope??null)&&h.isRangeWithinRange(g,t)||(g.scope??null)===(n.scope??null)&&h.isRangeWithinRange(g,n))continue;let _=m.getReferences(g.rowStart,g.colStart)?.[d.index];if(!_||V.isError(_)||`nameId`in _||`tableId`in _)continue;let v=_;if(v.rowStart===-(2**53-1)||v.colStart===-(2**53-1))continue;let y=v.$rowStart?v.rowStart:g.rowStart+v.rowStart,b=v.$rowEnd?v.rowEnd:g.rowStart+v.rowEnd,x=v.$colStart?v.colStart:g.colStart+v.colStart,S=v.$colEnd?v.colEnd:g.colStart+v.colEnd,C=c&&t.colStart<=x&&S<=t.colEnd?CO(y,b,t.rowStart,t.rowEnd,o,a):null,w=l&&t.rowStart<=y&&b<=t.rowEnd?CO(x,S,t.colStart,t.colEnd,s,a):null;if(!C&&!w)continue;let T={...v};C&&(T.rowStart=v.$rowStart?C[0]:C[0]-g.rowStart,T.rowEnd=v.$rowEnd?C[1]:C[1]-g.rowStart),w&&(T.colStart=v.$colStart?w[0]:w[0]-g.colStart,T.colEnd=v.$colEnd?w[1]:w[1]-g.colStart),m.unanchored&&(T.rowStart!==v.rowStart&&!v.$rowStart||T.rowEnd!==v.rowEnd&&!v.$rowEnd||T.colStart!==v.colStart&&!v.$colStart||T.colEnd!==v.colEnd&&!v.$colEnd)||(r.has(f)||i.push(f),r.set(f,{...p,value:m.setReferenceAt(d.index,T)}))}return i}(a,n,r,d),p=new Set,m=new Set;for(let e=0;e<o;e++){let t=a[e],i=t.value,o=i.formulaEntry,f=d.get(o),g=f??o,_=g.value,v=_.ref,y=(v.scope??null)===(n.scope??null)&&h.isRangeWithinRange(v,n),b=_.getReferences(v.rowStart,v.colStart),x=b?b.length:0;if(x===0)continue;let S=i.index,C=b?b[S]:null;if(!C||V.isError(C)||`nameId`in C)continue;let w=`tableId`in C,T=C;if(!f&&x>1)for(let e=0;e<x;e++){if(e===S)continue;let t=b[e];if(!t||V.isError(t)||`nameId`in t)continue;let r=t;if((r.scope??null)!==(n.scope??null)||!h.isRangeWithinRange(r,n)){m.add(o);break}}let E=g.colEnd-g.colStart,D=g.rowEnd-g.rowStart,O=t.colStart,k=t.rowStart,A=t.colEnd,j=t.rowEnd,M=i.$absColEnd?A-O+1:A-O-E+1,N=i.$absRowEnd?j-k+1:j-k-D+1,ee=i.$absRowStart?k>=n.rowStart?0:D+1:Math.max(0,n.rowStart-k),te=i.$absRowEnd?j<=n.rowEnd?D:-1:Math.min(D,n.rowEnd-k-(N-1)),P=i.$absColStart?O>=n.colStart?0:E+1:Math.max(0,n.colStart-O),F=i.$absColEnd?A<=n.colEnd?E:-1:Math.min(E,n.colEnd-O-(M-1));if(ee>te||P>F||ee!==0||te!==D||P!==0||F!==E)continue;let ne=y||_.unanchored,re=t.scope!==r.scope,ie;if(s!==0){let[e,t]=SO(T.colStart,T.colEnd,s,!T.$colStart&&ne,!T.$colEnd&&ne);e===T.colStart&&t===T.colEnd||(ie??={...T},ie.colStart=e,ie.colEnd=t)}if(c!==0){let[e,t]=SO(T.rowStart,T.rowEnd,c,!T.$rowStart&&ne,!T.$rowEnd&&ne);e===T.rowStart&&t===T.rowEnd||(ie??={...T},ie.rowStart=e,ie.rowEnd=t)}if(!ie&&!re)continue;ie||={...T},_=w?_.remint():_.setReferenceAt(S,ie),g={...g},g.value=_,d.set(o,g),p.add(o),l.push(t);let ae={...t};ae.colStart+=s,ae.rowStart+=c,ae.colEnd+=s,ae.rowEnd+=c,ae.scope=r.scope,ae.value={...i},ae.value.formulaEntry=g,u.push(ae)}if(d.size>0){let n=t();for(let t of d.keys()){let r=t.value;if(!r)continue;let i=n.get(r);i&&(e.removeAll(i,TM),n.delete(r))}}let g=Array.from(d.keys()),_=Array.from(d.values()),v=m.size;if(v>0){let e=Array.from(m);for(let t=0;t<v;t++){let r=e[t],a=r.value,o=a.ref,s=a.getReferences(o.rowStart,o.colStart),c=s?s.length:0;if(c>1){let e=a.ref,t=e.colStart,o=e.rowStart;for(let e=0;e<c;e++){let a=s[e];if(!a||V.isError(a)||`nameId`in a)continue;let c=a;if(xM.colStart=c.$colStart?c.colStart:t+c.colStart,xM.rowStart=c.$rowStart?c.rowStart:o+c.rowStart,xM.colEnd=c.$colEnd?c.colEnd:t+c.colEnd,xM.rowEnd=c.$rowEnd?c.rowEnd:o+c.rowEnd,xM.scope=c.scope??r.scope,(xM.scope??null)===(n.scope??null)&&h.isRangeWithinRange(xM,n))continue;xM.colEnd=xM.colStart,xM.rowEnd=xM.rowStart;let f=i.search(xM);for(let e=0;e<f.length;e++){let t=f[e];if(t.value.formulaEntry===r){let e=d.get(r);if(e){let n={...t};n.value={...t.value},n.value.formulaEntry=e,l.push(t),u.push(n)}break}}}}}}return{precedents:{inserts:u,removes:l},formulas:{inserts:_,removes:g},edged:f.filter(e=>!p.has(e)).map(e=>d.get(e))}}var mM=(e,t,n)=>{let r=e.colStart,i=e.rowStart,a=e.colEnd,o=e.rowEnd,s=t.colStart,c=t.rowStart,l=t.colEnd,u=t.rowEnd,d=Math.max(r,s),f=Math.max(i,c),p=Math.min(a,l),m=Math.min(o,u);e.value.mintNodesIn(f,m,d,p,e=>{n(e,e.rowIndex-i,e.colIndex-r)})};function hM(e,t,n,r){if(e.isEmpty())return;let i=e.search(t),a=i.length;for(let e=0;e<a;e++)i[e].value.checkShift(t,n,r)}function gM(e){let t=h.sanitizeRange(e);return Aj.cellsOf({...t,scope:e.scope},e.value.getGap())}function _M(e,t,n,r,i,a,o){for(let s of gM(e)){let e={colStart:s.colStart+n,rowStart:s.rowStart+t,colEnd:s.colEnd+n,rowEnd:s.rowEnd+t};r.copyTo(i,{colIndex:e.colStart,rowIndex:e.rowStart},s),a.insertNonOverlapping({...e,value:new Fj(e,o)})}}function vM(e,t,n,r,i,a=!1,o=!1,s,c){if(!e||t.isEmpty())return null;yM.colStart=e.colStart,yM.rowStart=e.rowStart,yM.colEnd=e.colEnd,yM.rowEnd=e.rowEnd,yM.scope=null;let l=t.search(yM),u=l.length;if(!u)return null;let d,f,p;for(let i=0;i<u;i++){let a=l[i];if(a.value.getError()||a.value.getKind()===`pivot`)continue;let s=a.value.getAnchor();SM.colIndex=s.column,SM.rowIndex=s.row,SM.scope=a.scope;let c=h.isCellWithinRange({colIndex:SM.colIndex,rowIndex:SM.rowIndex,scope:SM.scope},e);if(!c||!o){d||(f=[],d=[],p=n.clone()),c?d.push(a):f.push(a);for(let e of gM(a))n.delete(e),r.insertNonOverlapping({...e,value:null});t.remove(a,TM)}}return u?(o=!1,l,u)=>{let m=a?B.Axis.Row:B.Axis.Column,g;f&&(l||u)&&(f=f.filter(t=>{let n=t.value.getAnchor();return!(l?n.row>e.rowEnd&&n.column>=e.colStart&&n.column<=e.colEnd:n.column>e.colEnd&&n.row>=e.rowStart&&n.row<=e.rowEnd)||((g??=[]).push(t),!1)}));let _=f?f.length:0;if(_>0){t.load(f);for(let e=0;e<_;e++){let t=f[e],i=h.sanitizeRange(t);for(let e of gM(t))p.copyTo(n,{colIndex:e.colStart,rowIndex:e.rowStart},e),r.insertNonOverlapping({colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colEnd,rowEnd:e.rowEnd,value:new Fj(e,m)});s?.insertNonOverlapping({colStart:i.colStart,rowStart:i.rowStart,colEnd:i.colEnd,rowEnd:i.rowEnd,scope:t.scope,value:null});let a=t.value.getAnchor();c?.(a.column,a.row,a.column,a.row)}}if(g){let e=[];for(let t of g){let a=t.value.getTranslated(l??0,u??0);e.push(a),i?.(a,t),_M(t,l??0,u??0,p,n,r,m)}t.load(e)}let v=d?d.length:0;if(i)for(let e=0;e<v;e++)i(null,d[e]);if(!o||l===void 0&&u===void 0||v===0)return;l??=0,u??=0;let y=[];for(let e=0;e<v;e++){let t=d[e],a=t.value.getTranslated(l,u);y.push(t.value.getTranslated(l,u)),i?.(a,null),_M(t,l,u,p,n,r,m)}t.load(y)}:null}var yM={colStart:0,rowStart:0,colEnd:0,rowEnd:0,scope:null},bM={colStart:0,rowStart:0,colEnd:0,rowEnd:0,scope:null},xM={colStart:0,rowStart:0,colEnd:0,rowEnd:0,scope:null},SM={colIndex:0,rowIndex:0,scope:null},CM=[],wM=[];function TM(e,t){return e.value===t.value}var EM=class e{constructor(e,t,n,r,i,a,o=eV,s){this._runtime=e,this._skipOrigin=s,this._grid=t,this._range=n,this._localCoords=r??[t.getCoords()],this._iteratorOptions=i,this._segmentCache=a??$B(t),this._ZoneSizeMinor=o}getGrid(){return this._grid}clone(t,n){return new e(this._runtime,t??this._grid,this._range?.clone()??null,n,this._iteratorOptions,$B(t??this._grid,this._segmentCache),this._ZoneSizeMinor,this._skipOrigin)}clear(){this._sortedNumbers=void 0,this._aggregates=void 0,this._typedCounts=void 0,this._raw=void 0,this._lastNumber=void 0,this._frequencies=void 0,this._ranked=void 0}_getLastNumber(){let e=this._lastNumber;return e===void 0&&(e=function(e,t,n,r,i,a){if(t.getCount()===0)return;let o=t.getAxis()===B.Axis.Column,s=r.length,c=KB(i,o,a),l=c?.major??null,u=c?.minor??null,d=rV(e,i),f=d.coerce,p=d.defaultCoerce,m=i?{...oV,...i,overflowRun:!0}:oV,h=m.bounds,g,_=-1,v=-1;for(let e=0;e<s;e++){let i=r[e];if(!i)continue;let a=o?i.colStart:i.rowStart,s=o?i.rowStart:i.colStart,c=o?i.colEnd:i.rowEnd,d=o?i.rowEnd:i.colEnd;h.colStart=o?a:s,h.rowStart=o?s:a,h.colEnd=o?c:d,h.rowEnd=o?d:c;let y=t.getRuns(m),b=y.next();for(;!b.done;){let[e,t,r]=b.value;if(b=y.next(),l&&qB(l,e))continue;let i=Math.max(0,s-t),a=Math.min(r.length-1,d-t);if(!(i>a))for(let s=a;s>=i;s--){let i=t+s;if(u){let e=JB(u,i,!0)-t;if(e!==s){e<s&&(s=e+1);continue}}let a=o?i:e,c=o?e:i;if(a<_||a===_&&c<=v){if(o)break;continue}let l=r.at(s),d=pB(l,!0);if(d===null&&(l=pg(l),d=pB(l,!0)),!(d!==U.Number&&(!f||(l=f(l,d,p,n),pB(l,!0)!==U.Number)))&&(_=a,v=c,g=l,o))break}}}return g}(this._runtime,this._grid,this._range,this._localCoords,this._iteratorOptions,this._skipOrigin)??null,this._lastNumber=e),e??void 0}toLocalCoords(t,n){return new e(this._runtime,this._grid,this._range,Array.isArray(t)?t:[t],n??this._iteratorOptions,this._segmentCache,this._ZoneSizeMinor,this._skipOrigin)}getCoords(){let e=this._localCoords,t=null;for(let n=0;n<e.length;n++){let r=e[n];r&&(t=t?{rowStart:Math.min(t.rowStart,r.rowStart),colStart:Math.min(t.colStart,r.colStart),rowEnd:Math.max(t.rowEnd,r.rowEnd),colEnd:Math.max(t.colEnd,r.colEnd)}:{rowStart:r.rowStart,colStart:r.colStart,rowEnd:r.rowEnd,colEnd:r.colEnd})}return t}getSize(){let e=this._localCoords,t=e.length,n=0;for(let r=0;r<t;r++){let t=e[r];n+=XB(this._iteratorOptions,t,this._skipOrigin)}return n}_walk(){let e=this._raw;return e===void 0&&(e=nV(this._runtime,this._grid,this._range,this._localCoords,this._iteratorOptions?{...this._iteratorOptions,onError:`ignore`}:DM,this._segmentCache,this._ZoneSizeMinor,this._skipOrigin),this._raw=e),e}getCount(){return this._walk()?.count??0}getAggregates(e){if(e)return iV(nV(this._runtime,this._grid,this._range,this._localCoords,this._iteratorOptions?{...this._iteratorOptions,...e}:e,this._segmentCache,this._ZoneSizeMinor,this._skipOrigin));let t=this._aggregates;if(!t){let e=this._iteratorOptions?.onError??`ignore`,n=this._raw,r;n!==void 0&&(e===`ignore`||n===null||n.typed[U.Error]===0&&(this._iteratorOptions?.coerce==null||n.count===n.typed[U.Number]))?r=n:(r=nV(this._runtime,this._grid,this._range,this._localCoords,this._iteratorOptions,this._segmentCache,this._ZoneSizeMinor,this._skipOrigin),this._raw=r),t=iV(r),this._aggregates=t}return t}getSnappedSum(e){let t=this.getAggregates(),n=e??t.sum??0;return((e,t)=>e!==0&&e!==1/0&&e!==-1/0&&Math.abs(e)*Cj<=t+Math.abs(e))(n,(e=>{let t=e.min;return t==null?0:Math.max(Math.abs(t),Math.abs(e.max))})(t))?((e,t)=>t===void 0?e:wj(e,e-t))(n,this._getLastNumber()):n}getSortedNumbers(){let e=this._sortedNumbers;return e||(e=DV.fromGrid(this._grid,this._localCoords,this._iteratorOptions,this._skipOrigin),this._sortedNumbers=e),e}getRanked(e){if(e)return CV(this._grid,this._localCoords,this._iteratorOptions,e,this._defaultCompare(),this._skipOrigin)[Symbol.iterator]();let t=this._ranked;return t||(t=CV(this._grid,this._localCoords,this._iteratorOptions,e,this._defaultCompare(),this._skipOrigin),this._ranked=t),t[Symbol.iterator]()}getFrequencies(e){if(e)return this._buildFrequencies(e);let t=this._frequencies;return t||(t=this._buildFrequencies(),this._frequencies=t),t}_buildFrequencies(e){let t=e?.includeBlanks?this.getTypedCounts([U.Null])[U.Null]:0,n=e?.filterFn?void 0:this.getCount()+t;return mg.fromGrid(this._grid,this._localCoords,this._iteratorOptions,e,this._defaultCompare(),t,n,this._skipOrigin)}_defaultCompare(){let e=this._runtime.getLocaleProfile();return(t,n)=>$l.compare(t,n,e)}getTypedCounts(e){let t=this._typedCounts;if(!t){let e=this._walk()?.typed,n={[U.Number]:e?.[U.Number]??0,[U.String]:e?.[U.String]??0,[U.Boolean]:e?.[U.Boolean]??0,[U.Error]:e?.[U.Error]??0,[U.RichData]:e?.[U.RichData]??0,[U.Null]:0},r=this._localCoords,i=r.length,a=0;for(let e=0;e<i;e++){let t=r[e];t&&(a+=XB(this._iteratorOptions,t,this._skipOrigin))}n[U.Null]=Math.max(0,a-n[U.Number]-n[U.String]-n[U.Boolean]-n[U.Error]-n[U.RichData]),t=Object.freeze(n),this._typedCounts=t}if(e===void 0)return t;let n={},r=e.length;for(let i=0;i<r;i++)n[e[i]]=t[e[i]]??0;return n}get isIRangeStats(){return!0}},DM={onError:`ignore`},OM=class{constructor(e){this._valuesEpoch=0,this._errorReconciled=null,this._deadSavepoints=null,this._emitter=null,this._closed=!1,this._backend=e.backend,this._calculation=e.calculation??null,this._host=e,this._valuesAxis=e.valuesAxis??B.Axis.Column,this._runtime=e.runtime,this._sizeOf=e.sizeOf,this._transactions=e.transactions??new se({transient:!0}),this._fixedCoords=e.entireCoords?kM(e.entireCoords):null,this._stateId=this._transactions.create(this._freshState())}_freshState(){let e=new fc({updateEntryOptions:{isMergeOnShift:!0,isSplitOnExpand:!0}}),t=new Xc({axis:this._valuesAxis}),n=new fc({updateEntryOptions:{isSplitOnExpand:!0,isMergeOnShift:!0}}),r=new fc({updateEntryOptions:{isMergeOnShift:!0,isTrailingEdge:!0}});return this._rangeStats=new EM(this._runtime,t,null),{formulaSpatial:e,cellValuesGrid:t,contentfulSpatial:n,spillSpatial:new fc,blockedSpillSpatial:new fc,volatile:null,calcStatusSpatial:new fc,calcErrorsSpatial:new fc,circularSpatial:new fc,errorSpatial:r,deleted:!1,hiddenRows:null,hiddenColumns:null,filtered:!1,pivots:null,entireCoords:this._fixedCoords}}_revive(){return!this._closed&&!this._hasState()&&(this._valuesEpoch++,this._errorReconciled=null,this._amend(this._freshState()),!0)}_loadContent(e,t){let n=this._valuesAxis===B.Axis.Column,r=t.formulas;r.clear(),e.formulas&&r.load(this._entriesFromJSON(e.formulas));let i=t.values;i.clear();let a=t.contentful;a.clear();let o=t.errorValues;o.clear();let s=e.data;if(s&&s.length>0){i.setValues(s),a.load(Ij(s,n));let e=Vj(s,n);e.length>0&&o.load(xc(e,B.Axis.Column,2**53-1))}let c=t.spills;c.clear();let l=t.blockedSpills;if(l.clear(),e.formulaArray){let t=this._spillsFromJSON(e.formulaArray),n=t.filter(e=>e.value.getError());n.length>0&&l.load(n),t.length>n.length&&c.load(n.length>0?t.filter(e=>!e.value.getError()):t)}t.volatile=e.volatile&&e.volatile.length>0?e.volatile:null,t.calcStatus.clear(),t.calcErrors.clear(),t.circulars.clear()}_getBackend(){return this._backend}getStateId(){return this._stateId}_getState(e){return e?e.getState(this._stateId):this._transactions.getState(this._stateId)}_pinned(){return this._pinTo(this._getState())}_pinnedAt(e){let t=this._getStateAt(e);return t?this._pinTo(t):null}_pinTo(e){let t=Object.create(this);return t._getState=t=>t?this._getState(t):e,t}_getStateAt(e){let t=this._transactions;return e===t.getPendingTransaction()?.getId()?this._getState():t.getStateAt(e,this._stateId)}getFormulaAt(e,t){let n=this._getState().formulaSpatial.search({colStart:t,rowStart:e,colEnd:t,rowEnd:e});return n.length>0?n[0].value??null:null}getFormulas(e){return this._getState(e).formulaSpatial}getValues(e){return this._getState(e).cellValuesGrid}getContentful(e){return this._getState(e).contentfulSpatial}getSpills(e){return this._getState(e).spillSpatial}getBlockedSpills(){return this._getState().blockedSpillSpatial}getCalcStatus(e){return this._getState(e).calcStatusSpatial}getCalcErrors(e){return this._getState(e).calcErrorsSpatial}getCirculars(e){return this._getState(e).circularSpatial}getVolatileRegions(){return this._getState().volatile}getRangeStats(){let e=this._getState().cellValuesGrid;return this._rangeStats.getGrid()!==e&&(this._rangeStats=this._rangeStats.clone(e)),this._rangeStats}getValuesEpoch(){return this._valuesEpoch}getErrorValues(){let e=this._getState().cellValuesGrid,t=this._errorReconciled;if(t&&t.values===e&&t.epoch===this._valuesEpoch)return t.spatial;let n=new fc,r=function(e){let t=[],n=e.getAxis()===B.Axis.Column,r=e.getRuns(),i=r.next();for(;!i.done;){let[e,a,o]=i.value;i=r.next(),Bj(t,e,a,o,n)}return t}(e);return r.length>0&&n.load(xc(r,B.Axis.Column,2**53-1)),this._errorReconciled={values:e,epoch:this._valuesEpoch,spatial:n},n}_beginWrite(e,t=!0){let n=this,r=this._transactions,i=this._getState(),a=e?.cloneKey??r.getCurrentTransaction()?.getSavepointId(),o={},s=null;return{current:i,noteArray(e){(s??=[]).push(e)},get formulas(){return o.formulaSpatial??=i.formulaSpatial.clone(a)},set formulas(e){o.formulaSpatial=e},get values(){return o.cellValuesGrid??=i.cellValuesGrid.clone(a)},set values(e){o.cellValuesGrid=e},get contentful(){return o.contentfulSpatial??=i.contentfulSpatial.clone(a)},set contentful(e){o.contentfulSpatial=e},get spills(){return o.spillSpatial??=i.spillSpatial.clone(a)},set spills(e){o.spillSpatial=e},get blockedSpills(){return o.blockedSpillSpatial??=i.blockedSpillSpatial.clone(a)},set blockedSpills(e){o.blockedSpillSpatial=e},get calcStatus(){return o.calcStatusSpatial??=i.calcStatusSpatial.clone(a)},set calcStatus(e){o.calcStatusSpatial=e},get calcErrors(){return o.calcErrorsSpatial??=i.calcErrorsSpatial.clone(a)},set calcErrors(e){o.calcErrorsSpatial=e},get circulars(){return o.circularSpatial??=i.circularSpatial.clone(a)},set circulars(e){o.circularSpatial=e},get errorValues(){return o.errorSpatial??=i.errorSpatial.clone(a)},set errorValues(e){o.errorSpatial=e},get volatile(){return o.volatile===void 0?i.volatile:o.volatile},set volatile(e){o.volatile=e},commit(){if(Object.keys(o).length===0)return;let e=r.getCurrentTransaction()?.getSavepointId(),i=r.beginCommit(e===void 0?void 0:{onRollback:()=>{(n._deadSavepoints??=new Set).add(e)}});try{let e=o.cellValuesGrid;if(e&&(n._rangeStats=n._rangeStats.clone(e)),i.updateState(n._stateId,o),t){let e={inputsId:String(++jM),arrays:s};s=null,n._notify(`onInputsWritten`,e)}i.commit()}catch(e){throw i.rollback(),e}}}}_write(e,t,n=!0){let r=this._beginWrite(t,n);e(r),r.commit()}_amend(e){let t=this._transactions.beginCommit();try{t.updateState(this._stateId,e),t.amend()}catch(e){throw t.rollback(),e}}setInputs(e,t,n){let r=t?t.length:0,i=e?.tuples;return(r>0||i&&i.length>0)&&this._write(e=>{let a=e.formulas;if(i){let e=this._valuesAxis===B.Axis.Column,t={majorStart:0,minorStart:0,majorEnd:0,minorEnd:0};for(let n=0;n<i.length;n++){let r=i[n];t.majorStart=t.majorEnd=r[0];let o=r[1];for(let n=0;n<o.length;n++){let r=o[n];t.minorStart=r[0],t.minorEnd=r[0]+r[1].length-1;let i=Mc(t,e);a.has(i)&&MM(a,i)}}}for(let e=0;e<r;e++){let n=t[e],r={colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colEnd,rowEnd:n.rowEnd},i=n.value;i==null?a.has(r)&&MM(a,r):a.insertNonOverlapping({...r,value:new wA(i,r,null)},{noMerge:!0})}let o=n?.arrayFixed,s=o?o.rowStart:-1,c=o?o.colStart:-1;for(let n=0;n<r;n++){let r=t[n];r.value!==null&&r.value!==void 0&&(s===r.rowStart&&c===r.colStart||FM(a,e.spills,r))}this._writeInputValues(e,i,t,o)},n),this._backend.setInputs(e,t,n).then(this._adopter())}_writeInputValues(e,t,n,r){let i=this._valuesAxis===B.Axis.Column,a=e.current,o=t&&t.length>0?Ij(t,i):null,s=o?o.length:0;if(!a.spillSpatial.isEmpty()){let t=a.spillSpatial;for(let n=0;n<s;n++){let r=o[n],i=t.search(r);for(let t=0;t<i.length;t++){let n=i[t];n.value.getKind()!==`pivot`&&Rj(n.rowStart,n.colStart,r)&&e.values.delete(n)}}}let c=e=>{for(let t=0;t<s;t++)e(o[t]);if(n)for(let t=0;t<n.length;t++)e(n[t])};if(!a.spillSpatial.isEmpty()){let t=e.spills;c(e=>NM(t,e))}if(!a.blockedSpillSpatial.isEmpty()){let t=e.blockedSpills;c(e=>PM(t,e))}if(r){let t={colStart:r.colStart,rowStart:r.rowStart,colEnd:r.colEnd,rowEnd:r.rowEnd};e.spills.insertNonOverlapping({...t,value:new Aj(t,0,`fixed`)})}if(!o)return;e.values.setValues(t);let l=e.contentful;for(let e=0;e<s;e++)l.insertNonOverlapping(o[e]);if(!a.circularSpatial.isEmpty()){let t=e.circulars;for(let e=0;e<s;e++){let n=o[e];t.insertNonOverlapping({colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colEnd,rowEnd:n.rowEnd,value:null})}}let u=Vj(t,i);if(!a.errorSpatial.isEmpty()||u.length>0){let t=e.errorValues;for(let e=0;e<s;e++){let n=o[e];t.insertNonOverlapping({colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colEnd,rowEnd:n.rowEnd,value:null})}for(let e=0;e<u.length;e++)t.insertNonOverlapping(u[e])}}_removeInputValues(e,t){let n=e.current,r={colStart:t.colStart,rowStart:t.rowStart,colEnd:t.colEnd,rowEnd:t.rowEnd};e.values.delete(r),e.contentful.insertNonOverlapping({...r,value:null}),n.spillSpatial.isEmpty()||NM(e.spills,r),n.blockedSpillSpatial.isEmpty()||PM(e.blockedSpills,r),n.circularSpatial.isEmpty()||e.circulars.insertNonOverlapping({...r,value:null}),n.errorSpatial.isEmpty()||e.errorValues.insertNonOverlapping({...r,value:null})}remove(e,t){let n=t?.clearArrays??!1;this._write(t=>{let r=null;if(n&&!t.current.spillSpatial.isEmpty()){let n=(e,n)=>{e&&t.noteArray(e),n&&t.noteArray(n)};r=vM(e,t.spills,t.values,t.contentful,n),Yj(-1,[e],[],t.contentful,t.spills,t.values,void 0,void 0,n,void 0,void 0,void 0,!1,void 0,void 0,t.blockedSpills)}t.current.formulaSpatial.has(e)&&MM(t.formulas,e),this._removeInputValues(t,e),r?.()},t);let r=t;if(t?.clearArrays!==void 0){let{clearArrays:e,...n}=t;r=n}return this._backend.remove(e,r).then(this._adopter())}_shiftInputValues(e,t,n){let r=n===B.Direction.Left||n===B.Direction.Right,i=n===B.Direction.Right||n===B.Direction.Down,a=e.current,o=i?this._insertValidator():void 0,s=a.cellValuesGrid.getCoords();if(s){let c=(i?1:-1)*(r?t.colEnd-t.colStart+1:t.rowEnd-t.rowStart+1),l=e.values,u=e.spills,d=e.contentful,f=vM(t,u,l,d,(t,n)=>{t&&e.noteArray(t),n&&e.noteArray(n)},!r);if(i){let e={...t,colEnd:r?Math.max(t.colEnd,s.colEnd)+(t.colEnd-t.colStart+1):t.colStart,rowEnd:r?t.rowStart:Math.max(t.rowEnd,s.rowEnd)+(t.rowEnd-t.rowStart+1)},n=d.search(e);for(let e=0;e<n.length;e++){let i=n[e],a={...t};r?a.colEnd=Math.max(a.colEnd,i.colEnd)+c:a.rowEnd=Math.max(a.rowEnd,i.rowEnd)+c,o(a)}}if(l.shift(t,n),e.spills=u.shift({range:t,direction:n,cloneIfUpdate:!1,coordValidator:o}),!a.blockedSpillSpatial.isEmpty()){let r=e.blockedSpills;i||PM(r,t),e.blockedSpills=r.shift({range:t,direction:n,cloneIfUpdate:!1})}e.contentful=d.shift({range:t,direction:n,cloneIfUpdate:!1,coordValidator:o}),f?.(i,r?0:c,r?c:0)}a.errorSpatial.isEmpty()||(e.errorValues=e.errorValues.shift({range:t,direction:n,cloneIfUpdate:!1,coordValidator:o})),a.calcStatusSpatial.isEmpty()||(e.calcStatus=e.calcStatus.shift({range:t,direction:n,cloneIfUpdate:!1,coordValidator:o}))}_insertValidator(){let e=this.getEntireCoords();return(t,n)=>{if(!h.isRangeWithinRange(t,e))throw new w(n??N(`error.sheet.insertOob`))}}shift(e){return this._write(t=>{this._shiftInputValues(t,e.range,e.direction),t.formulas.shift({range:e.range,direction:e.direction})},e),this._backend.shift(e).then(this._adopter())}autoFill(e,t,n){let r=typeof e==`string`?uf(e):e,i=typeof t==`string`?uf(t):t;return this._write(e=>{let t=e.formulas,n=t.createCopiedEntries(r,i);LM(t,i,n.inserts)},n),this._backend.autoFill(e,t,n).then(this._adopter())}getSnapshot(e){let t=this,n=this._backend.getSnapshot(e),r=this._getState().formulaSpatial.clone(),i=e?.range,a={...typeof i==`string`?uf(i):i};a.scope=this.getId();let o=e?.isCut??!1;return{...n,copyTo(e,i){let s=e.grid??t._host.getGrid?.(e.gridId)??null;if(!s)return n.copyTo(e,i);let c=typeof e.range==`string`?uf(e.range):e.range,l=i?.isCut??o,u=s._copyFormulaEntries(r,a,c,{transpose:i?.transpose??!1,cutFrom:l?a:void 0},i),d=e=>{let t=e._calculation?.getStatus();return t===Q.Status.Running||t===Q.Status.Starting};return s._calculation===t._calculation&&d(t)&&d(s)?n.copyTo(e,i).then(s._adopter()):u.length===0?Promise.resolve({cycleId:0}):s._backend.setInputs(null,u,{commitId:i?.commitId}).then(s._adopter())},getCoords:()=>a}}_copyFormulaEntries(e,t,n,r,i){let a=e.createCopiedEntries(t,n,r),o=[];return this._write(e=>{let t=LM(e.formulas,n,a.inserts);o=Array(t.length);for(let e=0;e<t.length;e++){let n=t[e];o[e]={colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colEnd,rowEnd:n.rowEnd,value:n.value.a1}}},i),o}seed(e,t){if(e.entireCoords){let t=kM(e.entireCoords);this._holdOwnerState({entireCoords:t}),e={...e,entireCoords:t}}this._write(t=>this._loadContent(e,t),void 0,!1);let n=IM(e.hiddenRows),r=IM(e.hiddenColumns);return this._holdOwnerState({hiddenRows:n,hiddenColumns:r,filtered:e.filtered??!1,pivots:e.pivots?.length?e.pivots:null}),(n||r)&&(e={...e,hiddenRows:n??void 0,hiddenColumns:r??void 0}),this._backend.seed(e,t)}revert(e){return this._backend.revert(e).then(this._adopter())}delete(e){if(this._hasState()){let e=this._transactions.beginCommit();try{e.updateState(this._stateId,{deleted:!0}),e.commit()}catch(t){throw e.rollback(),t}}this._backend.delete(e)}_isLive(){if(this._closed)return!1;let e=this._transactions.getState(this._stateId);return e!==void 0&&!e.deleted}setReferenceAt(e,t,n,r){return this._backend.setReferenceAt(e,t,n,r).then(n=>this._adoptAt(e,t,n))}setReferenceModeAt(e,t,n,r,i){return this._backend.setReferenceModeAt(e,t,n,r,i).then(n=>this._adoptAt(e,t,n))}calculate(e){return this._backend.calculate(e)}markDirtyRegions(e){this._backend.markDirtyRegions(e)}_resendFormula(e,t){return this._backend.setInputs(null,[{colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colEnd,rowEnd:e.rowEnd,value:t}]).then(this._adopter())}_isOwned(){return!0===this._host.isOwned}_requestPass(){this._backend.requestPass()}_demand(e){this._backend.demand(e)}getGraphNeighborsAt(e,t,n){return this._backend.getGraphNeighborsAt(e,t,n)}evaluateAt(e,t,n){return this._backend.evaluateAt(e,t,n)}_isClosed(){return this._closed}_hasState(){return this._transactions.getState(this._stateId)!==void 0}_evaluateScalarAt(e,t,n){return this._backend.evaluateScalarAt(e,t,n)}_setBody(e,t){let n=this._adopter();return this._backend.setBody(e).then(e=>t&&!t()?e:n(e))}isVolatileAt(e,t){return this._backend.isVolatileAt(e,t)}addListeners(e,t){return this._emitter??=new ne(this),this._emitter.addListeners(e,t)}_notify(e,t){this._emitter?.notify(e,{params:t})}getEntireCoords(){let e=this._transactions.getState(this._stateId)?.entireCoords;if(e)return e;let t=this._sizeOf;return(t===void 0?null:this._host.getGrid?.(t)?.getEntireCoords())??lB}resize(e,t){let n=kM(e);this._holdOwnerState({entireCoords:n}),this._backend.resize(n,t)}setHidden(e,t,n){let r=IM(t);this._holdOwnerState(e===B.Axis.Column?{hiddenColumns:r}:{hiddenRows:r}),this._backend.setHidden(e,r??i.EmptyArray,n)}setFiltered(e,t){this._holdOwnerState({filtered:e}),this._backend.setFiltered(e,t)}setPivots(e,t){return this._holdOwnerState({pivots:e.length>0?e:null}),this._backend.setPivots(e,t).then(this._adopter())}_holdOwnerState(e){let t=this._transactions.getState(this._stateId);if(!t||(e.hiddenRows===void 0||e.hiddenRows===t.hiddenRows)&&(e.hiddenColumns===void 0||e.hiddenColumns===t.hiddenColumns)&&(e.filtered===void 0||e.filtered===t.filtered)&&(e.pivots===void 0||e.pivots===t.pivots)&&(e.entireCoords===void 0||AM(e.entireCoords,t.entireCoords)))return;let n=this._transactions.beginCommit();try{n.updateState(this._stateId,e),n.commit()}catch(e){throw n.rollback(),e}}getId(){return this._backend.getId()}async toJSON(e){let t=this._calculation?.getStatus();return t!==Q.Status.Off&&t!==Q.Status.Error&&t!==Q.Status.Stopping&&this._calculation?this._backend.toJSON(e):this._content(e)}_seedContent(){if(!this._host.isOwned)return null;let e=this._content({includeData:!0})??{},t=this._getState(),n=t.entireCoords;return n&&(e.entireCoords=n),t.pivots&&(e.pivots=t.pivots),e}_content(e){let t=this._getState(),n={};if(e?.includeData){let e=Yc(t.cellValuesGrid);e.length>0&&(n.data=e)}t.hiddenRows&&(n.hiddenRows=t.hiddenRows),t.hiddenColumns&&(n.hiddenColumns=t.hiddenColumns),t.filtered&&(n.filtered=!0);let r=t.formulaSpatial,i=r.all(),a=i.length;if(a>0){i.sort(h.rowFirstRangeComparator);let e=this.getEntireCoords(),o=t.spillSpatial.all().concat(t.blockedSpillSpatial.all()),s=null;if(o.length>0){o.sort(h.rowFirstRangeComparator);for(let t=0;t<o.length;t++){let n=o[t],i={rowStart:n.rowStart,colStart:n.colStart,rowEnd:n.rowStart,colEnd:n.colStart};r.search(i).length!==0&&(s??=[]).push([zd(n.value.getError()?i:n,e),n.value.getKind()])}}let c=Array(a);for(let e=0;e<a;e++){let t=i[e],n=t.value,r=n.isCompiled()?n.getTextAt(t.rowStart,t.colStart,!1):n.a1;c[e]=[zd(t),r]}n.formulas=c,s&&(n.formulaArray=s);let l=t.volatile;if(l){let t=[];for(let n=0;n<l.length;n++){let i=Ff(l[n],e);i&&r.search(i).length>0&&t.push(l[n])}t.length>0&&(n.volatile=t)}}return a!==0||n.data||n.hiddenRows||n.hiddenColumns||n.filtered?n:null}_spillsFromJSON(e){let t=this.getEntireCoords(),n=[];for(let r=0;r<e.length;r++){let i=wf(e[r],t);if(!i)continue;let a={colStart:i.colStart,rowStart:i.rowStart,colEnd:i.colEnd,rowEnd:i.rowEnd};n.push({...a,value:new Aj(a,0,i.value??`dynamic`)})}return n}_entriesFromJSON(e){let t=this.getEntireCoords(),n=[];for(let r=0;r<e.length;r++){let i=wf(e[r],t);if(!i||typeof i.value!=`string`)continue;let a={colStart:i.colStart,rowStart:i.rowStart,colEnd:i.colEnd,rowEnd:i.rowEnd};n.push({...a,value:new wA(i.value,a,null)})}return n}_onCalculated(e){if(this._closed)return;let t=this._vendSnapshots(e.commitId);t&&(this._valuesEpoch++,this._adopt(e,t),this._applyValueVend(e,t),this._notify(`onComplete`,e))}_adopter(){let e=this._transactions.getCurrentTransaction()?.getSavepointId();return t=>(this._closed||!this._hasState()||e!==void 0&&this._deadSavepoints?.has(e)||this._adopt(t),t)}_adoptAt(e,t,n){if(!n||this._closed)return n;let r={colStart:t,rowStart:e,colEnd:t,rowEnd:e},i=this._getState().formulaSpatial,a=i.search(r),o=null,s=!1;for(let e=0;e<a.length;e++){let t=a[e];if(!h.isEqualRanges(t,r))continue;let c=t.value,l=RM(c,n);l!==c&&(s=!0,o??=i.clone(this._transactions.getCurrentTransaction()?.getSavepointId()),o.insertNonOverlapping({...t,value:l},{noMerge:!0}))}return o&&this._amend({formulaSpatial:o}),this._notify(`onFormulasChanged`,s),n}_vendSnapshots(e){let t=this._transactions,n=this._getState(),r=t.getPendingTransaction(),i=r?{id:r.getId(),state:n,open:!0}:null;if(e===void 0||i&&e===i.id)return[i??{id:t.getCurrentCommit(!1).getId(),state:n,open:!1}];let a=t.getCurrentCommit(!1).getId();if(t.getStateAt(e,this._stateId)===void 0||t.getStateAt(a,this._stateId)===void 0)return null;let o=[],s=!1;for(let n=4,r=0;!s;n*=8){let i=t.getLog(a,n);for(let n=r;n<i.length;n++){let r=i[n].getId(),a=t.getStateAt(r,this._stateId);if(a&&o.push({id:r,state:a,open:!1}),r===e){s=!0;break}}if(i.length<n)break;r=i.length}return s&&o.length!==0?(o.reverse(),i&&o.push(i),o):null}_vendParentState(e){let t=this._transactions;if(e.open)return t.getStateAt(t.getCurrentCommit(!1).getId(),this._stateId)??null;let n=t.getLog(e.id,2);return n.length<2?null:t.getStateAt(n[1].getId(),this._stateId)??null}_writeVend(e,t){let n=this._transactions;n.amend(e.id,()=>{let e=n.beginCommit();try{e.updateState(this._stateId,t),e.commit()}catch(t){throw e.rollback(),t}})}_adopt(e,t){let n=e.formulaInserts,r=e.formulaRemoves;if(!e.isFull&&!n&&!r)return;let i=t??this._vendSnapshots(e.commitId);if(!i)return;let a=i[0].state.formulaSpatial;if(e.isFull){let e=a.all();for(let t=0;t<e.length;t++)e[t].value.setBlock(null)}let o=e=>`${e.rowStart},${e.colStart},${e.rowEnd},${e.colEnd}`,s=n?n.length:0,c=null;if(s>0&&r){c=new Map;for(let e=0;e<s;e++)c.set(o(n[e]),n[e])}let l=!1,u=new Map,d=(e,t)=>{let n=u.get(e);return n||(n=RM(e,t),n!==e&&(l=!0,u.set(e,n)),n)},f=this._transactions.getPendingTransaction(),p=null,m=null,g=!1;for(let e=0;e<i.length;e++){let t=i[e],l=t.state.formulaSpatial,u=e===i.length-1;if(e>0&&l===p){m&&(this._writeVend(t,{formulaSpatial:m}),u&&(g=!0));continue}let _=e===0,v=e=>_||BM(a,l,e),y=e=>_||zM(a,e),b=[],x=!1,S=new Set;if(r)for(let e=0;e<r.length;e++){let t=r[e];if(!v(t))continue;let n=l.search(t),i=[],a=!1;for(let e=0;e<n.length;e++){let r=n[e],s=r.value,l=c?.get(o(r));if(!l||!h.isRangeWithinRange(r,t)){a=!0;continue}let u=s;S.has(l)||(u=d(s,l.value),S.add(l)),u!==s&&(a=!0),i.push({coords:{colStart:r.colStart,rowStart:r.rowStart,colEnd:r.colEnd,rowEnd:r.rowEnd},entry:u})}a&&(x=!0,b.push({region:t,kept:i}))}let C=[],w=[];for(let e=0;e<s;e++){let t=n[e];if(S.has(t))continue;let r=t.value,i=l.search(t),a=null;for(let e=0;e<i.length;e++)if(h.isEqualRanges(i[e],t)){a=i[e];break}if(a){if(y(a)){let e=a.value,n=d(e,r);n!==e&&(x=!0,w.push({...t,value:n}))}continue}if(!v(t))continue;let o={colStart:t.colStart,rowStart:t.rowStart,colEnd:t.colEnd,rowEnd:t.rowEnd},s=new wA(``,o,null);s.setBlock(r),C.push({...o,value:s}),x=!0}let T=null;if(x){let e=t.open?f?.getSavepointId():void 0;T=l.clone(e);for(let e=0;e<b.length;e++){let t=b[e];T.insertNonOverlapping({...t.region,value:null},{noMerge:!0});for(let e=0;e<t.kept.length;e++)T.insert({...t.kept[e].coords,value:t.kept[e].entry})}for(let e=0;e<w.length;e++)T.insertNonOverlapping(w[e],{noMerge:!0});for(let e=0;e<C.length;e++)T.insertNonOverlapping(C[e],{noMerge:!0});this._writeVend(t,{formulaSpatial:T}),u&&(g=!0)}p=l,m=T}(g||l)&&this._notify(`onFormulasChanged`,l)}_applyValueVend(e,t){let n=e=>(e.open?this._getState():this._getStateAt(e.id))?.formulaSpatial,r=n(t[0]);if(!r)return;let i=e=>{let t=null;for(let i=0;i<e.length;i++){let a=n(e[i]);a&&a!==r&&(t??=[]).push(a)}return t},a=(e,t)=>{if(!t)return!0;for(let n=0;n<t.length;n++)if(!BM(r,t[n],e))return!1;return!0},o=(e,t)=>{let n=[],i=t=>{let r=h.intersectRanges(t,e);r&&n.push(r)};for(let n=0;n<t.length;n++){let a=t[n],o=a.search(e);for(let e=0;e<o.length;e++)zM(r,o[e])||i(o[e]);let s=r.search(e);for(let e=0;e<s.length;e++)zM(a,s[e])||i(s[e])}return n},s=this._vendParentState(t[0]),c=e=>e.open?this._transactions.getCurrentTransaction()?.getSavepointId():void 0,l=(e,n,r)=>{let a=new Map;for(let n=0;n<t.length;n++){let r=e(t[n].state),i=a.get(r);i?i.push(t[n]):a.set(r,[t[n]])}let o=[];return a.forEach((t,a)=>{let c=a;if(s&&e(s)===a){c=r(a,t[0]);for(let e=0;e<t.length;e++)this._writeVend(t[e],{[n]:c})}o.push([c,i(t)])}),o},u=this._valuesAxis,d=u===B.Axis.Column,f=(e,t,n)=>({colStart:d?e:t,rowStart:d?t:e,colEnd:d?e:t+n-1,rowEnd:d?t+n-1:e}),p=(e,t)=>{if(!t)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r][0],o=e[r][1],s=[];for(let e=0;e<o.length;e++){let n=o[e][0],r=o[e][1],c=r.length;if(a(f(i,n,c),t)){s.push(o[e]);continue}let l=-1,u=[];for(let e=0;e<c;e++)a(f(i,n+e,1),t)?(l<0&&(l=e),u.push(r.at(e))):l>=0&&(s.push([n+l,u]),u=[],l=-1);l>=0&&s.push([n+l,u])}s.length>0&&n.push([i,s])}return n},m=(e,t)=>t?e.filter(e=>a(e,t)):e,g=(e,t)=>{if(!t)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(a(i,t)){n.push(i);continue}let s=mm([i],o(i,t));for(let e=0;e<s.length;e++)n.push({...s[e],value:i.value})}return n},_=(e,t,n)=>{if(!t)return void e.clear();let r=e.all(),i=[];for(let e=0;e<r.length;e++){let s=r[e];if(a(s,t))continue;if(!n){i.push(s);continue}let c=o(s,t);for(let e=0;e<c.length;e++)i.push({...c[e],value:s.value})}e.clear();for(let t=0;t<i.length;t++)e.insertNonOverlapping(i[t])},v=!0===e.isFull,y=e.valueInserts,b=e.valueRemoves;if(y||b){let e=l(e=>e.cellValuesGrid,`cellValuesGrid`,e=>e.clone());for(let t=0;t<e.length;t++){let[n,r]=e[t];if(b){let e=m(b,r);for(let t=0;t<e.length;t++)n.delete(e[t])}y&&n.setValues(p(y.tuples,r))}let t=l(e=>e.contentfulSpatial,`contentfulSpatial`,(e,t)=>e.clone(c(t)));for(let e=0;e<t.length;e++){let[n,r]=t[e];if(b){let e=m(b,r);for(let t=0;t<e.length;t++)n.insertNonOverlapping({...e[t],value:null})}if(y){let e=p(y.tuples,r);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1];for(let e=0;e<i.length;e++){let t=f(r,i[e][0],i[e][1].length);n.insertNonOverlapping({...t,value:new Fj(t,u)})}}}}this._rangeStats=this._rangeStats.clone(this._getState().cellValuesGrid),this._rangeStats.clear()}let x=e.spillInserts,S=e.spillRemoves,C=(e,t)=>{let n=[],r=this._getState().pivots;for(let i=0;i<e.length;i++){if(e[i].value===`error`!==t)continue;let a=h.sanitizeRange(e[i]),o=null;if(r&&e[i].value===`pivot`)for(let e=0;e<r.length;e++){let t=r[e],n=t.block?.anchor;if(n&&h.isEqualRanges(t.range,a)){o={rows:n.row-a.rowStart,columns:n.column-a.colStart};break}}n.push({...a,value:new Aj(a,0,e[i].value,o)})}return n};if(v||x||S){let e=l(e=>e.spillSpatial,`spillSpatial`,(e,t)=>e.clone(c(t)));for(let t=0;t<e.length;t++){let[n,r]=e[t];if(v&&_(n,r,!1),S){let e=m(S,r);for(let t=0;t<e.length;t++)n.remove(e[t])}if(x){let e=C(m(x,r),!1);e.length>0&&n.load(e)}}let t=l(e=>e.blockedSpillSpatial,`blockedSpillSpatial`,(e,t)=>e.clone(c(t)));for(let e=0;e<t.length;e++){let[n,r]=t[e];v&&_(n,r,!1);let i=e=>{for(let t=0;t<e.length;t++)PM(n,{rowStart:e[t].rowStart,colStart:e[t].colStart,rowEnd:e[t].rowStart,colEnd:e[t].colStart})};if(S&&i(m(S,r)),x){let e=m(x,r);i(e);let t=C(e,!0);t.length>0&&n.load(t)}}}let w=e.errorInserts,T=e.errorRemoves;if(v||w||T){let e=l(e=>e.calcErrorsSpatial,`calcErrorsSpatial`,(e,t)=>e.clone(c(t)));for(let t=0;t<e.length;t++){let[n,r]=e[t];if(v&&_(n,r,!0),T){let e=g(T,r);for(let t=0;t<e.length;t++)n.remove(e[t])}if(w){let e=g(w,r);e.length>0&&n.load(e)}}}let E=e.calcStatusUpdates;if(v||E){let e=l(e=>e.calcStatusSpatial,`calcStatusSpatial`,(e,t)=>e.clone(c(t)));for(let t=0;t<e.length;t++){let[n,r]=e[t];if(v&&_(n,r,!0),E){let e=g(E,r);for(let t=0;t<e.length;t++){let r=e[t];n.insertNonOverlapping(!1===r.value?{...r,value:null}:r)}}}}let D=e.circularUpdates;if(v||D){let e=l(e=>e.circularSpatial,`circularSpatial`,(e,t)=>e.clone(c(t)));for(let t=0;t<e.length;t++){let[n,r]=e[t];if(v&&_(n,r,!1),D){let e=m(D,r);for(let t=0;t<e.length;t++)n.insertNonOverlapping(e[t])}}}}close(){this._closed||(this._closed=!0,this._backend.close(),this._notify(`onClose`,void 0),this._emitter?.close(),this._emitter=null,this._transactions.remove(this._stateId))}get[Symbol.toStringTag](){return`[CalcGrid]`}},kM=e=>({colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colEnd,rowEnd:e.rowEnd}),AM=(e,t)=>e===t||!!e&&!!t&&e.colStart===t.colStart&&e.rowStart===t.rowStart&&e.colEnd===t.colEnd&&e.rowEnd===t.rowEnd,jM=0,MM=(e,t)=>{e.insertNonOverlapping({colStart:t.colStart,rowStart:t.rowStart,colEnd:t.colEnd,rowEnd:t.rowEnd,value:null},{noMerge:!0})},NM=(e,t)=>{let n=e.search(t);for(let r=0;r<n.length;r++){let i=n[r];i.value.getKind()!==`pivot`&&Rj(i.rowStart,i.colStart,t)&&e.remove(i)}},PM=(e,t)=>{let n=e.search(t);for(let r=0;r<n.length;r++){let i=n[r];i.rowStart>=t.rowStart&&i.rowStart<=t.rowEnd&&i.colStart>=t.colStart&&i.colStart<=t.colEnd&&e.remove(i)}},FM=(e,t,n)=>{let r=e.search(n);if(r.length!==1)return;let i=r[0];if(i.colStart!==n.colStart||i.rowStart!==n.rowStart||i.colEnd!==n.colEnd||i.rowEnd!==n.rowEnd)return;let a=e=>{let n=t.search({colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colStart,rowEnd:e.rowStart});for(let t=0;t<n.length;t++){let r=n[t];if(r.value.isFixed()&&Rj(r.rowStart,r.colStart,e))return!0}return!1};Tc(t=>e.search(t),i,(e,t,n,r)=>{if(a(e)||a(t))return;let i=e.value.getMerged(t.value,n,r);return i&&(i.block=null),i},(t,n)=>{e.removeAll(t,TM),e.insertNonOverlapping(n,{noMerge:!0})})},IM=e=>{if(!e||e.length===0)return null;let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]={min:e[n].min,max:e[n].max};return t},LM=(e,t,n)=>{if(MM(e,t),n.length===0)return n;let r=n.length>1?xc(n,B.Axis.Column,2**53-1,wc):n;return e.load(r),r},RM=(e,t)=>{let n=e.imageBlock(t);if(n===e.a1)return e.setBlock(t),e;let r=new wA(n,e.ref,t);return r.relativeForm()===e.relativeForm()?(e.setBlock(t),e):r},zM=(e,t)=>{let n=e.search(t);for(let e=0;e<n.length;e++)if(n[e].value===t.value&&h.isEqualRanges(n[e],t))return!0;return!1},BM=(e,t,n)=>{let r=t.search(n);if(r.length!==e.search(n).length)return!1;for(let t=0;t<r.length;t++)if(!zM(e,r[t]))return!1;return!0},VM=class{constructor(e){this._body=null,this._blank=null,this._bodyRequest=null,this._bodyPending=!1,this._wanted=new Map,this._evaluated=new Set,this._demandQueued=!1,this._demandSent=!1,this._waitUntil=e.waitUntil,this._onDispose=e.onDispose,this._onCalculated=e.onCalculated,this._onResync=e.onResync,this._id=e.id,this._grid=e.grid,this._transactions=e.transactions??null,this._runtime=e.runtime}getId(){return this._id}setBody(e,t){return this._sendBody({options:e,onAnswered:t})}_sendBody(e){this._bodyRequest=e,this._bodyPending=!0,this._body=null;let t=()=>this._bodyRequest===e&&this._bodyPending,n=this._amendCurrent(()=>this._grid._setBody(e.options,t));return n.then(t=>{this._bodyRequest===e&&this._bodyPending&&!this._grid._isClosed()&&(this._refine(t),this._getEntry()?.value.isCompiled()&&(this._bodyPending=!1,e.onAnswered?.()))},()=>{}),n}_restart(){let e=this._bodyRequest;if(e&&this._bodyPending)return this._sendBody(e);let t=this._getEntry(),n=this._body=t?{coords:this._coordsOf(t),text:t.value.getTextAt(t.rowStart,t.colStart)}:null;if(!n)return null;let r=this._grid._resendFormula(n.coords,n.text);return r.then(e=>{this._body===n&&this._refine(e)},()=>{}),r}getBody(){return this._body}hasBody(){return this._bodyPending||this._body!==null}_onComplete(e){if(this._refine(e),this._bodyPending&&e.formulaInserts?.length&&this._getEntry()?.value.isCompiled()&&(this._bodyPending=!1,this._bodyRequest?.onAnswered?.()),e.blankRegion!==void 0){let t=this._blank=e.blankRegion,n=this._evaluated;if(n.clear(),t?.paged){let e=t.evaluated??GM;for(let r=0;r<e.length;r++)n.add(this._tileOf(e[r].rowStart,t.extent));if(!this._demandSent){for(let e of this._wanted.keys())if(!n.has(e)){this._queueDemand();break}}}else this._wanted.clear();this._demandSent=!1}this._onCalculated?.(e)}request(e,t){let n=this._blank;if(!n?.paged)return!0;let r=n.extent;if(e<r.rowStart||e>r.rowEnd||t<r.colStart||t>r.colEnd||!KM(n.rects,e,t))return!0;let i=this._tileOf(e,r),a=this._wanted,o=a.delete(i);return a.set(i,!0),!!this._evaluated.has(i)||(o||(a.size>WM&&a.delete(a.keys().next().value),this._queueDemand()),!1)}_tileOf(e,t){return Math.floor((e-t.rowStart)/UM)}_queueDemand(){if(this._demandQueued)return;this._demandQueued=!0;let e=Promise.resolve().then(()=>{this._demandQueued=!1;let e=this._blank?.paged?this._blank.extent:null;e&&!this._grid._isClosed()&&(this._sendDemand(e),this._demandSent=!0,this._grid._requestPass())});this._waitUntil?.(e)}_sendDemand(e){let t=[];for(let n of this._wanted.keys()){let r=e.rowStart+n*UM;t.push({colStart:e.colStart,rowStart:r,colEnd:e.colEnd,rowEnd:Math.min(e.rowEnd,r+UM-1)})}this._grid._demand(t)}_refine(e){let t=e.formulaInserts;if(!t||t.length===0)return;let n=t[0],r=n.value;r&&(this._body={coords:this._coordsOf(n),text:r.getTextAt(n.rowStart,n.colStart)})}_resync(){this._bodyPending=!1;let e=this._getEntry();this._body=e?{coords:this._coordsOf(e),text:e.value.getTextAt(e.rowStart,e.colStart)}:null,this._onResync?.()}_rewrite(e,t){return this._write(e,t)}_write(e,t){this._bodyRequest=null,this._bodyPending=!1;let n=this._body={coords:this._coordsOf(e),text:t},r=this._amendCurrent(()=>this._grid.setInputs(null,[{colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colEnd,rowEnd:e.rowEnd,value:t}]));return r.then(e=>{this._body===n&&this._refine(e)},()=>{}),r}setPlaceholder(e){let t=this.getCoords()??HM;return this._write(t,e)}moveBody(e){let t=this._getEntry();if(!t)return null;let n=t.value.getTextAt(t.rowStart,t.colStart);return this._amendCurrent(()=>this._grid.remove(this._grid.getEntireCoords())),this._write(e,n)}requestPass(){this._grid._requestPass()}clear(){return this._body=null,this._amendCurrent(()=>this._grid.remove(this._grid.getEntireCoords()))}getCoords(){let e=this._getEntry();return e?this._coordsOf(e):null}_coordsOf(e){return{colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colEnd,rowEnd:e.rowEnd}}getBlock(){return this._bodyPending?null:this._getEntry()?.value.block??null}_getCalcGrid(){return this._grid}_isLive(){return this._grid._isLive()}getView(){return this._getEntry()?.value??null}_evaluateScalarAt(e,t,n){return this._grid._evaluateScalarAt(e,t,n)}getValueGrid(){return this._grid.getValues()}getBlankRegion(){return this._blank}getBlankValueWithin(e){let t=this._blank;if(!t||t.paged)return null;let n=t.extent;return e.rowStart<n.rowStart||e.rowEnd>n.rowEnd||e.colStart<n.colStart||e.colEnd>n.colEnd?null:t.value??null}getValues(e){let t=this._getEntry(),n=e??(t?this._coordsOf(t):null);return n?new LV(this._runtime,this._grid.getValues(),n,null,!1,!1,this.getBlankValueWithin(n)):null}dispose(){this._body=null,this._onDispose?.(),this._amendCurrent(()=>{this._grid._hasState()&&this._grid.remove(this._grid.getEntireCoords()),this._grid.delete()})}setInputs(e,t){return this._amendCurrent(()=>this._grid.setInputs(e,t))}_amendCurrent(e){let t=this._transactions;if(!t||t.getCurrentTransaction())return e();let n=t.beginCommit();try{let t=e();return n.amend(),t}catch(e){throw n.rollback(),e}}_getEntry(){if(this._grid._isClosed()||!this._grid._hasState())return null;let e=this._grid.getFormulas().search(this._grid.getEntireCoords());if(e.length===0)return null;let t=e[0];return t.value?t:null}},HM=Object.freeze({colStart:0,rowStart:0,colEnd:0,rowEnd:0}),UM=256,WM=64,GM=Object.freeze([]),KM=(e,t,n)=>{for(let r=0;r<e.length;r++){let i=e[r];if(t>=i.rowStart&&t<=i.rowEnd&&n>=i.colStart&&n<=i.colEnd)return!0}return!1};function qM(e,t){let n=e.measureText(`M`);return{ascent:n.ascent??t.baseline,descent:n.descent??t.bounds.height-t.baseline}}var JM=Object.freeze({value:null,style:null,impliedStyle:void 0,hyperlink:null,comments:null,formula:null,type:U.Null,stringToParse:null}),YM=Object.seal({value:void 0,style:void 0,impliedStyle:void 0,hyperlink:void 0,comments:void 0,formula:void 0,type:void 0,stringToParse:void 0}),XM=Object.seal({value:void 0,style:void 0,hyperlink:void 0,comments:void 0,formula:void 0}),ZM=Object.freeze({width:1,height:1});function QM(e,t,n){let r=e=>{let n=Fd(e)??``;return e.scope&&e.scope!==t?`${Ld(e.scope)}!${n}`:n};if(e.kind===`downstream`){let t=e.cycle.getRepresentative();return t?`Reads a circular reference at ${r(t)}`:`Reads a circular reference`}let i=e.cycle.getPath({rowIndex:n.rowIndex,colIndex:n.colIndex,scope:t});if(i.length===0)return`Circular reference${$M(e.cycle)}`;let a=i.slice(0,8).map(r),o=i.length-a.length;return`Circular reference: ${a.join(` → `)}${o>0?` → … (+${o} more)`:``} → ${a[0]}${$M(e.cycle)}`}function $M(e){if(!e.isIterative())return``;let t=e.getIterationCount(),n=`${t} iteration${t===1?``:`s`}`;if(e.isConverged())return` (converged after ${n})`;let r=e.getLastChange(),i=Number.isFinite(r)?`, last change ${Number(r.toPrecision(6))}`:``,a=e.getPreviousChange();return` (did not converge after ${n}${i}${Number.isFinite(r)&&Number.isFinite(a)&&r<a?` — still converging, raise max iterations`:``})`}var eN=new Mh({max:1e3}),tN=e=>{if(Array.isArray(e))return`array`;let t=typeof e;if(t!==`object`)return t;if(e instanceof Date)return`Date (invalid)`;let n=e?.constructor?.name;return n&&n!==`Object`?n:`object`};function nN(e,t,n=null,r=null,i=!1,a=null,o=!1,s=null){if(t===void 0)return;if(t===null)return JM;if(t&&t.isICell){let e=t,n=YM;return n.value=e.getValue(),n.style=e.getStyle().getAuthoredProperties()??null,n.impliedStyle=void 0,n.formula=(a?e.getExpressionText({cell:a}):e.getExpressionText())||void 0,n.stringToParse=void 0,n.hyperlink=e.getStoredHyperlink(),n.comments=e.getComments()?.toJSON()??null,n.type=e.getType(),n}let c,l=pB(t),u=!!l;u||t.value===void 0&&t.style===void 0&&t.hyperlink===void 0&&t.comments===void 0?(c=XM,c.value=!u&&t.hasOwnProperty(`value`)?t.value:t,c.style=void 0,c.hyperlink=void 0,c.comments=void 0):c=t;let d=YM;d.type=void 0,d.value=void 0,d.style=void 0,d.impliedStyle=void 0,d.formula=void 0,d.hyperlink=void 0,d.comments=void 0,d.stringToParse=void 0;let f,p=c.value,m=!1,h=!1;if(c.value!==void 0&&(f=p===t?l:pB(p),f||(m=we(p,!0),m?f=U.Number:s&&ku.isJSON(p)&&(p=ku.fromJSON(p,s),f=pB(p),h=!0)),!f))throw typeof p?.then==`function`?new k(N(`error.sheet.promiseCellValue`)):new k(N(`error.sheet.invalidCellType`,{type:tN(p)}));let g,_,v=null,y=null,b;if(f===U.String){if(b=c.value,n){let t=r?.get(b),a=b.charAt(0);t||(a===`=`&&b.length>1?(_=b.substring(1),p=null):(t=zz(e,b,n),t!==void 0&&r&&r.set(b,t))),t&&typeof t.value==`string`&&(a===`+`||a===`-`)&&(e=>{for(let t=0;t<e.length;t++){let n=e.charAt(t);if(n!==`+`&&n!==`-`&&n!==` `&&n!==` `)return!0}return!1})(b)&&(_=b,p=null),t&&(t.value!==void 0&&(p=t.value,f=pB(p)),t.style!==void 0&&(v=t.style),t.hyperlink!==void 0&&(g=t.hyperlink)),!i&&n.parse&&(y=b)}else o&&b.charAt(0)===`'`&&(p=b.substring(1),v={quotePrefix:!0})}else m?(p=Dt(c.value,e.isDate1904()),v=e=>{let t=e.getNumberFormat();if(!nt(t))return{numberFormat:`Short Date`}}):h||(p=c.value);let x=c.style;x&&x.isICellStyle&&(x=x.getAuthoredProperties()??null),g=c.hyperlink??g,v&&(d.impliedStyle=v);let S=!1;p!==void 0&&(p===null?(d.value=null,d.type=U.Null):(d.value=p,d.type=f),S=!0),x!==void 0&&(d.style=x,S=!0),g!==void 0&&(d.hyperlink=g,S=!0);let C=c.comments;return C!==void 0&&(d.comments=C,S=!0),_!==void 0&&(d.formula=_,S=!0),i||(d.stringToParse=y,S=!0),S?(d.type=f,d):void 0}var rN=e=>e===R.HorizontalAlignment.Center||e===R.HorizontalAlignment.CenterContinuous?o.Center:e===R.HorizontalAlignment.Right?o.Right:o.Left,iN=(e,t,n)=>t===U.Null?null:Ym(t,e.getFont(),e.getAlignment(),!1,!0,Fl),aN=(e,t,n,r,i=!1)=>{if(e===U.Null)return null;let a=``;if(i)a=jv(n,e);else{let i=kv(r.runtime,n,t,e,t.getNumberFormatRef?.()??t.getNumberFormat(),e=>r.styles.parseColor(e));if(i.formattedRuns){let e=i.formattedRuns.runs,t=e.length;for(let n=0;n<t;n++)a+=e[n].text}else a=i.displayText}return Ym(a,t.getFont(),t.getAlignment(),e===U.String,i,Fl)},oN=Object.freeze({dataBar:null,iconSet:null}),sN=e=>e.isStopIfTrue()&&!e.getScale(),cN=(e,t)=>{let n=t.getInsets();if(e===U.Null)return n;let r=n,i=fN(e,t),a=t.getAlignment().getStacked()?0:t.getAlignment().getIndent();if(a&&(i===R.HorizontalAlignment.Left||i===R.HorizontalAlignment.Right)){r={...n};let e=a*zC(t);i===R.HorizontalAlignment.Left?r.left+=e:i===R.HorizontalAlignment.Right&&(r.right+=e)}return Object.freeze(r)};function lN(e,t,n,r,i){if(!e)return oN;let a=Array.isArray(e)?e:[e],o=null,s=null;for(let e=0;e<a.length;e++){let i=a[e],c=i.getDecorationAt(t,n,r);if(c&&(c.type===CD.ScaleType.DataBar?o??=c:s??=c),o&&s||sN(i)&&(c||i.getPropertiesAt(t,n,r)))break}if(s){let e=i().getAlignment();(e.getRotation()!==0||e.getStacked())&&(s=null)}return o||s?Object.freeze({dataBar:o,iconSet:s}):oN}var uN=e=>{let t=e.measureText(``);return(t.ascent??t.lineHeight)+(t.descent??0)+e.getInsets().left},dN=(e,t,n)=>YC(t,n).textLeft-cN(e,t).left,fN=(e,t)=>{let n=t.getAlignment(),r=n.getHorizontal();if(n.getStacked())return r===R.HorizontalAlignment.General||r===R.HorizontalAlignment.Distributed?R.HorizontalAlignment.Center:r===R.HorizontalAlignment.Justify?R.HorizontalAlignment.Left:r;let i=Tn(n.getRotation());return i!==0&&r===R.HorizontalAlignment.General?i>0&&i<90||i>180&&i<=270?R.HorizontalAlignment.Right:R.HorizontalAlignment.Left:r===R.HorizontalAlignment.General?e===U.Null?R.HorizontalAlignment.Left:e===U.Boolean||e===U.Error?R.HorizontalAlignment.Center:t.getNumberFormat()===`@`?R.HorizontalAlignment.Left:e===U.Number?R.HorizontalAlignment.Right:R.HorizontalAlignment.Left:r};function pN(e,t,n,r,i,a,s,c,l,u=0){if(n===U.Null||i===``)return null;let d=t;if(!function(e,t,n=!1,r=!1){if(e===U.Null)return!1;let i=t.getAlignment(),a=i.getHorizontal();if(a===R.HorizontalAlignment.CenterContinuous||a===R.HorizontalAlignment.Fill)return!0;if(a===R.HorizontalAlignment.Distributed||i.getStacked())return!1;if(En(i.getRotation())){let i=rN(fN(e,t));return!(i===o.Right&&n||i===o.Center&&n&&r||i===o.Left&&r)}if(e!==U.String||i.getOverflow()!==R.Overflow.Visible||a===R.HorizontalAlignment.Right&&n||a===R.HorizontalAlignment.Center&&n&&r||r&&(a===R.HorizontalAlignment.General||a===R.HorizontalAlignment.Left))return!1;let s=i.getVertical();return s!==R.VerticalAlignment.Justify&&s!==R.VerticalAlignment.Distributed}(n,r,a!==null&&a.colIndex+1===d,s!==null&&s.colIndex-1===d))return null;let f=r.getAlignment(),p=f.getHorizontal(),m=!En(f.getRotation())&&(f.getOverflow()===R.Overflow.Wrap||n===U.String&&(p===R.HorizontalAlignment.Justify||p===R.HorizontalAlignment.Distributed||f.getVertical()===R.VerticalAlignment.Justify||f.getVertical()===R.VerticalAlignment.Distributed)),h=p===R.HorizontalAlignment.Fill,g=p===R.HorizontalAlignment.CenterContinuous||h,_=h?null:bN(n,r,i,l,e,u);if(!_&&!g)return null;let v=rN(fN(n,r)),y=0,b=0,x=0,S=0,C=1;if(g&&i!==null&&c){TN.colIndex=t,TN.rowIndex=e;let n=c.colEnd;C=Math.min(l.nextContentful(TN,n),n)-t+1}let w=l.colHeaders.getMetrics(),T=w.getOffset.bind(w),E=w.getIndex.bind(w),D=T(d),O=D,k=T(d+C),A=k-D,j=d,M=d,N={x:0,y:0,width:A,height:_?.height??0},ee=d-d+C,te=_?_.width-A:0,P=N;return A>0&&te>0&&!m&&(v===o.Center&&(te/=2),v!==o.Left&&v!==o.Center||(M=E(k+te),s!==null&&(M=Math.min(M,s.colIndex-1)),k=T(M),S=te,b=M-d),v!==o.Right&&v!==o.Center||(j=E(D-te),a!==null&&(j=Math.max(j,a.colIndex+1)),D=T(j),x=te,y=d-j),N.x=O-D,P.x=N.x),C>1&&(b=v===o.Center?Math.max(ee-1,b):C-1,k=T(d+1),N.width=k-D,P={...N},P.width=A),{anchorBounds:N,leftIndex:y,rightIndex:b,leftOffset:x,rightOffset:S,colSpan:ee,colBounds:P}}var mN=class{constructor(e,t){this._styles=e,this._ri=t;let n=t?.table;n?this._table=n.getRangedStyle():t?.pivot&&(this._table=t.pivot._getCellLayer())}getCoords(){return h.EmptyRange}_directAt(e,t,n){let r=this._ri,i=r.borderStyle?r.borderStyle.getPropertiesAt(e,t,n):null,a=r.fillStyle?r.fillStyle.getPropertiesAt(e,t,n):null,o=r.contentStyle?r.contentStyle.getPropertiesAt(e,t,n):null;return!i||a||o?i||!a||o?i||a||!o?i||a||o?{...o,...a,...i}:null:o:a:i}getPropertiesAt(e,t,n){let r=this._ri,i=this._styles,o=null,s=this._table?.getPropertiesAt(e,t,n);s&&(o=a.resolveTypedUpdates(s,yt,i,o));let c=null,l=r.conditionals;l&&!Array.isArray(l)&&(l=[l]);let u=l?l.length:0;if(u>0){let r=null,o=null;for(let i=0;i<u;i++){let a=l[i],s=a.getPropertiesAt(e,t,n);if(s&&(o?(r??=[o]).push(s):o=s),s&&sN(a))break}if(r)for(let e=r.length-1;e>=0;e--)c=c?a.resolveTypedUpdates(r[e],yt,i,c):r[e];else c=o}let d=this._directAt(e,t,n),f=null;if(d&&d.named){let r=d.named;if(r!==z.BuiltInName.Normal){let a=i.getNamedStyles().getByName(r);a?f=a.getRanged().getPropertiesAt(e,t,n):console.warn(`A named styled was referenced but not found: '${r}'.`)}}let p=null;f&&(p=a.resolveTypedUpdates(f,yt,i,p)),d&&(p=p?a.resolveTypedUpdates(d,yt,i,p):d);let m=null;if(o&&p){let e=i.normalize(p,z.BuiltInName.Normal),t=e?.font,n=t?.color;n==null||n!==Mt.Type.Auto&&!((e,t)=>{let n=e.getNormal().getFont().getColor();if(!n)return!1;try{let r=typeof t==`string`?e.parseColor(t):t;return!!r&&r.toCSS(`adaptive`)===e.parseColor(n).toCSS(`adaptive`)}catch{return!1}})(i,n)||(delete t.color,Object.keys(t).length===0&&delete e.font),m=e?a.resolveTypedUpdates(e,yt,i,o):o}else m=p??o;return c&&(m=m?a.resolveTypedUpdates(c,yt,i,m):c),m}cloneWithUpdate(e){let t=this._ri;return(Am.compose(t.borderStyle,t.fillStyle,t.contentStyle)??this._styles.getNormalRanged()).cloneWithUpdate(e)}getAuthoredPropertiesAt(e,t,n){return this._directAt(e,t,n)}};function hN(e,t,n,r,i,a){let o=r.styles,s=null;return n&&(s=i?Am.compose(n.borderStyle,n.fillStyle,n.contentStyle)??null:new mN(o,n)),ch(e,o,s,t,r.styleUpdater,a)}function gN(e,t){if(!e)return!1;if(!Array.isArray(e))return!e.isAnchor(t.rowIndex,t.colIndex);let n=e.length;for(let r=0;r<n;r++)if(e[r].isAnchor(t.rowIndex,t.colIndex))return!1;return!0}function _N(e,t,n,r,a,o,s,c=0,l=null,u=eN,d){let f=d?.formulaText,p=d?.formulaView??!1;if(n===null&&f===void 0)return t?t.getBestFit():null;let m=f===void 0&&e===U.String,h=t.getFont(),g=h.getWeight(),_=h.getSize(),v=h.getFamily(),y=t.getAlignment(),b=y.getOverflow(),x=y.getStacked(),S=x?0:y.getRotation(),C=y.getVertical(),w=t.getNumberFormat(),T=m&&b===R.Overflow.Visible,E=m&&(b===R.Overflow.Wrap||C===R.VerticalAlignment.Justify||C===R.VerticalAlignment.Distributed),D=cN(e,t),O=D.left+c+D.right+2,k=r?.styles?zm(r.styles.getNormal()):7,A=(l??``)+`\0`+_+v+g+w+S+x+T+E+o+s+O+(l?``:n)+`\0`+p+`\0`+(f??``)+`\0`+(E?a:``)+`\0`+j.getRevision()+`\0`+Lm()+`\0`+k,M=u.get(A);if(M)return M;let N=null,ee=null,te=D.top+D.bottom-2+function(e){let t=e.getFont().getUnderline()===I.UnderlineStyle.SingleAccounting,n=e.getFont().getUnderline()===I.UnderlineStyle.DoubleAccounting,r=0;return(t||n)&&(r=e.measureText(``).underlineThickness+1,n?r*=2:r+=1),r}(t),P=!1,F=!1,ne=!1;s&&(ne=!0,(S!==0||x||E)&&(ne=!1));let re=ne?void 0:f===void 0?aN(e,t,n,r,p):iN(t,f);if(re){if(!p&&e===U.Number&&w===`General`&&o){let e=n,r=i.splitNumber(e),a=``;a=Math.abs(e)>=10**12||Math.abs(e)<=10**-12?`0.${`0`.repeat(Math.max(2,Math.min(r.ipLength,5)))}E+00`:Math.abs(r.ipLength)===0?`0.0`:Math.abs(r.fpLength)>0?`0`.repeat(r.ipLength)+`.0`:`0`.repeat(r.ipLength),e<0&&(a=`-`+a),a=`0`.repeat(a.length);let o=t.measureText(a);N=o.width,ee=o.lineHeight}else if(f===void 0&&!p&&x){let e=re.layout({width:1e9}),t=e.lines[0]?.bounds.height??e.bounds.height,n=Nn(yN(re),re.wrapped,2**53-1);ee=Pn(n)*t+2,N=n.length*t+(n.length===1?-1:1),F=!0}else if(f===void 0&&!p&&En(S)){let e=Tn(S)*Math.PI/180,t=Math.abs(Math.sin(e)),n=Math.abs(Math.cos(e)),r=re.layout({width:1e9}),i=r.lines[0]?.bounds.height??r.bounds.height;if(E){let e=Math.max(1,a-O),t=Math.max(1,Math.round(e/(1.5*i)));if(r.lines.length<t||t>1){let e=Math.max(1,r.bounds.width/t);for(let n=0;n<8;n++){let n=re.layout({width:e});if(n.lines.length<=t){r=n;break}e*=1.25}let n=0;for(let e=0;e<r.lines.length;e++)n=Math.max(n,r.lines[e].bounds.width);let i=re.layout({width:n});i.lines.length===r.lines.length&&(r=i)}}let o=r.lines,s=0,c=0;for(let e=0;e<o.length;e++){let r=o[e].bounds.width,i=o[e].bounds.height;s=Math.max(s,r*t+i*n),c=Math.max(c,r*n+i*t)}ee=s,N=(o.length-1)*(t>0?i/t:0)+c,F=!0}else{let e=null;E&&(e={width:Math.max(1,a-O)});let t=re.layout(e);if(ee=t.bounds.height,E){let e=t.lines,n=e.length,r=0;for(let t=0;t<n;t++){let n=e[t].bounds.width;n>r&&(r=n)}N=r}else N=t.bounds.width}if(N!==null){if(S||x)N+=O;else{let e=zm(t);N=((e,t,n,r,i)=>{let a=Math.ceil(e),o=Math.max(3,Math.floor(a/(4*Math.max(1,t)))+1),s=a+2*Math.ceil(n/4)+o+r;return Math.ceil(Math.max(s,i))})(N,k,e,O-(2*kt(e)+2),N+O)}}if(ee!==null&&(ee+=te),P=e===U.String&&!x,S&&(P&&b===R.Overflow.Wrap&&(P=!1),!F)){let e=function(e,t){let{x:n,y:r,width:i,height:a}=e,o=t*Math.PI/180,s=Math.sin(o),c=Math.cos(o),l=i/2,u=a/2,d=bA(-l,-u,s,c),f=bA(l,-u,s,c),p=bA(-l,u,s,c),m=bA(l,u,s,c),h=Math.min(d.x,f.x,p.x,m.x)+l,g=Math.max(d.x,f.x,p.x,m.x)+l,_=Math.min(d.y,f.y,p.y,m.y)+u;return{x:n+h,y:r+_,width:g-h,height:Math.max(d.y,f.y,p.y,m.y)+u-_}}({x:0,y:0,width:N,height:ee},S);N=e.width,ee=e.height}E&&N!==null&&(N=Math.ceil(N))}else ee=t.getBestFit().height;o&&P&&(N=0);let ie=Object.freeze({width:N,height:ee});return u.set(A,ie),ie}var vN=(e,t,n,r)=>{let i=t.getAlignment(),a=i.getHorizontal();if(a===R.HorizontalAlignment.Fill||a===R.HorizontalAlignment.CenterContinuous||i.getStacked())return null;let o=i.getRotation();if(!En(o))return null;let s=cN(e,t),c={x:s.left,y:s.top,width:Math.max(0,r.width-s.left-s.right),height:Math.max(0,r.height-s.top-s.bottom)},l=n.layout({width:1e9}),u=l.lines[0]?.bounds.height??l.bounds.height,d=i.getVertical(),f=n.wrapped?n.layout({width:Dn(c.height,u,o)}):l;return{layout:kn(f.lines.map(e=>({width:e.bounds.width,height:e.bounds.height})),o,c,fN(e,t),d),frame:f,lineHeight:u,content:c}},yN=e=>{let t=``,n=e.paragraphs;for(let e=0;e<n.length;e++){let r=n[e].runs;for(let e=0;e<r.length;e++)t+=r[e].text}return t},bN=(e,t,n,r,i,a)=>{if(En(t.getAlignment().getRotation())){let a=r.sheet?.getRowHeaders().getMetrics().getSpanSize(i),o=a?aN(e,t,n,r,!1):null;if(o){let n=vN(e,t,o,{width:0,height:a});if(n)return{width:Math.ceil(n.layout.bounds.width),height:Math.ceil(n.layout.bounds.height)}}}let o=cN(e,t),s=fN(e,t),c=o.left+o.right;s===R.HorizontalAlignment.Left?c=o.right:s===R.HorizontalAlignment.Right?c=o.left:s===R.HorizontalAlignment.Center&&(c=o.left+o.right);let l=_N(e,t,n,r,2**53-1,!1,!1,a);return{width:Math.ceil(l.width-c),height:Math.ceil(l.height)}},xN={hideStringPrefix:!0},SN=class e{constructor(e,t,n=U.Null,r=null,i=null,a=null,o=null){this._options=e,this._r=e.runtime,this._coords=t??null,this._p=a,this._n=o,this._t=n,this._ri=i,this._v=r,this._dfmt=n===U.Number&&i?.dateFormat?i.dateFormat:null}_getDate(){let e=this._d;if(e!==void 0)return e;let t=this._dfmt;return e=t&&(nt(t)||pt(t))?he(this._v,this._r?.isDate1904()??!1)??null:null,this._d=e,e}getRange(){let e=this._coords,t=null,n=this._ri;return t=n&&n.merge?n.merge.getCoords():e?h.cellToRange(e):null,this._options.getRange(t)}isEqual(e){if(!e)return!1;if(this===e)return!0;let t=e;return!!t.isICell&&this._v===t._v&&!!h.isEqualCells(this._coords,e.getCoords())&&this._options.sheet===t._options?.sheet}getCoords(){return this._coords}getA1(){return this.getAddress()}getAddress(e){let t=this._coords;return t?Wd(this._options.getRange(t).getCoords()):gd}getWorksheet(){return this._options.sheet}select(e){return this._options.opener(`#`+Fd(this._coords),e)}_openAddress(e,t,n,r){return this._options.opener(e,t,n,r)}getConditionalDecorations(){let e=this._cd;if(e!==void 0)return e;let t=this._coords;return this._cd=t?lN(this._ri?.conditionals,t.rowIndex,t.colIndex,this._v,()=>this.getStyle()):oN}getControl(){let e=this._ri?.cellControls;return e?Array.isArray(e)?e[0]??null:e:null}getSparkline(){let e=this._ri?.sparklineGroups,t=Array.isArray(e)?e[0]:e;return t?t.getSparkline(this.getCoords()):null}getProtection(){return this.getStyle().getProtection()}getTextOverflow(){let e=this._to;if(e!==void 0)return e;let t=this._ri;if(t&&t.merge)return this._to=null,null;let n=this._layoutType(),r=null;if(n===U.String||t&&t.continuous){let e=this.getStyle(),i=this._coords;r=pN(i.rowIndex,i.colIndex,n,e,this._v,this._p,this._n,t?.continuous?.getCoords()??null,this._options,this._iconGutter())}return r===null||r.leftIndex===0&&r.rightIndex===0&&r.colSpan<=1?(this._to=null,null):(this._to=r,r)}getRenderHorizontalAlignment(){return fN(this._layoutType(),this.getStyle())}isEmpty(){return this._v===null&&!this._ri}getExtrusions(){let e=this._ri;if(!e&&this._to===null)return null;if(e){let t=e.merge;if(t!==void 0)return t.getCoords()}let t=this.getTextOverflow();if(!t)return null;let n=this._coords;return{colStart:n.colIndex-t.leftIndex,rowStart:n.rowIndex,colEnd:n.colIndex+t.rightIndex,rowEnd:n.rowIndex}}isEditAllowed(){let e=this._options;if(!e||!e.getProtection().isLocked()||this.getStyle().getProtection().isAlwaysUnlocked())return!0;let t=this._ri?.unlock;if(t===void 0)return!1;if(Array.isArray(t)){for(let e=0;e<t.length;e++)if(t[e].isUnlocked())return!0;return!1}return t.isUnlocked()}isFormulaHidden(){let e=this._options?.getProtection();return!!e&&!!e.isLocked()&&!e.isShowFormulasAllowed()&&!this.getStyle().getProtection().isShowFormulas()}isContentful(){return this._v!==null}getBestFit(e,t=!1){return e===void 0&&(e=this._options.sheet?.getColumnHeaders().getMetrics().getSpanSize(this._coords.colIndex)??64),_N(this._layoutType(),this.getStyle(),this._v,this._options,e,t,!1,this._iconGutter(),null,eN)}getInsets(){if(this._v===null)return this.getStyle().getInsets();let e=cN(this._layoutType(),this.getStyle()),t=this._iconGutter();return t===0?e:Object.freeze({...e,left:e.left+t})}_iconGutter(){let e=this.getConditionalDecorations().iconSet?uN(this.getStyle()):0,t=this._pivotLabel();return t&&(e+=dN(this._layoutType(),this.getStyle(),t)),e}_pivotLabel(){let e=this._ri?.pivot,t=this._coords;return e&&t?e._getLabelInsetAt(t.rowIndex,t.colIndex):null}getTextFrame(e){let t,n;if(e&&(n=this.getFormulaText({target:`display`})),t=n??this._v,t===null)return null;let r=this.getStyle();return n?iN(r,t,this._options):aN(this._t,r,t,this._options,e)}getTextPlacement(e,t){let n=this.getTextFrame(t),r=n??this.getStyle().createTextFrame(` `);if(!r)return null;if(!t&&n){let t=((e,t,n,r)=>{let i=t.getAlignment();if(!i.getStacked())return null;let a=i.getHorizontal();if(a===R.HorizontalAlignment.Fill||a===R.HorizontalAlignment.CenterContinuous)return null;let o=cN(e,t),s={x:o.left,y:o.top,width:Math.max(0,r.width-o.left-o.right),height:Math.max(0,r.height-o.top-o.bottom)},c=n.layout({width:1e9}),l=c.lines[0]?.bounds.height??c.bounds.height,u=n.wrapped&&l>0?Math.max(1,Math.floor(s.height/l)):2**53-1;return{layout:In(Nn(yN(n),n.wrapped,u),l,s,fN(e,t),i.getVertical()),frame:c,lineHeight:l,content:s}})(this._layoutType(),this.getStyle(),n,e);if(t)return{content:Object.freeze(t.content),frame:t.frame,bounds:Object.freeze({...t.layout.bounds}),lineHeight:t.lineHeight,stacked:t.layout};let r=vN(this._layoutType(),this.getStyle(),n,e);if(r)return{content:Object.freeze(r.content),frame:r.frame,bounds:Object.freeze({...r.layout.bounds}),lineHeight:r.lineHeight,rotation:r.layout}}let i=this.getInsets(),a={x:i.left,y:i.top,width:Math.max(0,e.width-i.left-i.right),height:Math.max(0,e.height-i.top-i.bottom)},o=r.layout(r.wrapped?{width:a.width}:void 0),s=o.bounds,c=o.lines[0]?.bounds.height??s.height,l=o.lines,u=l[0],d=l[l.length-1],f=this.getStyle().getAlignment().getVertical(),p=a.y;if(u&&d){let{ascent:e,descent:t}=qM(this.getStyle(),u),n=u.bounds.y+u.baseline,r=d.bounds.y+d.baseline,i=a.y,o=a.y+a.height+1;if(f===R.VerticalAlignment.Bottom){let e=qM(this.getWorksheet().getStyles().getNormal(),u).descent;p=o-Math.max(t,e)-r}else if(f===R.VerticalAlignment.Top)p=i+1+e-n;else if(f===R.VerticalAlignment.Center){let a=r-n+e+t;p=i+Math.ceil((o-i-a)/2)+e-n}}let m=this.getRenderHorizontalAlignment(),h=a.x;return m===R.HorizontalAlignment.Center||m===R.HorizontalAlignment.CenterContinuous?h=a.x+(a.width-s.width)/2:m===R.HorizontalAlignment.Right&&(h=a.x+a.width-s.width),{content:Object.freeze(a),frame:o,bounds:Object.freeze({x:h,y:p,width:s.width,height:s.height}),lineHeight:c}}getFormula(){let e=this._ri?.formula;if(!e)return null;let t=this._coords;return t?new EA(t,e,this._options,()=>e.isCompiled()):null}getFormulaText(e){let t=this.getExpressionText(e);return t===null?null:`=`+t}getExpressionText(e){let t=this._ri?.formula;if(!t)return null;let n=e?.cell??this._coords;return n?t.getTextAt(n.rowIndex,n.colIndex,e?.r1c1,e?.evalIndex,e?.target):null}getCalculationStatus(){let e=this._ri;return e?e.calcStatus===SA.CalcStatus.Working?Q.ResultStatus.Pending:e.calcStatus===SA.CalcStatus.Waiting?Q.ResultStatus.Waiting:Q.ResultStatus.Ready:Q.ResultStatus.Ready}_dependencyRanges(e,t){let n=this._coords;if(!n)return Promise.resolve(null);let r=this._options.dependencyRanges;return r?r(h.cellToRange(n),e,t):Promise.resolve(null)}getDirectDependents(){return this._dependencyRanges(`dependents`,!0)}getDirectPrecedents(){return this._dependencyRanges(`precedents`,!0)}getDependents(){return this._dependencyRanges(`dependents`,!1)}getPrecedents(){return this._dependencyRanges(`precedents`,!1)}getValue(){return this._v}getType(){return this._t}_layoutType(){let e=this._t;return e===U.RichData?ku.layoutTypeOf(this._v):e}getInteropValue(){return this._getDate()??this._v}getInteropType(){return this._getDate()?H.Date:this._t}getStyle(e=!1){if(!e&&this._s)return this._s;if(e&&this._sd)return this._sd;let t=hN(this._v,h.cellToRange(this._coords),this._ri,this._options,e);return e?this._sd=t:this._s=t,t}createCell(t,n){if(t===null)return new e(this._options,this._coords);let r=this._r,i=n?.textParser,a=nN(r,t,i?{ignoreQuotePrefix:!1,...!0===i?{}:i}:null),o=this._ri,s=[];a.impliedStyle!==void 0&&s.push(a.impliedStyle),a.style!==void 0&&s.push(a.style);for(let e=0;e<s.length;e++){let t=this._coords??h.EmptyCell,n=h.cellToRange(t),r=this._options,i=o,a=Xm(s[e],()=>hN(this._v,n,i,r,!0)),c=(Am.compose(i?.borderStyle,i?.fillStyle,i?.contentStyle)??new Am(r.styles,null,n)).cloneWithUpdate(a),l=c.splitByFeature();o={...o,borderStyle:l.border??void 0,fillStyle:l.fill??void 0,contentStyle:l.content??void 0};let u=Cm(r.styles,c._p);u&&(nt(u)||pt(u))?o.dateFormat=u:o.dateFormat&&delete o.dateFormat}a.comments!==void 0&&(o={...o,comments:void 0});let c=this._t,l=this._v;return a&&a.value!==void 0&&(l=a.value,c=a.type),l===this._v&&c===this._t&&o===this._ri?this:l!==null||o?new wN(this._options,this._coords,c,l,o):new wN(this._options,this._coords)}_withProjectedMerge(e){let t=this._v;return new wN(this._options,this._coords,this._t,t,{...this._ri,merge:new CA(e,()=>t)})}getNumberFormat(e){let t=this._r,n=this._options,r=this._v;if(e!==void 0){let i=Ge(e);return kv(t,r,this.getStyle(),this._t,typeof i==`number`&&i!==0?i:e,e=>n.styles?.parseColor(e))}let i=this.getStyle();return kv(t,r,i,this._t,i.getNumberFormatRef(),e=>n.styles.parseColor(e))}getDate(){return this._getDate()}getFormattedValue(){return this.getText()}getText(e){let t;if(e?.showFormulas)return this.isSpillOverflow()?``:this.getFormulaText({target:`display`})||jv(this._v,this._t);if(e&&e.useFormattingCategory){let e=this._v;return this.isSpillOverflow()&&(e=null),t=function(e,t,n,r,a){if(n===U.Null||t==null)return``;if(n===U.RichData){let e=ku.toPrimitive(t);e!==void 0&&(n=ku.primitiveTypeOf(t),t=e)}if(n===U.Number){let n=ve(),o=t,s=n.isDateFormat(r),c=n.isTimeFormat(r);if(s||c){let n=parseFloat(t),r=n%1!=0,l=n>=1;if(n<0)return i.castToString(t);if(!s||c||r){if(!c||s||l){let t=qe(e,`Short Date`,o,a),n=qe(e,`Long Time`,o,a);if(t&&n)return t.fmt+` `+n.fmt}else{let t=qe(e,`Long Time`,o,a);if(t)return t.fmt}}else{let t=qe(e,`Short Date`,o,a);if(t)return t.fmt}}}if(n===U.Number&&Ye(r).endsWith(`%`)){let e=i.roundAccurately(100*parseFloat(t),14);if(!isNaN(e))return Av(e)+`%`}if(n===U.Boolean)return ml(t);if(n===U.Error){let e=t;return typeof e?.getLabel==`function`?hl(e):V.Label.Unknown}return n===U.RichData?ku.toPlaceholderText(t):n===U.Number?Av(t):i.castToString(t)}(this._r,e,this._t,this.getStyle().getNumberFormat()),t}t=this.getNumberFormat().displayText,this._t!==U.String&&(t=t.replaceAll(`\xA0`,` `));let n=this._t;return e?.hideStringPrefix||n!==U.String||(t=`'${t}`),t}getComments(){return this._ri?.comments??null}isErrorIgnored(e){return this._ri?.ignoredErrors?.includes(e)??!1}getAnomalies(){let e=this._coords;return e&&this._options.getAnomalies?this._options.getAnomalies(e):[]}getRole(){let e=this._coords;return e&&this._options.getRole?this._options.getRole(e):null}getHyperlink(){let e=this._ri?.hyperlink,t=()=>this.getText(xN);if(!e){let e=this._v,n=e instanceof Su?e.getAddress():null;return n?new Uh(t,this._options.opener,{address:n},void 0,!0):null}return new Uh(t,this._options.opener,e,e=>{this.getRange().setHyperlink(null,e)})}getStoredHyperlink(){return this._ri?.hyperlink??null}getRichText(){let e=this._v;if(!(e instanceof yu&&e.isFormatted()))return null;let t=function(e){let t={family:e.getThemeFamily()??e.getFamily(),size:e.getSize(),weight:e.getWeight(),style:e.getItalic()?I.Style.Italic:I.Style.Normal,underline:e.getUnderline(),strike:e.getStrike(),baseline:e.getBaseline(),color:String(e.getColor())},n=e.getFallbacks();return n?.length&&(t.fallbacks=[...n]),t}(this.getStyle().getFont()),n=e.getRuns(),r=Array(n.length);for(let e=0;e<n.length;e++){let i=n[e],a=i.font?{...t,...i.font}:{...t};r[e]={text:i.text,font:a}}return{runs:r}}getErrors(){let e=this._ri;if(e&&e.calcError)return[e.calcError];if(this._t===U.Error)return[this._v];let t=e?.circular;return t&&!t.cycle.isIterative()?[QM(t,this.getWorksheet().getName(),this.getCoords())]:i.EmptyArray}getCircularReference(){return this._ri?.circular?.cycle??null}getWarnings(){let e=this._ri?.circular;return e?[QM(e,this.getWorksheet().getName(),this.getCoords())]:i.EmptyArray}getSpans(){let e=this._ri?.merge;if(!e)return ZM;let t=e.getCoords();return Object.freeze({width:t.colEnd-t.colStart+1,height:t.rowEnd-t.rowStart+1})}isTopLeft(){let e=this._ri?.merge;if(!e)return!0;let t=e.getCoords();return this._coords&&this._coords.colIndex===t.colStart&&this._coords.rowIndex===t.rowStart}getSpill(){let e=this._getSpillEntry();return e?this._options.getRange(e.getCoords()):null}getSpillKind(){return this._getSpillEntry()?.getKind()??null}_getSpillEntry(){let e=this._coords;if(!e)return null;let t=this._ri?.spills;if(t)return Array.isArray(t)?t[0]:t;let n=this._options.getCalcGrid?.()?.getBlockedSpills().search(h.cellToRange(e),!1,!0);if(!n||n.length===0)return null;for(let t=0;t<n.length;t++){let r=n[t];if(r.rowStart===e.rowIndex&&r.colStart===e.colIndex)return r.value}return n[0].value}isSpillOverflow(){let e=this._ri?.spills;if(!e)return!1;let t=this._coords;return t?gN(e,t):null}get[Symbol.toStringTag](){return`[Cell]`}toString(){let e=`{blank}`;return this._v!==null&&(e=this.getText(EN),this.getType()===U.String&&(e=`'${e}'`)),`${this.getAddress()} => ${e}`}get isICell(){return!0}},CN=class extends SN{constructor(e){super(e,null,null,null)}isEmpty(){return!0}isContentful(){return!1}toString(){return`{EMPTY CELL}`}},wN=class extends SN{getAddress(e){return`{TEMPORARY CELL}`+(this._coords?`: ${super.getAddress(e)}`:``)}},TN={colIndex:-1,rowIndex:-1},EN={useFormattingCategory:!0},DN=Object.freeze({}),ON=e=>{let t=e?.style;return t?L.BuiltInDefinitions.get(t)?.width??0:0};function kN(e,t,n,r,i,a){let o=e.getPropertiesAt(t,r,void 0)?.borders,s=n===t?o:e.getPropertiesAt(n,r,void 0)?.borders;if(!o&&!s)return;let c=(e,t,n)=>{let r=Math.max(e,i.rowStart),o=Math.min(t,i.rowEnd);r<=o&&a.push({address:{min:r,max:o},edge:n})},l=ON(o?.top);l>=3&&c(t,t,`top`),l>=2&&c(t-1,t-1,`bottom`);let u=ON(s?.bottom);if(u>=2&&c(n,n,`bottom`),u>=3&&c(n+1,n+1,`top`),n>t){let e=ON(o?.bottom);e>=2&&c(t,n-1,`bottom`),e>=3&&c(t+1,n,`top`)}}var AN={colStart:0,rowStart:0,colEnd:0,rowEnd:0},jN={colStart:0,rowStart:0,colEnd:0,rowEnd:0},MN={colStart:0,rowStart:0,colEnd:0,rowEnd:0},NN={size:null,autoSize:!0},PN=(e,t)=>e.sizeSet-t.sizeSet;function FN(e,t){let n=e.getMetrics().getSpanSize(t);if(n>0||!e.getMetrics().hasHidden())return n;let r=e.at(t).getSize();return r>0?r:e.getMetrics().getDefaultSize()}var IN={colStart:0,rowStart:0,colEnd:0,rowEnd:0};function LN(e,t,n){let r=e._colHeaders;if(!r.getMetrics().hasHidden())return n>1?r.getMetrics().getSpanSize(t,t+n):r.getMetrics().getSpanSize(t);let i=0;for(let e=t;e<t+n;e++)i+=FN(r,e);return i}function RN(e,t,n){if(e>t)return null;let r=[],i=e,a=n?n.length:0;for(let e=0;e<a;e++){let t=n[e],a=t.min,o=t.max;if(i>=a){i=o+1;continue}let s={address:{min:i,max:a-1},update:NN};r.push(s),i=o+1}if(i<=t){let e={address:{min:i,max:t},update:NN};r.push(e)}return r}function zN(e,t,n){let r={colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colEnd,rowEnd:n.rowEnd},{isShrinkToFitRow:i,isShrinkToFitColumn:a}=t;if(t.within||!i&&!a)return r;let o=e._getUsedCoords();return o&&(i&&(r.colStart=o.colStart,r.colEnd=o.colEnd),a&&(r.rowStart=o.rowStart,r.rowEnd=o.rowEnd)),r}function BN(e,t=!1){return{searchTypes:{...t?{[G.Type.BorderStyle]:!1}:null,[G.Type.ContentStyle]:!1,[G.Type.Merge]:!1,[G.Type.Continuous]:!1,[G.Type.DateFormat]:!1,[G.Type.Contentful]:!1},ignoreHidden:!1,bounds:{colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colEnd,rowEnd:e.rowEnd},axis:B.Axis.Column}}function VN(e){let t=typeof e==`string`?$e[e]:void 0,n=String(Ye(t??e)).replaceAll(/\[[^\]]*\]/g,``).replaceAll(/"[^"]*"/g,``).replaceAll(/\\./g,``).replace(/[_*]./g,``).toLowerCase(),r=/am\/pm|a\/p/.test(n);r&&(n=n.replaceAll(/am\/pm|a\/p/g,``));let i=n.match(/y+|m+|d+|h+|s+/g);if(i===null)return null;let a=!1,o=!1,s=!1,c=!1,l=!1,u=i.length;for(let e=0;e<u;e++){let t=i[e],n=t[0];if(n===`m`){if(t.length>=3)return`names`;e>0&&i[e-1][0]===`h`||e<u-1&&i[e+1][0]===`s`?t.length===1&&(c=!0):t.length===1&&(a=!0)}else if(n===`d`){if(t.length>=3)return`names`;t.length===1&&(o=!0)}else n===`h`?t.length===1&&(s=!0):n===`s`&&t.length===1&&(l=!0)}return{monthVar:a,dayVar:o,hourVar:s,minuteVar:c,secondVar:l,clock12:r,maxScore:+!!a+ +!!o+ +!!s+ +!!c+ +!!l}}var HN={year:0,month:0,day:0,hour:0,minute:0,second:0,millis:0,dow:0,serial:0};function UN(e,t,n){let{host:r,cellOptions:i,normalStyle:a,isFormulaView:o}=e,s=[],c=()=>({col:-1,fit:!1,style:a,formula:null,key:``,spanWidth:1,spanHeight:1,colSpan:1,minVal:2**53-1,maxVal:-(2**53-1),hasZero:!1,proxyVal:null,proxyLen:-1,proxyScore:-1,text:``,errorText:``,hasTrue:!1,hasFalse:!1,hasEmpty:!1,minRow:2**53-1,maxRow:-(2**53-1),maxContentRow:-(2**53-1),rowRuns:[],iconGutter:0,lastRow:-1}),l=(e,t,n,r,i,a,o,s,c,l,u)=>{e.col=t,e.fit=a,e.style=r,e.formula=o,e.key=i,e.spanWidth=s,e.spanHeight=c,e.colSpan=l,e.iconGutter=u,e.minVal=2**53-1,e.maxVal=-(2**53-1),e.hasZero=!1,e.proxyVal=null,e.proxyLen=-1,e.proxyScore=-1,e.text=``,e.errorText=``,e.hasTrue=!1,e.hasFalse=!1,e.hasEmpty=!1,e.minRow=n,e.maxRow=n,e.maxContentRow=n,e.rowRuns=[n,n],e.lastRow=n},u=e=>{s.push({col:e.col,style:e.style,spanWidth:e.spanWidth,spanHeight:e.spanHeight,minVal:e.minVal,maxVal:e.maxVal,hasZero:e.hasZero,proxyVal:e.proxyVal,text:e.text,errorText:e.errorText,hasFalse:e.hasFalse,hasTrue:e.hasTrue,hasEmpty:e.hasEmpty,minRow:e.minRow,maxRow:e.maxRow,maxContentRow:e.maxContentRow,rowRuns:e.rowRuns,colWidth:LN(r,e.col,e.colSpan),colSpan:e.colSpan,iconGutter:e.iconGutter,measureWidth:-1,measureHeight:-1,isFit:e.fit,formula:e.formula}),e.col=-1},d=new Map,f=()=>{for(let e of d.values())e.col!==-1&&u(e)},p=null,m=-1,g=-1,_={[G.Type.Merge]:!1,[G.Type.Table]:!1,[G.Type.AutoTable]:!1,[G.Type.Pivot]:!1,[G.Type.ContentStyle]:!1,[G.Type.Continuous]:!1,[G.Type.DateFormat]:!1};o&&(_[G.Type.Formula]=!1,_[G.Type.Spills]=!1);let v=function(e,t){let n=e._getState().conditionalFormats;if(!n||n.isEmpty())return!1;let r=n.search({rowStart:t.rowStart,colStart:t.colStart,rowEnd:t.rowEnd,colEnd:t.colEnd});for(let e=0;e<r.length;e++)if(r[e].value?.getScale()?.type===CD.ScaleType.IconSet)return!0;return!1}(r,n);v&&(_[G.Type.Conditionals]=!1);let y=ve(),b=i.runtime,x=b?.isDate1904()??!1,S={date1904:x,locale:b?.getLocale()??void 0},C=new Map,w=new Map,T=r._cellStateIterator({...BN(n),searchTypes:_,ignoreEmptyIntersections:!0}),E,D,O=T.next(),k=``,A=new Map,j=new WeakMap,M,N=0,ee=`General`,te=!1,P=null,F=null,ne=1,re=1;for(;!O.done;){let n=O.value,s=n[0],_=n[1],b=n[2],ie=a,ae=b?.contentStyle??b?.table?.getStyle()??null,oe=b?.pivot,se=oe?oe._getCellLayer().getPropertiesAt(s.rowIndex,s.colIndex,_):null;if(se===null&&ae===E)ie=D;else{E=se===null?ae:DN;let t=``;if(ae&&(t=ae.getMeasureKey?.(),t===void 0)){let e=j.get(ae);e===void 0&&(e=`!`+ ++N,j.set(ae,e)),t=e}se!==null&&(t+=`|pivot`+JSON.stringify(se));let n=A.get(t);if(n===void 0){let r=ae||se!==null?hN(_,h.cellToRange(s,MN),b,i,!1):a,c=r.getNumberFormat(),l=r.getAlignment(),u=l.getVertical(),d=e.isRow&&(l.getOverflow()===R.Overflow.Wrap||u===R.VerticalAlignment.Justify||u===R.VerticalAlignment.Distributed||l.getStacked()||En(l.getRotation())),f=null,p=null;if(!o&&(y.isDateFormat(c)||y.isTimeFormat(c))){let e=C.get(c);if(e===void 0&&(e=VN(c),C.set(c,e)),e===`names`){let e=w.get(c);e===void 0&&(e=new Map,w.set(c,e)),f=e}else p=e}n={style:r,numFmt:c,perCellText:d,lengthCache:f,plan:p},A.set(t,n)}ie=D=n.style,k=t,ee=n.numFmt,te=n.perCellText,P=n.lengthCache,F=n.plan}let ce=1,le=1,ue=b?.merge??null;if(ue===M)ce=ne,le=re;else{if(ue){let e=ue.getCoords();ce=e.colEnd-e.colStart+1,le=e.rowEnd-e.rowStart+1}else ce=1,le=1;ne=ce,re=le}let de=s.colIndex,fe=s.rowIndex,pe=pB(_),me=h.isCellWithinRange(s,t),he=b?.continuous??null,I=he?he.getCoords().colEnd-de+1:1,ge=_ instanceof V.Parse,_e=b?.formula??null;_e||!ge||o||(IN.colStart=IN.colEnd=de,IN.rowStart=IN.rowEnd=fe,_e=r._calcGrid.getFormulas().search(IN)[0]?.value??null);let ve=_e&&(o||ge)?_e:null,ye=pe===U.RichData||le>1||ce>1||o&&gN(b?.spills,s);M=ue,de!==g&&(f(),g=de,m=-1,p=null);let be=m;if(m=fe,ye){p!==null&&p.col!==-1&&(p.maxRow=fe,p.rowRuns[p.rowRuns.length-1]=fe,p.lastRow=fe),O=T.next();continue}let xe=0;v&&b?.conditionals&&lN(b.conditionals,fe,de,_,()=>ie).iconSet&&(xe=uN(ie));let Se=oe?._getLabelInsetAt(fe,de);Se&&(xe+=dN(pe,ie,Se));let Ce=d.get(k);Ce===void 0&&(Ce=c(),d.set(k,Ce));let we=!1;if((Ce.col===-1||ce!==Ce.spanWidth||le!==Ce.spanHeight||I!==Ce.colSpan||(pe===U.String||pe===U.Error)&&te||ve!==Ce.formula||xe!==Ce.iconGutter||me!==Ce.fit)&&(Ce.col!==-1&&u(Ce),l(Ce,de,fe,ie,k,me,ve,ce,le,I,xe),we=!0),p=Ce,!we){let e=Ce.rowRuns;be<=Ce.lastRow?e[e.length-1]=fe:e.push(fe,fe),Ce.lastRow=fe,Ce.maxRow=fe}if(Ce.maxContentRow=fe,!ve){if(_===null)Ce.hasEmpty=!0;else switch(pe){case U.Number:if(_===0&&(Ce.hasZero=!0),Ce.minVal=Math.min(Ce.minVal,_),Ce.maxVal=Math.max(Ce.maxVal,_),F!==null){if(Ce.proxyScore<F.maxScore||Ce.proxyVal===null){let e=Te(_,x,HN);if(e!==null){let t=0;if(F.monthVar&&e.month>=10&&t++,F.dayVar&&e.day>=10&&t++,F.hourVar){let n=e.hour;(F.clock12?n%12==0?12:n%12:n)>=10&&t++}F.minuteVar&&e.minute>=10&&t++,F.secondVar&&e.second>=10&&t++,t>Ce.proxyScore&&(Ce.proxyScore=t,Ce.proxyVal=_)}}}else if(P!==null){let e=_,t=P.get(e);t===void 0&&(t=y.format(ee,e,S).text?.length??0,P.set(e,t)),t>Ce.proxyLen&&(Ce.proxyLen=t,Ce.proxyVal=e)}break;case U.String:{let e=_;e.length>Ce.text.length&&(Ce.text=e);break}case U.Error:{let e=hl(_);e.length>Ce.errorText.length&&(Ce.errorText=e);break}case U.Boolean:_?Ce.hasTrue=!0:Ce.hasFalse=!0}}O=T.next()}return f(),s}function WN(e,t,n){let{cellOptions:r,isRowAxis:i,minContent:a,mapCache:o,isFormulaView:s}=e,c=s?{formulaView:!0}:void 0,l={formulaView:s,formulaText:void 0},u=t.length;for(let e=0;e<u;e++){let s=t[e],u=s.col>=n.colStart&&s.col<=n.colEnd,d=i||!u,f=s.style,p=s.colWidth,m=(e,t,n)=>{let i=e===U.String||n?.formulaText!==void 0;return _N(e,f,t,r,p,a,d,s.iconGutter,null,i?o:void 0,n)},h=0,g=0,_=e=>{h=Math.max(h,e.width),g=Math.max(g,e.height)};if(s.formula){l.formulaText=`=`+s.formula.getTextAt(s.maxContentRow,s.col,!1,void 0,`display`);let e=m(U.String,null,l);s.measureWidth=e.width??0,s.measureHeight=e.height??0;continue}let v=s.maxVal;if(v!==-(2**53-1)){_(m(U.Number,v,c));let e=s.minVal;e!==v&&_(m(U.Number,e,c)),s.hasZero&&e!==0&&v!==0&&_(m(U.Number,0,c));let t=s.proxyVal;t!==null&&t!==e&&t!==v&&_(m(U.Number,t,c))}let y=s.text;y.length>0&&_(m(U.String,y,c));let b=s.errorText;b.length>0&&(l.formulaText=b,_(m(U.Error,null,l))),s.hasFalse&&_(m(U.Boolean,!1,c)),s.hasTrue&&_(m(U.Boolean,!0,c)),s.hasEmpty&&_(m(U.Boolean,null,c)),s.measureWidth=h,s.measureHeight=g}}function GN(e,t,n,r){return e===R.Overflow.Wrap||t===R.VerticalAlignment.Justify||t===R.VerticalAlignment.Distributed||!0===r||n!==void 0&&n!==0&&En(n)}function KN(e,t){let n=e.normalStyle.getAlignment();if(GN(n.getOverflow(),n.getVertical(),n.getRotation(),n.getStacked()))return!0;let r=e.host._getState();for(let e=0;e<t.length;e++){let n=t[e];if(r.tables.has(n)||r.pivotTables.has(n))return!0;let i=r.contentSpatial.search(n);for(let e=0;e<i.length;e++){let t=i[e].value?._p;if(!t)continue;if(t.named&&t.named!==z.BuiltInName.Normal&&!t.alignment)return!0;let n=t.alignment;if(n&&GN(n.overflow,n.vertical,n.rotation,n.stacked))return!0}}return!1}function qN(e,t,n){let r=[],i=[],a=[];if(function(e,t,n,r,i,a){let{host:o,cellOptions:s,isRow:c,isColumn:l}=e,u=new Map,d=c?{...n,rowStart:Math.max(n.rowStart-1,0),rowEnd:Math.min(n.rowEnd+1,o._getEntireCoords().rowEnd)}:n,f=o._rangeStateIterator(BN(d,c)),p=f.next();for(;!p.done;){let e=p.value,o=e.intersection,d=e.start,m=e.end;if(c&&o.borderStyle&&kN(o.borderStyle,d.rowIndex,m.rowIndex,d.colIndex,t,a),m.rowIndex<n.rowStart||d.rowIndex>n.rowEnd){p=f.next();continue}jN.colStart=d.colIndex,jN.rowStart=d.rowIndex,jN.colEnd=m.colIndex,jN.rowEnd=m.rowIndex;let g=h.intersectRanges(jN,t,AN),_;if(!o.table){let e=o.contentStyle;_=e?e.getMeasureKey?.():``}let v=_===void 0?void 0:u.get(_);if(v===void 0&&(v=hN(void 0,g,o,s,!0).getBestFit(),_!==void 0&&u.set(_,v)),c){let e=Math.max(d.rowIndex,t.rowStart),n=Math.min(m.rowIndex,t.rowEnd);e<=n&&r.push({address:{min:e,max:n},sizeSet:v.height??-1})}if(l){let e=Math.max(d.colIndex,t.colStart),n=Math.min(m.colIndex,t.colEnd);e<=n&&i.push({address:{min:e,max:n},sizeSet:v.width??-1})}p=f.next()}}(e,t,n,r,i,a),function(e,t){return e.isRowAxis&&!KN(e,[t])}(e,n))return{segments:[],rowFloors:r,colFloors:i,rowMargins:a};let o=UN(e,t,function(e,t,n){if(n.colStart>=t.colStart&&n.colEnd<=t.colEnd)return n;let r=[];return n.colStart<t.colStart&&r.push({colStart:n.colStart,rowStart:n.rowStart,colEnd:t.colStart-1,rowEnd:n.rowEnd}),n.colEnd>t.colEnd&&r.push({colStart:t.colEnd+1,rowStart:n.rowStart,colEnd:n.colEnd,rowEnd:n.rowEnd}),KN(e,r)?n:{colStart:t.colStart,rowStart:n.rowStart,colEnd:t.colEnd,rowEnd:n.rowEnd}}(e,t,n));return WN(e,o,t),{segments:o,rowFloors:r,colFloors:i,rowMargins:a}}function JN(e,t){return t?.formulaView??e.getView()?.isShowFormulas()??!1}function YN(e,t){let n=null,r=e.length;for(let i=0;i<r;i++){let r=e[i],a=t(r.col,r.colSpan);a!==r.colWidth&&(r.colWidth=a,(n??=[]).push(r))}return n}function XN(e,t,n){let r=e.length;for(let i=0;i<r;i++){let r=e[i],a=r.col,o=e[i+1],s=r.measureWidth??0;for(;o&&o.col===a;)o.measureWidth&&(s=Math.max(o.measureWidth??0,s)),i++,r=e[i],o=e[i+1];a<t.colStart||a>t.colEnd||(s===0&&(s=null),n(a,s,r.spanWidth))}}function ZN(e,t,n){let r=e.length;for(let i=0;i<r;i++){let r=e[i],a=r.measureHeight??0;a===0&&(a=null);let o=r.rowRuns,s=o.length;for(let e=0;e<s;e+=2){let i=Math.max(o[e],t.rowStart),s=Math.min(o[e+1],t.rowEnd);i>s||n(i,s,a,r.spanHeight)}}}function QN(e,t,n,r,i){let{isShrinkToFitColumn:a,updateHeaderOptions:o}=t,s=i.length,c=Array(s);for(let e=0;e<s;e++){let n=i[e];c[e]={address:n.address,update:{size:t.clampWidth(n.sizeSet===-1?void 0:n.sizeSet),autoSize:!0},sizeSet:n.sizeSet}}XN(r,n,(e,n,r)=>{let i=t.clampWidth(n,r);c.push({address:{min:e,max:e},update:{size:i,autoSize:!0},sizeSet:n===null?-1:n})}),c.sort(PN);let l=e._colHeaders.updateHeaderPairs(c,o);if(a){l=ao(oo(so(l)));let t=RN(n.colStart,n.colEnd,l);t&&e._colHeaders.updateHeaderPairs(t,o)}}function $N(e,t,n,r,a,o){let{isShrinkToFitRow:s,updateHeaderOptions:c}=t,l=2**53-1,u=-1,d=a.length;for(let e=0;e<d;e++){let t=a[e].address;t.min<l&&(l=t.min),t.max>u&&(u=t.max)}ZN(r,n,(e,t)=>{e<l&&(l=e),t>u&&(u=t)});let f=o.length;for(let e=0;e<f;e++){let t=o[e].address;t.min<l&&(l=t.min),t.max>u&&(u=t.max)}let p=[],m=[];if(u>=l){let s=u-l+1,h=new Float64Array(s).fill(-3),g=(e,t,n)=>{for(let r=e-l,i=t-l;r<=i;r++)n>h[r]&&(h[r]=n)};for(let e=0;e<d;e++){let t=a[e];g(t.address.min,t.address.max,t.sizeSet===0?-2:t.sizeSet)}ZN(r,n,(e,t,n,r)=>{g(e,t,r>1?-2:n??-1)});let _=e._rowHeaders,v=_.getMetrics().getScaleFactor(),y=_.getMetrics().getDefaultSize(),b=new Float64Array(s).fill(y),x=new Uint8Array(s),S=_._getState().headers;for(let e=i.findEqualOrGreater(S,l,e=>e.max);e<S.length&&S[e].min<=u;e++){let t=S[e],n=t.value;if(!n)continue;let r=n.sz===void 0?y:n.sz*v,i=+!!n.csz|(n.h?2:0);for(let e=Math.max(t.min,l)-l,n=Math.min(t.max,u)-l;e<=n;e++)b[e]=r,x[e]=i}if(f>0){let e=new Uint8Array(s);for(let t=0;t<f;t++){let n=o[t],r=n.edge===`top`?1:2;for(let t=n.address.min-l,i=n.address.max-l;t<=i;t++)e[t]|=r}let t=.75*v;for(let n=0;n<f;n++){let r=o[n];for(let n=r.address.min-l,i=r.address.max-l;n<=i;n++){let r=e[n];if(r===0)continue;e[n]=0;let i=h[n];h[n]=(i>=0?Math.max(i,y):y)+((1&r)+(r>>1))*t}}}let C=!0===c.skipCustomSize,w=-1,T=-3,E=e=>{if(w===-1||T===-3)return;m.push({min:w+l,max:e-1+l});let n=T===-2?void 0:t.clampHeight(T===-1?null:T),r=-1,a=e=>{r!==-1&&(p.push({address:{min:r+l,max:e-1+l},update:{size:n,autoSize:!0},sizeSet:T}),r=-1)};for(let t=w;t<e;t++){let e;if(x[t]!==0)e=!C;else if(n===void 0)e=!1;else{let r=b[t];e=i.roundAccurately(n(r))!==i.roundAccurately(r)}e?r===-1&&(r=t):a(t)}a(e)};for(let e=0;e<s;e++){let t=h[e];t!==T&&(E(e),w=e,T=t)}E(s)}if(e._rowHeaders.updateHeaderPairs(p,c),s){let t=ao(oo(so(m))),r=RN(n.rowStart,n.rowEnd,t);r&&e._rowHeaders.updateHeaderPairs(r,c)}}function eP(e,t,n){let r=e;if(r._closed)throw Error(N(`error.sheet.modelClosed`));let i;n={expandOnly:!1,skipCustomSize:!1,minContent:!1,...n};let a=bz(t,r._getEntireCoords(),!0),o=yz(t,r._getEntireCoords(),!0);i=m(!a&&o?`op.autofitColumns`:!o&&a?`op.autofitRows`:o&&a?`op.autofitAll`:`op.autofit`);let s=n.axes!==B.AxisSelection.Row;r._colHeaders.isProtected()&&(s=!1);let c=n.axes!==B.AxisSelection.Column;if(r._rowHeaders.isProtected()&&(c=!1),!c&&!s)return;let l=s&&(!1===n.expandOnly||n.expandOnly===B.Axis.Row),u=c&&(!1===n.expandOnly||n.expandOnly===B.Axis.Column),d=n.minContent??!1;c&&r._protectionCheck(()=>[`formatRows`],t,i),s&&r._protectionCheck(()=>[`formatColumns`],t,i);let f=SD(t),p=r._beginCommit({description:n.description??i}),g=r._isAdjustHeaders;r._isAdjustHeaders=!0;try{let e=I.getDeviceScale(),i=r._defaultRowHeight()*e,a=r._defaultColWidth(),o={host:r,cellOptions:r._cellOptions,normalStyle:r._styles.getNormal(),isRow:c,isColumn:s,isRowAxis:n.axes===B.AxisSelection.Row,minContent:d,isFormulaView:JN(r,n),mapCache:new Map},m={isShrinkToFitRow:u,isShrinkToFitColumn:l,within:!0===n.within,updateHeaderOptions:{skipCustomSize:n.skipCustomSize},clampHeight:(e,t=1)=>{if(e===0||t>1)return;let n=Math.max(e??0,i);return u?()=>n:e=>Math.max(e??0,n)},clampWidth:(e,t=1)=>{if(!(e===0||t>1))return l?()=>e:t=>Math.max(t??0,e??a)}},_=Sc(t,1);_.sort(h.createRangeComparator(B.Axis.Column));let v=_.length,y=tP(r,_,c,s);for(let e=0;e<v;e++){let t=_[e],{segments:n,rowFloors:i,colFloors:a,rowMargins:l}=qN(o,t,zN(r,m,t));if(s&&QN(r,m,t,n,a),c){let e=s?YN(n,(e,t)=>LN(r,e,t)):null;e&&WN(o,e,t),$N(r,m,t,n,i,l)}}r._isAdjustHeaders=g,r._processLayoutChange(),tP(r,_,c,s)!==y&&r._recordChange(p,`layout`,t),r._commitWithDirectives(p,n?.autoSelect?f:null,n)}catch(e){throw r._isAdjustHeaders=g,p.rollback(),e}}function tP(e,t,n,r){let i=[],a=(e,t,n,r)=>{i.push(r),e.getRange({min:t,max:n}).forEachSpan((e,t)=>{let n=t.getCoords();i.push(`${n.min}-${n.max}:${e}`)},{includeSizes:!0})},o=t.length;for(let i=0;i<o;i++){let o=t[i];n&&a(e._rowHeaders,o.rowStart,o.rowEnd,`r`),r&&a(e._colHeaders,o.colStart,o.colEnd,`c`)}return i.join(`,`)}function nP(e,t,n){let r=e.get(t);(r===void 0||n>r)&&e.set(t,n)}function rP(e,t){let n=e.length;for(let r=0;r<n;r++){let n=e[r],i=n.sizeSet;if(i<=0)continue;let a=n.address;for(let e=a.min;e<=a.max;e++)nP(t,e,i)}}function iP(e,t){return Math.max(e.getMinSize(),Math.min(i.roundAccurately(t),e.getMaxSize()))}function aP(e,t,n){let r=e.getMetrics().hasHidden(),i=new Map;for(let[a,o]of t)r&&e.getMetrics().getSpanSize(a)===0?i.set(a,0):i.set(a,iP(e,o>0?o:n));return i}function oP(e,t,n,r){let i=0,a=0;for(let e of r.values())i+=e,e>0&&a++;return i+(e.getMetrics().getVisibleCount(t,n)-a)*e.getMetrics().getDefaultSize()}var sP=class{constructor(e){this.isIAnchored=!0,this._deleted=!1,this._closed=!1,this._edits=[],this._nodeId=e.nodeId,this._options=e.listenerOptions,this._resolveRanges=e.resolveRanges,this._getContainerCoords=e.getContainerCoords}getNodeId(){return this._nodeId}getContainerCoords(){let e=this._getContainerCoords();return e&&e.length!==0?e:null}noteShift(e){if(!this._options.edits)return;let t=e.intersect,n=e.axis===s.Column?e.amount>0?B.Direction.Right:B.Direction.Left:e.amount>0?B.Direction.Down:B.Direction.Up;this._edits.push({type:`shift`,range:{rowStart:t.rowStart,colStart:t.colStart,rowEnd:t.rowEnd,colEnd:t.colEnd},direction:n})}noteMove(e,t,n){this._options.edits&&this._edits.push(n?{type:`move`,from:{...e},to:{...t},toSheet:n}:{type:`move`,from:{...e},to:{...t}})}hasEdits(){return this._edits.length>0}takeEdits(){let e=this._edits;return e.length>0&&(this._edits=[]),e}getListenerOptions(){return this._options}getRanges(){return this._resolveRanges(this.getContainerCoords())}isProtected(){return!1}addListeners(e,t){return()=>{}}delete(){this._deleted=!0}undelete(){this._deleted=!1}isDeleted(){return this._deleted}close(){this._closed=!0,this._deleted=!0}isClosed(){return this._closed}};(sP||={}).shiftReference=function(e,t,n=Ih.Type.TwoCell){let r=e.before;if(n===Ih.Type.Absolute)return{colStart:r.colStart,rowStart:r.rowStart,colEnd:r.colEnd,rowEnd:r.rowEnd};let i=e.intersect,a=e.axis===s.Column,o=a?r.colStart:r.rowStart,c=a?r.colEnd:r.rowEnd,l=a?i.colStart:i.rowStart,u=a?i.colEnd:i.rowEnd,d;if(n===Ih.Type.OneCell){let t=xO(o,o,l,e.amount,u),n=t?t[0]:o;d=[n,n+(c-o)]}else d=xO(o,c,l,e.amount,u);let f=a?t.colStart:t.rowStart,p=a?t.colEnd:t.rowEnd;return d===null||d[0]<f||d[1]>p?null:a?{...r,colStart:d[0],colEnd:d[1]}:{...r,rowStart:d[0],rowEnd:d[1]}};var cP=class extends sP{constructor(e){super(e),this._lastValues=null,this._lastBlank=null,this.host=e.host}deliver(e,t){if(!e.bounds&&!e.isFull)return;let n=this.getContainerCoords()?.[0]??null;if(!n)return;let r=t.onValues;if(!r)return void t.onChange?.();let i=this.host.getValueGrid(),a=this.host.getBlankRegion(),o=this._lastValues;if(o){let t=e.isFull?n:h.intersectRanges(n,e.bounds);if(!t||lP(a,this._lastBlank)&&!fP(i,o,t)&&!fP(o,i,t))return}this._lastValues=i.clone(),this._lastBlank=a;let s=this.host.getValues(n);if(s)try{r(s)}catch(e){console.warn(e)}}reconcile(){let e=this.host,t=this.getContainerCoords()?.[0]??null,n=e.getCoords();t?n&&!h.isEqualRanges(n,t)&&e.moveBody(t):n&&e.clear()}},lP=(e,t)=>e===t||!(!e||!t||(e.value??null)!==(t.value??null)||!!e.paged!=!!t.paged)&&dP(e.rects,t.rects)&&dP(e.evaluated??uP,t.evaluated??uP),uP=Object.freeze([]),dP=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!h.isEqualRanges(e[n],t[n]))return!1;return!0},fP=(e,t,n)=>{let r=e.getAxis()===B.Axis.Column,i=e.getRuns({bounds:n}),a=t.getRuns({bounds:n}),o=i.next(),s=a.next();for(;!o.done||!s.done;){let n;if(o.done)n=!1;else if(s.done)n=!0;else{let[e,t,r]=o.value,[c,l,u]=s.value;if(r===u&&e===c&&t===l){o=i.next(),s=a.next();continue}n=e<c||e===c&&t<=l}let[c,l,u]=n?o.value:s.value,d=n?t:e,f=u.length;for(let e=0;e<f;e++){let t=l+e,n=r?t:c,i=r?c:t;if((u.at(e)??null)!==(d.getValueAt(n,i)??null))return!0}n?o=i.next():s=a.next()}return!1},pP=`sheet.formulasEntered`,mP=`sheet.selection`,hP=`sheet.batchSelect`,gP=`sheet.autoFit`,_P=`sheet.skipProtectionCheck`,vP=`sheet.freezePanes`,yP=`sheet.shifts`,bP=`sheet.movableSelection`,xP=`sheet.autoFormat`,SP=new WeakMap,CP=(e,t,n)=>{if(e!==void 0&&SP.get(e)===n){let n=e;for(let e=0;e<t.length;e++)n.push(t[e]);return n}let r=e===void 0?[...t]:[...e,...t];return SP.set(r,n),r},wP=e=>{let t=e;for(;t.getDepth()>0;)if(t=t.getParent(),t.getOperation())return!0;return!1},TP=(e,t,n,r)=>{let i=e?.[mP];if(!i)return null;let a=e?.[hP]?.[t],o=r===`undo`,s=e=>(r===`forward`?e.options:e.restoreOptions)||a||!1,c=null,l=i.length;for(let e=0;e<l;e++){let n=i[o?e:l-1-e];if(n.sheetId===t&&!n.nested&&s(n)){c=n;break}}return c&&c.viewId===n?{selection:(o?c.undo:void 0)??c.selection,options:s(c)}:null},EP=e=>{let t=e.getActive();if(!t)return e.getItems();let n=e.getItems().filter(e=>e!==t);return n.push(t),n},DP=(e,t,n,r,i)=>{let a=t.getView(),o=r?.autoSelect,s=r?.autoSelectRestore===void 0?!!o:r.autoSelectRestore,c={sheetId:t.getId(),viewId:a.getId(),selection:n.map(e=>e.getId()),add:typeof o==`object`&&!!o.addToSelection,undo:(i??EP(a.getMovableSelection())).map(e=>e.getId()),options:!!o,restoreOptions:s};e.setIntent(bP,e=>e?[...e,c]:[c])},OP=(e,t,n,r)=>{let i=e?.[bP];if(!i)return null;let a=i.filter(e=>e.sheetId===t&&(r===`forward`?e.options:e.restoreOptions));if(a.length===0)return null;if(r===`undo`)return a[0].viewId===n?a[0].undo:null;if(a[a.length-1].viewId!==n)return null;let o=a[0].undo;for(let e=0;e<a.length;e++){let t=a[e];if(!t.add){o=t.selection;continue}let n=new Set(t.selection);o=[...o.filter(e=>!n.has(e)),...t.selection]}return o},kP=(e,t,n)=>{let r=n.map(({rowStart:e,colStart:t,rowEnd:n,colEnd:r})=>({rowStart:e,colStart:t,rowEnd:n,colEnd:r}));return e._snapshotAt(t.getId())?.getRanges(r)??null},AP=Object.freeze({commit:null}),jP=class e{constructor(e,t,n,r){this._sheet=e,this._kind=t,this._coords=n,this._details=r,this._ranges=void 0,this._previousRanges=void 0,this._shifts=void 0,this._merged=!1}getSheet(){return this._sheet}getKind(){return this._kind}getRanges(){return this._ranges===void 0&&(this._ranges=this._coords?this._sheet.getRanges(this._coords):null),this._ranges}getCommit(){return this._details.commit}isUndo(){return!0===this._details.isUndo}getPreviousCommit(){return this._details.previous??null}getPreviousRanges(){if(this._previousRanges===void 0){let e=this._details.previous,t=this._coords;this._previousRanges=null,e&&t&&!this._details.isStructural&&(this._previousRanges=kP(this._sheet,e,t))}return this._previousRanges}getShifts(){return this._shifts===void 0&&(this._shifts=(this._details.shifts??[]).map(e=>new MP(this._sheet,e,this._details.previous??null))),this._shifts}static merge(t,n){if(!(t instanceof e))return n??t;if(!(n instanceof e))return t;let r=t._merged?t:t._toMerged(),i=r._kind===n._kind?r._coords:null;if(i&&n._coords)for(let e=0;e<n._coords.length;e++)i.push(n._coords[e]);else r._coords=null;r._kind=n._kind;let a=r._details,o=n._details;return a.commit=o.commit??a.commit,a.previous=a.previous??o.previous??null,a.isUndo=o.isUndo,a.isStructural=a.isStructural||o.isStructural,o.shifts&&o.shifts.length>0&&a.shifts.push(...o.shifts),r}_toMerged(){let t=this._details,n=new e(this._sheet,this._kind,this._coords?[...this._coords]:null,{commit:t.commit,previous:t.previous??null,isUndo:t.isUndo,isStructural:t.isStructural,shifts:[...t.shifts??[]]});return n._merged=!0,n}},MP=class{constructor(e,t,n){this._sheet=e,this._shift=t,this._previous=n,this._ranges=void 0}getKind(){return this._shift.kind}getAxis(){return this._shift.axis}getRanges(){return this._ranges===void 0&&(this._ranges=this._shift.kind===`insert`?this._sheet.getRanges(this._shift.ranges):this._previous?kP(this._sheet,this._previous,this._shift.ranges):null),this._ranges}};ee({boundsToPoints:()=>IP,centerPoint:()=>FP,clipToOuterRect:()=>qP,minBoundingRect:()=>LP,rotatePoints:()=>RP,unionBounds:()=>PP});var NP=(e,t)=>{let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push({x:i.x+t.x,y:i.y+t.y})}return n};function PP(e,t){if(!e)return{...t};if(!t)return{...e};let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return{x:n,y:r,width:Math.max(e.width+e.x,t.width+t.x)-n,height:Math.max(e.height+e.y,t.height+t.y)-r}}function FP(e){return{x:e.width/2+e.x,y:e.height/2+e.y}}function IP(e){return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}]}function LP(e){let t=2**53-1,n=2**53-1,r=-(2**53-1),i=-(2**53-1);for(let a=0;a<e.length;a++){let o=e[a];t=Math.min(t,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x),i=Math.max(i,o.y)}return{x:t,y:n,width:r-t,height:i-n}}function RP(e,t,n){if(!n){let t=LP(e);n={x:t.x+t.width/2,y:t.y+t.height/2}}e=NP(e,{x:-n.x,y:-n.y});let r=t*Math.PI/180,i=Math.sin(r),a=Math.cos(r),o=[];for(let t=0;t<e.length;t++){let n=e[t],r=a*n.x-i*n.y,s=i*n.x+a*n.y;o.push({x:r,y:s})}return e=NP(o,{x:n.x,y:n.y})}var zP=0,BP=1,VP=2,HP=3;function UP(e,t,n=!0){return function(e,t,n,r,i,a,o,s,c=!0){if(e===n&&t===r||i===o&&a===s)return!1;let l=(s-a)*(n-e)-(o-i)*(r-t);if(l===0)return!1;let u=((o-i)*(t-a)-(s-a)*(e-i))/l,d=((n-e)*(t-a)-(r-t)*(e-i))/l;return(!c||!(u<0||u>1||d<0||d>1))&&{x:e+u*(n-e),y:t+u*(r-t)}}(e.p1.x,e.p1.y,e.p2.x,e.p2.y,t.p1.x,t.p1.y,t.p2.x,t.p2.y,n)}var WP=e=>({top:{p1:e[zP],p2:e[BP]},left:{p1:e[HP],p2:e[zP]},right:{p1:e[BP],p2:e[VP]},bottom:{p1:e[VP],p2:e[HP]}}),GP=(e,t,n)=>{let r=n*Math.PI/180,i=Math.sin(r),a=Math.cos(r);return{x:e*a-t*i,y:e*i+t*a}},KP=(e,t)=>{let n=e.p2.x-t.x,r=e.p2.y-t.y,i=GP(n,r,90);n=i.x+t.x,r=i.y+t.y;let a=e.p1.x-t.x,o=e.p1.y-t.y,s=GP(a,o,90);return a=s.x+t.x,o=s.y+t.y,{p1:{x:a,y:o},p2:{x:n,y:r}}};function qP(e,t,n=0){if(n<0&&(n+=360),n>90&&n<=180?n+=180:n>180&&n<=270&&(n-=180),n===0||n===180)return{height:t.height,width:t.width};if(n===90||n===270)return{height:t.width,width:t.height};let r=IP({...t,x:0,y:0}),i=IP({...e,x:0,y:0});i=NP(i,{x:t.width/2-e.width/2,y:t.height/2-e.height/2}),i=RP(i,n);let a=WP(i),o=WP(r);if(n>90){let e=UP(a.top,o.top);if(e){let t=e,n=UP(a.bottom,o.bottom,!1)||i[HP];i[zP]=UP(a.top,KP(a.bottom,n),!1)||i[zP],i[BP]=t,i[HP]=n,i[VP]=UP(a.bottom,KP(a.top,t),!1)||i[VP],a=WP(i)}let t=UP(a.top,o.left);if(t){let e=t,n=UP(a.bottom,o.right,!1)||i[VP];i[zP]=e,i[BP]=UP(a.top,KP(a.bottom,n),!1)||i[BP],i[HP]=UP(a.bottom,KP(a.top,e),!1)||i[HP],i[VP]=n}}else if(n<90){let e=UP(a.top,o.top);if(e){let t=e,n=UP(a.bottom,o.bottom,!1)||i[VP];i[zP]=t,i[BP]=UP(a.top,KP(a.bottom,n),!1)||i[BP],i[HP]=UP(a.bottom,KP(a.top,t),!1)||i[HP],i[VP]=n,a=WP(i)}let t=UP(a.top,o.right);if(t){let e=t,n=UP(a.bottom,o.left,!1)||i[HP];i[zP]=UP(a.top,KP(a.bottom,n),!1)||i[zP],i[BP]=e,i[HP]=n,i[VP]=UP(a.bottom,KP(a.top,e),!1)||i[VP]}}i=RP(i,-n);let s=LP(i);return{width:s.width,height:s.height}}var JP=class{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>`)}};function YP(t,n=` `){return new Promise((r,i)=>{e(()=>import(`./CnPgk3HcIziOcskY.js`).then(e=>te(e.default,1)),__vite__mapDeps([29,3]),import.meta.url).then(e=>{try{let i=e.parse(t,{delimiter:n}).data;i.length>1&&(i[i.length-1].length===0||i[i.length-1].length===1&&i[i.length-1][0].length===0)&&i.pop(),r(i)}catch(e){console.warn(e),i(e)}},e=>{i(e)})})}var XP=e=>{let t={};if(!e)return t;e.endsWith(`;`)||(e+=`;`);let n=RegExp(`;(?=([^"]*"[^"]*")*[^"]*$)`,`gsm`),r,i=0;for(;(r=n.exec(e))!==null;){try{let n=e.substring(i,r.index).trim(),a=RegExp(`:(?=([^"]*"[^"]*")*[^"]*$)`,`gsm`),o,s,c;for(;(c=a.exec(n))!==null;)o=unescape(n.substring(0,c.index)).trim(),s=unescape(n.substring(c.index+1,n.length)).trim();o!==void 0&&s!=null&&s!==`null`&&(o=an(o),t[o]=s)}catch(e){console.warn(e)}i=r.index+1}return t},ZP=(e,t)=>{let n=[];if(!e)return n;let r=e.children;for(let e=0;e<r.length;e++){let i=r.item(e);if(i.nodeType===1){let e=i.tagName.toUpperCase();t.includes(e)&&n.push(i)}}return n};function QP(e,t,n){try{let r=null,i=null,a=e=>((e,t)=>{if(!e)return{};let n={},r=t.get(e.localName);r&&(n=Object.assign(n,r));let i=e.getAttribute(`class`);if(i){let e=t.get(`.`+i);e&&(n=Object.assign(n,e))}let a=e.getAttribute(`style`);if(a){let e=XP(a);e&&(n=Object.assign(n,e))}return e.getAttribute(`align`)&&!n.textAlign&&(n.textAlign=e.getAttribute(`align`)),n})(e,i);if(e)try{r=[];let o=`P, H1, H2, H3, H4, H5, H6, PRE`,s=e.querySelector(`parsererror`);if(s)return console.warn(`error`,s),!1;let c=e.querySelectorAll(`html`),l=c[c.length-1];i=(e=>{let t=e.querySelectorAll(`style`),n=new Map;if(t.length<=0)return n;for(let e=0;e<t.length;e++){let r=t[e].childNodes;for(let e=0;e<r.length;e++)if(r[e].nodeType===Node.TEXT_NODE){let t=RegExp(`<!--(.*)-->`,`gs`),i=r[e].textContent,a=t.exec(r[e].textContent);if(a&&a.length>1&&(i=a[1]),i=i.replace(/^\s/,``),i?.startsWith(`table`)){let e=RegExp(`{(.*?)}`,`gs`),t,r=0;for(;(t=e.exec(i))!==null;)try{let e=i.substring(r,t.index),a=XP(t[1]);n.set(e.trim(),a),r=t.index+t[0].length}catch(e){console.warn(e)}return n}}}return n})(l);let u=l.querySelectorAll(`body`),d=u[u.length-1],f=d.querySelectorAll(`table`)[0],p=!1;if(!f){let e=d.querySelectorAll(`span`);f=e[0],p=e.length>1}if(f||=ZP(d,o)[0],f||=ZP(e,o)[0],f?.nodeName.toUpperCase()===`TABLE`){n.onStart?.(i);let e=f;n.onTableStart?.(a,e);let t=ZP(e,`COLGROUP`);for(let e=0;t&&e<t.length;e++){let r=ZP(t[e],`COL`),i=0;for(let e=0;e<r.length;e++){let t=r[e],o=parseFloat(t.getAttribute(`span`)),s=isNaN(o)?1:o;n.onColumn?.(i,s,a,t),i+=s}}let o=e.rows,s=0;for(let e=0;e<o.length;e++){let t=o[e],i=parseFloat(t.getAttribute(`span`)),c=isNaN(i)?1:i;n.onRowStart?.(s,c,a,t);let l=[];r.push(l);let u=t.cells;for(let e=0;e<u.length;e++){let t=u[e],n=!1;for(let e=0;!n&&e<t.childNodes.length;e++)if(t.childNodes[e].nodeType===8){let r=t.childNodes[e].textContent;if(r!==`[if gte vml 1]`&&r!==`[if !vml]`&&r===`[endif]`){let r=t.childNodes[e+1];r?.querySelectorAll&&r.querySelectorAll(`table, td`).length===2&&(t=r?.querySelectorAll(`table, td`)[1],n=!0)}}l.push({htmlValue:t.textContent?.replace(/^"|"$/gi,``),element:t})}s+=c,n.onRowDow?.(s,c,a,t)}n.onTableDone?.(a,e)}else{if(f?.nodeName.toUpperCase()===`SPAN`){let e=t?t[0]?.[0]:null,r=p&&e?e:f.textContent.replace(/^"|"$/gi,``);return n.onStart?.(i),n.onCell({colStart:0,colEnd:0,rowStart:0,rowEnd:0},t?t[0]?.[0]:null,r,e=>{let t=a(e);return delete t.backgroundColor,t},f),n.onDone?.(),!0}if(f?.textContent){let e=f.textContent.replace(/^"|"$/gi,``);return n.onStart?.(i),n.onNoTable?.(e,a,f),n.onDone?.(),!0}}}catch(e){console.warn(e),r=null}!r||r.length!==0&&(r.length!==1||r[0]!==null&&r[0].length!==0)||(r=null);let o=t&&(t.length===0||t.length===1&&(t[0]===null||t[0].length===0));r&&o&&(t=null);let s=e=>{let n=new Set,i=1,o=1;for(let s=0;s<Math.max(t?t.length:0,r?r.length:0);s++){let c=0,l=0,u=r&&r[s]?r[s].length:t&&t[s]?t[s].length:0;for(;l<u;){let u=s+`-`+c;if(!n.has(u)){i=Math.max(i,c+1),o=Math.max(o,s+1);let u=null,d=r?r[s]?.[l]?.element:void 0;if(d&&(d.getAttribute(`rowspan`)||d.getAttribute(`colspan`))){let e=parseInt(d.getAttribute(`colspan`))||1,t=parseInt(d.getAttribute(`rowspan`))||1;i=Math.max(i,c+e),o=Math.max(o,s+t),u={rowStart:s,colStart:c,rowEnd:s+Math.max(0,t-1),colEnd:c+Math.max(0,e-1)};for(let r=s;r<s+t;r++)for(let t=c;t<c+e;t++)r===s&&t===c||n.add(r+`-`+t)}else u={rowStart:s,colStart:c,rowEnd:s,colEnd:c};e(u,t?t[s]?.[c]:void 0,r?r[s]?.[l]?.htmlValue:null,a,d||null),l++}c++}}};if(r&&t){let e=0,n=0,r=t.length,i=0;for(let e=0;e<r;e++)i=Math.max(i,t[e]?.length??0);let a=!0;s((t,r,i,o,s)=>{s&&(e=Math.max(e,t.colEnd+1),n=Math.max(n,t.rowEnd+1)),!(r&&r.trim().length>0)||s&&i&&i.trim().length!==0||(a=!1)}),r===n&&i===e||r<=n&&i<=e&&a||(console.warn(`Clipboard text (${r}x${i}) does not align with its html (${n}x${e}); pasting from the html only.`),t=null)}return s(n.onCell.bind(n)),n.onDone?.(),!o||r!==null}catch(e){throw console.warn(e),e}}var $P=(e,t)=>{if(t){if(t.getType()===Ee.Type.Solid)e.background=at(t.getColor())||`none`,e[`mso-pattern`]=`black none`;else if(t.getType()===Ee.Type.Pattern){let n=t;e.background=at(n.getBackground())||`none`;let r=at(n.getForeground())||``;if(n.getPatternType()===Ee.BuiltInSheetPattern.Solid)e[`mso-pattern`]=`${e.background} none`,e.background=r;else{let t=lt(n.getPatternType());e[`mso-pattern`]=r+(t?` `:``)+t}}else if(t.getType()===Ee.Type.Gradient){let n=t;e.background=at(n.getStops()?.[0]?.getColor())||`auto`,e[`mso-pattern`]=`${e.background} none`,e.msoGradient=ut(n)||`auto`}}},eF=class{constructor(e,t){if(this._visitedStyles=new Map,this._lastStyleClassId=63,this._wroteTD=!1,!e)throw Error(`Can not create with a null sheet.`);this._sheet=e,this._includeSizeInCell=t?.includeSizeInCell??!1,this._textOptions=t?.showFormulas?nF:tF,this._normalStyle=e.getStyles().getNormal()}_createCSSStyle(e){let t=this._normalStyle,n={},r=(e,t)=>e===t||!(e&&!t)&&!(!e&&t)&&t.isEqual?.(e),i=e.getFont(),a=t.getFont();r(i.getColor(),a.getColor())||(n.color=at(i.getColor())),r(i.getSize(),a.getSize())||(n[`font-size`]=ue(i.getSize())),r(i.getWeight(),a.getWeight())||(n[`font-weight`]=i.getWeight()),i.getItalic()!==a.getItalic()&&(n[`font-style`]=i.getItalic()?I.Style.Italic:I.Style.Normal),r(i.getUnderline(),a.getUnderline())||(n[`text-decoration`]=`underline`,n[`text-underline-style`]=At(i.getUnderline())),r(i.getFamily(),a.getFamily())&&r(i.getFallbacks(),a.getFallbacks())||(n[`font-family`]=ft(i.getFamily(),i.getFallbacks())),r(e.getNumberFormat(),t.getNumberFormat())||(n[`mso-number-format`]=Et(e.getNumberFormat()));let o=e.getAlignment(),s=t.getAlignment();if(!r(o.getHorizontal(),s.getHorizontal())){let e=o.getHorizontal();n[`text-align`]=e===R.HorizontalAlignment.CenterContinuous?`center-across`:e===R.HorizontalAlignment.Fill?`fill`:e===R.HorizontalAlignment.Distributed?o.getJustifyLastLine()?`121`:`010`:R.toCSSHorizontalTextAlign(e)}if(!r(o.getVertical(),s.getVertical())){let e=o.getVertical();n[`vertical-align`]=e===R.VerticalAlignment.Distributed?`121`:Ct(e)}if(!r(o.getOverflow(),s.getOverflow())){let e=o.getOverflow();n[`white-space`]=dt(e),e===R.Overflow.Shrink&&(n[`mso-text-control`]=`shrinktofit`)}o.getStacked()&&!s.getStacked()?n[`layout-flow`]=`vertical`:o.getStacked()||r(o.getRotation(),s.getRotation())||(n[`mso-rotate`]=Ke(o.getRotation())),r(o.getIndent(),s.getIndent())||(n[`mso-char-indent-count`]=o.getIndent()),r(e.getFill(),t.getFill())||$P(n,e.getFill());let c=e.getBorders();return c.getTop().isNone()||(n[`border-top`]=wt(c.getTop())),c.getLeft().isNone()||(n[`border-left`]=wt(c.getLeft())),c.getRight().isNone()||(n[`border-right`]=wt(c.getRight())),c.getBottom().isNone()||(n[`border-bottom`]=wt(c.getBottom())),c.getDiagonalUp().isNone()||(n[`border-mso-diagonal-up`]=wt(c.getDiagonalUp())),c.getDiagonalDown().isNone()||(n[`border-mso-diagonal-down`]=wt(c.getDiagonalDown())),Object.keys(n).length===0?null:n}_createCSSNormalStyle(){let 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=at(n.getColor()),$P(t,e.getFill()),t[`font-size`]=ue(n.getSize()),t[`font-weight`]=n.getWeight(),t[`font-style`]=n.getItalic()?I.Style.Italic:I.Style.Normal,t[`text-decoration`]=Ve(n.getUnderline(),n.getStrike()),t[`font-family`]=ft(n.getFamily(),n.getFallbacks()),t[`mso-font-charset`]=`0`,t[`mso-background-source`]=`auto`,t[`mso-number-format`]=Et(e.getNumberFormat()),t[`text-align`]=R.toCSSHorizontalTextAlign(r.getHorizontal()),t[`vertical-align`]=Ct(r.getVertical()),t.border=`none`,t[`mso-pattern`]=`auto`,t[`white-space`]=dt(r.getOverflow()),r.getOverflow()===R.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=e.getSpans();if(r.width>1||r.height>1){if(!e.isTopLeft())return!1;r.height>1&&n.addAttribute(`rowspan`,r.height),r.width>1&&n.addAttribute(`colspan`,r.width)}let a=this._textOptions,o=e.getText(a),s=a.showFormulas?null:e.getNumberFormat().errorPlaceholder;s&&(o=s.repeat(5));let c=a.showFormulas||s?o:e.getText(rF);n.setPlainText(c||``);let l=e.getStyle(),u=l.getFont();if(u.getBaseline()>0&&(o=`<sup>${o}</sup>`),u.getBaseline()<0&&(o=`<sub>${o}</sub>`),u.getStrike()!==I.StrikeStyle.None&&(o=`<s>${o}</s>`),e.getHyperlink()&&(o=`<a href="${e.getHyperlink().getAddress()}">${o}</a>`),n.setHTMLText(o||` `),!this._wroteTD){let e=this._createCSSNormalStyle();n.addSharedStyle(`td`,e),this._wroteTD=!0}let d=this._visitedStyles.get(l);if(!d){let e=this._createCSSStyle(l);e&&(d=`xl`+ ++this._lastStyleClassId,this._visitedStyles.set(l,d),n.addSharedStyle(`.`+d,e))}if(d&&n.addAttribute(`class`,d),this._includeSizeInCell){let e=this._sheet.getColumnHeaders().at(t.colIndex).getSize();n.addAttribute(`width`,e),n.addStyle(`width`,i.roundAccurately(e/I.getDeviceScale(),2)+`pt`);let r=this._sheet.getRowHeaders().at(t.rowIndex).getSize();n.addAttribute(`height`,r),n.addStyle(`height`,i.roundAccurately(r/I.getDeviceScale(),2)+`pt`)}}onRow(e,t,n,r){let a=e.getSize();r.addAttribute(`height`,a),r.addStyle(`height`,i.roundAccurately(a/I.getDeviceScale(),2)+`pt`),e.isCustomSize()&&r.addStyle(`mso-height-source`,`userset`)}onColumn(e,t,n,r){let a=e.getSize();r.addAttribute(`width`,a),r.addStyle(`width`,i.roundAccurately(a/I.getDeviceScale(),2)+`pt`),e.isCustomSize()&&r.addStyle(`mso-width-source`,`userset`),n>1&&r.addAttribute(`colspan`,n)}},tF={useFormattingCategory:!0},nF={showFormulas:!0},rF={hideStringPrefix:!0};function iF(e,t,n,r=!1){let i=t.rowEnd-t.rowStart+1,a=t.colEnd-t.colStart+1,o=r?a:i,s=r?i:a,c=Math.max(1,Math.ceil((n.rowEnd-n.rowStart+1)/o)),l=Math.max(1,Math.ceil((n.colEnd-n.colStart+1)/s)),u=(e,t,n,r,i)=>{if(t-e+1===r)return[[n+e,n+(i-1)*r+t]];let a=[];for(let o=0;o<i;o++)a.push([n+o*r+e,n+o*r+t]);return a},d=[];for(let i=0;i<e.length;i++){let a=e[i],f=a.rowStart-t.rowStart,p=a.rowEnd-t.rowStart,m=a.colStart-t.colStart,g=a.colEnd-t.colStart,_=r?f:m,v=r?p:g,y=u(r?m:f,r?g:p,n.rowStart,o,c),b=u(_,v,n.colStart,s,l);for(let e=0;e<y.length;e++)for(let t=0;t<b.length;t++){let r={rowStart:y[e][0],rowEnd:y[e][1],colStart:b[t][0],colEnd:b[t][1]},i=h.intersectRanges(r,n);i&&d.push(i)}}return bm(h.EmptyRanges,d)}function aF(e,t,n){let r=null;for(let i=0;i<e.length;i++){let a=e[i].prepare?.(t,n);a&&typeof a.then==`function`&&(r??=[]).push(a)}if(r)return Promise.all(r).then(()=>{})}function oF(e,t,n){let r=e.getAxis()===B.Axis.Column,i=m(r?`copy.columnCopy`:`copy.rowCopy`),a=e.getSnapshot(n);return{...a,getName:()=>N(i),getCoords:()=>t,copyTo:(e,i)=>{let o=r?e.getColumnHeaders():e.getRowHeaders(),s={...n,...i};if(!0===s.includeHeaders&&!e.getWorksheet().getProtection().isLocked()){let e=a.copyTo(o,s);return r?{colStart:e.min,rowStart:t.rowStart,colEnd:e.max,rowEnd:t.rowEnd}:{colStart:t.colStart,rowStart:e.min,colEnd:t.colEnd,rowEnd:e.max}}},getMarkOptions:()=>n}}function sF(e,t,n,r,a,o){let s=n[0],c=e.getView()?.isShowFormulas()??!1,l,u,d=()=>{if(u!==void 0)return;let[e,n]=function(e,t){let n=t.getRowHeaders(),r=t.getColumnHeaders(),a=t.getUsedRange()?.getCoords(),o=n.getUsedRange()?.getCoords(),s=r.getUsedRange()?.getCoords(),c={...h.EmptyRange,...a,colEnd:Math.max(a?.colEnd??0,s?.max??0),rowEnd:Math.max(a?.rowEnd??0,o?.max??0)},l=new Map,u=[];e.onStart?.();let d={rows:[],cols:[]},f=new JP(l,u);f.setNode(d),e.onTable?.(f,c);let p=0;r.forEachSpan((t,n)=>{let r=n.getCoords();p=p+r.max-r.min+1;let i={};f.setNode(i),e.onColumn?.(n.getCellHeader(),r.min,r.max-r.min+1,f),d.cols.push(i)},{address:c,includeEmpty:!0});let m=0,g=[];if(n.forEachSpan((e,t)=>{let n=t.getCoords();m=m+n.max-n.min+1,g.push({min:n.min,max:n.max,value:t.getCellHeader()})},{address:c,includeEmpty:!0,visibility:`all`}),p*m>5e4)return[null,`The data you've selected is too large. Try selecting a smaller set of data.`];let _=0,v=-1,y=null;t.forEach((t,n)=>{let r=n.getCoords(),i=n.getCell();if(r.rowIndex!==v){r.rowIndex>g[_].max&&++_;let t=g[_];y={cells:[]},f.setNode(y),e.onRow?.(t.value,r.rowIndex,1,f),d.rows.push(y),v=r.rowIndex}let a={};f.setNode(a),!1!==e.onCell(i,r,f)&&y.cells.push(a)},{address:c,includeEmpty:!0,ignoreHidden:!1}),e.onDone?.(),d.rows.length===0&&d.rows.push({cells:[]});let b=[];for(let e=0;e<u.length;e++){let t=u[e],n=l.get(t);b.push(t);let r=``,i=Object.keys(n);for(let e=0;e<i.length;e++){r+=` `,e===0&&(r+=`{`);let t=i[e];r+=`${t}:${n[t]};`,e===i.length-1?r+=`}`:r+=`
|
|
558
|
-
`}b.push(r)}let x=[`<div clipboard-uuid=xxx>
|
|
559
|
-
<html
|
|
560
|
-
xmlns:v="urn:schemas-microsoft-com:vml"
|
|
561
|
-
xmlns:o="urn:schemas-microsoft-com:office:office"
|
|
562
|
-
xmlns:x="urn:schemas-microsoft-com:office:excel"
|
|
563
|
-
xmlns="http://www.w3.org/TR/REC-html40"
|
|
564
|
-
>`];x.push(`<head>
|
|
565
|
-
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
|
|
566
|
-
<meta name=ProgId content=Excel.Sheet>
|
|
567
|
-
<meta name=Generator content="Microsoft Excel 15">`),x.push(`<style>
|
|
568
|
-
table
|
|
569
|
-
{mso-displayed-decimal-separator:"\\.";
|
|
570
|
-
mso-displayed-thousand-separator:"\\,";}
|
|
571
|
-
@page
|
|
572
|
-
{margin:.75in .25in .75in .25in;
|
|
573
|
-
mso-header-margin:.3in;
|
|
574
|
-
mso-footer-margin:.3in;
|
|
575
|
-
mso-horizontal-page-align:center;}
|
|
576
|
-
tr
|
|
577
|
-
{mso-height-source:auto;}
|
|
578
|
-
col
|
|
579
|
-
{mso-width-source:auto;}
|
|
580
|
-
br
|
|
581
|
-
{mso-data-placement:same-cell;}`),b.length>0&&x.push(b.join(`
|
|
582
|
-
`)),x.push(`</style>`),x.push(`</head>`),x.push(`<body>`),x.push(`<table>`),x.push(`<!--StartFragment-->`);let S=e=>{let t=(e=>{let t=``;return e&&e.attributes&&e.attributes.length!==0&&e.attributes.forEach((e,n)=>{t.length>0&&(t+=` `),t+=`${n}=${e}`}),t})(e);t.length>0&&(t=` `+t);let n=(e=>{let t=``;return e&&e.styles&&e.styles.length!==0&&(e.styles.forEach((e,n)=>{t.length>0&&(t+=`;`),t+=n+`:`+e}),t.length>0&&(t=`style='${t}'`)),t})(e);return n.length>0&&(n=` `+n),`${t}${n}`},C=[];return d.cols?.forEach(e=>{x.push(` <col${S(e)}>`)}),d.rows.forEach(e=>{x.push(` <tr${S(e)}>`);let t=[];e.cells.forEach(e=>{x.push(` <td${S(e)}>${e.htmlText??e.plainText??``}</td>`);let n=`${i.castToString(e.plainText??``)?.replace(/"/g,`""`)}`;t.push(n)}),C.push(t.join(` `)),x.push(` </tr>`)}),x.push(`<!--EndFragment-->`),x.push(`</table>`),x.push(`</body>`),x.push(`</html>`),x.push(`</div>`),[x.join(`
|
|
583
|
-
`),C.join(`
|
|
584
|
-
`).concat(`
|
|
585
|
-
`)]}(new eF(t,{showFormulas:c}),t.getRange(s));l=e??null,u=n??null},f=!1;return{copyTo(e,t){let n={...a,...t};if(t?.isCut&&f)throw f=!0,Error(N(`error.sheet.snapshotDone`));return o(e,n)},getMarkOptions:()=>a,getSource:()=>e,getName:()=>N(r),getCoords:()=>s,toText:()=>(d(),u),toHtml:()=>(d(),l),toImage:()=>null,isISnapshot:!0}}var cF=class e{constructor(e,t,n,r,i){this._getColumnAt=void 0,this._index=e,this._sheetHeader=t,this._headerState=n,this._template=r,this._getColumnAt=i}getSize(){let e=this._headerState?.sz;return Math.round(e===void 0?this._sheetHeader.getMetrics().getDefaultSize():e*this._sheetHeader.getMetrics().getScaleFactor())}getText(){return``+this.asCell().getValue()}isBestFit(){return this._headerState?.bf??!1}getAxis(){return this._sheetHeader.getAxis()}isHidden(){return this._headerState?.h??!1}isCustomSize(){return this._headerState?.csz??!1}getSheetHeader(){return this._sheetHeader}getColumn(){return this._getColumnAt?.(this._index)??null}asCell(){return this._cellTemplate||=this._sheetHeader.getWorksheet().createCell(this._template),this._cellTemplate}getSizeRelative(){return this.getSize()/this._sheetHeader.getMetrics().getScaleFactor()}getOutlineLevel(){return this._headerState?.l??0}createCellHeader(t){let n=lF(this._sheetHeader,this._sheetHeader.getWorksheet().getStyles(),this._headerState,t);return new e(this._index,this._sheetHeader,n,this._template,this._getColumnAt)}isEqual(e){if(!e)return!1;if(e===this)return!0;let t=e;if(!t.isICellHeader)return!1;let 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.getOutlineLevel()===t.getOutlineLevel()&&(n?.cl??!1)===(r?.cl??!1)&&this.isBestFit()===t.isBestFit()}isEmpty(){let e=this._headerState;return!e||e.sz===void 0&&e.csz===void 0&&e.h===void 0&&e.l===void 0&&e.cl===void 0&&!e.bf}get[Symbol.toStringTag](){return`[SheetCellHeader]`}toString(){return`[SheetCellHeader: ${this.getText()}]`}get isICellHeader(){return!0}};function lF(e,t,n,r){if(r!==void 0){if(r===null)return null;if(r?.isICellHeader)return{...r._headerState};if(r){let a=r,o,s=a.hidden;n&&(o={...n});let c,l=a.size;if(a.size!==void 0){if(typeof l==`function`){let t=n?.sz===void 0?e.getMetrics().getDefaultSize():n?.sz*e.getMetrics().getScaleFactor();l=l?.(t)}if(typeof l==`string`&&(l=It(l,t.getNormal().getFont().getSize(),`px`)),typeof l==`number`){let t=e.getMinSize(),n=e.getMaxSize();l=Math.max(t,Math.min(i.roundAccurately(l),n)),!0!==a.relativeSize&&(l/=e.getMetrics().getScaleFactor()),isNaN(l)&&(console.warn(`Invalidate size: '${l}'`),l=void 0),l===0&&(s=!0,l=void 0),c=!a.autoSize}l===null&&(c=!a.autoSize)}l!==void 0&&n?.sz!==l&&(o||={},l===null?delete o.sz:o&&(o.sz=l)),s===void 0&&a.autoSize&&(s=!1),s!==void 0&&n?.h!==s&&(s?(o||={},o.h=s):o&&delete o.h),c!==void 0&&n?.csz!==c&&(c?(o||={},o.csz=c):o&&delete o.csz);let u=a.outlineLevel;if(u!==void 0){let e=n?.l??0;typeof u==`function`&&(u=u(e)),u=Math.max(0,Math.min(7,Math.trunc(u))),u!==e&&(u>0?(o||={},o.l=u):o&&delete o.l)}let d=!!a.autoSize&&a.size!==null;a.size!==void 0&&e.getAxis()===B.Axis.Column&&(n?.bf??!1)!==d&&(d?(o||={},o.bf=!0):o&&delete o.bf);let f=a.collapsed;return f!==void 0&&(n?.cl??!1)!==f&&(f?(o||={},o.cl=!0):o&&delete o.cl),o?Object.keys(o).length===0?null:o:null}}}function uF(e,t){return Math.round(e*t)}function dF(e,t,n,r){if(e==null)return null;let i,a,o={};if(typeof e==`number`)o.colStart=e,o.colEnd=e,o.rowStart=e,o.rowEnd=e;else if(typeof e==`string`){if(t){if(e.match(/[0-9]+/))throw Error(`Invalid range address for header axis`)}else if(e.match(/[a-zA-Z]+/))throw Error(`Invalid range address for header axis`);let r=Jd(e,n);if(!r){let t=Kd(e.toUpperCase(),!0);t?.colIndex!==void 0&&(o.colStart=t.colIndex,o.colEnd=t.colIndex),t?.rowIndex!==void 0&&(o.rowStart=t.rowIndex,o.rowEnd=t.rowIndex)}o={...o,...r}}return t?(i=e.min??e.colStart??o.colStart,a=e.max??e.colEnd??o.colEnd):(i=e.min??e.rowStart??o.rowStart,a=e.max??e.rowEnd??o.rowEnd),i===void 0||a===void 0?null:{min:i,max:a}}var fF=class{constructor(e,t,n,r,i){this._lastVisibleIndex=null,this._lastVisibleRun=null,this._indexedSizes=e,this._defaultPxSize=t,this._scaleFactor=n,this._maxIndex=r,this._hasHidden=i}getScaleFactor(){return this._scaleFactor}getDefaultSize(){return this._defaultPxSize}getOffset(e){return function(e,t,n){if(t<=0)return 0;let r=e?e.length:0;if(r===0)return t*n;let a=e[r-1];if(t>a.max)return a.runningOffsetMax+Math.round((t-a.max-1)*n+(a.spanSize===0?0:1));let o=e[r===1?0:i.findEqualOrGreater(e,t,e=>e.max)],s=t-o.min;return o.runningOffsetMin+s*o.spanSize}(this._indexedSizes,e,this._defaultPxSize)}getIndex(e){return Math.min(Math.max(0,function(e,t,n){let r=e?e.length:0;if(r===0)return Math.floor(t/n);let a=e[r-1];if(t>a.runningOffsetMax)return a.max+Math.ceil((t-a.runningOffsetMax)/n);let o=e[r===1?0:i.findEqualOrGreater(e,t,e=>e.runningOffsetMax)];if(o.spanSize===0)return Math.max(0,o.min-1);let s=t-o.runningOffsetMin;return o.min+Math.floor(s/o.spanSize)}(this._indexedSizes,e,this._defaultPxSize)),this._maxIndex)}getSpanSize(e,t=e+1){return this.getOffset(t)-this.getOffset(e)}getVisibleIndex(e){return this._lastVisibleIndex===e||(this._lastVisibleRun=function(e,t,n=2**53-1){let r=e?e.length:0;if(r===0)return{min:t,max:t};let a=r-1,o=e[a];if(t>o.max){let e=t-o.runningHiddenRuns;return{min:e,max:e}}a=r===1?0:i.findEqualOrGreater(e,t,e=>e.max),o=e[a];let s=o.spanSize===0?Math.max(-1,o.min-1-(e[a-1]?.runningHiddenRuns??1)):t-o.runningHiddenRuns;return{min:s,max:s+Math.min(n+1,+(o.spanSize===0))}}(this._indexedSizes,e,this._maxIndex),this._lastVisibleIndex=e),this._lastVisibleRun}getVisibleCount(e,t){if(e>t)throw Error(N(`error.address.invalidArguments`));if(e<0||t>this._maxIndex)throw new w;return this._hasHidden?function(e,t,n){let r=n-t+1;if(e.length===0)return r;let a=e.length-1,o=e[a];if(t>o.max)return r;a=e.length===1?0:i.findEqualOrGreater(e,t,e=>e.max),o=e[a];let s=o.runningHiddenRuns;if(o.spanSize===0&&t<=o.max){let e=o.max-o.min+1;r-=Math.min(e,o.max-t+1)}n>o.max&&a<e.length&&(a=i.findEqualOrGreater(e,n,e=>e.max),o=e[Math.min(a,e.length-1)]);let c=o.runningHiddenRuns;if(o.spanSize===0&&o.min<=n){let e=o.max-o.min+1;r-=Math.min(e,n-o.min+1),c-=e}return r-=c-s,r}(this._indexedSizes,e,t):t-e+1}hiddenHeadersAt(e,t=!1){let n=this._indexedSizes;if(n.length===0)return 0;let r=n[n.length===1?0:i.findEqualOrGreater(n,e,e=>e.max)];return!r||r.spanSize!==0||r.min>e||r.max<e?0:t?e-r.min+1:r.max-e+1}hasHidden(){return this._hasHidden}},pF=()=>{},mF=()=>0,hF=()=>!1,gF=class{constructor(e,t){this._header=e,this._coords=t}_forEachSpan(e,t,n){let r=this._header,i=this._coords,a=r._options;n||=a.createCellHeader;let o=i;if(t?.address){let e=r._parseHeaderRangeAddress(t?.address);if(e&&(o=lo(i,e),!o))return}let s=r._scanHeaders(e,this._header._getState(),n,a,o,t);if(s&&s.break)return s.break}forEachSpan(e,t){return this._forEachSpan(e,t)}forEach(e,t){let n,r=2**53-1,i=null,a={getIndex:()=>r,getCellHeader:()=>i.getCellHeader(),getAddress:(e,t)=>i.getAddress(e,t),getCoords:()=>i.getCoords()};return this._forEachSpan((t,o)=>{i=o;let s=this._coords,c=s.max;for(let i=s.min;i<c;i++)r=i,n=i-s.min,e(t,a)},t,()=>this.at(n))}updateHeaders(e,t){let n=this._header;return n.updateHeaderPairs([{address:this._coords,update:e}],{description:t?.description??(n._isColumn?N(`op.updateColumnsRange`,{range:toString()}):N(`op.updateRowsRange`,{range:toString()})),...t}),this}getCoords(){return{...this._coords}}getUsedRange(e){let t=this._header,n=t._headerRunCoords;return!n||n.min<0||n.max>t._maxDataIndex?null:lo(n,this._coords)?t.getRange(n,e):null}getCount(){let e=this._coords;return e.max-e.min+1}getHeaderCount(){let e=this._coords;return e.max-e.min+1}getVisibleCount(){let e=this._coords;return this._header.getVisibleCount(e.min,e.max)}isEntireHeaders(){let e=this._header._entireRunCoords,t=this._coords;return!(t.min>e.min||t.max<e.max)}getSnapshot(e){return this._header._getSnapshot(this._coords,e)}setSize(e,t){return this._header._setSize(this._coords,e,t),this}setHidden(e,t){return this._header._setHidden(this._coords,e,t),this}clear(){return this._header._clear(this._coords),this}at(e){return this._header.at(this._coords.min+e)}getAxis(){return this._header.getAxis()}doBatch(e,t){return this._header.doBatch(t=>e(t),t)}getSheetHeader(){return this._header}getA1(){return this.getAddress()}getAddress(e){let t=this._coords,n=this._header;return Wd(n._isColumn?{colStart:t.min,colEnd:t.max}:{rowStart:t.min,rowEnd:t.max},n._entireRangeCoords)??`#REF!`}get[Symbol.toStringTag](){return`[SheetCellHeaderRange]`}toString(){return this.getAddress()}get isICellHeaderRange(){return!0}},_F=class{constructor(e,t){this._header=e,this._coords=t}updateHeaders(e,t){let n=this._header;return n.updateHeaderPairs([{address:this._coords,update:e}],{description:t?.description??(n._isColumn?N(`op.updateColumnsRange`,{range:toString()}):N(`op.updateRowsRange`,{range:toString()})),...t}),this}getCoords(){return[...this._coords]}setHidden(e,t){return this._header._setHidden(this._coords,e,t),this}setSize(e,t){return this._header._setSize(this._coords,e,t),this}getCount(){return this._coords.length}getHeaderCount(){let e=mo(this._coords,!0),t=0,n=e.length;for(let r=0;r<n;r++){let n=e[r];t+=n.max-n.min+1}return t}getVisibleCount(){let e=mo(this._coords,!0),t=0,n=this._header,r=e.length;for(let i=0;i<r;i++){let r=e[i];t+=n.getVisibleCount(r.min,r.max)}return t}isEntireHeaders(){let e=this._header._entireRunCoords,t=this._coords,n=e.min,r=e.max,i=t.length;for(let e=0;e<i;e++){let i=t[e];if(n<i.min||r>i.max)return!1}return!0}isEntireHeadersAny(){let e=this._header._entireRunCoords,t=this._coords,n=e.min,r=e.max,i=t.length;for(let e=0;e<i;e++){let i=t[e];if(i.min<=n&&i.max>=r)return!0}return!1}clear(){return this._header._clear(this._coords),this}at(e){let t=this._coords;return e<0||e>=t.length?null:this._header.getRange(t[e])}getAxis(){return this._header.getAxis()}doBatch(e,t){return this._header.doBatch(t=>e(t),t)}getSheetHeader(){return this._header}getA1(){return this.getAddress()}getAddress(e){let t=this._coords,n=this._header;return function(e,t,n=Wd){if(!e)return`#REF!`;let r=e.length,i=Array(r);for(let a=0;a<r;a++)i[a]=n(e[a],t);return i.join(`,`)}(function(e,t,n){if(!e||e.length===0)return i.EmptyArray;let r=e.length,a=Array(r),o=n?t.rowStart:t.colStart,s=n?t.rowEnd:t.colEnd;for(let t=0;t<r;t++){let r=e[t],i={colStart:n?r.min:o,rowStart:n?o:r.min,colEnd:n?r.max:s,rowEnd:n?s:r.max};r.value!==void 0&&(i.value=r.value),a[t]=i}return a}(t,n._entireRangeCoords,n._isColumn),n._entireRangeCoords)??`#REF!`}get[Symbol.toStringTag](){return`[SheetCellHeaderRanges]`}toString(){return this.getAddress()}get isICellHeaderRanges(){return!0}},vF=class{constructor(e){if(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._hasHidden=!1,this._hiddenSignature=0,this._outlineSignature=0,this._lastHeaderRead=null,this._readCache=null,this._lastHeaders=null,this._metrics=null,this._selectionRuns=null,this._options={isProtected:()=>!1,scaleFactor:()=>1,defaultSize:()=>100,minSize:()=>0,maxSize:()=>500,getEntireSheetCoords:()=>null,axis:B.Axis.Column,createCellHeader:(t,n,r,i)=>new cF(t,n,r,i,e?.getColumnAt??yF),...e},!this._options.sheet)throw Error(`An IWorksheet must be provided`);this._emptyHeader=this._options.createCellHeader(0,this,null,null);let t=this._options.axis===B.Axis.Column;this._isColumn=t;let n=this;this._options.setContainerShiftedCallback&&this._options.setContainerShiftedCallback((e,t)=>{t<0?n._deleteHeaders(e,-t):n._insertHeaders(e,t)}),this._options.sheet&&(this._sheetRemoveListener=this._options.sheet.addListeners({onProtectionChange(){},onSelectionChange(e){n._selection=e.getSelection().getCoords(),n._selectionRuns=null},onStyleChange:()=>{},onViewChange(){let e=n._invalidSizes(),t=n._invalidateMaxIndex();(e||t)&&n._emitter.notify(`onMetricsChange`)}},{transactional:!1}),n._selection=n._options.sheet.getSelection().getCoords()),this._transactions=this._options.transactions??new se({transient:!0}),this._id=this._transactions.create(),this._emitter=new ne(n,this._transactions),this._transactionsRemoveListener=this._transactions.addStateListener(this._id,{onAfterStateChange(e){n._lastHeaders!==e.headers&&n._onHeaderChange(!0)},async onRestoreOrRevert(e){n._onHeaderChange(!0)}}),this.fromJSON(this._options?.json)}addListeners(e,t){return this._emitter.addListeners(e,t)}_invalidateExtent(){let e=this._invalidSizes(),t=this._invalidateMaxIndex();(e||t)&&this._emitter.notify(`onMetricsChange`)}_invalidateMaxIndex(){let e=this._options.getEntireSheetCoords()??{colStart:0,rowStart:0,colEnd:2**53-1,rowEnd:2**53-1};this._entireSheetCoords=e;let t=this._isColumn,n=t?e.colEnd:e.rowEnd,r=n!==this._entireRunMax;return r&&(this._metrics=null),this._entireRunMax=n,this._entireRunCoords={min:0,max:n},this._entireHeaderRange=this.getRange(this._entireRunCoords),this._entireRangeCoords={colStart:0,rowStart:0,colEnd:t?n:0,rowEnd:t?0:n},r}_invalidSizes(e=!1){let t=this._defaultCustomSize===-1?this._options.defaultSize():this._defaultCustomSize;if(t<0)throw Error(`defaultSize must be greater than 0`);let n=this._options.scaleFactor();if(globalThis.__SXL_LOG_EVENTS){let r=e||t!==this._defaultSize||n!==this._scaleFactor;console.log(`[sxl:SheetHeader:${this._isColumn?`col`:`row`}] _invalidSizes force=${e} scale ${this._scaleFactor}->${n} default ${this._defaultSize}->${t} rebuild=${r}`)}if(e||t!==this._defaultSize||n!==this._scaleFactor){this._defaultSize=t,this._scaleFactor=n,this._defaultPxSize=uF(t,n);let e=function(e,t,n){let r=[],i=[],a=[];if(!e||e.length===0)return{sizes:r,hidden:i};if(!t||!n)return console.warn(`_HeaderUtils:default size and scaleFactor should be available`),{sizes:r,hidden:i};let o=0,s=0,c=0,l=null,u=-2,d=null,f=-2,p=e.length;for(let m=0;m<p;m++){let p=e[m],h=p.min,g=p.max;if(o=r.length===0?0:r[r.length-1].runningOffsetMax,r.length>0&&r[r.length-1].spanSize>0&&o++,s<p.min){r.push({min:s,max:h-1,runningOffsetMin:o,runningOffsetMax:Math.round(o+(h-s)*t*n)-1,runningHiddenRuns:c,spanSize:Math.round(t*n)});let e=s,i=h-1;f+1===e?d.max=i:(d={min:e,max:i,value:!0},a.push(d)),f=i}let _=r.length,v=r[_-1];o=_===0?0:v.runningOffsetMax,_>0&&v.spanSize>0&&o++;let y=p.value,b=y.h?0:uF(y.sz??t,n),x=b===0?0:-1;b===0?(c+=g-h+1,u+1===h?l.max=g:(l={min:h,max:g,value:!0},i.push(l)),u=g):(f+1===h?d.max=g:(d={min:h,max:g,value:!0},a.push(d)),f=g),_>0&&v.spanSize===b&&v.max+1===h?(v.max=g,v.runningHiddenRuns=c,v.runningOffsetMax=v.runningOffsetMin+(g+1-v.min)*b+x):r.push({min:h,max:g,runningOffsetMin:o,runningOffsetMax:Math.round(o+(g+1-h)*b)+x,runningHiddenRuns:c,spanSize:b}),s=g+1}return{sizes:r,hidden:i}}(this._headers,t,n);return this._indexedSizes=e.sizes,this._indexedHidden=e.hidden,this._metrics=null,!0}return!1}invalidate(){this._invalidSizes(!0),this._invalidateMaxIndex(),this._selection=this._options.sheet.getSelection()?.getCoords()}_onHeaderChange(e){this._lastHeaders=null;let t=this._headers,n=this._getState();this._defaultCustomSize=n.defaultCustomSize,this._invalidateMaxIndex(),this._invalidSizes(!0),this._lastHeaderRead=null,this._readCache=uo(this._lastHeaders);let r=!1,i=0,a=0,o=-1,s=t.length,c=this._entireRunMax;for(let e=s-1;e>=0;e--){let n=t[e],s=n.value;o===-1&&(o=n.max),(s.h||s.sz===0)&&(r=!0,i=Math.imul(i,31)+n.min|0,i=Math.imul(i,31)+n.max|0),s.l===void 0&&s.cl===void 0||(a=Math.imul(a,31)+n.min|0,a=Math.imul(a,31)+n.max|0,a=Math.imul(a,31)+2*(s.l??0)+ +!!s.cl|0)}o=Math.min(o??0,c);let l=Math.min(t[0]?.min??o,o);this._headerRunCoords=Object.freeze({min:l,max:o}),this._hasHidden!==r&&(this._metrics=null),this._hasHidden=r;let u=this._hiddenSignature!==i;this._hiddenSignature=i;let d=this._outlineSignature!==a;this._outlineSignature=a,e&&this._emitter.notify(`onMetricsChange`),u&&(this._options.hiddenChanged?.(),this._emitter.notify(`onHiddenChange`)),d&&this._emitter.notify(`onOutlineChange`)}getWorksheet(){return this._options.sheet}getAxis(){return this._isColumn?B.Axis.Column:B.Axis.Row}getTextAt(e){return this._options.getTextAt?.(e)??e+``}_scanHeaders(e,t,n,r,i,a){let o=i?.min??null,s=i?.max??null,c=a?.includeEmpty??!1,l=a?.visibility??`all`,u=a?.includeSizes??!1,d=this,f=this._defaultSize,p=this._scaleFactor,m=t.headers,h=this._emptyHeader,g=null,_={getCoords(){if(!g)throw Error(N(`error.sheet.iteratorClosed`));return{min:g.min,max:g.max}},getIndex:()=>g.min,getCellHeader(){if(!g)throw Error(N(`error.sheet.iteratorClosed`));return g.value?n(o,d,g.value):h},getAddress(e,t=!1){if(!g)throw Error(N(`error.sheet.iteratorClosed`));let n=e===void 0?g.min:Math.max(g.min,e),r=e===void 0?g.max:Math.min(g.max,e),i=d._parseHeaderRangeAddress({min:n,max:r}),a=d._entireRangeCoords,o=d._isColumn;return Wd({colStart:o?i.min:a.colStart,rowStart:o?a.rowStart:i.min,colEnd:o?i.max:a.colEnd,rowEnd:o?a.rowEnd:i.max},a,void 0,!0)??`#REF!`}},v=t=>{let n=t.value;if(!c&&!n)return;let r=c;if(u&&!r&&n&&(n.csz||n.sz!==f)&&(r=!0),n&&!0===n.h?r=l!==`visible`:l===`hidden`&&(r=!1),!r)return;let i=f;t.value&&(i=t.value.h?0:t.value?.sz??f),i*=p,g=t;let a=e(i,_);return a&&a.break?a:void 0},y;return y=l===`visible`?po(this._indexedHidden,e=>{if(!0===e.value)return;let t=o===null?e.min:Math.max(e.min,o),n=s===null?e.max:Math.min(e.max,s),r=po(m,v,t,n);return r&&r.break?r:void 0},o,s):po(m,v,o,s),g=null,y}getRange(e,t){if(!e)throw Error(N(`error.address.noAddress`));let n=this._parseHeaderRangeAddress(e);return n.min<0||n.max>this._entireRunMax?function(e){return Object.freeze({getCoords:()=>null,getAxis:()=>e.getAxis(),toString:()=>gd,getAddress:()=>gd,getA1:()=>gd,getCount:mF,getHeaderCount:mF,getVisibleCount:mF,isEntireHeaders:hF,forEach:pF,forEachSpan:pF,getUsedRange:X,getSnapshot:X,updateHeaders:X,clear:X,setHidden:X,setSize:X,at:X,doBatch:X,getSheetHeader:()=>e,isICellHeaderRange:!0})}(this):new gF(this,n)}getFilteredRanges(e){if(this._isColumn)return i.EmptyArray;let t=this._options.sheet._getInternal().filteredTables();if(t.length===0)return i.EmptyArray;let n=[];for(let r=0;r<t.length;r++){let i=t[r].getDataRange();if(i.isInvalid())continue;let a=i.getCoords();e&&(a.rowEnd<e.min||a.rowStart>e.max)||n.push(new gF(this,{min:a.rowStart,max:a.rowEnd}))}return n}getRanges(e,t){if(!e)throw Error(N(`error.address.noAddress`));let n=function(e,t,n){if(typeof e==`string`){let r=af(e,n),i=r?r.length:0,a=Array(i);for(let e=0;e<i;e++){let n=r[e];a[e]={min:t?n.colStart:n.rowStart,max:t?n.colEnd:n.rowEnd}}return e=a,a}Array.isArray(e)||(e=[e]);let r=e.length,i=Array(r);for(let a=0;a<r;a++)i[a]=dF(e[a],t,n);return i}(e,this._isColumn,this._entireRangeCoords);return new _F(this,n)}getSelectedRange(e){let t=this._options.sheet.getSelection().getRange().getCoords();return this.getRange(t,e)}getSelectedRanges(e){let t=this._options.sheet.getSelection().getRanges().getCoords();return this.getRanges(t,e)}getUsedRange(e){return this.getRange(this._headerRunCoords,e)}getEntireRange(e){return e?this.getRange(this._entireRangeCoords,e):this._entireHeaderRange}at(e){if(e<0||e>this._entireRunMax)return this._emptyHeader;if(this._lastHeaderRead?.offset===e)return this._lastHeaderRead.header;let t=fo(e,this._readCache),n=this._options.getTextAt?.(e)??e+``,r=this._options.createCellHeader(e,this,t,{value:n});return this._lastHeaderRead={offset:e,header:r},r}updateHeaderPairs(e,t){if(this.isProtected())throw new b(this._isColumn?N(`error.sheetHeader.protectedColumns`):N(`error.sheetHeader.protectedRows`));return this._updatePairsInternal(e,t)}_parseHeaderRangeAddress(e,t){if(e==null)throw Error(N(`error.address.noRange`));let n=dF(e,this._isColumn,this._entireRangeCoords);if(!n)throw Error(N(`error.address.invalidRangeHeader`));return n}_update(e,t,n){if(!e||(Array.isArray(e)||(e=[e]),e.length===0))return;let r=[],i=e.length;for(let n=0;n<i;n++){let i=this._parseHeaderRangeAddress(e[n]);this.getRange(i).forEachSpan((e,n)=>{let i=n.getCoords();r.push({address:i,update:t})},{includeEmpty:!0})}return this.updateHeaderPairs(r,n),this}_setSize(e,t=null,n){(n?.relativeSize??!1)||typeof t!=`number`||(t+=`px`);let r={size:t,autoSize:n?.autoSize??!1},i=this._isColumn?m(`op.resizeColumns`):m(`op.resizeRows`);return this._update(e,r,{description:i,...n}),this}_setHidden(e,t=null,n){let r={hidden:t},i=this._isColumn?m(t?`op.unhideColumns`:`op.hideColumns`):m(t?`op.unhideRows`:`op.hideRows`);return this._update(e,r,{description:i,...n}),this}_clear(e,t){let n=this._isColumn?m(`op.clearColumnHeaders`):m(`op.clearRowHeaders`);this.updateHeaderPairs([{address:e,update:null}],{description:n,...t})}_getSnapshot(e,t){if(e.min<0)return i.EmptyArray;t=Object.freeze({...t});let n=this,r=this._getState(),a=this._isColumn?m(`copy.columnHeaders`):m(`copy.rowHeaders`);return{copyTo(o,s){let c={...t,...s},l=o.getCoords(),u=l.min-e.min,d=[];if(n._scanHeaders((e,t)=>{let n=t.getCoords();d.push({address:{min:n.min+u,max:n.max+u},update:t.getCellHeader()})},r,n._options.createCellHeader,null,e,{includeSizes:!0}),!c.fitDestination){let t=e.max-e.min+1,n=l.max-l.min+1,r=i.roundAccurately(n/t);if(r>1&&n%t===0){let e=d.length;for(let n=0;n<r;n++)for(let r=0;r<e;r++){let e=d[r],i=e.address,a=(n+1)*t;d.push({address:{min:i.min+a,max:i.max+a},update:e.update})}}}if(o.doBatch(()=>{o.clear(),o.getSheetHeader()._updatePairsInternal(d)},a),c.isCut){let t=n._entireRunCoords;e.min<=t.min&&e.max>=t.max&&n._clear(e)}return l},getCoords:()=>e,toText:()=>null,toHtml:()=>null,toImage:()=>null,getSource:()=>n,getName:()=>a,isISnapshot:!0}}isProtected(){return this._options?.isProtected()??!1}get _headers(){return this._lastHeaders===null&&(this._lastHeaders=this._getState()?.headers),this._lastHeaders}_updatePairsInternal(e,t){if(!e||e.length===0)return null;let n=t?.skipCustomSize??!1,r=this._isColumn,i=this.getWorksheet().getStyles(),a=this._beginCommit({description:t?.description??m(r?`op.updateColumns`:`op.updateRows`)}),o=[...this._getState().headers],s=!1,c=this,l=this._defaultCustomSize===-1?this._options.defaultSize():this._defaultCustomSize,u=(e,t,r)=>{if(this.isProtected())throw new b(this._isColumn?N(`error.sheetHeader.protectedColumns`):N(`error.sheetHeader.protectedRows`));return io(e,{min:t.min,max:t.max,value:r},{onUpdate:(e,t)=>{if(n&&(e?.csz||e?.h))return e;let r=lF(c,i,e,t);return r===void 0?e:r?e?(s||=r.sz!==e.sz,s||=r.h!==e.h,r):(s=!0,r):(e&&(s=!0),r)},onSplit:e=>[e.value,e.value],onMerge:(e,t,n,r)=>{if(!(e&&!t||!e&&t||!e&&!t)&&e.sz===t.sz&&e.csz===t.csz&&e.h===t.h&&e.l===t.l&&e.cl===t.cl&&e.bf===t.bf)return e},isCull:(e,t,n)=>e===void 0})},d=this._entireRunMax,f=e.length,p=Array(f);for(let t=0;t<f;t++){let n=this._parseHeaderRangeAddress(e[t].address);if(n.min<0||n.max>d)throw new w(N(`error.sheet.oobRange`));p[t]=n}let h=Array(f);for(let e=0;e<f;e++)h[e]=e;h.sort((e,t)=>p[e].min-p[t].min);let g=!1;for(let e=1;!g&&e<f;e++)p[h[e]].min<=p[h[e-1]].max&&(g=!0);if(g)for(let t=0;t<f;t++)o=ao(u(o,p[t],e[t].update));else{let t=o,n=t.length,r=[],i=[],a=0;for(let o=0;o<f;o++){let s=h[o],c=p[s],l=i;for(i=[];a<n&&t[a].max<c.min;)l.push(t[a++]);let d=0;for(;d<l.length-1&&l[d+1].max<c.min;)d++;for(let e=0;e<d;e++)r.push(l[e]);for(d>0&&l.splice(0,d);a<n&&t[a].min<=c.max;)l.push(t[a++]);a<n&&(l.length===0||l[l.length-1].max<=c.max)&&l.push(t[a++]);let f=u(l,c,e[s].update);for(let e=0;e<f.preceding.length;e++)r.push(f.preceding[e]);i=f.modified.concat(f.trailing)}for(let e=0;e<i.length;e++)r.push(i[e]);for(;a<n;a++)r.push(t[a]);o=r}let _=!1,v=o.length;if(v>0&&o[0].min===0&&o[v-1].max===d){let e=o[0],t=!1,n=-1;for(let r=0;!t&&r<v;r++){let i=o[r],a=i.min;if(n+1!==a){t=!0;continue}let s=i.max;n=s,e.max-e.min<s-a&&(e=i)}t||(this._defaultCustomSize=e.value?.sz??-1,_=!0);let r=[];for(let e=0;e<v;e++){let t=o[e],n=t.value;if(n===null)continue;let i=Object.keys(n).length;if(i===0)continue;let a=n.sz;(i!==1||a===void 0||a!==null&&a!==l)&&r.push(t)}o=r,v=o.length}let y=[];for(let e=0;e<v;e++){let t=o[e],n=t.value;if(n===null)continue;let r=!1;n.sz!==void 0&&n.sz!==l&&(r=!0),n.csz!==void 0&&(r=!0),n.h!==void 0&&(r=!0),n.l!==void 0&&(r=!0),n.cl!==void 0&&(r=!0),n.bf&&(r=!0),r&&y.push(t)}return _&&c._invalidSizes(!0),this._updateState({headers:y,defaultCustomSize:this._defaultCustomSize},s),a.commit(),p}_getHeaderRuns(){return this._headers}getDefaultSizeNative(){return this._defaultSize}getMaxSize(){return Math.ceil(this._options.maxSize()*this._options.scaleFactor())}getMinSize(){return Math.floor(this._options.minSize()*this._options.scaleFactor())}getMetrics(){let e=this._metrics;return e||(e=new fF(this._indexedSizes,this._defaultPxSize,this._scaleFactor,this._entireRunMax,this._hasHidden),this._metrics=e),e}isSelectedAll(e){let t=this.getSelectedRuns();if(t.length===0)return!1;let n=t[i.findEqualOrGreater(t,e,e=>e.max)];return!(!n||e<n.min||e>n.max)&&n.value}isSelected(e){let t=this.getSelectedRuns();if(t.length===0)return!1;let n=t[i.findEqualOrGreater(t,e,e=>e.max)];return!(!n||e<n.min||e>n.max)}getSelectedRuns(){let e=this._selectionRuns;return e||(this._selection&&(e=yD(this.getAxis(),this._selection,this._entireSheetCoords)),e||=i.EmptyArray),this._selectionRuns=e,this._selectionRuns}_insertHeaders(e,t){if(t<=0)return;let n=this._beginCommit({description:this._isColumn?m(`op.insertColumns`):m(`op.insertRows`)}),r=this._getState().headers,a=r.length,o=e<=(a>0?r[a-1].max:0),s=r;o&&(s=ao(function(e,t,n=1){let r=i.findEqualOrGreater(e,t,e=>e.max),a=e.slice(0,r),o=[],s=[];if(!e[r])return{preceding:a,modified:s,trailing:o};e[r].min>=t?o.push({...e[r],min:e[r].min+n,max:e[r].max+n}):s.push({...e[r],min:e[r].min,max:e[r].max+n});for(let t=r+1;t<e.length;t++)o.push({...e[t],min:e[t].min+n,max:e[t].max+n});return{preceding:a,modified:s,trailing:o}}([...s],e,t))),this._updateState({headers:s},o),n.commit()}_deleteHeaders(e,t){let n=this._beginCommit({description:this._isColumn?m(`op.deleteColumns`):m(`op.deleteRows`)}),r=this._getState().headers,i=r.length,a=e<=(i>0?r[i-1].max:0),o=r;a&&(o=ao(ro([...o],e,t))),this._updateState({headers:o},a),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:m(`op.updateHeader`),...t})}getId(){return this._id}getVersionId(){return this._transactions.getVersionId(this._id)}isClosed(){return this._closed}close(){this._sheetRemoveListener?.(),this._emitter.close(),this._transactionsRemoveListener?.(),this._closed=!0,this._transactions.remove(this._id)}_getState(){return this._transactions.getState(this._id)}_beginCommit(e){return this._transactions.beginCommit(e)}_updateState(e,t=!1){let n=this._transactions.beginCommit();try{n.updateState(this._id,e),this._onHeaderChange(t),n.commit()}catch(e){throw n.rollback(),e}}fromJSON(e){let t=e||{};this._defaultCustomSize=t.defaultSize??-1,this._defaultCustomSize<=0&&(this._defaultCustomSize=-1),this._invalidateMaxIndex();let n=[],r=t.headers,i=r?r.length:0,a=this._entireRunMax??2**53-1,o=this._isColumn;for(let e=0;e<i;e++){let t=jf(r[e],o);if(!t)continue;let i=t.min;if(i>=a)continue;let s={min:i,max:Math.min(t.max,a)},c=t.value,l={};c.sz!==void 0&&c.sz!==-1&&(l.sz=c.sz),c.h&&(l.h=!0),c.csz&&(l.csz=!0),c.l&&(l.l=Math.max(0,Math.min(7,c.l))),c.cl&&(l.cl=!0),c.bf&&(l.bf=!0),Object.keys(l).length!==0&&(s.value=l,n.push(s))}this._updateState({headers:n,defaultCustomSize:this._defaultCustomSize})}toJSON(){let e=this._headers,t=e.length;if(t===0&&this._defaultCustomSize===-1)return null;let n={headers:[]};if(this._defaultCustomSize!==-1&&(n.defaultSize=i.roundAccurately(this._defaultCustomSize,8)),t===0)return n;let r=this._defaultCustomSize,a=this._isColumn;for(let o=0;o<t;o++){let t=e[o],s=t.value;if(!s)continue;let c={},l=s.sz;l!==void 0&&l!==r&&(c.sz=i.roundAccurately(l,8)),s.csz&&(c.csz=!0),s.h&&(c.h=!0),s.l&&(c.l=s.l),s.cl&&(c.cl=!0),s.bf&&(c.bf=!0),Object.keys(c).length>0&&n.headers.push({r:Of(t.min,t.max,a),v:c})}return n}get[Symbol.toStringTag](){return`[SheetHeader]`}toString(){return`[SheetHeader]`}get isISheetHeader(){return!0}},yF=e=>null,bF=class e extends fc{constructor(e){super(e),this._entireCoords=e?.entireCoords}getContentfulCoords(){let e=this._contentfulCoords;if(e!==void 0)return e;let t=this._entireCoords;if(!t||this.isEmpty())return this._contentfulCoords=null,null;let n=this.all(),r=n.length,i=t.colStart,a=t.rowStart,o=t.colEnd,s=t.rowEnd,c=2**53-1,l=2**53-1,u=-(2**53-1),d=-(2**53-1),f=0,p=0,m=0,h=0;for(let t=0;t<r;t++){let r=n[t];f=r.colStart,m=r.colEnd,m>=o&&(f=Math.max(f-1,i),m=f),p=r.rowStart,h=r.rowEnd,h>=s&&(p=Math.max(p-1,a),h=p),c=Math.min(c,f),u=Math.max(u,m),l=Math.min(l,p),d=Math.max(d,h),e={colStart:c,rowStart:l,colEnd:u,rowEnd:d}}return this._contentfulCoords=e,e}setEntireCoords(e){this._entireCoords=e,this._onModified()}getEntireCoords(){return this._entireCoords??null}clone(e=null){let t=super.clone(e);return t._entireCoords=this._entireCoords,t._contentfulCoords=this._contentfulCoords,t}_onModified(){super._onModified(),this._contentfulCoords=void 0}_createClone(t){return new e(t)}},xF=()=>[],SF=(e,...t)=>{if(e.isEmpty())return;let n,r=t.length;for(let i=0;i<r;i++){let r=t[i],a=r.length;for(let t=0;t<a;t++){let i=e.search(r[t]),a=i.length;for(let e=0;e<a;e++){let t=i[e],r=t.value;if(!r.isFixed())continue;n||=[];let a=!1;for(let e=0;e<n.length&&!a;e++)a=n[e].value===r;a||n.push(t)}}}if(!n)return;let i=n.length;for(let e=0;e<i;e++){let i=n[e],a=i.colEnd-i.colStart+1,o=a*(i.rowEnd-i.rowStart+1),s=new Set;for(let e=0;e<r&&s.size<o;e++){let n=t[e],r=n.length;for(let e=0;e<r&&s.size<o;e++){let t=h.intersectRanges(i,n[e]);if(t)for(let e=t.rowStart;e<=t.rowEnd;e++)for(let n=t.colStart;n<=t.colEnd;n++)s.add((e-i.rowStart)*a+(n-i.colStart))}}if(s.size<o)throw new k(N(`error.sheet.changePartOfArray`))}},CF=(e,t)=>t.some(t=>e.some(e=>h.isRangesIntersect(e,t))),wF=e=>!TF(e)||e.isICellStyle||typeof e.font==`string`?null:EF(e)??null,TF=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,EF=e=>{if(e===null||typeof e==`function`)return;if(Array.isArray(e)){let t=e.map(EF);return t.includes(void 0)?void 0:t}if(typeof e!=`object`)return e;if(e.isIColor)return e.toString();if(!TF(e)){let t=e.toJSON;return typeof t==`function`?EF(t.call(e)):void 0}let t={};for(let n in e){let r=e[n];if(r===void 0)continue;let i=EF(r);if(i===void 0)return;t[n]=i}return t},DF=(e,t,n=[],r=[],i=!1)=>{let a={covered:null,typed:null};if(e.isEmpty())return a;let o=e.all();for(let e=0;e<o.length;e++){let s=o[e],c=eD(s);if(!c)continue;let l=c.cells,u=e=>CF(l,e);if(u(r))throw new k(N(`error.pivotTable.formula`));if(u(n)){if(!i||c.isBlocked)throw new k(N(`error.pivotTable.changePart`));a.typed={table:s,row:n[0].rowStart,column:n[0].colStart};continue}if(!u(t))continue;let d=l;for(let e=0;e<t.length&&d.length>0;e++){let n=[];for(let r=0;r<d.length;r++){let i=uD(d[r],t[e]);for(let e=0;e<i.length;e++)n.push(i[e])}d=n}if(d.length>0)throw new k(N(`error.pivotTable.clearPart`));(a.covered??=[]).push(s)}return a},OF={rowStart:0,colStart:0,rowEnd:0,colEnd:0},kF=[{colIndex:-1,rowIndex:-1},null,null,null,null];function AF(e,t,n,r,a){let o;r&&(a??=((t,n)=>{e.validateCoords(t,n??N(`error.sheet.insertOob`))})),n===B.Axis.Column||n===B.Axis.Row?(o=n,n={}):n&&(o=n.axis);let s=n?.description??m(r?`op.insertCells`:`op.deleteCells`),c=(o??e.getDefaultShiftAxis(t[0]))===B.Axis.Column;if(e.protectionCheck(()=>{let n=e.getEntireCoords(),i=e.getState().tables,a=e=>{let t=c?{...e,colStart:e.colStart-1}:{...e,rowStart:e.rowStart-1},n=i.search(t);for(let t=0;t<n.length;t++){let r=n[t];if(c?r.rowStart===e.rowStart&&r.rowEnd===e.rowEnd:r.colStart===e.colStart&&r.colEnd===e.colEnd)return!0}return!1};for(let e=0;e<t.length;e++){let r=t[e];if(!(c?r.rowStart<=n.rowStart&&r.rowEnd>=n.rowEnd:r.colStart<=n.colStart&&r.colEnd>=n.colEnd)&&!a(r))return[]}return[c?r?`insertColumns`:`deleteColumns`:r?`insertRows`:`deleteRows`]},t,s),lD(t))throw new k(N(r?`error.sheet.insertOverlapping`:`error.sheet.deleteOverlapping`));let l=e.calcGrid.getSpills();for(let e=0;e<t.length;e++)hM(l,t[e],c,r);let u=e.getEntireCoords(),d=u.colEnd,f=u.rowEnd,p=SD(t),h=e.beginCommit({description:s,operation:{name:r?`insertCells`:`deleteCells`}});e.getProtection().isLocked()&&e.recordSkipProtectionCheck(h);let g=e.stateFor(h),_=c?r?B.Direction.Right:B.Direction.Left:r?B.Direction.Down:B.Direction.Up;try{let o=g.mergeSpatial,s=g.borderSpatial,l=g.fillSpatial,m=g.contentSpatial,v=g.continuousFillSpatial,y=g.dateFormatSpatial,b=g.hyperlinkSpatial,x=g.movableSpatial,S=e.calcGrid,C=e.getView().getFreezePanes().coords,w=C.rowIndex>0||C.colIndex>0,T={...C},E=Qo(t.slice(),B.Direction.Left),D=E.length,O=function(e,t,n){if(e.isEmpty())return i.EmptyArray;let r=Array(t.length);for(let e=0;e<t.length;e++)r[e]={range:t[e],direction:n};let a=[],o=e.all();for(let e=0;e<o.length;e++){let t=o[e];t._planShift(r),a.push(t)}return a}(g.sparklineGroups,E,_);for(let t=0;t<D;t++){let n=E[t];d=Math.min(d,n.colStart),f=Math.min(f,n.rowStart);let i=(r?1:-1)*(c?n.colEnd-n.colStart+1:n.rowEnd-n.rowStart+1);S.shift({range:n,direction:_,commitId:h.getId(),cloneKey:h.getSavepointId()});let p=n.colStart<=u.colStart&&n.colEnd>=u.colEnd,C=n.rowStart<=u.rowStart&&n.rowEnd>=u.rowEnd;w&&(p||C)&&(T=tB(T,n,c,i,u));let D=(e,t,n,r)=>{let i=null;n>0&&!e.isProtected()&&(i=e.at(n-1).createCellHeader({hidden:!1,collapsed:!1}));let a=r-n+1;t?.(n,a),i&&e.updateHeaderPairs([{address:{min:n,max:r},update:i}])};p&&e.pageLayout._shiftBreaks(B.Axis.Row,n.rowStart,n.rowEnd,r),C&&e.pageLayout._shiftBreaks(B.Axis.Column,n.colStart,n.colEnd,r),p&&(r?D(e.rowHeaders,e.rowHeadersShiftCallback,n.rowStart,n.rowEnd):e.rowHeadersShiftCallback(n.rowStart,-1*(n.rowEnd-n.rowStart+1))),C&&(r?D(e.columnHeaders,e.columnHeadersShiftCallback,n.colStart,n.colEnd):e.columnHeadersShiftCallback(n.colStart,-1*(n.colEnd-n.colStart+1))),o=o.shift({range:n,direction:_,cloneIfUpdate:o===g.mergeSpatial}),s=s.shift({range:n,direction:_,cloneIfUpdate:s===g.borderSpatial}),l=l.shift({range:n,direction:_,cloneIfUpdate:l===g.fillSpatial}),m=m.shift({range:n,direction:_,cloneIfUpdate:m===g.contentSpatial}),v=v.shift({range:n,direction:_,cloneIfUpdate:v===g.continuousFillSpatial,coordValidator:a}),y=y.shift({range:n,direction:_,cloneIfUpdate:y===g.dateFormatSpatial,coordValidator:a}),b=b.shift({range:n,direction:_,cloneIfUpdate:b===g.hyperlinkSpatial,coordValidator:a}),x=x.shift({range:n,direction:_,cloneIfUpdate:x===g.movableSpatial,coordValidator:a})}let k=g.tables.shift({ranges:E,direction:_,coordValidator:a}),A=g.autoTables.shift({ranges:E,direction:_,coordValidator:a}),j=g.dataValidations.shift({ranges:E,direction:_,coordValidator:a}),M=g.conditionalFormats.shift({ranges:E,direction:_,coordValidator:a}),N=g.protectedRanges.shift({ranges:E,direction:_,coordValidator:a}),ee=g.cellControls.shift({ranges:E,direction:_,coordValidator:a}),te=g.sparklineGroups.shift({ranges:E,direction:_,coordValidator:a});for(let e=0;e<O.length;e++){let t=O[e]._settleShift();t&&(te=te.setCoords(O[e],t))}let P=g.pivotTables.shift({ranges:E,direction:_,coordValidator:a}),F=g.ignoredErrors.shift(E,_,a),ne=g.comments.shift({ranges:E,direction:_,coordValidator:a}),re=e.getState().noteSpatial;for(let t=0;t<D;t++)re=re.shift({range:E[t],direction:_,cloneIfUpdate:re===e.getState().noteSpatial,coordValidator:a});let ie=g.listeners.shift({ranges:E,direction:_}),ae=T.rowIndex!==C.rowIndex||T.colIndex!==C.colIndex;ae&&e.getView().setFreezePanes({coords:T}),e.updateState({mergeSpatial:o,borderSpatial:s,fillSpatial:l,contentSpatial:m,continuousFillSpatial:v,dateFormatSpatial:y,hyperlinkSpatial:b,movableSpatial:x,movableMapModel:e.takeShiftedMovableModels()??e.getState().movableMapModel,noteSpatial:re,noteMapModel:e.takeShiftedNoteModels()??e.getState().noteMapModel,tables:k,autoTables:A,dataValidations:j,conditionalFormats:M,protectedRanges:N,cellControls:ee,sparklineGroups:te,comments:ne,listeners:ie,pivotTables:P,ignoredErrors:F}),e.processLayoutChange(),e.markColumnHeaderTableNames(),P!==g.pivotTables&&e.tellPivots();let oe=r?`insert`:`delete`,se=c?B.Axis.Column:B.Axis.Row;e.recordChange(h,`address`,E,[{kind:oe,axis:se,ranges:E}]),e.recordShift(h,oe,se,E),ae&&e.recordFreezePanes(h,C,T),e.commitWithDirectives(h,p,{...n,autoFit:n?.autoFit??!1},{axis:c?B.Axis.Column:B.Axis.Row})}catch(t){throw e.takeShiftedMovableModels(),h.rollback(),t instanceof w?new k(t.message||N(r?`error.sheet.insertOob`:`error.sheet.deleteOob`)):t}}function jF(e,t,n,r){let i=r?.description??m(`op.setComments`),a=SD(t),o=e.beginCommit({description:i});try{let s=e.getState();if(!s)return;let c=s.comments,l=[],u=t.length;for(let r=0;r<u;r++){let a=t[r],o=n===void 0?a.value:n;if(o===void 0)continue;let s=hk(o);if(s===null){if(!c.has(a))continue;c=c.deleteRanges([a]),l.push(a);continue}let u={rowStart:a.rowStart,rowEnd:a.rowStart,colStart:a.colStart,colEnd:a.colStart},d=c.search(u)[0]?.value??null,f=s.id?s:null;f?(d&&(c=c.deleteRanges([u])),c=e.loadComments(c,[{r:u,v:f}])):d?d.update(s,{description:i}):c=e.loadComments(c,[{r:u,v:e.newCommentJSON(s)}]),l.push(u)}if(l.length===0)return void o.commit();c!==s.comments&&e.updateState({comments:c}),e.invalidateUsedCoords(),e.notifyCommentsChange(),e.recordChange(o,`comments`,l),e.commitWithDirectives(o,a,r)}catch(e){throw o.rollback(),e}}var MF=e=>bn(e)??e;function NF(e,t,n,r,a=!1){let o=r?.description??m(`op.setHyperlink`);a||e.isMoveRuled()||e.protectionCheck(()=>[`insertHyperlinks`,`formatCells`],t,o);let s=SD(t),c=e.beginCommit({description:o});e.getProtection().isLocked()&&e.recordSkipProtectionCheck(c);try{let a=e.getState();if(!a)return;let o=a.hyperlinkSpatial,l=o,u=e.styles,d=e=>{let t={...e.getAuthoredProperties()};if(t.named){let e=u.getNamedStyles().getByName(t.named)?.getRanged().getPropertiesAt(0,0,null);t=i.mergeContentful(e,t)}return delete t.font,t.named=z.BuiltInName.Hyperlink,t},f=[],p=t.length;for(let r=0;r<p;r++){let i=t[r],s=null,c=i.value,u=c===void 0?n:c,p;if(u!==null){if(u.isIHyperlink)p={...u._p},s=u.getTextToDisplay();else if(typeof u==`string`)p={address:MF(u)};else if(u.address||u.textToDisplay){let e=u,t={...e};delete t.textToDisplay,t.address?(t.address=MF(t.address),p=t):p=null,s=e.textToDisplay??null}else p=null}else p=null;if(o===l&&(l=o.clone()),p!==null||o.size()>0){if(s&&n){let t=e.isDataColumn;nI(e,Vc(s,{majorStart:t?i.colStart:i.rowStart,majorEnd:t?i.colEnd:i.rowEnd,minorStart:t?i.rowStart:i.colStart,minorEnd:t?i.rowEnd:i.colEnd},t),void 0,null,{isHyperlink:!0,isBroadcast:!0})}p===null?e.getRangedEntries(a.hyperlinkSpatial,[i],{onEntry:(e,t)=>(l.insertNonOverlapping({...t,value:p}),t.value)}):(l.insertNonOverlapping({...i,value:p}),f.push({...i,value:d}))}}e.invalidateUsedCoords(),e.updateState({hyperlinkSpatial:l}),f.length>0&&FF(e,f,void 0,void 0,!1,!0),e.recordChange(c,`hyperlinks`,t),e.commitWithDirectives(c,s,r)}catch(e){throw c.rollback(),e}}var PF={axes:B.AxisSelection.Row,expandOnly:B.Axis.Column,skipCustomSize:!0,minContent:!0};function FF(e,t,n,r,i=!1,a=!1){let o=r?.description??m(`op.updateStyle`);a||e.protectionCheck(()=>[`formatCells`],t,o);let s=!a&&typeof n==`function`;for(let e=0;!a&&!s&&e<t.length;e++)s=typeof t[e].value==`function`;let c=e.beginCommit({description:o,savepoint:s});e.getProtection().isLocked()&&e.recordSkipProtectionCheck(c);let l=SD(t);try{let a=e.getState();if(!a)return;let o=c.getSavepointId(),s=e.getEntireCoords(),u=e.getEntireCoords,d=a.borderSpatial.clone(o),f=a.fillSpatial.clone(o),p=a.contentSpatial.clone(o),m=a.continuousFillSpatial,g=a.dateFormatSpatial,_=e.styles,v=rB(_),y=(e,t)=>{if(i&&e.value&&e.value.getProperties()?.numberFormat)return e;let n=h.sanitizeRange(e),r=e.value??new Am(_,u,n),a=t.value,o=a?a.getUpdateProperties()??a.getProperties():null,s=r.cloneWithUpdate(o);return s.isEmpty()&&(s=null),{...t,value:s}},b=e=>{let t=!m.isEmpty(),n=!g.isEmpty(),r=p.search(e),i=[],o=[];for(let t=0;t<r.length;t++){let n=r[t],a=n.value?n.value._p:null;if(!a)continue;let s=h.intersectRanges(n,e),c=a.alignment?.horizontal;c!==R.HorizontalAlignment.CenterContinuous&&c!==R.HorizontalAlignment.Fill||i.push({...s,value:v(new Am(_,u,s),{alignment:{horizontal:c}})});let l=Cm(_,a);l&&(nt(l)||pt(l))&&o.push({...s,value:l})}(t||i.length)&&(m===a.continuousFillSpatial&&(m=m.clone()),m.insertNonOverlapping({...e,value:null}),i.length>0&&m.load(xc(i,B.Axis.Column,2**53-1,(e,t)=>e[0].value?._p?.alignment?.horizontal===e[1].value?._p?.alignment?.horizontal?t:void 0))),(n||o.length)&&(g===a.dateFormatSpatial&&(g=g.clone()),g.insertNonOverlapping({...e,value:null}),o.length>0&&g.load(xc(o,B.Axis.Column,2**53-1,(e,t)=>e[0].value===e[1].value?t:void 0)))},x=(e,t,n)=>{let r=t?t.getUpdateProperties()??t.getProperties():null,i;if(n||r?.alignment===null?i=null:r?.alignment&&r.alignment.horizontal!==void 0&&(i=r.alignment.horizontal??null),i!==void 0){let t=i===R.HorizontalAlignment.CenterContinuous||i===R.HorizontalAlignment.Fill;if(t||!m.isEmpty()){m===a.continuousFillSpatial&&(m=m.clone());let n=t?v(new Am(_,u,e),{alignment:{horizontal:i}}):null;m.insertNonOverlapping({...e,value:n})}}let o=n?null:r?.numberFormat;if(o!==void 0){typeof o==`number`&&(o=Ce(o));let t=!!o&&(nt(o)||pt(o));!t&&g.isEmpty()||(g===a.dateFormatSpatial&&(g=g.clone()),g.insertNonOverlapping({...e,value:t?o:null}))}},S=!1,C=[],w=e=>{C.push({...e,rowStart:Math.max(e.rowStart-1,s.rowStart),rowEnd:Math.min(e.rowEnd+1,s.rowEnd)})},T=t.length;for(let r=0;r<T;r++){let a=t[r],o=a.value,c=o===void 0?n:o;if(typeof c==`function`){S=!0,w(a);let t={colStart:Math.max(a.colStart-1,s.colStart),rowStart:Math.max(a.rowStart-1,s.rowStart),colEnd:Math.min(a.colEnd+1,s.colEnd),rowEnd:Math.min(a.rowEnd+1,s.rowEnd)},n=e.composeDirectStyleView(t,{border:d,fill:f,content:p}),r=(e,t)=>{let n=e.value??new Am(_,u,h.sanitizeRange(e)),r=v(n,c);return r&&r.isEmpty()&&(r=null),{...t,value:r}},i=v(new Am(_,u,a),c,!0);i?._p?.borders&&iB(i,a,n,v,s),n.insertNonOverlapping({...a,value:i},{onIntersect:r}),aB(n,d,f,p,t),b(t);continue}let l=v(new Am(_,u,a),c,!0),m=null;if(l===null){w(a);let e={...a,value:null};d.insertNonOverlapping(e,{onIntersect:y}),f.insertNonOverlapping(e,{onIntersect:y}),p.insertNonOverlapping(e,{onIntersect:y})}else{let e=l.splitByFeature();m=e.content,e.border&&(w(a),e.border?._p?.borders&&iB(e.border,a,d,v,s),d.insertNonOverlapping({...a,value:e.border},{onIntersect:y})),e.fill&&f.insertNonOverlapping({...a,value:e.fill},{onIntersect:y}),e.content&&p.insertNonOverlapping({...a,value:e.content},{onIntersect:y})}(l===null||m)&&(S=!0);let g=m?m.getUpdateProperties()??m.getProperties():null;i||g?.named!==void 0?b(a):(l===null||m)&&x(a,m,l===null)}e.invalidateUsedCoords(),e.updateState({borderSpatial:d,fillSpatial:f,contentSpatial:p,continuousFillSpatial:m,dateFormatSpatial:g}),i?(e.notify(`onStyleChange`),c.commit()):(e.recordChange(c,`style`,t),C.length>0&&!1!==r?.autoFit&&e.recordAutoFit(c,C,PF),e.commitWithDirectives(c,l,S?r:{...r,autoFit:!1}))}catch(e){throw c.rollback(),e}}function IF(e,t,n,r,i){let a=ZF(i),o=t;for(let t=0;t<a.length;t++)if(o=LF(e,o,n,r,a[t]),o===null)return null;return o}function LF(e,t,n,r,i){if(i===null||t?.continuous)return null;let a=e.styles,o=e.getEntireCoords,s=rB(a),c={colStart:r,rowStart:n,colEnd:r,rowEnd:n},l=t?.borderStyle,u=t?.fillStyle,d=t?.contentStyle,f=u,p=d;if(typeof i==`function`){let e=s(Am.compose(l,u,d)??new Am(a,o,c),i),t=e&&!e.isEmpty()?e.splitByFeature():null,n=e=>JSON.stringify(e?.getProperties()?.borders??null);if(n(t?.border)!==n(l))return null;f=t?.fill,p=t?.content}else{let e=s(new Am(a,o,c),i,!0);if(!e)return null;let t=e.splitByFeature();if(t.border)return null;let n=(e,t)=>(e??new Am(a,o,c)).cloneWithUpdate(t.getUpdateProperties()??t.getProperties());t.fill&&(f=n(u,t.fill)),t.content&&(p=n(d,t.content))}let m={...t};f&&!f.isEmpty()?m.fillStyle=f:delete m.fillStyle,p&&!p.isEmpty()?m.contentStyle=p:delete m.contentStyle;let h=m.contentStyle?.getProperties(),g=h?.alignment?.horizontal;if(g===R.HorizontalAlignment.CenterContinuous||g===R.HorizontalAlignment.Fill)return null;let _=h?.numberFormat;return typeof _==`number`&&(_=Ce(_)),_&&(nt(_)||pt(_))?m.dateFormat=_:delete m.dateFormat,m}function RF(e,t,n,r,i){let a={colStart:r,rowStart:n,colEnd:r,rowEnd:n},o=rB(e.styles),s=ZF(i),c=t.search(a)[0]?.value??null;for(let t=0;t<s.length;t++)c=o(c??new Am(e.styles,e.getEntireCoords,a),s[t]);let l=Cm(e.styles,c?.getProperties());return!!l&&(nt(l)||pt(l))}function zF(e,t,n=null){if(e.protectionCheck(xF,t),t.length===1&&h.isSingleCell(t[0]))return;let r=B.AxisSelection.Both;n?.axes?r=n.axes:n===B.AxisSelection.Row?r=B.AxisSelection.Row:n===B.AxisSelection.Column&&(r=B.AxisSelection.Column);let i=n?.discardMultipleValues??!1,a=SD(t),o=e.getSelection().getCoords(),s=null,c=e.beginCommit({description:n?.description??m(`op.merge`)}),l=t[0];try{let u=e.getMerges(t);if(lD(t)||u.length>0){let n=h.unionRangesArrays(u),r=h.unionRangesArrays(t);if(!(!n&&!r||n&&r&&h.isRangeWithinRange(n,r)))throw console.warn(N(`error.sheet.mergeOverlapping`),t),new k(N(`error.sheet.mergeOverlapping`));BF(e,u)}let d=e.createSparseBuilder({axis:B.Axis.Column}),f=[],p=[],m=[];try{let n=e.getEntireCoords(),c=e.calcGrid.getContentful(),u=null;for(let e=0;e<t.length;e++)u=h.unionRanges(u,t[e]);let g=e.composeDirectStyleView(u??void 0),_=!1,v=t=>{let n={rowIndex:t.rowStart,colIndex:t.colStart},r=null;if(_){let e=c.search(t),a=e.length,o=[];for(let n=0;n<a;n++){let r=h.intersectRanges(e[n],t);if(r){for(let e=r.rowStart;e<=r.rowEnd;e++)for(let t=r.colStart;t<=r.colEnd;t++)o.push({rowIndex:e,colIndex:t});if(o.length>1&&!i)throw new A(N(`error.sheet.mergeMultipleValues`),`discardMultipleValues`)}}if(o.length>0){let e=o[0];for(let t=1;t<o.length;t++){let n=o[t];(n.rowIndex<e.rowIndex||n.rowIndex===e.rowIndex&&n.colIndex<e.colIndex)&&(e=n)}e.rowIndex===n.rowIndex&&e.colIndex===n.colIndex||(r=e);for(let t=0;t<o.length;t++){let r=o[t];r===e||r.rowIndex===n.rowIndex&&r.colIndex===n.colIndex||m.push({rowIndex:r.rowIndex,colIndex:r.colIndex,update:null})}}}r||=n;let a=null,o=null,s=null,u=null,d=null,v=null,y=null;OF.colStart=t.colStart,OF.rowStart=t.rowStart,OF.colEnd=t.colStart,OF.rowEnd=t.rowStart;let b=g.search(OF);if(b.length>0){y=b[0].value?.getPropertiesAt(t.rowStart,t.colEnd,null);let e=y?.borders;a=e?.left??null,o=e?.top??null,d=e?.right??null,v=e?.bottom??null}if(OF.colStart=t.colEnd,OF.colEnd=t.colEnd,b=g.search(OF),b.length>0){let e=b[0].value?.getPropertiesAt(t.rowStart,t.colEnd,null)?.borders;e&&e.right&&(s=e.right)}if(OF.colStart=t.colStart,OF.colEnd=t.colStart,OF.rowStart=t.rowEnd,OF.rowEnd=t.rowEnd,b=g.search(OF),b.length>0){let e=b[0].value?.getPropertiesAt(t.rowEnd,t.colStart,null)?.borders;e&&e.bottom&&(u=e.bottom)}if(!s||!u){OF.colStart=t.colEnd,OF.colEnd=t.colEnd,OF.rowStart=t.rowEnd,OF.rowEnd=t.rowEnd,b=g.search(OF);let e=b?.[0];if(e){let n=e.value?.getPropertiesAt(t.rowEnd,t.colEnd,null)?.borders;n&&(s||=n.right??null,u||=n.bottom??null)}}let x=!h.isEqualCells(r,n);if(x){OF.colStart=r.colIndex,OF.colEnd=r.colIndex,OF.rowStart=r.rowIndex,OF.rowEnd=r.rowIndex;let e=g.search(OF);e.length>0&&(y=e[0].value?.getPropertiesAt(r.rowIndex,r.colIndex,null)??y)}if(f.push({...t,value:null}),f.push({...t,value:{...y,borders:{top:o,left:a,right:s??d,bottom:u??v,horizontal:null,vertical:null}}}),x){let t=e.getRange(r).getCell();m.push({rowIndex:n.rowIndex,colIndex:n.colIndex,update:t}),m.push({rowIndex:r.rowIndex,colIndex:r.colIndex,update:null})}p.push(t),l=h.unionRanges(l,t)},y=[...t].sort(h.createRangeComparator(B.Axis.Column)),b=y.length;for(let t=0;t<b;t++){let i=y[t];if(!h.isSingleCell(i)){if(s||!o||!h.isCellWithinRange(o.cell,i)||o.cell.rowIndex===i.rowStart&&o.cell.colIndex===i.colStart||(s={...a,cell:{rowIndex:i.rowStart,colIndex:i.colStart}}),_=c.search(i).length>0,e.validateOrRemoveOverlaps(i,`merge`),i.colStart<n.colStart||i.rowStart<n.rowStart||i.colEnd>n.colEnd||i.rowEnd>n.rowEnd)throw new k(N(`error.sheet.mergeOob`));if(r===B.AxisSelection.Column){let e=i.rowEnd===n.rowEnd?Math.max(1,n.rowEnd):i.rowEnd;for(let t=i.rowStart;t<=e;t++)v({...i,rowStart:t,rowEnd:t})}else if(r===B.AxisSelection.Row){let e=i.colEnd===n.colEnd?Math.max(1,n.colEnd):i.colEnd;for(let t=i.colStart;t<=e;t++)v({...i,colStart:t,colEnd:t})}else v(i)}}m.sort((e,t)=>e.colIndex-t.colIndex||e.rowIndex-t.rowIndex);let x=m.length;for(let e=0;e<x;e++){let t=m[e];d.pushAt(t.rowIndex,t.colIndex,t.update)}d.apply(),e.indexMerges(p),FF(e,f),e.updateState({})}catch(e){throw e.type?new A(e.message??`Unable to merge`,e.type):new k(e.message??`Unable to merge`)}s&&(a=s),a&&e.recordSelection(c,a,n),e.recordChange(c,`merges`,t),c.commit()}catch(e){throw c.rollback(),e}}function BF(e,t,n){if(e.protectionCheck(xF,t),lD(t))throw new k(N(`error.sheet.unmergeOverlapping`));if(!e.getState())return;let r=h.unionRangesArrays(t),i=SD(t),a=e.beginCommit({description:n?.description??m(`op.unmerge`)}),o=e.stateFor(a).mergeSpatial,s=[];try{let c=t.length;for(let e=0;e<c;e++){let n=t[e],i=o.search(n),a=i.length;for(let e=0;e<a;e++){let t=i[e];if(!h.isSingleCell(n)&&!h.isRangeWithinRange(t,r))throw new k(N(`error.sheet.unmergePartial`));s.push(t)}}if(s.length===0)return void a.rollback();e.indexMerges(null,s),e.recordChange(a,`merges`,t),e.commitWithDirectives(a,i,n)}catch(e){throw a.rollback(),e}}function VF(e){let t=e.entry;if(t===null){let n=e.rowIndex,r=e.colIndex;t=e.entry=new wA(e.a1,{colStart:r,rowStart:n,colEnd:r,rowEnd:n},null).imageAtAnchor()}return t}function HF(e,t,n){return VF(e).getTextAt(t,n)}var UF={rowIndex:0,colIndex:0},WF=e=>e.r1c1??=Cf(e.a1,e.rowIndex,e.colIndex),GF=(e,t)=>e===null||t===null?e===t?t:void 0:WF(e)===WF(t)?e:void 0,KF=(e,t)=>e===null||t===null?e===t?t:void 0:e,qF=e=>(t,n)=>{let r=t[0].value,i=t[1].value;if(r!==void 0&&i!==void 0)return e(r,i)===void 0?void 0:n},JF=qF(GF),YF=qF(KF),XF=class{constructor(e){this.updates=e}};function ZF(e){return e instanceof XF?e.updates:[e]}var QF=(e,t)=>new XF([...ZF(e),...ZF(t)]);function $F(e,t,n,r,i=e.isDataColumn,a=!1){let o=i?B.Axis.Column:B.Axis.Row,s=e.getProtection().isLocked()&&!r?.isCalculatedFill&&!r?.isPivotLayout,c=e.getProtection().isFormatCellsAllowed(),l=e.strings,u={[G.Type.BorderStyle]:!1,[G.Type.FillStyle]:!1,[G.Type.ContentStyle]:!1,[G.Type.Table]:!1},d=!1,f=!1;s&&e.hasRangedEntries(`protectedRanges`,t)&&(u[G.Type.Unlock]=!1,d=!0,f=!0),e.hasRangedEntries(`mergeSpatial`,t)&&(u[G.Type.Merge]=!1,d=!0);let p=e.rangeStateIterator({bounds:t,axis:o,searchTypes:u,byCell:!0}),m=qc(i),h=qc(i,(e,t)=>{if(e===t)return t},QF),g=qc(i,(e,t)=>{if(e===t)return t}),_=qc(i,(e,t)=>{if(e===t)return t}),v=r?.isBroadcast??!1,y=qc(i,v?KF:GF),b=null,x=null;!1!==n?.textParser&&(x={ignoreQuotePrefix:!1,parse:null,...n&&!0!==n.textParser?n.textParser:{}},b=new Xz(l,null,e.cellOptions));let S=s&&xm(e.styles,null);return{ctx:e,options:n,internalOptions:r,isColumn:i,isDataChange:r?.isCell??!1,isInternalHyperlink:r?.isHyperlink??!1,isBroadcast:v,isLocked:s,allowFormatCells:c,hasUnlockRanges:f,runtime:e.runtime,richData:e.richData,isHeld:a,isRefused:!1,isLocalStyle:null,hasLateRefusals:!1,iterRanges:p,requiresRangeCheck:d,seekCoords:{rowIndex:0,colIndex:0},cellMajor:-1,cellMinor:-1,cellIntersection:null,optionsFromString:x,contextState:b,resolvedStringCache:new Map,lastDirectStyle:void 0,isTextNumFmt:!1,defaultStyleUnlocked:S,isStyleUnlocked:S,usedStyleUnlock:!1,lastUnlock:void 0,isUnlockExempt:!1,isPasswordGated:!1,deletes:m,styleUpdates:h,hyperlinkUpdates:g,commentUpdates:_,formulaUpdates:y,mergeUpdates:[]}}function eI(e,t,n,r){let i=null;if(e.requiresRangeCheck||e.isLocked||typeof t!=`number`?(e.requiresRangeCheck||e.isLocked||t!==null||e.isDataChange)&&(i=function(e,t,n,r){let i=function(e,t,n){let r=e.iterRanges;if(r===null)return null;let i=e.cellMajor,a=e.cellMinor;if(t<i||t===i&&n<a)return null;if(t===i&&n===a)return e.cellIntersection;let o=e.isColumn,s=e.seekCoords;s.rowIndex=o?n:t,s.colIndex=o?t:n;let c=r.next(s);if(c.done)return e.cellIntersection=null,e.iterRanges=null,e.requiresRangeCheck=!1,null;let l=c.value.cell,u=e.cellMajor=o?l.colIndex:l.rowIndex,d=e.cellMinor=o?l.rowIndex:l.colIndex,f=e.cellIntersection=c.value.intersection;return t===u&&n===d?f:null}(e,n,r);if(i?.merge){let t=i.merge.getCoords(),a=e.isColumn?t.colStart:t.rowStart,o=e.isColumn?t.rowStart:t.colStart;if(a!==n||o!==r)return}let a=i?.contentStyle;if(e.lastDirectStyle!==a&&(e.lastDirectStyle=a,e.isTextNumFmt=!1,e.isStyleUnlocked=e.defaultStyleUnlocked,a)){let t=a.getPropertiesAt(0,0,null),n=t?.numberFormat;n&&(e.isTextNumFmt=_t(n)),e.isLocked&&(e.isStyleUnlocked=xm(e.ctx.styles,t))}if(e.isDataChange&&t&&t.isICell){let i=t;if(i.isTopLeft()){let t=i.getSpans();e.hasLateRefusals=!0,e.mergeUpdates.push({colStart:e.isColumn?n:r,rowStart:e.isColumn?r:n,colEnd:(e.isColumn?n:r)+t.width-1,rowEnd:(e.isColumn?r:n)+t.height-1})}}UF.rowIndex=e.isColumn?r:n,UF.colIndex=e.isColumn?n:r;let o=nN(e.runtime,t,e.isTextNumFmt?null:e.optionsFromString,e.resolvedStringCache,!1,UF,e.isTextNumFmt&&!!e.optionsFromString&&!e.optionsFromString.ignoreQuotePrefix,e.richData);if(o===void 0)return;let s=o.value;if(typeof s==`string`&&s.length>Ut.MAX_TEXT_LENGTH&&(s=s.slice(0,Ut.MAX_TEXT_LENGTH)),o.stringToParse){kF[0].colIndex=e.isColumn?n:r,kF[0].rowIndex=e.isColumn?r:n,kF[1]=s,kF[2]=i,e.contextState.setState(kF);let t=e.optionsFromString?.parse(o.stringToParse,e.contextState.context),a=nN(e.runtime,t,e.optionsFromString,e.resolvedStringCache,!0,null,!1,e.richData);if(e.contextState.clear(),a===null)return a;a!==void 0&&(o={...a})}if(e.isLocked){let n=i?.unlock;if(n!==e.lastUnlock&&(e.lastUnlock=n,e.isUnlockExempt=!1,e.isPasswordGated=!1,n)){if(Array.isArray(n)){let t=n.length;for(let r=0;r<t;r++){if(n[r].isUnlocked()){e.isUnlockExempt=!0;break}e.isPasswordGated=!0}}else n.isUnlocked()?e.isUnlockExempt=!0:e.isPasswordGated=!0}if(!e.isUnlockExempt&&e.isStyleUnlocked)e.usedStyleUnlock=!0;else if(!e.isUnlockExempt){let n=e.isPasswordGated?N(`error.sheet.protectedRangeLocked`):N(`error.sheet.protectedSheet`);if(t===null||o.value!==void 0||!e.allowFormatCells&&o.style!==void 0)throw new b(n)}}if(e.isHeld&&(o.hyperlink!==void 0||o.comments!==void 0))return void(e.isRefused=!0);let c=e.isLocalStyle;if(c&&o.style&&!c(e.isColumn?r:n,e.isColumn?n:r,o.style))return void(e.isRefused=!0);if(!e.isInternalHyperlink){let t=o.style,i=t!==void 0&&(t!==null||e.isDataChange),a=o.hyperlink,s=a!==void 0&&(a!==null||e.isDataChange);e.isLocked&&!e.ctx.isMoveRuled()&&(i&&e.ctx.protectionCheck(()=>[`formatCells`],null,m(`op.updateStyle`)),s&&e.ctx.protectionCheck(()=>[`insertHyperlinks`,`formatCells`],null,m(`op.setHyperlink`)));let c=o.impliedStyle;c!==void 0&&e.styleUpdates.append(n,r,c),i&&(typeof t==`function`&&(e.hasLateRefusals=!0),e.styleUpdates.append(n,r,t)),s&&(e.hasLateRefusals=!0,e.hyperlinkUpdates.append(n,r,a));let l=o.comments;l!==void 0&&(e.hasLateRefusals=!0,e.commentUpdates.append(n,r,l))}let l=o.formula;return l===void 0||l===null&&!e.isDataChange||e.formulaUpdates.append(n,r,l===null?null:{a1:l,rowIndex:e.isColumn?r:n,colIndex:e.isColumn?n:r,r1c1:null,entry:null}),s}(e,t,n,r)):i=t,typeof i==`number`){let e=FB(i);i=typeof e==`number`?IB(e):e}return i===null&&e.deletes.append(n,r),i}function tI(e,t,n,r,i){let a=e.ctx,o=a.beginCommit({description:e.options?.description??m(`op.updateCells`),savepoint:e.hasLateRefusals});(e.hasUnlockRanges||e.isLocked&&e.allowFormatCells)&&a.recordSkipProtectionCheck(o);try{(function(e,t,n,r,i,a){let{ctx:o,options:s,internalOptions:c,isBroadcast:l,usedStyleUnlock:u,deletes:d,styleUpdates:f,hyperlinkUpdates:p,commentUpdates:m,formulaUpdates:g,mergeUpdates:_}=e,v=o.calcGrid,y=t.getSavepointId(),b={commitId:t.getId(),cloneKey:y},x=d.done(),S=x.length,C=Ij(n,o.isDataColumn),w=g.done();w.length>1&&(w=xc(w,e.isColumn?B.Axis.Column:B.Axis.Row,1,l?YF:JF)),SF(v.getSpills(),x,C,w);let T=S===0&&w.length===0&&C.length===1&&h.isSingleCell(C[0]),E=DF(o.getState().pivotTables,x,C,w,T);if(E.typed){let{table:e,row:r,column:a}=E.typed;e._typeAt(r,a,n[0][1][0][1].at(0)),o.commitWithDirectives(t,{ranges:[i]},s);return}let D=E.covered;if(D)for(let e=0;e<D.length;e++)D[e].delete();let O=o.getState().ignoredErrors,A=O.remove(x,C,w);A!==O&&o.updateState({ignoredErrors:A});let j=c?.arrayFixed;if(j){let e=w.length===1?w[0]:null;if(!e||!e.value||!h.isSingleCell(e)||e.colStart!==j.colStart||e.rowStart!==j.rowStart)throw new k(N(`error.sheet.arrayFixedFormula`))}for(let e=0;e<S;e++)v.remove(x[e],b);let M;n.length>0&&(M={tuples:n,bounds:r});let ee=w.length,te=Array(ee);for(let e=0;e<ee;e++){let t=w[e],n=t.value?VF(t.value).a1:null;te[e]={...t,value:n}}(M||te.length>0)&&v.setInputs(M,te,j?{...b,arrayFixed:j}:b);let P=function(e){let t=null;for(let n=0;n<e.length;n++){let r=e[n];if(!(r.value instanceof XF)){t?.push(r);continue}t??=e.slice(0,n);let i=r.value.updates;for(let e=0;e<i.length;e++)t.push({...r,value:i[e]})}return t??e}(f.done());P.length>0&&FF(o,P,void 0,void 0,!1,!0),_.length>0&&zF(o,_);let F=p.done();F.length>0&&NF(o,F);let ne=m.done();ne.length>0&&jF(o,ne),s?.autoFormat&&o.recordAutoFormat(t);let re={ranges:[a?.selection??i]};o.recordChange(t,`data`,a?.changes??[i]);let ie=[];for(let e=0;e<ee;e++){let t=w[e];t.value&&ie.push({colStart:t.colStart,rowStart:t.rowStart,colEnd:t.colEnd,rowEnd:t.rowEnd})}o.recordFormulasEntered(t,ie),u&&o.recordSkipProtectionCheck(t),o.commitWithDirectives(t,re,s)})(e,o,t,n,r,i)}catch(e){throw o.rollback(),e}}function nI(e,t,n,r=void 0,i=null){if(!t)return;let a=t.tuples,o=t.bounds,s=e.isDataColumn,c=o.majorStart,l=o.majorEnd,u=o.minorStart,d=o.minorEnd,f={colStart:s?c:u,rowStart:s?u:c,colEnd:s?l:d,rowEnd:s?d:l};(r??=((t,n)=>{e.validateCoords(t,n??N(`error.sheet.oobRange`))}))(f);let p=$F(e,f,n,i),m=[],h=e.lists.createList,g=[],_=-1,v=-1,y=a.length;for(let e=0;e<y;e++){let t=a[e],n=t[0];if(_>=n)throw new Lo.OutOfOrderError(`Duplicate or out of order major indices: {${n}}.`);if(_=n,v=-(2**53-1),n<c||n>l)throw new w(`Provided major bounds is invalid`);let r=t[1],i=[],o=r.length;for(let e=0;e<o;e++){let t=r[e],a=t[1],o=a.length,s=t[0],c=s;if(v>c)throw new Lo.OutOfOrderError(`Duplicate or out of order minor indices: {${c}}.`);if(c<u||c+o>d+1)throw new w(`Provided minor bounds is invalid`);let l=0,f=0,m=typeof a.at==`function`;for(let e=0;e<o;e++){let t=eI(p,m?a.at(e):a[e],n,c);t==null?(l>0&&(i.push([s,h(g,l,f)]),l=0,f=0),s=c+1):(g[l++]=t,f|=Lo.hintOf(t)|(t===g[0]?0:Lo.Hint.NotUniform)),c++}v=c,l>0&&i.push([s,h(g,l,f)])}i.length>0&&m.push([n,i])}tI(p,m,o,f)}function rI(e,t){let n=e.search(t),r=n.length;if(r===0)return e;let i=new Set;for(let e=0;e<r;e++){let t=n[e].value;t!==void 0&&i.add(t)}for(let n of i){let r=e.getCoords(n);r&&(e=e.setCoords(n,mm(r,[t])))}return e}var iI=new Map(Object.values($.Content).map(e=>[e.toLowerCase(),e]));function aI(e){if(e==null)return null;if(typeof e==`object`){let t=e.type??e.applyTo;return typeof t==`string`?aI(t):e}if(typeof e!=`string`)return e;let t=e.toLowerCase();return t===`all`?null:(t===`contents`||t===`content`?$.Content.Values:iI.get(t))??e}function oI(e,t,n=null,r,i=!1,a=null){n=aI(n);let o=null,s=m(`op.clear`),c=!1,l=!1,u=!1,d=!1,f=!1,p=!1,g=!1,_=!1,v=!1;if(n===$.Content.Formulas)s=m(`op.clearFormulas`),v=!0;else if(n===$.Content.Values)s=m(`op.clearValues`),p=!0;else if(n===$.Content.Formats)s=m(`op.clearFormats`),c=!0,o=[`formatCells`];else if(n===$.Content.Comments)s=m(`op.clearComments`),u=!0;else if(n===$.Content.Notes)s=m(`op.clearNotes`),d=!0;else if(n===$.Content.Hyperlinks)s=m(`op.clearHyperlinks`),l=!0,o=[`formatCells`];else if(n===$.Content.DataValidations)s=m(`op.clearDataValidations`),g=!0,o=[];else if(n===$.Content.Sparklines)s=m(`op.clearSparklines`),_=!0,o=[`formatCells`];else if(n===$.Content.Tables)s=m(`op.clearTables`),f=!0;else{if(n!==null)throw new k(N(`error.sheet.clearUnsupported`,{type:n}));o=[],s=m(`op.clearAll`),p=!0,c=!0,l=!0,u=!0,d=!0,g=!0}let y=(n===$.Content.Values||n===$.Content.Formulas||n===null)&&(e.isMoveRuled()?e.getProtection().isLocked():e.assertContentEditable(t));y&&n===null&&(o=null,a||(c=!1,u=!1,d=!1)),o!==null&&e.protectionCheck(()=>o,t,r?.description??s),(p||v)&&SF(e.calcGrid.getSpills(),h.sanitizeRangeArray(t));let b=v?function(e,t){let n=e.getFormulas(),r=e.getSpills(),i=[],a=t.length;for(let e=0;e<a;e++){let a=t[e],o=n.search(a);for(let e=0;e<o.length;e++){let t=h.intersectRanges(o[e],a);t&&i.push(t)}if(r.isEmpty())continue;let s=r.search(a);for(let e=0;e<s.length;e++){let t=s[e];t.value.getKind()!==`pivot`&&h.isCellWithinRange({rowIndex:t.rowStart,colIndex:t.colStart},a)&&i.push({colStart:t.colStart,rowStart:t.rowStart,colEnd:t.colEnd,rowEnd:t.rowEnd})}}return i.length>1?Sc(i):i}(e.calcGrid,h.sanitizeRangeArray(t)):null,x=p?DF(e.getState().pivotTables,h.sanitizeRangeArray(t)).covered:null,S=SD(t),C=e.beginCommit({description:r?.description??s});if((o!==null||y)&&e.getProtection().isLocked()&&e.recordSkipProtectionCheck(C),x)for(let e=0;e<x.length;e++)x[e].delete();if(p||c){let n=e.getState().ignoredErrors,r=n.remove(h.sanitizeRangeArray(t));r!==n&&e.updateState({ignoredErrors:r})}else if(b&&b.length>0){let t=e.getState().ignoredErrors,n=t.remove(b);n!==t&&e.updateState({ignoredErrors:n})}let w=e.getState(),T=e.calcGrid,E={commitId:C.getId(),cloneKey:C.getSavepointId()},D=w.conditionalFormats,O=w.dataValidations,A=w.cellControls,j=w.sparklineGroups;try{let o=h.sanitizeRangeArray(t);if(l&&!w.hyperlinkSpatial.isEmpty()&&NF(e,o,null,void 0,y),u&&d&&!w.comments.isEmpty())jF(e,o,null);else if((u||d)&&!w.comments.isEmpty()){let t=function(e,t,n){let r=[],i=t.length;for(let a=0;a<i;a++){let i=t[a],o=e.search(i),s=o.length;for(let e=0;e<s;e++){let t=o[e];t.value&&t.value.isNote()===n&&r.push({...h.sanitizeRange(t),value:null})}}return r}(w.comments,o,d);t.length>0&&jF(e,t,null)}if(c&&(FF(e,o,null,void 0,!1,y),i||y||BF(e,o)),g&&!(c||p||f)&&!O.isEmpty()){let e=t.length;for(let n=0;n<e;n++)O=rI(O,t[n])}if(_&&!j.isEmpty()){let e=t.length;for(let n=0;n<e;n++)j=rI(j,t[n])}if(c||p||f){let r=t.length;for(let o=0;o<r;o++){let r=t[o];if(!c||i||D.isEmpty()||(D=rI(D,r)),!c||i||A.isEmpty()||(A=rI(A,r)),n===null&&c&&p&&!i&&!j.isEmpty()&&(j=rI(j,r)),!g||i||O.isEmpty()||(O=rI(O,r)),!i){let t=e.getTables().getItems({address:r}),i=t.length;for(let e=0;e<i;e++){let i=t[e],o=i.getRange().getCoords();h.isRangeWithinRange(o,r)&&(a&&h.isRangeWithinRange(o,a)||(y||!f&&n!==null?c&&i.updateStyleOptions({name:null}):i._remove(`error`)))}let o=e.getAutoTable();if(o&&!y){if(!h.isRangeWithinRange(o.getRange().getCoords(),r))continue;o.delete()}}}}if(p){let e=t.length;for(let n=0;n<e;n++)T.remove(t[n],{...E,clearArrays:!0})}if(b&&b.length>0){let e=T.getValues(),t=b.length,n=Array(t);for(let r=0;r<t;r++)n[r]=e.getValues(b[r]);for(let e=0;e<t;e++){T.remove(b[e],E);let t=n[e];t&&t.tuples.length>0&&T.setInputs(t,null,E)}}e.updateState({conditionalFormats:D,dataValidations:O,cellControls:A,sparklineGroups:j}),e.recordChange(C,`data`,t),e.commitWithDirectives(C,S,r)}catch(e){throw C.rollback(),e}}var sI=new Set([`description`,`axis`,`skipBoundsCheck`]),cI=class e{constructor(e){this._transaction=null,this._count=0,this._isCell=!1,this._scan=null,this._isBeginning=!1,this._isOriented=!1,this._isTransposed=!1,this._builder=null,this._changes=null,this._firstWrites=[],this._firstValue=void 0,this._lastMajor=0,this._lastMinor=0,this._isValueAtLast=!1,this._hasValues=!1,this._majorMin=0,this._majorMax=0,this._minorMin=0,this._minorMax=0,this._generation=0,this._ctx=e}isHolding(){return this._count>0}hold(e,t,n,r){let i=this._ctx;if(!e||n||i.isClosed())return!1;if(i.isMadeAsItComes())return this.release(),!1;let a=i.transactions.getCurrentTransaction();if(!a)return!1;let o=e.bounds,s=o.majorStart,c=o.minorStart;if(s!==o.majorEnd||c!==o.minorEnd)return!1;let l=!1;if(r){for(let e in r)if(r[e]){if(e===`isCell`)l=!0;else if(e!==`isBroadcast`)return!1}}if(t){for(let e in t)if(t[e]!==void 0&&!sI.has(e))return!1}let u=e.tuples[0]?.[1][0]?.[1];if(!u)return!1;let d=typeof u.at==`function`?u.at(0):u[0];if(typeof d==`object`&&d&&d.isICell)return!1;let f=i.isDataColumn,p=f?c:s,m=f?s:c,h=i.getEntireCoords();if(!h||p<h.rowStart||p>h.rowEnd||m<h.colStart||m>h.colEnd)return!1;let g=i.getSpills(a);return!(!g.isEmpty()&&g.search({rowStart:p,colStart:m,rowEnd:p,colEnd:m}).length>0)&&(this._holdIn(a),this._count>0&&!this._continues(s,c,l)&&this.flush(),this._push(s,c,d,l,h))}holdStyle(e,t,n,r,i){let a=this._ctx;if(typeof n!=`object`||!n||a.isClosed())return!1;if(a.isMadeAsItComes())return this.release(),!1;let o=a.transactions.getCurrentTransaction();if(!o)return!1;if(r){for(let e in r)if(r[e]!==void 0&&!sI.has(e))return!1}if(a.getMutations().getProtection().isLocked())return!1;let s=a.getEntireCoords();if(!s||e<s.rowStart||e>s.rowEnd||t<s.colStart||t>s.colEnd||!i())return!1;let c=a.isDataColumn,l=c?t:e,u=c?e:t;return this._holdIn(o),this._count>0&&!this._continues(l,u,null)&&this.flush(),this._pushStyle(l,u,n,s),!0}_holdIn(e){this._transaction!==e&&(this.flush(),this._transaction=this._ctx.transactions.beginCommit({savepoint:!1,flush:()=>{this._isBeginning||this.flush()},writes:this._ctx.writes,onRollback:()=>this.discard()}))}getTransaction(){return this._transaction}read(t,n){if(this._count===0)return e.NotHeld;let r=this._scan.isColumn;return this._valueAt(r?n:t,r?t:n)}_valueAt(t,n){if(!this._isOriented){let r=this._firstValue;return t===this._lastMajor&&n===this._lastMinor&&r!==void 0?r:e.NotHeld}if(this._changes.find(t,n)===void 0)return e.NotHeld;let r=this._builder.getAt(t,n);return r===void 0?this._scan.deletes.find(t,n)===void 0?e.NotHeld:null:r}readCell(t,n){if(this._count===0)return e.NotHeld;let r=this._scan,i=r.isColumn,a=i?n:t,o=i?t:n,s=this._valueAt(a,o),c=r.styleUpdates.find(a,o)?.value;if(s===e.NotHeld)return c===void 0?e.NotHeld:{value:null,isValueHeld:!1,formula:null,style:c};if(s===null&&this._isCell)return;let l=r.formulaUpdates.find(a,o)?.value;return{value:s,isValueHeld:!0,formula:l?HF(l,t,n):null,style:c}}readStyleUpdate(e,t){let n=this._scan.isColumn;return this._scan.styleUpdates.find(n?t:e,n?e:t)?.value}isHeldGeneration(e){return this._count>0&&this._generation===e}getGeneration(){return this._generation}flush(){if(this._count===0)return;let e=this._ctx.isDataColumn,t=this._scan,n=this._lastMajor,r=this._lastMinor,i=this._hasValues,a=i?{majorStart:this._majorMin,majorEnd:this._majorMax,minorStart:this._minorMin,minorEnd:this._minorMax}:{majorStart:n,majorEnd:n,minorStart:r,minorEnd:r},o=this._toRange(a.majorStart,a.minorStart,a.majorEnd,a.minorEnd),s,c;if(this._isOriented){s=this._builder.build()?.tuples??[];let e=this._changes.done(!0);c=Array(e.length);for(let t=0;t<e.length;t++){let n=e[t];c[t]={colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colEnd,rowEnd:n.rowEnd}}}else{let e=this._firstValue;s=e==null?[]:[[n,[[r,t.ctx.lists.createList([e])]]]],c=i?[o]:[]}this._clear();let l=e?n:r,u=e?r:n;tI(t,s,a,o,{changes:c,selection:{colStart:l,rowStart:u,colEnd:l,rowEnd:u}})}release(){let e=this._transaction;this.flush(),e&&this._ctx.transactions.getCurrentTransaction()===e&&(this._transaction=null,e.commit())}discard(){this._clear()}_toRange(e,t,n,r){return this._ctx.isDataColumn?{colStart:e,rowStart:t,colEnd:n,rowEnd:r}:{colStart:t,rowStart:e,colEnd:r,rowEnd:n}}_continues(e,t,n){if(n!==null&&n!==this._isCell)return!1;let r=this._lastMajor,i=this._lastMinor;return e===r&&t===i?n===null||!this._isValueAtLast:this._isOriented?this._isTransposed?t>i||t===i&&e>r:e>r||e===r&&t>i:e>r||t>i}_begin(e,t,n){this._isBeginning=!0;try{let r=$F(this._ctx.getMutations(),e,void 0,t?{isCell:!0}:null,n,!0);return r.isLocalStyle=(e,t,n)=>this._ctx.isLocalStyle(this._transaction,e,t,n),r}finally{this._isBeginning=!1}}_scanCell(e,t,n,r){return e.isRefused=!1,eI(e,t,n,r)}_beginRun(e,t,n){let r=this._begin(this._toRange(e,t,e,t),n,this._ctx.isDataColumn);return this._scan=r,this._isCell=n,this._isOriented=!1,r}_orientTo(e,t,n){this._orient(e!==this._lastMajor&&(t===this._lastMinor||e<=this._lastMajor),n)}_push(e,t,n,r,i){let a;if(this._count===0||!this._isOriented&&e===this._lastMajor&&t===this._lastMinor){let i=this._count===0?this._beginRun(e,t,r):this._scan;if(a=this._scanCell(i,n,e,t),i.isRefused)return!1;this._firstWrites.push(n),this._firstValue=a}else{this._isOriented||this._orientTo(e,t,i);let r=this._scan,o=this._isTransposed,s=o?t:e,c=o?e:t;if(a=this._scanCell(r,n,s,c),r.isRefused)return!1;a!=null&&this._builder.pushAt(s,c,a),this._changes.append(s,c)}return this._hasValues?(e<this._majorMin&&(this._majorMin=e),e>this._majorMax&&(this._majorMax=e),t<this._minorMin&&(this._minorMin=t),t>this._minorMax&&(this._minorMax=t)):(this._hasValues=!0,this._majorMin=this._majorMax=e,this._minorMin=this._minorMax=t),this._lastMajor=e,this._lastMinor=t,this._isValueAtLast=!0,this._count++,!0}_pushStyle(e,t,n,r){if(this._count===0||!this._isOriented&&e===this._lastMajor&&t===this._lastMinor)(this._count===0?this._beginRun(e,t,!1):this._scan).styleUpdates.append(e,t,n),this._firstWrites.push(new lI(n));else{this._isOriented||this._orientTo(e,t,r);let i=this._isTransposed;this._scan.styleUpdates.append(i?t:e,i?e:t,n)}e===this._lastMajor&&t===this._lastMinor&&this._count!==0||(this._isValueAtLast=!1),this._lastMajor=e,this._lastMinor=t,this._count++}_orient(e,t){let n=this._ctx.isDataColumn,r=this._begin(t,this._isCell,e?!n:n),i=e?this._lastMinor:this._lastMajor,a=e?this._lastMajor:this._lastMinor,o=r.ctx.lists.createList,s=e?new Lo.TransposedBuilder(o):new Lo.Builder(o),c=qc(r.isColumn),l=this._firstWrites;for(let e=0;e<l.length;e++){let t=l[e];if(t instanceof lI){r.styleUpdates.append(i,a,t.update);continue}let n=this._scanCell(r,t,i,a);n!=null&&s.pushAt(i,a,n),c.append(i,a)}this._scan=r,this._builder=s,this._changes=c,this._isTransposed=e,this._isOriented=!0,this._firstWrites=[],this._firstValue=void 0}_clear(){this._generation++,this._count=0,this._scan=null,this._builder=null,this._changes=null,this._isOriented=!1,this._firstWrites=[],this._firstValue=void 0,this._isValueAtLast=!1,this._hasValues=!1}},lI=class{constructor(e){this.update=e}};(cI||={}).NotHeld=Symbol(`NotHeld`);var uI=(e,t,n)=>{if(!e||e.length===0)return null;let r=[],i=[],a=t,o=!1,s=e.length;for(let t=0;t<s;t++){let s=e[t];if(!(s.max<a)){if(s.min>n)break;o=!0,s.min>a&&(r.push(a),i.push(s.min-1)),a=Math.max(a,s.max+1)}}return o?(a<=n&&(r.push(a),i.push(n)),{start:Int32Array.from(r),end:Int32Array.from(i),count:r.length}):null},dI=(e,t)=>{let n=e.end,r=0,i=e.count;for(;r<i;){let e=r+i>>>1;n[e]<t?r=e+1:i=e}return r},fI=class extends x{_materialize(e){let t=this._rOff,n=this._pool,r=this._store,i=r.keys,a=r.type,o=r.value,s=t[e+1],c={};for(let r=t[e];r<s;r++){let e=n[r],t=i[a[e]],s=o[e],l=c[t];if(l){if(Array.isArray(l)){if(Array.isArray(s)){let e=s.length;for(let t=0;t<e;t++)l.push(s[t])}else l.push(s)}else c[t]=[l,s]}else c[t]=s}return c}},pI=(e,t,n)=>{if(e.pivotTables.isEmpty())return null;let r=nD(e.pivotTables,{rowStart:t,colStart:n,rowEnd:t,colEnd:n});return r.length>0?r[0].value:null},mI={rowStart:0,colStart:0,rowEnd:0,colEnd:0},hI={visibility:`visible`,includeEmpty:!0};function gI(e,t){if(!e.state||!t||!t.searchTypes)return bo;let n=t.bounds??e.getUsedCoords()??e.getEntireCoords(),r=null;!0===t.searchTypes?r=Wf:i.isObject(t.searchTypes)&&(r=t.searchTypes);let a=t.ignoreHidden,o=!0===a||a===B.Axis.Row?Bz(e.rowHeaders):null,s=!0===a||a===B.Axis.Column?Bz(e.columnHeaders):null,c=function(e,t,n,r,i,a,o){let s=e.state,c=e.calcGrid,l=uI(a,t.rowStart,t.rowEnd),d=uI(o,t.colStart,t.colEnd);if(l&&l.count===0||d&&d.count===0)return null;let f=u(),p=f.keys,m=new Map,_=t.rowStart,v=t.rowEnd,y=t.colStart,b=t.colEnd,x=(e,t,n,r,i,a)=>{let o=f.count;o>=f.rowS.length&&g(f,o+1),f.rowS[o]=e,f.rowE[o]=t,f.colS[o]=n,f.colE[o]=r,f.type[o]=i,f.value[o]=a,f.count=o+1},S=(e,t,n)=>{let r=e.rowStart>_?e.rowStart:_,i=e.rowEnd<v?e.rowEnd:v,a=e.colStart>y?e.colStart:y,o=e.colEnd<b?e.colEnd:b;if(r>i||a>o)return;if(!l&&!d)return void x(r,i,a,o,t,n);if(l){let e=l.count;for(let s=dI(l,r);s<e;s++){let e=l.start[s];if(e>i)break;let c=e>r?e:r,u=l.end[s],f=u<i?u:i;if(!d){x(c,f,a,o,t,n);continue}let p=d.count;for(let e=dI(d,a);e<p;e++){let r=d.start[e];if(r>o)break;let i=d.end[e];x(c,f,r>a?r:a,i<o?i:o,t,n)}}return}let s=d.count;for(let e=dI(d,a);e<s;e++){let s=d.start[e];if(s>o)break;let c=d.end[e];x(r,i,s>a?s:a,c<o?c:o,t,n)}},C=e=>{let t=m.get(e);return t===void 0&&(t=p.length,p.push(e),m.set(e,t)),t};if(r&&r.length>0){let t=e.getEntireCoords(),n=r.length;for(let e=0;e<n;e++){let n=r[e],i=n?n.length:0;if(i===0)continue;let a=C(``+e);for(let e=0;e<i;e++){let r=wf(n[e],t);S(r,a,r.value)}}}if(!n)return f.count>0?f:null;let w=(e,r)=>{let a=n[e];if(a===void 0||!r)return;let o=r.search(t,!1),s=o.length;if(s===0)return;let c=C(e);for(let e=0;e<s;e++){let n=o[e];if(a&&!h.isRangeWithinRange(t,n)||i&&!h.isRangeWithinRange(n,i))continue;let r=n.value;S(n,c,r?.model??r??!0)}};if(n[G.Type.Merge]!==void 0&&s.mergeSpatial){let e=s.mergeSpatial.search(t),n=e.length;if(n>0){let t=C(G.Type.Merge);for(let r=0;r<n;r++){let n=e[r];S(n,t,n.value)}}}return w(G.Type.Unlock,s.protectedRanges),w(G.Type.Continuous,s.continuousFillSpatial),w(G.Type.DateFormat,rD(s.dateFormatSpatial,s.pivotTables,s.contentSpatial)),w(G.Type.Hyperlink,s.hyperlinkSpatial),w(G.Type.IgnoredErrors,s.ignoredErrors.getMap()),w(G.Type.Comments,s.comments),w(G.Type.BorderStyle,s.borderSpatial),w(G.Type.FillStyle,s.fillSpatial),w(G.Type.ContentStyle,s.contentSpatial),w(G.Type.Contentful,c.getContentful()),w(G.Type.Formula,{search:t=>wm(c.getFormulas(),s.contentSpatial,t,e.cellOptions.getProtection(),e.cellOptions.styles)}),w(G.Type.CalcStatus,c.getCalcStatus()),w(G.Type.CalcError,c.getCalcErrors()),w(G.Type.Circular,c.getCirculars()),n[G.Type.Error]!==void 0&&w(G.Type.Error,e.calcGrid.getErrorValues()),n[G.Type.Kind]!==void 0&&e.getKinds&&w(G.Type.Kind,e.getKinds()),n[G.Type.Anomalies]!==void 0&&e.getAnomalies&&w(G.Type.Anomalies,e.getAnomalies()),n[G.Type.Role]!==void 0&&e.getRoles&&w(G.Type.Role,e.getRoles()),w(G.Type.Spills,{search:e=>jj(c.getSpills(),e)}),w(G.Type.Table,s.tables),w(G.Type.AutoTable,s.autoTables),w(G.Type.Pivot,{search:e=>nD(s.pivotTables,e)}),w(G.Type.DataValidations,s.dataValidations),w(G.Type.Conditionals,s.conditionalFormats),w(G.Type.CellControls,s.cellControls),w(G.Type.Sparklines,s.sparklineGroups),f.count>0?f:null}(e,n,r,t.injectReferences,t.fullyContained?n:void 0,o,s);if(!c)return bo;let l=(t.axis??B.Axis.Column)!==B.Axis.Row,d=t.reverse??!1,f=t.byCell??!1,p=t.includeMergeOverflow??!1,m=n.colStart,_=n.rowStart,v=new fI(c,n,l,d);return{next:e=>{let t;if(t=f?e?v.seekCell(e.rowIndex,e.colIndex):v.nextCell():v.nextRegion(),!t)return yo;let n=v.intersection,r;if(p){let e=n?.merge;if(e){let t=e.getCoords(),n=t.colStart,i=t.rowStart;n<m&&_<i&&(r={colIndex:n,rowIndex:i})}}r||={colIndex:v.colStart,rowIndex:v.rowStart};let i={colIndex:v.colEnd,rowIndex:v.rowEnd};return{done:!1,value:{start:d?i:r,end:d?r:i,cell:f?{colIndex:v.cellCol,rowIndex:v.cellRow}:null,intersection:n}}}}}function _I(e,t,n){let r=e.state;if(!r||!t)return null;let i=e.getEntireCoords();n&&(i={colStart:Math.max(i.colStart-n,i.colStart),rowStart:i.rowStart,colEnd:Math.min(i.colEnd+n,i.colEnd),rowEnd:i.rowEnd});let a={rowStart:t.rowStart,colStart:i.colStart,rowEnd:t.rowEnd,colEnd:i.colEnd},o={bounds:a,searchTypes:qf,axis:B.Axis.Row,ignoreHidden:!0,byCell:!1},s=t.colStart,c=t.colEnd,l,u,d=-1,f=(e,t)=>{let n=e.next();for(;!n.done;){let r=n.value,i=r.intersection,a=i.contentful;if(a){let e=r.start.rowIndex;if(!u||e!==d){let n=r.end.rowIndex,o=a.getCoords(),s=t?o.colEnd:o.colStart,c=null;t&&(c=i.continuous),l||=[];for(let t=e;t<=n;t++)l.push({rowIndex:t,colIndex:s,continuous:c,intersection:i,scalar:null,leftIndex:0,rightIndex:0,overflow:null,style:null})}d=e,u=r}n=e.next()}};s>i.colStart&&(a.colStart=i.colStart,a.colEnd=t.colStart-1,f(gI(e,o),!0)),d=-1,u=void 0,c<i.colEnd&&(a.colStart=t.colEnd+1,a.colEnd=i.colEnd,f(gI(e,o),!1));let p=e.calcGrid.getValues();if(!l)return null;l.sort(h.columnFirstCellComparator);let m=l.length,g=e.cellOptions,_,v;for(let e=0;e<m;e++){let t=l[e],n=t.rowIndex,i=t.colIndex,a=p.getValueAt(n,i);t.scalar=a;let o=t.continuous;if(o||typeof a==`string`&&!t.intersection?.merge){mI.colStart=i,mI.rowStart=n,mI.colEnd=i,mI.rowEnd=n;let e=pI(r,n,i),l=e?hN(a,mI,{...t.intersection,pivot:e},g,!1):hN(void 0,mI,t.intersection,g,!0);t.style=l;let u=e?._getLabelInsetAt(n,i)??null,d=pN(n,i,U.String,l,a,null,null,o?.getCoords(),g,u?dN(U.String,l,u):0);if(d){let e=d.leftIndex,n=d.rightIndex;t.leftIndex=e,t.rightIndex=n,(n>0&&i<s||e>0&&i>c)&&(t.overflow=d)}}t.overflow?(_||=[],_.push(t)):(v||=[],v.push(t))}return{overflows:_,stops:v}}var vI,yI=RegExp(`([0-9]+)$`),bI=86400,xI=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]!==null&&e[t]!==void 0)return{value:e[t],index:t};return null},SI=(e,t)=>Math.abs(e-t)<=1e-9*Math.max(1,Math.abs(e),Math.abs(t)),CI=(e,t,n)=>t===void 0?e:r=>{let i=e(r);return i===null||((e,t,n)=>n?e>t:e<t)(i,t,n)?null:i},wI=e=>Math.round((e-Math.floor(e))*bI),TI=(e,t,n)=>{let r=e+t/bI;return n&&r<0?r-Math.floor(r):r},EI=(e,t,n=!1)=>{let r=t(e[0],e[1]);if(r===0&&!n)return null;for(let n=2;n<e.length;n++)if(t(e[n-1],e[n])!==r)return null;return r},DI=(e,t)=>{for(let n=0;n<e.length;n++)if(!Pt(e[n],t))return!1;return!0},OI=(e,t)=>{if(e.length<2)return null;let n=EI(e,(e,t)=>wI(t)-wI(e),!0),r=DI(e,t),i=!0,a=xe(e[0],t);for(let n=1;n<e.length;n++)if(xe(e[n],t)!==a){i=!1;break}if(n!==null&&(r||i)){let n=EI(e,(e,n)=>Re(n,t)-Re(e,t));if(n!==null)return n%12==0?{unit:td.Year,monthEnd:r}:{unit:td.Month,monthEnd:r}}if(EI(e,(e,t)=>Math.round((t-e)*bI))===null){let n=!0;for(let r=0;r<e.length;r++)if(pe(e[r],t)){n=!1;break}return n&&EI(e,(e,n)=>ct(n,t)-ct(e,t))!==null?{unit:td.Weekday,monthEnd:!1}:null}return{unit:td.Day,monthEnd:!1}},kI={[td.Day]:`days`,[td.Weekday]:`weekdays`,[td.Month]:`months`,[td.Year]:`years`};function AI(e,t,n,r,i){let a=n=>{let i=t+n-1,a=t+n;for(let t=0;t<e.length;t++){let n=e[t],o=r?n.rowStart:n.colStart,s=r?n.rowEnd:n.colEnd;if(o<=i&&s>=a)return!0}return!1},o=[0];for(let e=1;e<n;e++)a(e)||o.push(e);return o.push(n),i?o:o.map(e=>n-e).sort((e,t)=>e-t)}(function(e){e.Date=class{constructor(e){this.type=H.Date,this.supportsStep=!0,this.supportsStop=!0,this._options=e;let t=e?.unit?kI[e.unit]:null;this.id=e?.monthEnd?`date.monthEnd`:t?`date.${t}`:`date`}matches(e,t=0){let n=0;for(let r=t;r<e.length;r++){let i=e[r];if(i!==null){if(typeof i!=`number`)break;n=r-t+1}}return n}createFillAt(e,t){let n=!0===(t={...this._options,...t}).date1904,r=this._options?.unit,i=[];for(let t=0;t<e.length;t++)e[t]!==null&&i.push(e[t]);let a=i.length;if(a===0)return null;let o=i[0],s=!0;for(let e=0;e<a;e++)if(i[e]>=1){s=!1;break}let c=!0===t.monthEnd,l=t.stopValue,u=t.stepValue,d=(e,t,r,i)=>{if(r===td.Month||r===td.Year){let a=r===td.Year?12*i:i;return CI(r=>le(e,a*(r-t),c,n),l,a>=0)}if(r===td.Weekday)return CI(r=>Xe(e,i*(r-t),n),l,i>=0);let a=(r===td.Day||e>=1?bI:3600)*i;return CI(n=>TI(e,a*(n-t),s),l,a>=0)};if(u!==void 0&&r!==void 0){let t=xI(e);return t?d(t.value,t.index,r,u):null}if(a===1){let n=u??(t.reverse?-1:1);return d(o,xI(e).index,r,n)}let f=(e,t=!1)=>EI(i,e,t),p=f((e,t)=>wI(t)-wI(e),!0),m=r?null:OI(i,n),h=r===td.Month||r===td.Year;if(h||m?.unit===td.Month||m?.unit===td.Year){let t=f((e,t)=>Re(t,n)-Re(e,n));if(t!==null&&p!==null){let r=DI(i,n)||c;if(u!==void 0){let t=xI(e);return d(t.value,t.index,td.Month,u)}return CI(e=>TI(le(o,t*e,r,n),p*e,!1),l,t>=0)}if(h)return null}if(r===td.Weekday||m?.unit===td.Weekday){let e=f((e,t)=>ct(t,n)-ct(e,n));return e===null?null:CI(t=>Xe(o,e*t,n),l,e>=0)}if(!r||r===td.Day){let t=f((e,t)=>Math.round((t-e)*bI));if(t!==null){if(u!==void 0){let t=xI(e);return d(t.value,t.index,td.Day,u)}return CI(e=>TI(o,t*e,s),l,t>=0)}}return null}};let t=e=>{let t=0;for(let n=0;n<e.length;n++)typeof e[n]!=`number`||isNaN(e[n])||t++;return t};e.Linear=class{constructor(e){this.id=`linear`,this.type=H.Number,this.supportsStep=!0,this.supportsStop=!0,this.supportsTrend=!0,this._options=e}matches(e,t=0){let n=0;for(let r=t;r<e.length;r++){let i=e[r];if(i!==null){if(typeof i!=`number`)break;n=r-t+1}}return n}createFillAt(e,n){let r=(n={...this._options,...n}).stopValue;if(!0===n.trend){if(t(e)<2)return null;let n=xA(e);return e=>n.m*(e+1)+n.b}let i=n.stepValue;if(i!==void 0){let t=xI(e);if(!t)return null;let n=t.value,a=t.index;return CI(e=>n+i*(e-a),r,i>=0)}let a=xA(e),o=a.b,s=a.m;return e.length===1?(n.reverse&&(s=-s),n.multiFill?CI(e=>e*s+o,r,s>=0):null):CI(e=>s*(e+1)+o,r,s>=0)}};let n=e=>{let t=[];for(let n=0;n<e.length;n++){let r=e[n];r!=null&&t.push(r)}return t},r=e=>{if(e.length<2||e[0]===0)return null;let t=e[1]/e[0];for(let n=2;n<e.length;n++)if(e[n-1]===0||!SI(e[n]/e[n-1],t))return null;return t};e.Growth=class{constructor(e){this.id=`growth`,this.type=H.Number,this.supportsStep=!0,this.supportsStop=!0,this.supportsTrend=!0,this._options=e}matches(e,t=0,i){let a=0;for(let n=t;n<e.length;n++){let r=e[n];if(r!==null){if(typeof r!=`number`)break;a=n-t+1}}if(a===0)return 0;if(i?.stepValue!==void 0||!0===i?.trend)return a;let o=n(e.slice(t,t+a));return o.length>=2&&r(o)===null?0:a}createFillAt(e,i){if(!0===(i={...this._options,...i}).trend){let n=[];for(let t=0;t<e.length;t++){let r=e[t];if(typeof r!=`number`||isNaN(r))n.push(null);else{if(r<=0)return null;n.push(Math.log(r))}}if(t(n)<2)return null;let r=xA(n);return e=>Math.exp(r.m*(e+1)+r.b)}let a=xI(e);if(!a)return null;let o,s=i.stepValue;if(s!==void 0)o=s;else{let t=n(e);if(t.length<2)return null;let i=r(t);if(i===null)return null;o=i}let c=a.value,l=a.index;return CI(e=>c*o**+(e-l),i.stopValue,c*o>=c)}};let i={sensitivity:`accent`};e.Ordinal=class{constructor(){this.id=`ordinal`,this.type=H.String}_template(e){let t=e.match(yI);if(!t)return null;let n=t[1],r=e.lastIndexOf(n);return r===-1?null:e.substring(0,r)}matches(e,t=0){let n=null,r=0;for(let a=t;a<e.length;a++){let o=e[a];if(o===null)continue;if(typeof o!=`string`)break;let s=this._template(o);if(s===null)break;if(n===null)n=s;else if(s.localeCompare(n,void 0,i)!==0)break;r=a-t+1}return r}createFillAt(e,t){let n=[],r=e[0],i=null,a=null,o=0;if(r){let e=r.match(yI);if(e){i=e[1],i.startsWith(`0`)&&(o=i.length);let t=r.lastIndexOf(i);a=r.substring(0,t)}}let s=e.length;for(let t=0;t<s;t++){let r=e[t],i=null;if(r){let e=r.substring(a.length,r.length);e.startsWith(`0`)&&(o=Math.max(o,e.length));let t=parseFloat(e);isNaN(t)||(i=t)}n.push(i)}let c=xA(n),l=c.b,u=c.m;return u!==0&&Number.isInteger(u)?n=>{if(e[n%s]===null)return null;let r=(s===1?t.reverse?-n:n:u*(n+1))+l,i=``+Math.abs(r),c=`0`.repeat(Math.max(0,o-i.length))+i;return a+c}:null}},e.Copy=class{constructor(){this.id=`copy`}matches(e,t=0){let n=0;for(let r=t;r<e.length;r++)e[r]!==null&&(n=r-t+1);return n}createFillAt(e,t){let n=e.length;return t=>e[t%n]??null}};let a=Object.freeze([`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`]),o=Object.freeze([`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]),s=Object.freeze([`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`]),c=Object.freeze([`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]);e.List=class{constructor(e){this.id=`list`,this.type=H.String,this._lists=[],this._map=new Map;let t=[];if(e?.customLists){let n=e.customLists;for(let e=n.length-1;e>=0;e--)t.push(n[e])}t.push(c),t.push(s),t.push(o),t.push(a);let n=this._map,r=[],i=t.length;for(let e=0;e<i;e++){let i=t[e],a=[];r.push(a);let o=i.length;for(let t=0;t<o;t++){let r=tn(i[t],!0),o=r.toLowerCase().trim(),s=n.get(o);s||(s=[],n.set(o,s));let c={value:r,asKey:o,major:e,minor:t};s.push(c),a.push(c)}}this._lists=Object.freeze(r)}matches(e,t=0){let n=null,r=0;for(let i=t;i<e.length;i++){let a=e[i];if(a===null)continue;if(typeof a!=`string`)break;let o=this._map.get(a.toLowerCase().trim());if(!o)break;if(n===null)n=o.map(e=>e.major);else{let e=[];for(let t=0;t<n.length;t++)for(let r=0;r<o.length;r++)if(o[r].major===n[t]){e.push(n[t]);break}if(e.length===0)break;n=e}r=i-t+1}return r}createFillAt(e,t){let n=[],r=e[0];n.push(r.toLowerCase().trim());let i=this._map.get(n[0]),a=new Map,o=new Set,s=i.length;for(let e=0;e<s;e++){let t=i[e];a.set(t.major,t)}if(e.length>1){let t=e.length;for(let r=1;r<t;r++){let t=e[r].toLowerCase().trim(),i=this._map.get(t);if(!i)return null;n.push(t);let s=i.length;for(let e=0;e<s;e++){let t=i[e].major;a.has(t)&&o.add(t)}}if(o.size===0)return null}let c=null,l=this._lists;for(let t=0;!c&&t<l.length;t++)(e.length===1||o.has(t))&&(c=a.get(t));if(!c)return null;let u=!1,d=!1,f=Jm(r);f===1?u=!0:(f===-1||Jm(r[0])===-1)&&(d=!0);let p=l[c.major],m=p.length,h=e=>{let t=this._map.get(e);if(!t)return-1;for(let e=0;e<t.length;e++)if(t[e].major===c.major)return t[e].minor;return-1},g=c.minor,_=1;if(n.length>1){let e=h(n[1]);if(e===-1)return null;_=e-g;let t=_>0?_-m:_+m;Math.abs(t)<Math.abs(_)&&(_=t);let r=n.length;for(let e=2;e<r;e++){let t=((g+e*_)%m+m)%m;if(h(n[e])!==t)return null}}e.length===1&&t?.reverse&&(_=-_);let v=e.length;return t=>{if(e[t%v]===null)return null;let n=(t*_+g)%m;n<0&&(n=m+n);let r=p[n].value??null;return u?r.toUpperCase():d?r.toLowerCase():r}}},e.Composite=class{constructor(e,t=`composite`){this._byType=new Map,e=Array.isArray(e)?[...e]:[e],this._fillers=e,this.id=t;let n=Object.values(H);for(let t=0;t<n.length;t++){let r=n[t];this._byType.set(r,e.filter(e=>e.type===void 0||e.type===r))}}matches(e,t=0,n){let r=0;for(let n=t;n<e.length;n++)e[n]!==null&&(r=n-t+1);if(r===0)return 0;let i=n?.types,a=t+r;for(let o=t;o<a;o++){if(e[o]===null)continue;let t=i?i[o]:pB(e[o],!0),a=this._byType.get(t),s=a?a.length:0;for(let t=0;t<s;t++)if(a[t].matches(e,o,n)>0)return r}return 0}createFillAt(e,t){this._fillers,t={multiFill:e.length>1,...t,trend:!1};let n=e.length,r=0,i=!1;for(let t=0;!i&&t<=n;t++)e[t]===null?r++:i=!0;let a=0;i=!1;for(let t=n-1;!i&&t>=r;t--)e[t]===null?a++:i=!0;let o=[],s=null,c=null,l=[],u=r,d=0,f=e=>{if(s&&s.max+1===u){let t=s.value;t.fillAt.push(e),s.max=u,t.length++,t.valuesLength++}else s={min:u,max:u,value:{fillAt:[e],start:u,length:1,valuesLength:n,blankInterval:0}};o.push(s)},p=t.types,m=t=>p?p[t]:pB(e[t],!0),h=n-a;for(u=r;u<h;){let n=e[u];if(n===null){u++;continue}let r=m(u),i=u+1;for(;i<h;){let e=m(i);if(e!==r&&e!==H.Null)break;i++}c=null;let a=0,s=this._byType.get(r),p=s?s.length:0;for(let t=0;!c&&t<p;t++){let n=Math.min(s[t].matches(e,u),i-u);n>0&&(c=s[t],a=n)}for(;a>0&&e[u+a-1]===null;)a--;if(!c){f(n),u++;continue}let g=0;d=0;for(let t=1;t<a;t++)e[u+t]===null?g++:(g>0&&(t-g===1?d=g:g!==d&&(d=0)),g=0);l=[e[u]];let _=1+d,v=a;for(let t=_;t<v;t+=_)l.push(e[u+t]);if(l.length>0){let e=l.length,n=e+(e-1)*d,r=c.createFillAt?.(l,t)??l;o.push({min:u,max:u+n-1,value:{fillAt:r,start:u,length:n,valuesLength:e,blankInterval:d}})}u+=a}let g=uo(o);return e=>{let t=e>=0,r=Math.abs(e),i=fo(r%n,g);if(!i)return null;let a=Math.floor(r/n),o=i.length,s=i.start,c=(a+ +!!t)*s+(a+ +!t)*(n-(s+o)),l=e+(t?-c:c),u=i.blankInterval;if(u!==0){let e=l%o;if(e%(1+u)!==0)return null;l=Math.floor(e/(1+u))+i.valuesLength*a}let d=i.fillAt;return typeof d==`function`?d(l):d[l%d.length]}}};let l=e.Types={Series:new vI.Composite([new vI.Date,new vI.Linear,new vI.Ordinal,new vI.List],`series`),Linear:new vI.Linear,Growth:new vI.Growth,DateDays:new vI.Date({unit:td.Day}),DateWeekdays:new vI.Date({unit:td.Weekday}),DateMonths:new vI.Date({unit:td.Month}),DateYears:new vI.Date({unit:td.Year}),DateMonthEnd:new vI.Date({unit:td.Month,monthEnd:!0}),Copy:new vI.Copy},u=e.Presets={Copy:{id:`copy`,filler:l.Copy},Series:{id:`series`,filler:l.Series},Linear:{id:`linear`,filler:l.Linear},Growth:{id:`growth`,filler:l.Growth},DateYears:{id:`date.years`,filler:l.DateYears},DateMonthEnd:{id:`date.monthEnd`,filler:l.DateMonthEnd},DateMonths:{id:`date.months`,filler:l.DateMonths},DateWeekdays:{id:`date.weekdays`,filler:l.DateWeekdays},DateDays:{id:`date.days`,filler:l.DateDays},LinearTrend:{id:`linear.trend`,filler:l.Linear,options:{trend:!0},minValues:2},GrowthTrend:{id:`growth.trend`,filler:l.Growth,options:{trend:!0},minValues:2}};e.canApply=(e,t,n)=>{let r=e.filler.type,i=0,a=n.length;for(let e=0;e<a;e++){let t=n[e];if(t!==H.Null&&(i++,r!==void 0&&t!==r))return!1}return!(i<(e.minValues??1))&&e.filler.matches(t,0,{...e.options,types:n})>0};let d=new Map(Object.values(u).map(e=>[e.id,e]));e.getPreset=e=>d.get(e),e.detectPreset=(e,t,n)=>{let r=[],i=!1,a=!1;for(let n=0;n<t.length;n++){let o=t[n];o!==H.Null&&(a=!0,o===H.Date?r.push(e[n]):o===H.Number&&(i=!0))}return r.length>0?(o=OI(r,!0===n?.date1904))?o.unit===td.Year?u.DateYears:o.unit===td.Month?o.monthEnd?u.DateMonthEnd:u.DateMonths:o.unit===td.Weekday?u.DateWeekdays:u.DateDays:u.DateDays:i?u.Linear:a?u.Series:u.Copy;var o},e.toFillOptions=(e,t)=>{let n=!0===(t?.trend??e.options?.trend)&&!0===e.filler.supportsTrend;return{filler:e.filler,fillerOptions:{...t,...e.options,trend:n,stepValue:n?void 0:t?.stepValue,stopValue:n?void 0:t?.stopValue}}},e.fillTo=(e,t,n,r)=>{let i=[],a=t.length,o=e.createFillAt(t,r);for(let e=a;e<n;e++)i.push(o(e));return i}})(vI||={});var jI=e=>e?B.Axis.Row:B.Axis.Column;function MI(e,t,n,r){let i,a,o;if(r){let e=Zz(t,r);if(n!==void 0&&n!==e.direction)throw new k(d.MESSAGE_ERROR_INVALID_ARG(n));if(e.amount<=0)return null;i=e.direction,a={...t},o={...r}}else{i=n??(t.rowStart===t.rowEnd&&t.colStart!==t.colEnd?B.Direction.Right:B.Direction.Down);let r=i===B.Direction.Down||i===B.Direction.Up,s=r?t.rowStart:t.colStart,c=(r?t.rowEnd:t.colEnd)-s+1;if(c<2)return null;let l=function(e,t,n){let r=[];for(let t of e.getRegions(Qh.Feature.Contentful))r.push(t.getRange().getCoords());let i=e=>t?e.rowStart:e.colStart;r.sort((e,t)=>i(e)-i(t));let a=n-1;for(let e=0;e<r.length;e++){let n=r[e];if(i(n)>a+1)break;let o=t?n.rowEnd:n.colEnd;o>a&&(a=o)}return a-n+1}(e.getRange(t),r,s),u=l<=0||l>=c?1:l;a=r?{...t,rowEnd:s+u-1}:{...t,colEnd:s+u-1},o={...t}}let s=i===B.Direction.Down||i===B.Direction.Up,c=s?a.rowStart:a.colStart,l=(s?a.rowEnd:a.colEnd)-c+1,u=s?o.rowEnd-o.rowStart+1:o.colEnd-o.colStart+1,f=s?a.colStart:a.rowStart,p=new Map,m,h=-1;for(let t of e.getRange(a).entries({axis:jI(s),features:[Qh.Feature.DateFormat],reuseContext:!0})){let e=t.context.getCoords(),n=(s?e.colIndex:e.rowIndex)-f,r=n===h?m:p.get(n);if(!r){if(p.size>=64)continue;r={values:Array(l).fill(null),types:Array(l).fill(H.Null)},p.set(n,r)}h=n,m=r;let i=(s?e.rowIndex:e.colIndex)-c;r.values[i]=t.value??null,r.types[i]=t.context.getInteropType()}let g=e.getWorkbook()?.getRuntime().isDate1904()??!1,_=Object.values(vI.Presets),v=new Set;for(let e of p.values()){if(v.size>=_.length)break;for(let t=0;t<_.length;t++){let n=_[t];v.has(n.id)||vI.canApply(n,e.values,e.types)&&v.add(n.id)}}let y=[];for(let e=0;e<_.length;e++)v.has(_[e].id)&&y.push(_[e].id);let b=p.values().next().value,x=[b?vI.detectPreset(b.values,b.types,{date1904:g}).id:vI.Presets.Copy.id,vI.Presets.DateDays.id,vI.Presets.Linear.id,vI.Presets.Series.id],S=y[0]??vI.Presets.Copy.id;for(let e=0;e<x.length;e++)if(v.has(x[e])){S=x[e];break}return{direction:i,template:a,destination:o,templateSize:l,size:u,offered:y,presetId:S}}function NI(e,t){return e._withProjectedMerge(t)}function PI(e,t){return{coords:t,getCellAt:(t,n)=>e.getCell({rowIndex:t,colIndex:n})}}function FI(e){let{ctx:t,template:n,destination:r,mergesTemplate:i,filler:a,withValues:o,withFormats:s,isVertical:c,isForward:l,templateStart:u,templateEnd:d,templateSize:f,fillerOptions:p,scanFills:m,createLineFillAt:g}=e,_=t.getState(),v=t.getAutoFillPreviewCache(),y;return v&&v.state===_&&v.isForward===l&&v.filler===a&&v.fillerOptions===p&&h.isEqualRanges(v.template,n)?y=v.seriesByLine:(y=new Map,t.setAutoFillPreviewCache({state:_,template:n,isForward:l,filler:a,fillerOptions:p,seriesByLine:y})),{coords:r,getCellAt:(e,r)=>{let a={rowIndex:e,colIndex:r};if(h.isCellWithinRange(a,n))return t.getCell(a);let p=null;if(s&&i.length>0){let t=c?e:r,n=c?r:e,a=u+((t-u)%f+f)%f;for(let e=0;e<i.length;e++){let r=i[e],o=c?r.rowStart:r.colStart,s=c?r.rowEnd:r.colEnd,l=c?r.colStart:r.rowStart,u=c?r.colEnd:r.rowEnd;if(o<=a&&a<=s&&l<=n&&n<=u){let e=t-(a-o);p=c?{rowStart:e,rowEnd:e+(s-o),colStart:l,colEnd:u}:{rowStart:l,rowEnd:u,colStart:e,colEnd:e+(s-o)};break}}}if(p&&(e!==p.rowStart||r!==p.colStart))return NI(t.createCell(null,a),p);let _=c?a.rowIndex:a.colIndex,v=l?_-u:u-_+f-1,b={...a},x=v%f;b[c?`rowIndex`:`colIndex`]=l?x+u:d-x;let S=t.getCell(b),C,w=null;if(o){let e=(e=>{if(y.has(e))return y.get(e);let t={...n};c?t.colStart=t.colEnd=e:t.rowStart=t.rowEnd=e;let r=m(t),i=r.length>0?r[r.length-1]:null,a=i?g(i):null;return y.set(e,a),a})(c?a.colIndex:a.rowIndex);e&&(w=e(v))}return C=s?o?t.createCell(null,a).createCell({value:w,style:S.getStyle()}):t.createCell({value:t.getCell(a).getValue(),style:S.getStyle()},a):t.getCell(a).createCell({value:w}),p?NI(C,p):C}}}function II(e,t){let n=t?.type;if(n!==void 0&&n!==$.Content.Formats&&n!==$.Content.Values)throw new k(d.MESSAGE_ERROR_INVALID_ARG(n));if(e.getProtection().isLocked()){if(n===$.Content.Formats)throw new b(N(`error.sheet.protectedSheet`));return{withValues:!0,withFormats:!1,type:$.Content.Values}}return{withValues:n!==$.Content.Formats,withFormats:n!==$.Content.Values,type:n??null}}function LI(e,t,n,r){let{withValues:i,withFormats:a,type:o}=II(e,r),{direction:s,amount:c}=Zz(t,n),l=!0===r?.preview;if(c===0)return!!l&&PI(e,n);if(c<0)return l?PI(e,n):RI(e,t,n,s,r);let u=s===B.Direction.Up||s===B.Direction.Down,f=e.getSelection().getCoords(),p=[],g=r?.filler??vI.Types.Series,_={...r?.fillerOptions},v=null,y=null;try{let b={...t},x={...t},S=[t],C=e.getMerges(S);if(C.length>0&&!h.isRangeWithinRange(h.unionRangesArrays(C),t))throw new k(N(`error.sheet.autofillOverlapMerge`));if(s===B.Direction.Left)b.colStart=x.colStart=t.colStart-c,b.colEnd=t.colStart-1;else if(s===B.Direction.Right)b.colEnd=x.colEnd=t.colEnd+c,b.colStart=t.colEnd+1;else if(s===B.Direction.Up)b.rowStart=x.rowStart=t.rowStart-c,b.rowEnd=t.rowStart-1;else{if(s!==B.Direction.Down)throw new k(d.MESSAGE_ERROR_INVALID_ARG(s));b.rowEnd=x.rowEnd=t.rowEnd+c,b.rowStart=t.rowEnd+1}if(C.length>0){let e=s===B.Direction.Down||s===B.Direction.Right,n=u?t.rowStart:t.colStart,r=(u?t.rowEnd:t.colEnd)-n+1,i=AI(C,n,r,u,e),a=c%r;if(!i.some(e=>e%r===a)){let e=r;for(let t=0;t<i.length;t++){let n=i[t];n>0&&n<e&&(e=n)}throw new k(N(`error.sheet.autofillMultiple`,{modulus:e}))}}let w=u?`rowIndex`:`colIndex`,T=u?`colIndex`:`rowIndex`,E=u?t.rowEnd+1-t.rowStart:t.colEnd+1-t.colStart,D=u?t.rowStart:t.colStart,O=u?t.rowEnd:t.colEnd,A=u?n.rowStart:n.colStart,j=u?n.rowEnd:n.colEnd,M=u?s===B.Direction.Down:s===B.Direction.Right;M||(_.reverse=!0);let ee=M?O+1:A,te=(M?j:D-1)-ee+1;p.push(h.unionRanges(b,t));let P=e.runtime.isDate1904(),F=!rD(e.getState().dateFormatSpatial,e.getState().pivotTables,e.getState().contentSpatial).isEmpty(),ne=F?ve():null,re=new Map,ie=e=>{let t=re.get(e);return t===void 0&&(t=ne.isDateFormat(e)||ne.isTimeFormat(e),re.set(e,t)),t},ae=t=>{let n=[],r=null,i=e.cellStateIterator({bounds:t,reverse:!M,axis:u?B.Axis.Column:B.Axis.Row,searchTypes:!!F&&{[G.Type.DateFormat]:!1},ignoreEmptyIntersections:!0}),a=i.next();for(;!a.done;){let e=a.value,t=e[0];r?.oppositeIndex!==t[T]&&(r={oppositeIndex:t[T],lastIndex:M?D-1:O+1,values:[],types:[]},n.push(r));let o=t[w];if(M)for(let e=r.lastIndex+1;e<o;e++)r.values.push(null),r.types.push(H.Null);else for(let e=r.lastIndex-1;e>o;e--)r.values.push(null),r.types.push(H.Null);r.lastIndex=o;let s=e[1]??null,c=e[2]?.dateFormat,l=c!==void 0&&typeof s==`number`&&ie(c);r.values.push(s),r.types.push(l?H.Date:pB(s)),a=i.next()}let o=n.length;for(let e=0;e<o;e++){let t=n[e],r=t.values;for(let e=r.length;e<E;e++)r.push(null),t.types.push(H.Null)}let s=e.calcGrid.getFormulas().search(t);if(s.length===0)return n;let c=new Map;for(let e=0;e<o;e++)c.set(n[e].oppositeIndex,n[e]);for(let e=0;e<s.length;e++){let n=h.intersectRanges(s[e],t),r=u?n.colStart:n.rowStart,i=u?n.colEnd:n.rowEnd,a=u?n.rowStart:n.colStart,o=u?n.rowEnd:n.colEnd;for(let e=r;e<=i;e++){let t=c.get(e);if(!t)continue;let n=t.formulaAt??=Array(E).fill(!1);for(let e=a;e<=o;e++){let r=M?e-D:O-e;t.values[r]=null,t.types[r]=H.Null,n[r]=!0}}}return n.filter(e=>!e.formulaAt||e.values.some(e=>e!==null))},oe=(e,t,n)=>{let r={..._,types:t,date1904:P};if(n&&(r.multiFill=!0),g.matches(e,0,r)>0){let t=g.createFillAt(e,r);if(t)return t}return vI.Types.Copy.createFillAt(e)},se=e=>{let{values:t,types:n,formulaAt:r}=e;if(!r)return oe(t,n);let i=t.length,a=Array(i);for(let e=0;e<i;e++){if(r[e]||t[e]===null)continue;let o=e;for(let n=e+1;n<i&&!r[n];n++)t[n]!==null&&(o=n);let s={start:e,length:o-e+1,fillAt:oe(t.slice(e,o+1),n.slice(e,o+1),!0)};for(let t=e;t<=o;t++)a[t]=s;e=o}return e=>{let t=e%i,n=a[t];return n?n.fillAt(t-n.start+Math.floor(e/i)*n.length):null}};if(l)return FI({ctx:e,template:t,destination:n,mergesTemplate:C,filler:g,withValues:i,withFormats:a,isVertical:u,isForward:M,templateStart:D,templateEnd:O,templateSize:E,fillerOptions:r?.fillerOptions,scanFills:ae,createLineFillAt:se});v=e.beginCommit({description:m(`op.autoFill`),operation:{name:`autoFill`,params:[t,n,r]}});let ce=i?ae(t):[],le=e.createSparseBuilder({axis:u?B.Axis.Column:B.Axis.Row}),ue=ce.length;ce.sort((e,t)=>e.oppositeIndex-t.oppositeIndex);for(let e=0;e<ue;e++){let t=e,n=se(ce[t]),r=ce[t].oppositeIndex,i=M?E:E+te-1;for(let e=0;e<te;e++){let t=n(i+(M?e:-e));if(t===null)continue;we(t,!0)&&(t=Dt(t,P));let a=ee+e;u?le.pushAt(a,r,t):le.pushAt(r,a,t)}}oI(e,[b],o),i&&le.apply();let de=a?e.getMerges([x]):[],fe=h.unionRangesArrays(de);if(de.length>0&&!h.isRangeWithinRange(fe,x))throw new k(N(`error.sheet.autofillOverlapMerge`));if(de.length>0){let n=[],r=de.length;if(u){let e=t.rowEnd-t.rowStart+1,i=s===B.Direction.Up?-e:e;for(let e=0;e<r;e++){let t=de[e],r=t.rowEnd-t.rowStart+1;for(let e=1;;e++){let a=t.rowStart+e*i,o=a+r-1;if(a<b.rowStart||o>b.rowEnd)break;n.push({colStart:t.colStart,rowStart:a,colEnd:t.colEnd,rowEnd:o})}}}else{let e=t.colEnd-t.colStart+1,i=s===B.Direction.Left?-e:e;for(let e=0;e<r;e++){let t=de[e],r=t.colEnd-t.colStart+1;for(let e=1;;e++){let a=t.colStart+e*i,o=a+r-1;if(a<b.colStart||o>b.colEnd)break;n.push({colStart:a,rowStart:t.rowStart,colEnd:o,rowEnd:t.rowEnd})}}}zF(e,n)}let pe=e.getState(),me={},he={};he.borderSpatial=pe.borderSpatial,he.fillSpatial=pe.fillSpatial,he.contentSpatial=pe.contentSpatial,he.continuousFillSpatial=pe.continuousFillSpatial,he.dateFormatSpatial=pe.dateFormatSpatial;let I=[],ge=M?0:c%E,_e=u?`rowStart`:`colStart`,ye=u?`rowEnd`:`colEnd`;ge!==0&&I.push({from:{...t,[_e]:t[ye]-ge+1},to:{...b,[ye]:b[_e]+ge-1}}),c>ge&&I.push({from:t,to:{...b,[_e]:b[_e]+ge}});let be=a?Object.keys(he):[],xe=be.length;for(let e=0;e<xe;e++){let t=be[e],n=he[t],r=pe[t].clone();for(let e=0;e<I.length;e++){let t=n.createCopiedEntries(I[e].from,I[e].to),i=t.removes,a=i.length;for(let e=0;e<a;e++)r.remove(i[e]);r.load(t.inserts)}me[t]=r}if(M&&i&&!e.getProtection().isLocked()){let n=e.getTables().getItems({address:{rowIndex:t.rowEnd,colIndex:t.colEnd}});if(n.length===1){let e=n[0],t=e.getRange().getCoords();(b.rowEnd>t.rowEnd||b.colEnd>t.colEnd)&&e.resize({colStart:t.colStart,rowStart:t.rowStart,colEnd:Math.max(t.colEnd,b.colEnd),rowEnd:Math.max(t.rowEnd,b.rowEnd)})}}if(a&&(zI(pe.conditionalFormats,t,b,E,u),zI(pe.dataValidations,t,b,E,u),zI(pe.cellControls,t,b,E,u)),i&&function(e,t,n,r,i){if(e.isEmpty())return;let a=e.search(t),o=new Set;for(let e=0;e<a.length;e++)a[e].value&&o.add(a[e].value);let s=i?n.rowStart:n.colStart,c=i?n.rowEnd:n.colEnd,l=i?n.rowStart>t.rowEnd:n.colStart>t.colEnd;for(let e of o){let a=e._rangesWithin(t),o=[];for(let e=0;e<a.length;e++){let t=a[e],u=i?t.location.rowStart:t.location.colStart,d=i?t.location.rowEnd:t.location.colEnd,f=Math.max(Math.ceil((s-d)/r),l?1:-1/0),p=KO(t,f,Math.min(Math.floor((c-u)/r),l?1/0:-1)-f+1,r,i?`row`:`col`);l||p.reverse();for(let e=0;e<p.length;e++){let t=WO(p[e],n);t&&o.push(t)}}e._addRanges(o)}}(pe.sparklineGroups,t,b,E,u),i){e.calcGrid.getFormulas().search(t).length>0&&e.recordFormulasEntered(v,[b]);let n={commitId:v.getId(),cloneKey:v.getSavepointId()};for(let t=0;t<I.length;t++)e.calcGrid.autoFill(I[t].from,I[t].to,n)}e.updateState(me),y={...f,ranges:p},e.commitWithDirectives(v,y,r,{undo:SD([t])})}catch(e){throw v?.rollback(),e}return!0}function RI(e,t,n,r,i){let a={...t};if(r===B.Direction.Down)a.rowStart=n.rowEnd+1;else if(r===B.Direction.Up)a.rowEnd=n.rowStart-1;else if(r===B.Direction.Right)a.colStart=n.colEnd+1;else{if(r!==B.Direction.Left)throw new k(d.MESSAGE_ERROR_INVALID_ARG(r));a.colEnd=n.colStart-1}let o=e.getMerges([a]);if(o.length>0&&!h.isRangeWithinRange(h.unionRangesArrays(o),a))throw new k(N(`error.sheet.autofillOverlapMerge`));let s=e.getSelection().getCoords(),c={colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colEnd,rowEnd:n.rowEnd},l=e.beginCommit({description:`Auto Fill`,operation:{name:`autoFill`,params:[t,n,i]}});try{oI(e,[a],II(e,i).type);let n={...s,cell:{rowIndex:Math.min(Math.max(s.cell.rowIndex,c.rowStart),c.rowEnd),colIndex:Math.min(Math.max(s.cell.colIndex,c.colStart),c.colEnd)},ranges:[c]};e.commitWithDirectives(l,n,i,{undo:SD([t])})}catch(e){throw l?.rollback(),e}return!0}function zI(e,t,n,r,i){if(e.isEmpty())return;let a=e.search(t),o=a.length;if(o===0)return;let s=new Set;for(let e=0;e<o;e++){let t=a[e].value;t!==void 0&&s.add(t)}let c=i?n.rowStart:n.colStart,l=i?n.rowEnd:n.colEnd;for(let a of s){let o=e.getCoords(a);if(!o)continue;let s=[];for(let e=0;e<o.length;e++){let a=h.intersectRanges(o[e],t);if(!a)continue;let u=i?a.rowStart:a.colStart,d=i?a.rowEnd:a.colEnd,f=Math.ceil((c-d)/r),p=Math.floor((l-u)/r);if(p<f)continue;let m=(e,t)=>{let r=i?{...a,rowStart:e,rowEnd:t}:{...a,colStart:e,colEnd:t},o=h.intersectRanges(r,n);o&&s.push(o)};if(d-u+1===r)m(u+f*r,d+p*r);else for(let e=f;e<=p;e++)e!==0&&m(u+e*r,d+e*r)}s.length!==0&&a._extendRanges(s)}}function BI(e,t){let n=t.indexOf(`:`);return e.getColumnById(n>=0?t.substring(n+1):t)}function VI(e,t){let{columnFromId:n,columnToId:r}=e;return!!n&&!BI(t,n)||!!r&&!BI(t,r)}function HI(e,t,n){let r,i;switch(e.spec){case 1:{let e=n.getRange().getCoords();r=e.rowStart,i=e.rowEnd;break}case 2:{if(!n.isShowHeaders())return V.BuiltIn.Ref;let e=n.getHeaderRowRange().getCoords();r=e.rowStart,i=e.rowEnd;break}case 3:{if(!n.isShowTotals())return V.BuiltIn.Ref;let e=n.getTotalRowRange().getCoords();r=e.rowStart,i=e.rowEnd;break}case 4:{let e=n.isShowHeaders()?n.getHeaderRowRange().getCoords():n.getDataRange().getCoords(),t=n.getDataRange().getCoords();r=e.rowStart,i=t.rowEnd;break}case 5:{let e=n.getDataRange().getCoords(),t=n.isShowTotals()?n.getTotalRowRange().getCoords():e;r=e.rowStart,i=t.rowEnd;break}default:{let e=n.getDataRange().getCoords();r=e.rowStart,i=e.rowEnd}}let a=n.getRange().getCoords(),o=a.colStart,s=a.colEnd,c=e.columnFromId,l=e.columnToId;if(c){let e=BI(n,c);if(!e)return V.BuiltIn.Ref;if(o=a.colStart+e.getIndex(),s=o,l&&l!==c){let e=BI(n,l);if(!e)return V.BuiltIn.Ref;s=a.colStart+e.getIndex()}}if(e.isThisRow){if(t<r||t>i)return V.BuiltIn.Value;r=t,i=t}return{colStart:o,colEnd:s,rowStart:r,rowEnd:i,scope:n.getWorksheet().getId(),$colStart:!0,$rowStart:!0,$colEnd:!0,$rowEnd:!0}}function UI(e,t){let n=HI({...e,isThisRow:!1},0,t);if(V.isError(n))return r_();let r=n,i=e.isThisRow,a=Dg({colIndex:r.colStart,rowIndex:i?0:r.rowStart,$colIndex:!0,$rowIndex:!i,scope:r.scope});return r.colStart===r.colEnd&&(i||r.rowStart===r.rowEnd)?a:Kg(`:`,a,Dg({colIndex:r.colEnd,rowIndex:i?0:r.rowEnd,$colIndex:!0,$rowIndex:!i}),!0)}var WI=[...Ig].sort((e,t)=>t.length-e.length),GI=RegExp(`^\\[#(${WI.join(`|`)})\\]$`,`i`),KI=RegExp(`#(${WI.join(`|`)})`,`iy`),qI=/^\s*\[[^\]]*\][^!]*!/,JI=e=>{let t=[],n=e.length,r=0,i=()=>{for(;r<n&&/\s/.test(e.charAt(r));)r++},a=()=>{let t=r;for(r++;r<n;){let n=e.charAt(r);if(n===`'`)r+=`'[]#`.indexOf(e.charAt(r+1))>=0?2:1;else{if(n===`[`)return null;if(n===`]`)return r++,e.substring(t,r);r++}}return null},o=()=>{i();let t=e.charAt(r);if(t===`#`){KI.lastIndex=r;let t=KI.exec(e);return t?(r+=t[0].length,{word:t[1]}):null}if(t!==`[`)return null;let n=a();if(!n)return null;let o=GI.exec(n);if(o)return{word:o[1]};let s=Gg(n).value;if(i(),e.charAt(r)!==`:`)return{from:s,to:s,range:!1};if(r++,i(),e.charAt(r)!==`[`)return null;let c=a();return!c||GI.test(c)?null:{from:s,to:Gg(c).value,range:!0}};for(;;){let a=o();if(!a)return null;if(t.push(a),i(),r===n)return t;if(e.charAt(r)!==`,`)return null;r++}};function YI(e){let t=e.trim(),n=t.charCodeAt(0)===91,r=n?Wg(t,0):Hg(t,0);if(!r||r[0].length!==t.length)return null;let i=n?0:t.indexOf(`[`),a=t.substring(0,i),o=t.substring(i+1,t.length-1),s=o.trim();if(!s)return{table:a,spec:0,columnFrom:null,columnTo:null,isThisRow:!1};let c=s.charAt(0);if(c===`@`){let e=s.substring(1).trim();if(!e)return{table:a,spec:0,columnFrom:null,columnTo:null,isThisRow:!0};if(e.charAt(0)===`[`){let t=JI(e),n=t?.length===1?t[0]:null;if(n&&`from`in n&&n.range)return{table:a,spec:0,columnFrom:n.from,columnTo:n.to,isThisRow:!0}}let t=Gg(e).value;return{table:a,spec:0,columnFrom:t,columnTo:t,isThisRow:!0}}if(c!==`[`&&c!==`#`){let e=Gg(o).value;return{table:a,spec:0,columnFrom:e,columnTo:e,isThisRow:!1}}let l=JI(s);return l?((e,t)=>{let n=null,r=null,i=new Set;for(let e of t)if(`word`in e){let t=e.word.toUpperCase();if(i.has(t))return null;i.add(t)}else{if(n!==null)return null;n=e.from,r=e.to}let a=i.has(`ALL`),o=i.has(`DATA`),s=i.has(`HEADERS`),c=i.has(`TOTALS`),l=i.has(`THIS ROW`);return i.size>1&&(i.size!==2||!o||!s&&!c)?null:{table:e,spec:Lg(a,s,o,c),columnFrom:n,columnTo:r,isThisRow:l}})(a,l):null}function XI(e){return e?.getType()===`table`?e.getValue():null}function ZI(e,t){if(e.indexOf(`[`)===-1)return null;if(qI.test(e))throw new k(N(`error.address.externalReference`));let n=YI(e);if(!n)return null;let r=t.getAnchor(),i;if(n.table){if(i=t.getTable(n.table),!i)throw new k(N(`error.address.tableNotFound`,{name:n.table}))}else{let t=r?.coords;if(i=t?r.sheet.getTables().getItems({address:{rowStart:t.rowIndex,colStart:t.colIndex,rowEnd:t.rowIndex,colEnd:t.colIndex}})[0]??null:null,!i)throw new k(N(`error.address.noTableAtActiveCell`,{address:e}))}let a=i.getWorksheet();if(!a)throw new k(N(`error.address.tableNotFound`,{name:n.table}));let o=i.getName(),s=e=>{if(e===null)return null;let t=i.getColumnByName(e);if(!t)throw new k(N(`error.address.tableColumnNotFound`,{table:o,column:e}));return t.getId()},c={tableId:``,spec:n.spec,columnFromId:s(n.columnFrom),columnToId:s(n.columnTo),isThisRow:n.isThisRow},l=0;if(n.isThisRow){if(!r||r.sheet.getId()!==a.getId())throw new k(N(`error.address.thisRowNotInTable`,{address:e,table:o}));l=r.coords.rowIndex}let u=HI(c,l,i);if(V.isError(u))throw V.isError(u,V.Code.Value)?new k(N(`error.address.thisRowNotInTable`,{address:e,table:o})):new k(N(`error.address.tableSectionHidden`,{address:e,table:o}));return{...u,scope:a.getName()}}function QI(e,t,n,r=null){let i=null;return r===null&&e.readonly&&(r=m(`error.sheet.readonlyRange`)),(n||r)&&(i={getOptions:n,readOnly:r}),new tz(function(e,t){if(!e)return e;let n=!1;for(let r=0;r<e.length;r++){let i=e[r]?.scope;if(i&&wz(i,t)){n=!0;break}}return n?e.map(e=>typeof e==`string`||!0===e?.isICellRange?e:Cz(e,t)):e}(t,e.internal.getSheet()),e.internal,i)}function $I(e,t,n=N(`error.sheet.oobRange`),r=!1){if(!r&&!h.isRangeWithinRange(t,e.getEntireCoords()))throw new w(n);let i=t.colStart,a=t.rowStart,o=t.colEnd,s=t.rowEnd;if(s<a||o<i)throw new k(N(`error.address.invalidRangeInverted`));if(!(Number.isInteger(i)&&Number.isFinite(i)&&Number.isInteger(a)&&Number.isFinite(a)&&Number.isInteger(o)&&Number.isFinite(o)&&Number.isInteger(s)&&Number.isFinite(s)))throw new k(N(`error.address.invalidRangeCoords`))}function eL(e){return new k(e?N(`error.address.noAddress`):bh(e))}function tL(e,t=null,n=null,r=null){if(t&&e.isClosed)return;if(!e.isInitializing&&e.readonly)throw new k(((e=m(`op.update`))=>N(`error.sheet.readonlySheet`,{description:N(e)}))(r));n&&!Array.isArray(n)&&(n=[n]);let i=t(n),a=e.getProtection();if(!a?.isLocked())return;if(i.length===0)throw new b(N(`error.sheet.protectedSheet`));let o=i.length;for(let e=0;e<o;e++){let t=i[e];if(!0!==a[`is${t.charAt(0).toUpperCase()}${t.slice(1)}Allowed`]?.())throw new b(wx())}}function nL(e,t,n=null,r=!0,a=!1,o=!1){if(n&&e.isClosed||t==null)return i.EmptyArray;let s=af(t,e.getEntireCoords(),a?Jd:Yd,t=>{if(r&&typeof t==`string`){let n=e.internal.getSheet(),r=ZI(t,{getTable:t=>XI(e.getNames()?.getByName(t)),getAnchor:()=>({sheet:n,coords:n.getSelectedCell().getCoords()})});if(r)return[r];let i=(e.getNames()?.getByName(t))?.getRanges?.();if(i)return i.getCoords();let a=e.resolveRange(t);if(a&&a.getWorksheet()===e.internal.getSheet())return console.warn(N(`error.sheet.addressInvalidScope`)),[a.getCoords()];throw new k(`Invalid sheet reference '${t}'.`)}}),c=s.length;for(let t=0;t<c;t++){let n=s[t];if(n){if(a){let t=n.scope;if(t&&t!==e.getName())throw new k(N(`error.sheet.addressInvalidScope`))}$I(e,n,void 0,o)}}if(!n)return s;if(s.length===0)throw eL(t);return tL(e,n,s),s}function rL(e,t,n=null,r=!0){if(!t)throw new k(N(`error.address.noAddress`));let i=nL(e,t,n?e=>n(e):void 0,r);if(i.length===0)throw new k(bh(t));return i[0]}var iL=class{constructor(){this._picks=Object.freeze([]),this._container=null,this._emitter=new ne(this)}getContainer(){return this._container}getItems(){return this._picks}getActive(){let e=this._picks;return e.length>0?e[e.length-1]:null}isSelected(e){return this._picks.includes(e)}isEmpty(){return this._picks.length===0}select(e,t){let n=t?.add?[...this._picks]:[],r=n.length>0?this._container:null,i=e?.length??0;for(let t=0;t<i;t++){let i=e[t];this._check(i);let a=i.getParent();n.length>0&&a!==r&&(n=[]),r=a;let o=n.indexOf(i);o!==-1&&n.splice(o,1),n.push(i)}return this._beforeSelect(n),this._update(n,r)}unselect(e){let t=this._picks.filter(t=>!e.includes(t));return t.length===this._picks.length?this:this._update(t,this._container)}clear(){return this._update([],null)}traverse(e=!1){let t=this._traversal(),n=t.length;if(n===0)return this;let r=this.getActive(),i=r?t.indexOf(r):-1,a=e?-1:1,o=i===-1?e?0:n-1:i;return this.select([t[(o+a+n)%n]])}isEquals(e){if(!e)return!1;if(e===this)return!0;if(!this._comparable(e)||e.getActive()!==this.getActive())return!1;let t=this._picks,n=e.getItems();if(t.length!==n.length)return!1;for(let n=0;n<t.length;n++)if(!e.isSelected(t[n]))return!1;return!0}addListeners(e,t){return this._emitter.addListeners(e,t)}_comparable(e){return!0}_beforeSelect(e){}_afterChange(){}_update(e,t){let n=this._picks,r=n.length!==e.length;for(let t=0;!r&&t<e.length;t++)n[t]!==e[t]&&(r=!0);return r&&(this._picks=Object.freeze([...e]),this._container=e.length>0?t:null,this._afterChange(),this._emitter.notify(`onChange`)),this}},aL=class extends iL{constructor(e){if(super(),this._chartRemoveListener=null,this._sheet=e?.sheet??null,this._own=e?.chart??null,!this._sheet&&!this._own)throw Error(`ChartElementSelection requires a sheet or a chart.`)}getChart(){return this.getActive()?.getChart()??null}addListeners(e,t){return super.addListeners(e,t)}_follow(){let e=this.getChart();if(!e)return;let t=e.getMovable(),n=this._sheet?.getView().getMovableSelection();t&&n&&(n.getActive()===t&&n.getItems().length===1||this.clear())}_traversal(){let e=this.getChart()??this._own??this._activeChartOnSheet();return e?e.getElements().filter(e=>e.getElementType()!==`chartArea`):[]}_activeChartOnSheet(){let e=this._sheet?.getView().getMovableSelection().getActive()?.getContent();return e&&e.isIChart?e:null}_comparable(e){return!0===e.isIChartElementSelection}_check(e){let t=e?.getChart?.();if(!t)throw Error(`Not a chart element.`);if(e.getElementType()===`chartArea`)throw Error(`The chart area is the chart itself: select its movable.`);if(this._own&&t!==this._own)throw Error(`The element is not of this chart.`);if(this._sheet&&t.getMovable()?.getRange().getWorksheet()!==this._sheet)throw Error(`The chart is not on this sheet.`);if(t.getElement(e.getPath())!==e)throw Error(`Chart element ${e.getPath()} not found.`)}_beforeSelect(e){let t=(e.length>0?e[e.length-1].getChart():null)?.getMovable();if(!t||!this._sheet)return;let n=this._sheet.getView().getMovableSelection();n.getActive()===t&&n.getItems().length===1||n.select([t])}_afterChange(){this._chartRemoveListener?.(),this._chartRemoveListener=null;let e=this.getChart();e&&(this._chartRemoveListener=e.addListeners({onAnyChange:()=>this._prune()},{transactional:!1}))}_prune(){let e=this.getChart();if(!e)return;if(e.isDeleted())return void this.clear();let t=this._picks.filter(t=>e.getElement(t.getPath())!==t);t.length>0&&this.unselect(t)}get[Symbol.toStringTag](){return`[ChartElementSelection]`}get isIChartElementSelection(){return!0}},oL=class e{constructor(e){if(this._magicCell=null,this._adjusting=null,this._firstActiveCoords=null,this._cache={range:null,ranges:null},this._sheet=e.sheet,!this._sheet)throw Error(`Sheet is required`);this._coords=e.coords??h.EmptySelection,this._emitter=new ne(this),this._adjusting=null,this._shapePolicy=e.shapePolicy??`mixed`,this._navigationPolicy=e.navigationPolicy??`clear`}navigate(e,t=!1,n=!1,r=0){let i=this._coords;if(!i.cell)return this;let a=i.cell,o=i.cell;if(t&&i.ranges.length>0){let t=i.ranges[i.rangeIndex],n=i.cell;switch(e){case B.Direction.Up:o={rowIndex:n.rowIndex===t.rowStart?t.rowEnd:t.rowStart,colIndex:t.colEnd},a={rowIndex:n.rowIndex===t.rowStart?t.rowStart:t.rowEnd,colIndex:t.colStart};break;case B.Direction.Down:o={rowIndex:n.rowIndex===t.rowEnd?t.rowStart:t.rowEnd,colIndex:t.colEnd},a={rowIndex:n.rowIndex===t.rowEnd?t.rowEnd:t.rowStart,colIndex:t.colStart};break;case B.Direction.Left:o={rowIndex:t.rowEnd,colIndex:n.colIndex===t.colStart?t.colEnd:t.colStart},a={rowIndex:t.rowStart,colIndex:n.colIndex===t.colStart?t.colStart:t.colEnd};break;case B.Direction.Right:o={rowIndex:t.rowEnd,colIndex:n.colIndex===t.colEnd?t.colStart:t.colEnd},a={rowIndex:t.rowStart,colIndex:n.colIndex===t.colEnd?t.colEnd:t.colStart}}}let s=this._getRangeFromCell(o),{rowStart:c,colStart:l}=s,u=this._magicCell;if(u)switch(e){case B.Direction.Up:case B.Direction.Down:u.colIndex>=s.colStart&&u.colIndex<=s.colEnd&&(l=u.colIndex);break;case B.Direction.Left:case B.Direction.Right:u.rowIndex>=s.rowStart&&u.rowIndex<=s.rowEnd&&(c=u.rowIndex)}if(!r){let t=this._getEntireRange(),r=t.rowStart??0,i=t.rowEnd??2**53-1,a=t.colStart??0,u=t.colEnd??2**53-1;switch(e){case B.Direction.Up:c=M.traverseHiddenHeaders(this._hiddenRowsAt.bind(this),Math.max(s.rowStart-1,r),e,Math.max(r,this._hiddenRowsAt(r,!1)));break;case B.Direction.Down:c=M.traverseHiddenHeaders(this._hiddenRowsAt.bind(this),Math.min(s.rowEnd+1,i),e,Math.min(i,i-this._hiddenRowsAt(i,!0)));break;case B.Direction.Left:l=M.traverseHiddenHeaders(this._hiddenColumnsAt.bind(this),Math.max(s.colStart-1,a),e,Math.max(a,this._hiddenColumnsAt(a,!1)));break;case B.Direction.Right:l=M.traverseHiddenHeaders(this._hiddenColumnsAt.bind(this),Math.min(s.colEnd+1,u),e,Math.min(u,u-this._hiddenColumnsAt(u,!0)))}if(n)switch(e){case B.Direction.Up:case B.Direction.Down:c=this._contentfulCellFinder({...o,colIndex:this._coords.cell.colIndex},e);break;case B.Direction.Left:case B.Direction.Right:l=this._contentfulCellFinder({...o,rowIndex:this._coords.cell.rowIndex},e)}c=Math.min(Math.max(c,r),i),l=Math.min(Math.max(l,a),u)}let d=null;r&&(d={});let f={rowIndex:c,colIndex:l},p=this._getRangeFromCell(f),m={rowIndex:p.rowStart,colIndex:p.colStart};t||(this._magicCell=f);let g=this._firstActiveCoords,_=h.isEqualCells(g,m)&&h.isEqualCells(g,a);if(t&&!_?this.modify(m,a):this.clearAndModify(m),d)this._scrollCellCoordsIntoView(d);else{if(t&&g){let t=this._getEntireRange();if(e===B.Direction.Right&&g.colIndex===t.colEnd||e===B.Direction.Left&&g.colIndex===t.colStart||e===B.Direction.Up&&g.rowIndex===t.rowEnd||e===B.Direction.Down&&g.rowIndex===t.rowStart)return this}e===B.Direction.Left||e===B.Direction.Right?this._scrollCellCoordsIntoView({colStart:f.colIndex}):e!==B.Direction.Up&&e!==B.Direction.Down||this._scrollCellCoordsIntoView({rowStart:f.rowIndex})}return this}getCoords(){return this._coords}hasTopOrLeft(){let e=this._coords;if(e.cell.rowIndex===0||e.cell.colIndex===0)return!0;let t=e.ranges,n=t.length;for(let e=0;e<n;e++){let n=t[e];if(n.rowStart===0||n.colStart===0)return!0}return!1}getWorksheet(){return this._sheet}getCell(){let e=this._coords;return this._sheet.getCell(e.cell)}getRange(e){let t=this._coords,n=this._cache;if(!e&&n.range)return n.range;let r=xD(t),i=this._sheet.getRange(this._localCoords(r[0]));return e||(n.range=i),i}getRanges(e){let t=this._coords,n=this._cache;if(!e&&n.ranges)return n.ranges;let r=xD(t),i=this._sheet.getRanges(r,e);return e||(this._cache.ranges=i),i}updateCoords(e){let t=this._coords;if(h.isEqualSelectionCoords(t,e))return this;let n=this._resolveMerges(this._resolveEntireHeaderSelection(bD(e,this._coords,this._getEntireRange())));if(h.isEqualSelectionCoords(t,n))return this;this._coords=n;let r=this._cache;return r.range=null,r.ranges=null,this._emitter.notify(`onChange`),this}isEntire(){let e=this._coords;if(e.ranges.length===0)return!1;let t=this._getEntireRange(),n=e.ranges,r=n.length;for(let e=0;e<r;e++){let r=n[e];if(!h.isRangeWithinRange(t,r))return!1}return!0}getSelectedRuns(e){return yD(e,this._coords,this._getEntireRange())}isEquals(e){let t=this._coords,n=e.getCoords();return h.isEqualSelectionCoords(t,n)}traverse(e=B.Axis.Row,t=!1,n){let r=B.Direction.Right;r=e===B.Axis.Row?t?B.Direction.Left:B.Direction.Right:t?B.Direction.Up:B.Direction.Down;let i=this._coords;if(i.ranges.length===0){let a=xz(this._sheet).getTraverseRegion(i.cell,e,t)??n;if(a&&!h.isSingleCell(a)){let e={ranges:[a],cell:i.cell,rangeIndex:0},t=M.findNextCellWithinSelection(e,r,this._getRangeFromCell.bind(this),this._hiddenRowsAt.bind(this),this._hiddenColumnsAt.bind(this));return this.clearAndModify(t.cell),this._scrollCellCoordsIntoView({rowStart:t.cell.rowIndex,colStart:t.cell.colIndex}),this}return this.navigate(r)}let a=this._getRangeFromCell(i.cell);if(h.isEqualRangesArrays([a],i.ranges))return this.navigate(r);let o=M.findNextCellWithinSelection(i,r,this._getRangeFromCell.bind(this),this._hiddenRowsAt.bind(this),this._hiddenColumnsAt.bind(this));return this.updateCoords(o)}traverseCorners(){let e=this._coords;if(e.ranges.length===0)return this;let t=e.ranges[e.rangeIndex],n=this._hiddenRowsAt.bind(this),r=this._hiddenColumnsAt.bind(this),i=M.traverseHiddenHeaders(n,t.rowStart,B.Direction.Down,t.rowEnd),a=M.traverseHiddenHeaders(n,t.rowEnd,B.Direction.Up,t.rowStart),o=M.traverseHiddenHeaders(r,t.colStart,B.Direction.Right,t.colEnd),s=M.traverseHiddenHeaders(r,t.colEnd,B.Direction.Left,t.colStart),{rowIndex:c,colIndex:l}=e.cell,u;return u=c===i&&l===o?{rowIndex:i,colIndex:s}:c===i&&l===s?{rowIndex:a,colIndex:o}:c===a&&l===o?{rowIndex:a,colIndex:s}:{rowIndex:i,colIndex:o},this.updateCoords({ranges:e.ranges,rangeIndex:e.rangeIndex,cell:u}),this._scrollCellCoordsIntoView({rowStart:u.rowIndex,colStart:u.colIndex}),this}clearHidden(){let e=this.getRanges().getVisible();if(!e)return this;let t=e.getCoords();if(t.length===0)return this;let n=this._coords.cell,r=this._hiddenRowsAt(n.rowIndex)>0||this._hiddenColumnsAt(n.colIndex)>0?{rowIndex:t[0].rowStart,colIndex:t[0].colStart}:n,i=0;for(let e=0;e<t.length;e++)if(h.isCellWithinRange(r,t[e])){i=e;break}return this.updateCoords({ranges:t,rangeIndex:i,cell:r})}_resolveEntireHeaderSelection(e){let t=e.rangeIndex,n=t>=0?e.ranges[t]:null;if(!n)return e;let r=this._getEntireRange(),i=yz([n],r,!0),a=bz([n],r,!0);if(i===a)return e;let o=e.cell;if(i&&o.rowIndex!==n.rowStart||a&&o.colIndex!==n.colStart)return e;let s=this._sheet.getView();if(!s)return e;let c=(i?this._entireColumnsToTableBody(n):null)??n,l=s.getTopLeftCell(),u=i?Math.max(c.rowStart,Math.min(l.rowIndex,c.rowEnd)):o.rowIndex,d=a?Math.max(c.colStart,Math.min(l.colIndex,c.colEnd)):o.colIndex;return c===n&&u===o.rowIndex&&d===o.colIndex?e:Object.freeze({cell:Object.freeze({...o,rowIndex:u,colIndex:d}),ranges:c===n?e.ranges:e.ranges.map((e,n)=>n===t?c:e),rangeIndex:t})}_entireColumnsToTableBody(e){let t=this._sheet.getColumnHeaders(),n=t.at(e.colStart)?.getColumn();if(!n)return null;let r=n.getTable();for(let n=e.colStart+1;n<=e.colEnd;n++)if(t.at(n)?.getColumn()?.getTable()!==r)return null;let i=r.getDataRange().getCoords();return!i||i.rowStart>i.rowEnd?null:Object.freeze({...e,rowStart:i.rowStart,rowEnd:i.rowEnd})}_isEntireRange(e){e||=xD(this._coords)[0];let t=this._sheet.getEntireRange().getCoords();return bz([e],t,!0)&&yz([e],t,!0)}async selectRegion(e){let t=e?.entireRegion??!1,n=e?.contentOnly??!1,r=e?.axis,i=this._sheet;if(r!==void 0){let e=this._coords,t=i.getRange(e.cell).getTables()[0]??null,n=(t?t.getDataRange():i.getEntireRange()).getCoords(),a=e.ranges.length&&e.rangeIndex>=0?e.ranges[e.rangeIndex]:h.cellToRange(e.cell),o=r===B.Axis.Column||r===B.AxisSelection.Both,s=r===B.Axis.Row||r===B.AxisSelection.Both,c={rowStart:o?n.rowStart:a.rowStart,rowEnd:o?n.rowEnd:a.rowEnd,colStart:s?n.colStart:a.colStart,colEnd:s?n.colEnd:a.colEnd},l=e.rangeIndex;return this._setSelectionRanges(e=>e.length?e.map((e,t)=>t===l?{...e,...c}:e):[c]),i.getRange(c)}let a=null;if(t)a=i.getEntireRange();else{let e=this._coords;if(this._isEntireRange()){let t=i.getRange(e.cell);a=t.getSurrounding(),a.isEntireRange()&&(a=t)}else a=this.getRange().getSurrounding({contentOnly:n})}return a&&await a.select(),a}clear(){this._setSelectionRanges(h.EmptyRanges)}modify(e,t,n){if(this._shapePolicy===`cell`)return;let r=this._coords,i=this._rangesFromCellOptional(r,e,t??r.cell);if(!i)return;let a=r.rangeIndex;this._setSelectionRanges(e=>e.length?e.map((e,t)=>a===t?{...e,...i}:e):[i]),n&&i&&this._setSelectionCell({colIndex:i.colStart,rowIndex:i.rowStart})}append(e,t=e,n){if(this._shapePolicy!==`ranges`&&this._shapePolicy!==`mixed`||!e||this._isCellOutOfBounds(e)||this._isCellOutOfBounds(t))return;let r=this._coords,i=this._cellToRangeActual(e,t);if(!i)return;let a=r.ranges.length>0?[...r.ranges]:[this._cellToRangeActual(r.cell,r.cell)];a.push(i);let o={ranges:a,cell:{rowIndex:i.rowStart,colIndex:i.colStart,...n},rangeIndex:a.length-1};h.isEqualSelectionCoords(o,r)||this.updateCoords(o)}clearAndModify(e,t,n){let r=this._coords;e={...r.cell,...e},t??=e;let i=this._rangesFromCellOptional(r,e,t);if(!i)return;let a={rowIndex:i.rowStart,colIndex:i.colStart},o={...a,...n};this._navigationPolicy===`modify`?this.modify(a,a):(this._firstActiveCoords=o,this.clear()),this._setSelectionCell(o)}setAdjusting(e){this._adjusting=e,this._emitter.notify(`onAdjustingChange`)}getAdjusting(){let t=this._adjusting;if(!t)return null;let n=new e({sheet:this._sheet,coords:t,shapePolicy:this._shapePolicy,navigationPolicy:this._navigationPolicy});return n._adjusting=t,n}createSelection(t){return new e({sheet:this._sheet,coords:t?.coords,shapePolicy:t?.shapePolicy??this._shapePolicy,navigationPolicy:t?.navigationPolicy??this._navigationPolicy})}addListeners(e,t){return this._emitter.addListeners(e,t)}_setSelectionRanges(e){let t=this._coords,n=typeof e==`function`?e(t.ranges):e??h.EmptyRanges;if(h.isEqualRangesArrays(n,t.ranges))return;let r=Math.max(n.length?0:-1,Math.min(t.rangeIndex,n.length-1)),i=t.cell;r===-1||h.isCellWithinRange(i,n[r])||(i={rowIndex:n[r].rowStart,colIndex:n[r].colStart}),this._shapePolicy===`mixed`&&n.length===1&&h.isSingleCell(n[0])&&h.isCellWithinRange(i,n[0])&&(n=[],r=-1);let a={cell:i,ranges:n,rangeIndex:r};h.isEqualSelectionCoords(a,t)||this.updateCoords(a)}_setSelectionCell(e){let t=this._coords,n=e??h.EmptyCell,r=this._getRangeFromCell(n),i=this._shapePolicy===`range`||this._shapePolicy===`ranges`;if(t.ranges.length===0&&(i||!h.isSingleCell(r)))return this.updateCoords({ranges:[r],rangeIndex:0,cell:n});if(h.isEqualCells(n,t.cell))return this;let a=t.ranges,o=t.rangeIndex;this._shapePolicy===`mixed`&&t.ranges.length===1&&(h.isSingleCell(t.ranges[0])&&h.isCellWithinRange(n,t.ranges[0])||!h.isCellWithinRange(n,t.ranges[0]))&&(a=[],o=-1);let s={ranges:a,rangeIndex:o,cell:n};return h.isEqualSelectionCoords(s,t)?this:this.updateCoords(s)}_isCellOutOfBounds(e){let t=this._getEntireRange();return e.rowIndex<t.rowStart||e.colIndex<t.colStart||e.colIndex>t.colEnd||e.rowIndex>t.rowEnd}_cellToRangeActual(e,t){let 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)};return this._canSelectionSpanMergedCells(n)?n:this._closeOverMerges(n)}_closeOverMerges(e){return this._sheet.isDeleted()?e:$z(e,this._getMergedRanges.bind(this),this._getEntireRange())}_resolveMerges(e){if(this._sheet.isDeleted())return e;let t=e.ranges;if(t.length===0){let t=e.cell;if(!t||t.scope!==void 0)return e;let n=this._getRangeFromCell(t);return h.isSingleCell(n)?e:Object.freeze({cell:t,ranges:[n],rangeIndex:0})}let n=null;for(let e=0;e<t.length;e++){let r=t[e];if(!r||r.scope!==void 0||this._canSelectionSpanMergedCells(r))continue;let i=this._closeOverMerges(r);i!==r&&(n??=[...t],n[e]=i)}return n?Object.freeze({...e,ranges:n}):e}_rangesFromCellOptional(e,t,n){let 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},i={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)},a={rowIndex:i.rowStart,colIndex:i.colStart},o={rowIndex:i.rowEnd,colIndex:i.colEnd};if(!this._isCellOutOfBounds(a)&&!this._isCellOutOfBounds(o))return this._cellToRangeActual(a,o)}_getEntireRange(){return this._sheet.getEntireRange().getCoords()}_hiddenRowsAt(e,t){return this._sheet.getRowHeaders().getMetrics().hiddenHeadersAt(e,t)}_hiddenColumnsAt(e,t){return this._sheet.getColumnHeaders().getMetrics().hiddenHeadersAt(e,t)}_localCoords(e){if(!e||e.scope===void 0)return e;let{scope:t,...n}=e;return n}_getRangeFromCell(e){let t=h.cellToRange(e);if(this._sheet.isDeleted())return t;let n=this._sheet.getRange(this._localCoords(t),{ignoreHidden:!0}).getMerges();return n.length===0?t:n[0]}_canSelectionSpanMergedCells(e){let t=this._sheet.getRange(this._localCoords(e));return t.isEntireColumns()||t.isEntireRows()}_getMergedRanges(e){return this._sheet.getRange(this._localCoords(e),{ignoreHidden:!0}).getMerges()}_isContentfulCell(){return!1}_contentfulCellFinder(e,t){let n=this._sheet.getRange(this._localCoords(h.cellToRange(e))).getExtended(t,e).getCoords();switch(t){case B.Direction.Up:return n.rowStart;case B.Direction.Down:return n.rowEnd;case B.Direction.Left:return n.colStart;case B.Direction.Right:return n.colEnd}}_scrollCellCoordsIntoView(e,t){return this._sheet.scrollTo(e,t?{scroll:t}:void 0)}get[Symbol.toStringTag](){return`[RangeShape]`}toString(){let e=``;return e+=`selection:[${this._sheet.getRange(this._localCoords(this._coords.cell)).toString()}`,this._coords.ranges&&this._coords.ranges.length>0&&(e+=`, ${this._sheet.getRanges(this._coords.ranges.map(e=>this._localCoords(e))).toString()}`),this._coords.rangeIndex!==void 0&&this._coords.rangeIndex!==-1&&(e+=`, ${this._coords.rangeIndex}`),e+=`]`,e}get isIRangeSelection(){return!0}},sL=(e,t)=>e.getZIndex()-t.getZIndex(),cL=class extends iL{constructor(e){super(),this._items=Object.freeze([]);let t=e?.sheet;if(!t)throw Error(`MovableSelection requires a sheet.`);this._sheet=t}getWorksheet(){return this._sheet}getItems(){let e=this._items;for(let t=1;t<e.length;t++)if(sL(e[t-1],e[t])>0){this._items=Object.freeze([...e].sort(sL));break}return this._items}addListeners(e,t){return super.addListeners(e,t)}_traversal(){let e=[],t=n=>{let r=[...n].sort(sL);for(let n=0;n<r.length;n++){let i=r[n];if(i.isHidden()||i.isDeleted())continue;e.push(i);let a=i.getMovables();a&&t(a.getItems())}};return t(this._sheet.getMovables().getItems()),e}_comparable(e){return e.getWorksheet?.()===this._sheet}_check(e){if(!e||e.isDeleted()||e.getRange()?.getWorksheet()!==this._sheet)throw Error(`Movable ${e?.getContent()?.getName?.()??``} not found in sheet.`)}_afterChange(){this._items=Object.freeze([...this._picks].sort(sL))}get[Symbol.toStringTag](){return`[MovableSelection]`}get isIMovableSelection(){return!0}},lL=Object.freeze({coords:h.EmptyCell,topLeft:T.EmptyTopLeft}),uL=(Object.freeze({cell:h.EmptyCell,ranges:i.EmptyArray,rangeIndex:0}),Object.freeze({selection:null,topLeft:T.EmptyTopLeft,freezePanes:lL,showRowHeaders:!0,showColumnHeaders:!0,showRowGridlines:!0,showColumnGridlines:!0,rowHeaderStyle:Pk.HeaderTextStyle.One,columnHeaderStyle:Pk.HeaderTextStyle.A1,tableNames:Pk.ColumnHeaderTableNames.Sticky,showFormulas:!1,showLockedShading:!1,showInvalid:!1,showZeros:!0,showOutlineSymbols:!0,rightToLeft:!1,zoomScale:100,viewMode:Pk.ViewMode.Normal,zoomScales:null,showRuler:!0,showWhitespace:!0,windowProtection:!1,gridLineColor:null})),dL=Object.freeze({[Pk.ViewMode.Normal]:100,[Pk.ViewMode.PageBreakPreview]:60,[Pk.ViewMode.PageLayout]:100});function fL(e,t=!0,n=15,r=10,i=400){let a=Math.max(e-r,0)+(t?1:-1);return Math.min(i,Math[t?`ceil`:`floor`](a/n)*n+r)}var pL,mL,hL=class{constructor(e){let t=e?.sheet;if(!t)throw Error(`WorksheetView requires a sheet.`);this._id=i.uuidV4();let n=new ne(this);this._emitter=n,this._sheet=t;let r=new oL({sheet:t});this._rangeSelection=r;let a=new cL({sheet:t});this._movableSelection=a,this.clear(!1),e?.json&&this._fromJSON(e.json);let o=this,s={onChange(e){o._emitter.notify(`onSelectionChange`)}};this._rangeSelectionRemoveListener=r.addListeners(s,{transactional:!1});let c=new aL({sheet:t});this._chartElementSelection=c,this._movableSelectionRemoveListener=a.addListeners({onChange(){c._follow(),o._emitter.notify(`onMovableSelectionChange`)}},{transactional:!1}),this._chartElementSelectionRemoveListener=c.addListeners({onChange(){o._emitter.notify(`onChartElementSelectionChange`)}},{transactional:!1})}getId(){return this._id}addListeners(e,t){return this._emitter.addListeners(e,t)}setTopLeft(e){if(!e)return this;let t=this._state,n=t.topLeft,r=n.left,i=n.top,a=e.left??r,o=e.top??i;return a===r&&o===i||(t.topLeft=Object.freeze({left:a,top:o}),this._emitter.notify(`onTopLeftChange`)),this}getTopLeft(){return this._state.topLeft}getTopLeftCell(){let e=this._state.topLeft,t=this._state.freezePanes,n=t?.coords,r=t?.topLeft,i=(n?.rowIndex??0)>0,a=(n?.colIndex??0)>0;return{rowIndex:this._sheet.getRowHeaders().getMetrics().getIndex(i?r?.top??0:e.top),colIndex:this._sheet.getColumnHeaders().getMetrics().getIndex(a?r?.left??0:e.left)}}getFreezePanes(){return this._state.freezePanes}setFreezePanes(e){return this._state.freezePanes=this._mergeFreezePanes(e),this._emitter.notify(`onFreezePaneChange`),this}_mergeFreezePanes(e){if(!e)return lL;let t=this._state.freezePanes,n={...t,coords:{colIndex:e?.coords?.colIndex??t.coords.colIndex,rowIndex:e?.coords?.rowIndex??t.coords.rowIndex},topLeft:{left:e?.topLeft?.left??this._state.topLeft.left,top:e?.topLeft?.top??this._state.topLeft.top}};return e.paneSelections===void 0?n.coords.colIndex===t.coords.colIndex&&n.coords.rowIndex===t.coords.rowIndex||delete n.paneSelections:n.paneSelections=e.paneSelections,n}isShowRowHeaders(){return this._state.showRowHeaders}setShowRowHeaders(e){return this._update(e,`showRowHeaders`,`onHeaderChange`),this}isShowColumnHeaders(){return this._state.showColumnHeaders}setShowColumnHeaders(e){return this._update(e,`showColumnHeaders`,`onHeaderChange`),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._update(e,`rowHeaderStyle`,`onHeaderChange`),this}setColumnHeaderStyle(e){return this._update(e,`columnHeaderStyle`,`onHeaderChange`),this}getColumnHeaderStyle(){return this._state.columnHeaderStyle}setColumnHeaderTableNames(e){return this._update(e,`tableNames`,`onHeaderChange`),this}getColumnHeaderTableNames(){return this._state.tableNames}getZoomScale(){return this._state.zoomScale}setZoomScale(e){e<1&&console.warn(`Zoom scale is expressed as a whole number percentage (e.g., 100 for 100%).`);let t=Math.min(400,Math.max(10,e));return this._state.zoomScale===t?this:this._updateZoom(t)}zoomIn(){return this._updateZoom(fL(this.getZoomScale(),!0))}zoomOut(){return this._updateZoom(fL(this.getZoomScale(),!1))}_updateZoom(e){return e===this.getZoomScale()||(this.update({zoomScale:e,zoomScales:{...this._state.zoomScales,[this._state.viewMode]:e}}),this._emitter.notify(`onZoomScaleChange`)),this}getNextZoomScale(e,t){return fL(this.getZoomScale(),e,t)}getViewMode(){return this._state.viewMode}setViewMode(e){if(this._state.viewMode===e)return this;let t=this.getZoomScale();return this.update({viewMode:e,zoomScale:this._state.zoomScales?.[e]??dL[e]}),this.getZoomScale()!==t&&this._emitter.notify(`onZoomScaleChange`),this}isShowRuler(){return this._state.showRuler}setShowRuler(e){return this._state.showRuler=e,this._notifyAll(),this}isShowWhitespace(){return this._state.showWhitespace}setShowWhitespace(e){return this._state.showWhitespace=e,this._notifyAll(),this}isShowFormulas(){return this._state.showFormulas}setShowFormulas(e){return this._state.showFormulas=e,this._notifyAll(),this}isShowLockedShading(){return this._state.showLockedShading}setShowLockedShading(e){return this._state.showLockedShading=e,this._notifyAll(),this}isShowInvalid(){return this._state.showInvalid}setShowInvalid(e){return this._state.showInvalid=e,this._notifyAll(),this}isRightToLeft(){return this._state.rightToLeft}setRightToLeft(e){return this._state.rightToLeft=e,this._notifyAll(),this}isShowZeros(){return this._state.showZeros}setShowZeros(e){return this._state.showZeros=e,this._notifyAll(),this}isShowOutlineSymbols(){return this._state.showOutlineSymbols}setShowOutlineSymbols(e){return this._state.showOutlineSymbols=e,this._notifyAll(),this}getGridLineColor(){return this._state.gridLineColor}setGridLineColor(e){return this._state.gridLineColor=e,this._notifyAll(),this}getRangeSelection(){return this._rangeSelection}getMovableSelection(){return this._movableSelection}getChartElementSelection(){return this._chartElementSelection}_update(e,t,n){let r=this._state,i=r[t];return r[t]=e,i!==e&&this._emitter.notify(n),i}_notifyAll(){let e=this._emitter;e.notify(`onSelectionChange`),e.notify(`onTopLeftChange`),e.notify(`onZoomScaleChange`),e.notify(`onFreezePaneChange`),e.notify(`onAnyChange`),e.notify(`onHeaderChange`)}toJSON(){let e={},t=Object.keys(this._state),n=t.length;for(let r=0;r<n;r++){let n=t[r],i=this._state[n];i!=null&&i!==uL[n]&&(e[n]=i)}delete e.gridLineColor,this._state.gridLineColor instanceof De&&(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;let r=this._rangeSelection.getCoords();if(r){let t={};!r.cell||r.cell.colIndex===0&&r.cell.rowIndex===0||(t.cell=Fd(r.cell)),r.ranges&&r.ranges.length>0&&(t.ranges=Zd(r.ranges),r.rangeIndex!==void 0&&r.rangeIndex!==-1&&r.rangeIndex!==0&&(t.rangeIndex=r.rangeIndex)),Object.keys(t).length>0&&(e.selection=t)}return delete e.freezePanes,!this._state.freezePanes||this._state.freezePanes.coords.colIndex===0&&this._state.freezePanes.coords.rowIndex===0||(e.freezePanes={...this._state.freezePanes}),Object.keys(e).length===0?null:e}_fromJSON(e){let t=JSON.parse(JSON.stringify(e||{}));t?.zoomScale&&(t.zoomScale=i.roundAccurately(parseFloat(e.zoomScale),2));let n=e=>{let t=this._sheet.getRange(e).getBounds();return{x:1*t.x,y:1*t.y,width:1*t.width,height:1*t.height}};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`){let e=n(of(t.topLeft));t.topLeft={left:e.x,top:e.y}}else t.topLeft=Object.freeze({left:t.topLeft?.left??t?.x??0,top:t.topLeft?.top??t?.y??0})}if(t.selection){let e=of(t.selection.cell??`A1`);if(t.selection.cell=e,t.selection.ranges){let n=Math.max(0,Math.min(t.selection.rangeIndex??t.selection.ranges?.length-1,t.selection.ranges?.length-1));t.selection.rangeIndex=n;let r=!1;for(let i=0;i<t.selection.ranges.length;i++){let a=uf(t.selection.ranges[i]);t.selection.ranges[i]=a,i===n&&e&&!h.isCellWithinRange(e,a)&&(r=!0)}if(r)for(let n=0;r&&n<t.selection.ranges.length;n++)h.isCellWithinRange(e,t.selection.ranges[n])&&(r=!1,t.selection.rangeIndex=n);r&&(t.selection.ranges.push(h.cellToRange(e)),t.selection.rangeIndex=t.selection.ranges.length-1)}else delete t.selection.rangeIndex}if(t.freezePanes){let e=t.freezePanes;if(typeof e.coords==`string`&&(e.coords=of(e.coords)),typeof e.topLeft==`string`){let r=of(e.topLeft),i=n({colIndex:r.colIndex,rowIndex:r.rowIndex}),a=n({colIndex:e?.coords?.colIndex??0,rowIndex:e?.coords?.rowIndex??0});e.topLeft={left:0,top:0},t.topLeft||={top:0,left:0},r.colIndex>0&&(e.topLeft.left=t.topLeft?.left??0,t.topLeft.left=i.x-a.x+e.topLeft.left),r.rowIndex>0&&(e.topLeft.top=t.topLeft?.top??0,t.topLeft.top=i.y-a.y+e.topLeft.top)}t.freezePanes={coords:{colIndex:e?.coords?.colIndex??0,rowIndex:e?.coords?.rowIndex??0},topLeft:{left:e?.topLeft?.left??0,top:e?.topLeft?.top??0},...e?.paneSelections?{paneSelections:{...e.paneSelections}}:{}}}this.update(t)}clear(e=!0){return this._state={...uL},this._movableSelection.clear(),this._rangeSelection.clear(),e&&this._notifyAll(),this}update(e){let t={...uL,...this._state,...e};return t.selection&&(this._rangeSelection.updateCoords(t.selection),delete t.selection),t.freezePanes=this._mergeFreezePanes(t.freezePanes),t.zoomScale=Math.min(400,Math.max(10,t.zoomScale)),this._state=t,this._notifyAll(),this}get[Symbol.toStringTag](){return`[WorksheetView]`}toString(){let e=this.toJSON();return e?JSON.stringify(e):`DefaultSheetView`}get isIWorksheetView(){return!0}},gL=Object.freeze({summaryRow:B.Direction.Down,summaryColumn:B.Direction.Right,automaticStyles:!1}),_L=class{constructor(e){var t;this._removeListeners=[],this._closed=!1,this._rowGroups=null,this._columnGroups=null,this._options=e,this._transactions=e.transactions??new se({transient:!0}),this._id=this._transactions.create((t=e.json)?{summaryRow:t.summaryRow===`up`?B.Direction.Up:B.Direction.Down,summaryColumn:t.summaryColumn===`left`?B.Direction.Left:B.Direction.Right,automaticStyles:!0===t.automaticStyles}:gL),this._emitter=new ne(this,this._transactions);let n=this,r=()=>{n._emitter.notify(`onOutlineChange`)};this._removeListeners.push(this._transactions.addStateListener(this._id,{onAfterStateChange(){},onRestoreOrRevert(){n._rowGroups=null,n._columnGroups=null,r()}}));let i={onOutlineChange:r,onHiddenChange:r};this._removeListeners.push(e.rowHeaders.addListeners(i,{transactional:!1})),this._removeListeners.push(e.columnHeaders.addListeners(i,{transactional:!1}))}_getState(){return this._transactions.getState(this._id)}_updateState(e,t){let n=this._transactions.beginCommit({description:m(`op.updateOutline`),...t});try{n.updateState(this._id,e),this._rowGroups=null,this._columnGroups=null,this._emitter.notify(`onOutlineChange`),n.commit()}catch(e){throw n.rollback(),e}}_header(e){return e===B.Axis.Column?this._options.columnHeaders:this._options.rowHeaders}_sheet(){return this._options.rowHeaders.getWorksheet()}_assertUnlocked(){if(this._sheet().getProtection().isLocked())throw new b(N(`error.outline.sheetProtected`))}getSummaryDirection(e){let t=this._getState();return e===B.Axis.Column?t.summaryColumn:t.summaryRow}setSummaryDirection(e,t,n){let r=e===B.Axis.Column;if(!(r?t===B.Direction.Left||t===B.Direction.Right:t===B.Direction.Up||t===B.Direction.Down))throw Error(N(`error.outline.invalidSummaryDirection`,{direction:t,axis:e}));return this.getSummaryDirection(e)===t||(this._assertUnlocked(),this._updateState(r?{summaryColumn:t}:{summaryRow:t},n)),this}isAutomaticStyles(){return this._getState().automaticStyles}setAutomaticStyles(e,t){return this.isAutomaticStyles()===!!e||(this._assertUnlocked(),this._updateState({automaticStyles:!!e},t)),this}getLevelCount(e){return this._groups(e).byLevel.length}getGroups(e,t){let n=this._groups(e).byLevel,r=t?.level,a=t?.from,o=t?.to;if(r!==void 0){let e=n[r-1];return e?a===void 0&&o===void 0?e:SL(e,a??0,o??2**53-1):i.EmptyArray}let s=[];for(let e=0;e<n.length;e++){let t=a===void 0&&o===void 0?n[e]:SL(n[e],a??0,o??2**53-1);for(let e=0;e<t.length;e++)s.push(t[e])}return s}setVisibleLevels(e,t,n){let r=this._transactions.beginCommit({description:m(`op.showOutlineLevels`),...n});try{this._setVisibleLevels(e,Math.max(1,Math.floor(t))),r.commit()}catch(e){throw r.rollback(),e}return this}_setVisibleLevels(e,t){let n=this._groups(e);if(n.byLevel.length===0)return;let r=[],i=n.runs,a=null,o=()=>{a&&r.push({address:{min:a.min,max:a.max},update:{hidden:a.hidden}})};for(let e=0;e<i.length;e++){let n=i[e],r=n.value?.l??0;if(r===0)continue;let s=r>=t;a&&a.hidden===s&&a.max+1===n.min?a.max=n.max:(o(),a={min:n.min,max:n.max,hidden:s})}o();let s=new Map,c=n.byLevel;for(let e=0;e<c.length;e++){let n=c[e];for(let e=0;e<n.length;e++){let r=n[e].summary;r!==null&&s.set(r,n[e].level>=t)}}let l=this._header(e);l.updateHeaderPairs(r),l.updateHeaderPairs(function(e){let t=[...e.keys()].sort((e,t)=>e-t),n=Array(t.length);for(let r=0;r<t.length;r++){let i=t[r];n[r]={address:{min:i,max:i},update:{collapsed:e.get(i)}}}return n}(s))}_changeLevels(e,t,n,r){this._assertUnlocked();let i=this._header(e);n>0&&this._assertNotDeepest(e,t);let a=e===B.Axis.Column,o=m(n>0?a?`op.groupColumns`:`op.groupRows`:a?`op.ungroupColumns`:`op.ungroupRows`);i.updateHeaderPairs([{address:t,update:{outlineLevel:e=>e+n}}],{description:o,...r})}_assertNotDeepest(e,t){let n=this._header(e)._getHeaderRuns();for(let e=bL(n,t.min);e<n.length&&n[e].min<=t.max;e++)if((n[e].value?.l??0)>=7)throw Error(N(`error.outline.tooDeep`,{max:7}))}clear(e,t){this._assertUnlocked();let n=this._transactions.beginCommit({description:m(`op.clearOutline`),...t});try{e!==B.AxisSelection.Column&&this._clearAxis(B.Axis.Row),e!==B.AxisSelection.Row&&this._clearAxis(B.Axis.Column),n.commit()}catch(e){throw n.rollback(),e}return this}_clearAxis(e){let t=this._header(e);this._clear(e,t.getEntireRange().getCoords())}_clear(e,t,n){this._assertUnlocked(),this._header(e).updateHeaderPairs([{address:t,update:{outlineLevel:0,collapsed:!1}}],{description:m(`op.clearOutline`),...n})}_setGroupDetails(e,t,n,r){let i=this._selectGroups(e,t);if(i.length===0)return;let a=this._transactions.beginCommit({description:m(n?`op.showDetail`:`op.hideDetail`),...r});try{i.sort((e,t)=>n?e.level-t.level:t.level-e.level);for(let t=0;t<i.length;t++)n?this._showGroupDetails(e,i[t]):this._hideGroupDetails(e,i[t]);a.commit()}catch(e){throw a.rollback(),e}}_selectGroups(e,t){let n=this._groups(e).byLevel,r=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let e=0;e<a.length;e++){let n=a[e];n.summary!==null&&n.summary>=t.min&&n.summary<=t.max&&r.push(n),n.start<=t.max&&n.end>=t.min&&o.push(n)}o.length>0&&(i=o)}return r.length>0?r:i}_innerGroups(e,t){let n=this._groups(e).byLevel,r=[];for(let e=t.level;e<n.length;e++){let i=SL(n[e],t.start,t.end);for(let e=0;e<i.length;e++){let n=i[e];n.summary!==t.summary&&(n.start>t.end||n.end<t.start||r.push(n))}}return r}_hideGroupDetails(e,t){let n=this._header(e),r=[],i=new Set,a=this._innerGroups(e,t);for(let e=0;e<a.length;e++){let n=a[e].summary;a[e].collapsed&&n!==null&&!i.has(n)&&(n<t.start||n>t.end||(i.add(n),r.push({address:{min:n,max:n},update:{collapsed:!0}})))}r.push({address:{min:t.start,max:t.end},update:{hidden:!0}}),t.summary!==null&&r.push({address:{min:t.summary,max:t.summary},update:{collapsed:!0}}),n.updateHeaderPairs(r)}_showGroupDetails(e,t){let n=this._header(e),r=[],i=this._innerGroups(e,t);for(let e=0;e<i.length;e++)i[e].collapsed&&r.push({min:Math.max(i[e].start,t.start),max:Math.min(i[e].end,t.end)});r.sort((e,t)=>e.min-t.min);let a=[];t.summary!==null&&a.push({address:{min:t.summary,max:t.summary},update:{collapsed:!1}});let o=t.start;for(let e=0;e<r.length;e++){let t=r[e];t.min>o&&a.push({address:{min:o,max:t.min-1},update:{hidden:!1}}),o=Math.max(o,t.max+1)}o<=t.end&&a.push({address:{min:o,max:t.end},update:{hidden:!1}}),n.updateHeaderPairs(a)}autoOutline(e){this._assertUnlocked();let t=this._sheet().getUsedRange()?.getCoords()??null,n=t?this._findSummaries(t,B.Axis.Row):null,r=t?this._findSummaries(t,B.Axis.Column):null;if(!n?.spans.length&&!r?.spans.length)throw Error(N(`error.outline.cannotCreate`));let i=this._transactions.beginCommit({description:m(`op.autoOutline`),...e});try{for(let e of[B.Axis.Row,B.Axis.Column]){this._clearAxis(e);let t=e===B.Axis.Row?n:r;t.spans.length!==0&&(this._header(e).updateHeaderPairs(vL(t.spans)),this.setSummaryDirection(e,t.direction))}i.commit()}catch(e){throw i.rollback(),e}return this}_findSummaries(e,t){let n=t===B.Axis.Column,r=this._sheet(),i=new Map,a=new Map,o=e=>n?e.colStart:e.rowStart,s=e=>n?e.colEnd:e.rowEnd,c=e=>n?e.rowStart:e.colStart,l=(e,t)=>n?{rowStart:t,rowEnd:t,colStart:e,colEnd:e}:{rowStart:e,rowEnd:e,colStart:t,colEnd:t},u=e=>function(e,t,n,r,i){if(!e||e.getWorksheet()!==t)return null;let a=[],o=e.getCount();for(let t=0;t<o;t++){let r=e.at(t).getCoords(),o=n?r.colStart:r.rowStart,s=n?r.colEnd:r.rowEnd,c=n?r.rowStart:r.colStart,l=n?r.rowEnd:r.colEnd;if(c===i&&l===i)a.push({start:o,end:s});else if(s>o)return null}return a.length>0?a:null}(r.getRange(e).getCell().getFormula()?.getReferences()??null,r,n,o(e),c(e));for(let t of r.getRange(e).getRegions(Qh.Feature.Formula)){let e=t.getCoords(),n=o(e),r=s(e),d=c(e),f=u(l(n,d));if(!f)continue;let p=null;if(r>n){let e=u(l(n+1,d));if(!e||e.length!==f.length)continue;p=f.map((t,n)=>({start:e[n].start===t.start?0:1,end:e[n].end===t.end?0:1}))}for(let e=n;e<=r;e++){let t=e-n,r=Array(f.length);for(let e=0;e<f.length;e++)r[e]={start:f[e].start+t*(p?.[e].start??0),end:f[e].end+t*(p?.[e].end??0)};let o=yL(r,e);if(o===null)continue;let s=o===`before`?i:a,c=s.get(e);c?c.push(...r):s.set(e,r)}}if(i.size===0&&a.size===0)return{direction:this.getSummaryDirection(t),spans:[]};let d=Math.min(...i.keys())<=Math.min(...a.keys()),f=[...(d?i:a).keys()].sort((e,t)=>d?e-t:t-e),p=[],m=e=>{let{start:t,end:n}=e,r=!0;for(;r;){r=!1;for(let e=0;e<p.length;e++){let i=p[e];i.summary<t||i.summary>n||(i.start<t&&(t=i.start,r=!0),i.end>n&&(n=i.end,r=!0))}}return{start:t,end:n}};for(let e=0;e<f.length;e++){let t=f[e],n=(d?i:a).get(t).map(m);n.sort((e,t)=>e.start-t.start);let r=n[0].start,o=n[0].end;for(let e=1;e<n.length;e++){if(n[e].start>o+1)throw Error(N(`error.outline.cannotCreate`));o=Math.max(o,n[e].end)}r!==o&&(d?o=t-1:r=t+1,{start:r,end:o}=m({start:r,end:o}),r>o||p.push({summary:t,start:r,end:o}))}return{direction:n?d?B.Direction.Right:B.Direction.Left:d?B.Direction.Down:B.Direction.Up,spans:p}}_groups(e){let t=e===B.Axis.Column,n=this._header(e),r=n._getHeaderRuns(),i=this.getSummaryDirection(e),a=n.getEntireRange().getCoords().max,o=t?this._columnGroups:this._rowGroups;if(o&&o.runs===r&&o.direction===i&&o.entireMax===a)return o;let s={runs:r,direction:i,entireMax:a,byLevel:TL(r,i===B.Direction.Down||i===B.Direction.Right,a)};return t?this._columnGroups=s:this._rowGroups=s,s}addListeners(e,t){return this._emitter.addListeners(e,t)}toJSON(){let e=this._getState(),t={};return e.summaryRow===B.Direction.Up&&(t.summaryRow=`up`),e.summaryColumn===B.Direction.Left&&(t.summaryColumn=`left`),e.automaticStyles&&(t.automaticStyles=!0),Object.keys(t).length>0?t:null}close(){if(!this._closed){this._closed=!0;for(let e=0;e<this._removeListeners.length;e++)this._removeListeners[e]();this._removeListeners=[],this._emitter.close(),this._transactions.remove(this._id)}}get[Symbol.toStringTag](){return`[Outline]`}toString(){return`[Outline]`}get isIOutline(){return!0}};function vL(e){let t=new Map;for(let n=0;n<e.length;n++)t.set(e[n].start,(t.get(e[n].start)??0)+1),t.set(e[n].end+1,(t.get(e[n].end+1)??0)-1);let n=[...t.keys()].sort((e,t)=>e-t),r=[],i=0;for(let e=0;e<n.length-1;e++)i+=t.get(n[e]),i<=0||r.push({address:{min:n[e],max:n[e+1]-1},update:{outlineLevel:Math.min(7,i)}});return r}function yL(e,t){let n=0;for(let r=0;r<e.length;r++)if(e[r].end<t)n++;else if(e[r].start<=t)return null;return n!==0&&n!==e.length?null:n===e.length?`before`:`after`}function bL(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>>1;e[i].max<t?n=i+1:r=i}return n}function xL(e,t){let n=e[bL(e,t)];return!n||n.min>t?null:n.value??null}function SL(e,t,n){let r=0,i=e.length;for(;r<i;){let n=r+i>>>1;wL(e[n])<t?r=n+1:i=n}let a=r;for(;a<e.length&&CL(e[a])<=n;)a++;return r===0&&a===e.length?e:e.slice(r,a)}function CL(e){return e.summary!==null&&e.summary<e.start?e.summary:e.start}function wL(e){return e.summary!==null&&e.summary>e.end?e.summary:e.end}function TL(e,t,n){let r=0;for(let t=0;t<e.length;t++){let n=e[t].value?.l??0;n>r&&(r=n)}let i=Array(r);for(let a=1;a<=r;a++){let r=[],o=-1,s=-2,c=!0,l=()=>{if(o<0)return;let i=t?s+1:o-1;(i<0||i>n)&&(i=null);let l=c;if(l&&i!==null){let t=xL(e,i);!0===t?.h&&(l=!0===t.cl)}r.push(Object.freeze({level:a,start:o,end:s,summary:i,collapsed:l}))};for(let t=0;t<e.length;t++){let n=e[t],r=n.value;if((r?.l??0)<a)continue;let i=!0===r?.h;o>=0&&s+1===n.min?(s=n.max,c&&=i):(l(),o=n.min,s=n.max,c=i)}l(),i[a-1]=r}return i}(mL=pL||={}).Orientation={Portrait:`portrait`,Landscape:`landscape`},mL.PaperType={Letter:`letter`,LetterSmall:`letterSmall`,Tabloid:`tabloid`,Ledger:`ledger`,Legal:`legal`,Statement:`statement`,Executive:`executive`,A3:`a3`,A4:`a4`,A4Small:`a4Small`,A5:`a5`,B4:`b4`,B5:`b5`,Folio:`folio`,Quatro:`quatro`,Paper10x14:`paper10x14`,Paper11x17:`paper11x17`,Note:`note`,Envelope9:`envelope9`,Envelope10:`envelope10`,Envelope11:`envelope11`,Envelope12:`envelope12`,Envelope14:`envelope14`,Csheet:`csheet`,Dsheet:`dsheet`,Esheet:`esheet`,EnvelopeDL:`envelopeDL`,EnvelopeC5:`envelopeC5`,EnvelopeC3:`envelopeC3`,EnvelopeC4:`envelopeC4`,EnvelopeC6:`envelopeC6`,EnvelopeC65:`envelopeC65`,EnvelopeB4:`envelopeB4`,EnvelopeB5:`envelopeB5`,EnvelopeB6:`envelopeB6`,EnvelopeItaly:`envelopeItaly`,EnvelopeMonarch:`envelopeMonarch`,EnvelopePersonal:`envelopePersonal`,FanfoldUS:`fanfoldUS`,FanfoldStdGerman:`fanfoldStdGerman`,FanfoldLegalGerman:`fanfoldLegalGerman`},mL.PrintOrder={DownThenOver:`downThenOver`,OverThenDown:`overThenDown`},mL.PrintComments={NoComments:`noComments`,EndSheet:`endSheet`,InPlace:`inPlace`},mL.PrintErrorType={AsDisplayed:`asDisplayed`,Blank:`blank`,Dash:`dash`,NotAvailable:`notAvailable`},mL.PrintMarginUnit={Points:`points`,Inches:`inches`,Centimeters:`centimeters`},mL.HeaderFooterState={Default:`default`,FirstAndDefault:`firstAndDefault`,OddAndEven:`oddAndEven`,FirstOddAndEven:`firstOddAndEven`};var EL=Object.freeze({left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3}),DL=72,OL=Object.values(pL.PaperType),kL=`_xlnm.Print_Area`,AL=`_xlnm.Print_Titles`,jL=e=>{let t=``;return e[0]&&(t+=`&L`+e[0]),e[1]&&(t+=`&C`+e[1]),e[2]&&(t+=`&R`+e[2]),t},ML=e=>Object.keys(e).length===0,NL=class{constructor(e){this._headersFooters=null,this._options=e,this._transactions=e.transactions??new se({transient:!0});let t={...e.json},n=Kx.fromJSON(t.printerSettings,e.fromResourceId);delete t.printerSettings,this._id=this._transactions.create({json:Object.freeze(t),printerSettings:n})}_getState(){return this._transactions.getState(this._id)}_getJSON(){return this._getState().json}_update(e,t,n){let r={...this._getJSON()},i=!1;for(let t of Object.keys(e)){let n=e[t];r[t]!==n&&(i=!0,n===void 0?delete r[t]:r[t]=n)}if(!i)return this;let a=this._transactions.beginCommit({description:n??m(`op.updatePageLayout`),...t});try{a.updateState(this._id,{json:Object.freeze(r)}),a.commit()}catch(e){throw a.rollback(),e}return this}_sheet(){return this._options.getSheet()}_getSheet(){return this._sheet()}getOrientation(){return this._getJSON().orientation??pL.Orientation.Portrait}setOrientation(e,t){return this._update({orientation:e},t)}getPaperSize(){return OL[this.getPaperSizeCode()-1]??null}getPaperSizeCode(){return this._getJSON().paperSize??1}setPaperSize(e,t){let n=typeof e==`number`?Math.floor(e):OL.indexOf(e)+1;if(!(n>=1))throw Error(N(`error.pageLayout.invalidPaperSize`,{paperSize:e}));return this._update({paperSize:n===1?void 0:n},t)}getZoom(){let e=this._getJSON();return e.fitToPage?{horizontalFitToPages:e.fitToWidth??1,verticalFitToPages:e.fitToHeight??1}:{scale:e.scale??100}}setZoom(e,t){let{scale:n,horizontalFitToPages:r,verticalFitToPages:i}=e??{},a=r!==void 0||i!==void 0;if(n!==void 0&&a)throw Error(N(`error.pageLayout.zoomScaleAndFit`));if(n!==void 0){if(!(n>=10&&n<=400))throw Error(N(`error.pageLayout.invalidScale`,{scale:n}));let e=Math.round(n);return this._update({fitToPage:void 0,scale:e===100?void 0:e},t)}if(!a)return this;let o=(e,t)=>{if(e===void 0)return t;if(!(e>=0&&e<=32767))throw Error(N(`error.pageLayout.invalidFitToPages`,{pages:e}));let n=Math.round(e);return n===1?void 0:n},s=this._getJSON();return this._update({fitToPage:!0,fitToWidth:o(r,s.fitToWidth),fitToHeight:o(i,s.fitToHeight)},t)}_margins(){return this._getJSON().margins??EL}_setMargins(e,t){let n={...this._margins()};for(let t of Object.keys(e)){let r=e[t];if(r!==void 0){if(!(r>=0))throw Error(N(`error.pageLayout.invalidMargin`,{margin:t,value:r}));n[t]=r}}let r=Object.keys(EL).every(e=>n[e]===EL[e]),i=this._getJSON().margins;return i&&Object.keys(n).every(e=>n[e]===i[e])?this:this._update({margins:r?void 0:n},t)}getTopMargin(){return this._margins().top*DL}setTopMargin(e,t){return this.setPrintMargins(pL.PrintMarginUnit.Points,{top:e},t)}getBottomMargin(){return this._margins().bottom*DL}setBottomMargin(e,t){return this.setPrintMargins(pL.PrintMarginUnit.Points,{bottom:e},t)}getLeftMargin(){return this._margins().left*DL}setLeftMargin(e,t){return this.setPrintMargins(pL.PrintMarginUnit.Points,{left:e},t)}getRightMargin(){return this._margins().right*DL}setRightMargin(e,t){return this.setPrintMargins(pL.PrintMarginUnit.Points,{right:e},t)}getHeaderMargin(){return this._margins().header*DL}setHeaderMargin(e,t){return this.setPrintMargins(pL.PrintMarginUnit.Points,{header:e},t)}getFooterMargin(){return this._margins().footer*DL}setFooterMargin(e,t){return this.setPrintMargins(pL.PrintMarginUnit.Points,{footer:e},t)}setPrintMargins(e,t,n){let r=e===pL.PrintMarginUnit.Inches?e=>e:e===pL.PrintMarginUnit.Centimeters?e=>e/2.54:e=>e/DL,i={};for(let e of Object.keys(t??{})){let n=t[e];n!==void 0&&(i[e]=n<0?n:r(n))}return this._setMargins(i,n)}getCenterHorizontally(){return!!this._getJSON().centerHorizontally}setCenterHorizontally(e,t){return this._update({centerHorizontally:!!e||void 0},t)}getCenterVertically(){return!!this._getJSON().centerVertically}setCenterVertically(e,t){return this._update({centerVertically:!!e||void 0},t)}getPrintGridlines(){return!!this._getJSON().printGridlines}setPrintGridlines(e,t){return this._update({printGridlines:!!e||void 0},t)}getPrintHeadings(){return!!this._getJSON().printHeadings}setPrintHeadings(e,t){return this._update({printHeadings:!!e||void 0},t)}getBlackAndWhite(){return!!this._getJSON().blackAndWhite}setBlackAndWhite(e,t){return this._update({blackAndWhite:!!e||void 0},t)}getDraftMode(){return!!this._getJSON().draftMode}setDraftMode(e,t){return this._update({draftMode:!!e||void 0},t)}getFirstPageNumber(){let e=this._getJSON();return e.useFirstPageNumber?e.firstPageNumber??1:``}setFirstPageNumber(e,t){return e===``||e==null?this._update({useFirstPageNumber:void 0,firstPageNumber:void 0},t):this._update({useFirstPageNumber:!0,firstPageNumber:Math.floor(e)},t)}getPrintOrder(){return this._getJSON().printOrder??pL.PrintOrder.DownThenOver}setPrintOrder(e,t){return this._update({printOrder:e===pL.PrintOrder.OverThenDown?e:void 0},t)}getPrintComments(){return this._getJSON().printComments??pL.PrintComments.NoComments}setPrintComments(e,t){return this._update({printComments:e===pL.PrintComments.NoComments?void 0:e},t)}getPrintErrors(){return this._getJSON().printErrors??pL.PrintErrorType.AsDisplayed}setPrintErrors(e,t){return this._update({printErrors:e===pL.PrintErrorType.AsDisplayed?void 0:e},t)}getHeadersFooters(){return this._headersFooters||=new PL(this),this._headersFooters}_getName(e){let t=this._sheet(),n=t.getNames().getByName(e);return n&&n.getScope()?.toLowerCase()===t.getName().toLowerCase()?n:null}_setName(e,t){let n=this._getName(e);t===null?n?.delete():n?n.setExpression(t):this._sheet().getNames().addFormula(e,t,!0)}_toReference(e){let t=this._sheet(),n=t.getEntireCoords(),r=t.getName();return e.map(e=>Gd({...e,scope:r,$colStart:!0,$colEnd:!0,$rowStart:!0,$rowEnd:!0},n)).join(`,`)}_nameCoords(e){let t=this._getName(e)?.getExpression();if(!t)return null;let n=this._sheet().getEntireCoords(),r=[];for(let e of t.split(/,(?=(?:[^']*'[^']*')*[^']*$)/)){let t=Yd(e.trim(),n);if(!t||t.rowStart===void 0||t.colStart===void 0)return null;r.push({rowStart:t.rowStart,colStart:t.colStart,rowEnd:t.rowEnd,colEnd:t.colEnd})}return r.length>0?r:null}getPrintArea(){let e=this._nameCoords(kL);return e?this._sheet().getRanges(e):this._getName(kL)?.getRanges()??null}setPrintArea(e,t){if(e==null||e===``)return this._setName(kL,null),this;let n=this._sheet().getRanges(e);return this._setName(kL,this._toReference(n.getCoords())),this}_titles(){let e={rows:null,columns:null},t=this._nameCoords(AL);if(!t)return e;let n=this._sheet(),r=n.getEntireCoords();for(let i of t){let t=i.colStart<=r.colStart&&i.colEnd>=r.colEnd,a=i.rowStart<=r.rowStart&&i.rowEnd>=r.rowEnd;t&&!e.rows?e.rows=n.getRange(i):a&&!e.columns&&(e.columns=n.getRange(i))}return e}_setTitles(e,t){let n=[];t&&n.push(t),e&&n.push(e),this._setName(AL,n.length>0?this._toReference(n):null)}_toTitle(e,t){if(e==null||e===``)return null;let n=this._sheet(),r=(typeof e==`string`?n.getRange(e):e).getCoords(),i=n.getEntireCoords();if(!(t===B.Axis.Row?r.colStart<=i.colStart&&r.colEnd>=i.colEnd:r.rowStart<=i.rowStart&&r.rowEnd>=i.rowEnd))throw Error(t===B.Axis.Row?N(`error.pageLayout.titleRowsNotEntire`):N(`error.pageLayout.titleColumnsNotEntire`));return{colStart:r.colStart,colEnd:r.colEnd,rowStart:r.rowStart,rowEnd:r.rowEnd}}getPrintTitleRows(){return this._titles().rows}setPrintTitleRows(e,t){let n=this._toTitle(e,B.Axis.Row);return this._setTitles(n,this._titles().columns?.getCoords()??null),this}getPrintTitleColumns(){return this._titles().columns}setPrintTitleColumns(e,t){let n=this._toTitle(e,B.Axis.Column);return this._setTitles(this._titles().rows?.getCoords()??null,n),this}_getHeaderFooter(e){return this._getJSON().headerFooter?.[e]??``}_updateHeaderFooter(e,t){let n={...this._getJSON().headerFooter};for(let t of Object.keys(e)){let r=e[t];r===void 0||r===``||!1===r?delete n[t]:n[t]=r}let r=this._getJSON().headerFooter??{},i=new Set([...Object.keys(r),...Object.keys(n)]),a=!1;return i.forEach(e=>{r[e]!==n[e]&&(a=!0)}),a?this._update({headerFooter:ML(n)?void 0:n},t):this}_getBreaks(e){let t=this._getJSON();return(e===B.Axis.Row?t.rowBreaks:t.columnBreaks)??[]}_setBreaks(e,t,n){let r=t.length>0?t:void 0;return this._update(e===B.Axis.Row?{rowBreaks:r}:{columnBreaks:r},n,m(`op.updatePageBreaks`))}_shiftBreaks(e,t,n,r){let i=this._getBreaks(e);if(i.length===0)return;let a=n-t+1,o=[],s=!1;for(let e=0;e<i.length;e++){let c=i[e],l=c.index;r?l>=t?(o.push({...c,index:l+a}),s=!0):o.push(c):l>=t&&l<=n?s=!0:l>n?(o.push({...c,index:l-a}),s=!0):o.push(c)}s&&this._setBreaks(e,o)}_getPageBreaks(e){let t=this._getBreaks(e),n=[];for(let r=0;r<t.length;r++)t[r].automatic||n.push(new IL(this,e,t[r]));return n}getHorizontalPageBreaks(){return this._getPageBreaks(B.Axis.Row)}getVerticalPageBreaks(){return this._getPageBreaks(B.Axis.Column)}addHorizontalPageBreak(e,t){return this._addPageBreak(B.Axis.Row,this._sheet().getRange(e).getCoords().rowStart,t)}addVerticalPageBreak(e,t){return this._addPageBreak(B.Axis.Column,this._sheet().getRange(e).getCoords().colStart,t)}removeAllHorizontalPageBreaks(e){return this._removeAllPageBreaks(B.Axis.Row,e),this}removeAllVerticalPageBreaks(e){return this._removeAllPageBreaks(B.Axis.Column,e),this}get isIPageLayout(){return!0}_addPageBreak(e,t,n){if(!(t>=1))throw Error(e===B.Axis.Row?N(`error.pageLayout.breakBeforeFirstRow`):N(`error.pageLayout.breakBeforeFirstColumn`));let r=this._getBreaks(e).slice(),i=0;for(;i<r.length&&r[i].index<t;)i++;let a=r[i]?.index===t?r[i]:null;if(a&&!a.automatic)return new IL(this,e,a);let o;if(a)o={...a},delete o.automatic;else{let n=this._sheet().getEntireCoords();o={index:t,max:e===B.Axis.Row?n.colEnd:n.rowEnd}}return r.splice(i,+!!a,o),this._setBreaks(e,r,n),new IL(this,e,o)}_removePageBreak(e,t,n){let r=this._getBreaks(e),i=r.filter(e=>e.index!==t);i.length!==r.length&&this._setBreaks(e,i,n)}_removeAllPageBreaks(e,t){this._getBreaks(e).length>0&&this._setBreaks(e,[],t)}_getPrinterSettings(){return this._getState().printerSettings}toJSON(e){let t=this._getState(),n={...t.json},r=Kx.toJSON(t.printerSettings,e);return r&&(n.printerSettings=r),ML(n)?null:n}_sections(e){return(e=>{let t=[``,``,``],n=1,r=0,i=0,a=e.length;for(;i<a;){if(e[i]!==`&`||i+1>=a){i++;continue}let o=e[i+1];if(o===`L`||o===`C`||o===`R`)t[n]+=e.substring(r,i),n=o===`L`?0:o===`C`?1:2,i+=2,r=i;else if(o===`"`){let t=e.indexOf(`"`,i+2);i=t===-1?a:t+1}else i+=2}return t[n]+=e.substring(r),t})(this._getHeaderFooter(e))}_setSection(e,t,n,r){let i=this._sections(e);return i[t]===n?this:(i[t]=n??``,this._updateHeaderFooter({[e]:jL(i)},r))}},PL=class{constructor(e){this._layout=e,this._sets={odd:new FL(e,`odd`),even:new FL(e,`even`),first:new FL(e,`first`)}}getState(){let e=this._layout._getJSON().headerFooter,t=!!e?.differentFirst,n=!!e?.differentOddEven;return t&&n?pL.HeaderFooterState.FirstOddAndEven:t?pL.HeaderFooterState.FirstAndDefault:n?pL.HeaderFooterState.OddAndEven:pL.HeaderFooterState.Default}setState(e,t){let n=e===pL.HeaderFooterState.FirstAndDefault||e===pL.HeaderFooterState.FirstOddAndEven,r=e===pL.HeaderFooterState.OddAndEven||e===pL.HeaderFooterState.FirstOddAndEven;return this._layout._updateHeaderFooter({differentFirst:n,differentOddEven:r},t),this}getDefaultForAllPages(){return this._sets.odd}getOddPages(){return this._sets.odd}getEvenPages(){return this._sets.even}getFirstPage(){return this._sets.first}getUseSheetMargins(){return!this._layout._getJSON().headerFooter?.ignoreSheetMargins}setUseSheetMargins(e,t){return this._layout._updateHeaderFooter({ignoreSheetMargins:!e},t),this}getUseSheetScale(){return!this._layout._getJSON().headerFooter?.ignoreSheetScale}setUseSheetScale(e,t){return this._layout._updateHeaderFooter({ignoreSheetScale:!e},t),this}},FL=class{constructor(e,t){this._layout=e,this._header=`${t}Header`,this._footer=`${t}Footer`}getLeftHeader(){return this._layout._sections(this._header)[0]}setLeftHeader(e,t){return this._layout._setSection(this._header,0,e,t),this}getCenterHeader(){return this._layout._sections(this._header)[1]}setCenterHeader(e,t){return this._layout._setSection(this._header,1,e,t),this}getRightHeader(){return this._layout._sections(this._header)[2]}setRightHeader(e,t){return this._layout._setSection(this._header,2,e,t),this}getLeftFooter(){return this._layout._sections(this._footer)[0]}setLeftFooter(e,t){return this._layout._setSection(this._footer,0,e,t),this}getCenterFooter(){return this._layout._sections(this._footer)[1]}setCenterFooter(e,t){return this._layout._setSection(this._footer,1,e,t),this}getRightFooter(){return this._layout._sections(this._footer)[2]}setRightFooter(e,t){return this._layout._setSection(this._footer,2,e,t),this}getHeader(){return this._layout._getHeaderFooter(this._header)}setHeader(e,t){return this._layout._updateHeaderFooter({[this._header]:e??``},t),this}getFooter(){return this._layout._getHeaderFooter(this._footer)}setFooter(e,t){return this._layout._updateHeaderFooter({[this._footer]:e??``},t),this}},IL=class{constructor(e,t,n){this._layout=e,this._axis=t,this._json=n}getRowIndex(){return this._axis===B.Axis.Row?this._json.index:this._json.min??0}getColumnIndex(){return this._axis===B.Axis.Column?this._json.index:this._json.min??0}getCellAfterBreak(){let e=this.getRowIndex(),t=this.getColumnIndex();return this._layout._getSheet().getRange({rowStart:e,rowEnd:e,colStart:t,colEnd:t})}delete(e){this._layout._removePageBreak(this._axis,this._json.index,e)}},LL=class e{constructor(e,t,n){this.isIExternalBook=!0,this._json=e,this._id=t,this._collection=n}getId(){return this._id}getDisplayName(e){return FA(this,e)}getSources(){return this._json.sources??i.EmptyArray}getSheetNames(){return this._json.sheetNames}getDefinedNames(){return this._json.definedNames??[]}getSheetData(e){return this._json.sheetDataSet?.find(t=>t.sheetIndex===e)??null}getDependents(){return this._collection._getDependents(this._id)}delete(e){this._collection._remove(this._id,e)}breakLink(e){this._collection._breakLink(this._id,e)}refresh(){return this._collection._refresh(this._id)}toJSON(){return this._json}_withSnapshot(t){return new e({...this._json,sheetNames:[...t.sheetNames],definedNames:t.definedNames?[...t.definedNames]:void 0,sheetDataSet:t.sheetDataSet?[...t.sheetDataSet]:void 0},this._id,this._collection)}_withRefreshError(){let t=this._json.sheetDataSet;return!t||t.length===0||t.every(e=>e.refreshError)?this:new e({...this._json,sheetDataSet:t.map(e=>e.refreshError?e:{...e,refreshError:!0})},this._id,this._collection)}_withSheetName(t){return new e({...this._json,sheetNames:[...this._json.sheetNames,t]},this._id,this._collection)}},RL=class extends Qt{constructor(e){super(e?.transactions),this.isIExternalBookCollection=!0,this._getDependentsById=e?.getDependents??null,this._getSheetRange=e?.getSheetRange??null,this._resolver=e?.resolver??null;let t=this;this._transactions=e?.transactions??new se({transient:!0}),this._stateId=this._transactions.create(),this._transactionsRemoveListener=this._transactions.addStateListener(this._stateId,{onAfterStateChange(e){t._notifyCollectionChange()}});let n=e?.json??[],r=n.map(()=>i.uuidV4()),a=n.map((e,t)=>e?new LL(e,r[t],this):null),o=this._beginCommit(m(`op.initialize`));try{o.updateState(this._stateId,()=>({items:a,ids:r})),o.amend()}catch(e){throw o.rollback(),e}}_getIdByIndex(e){return this._getState().ids[e-1]??null}_getIndexById(e){let t=this._getState().ids.indexOf(e);return t===-1?-1:t+1}getById(e){let t=this._getState(),n=t.ids.indexOf(e);return n===-1?null:t.items[n]??null}_getItems(){let e=[],t=this._getState().items,n=t.length;for(let r=0;r<n;r++){let n=t[r];n&&e.push(n)}return e}_getByIndex(e){return this._getState().items[e-1]??null}add(e,t){this._assertWritable();let n=typeof e.sources==`string`?[LA(e.sources)]:[...e.sources];if(n.length===0)throw Error(`sources is required`);let r={sources:n,sheetNames:e.sheetNames?[...e.sheetNames]:[]},a=i.uuidV4(),o=new LL(r,a,this);return this._updateState(e=>({items:[...e.items,o],ids:[...e.ids,a]}),{description:N(`op.addExternalBook`,{name:PA(o)}),...t}),o}_remove(e,t){this._assertWritable();let n=this._getState(),r=n.ids.indexOf(e);if(r===-1)return!1;let i=n.items[r],a=i?N(`op.removeExternalBook`,{name:PA(i)}):m(`op.removeExternalBook`);return this._updateState(t=>{let n=t.ids.indexOf(e);if(n===-1)return t;let r=[...t.items],i=[...t.ids];return r.splice(n,1),i.splice(n,1),{items:r,ids:i}},{description:a,...t}),!0}_breakLink(e,t){this._assertWritable();let n=this.getById(e);if(!n)return!1;let r=N(`op.breakExternalLink`,{name:PA(n)});return this._transactions.doBatch(()=>(this._breakDependents(n),this._remove(e)),{description:r,...t})}breakAll(e){this._assertWritable();let t=this.getItems();return t.length===0?0:this._transactions.doBatch(()=>{let e=0;for(let n=0;n<t.length;n++)this._breakDependents(t[n]),this._remove(t[n].getId())&&e++;return e},{description:m(`op.breakExternalLinks`),...e})}async refreshAll(){let e=this.getItems(),t=[];for(let n=0;n<e.length;n++)t.push(await this._refresh(e[n].getId()));return t}async _refresh(e){let t=this.getById(e),n=this._resolver;if(!t||!n)return{bookId:e,status:`unavailable`};let r;try{r=await n.resolve(t)}catch(t){return this.getById(e)&&this._markRefreshError(e),{bookId:e,status:`failed`,error:t?.message??String(t)}}return r&&this.getById(e)?(this._assertWritable(),this._updateState(t=>{let n=t.ids.indexOf(e),i=t.items[n];if(!i)return t;let a=[...t.items];return a[n]=i._withSnapshot(r),{...t,items:a}},{description:N(`op.refreshExternalLink`,{name:PA(t)})}),{bookId:e,status:`refreshed`}):{bookId:e,status:`unavailable`}}_markRefreshError(e){this._assertWritable(),this._updateState(t=>{let n=t.ids.indexOf(e),r=t.items[n];if(!r)return t;let i=r._withRefreshError();if(i===r)return t;let a=[...t.items];return a[n]=i,{...t,items:a}},{description:N(`op.refreshExternalLink`,{name:PA(this.getById(e))})})}_breakDependents(e){let t=e.getDependents();for(let e=0;e<t.length;e++){let n=t[e],r=this._getSheetRange?.(n)??null;r&&r.setValues(r.getValues())}}_getDependents(e){return this._getDependentsById?.(e)??i.EmptyArray}_addSheetName(e,t){this._assertWritable();let n=this._getState(),r=n.ids.indexOf(e),i=n.items[r];if(!i)return-1;let a=i.getSheetNames(),o=t.toLowerCase();for(let e=0;e<a.length;e++)if(a[e].toLowerCase()===o)return e;return this._updateState(n=>{let r=n.ids.indexOf(e),i=n.items[r];if(!i)return n;let a=[...n.items];return a[r]=i._withSheetName(t),{...n,items:a}},{description:N(`op.addExternalBook`,{name:PA(i)})}),a.length}toJSON(){let e=this._getState().items;return e.length===0?null:e.map(e=>e?.toJSON()??null)}addListeners(e,t){return super.addListeners(e,t)}close(){this.isClosed()||(this._close(),this._transactionsRemoveListener?.())}_assertWritable(){if(this.isClosed())throw Error(N(`error.model.modelClosed`))}_getState(){return this._transactions.getState(this._stateId)}_beginCommit(e){return this._transactions.beginCommit(typeof e==`string`?{description:e}:e)}_updateState(e,t){let n=this._beginCommit(t);try{n.updateState(this._stateId,e),n.commit()}catch(e){throw n.rollback(),e}}},zL=Object.freeze({colStart:0,rowStart:0,colEnd:0,rowEnd:0}),BL=class extends Qt{constructor(e){super(e?.transactions),this._pendingJSON=null,this._wiringDirty=!1,this._wiringBatchDepth=0,this._namesEmitter=null,this._nameIndex=null,this._written=new Set,this._hydrating=!1,this._hydratingItems=null,this._engine=e?.engine??null,this._bindSheet=e?.bindSheet??null,this._ready=e?.ready??null,this._getActiveCell=e?.getActiveCell??(()=>null),this._createHost=e?.createHost??null,this._getRange=e?.getRange,this._getRanges=e?.getRanges,this._createGraphRanges=e?.createGraphRanges,this._resolveSheetScope=e?.resolveSheetScope??null,this._isReadOnly=e?.isReadOnly??null,this._getOrBindProxyFakeId=e?.getOrBindProxyFakeId??null,this._queuePendingAction=e?.queuePendingAction??null,this._isEngineReady=e?.isEngineReady??null;let t=this;this._transactions=e?.transactions??new se({transient:!0}),this._stateId=this._transactions.create(),this._transactionsRemoveListener=this._transactions.addStateListener(this._stateId,{onAfterStateChange(e){t._notifyCollectionChange()},onRestoreOrRevert(){for(let e of t._written)e._isStateAbsent()&&e._onRestoreOrRevert()}}),this._initState()}hydrate(e){if(this._pendingJSON=null,!e||e.length===0)return;let t=e.length;this._hydrating=!0;let n=this._beginCommit(m(`op.initialize`));try{for(let n=0;n<t;n++){let t=e[n];try{this._add({name:t.name,expression:t.ref,scope:t.scope??null,comment:t.comment,hidden:t.hidden,fileAttributes:t.fileAttributes},!UL.test(t.ref??``))}catch(e){O.warn(`Unable to load named item '${t?.name}'.`,{meta:e?.message})}}n.amend()}catch(e){throw n.rollback(),e}finally{this._hydrating=!1,this._hydratingItems=null}}setPendingJSON(e){this._pendingJSON=e??null}toJSON(){let e=this._getState();if(!e||e.itemsById.size===0){let e=this._pendingJSON;return e&&e.length>0?e.map(e=>({...e})):null}let t=Array.from(e.itemsById.values());t.sort((e,t)=>{let n=qL(e.getScope()).localeCompare(qL(t.getScope()));return n===0?qL(e.getName()).localeCompare(qL(t.getName())):n});let n=[],r=t.length;for(let e=0;e<r;e++){let r=t[e].toJSON();r&&n.push(r)}return n.length>0?n:null}add(e){return this._add(e,!1)}_add(e,t){if(this.isClosed())throw Error(N(`error.model.modelClosed`));if(!this._hydrating&&this._isReadOnly?.())throw Error(N(`error.named.nameReadonly`));if(!e?.name)throw Error(`name is required`);if(!e?.expression)throw Error(`expression is required`);let n=null;if(e.cell&&this._getRange){let t=this._getRange(e.cell)?.getCoords()??null;t&&h.isSingleCell(t)&&(n={colIndex:t.colStart,rowIndex:t.rowStart})}n||=this._getActiveCell?.()??h.EmptyCell;let r=n.scope??this._getActiveCell?.()?.scope??null,i=this._resolveScopeInput(e.scope??null),a=this._findSameIdentity(e.name,i);if(a){if(!e.replaceExisting)throw Error(N(`error.named.nameExists`,{name:e.name}));a.delete()}let o=this._getOrBindProxyFakeId?.(e.name,this._resolveScopeName(i))??null,s=this._createHost,c=this._engine&&this._ready?{engine:this._engine,ready:this._ready,createHost:o&&s?()=>s(o):null,getScopeGridId:()=>r||(i?this._bindSheetScope(i):this._getActiveCell?.()?.scope??null),queuePendingAction:this._queuePendingAction??void 0,isEngineReady:this._isEngineReady??void 0,markWired:()=>this._markWired(),getRanges:this._getRanges,getRange:this._getRange,createGraphRanges:this._createGraphRanges,resolveSheetScope:this._resolveSheetScope??void 0,getNamedById:e=>this.getById(e)}:null,l=new HL(n,{...e,scope:i},()=>this._remove(l.getId()),c,o,e=>{let t=this._findSameIdentity(e,l.getScopeId());if(t&&t!==l)throw Error(N(`error.named.nameExists`,{name:e}))},this._transactions,this._isReadOnly,this._resolveSheetScope??void 0,()=>this._markContentsChanged(),()=>this._notifyNamesWritten(l,!1),t,()=>this._written.add(l),()=>this._getState()?.itemsById.has(l.getId())??!1);return this._updateState(e=>{let t=e.itemsById;return this._hydrating&&t===this._hydratingItems?t.set(l.getId(),l):(t=new Map(t).set(l.getId(),l),this._hydrating&&(this._hydratingItems=t)),{...e,itemsById:t}},N(`op.addNamedFormulaNamed`,{name:e.name})),this._notifyNamesWritten(l,!1),c&&!t&&l._wireNow(this._hydrating),l}_materializeMentioning(e){let t=this._getState();if(!t||!e)return;let n=e.toUpperCase(),r=[];for(let e of t.itemsById.values())e._isUnmaterialized()&&e.getExpression().toUpperCase().includes(n)&&r.push(e);this._materializeMany(r)}prepareRanges(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];r instanceof HL&&r._compilesForRanges()&&t.push(r)}this._materializeMany(t)}async removeUnused(e){await this._ready?.();let t=this._getState();if(!t)return 0;let n=[];for(let e of t.itemsById.values())e.isDeleted()||n.push(e);let r=new Set,i=[];for(let t=0;t<n.length;t++){let a=n[t];e.hiddenOnly&&!a.isHidden()||e.scope!==void 0&&a.getScope()!==e.scope||UL.test(a.getExpression())||WL.test(a.getName())||(a._isUnmaterialized()?r.add(a):i.push(a.getDirectDependents().then(e=>{e||r.add(a)})))}await Promise.all(i);let a=n.filter(e=>!r.has(e));for(;a.length>0&&r.size>0;){let e=new Set;for(let t=0;t<a.length;t++)a[t]._addSpelledNames(e);let t=[];for(let n of r)e.has(n.getName().toLowerCase())&&t.push(n);for(let e=0;e<t.length;e++)r.delete(t[e]);a=t}return e.dryRun||r.size===0||this._removeMany([...r]),r.size}_removeMany(e){let t=this._beginCommit(N(`op.removeUnusedNames`,{count:e.length}));try{for(let n=0;n<e.length;n++)e[n]._deleteWithin(t);this._updateState(t=>{let n=new Map(t.itemsById);for(let t=0;t<e.length;t++)n.delete(e[t].getId());return{...t,itemsById:n}}),this._notifyManyWritten(e,!0),t.commit()}catch(e){throw t.rollback(),e}}_materializeMany(e){let t=null;for(let n=0;n<e.length;n++)e[n]._isUnmaterialized()&&(t??=[]).push(e[n]);if(!t)return;let n=this._transactions,r=n.getCurrentTransaction()?null:n.beginCommit();try{let e=()=>{for(let e=0;e<t.length;e++)t[e]._materialize()},n=this._engine?.collectGrids;n?n.call(this._engine,e):e(),r?.amend()}catch(e){throw r?.rollback(),e}}_markWired(){this._markContentsChanged()}_markContentsChanged(){this.isClosed()||(this._wiringDirty=!0,this._wiringBatchDepth===0&&this._flushWired())}_beginWiringBatch(){this._wiringBatchDepth++}_endWiringBatch(){this._wiringBatchDepth>0&&this._wiringBatchDepth--,this._wiringBatchDepth===0&&this._flushWired()}_flushWired(){this._wiringDirty&&!this.isClosed()&&(this._wiringDirty=!1,this._notifyCollectionChange())}_getItems(e){let t=this._getState();if(!t)return i.EmptyArray;let n=Array.from(t.itemsById.values());if(!e)return n;let r=e.name?.toUpperCase(),a=`scope`in e;return n.filter(t=>(!r||t.getName().toUpperCase()===r)&&(!a||t.getScope()===e.scope))}getByName(e,t){if(!e)return null;let n=this._getState();if(!n)return null;let r=e.toUpperCase(),i=t?t.toUpperCase():null,a=null,o=null,s=this._itemsNamed(r,n);for(let e=0;e<s.length;e++){let t=s[e],n=t.getScope();if(n!==null){if(i!==null&&n.toUpperCase()===i)return t;o||=t}else a||=t}return i===null?a??o:a}getCount(){return this._getState()?.itemsById.size??0}addListeners(e,t){return super.addListeners(e,t)}getById(e){return e?this._getState()?.itemsById.get(e)??null:null}_findSameIdentity(e,t){let n=this._getState();if(!n)return null;let r=this._itemsNamed(e.toUpperCase(),n);for(let e=0;e<r.length;e++)if(r[e].getScopeId()===t)return r[e];return null}_itemsNamed(e,t){let n=this._transactions,r=n.getCurrentCommit(!1).getId(),a=n.getPendingTransaction(),o=this._nameIndex;if(!o||o.commitId!==r||o.transaction!==a||o.items!==t.itemsById){let e=new Map,n=new Map;for(let r of t.itemsById.values()){let t=r.getName().toUpperCase();n.set(r,t);let i=e.get(t);i?i.push(r):e.set(t,[r])}o=this._nameIndex={commitId:r,transaction:a,items:t.itemsById,byUpper:e,upperOf:n}}return o.byUpper.get(e)??i.EmptyArray}_indexItem(e,t){let n=this._nameIndex;if(!n)return;let r=this._getState();if(!r)return;let i=this._transactions;if(n.commitId!==i.getCurrentCommit(!1).getId()||n.transaction!==i.getPendingTransaction())return void(this._nameIndex=null);n.items=r.itemsById;let a=n.upperOf.get(e);if(a!==void 0){let t=n.byUpper.get(a);if(t){let r=t.indexOf(e);r!==-1&&t.splice(r,1),t.length===0&&n.byUpper.delete(a)}n.upperOf.delete(e)}if(t)return;let o=e.getName().toUpperCase();n.upperOf.set(e,o);let s=n.byUpper.get(o);s?s.push(e):n.byUpper.set(o,[e])}_bindSheetScope(e){return this._bindSheet?.(e)??null}_resolveScopeInput(e){if(!e)return null;try{return this._bindSheetScope(e)??e}catch{return e}}_resolveScopeName(e){return e?this._resolveSheetScope?.(e)??e:null}_remove(e){let t=this.getById(e);this._updateState(t=>{let n=new Map(t.itemsById);return n.delete(e),{...t,itemsById:n}},m(`op.removeNamedFormula`)),t&&this._notifyNamesWritten(t,!0)}_addNamesWrittenListener(e){return this._namesEmitter??=new ne(this),this._namesEmitter.addListeners(e)}_notifyNamesWritten(e,t){this._notifyManyWritten([e],t)}_notifyManyWritten(e,t){for(let n=0;n<e.length;n++)this._indexItem(e[n],t);if(!this._namesEmitter)return;let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=VL(e[r],t);this._namesEmitter.notify(`onNamesWritten`,{params:n})}_namesAsWritten(){let e=this._getState();if(!e)return i.EmptyArray;let t=[];for(let n of e.itemsById.values())t.push(VL(n,!1));return t}close(){this.isClosed()||(this._close(),this._transactionsRemoveListener?.())}_getState(){return this.isClosed()?null:this._transactions.getState(this._stateId)}_beginCommit(e){return this._transactions.beginCommit(typeof e==`string`?{description:e}:e)}_updateState(e,t=m(`op.update`),n){let r=this._beginCommit(t);try{r.updateState(this._stateId,e),r.commit(n)}catch(e){throw r.rollback(),e}}_initState(){let e=this._beginCommit(m(`op.initialize`));try{e.updateState(this._stateId,()=>({itemsById:new Map})),e.amend()}catch(t){throw e.rollback(),t}}get isINamedFormulasCollection(){return!0}},VL=(e,t)=>({id:e.getId(),name:e.getName(),scopeId:e.getScopeId(),removed:t}),HL=class extends EA{_getNamedState(){let e=this._stateId,t=e===null?void 0:this._transactions.getState(e);if(t)return t;let n=this._loaded;return n&&this._isListed&&!this._isListed()?this._loadedDeleted??={...n,isDeleted:!0}:n}_listenToState(e){let t=this;this._transactionsRemoveListener=this._transactions.addStateListener(e,{onAfterStateChange(e,n,r,i){r||i||t._recordSeen(t._block??null,e)},onRestoreOrRevert(){t._onRestoreOrRevert()}})}_isStateAbsent(){return this._stateId!==null&&this._transactions.getState(this._stateId)===void 0}_onRestoreOrRevert(){this._emitter?.notify(`onInvalidated`),this._notifyCollection?.();let e=this._block??null,t=this._getNamedState(),n=e!==this._seenBlock||t.isDeleted!==this._seenDeleted||t.expression!==this._seenExpression;this._recordSeen(e,t),n&&this._wire&&e&&(this._wire.engine.invalidateNamed(this._id),this._emitter?.notify(`onRangesChange`),this._wire.markWired?.())}_deleteWithin(e){this._host&&this._wire?.engine&&this._host.setPlaceholder(`#NAME?`),this._stateId!==null&&this._writeNamedState(e,{isDeleted:!0}),this._emitter?.notify(`onDelete`)}_addSpelledNames(e){let t=this.getExpression();if(!KL.test(t.trim()))for(let n of t.matchAll(GL))e.add(n[0].toLowerCase())}_writeNamedState(e,t){let n=this._stateId;n===null&&(n=this._stateId=this._transactions.create(),this._listenToState(n),this._noteWritten?.());let r=e.getState(n)!==void 0;e.updateState(n,r?t:{...this._loaded,...t})}get _block(){return this._host?.getBlock()}constructor(e,t,n,r,a,o,s,c,l,u,d,f=!1,p,m){let h=a??i.uuidV4(),g=()=>null;super(e,null,{getRanges:e=>r?.getRanges?.(e)??null,getRange:e=>r?.getRange?.(e)??null,getCalcGrid:()=>g()?._getCalcGrid()??null,resolveSheetScope:e=>r?.resolveSheetScope?.(e)??null,getOwnScope:()=>{let e=r?.getScopeGridId();return e?r?.resolveSheetScope?.(e)??null:null}}),this._loadedDeleted=null,this._emitter=null,this._transactionsRemoveListener=null,this._closed=!1,this._seenBlock=null,this._seenDeleted=!1,this._seenExpression=null,this._materializeQueued=!1,this._id=h,this._transactions=s??new se({transient:!0});let _={name:t.name,scope:t.scope??null,comment:t.comment??null,hidden:t.hidden??!1,fileAttributes:t.fileAttributes?{...t.fileAttributes}:null,isDeleted:!1,expression:JL(t.expression)};this._loaded=f?_:null,this._stateId=f?null:this._transactions.create(_),this._noteWritten=p??null,this._isListed=m??null,this._deleteFromCollection=n,this._checkRename=o??null,this._wire=r,this._lazy=f,this._host=!f&&r?.createHost?r.createHost():null,g=()=>this._host,this._isReadOnly=c??null,this._resolveSheetScope=l??null,this._notifyCollection=u??null,this._notifyNameWritten=d??null,this._stateId!==null&&this._listenToState(this._stateId)}_wireNow(e=!1){this._wire&&!this._closed&&this._doWireCore(e)}_isUnmaterialized(){return this._lazy&&!this._closed&&!this._host?._isLive()}_materialize(e=!0){if(this._closed||!this._wire||this.isDeleted())return;let t=this._host;if(t&&!t._isLive()&&(t=null),t?.hasBody())return;let n=this._transactions,r=n.getCurrentTransaction()?null:n.beginCommit();try{t||=this._host=this._wire.createHost?.()??null,t&&this._wireNow(e),r?.amend()}catch(e){throw r?.rollback(),e}}_materializeLater(){if(!this._isUnmaterialized()||this._materializeQueued)return;let e=this._wire?.queuePendingAction;e?(this._materializeQueued=!0,e(async()=>{this._materializeQueued=!1,this._materialize()})):this._materialize()}_parseAddressText(){let e=Xd(this._getNamedState().expression);if(e.length===0)return null;let t=[];for(let n=0;n<e.length;n++){let r=Yd(e[n]);if(!r||!r.scope)return null;t.push(r)}return t}_isLiteralText(){return KL.test(this._getNamedState().expression.trim())}_compilesForRanges(){return this._isUnmaterialized()&&!this._isLiteralText()&&this._parseAddressText()===null}_recordSeen(e,t){this._seenBlock=e,this._seenDeleted=t.isDeleted,this._seenExpression=t.expression}getId(){return this._id}getName(){return this._getNamedState().name}getScope(){let e=this._getNamedState().scope;return e?this._resolveSheetScope?.(e)??e:null}getScopeId(){return this._getNamedState().scope}getType(){return`formula`}getValue(){return this.getExpression()}setName(e,t){let n=this._getNamedState();return e&&e!==n.name&&(this._checkRename?.(e),this._updateNamedState({name:e},N(`op.updateNamed`,{name:e}),t),this._notifyNameWritten?.()),this}setExpression(e,t){if(!e)throw Error(`expression is required`);let n=JL(e);return n===this._getNamedState().expression||(this._updateNamedState({expression:n},N(`op.updateNamed`,{name:this.getName()}),t),this._host?._isLive()&&this._host.hasBody()?this._doWireCore():this._materialize(!1)),this}getComment(){return this._getNamedState().comment}getFileAttributes(){return this._getNamedState().fileAttributes}setComment(e,t){return this._updateNamedState({comment:e},m(`op.setComment`),t)}isHidden(){return this._getNamedState().hidden}setHidden(e=!1,t){return this._updateNamedState({hidden:e},m(`op.setHidden`),t)}_updateNamedState(e,t,n){if(this._closed)throw Error(N(`error.model.modelClosed`));if(this.isReadOnly())throw Error(N(`error.named.nameReadonly`));let r=this._transactions.beginCommit({description:t,...n});try{this._writeNamedState(r,e),this._emitter?.notify(`onAnyChange`),r.commit()}catch(e){throw r.rollback(),e}return this._notifyCollection?.(),this}async select(e){return await this.getRanges()?.select(e),this}toJSON(){let e=this._getNamedState(),t={name:e.name,ref:this.getExpression()},n=this.getScope();return n&&(t.scope=n),e.comment&&(t.comment=e.comment),e.hidden&&(t.hidden=!0),e.fileAttributes&&(t.fileAttributes={...e.fileAttributes}),t}isReadOnly(){return this._isReadOnly?.()??!1}isDeleted(){return this._getNamedState()?.isDeleted??!1}addListeners(e,t){return this._emitter??=new ne(this,this._transactions),this._emitter.addListeners(e,t)}getVersionId(){return this._stateId===null?0:this._transactions.getVersionId(this._stateId)}beginCommit(e){return this._transactions.beginCommit(typeof e==`string`?{description:e}:e)}doBatch(e,t){return this._transactions.doBatch(e,typeof t==`string`?{description:t}:t)}isClosed(){return this._closed}close(){this._closed||(this._emitter?.notify(`onClose`),this._closed=!0,this._transactionsRemoveListener?.())}get isIModel(){return!0}get isINamed(){return!0}getRanges(){if(this._isUnmaterialized()){if(this._isLiteralText())return null;let e=this._parseAddressText();if(e)try{let t=this._wire?.getRanges?.(e)??null;if(t)return t}catch{}}return this._materialize(),this._block?.isReferenceOnly()?this.getReferences():null}getReferences(){return this._materialize(),super.getReferences()}getDirectDependents(){return this._graphRanges(`dependents`,!0)}getDependents(){return this._graphRanges(`dependents`,!1)}_asNodeInfo(){let e=this._coords,t=e?.scope,n=(t?this._wire?.resolveSheetScope?.(t):null)??this.getScope()??null;return{id:this._id,name:this.getName(),sheetName:n,rowIndex:e?.rowIndex??0,colIndex:e?.colIndex??0}}getDirectPrecedents(){return this._graphRanges(`precedents`,!0)}getPrecedents(){return this._graphRanges(`precedents`,!1)}async _graphRanges(e,t){let n=this._wire;if(!n||e===`precedents`&&(this._isUnmaterialized()&&this._isLiteralText()||(this._materialize(),!this._host?._getCalcGrid())))return null;let{cells:r,names:i}=await n.engine.getNameGraph(this._id,e,t),a=n.resolveSheetScope,o=[];for(let e=0;e<r.length;e++){let t=r[e],n=t.scope?a?.(t.scope):null;n&&o.push({...t,scope:n})}if(o.length===0&&i.length===0)return null;let s=o.length>0?Sc(o):[];return i.length===0?n.getRanges?.(s)??null:n.createGraphRanges?.(s,i)??(s.length>0?n.getRanges?.(s)??null:null)}delete(e){if(this._getNamedState()?.isDeleted)return;if(this.isReadOnly())throw Error(N(`error.named.nameReadonly`));let t=this._wire?.engine,n=this._transactions.beginCommit({description:N(`op.deleteNamedItem`,{name:this.getName()}),...e});try{this._host&&t&&this._host?.setPlaceholder(`#NAME?`),this._writeNamedState(n,{isDeleted:!0}),this._deleteFromCollection(),this._emitter?.notify(`onDelete`),n.commit()}catch(e){throw n.rollback(),e}t?.recompileNamed(this._id)}async evaluate(e){this._materialize(),this._wire&&!this._block&&await this._wire.ready();let t=this._wire,n=this._block;if(!t||!n)throw Error(`Named formula '${this.getName()}' cannot be evaluated: calculation engine not available.`);let r=typeof e==`number`?e:e?.evalIndex;return this._host._evaluateScalarAt(0,0,r)}getCalculationStatus(){return this._block?Q.ResultStatus.Ready:Q.ResultStatus.Stale}getExpression(e){let t=this._block;if(!t)return this._host?.getBody()?.text??this._getNamedState().expression;let n=e?.cell?.rowIndex??0,r=e?.cell?.colIndex??0,i=e?.r1c1??!1,a=e?.evalIndex;return t.getTextAt(n,r,i,a,e?.target)}_getBodyNode(){return this._wire?.engine.getBodyNode(this._id)??null}getTokens(e){return this._block?super.getTokens(e):i.EmptyArray}isReferenceOnly(){return this._isUnmaterialized()?this._parseAddressText()!==null:this._block?.isReferenceOnly()??!1}_referencesAt(){return this._block?.getReferencesAt(0,0)??null}async setReferenceAt(e,t,n){throw Error(`setReferenceAt is not supported on a named formula.`)}async setReferenceModeAt(e,t,n,r){throw Error(`setReferenceModeAt is not supported on a named formula.`)}async _doWireCore(e=!1){let{getScopeGridId:t}=this._wire,n=t();if(!n)return;let r=this._coords?.rowIndex??0,i=this._coords?.colIndex??0,a=this._host?.setBody({coords:zL,expression:this._getNamedState().expression,authoredAt:{rowIndex:r,colIndex:i},scopeGridId:n,recompile:!e||`load`,priority:!0},()=>this._bodyAnswered());a&&await a.then(()=>{},()=>{})}_bodyAnswered(){!this._closed&&this._wire&&(this._recordSeen(this._block??null,this._getNamedState()),this._emitter?.notify(`onRangesChange`),this._wire.markWired?.())}toString(){return`${this.getName()} => ${this._block?this._block.getTextAt(0,0,!1):this._getNamedState().expression}`}get[Symbol.toStringTag](){return`[NamedFormula]`}},UL=/LAMBDA\s*\(/i,WL=/^_xlnm\./i,GL=/[A-Za-z_\\][\w.\\?]*/g,KL=RegExp(`^(?:[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?%?|"(?:[^"]|"")*"|TRUE|FALSE|#(?:REF!|N/A|NAME\\?|DIV/0!|VALUE!|NULL!|NUM!|PARSE!|FIELD!|GETTING_DATA|SPILL!|CONNECT!|BLOCKED!|UNKNOWN!|CALC!|BUSY!|PYTHON!|TIMEOUT!)|\\{[^{}]*\\})$`,`i`);function qL(e){return e?e.toUpperCase():``}function JL(e){return e.startsWith(`=`)?e.substring(1):e}var YL=class extends vb{isLambda(){return!0}},XL=new WeakMap,ZL=e=>{let t;try{t=e._getBodyNode?.()??null}catch{return null}if(t?.type!==`function`||String(t.value).toUpperCase()!==`LAMBDA`)return null;let n=t.inputs??[],r=[];for(let e=0;e<n.length-1;e++){let t=n[e]?.value;if(n[e]?.type!==`named`||!t?.name)return null;r.push(t.optional?{name:t.name,optional:!0}:{name:t.name})}let i=e.getName(),a=e.getComment()||e.getValue()||void 0,o=JSON.stringify([i,a,r]),s=XL.get(e);if(s?.key===o)return s.fn;let c=new YL({name:i,parameters:r},()=>V.BuiltIn.Calc,()=>null,{summary:a,category:`Lambda`});return XL.set(e,{key:o,fn:c}),c},QL=t(`sdk:calc-engine`,()=>e(()=>import(`./37LAUhU1_yKtsBlH.js`),__vite__mapDeps([30,2,1,21,11,3,12,7,9,10,28,14]),import.meta.url)),$L=3e4,eR=class extends oe{constructor(e){super({...e??{},transactions:void 0}),this._backend=null,this._startReplica=null,this._status=Q.Status.Off,this._statusTransition=null,this._pendingNames=null,this._compilerEditingStorage=null,this._engineModule=null,this._planCache=null,this._startFunctions=null,this._formulaHosts=new Map,this._modelStore=null,this._fronts=new Map,this._gridSpecs=new Map,this._modelStoreRemoveListener=null,this._mirrorRemoveListener=null,this._modelMirrorId=null,this._landedCommits=null,this._outstanding=null,this._pendingActions=null,this._pendingPriority=null,this._draining=!1,this._drainDepth=0,this._drainScheduled=!1,this._calcOwed=!1,this._calcOwedBy=null,this._channel=null,this._bootPending=null,this._passesInFlight=0,this._calculationState=Q.CalculationState.Done,this._calculationStatePosted=!1,this._calculationStateWaiters=null,this._bootFull=!1,this._bootFullForLoad=!1,this._bootEdited=!1,this._passForLoad=!1,this._consumerWork=0,this._bootExplicit=!1,this._compilerWaiters=null,this._wroteWhileOff=!1,this._calcMode=Q.CalculationMode.Automatic,this._iterate=!1,this._maxIteration=100,this._maxIterateChange=.001,this._calcJSON=null,this._removeNamedItemsListeners=null,this._tableListenerRemovers=[],this._resolvers=null,this._tableSymbols=null,this._nameSymbols=null,this._openSymbolMessages=null,this._symbolsTold=null,this._rollbackHooked=null,this._modelStore=e?.transactions??null,this._initialize(e)}_initialize(e){this._runtime=e?.runtime??new Qa(`Calculation Runtime`,{getNow:()=>this._backend?.getCommitTimestamp()??this._modelStore?.getCurrentCommit().getTimestamp()??Date.now()}),this._getActiveCell=e?.getActiveCell??(()=>null),this._startFunctions=e?.startFunctions??null,this._getRange=e?.getRange??(()=>null),this._getRanges=e?.getRanges??(()=>null);let t=e,n=t?.namedCollection??null,r=e=>e?.getType()===`table`?e:null,a=e=>{if(!e)return null;let t=this._replicaTables();if(t){let i=t.idByName.get(e.toLowerCase());return i===void 0?null:r(n?.getById(i))}return r(n?.getByName(e,!0))},o=e=>this._replicaTables()?.of.get(e.getId())?.[0]??e.getName(),s=(e,t)=>{let n=this._replicaTables()?.of.get(e.getId())?.[1];if(!n)return null;for(let e=0;e<n.length;e++)if(t(n[e]))return n[e];return null},c=new aj(a,e=>r(n?.getById(e)),o);this._tableSymbols=c;let l=new Map,u={bind:(e,t)=>{let r=t?.at;if(e||!r)return c.bind(e,t);let i=(e=>{if(!e.scope||!n)return null;let t=e.scope,r=t.toLowerCase(),i=n.getItems({type:`table`});for(let n=0;n<i.length;n++){let a=i[n].getValue(),o=a?.getWorksheet();if(!o||o.getId()!==t&&o.getName()?.toLowerCase()!==r)continue;let s=a.getRange().getCoords();if(e.rowIndex>=s.rowStart&&e.rowIndex<=s.rowEnd&&e.colIndex>=s.colStart&&e.colIndex<=s.colEnd)return i[n]}return null})(r);return i?c.bind(o(i)):null},resolve:(e,t)=>c.resolve(e,t)},d=new oj((e,t)=>{try{e=e.toLowerCase();let n=(t?c.getRealById(t):null)??a(t);if(!n)return null;let r=this._replicaTables()?.of.has(n.getId())?s(n,t=>t[1].toLowerCase()===e)?.[0]:n.getValue().getColumnByName(e)?.getId();return r==null?null:`_`+(c.bind(o(n))??``)+`:`+r}catch{return null}},e=>{if(!e.startsWith(`_`))return null;let t=(e=e.substring(1)).split(`:`),n=t[0],r=t[1],i=c.getRealById(n);if(!i)return null;let a=i.getValue().getColumnById(r);return a?{stableId:e,toString:()=>s(i,e=>e[0]===r)?.[1]??a.getName()??`(untitled)`}:null}),f=new RL({json:t?.externalBooks,resolver:t?.externalBookResolver,transactions:t?.transactions,getDependents:e=>w._backend?.getSymbolDependents(e)??i.EmptyArray,getSheetRange:e=>{let t=e.scope?w._heldSheetAt(e.scope)?.[1]:null;if(!t)return null;let{rowStart:n,colStart:r,rowEnd:i,colEnd:a}=e;return w._getRange({rowStart:n,colStart:r,rowEnd:i,colEnd:a,scope:t})}});this._externalBooks=f;let p=()=>f,m={addBook:e=>f.add(function(e){return{sources:[LA(e.dir+e.book)],sheetNames:e.sheetName===null?[]:[e.sheetName]}}(e)).getId(),addSheet:(e,t)=>f._addSheetName(e,t)},h=()=>{let e=new Set,t=f.toJSON()?.length??0;for(let n=1;n<=t;n++)e.add(f._getIdByIndex(n));return e},g=h();f.addListeners({onCollectionChange:()=>{if(w.isClosed())return;let e=h(),t=new Set;for(let n of e)g.has(n)||t.add(n);for(let n of g)e.has(n)||t.add(n);g=e,w._whenSafe(async()=>{if(!w.isClosed()){for(let e of w._backend?.syncExternalBooks()??i.EmptyArray)t.add(e);w._backend.markDirtyReferencing(t)}})}},{transactional:!1});let _={bind:(e,t,n)=>KA(p(),e,t?m:null,n),resolve:(e,t)=>function(e,t,n){let r=e?HA(t):null;if(!r)return null;let i=e._getIndexById(r.bookId);if(i===-1)return YA(t);let a=e.getById(r.bookId),o=a?.getSheetNames(),s=null;if(r.sheetIndex>=0){let e=o?.[r.sheetIndex],n=o?.[r.sheetEnd];if(e===void 0||n===void 0)return YA(t);s=r.sheetEnd===r.sheetIndex?e:e+`:`+n}return{stableId:t,toString:()=>n&&a?a.getDisplayName(s):`[`+i+`]`+(s??``),getName:()=>s,getEntireCoords:()=>null}}(p(),e,t)},v=new XA(e=>w._sheetIdByName(e),e=>{let t=w._backend,n=t?.getSheets();if(n?.has(e)){let r=n.get(e)??null,i=t.getGrids().get(e);return{stableId:e,toString:()=>r??e,getName:()=>r,getEntireCoords:()=>i?.getEntireCoords()??null}}if(VA(e))return null;let r=t?.getGrids().get(e);return r?{stableId:e,toString:()=>V.BuiltIn.Ref.toString(),getEntireCoords:()=>r.getEntireCoords()}:null},_,e=>w._sheetIds().indexOf(e)),y=new jA;this._symbols=y,y.registerProvider(AA.Sheet,v),y.registerProvider(AA.Table,u),y.registerProvider(AA.TableColumn,d);let b=new XA(e=>{let t=w._heldSheets(),n=e.toLowerCase();for(let e=0;e<t.length;e++)if(t[e][1]?.toLowerCase()===n)return t[e][0];return null},e=>{let t=w._heldSheetAt(e);if(t){let n=t[1];return{stableId:e,toString:()=>n??e,getName:()=>n,getEntireCoords:()=>w._fronts.get(e)?.getEntireCoords()??null}}if(VA(e))return null;let n=w._fronts.get(e);return n?{stableId:e,toString:()=>V.BuiltIn.Ref.toString(),getEntireCoords:()=>n.getEntireCoords()}:null},_,e=>w._heldSheets().findIndex(t=>t[0]===e)),x=new Map([[AA.Sheet,b],[AA.Table,{bind:(e,t)=>u.bind(e,t),resolve:(e,t)=>{let n=c.resolve(e,t);return n?{stableId:n.stableId,toString:()=>c.getRealById(e)?.getName()??n.toString()}:null}}],[AA.TableColumn,{bind:(e,t)=>d.bind(e,t),resolve:(e,t)=>{let n=d.resolve(e,t);if(!n)return null;let r=(e.startsWith(`_`)?e.substring(1):e).split(`:`),i=c.getRealById(r[0])?.getValue().getColumnById(r[1])??null;return{stableId:n.stableId,toString:()=>i?.getName()??n.toString()}}}]]);this._modelSymbolRegistry=new MA(y,x);let S=null;this._resolvers={getStructureReferenceCoords:(e,t,n,r)=>{if(!e)return V.BuiltIn.Ref;let i=e.tableId;if(!i)return V.BuiltIn.Ref;let a=c.getRealById(i);if(!a)return V.BuiltIn.Ref;let o=a.getValue();return!o||o.isDeleted()?V.BuiltIn.Ref:HI(e,t,o)},getNamedFormulaBlock:e=>w._backend?.getGrid(e)?.getFormulaBlockAt(0,0)??null},this._emitter=new ne(this);{let e=this._modelStore??new se({transient:!0});this._ownerStore=e;let t={sheets:i.EmptyArray};this._sheetListId=e.amend(e.getCurrentCommit(!1).getId(),()=>e.create(t))}let C=this._modelStore,w=this;if(C){let e=C.amend(C.getCurrentCommit(!1).getId(),()=>C.create({mirror:!0}));this._modelMirrorId=e,this._mirrorRemoveListener=C.addStateListener(e,{onRestoreOrRevert(e,t){if(w._followRestore(t.getId()),w._channel){let e=w._modelHistory();w._markHeld(t=>t.commitId!==void 0&&w._hasLanded(t.commitId)&&!e.has(t.commitId))}}}),this._modelStoreRemoveListener=C.addListener({onCommitClose(e,t,n,r){if(t){let t=e.getId();w._markHeld(e=>e.dead||e.commitId===t),w._backend?.restoreTo(C.getCurrentCommit(!1).getId()),w._backend?.dropLanding(`${t}:0`)}else n||r?w._backend?.foldPhantom(e.getId()):w._backend?.mirror(e.getId())}})}let T=e?.json;this._calcJSON=T?{...T}:null,this._calcMode=T?.calcMode??Q.CalculationMode.Automatic,this._iterate=T?.iterate??e?.enableIterativeCalculations??!1,this._maxIteration=T?.maxIteration??T?.maxIterations??e?.maxIteration??100,this._maxIterateChange=T?.maxIterateChange??e?.maxIterateChange??.001,this._removeNamedItemsListeners=n?.addListeners({onCollectionChange:()=>{if(w.isClosed())return;let e=c.reconcile(),t=n.getItems();w._tableListenerRemovers.forEach(e=>e());let r=[];for(let e of t)if(e.getType()===`table`){let t=e.getValue(),n=()=>{if(t.isDeleted())return``;let e=t.getRange().getCoords();return`${t.getWorksheet()?.getId()}!${e.rowStart},${e.colStart}:${e.rowEnd},${e.colEnd}|${t.isShowHeaders()}|${t.isShowTotals()}`},i=t.getId();l.has(i)||l.set(i,n());let a=()=>{if(w.isClosed())return;let t=n();if(t===l.get(i)||(l.set(i,t),!t))return;let r=c.bind(o(e),{existing:!0});r&&w._whenSafe(async()=>{w.isClosed()||w._backend.recompileReferencing(new Set([r]))})};r.push(t.addListeners({onAnchorCoordsChange:a,onInvalidated:a},{transactional:!1}))}w._tableListenerRemovers=r,e.length>0&&w._whenSafe(async()=>{w.isClosed()||w._backend.markDirtyReferencing(new Set(e))})}},{transactional:!1})??null;let E=new BL({engine:{invalidateNamed:e=>this._invalidateNamed(e),recompileNamed:e=>this._recompileNamed(e),getBodyNode:e=>this._backend?.getGrid(e)?.getFormulaBlockAt(0,0)?.getNode()??null,getNameGraph:async(e,t,n)=>Tj(await this._sendRequest(``,void 0,{type:`nameGraph`,nameId:e,kind:t,direct:n}))??{cells:[],names:[]},collectGrids:e=>this._backend?this._backend._collectingGrids(e):e()},ready:()=>this.ready(),getActiveCell:()=>this._getActiveCell(),getRange:e=>this._getRange(e),getRanges:e=>this._getRanges(e),createGraphRanges:this._options?.createGraphRanges,resolveSheetScope:e=>this._heldSheetAt(e)?.[1]??this._sheetName(e),bindSheet:e=>this._modelSymbolRegistry.bind(AA.Sheet,e),createHost:e=>this._createFormulaHost({id:e,entireCoords:fB(),unanchored:!0}),getOrBindProxyFakeId:(e,t)=>S?.bind(e,{scope:t,own:!0})??null,queuePendingAction:e=>this._whenSafe(e,!0),isEngineReady:()=>this._status===Q.Status.Running&&!this._draining,transactions:t?.transactions,isReadOnly:()=>this.isReadOnly()||(this._options?.isNamesReadOnly?.()??!1)});this._namedFormulas=E,S=new aj((e,t)=>{if(VA(t))return w._backend?.getExternalNameByScope(e,t)??null;let n=w._replicaNameId(e,t);return n===void 0?E.getByName(e,t):E.getById(n)},e=>E.getById(e)??w._backend?.getExternalName(e)??null,e=>w._replicaNames()?.of.get(e.getId())?.[0]??e.getName()),this._nameSymbols=S;let D=S,O=(e,t)=>{let n=D.bind(e,t);return n!==null&&!0!==t?.own&&!0!==t?.existing&&E.getById(n)?._materializeLater(),n};y.registerProvider(AA.NamedFormula,{bind:O,resolve:(e,t)=>D.resolve(e,t)}),x.set(AA.NamedFormula,{bind:O,resolve:(e,t)=>{let n=D.resolve(e,t);return n?{stableId:n.stableId,toString:()=>D.getRealById(e)?.getName()??n.toString()}:null}}),E._addNamesWrittenListener({onNamesWritten:(e,t)=>{w._nameWritten(t)}}),this._pendingNames=t?.names??null,E.setPendingJSON(this._pendingNames)}_attachEngine(e){if(this._engineModule)return;this._engineModule=e;let t=this._options,n=this._startReplica;this._startReplica=null,this._backend=new e.CalcBackend({callbacks:this._backendCallbacks(),runtime:this._runtime,symbols:this._symbols,resolvers:this._resolvers,functions:t?.functions,getSheetIndex:t?.getSheetIndex,legacyIntersect:!0===this._calcJSON?.legacyIntersect,gridOptions:t,calculation:this,books:this._externalBooks,richData:{get resources(){return t?.resources??null},get strings(){return t?.strings??null}},fetch:t?.fetch,parseText:t?.parseText,replica:n??void 0,modelCommitId:this._modelStore?.getCurrentCommit(!1).getId()??null,planCacheMode:this._planCache}),this._backend.syncExternalBooks(!0)}_backendCallbacks(){let e=this._nameSymbols;return{getCompiler:e=>this._compiler?e?this._getEditingCompiler(e):this._compiler:null,getModelLanding:()=>this._modelLanding(),sendRequest:(e,t,n)=>this._sendRequest(e,t,n),getImager:e=>this._imagerFor(e),onCalculated:(e,t)=>{this._fronts.get(e)?._onCalculated(t)},onRestored:()=>{this._emitter.notify(`onInvalidated`),this._formulaHosts.forEach(e=>{e._resync()})},onDirty:()=>this._noteCalculationState(),onPendingChange:()=>{this._emitter.notify(`onPendingChange`)},onSymbolsChanged:e=>this._markDirtyReconciled(e===`tables`?this._tableSymbols:this._nameSymbols),whenSafe:(e,t)=>this._whenSafe(e,t),isLoading:()=>this._draining||this._status===Q.Status.Starting,calculate:(e,t,n)=>this._calculate(e,t,n),owePass:e=>this._owePass(e),isDefinedName:e=>!!this._namedFormulas.getById(e),getNameNodeInfo:e=>this._namedFormulas.getById(e)?._asNodeInfo()??null,getTable:e=>{let t=this._tableSymbols?.getRealById(e)?.getValue();return t&&!t.isDeleted()?t:null},rewriteHost:(e,t,n)=>{let r=this._formulaHosts.get(e);return!!r&&(r._rewrite(t,n),!0)},createHost:e=>this._createFormulaHost({id:e,entireCoords:fB(),unanchored:!0}),bindNameId:(t,n)=>e.bind(t,{scope:n,own:!0})}}_recompileNamed(e){this._whenSafe(async()=>{this._backend.recompileReferencing(new Set([e]))})}_invalidateNamed(e){this._whenSafe(async()=>{this._backend.markDirtyReferencing(new Set([e]))})}_releaseTableReferences(e,t){let n=this._tableSymbols?.bind(e.getName(),{existing:!0});if(!n)return;let r=t===`address`?function(e){let t=e=>({getCoords:()=>e}),n=e.getRange().getCoords(),r=t(e.getDataRange().getCoords()),i=e.isShowHeaders(),a=e.isShowTotals(),o=i?t(e.getHeaderRowRange().getCoords()):r,s=a?t(e.getTotalRowRange().getCoords()):r,c=new Map,l=n.colEnd-n.colStart+1;for(let t=0;t<l;t++){let n=e.getColumnAt(t);n&&c.set(String(n.getId()),n.getIndex())}let u=e.getWorksheet().getId();return{getRange:()=>t(n),getDataRange:()=>r,getHeaderRowRange:()=>o,getTotalRowRange:()=>s,isShowHeaders:()=>i,isShowTotals:()=>a,getColumnById:e=>{let t=c.get(e);return t===void 0?null:{getIndex:()=>t}},getWorksheet:()=>({getId:()=>u})}}(e):null;this._whenSafe(async()=>{this.isClosed()||this._backend.rewriteTableReferences(n,r)})}_refitTableRows(e,t,n,r,i,a,o){let s=()=>{this.isClosed()||this._backend.refitTableRows(e,t,n,r,i)};a||this._status!==Q.Status.Running||s(),this._whenSafe(async()=>{o()&&s()})}_replaceSheetSpans(e,t,n){let r=this._backend;r&&r.landRequest(void 0,()=>{for(let i=0;i<t.length;i++){let a=r.getGrid(t[i]);if(a)return void a._replaceSheetSpans(e,t,n)}})}_stats(){return this._backend.getDemandStats()}_resetStats(){this._backend.resetStats()}_planCacheMode(e){return e&&(this._planCache=e,this._backend?.setPlanCacheMode(e)),this._backend?.getPlanCacheMode()??this._planCache??`on`}start(){return this._statusTransition||(this._statusTransition=(async()=>{if(this._status===Q.Status.Off||this._status===Q.Status.Error)try{this._status=Q.Status.Starting,this._emitter.notify(`onStatusChange`),this._emitter.notify(`onStarting`);let t=this._heldSheets(),n={sheets:tR(t),gridless:nR(t),tables:t.length>0?this._liveTables():new Map,names:this._liveNames()};this._backend?this._backend.setReplica(n):this._startReplica=n,this._openEngineGrids(!0);let r=e(()=>import(`./B2PWru6Ty7ODc2Ie.js`),__vite__mapDeps([31,1,2,7,10,11,3,12,13]),import.meta.url),a=__.load();r.catch(()=>{}),a.catch(()=>{});let o=Ol.load();o.catch(()=>{});let s=this._startFunctions?this._startFunctions().catch(e=>(O.error(e instanceof Error?e:String(e)),i.EmptyArray)):Promise.resolve(i.EmptyArray);this._attachEngine(await QL.load());let[c,l,,u]=await Promise.all([this._backend.initialize(),r,a,s,o]);if(this._closed)return void(this._status=Q.Status.Off);let d=c.functions;this._functions=d;let f=this._namedFormulas;d._setNamedSource({getByName:(e,t)=>{let n=f.getByName(e,t??null);return n?ZL(n):null},getItems:()=>{let e=new Map,t=f.getItems();for(let n of[!0,!1])for(let r of t){if(r.getScope()===null!==n)continue;let t=r.getName().toUpperCase();if(e.has(t))continue;let i=ZL(r);i&&e.set(t,i)}return Array.from(e.values())}}),this._symbols.registerProvider(AA.Function,new uj(()=>d)),this._compilerModule=l,this._compiler=new l.FormulaCompiler;for(let e of u)try{await d.add(e)}catch(e){O.error(e instanceof Error?e:String(e))}this.hydrateNames(),await this._boot()}catch(e){throw this._status=Q.Status.Error,this._abandonStart(),this._dropEngine(),this._emitter.notify(`onError`,e),this._emitter.notify(`onStatusChange`),e}finally{this._statusTransition=null,this._noteCalculationState()}})(),this._statusTransition.catch(()=>{})),this._statusTransition}_whenSafe(e,t=!1){if(t){let t=this._pendingPriority;t||(this._pendingPriority=t=[]),t.push(e)}else{let t=this._pendingActions;t||(this._pendingActions=t=[]),t.push(e)}this._scheduleDrain()}_sendRequest(e,t,n){t!==void 0&&this._hookRollback(t),dR.has(n.type)&&(this._bootEdited=!0),n.type===`shift`&&this._materializeNamesMentioning(e);let r=t=>Ej(t,this._imagerFor(e)),i;if(Mj.getMode()===`off`)i=this._sendRequestNow(e,t,n).then(r);else{let a=Mj.request(n,n.type);i=this._sendRequestNow(e,t,a).then(e=>r(Mj.results(e,`response`)))}let a=this._outstanding??=new Set;a.add(i),this._noteCalculationState();let o=()=>{a.delete(i),this._noteCalculationState()};return i.then(o,o),i}_sendRequestNow(e,t,n){let r=this._status;if(n.type===`requestPass`)return this._owePass(e),Promise.resolve({cycleId:this._cycleId});if(n.type===`revert`&&r!==Q.Status.Running)return Promise.resolve({cycleId:this._cycleId,commitId:Dj(n)});if(n.type===`close`&&r!==Q.Status.Running&&r!==Q.Status.Starting)return this._backend?.getGrid(e)?._detach(),Promise.resolve({cycleId:this._cycleId});if(r===Q.Status.Running)try{return Promise.resolve(this._backend.apply(e,t,n))}catch(e){return Promise.reject(e)}if(r===Q.Status.Starting){if(n.type===`rollback`){let e=n.savepointId;this._markHeld(t=>t.dead||t.landingId===e)}return new Promise((r,i)=>{(this._channel??=[]).push({gridId:e,request:n,landingId:t,commitId:Dj(n),dead:!1,resolve:r,reject:i})})}return aR.has(n.type)||(this._wroteWhileOff=!0),Promise.resolve({cycleId:this._cycleId,commitId:Dj(n)})}_markHeld(e){let t=this._channel;if(t)for(let n=0;n<t.length;n++)t[n].dead=e(t[n])}_abandonStart(){let e=this._channel;if(this._channel=null,this._openSymbolMessages=null,this._symbolsTold=null,this._landedCommits=null,e)for(let t=0;t<e.length;t++)e[t].resolve({cycleId:this._cycleId,commitId:e[t].commitId});this._releaseCompilerWaiters()}_releaseCompilerWaiters(){let e=this._compilerWaiters;if(this._compilerWaiters=null,e)for(let t=0;t<e.length;t++)e[t]()}_underOneModelOperation(e){let t=this._modelStore;if(!t)return e();let n=t.beginCommit();try{let t=e();return n.amend(),t}catch(e){throw n.rollback(),e}}_whenCanCompile(){return this._status===Q.Status.Running?Promise.resolve():new Promise(e=>{(this._compilerWaiters??=[]).push(e)})}async _boot(){this._drainDepth++,this._draining=!0;try{let e=this._backend;if(e.open(),this._pendingPriority?.length&&await this._drainPending(!0),this._closed)return;let t=this._wroteWhileOff;for(this._wroteWhileOff=!1,t&&(this._bootEdited=!0);this._channel;){let n=this._channel;this._channel=null,this._openSymbolMessages=null;let r=this._underOneModelOperation(()=>e.applyHeld(n,t));for(let e=0;e<r.length;e++){let t=r[e];t.failed?n[t.index].reject(t.error):n[t.index].resolve(t.response)}}this._landedCommits=null,e.forgetEarlierLandings(),this._status=Q.Status.Running,this._emitter.notify(`onStatusChange`),this._emitter.notify(`onReady`),this._releaseCompilerWaiters(),(this._pendingPriority?.length||this._pendingActions?.length)&&await this._drainPending()}finally{this._drainDepth--,this._draining=this._drainDepth>0}this._closed||await this._scheduleBoot()}_scheduleBoot(){return this._bootPending??=new Promise(e=>{setTimeout(()=>{this._runBoot().catch(e=>{this.isClosed()||this._emitter.notify(`onError`,e)}).finally(e)},0)})}async _runBoot(){this._bootPending=null;let e=this._bootFull,t=this._bootExplicit,n=!this._bootEdited&&(e?this._bootFullForLoad:!t);if(this._bootFull=!1,this._bootExplicit=!1,this._bootFullForLoad=!1,this._bootEdited=!1,!this.isClosed()&&this._status===Q.Status.Running){this._passForLoad=n;try{if(e||t)return this._calcOwed=!1,this._calcOwedBy=null,void await this._calculate(e?fR:void 0);await this._drainStandalone()}finally{this._passForLoad=!1}}}_calculateForLoad(){return this._bootFullForLoad=!0,this.calculate(fR)}_scheduleDrain(){this._drainScheduled||this._draining||this._status===Q.Status.Running&&(this._bootPending||(this._drainScheduled=!0,this._noteCalculationState(),queueMicrotask(()=>{this._drainScheduled=!1,this._noteCalculationState(),this.isClosed()||this._status!==Q.Status.Running||(this._pendingActions?.length||this._pendingPriority?.length||this._calcOwed)&&this._drainStandalone().catch(e=>{this.isClosed()||this._emitter.notify(`onError`,e)})})))}async _drainStandalone(){await this._drainPending();let e=this._calcOwedBy;this._calcOwed=!1,this._calcOwedBy=null,this.isClosed()||this._status!==Q.Status.Running||this._backend.hasDirty()&&(e||this._calcMode!==Q.CalculationMode.Manual?await this._calculate(void 0,e??void 0):this._emitter.notify(`onStale`))}_owePass(e){this._calcOwed=!0,this._calcOwedBy??=e,this._scheduleDrain(),this._noteCalculationState()}async _drainPending(e=!1){this._drainDepth++,this._draining=!0;let t=this._namedFormulas;t?._beginWiringBatch();try{for(;this._pendingPriority?.length||!e&&this._pendingActions?.length;){let e=this._pendingPriority;if(e?.length){this._pendingPriority=null;for(let t of e)await t();continue}let t=this._pendingActions;this._pendingActions=null;for(let e of t)await e()}this._pendingPriority=null,e||(this._pendingActions=null)}finally{this._drainDepth--,this._draining=this._drainDepth>0,t?._endWiringBatch(),this._noteCalculationState()}this._drainDepth===0&&this._calcOwed&&this._scheduleDrain()}getPendingCount(){return this._backend?.getDeferred().getOpenCount()??0}async whenPendingDone(e){let t=Date.now()+(e?.timeout??$L);for(;;){await this.ready();let e=this._backend?.getDeferred();if(!e||e.getOpenCount()===0&&!e.hasSettleWork())return!0;let n=t-Date.now();if(n<=0)return!1;await e.whenChanged(n)}}async cancelAsync(e){let t=this._backend;if(!t||this.getStatus()!==Q.Status.Running)return this.getStatus();let n=!0;if(e?.range){let t=this._getRange(e.range),r=t?this._sheetIdByName(t.getWorksheet().getName()):null;if(!r)return this.getStatus();let{rowStart:i,colStart:a,rowEnd:o,colEnd:s}=t.getCoords();n={rowStart:i,colStart:a,rowEnd:o,colEnd:s,scope:r}}else if(e?.scope){let t=this._sheetIdByName(e.scope);if(!t)return this.getStatus();n=t}return await t.cancelAsync(n)??this.getStatus()}async calculate(e){let t;return!0===e?t=fR:e&&(t=e),!t?.external||t.range||t.scope||this._externalBooks.refreshAll().catch(e=>console.warn(`Refreshing the external books failed`,e)),this._calculate(t)}async _calculate(e,t,n){return this._calculateNow(e,t,n)}async _calculateNow(e,t,n){this._passesInFlight++,this._noteCalculationState();try{return await this._runCalculation(e,t,n)}finally{this._passesInFlight--,this._noteCalculationState()}}async _runCalculation(e,t,n){let r=this.getStatus();if(r===Q.Status.Off||r===Q.Status.Starting||this._bootPending)return!t&&e?.full?this._bootFull=!0:t?this._owePass(t):this._bootExplicit=!0,r===Q.Status.Off?await this.start():r===Q.Status.Starting?await this._statusTransition:await this._bootPending,this.getStatus();if(r!==Q.Status.Running)return r;if(t&&this._draining)return this._calcOwed=!0,this._calcOwedBy??=t,r;if(this._pendingActions?.length&&await this._drainPending(),this.isClosed())return this._status;this._flushModel();let i=this._backend;if(t&&this._calcMode===Q.CalculationMode.Manual)return i.hasDirty()&&this._emitter.notify(`onStale`),r;if(e?.scope){let t=this._sheetIdByName(e.scope);t&&t!==e.scope&&(e={...e,scope:t})}let a,o=e?.full,s=e?.range;if(s){let e=this._options;if(e.getRange){let t=e.getRange(s),n=t?this._sheetIdByName(t.getWorksheet().getName()):null;if(!n)return r;let{rowStart:i,colStart:o,rowEnd:c,colEnd:l}=t.getCoords();a={rowStart:i,colStart:o,rowEnd:c,colEnd:l,scope:n}}else s?.rowStart===void 0?o=!0:a=s}let c=this._passForLoad;return this._passForLoad=!1,i.runPass(e,{full:o,calcCoords:a,gridId:t,settle:n,external:!t&&!0===e?.external,load:c,iterate:this._iterate?{maxIteration:this._maxIteration,maxChange:this._maxIterateChange}:null,openOperationId:this._modelStore?.getPendingTransaction()?.getId()??null,exceptTables:!!t&&this._calcMode===Q.CalculationMode.AutomaticExceptTables}),this.getStatus()}get _calculatedCommitId(){return this._backend?.getCalculatedCommitId()??null}get _cycleId(){return this._backend?.getCycleId()??0}_toStoredText(e,t){this._checkReady(),e.startsWith(`=`)&&(e=e.substring(1));let n=this._symbols.bind(AA.Sheet,t.scope);if(!n)throw Error(`'${t.scope}' not found.`);return this._backend.toStoredText(n,e,t.rowIndex,t.colIndex)}_hasLiveGrid(e){return this._fronts.get(e)?._isLive()??!1}_createFormulaHost(e){let t=e.id,n=this._fronts.get(t)??null;n&&!n._isLive()&&(n._revive()?this._sendRequest(t,void 0,{type:`create`,spec:this._specOf(n)}):n=null),n||(n=this._createCalcGrid({uuid:t,shadowOf:e.shadowOf,unanchored:e.unanchored,arrayFirstCell:e.arrayFirstCell,paged:e.paged,entireCoords:e.entireCoords,sizeOf:e.sizeOf,isOwned:!1}),n.addListeners({onComplete:(e,n)=>{this._formulaHosts.get(t)?._onComplete(n)}}));let r=new VM({id:t,grid:n,runtime:this._runtime,transactions:this._modelStore,onCalculated:e.onCalculated,onResync:e.onResync,waitUntil:e=>{this.waitUntil(e)},onDispose:()=>{this._formulaHosts.get(t)===r&&this._formulaHosts.delete(t)}});return this._formulaHosts.set(t,r),r}async _evaluateOver(e){let{sheetGridId:t,coords:n,expression:r,authoredAt:a}=e;if(!this._fronts.has(t))throw Error(`'${t}' not found.`);let o=new Set,s=this._createFormulaHost({id:`once-${t}-${i.uuidV4()}`,shadowOf:t,arrayFirstCell:e.arrayFirstCell,sizeOf:t});try{if(await s.setBody({coords:n,expression:r,authoredAt:a,scopeGridId:t}),this.isClosed())throw Error(`Calculation not started.`);await this._calculate({scope:s.getId()});let i=await this._settledValuesOf(s,e.timeout,o);return new LV(this._runtime,i,n,null,!1,!1,s.getBlankValueWithin(n))}finally{this._backend?.getDeferred().closeCalls(o),s.dispose()}}async _settledValuesOf(e,t,n){let r=this._backend?.getDeferred(),a=Date.now()+(t??$L),o=i.EmptyArray;for(;r&&!this.isClosed();){await this.ready();let t=r.getCallsOf(e.getId());for(let e=0;e<t.length;e++)n.add(t[e]);let i=t.filter(e=>e.isOpen());if(i.length===0&&!r.hasSettleWork())break;let s=a-Date.now();if(s<=0){o=i;break}await r.whenChanged(s)}let s=e.getValueGrid().clone();for(let e=0;e<o.length;e++){let t=o[e].owner;s.setValueAt(t.rowIndex,t.colIndex,new V.Timeout(`The answer did not arrive in time`,{cause:{payload:o[e].payload}}))}return s}async evaluateBatch(e){await this.ready();let t=new Set,n=this._createFormulaHost({id:`batch-${i.uuidV4()}`,entireCoords:fB()});try{let r=[];for(let[t,n]of e.values)for(let[e,i]of n){let n=i.length;for(let a=0;a<n;a++)r.push([e+a,t,i.at(a)])}r.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);let i=new Lo.Builder;for(let[e,t,n]of r)i.pushAt(e,t,n);let a=e.formulas.map(({expression:e,coords:t})=>({...t,value:e.replace(/^\s*=/,``)}));if(await n.setInputs(i.build(),a),this.isClosed())throw Error(`Calculation not started.`);await this._calculate({scope:n.getId()});let o=await this._settledValuesOf(n,e.timeout,t);return e.formulas.map(({coords:e})=>new LV(this._runtime,o,e,null,!1,!1,null))}finally{this._backend?.getDeferred().closeCalls(t),n.dispose()}}_createCalcGrid(e){let{isOwned:t,valuesAxis:n,getGrid:r,...a}=e,o=e.uuid||`gen`+i.uuidV4(),s=e.sizeOf,c=new OM({backend:new Oj({id:o,send:(e,t,n)=>this._sendRequest(e,t,n),calculation:this}),calculation:this,runtime:this.getRuntime(),transactions:this._modelStore??void 0,valuesAxis:n,isOwned:t,entireCoords:e.entireCoords,sizeOf:s,getGrid:e=>this._fronts.get(e)??null});return this._fronts.set(o,c),this._gridSpecs.set(o,{id:o,shadowOf:a.shadowOf,unanchored:a.unanchored,arrayFirstCell:a.arrayFirstCell,paged:a.paged,entireCoords:a.entireCoords,sizeOf:s}),c.addListeners({onClose:()=>{this._fronts.get(o)===c&&(this._fronts.delete(o),this._gridSpecs.delete(o))}}),this._sendRequest(o,void 0,{type:`create`,spec:this._specOf(c)}),c}_specOf(e){let t=e.getId();return{...this._gridSpecs.get(t),id:t}}_openEngineGrids(e){let t=[],n=[];this._fronts.forEach(e=>{e._isLive()&&(e._isOwned()?n:t).push(e)});let r=[...t,...n];for(let e=0;e<r.length;e++)this._sendRequest(r[e].getId(),void 0,{type:`create`,spec:this._specOf(r[e])});this._formulaHosts.forEach(e=>{e._restart()});for(let t=0;t<n.length;t++){let r=n[t]._seedContent();r&&n[t]._getBackend().seed(r,{full:e}).catch(e=>this._reportError(e))}}_dropEngine(){this._backend?.drop()}_followRestore(e){this._backend?.followRestore(e,this._status)&&this._whenSafe(async()=>{this.isClosed()||this._status!==Q.Status.Running||this._rebuildEngine()},!0)}_rebuildEngine(){let e=this._backend,t=this._heldSheets();e.rebuild({sheets:tR(t),gridless:nR(t),tables:t.length>0?this._liveTables():new Map,names:this._liveNames()}),this._openEngineGrids(!1),e.forgetEarlierLandings()}_reportError(e){this.isClosed()||this._emitter.notify(`onError`,e)}_heldSheets(){return this._ownerStore.getState(this._sheetListId)?.sheets??i.EmptyArray}_heldSheetAt(e){let t=this._heldSheets();for(let n=0;n<t.length;n++)if(t[n][0]===e)return t[n]}_setSheets(e){if(this.isClosed())return;let t=this._heldSheets();if(rR(t,e))return;for(let n=0;n<t.length;n++){let[r,i]=t[n],a=e.find(e=>e[0]===r);a&&a[1]===i||this._materializeNamesMentioning(r,i)}let n=e.map(([e,t,n])=>n?[e,t,!0]:[e,t]),r=this._ownerStore.beginCommit();try{r.updateState(this._sheetListId,{sheets:n}),r.amend()}catch(e){throw r.rollback(),e}if(this._status===Q.Status.Off&&iR(t,n))return;let i=this._modelStore,a=i?i.getPendingTransaction()?.getId()??i.getCurrentCommit(!1).getId():void 0;this._sendRequest(``,void 0,{type:`sheets`,sheets:n,options:{commitId:a}})}_materializeNamesMentioning(e,t){let n=this._status;if(n!==Q.Status.Running&&n!==Q.Status.Starting)return;let r=t??this._heldSheetAt(e)?.[1]??this._sheetName(e);r&&this._namedFormulas._materializeMentioning(r)}_liveTables(){let e=(this._options?.namedCollection)?.getItems({type:`table`})??i.EmptyArray,t=new Map;for(let n=0;n<e.length;n++){let r=e[n],i=r.getValue();i&&!i.isDeleted()&&t.set(r.getId(),oR(i))}return t}_liveNames(){let e=new Map,t=this._namedFormulas?._namesAsWritten()??i.EmptyArray;for(let n=0;n<t.length;n++)e.set(t[n].id,[t[n].name,t[n].scopeId]);return e}_tableChanged(e,t){let n=e.getNamed?.()?.getId();if(!n)return;let r=t||e.isDeleted()?null:oR(e);this._sendSymbolChange(`tables`,n,r,sR)}_nameWritten(e){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];t[n]=[r.id,r.removed?null:[r.name,r.scopeId]]}this._sendSymbolChanges(`names`,t,cR)}_sendSymbolChange(e,t,n,r){this._sendSymbolChanges(e,[[t,n]],r)}_sendSymbolChanges(e,t,n){if(this.isClosed())return;let r=this._status;if(r!==Q.Status.Running&&r!==Q.Status.Starting)return;let i=this._modelStore,a=i?i.getPendingTransaction()?.getId()??i.getCurrentCommit(!1).getId():void 0;if(r===Q.Status.Running){let r=this._backend,i=e===`tables`?r.getTables():r.getNames(),o=[];for(let e=0;e<t.length;e++){let[r,a]=t[e];n(i.get(r),a)||o.push([r,a])}if(o.length===0)return;this._sendRequest(``,void 0,{type:e,changes:o,options:{commitId:a}});return}let o=this._openSymbolMessages??=new Map,s=this._symbolsTold??=new Map,c=s.get(e)??new Set;s.set(e,c);for(let n=0;n<t.length;n++){let[r,i]=t[n],s=o.get(e);if(!c.has(r)&&s&&!s.dead&&s.commitId===a){s.request.changes.push([r,i]),c.add(r);continue}c.add(r);let l=[[r,i]];this._sendRequest(``,void 0,{type:e,changes:l,options:{commitId:a}});let u=this._channel,d=u?u[u.length-1]:void 0;d&&d.gridId===``&&d.request.type===e&&o.set(e,d)}}_markDirtyReconciled(e){let t=e?.reconcile()??i.EmptyArray;t.length!==0&&this._whenSafe(async()=>{this.isClosed()||this._backend.markDirtyReferencing(new Set(t))})}_hasReplicas(){return this._status!==Q.Status.Off&&this._status!==Q.Status.Error}_replicaTables(){return this._hasReplicas()?this._backend?.getReplicaTables()??null:null}_replicaNames(){return this._hasReplicas()?this._backend?.getReplicaNames()??null:null}_replicaNameId(e,t){if(this._hasReplicas())return this._backend?.getReplicaNameId(e,t)}_modelSymbols(){return this._modelSymbolRegistry}_imagerFor(e){return{symbols:this._modelSymbolRegistry,gridId:e,getEntireCoords:()=>this._fronts.get(e)?.getEntireCoords()??lB,getDisplayLocale:()=>wg(bg(this._runtime.getLocaleProfile().decimal)),resolveTableReference:(t,n)=>this._resolvers?.getStructureReferenceCoords?.(t,n,0,e)??V.BuiltIn.Ref}}_sheetIds(){return this._backend?.getSheetIds()??i.EmptyArray}_sheetIdByName(e){return this._backend?.getSheetIdByName(e)??null}_sheetName(e){return this._backend?.getSheetName(e)??null}async stop(){this._status===Q.Status.Running&&(this._status=Q.Status.Stopping,this._emitter.notify(`onStatusChange`),this._emitter.notify(`onStopping`),this._status=Q.Status.Off,this._dropEngine(),this._emitter.notify(`onStatusChange`),this._emitter.notify(`onStop`),this._noteCalculationState())}close(){if(!this.isClosed()){this.stop(),this._releaseCompilerWaiters(),this._modelStoreRemoveListener?.(),this._modelStoreRemoveListener=null,this._mirrorRemoveListener?.(),this._mirrorRemoveListener=null,this._externalBooks?.close();for(let e of Array.from(this._fronts.values()))e.close();super.close(),this._backend?.close()}}_flushModel(){this._modelStore&&this._modelMirrorId&&this._modelStore.getState(this._modelMirrorId)}_modelHistory(){let e=new Set,t=this._modelStore;if(!t)return e;let n=t.getLog(t.getCurrentCommit(!1).getId(),2**53-1);for(let t=0;t<n.length;t++)e.add(n[t].getId());return e}_hasLanded(e){if(this._landedCommits?.has(e))return!0;let t=this._modelStore,n=this._modelMirrorId;return!(!t||!n||t.getStateAt(e,n)===void 0)&&((this._landedCommits??=new Set).add(e),!0)}_modelLanding(){let e=this._modelStore;if(!e)return null;let t=e.getCurrentTransaction();if(!t)return null;let n=t.getSavepointId(),r=t.getId();return n===r?`${r}:0`:n}_hookRollback(e){let t=this._modelStore;if(!t||e.endsWith(`:0`))return;let n=t.getCurrentTransaction();if(!n||n.getDepth()===0||n.getSavepointId()!==e)return;let r=this._rollbackHooked??=new Set;r.has(e)||(r.add(e),t.beginCommit({savepoint:!1,onCommit:()=>{r.delete(e)},onRollback:()=>{r.delete(e),this.isClosed()||this._sendRequest(``,void 0,{type:`rollback`,savepointId:e})}}).commit())}getStatus(){return this._status}_whenRequestsSettled(){let e=this._outstanding;return e&&e.size!==0?Promise.allSettled(Array.from(e)).then(()=>this._whenRequestsSettled()):Promise.resolve()}getCalculationMode(){return this._calcMode}setCalculationMode(e){if(!uR.has(e))throw Error(`Invalid calculation mode: '${e}'.`);if(e===this._calcMode)return this;let t=this._calcMode===Q.CalculationMode.Manual;return this._calcMode=e,this._emitter.notify(`onOptionsChange`),this._noteCalculationState(),t&&this.isCalculationRequired()&&this.calculate(),this}isCalculationRequired(){return this._backend?.hasDirty()??!1}getIterativeCalculation(){return{enabled:this._iterate,maxIteration:this._maxIteration,maxChange:this._maxIterateChange}}setIterativeCalculation(e){let t=typeof e==`boolean`?{enabled:e}:e??{},n=t.enabled??this._iterate,r=Math.max(1,Math.floor(t.maxIteration??this._maxIteration))||1,i=Math.max(0,t.maxChange??this._maxIterateChange)||0;if(n===this._iterate&&r===this._maxIteration&&i===this._maxIterateChange)return this;if(this._iterate=n,this._maxIteration=r,this._maxIterateChange=i,this._emitter.notify(`onOptionsChange`),this._status===Q.Status.Running){let e=this._backend,t=e.getCycleCells();t.length>0&&e.markDirty(t),this.calculate()}return this}toJSON(){let e={...this._calcJSON??{}};return this._calcMode===Q.CalculationMode.Automatic?delete e.calcMode:e.calcMode=this._calcMode,this._iterate?e.iterate=!0:delete e.iterate,this._maxIteration===100?delete e.maxIteration:e.maxIteration=this._maxIteration,delete e.maxIterations,this._maxIterateChange===.001?delete e.maxIterateChange:e.maxIterateChange=this._maxIterateChange,e}async ready(e){if(this._status===Q.Status.Error)return this._status;let t=typeof e==`boolean`?e:e?.full??!1;for(;await this._readyPass(t),t=!1,await this._whenRequestsSettled(),!this.isClosed()&&this._status===Q.Status.Running&&this._isWorking();)await new Promise(e=>{(this._calculationStateWaiters??=[]).push(e)});return lR}waitUntil(e){this._consumerWork++,this._noteCalculationState();let t=()=>{this._consumerWork--,this._noteCalculationState()};return e.then(t,t),e}async _readyPass(e){this._status===Q.Status.Off?await this.start():this._status===Q.Status.Starting?await this._statusTransition:this._bootPending&&await this._bootPending,this._pendingActions?.length&&await this._drainPending(),this._calcMode!==Q.CalculationMode.Manual&&(this._flushModel(),await this._backend?.calculateGrids(e))}getCalculationState(){let e=this._status;return e===Q.Status.Starting?Q.CalculationState.Calculating:e!==Q.Status.Running||this.isClosed()?Q.CalculationState.Done:this._isWorking()?Q.CalculationState.Calculating:this._backend.hasDirty()?this._calcMode===Q.CalculationMode.Manual||this._calcMode===Q.CalculationMode.AutomaticExceptTables?Q.CalculationState.Pending:Q.CalculationState.Calculating:Q.CalculationState.Done}_isWorking(){return(this._outstanding?.size??0)>0||this._drainScheduled||this._draining||!!this._pendingActions?.length||!!this._pendingPriority?.length||this._calcOwed||this._passesInFlight>0||this._bootPending!==null||this._consumerWork>0&&this._calcMode!==Q.CalculationMode.Manual}_noteCalculationState(){this._calculationStatePosted||(this._calculationStatePosted=!0,queueMicrotask(()=>{this._calculationStatePosted=!1;let e=this._calculationStateWaiters;if(this._calculationStateWaiters=null,!this.isClosed()){let e=this.getCalculationState();e!==this._calculationState&&(this._calculationState=e,this._emitter.notify(`onCalculationStateChange`))}e?.forEach(e=>e())}))}_getEditingCompiler(e=`display`){let t=this._compilerModule;if(!t)throw Error(`Calculation not started.`);if(e===`storage`)return this._compilerEditingStorage??=new t.FormulaCompiler({profile:`editing`}),this._compilerEditingStorage;let n=bg(this._runtime.getLocaleProfile().decimal),r=wg(n),i=r.specifiers,a=i?`${i.all},${i.data},${i.headers},${i.totals},${i.thisRow}`:``,o=`${n.separatorDecimal}|${n.separatorFunction}|${n.separatorRow}|${r.booleanTrue}|${r.booleanFalse}|${r.errorLiterals.join(`,`)}|${r.errorRefs.join(`,`)}|${a}`;if(!this._compilerEditing||this._compilerEditingSig!==o){let e={locale:r};this._compilerEditing=new t.FormulaCompiler({profile:`editing`,lexerOptions:e}),this._compilerEditingSig=o}return this._compilerEditing}createFormula(e,t,n){return this._createFormula(e,t,n?.target??`storage`)}_createFormula(e,t,n){this._checkReady(),e.startsWith?.(`=`)&&(e=e.substring(1));let r=null,i=0,a=0,o=this._getActiveCell()?.scope??null;t&&(r=t.scope,i=t.colIndex??0,a=t.rowIndex??0,r&&(o=this._symbols.bind(AA.Sheet,r)));let s=t?null:o,c=this._backend.compileTemporary(e,{gridId:o,virtual:!t,rowIndex:a,colIndex:i,target:n});if(!c)throw Error(`'${r}' not found.`);let{block:l,calcGrid:u}=c;return o=c.gridId,new DA({colIndex:i,rowIndex:a},l,{...this._options,getRange:this._getRange,getRanges:this._getRanges,getCalcGrid:()=>u,resolveSheetScope:e=>this._sheetName(e),getOwnScope:()=>this._sheetName(o),inputTarget:n,autoCorrect:e=>{let r=this._getEditingCompiler(n).autoCorrect(e);if(r===null)return null;let i=this._createFormula(r,t,n);return i.isValid()?i:null},createAt:(e,r)=>this._createFormula(e,{scope:t?.scope,rowIndex:r.rowIndex,colIndex:r.colIndex},n)},async(t,n)=>{await this.ready();let r=typeof n==`number`?void 0:n,l=typeof n==`number`?n:n?.evalIndex,u=r?.block;if(u){let t=await this._evaluateOver({sheetGridId:s??o,coords:u,expression:e,authoredAt:{rowIndex:a,colIndex:i},arrayFirstCell:!0===r?.arrayFirstCell,timeout:r?.timeout});return t.getRowCount()!==1||t.getColumnCount()!==1||r?.alwaysReturnRange?t:t.getValueAt(0,0)??0}let d=!0===r?.alwaysReturnRange,f=c.evaluate(t,l,d);if(c.getCalls().length===0)return f;let p=this._backend.getDeferred(),m=Date.now()+(r?.timeout??$L),h=new Set;try{for(;;){let e=c.getCalls();for(let t=0;t<e.length;t++)h.add(e[t]);let n=e.filter(e=>e.isOpen());if(n.length===0)return f;let r=m-Date.now();if(r<=0)return new V.Timeout(`The answer did not arrive in time`,{cause:{payload:n[0].payload}});if(await p.whenChanged(r),this.isClosed())return f;n.every(e=>!e.isOpen())&&(f=c.evaluate(t,l,d))}}finally{p.closeCalls(h)}})}async evaluate(e,t){let n,r,i;if(await this.ready(),typeof t==`number`)n=t;else if(t){let{target:e,...a}=t;i=e,n=a,r=Object.keys(a).length>0?a:void 0}return this.createFormula(e,r,{target:i}).evaluate(n)}getFunctions(){return this._checkReady(),this._functions}getExternalBooks(){return this._externalBooks}getNamedFormulas(){return this._namedFormulas}hydrateNames(){let e=this._pendingNames;e&&(this._pendingNames=null,this._namedFormulas.hydrate(e))}getRuntime(){return this._runtime}_checkReady(){if(this._status!==Q.Status.Running)throw Error(this._statusMessage())}_statusMessage(){switch(this._status){case Q.Status.Off:return`Calculation is off`;case Q.Status.Error:return`Calculation failed to start`;case Q.Status.Starting:return`Calculation is starting`;case Q.Status.Stopping:return`Calculation is stopping`;case Q.Status.Running:return`Calculation is running`;default:return`Unknown calculation status`}}get[Symbol.toStringTag](){return`[Calculation]`}toString(){return`Calculation`}get isICalculation(){return!0}},tR=e=>{let t=new Map;for(let n=0;n<e.length;n++)t.set(e[n][0],e[n][1]);return t},nR=e=>{let t=new Set;for(let n=0;n<e.length;n++)e[n][2]&&t.add(e[n][0]);return t},rR=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n][0]!==t[n][0]||e[n][1]!==t[n][1]||!!e[n][2]!=!!t[n][2])return!1;return!0},iR=(e,t)=>{if(t.length<e.length)return!1;for(let n=0;n<e.length;n++)if(e[n][0]!==t[n][0]||e[n][1]!==t[n][1]||!!e[n][2]!=!!t[n][2])return!1;return!0},aR=new Set([`seed`,`snapshot`,`rollback`,`calculate`,`markDirty`,`demand`,`revert`,`close`,`create`,`resize`,`graph`,`nameGraph`,`isVolatile`]),oR=e=>{let t=e.getColumns(),n=Array(t.length);for(let e=0;e<t.length;e++)n[e]=[String(t[e].getId()),t[e].getName()??``];return[e.getName(),n]},sR=(e,t)=>{if(!e||!t)return!e&&!t;if(e[0]!==t[0]||e[1].length!==t[1].length)return!1;for(let n=0;n<e[1].length;n++)if(e[1][n][0]!==t[1][n][0]||e[1][n][1]!==t[1][n][1])return!1;return!0},cR=(e,t)=>e&&t?e[0]===t[0]&&e[1]===t[1]:!e&&!t,lR=Promise.resolve(Q.Status.Running),uR=new Set(Object.values(Q.CalculationMode)),dR=new Set([`setInputs`,`setReference`,`setReferenceMode`,`shift`,`autoFill`,`copyTo`,`delete`]),fR=Object.freeze({full:!0}),pR=class extends EA{constructor(e,t,n,r){super(t,null,r),this._host=e,this._last=n}get _block(){return this._host.getView()}_view(){return this._host.getView()}_getHostId(){return this._host.getId()}_setLast(e){this._last=e}isCompiled(){return this._host.getBlock()!==null}getCalculationStatus(){return this.isCompiled()?Q.ResultStatus.Ready:Q.ResultStatus.Pending}getExpression(e){return this._view()?super.getExpression(e):this._last}getTokens(e){return this._view()?super.getTokens(e):mR}isValid(){return!this._view()||super.isValid()}isReferenceOnly(){return!!this._view()&&super.isReferenceOnly()}getReferences(){return this._view()?super.getReferences():null}hasRefError(){return!!this._view()&&super.hasRefError()}setReferenceAt(e,t,n){return Promise.reject(Error(`The references of a formula a content names cannot be edited through it.`))}setReferenceModeAt(e,t,n,r){return Promise.reject(Error(`The references of a formula a content names cannot be edited through it.`))}},mR=Object.freeze([]),hR=/^(?:'((?:[^']|'')+)'|([^'!]+))!([^!]+)$/;function gR(e){let t=hR.exec(e);return t?{sheet:t[1]===void 0?t[2]:t[1].replace(/''/g,`'`),reference:t[3]}:null}var _R=Object.freeze([]),vR=e=>!!e&&typeof e.then==`function`,yR=e=>{if(typeof e==`string`)return`'${e}'`;try{return JSON.stringify(e)}catch{return String(e)}},bR=(e,t)=>{if(!e)return null;let n={colStart:Math.max(e.colStart,t.colStart),rowStart:Math.max(e.rowStart,t.rowStart),colEnd:Math.min(e.colEnd,t.colEnd),rowEnd:Math.min(e.rowEnd,t.rowEnd)};return n.rowStart>n.rowEnd||n.colStart>n.colEnd?null:n},xR=(e,t)=>{if(!e?.xml)return null;let n={xml:e.xml},r=e.images;if(r){let e=[];for(let n=0;n<r.length;n++){let i=t(r[n].resId);i&&e.push({id:r[n].id,resource:i})}e.length>0&&(n.images=e)}return n},SR=(e,t)=>{if(!e)return null;let n={xml:e.xml},r=e.images;return r&&r.length>0&&(n.images=r.map(e=>({id:e.id,resId:t(e.resource)??0}))),n},CR=new Set([`onDataChange`,`onStyleChange`,`onMergesChange`,`onSpillsChange`]),wR=[[`onMergesChange`,[`merges`]],[`onSpillsChange`,[`spills`]],[`onStyleChange`,[`style`]],[`onDataChange`,[`data`,`address`,`sheets`,`hyperlinks`]]],TR=new Map(wR.flatMap(([e,t])=>t.map(t=>[t,e]))),ER=!1,DR=class e{_getInternal(){return this._internal}_getReadCtx(){if(!this._readCtx){let e=this;this._readCtx={get state(){return e._getState()},get rowHeaders(){return e._rowHeaders},get columnHeaders(){return e._colHeaders},get cellOptions(){return e._cellOptions},get strings(){return e._strings},get lists(){return e._lists},getEntireCoords:this._getEntireCoords.bind(this),getUsedCoords:this._getUsedCoords.bind(this),get calcGrid(){return e._calcGrid},getAnomalies:this._getAnomalies.bind(this),getKinds:this._getKinds.bind(this),getRoles:this._getRoles.bind(this)}}return this._readCtx}_getAnomalyFindings(e=this._getWorkbookRoleColors()){let t=this._getState(),n=this._calcGrid,r=n.getValues(),i=n.getFormulas(),a=n.getValuesEpoch(),o=this._getForeignReads(),s=this._anomalyFindings;if(s&&s.state===t&&s.values===r&&s.formulas===i&&s.epoch===a&&s.roleColors===e.key&&s.reads===o)return s.findings;let c=oE({...this._anomalySource(),workbookRoleColors:()=>e.colors,workbookReads:()=>o});return this._anomalyFindings={state:t,values:r,formulas:i,epoch:a,roleColors:e.key,reads:o,findings:c},c}_getForeignReads(){let e=this._getWorkbookSheets().slice(1),t=e.map(e=>e._calcGrid.getFormulas()),n=this._foreignReads;if(n&&n.sheets.length===e.length&&n.sheets.every((t,n)=>t===e[n])&&n.formulas.every((e,n)=>e===t[n]))return n.map;let r=function(e,t){let n=new fc,r=[];for(let n=0;n<t.length;n++){let i=t[n];if(i===e)continue;let a=i.getUsedRange();if(a)for(let t of a.getRegions(Qh.Feature.Formula)){let n=t.getCoords(),a=OE(i,n.rowStart,n.colStart);if(!a)continue;let o=n.rowEnd>n.rowStart||n.colEnd>n.colStart?OE(i,n.rowEnd,n.colEnd):null;for(let t=0;t<a.length;t++){let n=a[t];if(n.sheet!==e||!n.coords)continue;let i=o&&o.length===a.length&&o[t].sheet===e?o[t].coords:null;r.push(i?{rowStart:Math.min(n.coords.rowStart,i.rowStart),rowEnd:Math.max(n.coords.rowEnd,i.rowEnd),colStart:Math.min(n.coords.colStart,i.colStart),colEnd:Math.max(n.coords.colEnd,i.colEnd),value:!0}:{...n.coords,value:!0})}}}return r.length>0&&n.insertAllNonOverlapping(r),n}(this,e);return this._foreignReads={sheets:e,formulas:t,map:r},r}_getWorkbookSheets(){let t=[this],n=this._workbook?.getWorksheets().getItems({visibility:Qu.Visibility.VeryHidden})??[];for(let r=0;r<n.length;r++){let i=n[r];i!==this&&i instanceof e&&t.push(i)}return t}_getWorkbookRoleColors(){let e=this._getWorkbookSheets().map(e=>e._getRoleColors()),t=this._workbookRoleColors;if(t&&t.sheets.length===e.length&&t.sheets.every((t,n)=>t===e[n]))return t;let n=new Set;for(let t of e)for(let e of t)n.add(e);let r=[...n].sort().join(`,`);return this._workbookRoleColors={sheets:e,key:r,colors:t?.key===r?t.colors:n},this._workbookRoleColors}_getAnomalies(){let e=this._getWorkbookRoleColors(),t=this._getWorkbookSheets().map(t=>t._getAnomalyFindings(e)),n=t[0],r=this._anomalies;if(r&&r.workbook.length===t.length&&r.workbook.every((e,n)=>e===t[n]))return r.map;let i=sE(n,function(e){let t=new Map;for(let n=0;n<e.length;n++)for(let{key:r,count:i}of e[n].repeats.values())t.set(r,(t.get(r)??0)+i);return t}(t),this._getState().ignoredErrors);return this._anomalies={workbook:t,map:i},i}_roleSource(){let e=this._calcGrid;return{sheet:this,bounds:this._getUsedCoords(),kinds:this._getKinds(),contentful:e.getContentful(),formulas:e.getFormulas()}}_getRoles(){let e=this._getState(),t=this._calcGrid,n=t.getValues(),r=t.getFormulas(),i=t.getValuesEpoch(),a=this._roles;if(a&&a.state===e&&a.values===n&&a.formulas===r&&a.epoch===i)return a.map;let o=function(e){let t=new fc,n=e.bounds;if(!n)return t;let r=QE(e.contentful.search(n),n);if(r.length===0)return t;let i=dE(e),a=new fc,o=[];for(let t=0;t<i.length;t++){let n=i[t].coords,r=VE(e.sheet,i[t]);for(let e=0;e<r.length;e++){let t=r[e].at;o.push({rowStart:t.rowStart,rowEnd:t.rowEnd+r[e].rowEnd*(n.rowEnd-n.rowStart),colStart:t.colStart,colEnd:t.colEnd+r[e].colEnd*(n.colEnd-n.colStart),value:!0})}}o.length>0&&a.insertAllNonOverlapping(o);let s=e=>QE(a.search(e),e),c=KE(r,QE(e.formulas.search(n),n));t.load(c.map(e=>({...e,value:$.Role.Label})));let l=[];for(let e=0;e<c.length;e++)for(let t of s(c[e]))l.push({...t,value:$.Role.Input});l.length>0&&t.insertAllNonOverlapping(l);let u=Yw(e),d=[];for(let t=0;t<i.length;t++){let n=i[t],r=kE(e.sheet,n,u);if(!r)continue;if(r!==$.Role.Computed){d.push({...n.coords,value:r});continue}let a=s(n.coords);for(let e=0;e<a.length;e++)d.push({...a[e],value:$.Role.Computed});for(let e of KE([n.coords],a))d.push({...e,value:$.Role.Output})}return d.length>0&&t.insertAllNonOverlapping(d),t}(this._roleSource());return this._roles={state:e,values:n,formulas:r,epoch:i,map:o},o}_anomalySource(){let e=this._getState();return{...this._roleSource(),roles:this._getRoles(),contentStyles:e.contentSpatial,fillStyles:e.fillSpatial,styles:this._styles,ignored:e.ignoredErrors,isProtected:this.getProtection().isLocked(),workbookRoleColors:()=>this._getWorkbookRoleColors().colors,workbookReads:()=>this._getForeignReads()}}_getRoleColors(){let e=this._getState(),t=this._calcGrid,n=t.getValues(),r=t.getFormulas(),i=t.getValuesEpoch(),a=this._roleColors;if(a&&a.state===e&&a.values===n&&a.formulas===r&&a.epoch===i)return a.colors;let o=function(e){let t=new Set;if(!e.bounds)return t;let n=e.roles.search(e.bounds);if(n.length===0)return t;for(let r of jE(n,AE(e,new vE(e.styles))).values())t.add(r.color);return t}(this._anomalySource());return this._roleColors={state:e,values:n,formulas:r,epoch:i,colors:o},o}_getKinds(){let e=this._getState(),t=this._calcGrid,n=t.getValues(),r=t.getValuesEpoch(),i=this._kinds;if(i&&i.state===e&&i.values===n&&i.epoch===r)return i.map;let a=this._runtime,o=yT({values:n,dateFormats:rD(e.dateFormatSpatial,e.pivotTables,e.contentSpatial),parseNumber:e=>function(e,t){let n={value:null};return Rz(e,t,e.getLocaleProfile(),n)&&typeof n.value==`number`?n.value:null}(a,e)});return this._kinds={state:e,values:n,epoch:r,map:o},o}_getMutationCtx(){return this._mutationCtx||=this._buildMutationCtx(),this._mutationCtx}_buildMutationCtx(){let e=this;return{get rowHeaders(){return e._rowHeaders},get columnHeaders(){return e._colHeaders},get pageLayout(){return e._pageLayout},get rowHeadersShiftCallback(){return e._rowHeadersShiftCallback},get columnHeadersShiftCallback(){return e._colHeadersShiftCallback},getEntireCoords:this._getEntireCoords.bind(this),getView:this.getView.bind(this),beginCommit:this._beginCommit.bind(this),updateState:this._updateState.bind(this),getState:this._getState.bind(this),stateFor:e=>e.getState(this._stateId),get calcGrid(){return e._calcGrid},invalidateUsedCoords:()=>{e._lastUsedCoordsRead.coords=null},validateCoords:this._validateCoords.bind(this),protectionCheck:this._protectionCheck.bind(this),assertContentEditable:this._assertContentEditable.bind(this),isMoveRuled:()=>e._isMoveRuled,getDefaultShiftAxis:this._getDefaultShiftAxis.bind(this),getName:()=>e.getName(),processLayoutChange:this._processLayoutChange.bind(this),takeShiftedMovableModels:()=>{let t=e._shiftedMovableModels;return e._shiftedMovableModels=null,t},takeShiftedNoteModels:()=>{let t=e._shiftedNoteModels;return e._shiftedNoteModels=null,t},markColumnHeaderTableNames:this._markColumnHeaderTableNames.bind(this),tellPivots:this._tellPivots.bind(this),commitWithDirectives:this._commitWithDirectives.bind(this),recordAutoFit:this._recordAutoFit.bind(this),get styles(){return e._styles},getRangedEntries:this._getRangedEntries.bind(this),createSparseBuilder:this._createSparseBuilder.bind(this),composeDirectStyleView:this._composeDirectStyleView.bind(this),autoFit:this._autoFit.bind(this),recordAutoFormat:this._recordAutoFormat.bind(this),recordSkipProtectionCheck:this._recordSkipProtectionCheck.bind(this),recordFreezePanes:this._recordFreezePanes.bind(this),recordShift:this._recordShift.bind(this),recordSelection:this._recordSelection.bind(this),notify:this._notify.bind(this),getRange:this.getRange.bind(this),getSelection:this.getSelection.bind(this),getMerges:this._getMerges.bind(this),indexMerges:this._indexMerges.bind(this),validateOrRemoveOverlaps:this._validateOrRemoveOverlaps.bind(this),autoSelect:this._autoSelect.bind(this),get isDataColumn(){return e._isDataColumn},get strings(){return e._strings},get lists(){return e._lists},get richData(){return e._richData},get cellOptions(){return e._cellOptions},get runtime(){return e._runtime},getProtection:this.getProtection.bind(this),hasRangedEntries:this._hasRangedEntries.bind(this),rangeStateIterator:this._rangeStateIterator.bind(this),recordChange:this._recordChange.bind(this),loadComments:(t,n)=>e._createComments(t,`comments`,n,e=>new jk(e)),newCommentJSON:this._newCommentJSON.bind(this),notifyCommentsChange:this._notifyCommentsChange.bind(this),recordFormulasEntered:this._recordFormulasEntered.bind(this),getTables:this.getTables.bind(this),getAutoTable:this.getAutoTable.bind(this),cellIterator:this._cellIterator.bind(this),cellStateIterator:this._cellStateIterator.bind(this),rangeToCoords:this._rangeToCoords.bind(this),getCell:this.getCell.bind(this),createCell:this.createCell.bind(this),getAutoFillPreviewCache:()=>e._autoFillPreviewCache,setAutoFillPreviewCache:t=>{e._autoFillPreviewCache=t}}}_getCoordCtx(){return this._coordCtx||=this._buildCoordCtx(),this._coordCtx}_buildCoordCtx(){let e=this;return{get internal(){return e._internal},get readonly(){return e._options.readonly??!1},get isClosed(){return e._closed},get isInitializing(){return e._initializing},get lastCellDecoded(){return e._lastCellDecoded},getEntireCoords:this._getEntireCoords.bind(this),getNamedFormulas:()=>e._calculation?.getNamedFormulas(),getNames:this.getNames.bind(this),getProtection:this.getProtection.bind(this),getName:this.getName.bind(this),resolveRange:t=>e._options.resolveRange?.(t)}}constructor(e){this._selectionAtCommitStart=null,this._movableSelectionAtCommitEnd=new Map,this._heldPassRanges=null,this._initializing=!0,this._starting=null,this._pendingFits=[],this._engineWait=null,this._loadFitSkipped=!1,this._legacyDrawing=null,this._legacyDrawingHF=null,this._pivotTableCollection=new ew(()=>this._closed?[]:this._getState().pivotTables.all().slice(),(e,t)=>this.doBatch(e,t),(e,t,n)=>this._addPivotTable(e,t,n)),this._announcedDeletes=new WeakSet,this._namesScoped=null,this._listenerNodes=new Map,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._isMoveRuled=!1,this._lastRangeRead={address:null,range:null,ranges:null},this._isDataColumn=!0,this._codeName=null,this._baseColSize=null,this._conditionalFormatCalculation=!0,this._validationSettings={},this._sheetPr={},this._isDate1904=!1,this._colHeaders=null,this._colHeadersShiftCallback=null,this._colHeadersListener=null,this._colHeadersRemoveListener=null,this._colHeadersHiddenRemoveListener=null,this._rowHeaders=null,this._rowHeadersShiftCallback=null,this._rowHeadersListener=null,this._rowHeadersRemoveListener=null,this._rowHeadersHiddenRemoveListener=null,this._isAdjustHeaders=!1,this._shiftedMovableModels=null,this._shiftedNoteModels=null,this._closed=!1,this._pivotsTold=!1,this._cellBuffer=null,this._defaultFontsVersion=-1,this._internal={getSheet:()=>this,getState:this._getState.bind(this),getCalcGrid:()=>this._calcGrid,isDataColumn:()=>this._isDataColumn,createRange:this._createRange.bind(this),isContentful:this._isContentful.bind(this),cellToCoords:this._cellToCoords.bind(this),rangeToCoords:this._rangeToCoords.bind(this),rangesToCoords:this._rangesToCoords.bind(this),validateCoords:this._validateCoords.bind(this),getScalar:this._getScalar.bind(this),getCellAt:this._getCellAt.bind(this),cellIterator:this._cellIterator.bind(this),getVisible:this._getVisible.bind(this),getUsedCoords:this._getUsedCoords.bind(this),updateTuples:this._updateTuples.bind(this),merge:this._merge.bind(this),unmerge:this._unmerge.bind(this),getMerges:this._getMerges.bind(this),insertFrom:this._insertFrom.bind(this),canInsertFrom:this._canInsertFrom.bind(this),insertCells:this._insertCells.bind(this),deleteCells:this._deleteCells.bind(this),getStyle:this._getStyle.bind(this),updateStyles:this._updateStyles.bind(this),getSnapshot:this._getSnapshot.bind(this),getRangeStats:this._getRangeStats.bind(this),getDefaultShiftAxis:this._getDefaultShiftAxis.bind(this),getDefaultSortCriteria:this._getDefaultSortCriteria.bind(this),getDefaultAutoFillCriteria:this._getDefaultAutoFillCriteria.bind(this),find:this._find.bind(this),copyFrom:this._copyFrom.bind(this),contentCounts:this._contentCounts.bind(this),featureCounts:this._featureCounts.bind(this),featureRegions:this._featureRegions.bind(this),dependencyRanges:this._dependencyRanges.bind(this),clear:this._clear.bind(this),calculate:this._calculate.bind(this),autoSelect:this._autoSelect.bind(this),beginCommit:this._beginCommit.bind(this),recordSelection:this._recordSelection.bind(this),commitWithDirectives:this._commitWithDirectives.bind(this),autoFit:this._autoFit.bind(this),getBestFit:this._getBestFit.bind(this),invalidateRendering:this._invalidateRendering.bind(this),addListenerNode:this._addListenerNode.bind(this),addWatch:this._addWatch.bind(this),surroundingRegion:this._surroundingRegion.bind(this),getTraverseRegion:this._getTraverseRegion.bind(this),sort:this._sort.bind(this),filter:this._filter.bind(this),evalFilter:this._evalFilter.bind(this),applyFilterRuns:this._applyFilterRuns.bind(this),filteredTables:this._filteredTables.bind(this),setHyperlinks:this._setHyperlinks.bind(this),setCellControl:this._setCellControl.bind(this),setSparkline:this._setSparkline.bind(this),setErrorIgnored:this._setErrorIgnored.bind(this),setComments:this._setComments.bind(this),getBoundsAtCoords:this._getBoundsAtCoords.bind(this),extendRange:this._extendRange.bind(this),createTupleBuilder:e=>this._createTupleBuilder(e),createSparseBuilder:this._createSparseBuilder.bind(this),autoFill:this._autoFill.bind(this),autoFillRange:this._autoFillRange.bind(this)},this._readCtx=null,this._anomalyFindings=null,this._foreignReads=null,this._workbookRoleColors=null,this._anomalies=null,this._roles=null,this._roleColors=null,this._kinds=null,this._ownsCalcGrid=!0,this._mutationCtx=null,this._autoFillPreviewCache=null,this._coordCtx=null,this._pivotsInTransit=null,this._batchesHeard=null,this._connectorScan=null,this._movableOverhangs=new WeakMap,this._drawnNotifyQueued=!1,this._onMovableDrawnReady=()=>{xt(),this._drawnNotifyQueued||(this._drawnNotifyQueued=!0,queueMicrotask(()=>{this._drawnNotifyQueued=!1,this._getState()!==null&&this._emitterMovables.notify(`onCollectionChange`)}))};let t=Object.freeze({...e}),n=e?.container?.getName?.();this._id=e?.uid?.()??(n?n+`-`:``)+i.uuidV4(),qa.assertUsable().catch(e=>{ER||(ER=!0,O.error(e))}),this._transactions=t.transactions??new se,this._ownTransactions=!t.transactions,this._stateId=this._transactions.create();let r=this,a=this._beginCommit({description:m(`op.newSheet`)});try{this._strings=t.strings??new zh,this._ownStrings=!t.strings,this._richValues=t.richData??new sD,this._ownRichValues=!t.richData,this._richData={get resources(){return r._resources??null},get strings(){return r._strings},fromResourceId:e=>r._readingResources?.fromResourceId(e)??null},this._lists=new Hk(this._strings,()=>this._richData,this._richValues);let e=t.styles??new Pm;this._styles=e,this._ownStyles=!t.styles,this._namedTableSource=new rg({getSheets:()=>[r]}),this._names=t.names??new Bx({addressToRanges:e=>r.getRanges(e),getCurrentScope:()=>r.getName(),isReadOnly:()=>r._options.readonly??!1,transactions:r._transactions,getSources:()=>r._calculation?[r._calculation.getNamedFormulas(),r._namedTableSource]:i.EmptyArray}),this._ownNames=!t.names,this._namesRemoveListener=this._names.addListeners({onCollectionChange:e=>{r._calculateFull()}},{transactional:!1}),this._runtime=t.runtime??new Qa(`Sheet Runtime`,{isDate1904:()=>this._isDate1904,getNow:()=>this._transactions.getCurrentCommit().getTimestamp()}),this._calculation=t.calculation,this._ownCalculation=!t.calculation;let n=e=>{let t=r.getName();return typeof t==`string`&&t.toUpperCase()===e.toUpperCase()};this._calculation||=new eR({runtime:r._runtime,functions:t.functions,getActiveCell:()=>{let e=r.getSelectedRange()?.getCoords();return e?{rowIndex:e.rowStart,colIndex:e.colStart,scope:r.getId()}:null},getRange:r.getRange.bind(r),getRanges:r.getRanges.bind(r),getSheetIndex:e=>e===void 0||n(e)?0:-1,getSheetCount:()=>1,namedCollection:r.getNames(),strings:r._strings,transactions:r._transactions}),this._workbook=t.workbook??null,this._normalStyleRanged=e.getNamedStyles().getByName(z.BuiltInName.Normal).getRanged(),this._resources=t.resources??new Rh,this._ownResources=!t.resources;let o=t.calcOnLoad??`auto`,s=!1,c=(async()=>{try{if(this._ownCalculation&&o!==`none`&&(o===`full`?await this._calculation.calculate({full:!0}):await this._calculation.start(),this._closed))return}finally{s=!0,this._starting=null}})();s||(this._starting=c),this._starting?.catch(()=>{}),t.container?.setNameChangeCallback&&t.container.setNameChangeCallback(()=>{r._notify(`onNameChange`);let e=this._beginCommit({description:m(`op.setName`)});e.updateState(r._stateId,{}),r._recordChange(e,`sheets`,[r._getEntireCoords()]),e.amend()}),t.container?.setVisibilityCallback&&t.container.setVisibilityCallback(()=>{r._notify(`onVisibilityChange`)}),t.container?.setIndexCallback&&t.container.setIndexCallback(()=>{r._notify(`onIndexChange`)}),this._modules=new Vy({transactions:this._transactions,isReadOnly:()=>this._isModulesReadOnly()}),this._placedIndex={spatial:`movableSpatial`,byModel:`movableMapModel`,zIndexBase:()=>0,create:e=>new Mx(e)},this._noteIndex={spatial:`noteSpatial`,byModel:`noteMapModel`,zIndexBase:()=>r._getState()?.movableSpatial.size()??0,create:e=>new Vk(e)},this._noteBoxes={add:(e,t,n)=>r._addNoteBox(e,t,n),isDefault:(e,t)=>{let n=t.getBounds();if(!n)return!1;let i=e.getRange().getCoords(),a=Tk(e=>r._mergeAt(e),{rowIndex:i.rowStart,colIndex:i.colStart});return o=n,s=Ek(a,r._noteLayout()),Math.abs(o.x-s.x)<=1&&Math.abs(o.y-s.y)<=1&&Math.abs(o.x+o.width-(s.x+s.width))<=1&&Math.abs(o.y+o.height-(s.y+s.height))<=1;var o,s}},this._movables=new Fx(this._prepareMovable.bind(this),this._preparePicture.bind(this),this._insertMovable.bind(this),this._searchMovables.bind(this),()=>{let e=r._getState();return e?(e.movableMapModel?.size??0)+(e.noteMapModel?.size??0):0},this._updateSelectedMovables.bind(this),(e,t)=>this._emitterMovables.addListeners(e,t),this._groupMovables.bind(this)),this._emitterMovables=new ne(this._movables,this._transactions),this._charts=new Lx(this._movables,this),this._tables=new vD(this._addTable.bind(this),this._getTables.bind(this),e=>{let t=r._getState();return t?t.tables.getByName(e):null},this._forwardCollectionListeners(`onTablesChange`,()=>this._tables)),this._dataValidations=new cO(this._addDataValidation.bind(this),(e,t,n)=>{let a=e?this._rangeToCoords(e):this._getEntireCoords(),o=r._getState();return o?r._getRangedEntries(o.dataValidations,[a],{ignoreHidden:t,fullyContained:n},!0):i.EmptyArray},e=>{let t=[{r:e?.getRanges().getCoords()??this.getSelectedRanges().getCoords(),v:e?.toJSON()??{}}],n=r._getState().dataValidations.clone(),i;return r._createDataValidations(n,`dataValidations`,t,e=>(i=new tO({...e,transactions:null,setContainerCallbacks:null,setContainerCoords:null,setContainerName:null,setContainerIndex:null,isProtected:null,invalidate:null}),i)),i},this._forwardCollectionListeners(`onDataValidationsChange`,()=>this._dataValidations),()=>this._validationSettings),this._conditionals=new $D(this._addConditionalFormat.bind(this),(e,t,n)=>{let a=e?this._rangeToCoords(e):this._getEntireCoords(),o=r._getState();return o?r._getRangedEntries(o.conditionalFormats,[a],{ignoreHidden:t,fullyContained:n},!0):i.EmptyArray},e=>{let t=[{r:e?.getRanges().getCoords()??this.getSelectedRanges().getCoords(),v:e?.toJSON()??{condition:{operator:Z.BuiltInOperatorNames.Between,param:null}}}],n=r._getState().conditionalFormats.clone(),i;return r._createConditionalFormats(n,`conditionalFormats`,t,e=>(i=new MD({...e,transactions:null,setContainerCallbacks:null,setContainerCoords:null,setContainerName:null,setContainerIndex:null,isProtected:null,invalidate:null}),i)),i},this._forwardCollectionListeners(`onConditionalFormatsChange`,()=>this._conditionals)),this._protectedRanges=new mk(this._addProtectedRange.bind(this),(e,t,n)=>{let a=e?this._rangeToCoords(e):this._getEntireCoords(),o=r._getState();return o?r._getRangedEntries(o.protectedRanges,[a],{ignoreHidden:t,fullyContained:n},!0):i.EmptyArray},e=>{let t=r._getState();return t?t.protectedRanges.getByName(e):null},e=>{let t=[{r:e?.getRanges().getCoords()??this.getSelectedRanges().getCoords(),v:e?.toJSON()??{name:r._nextProtectedRangeName()}}],n=r._getState().protectedRanges.clone(),i;return r._createProtectedRanges(n,`protectedRanges`,t,e=>(i=new lO({...e,transactions:null,setContainerCallbacks:null,setContainerCoords:null,setContainerName:null,setContainerIndex:null,isProtected:null,invalidate:null}),i)),i},this._forwardCollectionListeners(`onProtectedRangesChange`,()=>this._protectedRanges)),this._cellControls=new gO(this._addCellControl.bind(this),(e,t,n)=>{let a=e?this._rangeToCoords(e):this._getEntireCoords(),o=r._getState();return o?r._getRangedEntries(o.cellControls,[a],{ignoreHidden:t,fullyContained:n},!0):i.EmptyArray},this._forwardCollectionListeners(`onCellControlsChange`,()=>this._cellControls)),this._sparklineGroups=new pk(this._setSparkline.bind(this),(e,t,n)=>{let a=e?this._rangeToCoords(e):this._getEntireCoords(),o=r._getState();return o?r._getRangedEntries(o.sparklineGroups,[a],{ignoreHidden:t,fullyContained:n},!0):i.EmptyArray},this._forwardCollectionListeners(`onSparklineGroupsChange`,()=>this._sparklineGroups)),this._comments=new Bk(this._addComment.bind(this),(e,t,n)=>{let a=e?this._rangeToCoords(e):this._getEntireCoords(),o=r._getState();return o?r._getRangedEntries(o.comments,[a],{ignoreHidden:t,fullyContained:n},!0):i.EmptyArray},this._forwardCollectionListeners(`onCommentsChange`,()=>this._comments)),this._options=t,this._emitter=new ne(this,this._transactions),this._view=new hL({sheet:this}),this._initListenerState(),t?.container?.beforeFromJSON?.(this),this._fromJSON(t?.json,t.disableLoadAutoFit),this._recordInitial(a),this._ownTransactions?a.amend():a.commit()}catch(e){throw a.rollback(),e}this._initializing=!1}_createRange(e,t,n=null){return function(e,t,n,r=null){if(typeof t==`string`){let i=t,a=e.getNamedFormulas()?.getById?.(i),o=a?.getName()??i,s=(a?.isReferenceOnly?.()?a.getReferences()?.at(0)?.getCoords():null)??e.getEntireCoords();r===null&&e.readonly&&(r=m(`error.sheet.readonlyRange`));let c=null;return(n||r)&&(c={getOptions:n,readOnly:r}),new _A(i,o,s,e.internal,c,a?()=>a.getRanges():null)}if(!t)return Tz(e.internal.getSheet(),e.getEntireCoords());if($I(e,t),e.isClosed)return Tz(null,e.getEntireCoords(),t);r===null&&e.readonly&&(r=m(`error.sheet.readonlyRange`));let i=null;(n||r)&&(i={getOptions:n,readOnly:r});let a=Cz(t,e.internal.getSheet()),o=Sz(e.internal,a.scope);return o?new mA(function(e){if(!e)return null;let t={colStart:e.colIndex??e.colStart??0,rowStart:e.rowIndex??e.rowStart??0,colEnd:e.colIndex??e.colEnd??0,rowEnd:e.rowIndex??e.rowEnd??0};return e.scope&&(t.scope=e.scope),(e.$colStart||e.$colIndex)&&(t.$colStart=!0),(e.$colEnd||e.$colIndex)&&(t.$colEnd=!0),(e.$rowStart||e.$rowIndex)&&(t.$rowStart=!0),(e.$rowEnd||e.$rowIndex)&&(t.$rowEnd=!0),t}(a),o,i):Tz(e.internal.getSheet(),e.getEntireCoords(),t)}(this._getCoordCtx(),e,t,n)}_createRanges(e,t,n=null){return QI(this._getCoordCtx(),e,t,n)}getRange(e,t){if(e===void 0)return this.getSelectedRange(t);typeof e==`number`&&(e=nf(arguments),t=void 0);let n=e?.scope;n!==void 0&&n!==this.getName()&&console.error(`Sheet.getRange(${yR(e)}) called with a scope (${n}) that does not match this sheet (${this.getName()}).`,e,Error(`caller`));let r=!t&&e&&(e.rowStart!==void 0||typeof e==`string`&&kR.test(e));if(r){if(typeof e==`string`){if(this._lastRangeRead.address===e)return this._lastRangeRead.range}else if(e.rowStart!==void 0&&qz(e,this._lastRangeRead.address))return this._lastRangeRead.range}try{let n=this._rangesToCoords(e);if(n.length>1)throw new k(N(`error.address.singleRangeOnlyAlt`));let i=n[0]?.scope;i!==void 0&&i!==this.getName()&&console.error(`Sheet.getRange(${yR(e)}) called with a scope (${i}) that does not match this sheet (${this.getName()}).`,e,Error(`caller`));let a=this._createRange(n[0],t);return r&&(this._lastRangeRead.address=typeof e==`string`?e:{...e},this._lastRangeRead.range=a),a}catch(t){throw t instanceof w?new w(t.message):new k(t.message??bh(e))}}getCell(e){if(e===void 0)return this.getSelectedCell();let t=this.getRange(e);if(t.size>1)throw new k(N(`error.address.singleCellOnly`));return t.getCell()}getRanges(e,t){if(!e)throw new k(N(`error.address.noAddress`));let n=this._rangesToCoords(e);if(n.length===0)throw this._createRangeError(e);return this._createRanges(n,t)}getEntireRange(e){if(!e){let e=this._entireRangeCache;return e||(e=this._createRange(this._getEntireCoords()),this._entireRangeCache=e),e}return this.getRange(this._getEntireCoords(),e)}_getEntireCoords(){let e=this._entireCoordsCache;if(!e){let t=this._getState();if(!t)return null;e=t.entireCoords,this._entireCoordsCache=e}return e}getEntireCoords(){return this._getEntireCoords()}getUsedRange(e){let t=this._getUsedCoords(e),n=t?this.getRange(t,e):null;return e||(this._lastUsedCoordsRead.coords=t,this._lastUsedCoordsRead.range=n),n}getStats(e){let t=this._getUsedCoords();return this._getRangeStats(t?[t]:[],e)}getRegions(e,t){let n=$k(e??t?.features);return new rA(this._getEntireCoords(),this._getInternal(),n,t)}getAnomalies(e){let t=dA(e);return new fA([{bounds:this._getEntireCoords(),internal:this._getInternal(),qualified:!1}],()=>this.getEntireRange(),t)}_cellToCoords(e){return function(e,t){let n=e.lastCellDecoded;if(n.address===t)return n.coords;let r=rL(e,t);if(!r||!h.isSingleCell(r))throw new k(N(`error.address.singleCellOnly`));let i={colIndex:r.colStart,rowIndex:r.rowStart};return n.address=t,n.coords=i,i}(this._getCoordCtx(),e)}_validateCoords(e,t=N(`error.sheet.oobRange`),n=!1){$I(this._getCoordCtx(),e,t,n)}_createRangeError(e){return eL(e)}_protectionCheck(e=null,t=null,n=null){tL(this._getCoordCtx(),e,t,n)}_rangesToCoords(e,t=null,n=!0,r=!1,i=!1){return nL(this._getCoordCtx(),e,t,n,r,i)}_rangeToCoords(e,t=null,n=!0){return rL(this._getCoordCtx(),e,t,n)}_collectRanges(e,t=[],n=!0,r=this._getState(),i,a){(function(e,t,n=[],r=!0,i,a=e.state,o,s){let c=!0===r||typeof r==`object`&&!!r&&Object.keys(r).length>0,l=i&&i.length>0;if(!c&&!l)return;let u=(e,i,a=!1)=>{if(!a&&!0!==r&&r[e]===void 0||!i)return;let s=i.search(t,!1),c=s.length;if(c===0)return;let l=r[e];for(let r=0;r<c;r++){let i=s[r];if(l&&!h.isRangeWithinRange(t,i)||o&&!h.isRangeWithinRange(i,o))continue;let a=h.intersectRanges(t,i),c=i.value,u=i.value?.model??c??!0;n.push({...a,value:{[e]:u}})}};if(l){let r=i?i.length:0,a=e.getEntireCoords(),o=h.isEqualRanges(t,a);for(let e=0;e<r;e++){let t=i[e],r=t?t.length:0;if(r>0){let i=``+e;if(o)for(let e=0;e<r;e++){let r=wf(t[e],a);r.value={[i]:r.value},n.push(r)}else{let e=[...t];for(let t=0;t<r;t++)e[t]=wf(e[t],a);let n=new fc;n.load(e),u(i,n,!0)}}}}if(!c)return;if(d=G.Type.Merge,(typeof r==`boolean`&&!0===r||r[d]!==void 0)&&a.mergeSpatial){let e=a.mergeSpatial.search(t),r=e.length;for(let i=0;i<r;i++){let r=e[i],a=h.intersectRanges(t,r);n.push({...a,value:{merge:r.value}})}}var d;u(G.Type.Unlock,a.protectedRanges),u(G.Type.Continuous,a.continuousFillSpatial),u(G.Type.DateFormat,rD(a.dateFormatSpatial,a.pivotTables,a.contentSpatial)),u(G.Type.Hyperlink,a.hyperlinkSpatial);let f=a.ignoredErrors.getMap();f&&u(G.Type.IgnoredErrors,f),u(G.Type.Comments,a.comments),u(G.Type.BorderStyle,a.borderSpatial),u(G.Type.FillStyle,a.fillSpatial),u(G.Type.ContentStyle,a.contentSpatial);let p=e.calcGrid;u(G.Type.Contentful,p.getContentful(s)),u(G.Type.Formula,{search:t=>wm(p.getFormulas(s),a.contentSpatial,t,e.cellOptions.getProtection(),e.cellOptions.styles)}),u(G.Type.CalcStatus,p.getCalcStatus(s)),u(G.Type.CalcError,p.getCalcErrors(s)),u(G.Type.Circular,p.getCirculars(s)),!0!==r&&r[G.Type.Error]!==void 0&&u(G.Type.Error,e.calcGrid.getErrorValues()),!0!==r&&r[G.Type.Kind]!==void 0&&e.getKinds&&u(G.Type.Kind,e.getKinds()),!0!==r&&r[G.Type.Anomalies]!==void 0&&e.getAnomalies&&u(G.Type.Anomalies,e.getAnomalies()),!0!==r&&r[G.Type.Role]!==void 0&&e.getRoles&&u(G.Type.Role,e.getRoles()),u(G.Type.Spills,{search:e=>jj(p.getSpills(s),e)}),u(G.Type.Table,a.tables),u(G.Type.AutoTable,a.autoTables),u(G.Type.Pivot,{search:e=>nD(a.pivotTables,e)}),u(G.Type.DataValidations,a.dataValidations),u(G.Type.Conditionals,a.conditionalFormats),u(G.Type.CellControls,a.cellControls),u(G.Type.Sparklines,a.sparklineGroups)})(this._getReadCtx(),e,t,n,i,r,void 0,a)}_cellIterator(e){let t=this._cellOptions,n=this._strings,r=this._cellStateIterator(e),i=e?.reuseContext?new Xz(n,e,t):null;return{next(a){let o=r.next(a);if(o.done)return yo;let s=o.value,c=i??new Xz(n,e,t),l=c.context;return{done:!1,value:{value:c.setState(s),context:l}}},[Symbol.iterator](){return this}}}_rangeStateIterator(e){return gI(this._getReadCtx(),e)}_overflowAndStops(e,t){return _I(this._getReadCtx(),e,t)}_cellStateIterator(e){return function(e,t){let n=e.state;if(!n)return bo;let r=t?.bounds,a=r??e.getEntireCoords(),o=t?.axis??B.Axis.Row,s=t?.reverse??!1,c=t?.includeEmpty,l={bounds:a,axis:o,reverse:s},u;c&&(u={bounds:a,axis:o,reverse:s});let d=t?.ignoreHidden;if(!0===d||d===B.Axis.Row){let t=Bz(e.rowHeaders);l.processRowSkip=_o(t),c&&(u.processRowSkip=_o(t))}if(!0===d||d===B.Axis.Column){let t=Bz(e.columnHeaders);l.processColumnSkip=_o(t),c&&(u.processRowSkip=_o(t))}let f=c||!t?.ignoreEmptyIntersections,p=t?.includeMergeOverflow??!1,m=t?.injectReferences,g=t.searchTypes;!0===g?g=Gf:g||!m&&!p||(g=i.EmptyObject);let _=g?gI(e,{bounds:a,axis:o,reverse:s,searchTypes:g,includeMergeOverflow:p,ignoreHidden:d,injectReferences:m,byCell:!0}):bo,v,y;if(p&&r){let t=_I(e,r);t&&(v=t.overflows,v?.sort(h.createCellComparator(o,s)),y=t.stops,y?.sort(h.createCellComparator(o,s)))}let b=v?v.length:0,x=y?y.length:0,S=0,C=0,w=n?e.calcGrid.getValues():null,T=w?w.entries(l):bo,E=T.next(),D=null,O=null,k=null;E.done||(D=E.value[0],O=E.value[1]);let A=v?.[S++],j=_.next(),M=null,N=o!==B.Axis.Row,ee,te=h.createCellComparator(o,s),P;if(!j.done){let e=j.value;M=e.intersection,P=e.start}ee=e=>{let t=null,n=null,r=null,i=!1,a=!1,o=null,s=null;!f&&D&&P&&te(D,P)>0&&(j=_.next(D),j.done?(M=null,P=null):(M=j.value.intersection,P=j.value.cell));let c=!1;if(A&&(D?te(A,D)<0&&(c=!0):P?te(A,P)<0&&(c=!0):S<=b&&(c=!0)),c)t={colIndex:A.colIndex,rowIndex:A.rowIndex},n=A.scalar,r=A.intersection,A=v[S++];else if(D&&P){let e=te(D,P);e<0?(t=D,n=O,i=!0):e>0?(t=P,r=M,a=!0):(t=D,n=O,r=M,i=!0,a=!0)}else if(D)t=D,n=O,i=!0;else{if(!P||!f)return yo;t=P,r=M,a=!0}if(i&&(E=T.next(),E.done?D=null:(D=E.value[0],O=E.value[1])),a){let e=f?void 0:D;if(j=_.next(e),j.done)P=null,M=null;else{let e=j.value;M=e.intersection,P=e.cell}}let l=!1,u=t.rowIndex,d=t.colIndex;N||(l=u===k?.rowIndex);let m=!1;if(N||(m=u===D?.rowIndex),l)o=k;else if(p){let e=!1;for(;!e&&C<x;){let t=y[C],n=t.rowIndex;n<u?C++:(e=!0,n===u&&t.colIndex<d&&(C++,o={colIndex:t.colIndex,rowIndex:t.rowIndex}))}}if(m)s=D;else if(p){let e=!1;for(;!e&&C<x;){let t=y[C],n=t.rowIndex;n<u?C++:(e=!0,n===u&&t.colIndex>d&&(C++,s={colIndex:t.colIndex,rowIndex:t.rowIndex}))}}return(i||c)&&(k=t),{done:!1,value:[t,n,r,o,s]}};let F={next:ee,return:e=>yo,throw:e=>yo};return c&&(F=new Lc(F,l)),F}(this._getReadCtx(),e)}_indexMerges(e,t=null){if(!(e&&e.length!==0||t&&t.length!==0))return;let n=this._getState();if(!n)return;let r=this._beginCommit({description:`indexMerges`}),i=n.mergeSpatial.clone();if(t){let e=t.length;for(let n=0;n<e;n++)i.remove(t[n])}if(e){let t=e=>this._calcGrid.getValues().getValueAt(e.rowStart,e.colStart),n=[],r=e.length;for(let i=0;i<r;i++){let r=e[i];n.push({...r,value:new CA(r,t)})}i.load(n)}this._updateState({mergeSpatial:i}),r.commit()}_composeDirectStyleView(e,t){let n=this._getState(),r=t??{border:n.borderSpatial,fill:n.fillSpatial,content:n.contentSpatial},i=new bF({entireCoords:this._getEntireCoords()}),a=(e,t)=>({...t,value:Am.mergeOverlay(e.value,t.value)}),o=t=>{let n=e?t.search(e):t.all(),r=n.length;for(let e=0;e<r;e++){let t=n[e];t.value&&i.insertNonOverlapping({...t,value:t.value},{onIntersect:a})}};return o(r.content),o(r.fill),o(r.border),i}_updateStyles(e,t,n,r=!1){!r&&this._formatPivotTables(e,t,n)||!r&&e.length===1&&this._holdStyle(e[0],t,n)||FF(this._getMutationCtx(),e,t,n,r)}_formatPivotTables(e,t,n){let r=this._getCellBuffer(),a=r.isHolding()?r.getTransaction().getState(this._stateId):this._getState();if(!a||a.pivotTables.isEmpty())return!1;let o=((e,t,n)=>{if(e.isEmpty())return null;let r=[],a=e.all();for(let e=0;e<a.length;e++){let n=eD(a[e]);n&&!n.isBlocked&&a[e].isPreserveFormatting()&&CF(n.cells,t)&&r.push({table:a[e],cells:n.cells})}if(r.length===0)return null;let o=[],s=new fc,c=[];for(let e=0;e<t.length;e++){let r=wF(t[e].value===void 0?n:t[e].value);r?c.push({...h.sanitizeRange(t[e]),value:r}):o.push(t[e])}s.insertAllNonOverlapping(c,{onIntersect:(e,t)=>({...t,value:e.value?i.deepMerge(e.value,t.value):t.value})});let l=[];for(let{table:e,cells:t}of r){let n=new Map;for(let e=0;e<t.length;e++){let r=s.search(t[e]);for(let i=0;i<r.length;i++){let a=h.intersectRanges(r[i],t[e]),o=n.get(r[i].value);o?o.push(a):n.set(r[i].value,[a])}s.delete(t[e])}n.size>0&&l.push({table:e,styles:n})}if(l.length===0)return null;let u=s.all();for(let e=0;e<u.length;e++)o.push(u[e]);return{tables:l,rest:o}})(a.pivotTables,e,t);if(!o)return!1;let s=n?.description??m(`op.updateStyle`);return this._protectionCheck(()=>[`formatCells`],o.tables.flatMap(({styles:e})=>[...e.values()].flat()),s),this.doBatch(()=>{for(let{table:e,styles:t}of o.tables)for(let[n,r]of t)e._formatCells(r,n);o.rest.length>0&&FF(this._getMutationCtx(),o.rest,t,n,!1)},{...n,description:s}),!0}_holdStyle(e,t,n){if(e.rowStart!==e.rowEnd||e.colStart!==e.colEnd)return!1;let r=e.value===void 0?t:e.value;if(r===void 0)return!1;let i=e.rowStart,a=e.colStart,o=this._getCellBuffer();return o.holdStyle(i,a,r,n,()=>{let e=o.isHolding()?o.getTransaction().getState(this._stateId):this._getState();return this._isLocalStyle(e,i,a,r)})}_isLocalStyle(e,t,n,r){return typeof r!=`function`&&function(e,t,n,r,i){if(i===null||typeof i==`function`)return!1;let a={colStart:r,rowStart:n,colEnd:r,rowEnd:n},o=rB(e.styles)(new Am(e.styles,e.getEntireCoords,a),i,!0);if(!o)return!1;let s=o.splitByFeature();if(s.border)return!1;let c=s.content?(s.content.getUpdateProperties()??s.content.getProperties())?.alignment:void 0;if(c!==void 0){let e=c?.horizontal;if(e===R.HorizontalAlignment.CenterContinuous||e===R.HorizontalAlignment.Fill||t.search(a).length>0)return!1}return!0}(this._getMutationCtx(),e.continuousFillSpatial,t,n,r)}_createSparseBuilder(e,t=null,n){let r=e?.axis??B.Axis.Row,a=e?.allowUnorderedWrites??!1,o=r===B.Axis.Column,s=o!==this._isDataColumn,c=this,l,u,d,f=this._createTupleBuilder(s),p=null;if(t){let e=t.getCoords(),n=e.colStart,r=e.rowStart,i=e.colEnd,a=e.rowEnd;p=(e,t)=>{if(e<r||e>a||t<n||t>i)throw new w}}o?(u=(e,t,n)=>(p?.(e,t),f.pushAt(t,e,n),l),d=(e,t,n)=>(p?.(e,t+(n?.length??0)),f.pushMultipleAt(t,e,n),l)):(u=(e,t,n)=>(p?.(e,t),f.pushAt(e,t,n),l),d=(e,t,n)=>(p?.(e+(n?.length??0),t),f.pushMultipleAt(e,t,n),l));let m=e=>{let r=f.build();return r&&c._updateTuples(r,e,null,n),t},g=!1===a?null:h.createCellComparator(e?.axis),_=i.isObject(a)?a:void 0,v=null;return l=Object.freeze({push:(e,t)=>{let n=c._cellToCoords(e);return g&&(v&&g(n,v)<=0&&(m(_),f=c._createTupleBuilder(s)),v=n),u(o?n.colIndex:n.rowIndex,o?n.rowIndex:n.colIndex,t)},pushAt:u,pushMultipleAt:d,apply:m}),l}_updateTuples(e,t,n=void 0,r=null){if(this._getCellBuffer().hold(e,t,n,r))return;let i=e?e.bounds:null,a=i?this._pivotsWaitingOn([this._isDataColumn?{colStart:i.majorStart,colEnd:i.majorEnd,rowStart:i.minorStart,rowEnd:i.minorEnd}:{rowStart:i.majorStart,rowEnd:i.majorEnd,colStart:i.minorStart,colEnd:i.minorEnd}]):null;a?this.doBatch(()=>{nI(this._getMutationCtx(),e,t,n,r),this._unblockPivots(a)},t?.description):nI(this._getMutationCtx(),e,t,n,r)}_getCellBuffer(){let e=this._cellBuffer;if(!e){let t=this;e=new cI({isDataColumn:this._isDataColumn,transactions:this._transactions,writes:[this._stateId,this._calcGrid.getStateId(),this._calculation._modelMirrorId??this._calculation.getId()],isClosed:()=>t._closed,getEntireCoords:()=>t._getEntireCoords(),getSpills:e=>t._calcGrid.getSpills(e),isLocalStyle:(e,n,r,i)=>t._isLocalStyle(e.getState(t._stateId),n,r,i),getMutations:()=>t._getMutationCtx(),isMadeAsItComes:()=>F.isStepping(t._transactions)||t._hasChangeParticipants()}),this._cellBuffer=e}return e}_sort(e,t){return yA(this,e,t)}_filter(e,t,n){return async function(e,t,n,r){let i=await fy(e,t,n),a=r?.description??m(`op.filter`),o=e._beginCommit({description:a,...r});try{py(e,i,{description:a}),o.commit()}catch(e){throw o.rollback(),e}return t}(this,e,t,n)}_evalFilter(e,t){return fy(this,e,t)}_applyFilterRuns(e,t){py(this,e,t)}_autoFill(e,t,n){return LI(this._getMutationCtx(),e,t,n)}_autoFillRange(e,t){return function(e,t,n){let{direction:r,amount:i}=Zz(t,n);if(i<=0)return{...n};let a=e.getMerges([t]);if(a.length===0)return{...n};let o=r===B.Direction.Up||r===B.Direction.Down,s=r===B.Direction.Down||r===B.Direction.Right,c=o?t.rowStart:t.colStart,l=(o?t.rowEnd:t.colEnd)-c+1,u=AI(a,c,l,o,s),d=e.getEntireCoords(),f=s?o?d.rowEnd-t.rowEnd:d.colEnd-t.colEnd:o?t.rowStart-d.rowStart:t.colStart-d.colStart,p=function(e,t,n){let r=e-e%t,i=e%t;for(let e=0;e<n.length;e++)if(n[e]>=i)return r+n[e];return r+t}(i,l,u);return p>f&&(p=function(e,t,n){if(e<0)return 0;let r=e-e%t,i=e%t;for(let e=n.length-1;e>=0;e--)if(n[e]<=i)return r+n[e];return r}(f,l,u)),p<=0?{...t}:o?s?{...t,rowEnd:t.rowEnd+p}:{...t,rowStart:t.rowStart-p}:s?{...t,colEnd:t.colEnd+p}:{...t,colStart:t.colStart-p}}(this._getMutationCtx(),e,t)}_autoFillShrink(e,t,n,r){return RI(this._getMutationCtx(),e,t,n,r)}_setErrorIgnored(e,t,n,r){(function(e,t,n,r,i){let a=h.sanitizeRangeArray(t),o=i?.description??m(r?`op.ignoreError`:`op.showError`),s=e.beginCommit({description:o}),c=e.getState().ignoredErrors,l=c.set(a,n,r);l!==c&&(e.updateState({ignoredErrors:l}),e.recordChange(s,`anchored`,a)),e.commitWithDirectives(s,SD(a),i)})(this._getMutationCtx(),e,t,n,r)}_setHyperlinks(e,t,n){NF(this._getMutationCtx(),e,t,n)}_requestFor(e){return e?{commitId:e.getId(),cloneKey:e.getSavepointId()}:{commitId:this._transactions.getCurrentCommit().getId()}}_resolveInheritedFormats(t,n,r){let i=this._transactions,a=e=>i.getStateAt(t,e._stateId)??e._getState(),o=t=>{if(!t||t===this.getId()||t===this.getName())return this;let n=this._workbook?.getWorksheets().getItems({visibility:Qu.Visibility.VeryHidden});if(!n)return null;for(let r=0;r<n.length;r++){let i=n[r];if((i.getId()===t||i.getName()===t)&&i instanceof e)return i}return null},s=new fc,c=n.length;for(let e=0;e<c;e++){let t=n[e].coords,i=[];for(let e=0;e<r.length;e++){let n=h.intersectRanges(t,r[e]);n&&i.push(n)}if(i.length===0)continue;let c=t.rowStart,l=t.colStart,u=n[e].references;for(let e=u.length-1;e>=0;e--){let n=u[e],r=o(n.scope);if(!r)continue;let d=!0===n.$rowStart,f=!0===n.$colStart,p=bf(n,c,l),m=p.rowStart,g=p.colStart,_=h.intersectRanges({rowStart:d?m:m+(t.rowStart-c),colStart:f?g:g+(t.colStart-l),rowEnd:d?m:m+(t.rowEnd-c),colEnd:f?g:g+(t.colEnd-l)},r._getEntireCoords());if(!_)continue;let v=a(r);if(!v)continue;let y=v.contentSpatial.search(_),b=y.length;for(let e=0;e<b;e++){let n=y[e],r=n.value?.getProperties()?.numberFormat;if(ZR(r))continue;let a=h.intersectRanges(n,_),o={rowStart:d?t.rowStart:a.rowStart-m+c,rowEnd:d?t.rowEnd:a.rowEnd-m+c,colStart:f?t.colStart:a.colStart-g+l,colEnd:f?t.colEnd:a.colEnd-g+l};for(let e=0;e<i.length;e++){let t=h.intersectRanges(o,i[e]);t&&s.insertNonOverlapping({...t,value:{numberFormat:r}})}}}}return s.all()}_realizeCalcedValues(e){if(!e||!this._getState())return;let t=e.spillInserts,n=e.spillRemoves,r=this._calculation._calculatedCommitId??this._transactions.getCurrentCommit(!1).getId(),i=n&&!this._initializing?this._pivotsWaitingOn(n):null;this._amendBookkeeping(r,t=>{this._promoteCalcResults(t,e),i&&this._unblockPivots(i)});let a=e.bounds;if((a||e.isFull)&&!this._initializing){this._invalidateCaches(),this._notifyUsedRangeChange();let r=e.bounds??this._getEntireCoords();if(this._transactions.getPendingTransaction()?(this._heldPassRanges??=[]).push(r):this._notifyPassToListenerNodes([r]),t||n){let e=[];t&&e.push(...t),n&&e.push(...n),this._notifyChange(`onSpillsChange`,e,{commit:null})}this._notifyChange(`onDataChange`,a?[a]:null,{commit:null})}}_notifyPassToListenerNodes(e){this._closed||this._notifyListenerNodes(this._getState(),e,{commit:null,timeStamp:Date.now()},!1)}_promoteCalcResults(e,t){let n=this.getId();if(e.getIntents()[`sheet.calcResolved`]?.includes(n))return;let r=t.bounds;if(!r)return;let i=this._enteredSince(e,r);if(i.length===0)return;let a=this._beginCommit();try{let e=t.formatInserts,r=[],o=[];if(e)for(let t=0;t<e.length;t++){let n=e[t],i=n.value,a;typeof i==`string`?a=i:(o.push({coords:n,references:i.references}),a=i.fallback),a!==null&&r.push({coords:n,numberFormat:a})}for(let t=0;t<i.length;t++){let{commit:a,entered:s}=i[t],c=a.getIntents(),l=c[xP];if(e&&l?.includes(n)){let e=[];for(let t=0;t<r.length;t++)for(let n=0;n<s.length;n++){let i=h.intersectRanges(r[t].coords,s[n]);i&&e.push({...i,value:{numberFormat:r[t].numberFormat}})}if(o.length>0){let e=this._resolveInheritedFormats(a.getId(),o,s);e.length>0&&this._updateStyles(e,void 0,void 0,!0)}e.length>0&&this._updateStyles(e,void 0,void 0,!0)}let u=c[gP]?.find(e=>e.sheetId===n);u&&this._autoFit(s,u.options??IR)}a.setIntent(`sheet.calcResolved`,e=>[...e??[],n]),a.updateState(this._stateId,{}),a.commit()}catch(e){throw a.rollback(),e}}_enteredSince(t,n){let r=this.getId(),i;try{i=this._transactions.getLog(t.getId(),e._MAX_PROMOTE_WALK)}catch{let n=this._transactions.getCurrentCommit(!1);i=n.getId()===t.getId()?[t]:[t,...this._transactions.getLog(n.getId(),e._MAX_PROMOTE_WALK-1)]}let a=[],o=[];for(let e=0;e<i.length;e++){let t=i[e],s=t.getIntents();if(e>0&&s[`sheet.calcResolved`]?.includes(r))break;let c=s[pP]?.[r];if(!c||c.length===0)continue;let l=[];for(let e=0;e<c.length;e++){let t=h.intersectRanges(c[e],n);t&&l.push(t)}for(let e=0;e<o.length&&l.length>0;e++){let t=[];for(let n=0;n<l.length;n++)t.push(...uD(l[n],o[e]));l=t}l.length!==0&&(a.push({commit:t,entered:l}),o=o.concat(l))}return a}static{this._MAX_PROMOTE_WALK=64}calculate(e){return this._calculation.calculate({full:e,scope:this._calcGrid.getId()})}_calculate(e,t){let n=this._calcGrid;n.markDirtyRegions(e),this._calculation.calculate({...t,scope:n.getId()})}_calculateFull(){this._ownCalculation&&!this._initializing&&this._calculation.getStatus()!==Q.Status.Off&&this._calculation.calculate(!0)}_setComments(e,t,n){jF(this._getMutationCtx(),e,t,n)}_clear(e,t=null,n,r=!1,i=null){let a=this._pivotsWaitingOn(e);a?this.doBatch(()=>{oI(this._getMutationCtx(),e,t,n,r,i),this._unblockPivots(a)},n):oI(this._getMutationCtx(),e,t,n,r,i)}_merge(e,t=null){zF(this._getMutationCtx(),e,t)}_unmerge(e,t){BF(this._getMutationCtx(),e,t)}_getMerges(e,t=!1){if(e.length===0)return i.EmptyArray;let n=this._getState();return n?this._getRangedEntries(n.mergeSpatial,e,{ignoreHidden:t,fullyContained:!1,onEntry:e=>e.getCoords()}):i.EmptyArray}_clone(){return this._cloneOver(this._transactions.getState(this._stateId),this._calcGrid._pinned())}_snapshotAt(e){let t=this._transactions.getStateAt(e,this._stateId);if(!t)return null;let n=this._calcGrid._pinnedAt(e);return n?this._cloneOver(t,n):null}_cloneOver(t,n){let r={...this._options,calcGrid:n,container:{getName:()=>`Snapshot of ${this.getName()}`,getIndex:()=>1}};this._ownStyles&&(r.styles=this._styles),this._ownStrings&&(r.strings=this._strings),this._ownResources&&(r.resources=this._resources),this._ownNames&&(r.names=this._names),this._ownCalculation&&(r.calculation=this._calculation),r.transactions=new se({transient:!0});let i=new e(r);i._updateState(t);let a=new hL({sheet:this,json:this.getView().toJSON()});return a.getMovableSelection().select(EP(this.getView().getMovableSelection())),i.setView(a),i}_getSnapshot(e,t,n){if(e.length===0)return i.EmptyArray;let r=this._getState();if(!n){let e=this._transactions.getCurrentCommit().getId();e&&(n=()=>e)}if(!r)return null;t=Object.freeze({...t});let a=this._clone();a.isMarked=!0;let o=this,s=o.getView(),c=m(`op.range`),l=[];if(e.length>1)throw new k(N(`error.sheet.copyMultipleRanges`));let u=eB(e,a._getState().mergeSpatial,a.getEntireCoords()),d=function(e,t,n,r){let i=[],a=null,o=null,s=n&&n.length>0;if(s){let e=n.length;for(let t=0;t<e;t++){let e=n[t].getSnapshot?.(r);e&&(i.push(e),a=PP(e.getCoords(),a))}}else if(t){let n=t.length;for(let s=0;s<n;s++){let n=t[s],c=e.getMovables().getItems({ignoreHidden:!1,fullyContained:!0,address:n}),l=c.length;for(let t=0;t<l;t++){let s=c[t].getSnapshot?.(r);s&&(i.push(s),a=PP(e.getRange(n).getBounds(),a),o=h.unionRanges(o,n))}}}if(i.length===0)return null;let c=()=>r.description??(i?.length===1?i[0]?.getName():N(`copy.drawings`));return{prepare:()=>aF(i,void 0),copyTo:(e,t)=>{let n={...r,...t},o=e.getWorksheet(),s=o.getView().getMovableSelection().getItems(),l=e.getCoords(),u=n?.isCut??!1,d=o.beginCommit(n.description??N(u?`op.cutNamed`:`op.copyNamed`,{name:c()}));try{DP(d,o,[],{autoSelect:!0});let e=0,t=0;if(s.length>0&&i.length>0){let n=2**53-1,r=2**53-1;for(let e=0;e<s.length;e++){let t=s[e].getBounds();n=Math.min(t.x,n),r=Math.min(t.y,r)}let a=2**53-1,c=2**53-1,l=i.length;for(let e=0;e<l;e++){let t=i[e].getCoords();a=Math.min(t.x,a),c=Math.min(t.y,c)}e=n-a,t=r-c;let u=i[0].getCoords(),d={...u,x:u.x+e,y:u.y+t},f=cD(o.getMovables(),d);e+=f.x,t+=f.y}else if(a){let n=o.getRange(l).getBounds();e=n.x-a.x,t=n.y-a.y}let r=i.length;for(let a=0;a<r;a++){let r=i[a],s=r.getCoords(),c={...s,x:s.x+e,y:s.y+t};r.copyTo({movables:o.getMovables(),bounds:c},{autoSelect:{addToSelection:!0},...n})}d.commit()}catch(e){throw d.rollback(),e}return null},getName:c,getCoords:()=>o,getMarkOptions:()=>r,toText:()=>s?i[0].toText?.()??null:null,toHtml:()=>s?i[0].toHtml?.()??null:null,toImage:()=>s?i[0].toImage?.()??null:null,getSource:()=>e,isISnapshot:!0}}(a,u,s.getMovableSelection().getItems(),t);if(d){if(!s.getMovableSelection().isEmpty())return d;l.push(d)}let f={singleMerge:null};l.push({copyTo(n,r){let i={...t,...r},s=n.getWorksheet(),c=n.getCoords(),l=c,d=s.getRange(l),p=!1,m=d.getMerges();if(!i.isCut&&m.length===1&&h.isEqualRanges(m[0],c)){if(h.isSingleCell(e[0]))p=!0;else{let e=fD(S);a._getMerges([h.cellToRange(e)]).length===1&&(p=!0)}}let g=i.type;return p&&(f.singleMerge=c,g??=$.Content.Values),i.isCut&&s===o?o._clear([l],g??null,void 0,!1,u[0]):d.clear(g??(s.getProtection().isLocked()&&!i.isCut?$.Content.Values:void 0)),l}});let p=a._getEntireCoords(),g=u.length,_=a._getState();if(!_)return i.EmptyArray;for(let e=0;e<g;e++){let n=u[e];l.push(oF(o.getColumnHeaders().getRange(n),n,Object.freeze({...t,includeHeaders:n.rowStart<=p.rowStart&&n.rowEnd>=p.rowEnd})))}for(let e=0;e<g;e++){let n=u[e];l.push(oF(o.getRowHeaders().getRange(n),n,Object.freeze({...t,includeHeaders:n.colStart<=p.colStart&&n.colEnd>=p.colEnd})))}let v=sF(o,a,u,c,t,(e,t)=>a._copyRange(o,a,u,e,t,f));l.push(v);let y=a._calcGrid.getSnapshot({range:u[0],isCut:t?.isCut});l.push({copyTo(e,n){if(n?.type&&n?.type!==$.Content.Formulas)return null;let r=e.getWorksheet(),i=e.getCoords();if(a.getProtection().isLocked()&&(r!==a||!a._isProtectionRuled()))return null;let s={...t,...n},c=r,l=c._calcGrid,d=c._requestFor(c._transactions.getCurrentTransaction());y.copyTo({gridId:l.getId(),grid:l,range:i},{isCut:s.isCut,fitDestination:n?.fitDestination,transpose:s.transpose,commitId:d.commitId,cloneKey:d.cloneKey});let f=i;return s.isCut&&(r!==o||s.transpose?s.transpose||o._moveReferencesToSheet(r,u[0],i):o._moveReferences(u[0],i)),f}});let b={ignoreHidden:!1,fullyContained:!0,onEntry:e=>e.model};for(let e=0;e<g;e++){let n=u[e],r=a._getRangedEntries(_.tables,[n],b),i=r.length;for(let e=0;e<i;e++){let i=r[e],o=i.getRange().getCoords(),s=o.colStart-n.colStart,c=o.rowStart-n.rowStart,u=i.getSnapshot(t);l.push({copyTo(e,t){let n=e.getWorksheet(),r=e.getCoords();if(a.getProtection().isLocked()||n.getProtection().isLocked())return null;let i={colStart:r.colStart+s,rowStart:r.rowStart+c,colEnd:r.colEnd+s,rowEnd:r.rowEnd+c};return u.copyTo({tables:n.getTables(),range:i},t)}})}}let x={ignoreHidden:!1,fullyContained:!1};for(let e=0;e<g;e++){let n=u[e],r=a._getRangedEntries(_.conditionalFormats,[n],x,!0),i=r.length;for(let e=0;e<i;e++){let i=r[e],s=i.getRanges().getCoords(),c=[];for(let e=0;e<s.length;e++){let t=h.intersectRanges(s[e],n);t&&c.push(t)}if(c.length===0)continue;let u=i.getSnapshot(t),d=e;l.push({copyTo(e,r){let i={...t,...r};if(i.type&&i.type!==$.Content.Formats||!i.isCut&&(a.getProtection().isLocked()||e.getWorksheet().getProtection().isLocked()))return null;let s=e.getWorksheet(),l=iF(c,n,e.getCoords(),!!i.transpose);return l.length===0?null:u.copyTo({conditionals:s.getConditionalFormats(),range:l[0],ranges:l,extend:s===o,index:d},r)}})}let s=a._getRangedEntries(_.dataValidations,[n],x,!0),c=s.length;for(let e=0;e<c;e++){let r=s[e],i=r.getRanges().getCoords(),c=[];for(let e=0;e<i.length;e++){let t=h.intersectRanges(i[e],n);t&&c.push(t)}if(c.length===0)continue;let u=r.getSnapshot(t),d=e;l.push({copyTo(e,r){let i={...t,...r};if(i.type||!i.isCut&&(a.getProtection().isLocked()||e.getWorksheet().getProtection().isLocked()))return null;let s=e.getWorksheet(),l=iF(c,n,e.getCoords(),!!i.transpose);return l.length===0?null:u.copyTo({validations:s.getDataValidations(),range:l[0],ranges:l,extend:s===o,index:d},r)}})}let d=a._getRangedEntries(_.cellControls,[n],x,!0);for(let e=0;e<d.length;e++){let r=d[e],i=r.getRanges().getCoords(),o=[];for(let e=0;e<i.length;e++){let t=h.intersectRanges(i[e],n);t&&o.push(t)}if(o.length===0)continue;let s=r.toJSON();l.push({copyTo(e,r){let i={...t,...r};if(i.type&&i.type!==$.Content.Formats||!i.isCut&&(a.getProtection().isLocked()||e.getWorksheet().getProtection().isLocked()))return null;let c=iF(o,n,e.getCoords(),!!i.transpose);return c.length===0?null:(e.getWorksheet()._getInternal().setCellControl(c,s,r),h.unionRangesArrays(c))}})}let f=a._getRangedEntries(_.sparklineGroups,[n],x,!0);for(let e=0;e<f.length;e++){let r=f[e],i=r._rangesWithin(n);if(i.length===0)continue;let s=r._rangesNow(),c=r.getProperties();l.push({copyTo(e,l){let u={...t,...l};if(u.type||u.transpose||!u.isCut&&(a.getProtection().isLocked()||e.getWorksheet().getProtection().isLocked()))return null;let d=e.getWorksheet(),f=d===o,p=YO(i,n,e.getCoords(),{isCut:!!u.isCut,sourceSheet:f?null:o});if(p.length===0)return null;if(u.isCut&&f&&d._getState().sparklineGroups.getCoords(r)){let t=e.getCoords();r._putBackCut(p,s,t.rowStart-n.rowStart,t.colStart-n.colStart)}else d._addSparklineGroup(p,c,l);return h.unionRangesArrays(p.map(e=>e.location))}})}}let S=u[0];return function(e,t,n,r,i,a,o=null){return{prepare:(t,n)=>aF(e,t,{...i,...n}),copyTo(n,o){let s=null,c={...i,...o},l=n.getWorksheet(),u=l._beginCommit({description:c.description??a,operation:{name:`copyTo`}});try{let i=e.length;for(let t=0;t<i;t++){let r=e[t].copyTo(n,c);r&&(s=h.unionRanges(s,r))}let a=c.undoRange?.getCoords()??(c.isCut&&l===t?r:null);l._recordSelection(u,SD([s??n.getCoords()]),c,a?SD([a]):null),u.commit()}catch(e){throw u.rollback(),e}return s},getMarkOptions:()=>i,getName:()=>N(a),getSource:()=>t,getCoords:()=>r,toText(){let t=o?.toText?.()??null,n=e.length;for(let r=0;!t&&r<n;r++)t=e?.[r].toText?.();return t??null},toHtml(){let t=o?.toHtml?.()??null,n=e.length;for(let r=0;!t&&r<n;r++)t=e?.[r].toHtml?.();return t??null},toImage(){let t=o?.toImage?.()??null,n=e.length;for(let r=0;!t&&r<n;r++)t=e?.[r].toImage?.();return t??null},isISnapshot:!0}}(l,o,0,S,t,c,v)}_copyRange(e,t,n,r,a,o){if(n.length>1)throw new k(N(`error.sheet.insertCopyMultipleRanges`));if(!n||n.length===0)throw new k(N(`error.sheet.copyNoSource`));let s=r.getWorksheet(),c=r.getCoords(),l={...n[0]},u=(a={...a}).isCut,d=!a.type||a.type===$.Content.Formats,f=!a.type||a.type===$.Content.Values,p=!a.type||a.type===$.Content.Formats||a.type===$.Content.Hyperlinks;s.getProtection().isLocked()&&!u&&(d=!1,p=!1);let g=s.getEntireRange(),_=g.getCoords(),v=[],y=[],b=[],x=[],S=[],C=(a.fitDestination??!1)&&!h.isSingleCell(c),w=c;if(C&&(l={...l,colEnd:l.colStart+Math.min(w.colEnd-w.colStart,l.colEnd-l.colStart),rowEnd:l.rowStart+Math.min(w.rowEnd-w.rowStart,l.rowEnd-l.rowStart)}),!h.isRangeWithinRange(w,_))throw console.warn(w,_),new k(N(`error.sheet.pasteOob`));let T=a.undoRange?SD([a.undoRange.getCoords()]):null,E=s.getTransactions().beginCommit({description:a.description??m(`op.paste`)});try{if(!this._getState())return i.EmptyArray;let n=new Set,r=a.transpose,m=!((r||a.adjustCells)&&d)&&n.size===1;if(m){let e=n.values().next();m=h.isRangeWithinRange(l,e.value.getCoords())&&!qz(l,e.value.getCoords())}m&&=s.getTables().getItems({address:w}).length===0,r&&(m=!0),o.singleMerge&&(d=!1,p=!1);let _=c.colStart-l.colStart,C=c.rowStart-l.rowStart,D=a.adjustCells,O={...Kf};if(delete O[G.Type.BorderStyle],delete O[G.Type.FillStyle],delete O[G.Type.ContentStyle],!d){let e=this.getProtection().isLocked();O={},e&&(O[G.Type.Unlock]=!1)}let k=B.Axis.Column,A;if(f){A=g.createSparseBuilder({axis:a.transpose?B.Axis.Row:B.Axis.Column});let e={axis:k,searchTypes:O,bounds:l},t=new Xz(this._strings,e,this._cellOptions),n=(e,n,i)=>{let o=e[0],s=t.setState(e),u=t.context,h=u.getCell(),g=h.isTopLeft(),y=C,b=_;if(r){let e=o.colIndex-l.colStart,t=o.rowIndex-l.rowStart;y=e+i+c.rowStart,b=t+n+c.colStart}else y=C+o.rowIndex+n,b=_+o.colIndex+i;let x=!1,S={value:void 0,style:void 0,hyperlink:void 0};if(f&&(S.value=a.type===$.Content.Values&&!0===s?.isIRichData?ku.toPrimitive(s)??s:s,x=!0),d){let t=e[2];t&&(t.borderStyle||t.fillStyle||t.contentStyle||t.table||t.pivot)&&(S.style=h.getStyle(!m&&!t.pivot),x=!0)}p&&(S.hyperlink=e[2]?.hyperlink??null,x=!0);let w=S;if(D&&g){let e=D(s,u,{rowIndex:y,colIndex:b},a);e!==void 0&&(w=e,x=!0)}if(x&&(A.pushAt(y,b,w),d)){let e=h.getSpans();(e.width>1||e.height>1)&&g&&v.push({colStart:b,rowStart:y,colEnd:b+(a.transpose?e.height:e.width)-1,rowEnd:y+(a.transpose?e.width:e.height)-1})}},i=this._cellStateIterator(e),s={next(){let e=i.next();if(e.done)return yo;let t=e.value[0],n;return e.value&&(n=[t,e.value]),{done:e.done,value:n}}};if(!o.singleMerge&&!h.isEqualRanges(w,l)){let e=w.colEnd-w.colStart+1,t=w.rowEnd-w.rowStart+1;s=new Rc({delegate:s,bounds:l,axis:k,dims:{major:a.transpose?t:e,minor:a.transpose?e:t}})}let u=s.next();for(;!u.done;){let e=u.value,t=e[1],r=e[0],i=t[0];n(t,r.rowIndex-i.rowIndex,r.colIndex-i.colIndex),u=s.next()}}let j=t._getState(),M={},N={transpose:r??!1};d&&(M.borderSpatial=j.borderSpatial,M.fillSpatial=j.fillSpatial,M.contentSpatial=j.contentSpatial,M.continuousFillSpatial=j.continuousFillSpatial,M.mergeSpatial=j.mergeSpatial),u&&(e._clear([l],void 0,void 0,!1,l),x.push(l));let ee=s,te=ee._getState(),P=Object.keys(M),F=P.length;for(let e=0;e<F;e++){let t=P[e],n=M[t].createCopiedEntries(l,w,N),r=te[t].clone(),i=n.removes,a=i.length;for(let e=0;e<a;e++)r.remove(i[e]);r.load(n.inserts),te[t]=r}ee._updateState(te),x.push(w),S.push(w),y&&y.length>0&&ee._colHeaders.updateHeaderPairs(y),b&&b.length>0&&ee._rowHeaders.updateHeaderPairs(b),A?.apply(),v.length>0&&s.getRanges(v).merge(),ee._recordSelection(E,SD(S),a,T),ee._recordChange(E,`data`,x),E.commit()}catch(e){throw console.warn(e),E.rollback(),Error((D=e.message,N(`error.sheet.paste`,{message:D})),{cause:e})}var D;return h.unionRangesArrays(S)}_snapShotFromSource(e,t){if(e.isISnapshot)return e;let n=e,r=null;if(n?.isICellRanges)throw new k(N(`error.sheet.copyMultipleRanges`));if(n?.isICellRange)r=n;else{let e=this.getWorkbook();r=typeof n==`string`&&n.includes(`!`)&&e?e.getRange(n):this.getRange(n)}if(r.isICellRange){let e=r;if(e.isInvalid())throw new k(N(`error.sheet.copyInvalidSource`));return e.getSnapshot(t)}throw new k(N(`error.sheet.copyInvalidSource`))}_copyFrom(e,t,n){if(!t)throw new k(N(`error.sheet.copyMissingArgs`));let r=this._snapShotFromSource(t,n),i=r.prepare?.(this.getRange(e),n);return vR(i)?i.then(()=>this._copyFromNow(e,r,n)):Promise.resolve(this._copyFromNow(e,r,n))}_copyFromNow(t,n,r){let i=m(`op.paste`),a=this._beginCommit({description:r?.description??i,operation:{name:`copyFrom`}}),o=r?.isCut??n.getMarkOptions?.()?.isCut;try{let s=this._resolveCopyDestination(t,n,r,o??!1),c=o?n.getSource?.():void 0,l=o?n.getCoords():null,u=!!c&&(this.getProtection().isLocked()||c.getProtection().isLocked());if(u){let e=c.getTables().getItems({address:l});if(r?.type!==void 0||e.length>0||c._getMerges([l]).length>0)throw new b(N(`error.sheet.protectedSheet`));this._assertContentEditable([s],!1)&&this._recordSkipProtectionCheck(a),c._assertContentEditable([l],!1)&&c!==this&&c._recordSkipProtectionCheck(a)}else if(this.getProtection().isLocked()){let e=r?.type;if(o||e!==void 0&&e!==$.Content.Values&&e!==$.Content.Formulas)throw new b(N(`error.sheet.protectedSheet`));this._assertContentEditable([s]),this._recordSkipProtectionCheck(a)}let d=this.getRange(s),f=c instanceof e&&this._cutPivots(c,l,{rowStart:s.rowStart,colStart:s.colStart,rowEnd:s.rowStart+l.rowEnd-l.rowStart,colEnd:s.colStart+l.colEnd-l.colStart}),p;u&&(this._isMoveRuled=c._isMoveRuled=!0);try{p=n.copyTo(d,r)}finally{u&&(this._isMoveRuled=c._isMoveRuled=!1),f&&this._landPivots()}if(f&&(c._tellPivots(),c!==this&&this._tellPivots()),vR(p))throw Error(`A snapshot's 'copyTo' must copy synchronously; anything it waits for belongs in 'prepare'.`);u&&FF(c._getMutationCtx(),[l],{protection:{alwaysUnlocked:!0}},void 0,!1,!0);let m=n.getName?.(),h=p?[p]:[];o&&h.push(n.getCoords());let g=r?.undoRange?.getCoords()??(o&&n.getSource?.()===this?n.getCoords():null);return this._recordChange(a,`data`,h),this._commitWithDirectives(a,SD([p??s]),r,{undo:g?SD([g]):void 0,commit:{description:m?r?.description??N(`op.pasteNamed`,{name:m}):i}}),p}catch(e){throw a.rollback(),e}}_resolveCopyDestination(e,t,n,r){let a=t.getCoords();r&&(e=h.cellToRange({rowIndex:e.rowStart,colIndex:e.colStart}));let o=hD(e,a,n?.fitDestination,n?.transpose),s=this._getMerges([e]);if(!r&&s.length===1&&h.isEqualRanges(s[0],e)){let n=t.getSource?.()?.getRange(a).getMerges()??i.EmptyArray;(h.isSingleCell(a)||n.length===1&&h.isEqualRanges(n[0],a))&&(o=e)}let c=this._getMerges([o]).filter(e=>!h.isRangeWithinRange(e,o));if(c.length===0)return o;let l=t.getSource?.()===this;if(!r||l&&c.some(e=>h.isRangeWithinRange(e,a)))throw new k(N(`error.sheet.pasteMergePartial`));return this._unmerge(c),o}addAutoTable(e,t){e||=this.getSelectedRange().getCoords();let n=this._rangeToCoords(e);if(n=this._surroundingRegion(n,{contentOnly:!0}),h.isSingleCell(n)&&!this._isContentful([n]))throw new k(N(`error.sheet.tableEmpty`));n=this._rangeToCoords(n,()=>[`sort`,`autoTable`]);let r=this._getEntireCoords();if(n.rowStart===n.rowEnd){if(n.rowEnd===r.rowEnd)throw new k(N(`error.sheet.table1By1`));n.rowEnd+=1}let i={...n},a=m(`op.insertAutoTable`),o=this._beginCommit({description:t?.description??a}),s;try{let e={...t?.properties,style:null};this._validateOrRemoveOverlaps(n,`table`,null,t?.replaceExisting??!1);let r=this._getState().autoTables;r=this._createTables(r,`autoTables`,[{r:n,v:e}],e=>{let t=new By(e);return s=t,t}),this._updateState({autoTables:r}),this._tellFiltered(),this._notify(`onAutoTableChange`),this._notifyTablesChange();let a=SD([n]);this._recordSelection(o,a,t),this._recordChange(o,`anchored`,[i,n]),o.commit()}catch(e){throw o.rollback(),e}return s}getAutoTable(){let e=this._getState();if(!e)return null;let t=e.autoTables.all();return t.length===0?null:t[0]}_filteredTables(){let e=[],t=this.getAutoTable();t&&t.getActiveFilters().length>0&&e.push(t);let n=this._tables.getItems();for(let t=0;t<n.length;t++)n[t].getActiveFilters().length>0&&e.push(n[t]);return e}_tellFiltered(){if(this._closed||!this._ownsCalcGrid)return;let e=this._transactions.getCurrentTransaction(),t=this._calcGrid;e&&t&&t.setFiltered(this._filteredTables().length>0,this._requestFor(e))}_landPivots(){let e=this._pivotsInTransit;if(e){this._pivotsInTransit=null;for(let t of e)t._setSettling(!1);this._unblockPivots(e)}}_pivotObstructionOf(e,t,n){let r=[...t];for(let e of n){let t=[];for(let n of r)t.push(...uD(n,e));r=t}if(r.length===0)return null;let i=this._getState().pivotTables.all().filter(t=>t!==e);for(let e of r)for(let t of i)if(t._getOwnCells().some(t=>h.isRangesIntersect(t,e)))return`pivot`;let a=this._calcGrid.getSpills();for(let e of r)if(a.search(e).some(e=>e.value.getKind()!==`pivot`))return`array`;let o=this._calcGrid.getValues();for(let e of r){let t=o.getValues(e);if(t){for(let[,e]of t.tuples)for(let[,t]of e)for(let e=0;e<t.length;e++)if(t.at(e)!=null)return`value`}}return null}async _addPivotTable(e,t,n){if(this.getProtection().isLocked())throw new b(N(`error.sheet.protectedSheet`));let r=this.getWorkbook(),i=r._pivotSourceOf(e,this),a=i?await r._pivotSourceRangeOf(i):null;if(!i||!a)throw new k(N(`error.pivotTable.sourceNotFound`));if(a.getRowCount()<2)throw new k(N(`error.pivotTable.refreshSourceTooSmall`));let o=await vC.load(),s=n?.name??this._nextPivotName(r);this._assertPivotName(s,null);let c=this._pivotAnchorAt(t,n?.pages?.length??0,null),l=r._findPivotCache(i),u;l?u=l._getData().model:(a.getWorksheet()._cellBuffer?.release(),u=o.newPivotCache(o.readPivotSource(a),i,this.getRuntime().isDate1904()));let d=o.newPivotTable({cacheId:0,...u},n),f=o.withListedFields(u,o.axisFieldsOf(d)),p;return await r.doBatch(async()=>{let e=l;e?f!==u&&e._replace(f):e=r._addPivotCache(f);let t=this._beginCommit({description:m(`op.addPivotTable`)}),i={...d,name:s,cacheId:e.cacheId,location:zd(c)},a=this._createPivotTables(this._getState().pivotTables,`pivotTables`,[{r:c,v:i}]);this._updateState({pivotTables:a}),t.commit(),p=a.all().find(e=>e.getName()===s),await p._prepareFilters(o),p._refreshFrom(o,void 0,{discardValues:n?.discardValues??!1})},{description:m(`op.addPivotTable`),...n}),this._notifyPivotTablesChange(),p}_assertPivotName(e,t){if(typeof e!=`string`||e.length===0||e.length>255)throw new k(N(`error.pivotTable.nameInvalid`));if(this._getState().pivotTables.all().some(n=>n!==t&&fS(n.getName(),e)))throw new k(N(`error.pivotTable.nameExists`))}_pivotAnchorAt(e,t,n){let r=typeof e==`string`?gR(e):null;if(r?!fS(r.sheet,this.getName()):!0===e.isICellRange&&e.getWorksheet()!==this)throw new k(N(`error.pivotTable.moveToSheet`));let i=this._rangeToCoords(r?r.reference:e),a=Math.max(i.rowStart,t>0?t+1:0),o={rowStart:a,colStart:i.colStart,rowEnd:a,colEnd:i.colStart};if(this._getState().pivotTables.search(o).some(({value:e})=>e!==n&&e._getOwnCells().some(e=>h.isRangesIntersect(e,o))))throw new k(N(`error.pivotTable.overlapsPivot`));return o}_nextPivotName(e){let t=0;for(let n of e.getPivotTables().getItems()){let e=/^PivotTable(\d+)$/i.exec(n.getName())?.[1];e&&(t=Math.max(t,parseInt(e,10)))}return`PivotTable${t+1}`}_getPivotCellOrder(){return this._isDataColumn?`columns`:`rows`}_writePivotCells(e,t,n){let r=this._getMutationCtx(),i=this.getProtection().isLocked();if(i&&this._recordSkipProtectionCheck(this._transactions.getPendingTransaction()),e.length>0){let t=this._isMoveRuled;this._isMoveRuled||=i;try{oI(r,e,$.Content.Values),FF(r,h.sanitizeRangeArray(e),null,void 0,!1,i)}finally{this._isMoveRuled=t}}if(t.length===0)return;let[a,o]=this._isDataColumn?[n.column,n.row]:[n.row,n.column],s=new Lo.Builder;for(let[e,n]of t)for(let[t,r]of n)s.pushMultipleAt(a+e,o+t,r);nI(r,s.build(),{textParser:!1},null,{isPivotLayout:!0})}_pivotsWaitingOn(e){let t=this._getState().pivotTables;if(t.isEmpty())return null;let n=null;for(let r of t.all()){let t=r;if(!t._isBlocked()||t._isSettling())continue;let i=t._getWanted();i&&i.cells.some(t=>e.some(e=>h.isRangesIntersect(t,e)))&&(n??=[]).push(t)}return n}_unblockPivots(e){let t=vC.peek();if(!t)return;let n=this.getProtection();if(!n.isLocked()||n.isPivotTablesAllowed())for(let n of e){if(n.isDeleted()||!n._isBlocked())continue;let e=n._getWanted();e&&!this._pivotObstructionOf(n,e.cells,n._getOwnCells())&&(n._getFilterResult()===void 0?n._prepareFiltersOnce(t).then(()=>{n._getFilterResult()!==void 0&&this.doBatch(()=>this._unblockPivots([n]))}).catch(e=>this._calculation._reportError(e)):n._refreshFrom(t))}}_autoFitPivotColumns(e){this._autoFit([e],{axes:B.AxisSelection.Column,within:!0,description:``})}_tellPivots(){if(this._closed||!this._ownsCalcGrid||!this._calcGrid)return;let e=this._getState().pivotTables.all();if(e.length===0&&!this._pivotsTold)return;let t=vC.peek();if(!t&&e.some(e=>e._isModeled()))return void vC.load().then(()=>this._tellPivots()).catch(e=>{this._calculation._reportError(e)});let n=this.getWorkbook(),r=this.getRuntime(),i=[];for(let a of e){let e=a,o=t&&e._isModeled()?e._getFilterResult():null;t&&o===void 0&&e._prepareFiltersOnce(t).then(()=>{e._getFilterResult()!==void 0&&this._tellPivots()}).catch(e=>this._calculation._reportError(e));let s=t&&e._isModeled()&&o!==void 0?e._getPivotView((i,a,s)=>{let c=n?._getPivotCache(i.cacheId)?.toJSON();return c?t.buildPivotView(i,c,a,r,s,o,e._slicerFields()):null}):null;if(s){i.push(s);continue}let{rowStart:c,colStart:l,rowEnd:u,colEnd:d}=a.getRange().getCoords();i.push({range:{rowStart:c,colStart:l,rowEnd:u,colEnd:d},dataFields:[],fields:[],values:[],computed:!1})}this._pivotsTold=i.length>0,this._calcGrid.setPivots(i,this._requestFor(this._transactions.getCurrentTransaction()))}_cutPivots(e,t,n){let r=e._getState().pivotTables,i=this._getState().pivotTables;if(r.isEmpty()&&i.isEmpty())return!1;let a=((e,t)=>{let n={moves:[],covered:[]},r=e.pivotTables.search(e.coords);for(let t=0;t<r.length;t++){let i=r[t].value,a=eD(i);if(a&&CF(a.cells,[e.coords])){if(!h.isRangeWithinRange(a.extent,e.coords))throw new k(N(`error.pivotTable.shiftPartial`));n.moves.push({table:i,extent:a.extent})}}let i=t.pivotTables.search(t.coords);for(let e=0;e<i.length;e++){let r=i[e].value;if(n.moves.some(e=>e.table===r))continue;let a=eD(r);if(a&&CF(a.cells,[t.coords])){if(!a.cells.every(e=>h.isRangeWithinRange(e,t.coords)))throw new k(N(`error.pivotTable.shiftPartial`));n.covered.push(r)}}return n})({pivotTables:r,coords:t},{pivotTables:i,coords:n}),o=a.moves;if(o.length===0&&a.covered.length===0)return!1;if(o.length>0&&e!==this)throw new k(N(`error.pivotTable.moveToSheet`));let s=n.rowStart-t.rowStart,c=n.colStart-t.colStart;for(let e=0;e<o.length;e++){let n=o[e].extent,r={rowStart:n.rowStart+s,colStart:n.colStart+c,rowEnd:n.rowEnd+s,colEnd:n.colEnd+c};if(this.getTables().getItems({address:r}).filter(e=>!h.isRangeWithinRange(e.getRange().getCoords(),t)).length>0)throw new k(N(`error.pivotTable.overlapsTable`))}this._protectionCheck(()=>[`pivotTables`],[n],m(`op.updateAnchor`));for(let e=0;e<a.covered.length;e++)a.covered[e].delete();if(o.length===0)return!0;let l=this._getState().pivotTables;for(let e=0;e<o.length;e++){let t=o[e].table;t._holdLocation(),t._setSettling(!0),(this._pivotsInTransit??=[]).push(t);let n=t.getFirstAnchorCoords();l=l.setCoords(t,[{rowStart:n.rowStart+s,colStart:n.colStart+c,rowEnd:n.rowEnd+s,colEnd:n.colEnd+c}])}return this._updateState({pivotTables:l}),!0}_getSpillAt(e,t){let n=this._calcGrid?.getSpills();if(!n||n.isEmpty())return null;let r=n.search({rowStart:e,colStart:t,rowEnd:e,colEnd:t});for(let n=0;n<r.length;n++)if(r[n].value.isAnchor(e,t))return r[n].value;return null}_getDefaultShiftAxis(e){return function(e,t){if(t){if(e.colStart<=t.colStart&&e.colEnd>=t.colEnd)return B.Axis.Row;if(e.rowStart<=t.rowStart&&e.rowEnd>=t.rowEnd)return B.Axis.Column}return e?function(e){return e.rowEnd-e.rowStart>e.colEnd-e.colStart?B.Axis.Column:B.Axis.Row}(e):B.Axis.Row}(e,this._getEntireCoords())}_getTables(e,t=!1,n=!1){let r=e?this._rangeToCoords(e):this._getEntireCoords(),a=this._getState();return a?this._getRangedEntries(a.tables,[r],{ignoreHidden:t,fullyContained:n,onEntry:e=>e.model}):i.EmptyArray}_getDefaultAutoFillCriteria(e,t,n){return MI(this,e,t,n)}_getDefaultSortCriteria(e,t=B.Axis.Row,n){let r=(n?this._cellToCoords(n):null)??fD(e),i=h.cellToRange(r),a=this._getTables(i)[0]??null,o=!1;if(!a){let e=this.getAutoTable();e&&e.getRange().getIntersect(i)&&(a=e,o=!0)}let s=function(e,t,n,r=B.Axis.Row){let i=e.getRange(t,{ignoreHidden:r}),a=i.forEach((e,t)=>({break:t.getCoords()}),{features:[],axis:r});if(!a)return;let o=r===B.Axis.Row,s=new Map,c,l=new Map,u=null,d=o?a.rowIndex:a.colIndex;i.forEach((e,t)=>{let n=t.getCoords(),r=o?n.colIndex:n.rowIndex;if((o?n.rowIndex:n.colIndex)===d)s.set(r,e),c=t.getType();else{let e=t.getType();c!==U.Null&&e!==U.Null&&c!==e&&(u=!0)}if(u)return zf},{axis:r===B.Axis.Row?B.Axis.Column:B.Axis.Row,features:[],includeEmpty:!0,address:{colStart:a.colIndex,rowStart:a.rowIndex,colEnd:o?t.colEnd:a.colIndex+1,rowEnd:o?a.rowIndex+1:t.rowEnd}});let f={colStart:a.colIndex,rowStart:a.rowIndex,colEnd:t.colEnd,rowEnd:t.rowEnd};if(f.colStart>f.colEnd||f.rowStart>f.rowEnd||h.isSingleCell(f))return null;if(u){let e=o?f.colStart:f.rowStart;s.forEach((t,n)=>{n<e||l.set(n-e,t+``)})}let p={colIndex:Math.min(Math.max(n?.colIndex??0,f.colStart),f.colEnd),rowIndex:Math.min(Math.max(n?.rowIndex??0,f.rowStart),f.rowEnd)},m=r!==B.Axis.Row,g={...Au.DefaultRangeOptions,hasHeader:u,axis:r,sorts:[{index:m?p.rowIndex-f.rowStart:p.colIndex-f.colStart}]},_=f;return u&&(_={colStart:m?f.colStart+1:f.colStart,rowStart:m?f.rowStart:f.rowStart+1,colEnd:f.colEnd,rowEnd:f.rowEnd}),{coords:f,options:g,headers:l,sortCoords:_}}(this,e,r,t);if(!s)return s;if(a){let e=a.getActiveSorts(),n=[];for(let t=0;t<e.length;t++)n.push({index:e[t].getIndex(),criteria:e[t].getCriteria()});let i=a.getRange().getCoords(),c=a.getSortAt(r.colIndex-i.colStart),l=c.getCriteria();n.length===0&&n.push({index:c.getIndex(),criteria:l}),s.options.sorts=n,l!==null&&(s.options.reverse=l.reverse,s.options.collatorOptions=l.collatorOptions);let u=o?a.getDataRange().getCoords():null,d=u?u.rowStart>i.rowStart:a.isShowHeaders();if(!o){let e=new Map;if(d){let t=a.getColumns();for(let n=0;n<t.length;n++)e.set(n,t[n].getName())}s.headers=e}s.options.hasHeader=d;let f=t!==B.Axis.Row;s.sortCoords=d?{...s.coords,colStart:f?Math.min(s.coords.colStart+1,s.coords.colEnd):s.coords.colStart,rowStart:f?s.coords.rowStart:Math.min(s.coords.rowStart+1,s.coords.rowEnd)}:s.coords}return s}_getInsertFromRefusal(e,t,n,r,i){if(r&&i){let r=h.classifyInsertCut(t,e,n);if(r===h.InsertCutShift.Inside)return N(`error.sheet.insertCutInside`);if(r===h.InsertCutShift.Tear)return N(`error.sheet.insertCutOverlap`)}let a=this._getState();if(!a)return null;let o=n===B.Axis.Row,s=this._getEntireCoords(),c=o?{colStart:e.colStart,colEnd:e.colEnd,rowStart:e.rowStart,rowEnd:s.rowEnd}:{rowStart:e.rowStart,rowEnd:e.rowEnd,colStart:e.colStart,colEnd:s.colEnd},l=o?B.AxisSelection.Row:B.AxisSelection.Column,u=a.mergeSpatial.search(c);for(let t=0;t<u.length;t++){let n=u[t];if(Ec(e,n,l)||(o?e.rowStart>n.rowStart&&e.rowStart<=n.rowEnd:e.colStart>n.colStart&&e.colStart<=n.colEnd))return N(`error.sheet.insertMergeThrough`)}let d=this._getTables(c);for(let t=0;t<d.length;t++)if(Ec(e,d[t].getRange().getCoords(),l))return N(`error.table.tableSplit`);return null}_canInsertFrom(e,t,n){if(!t||!e?.length)return!1;let r=null,i=this,a=t;if(a.isISnapshot)r=a.getCoords?.()??null,i=a.getSource?.()??null;else{let e=t,n=e?.isICellRange?e:null;if(!n){let t=this.getWorkbook();n=typeof e==`string`&&e.includes(`!`)&&t?t.getRange(e):this.getRange(e)}if(!n||n.isInvalid())return!1;r=n.getCoords(),i=n.getWorksheet()}if(!r)return!1;let o=hD(e[0],r,n?.fitDestination),s=n?.axis??this._getDefaultShiftAxis(o);return this._getInsertFromRefusal(o,r,s,n?.isCut??!1,i===this)===null}_insertFrom(e,t,n){if(!t)throw new y;let r=this._snapShotFromSource(t),i=r.prepare?.(this.getRange(e[0]),n);return vR(i)?i.then(()=>this._insertFromNow(e,r,n)):Promise.resolve(this._insertFromNow(e,r,n))}_insertFromNow(e,t,n){let r=t.getCoords(),i=hD(e[0],r,n?.fitDestination),a=SD([i]),o=a,s=n?.axis??this._getDefaultShiftAxis(i),c=s===B.Axis.Row,l={...r},u=n?.isCut??!1,d=this===t.getSource(),f=this._getInsertFromRefusal(i,l,s,u,d);if(f)throw new k(f);let p=u&&d&&h.classifyInsertCut(l,i,s)===h.InsertCutShift.Close,g=this._beginCommit({description:n?.description??m(`op.insertCopiedCells`),operation:{name:`insertFrom`}});try{this._insertCells([i],s);let u=c?i.rowStart<=l.rowStart:i.colStart<=l.colStart;if(p&&u){if(c){let e=l.rowEnd-l.rowStart+1;l.rowStart+=e,l.rowEnd+=e}else{let e=l.colEnd-l.colStart+1;l.colStart+=e,l.colEnd+=e}}let d=p&&this._cutPivots(this,l,i);try{this._copyFromNow(i,t,{...n,isCut:(n?.isCut??!1)&&!p})}finally{d&&this._landPivots()}if(n?.isCut){if(a=SD([r]),i={...i},p){if(!u){if(c){let e=l.rowEnd-l.rowStart+1;i.rowStart-=e,i.rowEnd-=e}else{let e=l.colEnd-l.colStart+1;i.colStart-=e,i.colEnd-=e}}t.getSource().getRanges([l]).delete(s),d&&this._tellPivots()}o=SD([i])}this._recordChange(g,`address`,e),this._commitWithDirectives(g,o,n,{undo:a})}catch(e){throw g.rollback(),e}return i}_insertCells(e,t,n){this._shiftCells(e,t,!0,n)}_deleteCells(e,t){this._shiftCells(e,t,!1)}_shiftCells(e,t,n,r){let i=this._getMutationCtx(),a=this._getState().entireFit,o=t===B.Axis.Row||t===B.Axis.Column,s=o?void 0:t,c=(o?t:s?.axis??this._getDefaultShiftAxis(e[0]))===B.Axis.Column;if(!(c?a?.width:a?.height)||e.length===0)return void AF(i,e,t,n,r);let l=this._beginCommit({description:s?.description??m(n?`op.insertCells`:`op.deleteCells`),operation:{name:n?`insertCells`:`deleteCells`}});try{if(n){let t=0;for(let n=0;n<e.length;n++){let r=e[n];t+=c?r.colEnd-r.colStart+1:r.rowEnd-r.rowStart+1}let n=this._getEntireSize();this._resizeEntire(c?{...n,width:n.width+t}:{...n,height:n.height+t},l)}AF(i,e,t,n,r);let a=this._getEntireSize(),o=this._getFittedSize();this._resizeEntire(c?{...a,width:o.width}:{...a,height:o.height},l),l.commit()}catch(e){throw l.rollback(),e}}_processLayoutChange(){let e=this._getState();if(!e)return;let t=this._isAdjustHeaders;this._isAdjustHeaders=!0;try{this._colHeaders._invalidateExtent(),this._rowHeaders._invalidateExtent()}finally{this._isAdjustHeaders=t}this._cellOptions?.renderCellCache?.clear();let n=[...e.movableSpatial.all(),...e.noteSpatial.all()],r=n.length;for(let e=0;e<r;e++)n[e].value.callbacks?.processLayout?.();this._glueStrayConnectors(),this._notify(`onLayoutChange`)}_autoFit(e,t,n=!1){let r=Gl.getShared();if(!jl.isLoaded())return this._pendingFits.push({ranges:e,options:t,ran:!1}),void(this._engineWait??=jl.load().then(()=>{this._engineWait=null,this._closed||r.isLoading()||this._runPendingFits()},()=>{this._engineWait=null}));if(n&&r.isLoading())return void this._pendingFits.push({ranges:e,options:t,ran:!1});let i=r.loadingAnswers;eP(this,e,t),r.loadingAnswers!==i&&this._pendingFits.push({ranges:e,options:t,ran:!0})}_runPendingFits(){let e=this._pendingFits;if(this._pendingFits=[],e.length===0)return!1;this._invalidateRendering(null);for(let t of e)this._autoFit(t.ranges,t.ran?{...t.options,skipCustomSize:!0,description:``}:t.options);return!0}_getBestFit(e,t){return function(e,t,n){let r=e;if(r._closed)throw Error(N(`error.sheet.modelClosed`));let i=n?.axes!==B.AxisSelection.Row,a=n?.axes!==B.AxisSelection.Column,o=r._colHeaders,s=r._rowHeaders,c=r._defaultRowHeight()*I.getDeviceScale(),l={host:r,cellOptions:r._cellOptions,normalStyle:r._styles.getNormal(),isRow:a,isColumn:i,isRowAxis:n?.axes===B.AxisSelection.Row,minContent:n?.minContent??!1,isFormulaView:JN(r,n),mapCache:new Map},{segments:u,rowFloors:d,colFloors:f}=qN(l,t,t),p,m,h=null;if(i){let e=new Map;rP(f,e),XN(u,t,(t,n,r)=>{r>1||nP(e,t,n??0)}),h=e,p=oP(o,t.colStart,t.colEnd,aP(o,e,o.getMetrics().getDefaultSize()))}else p=o.getMetrics().getSpanSize(t.colStart,t.colEnd+1);if(a){if(h){let e=h,n=o.getMetrics().getDefaultSize(),r=YN(u,(t,r)=>{let i=0;for(let a=t;a<t+r;a++){let t=e.get(a);i+=t===void 0?FN(o,a):iP(o,t>0?t:n)}return i});r&&WN(l,r,t)}let e=new Map;rP(d,e),ZN(u,t,(t,n,r,i)=>{if(i>1)return;let a=r??0;for(let r=t;r<=n;r++)nP(e,r,a)});for(let[t,n]of e)n<c&&e.set(t,c);let n=aP(s,e,s.getMetrics().getDefaultSize());m=oP(s,t.rowStart,t.rowEnd,n)}else m=s.getMetrics().getSpanSize(t.rowStart,t.rowEnd+1);return{width:p,height:m}}(this,e,t)}_createRangeEvent(e,t,n,r){let i=this,a=e=>{if(!t.qualified||!i.getWorkbook())return e;let n=i.getName();return e.map(e=>({...e,scope:n}))},o=e=>{let n=t.qualified?i.getWorkbook():null;return n?n.getRanges(a(e)):i._createRanges(e)},s=e=>{let n=i._getState();if(i._closed||n.deleted)return Tz(null);if(!e)return Tz(i,i._getEntireCoords(),null,t.invalidError);if(t.collection)return o(e);let r=t.qualified?i.getWorkbook():null;return r?r.getRange(a(e)[0]):i._createRange(e[0])},c=t.trigger,l=t.timeStamp??Date.now();return{getSource:()=>s(e),getRanges:()=>c===`data`&&n?o(n):null,getPreviousAddress:()=>c===`address`&&r?s(r).getAddress():null,getEdits:()=>t.edits??JR,getTrigger:()=>c,isUndo:()=>t.isUndo??!1,getCommit:()=>t.commit,toString:()=>`SheetRangeEvent: ('${c}', ${s(e).toString()})`,getTimeStamp:()=>l}}_addListenerNode(e,t,n,r=!1){return this._registerListenerNode(e,t,n,void 0,r).remove}_registerListenerNode(e,t,n,r=qR,i=!1){if(this._closed)throw Error(N(`error.sheet.modelClosed`));if(!t)throw Error(N(`error.sheet.listenerNull`));let a={...AR,...n,transactional:n?.transactional??ae(this._transactions)},o=a.transactional&&ae(this._transactions)?re():null,s=this,c=UR++%(2**53-1),l=null;this._amendCurrent(()=>{let t=this._getState().listeners.load([{r:[...e],v:void 0}],{createModel:e=>(l=r({nodeId:c,listenerOptions:a,resolveRanges:e=>e?s.getRanges(e):Ez(s),getContainerCoords:()=>s._getState()?.listeners?.getCoords(l)??null}),e.setContainerCallbacks?.({processDelete:()=>{l?.delete()}}),l),addListeners:()=>KR});this._updateState({listeners:t})});let u={node:l,handler:a.weakly?null:t,handlerW:a.weakly?new WeakRef(t):null,collection:i,options:a,lastCoords:this._getState()?.listeners?.getCoords(l)??null,qualified:e.some(e=>!!e?.scope),batch:o};return this._listenerNodes.set(c,u),o&&this._hearBatchSteps(o),{node:l,remove:()=>{s._dropListenerEntry(u)}}}_dropListenerEntry(e){if(e.dropped)return;e.dropped=!0,this._listenerNodes.delete(e.node.getNodeId()),this._removeListenerNode(e.node);let t=e.twins;if(t)for(let e=0;e<t.length;e++)t[e].sheet._dropListenerEntry(t[e].entry)}_moveReferencesToSheet(e,t,n){if(this._closed||e._closed)return;let r=this._getState();if(!r)return;let i=n.rowStart-t.rowStart,a=n.colStart-t.colStart,o=r.listeners,s=[];this._listenerNodes.forEach(r=>{if(r.watch||r.dropped)return;let i=o.getCoords(r.node);if(!i)return;let a=!1,c=!0;for(let e=0;e<i.length;e++)h.intersectRanges(i[e],t)&&(a=!0),h.isRangeWithinRange(i[e],t)||(c=!1);a&&(c?(o=o.deleteModel(r.node),s.push({entry:r,coords:i})):r.node.noteMove(t,n,e))}),o!==r.listeners&&this._updateState({listeners:o});for(let r=0;r<s.length;r++){let{entry:o,coords:c}=s[r],l=c.map(e=>({rowStart:e.rowStart+i,colStart:e.colStart+a,rowEnd:e.rowEnd+i,colEnd:e.colEnd+a})),u=e._adoptListenerNode(o,l,c,t,n,this);(o.twins??=[]).push({sheet:e,entry:u})}if(!r.sparklineGroups.isEmpty()){let i=r.sparklineGroups.all();for(let r=0;r<i.length;r++)i[r]._moveData(t,n,e)}}_adoptListenerNode(e,t,n,r,i,a){let o=this,s=UR++%(2**53-1),c=null,l=this._getState().listeners.load([{r:[...t],v:void 0}],{createModel:t=>(c=new sP({nodeId:s,listenerOptions:e.options,resolveRanges:e=>e?o.getRanges(e):Ez(o),getContainerCoords:()=>o._getState()?.listeners?.getCoords(c)??null}),t.setContainerCallbacks?.({processDelete:()=>{c?.delete()}}),c),addListeners:()=>KR});this._updateState({listeners:l}),c.noteMove(r,i,this);let u={node:c,handler:e.handler,handlerW:e.handlerW,collection:e.collection,options:e.options,lastCoords:[...n],qualified:e.qualified,batch:e.batch,twins:[{sheet:a,entry:e}]};return this._listenerNodes.set(s,u),u}_addWatch(e,t,n,r,i){if(this._closed)throw Error(N(`error.sheet.modelClosed`));let a=this,o=null,s=!1,c=null,l=()=>{if(s||a._closed)return;let c=r??{rowIndex:e.rowStart,colIndex:e.colStart},l=typeof t==`string`?t:t.getExpression(),u=l.startsWith(`=`)?l.substring(1):l;o=a._registerWatch(e,u,c,n,!0===i?.arrayFirstCell,!0===i?.paged)};return this._calculation.getStatus()===Q.Status.Running?l():c=a._calculation.addListeners({onReady:()=>{c?.(),c=null,l()}},{transactional:!1}),()=>{s||(s=!0,c?.(),o?.())}}_registerWatch(e,t,n,r,i,a){let o=this,s=this.getId();this._ensureWatchAtCurrent(`added`);let c=this._calculation,l=`watch-${s}-${UR++%(2**53-1)}`,u=-1,d=!1,f=()=>{let e=o._listenerNodes.get(u);return!e?.watch||o._closed?null:{anchor:e.node,handlers:e.watch}},{host:p,removeNode:m}=this._amendCurrent(()=>{let p=c._createFormulaHost({id:l,shadowOf:s,arrayFirstCell:i,paged:a,sizeOf:s,onCalculated:e=>{let t=f();t&&t.anchor.deliver(e,t.handlers)}}),{node:m,remove:h}=this._registerListenerNode([e],()=>{f()?.anchor.reconcile()},{transactional:!0,ignoreDataChanges:!0},e=>new cP({...e,host:p}));return u=m.getNodeId(),this._listenerNodes.get(u).watch=r,p.setBody({coords:e,expression:t,authoredAt:n,scopeGridId:s}),this._transactions.beginCommit({savepoint:!1,onRollback:()=>{if(!d){d=!0,o._listenerNodes.delete(u),r.onRemoved?.();try{p.dispose()}catch(e){console.warn(e)}}}}).commit(),{host:p,removeNode:h}});return p.requestPass(),r.onRegistered?.(p),()=>{d||(d=!0,o._closed||o._ensureWatchAtCurrent(`removed`),m(),o._closed||o._amendCurrent(()=>{p.dispose()}))}}_ensureWatchAtCurrent(e){if(this._transactions.isAmendingOtherCommit())throw Error(`A watch can not be ${e} while amending a commit other than the current one.`)}_contentAddWatch(e){let t=this,n=this._calculation;return(r,i,a)=>{if(t._closed)throw Error(N(`error.sheet.modelClosed`));if(a?.evaluate)throw Error(`An evaluated content watch is not supported yet.`);let o=typeof r==`string`?r:r.getExpression(),s=o.startsWith(`=`)?o.substring(1):o,c=r instanceof pR?r:null,l=null,u=null,d=null,f=null,p=!1,m=null,g=()=>{if(p||t._closed)return;let e=l&&d?l.getBlock()?.getTextAt(d.rowIndex,d.colIndex)??null:null;if(e!==null&&e!==f){if(f=e,u)u._setLast(e);else{let n=t.getWorkbook()??t;u=new pR(l,d,e,{getRanges:n.getRanges.bind(n),getRange:n.getRange.bind(n),getCalcGrid:()=>l?._getCalcGrid()??null,getCalculationStatus:()=>t._calculation.getStatus(),resolveSheetScope:e=>t._resolveSheetScope(e),getOwnScope:()=>t.getName(),createAt:(e,n)=>t.getCalculation().createFormula(e,{...n,scope:t.getName()})})}try{i({formula:u})}catch(e){console.warn(e)}}},_=()=>{m?.(),m=null;let e=l;l=null,e&&!t._closed&&e._getCalcGrid()._isLive()&&t._amendCurrent(()=>{e.dispose()})};return n._whenSafe?.(async()=>{if(p||t._closed)return;d=a?.origin??c?.getAnchor()??e()??{rowIndex:0,colIndex:0};let r=t.getId(),i=d,o=null;try{let e=t._amendCurrent(()=>{let e=c?._getHostId(),t=e!==void 0&&!0===n._hasLiveGrid?.(e),a=t?e:`held-${r}-${UR++%(2**53-1)}`,o=n._createFormulaHost({id:a,unanchored:!0,arrayFirstCell:!0,sizeOf:r,onCalculated:()=>g(),onResync:()=>g()});return t?(o._resync(),{host:o,written:null}):{host:o,written:o.setBody({coords:h.cellToRange(i),expression:s,authoredAt:i,scopeGridId:r})}});l=e.host,o=e.written}catch{return}if(o&&await o.catch(()=>null),p||t._closed)p&&_();else{if(!l.getBlock())return t._amendCurrent(()=>{l.dispose()}),void(l=null);m=l._getCalcGrid().addListeners({onFormulasChanged:()=>g()}),g()}}),()=>{p||(p=!0,_())}}}_moveReferences(e,t){if(this._closed||e.colStart===t.colStart&&e.rowStart===t.rowStart)return;let n=this._getState();if(!n)return;this._listenerNodes.forEach(r=>{if(!r.options.edits)return;let i=n.listeners.getCoords(r.node);if(i){for(let n=0;n<i.length;n++)if(h.intersectRanges(i[n],e))return void r.node.noteMove(e,t)}});let r=n.listeners.copyTo({colIndex:t.colStart,rowIndex:t.rowStart},e,!0);if(r!==n.listeners&&this._updateState({listeners:r}),!n.sparklineGroups.isEmpty()){let r=n.sparklineGroups.all();for(let n=0;n<r.length;n++)r[n]._moveData(e,t)}}_removeListenerNode(e){let t=this._getState();t&&!this._closed&&t.listeners.getCoords(e)!==null&&this._amendCurrent(()=>{this._updateState({listeners:t.listeners.deleteModel(e)})})}_hearBatchSteps(e){let t=this._batchesHeard??=new WeakSet;if(t.has(e))return;t.add(e);let n=this._workbook?.getWorksheets().getItems()??[this];for(let e=0;e<n.length;e++)n[e]._cellBuffer?.release();let r=t=>t.batch===e;e.addStepListener((e,t)=>{if(this._closed)return;let n=this._getState(),i={commit:e,timeStamp:e.getTimestamp()};this._notifyListenerNodeMoves(n,!0,i,r),this._notifyListenerNodes(n,this._changedRanges(t),i,!0,!!this._changedRanges(t,[`sheets`]),r)})}_notifyListenerNodes(e,t,n,r,i=!1,a=null){let o=e?.listeners;if(!o||o.isEmpty()||this._listenerNodes.size===0||!t)return;let s=this._getEntireCoords(),c=new Map,l=t.length;for(let e=0;e<l;e++){let n=h.intersectRanges(s,t[e]);if(!n)continue;let i=o.search(n),l=i.length;for(let e=0;e<l;e++){let t=i[e].value.getNodeId(),o=this._listenerNodes.get(t);if(!o||(o.options.transactional??!1)!==r||a&&!a(o))continue;let s=c.get(t);s?s[s.length-1]!==n&&s.push(n):c.set(t,[n])}}c.forEach((e,t)=>{let r=this._listenerNodes.get(t);r&&(i&&r.qualified?this._deliverToNode(r,`address`,n):this._deliverToNode(r,`data`,n,e))})}_notifyListenerNodeMoves(e,t,n,r=null){if(this._listenerNodes.size===0)return;let i=e?.listeners;this._listenerNodes.forEach(e=>{if((e.options.transactional??!1)!==t||r&&!r(e))return;let a=i?i.getCoords(e.node):null;if(!a&&e.node.getContainerCoords())return;if(!a&&e.twins&&e.twins.some(e=>!!e.sheet._getState()?.listeners?.getCoords(e.entry.node)))return e.lastCoords=null,void e.node.takeEdits();if(function(e,t){if(!e||!t)return e===t||!e?.length&&!t?.length;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!h.isEqualRanges(e[n],t[n]))return!1;return!0}(e.lastCoords,a)&&!e.node.hasEdits())return;let o=e.lastCoords;if(e.lastCoords=a?[...a]:null,a&&e.node.undelete(),!n)return void e.node.takeEdits();let s=a||e.node.isDeleted()?`address`:`restore`;s===`restore`&&t||this._deliverToNode(e,s,n,void 0,o)})}_deliverToNode(e,t,n,r,i){let a=e.options,o=t===`address`?e.node.takeEdits():JR;if(t===`restore`&&e.node.takeEdits(),t===`data`&&a.ignoreDataChanges||t===`address`&&a.ignoreAddressChanges)return;let s=e.handler??e.handlerW?.deref();if(!s)return;let c=e.node.getContainerCoords();t===`data`&&c&&(e.lastCoords=[...c]);let l=this._createRangeEvent(c,{...n,trigger:t,qualified:e.qualified,collection:e.collection,invalidError:e.node.isDeleted()?gd:V.Label.NA,edits:o},r,i);a.once&&(this._listenerNodes.delete(e.node.getNodeId()),this._removeListenerNode(e.node));try{s(l)}catch(e){console.warn(e)}}_notifyUsedRangeChange(){this._lastCellRead.coords=null,this._lastUsedCoordsRead.coords=null,this._notify(`onUsedRangeChange`)}_notify(e){return CR.has(e)?this._notifyChange(e,null,AP):this._emitter.notify(e)}_notifyChange(e,t,n){this._emitter.notify(e,{params:new jP(this,e,t,n),merge:jP.merge})}_commitChanges(e,t){if(!e)return[];let n=[];for(let r=0;r<wR.length;r++){let[i,a]=wR[r],o=[];for(let t=0;t<a.length;t++){let n=e[a[t]];n&&o.push(...n)}o.length>0&&n.push({key:i,coords:o,details:t})}return n}_changeEventsOf(e,t){let n=this._sheetEvents(e.getIntents()),r={commit:e,previous:t,isStructural:!!n?.address?.length,shifts:this._sheetShifts(e.getIntents(),!1)};return this._commitChanges(n,r).map(({key:e,coords:t})=>new jP(this,e,t,r))}_notifyConditionalFormatsChange(){this._notify(`onConditionalFormatsChange`),this._notify(`onStyleChange`)}_notifyTablesChange(){this._notify(`onTablesChange`),this._notify(`onStyleChange`)}_notifyPivotTablesChange(){this._notify(`onPivotTablesChange`),this._notify(`onStyleChange`)}_notifyDataValidationsChange(){this._notify(`onDataValidationsChange`),this._notify(`onStyleChange`)}_notifyProtectedRangesChange(){this._notify(`onProtectedRangesChange`),this._notify(`onProtectionChange`)}_notifyCellControlsChange(){this._notify(`onCellControlsChange`),this._notify(`onStyleChange`)}_notifySparklineGroupsChange(){this._notify(`onSparklineGroupsChange`)}_notifyCommentsChange(){this._notify(`onCommentsChange`),this._notify(`onStyleChange`)}_forwardCollectionListeners(e,t){return(n,r)=>{let i=n.onCollectionChange,a=n.onInvalidated;return this._emitter.addListeners({[e]:i?()=>{i(t())}:void 0,onInvalidated:a?()=>{a(t())}:void 0},r)}}addListeners(e,t){return this._emitter.addListeners(e,t)}_getUsedCoords(e){let t=this._getState();if(!t)return null;let n=this._calcGrid.getValues().getCoords(),r=e?.features;if(r!==void 0){let e=typeof r==`string`?[r]:r;for(let r=0;r<e.length;r++)n=h.unionRanges(Hf(t,this._calcGrid,e[r]),n);return bR(n,this._getEntireCoords())}return n=h.unionRanges(t.borderSpatial.getContentfulCoords(),n),n=h.unionRanges(t.fillSpatial.getContentfulCoords(),n),n=h.unionRanges(t.contentSpatial.getContentfulCoords(),n),n=h.unionRanges(t.mergeSpatial.getContentfulCoords(),n),n=h.unionRanges(t.tables.getBoundingRange(),n),n=h.unionRanges(this._calcGrid.getFormulas().getBoundingRange(),n),n=h.unionRanges(this._calcGrid.getSpills().getBoundingRange(),n),n=h.unionRanges(this._calcGrid.getCalcStatus().getBoundingRange(),n),n=bR(n,this._getEntireCoords()),n?(this._lastUsedCoordsRead&&this._lastUsedCoordsRead.coords&&qz(this._lastUsedCoordsRead.coords,n)||(this._lastUsedCoordsRead.coords=n,this._lastUsedCoordsRead.range=null),this._lastUsedCoordsRead.coords):(this._lastUsedCoordsRead.coords=null,null)}_getRangeStats(e,t){if(e.length===0)return this._calcGrid.getRangeStats().toLocalCoords([],t);let n=nB(e),r=t?.ignoreHidden;if(r){let e=n[0];for(let t=1;t<n.length;t++)e=h.unionRanges(e,n[t]);let i=!0===r||r===B.Axis.Row?Hz(this._rowHeaders,e.rowStart,e.rowEnd):null,a=!0===r||r===B.Axis.Column?Hz(this._colHeaders,e.colStart,e.colEnd):null;(i||a)&&(t={...t},i&&(t.processRowSkip=Uz(t.processRowSkip,i)),a&&(t.processColumnSkip=Uz(t.processColumnSkip,a)))}return this._calcGrid.getRangeStats().toLocalCoords(n,t)}_isContentful(e,t,n){return!!this._contentCounts(e,void 0,t,n)}_contentCounts(e,t,n=!1,r=!1){if(!t){let e=Object.keys($.Content),n=e.length;t=[];for(let r=0;r<n;r++){let n=e[r],i=$.Content[n];i!==$.Content.Formats&&i!==$.Content.Tables&&t.push(i)}}let i={},a=t.length,o,s,c=!1;for(let e=0;e<a;e++){let n=t[e];n===$.Content.Values?i[G.Type.Contentful]=!1:n===$.Content.Formulas?i[G.Type.Formula]=!1:n===$.Content.Formats?(i[G.Type.BorderStyle]=!1,i[G.Type.FillStyle]=!1,i[G.Type.ContentStyle]=!1):n===$.Content.Tables&&(i[G.Type.Table]=!1,c=!0)}r&&WR(i);let l=()=>{o=new Set,s={};for(let e=0;e<a;e++){let n=t[e];s[n]=0}},u=e.length;for(let t=0;t<u;t++){let a=e[t],u=this._rangeStateIterator({searchTypes:i,ignoreHidden:n,bounds:a}),d=u.next();for(;!d.done;){let e=d.value,t=e.intersection;if(r&&t&&GR(t)){d=u.next();continue}s||l();let n=(e.end.colIndex-e.start.colIndex+1)*(e.end.rowIndex-e.start.rowIndex+1);if(t){t.contentful&&(s[$.Content.Values]=(s[$.Content.Values]??0)+n),t.formula&&(s[$.Content.Formulas]=(s[$.Content.Formulas]??0)+n);let e=t.table;e&&(c&&!o.has(e)&&(s[$.Content.Tables]=(s[$.Content.Tables]??0)+1,o.add(e)),t.contentful||(s[$.Content.Values]=(s[$.Content.Values]??0)+n))}d=u.next()}}return s}_featureCounts(e,t,n=!1,r=!1){let i=Qh.Feature,a=Object.values(i),o=e=>e===i.Anomalies||e===i.Role,s=t===void 0?a.filter(e=>!o(e)):$k(t),c={};for(let e=0;e<a.length;e++)o(a[e])||(c[a[e]]=0);s.includes(i.Anomalies)&&(c[i.Anomalies]=0),s.includes(i.Role)&&(c[i.Role]=0),e.length>1&&(e=nB(e));let l=new Map;for(let e=0;e<s.length;e++){let t=s[e],n=Bf[t];if(n===null)continue;let r=l.get(n);r?r.push(t):l.set(n,[t])}let u=e.length;for(let[t,a]of l){let o=t===G.Type.ContentStyle,s={[t]:!1};t===G.Type.Unlock&&(s[G.Type.ContentStyle]=!1),r&&WR(s);for(let t=0;t<u;t++){let l=this._rangeStateIterator({searchTypes:s,ignoreHidden:n,bounds:e[t]}),u=l.next();for(;!u.done;){let e=u.value,t=e.intersection;if(t&&(!r||!GR(t))){let n=(e.end.colIndex-e.start.colIndex+1)*(e.end.rowIndex-e.start.rowIndex+1);if(o){let r=t.contentStyle?.getPropertiesAt(e.start.rowIndex,e.start.colIndex,null);if(r)for(let e=0;e<a.length;e++){let t=a[e];(t===i.NumberFormat&&Cm(this._styles,r)!==void 0||t===i.Alignment&&r.alignment!==void 0||t===i.Font&&r.font!==void 0||t===i.Protection&&r.protection!==void 0)&&(c[t]+=n)}}else for(let e=0;e<a.length;e++){let r=a[e];PR(t,r,this._styles)&&(c[r]+=n)}}u=l.next()}}}return new MR(c)}async _dependencyRanges(e,t,n){let r=this._calcGrid;if(!r)return null;let i=e.scope&&e.scope===this.getName()?{...e,scope:void 0}:e,{cells:a,names:o}=await r.getGraphNeighborsAt(i,t,n);if(this._closed)return null;let s=this._toRangeScopes(a),c=this._namedGraphRanges(o);return s.length!==0||c?this._createRanges(c?[...c,...s]:s):null}_namedGraphRanges(e){if(e.length===0)return null;let t=this._calculation?.getNamedFormulas()??null,n=this._internal,r=Array(e.length);for(let i=0;i<e.length;i++){let a=e[i],o=(a.sheetName?Sz(n,a.sheetName):null)??n;r[i]=new vA(a,t,o,null)}return r}_toRangeScopes(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(!i.scope){n.push(i);continue}let a=this._resolveSheetScope(i.scope);a?n.push({...i,scope:a}):t?.add(i.scope)}return n}_resolveSheetScope(e){if(this.getId()===e)return this.getName();let t=this._workbook?.getWorksheets().getItems();if(t){for(let n of t)if(n.getId()===e)return n.getName()}return null}_featureRegions(e,t,r){let i=Qh.Feature,a=r?.containment===`fullyContained`,o={},s=[],c=[];for(let e=0;e<t.length;e++){let n=t[e];switch(n){case i.NumberFormat:case i.Alignment:case i.Font:case i.Protection:s.push(n),o[G.Type.ContentStyle]=!1;break;case i.Unlock:o[G.Type.Unlock]=!1,o[G.Type.ContentStyle]=!1,c.push(n);break;default:{let e=Bf[n];if(e===null)return[];o[e]=!1,c.push(n)}}}let l=c.includes(i.Contentful),u=c.includes(i.Unlock),d=c.includes(i.Fill),f=c.includes(i.CellControl),p=c.includes(i.Hyperlink),m=[];for(let e=0;e<c.length;e++)c[e]!==i.Contentful&&c[e]!==i.Fill&&c[e]!==i.CellControl&&c[e]!==i.Hyperlink&&m.push(Bf[c[e]]);let h=[];for(let e=0;e<s.length;e++)switch(s[e]){case i.NumberFormat:h.push(`numberFormat`);break;case i.Alignment:h.push(`alignment`);break;case i.Font:h.push(`font`);break;case i.Protection:h.push(`protection`)}let g=new Map,_=(e,t)=>{if(!e)return``;let r=g.get(e);if(r===void 0){let i=e.getPropertiesAt(0,0,null);if(i){if(t){let e=i.named?this._styles.getNamedStyles().getByName(i.named)?.getRanged().getPropertiesAt(0,0,null):null,a=Array(t.length);for(let n=0;n<t.length;n++){let r=t[n];a[n]=r===`numberFormat`?Cm(this._styles,i)??null:[i[r]??null,e?.[r]??null]}r=n.JSONStableStringify(a)}else r=n.JSONStableStringify(i)}else r=``;g.set(e,r)}return r},v=new Map,y=new Map,b=e=>{let t=[];p&&t.push((e=>{if(!e)return``;let t=y.get(e);return t===void 0&&(t=n.JSONStableStringify(e)??``,y.set(e,t)),t})(e.hyperlink)),l&&t.push(!!e.contentful),u&&t.push(xm(this._styles,e.contentStyle?.getPropertiesAt(0,0,null))),d&&t.push(_(e.fillStyle,null)),f&&t.push((e=>{let t=Array.isArray(e)?e[0]:e;if(!t)return``;let r=v.get(t);return r===void 0&&(r=n.JSONStableStringify(t.toJSON())??``,v.set(t,r)),r})(e.cellControls));for(let n=0;n<m.length;n++)t.push(e[m[n]]);return h.length>0&&t.push(_(e.contentStyle,h)),t},x=new Map,S=Symbol(`rects`),C=e=>{let t=x;for(let n=0;n<e.length;n++){let r=t.get(e[n]);r||(r=new Map,t.set(e[n],r)),t=r}let n=t.get(S);return n||(n=[],t.set(S,n)),n},w=c.includes(i.Anomalies)&&r?.axis===void 0,T=new Map,E=this._rangeStateIterator({searchTypes:o,ignoreHidden:r?.ignoreHidden??!1,bounds:e,fullyContained:a}),D=E.next();for(;!D.done;){let t=D.value,n=t.intersection;if(n){let r=!1;for(let e=0;!r&&e<c.length;e++)r=PR(n,c[e],this._styles);if(!r&&s.length>0){let e=n.contentStyle?.getPropertiesAt(t.start.rowIndex,t.start.colIndex,null);if(e)for(let t=0;!r&&t<s.length;t++){let n=s[t];r=n===i.NumberFormat&&Cm(this._styles,e)!==void 0||n===i.Alignment&&e.alignment!==void 0||n===i.Font&&e.font!==void 0||n===i.Protection&&e.protection!==void 0}}if(r){let r=C(b(n));w&&!T.has(r)&&T.set(r,n.anomalies?.[0]?.rank??-1),r.push({rowStart:Math.max(t.start.rowIndex,e.rowStart),colStart:Math.max(t.start.colIndex,e.colStart),rowEnd:Math.min(t.end.rowIndex,e.rowEnd),colEnd:Math.min(t.end.colIndex,e.colEnd)})}}D=E.next()}let O=[],k=new Map,A=e=>{for(let[t,n]of e)if(t===S){let e=xc(n,B.Axis.Column,2**53-1);if(O.push(...e),w){let t=T.get(n)??-1;for(let n=0;n<e.length;n++)k.set(e[n],t)}}else A(n)};A(x);let j=r?.axis===B.Axis.Column,M=!0===r?.reverse;return O.sort((e,t)=>{let n=(w?k.get(t)-k.get(e):0)||(j?e.colStart-t.colStart||e.rowStart-t.rowStart:e.rowStart-t.rowStart||e.colStart-t.colStart);return M?-n:n}),O}find(e){return e?((e=typeof e==`string`?{text:e}:{...e}).from||(e.from=this.getSelection().getCoords().cell),this.getEntireRange().find(e)):bo}setEntireSize(e,t){let n=this._getState().entireFit,r=null;if(e){let t=e.width===void 0?n?.width??!1:e.width===`fit`,i=e.height===void 0?n?.height??!1:e.height===`fit`;(t||i)&&(r={width:t,height:i})}let i=e??zR,a=this._getEntireSize(),o=r?this._getFittedSize():a,s=r?.width?o.width:typeof i.width==`number`?i.width:a.width,c=r?.height?o.height:typeof i.height==`number`?i.height:a.height,l=n?.width!==r?.width||n?.height!==r?.height;if(s===a.width&&c===a.height&&!l)return this;let u=this._beginCommit({description:t?.description??m(`op.setEntireSize`),operation:{name:`setEntireSize`}});try{l&&this._updateState({entireFit:r}),this._resizeEntire({width:s,height:c},u,t),u.commit(t)}catch(e){throw u.rollback(),e}return this}_getEntireSize(){let e=this._getEntireCoords();return{width:e.colEnd-e.colStart+1,height:e.rowEnd-e.rowStart+1}}_getFittedSize(){let e=this.getUsedRange()?.getCoords();return{width:e?e.colEnd+1:1,height:e?e.rowEnd+1:1}}_resizeEntire(e,t,n){let r=this._getEntireCoords(),i=r.colEnd-r.colStart+1,a=r.rowEnd-r.rowStart+1,o=e.width,s=e.height;if(o===i&&s===a)return;let c=this._getMutationCtx();o<i&&AF(c,[{colStart:o,rowStart:r.rowStart,colEnd:r.colEnd,rowEnd:r.rowEnd}],B.Axis.Column,!1),s<a&&AF(c,[{colStart:r.colStart,rowStart:s,colEnd:r.colEnd,rowEnd:r.rowEnd}],B.Axis.Row,!1);let l=Object.freeze({colStart:0,rowStart:0,colEnd:o-1,rowEnd:s-1}),u=this._getState(),d=e=>{let t=(t,n)=>{let r=e.search(t,!1,!1,[]);if(r.length===0)return;e.removeAll(r);let i=[];for(let e=0;e<r.length;e++){let a=r[e];(n?a.rowStart>=t.rowStart:a.colStart>=t.colStart)||i.push(n?{...a,rowEnd:t.rowStart-1}:{...a,colEnd:t.colStart-1})}i.length>0&&e.load(i)};s<a&&t({colStart:0,rowStart:s,colEnd:r.colEnd,rowEnd:r.rowEnd},!0),o<i&&t({colStart:o,rowStart:0,colEnd:r.colEnd,rowEnd:r.rowEnd},!1)},f=u.borderSpatial.clone();d(f),f.setEntireCoords(l);let p=u.fillSpatial.clone();d(p),p.setEntireCoords(l);let m=u.contentSpatial.clone();d(m),m.setEntireCoords(l),this._updateState({entireCoords:l,borderSpatial:f,fillSpatial:p,contentSpatial:m}),this._entireCoordsCache=null,this._entireRangeCache=null,this._calcGrid.resize(l,this._requestFor(t)),this._emitter.notify(`onViewChange`,{source:this.getView()}),this._colHeaders._invalidateExtent(),this._rowHeaders._invalidateExtent(),o>i&&AF(c,[{colStart:r.colEnd+1,rowStart:l.rowStart,colEnd:o-i+r.colEnd,rowEnd:l.rowEnd}],B.Axis.Column,!0),s>a&&AF(c,[{colStart:l.colStart,rowStart:r.rowEnd+1,colEnd:l.colEnd,rowEnd:s-a+r.rowEnd}],B.Axis.Row,!0);let g=this.getSelection().getCoords(),_=bD(g,h.EmptySelection,l);this._notify(`onLayoutChange`),this._recordSelection(t,_,n,g)}_find(e,t){if(this._closed)throw Error(N(`error.sheet.modelClosed`));typeof t==`string`&&(t={text:t});let n=t?.text;if(!n)return bo;let r=[...e],i=t?.axis??B.Axis.Row,a=t?.reverse,o=!t?.disableWrap,s=t?.from?this._cellToCoords(t?.from):null,c=null;if(s){let e=-1;for(let t=0;e===-1&&t<r.length;t++)h.isCellWithinRange(s,r[t])&&(e=t);c=h.cellToRange(s);let t=uD(r[e],c,i);t.push(c);let n=h.createRangeComparator(i,a);t.sort(n);let l=-1,u=t.length;for(let e=0;e<u;e++)n(t[e],c)<=0&&(l=e);r.splice(e,1,...t);let d=e+l,f=[];for(let e=0;e<=d;e++)f.push(r.shift());if(o){let e=f.length;for(let t=0;t<e;t++)r.push(f[t])}}if(r.length===0)return bo;let l=t?.fields?.includes($.Content.Formulas)??!1,u=t?.fields?.includes($.Content.Values)??!0,d=t?.matchEntireCell??!1,f=t?.matchCase??!1,p=t?.useRegex??!1,m=function(e,t,n,r){let i=t?``:`i`;return n?new RegExp(r?`^(?:${e})$`:e,i):Vt.toRegex(e,i,r)}(n,f,p,d),g=(e,t)=>{let n=e=>!!e&&m.test(e),r=t.getCell(),i=!1;return!i&&l?i=n(r.getFormulaText({target:`display`})??r.getText(XR)):u&&(i=n(r.getNumberFormat().displayText)),i};if(t?.matchCustom){let e=t.matchCustom,n={matchCase:f,matchEntireCell:d,useRegex:p,fields:t?.fields??[$.Content.Formulas]},r,i,a=g,o=()=>a(r,i);g=(t,a)=>(r=t,i=a,e(t,o,n,a))}let _=-1,v=null,y=yo,b=!1,x=()=>{if(y.done){if(_++,_>=r.length)return b=!0,!1;v=this._cellIterator({reverse:a,axis:i,searchTypes:!1,bounds:r[_]})}if(y=v.next(),!y.done){let e=y.value;return g(e.value,e.context)}return!1};return{next:()=>{let e=null;for(;!b&&!e;)x()&&(e=y.value.context.getCell());return e?{value:e,done:!1}:yo}}}getRuntime(){return this._runtime}_getTraverseRegion(e,t,n){let r=this._getState().tables.search({rowStart:e.rowIndex,colStart:e.colIndex,rowEnd:e.rowIndex,colEnd:e.colIndex});return r.length===0?null:r[0].value._getTraverseRegion(e,t,n)}_surroundingRegion(e,t){let n=this._getState(),r=t?.contentOnly??!1,a=this._getEntireCoords();if(!r){let t=n.tables.search(e);if(t.length>0){let n=t[0].value,r=n.getDataRange().getCoords(),i=n.getRange().getCoords();return h.isEqualRanges(r,e)?i:h.isEqualRanges(i,e)?a:r}}let o=r?e:a;return function(e,t,n=2e4){if(!t||t.length===0)return null;let r=null,a=!1;for(let n=0;n<t.length;n++){let i=t[n];i&&(r=h.unionRanges(r,i.getBoundingRange()),a||=i.search(e).length>0)}if(!r)return null;let o={...h.EmptyRange},s=e,c=a?{...e}:null;if(!c){let n=(e=>{let n=[],r=t.length;for(let i=0;i<r;i++){let r=t[i];if(!r)continue;let a=r.search(e),o=a.length;n=o>0?Array(o):void 0;for(let e=0;e<o;e++){let t=a[e];n[e]=t}}return n||i.EmptyArray})({colStart:e.colEnd,rowStart:e.rowEnd,colEnd:e.colEnd+1,rowEnd:e.rowEnd+1}),r=n.length;if(r>0){c={...e};for(let e=0;e<r;e++){let t=n[e];c.colEnd=Math.max(c.colEnd,t.colStart),c.rowEnd=Math.max(c.rowEnd,t.rowStart)}}}let l={...h.EmptyRange},u=()=>{let e=t.length;for(let n=0;n<e;n++){let e=t[n];if(!e)continue;let r=e.search(o),i=r.length;for(let e=0;e<i;e++){let t=r[e];c=h.unionRanges(c,t,l)}}return c};o.colStart=e.colStart,o.rowStart=e.rowStart,o.colEnd=e.colEnd,o.rowEnd=e.rowEnd,u();let d={...c},f={...h.EmptyRange},p=0;do{if(o.colStart=f.colStart=d.colStart,o.rowStart=f.rowStart=d.rowStart,o.colEnd=f.colEnd=d.colEnd,o.rowEnd=f.rowEnd=d.rowEnd,d.colStart>r.colStart&&(o.colStart=d.colStart-1,o.colEnd=d.colStart-1,o.rowStart=d.rowStart-1,o.rowEnd=d.rowEnd+1,u()),d.rowStart>r.rowStart&&(o.rowStart=d.rowStart-1,o.rowEnd=d.rowStart-1,o.colStart=d.colStart-1,o.colEnd=d.colEnd+1,u()),d.colEnd<r.colEnd&&(o.colStart=d.colEnd+1,o.colEnd=d.colEnd+1,o.rowStart=d.rowStart-1,o.rowEnd=d.rowEnd+1,u()),d.rowEnd<r.rowEnd&&(o.rowStart=d.rowEnd+1,o.rowEnd=d.rowEnd+1,o.colStart=d.colStart-1,o.colEnd=d.colEnd+1,u()),!c)return null;if(d.colStart=c.colStart,d.rowStart=c.rowStart,d.colEnd=c.colEnd,d.rowEnd=c.rowEnd,h.isEqualRanges(d,f))return h.isEqualRanges(s,d)?null:d;if(h.isEqualRanges(d,s))return null;if(h.isEqualRanges(d,f))return d;p++}while(p<n);return null}(e,[this._calcGrid.getContentful(),n.mergeSpatial,this._calcGrid.getFormulas(),this._calcGrid.getSpills(),this._calcGrid.getCalcStatus()])||o}_extendRange(e,t){if(this._closed)throw Error(N(`error.sheet.modelClosed`));let n={...this._getEntireCoords()},r=this.getRowHeaders(),a=this.getColumnHeaders(),o=(this._cacheTableColumnHeaders?.table)?.getRange().getCoords(),s=!1;if(o){let i={...o};i.rowStart+=r.getMetrics().hiddenHeadersAt(i.rowStart,!1),i.rowEnd-=r.getMetrics().hiddenHeadersAt(i.rowEnd,!0),i.colStart+=a.getMetrics().hiddenHeadersAt(i.colStart,!1),i.colEnd-=a.getMetrics().hiddenHeadersAt(i.colEnd,!0),(e===B.Direction.Up&&t.rowIndex>i.rowStart||e===B.Direction.Down&&t.rowIndex<i.rowEnd||e===B.Direction.Left&&t.colIndex>i.colStart||e===B.Direction.Right&&t.colIndex<i.colEnd)&&(s=!0),s&&(n=i)}n.rowStart+=r.getMetrics().hiddenHeadersAt(n.rowStart,!1),n.rowEnd-=r.getMetrics().hiddenHeadersAt(n.rowEnd,!0),n.colStart+=a.getMetrics().hiddenHeadersAt(n.colStart,!1),n.colEnd-=a.getMetrics().hiddenHeadersAt(n.colEnd,!0);let c=this,l=[],u={ignoreHidden:!0,onFound:(e,t)=>{l.push(h.intersectRanges(e,t))},onEntry:(e,t)=>t},d={ignoreHidden:!0,onEntry:(e,t)=>e.tvTl()===void 0?null:t},f=this._getState();if(!f)return i.EmptyArray;let p,m=c._getRangedEntries(f.mergeSpatial,[h.cellToRange(t)],d);m.length>0&&(p=m[0]);let g=[e=>c._getRangedEntries(c._getState().mergeSpatial,e,d),e=>(l=[],c._getRangedEntries(c._calcGrid.getContentful(),e,u),l)];return s||g.push(e=>(l=[],c._getRangedEntries(c._getState().tables,e,u),l)),function(e,t,n,r,i){let a,o,s,c={...t},l=h.cellToRange(c),u=r(l).length>0;if(u){let t=1,i=e===B.Direction.Up||e===B.Direction.Down;n&&(t+=i?n.rowEnd-n.rowStart:n.colEnd-n.colStart),e!==B.Direction.Left&&e!==B.Direction.Up||(t=-t),i?c.rowIndex+=t:c.colIndex+=t,l=h.cellToRange(c),u=r(l).length>0}switch(e){case B.Direction.Up:l.rowStart=Math.min(i.rowStart,l.rowStart),o=r(l).sort(h.createRangeComparator(B.Axis.Row,!0)),a=t.rowIndex,s=u?o.length===1&&a===o[0].rowStart?i.rowStart:o[0].rowStart:o.length===0?i.rowStart:o[0].rowEnd;break;case B.Direction.Down:l.rowEnd=Math.max(i.rowEnd,l.rowEnd),o=r(l).sort(h.createRangeComparator(B.Axis.Row,!1)),a=t.rowIndex,s=u?o.length===1&&a===o[0].rowEnd?i.rowEnd:o[0].rowEnd:o.length===0?i.rowEnd:o[0].rowStart;break;case B.Direction.Left:l.colStart=Math.min(i.colStart,l.colStart),o=r(l).sort(h.createRangeComparator(B.Axis.Column,!0)),a=t.colIndex,s=u?o.length===1&&a===o[0].colStart?i.colStart:o[0].colStart:o.length===0?i.colStart:o[0].colEnd;break;case B.Direction.Right:l.colEnd=Math.max(i.colEnd,l.colEnd),o=r(l).sort(h.createRangeComparator(B.Axis.Column,!1)),a=t.colIndex,s=u?o.length===1&&a===o[0].colEnd?i.colEnd:o[0].colEnd:o.length===0?i.colEnd:o[0].colStart}let d=o?o.length:0;if(u&&d>1){let t=!1;for(let n=1;!t&&n<d;n++){let r=o[n];switch(e){case B.Direction.Up:r.rowEnd<s-1?t=!0:s=Math.min(s,r.rowStart);break;case B.Direction.Down:r.rowStart>s+1?t=!0:s=Math.max(s,r.rowEnd);break;case B.Direction.Left:r.colEnd<s-1?t=!0:s=Math.min(s,r.colStart);break;case B.Direction.Right:r.colStart>s+1?t=!0:s=Math.max(s,r.colEnd)}}}let f=h.cellToRange(t);switch(e){case B.Direction.Up:f.rowStart=s;break;case B.Direction.Down:f.rowEnd=s;break;case B.Direction.Left:f.colStart=s;break;case B.Direction.Right:f.colEnd=s}return f}(e,t,p,e=>{let t=[],n=[e],r=g.length;for(let e=0;e<r;e++){let r=(0,g[e])(n),i=r.length;for(let e=0;e<i;e++){let n=r[e];t.push(n)}}return t},n)}_defaultFontDims(){let e=Lm();if(e!==this._defaultFontsVersion&&(this._defaultFontsVersion=e,this._defaultFontBoundsCache=null,this._defaultColWidthCache=0,this._defaultRowHeightCache=0),this._defaultFontBoundsCache)return this._defaultFontBoundsCache;let t=this._styles.getNormal(),n=0,r=0;for(let e=0;e<=9;e++){let i=t.measureText(e.toString());n=Math.max(i.width,n),r=Math.max(i.lineHeight,r)}return n=Math.round(n),this._defaultFontBoundsCache={width:n,height:r},this._defaultFontBoundsCache}getColumnWidthAsFontUnit(e){let 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}_createTupleBuilder(e=!1){return e?new Lo.TransposedBuilder:new Lo.Builder}_defaultColWidth(){if(this._defaultFontDims(),this._defaultColWidthCache)return this._defaultColWidthCache;let e=this._baseColSize??8,t=this._defaultFontDims()?.width||7,n=8*Math.ceil((t*e+5)/8)/Math.round(this._defaultFontDims().width);return this._defaultColWidthCache=n}_defaultRowHeight(){if(this._defaultFontDims(),this._defaultRowHeightCache)return this._defaultRowHeightCache;let e=this._defaultFontDims();if(!e||e.width===0)return this._defaultRowHeightCache=20/I.getDeviceScale(),this._defaultRowHeightCache;let t=e.height;return this._defaultRowHeightCache=Math.round(t/I.getDeviceScale()*4)/4,this._defaultRowHeightCache}getProtection(){return this._protection??null}async _scrollIntoView(e,t){if(!t)return!0;!0===t&&(t=i.EmptyObject);let n=t.axis,r=e;n===B.Axis.Column?r={colStart:e.colStart,rowStart:void 0,colEnd:e.colEnd,rowEnd:void 0}:n===B.Axis.Row&&(r={colStart:void 0,rowStart:e.rowStart,colEnd:void 0,rowEnd:e.rowEnd});let a={coords:r},o=await this._emitter.notify(`onRequestScrollIntoView`,{params:a,async:!0});if(!o)return!1;let s=o.length;for(let e=0;e<s;e++)if(!1===o[e])return!1;return!0}async _selectSheet(e,t){return!1!==await this._options.container?.requestSelect?.()&&this._scrollIntoView(e,t)}async scrollTo(e,t){let n={...t,coords:e},r=await this._emitter.notify(`onRequestScrollIntoView`,{params:n,async:!0});if(!r)return!1;let i=r.length;for(let e=0;e<i;e++)if(!1===r[e])return!1;return!0}_resolveSelectOptions(e,t){return e?(!0===e&&(e={autoFocus:!0,scrollIntoView:!0}),!0===e.scrollIntoView&&(e={...e,scrollIntoView:{}}),t&&(e={...e,scrollIntoView:{axis:t,...e?.scrollIntoView}}),e):null}_commitWithDirectives(e,t,n,r){if(t){this._recordSelection(e,t,n,r?.undo,r?.axis);let i=n?.autoFit??FR;if(i){let n=t.ranges?.length?t.ranges:t.cell?[h.cellToRange(t.cell)]:null;n&&this._recordAutoFit(e,n,i)}}e.commit(r?.commit)}_recordSelection(e,t,n,r,i){let a=n?.autoSelect,o=n?.autoSelectRestore===void 0?a:n.autoSelectRestore,s={sheetId:this.getId(),viewId:this.getView().getId(),selection:t,options:!!a&&(this._resolveSelectOptions(a,i)??!0),restoreOptions:!!o&&(this._resolveSelectOptions(o,i)??!0),nested:wP(e)};r&&(s.undo=r),e.setIntent(mP,e=>e?[...e,s]:[s])}_restoredSelection(e,t){return TP(e,this.getId(),this.getView().getId(),t?`undo`:`redo`)}_recordChange(e,t,n,r){if(!n||n.length===0)return;let i=this.getId(),a=e.getId();e.setIntent(`sheet.events`,e=>{let r={...e},o={...r[i]};return o[t]=CP(o[t],n,a),r[i]=o,r}),this._announceChange(e,t,n,r)}_hasChangeParticipants(){let e=this._emitter;for(let t=0;t<wR.length;t++)if(e.hasTransactional(wR[t][0]))return!0;return!1}_announceChange(e,t,n,r){let a=TR.get(t);if(!a||this._initializing||e.getIntent(`sheet.initial`)?.includes(this.getId()))return;let o=this._transactions;this._notifyChange(a,n,{commit:o.getCurrentCommit(),previous:o.getCurrentCommit(!1),isStructural:t===`address`,shifts:r??i.EmptyArray})}_recordFormulasEntered(e,t){if(!t||t.length===0)return;let n=this.getId(),r=e.getId();e.setIntent(pP,e=>{let i={...e};return i[n]=CP(i[n],t,r),i})}_sheetEvents(e){return e?.[`sheet.events`]?.[this.getId()]??null}_changedRanges(e,t){let n=this._sheetEvents(e);if(!n)return null;let r=t??Object.keys(n),i=null,a=r.length;for(let e=0;e<a;e++){let t=n[r[e]];t&&t.length!==0&&(i?i.push(...t):i=[...t])}return i}_recordAutoFit(e,t,n){if(!n||t.length===0)return;let r=!0===n?void 0:n,i=this.getId();e.setIntent(gP,e=>{let n=e?[...e]:[],a=n.find(e=>e.sheetId===i&&e.options===r);return a?n[n.indexOf(a)]={...a,ranges:[...a.ranges,...t]}:n.push({sheetId:i,ranges:[...t],options:r}),n})}_recordAutoFormat(e){let t=this.getId();e.setIntent(xP,e=>e?.includes(t)?e:[...e??[],t])}_recordSkipProtectionCheck(e){let t=this.getId();e.setIntent(_P,e=>e?.includes(t)?e:[...e??[],t])}_isProtectionRuled(){return!!this._transactions.getPendingTransaction()?.getIntent(_P)?.includes(this.getId())}_assertContentEditable(e,t=!0){if(!this.getProtection().isLocked())return!1;let n=this._styles,r=xm(n,void 0),i=e=>{throw new b(N(e?`error.sheet.protectedRangeLocked`:`error.sheet.protectedSheet`))};for(let a=0;a<e.length;a++){let o=e[a],s=(o.rowEnd-o.rowStart+1)*(o.colEnd-o.colStart+1),c=this._rangeStateIterator({searchTypes:{[G.Type.Unlock]:!1,[G.Type.ContentStyle]:!1},ignoreHidden:!1,bounds:o});for(let e=c.next();!e.done;e=c.next()){let r=e.value,a=Math.max(r.start.rowIndex,o.rowStart),c=Math.max(r.start.colIndex,o.colStart),l=Math.min(r.end.rowIndex,o.rowEnd),u=Math.min(r.end.colIndex,o.colEnd);if(l<a||u<c)continue;s-=(l-a+1)*(u-c+1);let d=r.intersection;if(xm(n,d?.contentStyle?.getPropertiesAt(0,0,null)))continue;let f=t?d?.unlock:void 0;f||i(!1);let p=Array.isArray(f)?f:[f],m=!1;for(let e=0;!m&&e<p.length;e++)m=p[e].isUnlocked();m||i(!0)}s>0&&!r&&i(!1)}return!0}_recordInitial(e){let t=this.getId();e.setIntent(`sheet.initial`,e=>e?.includes(t)?e:[...e??[],t]),this._recordSkipProtectionCheck(e)}_recordFreezePanes(e,t,n){let r=this.getId();e.setIntent(vP,e=>({...e,[r]:{before:e?.[r]?.before??t,after:n}}))}_recordShift(e,t,n,r){if(r.length===0)return;let i=this.getId(),a={kind:t,axis:n,ranges:r};e.setIntent(yP,e=>({...e,[i]:[...e?.[i]??[],a]}))}_sheetShifts(e,t){let n=e?.[yP]?.[this.getId()];if(!n)return[];if(!t)return n;let r=[];for(let e=n.length-1;e>=0;e--){let t=n[e];r.push({...t,kind:t.kind===`insert`?`delete`:`insert`})}return r}_movablesOfIds(e){let t=new Map,n=this.getMovables().getItems({deep:!0});for(let e=0;e<n.length;e++)t.set(n[e].getId(),n[e]);let r=[];for(let n=0;n<e.length;n++){let i=t.get(e[n]);i&&r.push(i)}return r}_amendCurrent(e){return this._amendBookkeeping(this._transactions.getCurrentCommit(!1).getId(),e)}_amendBookkeeping(e,t){let n=this._transactions.getPendingTransaction()===null;return this._transactions.amend(e,e=>(n&&this._recordSkipProtectionCheck(this._transactions.getPendingTransaction()),t(e)))}_resolveAutoFit(e){let t=e.getIntents()[gP];if(!t)return;let n=this.getId(),r=t.length;for(let e=0;e<r;e++){let r=t[e];r.sheetId===n&&this._autoFit(r.ranges,r.options??IR)}}_onRootTransactionClose(e,t=!1,n=!1,r=!1){t&&this._invalidateCaches(),(t||n)&&this._releaseHeldPassRanges();let i=this._selectionAtCommitStart;this._selectionAtCommitStart=null;let a=t||n||r?null:OP(e.getIntents(),this.getId(),this.getView().getId(),`forward`);a&&this._movableSelectionAtCommitEnd.set(e,a);let o=TP(e.getIntents(),this.getId(),this.getView().getId(),`forward`);o&&i&&h.isEqualSelectionCoords(i,this.getSelection().getCoords())&&this._autoSelect(o.options,o.selection)}_releaseHeldPassRanges(){let e=this._heldPassRanges;e&&(this._transactions.getPendingTransaction()||(this._heldPassRanges=null,this._notifyPassToListenerNodes(e)))}_normalizeSelection(e){let t=this._view?.getRangeSelection();if(!t)return;let n=this._selectionWithinEntire(t.getCoords());if(e){let e=n.cell,t=this._getMerges([h.cellToRange(e)])[0];!t||t.rowStart===e.rowIndex&&t.colStart===e.colIndex||(n={...n,cell:{rowIndex:t.rowStart,colIndex:t.colStart}})}t.updateCoords(n)}_selectionWithinEntire(e,t=this._getEntireCoords()){let n=!h.isCellWithinRange(e.cell,t),r=e.ranges??i.EmptyArray;for(let e=0;!n&&e<r.length;e++)n=!!r[e]&&!h.isRangeWithinRange(r[e],t);return n?bD(e,h.EmptySelection,t):e}async _autoSelect(e,t,n){if(!e)return i.EmptyArray;let r=this._resolveSelectOptions(e,n),a=r?.autoFocus,o=r?.scrollIntoView,s=r?.anchor,c=this.getSelection().getCoords(),l=xD(t??null),u=this._getEntireCoords(),d=eB(l,this._getState().mergeSpatial,u),f=-1,p=null;if(!s){let e=c?.cell,t=d.length;for(let n=0;f===-1&&n<t;n++){let t=d[n];h.isCellWithinRange(e,t)&&(f=n,p=e)}}let m=this._selectionWithinEntire(SD(d,p,f));this.getSelection().updateCoords(m);let g=h.cellToRange(m.cell);if(r?.preserveSelectedSheet)return await this._scrollIntoView(g,o),d;{let e=await this._selectSheet(g,o);if(!1!==o&&!1===e)return d}if(!1!==a){let e=await this._notify(`onRequestFocus`);if(!e)return d;let t=e.length;for(let n=0;n<t;n++)if(!1===e[n])return d}return d}getSelection(){return this.getView().getRangeSelection()}getSelectedCell(){return this.getSelection().getCell()}getSelectedRange(e){return this.getSelection().getRange(e)}getSelectedRanges(e){return this.getSelection().getRanges(e)}getView(){return this._view}setView(e){if(this._closed)throw Error(N(`error.sheet.modelClosed`));if(!e)throw new k(N(`error.sheet.emptyView`));this._viewRemoveListener?.(),this._view=e;let t=this._viewListener;return this._viewRemoveListener=e.addListeners(t,{transactional:!1}),t.onTopLeftChange?.(e),t.onFreezePaneChange?.(e),t.onHeaderChange?.(e),t.onZoomScaleChange?.(e),t.onSelectionChange?.(e),t.onMovableSelectionChange?.(e),t.onAnyChange?.(e),this._emitter.notify(`onViewChange`,{source:e}),this}getTabColor(){return this._tabColor}setTabColor(e){if(this._closed)throw Error(N(`error.sheet.modelClosed`));return this._tabColor=typeof e==`string`?this._styles.parseColor(e):e??null,this._notify(`onTabColorChange`),this}getCodeName(){return this._codeName}getOutline(){return this._outline}getPageLayout(){return this._pageLayout}getHorizontalPageBreaks(){return this._pageLayout.getHorizontalPageBreaks()}getVerticalPageBreaks(){return this._pageLayout.getVerticalPageBreaks()}addHorizontalPageBreak(e,t){return this._pageLayout.addHorizontalPageBreak(e,t)}addVerticalPageBreak(e,t){return this._pageLayout.addVerticalPageBreak(e,t)}removeAllHorizontalPageBreaks(e){this._pageLayout.removeAllHorizontalPageBreaks(e)}removeAllVerticalPageBreaks(e){this._pageLayout.removeAllVerticalPageBreaks(e)}isConditionalFormatCalculationEnabled(){return this._conditionalFormatCalculation}isTransitionFormulaEvaluation(){return this._sheetPr.transitionFormulaEvaluation??!1}isTransitionFormulaEntry(){return this._sheetPr.transitionFormulaEntry??!1}isExcludedFromPublishing(){return this._sheetPr.excludeFromPublishing??!1}getSyncScroll(){return this._sheetPr.syncScroll??null}_isModulesReadOnly(){return this.getWorkbook()?._isStructureProtected?.()??!1}getModules(){if(this._closed)throw Error(N(`error.sheet.modelClosed`));return this._modules}getRowHeaders(){return this._rowHeaders}getColumnHeaders(){return this._colHeaders}_openCalcGrid(e){let t=this,n=this._calculation;this._ownCalculation&&n._setSheets([[t.getId(),t.getName()??null]]);let r=n._createCalcGrid({isOwned:!0,valuesAxis:t._isDataColumn?B.Axis.Column:B.Axis.Row,uuid:t.getId()});return r.addListeners({onComplete(e,n){t._realizeCalcedValues(n)},onFormulasChanged(e,n){t._closed||(t._invalidateCaches(),n&&!t._initializing&&t._notifyChange(`onDataChange`,null,{commit:null}))},onInputsWritten(e,n){if(t._closed)return;t._updateState({inputsCommitId:n.inputsId});let r=t._transactions.getCurrentTransaction();n.arrays&&r&&t._recordChange(r,`spills`,n.arrays)}}),r.seed({...e,entireCoords:t._getEntireCoords()}).catch(e=>n._reportError(e)),r}async toJSON(e){if(this._closed)throw Error(N(`error.sheet.modelClosed`));await Promise.resolve(this._starting);let t=this.getCalculation();t.getStatus()!==Q.Status.Off&&await t.ready(),await this._emitter.notify(`onBeforeSave`,{async:!0});let n={},r=this._getState();if(!r)return n;let i=this._getEntireCoords(),a=null;{let t=e?.ignoreData??!1,r=e?.ignoreFormulas;t&&r||(a=await this._calcGrid.toJSON());let o=i.colEnd+1,s=i.rowEnd+1;if(o!==zR.width||s!==zR.height){let e={};o!==zR.width&&(e.width=o),s!==zR.height&&(e.height=s),n.entireSize=e}let c=this._getState().entireFit;c&&(n.entireSizeFit={...c.width?{width:!0}:{},...c.height?{height:!0}:{}});let l=this._colHeaders.toJSON();l&&(l.headers&&l.headers.length>0&&(n.cols=l.headers),l.defaultSize!==void 0&&l.defaultSize!==-1&&(n.defaultColSize=l.defaultSize)),this._baseColSize!==null&&(n.baseColSize=this._baseColSize);let u=this._rowHeaders.toJSON();u&&(u.headers&&u.headers.length>0&&(n.rows=u.headers),u.defaultSize!==void 0&&u.defaultSize!==-1&&(n.defaultRowSize=u.defaultSize));let d=this.getProtection().toJSON();d&&(n.protection=d);let f=this._view.toJSON();f&&(n.view=f),this._tabColor&&(n.tabColor=this._tabColor.toString()),this._codeName&&(n.codeName=this._codeName);let p=this._outline.toJSON();p&&(n.outline=p),this._conditionalFormatCalculation||(n.conditionalFormatCalculation=!1),Object.assign(n,this._sheetPr);let m=this._modules?.toJSON();m&&Object.keys(m).length>0&&(n.modules=m)}if(!e?.ignoreStyles){let e=Qo(r.mergeSpatial.all());e.length>0&&(n.merges=Zd(e));let t=Qo(this._composeDirectStyleView().all());if(t.length>0){let e=this._styles.beginPersist();try{let r=t.length,a=[];for(let n=0;n<r;n++){let r=t[n],o=r.value.toJSON();if(!o)continue;let s=e.getElementID(o);a.push([gD.rangeToString(r,i),s])}if(a.length>0&&(n.directStyles=a),this._ownStyles){let t=e.toJSON();t&&Object.keys(t).length>0&&(n.styles=t)}}catch(e){console.warn(e)}finally{e.endPersist()}}let a=Qo(r.hyperlinkSpatial.all()),o=a.length;if(o>0){let e=Array(o);for(let t=0;t<o;t++){let n=a[t],r=n.value;e[t]={r:gD.rangeToString(n,i),v:r}}n.hyperlinks=e}let s=r.ignoredErrors.toJSON(i);s&&(n.ignoredErrors=s)}let o=r.comments.toJSON();o&&o.length>0&&(n.comments=o);let s=r.tables.toJSON();s&&s.length>0&&(n.tables=s);let c=r.autoTables.toJSON();c&&c.length>0&&(n.autoTable=c[0]);let l=r.dataValidations.toJSON();l&&l.length>0&&(n.validations=l),Object.keys(this._validationSettings).length>0&&(n.validationSettings={...this._validationSettings});let u=r.conditionalFormats.toJSON();u&&u.length>0&&(n.conditionals=u);let d=r.protectedRanges.toJSON();d&&d.length>0&&(n.protectedRanges=d);let f=r.cellControls.toJSON();f&&f.length>0&&(n.cellControls=f);let p=r.sparklineGroups.toJSON();p&&p.length>0&&(n.sparklineGroups=p);let m=null,h=null;try{let t=this._searchMovableIndex(r.movableSpatial),i=t.length,a=e?.resources??`embed`,o;a===`ignore`?o=()=>0:(m=this._resources.beginPersist(),o=m.toResourceId.bind(m));let s=a===`ignore`?void 0:o,c,l=this._richValues.beginPersist();try{if(!e?.ignoreData){c=this._strings.beginPersist();let e=e=>c.add(e),t=Yc(this._calcGrid.getValues()),r=t.length;for(let n=0;n<r;n++){let r=t[n][1],i=r.length;for(let t=0;t<i;t++)r[t][1]=Hk.toJSONRun(r[t][1],e,s,l.add)}r>0&&(n.data=t)}if(c&&this._ownStrings&&(n.strings=await c.toJSONAsync()),this._ownRichValues){let e=await l.toJSONAsync(s);if(e.length>0){n.richData=e;let t=l.toKindsJSON();t.length>0&&(n.richTypes=t)}}}catch(e){h=e}finally{c?.endPersist(),l.endPersist()}if(h)throw h;if(i>0){let e=[];for(let n=0;n<i;n++)try{let r=t[n].toJSON?.(o);r&&e.push(r)}catch(e){console.warn(`Unable to persist movable`,e)}e.length>0&&(n.movables=e)}let u=this.getPicture();u&&(n.picture=u.toJSON(o));let d=SR(this._legacyDrawing,o);d&&(n.legacyDrawing=d);let f=SR(this._legacyDrawingHF,o);f&&(n.legacyDrawingHF=f);let p=this._pageLayout.toJSON(o);p&&(n.pageLayout=p);let g=this._getState().pivotTables.all();if(g.length>0){let e=[];for(let t=0;t<g.length;t++){let n=g[t].toJSON(o);n&&e.push(n)}e.length>0&&(n.pivotTables=e)}if(a!==`ignore`&&this._ownResources){let e=await m.toJSONAsync(typeof a==`function`?a:void 0);e.length>0&&(n.resources=e)}}catch(e){e!==h&&console.warn(e)}finally{m?.endPersist()}if(h)throw h;if(a){let e=a.formulas;e&&(n.formulas=e);let t=a.formulaArray;t&&(n.formulaArray=t);let r=a.volatile;r&&(n.volatile=r)}return this._emitter.notify(`onSave`,{params:n}),n}getStyles(){return this._styles}getResources(){return this._resources}getTransactions(){return this._transactions}getStrings(){return this._strings}_searchMovables(e){let t=this._getState();if(t===null)return i.EmptyArray;if(e?.deep){let{type:t,deep:n,...r}=e,i=this._searchMovables(r),a=t===void 0?null:Array.isArray(t)?t:[t],o=[];for(let n of i){a&&!a.includes(n.getContent().getType())||o.push(n);let r=n.getMovables();r&&o.push(...r.getItems({type:t,ignoreHidden:e.ignoreHidden,deep:!0}))}return o}let n=this._searchMovableIndex(t.movableSpatial,e),r=this._searchMovableIndex(t.noteSpatial,e);return r.length===0?n:n.length===0?r:[...n,...r]}_addNoteBox(e,t,n){let r=e.getRange().getCoords(),i={rowIndex:r.rowStart,colIndex:r.colStart},a=this._noteLayout(),o={anchor:t&&`anchor`in t?Ak(t.anchor,i,this._getEntireCoords()):kk(t?Dk(t.bounds,a):Ek(Tk(e=>this._mergeAt(e),i),a),a),content:{type:`note`,json:null}};n&&(o.hidden=!0);let s=this._getState(),c=this._createMovableEntry(o,s.noteSpatial.size(),void 0,this._noteIndex,e),l=c.value.model;if(this._initializing)return s.noteSpatial.insert(c),s.noteMapModel.set(l,c),l;let u=this._beginCommit({description:m(`op.addComment`)});try{let e=s.noteSpatial.clone();e.insert(c);let t=new Map(s.noteMapModel);t.set(l,c),this._updateState({noteSpatial:e,noteMapModel:t}),u.commit()}catch(e){throw u.rollback(),e}return this._emitterMovables.notify(`onCollectionChange`),this._notify(`onMovablesChange`),l}_glueConnectors(e,t=!1){if(this._initializing||this._closed)return;let n=()=>{this._closed||e.isDeleted()||this._amendCurrent(()=>Qe(this,e,n,t))};Qe(this,e,n,t)}_glueStrayConnectors(){if(this._initializing||this._closed)return;let e=this._getState()?.movableSpatial;if(!e)return;if(this._connectorScan?.spatial!==e){let t=e.all().some(e=>ke(e.value.model));this._connectorScan={spatial:e,any:t}}if(!this._connectorScan.any)return;let t=et(this,()=>this._glueStrayConnectors());t.length!==0&&this._amendCurrent(()=>{for(let[e,n]of t)Ue(e,n)})}_mergeAt(e){let t=this._getState()?.mergeSpatial.search(h.cellToRange(e))[0];return t?{rowStart:t.rowStart,colStart:t.colStart,rowEnd:t.rowEnd,colEnd:t.colEnd}:null}_noteLayout(){return{getBoundsAtCoords:this._getBoundsAtCoords.bind(this),getCoordsAtBounds:this._getCoordsAtBounds.bind(this),getMaxBounds:()=>this._getBoundsAtCoords(this._getEntireCoords())}}_maxMovableOverhang(e){let t=be(),n=this._movableOverhangs.get(e);if(n?.version===t)return n.reach;let r=0;for(let t of e.keys()){let e=t._getDrawnBounds?.(this._onMovableDrawnReady);e&&(r=Math.max(r,ot(e.anchor,e.drawn)))}return this._movableOverhangs.set(e,{version:be(),reach:r}),r}_searchMovableIndex(e,t){let n=t?.ignoreHidden??!1,r=t?.bounds,a=t?.fullyContained,o=this,s=this._getState();if(s===null)return i.EmptyArray;let c=t?.address?this._rangeToCoords(t?.address):this._getEntireCoords(),l=c,u=null;if(t?.drawn&&t?.address&&!a){let t=this._maxMovableOverhang(e===s.movableSpatial?s.movableMapModel:s.noteMapModel);if(t>0){u=this._getBoundsAtCoords(c);let e=this._getEntireCoords(),n=Math.max(0,u.x-t),r=Math.max(0,u.y-t),i=this._getCoordsAtBounds({x:n,y:r,width:u.x+u.width+t-n,height:u.y+u.height+t-r});l={rowStart:Math.max(e.rowStart,i.rowStart),colStart:Math.max(e.colStart,i.colStart),rowEnd:Math.min(e.rowEnd,i.rowEnd),colEnd:Math.min(e.colEnd,i.colEnd)}}}let d=this._onMovableDrawnReady;return this._getRangedEntries(e,[l],{ignoreHidden:n,fullyContained:a,onEntry:e=>{if(u&&!h.isRangesIntersect(e.model.getRange().getCoords(),c)){let t=e.model._getDrawnBounds?.(d)?.drawn;if(!t||!Ft(t,u))return null}let i=t?.type;if(i){if(Array.isArray(i)){if(!i.includes(e.model.getContent().getType()))return null}else if(i&&e.model.getContent().getType()!==i)return null}let a=null;if(n&&(e.model.isHidden()||(a=o._getBoundsAtCoords(e.model.getRange().getCoords()),a.width===0||a.height===0)))return null;if(r){a||=o._getBoundsAtCoords(e.model.getRange().getCoords());let t=a,n=r;if(t.y>n.y+n.height||t.y+t.height<n.y||t.x>n.x+n.width||t.x+t.width<n.x)return null}return e.model}}).sort((e,t)=>e.getZIndex()-t.getZIndex())}_updateSelectedMovables(e,t){let n=this.getView().getMovableSelection().getItems();if(n.length===0)return;let r=this._beginCommit({description:t??m(`op.updateMovables`)});try{let t=n.length;for(let r=0;r<t;r++)e(n[r]);DP(r,this,EP(this.getView().getMovableSelection()),{autoSelect:!1,autoSelectRestore:!0}),r.commit()}catch(e){throw r.rollback(),e}}async _addMovable(e){return this._insertMovable(await this._prepareMovable(e))}async _prepareMovable(e){this._checkInsertMovable(e),e.type&&await Ox({type:e.type,json:e.json});let t=e.bounds;return t?.width==null||t.height==null||t.x!=null&&t.y!=null||(e={...e,bounds:await this._placeMovable(e,t)}),e}async _placeMovable(e,t){let{width:n,height:r}=t,i=null;if(e.autoPlace===`viewport`){let e=(await this._emitter.notify(`onRequestViewport`,{async:!0}))?.find(Boolean)??null;e&&(n=Math.min(n,e.width-8),r=Math.min(r,e.height-8),i={x:e.x+(e.width-n)/2,y:e.y+(e.height-r)/2})}i??=this._getBoundsAtCoords(this.getSelection().getRange().getCoords());let a={x:t.x??i.x,y:t.y??i.y,width:n,height:r},o=cD(this.getMovables(),a,t.x==null,t.y==null);return{...a,x:a.x+o.x,y:a.y+o.y}}_checkInsertMovable(e){if(!this.getProtection().isObjectsAllowed())throw new b(N(`error.sheet.insertItemProtected`));if(!e)throw new k(`No movable options provided`);if(this._closed)throw Error(N(`error.sheet.modelClosed`));if(e.type===`note`)throw new k(Tx(e.type))}_insertMovable(e){this._checkInsertMovable(e);let t={};if(e?.type){t.content={type:e.type,json:e?.json},e.name&&(t.content.name=e.name);let n=e.altText;n&&(t.content.description=n)}e?.anchorType&&(t.anchorType=e?.anchorType),e?.rotation&&(t.rotation=e.rotation),e.bounds&&(t.anchor=null);let n=this._getState().movableSpatial,r=this._beginCommit({description:e?.description??m(`op.insertDrawing`)}),i=n.size(),a=Math.max(0,Math.min(i,e.zIndex??i)),o=this._createMovableEntry(t,a,e.fromResourceId),s=n.clone(),c=this._getState().movableMapModel,l=new Map(c),u=[];if(a<i){let e=s.all();for(let t=0;t<e.length;t++){let n=e[t];if(n.value.zIndex<a)continue;let r={...n,value:{...n.value,zIndex:n.value.zIndex+1}};s.remove(n,YR),l.set(r.value.model,r),u.push(r)}s.load(u)}s.insert(o);let d=o.value.model;l.set(d,o),this._updateState({movableSpatial:s,movableMapModel:l});for(let e=0;e<u.length;e++)u[e].value.callbacks.processZIndex?.();if(e.bounds){let t=o.value.model;e.anchorType||t.setAnchorType(t.getContent().getDefaultAnchorType?.()??Ih.Type.TwoCell),t.setBounds(e.bounds,e)}return DP(r,this,[o.value.model],e),r.commit(),this._emitterMovables.notify(`onCollectionChange`),this._notify(`onMovablesChange`),o.value.model}async _groupMovables(e,t){if(!this.getProtection().isObjectsAllowed())throw new b(N(`error.sheet.insertItemProtected`));if(!e||e.length<2)throw new k(N(`error.movable.groupTooFew`));let n=this._getState().movableMapModel;for(let t of e)if(!n.has(t)||t.isDeleted())throw new k(N(`error.movable.groupNotHere`));let r=[...e].sort((e,t)=>e.getZIndex()-t.getZIndex()),i=Le.unionBounds(r.map(e=>Nt(e.getBounds(),e.getRotation()))),a=this._resources.beginPersist();try{let e=r.map(e=>{let t=e.toJSON(a.toResourceId.bind(a)),n=e.getBounds();return delete t.anchorType,{...t,anchor:{tl:{x:n.x,y:n.y},br:{x:n.width,y:n.height}}}}),n={childBounds:{...i},members:e};await Ox({type:`group`,json:n});let o=t?.description??m(`op.groupDrawings`),s=EP(this.getView().getMovableSelection());return await this.doBatch(async()=>{let e=await this._addMovable({type:`group`,json:n,bounds:i,name:t?.name,autoSelect:!1,fromResourceId:a.fromResourceId.bind(a),description:o,zIndex:r[r.length-1].getZIndex()+1});for(let e of r)e.getContent().delete();let c=this._transactions.getPendingTransaction();return c&&DP(c,this,[e],{autoSelect:t?.autoSelect??!0,autoSelectRestore:t?.autoSelectRestore},s),e},{description:o})}finally{a.endPersist()}}async _preparePicture(e,t={type:`picture`}){if(!e)throw new k(N(`error.sheet.noImageProvided`));if(!this.getProtection().isObjectsAllowed())throw new b(N(`error.sheet.insertItemProtected`));let n=this._resources.add(e),r=await n.toBuffer(),a=await n.getType(),{naturalSize:o,asUrl:s}=await l.loadImageDetails(r,a?.mime);URL.revokeObjectURL(s);let c={...o,...t?.bounds};t?.bounds&&!1!==t?.json?.lockAspect&&(i.isNullOrUndefined(t?.bounds.width)&&i.isDefined(t?.bounds.height)&&(c.width=c.height*o.width/o.height),i.isNullOrUndefined(t?.bounds.height)&&i.isDefined(t?.bounds.width)&&(c.height=c.width*o.height/o.width));let u={...t?.json,resId:0};return this._prepareMovable({description:m(`op.insertImage`),...t,bounds:c,type:`picture`,json:u,fromResourceId:e=>e===0?n:(console.warn(`received an unexpected resourceId`,e),null)})}setPicture(e,t){let n=this,r;return e&&(r=new _x({resource:this._resources.add(e),deleteFromContainer:e=>{n._getState().picture&&(n._updateState({picture:null},{description:m(`op.deletePicture`),...e}),n._notify(`onStyleChange`))},transactions:this._transactions})),n._updateState({picture:r},{description:m(r?`op.setPicture`:`op.removePicture`),...t}),n._notify(`onStyleChange`),this}getPicture(){return this._getState().picture??null}getPivotTables(){return this._pivotTableCollection}getTables(){return this._tables}getDataValidations(){return this._dataValidations}getConditionalFormats(){return this._conditionals}getProtectedRanges(){return this._protectedRanges}getCellControls(){return this._cellControls}getSparklineGroups(){return this._sparklineGroups}getComments(){return this._comments}getConditionals(){return this._conditionals}getMovables(){return this._movables}getCharts(){return this._charts}_validateOrRemoveOverlaps(e,t,n=null,r=!1,i=!1){let a=this;t!==`merge`&&dD(this._getMerges([e]),e,(e,n)=>{if(n||!r)throw new k(Ex(t));a._unmerge([e])});let o=[],s=this.getTables().getItems({address:e}),c=s.length;for(let e=0;e<c;e++){let t=s[e];n!==t&&o.push(t.getRange().getCoords())}dD(o,e,(e,n,i)=>{if(n||!r)throw new k(Ex(t));s[i]._remove()});let l=this._getState().autoTables.search(e);if(l.length>0){let n=r||i;dD(l,e,(e,r,i)=>{if(r||!n)throw new k(Ex(t));l[i].value.delete()})}}_getAutoTableCarryOver(e){let t=this.getAutoTable();if(!t||!h.isEqualRanges(t.getRange().getCoords(),e))return null;let n=[],r=t.getActiveFilters();for(let e=0;e<r.length;e++){let t=r[e].getCondition();t&&n.push({index:r[e].getIndex(),...t.toJSON()})}let i=[],a=t.getActiveSorts();for(let e=0;e<a.length;e++)i.push({index:a[e].getIndex(),criteria:a[e].getCriteria()});return n.length===0&&i.length===0?null:{conditions:n,sorts:i}}_addTable(e,t){let n=this._rangeToCoords(e,()=>[`objects`]),r=this._getEntireCoords(),i;typeof t==`boolean`?i=t:t&&(i=t.hasHeader);let a=typeof t!=`object`||t?.properties?.headerRowCount!==0;a?i===void 0&&(i=this._getDefaultSortCriteria(n)?.options?.hasHeader??!1):i=!0;let o=n.rowEnd<r.rowEnd;if(a&&n.rowStart===n.rowEnd&&(i||!o)){if(!o)throw new k(N(`error.sheet.table1By1`));n.rowEnd+=1}let s={...n},c=this._beginCommit({description:m(`op.insertTable`)}),l;try{i||(this._insertCells([{...n,rowEnd:n.rowStart}],B.Axis.Row),o&&(n={...n,rowEnd:n.rowEnd+1}));let e=this._getAutoTableCarryOver(n);this._validateOrRemoveOverlaps(n,`table`,null,!1,!0);let r=t,a=r?.properties?.style??{};typeof a==`string`&&(a={name:a});let u={...r?.properties,style:a};u.style=a,a.name===void 0&&(a.name=this._styles.getTableStyles().getDefault().getName());let d=this._getState().tables;d=this._createTables(d,`tables`,[{r:n,v:u}],e=>{let t=new yy({...e,syncSheet:!0,hasTotals:!0===r?.hasTotals});return l=t,t}),this._updateState({tables:d}),l._showTotalsFromProps(),l._detectCalculatedColumns(),this._tellFiltered(),this._notifyTablesChange(),r?.disabledAutofit||this._autoFit(l.getRanges().getCoords(),{expandOnly:!0,formulaView:!1}),e&&(e.sorts.length>0&&l.sort({sorts:e.sorts}),e.conditions.length>0&&l._carryFilters(e.conditions));let f=SD([n]);this._recordSelection(c,f,typeof t==`object`?t:null),this._recordChange(c,`anchored`,[s,n]),c.commit()}catch(e){throw c.rollback(),e}return l}_addAnchored(e,t,n){let{index:r=0,replaceExisting:i=!1,description:a=n.description,autoSelect:o,author:s,readOnly:c,expectedCommitId:l,...u}=t??{},d,f;e||=this.getSelectedRanges(),n.isItem(e)?(d={...e.toJSON()},f=e.getRanges().getCoords()):(d=u,f=e);let p=this._rangesToCoords(f,this._isMoveRuled?null:()=>n.allowance),m=SD(p),g=[...p],_=this._beginCommit({description:a}),v;this.getProtection().isLocked()&&this._recordSkipProtectionCheck(_);try{let e=this._getState()[n.key],t=i?e.getByIndex(r):null;t&&Jz(e.getCoords(t)??void 0,h.sanitizeRangeArray(p)??void 0)&&(n.isSameItem?.(t,d)??1)?(n.replace(t,d,{description:a}),v=t):(e=n.load(e,{r:p,v:n.prepareInsert?.(d)??d},e=>{v=e}),r<e.size()-1&&(e=e.setIndex(v,r)),this._updateState({[n.key]:e}),n.autoFit&&this._autoFit(v.getRanges().getCoords(),{expandOnly:!0,formulaView:!1})),n.notify(),m&&this._recordSelection(_,m,{autoSelect:o}),this._recordChange(_,`anchored`,g),_.commit()}catch(e){throw _.rollback(),e}return v}_addDataValidation(e,t){return this._addAnchored(e,t,{key:`dataValidations`,isItem:e=>!!e?.isIDataValidation,description:m(`op.insertDataValidation`),allowance:[],load:(e,t,n)=>this._createDataValidations(e,`dataValidations`,[t],e=>{let t=new tO(e);return n(t),t}),replace:(e,t,n)=>{e.update(t,n)},notify:()=>this._notifyDataValidationsChange(),autoFit:!0})}_addConditionalFormat(e,t){return this._addAnchored(e,t,{key:`conditionalFormats`,isItem:e=>!!e?.isIConditionalFormat,description:m(`op.insertConditionalFormat`),allowance:[`formatCells`],load:(e,t,n)=>this._createConditionalFormats(e,`conditionalFormats`,[t],e=>{let t=new MD(e);return n(t),t}),isSameItem:(e,t)=>t.scale!==void 0&&e.getScale()?.type===t.scale.type,replace:(e,t,n)=>{e.update(MD.replaceModifiers(t),n)},notify:()=>this._notifyConditionalFormatsChange(),autoFit:!0})}_nextProtectedRangeName(){let e=this._getState()?.protectedRanges;if(!e)return`Range1`;for(let t=1;;t++){let n=`Range${t}`;if(!e.getByName(n))return n}}_addProtectedRange(e,t){return this._addAnchored(e,t,{key:`protectedRanges`,isItem:e=>!!e?.isIProtectedRange,description:m(`op.insertProtectedRange`),allowance:[],load:(e,t,n)=>this._createProtectedRanges(e,`protectedRanges`,[t],e=>{let t=new lO(e);return n(t),t}),prepareInsert:e=>!e.name||this._getState().protectedRanges.getByName(e.name)?{...e,name:this._nextProtectedRangeName()}:e,replace:(e,t,n)=>{let r=t.name?this._getState().protectedRanges.getByName(t.name):null,i=!t.name||r&&r!==e?void 0:t.name;e.update({...t,name:i},n)},notify:()=>this._notifyProtectedRangesChange()})}_addCellControl(e,t,n){if(!t)throw new k(N(`error.cellControl.noType`));return this._setCellControl(e,t,{description:m(`op.insertCellControl`),...n})}_addSparklineGroup(e,t,n){if(e.length===0)return null;let r=Array(e.length),i=Array(e.length);for(let t=0;t<e.length;t++)r[t]=e[t].location,i[t]=IO(e[t]);return this._putSparklineGroup(r,i,t,n)}_setSparkline(e,t,n,r){let i=h.sanitizeRangeArray(this._rangesToCoords(e,this._isMoveRuled?null:()=>[`formatCells`]));if(!i||i.length!==1)throw new k(N(`error.sparkline.location`));let a=i[0],o=this._sparklineDataRange(t),s=function(e,t){let n=sk([e],[t]);return`refused`in n?n:{first:n.pairs[0].first}}(a,o.getCoords());`refused`in s&&this._refuseSparklinePairing(s.refused);let c=this._sparklinePrefix(o)+Wd(s.first),l=dk.applyModifiers(dk.freshProperties(n?.type??void 0),n??{});return this._putSparklineGroup([a],[c],l,{description:m(`op.insertSparklines`),...r},!0)}_refuseSparklinePairing(e){switch(e){case`location2D`:throw new k(N(`error.sparkline.location2D`));case`data2D`:throw new k(N(`error.sparkline.data2D`));case`transposed`:throw new k(N(`error.sparkline.transposed`));case`count`:throw new k(N(`error.sparkline.count`))}}_sparklinePrefix(e){let t=e.getWorksheet();return t&&t!==this?Ld(t.getName())+`!`:``}_modifySparklineGroup(e,t,n,r){if(e.isDeleted())throw new k(N(`error.sparkline.location`));let i=t===null?dk.locationsOf(e._rangesNow()):h.sanitizeRangeArray(this._rangesToCoords(t,this._isMoveRuled?null:()=>[`formatCells`]));if(!i||i.length===0)throw new k(N(`error.sparkline.location`));t!==null||this._isMoveRuled||this._protectionCheck(()=>[`formatCells`],i,m(`op.editSparklineGroup`));let a=this._sparklineDataAreas(n??e.getDataRanges()),o=Array(a.length);for(let e=0;e<a.length;e++)o[e]=a[e].getCoords();let s=sk(i,o);`refused`in s&&this._refuseSparklinePairing(s.refused);let c=s.pairs,l=Array(c.length),u=Array(c.length);for(let e=0;e<c.length;e++)l[e]=c[e].location,u[e]=this._sparklinePrefix(a[c[e].dataIndex])+Wd(c[e].first);let d=dk.locationsOf(e._rangesNow()),f=this._beginCommit({description:r?.description??m(`op.editSparklineGroup`)});this.getProtection().isLocked()&&this._recordSkipProtectionCheck(f);try{let t=this._getState().sparklineGroups,n=new Set;for(let r=0;r<l.length;r++){let i=t.search(l[r]);for(let t=0;t<i.length;t++){let r=i[t].value;r&&r!==e&&n.add(r)}}for(let e of n){let n=t.getCoords(e);n&&(t=t.setCoords(e,mm(n,l)))}n.size>0&&this._updateState({sparklineGroups:t}),e._restate(l,u),this._notifySparklineGroupsChange(),this._recordChange(f,`anchored`,[...d,...l]),f.commit()}catch(e){throw f.rollback(),e}}_sparklineDataAreas(e){let t=[];if(typeof e==`string`){let n=Xd(e.trim().startsWith(`=`)?e.trim().substring(1):e);for(let e=0;e<n.length;e++)t.push(this._sparklineDataRange(n[e]))}else if(e.isICellRanges){let n=e,r=n.getCount();for(let e=0;e<r;e++)t.push(this._sparklineDataRange(n.at(e)))}else if(e.isICellRange)t.push(this._sparklineDataRange(e));else if(Array.isArray(e))for(let n=0;n<e.length;n++)t.push(this._sparklineDataRange(e[n]));else{let n=this.getRanges(e),r=n.getCount();for(let e=0;e<r;e++)t.push(this._sparklineDataRange(n.at(e)))}return t}_sparklineDataRange(e){let t;try{if(typeof e==`string`){let n=e.trim();if(n.startsWith(`=`)&&(n=n.substring(1)),n.includes(`[`))throw new k(N(`error.sparkline.structured`));let r=this.getWorkbook(),i=this.getNames().getByName(n)??r?.getNames().getByName(n)??null;i?.getType()===`formula`&&(n=String(i.getValue()).trim(),n.startsWith(`=`)&&(n=n.substring(1))),t=n.includes(`!`)&&r?r.getRanges(n):this.getRanges(n)}else if(e.isICellRange){let n=e;t=n.getWorksheet().getRanges(n.getCoords())}else t=this.getRanges(e)}catch(e){throw e instanceof k?e:new k(N(`error.sparkline.data`))}if(t.getCount()!==1)throw new k(N(`error.sparkline.union`));let n=t.at(0);if(n.isInvalid())throw new k(N(`error.sparkline.data`));return n}_putSparklineGroup(e,t,n,r,i=!1){let a=r?.description??m(`op.updateSparklineGroup`),o=this._beginCommit({description:a});i&&this.getProtection().isLocked()&&this._recordSkipProtectionCheck(o);try{let r=this._getState().sparklineGroups,i=new Set;for(let t=0;t<e.length;t++){let n=r.search(e[t]);for(let e=0;e<n.length;e++)n[e].value&&i.add(n[e].value)}for(let t of i){let n=r.getCoords(t);n&&(r=r.setCoords(t,mm(n,e)))}let a=new Set(r.all());r=this._createSparklineGroups(r,[{r:e,v:{...n,data:t.join(`,`)}}]);let s=null,c=r.all();for(let e=0;e<c.length&&!s;e++)a.has(c[e])||(s=c[e]);return this._updateState({sparklineGroups:r}),this._notifySparklineGroupsChange(),this._recordChange(o,`anchored`,e),o.commit(),s}catch(e){throw o.rollback(),e}}_setCellControl(e,t,n){let r=t?pO.normalizeJSON(t):null,i=n?.description??m(r?`op.setCellControl`:`op.removeCellControl`),a=h.sanitizeRangeArray(this._rangesToCoords(e,this._isMoveRuled?null:()=>[`formatCells`]));if(!a||a.length===0)return null;let o=this._getState().cellControls;if(!r&&!o.has(h.unionRangesArrays(a)))return null;let s=this._beginCommit({description:i});this.getProtection().isLocked()&&this._recordSkipProtectionCheck(s);try{let e=null;if(r){let t=o.all();for(let n=0;n<t.length&&!e;n++)pO.isSameJSON(t[n].toJSON(),r)&&(e=t[n])}let t=new Set;for(let n=0;n<a.length;n++){let r=o.search(a[n]);for(let n=0;n<r.length;n++){let i=r[n].value;i&&i!==e&&t.add(i)}}for(let e of t){let t=o.getCoords(e);t&&(o=o.setCoords(e,mm(t,a)))}let n=e;return e?o=o.setCoords(e,bm(o.getCoords(e)??[],a)):r&&(o=this._createCellControls(o,`cellControls`,[{r:a,v:r}],e=>(n=new pO(e),n))),this._updateState({cellControls:o}),this._notifyCellControlsChange(),this._recordChange(s,`anchored`,a),s.commit(),n}catch(e){throw s.rollback(),e}}_addComment(e,t,n){let{replaceExisting:r=!1,description:i=m(`op.addComment`),autoSelect:a,...o}=n??{},s=this._rangeToCoords(e,()=>[`objects`]);if(s.rowStart!==s.rowEnd||s.colStart!==s.colEnd)throw new k(N(`error.comment.singleCell`));let c=this._beginCommit({description:i}),l;try{let e=this._getState().comments.search(s)[0]?.value??null;if(e){if(!r)throw new k(N(`error.comment.cellHasComment`));e.delete()}let n=this._createComments(this._getState().comments,`comments`,[{r:s,v:this._newCommentJSON({...o,content:t})}],e=>{let t=new jk(e);return l=t,t});this._updateState({comments:n}),this._notifyCommentsChange(),this._recordSelection(c,SD([s]),{autoSelect:a}),this._recordChange(c,`comments`,[s]),c.commit()}catch(e){throw c.rollback(),e}return l}createCell(e,t=null,n){return e?.createCell?e:(t?this.getRange(t).getCell():this._emptyCell).createCell(e,n)}_getBoundsAtCoords(e){let t=this._rowHeaders,n=this._colHeaders,r=n.getMetrics().getOffset(e.colStart),i=t.getMetrics().getOffset(e.rowStart);return{x:r,y:i,width:n.getMetrics().getOffset(e.colEnd+1)-r,height:t.getMetrics().getOffset(e.rowEnd+1)-i}}_getCoordsAtBounds(e){let t=this._rowHeaders,n=this._colHeaders,r=e.x,i=e.y;return{colStart:n.getMetrics().getIndex(r),rowStart:t.getMetrics().getIndex(i),colEnd:n.getMetrics().getIndex(r+e.width),rowEnd:t.getMetrics().getIndex(i+e.height)}}getRangeAtBounds(e,t){if(!e)throw new y;let n=this._getCoordsAtBounds(e);return this.getRange(n,t)}getRangeAt(e,t,n,r,i){return this.getRange({rowStart:e,colStart:t,rowEnd:n??e,colEnd:r??t},i)}_getVisible(e,t){return function(e,t,n){if(t.length===0)return t;let r=new fc;r.load(t);let i=n?.axes??B.AxisSelection.Both,a=(e,t)=>{let n=r.search(e),i=n.length;for(let a=0;a<i;a++){let i=n[a],o=uD(i,e,t);r.remove(i),r.load(o)}},o=e.getEntireCoords();if(i===B.AxisSelection.Both||i===B.AxisSelection.Row){let n=e.rowHeaders,r=t.length;for(let e=0;e<r;e++){let r=t[e];n.getRange({min:r.rowStart,max:r.rowEnd}).forEachSpan((e,t)=>{if(e!==0)return;let n=t.getCoords();a({colStart:o.colStart,rowStart:n.min,colEnd:o.colEnd,rowEnd:n.max},B.Axis.Row)})}}if(i===B.AxisSelection.Both||i===B.AxisSelection.Column){let n=e.columnHeaders,r=t.length;for(let e=0;e<r;e++){let r=t[e];n.getRange({min:r.colStart,max:r.colEnd}).forEachSpan((e,t)=>{if(e!==0)return;let n=t.getCoords();a({colStart:n.min,rowStart:o.rowStart,colEnd:n.max,rowEnd:o.rowEnd},B.Axis.Column)})}}return r.all().sort(h.rowFirstRangeComparator)}(this._getReadCtx(),e,t)}_hasRangedEntries(e,t){return function(e,t,n){let r=e.state;if(!r)return!1;let i=r[t];if(!i)throw new k(`Invalid range key ${t}`);return!i.isEmpty()&&i.has(n)}(this._getReadCtx(),e,t)}_getRangedEntries(e,t,n,r=!1){return function(e,t,n,r){if(n.length===0||!t||t.isEmpty())return i.EmptyArray;let a=r?.spatialSort??!1,o=r?.ignoreHidden??!1,s=r?.fullyContained??!1,c=r?.onEntry??null,l=r?.onFound??null,u=r?.sort,d;u&&(d=h.createRangeComparator(u.axis,u.reverse));let f=new Set,p=(e,t)=>{let n=e.length,r=l&&d?[...e].sort(d):e;for(let e=0;e<n;e++){let n=r[e];l&&l(n,t),f.add(n)}},m=n.length;for(let r=0;r<m;r++){let i=n[r];if(o){if(!0===o){let n={min:i.colStart,max:i.colEnd},r={min:i.rowStart,max:i.rowEnd};e.rowHeaders.getRange(r).forEachSpan((r,i)=>{let o=i.getCoords(),c=o.min,l=o.max;e.columnHeaders.getRange(n).forEachSpan((e,n)=>{let r=n.getCoords(),i=r.min,o=r.max,u={colStart:i,rowStart:c,colEnd:o,rowEnd:l},d=t.search(u,s,a);d.length>0&&p(d,u)},hI)},hI)}else if(o===B.Axis.Column){let n={min:i.colStart,max:i.colEnd};e.columnHeaders.getRange(n).forEachSpan((e,n)=>{let r=n.getCoords(),o=r.min,c=r.max,l={colStart:o,rowStart:i.rowStart,colEnd:c,rowEnd:i.rowEnd},u=t.search(l,s,a);u.length>0&&p(u,l)},hI)}else if(o===B.Axis.Row){let n={min:i.rowStart,max:i.rowEnd};e.rowHeaders.getRange(n).forEachSpan((e,n)=>{let r=n.getCoords(),o=r.min,c=r.max,l={colStart:i.colStart,rowStart:o,colEnd:i.colEnd,rowEnd:c},u=t.search(l,s,a);u.length>0&&p(u,l)},hI)}}else{let e=i,n=t.search(e,s,a);n.length>0&&p(n,e)}}if(f.size===0)return i.EmptyArray;let g=Array.from(f.values());d&&g.sort(d);let _=[],v=new Set,y=g.length;for(let e=0;e<y;e++){let t;c&&(t=c(g[e].value,g[e])),t===void 0&&(t=g[e].value),t===null||v.has(t)||(v.add(t),_.push(t))}return _||=i.EmptyArray,_}(this._getReadCtx(),e,t,r?{...n,spatialSort:!0}:n)}_processAnchorShift(e){let t=e.after,n=h.sanitizeRange(e.after),r=h.sanitizeRange(e.before);e.after&&this._validateCoords(n,N(`error.sheet.insertItemOob`));let i=e.before.value.callbacks?.processShift?.({...e,after:n,before:r});return i&&(qz(i,n)||(t||=e.before,t={...t,...i})),t}delete(){if(this._closed)return;try{this._notify(`onBeforeDelete`)}catch(e){throw e instanceof Error?e:new k(e.message??N(`error.sheet.modelDelete`))}let e=this._beginCommit({description:N(`op.deleteSheet`,{name:this.getName()})});this._getState(),this._updateState({deleted:!0}),this._calcGrid.delete(this._requestFor(e)),this._listenerNodes.forEach(e=>{e.watch&&e.node.host.dispose()}),this._deleteCells([this._getEntireCoords()]),this._notify(`onDelete`),e.commit()}doBatch(e,t){let n=this;t=typeof t==`string`?{description:t}:{description:m(`op.updateSheet`),...t};let r=F.bind(this._transactions,this,e);return this._transactions.doBatch(r.callback,{...t,onChildCommit:r.onChildCommit},(e,i)=>{if(r.close(),e.getDepth()===0&&t?.autoSelect){let t=n.getId();e.setIntent(hP,e=>({...e,[t]:!0}))}})}isDeleted(){let e=this._getState();return!e||e?.deleted}isClosed(){return this._closed}close(){if(this._closed)return;this._cellBuffer?.discard(),this._protectionRemoveListener?.(),this._protection=new yh(void 0,this._options.readonly);let e=this._getState();e.tables.close(),e.autoTables.close(),e.pivotTables.close(),this._searchMovables().forEach(e=>{e.close()}),this._notify(`onClose`),this._ownResources,this._languageRemoveListener?.(),this._languageRemoveListener=void 0,this._fontsRemoveListener?.(),this._fontsRemoveListener=void 0,this._regionalRemoveListener?.(),this._regionalRemoveListener=void 0,this._namesRemoveListener?.(),this._ownNames&&this._names.close(),this._ownCalculation&&this._calculation.close(),this._ownStyles,this._modules.close(),this._outline?.close(),this._colHeaders.close(),this._rowHeaders.close(),this._emitter.close(),this._transactionsRemoveListener?.(),this._transactionsCloseRemoveListener?.(),this._ownsCalcGrid&&this._calcGrid?.close(),this._closed=!0}beginCommit(e){if(this._closed)throw Error(N(`error.sheet.modelClosed`));return this._beginCommit(typeof e==`string`?{description:e}:e)}_getState(){return this._closed?null:this._transactions.getState(this._stateId)}_getStateId(){return this._stateId}_beginCommit(e){let t=typeof e==`string`?{description:e}:{...e};return this._transactions.beginCommit(t)}_updateState(e,t){if(!e)return;this._lastGetRangeRead=null;let n=this._transactions.beginCommit(t),r;try{r=n.updateState(this._stateId,e),n.commit()}catch(e){throw n.rollback(),e}return r}_getScalar(e,t,n=!1){let r,i=null,a=null,o=this._cellBuffer;if(o!==null&&o.isHolding()){let s=o.read(e,t);if(s===cI.NotHeld){a=o.getTransaction(),i=a.getState(this._stateId);let r=n?o.readStyleUpdate(e,t):void 0;if(r!==void 0){let n=this._calcGrid.getValues(a).getValueAt(e,t);return typeof n==`number`?RF(this._getMutationCtx(),i.contentSpatial,e,t,r)?he(n,this._isDate1904):n:n??null}}else if(s!==void 0){if(!n||typeof s!=`number`)return s;a=o.getTransaction(),i=a.getState(this._stateId);let c=o.readStyleUpdate(e,t);if(c!==void 0)return RF(this._getMutationCtx(),i.contentSpatial,e,t,c)?he(s,this._isDate1904):s;r=s}}if(i===null&&(i=this._getState()),r===void 0&&(r=this._calcGrid.getValues(a).getValueAt(e,t)),r===void 0)return null;let s=r;if(n&&typeof s==`number`){let n=!1;jR.colStart=t,jR.rowStart=e,jR.colEnd=t,jR.rowEnd=e;let r=this._lastValueRead,a=this._lastValueRead.range;if(a&&h.isRangeWithinRange(jR,a))n=r.isDateOrTime;else{let e=rD(i.dateFormatSpatial,i.pivotTables,i.contentSpatial).search(jR);n=e.length>0,n&&(r.range=e[0],r.isDateOrTime=!0)}n&&(s=he(s,this._isDate1904))}return s}_markColumnHeaderTableNames(){let e=this._getState();if(!e)return;let t=this.getView().getColumnHeaderTableNames(),n=this._cacheTableColumnHeaders,r=n.showInHeader,i=e.tables;if(t===Pk.ColumnHeaderTableNames.None||i.isEmpty())return void(n.table&&(n.table=null,n.showInHeader=!1,n.tableMin=-1,n.tableMax=-1,n.lastTop=-1,n.lastColIndex=-1,n.lastRowIndex=-1,r&&this._notify(`onViewChange`)));let a=this.getSelection().getCoords().cell,o=a.colIndex,s=a.rowIndex,c=o!==n.lastColIndex||s!==n.lastRowIndex,l=n.table,u;if(c?(n.lastColIndex=o,n.lastRowIndex=s,l&&h.isCellWithinRange(a,l.getRange().getCoords())?u=l:(LR.colStart=o,LR.rowStart=s,LR.colEnd=o,LR.rowEnd=s,u=i.search(LR)[0]?.value??null)):u=l,!u)return n.showInHeader=!1,n.table=null,n.tableMin=-1,n.tableMax=-1,void(r&&this._notify(`onViewChange`));n.table=u;let d=u.getRange().getCoords();if(!d)return;let f;if(n.tableMin=d.colStart,n.tableMax=d.colEnd,t===Pk.ColumnHeaderTableNames.Sticky){let e=n.lastTop,t=this.getView(),r=t.getFreezePanes(),i=((r.coords?.rowIndex??0)>0?r.topLeft:t.getTopLeft())?.top??e;if(e===i&&l===u)return;n.lastTop=i;let a={colIndex:d.colStart,rowIndex:this.getRowHeaders().getMetrics().getIndex(i)-1};f=h.isCellWithinRange(a,d)}else t===Pk.ColumnHeaderTableNames.Hidden&&(f=u.isITable&&!u.isHeaderVisible());n.showInHeader=f,f!==r&&this._notify(`onViewChange`)}_getCellAt(e,t){let n=this._cellBuffer;if(n!==null&&n.isHolding()){let r=n.readCell(e,t);if(r!==void 0){let i=n.getTransaction(),a=this._getCellAtState(i.getState(this._stateId),i,e,t,r===cI.NotHeld?null:r);if(a!==null)return a}}let r=this._getState();return r?this._getCellAtState(r,null,e,t,null):this._emptyCell}_getCellAtState(e,t,n,r,i){let a={rowIndex:n,colIndex:r},o;if(i?.isValueHeld)o=i.value;else{let e=this._calcGrid.getValues(t).getValueAt(n,r);o=e===void 0?null:e}let s=[];this._collectRanges(h.cellToRange(a),s,!0,e,void 0,t);let c=Wz(s);if(i){if(i.isValueHeld&&c&&(c.formula||c.spills||c.calcStatus||c.calcError||c.circular))return null;let e=i.formula;if(e!==null){let t=this._cellBuffer.getGeneration(),i=this;c={...c,formula:new TA(e,{colStart:r,rowStart:n,colEnd:r,rowEnd:n},()=>{if(!i._cellBuffer?.isHeldGeneration(t))return i._calcGrid?.getFormulaAt(n,r)??null})}}if(i.style!==void 0&&(c=IF(this._getMutationCtx(),c,n,r,i.style),c===null))return null}if(c&&Object.keys(c).length===0&&(c=null),o===null&&!c)return new SN(this._cellOptions,a);let l=o===null?U.Null:pB(o);return new SN(this._cellOptions,a,l,o,c)}_queryStyle(e,t,n){if(this._closed)throw Error(N(`error.sheet.modelClosed`));RR.length=0;let r=RR,i,a=null,o=null,s=this._cellBuffer;if(s!==null&&s.isHolding()&&(!n||h.isSingleCell(n))){let t=s.readCell(e.rowStart,e.colStart);if(t!==void 0){let e=s.getTransaction();i=e.getState(this._stateId),a=e,t!==cI.NotHeld&&(o=t)}}this._collectRanges(e,r,!0,i??this._getState(),void 0,a);let c=Wz(r);if(o?.style!==void 0){let t=IF(this._getMutationCtx(),c,e.rowStart,e.colStart,o.style);t===null?(r.length=0,this._collectRanges(e,r),c=Wz(r)):c=t}return hN(null,e,c,t,!0,n)}_getStyle(e,t,n){let r;if(t)r={colStart:t.cell.colIndex,rowStart:t.cell.rowIndex,colEnd:t.cell.colIndex,rowEnd:t.cell.rowIndex};else{let t=e[0];r={colStart:t.colStart,rowStart:t.rowStart,colEnd:t.colStart,rowEnd:t.rowStart}}let i=e.length===1?e[0]:void 0,a=this,o=this._cellOptions;return o={...o,styleUpdater:(t,s)=>(n?n(t,s):a._updateStyles(e,t,s),a._queryStyle(r,o,i))},a._queryStyle(r,o,i)}_initHeadersState(e,t){let n=this;this._cacheTableColumnHeaders={table:null,showInHeader:!1,tableMin:-1,tableMax:-1,lastTop:0,lastColIndex:-1,lastRowIndex:-1},this._defaultFontBoundsCache=null,this._defaultColWidthCache=0,this._defaultRowHeightCache=0,this._colHeadersRemoveListener?.(),this._colHeadersHiddenRemoveListener?.(),this._colHeaders=new vF({sheet:n,json:e,axis:B.Axis.Column,transactions:this._transactions,isProtected:()=>!n._initializing&&!n.getProtection().isFormatColumnsAllowed(),getColumnAt:e=>{let t=n._cacheTableColumnHeaders;if(!t.showInHeader||e>t.tableMax||e<t.tableMin)return null;let r=e-t.tableMin;return t.table.getColumnAt(r)},getTextAt:e=>{let t=n._cacheTableColumnHeaders;if(t.showInHeader&&e<=t.tableMax&&e>=t.tableMin){let n=t.table.getColumns()[e-t.tableMin];if(n&&n.getName()!==void 0)return n.getName()}let r=this.getView().getColumnHeaderStyle();return r===Pk.HeaderTextStyle.A1?VR(e):r===Pk.HeaderTextStyle.Zero?BR(e):r===Pk.HeaderTextStyle.One?HR(e):void 0},defaultSize:()=>this._defaultColWidth(),scaleFactor:()=>{let e=this.getView().isShowFormulas()?2:1;return Math.round(this._defaultFontDims().width)*e},maxSize:()=>255,getEntireSheetCoords:()=>n._getEntireCoords(),setContainerShiftedCallback:e=>{this._colHeadersShiftCallback=e},hiddenChanged:()=>n._tellHidden(B.Axis.Column)}),this._colHeadersRemoveListener=this._colHeaders.addListeners(this._colHeadersListener,{transactional:!0}),this._colHeadersHiddenRemoveListener=this._colHeaders.addListeners({onHiddenChange:()=>{n._notify(`onColumnsHiddenChange`)}},{transactional:!1}),this._rowHeadersRemoveListener?.(),this._rowHeadersHiddenRemoveListener?.();let r=I.getDeviceScale();this._rowHeaders=new vF({sheet:n,json:t,axis:B.Axis.Row,transactions:this._transactions,isProtected:()=>!n._initializing&&!n.getProtection().isFormatRowsAllowed(),getTextAt:e=>{let t=this.getView().getRowHeaderStyle();return t===Pk.HeaderTextStyle.One?HR(e):t===Pk.HeaderTextStyle.Zero?BR(e):t===Pk.HeaderTextStyle.A1?VR(e):void 0},defaultSize:()=>this._defaultRowHeight(),scaleFactor:()=>r,minSize:()=>0,maxSize:()=>409,getEntireSheetCoords:()=>n._getEntireCoords(),setContainerShiftedCallback:e=>{this._rowHeadersShiftCallback=e},hiddenChanged:()=>n._tellHidden(B.Axis.Row)}),this._rowHeadersRemoveListener=this._rowHeaders.addListeners(this._rowHeadersListener,{transactional:!0}),this._rowHeadersHiddenRemoveListener=this._rowHeaders.addListeners({onHiddenChange:()=>{n._notify(`onRowsHiddenChange`)}},{transactional:!1})}_tellHidden(e){if(this._closed||!this._ownsCalcGrid)return;let t=this._transactions.getCurrentTransaction(),n=this._calcGrid;if(!t||!n)return;let r=e===B.Axis.Column?this._colHeaders:this._rowHeaders;n.setHidden(e,Bz(r),this._requestFor(t))}_invalidateCaches(){this._lastCellDecoded.address=null,this._lastCellSelected.coords=null,this._lastCellRead.coords=null,this._lastValueRead.range=null;let e=this._cellOptions?.renderCellCache;e&&e.size>0&&e.clear(),this._lastGetRangeRead={},this._lastUsedCoordsRead.coords=null,this._lastRangeRead.address=null,this._entireCoordsCache=null,this._entireRangeCache=null}_initListenerState(){let e=this,t=()=>{e._invalidateCaches()};this._transactionsRemoveListener=this._transactions.addStateListener(this._stateId,{onBeforeCommitStart(t,n,r,i,a){if(!e._initializing){if(!(a?.[`sheet.skipProtectionCheck`])?.includes(e.getId())&&e.getProtection().isLocked())throw new b(N(`error.sheet.protectedSheet`));if(t?.entireCoords){let n=e._view?.getRangeSelection();n&&n.updateCoords(e._selectionWithinEntire(n.getCoords(),t.entireCoords))}}},async onBeforeCommitEnd(t,n,r,i,a){e._resolveAutoFit(n);let o=e._changedRanges(a,[`address`]),s=o?e._pivotsWaitingOn(o):null;s&&e._unblockPivots(s);let c=n.getId(),l=e=>e.batch?.getCommitId()!==c,u={commit:n,timeStamp:n.getTimestamp()};e._notifyListenerNodeMoves(t,!0,u,l),e._notifyListenerNodes(t,e._changedRanges(a),u,!0,!!e._changedRanges(a,[`sheets`]),l)},async onRestoreOrRevert(n,r,i,a,o){t(),e._calculateFull();let s=e._restoredSelection(o,i);s&&e._autoSelect(s.options||!0,s.selection);let c=o?.[vP]?.[e.getId()];c&&e.getView().setFreezePanes({coords:i?c.before:c.after});let l=OP(o,e.getId(),e.getView().getId(),i?`undo`:`redo`);l&&e.getView().getMovableSelection().select(e._movablesOfIds(l)),e._notify(`onViewChange`),e._notify(`onInvalidated`),e._emitterMovables.notify(`onInvalidated`),e._notifyUsedRangeChange()},async onAfterStateChange(n,r,i,a,o,s){t();let c=e._sheetEvents(o);e._normalizeSelection(!!c?.merges);let l={commit:r,previous:s,isUndo:i,isStructural:!!c?.address?.length,shifts:e._sheetShifts(o,i)},u=e._commitChanges(c,l),d=i||a;for(let t of u)!d||t.key!==`onMergesChange`&&t.key!==`onSpillsChange`||e._notifyChange(t.key,t.coords,t.details);if(e._notifyListenerNodeMoves(n,!1,{commit:r,isUndo:i,timeStamp:r.getTimestamp()}),e._notifyListenerNodeMoves(n,!0,null),(o?.[`sheet.initial`])?.includes(e.getId()))return;let f=e._changedRanges(o);if(f&&((i||a)&&(e._calculation.getStatus()!==Q.Status.Off&&e._calcGrid.revert({commitId:r.getId()}),e._calcGrid.markDirtyRegions(f)),e._calculation.getStatus()!==Q.Status.Off&&e._calcGrid.calculate()),f){e._notifyUsedRangeChange(),e._notifyListenerNodes(n,f,{commit:r,isUndo:i,timeStamp:r.getTimestamp()},!1,!!e._changedRanges(o,[`sheets`]));for(let t of u)!d||t.key!==`onStyleChange`&&t.key!==`onDataChange`||e._notifyChange(t.key,t.coords,t.details)}},onClose(){let t=e._getState();t&&(t.movableSpatial.clear(),t.noteSpatial.clear())}}),this._transactionsCloseRemoveListener=this._transactions.addListener({onCommitStart(){e._selectionAtCommitStart=e._view?.getRangeSelection().getCoords()??null},onCommitClose(t,n,r,i){e._onRootTransactionClose(t,n,r,i)},onCommitEnd(t){e._releaseHeldPassRanges();let n=e._movableSelectionAtCommitEnd.get(t);e._movableSelectionAtCommitEnd.delete(t),n&&e.getView().getMovableSelection().select(e._movablesOfIds(n))},onAmendEnd(){e._releaseHeldPassRanges()}}),this._colHeadersListener={onMetricsChange:t=>{e._isAdjustHeaders||e._processLayoutChange()}},this._rowHeadersListener={onMetricsChange:t=>{e._isAdjustHeaders||e._processLayoutChange()}};let n=new Set,r={onTopLeftChange(t){e._markColumnHeaderTableNames(),e._notify(`onTopLeftChange`)},onZoomScaleChange(t){e._notify(`onZoomScaleChange`)},onFreezePaneChange(t){e._notify(`onFreezePaneChange`)},onHeaderChange(t){e._markColumnHeaderTableNames(),e._notify(`onNameChange`)},onSelectionChange(t){e._markColumnHeaderTableNames(),e._notify(`onSelectionChange`)},onMovableSelectionChange(t){let r=t.getMovableSelection(),i=r.getItems(),a=r.getActive(),o=new Map,s=new Set,c=e._getState().movableMapModel,l=i.length;for(let e=0;e<l;e++){let t=i[e];n.has(t)?n.delete(t):o.set(t,t===a),s.add(t)}let u=e._getState().noteMapModel,d=(e,t,n)=>{let r=(e=>c.get(e)??u.get(e))(e);r?r.value?.callbacks.processSelection(t,n):e.getParent()&&e._processSelection?.(t,n)};n.forEach(e=>d(e,!1,!1)),o.forEach((e,t)=>d(t,!0,e)),n=s,e._notify(`onMovableSelectionChange`)},onAnyChange(){e._defaultColWidthCache=0,e._defaultRowHeightCache=0,e._defaultFontBoundsCache=null,e._notify(`onLayoutChange`),e._notify(`onViewChange`)}};this._viewListener=r,this._protectionListener={onLockChange(){if(e._closed)return;let t=e._protection;if(t.isLocked()||t.isPaused())return;let n=e._protectedRanges.getItems();for(let e=0;e<n.length;e++)n[e].relock()},onChange(){if(e._closed)throw Error(N(`error.sheet.modelClosed`));let t=e=>{e.value?.callbacks.processProtection?.()};e._getState().movableMapModel.forEach(t),e._getState().noteMapModel.forEach(t),e._getState().tables.processCallbacks((e,t)=>{t.processProtection?.()}),e._invalidateCaches(),e._notify(`onProtectionChange`)}},this._stylesListener={onAnyChange(){e._invalidateRendering()}}}_invalidateRendering(e=B.AxisSelection.Both){this._defaultColWidthCache=0,this._defaultRowHeightCache=0,this._defaultFontBoundsCache=null,this._notify(`onLayoutChange`),this._notify(`onStyleChange`),this._notify(`onViewChange`),e!==null&&jl.isLoaded()&&eP(this,[this._getEntireCoords()],{axes:e,skipCustomSize:!0,expandOnly:!0,formulaView:!1})}_initViewState(e,t){this._lastGetRangeRead=null,this._lastCellDecoded.address=null,this._lastCellSelected.coords=null,this._lastCellRead.coords=null,this._cellOptions?.renderCellCache?.clear(),this._entireCoordsCache=e,this._entireRangeCache=null;let n=this;this._protectionRemoveListener?.(),this._protection=new yh(void 0,this._options.readonly),this._protectionRemoveListener=this._protection.addListeners(this._protectionListener),this._stylesRemoveListener?.(),this._stylesRemoveListener=this._styles.addListeners(this._stylesListener),this._languageRemoveListener?.(),this._languageRemoveListener=j.addChangeListener(()=>{n._closed||n._invalidateRendering()}),this._fontsRemoveListener?.(),this._fontsRemoveListener=Ll.getShared().addListeners({onCollectionChange:()=>{n._closed||n._rowHeaders.isClosed()||n._colHeaders.isClosed()||n._getState()&&(Ll.getShared().isLoading()||n._runPendingFits()||n._invalidateRendering(n._loadFitSkipped?null:B.AxisSelection.Row))}},{transactional:!1}),this._regionalRemoveListener?.(),this._regionalRemoveListener=this._workbook?.addListeners({onRegionalChange:()=>{n._closed||n._invalidateRendering()}},{transactional:!1}),this._viewRemoveListener?.();let r=new hL({sheet:this,json:t});this._view=r,this._viewRemoveListener=r.addListeners(this._viewListener,{transactional:!1});let i=this._getEntireCoords.bind(this),a={getRanges:(e,t)=>{if(!e)return Ez(this);let r=this._rangesToCoords(e);return n._createRanges(r,t)},getEntireRange:n.getEntireRange.bind(n)};this._updateState({borderSpatial:new bF({updateEntryOptions:{isMergeOnShift:!0,isTrailingEdge:!0},entireCoords:e}),fillSpatial:new bF({updateEntryOptions:{isMergeOnShift:!0,isTrailingEdge:!0},entireCoords:e}),contentSpatial:new bF({updateEntryOptions:{isMergeOnShift:!0,isTrailingEdge:!0},entireCoords:e}),continuousFillSpatial:new fc({updateEntryOptions:{isMergeOnShift:!0,isTrailingEdge:!0}}),dateFormatSpatial:new fc({updateEntryOptions:{isMergeOnShift:!0,isTrailingEdge:!0}}),mergeSpatial:new bF({updateEntryOptions:{getShifted(e,t,r){let i=Dm(r,n._getEntireCoords());return i?{...i,value:new CA(i,e.value._tvTl)}:null},getSplit(e,t){throw new k(N(`error.sheet.insertMergeThrough`))}},entireCoords:e}),movableMapModel:new Map,movableSpatial:new fc({updateEntryOptions:{isSplittable:!1,getShifted(e,t,r){let i=e.value.callbacks.processShift?.(r),a=null,o=n._shiftedMovableModels??=new Map(n._getState().movableMapModel),s=e.value.model;return i?(a={...i,value:{...e.value}},o.set(s,a)):o.delete(s),a}}}),noteMapModel:new Map,noteSpatial:new fc({updateEntryOptions:{isSplittable:!1,getShifted(e,t,r){let i=n._shiftedNoteModels??=new Map(n._getState().noteMapModel),a=e.value.model,o=a.isDeleted()?null:e.value.callbacks.processShift?.(r),s=null;return o?(s={...o,value:{...e.value}},i.set(a,s)):i.delete(a),s}}}),picture:null,ignoredErrors:cw.Empty,hyperlinkSpatial:new fc({updateEntryOptions:{isSplitOnExpand:!0,isMergeOnShift:!0}}),autoTables:new Gh(a),tables:new Gh(a),conditionalFormats:new Gh(a),dataValidations:new Gh(a),protectedRanges:new Gh(a),comments:new Gh(a),cellControls:new Gh(a),sparklineGroups:new Gh(a),pivotTables:new Gh(a),listeners:new Gh({...a,isSplittable:!1,shiftEntry:(e,t)=>(e.noteShift(t),sP.shiftReference(t,i(),e.getListenerOptions().anchor))}),entireCoords:{colStart:0,rowStart:0,colEnd:zR.width-1,rowEnd:zR.height-1},entireFit:null,inputsCommitId:null,deleted:!1})}_initCellState(){let e=this,t={colStart:0,rowStart:0,colEnd:0,rowEnd:0},n=[t],r={ignoreHidden:!0,sort:{axis:B.Axis.Column,reverse:!1}};this._cellOptions={runtime:this._runtime,renderCellCache:new Mh({max:OR}),doBatchCalcGrid:async(t,n)=>{this._getState();let r=this._beginCommit(n);try{let n=await t(this._calcGrid);n&&e._recordChange(r,`data`,[n]),r.commit()}catch(e){throw r.rollback(),e}this._calculation.getStatus()!==Q.Status.Off&&await this._calculation.calculate({scope:this._calcGrid.getId()})},sheet:this,normalStyleRanged:this._normalStyleRanged,colHeaders:this._colHeaders,styles:this._styles,getRange:this.getRange.bind(this),getRanges:this.getRanges.bind(this),getProtection:this.getProtection.bind(this),getCalcGrid:()=>this._calcGrid,getCalculationStatus:()=>this._calculation.getStatus(),dependencyRanges:this._dependencyRanges.bind(this),getAnomalies:e=>this._getAnomalies().search({rowStart:e.rowIndex,rowEnd:e.rowIndex,colStart:e.colIndex,colEnd:e.colIndex})[0]?.value??_R,getRole:e=>this._getRoles().search({rowStart:e.rowIndex,rowEnd:e.rowIndex,colStart:e.colIndex,colEnd:e.colIndex})[0]?.value??null,resolveSheetScope:e=>this._resolveSheetScope(e),autoCorrect:(e,t)=>this.getCalculation().createFormula(e,{...t,scope:this.getName()}).autoCorrect(),createAt:(e,t)=>this.getCalculation().createFormula(e,{...t,scope:this.getName()}),nextContentful:(a,o,s=!1)=>{if(t.colStart=s?o:a.colIndex+1,t.rowStart=a.rowIndex,t.colEnd=s?a.colIndex-1:o,t.rowEnd=a.rowIndex,r.sort.reverse=s,!e._getState())return i.EmptyArray;let c=e._getRangedEntries(e._calcGrid.getContentful(),n,r);if(!c||c.length===0)return o;let l=c[0],u=s?l.getState().colStart:l.getState().colEnd;return s?Math.min(u+1,a.colIndex):Math.max(u-1,a.colIndex)},styleUpdater:(t,n,r)=>{let i=[r];return e._updateStyles(i,t,n),e._getStyle(i)},opener:async(e,t,n,r)=>{if(e.startsWith(`#`)){e=e.substring(1);let n=this._rangesToCoords(e),r=n[0]?.scope;if(r&&r!==this.getName()){let n=this.getWorkbook()?.getWorksheets().getByName(r)??null;return!!n&&(await n.getRanges(e).select(t??!0),!0)}return await this._autoSelect(t??!0,SD(n)),!0}{let t=this._options.opener;return t?t(e,n??`_blank`,r):n===`_self`&&Hh(e)&&(e=>{if(typeof document>`u`||!document.body)return!1;let t=document.createElement(`iframe`);return t.style.display=`none`,t.setAttribute(`aria-hidden`,`true`),t.src=e,document.body.appendChild(t),setTimeout(()=>t.remove(),5e3),!0})(e)||window.open(e,n??`_blank`,r),!0}}},this._emptyCell=new CN(this._cellOptions)}_createTables(e,t,n,r){let i=this,a=()=>{let e=i._cacheTableColumnHeaders;e.lastRowIndex=-1,e.lastColIndex=-1,i._markColumnHeaderTableNames()};return e.load(n,{createModel:e=>r({transactions:i._transactions,sheet:i,names:i._names,isProtected:()=>!i._initializing&&!i.getProtection().isObjectsAllowed(),processTableUpdate(){i._notifyUsedRangeChange()},filteredChanged(){i._tellFiltered()},releaseReferences(e,t){i._calculation._releaseTableReferences(e,t)},symbolsChanged(e){i._calculation._tableChanged(e,!1)},refitBodyRows(e,t,n,r,a,o){i._calculation._refitTableRows(i.getId(),e,t,n,r,a,o)},fillCalculated(e,t){let n=i._isDataColumn,r={majorStart:n?e.colStart:e.rowStart,majorEnd:n?e.colEnd:e.rowEnd,minorStart:n?e.rowStart:e.colStart,minorEnd:n?e.rowEnd:e.colEnd};i._updateTuples(Vc(t,r,n),void 0,null,{isBroadcast:!0,isCalculatedFill:!0})},...e}),addListeners:e=>e.addListeners({onAnchorCoordsChange(){a(),i._notifyTablesChange()},onSortChange(){i._notifyTablesChange()},onFilterChange(){i._notifyTablesChange()},onHiddenButtonsChange(){i._notifyTablesChange()},onStyleChange(){i._cellOptions?.renderCellCache?.clear(),i._notify(`onStyleChange`)},onDelete(n){i._announcedDeletes.delete(e)||(i._cellOptions?.renderCellCache?.clear(),a(),i._notifyTablesChange(),t===`autoTables`&&i._notify(`onAutoTableChange`))}},{transactional:!1}),setContainerCoords(e,n,r){let a=r?.description??m(`op.resizeTable`);i._isProtectionRuled()||i._protectionCheck(()=>[`objects`],n,a);let o=n[0];i._validateOrRemoveOverlaps(o,`table`,e);let s=i._beginCommit({description:a}),c=i._getState()?.[t];c=c.setCoords(e,[o]),i._updateState({[t]:c}),i._recordSelection(s,SD(e.getRanges().getCoords()),r),s.commit()},setContainerName(e,n,r){let a=r?.description??m(`op.setTableName`);i._protectionCheck(()=>[`objects`],void 0,a);let o=i._beginCommit({description:a});try{let a=i._getState()?.[t],s=a.getByName(n);if(s&&s!==e)throw new k((e=>N(`error.sheet.uniqueName`,{name:e}))(n));a=a.setName(e,n),i._updateState({[t]:a},r),i._calculation._tableChanged(e,!1),i._notifyTablesChange(),o.commit()}catch(e){throw o.rollback(),e}},deleteFromContainer(e,n){let r=n?.description??N(`op.deleteTableNamed`,{name:e.getName?.()});i._protectionCheck(()=>[`objects`],void 0,r);let o=i._beginCommit({description:r}),s=i._getState()?.[t];s=s.deleteModel(e),i._updateState({[t]:s}),i._calculation._tableChanged(e,!0),i._tellFiltered(),i._announcedDeletes.add(e),i._notifyTablesChange(),t===`autoTables`&&i._notify(`onAutoTableChange`),i._notify(`onLayoutChange`),a(),i._recordSelection(o,SD(e.getRanges().getCoords()),n),o.commit()}})}_createDataValidations(e,t,n,r,i){let a=this;i||=e=>e.addListeners({onAnchorCoordsChange(){a._notifyDataValidationsChange()},onAnyChange(){a._notifyDataValidationsChange()},onDelete(t){a._announcedDeletes.delete(e)||a._notifyDataValidationsChange()}},{transactional:!1});let o={createModel:e=>r({transactions:a._transactions,isProtected(){if(a._initializing||a._isMoveRuled)return!1;let e=a.getProtection();return e.isLocked()||e.isReadOnly()},getGridValues:()=>a._calcGrid.getValues(),getRuntime:()=>a.getRuntime(),getCalculation:()=>a._calculation??null,...e}),addListeners:i,invalidate(e){a._notifyUsedRangeChange(),a._notifyDataValidationsChange()},setContainerCoords(e,n,r){let i=r?.description??m(`op.updateDataValidations`);a._protectionCheck(()=>[],n,i);let o=a._beginCommit({description:i}),s=a._getState()?.[t];s=s.setCoords(e,n),a._updateState({[t]:s}),a._notifyDataValidationsChange(),a._recordSelection(o,SD(e.getRanges().getCoords()),r),o.commit()},getContainerIndex:e=>(a._getState()?.[t]).getIndex(e)??-1,setContainerIndex(e,n,r){let i=r?.description??m(`op.reorderDataValidations`);a._protectionCheck(()=>[],e.getRanges().getCoords(),i);let o=a._beginCommit({description:i}),s=a._getState()?.[t];s=s.setIndex(e,n),a._updateState({[t]:s}),a._notifyDataValidationsChange(),a._recordSelection(o,SD(e.getRanges().getCoords()),r),o.commit()},deleteFromContainer(e,n){let r=n?.description??N(`op.deleteDataValidationNamed`,{name:e.getName?.()});a._protectionCheck(()=>[],void 0,r);let i=a._beginCommit({description:r}),o=a._getState()?.[t];o=o.deleteModel(e),a._updateState({[t]:o}),a._announcedDeletes.add(e),a._notifyDataValidationsChange(),a._recordSelection(i,SD(e.getRanges().getCoords()),n),i.commit()}};return e.load(n,o)}_createConditionalFormats(e,t,n,r,i){let a=this;i||=e=>e.addListeners({onAnchorCoordsChange(){a._notifyConditionalFormatsChange()},onDelete(t){a._announcedDeletes.delete(e)||a._notifyConditionalFormatsChange()}},{transactional:!1});let o={createModel:e=>r({transactions:a._transactions,sheet:a,isProtected:()=>!a._initializing&&!a._isMoveRuled&&!a.getProtection().isFormatCellsAllowed(),getGridValues:()=>a._calcGrid.getValues(),getRuntime:()=>a.getRuntime(),getCalculation:()=>a._calculation??null,...e}),addListeners:i,invalidate(e){a._invalidateCaches(),a._notifyUsedRangeChange(),a._notifyConditionalFormatsChange()},setContainerCoords(e,n,r){let i=r?.description??m(`op.updateConditionalFormat`);a._protectionCheck(()=>[`formatCells`],e.getRanges().getCoords(),i),a._protectionCheck(()=>[`formatCells`],n,i);let o=a._beginCommit({description:i});a.getProtection().isLocked()&&a._recordSkipProtectionCheck(o);let s=a._getState()?.[t];s=s.setCoords(e,n),a._updateState({[t]:s}),a._notifyConditionalFormatsChange(),a._recordSelection(o,SD(e.getRanges().getCoords()),r),o.commit()},getContainerIndex:e=>(a._getState()?.[t]).getIndex(e)??-1,setContainerIndex(e,n,r){let i=r?.description??m(`op.reorderConditionalFormat`);a._protectionCheck(()=>[`formatCells`],e.getRanges().getCoords(),i);let o=a._beginCommit({description:i});a.getProtection().isLocked()&&a._recordSkipProtectionCheck(o);let s=a._getState()?.[t];s=s.setIndex(e,n),a._updateState({[t]:s}),a._notifyConditionalFormatsChange(),a._recordSelection(o,SD(e.getRanges().getCoords()),r),o.commit()},deleteFromContainer(e,n){let r=n?.description??N(`op.deleteConditionalFormatNamed`,{name:e.getName?.()});a._protectionCheck(()=>[`formatCells`],void 0,r);let i=a._beginCommit({description:r});a.getProtection().isLocked()&&a._recordSkipProtectionCheck(i);let o=a._getState()?.[t];o=o.deleteModel(e),a._updateState({[t]:o}),a._announcedDeletes.add(e),a._notifyConditionalFormatsChange(),a._recordSelection(i,SD(e.getRanges().getCoords()),n),i.commit()}};return e.load(n,o)}_createProtectedRanges(e,t,n,r,i){let a=this;i||=e=>e.addListeners({onAnchorCoordsChange(){a._notifyProtectedRangesChange()},onConfigChange(){a._notifyProtectedRangesChange()},onDelete(t){a._announcedDeletes.delete(e)||a._notifyProtectedRangesChange()}},{transactional:!1});let o={createModel:e=>r({transactions:a._transactions,isProtected(){if(a._initializing)return!1;let e=a.getProtection();return e.isLocked()||e.isReadOnly()},...e}),addListeners:i,invalidate(e){a._notifyProtectedRangesChange()},setContainerCoords(e,n,r){let i=r?.description??m(`op.updateProtectedRanges`);a._protectionCheck(()=>[],n,i);let o=a._beginCommit({description:i}),s=a._getState()?.[t];s=s.setCoords(e,n),a._updateState({[t]:s}),a._notifyProtectedRangesChange(),a._recordSelection(o,SD(e.getRanges().getCoords()),r),o.commit()},setContainerName(e,n,r){let i=r?.description??m(`op.setProtectedRangeName`);a._protectionCheck(()=>[],void 0,i);let o=a._beginCommit({description:i});try{let i=a._getState()?.[t],s=i.getByName(n);if(s&&s!==e)throw new k(N(`error.protectedRange.uniqueName`,{name:n}));i=i.setName(e,n),a._updateState({[t]:i},r),a._notifyProtectedRangesChange(),o.commit()}catch(e){throw o.rollback(),e}},getContainerIndex:e=>(a._getState()?.[t]).getIndex(e)??-1,setContainerIndex(e,n,r){let i=r?.description??m(`op.reorderProtectedRange`);a._protectionCheck(()=>[],e.getRanges().getCoords(),i);let o=a._beginCommit({description:i}),s=a._getState()?.[t];s=s.setIndex(e,n),a._updateState({[t]:s}),a._notifyProtectedRangesChange(),a._recordSelection(o,SD(e.getRanges().getCoords()),r),o.commit()},deleteFromContainer(e,n){let r=n?.description??N(`op.deleteProtectedRangeNamed`,{name:e.getName?.()});a._protectionCheck(()=>[],void 0,r);let i=a._beginCommit({description:r}),o=a._getState()?.[t];o=o.deleteModel(e),a._updateState({[t]:o}),a._announcedDeletes.add(e),a._notifyProtectedRangesChange(),a._recordSelection(i,SD(e.getRanges().getCoords()),n),i.commit()}};return e.load(n,o)}_createCellControls(e,t,n,r){let i=this;return e.load(n,{createModel:e=>r({transactions:i._transactions,isProtected:()=>!i._initializing&&!i._isMoveRuled&&!i.getProtection().isFormatCellsAllowed(),...e}),addListeners:e=>e.addListeners({onAnchorCoordsChange(){i._notifyCellControlsChange()},onDelete(t){i._announcedDeletes.delete(e)||i._notifyCellControlsChange()}},{transactional:!1}),invalidate(e){i._notifyCellControlsChange()},setContainerCoords(e,n,r){let a=r?.description??m(`op.updateCellControl`);i._protectionCheck(()=>[`formatCells`],n,a);let o=i._beginCommit({description:a}),s=i._getState()?.[t];s=s.setCoords(e,n),i._updateState({[t]:s}),i._notifyCellControlsChange(),i._recordSelection(o,SD(e.getRanges().getCoords()),r),o.commit()},deleteFromContainer(e,n){let r=n?.description??m(`op.deleteCellControl`);i._protectionCheck(()=>[`formatCells`],void 0,r);let a=i._beginCommit({description:r}),o=i._getState()?.[t];o=o.deleteModel(e),i._updateState({[t]:o}),i._announcedDeletes.add(e),i._notifyCellControlsChange(),i._recordSelection(a,SD(e.getRanges().getCoords()),n),a.commit()}})}_createSparklineGroups(e,t){let n=this;return e.load(t,{createModel:e=>new dk({transactions:n._transactions,isProtected:()=>!n._initializing&&!n._isMoveRuled&&!n.getProtection().isFormatCellsAllowed(),getSheetName:()=>n.getName(),resolveSheet:e=>n.getWorkbook()?.getWorksheets()?.getByName(e)??null,resolveRange:e=>(n.getWorkbook()??n).getRange(e),getStyles:()=>n.getStyles(),modify:(e,t,r,i)=>n._modifySparklineGroup(e,t,r,i),...e}),addListeners:e=>e.addListeners({onAnchorCoordsChange(){n._notifySparklineGroupsChange()},onDelete(t){n._announcedDeletes.delete(e)||n._notifySparklineGroupsChange()}},{transactional:!1}),invalidate(e){n._notifySparklineGroupsChange()},setContainerCoords(e,t,r){let i=r?.description??m(`op.updateSparklineGroup`);n._protectionCheck(()=>[`formatCells`],t,i);let a=n._beginCommit({description:i}),o=n._getState();n._updateState({sparklineGroups:o.sparklineGroups.setCoords(e,t)}),n._notifySparklineGroupsChange(),a.commit()},deleteFromContainer(e,t){let r=t?.description??m(`op.deleteSparklineGroup`);n._protectionCheck(()=>[`formatCells`],void 0,r);let i=n._beginCommit({description:r}),a=n._getState();n._updateState({sparklineGroups:a.sparklineGroups.deleteModel(e)}),n._announcedDeletes.add(e),n._notifySparklineGroupsChange(),i.commit()}})}_createPivotTables(e,t,n,r){let i=this;return e.load(n,{createModel:e=>new QC({transactions:i._transactions,sheet:i,fromResourceId:r,isProtected:()=>!i._initializing&&!i.getProtection().isPivotTablesAllowed(),...e}),addListeners:e=>e.addListeners({onAnyChange(){i._cellOptions?.renderCellCache?.clear(),i._notifyPivotTablesChange()}},{transactional:!1}),setContainerCoords(e,n,r){let a=r?.description??m(`op.updateAnchor`);i._protectionCheck(()=>[`pivotTables`],n,a);let o=i._beginCommit({description:a}),s=i._getState()?.[t];s=s.setCoords(e,[n[0]]),i._updateState({[t]:s}),i._tellPivots(),o.commit()},setContainerName(e,t){},getContainerIndex:e=>(i._getState()?.[t]).getIndex(e)??-1,setContainerIndex(e,n,r){let a=r?.description??m(`op.updateAnchor`),o=i._beginCommit({description:a}),s=i._getState()?.[t];s=s.setIndex(e,n),i._updateState({[t]:s}),o.commit()},deleteFromContainer(e,n){let r=n?.description??m(`op.deletePivotTable`);i._protectionCheck(()=>[`pivotTables`],void 0,r);let a=i._beginCommit({description:r}),o=i._getState()?.[t];o=o.deleteModel(e),i._updateState({[t]:o}),i._tellPivots(),a.commit()}})}_createComments(e,t,n,r,i){let a=this;i||=e=>e.addListeners({onAnchorCoordsChange(){a._notifyCommentsChange()},onContentChange(){a._notifyCommentsChange()},onResolvedChange(){a._notifyCommentsChange()},onRepliesChange(){a._notifyCommentsChange()},onDelete(t){a._announcedDeletes.delete(e)||a._notifyCommentsChange()}},{transactional:!1});let o={createModel:e=>r({transactions:a._transactions,isProtected:()=>!a._initializing&&!a.getProtection().isObjectsAllowed(),getPeople:()=>a.getWorkbook()?.getPeople()??null,getStyles:()=>a.getStyles(),boxes:a._noteBoxes,...e}),addListeners:i,invalidate(e){a._notifyCommentsChange()},setContainerCoords(e,n,r){let i=r?.description??m(`op.updateComment`);a._protectionCheck(()=>[`objects`],e.getRanges().getCoords(),i),a._protectionCheck(()=>[`objects`],n,i);let o=a._beginCommit({description:i}),s=a._getState()?.[t];s=s.setCoords(e,n),a._updateState({[t]:s}),a._notifyCommentsChange(),o.commit()},getContainerIndex:e=>(a._getState()?.[t]).getIndex(e)??-1,deleteFromContainer(e,n){let r=n?.description??m(`op.deleteComment`);a._protectionCheck(()=>[`objects`],void 0,r);let i=a._beginCommit({description:r}),o=a._getState()?.[t];o=o.deleteModel(e),a._updateState({[t]:o}),a._announcedDeletes.add(e),a._notifyCommentsChange(),i.commit()}};return e.load(n,o)}_newCommentJSON(e){let t=this.getWorkbook()?.getPeople()??null,n=!!e.asNote,r={id:i.uuidV4().toUpperCase(),content:_k(e.content)},a=wk(e.person,t);return a&&(r.personId=a),n?r.asNote=!0:(r.dt=new Date().toISOString(),e.resolved&&(r.done=!0)),r}_createMovableEntry(e,t,n,r=this._placedIndex,i){let a=null;if(e?.anchor)a={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||--a.colEnd,e.anchor.br?.y||--a.rowEnd;else{let e=this.getSelection().getRange().getCoords();a={colStart:e.colStart,rowStart:e.rowStart,colEnd:e.colEnd,rowEnd:e.rowEnd}}let o={model:null,callbacks:{processShift:null,processAfterShift:null,processLayout:null,processDelete:null,processZIndex:null,processSelection:null,processProtection:null},zIndex:t},s={...a,value:o},c=()=>o.model?d._getState()?.[r.byModel]?.get(o.model):s,l=()=>r===d._noteIndex&&d._isMoveRuled,u=(e,t,n=!0)=>{if(p)return;let i=c();if(!i)return;let a=t??m(`op.updateDrawing`);l()||d._protectionCheck(()=>[`objects`],void 0,a);let o=d._beginCommit({description:a}),u=(d._getState()?.[r.spatial]).clone(),f=d._getState()?.[r.byModel],h=new Map(f);!1!==e(i,u,h)&&(d._updateState({[r.spatial]:u,[r.byModel]:h}),n&&(d._emitterMovables.notify(`onCollectionChange`,{transactional:!0}),d._notify(`onMovablesChange`)),s.value.model.isSelected()&&DP(o,d,EP(d.getView().getMovableSelection()),{autoSelect:!1,autoSelectRestore:!0}),o.commit())},d=this,f=e.content.type,p=!0,h=(e,t,n,r)=>{let i=n.all().sort((e,t)=>e.value.zIndex-t.value.zIndex),a=t.value.zIndex;if((e=Math.max(0,Math.min(i.length-1,e)))===a)return!1;let o=[],s=[],c=[],l=a<e,u=t=>{let n=i[t];o.push(n);let u={...n,value:{...n.value,zIndex:l?t-1:t+1}};n.value.zIndex===a&&(u.value.zIndex=e),s.push(u),r.set(u.value.model,u),c.push(u)};if(l)for(let t=a;t<=e;t++)u(t);else for(let t=a;t>=e;t--)u(t);let d=o.length;for(let e=0;e<d;e++)n.remove(o[e],YR);n.load(s);let f=c.length;for(let e=0;e<f;e++)c[e].value.callbacks.processZIndex?.()},g=()=>d._resources.beginPersist(),_={content:null,fromResourceId:n,beginPersistResource:g,getMaxBounds:()=>d._getBoundsAtCoords(d._getEntireCoords()),getRanges:e=>d.getRanges(e),invalidate:()=>{d._initializing||d._closed||(d._emitterMovables.notify(`onCollectionChange`),d._notify(`onMovablesChange`))},onPlacementChange:(e,t)=>d._glueConnectors(e,t),runtime:this._runtime,transactions:this._transactions,getBoundsAtCoords:d._getBoundsAtCoords.bind(d),getCoordsAtBounds:d._getCoordsAtBounds.bind(d),scrollIntoView:async e=>{let t=c()?.value?.model;return!!t&&d._selectSheet(t.getRange().getCoords(),e)},moveToBackOnContainer:()=>{u((e,t,n)=>h(0,e,t,n),m(`op.moveToBack`))},moveBackwardOnContainer:()=>{u((e,t,n)=>h(e.value.zIndex-1,e,t,n),m(`op.moveBackwards`))},moveForwardOnContainer(){u((e,t,n)=>h(e.value.zIndex+1,e,t,n),m(`op.moveForward`))},moveToFrontOnContainer(){u((e,t,n)=>h(t.size()-1,e,t,n),m(`op.moveToFront`))},getZIndex:()=>r.zIndexBase()+(c()?.value?.zIndex??0),getContainerIndex:()=>c()?.value?.zIndex??0,setContainerIndex(e,t){u((t,n,r)=>h(e,t,n,r),t?.description??m(`op.setIndex`))},setContainerCoords(e,t){if(!e)return;let n=d._rangesToCoords(e,()=>[`objects`]),r=n[0];return s.colStart=r.colStart,s.rowStart=r.rowStart,s.colEnd=r.colEnd,s.rowEnd=r.rowEnd,u((e,t,n)=>{let i={...e,...r};t.remove(e,YR),t.insert(i),n.set(i.value.model,i)},m(`op.updateDrawing`),!1),n},deleteFromContainer(e){let t=c();t?.value&&d.getView().getMovableSelection().unselect([t.value.model]);let n=[];u((e,t,r)=>{r.delete(e.value.model),t.remove(e,YR),e.value.callbacks.processDelete?.(),n.push(e);let i=e.value.zIndex,a=t.all().sort((e,t)=>e.value.zIndex-t.value.zIndex),o=[],s=[],c=a.length;for(let e=i;e<c;e++){let t=a[e];if(t.value.zIndex===e)continue;o.push(t);let n={...t,value:{...t.value,zIndex:e}};s.push(n),r.set(n.value.model,n)}let l=o.length;for(let e=0;e<l;e++)t.remove(o[e],YR);t.load(s)},e?.description??m(`op.deleteDrawing`),!0);let r=n.length;for(let e=0;e<r;e++)n[e].value.callbacks.processZIndex?.()},setContainerCallbacks(e){let t=c()?.value??o;t&&(t.callbacks={...t.callbacks,...e},t.removeListener?.())},isProtected:()=>!d._initializing&&!l()&&!d.getProtection().isObjectsAllowed(),coords:a,getEntireRange:d.getEntireRange.bind(d),json:e},v=e.content.json,y=e,b={type:f,transactions:this._transactions,beginPersistResource:g,fromResourceId:n,json:v,name:e.content.name??y.name??null,description:e.content.description??y.description??null,isReadOnly:_.isProtected,deleteFromContainer:()=>{o.model._deleteFromContent()},getMovable:()=>o.model,getStyles:()=>this.getStyles(),getRange:e=>(this.getWorkbook()??this).getRange(e),addWatch:this._contentAddWatch(()=>{let e=o.model?.getRange()?.getCoords();return e?{rowIndex:e.rowStart,colIndex:e.colStart}:null})},x=i??kx(f,b,{getMovable:()=>o.model,amend:e=>this._amendCurrent(e),isClosed:()=>this._closed});return o.model=r.create({..._,content:x}),p=!1,s}_fromJSON(e,t=!1){this._initializing=!0,this._loadFitSkipped=t,this._emitter.notify(`onBeforeLoad`,{params:e});let n=this._beginCommit({description:m(`op.loadSheet`)});this._recordInitial(n);let r=e||{},a=this._strings.beginPersist(),o=this._resources.beginPersist(),s=this._styles.beginPersist(),c=this._richValues.beginPersist();this._readingResources=o;try{this._ownStrings&&a.fromJSON(r.strings),this._ownResources&&o.fromJSON(r.resources),this._ownStyles&&s.fromJSON(r.styles),this._ownRichValues&&c.fromJSON(r.richData,this._richData,r.richTypes);let e={colStart:0,rowStart:0,colEnd:zR.width-1,rowEnd:zR.height-1},l=r.entireSize;l&&(e=Object.freeze({colStart:0,rowStart:0,colEnd:(l.width??zR.width)-1,rowEnd:(l.height??zR.height)-1})),this._baseColSize=r.baseColSize??null,this._defaultColWidthCache=0,this._initHeadersState({headers:r.cols,defaultSize:r.defaultColSize},{headers:r.rows,defaultSize:r.defaultRowSize}),this._initViewState(e,r.view),this._colHeaders.invalidate(),this._rowHeaders.invalidate(),this._initCellState(),r.tabColor&&(this._tabColor=this._styles.parseColor(r.tabColor)),this._codeName=r.codeName??null,this._outline?.close(),this._outline=new _L({rowHeaders:this._rowHeaders,columnHeaders:this._colHeaders,transactions:this._transactions,json:r.outline}),this._conditionalFormatCalculation=r.conditionalFormatCalculation??!0,this._sheetPr={},r.transitionFormulaEvaluation&&(this._sheetPr.transitionFormulaEvaluation=!0),r.transitionFormulaEntry&&(this._sheetPr.transitionFormulaEntry=!0),r.excludeFromPublishing&&(this._sheetPr.excludeFromPublishing=!0),r.syncScroll&&(this._sheetPr.syncScroll={...r.syncScroll}),this._pageLayout=new NL({getSheet:()=>this,transactions:this._transactions,json:r.pageLayout,fromResourceId:o.fromResourceId.bind(o)});let u=r.modules;if(u||this._modules.getCount()>0){let e=this,t={};for(let n of Object.keys(u??{}))t[n]=px(n,u[n],()=>e);this._modules.close(),this._modules=new Vy({transactions:this._transactions,initial:t,isReadOnly:()=>this._isModulesReadOnly()})}let d=this._getState(),f=r.data,p=f?.length??0,g=this._lists,_=[];if(p>0)for(let e=0;e<p;e++){let t=f[e];typeof t==`string`&&(t=JSON.parse(t));let n=t[1],r=n.length;for(let e=0;e<r;e++){let t=n[e];t[1]=g.fromJSONRun(t[1],void 0,c.at)}_.push(t)}let v=d.borderSpatial,y=d.fillSpatial,b=d.contentSpatial,x=d.continuousFillSpatial,S=d.dateFormatSpatial,C=this._options.styles,w=r.directStyles,T,E;if(w){let t=w.length;T=Array(t);for(let n=0;n<t;n++)T[n]=wf(w[n],e)}if(T){let e=this._getEntireCoords.bind(this),t=[],n=[],r=[],i=i=>{let a=s.getElementJSON(i.value),o=h.sanitizeRange(i),c=new Am(C,e,o,a),l=c._p?.alignment?.horizontal;l===R.HorizontalAlignment.CenterContinuous&&t.push(o),l===R.HorizontalAlignment.Fill&&n.push(o);let u=Cm(C,c._p);return u&&(nt(u)||pt(u))&&r.push({...o,value:u}),{...o,value:c}},a=T.length;E=Array(a);for(let e=0;e<a;e++)E[e]=i(T[e]);let o=[],c=[],l=[];for(let e=0;e<a;e++){let t=E[e];if(!t.value)continue;let n=t.value.splitByFeature();n.border&&o.push({...t,value:n.border}),n.fill&&c.push({...t,value:n.fill}),n.content&&l.push({...t,value:n.content})}let u=(e,t)=>{t.length!==0&&e.load(t.length>1?xc(t,B.Axis.Column,2**53-1,wc):t)};u(v,o),u(y,c),u(b,l);let d=(t,n)=>{let r=(t=xc(t,B.Axis.Column,2**53-1)).length,i=Array(r);for(let a=0;a<r;a++){let r=t[a];i[a]={...r,value:new Am(C,e,r,{alignment:{horizontal:n}})}}x.load(i)};d(t,R.HorizontalAlignment.CenterContinuous),d(n,R.HorizontalAlignment.Fill),r=xc(r,B.Axis.Column,2**53-1),S.load(r)}d=this._updateState({borderSpatial:v,fillSpatial:y,contentSpatial:b,continuousFillSpatial:x,dateFormatSpatial:S,entireCoords:e,entireFit:r.entireSizeFit?{width:!!r.entireSizeFit.width,height:!!r.entireSizeFit.height}:null});let D=r.merges;if(D){let t=[],n=D.length;for(let r=0;r<n;r++){let n=Ff(D[r],e);t.push(n)}this._indexMerges(t)}let O=d.hyperlinkSpatial,k=r.hyperlinks;if(k){let t=k,n=t.length,r=Array(n);for(let i=0;i<n;i++){let n=wf(t[i],e),a=n.value;n.value=typeof a==`string`?{address:a}:{...a},r[i]=n}O.load(r)}let A=d.comments,j=r.comments;j&&(A=this._createComments(A,`comments`,function(e){let t=[],n=new Map,r=null;for(let a=0;a<e.length;a++){let o=e[a];if(!o)continue;let s=Array.isArray(o),c=s?o[0]:o.r,l=s?o[1]:o.v;if(l==null)continue;let u=typeof l==`string`?{id:i.uuidV4().toUpperCase(),content:l}:{...l},d=u.parentId;d?(delete u.parentId,(r??=[]).push({parentId:d,json:u})):(u.id||=i.uuidV4().toUpperCase(),n.set(u.id,u),t.push({r:c,v:u}))}if(r)for(let e=0;e<r.length;e++){let{parentId:t,json:i}=r[e],a=n.get(t);if(!a)continue;let{done:o,asNote:s,replies:c,box:l,...u}=i;a.replies=[...a.replies??[],u]}return t}(j),e=>new jk(e)));let M=d.tables,N=r.tables;N&&(M=this._createTables(M,`tables`,N,e=>new yy(e)));let ee=d.autoTables,te=r.autoTable;te&&(ee=this._createTables(ee,`autoTables`,[te],e=>new By(e))),this._validationSettings=r.validationSettings?{...r.validationSettings}:{};let P=d.dataValidations,F=r.validations;F&&(P=this._createDataValidations(P,`dataValidations`,F,e=>new tO(e)));let ne=d.conditionalFormats,re=r.conditionals;re&&(ne=this._createConditionalFormats(ne,`conditionalFormats`,re,e=>new MD(e)));let ie=d.protectedRanges,ae=r.protectedRanges;ae&&(ie=this._createProtectedRanges(ie,`protectedRanges`,ae,e=>new lO(e)));let oe=d.cellControls,se=r.cellControls;se&&(oe=this._createCellControls(oe,`cellControls`,se,e=>new pO(e)));let ce=d.sparklineGroups,le=r.sparklineGroups;le&&(ce=this._createSparklineGroups(ce,le));let ue=d.movableMapModel,de=d.movableSpatial,fe=r.movables;if(fe){let e=[],t=fe.length;for(let n=0;n<t;n++){let t=fe[n];try{let r=this._createMovableEntry(t,n,o.fromResourceId.bind(o));ue.set(r.value.model,r),e.push(r)}catch(e){console.warn(`Unable to load movable`,n,t,e)}}de.load(e)}let pe=null,me=r.picture;if(me){let e=this;pe=new _x({json:me,fromResourceId:o.fromResourceId.bind(o),deleteFromContainer:t=>{e._getState().picture&&(e._updateState({picture:null},{description:m(`op.deletePicture`),...t}),e._notify(`onStyleChange`))},transactions:this._transactions})}let he=o.fromResourceId.bind(o);this._legacyDrawing=xR(r.legacyDrawing,he),this._legacyDrawingHF=xR(r.legacyDrawingHF,he);let I=d.pivotTables,ge=r.pivotTables;if(ge){let e=[];for(let t=0;t<ge.length;t++){let n=ge[t];n&&typeof n.cacheId==`number`&&(Ux(n)?e.push({r:QC.anchorOf(n),v:n}):console.warn(`Pivot table '${n.name??``}' states no location it can be laid out at; it was not loaded.`))}I=this._createPivotTables(I,`pivotTables`,e,he)}d=this._updateState({hyperlinkSpatial:O,movableSpatial:de,movableMapModel:ue,autoTables:ee,tables:M,conditionalFormats:ne,dataValidations:P,protectedRanges:ie,cellControls:oe,sparklineGroups:ce,comments:A,picture:pe,pivotTables:I,ignoredErrors:cw.fromJSON(r.ignoredErrors,e)});let _e={};r.formulas&&(_e.formulas=r.formulas),_.length>0&&(_e.data=_),r.formulaArray&&(_e.formulaArray=r.formulaArray),r.volatile&&r.volatile.length>0&&(_e.volatile=r.volatile);let ve=Bz(this._rowHeaders);ve.length>0&&(_e.hiddenRows=ve);let ye=Bz(this._colHeaders);ye.length>0&&(_e.hiddenColumns=ye),this._filteredTables().length>0&&(_e.filtered=!0);let be=this._options.calcGrid;if(be?(this._calcGrid=be,this._ownsCalcGrid=!1):this._calcGrid=this._openCalcGrid(_e),!t){let e=this._getUsedCoords();e&&this._autoFit([e],{axes:B.AxisSelection.Row,skipCustomSize:!0,expandOnly:B.Axis.Column,formulaView:!1},!0)}n.commit(),r.protection&&this._protection.fromJSON(r.protection),this._notify(`onLoad`)}finally{this._readingResources=null,c.endPersist(),s.endPersist(),o.endPersist(),a.endPersist()}this._initializing=!1}getId(){return this._id}getVersionId(){return this._transactions.getVersionId(this._stateId)}getName(){return this._closed?gd:this._options.container?.getName?.()??null}setName(e,t){if(this._closed)throw Error(N(`error.sheet.modelClosed`));let n=this._options.container?.setName;if(!n)throw new k(`Unable to set name for sheet.`);return n(e,t),this}getVisibility(){return this._closed?Qu.Visibility.VeryHidden:this._options.container?.getVisibility?.()??Qu.Visibility.Hidden}setVisibility(e=!0,t){if(this._closed)throw Error(N(`error.sheet.modelClosed`));let n=this._options.container?.setVisibility;if(!n)throw new k(`Unable to set visibility for sheet.`);let r;return r=!0===e?Qu.Visibility.Visible:!1===e?Qu.Visibility.Hidden:e,n(r,t),this}async select(e){return await this._options.container?.requestSelect?.(e),this}async duplicate(){return await this._options.container?.duplicate?.()??this}getIndex(){return this._options.container?.getIndex?.()??-1}setIndex(e,t){return this._options.container?.setIndex?.(e,t),this}getNames(){let e=this._names;return e&&(this._namesScoped||=e._scopedTo(this),this._namesScoped)}getCalculation(){let e=this._calculation;if(!e)return e;if(!this._calculationScoped){let t=this,n=new Map,r=e=>({...e??{},scope:e?.scope??t.getName()});this._calculationScoped=new Proxy(e,{get:(e,t)=>{if(t===`createFormula`)return(t,n,i)=>e.createFormula(t,r(n),i);if(t===`evaluate`)return(t,n)=>e.evaluate(t,r(n));let i=Reflect.get(e,t,e);if(typeof i!=`function`)return i;let a=n.get(t);return a||(a=i.bind(e),n.set(t,a)),a}})}return this._calculationScoped}createFormula(e,t,n){return this.getCalculation().createFormula(e,t,n)}evaluate(e,t){return t=typeof t==`number`?{evalIndex:t,scope:this.getName()}:{...t,scope:this.getName()},this.getCalculation().evaluate(e,t)}async whenCalculationReady(){let e=this._starting;return e?e.then(()=>this.getCalculation().ready()):this.getCalculation().ready()}getFonts(){return Ll.getShared()}whenFontsReady(){return this.getFonts().whenReady()}async whenReady(){await Promise.all([this.whenCalculationReady(),this.whenFontsReady()])}getWorkbook(){return this._workbook}get[Symbol.toStringTag](){return`[Sheet]`}toString(){return`[${this.getName()??`(untitled)`}]`}getKind(){return Qu.Kind.Worksheet}get isISheet(){return!0}get isIWorksheet(){return!0}},OR=8192,kR=/^\$?[A-Za-z]{1,3}\$?\d{1,7}(:\$?[A-Za-z]{1,3}\$?\d{1,7})?$/,AR={ignoreDataChanges:!1},jR={colStart:-1,rowStart:-1,colEnd:-1,rowEnd:-1},MR=class{constructor(e){Object.assign(this,e),Object.freeze(this)}get isICellRangeCounts(){return!0}};function NR(e){return new MR(e)}function PR(e,t,n){let r=Qh.Feature;switch(t){case r.Contentful:return!!e.contentful;case r.Kind:return!!e.kind;case r.DateFormat:return!!e.dateFormat;case r.Formula:return!!e.formula;case r.Spills:return!!e.spills;case r.CalcError:return e.calcError!==void 0;case r.CalcStatus:return!!e.calcStatus;case r.Circular:return!!e.circular;case r.Error:return!!e.error;case r.Fill:return!!e.fillStyle;case r.Borders:return!!e.borderStyle;case r.Merge:return!!e.merge;case r.Table:return!!e.table;case r.AutoTable:return!!e.autoTable;case r.Pivot:return!!e.pivot;case r.Hyperlink:return!!e.hyperlink;case r.IgnoredErrors:return!!e.ignoredErrors;case r.Anomalies:return!!e.anomalies;case r.Role:return!!e.role;case r.Comments:return!!e.comments;case r.Unlock:return!!e.unlock||xm(n,e.contentStyle?.getPropertiesAt(0,0,null));case r.Conditionals:return!!e.conditionals;case r.DataValidations:return!!e.dataValidations;case r.CellControl:return!!e.cellControls;case r.Sparkline:return!!e.sparklineGroups;default:return!1}}var FR={axes:B.AxisSelection.Row,skipCustomSize:!0,minContent:!0},IR={skipCustomSize:!0,expandOnly:B.Axis.Column,minContent:!0},LR={rowStart:0,colStart:0,rowEnd:0,colEnd:0},RR=[],zR={width:2**14,height:2**20},BR=e=>`${e}`,VR=e=>Sd(e),HR=e=>`${e+1}`,UR=0;function WR(e){e[G.Type.Spills]=!1,e[G.Type.Formula]=!1}function GR(e){return!e.formula&&!!e.spills}var KR=()=>{},qR=e=>new sP(e),JR=Object.freeze([]),YR=(e,t)=>!(!h.isEqualRanges(e,t)||e.value.model!==t.value.model),XR={useFormattingCategory:!0},ZR=e=>e==null||e===0||typeof e==`string`&&e.toLowerCase()===`general`,QR,$R=e=>typeof e==`object`&&!!e&&!0===e.isICellRange,ez=e=>typeof e==`object`&&!!e&&!e.isICellRange&&typeof e.scope==`string`,tz=class e{constructor(e,t,n){this._coords=Object.freeze(e),this._internal=t,this._readOnly=n?.readOnly??null,this._options=n??void 0,this._cacheRanges=[],this._memberSheets=((e,t)=>{if(!e)return null;let n=null;for(let r=0;r<e.length;r++){let i=e[r];ez(i)&&(n??=Array(e.length).fill(null),n[r]=Sz(t,i.scope)?.getSheet()??null)}return n})(e,t)}_getStickyOptions(){return this._options?.getOptions}_createRanges(t,n){let r=this._options;return n&&(r={...this._options,getOptions:Qz(this._options?.getOptions,n)}),new e(t,this._internal,r)}_createRange(e,t){if(typeof e==`string`)return this._internal.createRange(e,Qz(this._getStickyOptions(),t));let n=this._options;t&&(n={...this._options,getOptions:Qz(this._options?.getOptions,t)});let r=Sz(this._internal,e?.scope);return r?new mA(e,r,n):Tz(this._internal.getSheet(),this._internal.getSheet().getEntireCoords(),e)}_validateWrite(){let e=this._readOnly;if(e)throw Error(N(e))}_byScope(){let e=this.getCoords(),t=this._internal,n=!1;for(let r=0;r<e.length;r++){let i=e[r]?.scope;if(i&&Sz(t,i)!==t){n=!0;break}}if(!n)return null;let r=[],i=new Map;for(let n=0;n<e.length;n++){let a=e[n];if(!a)continue;let o=Sz(t,a.scope);if(!o)continue;let s=o.getSheet().getName(),c=i.get(s);c||(c={internal:o,coords:[]},i.set(s,c),r.push(c)),c.coords.push(a.scope?{...a,scope:void 0}:a)}return r}_writeByScope(e,t){let n=this._byScope();n?this.doBatch(()=>{for(let t=0;t<n.length;t++)e(n[t].internal,n[t].coords)},t):e(this._internal,this.getCoords())}_readCoordsByScope(e){let t=this._byScope();if(!t)return e(this._internal,this.getCoords());let n=this._internal,r=[];for(let i=0;i<t.length;i++){let a=t[i],o=a.internal===n?void 0:a.internal.getSheet().getName(),s=e(a.internal,a.coords);for(let e=0;e<s.length;e++)r.push(o?{...s[e],scope:o}:s[e])}return r}getCoords(){this._refreshScopes();let e=this._coords;for(let t=0;t<e.length;t++){let n=e[t];if(typeof n==`string`||$R(n))return this._resolveCoords()}return e}_refreshScopes(){let e=this._memberSheets;if(!e)return;let t=this._coords,n=null;for(let r=0;r<t.length;r++){let i=e[r];if(!i||i.isClosed())continue;let a=t[r],o=i.getName();o&&ez(a)&&a.scope!==o&&(n??=[...t],n[r]=Object.freeze({...a,scope:o}))}n&&(this._coords=Object.freeze(n))}_resolveCoords(){let e=this._coords,t=this._cacheRanges,n=Array(e.length);for(let r=0;r<e.length;r++){let i=e[r];if(typeof i==`string`){let e=t[r]??(t[r]=this._createRange(i));n[r]=e.getCoords()}else if($R(i)){t[r]||(t[r]=i);let e=i.getCoords(),a=i.getWorksheet()?.getName();n[r]=a&&a!==this._internal.getSheet().getName()&&!e.scope?{...e,scope:a}:e}else n[r]=i}return n}[Symbol.iterator](){let e=this.entries({features:pA});return{next(){let t=e.next();return t.done?yo:{done:!1,value:t.value.value}},[Symbol.iterator](){return this}}}entries(e){let t=this.getCoords(),n=e?.reverse??!1,r=n?t.length-1:0,i=this,a=i.at(r),o=a.entries(e),s=o.next();return{next(){let c=s;do{if(s.done){if(r=n?r-1:r+1,r>=t.length||r<0)return s=yo,c;a=i.at(r),o=a.entries(e)}s=o.next()}while(s.done);return c},[Symbol.iterator](){return this}}}async select(e){let t=await this._internal.autoSelect(e??!0,SD(this.getCoords()));return this._createRanges(t)}calculate(){let e=this._byScope();if(!e)return this._internal.calculate(this.getCoords()),this;for(let t=0;t<e.length;t++)e[t].internal.calculate(e[t].coords);return this}addListener(e,t){return this._listenByScope((n,r)=>n.addListenerNode(r,e,t,!0))}addWatch(e,t,n){return this._addWatch(e,(r,i,a)=>r._addWatch(e,{onValues:e=>{t(e,i,r)}},a,n))}_addWatch(e,t){let n=this.getCount();if(n===0)return()=>{};let r=h.unionRangesArrays(this.getCoords()),i={rowIndex:r.rowStart,colIndex:r.colStart},a=[];for(let e=0;e<n;e++)a.push(t(this.at(e),e,i));return()=>{for(let e=0;e<a.length;e++)a[e]()}}_listenByScope(e){let t=this.getCoords(),n=this._internal,r=new Map;for(let e=0;e<t.length;e++){let i=t[e];if(!i)continue;let a=Sz(n,i.scope);if(!a)continue;let o=r.get(a);o||r.set(a,o=[]),o.push(i)}if(t.length===0)return e(n,t);if(r.size===0)return()=>{};let i=[];return r.forEach((t,n)=>{i.push(e(n,t))}),()=>{for(let e=0;e<i.length;e++)i[e]?.()}}find(e){let t=this._byScope();if(!t)return this._internal.find(this.getCoords(),e);let n=0,r=t[0].internal.find(t[0].coords,e);return{next(){for(;;){let i=r.next();if(!i.done)return i;if(++n>=t.length)return yo;r=t[n].internal.find(t[n].coords,e)}}}}getFlattened(e){let t=this.getCoords();if(t.length===1)return this._createRanges(t,e);let n=nB(t);return this._createRanges(n,e)}getPrecedents(e=!1){return this._trace(!1,e)}getDependents(e=!1){return this._trace(!0,e)}async _trace(e,t){let n=this.getCoords(),r=[];for(let i=0;i<n.length;i++){if(!n[i])continue;let a=this.at(i);r.push(e?t?a.getDependents():a.getDirectDependents():t?a.getPrecedents():a.getDirectPrecedents())}let i=await Promise.all(r),a=[];for(let e=0;e<i.length;e++){let t=i[e];t&&t.getCount()>0&&a.push(...this._rehome(t))}return a.length===0?null:this._createRanges(a.length>1?nB(a):a)}_rehome(e){let t=this._internal.getSheet().getName(),n=e.getWorksheet()?.getName(),r=e.getCoords(),i=Array(r.length);for(let e=0;e<r.length;e++){let a=r[e],o=a.scope??n;i[e]=o===t?a.scope?{...a,scope:void 0}:a:{...a,scope:o}}return i}getVisible(e){let t=this._readCoordsByScope((t,n)=>t.getVisible(n,e));return t&&t.length!==0?this._createRanges(t,e):null}getFixed(e){let t=this.getCoords(),n=t.length,r=Array(n);for(let i=0;i<n;i++)r[i]=Yz(t[i],e);return this._createRanges(r)}autoFit(e){return this._validateWrite(),this._writeByScope((t,n)=>t.autoFit(n,e),e),this}clear(e,t){return this._validateWrite(),this._writeByScope((n,r)=>n.clear(r,e,t),t),this}setValue(e,t){this._validateWrite();let n=this.getCoords();return n.length===1?(this._createRange(n[0]).setValue(e,t),this):(this.doBatch(()=>{for(let r=0;r<n.length;r++)this._createRange(n[r]).setValue(e,t)},{description:m(`op.setValue`),...t}),this)}getStyle(){let e=this._byScope();if(!e)return this._internal.getStyle(this.getCoords());let t=e[0];return t.internal.getStyle(t.coords,void 0,(t,n)=>{this.doBatch(()=>{for(let r=0;r<e.length;r++)e[r].internal.updateStyles(e[r].coords,t,n)})})}merge(e){return this._validateWrite(),this._writeByScope((t,n)=>t.merge(n,e),typeof e==`object`?e:void 0),this}unmerge(e){return this._validateWrite(),this._writeByScope((t,n)=>t.unmerge(n,e),e),this}getMerges(){let e=this._getStickyOptions()?.ignoreHidden??!1;return this._readCoordsByScope((t,n)=>t.getMerges(n,e))}insert(e){if(this._validateWrite(),typeof e==`object`&&e?.span){if(this.getCount()!==1)throw new k(N(`error.address.singleRangeOnly`));return this.at(0).insert(e),this}return this._writeByScope((t,n)=>t.insertCells(n,e),typeof e==`object`?e:void 0),this}delete(e){if(this._validateWrite(),typeof e==`object`&&e?.span){if(this.getCount()!==1)throw new k(N(`error.address.singleRangeOnly`));return this.at(0).delete(e),this}return this._writeByScope((t,n)=>t.deleteCells(n,e),typeof e==`object`?e:void 0),this}async insertFrom(e,t){this._validateWrite();let n=await this._internal.insertFrom(this.getCoords(),e,t);return n?this._createRanges([n]):null}async copyFrom(e,t){let n=await this._internal.copyFrom(this.getCoords()[0],e,t);return n?this._createRanges([n]):null}isInvalidAny(){let e=this.getCoords(),t=e?e.length:0;if(t===0)return!0;for(let n=0;n<t;n++)if(e[n]===null)return!0;return!1}getSnapshot(e){return this._internal.getSnapshot(this.getCoords(),e)}getEntireRows(e,t){return this._createRanges(vz(this.getCoords(),this._internal.getSheet().getEntireCoords(),B.Axis.Column,e),t)}getEntireColumns(e,t){return this._createRanges(vz(this.getCoords(),this._internal.getSheet().getEntireCoords(),B.Axis.Row,e),t)}getRowHeaders(e){let t=this.getCoords();return this._internal.getSheet().getRowHeaders().getRanges(t,e)}getColumnHeaders(e){let t=this.getCoords();return this._internal.getSheet().getColumnHeaders().getRanges(t,e)}getDefaultShiftAxis(){return this._internal.getDefaultShiftAxis(this.getCoords()[0])}getCount(){return this.getCoords()?.length??0}get size(){let e=this.getCoords();if(!e)return 0;let t=0;for(let n of e)t+=(n.rowEnd-n.rowStart+1)*(n.colEnd-n.colStart+1);return t}get length(){return this.getCount()}getStats(e){return this._internal.getRangeStats(this.getCoords(),e)}getCounts(e){let t=this._getStickyOptions(),n=e??t?.features,r=t?.ignoreHidden??!1,i=t?.ignoreSpilled??!1,a=this._byScope();if(!a)return this._internal.featureCounts(this.getCoords(),n,r,i);let o={};for(let e=0;e<a.length;e++){let t=a[e].internal.featureCounts(a[e].coords,n,r,i);for(let e of Object.keys(t))o[e]=(o[e]??0)+(t[e]??0)}return NR(o)}isContentful(e){let t=this._getStickyOptions(),n=e??t?.features;if(n===void 0){let e=this._byScope();if(!e)return this._internal.isContentful(this.getCoords(),t?.ignoreHidden??!1,t?.ignoreSpilled??!1);for(let n=0;n<e.length;n++)if(e[n].internal.isContentful(e[n].coords,t?.ignoreHidden??!1,t?.ignoreSpilled??!1))return!0;return!1}let r=this.getCounts(n),i=typeof n==`string`?[n]:n;for(let e=0;e<i.length;e++)if((r[i[e]]??0)>0)return!0;return!1}getRowCount(){return this._internal.getSheet().getRowHeaders().getRanges(this.getCoords()).getHeaderCount()}getColumnCount(){return this._internal.getSheet().getColumnHeaders().getRanges(this.getCoords()).getHeaderCount()}isEntireRowsAny(){return this._internal.getSheet().getColumnHeaders().getRanges(this.getCoords()).isEntireHeadersAny()}isEntireColumnsAny(){return this._internal.getSheet().getRowHeaders().getRanges(this.getCoords()).isEntireHeadersAny()}isEntireRows(){return this._internal.getSheet().getColumnHeaders().getRanges(this.getCoords()).isEntireHeaders()}isEntireColumns(){return this._internal.getSheet().getRowHeaders().getRanges(this.getCoords()).isEntireHeaders()}isOverlapping(){let e=this._byScope();if(!e)return lD(this.getCoords());for(let t=0;t<e.length;t++)if(lD(e[t].coords))return!0;return!1}isSingleCell(){let e=this.getCoords();return e.length===1&&h.isSingleCell(e[0])}isEqual(e,t){let n=this._internal.rangesToCoords(e,void 0,void 0,void 0,!0);return Jz(this.getCoords(),n,this.getWorksheet().getName())}at(e){let t=this.getCoords();if(e<0||e>t.length-1)throw new w;let n=this._cacheRanges,r=n[e];return r||(r=this._createRange(t[e]),n[e]=r),r}isReadOnly(){return this._readOnly!==null}isInvalid(){return!1}getA1(){return this.getAddress()}getAddress(e){return Qd(this.getCoords(),this._internal.getSheet().getEntireCoords(),void 0,Id)}getWorksheet(){return this._internal.getSheet()}doBatch(e,t){return this._internal.getSheet().doBatch(t=>e(t),typeof t==`string`?t:{description:m(`op.rangesUpdate`),...t})}get[Symbol.toStringTag](){return`[SheetRanges]`}toString(){return this.getAddress()}get isICellRanges(){return!0}};function nz(){return!1}function rz(){return!0}function iz(){return null}function az(){return bo}function oz(){return 0}var sz=new Qa(`InvalidRuntime`,null),cz={runtime:sz,sheet:null,styles:null,normalStyleRanged:null,nextContentful:(e,t,n)=>0,getProtection:()=>mz,getRange:e=>gz,getRanges:e=>new _z(null),opener:(e,t,n,r)=>Promise.resolve(!1)},lz=class extends SN{constructor(e=null){super(cz,null),this._invalidSheet=e}getWorksheet(){return this._invalidSheet}createCell(){return this}getType(){return U.Error}getWarnings(){return[gd]}getStyle(e=!1){return QR||=new Pm().getNormal()}toString(){return`${this._coords?Fd(this._coords):gd} => ${this._v??`{blank}`}`}},uz=new lz,dz=new WeakMap,fz,pz=()=>gz,mz=new yh(void 0,!0),hz=new Xc,gz={forEach:function(){},[Symbol.iterator]:az,entries:az,values:az,select:X,find:X,calculate:X,getCell:()=>uz,getFormula:iz,getFormulas:()=>[[``]],getNumberFormat:X,getNumberFormats:X,createFormula:X,getValue:iz,getInteropValue:iz,getText:()=>``,getTexts:()=>[[``]],setValue:X,setFormula:X,setFormulas:X,setNumberFormat:X,setNumberFormats:X,setValues:X,updateCells:X,getCells:()=>[[uz]],getStyle:X,getFormat:X,setStyle:X,getValues:()=>[[null]],getValuesRange:()=>new LV(sz,hz,null,null),setComputedValues:X,getInteropValues:()=>[[null]],getBounds:iz,getBestFit:iz,getIntersect:pz,getUnion:pz,getDifferences:X,getResizeBy:pz,getResizeTo:pz,getOffsetBy:pz,getOffsetTo:pz,getFixed:pz,getRangeAt:pz,getRowAt:pz,getRowAfter:pz,getRowBefore:pz,getRowBy:pz,getColumnAt:pz,getColumnAfter:pz,getColumnBefore:pz,getColumnBy:pz,getTopLeft:pz,getBottomRight:pz,getUsedRange:pz,getEntireRows:pz,getEntireRow:pz,getEntireColumn:pz,getEntireColumns:pz,getSurrounding:X,getExtended:X,isEntireRows:nz,isEntireColumns:nz,isEntireRange:nz,isSingleCell:rz,isEqual:nz,size:0,sort:X,sortAt:X,filter:X,textToColumns:X,removeDuplicates:X,clear:X,setHyperlink:X,setRichText:X,setErrorIgnored:X,setComments:X,merge:X,unmerge:X,getMerges:X,getUnlocked:X,getConditionalFormats:X,getControls:X,setControl:X,getSparklineGroups:X,setSparkline:X,getDataValidations:X,getComments:X,getTables:X,getPivotTables:X,getMovables:X,insert:X,insertFrom:X,canInsertFrom:nz,delete:X,addAutoTable:X,addTable:X,getDefaultShiftAxis:X,getDefaultSortCriteria:X,getDefaultAutoFillCriteria:X,autoFill:X,autoFit:X,group:X,ungroup:X,showGroupDetails:X,hideGroupDetails:X,clearGroups:X,getSnapshot:X,copyFrom:X,doBatch:X,createSparseBuilder:X,getRowHeaders:X,getColumnHeaders:X,getCounts:X,getRegions:X,getAnomalies:X,getDirectPrecedents:X,getDirectDependents:X,getPrecedents:X,getDependents:X,getStats:()=>(fz||=new EM(sz,hz,null,[hz.getMaxCoords()]),fz),isContentful:nz,addListener:X,addWatch:X,getColumnStart:oz,getRowStart:oz,getColumnEnd:oz,getRowEnd:oz,getRowCount:oz,getColumnCount:oz,getVisible:X,getCoords:iz,isEmpty:rz,toString:()=>gd,getAddress:()=>gd,getA1:()=>gd,isInvalid:rz,getWorksheet:iz,isReadOnly:rz,isICellRange:!0},_z=class extends tz{constructor(e,t){super(null,e,t)}getMerges(){return X()}getStyle(){return X()}find(){return bo}[Symbol.iterator](){return bo}entries(){return bo}calculate(){return X()}clear(){return X()}merge(){return X()}unmerge(){return X()}insert(){return X()}delete(){return X()}insertFrom(){return X()}canInsertFrom(){return!1}getSnapshot(){return X()}copyFrom(){return X()}getEntireRows(){return X()}getEntireColumns(){return X()}getRowHeaders(){return X()}getColumnHeaders(){return X()}getDefaultShiftAxis(){return X()}getFlattened(){return X()}getVisible(){return X()}getAddress(){return X()}getStats(){return fz}getCounts(){return X()}getRegions(){return X()}getAnomalies(){return X()}getDirectPrecedents(){return X()}getDirectDependents(){return X()}getPrecedents(){return X()}getDependents(){return X()}isContentful(){return X()}getRowCount(){return 0}getColumnCount(){return 0}isReadOnly(){return!0}isOverlapping(){return!1}isEntireRows(){return!1}isEntireRowsAny(){return!1}isEntireColumns(){return!1}isEntireColumnsAny(){return!1}isInvalidAny(){return!1}isSingleCell(){return!0}isEqual(){return!1}getFixed(){return X()}at(){return X()}doBatch(){return X()}getCoords(){return null}isInvalid(){return!0}toString(){return gd}select(){return X()}addListener(){return X()}};function vz(e,t,n,r=!1){let i=n===B.Axis.Row,a=e.length,o=Array(a);for(let n=0;n<a;n++){let a=e[n];if(i){let e=a.colEnd-a.colStart+1;o[n]={...a,colStart:r?a.colEnd+1:a.colStart,rowStart:t.rowStart,colEnd:r?a.colEnd+e:a.colEnd,rowEnd:t.rowEnd}}else{let e=a.rowEnd-a.rowStart+1;o[n]={...a,colStart:t.colStart,rowStart:r?a.rowEnd+1:a.rowStart,colEnd:t.colEnd,rowEnd:r?a.rowEnd+e:a.rowEnd}}}return o}function yz(e,t,n){let r=t,i=e.length,a=r.rowStart,o=r.rowEnd;for(let t=0;t<i;t++){let r=e[t];if((r.rowStart<=a&&r.rowEnd>=o)!==n)return!n}return n}function bz(e,t,n){let r=t,i=e.length,a=r.colStart,o=r.colEnd;for(let t=0;t<i;t++){let r=e[t];if((r.colStart<=a&&r.colEnd>=o)!==n)return!n}return n}function xz(e){return e._getInternal()}function Sz(e,t){if(!t)return e;let n=e.getSheet();if(t===n.getName())return e;let r=n.getWorkbook();if(!r)return null;let i=r.getWorksheets().getItems({name:t,visibility:Qu.Visibility.VeryHidden})?.[0];return i?xz(i):null}function Cz(e,t){if(!e?.scope||!wz(e.scope,t))return e;let n={...e};return delete n.scope,n}function wz(e,t){return e===t.getName()||e===t.getId()}function Tz(e,t=null,n=null,r=gd){if(!e&&!n)return gz;let i=function(e){if(!e)return uz;let t=dz.get(e);return t||(t=new lz(e),dz.set(e,t)),t}(e);return Object.freeze({...gz,getWorksheet:()=>e,getCell:()=>i,getCells:()=>[[i]],bounds:()=>n,getAddress:()=>r,toString:()=>n?zd(n,t):r})}function Ez(e){return new _z(e)}var Dz=/(\d)\*\*([-+]?\d)/g,Oz=[` `,`\xA0`,` `,` `],kz=RegExp(`([0-9])[`+Oz.join(``)+`](?=[0-9])`,`g`),Az=/[^\s#0.,%E+\-_();[\]]/,jz=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);function Mz(e){let t=0,n=e.length;for(;t<n&&e.charCodeAt(t)===32;)t++;for(;n>t&&e.charCodeAt(n-1)===32;)n--;return e.slice(t,n)}var Nz=`€`,Pz=32767;function Fz(e,t){let n=Mz(e);if(n===``)return null;let r=!1;if(n.includes(`(`)||n.includes(`)`)){if(!n.startsWith(`(`)||!n.endsWith(`)`)||(n=Mz(n.slice(1,-1)),n.includes(`(`)||n.includes(`)`)))return null;r=!0}let i=e=>{let r=t.currencyPosition===`after`===e?[Nz]:[t.currencySymbol,Nz];for(let t of r)if(t&&(e?n.startsWith(t):n.endsWith(t)))return n=Mz(e?n.slice(t.length):n.slice(0,n.length-t.length)),!0;return!1},a=!1,o=()=>{(i(!0)||i(!1))&&(a=!0)};o(),(n.startsWith(`+`)||n.startsWith(`-`))&&(r=r!==n.startsWith(`-`),n=Mz(n.slice(1)),o());let s=!1;return n.startsWith(`%`)?(n=Mz(n.slice(1)),s=!0):n.endsWith(`%`)&&(n=Mz(n.slice(0,-1)),s=!0),a&&s?null:{core:n,negative:r,percent:s,currency:a}}var Iz=/[eE]/,Lz=/^(\d+) (\d{1,5})\/(\d{1,5})$/;function Rz(e,t,n,r){let i=function(e,t){let n=e.replace(Dz,`$1E$2`);return Oz.includes(t.group)&&(n=n.replace(kz,`$1${t.group}`)),n}(Mz(t),n);if(function(e,t,n){let r=Fz(e,t);if(!r)return!1;let i=Lz.exec(r.core);if(!i)return!1;let a=Number(i[2]),o=Number(i[3]);if(o===0||a>Pz||o>Pz)return!1;let s=Number(i[1])+a/o;r.percent&&(s/=100),r.negative&&(s=-s),n.value=s;let c=r.percent?`0.00%`:o>=10?`# ??/??`:`# ?/?`,l=r.percent?`%`:`/`;return n.style=e=>{if(!e.getNumberFormat().includes(l))return{numberFormat:c}},!0}(i,n,r))return!0;let a=function(e,t){let n=Fz(e,t);if(!n)return null;let r=n.core,i=jz(t.decimal),a=jz(t.group),o=t.group?`\\d+|\\d{1,3}(?:${a}\\d{3})+`:`\\d+`;return RegExp(`^(?:(?:${o})(?:${i}\\d*)?|${i}\\d+)(?:[eE][+-]?\\d+)?$`).test(r)?n:null}(i,n);if(!a||!Ut.isNumberTextInRange(i,n.decimal))return!1;if((a.percent||a.currency)&&Iz.test(a.core)){let e=Zu(Ut.truncateNumberText(a.core),{locale:n.tag});if(!e||typeof e.v!=`number`)return!1;let t=e.v;return a.percent&&(t/=100),a.negative&&(t=-t),r.value=Ut.flushSubnormal(t),e.z&&(r.style={numberFormat:e.z}),!0}let o=Zu(Ut.truncateNumberText(i),{locale:n.tag});if(!o||typeof o.v!=`number`)return!1;r.value=Ut.flushSubnormal(o.v);let s=o.z;if(!s)return!0;if(s.includes(`%`))return r.style=e=>{if(!e.getNumberFormat().includes(`%`))return{numberFormat:s}},!0;let c=s.match(Az)?.[0];if(c){if(c!==n.currencySymbol)return!0;let e=s.includes(`.`)?`${c}#,##0.00`:`${c}#,##0`;return r.style=t=>{if(!t.getNumberFormat().includes(c))return{numberFormat:`${e}_);[Red](${e})`}},!0}return r.style={numberFormat:s},!0}function zz(e,t,n,r){if(t===void 0)throw Error(`A value is required to create a cell from a text.`);let a=r??{value:null};if((t=i.castToString(t))===``)return a;let o=gl(t);if(o!==void 0)return a.value=o,a;if(t.startsWith(`'`)&&!n?.ignoreQuotePrefix)return a.style={quotePrefix:!0},a.value=t.substring(1,t.length),a;if(a.value=t,Rz(0,t,e.getLocaleProfile(),a)||function(e,t,n){if(t.startsWith(` `))return!1;let r=null,i=null;try{i=vt(e,t,!0,!0);let n=t;if(i){let e=i.leadingText.trim(),t=i.trailingText.trim();if(e.length>0&&t.length>0)return!1;n=e.length>0?e:t}n.trim().length>0&&(r=rt(e,n,null,!1,!0)),!r&&i&&(i.leadingText.trim().length>0||i.trailingText.trim().length>0)&&(i=null)}catch{}if(!r&&!i)return!1;n.style=t=>{let n=t.getNumberFormat(),a=nt(n);if(r&&a)return;let o=pt(n);if(!i||!o){if(r&&i&&!a&&!o?n=`m/d/yyyy h:mm`:r&&!a?n=r.numberFormat:i&&!o&&(n=i.numberFormat),i&&i.parsed.serial>1&&(n=`General`),r&&!a&&!i){let t=Je.Parser.formatValue(e,r.numberFormat,r.asSerialDate),i=e.getLocale();t===new Intl.DateTimeFormat(i).format(r.asJSDate)?n=`Short Date`:t===new Intl.DateTimeFormat(i,{dateStyle:`full`}).format(r.asJSDate)?n=`Long Date`:t===new Intl.DateTimeFormat(i,{timeStyle:`medium`}).format(r.asJSDate)&&(n=`Long Time`)}return{numberFormat:n}}};let a=0;return r&&(a+=r.asSerialDate),i&&(a+=i.parsed.serial),n.value=a,!0}(e,t,a))return a;let s=_l(t);if(s)return a.value=s,a;a.value=t;let c=bn(t);return c!==null&&(a.hyperlink=c),t.includes(`
|
|
586
|
-
`)&&(a.style={...a?.style,alignment:{overflow:R.Overflow.Wrap}}),a}function Bz(e){let t=e._indexedHidden;if(t)return t;let n=[];return e.getUsedRange().forEachSpan((e,t)=>{let r=t.getCoords();e===0&&n.push(r)}),ao(oo(n))}var Vz=new WeakMap;function Hz(e,t,n){let r=Bz(e),i=0,a=r.length;for(;i<a;){let e=i+a>>>1;r[e].max<t?i=e+1:a=e}if(i===r.length||r[i].min>n)return null;let o=Vz.get(r);return o||(o=_o(r),Vz.set(r,o)),o}function Uz(e,t){return e?(n,r)=>{for(;;){let i=t(e(n,r),r);if(i===n)return i;n=i}}:t}function Wz(e){if(!e)return null;let t=null,n=e.length;for(let r=0;r<n;r++){let n=e[r].value;if(!n)continue;t||={};let i=Object.keys(n),a=i.length;for(let e=0;e<a;e++){let r=i[e],a=t[r];if(a){if(Array.isArray(a)){let e=n[r];if(Array.isArray(e)){let t=e.length;for(let n=0;n<t;n++)a.push(e[n])}else a.push(e)}else t[r]=[a,n[r]]}else t[r]=n[r]}}return t}function Gz(e,t,n,r=!1,i=!1){let a,o=n?.includeMergeOverflow??!1;if(r)a=!0;else if(i||o){let e={};i&&(e[G.Type.DateFormat]=!1,e[G.Type.Table]=!1,e[G.Type.Pivot]=!1),o&&(e[G.Type.Merge]=!1),a=e}let s=n?.axis??B.Axis.Row,c=n?.maxSize??1e4,l=e({includeEmpty:!0,axis:s,reverse:n?.reverse,ignoreHidden:n?.ignoreHidden,includeMergeOverflow:o,searchTypes:a,bounds:t,reuseContext:!0}),u=s!==B.Axis.Row,d=[],f,p=-1,m=null,h=0;for(f=l.next();!f.done;){if(h>c)throw Error(Dx(c,`more than ${c}`,zd(t)));let e=f.value,n=e.context.getCoords(),a=u?n.colIndex:n.rowIndex;a!==p&&(m=[],d.push(m),p=a);let o=e.value;if(r)o=e.context.getCell();else if(i&&o!==null){let t=e.context.getInteropValue();t&&(o=t)}m.push(o),f=l.next(),h++}return d}var Kz=(e,t)=>{let n=e.scope;return n&&t&&n.toLowerCase()===t.toLowerCase()?void 0:n};function qz(e,t,n){return e===t||!(!e||!t)&&e.rowStart===t.rowStart&&e.rowEnd===t.rowEnd&&e.colStart===t.colStart&&e.colEnd===t.colEnd&&e.$rowStart===t.$rowStart&&e.$rowEnd===t.$rowEnd&&e.$colStart===t.$colStart&&e.$colEnd===t.$colEnd&&(e.scope===t.scope||Kz(e,n)===Kz(t,n))}function Jz(e,t,n){if(e===t)return!0;if(!e||!t)return!1;let r=e.length;if(r!==t.length)return!1;for(let i=0;i<r;i++)if(!qz(e[i],t[i],n))return!1;return!0}function Yz(e,t){if(!e)return;let n={...e};return t?typeof t==`boolean`?(n.$colStart=t,n.$rowStart=t,n.$colEnd=t,n.$rowEnd=t,n):(typeof t.colStart==`boolean`&&(n.$colStart=t.colStart),typeof t.rowStart==`boolean`&&(n.$rowStart=t.rowStart),typeof t.colEnd==`boolean`&&(n.$colEnd=t.colEnd),typeof t.rowEnd==`boolean`&&(n.$rowEnd=t.rowEnd),n):n}var Xz=class{constructor(e,t,n){this._c=null;let r=this;this.setState=e=>{let n=e[0],r=e[1],i=e[2];if(t&&t.includeMergeOverflow&&i&&i.merge){let e=t.bounds,a=i.merge.getCoords(),o=!1,s=a.colStart,c=a.rowStart,l=e.colStart,u=e.rowStart,d=n.colIndex,f=n.rowIndex;!o&&s<l&&c>=u&&d===l&&f===c&&(o=!0),!o&&c<u&&s>=l&&f===u&&d===s&&(o=!0),!o&&c<u&&s<l&&f===u&&d===l&&(o=!0),o&&(r=i.merge.tvTl())}i&&Object.keys(i).length===0&&(i=null);let a=r;return r===void 0?(this._t=U.Null,this._v=null,a=null):(this._t=pB(a),this._v=a),this._r=i,this._p=e[3],this._n=e[4],this._c=n,a},this.clear=()=>{r._c=null},this.context={getCoords(){let e=r._c;if(!e)throw Error(N(`error.sheet.iteratorClosed`));return e},getCell(){let e=r._c;if(!e)throw Error(N(`error.sheet.iteratorClosed`));let i=r._r,a=!0!==t?.searchTypes||i?.merge||t?.injectReferences?null:n.renderCellCache,o;if(a){o=32768*e.rowIndex+e.colIndex;let t=a.get(o);if(t)return t}let s=r._t,c=r._v,l=new SN(n,a?{rowIndex:e.rowIndex,colIndex:e.colIndex}:e,s,c,i,r._p,r._n);return a&&a.set(o,l),l},getType:()=>r._t,getInteropType(){let e=r._t;return e===U.Number&&r._r?.dateFormat?H.Date:e},getInteropValue(){let e=r._t,t=r._v;return e===U.Number&&r._r?.dateFormat?OB(n.runtime,t,r._t,H.Date,!1):t},getAddress(e,t=!1){if(!r.context)throw Error(N(`error.sheet.iteratorClosed`));let i=r._c;return e&&(i={...r._c,...e}),n.getRange(i).getAddress(t)},getInjectedReference(e){let t=r._r;if(!t)return;let n=t[e];return n===void 0?void 0:n}}}};function Zz(e,t){let n=B.Direction.Down,r=0,i={...e};if(t.colStart<e.colStart?(n=B.Direction.Left,r=e.colStart-t.colStart,i.colStart=t.colStart):t.colEnd>e.colEnd?(n=B.Direction.Right,r=t.colEnd-e.colEnd,i.colEnd=t.colEnd):t.rowStart<e.rowStart?(n=B.Direction.Up,r=e.rowStart-t.rowStart,i.rowStart=t.rowStart):t.rowEnd>e.rowEnd||t.rowEnd<e.rowEnd?(n=B.Direction.Down,r=t.rowEnd-e.rowEnd,i.rowEnd=t.rowEnd):t.colEnd<e.colEnd?(n=B.Direction.Right,r=t.colEnd-e.colEnd,i.colEnd=t.colEnd):t.rowStart>e.rowStart?(n=B.Direction.Up,r=e.rowStart-t.rowStart,i.rowStart=t.rowStart):t.colStart>e.colStart&&(n=B.Direction.Left,r=e.colStart-t.colStart,i.colStart=t.colStart),!_c(i,t))throw new k(((e,t)=>N(`error.sheet.autofillInvalidDestination`,{template:e,destination:t}))(zd(e),zd(t)));return{direction:n,amount:r}}function Qz(e,t){if(e||t)return e&&t?{...e,...t}:e||t}function $z(e,t,n){let r=e.rowStart<=n.rowStart&&e.rowEnd>=n.rowEnd,i=e.colStart<=n.colStart&&e.colEnd>=n.colEnd;if(r&&i)return e;let a=e,o=!0;for(;o;){o=!1;let e=t(a),n=e.length,s=null;for(let t=0;t<n;t++){let n=e[t],o=s??a,c=r?o.colStart:Math.min(o.colStart,n.colStart),l=r?o.colEnd:Math.max(o.colEnd,n.colEnd),u=i?o.rowStart:Math.min(o.rowStart,n.rowStart),d=i?o.rowEnd:Math.max(o.rowEnd,n.rowEnd);c===o.colStart&&l===o.colEnd&&u===o.rowStart&&d===o.rowEnd||(s={...o,colStart:c,colEnd:l,rowStart:u,rowEnd:d})}s&&(a=s,o=!0)}return a}function eB(e,t,n){if(!e||e.length===0||!t)return i.EmptyArray;let r=e=>t.search(e),a=e.length,o=Array(a);for(let t=0;t<a;t++)o[t]={...$z(e[t],r,n)};return o}function tB(e,t,n,r,i){let a=e,o=n?t.colStart:t.rowStart,s=n?i.colEnd:i.rowEnd,c=n?e.colIndex:e.rowIndex;if(r>0&&c>o||r<0&&o<=c){a={...e};let t=Math.max(c+r,o);if(a[n?`colIndex`:`rowIndex`]=t,c>s)throw new k(N(`error.sheet.insertOobFreeze`))}return a}function nB(e,t=B.AxisSelection.Both){let n=t===B.AxisSelection.Both,r=n?2**53-1:1,i=Sc(e,r,t===B.AxisSelection.Row?B.Axis.Column:B.Axis.Row);if(n){let t=Sc(e,r,B.Axis.Column);t.length<i.length&&(i=t)}return i}function rB(e){return(t,n,r=!1)=>{let i=null,a=Xm(n,()=>i||(i=ch(void 0,e,t,t.getCoords()),i)),o=t.cloneWithUpdate(a,r);return o.isEmpty()&&!o.getUpdateProperties()?null:o}}function iB(e,t,n,r,i){let a=e._p?.borders;if(!a)return;let o,s,c={onIntersect:(e,t)=>{if(!e)return e;let n=e.value?._p?.borders;if(!n)return e;let i;return o===L.Edge.Left?n.left&&e.colStart===s&&(i={borders:{left:null}}):o===L.Edge.Top?n.top&&e.rowStart===s&&(i={borders:{top:null}}):o===L.Edge.Right?n.right&&e.colEnd===s&&(i={borders:{right:null}}):o===L.Edge.Bottom&&n.bottom&&e.rowEnd===s&&(i={borders:{bottom:null}}),i?{...t,value:r(e.value,i)}:e}};a.right&&t.colEnd<i.colEnd&&(o=L.Edge.Left,s=t.colEnd+1,n.insertNonOverlapping({colStart:s,rowStart:t.rowStart,colEnd:s,rowEnd:t.rowEnd,value:void 0},c)),a.bottom&&t.rowEnd<i.rowEnd&&(o=L.Edge.Top,s=t.rowEnd+1,n.insertNonOverlapping({colStart:t.colStart,rowStart:s,colEnd:t.colEnd,rowEnd:s,value:void 0},c)),a.left&&t.colStart>i.colStart&&(o=L.Edge.Right,s=t.colStart-1,n.insertNonOverlapping({colStart:s,rowStart:t.rowStart,colEnd:s,rowEnd:t.rowEnd,value:void 0},c)),a.top&&t.rowStart>i.rowStart&&(o=L.Edge.Bottom,s=t.rowStart-1,n.insertNonOverlapping({colStart:t.colStart,rowStart:s,colEnd:t.colEnd,rowEnd:s,value:void 0},c))}function aB(e,t,n,r,i){let a=(e,t)=>({...t,value:null}),o={...i,value:null};t.insertNonOverlapping(o,{onIntersect:a}),n.insertNonOverlapping(o,{onIntersect:a}),r.insertNonOverlapping(o,{onIntersect:a});let s=e.search(i);for(let e=0;e<s.length;e++){let i=s[e],a=i.value;if(!a)continue;let o=a.splitByFeature();o.border&&t.insertNonOverlapping({...i,value:o.border}),o.fill&&n.insertNonOverlapping({...i,value:o.fill}),o.content&&r.insertNonOverlapping({...i,value:o.content})}}function oB(e,t){let n=!1;for(let r of e)if(t&&r===t)n=!n;else if(!n){if(r===`,`)return`,`;if(r===` `)return` `}}function sB(e,t,n,r){let i=[],a=``,o=!1,s=t.length;for(let r=0;r<e.length;r++){let c=e[r];n&&c===n?o=!o:o||e.slice(r,r+s)!==t?a+=c:(i.push(a),a=``,r+=s-1)}i.push(a);let c=r?i.map(e=>e.length>0?e:null):i.filter(e=>e.length>0);return c.length>0?c:[null]}function cB(e,t,n){let r=typeof t;if(r===`number`)return``+e+``+t.toString();if(r===`string`){let r=t,i=n.get(r);return i===void 0&&(i=r.toLowerCase(),n.set(r,i)),``+e+``+i}return r===`boolean`?``+e+``+(t?`1`:`0`):t==null?``+e+`\0`:``+e+``+t.getCode()}var lB=Object.freeze({colStart:0,rowStart:0,colEnd:2**14-1,rowEnd:2**20-1});function uB(){return lB}var dB=Object.freeze({colStart:0,rowStart:0,colEnd:2**31-2,rowEnd:2**31-2});function fB(){return dB}var pB=(e,t=!1)=>typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?U.Error:U.Number:typeof e==`string`?U.String:typeof e==`boolean`?U.Boolean:e?.isFormulaError?U.Error:e===null?U.Null:!0===e?.isIRichData?U.RichData:t&&we(e,!0)?H.Date:e===void 0?(console.warn(`undefined`),U.Null):null,mB=new Map([[U.Null,`any`],[U.Number,`number`],[U.String,`string`],[U.Boolean,`boolean`],[U.Error,`FormulaError`],[U.RichData,`richData`],[H.Date,`Date`],[`*`,`Scalar`]]),hB=new Map([[`p`,`IReferenceRange`],[`r`,`IRange`],[`m`,`[][]`],[`*`,`any`]]);function gB(e){let t=e.scalar,n=e.range,r=t?mB.get(t)??`InvalidScalar`:``,i=n?hB.get(n)??`InvalidRange`:``,a;return a=t&&n?n===`m`?`${r}${i}`:`${i}<${r}>`:r||i,a+=`[]`.repeat(e.arrayDepth??0),a}var _B={axis:B.Axis.Row},vB=22250738585072014e-324,yB=/^ *[^\S ]|[^\S ] *$/,bB=/^ *0[xXbBoO]/;function xB(e,t){return wB(e,t.getLocaleProfile().decimal,20)}function SB(e,t=`.`){return wB(e,t,21)}function CB(e,t){let[n,r]=e.toExponential(t-1).split(`e`),i=n.replace(`.`,``),a=i.length;for(;a>1&&i.charCodeAt(a-1)===48;)a--;return i=i.slice(0,a),[i,parseInt(r,10)]}function wB(e,t,n){if(e===0)return`0`;if(!Number.isFinite(e))return e.toString();let r=e<0,[i,a]=CB(Math.abs(e),15),o=null;if(a>=0){let e=a+1;i.length>e?o=i.slice(0,e)+t+i.slice(e):e<=n&&(o=i.padEnd(e,`0`))}else{let e=-a-1;2+e+i.length<=n&&(o=`0`+t+`0`.repeat(e)+i)}if(o===null){n===20&&Math.abs(a)>=100&&([i,a]=CB(Math.abs(e),14));let r=i.length>1?i[0]+t+i.slice(1):i,s=Math.abs(a);o=r+(a<0?`E-`:`E+`)+(s<10?`0`+s:String(s))}return r?`-`+o:o}function TB(e,t){return typeof e==`string`?e:e==null?``:typeof e==`boolean`?ml(e):typeof e==`number`?xB(e,t):e?.isFormulaError?hl(e):String(e)}function EB(e,t){let n=t.trim();if(n===``)return V.BuiltIn.Value;let r=Number(Ut.truncateNumberText(n));return Number.isFinite(r)?he(r,e.isDate1904())??V.BuiltIn.Value:V.BuiltIn.Value}function DB(e,t,n){let r=function(e,t,n){if(!n)switch(t){case H.Number:return null;case H.String:n=VB;break;case H.Boolean:n=HB;break;case H.Date:n=UB;break;case H.Null:n=WB;break;case H.Error:case H.RichData:default:return null}let r=!1,i=!1,a=!1,o=!1,s=n.length;for(let e=0;e<s;e++)switch(n[e]){case U.Number:r=!0;break;case U.String:i=!0;break;case U.Boolean:a=!0;break;case U.RichData:break;case U.Null:o=!0}return t===U.Number?(t,n)=>{if(n===U.Error)return t;switch(n){case U.Null:return o?0:null;case U.String:if(!i)return null;let n=t;if(n.length>255||yB.test(n))return V.BuiltIn.Value;let r=bB.test(n)?NaN:Number(Ut.truncateNumberText(n));if(r==r&&n.includes(`.`)&&e.getLocaleProfile().decimal!==`.`&&(r=NaN),r===0&&n.trim()===``)return V.BuiltIn.Value;if(isNaN(r)){let t=zz(e,n.trim());t&&(r=t.value)}return!Number.isFinite(r)||Math.abs(r)>999999999999999e293||!Ut.isNumberTextInRange(n)?V.BuiltIn.Value:Ut.flushSubnormal(r);case U.Boolean:return a?+!!t:null}return null}:t===U.String?(t,n)=>{if(n===U.Error)return t;switch(n){case U.Number:return r?xB(t,e):null;case U.Boolean:return a?ml(t):null;case U.Null:return o?``:null}return null}:t===H.Boolean?(e,t)=>{if(t===U.Error)return e;switch(t){case U.Number:return r?IB(e)!==0:null;case U.String:if(!i)return null;let t=e;return t===`TRUE`||t!==`FALSE`&&(t=t.toUpperCase(),t===`TRUE`||t!==`FALSE`&&null);case U.Null:return!o&&null}return null}:t===H.Date?(t,n)=>{if(n===U.Error)return t;switch(n){case U.Number:return r?he(t,e.isDate1904())??V.BuiltIn.Value:null;case U.String:if(!i)return null;let n=fe(e,t);return n===null?EB(e,t):he(n,e.isDate1904());case U.Null:return o?he(0,e.isDate1904()):null}return null}:t===U.Null?(e,t)=>{if(t===U.Error)return e;switch(t){case U.Number:return r?0:null;case U.String:return i?``:null;case U.Boolean:return!a&&null}return null}:t===H.RichData?(e,t)=>null:null}(e,t,n);return r&&t!==H.RichData?(e,t,n)=>{if(t!==U.RichData)return r(e,t,n);let i=ku.toPrimitive(e);return i===void 0?null:r(i,pB(i),n)}:r}function OB(e,t,n,r=U.Number,i=!1){if(n===r||!r)return n===U.Number&&(t=LB(t,null,`number`)),t;if(Yy(t)&&r!==`l`&&r!==`*`||Ht(t))return V.BuiltIn.Value;if(n===U.RichData){let n=ku.toPrimitive(t);return n===void 0?V.BuiltIn.Value:OB(e,n,pB(n),r,i)}if(r===U.Number){switch(n){case U.Null:return 0;case U.String:if(t.length>255)return V.BuiltIn.Value;let n=0;try{let r=zz(e,t);n=r&&typeof r.value==`number`?r.value:NaN}catch{}return!Number.isFinite(n)||Math.abs(n)>999999999999999e293?V.BuiltIn.Value:n;case U.Boolean:return i?+!!t:V.BuiltIn.Value;case H.Date:return Dt(t,e.isDate1904())??V.BuiltIn.Value;case U.Error:return t}return t.toString()}if(r===U.String){switch(n){case U.Null:return``;case U.Number:return xB(t,e);case U.Boolean:return ml(t);case U.Error:return t}return t}if(r===H.Boolean){switch(n){case U.Null:return!1;case U.Number:return IB(t)!==0;case U.String:let e=t.toUpperCase();return e===`TRUE`||e!==`FALSE`&&V.BuiltIn.Value;case U.Error:return t}return V.BuiltIn.Value}if(r===H.Date){switch(n){case U.Null:return he(0,e.isDate1904());case U.Number:return he(t,e.isDate1904())??V.BuiltIn.Value;case U.String:let n=fe(e,t);return n===null?EB(e,t):he(n,e.isDate1904());case U.Error:return t}return V.BuiltIn.Value}return r===H.RichData?null:V.BuiltIn.Value}var kB=(e,t,n=null)=>{let r=Array.isArray(t),i=e.next();for(;!i.done;){let a=i.value;if(n===`reject`&&V.isError(a)||a instanceof V.Value)return a;r?t.push(a):t.values[t.length++]=a,i=e.next()}};function AB(e){if(!Array.isArray(e))return!1;let t=e[0];return!(!t||typeof t!=`object`)&&(!!t.isIRange||t.colStart!==void 0)}function jB(e,t,n,r=!1,i,a,o=null,s=!1){let c=n;if(c===null)return;if(c.colStart!==void 0){let t=e.getReference?.(c);a&&!s&&(t=t.toType(a)),c=t}if(c.isIRange&&s&&a){let n=e.getRuntime(),r=Array.isArray(t);if(!0===c.isIReferenceRange&&c.size===1&&c.getValueAt(0,0)==null)return;for(let e of c.values({includeEmpty:!0,onError:`value`,..._B})){if(V.isError(e)){if(o===`reject`)return e;r?t.push(e):t.values[t.length++]=e;continue}let i=OB(n,e??null,pB(e??null,!0),a,!1);if(V.isError(i))return i;r?t.push(i):t.values[t.length++]=i}return}if(c.isIRange){let e=c,n=o===`reject`?`throw`:`value`;try{return kB(e.values({type:a,onError:n,..._B}),t,o)}catch(e){if(V.isError(e))return e;throw e}}let l=Array.isArray(t);if(Array.isArray(c)){let n=c.length;for(let u=0;u<n;u++){let n=c[u];if(n!==null||s){if(Array.isArray(n)){let c=jB(e,t,n,r,i,a,o,s);if(c)return c}else{if(o===`reject`&&V.isError(n))return n;if(a&&(n=OB(e.getRuntime(),n,pB(n,!0),a,!s&&r),n instanceof V.Value)){if(r&&a===U.Boolean)continue;return n}l?t.push(n):t.values[t.length++]=c}}}}else return o===`reject`&&V.isError(c)||a&&(c=OB(e.getRuntime(),c,pB(c,!0),a,r),c instanceof V.Value)?c:void(l?t.push(c):t.values[t.length++]=c)}function MB(e,t,n,r,i,a=null){if(n===`p`){let e=t;if(!e||!e.isIReferenceRange){if(V.isError(t))return t;let e=t;if(e?.isIRange&&e.size===1){let t=e.getValueAt(0,0);if(V.isError(t))return t}return V.BuiltIn.Value}return r&&(e=a===`accept`?e.toType({type:r,onError:`value`}):e.toType(r)),e}let o;try{t?.isIReferenceRange?(o=t,r&&(o=a===`accept`?o.toType({type:r,onError:`value`}):o.toType(r))):a===`accept`?(o=V.isError(t)?e.getRange(t,void 0,!1):e.getRange(t,void 0,i),r&&(o=o.toType({type:r,onError:`value`}))):(o=e.getRange(t,r??void 0,i),r&&o===t&&(o=o.toType({type:r,onError:`throw`})))}catch(e){if(Jy(e))throw e;return e}return n===`r`?o:o.getValues()}function NB(e,t,n,r,i,a,o,s,c=null,l=!1){let u=n;if(u&&u.colStart!==void 0){if(i)u=e.getReference?.(u);else{let t=u.colStart,n=u.rowStart,r=u.colEnd;u=u.rowEnd!==n||t!==r?e.getReference?.(u):e.getValueAt(n,t,u.scope)}}if(r&&typeof n==`string`&&a===U.Boolean){if(n===`TRUE`||n===`FALSE`)u=n===`TRUE`;else{let e=n.toUpperCase();e!==`TRUE`&&e!==`FALSE`||(u=e===`TRUE`)}}u?.isIRange&&u._isDirectScalarBox?.()&&(u=u.getValueAt(0,0));let d=u?function(e){let t=e,n=0;for(;Array.isArray(t);)n++,t=t[0];return t&&(t.isIRange||t.colStart!==void 0)&&(n+=2),n}(u):0;if(d===0&&V.isError(u)){if(c===`reject`)return u;if(c===`accept`){if(i)return void(Array.isArray(t)?t.push(u):t.values[t.length++]=u);a=null}}if(!l||!s||d!==0||u!==null){if(d===0&&a){let t=pB(u,!0);if(t!==a){let n=!r&&s;if(u=OB(e.getRuntime(),u,t,a,!l&&!n),r&&s&&a===U.Boolean&&V.isError(u))return}if(!o&&V.isError(u))return u}if(s){if(d===3){let n=u;for(let u=0;u<n.length;u++){let d=NB(e,t,n[u],r,i,a,o,s,c,l);if(d)return d}return}if(!i)return jB(e,t,u,r,i,a,c,l);if(u=MB(e,u,i,a,r,c),V.isError(u))return u}else{if(AB(u))return V.BuiltIn.Value;if(i){if(u=MB(e,u,i,a,r,c),V.isError(u))return u}else if(d>0){if(u=function(e,t=!1){let n=e;for(;Array.isArray(n);){if(n.length>1)return t?V.BuiltIn.Value:n;n=n[0]}if(n?.isIRange){if(t&&n.size!==1)return V.BuiltIn.Value;n=n.getValueAt(0,0)}return n}(u,!0),c===`reject`&&V.isError(u))return u;if(a&&!V.isError(u)){let t=pB(u,!0);if(t!==a&&(u=OB(e.getRuntime(),u,t,a,r)),!o&&V.isError(u))return u}}}if(!o&&V.isError(u))return u;Array.isArray(t)?t.push(u):t.values[t.length++]=u}}function PB(e,t,n,r,i,a,o){let s=n;if(r&&i===U.Boolean&&typeof n==`string`){if(n===`TRUE`||n===`FALSE`)s=n===`TRUE`;else{let e=n.toUpperCase();e!==`TRUE`&&e!==`FALSE`||(s=e===`TRUE`)}}if(V.isError(s)){if(o===`reject`)return s;o===`accept`&&(i=null)}if(i){let t=pB(s,!0);t!==i&&(s=OB(e.getRuntime(),s,t,i,!0))}if(!a&&V.isError(s))return s;t.values[t.length++]=s}function FB(e){return e!=e||e===1/0||e===-1/0?V.BuiltIn.Num:e}function IB(e){return e>-22250738585072014e-324&&e<vB?0:e}function LB(e,t,n=typeof e){if(n===`number`)return FB(e);if(n===`string`)return e.length>Ut.MAX_TEXT_LENGTH?V.BuiltIn.Value:e;if(e==null)return null;if(!t)return e;if(Array.isArray(e)){if(AB(e))return e;try{e=t.getRange(e)}catch{return V.BuiltIn.Value}}return e}function RB(e,t,n){let r;r=Array.isArray(e)?Array.isArray(e[0])?e:[e]:[[e]],t||=new Xc({axis:B.Axis.Column});let i=t.getAxis()===B.Axis.Column,a=n?.colStart??0,o=n?.rowStart??0,s=Hc(r,i,jc(a,o,void 0,void 0,i),!0);if(!s){let e=0;for(let t=0;t<r.length;t++)e=Math.max(e,r[t]?.length??0);return{values:t,coords:{rowStart:o,colStart:a,rowEnd:o+r.length-1,colEnd:a+e-1},isLiteral:!n}}let c=Mc(s.bounds,i);return t.setValues(s.tuples),{values:t,coords:c,isLiteral:!n}}function zB(e,t=null){if(e<48){let n=[];for(let r=0;r<e;r++)n.push(t);return n}return Array(e).fill(t)}function BB(e){if(e<48){let t=[];for(let n=0;n<e;n++)t.push(void 0);return t}return Array(e).fill(void 0)}var VB=Object.freeze([U.Number,U.Boolean,U.Null]),HB=Object.freeze([U.Number,U.Null]),UB=Object.freeze([U.Number,U.String,U.Null]),WB=Object.freeze([U.Number,U.String,U.Boolean]),GB=Object.freeze([U.Number,U.String,U.Boolean,U.Null,U.RichData]);function KB(e,t,n){let r=e?.processRowSkip,i=e?.processColumnSkip;if(!r&&!i)return null;let a=r?{skip:r,origin:n?.rowIndex??0}:null,o=i?{skip:i,origin:n?.colIndex??0}:null;return t?{major:o,minor:a}:{major:a,minor:o}}var qB=(e,t)=>{let n=t-e.origin;return e.skip(n)!==n},JB=(e,t,n)=>e.skip(t-e.origin,n)+e.origin,YB=(e,t,n)=>{if(!e)return n-t+1;let r=0;for(let i=t;i<=n;i++){let t=JB(e,i);t===i?r++:t>i&&(i=t-1)}return r};function XB(e,t,n){let r=KB(e,!0,n);return r?YB(r.minor,t.rowStart,t.rowEnd)*YB(r.major,t.colStart,t.colEnd):(t.colEnd-t.colStart+1)*(t.rowEnd-t.rowStart+1)}var ZB=(e,t)=>{let n=e.bySkip.get(t.skip);n||(n=new Map,e.bySkip.set(t.skip,n));let r=n.get(t.origin);return r||(r=new WeakMap,n.set(t.origin,r)),r},QB=new WeakMap,$B=(e,t)=>{let n=QB.get(e);return n||(n=t??{coerce:void 0,byRun:new WeakMap,bySkip:new WeakMap},QB.set(e,n)),n},eV=8192,tV=Object.freeze({count:0,numericalCount:0,sum:null,min:null,max:null,average:null,var:null,varP:null,stdDev:null,stdDevP:null});function nV(e,t,n,r,i,a,o,s){if(t.getCount()===0)return null;let c=null,l=t.getAxis()===B.Axis.Column,u=r.length,d=KB(i,l,s),f=d?.major??null,p=d?.minor??null,m=i?{...aV,...i}:aV,h=m.bounds,g=i?.coerce;a.coerce!==g&&(a.byRun=new WeakMap,a.bySkip=new WeakMap,a.coerce=g);let _=p?ZB(a,p):a.byRun,v=rV(e,i),y=v.coerce,b=v.defaultCoerce,x=i?.onError??`ignore`,S=!1,C=null;if(x!==`ignore`){if(x===`throw`)S=!0;else{if(x===`value`)throw Error(`onError "value" is not supported in RangeStats`);typeof x==`function`&&(C=x)}}for(let e=0;e<u;e++){let i=r[e];if(!i)continue;let a=l?i.colStart:i.rowStart,s=l?i.rowStart:i.colStart,u=l?i.colEnd:i.rowEnd,d=l?i.rowEnd:i.colEnd;h.colStart=l?a:s,h.rowStart=l?s:a,h.colEnd=l?u:d,h.rowEnd=l?d:u;let g=t.getRuns(m),v,x,w=0,T=0,E=0,D=0,O=0,k=0,A=0,j=0,M=0,N=0,ee=!1,te=g.next();for(te.done||c||(c=sV());!te.done;){let[e,t,r]=te.value;if(te=g.next(),!(f&&qB(f,e)||(w=r.length,T=Math.max(0,s-t),E=Math.min(w-1,d-t),T>E))){x=_.get(r),x!==void 0&&x.settles!==void 0&&x.settles!==lg()&&(x=void 0),x||(D=Math.ceil(w/o),x=Array(D),_.set(r,x)),O=Math.floor(T/o),k=Math.floor(E/o);for(let e=O;e<=k;e++){if(A=e*o,j=Math.min((e+1)*o-1,w-1),M=Math.max(T,A),N=Math.min(E,j),M>N)continue;ee=M===A&&N===j;let i=x[e];if(ee){if(i){if((S||C)&&(i.typed[U.Error]>0||y!==null&&i.count!==i.typed[U.Number]))for(let e=A;e<=j;e++){if(p){let n=JB(p,t+e)-t;if(n!==e){n>e&&(e=n-1);continue}}v=r.at(e);let i=pB(v,!0);if(i===null&&(v=pg(v),i=pB(v,!0)),i!==U.Number&&(y&&(v=y(v,i,b,n)),V.isError(v))){if(S)throw v;C(v)}}}else{let a=sV(),o=!1;xo.forEachLeaf(r,(e,r,i,s)=>{let c=r+s-i;if(y===null&&p===null){let t=e.getViews?.();if(t)return void vV(a,e,t,r,c,S,C)}let l;for(let s=r;s<=c;s++){if(p){let e=JB(p,t+i+(s-r))-t-i+r;if(e!==s){e>s&&(s=e-1);continue}}a.count++,l=e.at(s);let c=pB(l,!0);if(c===null){let e=pg(l);e!==l&&(o=!0),l=e,c=pB(l,!0)}if(Yy(l)&&(l=V.BuiltIn.Value,c=U.Error),a.typed[cV(c)]++,c!==U.Number){let e=!0;if(y&&(l=y(l,c,b,n),c=pB(l,!0),e=c!==U.Number),V.isError(l)){if(S)throw l;C&&C(l)}if(e)continue}lV(a,l)}},A,j),i=a,x[e]=i,o&&(x.settles=lg())}yV(c,i)}else for(let e=M;e<=N;e++){if(p){let n=JB(p,t+e)-t;if(n!==e){n>e&&(e=n-1);continue}}c.count++,v=r.at(e);let i=pB(v,!0);if(i===null&&(v=pg(v),i=pB(v,!0)),c.typed[cV(i)]++,i!==U.Number){let e=!0;if(y&&(v=y(v,i,null,n),i=pB(v,!0),e=i!==U.Number),V.isError(v)){if(S)throw v;C&&C(v)}if(e)continue}lV(c,v)}}}}}return c}function rV(e,t){let n=t?.coerce;if(n){if(typeof n==`function`)return{coerce:n,defaultCoerce:DB(e,U.Number,GB)};if(Array.isArray(n))return{coerce:DB(e,U.Number,n),defaultCoerce:null}}return{coerce:null,defaultCoerce:null}}function iV(e){if(!e||e.count===0)return tV;let t=e.numericalCount;if(!t||e.min===void 0)return Object.freeze({...tV,count:e.count});let n=e.sum/t,r=Math.max(0,e.sumSq/t-n*n),i=t>1?r*(t/(t-1)):null,a={count:e.count,numericalCount:t,sum:e.sum,min:e.min,max:e.max,average:n,varP:r,stdDevP:Math.sqrt(r),var:i,stdDev:i===null?null:Math.sqrt(i)};return a.populationVariance=r,Object.freeze(a)}var aV={bounds:{colStart:0,rowStart:0,colEnd:0,rowEnd:0},overflowRun:!0,reuseResult:!0},oV={bounds:{colStart:0,rowStart:0,colEnd:0,rowEnd:0},overflowRun:!0,reuseResult:!0},sV=()=>({count:0,min:void 0,max:void 0,numericalCount:0,sum:0,sumSq:0,typed:{[U.Number]:0,[U.String]:0,[U.Boolean]:0,[U.Error]:0,[U.RichData]:0,[U.Null]:0}}),cV=e=>{switch(e){case U.Number:case U.String:case U.Boolean:case U.Error:case U.RichData:case U.Null:return e;case H.Date:return U.Number;default:return U.Null}},lV=(e,t)=>{e.sum+=t,e.numericalCount++,e.sumSq+=t*t,e.min===void 0?(e.min=t,e.max=t):(t<e.min&&(e.min=t),t>e.max&&(e.max=t))},uV=cl.Type.Blank,dV=cl.Type.False,fV=cl.Type.True,pV=cl.Type.Int32,mV=cl.Type.Float64,hV=cl.Type.String,gV=cl.Type.Rich,_V=cl.Type.Error,vV=(e,t,n,r,i,a,o)=>{let s=n.types,c=e.typed;if(s===null&&(n.defaultType===pV||n.defaultType===mV)){let t=n.ints,a=n.doubles,o=n.intShift,s=n.intOffset,l=n.defaultType===pV,u=e.sum,d=e.sumSq,f=e.min,p=e.max,m=0,h=0;for(let e=r;e<=i;e++){let n=l?t[(e<<o)+s]:a[e];n-n===0?(u+=n,d+=n*n,m++,f===void 0?(f=n,p=n):(n<f&&(f=n),n>p&&(p=n))):h++}e.count+=i-r+1,e.sum=u,e.sumSq=d,e.min=f,e.max=p,e.numericalCount+=m,c[U.Number]+=m,c[U.Error]+=h;return}let l=n.defaultType,u=n.ints,d=n.doubles,f=n.intShift,p=n.intOffset;for(let n=r;n<=i;n++)switch(e.count++,s===null?l:s[n]){case pV:c[U.Number]++,lV(e,u[(n<<f)+p]);break;case mV:{let t=d[n];t-t===0?(c[U.Number]++,lV(e,t)):c[U.Error]++;break}case uV:c[U.Null]++;break;case dV:case fV:c[U.Boolean]++;break;case hV:c[U.String]++;break;case gV:c[U.RichData]++;break;case _V:if(c[U.Error]++,a)throw t.at(n);o&&o(t.at(n))}},yV=(e,t)=>{e.sum+=t.sum,e.numericalCount+=t.numericalCount,e.count+=t.count,e.sumSq+=t.sumSq;let n=e.typed,r=t.typed;n[U.Number]+=r[U.Number],n[U.String]+=r[U.String],n[U.Boolean]+=r[U.Boolean],n[U.Error]+=r[U.Error],n[U.RichData]+=r[U.RichData],n[U.Null]+=r[U.Null],t.min!==void 0&&(e.min===void 0?(e.min=t.min,e.max=t.max):(t.min<e.min&&(e.min=t.min),t.max>e.max&&(e.max=t.max)))},bV=class{constructor(e,t,n){this._kept=[],this._limit=e,this._distinct=t,this._rank=n}offer(e){let t=this._kept,n=this._rank;if(this._distinct){let r=t.length;for(let i=0;i<r;i++)if(n(t[i],e)===0)return}let r=t.length;r<this._limit?t.splice(xV(t,e,n),0,e):n(e,t[r-1])<0&&(t.pop(),t.splice(xV(t,e,n),0,e))}values(){return this._kept}};function xV(e,t,n){let r=0,i=e.length;for(;r<i;){let a=r+i>>>1;n(e[a],t)<=0?r=a+1:i=a}return r}function SV(e,t){let n=e?.compareFn??t;return e?.reverse?n:(e,t)=>n(t,e)}function CV(e,t,n,r,i,a){let o=r?.limit??10;if(!(o>0)||e.getCount()===0)return TV;let s=r?.includeBlanks??!1,c=r?.filterFn,l=SV(r,i),u=new bV(o,r?.distinct??!1,l),d=e.getAxis()===B.Axis.Column,f=t.length,p=KB(n,d,a),m=p?.major??null,h=p?.minor??null,g=n?{...EV,...n}:EV,_=g.bounds,v=0,y=0;for(let r=0;r<f;r++){let i=t[r];if(!i)continue;s&&(v+=XB(n,i,a));let o=d?i.colStart:i.rowStart,l=d?i.rowStart:i.colStart,f=d?i.colEnd:i.rowEnd,p=d?i.rowEnd:i.colEnd;_.colStart=d?o:l,_.rowStart=d?l:o,_.colEnd=d?f:p,_.rowEnd=d?p:f;let b=e.getRuns(g),x=b.next();for(;!x.done;){let[e,t,n]=x.value;if(x=b.next(),m&&qB(m,e))continue;let r=n.length,i=Math.max(0,l-t),a=Math.min(r-1,p-t);if(!(i>a))for(let e=i;e<=a;e++){if(h){let n=JB(h,t+e)-t;if(n!==e){n>e&&(e=n-1);continue}}y++;let r=pg(n.at(e));c&&!c(r)||u.offer(r)}}}if(s){let e=v-y,t=Math.min(e,o);for(let e=0;e<t;e++)u.offer(null)}return u.values()}function wV(e,t,n){let r=t?.limit??10;if(!(r>0))return TV;let i=SV(t,n),a=new bV(r,t?.distinct??!1,i),o=e.length;for(let n=0;n<o;n++){let r=e[n].getRanked(t),i=r.next();for(;!i.done;)a.offer(i.value),i=r.next()}return a.values()}var TV=Object.freeze([]),EV={bounds:{colStart:0,rowStart:0,colEnd:0,rowEnd:0},overflowRun:!0,reuseResult:!0},DV=class e{constructor(e){this._sorted=e}static fromGrid(t,n,r,i){return new e(e._collectNumbers(t,n,r,i))}getLarge(e){return this._inRank(e)?this._sorted[Math.trunc(this._sorted.length-e)]:null}getSmall(e){return this._inRank(e)?this._sorted[Math.trunc(e-1)]:null}_inRank(e){return e>=1&&e<=this._sorted.length}getPercentile(e,t=!1){let n=this._sorted,r=n.length;if(r===0)return null;if(t){if(e<=0||e>=1)return null;let t=e*(r+1)-1;return t<0||t>r-1?null:OV(n,t)}return e<0||e>1?null:OV(n,e*(r-1))}getRankOf(e,t=!0,n=!1){let r=this._sorted,i=r.length;if(i===0)return null;let a=kV(r,e);if(a>=i||r[a]!==e)return null;let o=AV(r,e)-1;return n?((t?i-o:a+1)+(t?i-a:o+1))/2:t?i-o:a+1}getPercentRankOf(e,t=!1,n){let r=this._sorted,i=r.length;if(i===0)return null;let a=kV(r,e),o;if(a<i&&r[a]===e){if(i===1)return 1;o=t?(a+1)/(i+1):a/(i-1)}else{if(a===0||a>=i)return null;let n=r[a-1],s=(e-n)/(r[a]-n);o=t?(a+s)/(i+1):(a-1+s)/(i-1)}if(n===void 0)return o;if(!(n>=1))return V.BuiltIn.Num;let s=10**Math.trunc(n);return Number.isFinite(s)?Math.floor(o*s)/s:V.BuiltIn.Div0}getValues(){return this._sorted}findFloor(e){let t=this._sorted;if(t.length===0)return null;let n=AV(t,e)-1;return n<0?null:t[n]}findCeiling(e){let t=this._sorted;if(t.length===0)return null;let n=kV(t,e);return n>=t.length?null:t[n]}static _collectNumbers(e,t,n,r){if(e.getCount()===0)return jV;let i=[],a=e.getAxis()===B.Axis.Column,o=t.length,s=KB(n,a,r),c=s?.major??null,l=s?.minor??null,u=n?{...MV,...n}:MV,d=u.bounds;for(let n=0;n<o;n++){let r=t[n];if(!r)continue;let o=a?r.colStart:r.rowStart,s=a?r.rowStart:r.colStart,f=a?r.colEnd:r.rowEnd,p=a?r.rowEnd:r.colEnd;d.colStart=a?o:s,d.rowStart=a?s:o,d.colEnd=a?f:p,d.rowEnd=a?p:f;let m=e.getRuns(u),h=m.next();for(;!h.done;){let[e,t,n]=h.value;if(h=m.next(),c&&qB(c,e))continue;let r=n.length,a=Math.max(0,s-t),o=Math.min(r-1,p-t);if(!(a>o))for(let e=a;e<=o;e++){if(l){let n=JB(l,t+e)-t;if(n!==e){n>e&&(e=n-1);continue}}let r=n.at(e);if(typeof r==`number`)i.push(r);else if(typeof r==`object`&&r){let e=pg(r);typeof e==`number`&&i.push(e)}}}}return i.sort((e,t)=>e-t),Object.freeze(i)}};function OV(e,t){let n=Math.floor(t),r=t-n;return r===0?e[n]:e[n]+r*(e[n+1]-e[n])}function kV(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>>1;e[i]<t?n=i+1:r=i}return n}function AV(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>>1;e[i]<=t?n=i+1:r=i}return n}var jV=Object.freeze([]),MV={bounds:{colStart:0,rowStart:0,colEnd:0,rowEnd:0},overflowRun:!0,reuseResult:!0},NV=new WeakMap;function PV(e){switch(typeof e){case`number`:case`boolean`:return e;case`string`:return Yl(e);default:{let t=pg(e);return t===e?void 0:PV(t)}}}var FV=(e,t,n,r,i)=>{if(e.length<16){if(i){for(let i=r;i>=n;i--)if(PV(e.at(i))===t)return i}else for(let i=n;i<=r;i++)if(PV(e.at(i))===t)return i;return-1}let a=(e=>{let t=NV.get(e);if(t!==void 0&&(t.settles===void 0||t.settles===lg()))return t.positions;let n=new Map,r=!1,i=e.length;for(let t=0;t<i;t++){let i=e.at(t);!r&&fg(i)&&(r=!0);let a=PV(i);if(a===void 0)continue;let o=n.get(a);o===void 0?n.set(a,t):typeof o==`number`?n.set(a,[o,t]):o.push(t)}return NV.set(e,r?{positions:n,settles:lg()}:{positions:n}),n})(e).get(t);if(a===void 0)return-1;if(typeof a==`number`)return a>=n&&a<=r?a:-1;let o=0,s=a.length-1;if(i){for(;o<s;){let e=o+s+1>>1;a[e]<=r?o=e:s=e-1}return a[o]<=r&&a[o]>=n?a[o]:-1}for(;o<s;){let e=o+s>>1;a[e]>=n?s=e:o=e+1}return a[o]>=n&&a[o]<=r?a[o]:-1},IV={bounds:void 0,overflowRun:!0,reuseResult:!0},LV=class e{constructor(e,t,n,r=null,i=!1,a=!1,o=null){this._isLiteral=!1,this._isDirectScalar=!1,this._localRangeStats=null,this._localRangeStatsOptions=void 0,this._absentValue=null,this._runtime=e,r&&(r={...GV,...r}).axis===`fastest`&&(r.axis=t.getAxis()),this._values=t,this._coords=n,this._optionsIterator=r??GV,this._isLiteral=i,this._isDirectScalar=a,this._absentValue=o??null}argsort(e=this,t=1,n=B.Axis.Row){let r=n===B.Axis.Column,i=Array.isArray(e)?e:[e],a=Array.isArray(t)?t:[t];return function(e,t,n,r){let i=Array.from({length:e},(e,t)=>t),a=t.length;if(a===1){let e=t[0],a=n[0]??1;return i.sort((t,n)=>aH(e[t],e[n],a,r)),i}return i.sort((e,i)=>{for(let o=0;o<a;o++){let a=n[o]??1,s=t[o],c=aH(s[e],s[i],a,r);if(c!==0)return c}return 0}),i}(r?this.getColumnCount():this.getRowCount(),i.map(e=>function(e,t,n){let r=n?e.getColumnCount():e.getRowCount(),i=Array(r).fill(null),a=e.entries(),o=a.next();for(;!o.done;){let{value:e,coords:r}=o.value;(n?r.rowIndex:r.colIndex)===t&&(i[n?r.colIndex:r.rowIndex]=e),o=a.next()}return i}(e,0,r)),a,this._runtime.getLocaleProfile())}uniqueIndices(e=B.Axis.Row,t=!1){let n=e===B.Axis.Column,r=n?this.getColumnCount():this.getRowCount(),i=Array(r).fill(``),a=new Map,o=this.entries({axis:e,includeEmpty:!1}),s=o.next();for(;!s.done;){let{value:e,coords:t}=s.value,r=n?t.colIndex:t.rowIndex,c=n?t.rowIndex:t.colIndex;i[r]+=sH(c,e,a),s=o.next()}return function(e,t){let n=new Map;for(let t of e)n.set(t,(n.get(t)??0)+1);let r=new Set,i=[];for(let a=0;a<e.length;a++){let o=e[a];r.has(o)||(r.add(o),t&&n.get(o)!==1||i.push(a))}return i}(i,t)}broadcast(e,t,n){if(e===void 0)return this._self();n=n?{...this._optionsIterator,...n}:this._optionsIterator;let r=n?.type,i=n?.otherType??r,a=r?this._coerceValue(null,r,n,U.Null):null,o=i?this._coerceValue(null,i,n,U.Null):null,s=this._values,c=s.getAxis()===B.Axis.Column,l=this._coords??h.EmptyRange,u=e?.isIRange?e:null,d=u?u._coords??h.EmptyRange:h.EmptyRange,f=l.colEnd-l.colStart+1,p=l.rowEnd-l.rowStart+1,m=d.colEnd-d.colStart+1,g=d.rowEnd-d.rowStart+1,_=Math.min(f,m),v=Math.min(p,g),y=Math.max(f,m),b=Math.max(p,g),x=n?.misalignValue??null,S=x!==null&&(y>_||b>v);if(f!==m){if(f===1)_=m;else if(m===1)_=f;else if(x===null)throw Error(`Incompatible shapes for broadcast: cols ${f} and ${m} must be equal or one must be 1`)}if(p!==g){if(p===1)v=g;else if(g===1)v=p;else if(x===null)throw Error(`Incompatible shapes for broadcast: rows ${p} and ${g} must be equal or one must be 1`)}let C=l.colStart,w=l.rowStart,T=c?_:v,E=c?v:_,D=t.length===2,O=(e,t,n,r,i)=>{let a=n.colEnd-n.colStart+1,o=n.rowEnd-n.rowStart+1;if(!t._coords||a===1&&o===1)return null;let s={colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colStart+Math.min(a,_)-1,rowEnd:n.rowStart+Math.min(o,v)-1},l=a===1?_:Math.min(a,_),u=o===1?v:Math.min(o,v);return new XV(e,t._values,s,c,c?l:u,c?u:l,r,r(void 0)??i,i,i,t._skipsOnGrid(t._optionsIterator))},k=this._memberReader(n,!1),A=O(0,this,l,k,a),j=a;A===null&&(j=(this._coords?k(s.getValueAt(l.rowStart,l.colStart)):k(void 0))??a);let M=null,N=o;if(u!==null){let e=u._memberReader({...n,type:i??null},!1);M=O(1,u,d,e,o),M===null&&(N=(u._coords?e(u._values.getValueAt(d.rowStart,d.colStart)):e(void 0))??o)}else N=(i?this._coerceValue(e,i,n):e)??o;let ee=[];A&&ee.push(A),M&&ee.push(M);let te=c?C:w,P=c?w:C,F=new Lo.Builder(void 0,0,0,!0),ne=(e,t)=>({colIndex:c?e:t,rowIndex:c?t:e}),re=D?`region`:A===null||M===null||this._absentValue!==null||u._absentValue!==null?`each`:`skip`,ie,ae,oe,se=(e,t)=>{ae=A===null?j:A.covers?A.valueAt(t):A.empty,oe=M===null?N:M.covers?M.valueAt(t):M.empty};ZV(ee,T,E,(e,n,r)=>{if(re!==`skip`){if(ae=A===null?j:A.empty,oe=M===null?N:M.empty,re!==`each`)F.pushAbsentAt(te+e,P+n,r-n),ie===void 0&&(ie=t(ae,oe,h.EmptyCell,this)??null,F.setAbsentValue(ie));else for(let i=n;i<r;i++)F.pushAt(te+e,P+i,t(ae,oe,ne(e,i),this))}},(e,n,r,i)=>{if(i&&D){se(0,n);let i=t(ae,oe,h.EmptyCell,this);F.pushMultipleAt(te+e,P+n,new Ro([i],r-n+1))}else for(let i=n;i<=r;i++)se(0,i),F.pushAt(te+e,P+i,t(ae,oe,ne(e,i),this))});let ce=F.build(),le=ce.absentValue??null,ue;if(S){let e=s.clone();if(this._applyRegion(e,ce,!1),y>_){let t=Vc(x,jc(C+_,w,C+y-1,w+b-1,c),c);e.setValues(t.tuples)}if(b>v){let t=Vc(x,jc(C,w+v,C+y-1,w+b-1,c),c);e.setValues(t.tuples)}ue=this._newRange(e,{colStart:C,rowStart:w,colEnd:C+y-1,rowEnd:w+b-1},this._optionsIterator,!1,!1,le)}else{let e=s.cloneEmpty();this._applyRegion(e,ce,!0),ue=this._newRange(e,{colStart:C,rowStart:w,colEnd:C+_-1,rowEnd:w+v-1},this._optionsIterator,!1,!1,le)}return ue._untyped()}choose(e,t,n){let r=n?.misalignValue??V.BuiltIn.NA;if(this.isEmpty())return this.replace([[r]]);let i=e.map(e=>e.isIRange?e:this.fill(e)),a=i.length,o=this.getColumnCount(),s=this.getRowCount();if(o===1&&s===1){let e=t(this.getValueAt(0,0),h.EmptyCell,this);return V.isError(e)?this.replace([[e]]):typeof e!=`number`||e<0||e>=a?this.replace([[r]]):i[e]}let c=o,l=s,u=c===1||l===1;for(let e=0;e<a;e++){let t=i[e],n=t.getColumnCount(),r=t.getRowCount();u=u||n===1||r===1,c=Math.max(c,n),l=Math.max(l,r)}let d=this;return u&&c>1&&l>1&&(o===1||s===1)&&(d=d.tile(s===1?l:1,o===1?c:1)),d=d.map((e,n)=>{let o=n.colIndex,s=n.rowIndex,c=t(e,n,this);if(V.isError(c))return c;if(typeof c!=`number`||c<0||c>=a)return r;let l=i[c];u&&(l.getColumnCount()===1&&(o=0),l.getRowCount()===1&&(s=0));let d=l.getValueAt(s,o);return d===void 0?r:d}),d=d.resize(l,c,r),d}clear(){let e=this._coords,t=this._values;return!e||t.getCount()===0&&this._absentValue===null?this._self():(t=t.cloneEmpty(),this._newRange(t,this._coords,this._optionsIterator))}clone(e,t=!1,n=!1){return this._newRange(this._values,this._coords,e?{...this._optionsIterator,...e}:this._optionsIterator,t,n,this._absentValue)}compute(e){return e(this)}concat(e,t=B.Axis.Row,n=V.BuiltIn.NA){let r=t===B.Axis.Column,i=this.getColumnCount(),a=this.getRowCount(),o=e.getColumnCount(),s=e.getRowCount(),c=r?i+o:Math.max(i,o),l=r?Math.max(a,s):a+s;if(n!==null){let u=r?a<l?this.resize(l,i,n):this:i<c?this.resize(a,c,n):this,d=r?s<l?e.resize(l,o,n):e:o<c?e.resize(s,c,n):e;return u.concat(d,t,null)}let u=this.resize(l,c,null).sparseBuilder(B.Axis.Column),d=r?0:a,f=r?i:0,p=e.entries({axis:B.Axis.Column,includeEmpty:!1}),m=p.next();for(;!m.done;){let{value:e,coords:t}=m.value;u.pushAt(t.rowIndex+d,t.colIndex+f,e),m=p.next()}return u.build()}empty(){let e=this._coords,t=this._values;return!e||t.getCount()===0&&this._absentValue===null?this._self():(t=t.cloneEmpty(),this._newRange(t,null,this._optionsIterator))}entries(e){let t=this._coords;if(!t)return bo;let n=e?.bounds;if(e={...this._optionsIterator,...e,bounds:t},n){let r=(n.colStart??0)-t.colStart,i=(n.rowStart??0)-t.rowStart,a=Math.max(r+t.colStart,t.colStart),o=Math.max(i+t.rowStart,t.rowStart),s=Math.min((n.colEnd??2**53-1)-r,t.colEnd-t.colStart)+1,c=Math.min((n.rowEnd??2**53-1)-i,t.rowEnd-t.rowStart)+1;e.bounds={colStart:a,rowStart:o,colEnd:a+s-1,rowEnd:o+c-1}}let r=this._entries(e),i={[Symbol.iterator]:()=>i,next(){for(;;){let e=r.next();if(e.done)return yo;let n=e.value,i=n[0];return{done:!1,value:{coords:{colIndex:i.colIndex-t.colStart,rowIndex:i.rowIndex-t.rowStart},value:n[1]??null}}}}};return i}errors(e){let t=this.entries({axis:e?.axis??B.Axis.Row,bounds:e?.bounds,reverse:e?.reverse,type:null}),n={[Symbol.iterator]:()=>n,next(){let e=t.next();for(;!e.done;){let n=e.value.value;if(V.isError(n))return e;if(Yy(n))return{done:!1,value:{coords:e.value.coords,value:V.BuiltIn.Value}};e=t.next()}return yo}};return n}every(e,t){if(!e)return!0;let n=this.entries(t),r=n.next();for(;!r.done;){let t=r.value;if(!e(t.value,t.coords,this))return!1;r=n.next()}return!0}fill(e,t){let n=this._coords;if(!n)return this._self();if(t){if(this._absentValue!==null)return this._materializeEmpty().fill(e,t);if(n=this._absoluteCoords(t),!n)return this._self()}let r=this._values.clone();return QV(r,n,e),this._newRange(r,n,this._optionsIterator)}fillEmpty(e,t){let n=this._coords;return n?this._absentValue!==null||e===null?this:t?(n=this._absoluteCoords(t),n?this._fillAbsent(e,n):this._self()):n.rowStart===n.rowEnd&&n.colStart===n.colEnd&&this._values.getValueAt(n.rowStart,n.colStart)!=null?this:this._newRange(this._values,n,this._optionsIterator,this._isLiteral,!1,e):this._self()}_fillAbsent(e,t){let n=this._values,r=n.getAxis(),i=r,a=i===B.Axis.Column,o=a?t.colStart:t.rowStart,s=a?t.rowStart:t.colStart,c=a?t.colEnd:t.rowEnd,l=a?t.rowEnd:t.colEnd,u=n.getRuns({bounds:t,overflowRun:!0}),d=u.next(),f=o,p=s,m=i===r?new Lo.Builder:new Lo.TransposedBuilder;for(;!d.done;){let t=d.value,n=t[0];for(;f<n;){let t=new Ro([e],l+1-p);m.pushMultipleAt(f,p,t),f++,p=s}let r=t[1],i=Math.max(r,s),a=t[2],o=Math.min(r+a.length-1,l);if(p<i){let t=new Ro([e],r-p);m.pushMultipleAt(f,p,t)}p=o+1,o>=l?(f=n+1,p=s):f=n,d=u.next()}for(;f<=c;){let t=new Ro([e],l+1-p);m.pushMultipleAt(f,p,t),f++,p=s}return this._cloneFromBuilder(m,null,!1,null)}_materializeEmpty(){let e=this._absentValue,t=this._coords;return e!==null&&t?this._fillAbsent(e,t):this}_visitColumnRuns(e){let t=this._coords,n=this._optionsIterator;if(!t||t.colStart!==t.colEnd||n.processRowSkip||n.processColumnSkip)return!1;let r=this._materializeEmpty()._values;if(r.getAxis()!==B.Axis.Column)return!1;let i=t.rowStart,a=t.rowEnd,o=r.getRuns({bounds:t,overflowRun:!0});for(let t=o.next();!t.done;t=o.next()){let[,n,r]=t.value,o=Math.max(0,i-n),s=Math.min(r.length-1,a-n);o>s||xo.forEachLeaf(r,(t,r,a,o)=>{e(n+a-i,t,r,r+o-a)},o,s)}return!0}filter(e,t){let n=this._coords,r=this._values;if(!n||r.getCount()===0&&this._absentValue===null)return this._self();let i=t?.axis===`fastest`?r.getAxis():t?.axis??this._optionsIterator.axis,a=this.empty()._createBuilder(i),o=i===B.Axis.Column,s=-1,c=-1,l=!1,u=0,d=this.entries(t),f=d.next();for(;!f.done;){let t=f.value,n=t.coords,r=o?n.colIndex:n.rowIndex,i=o?n.rowIndex:n.colIndex,p=t.value;u++;let m=e(p,n,this);m?(r!==s&&(s=r,c++),V.isError(m)&&(p=m),a.pushAt(c,i,p)):l=!0,f=d.next()}return l||u!==this.size?this.empty()._cloneFromBuilder(a):this._self()}firstError(){let e=this.errors().next();return e.done?null:e.value.value}flatten(e){if(e&&(e.processRowSkip||e.processColumnSkip)){let{processRowSkip:t,processColumnSkip:n,...r}=e;return this.clone({processRowSkip:t,processColumnSkip:n}).flatten(r)}let t=(e?.axis===B.Axis.Column?this.transpose():this).reshape(this.getRowCount()*this.getColumnCount(),1);return e&&(e.type!==void 0||e.coerce||e.onError||e.errorOnInvalidCoercion)?t.toType(e):t}getValuesFlat(e){let t=[],n=this.values(e),r=n.next();for(;!r.done;)t.push(r.value),r=n.next();return t}indexOf(e,t){let n=this._coords;if(!n)return-1;let r=!0===t?.reverse,i=this._values,a=i.getAxis()===B.Axis.Column;return(a?n.colStart!==n.colEnd:n.rowStart!==n.rowEnd)||this._absentValue!==null||this._optionsIterator.type||this._hasSkips()||!0===i.observesReads||PV(e)===void 0?this._indexOfScan(e,r):function(e,t,n,r,i){let a=PV(r);if(a===void 0)return-1;let o=n?t.rowStart:t.colStart,s=n?t.rowEnd:t.colEnd;IV.bounds=t;let c=e.getRuns(IV);if(!i){let e=c.next();for(;!e.done;){let t=e.value[1],n=e.value[2],r=Math.max(o-t,0),i=Math.min(s-t,n.length-1);if(r<=i){let e=FV(n,a,r,i,!1);if(e!==-1)return t+e-o}e=c.next()}return-1}let l=[],u=[],d=c.next();for(;!d.done;)l.push(d.value[1]),u.push(d.value[2]),d=c.next();for(let e=u.length-1;e>=0;e--){let t=l[e],n=u[e],r=Math.max(o-t,0),i=Math.min(s-t,n.length-1);if(r>i)continue;let c=FV(n,a,r,i,!0);if(c!==-1)return t+c-o}return-1}(i,n,a,e,r)}_indexOfScan(e,t){let n=this._coords,r=n.colEnd-n.colStart+1,i=this._runtime.getLocaleProfile(),a=this.entries({axis:B.Axis.Row,includeEmpty:!1,reverse:t}),o=a.next();for(;!o.done;){let t=o.value,n=t.value;if(n!=null&&oH(n,e,i))return t.coords.rowIndex*r+t.coords.colIndex;o=a.next()}return-1}forEach(e,t){if(!e)return;let n=this.entries(t),r=n.next();for(;!r.done;){let t=r.value,i=e(t.value,t.coords,this);if(i)return i.break;r=n.next()}}getColumnCount(){let e=this._coords;return e?e.colEnd-e.colStart+1:0}getRowCount(){let e=this._coords;return e?e.rowEnd-e.rowStart+1:0}getShape(){let e=this._coords;return{rows:e.rowEnd-e.rowStart+1,columns:e.colEnd-e.colStart+1}}getStats(e){let t=this._optionsIterator;if(t!==void 0&&t.type!==void 0&&e?.onError===void 0&&(t.onError===void 0||t.onError===`throw`)&&this.hasError())throw this.firstError();return this._getStats(e)}_getStats(e){let t=this._localRangeStats;if(!t||e!==this._localRangeStatsOptions){let n=this._coords,r=this._optionsIterator,i=e;(r.processRowSkip||r.processColumnSkip)&&(i={processRowSkip:r.processRowSkip,processColumnSkip:r.processColumnSkip,...e});let a=n&&i&&(i.processRowSkip||i.processColumnSkip)?{rowIndex:n.rowStart,colIndex:n.colStart}:void 0;t=new EM(this._runtime,this._materializeEmpty()._values,this,[n],i,void 0,void 0,a),this._localRangeStats=t,this._localRangeStatsOptions=e}return t}hasError(){if(this.size===1){let e=this._coords,t=zV(this._optionsIterator,0,0)?void 0:this._values.getValueAt(e.rowStart,e.colStart),n=t===void 0?this._absentValue:t;return sg()&&(n=pg(n)),V.isError(n)||Yy(n)}return this.size<=tH?!this.errors({axis:`fastest`}).next().done:(this._getStats().getTypedCounts(nH)[U.Error]??0)>0}getType(){return this._optionsIterator?.type??void 0}getValueAt(e,t,n){let r=this._coords;if(!r||e<0||t<0||e>=r.rowEnd-r.rowStart+1||t>=this.getColumnCount())return;let i=this._values;n=n?{...this._optionsIterator,...n}:this._optionsIterator;let a=zV(n,e,t)?void 0:i.getValueAt(e+r.rowStart,t+r.colStart),o=a===void 0?this._absentValue:a;sg()&&(o=pg(o));let s=n?.type;return s&&(o=this._coerceValue(o,s,n)),o}getValues(e){if(!this._coords)return[[]];let t={...e,includeEmpty:!0,reverse:!1,onError:`value`,bounds:{colStart:0,rowStart:0,colEnd:this.getColumnCount()-1,rowEnd:this.getRowCount()-1}},n=!1;t.axis=e?.axis??B.Axis.Row,e&&(e.maxRows&&(t.bounds.rowEnd=0+e.maxRows-1),e.maxCols&&(t.bounds.colEnd=0+e.maxCols-1),e.trailingEmpties&&(n=e.trailingEmpties),t.axis=e?.axis??B.Axis.Row);let r=[];if(!n){t.includeEmpty=!1,t.reverse=!0,t.axis=B.Axis.Row;let n=this.entries(t).next();if(n.done)return WV;t.axis=B.Axis.Column;let r=this.entries(t).next();t.bounds.rowEnd=n.value.coords.rowIndex,t.bounds.colEnd=r.value.coords.colIndex,t.includeEmpty=!0,t.reverse=!1,t.axis=e?.axis??B.Axis.Row}let i=this.entries(t),a=t.axis!==B.Axis.Row,o=e?.onValue,s,c=-1,l=[];for(s=i.next();!s.done;){let e=s.value,t=e.coords,n=a?t.colIndex:t.rowIndex;n!==c&&(l=[],r.push(l),c=n);let u=e.value;if(o){let e=o(u,t.rowIndex,t.colIndex,this);e!==void 0&&(u=e)}l.push(u),s=i.next()}return r}map(e,t){let n=this._coords,r=this._values;if(!n)return this._self()._untyped();if(t&&(t.processRowSkip||t.processColumnSkip)){let{processRowSkip:n,processColumnSkip:r,...i}=t;return this.clone({processRowSkip:n,processColumnSkip:r}).map(e,i)}let i=t?.blankRegions===`once`;if((i||e.length<=1)&&!t?.includeEmpty&&(i||this._absentValue===null)&&this.size>1)return this._mapRuns(e,t,i);let a=t?.axis===`fastest`?r.getAxis():t?.axis??this._optionsIterator.axis,o=this.entries(t),s,c=o.next();c.done||(s=this._createBuilder(a));let l=a===B.Axis.Column,u=l?n.colStart:n.rowStart,d=l?n.rowStart:n.colStart,f;for(;!c.done;){let t=c.value,n=t.coords,r=l?n.colIndex:n.rowIndex,i=l?n.rowIndex:n.colIndex,a=t.value;c=o.next();let p=e(a,n,this);p===void 0?p=a:p===null?(f||=qc(l),f.append(r+u,i+d)):s.pushAt(r,i,p)}let p=(t?.includeEmpty??!1)||this._absentValue!==null;return this._cloneFromBuilder(s,f,!1,p?null:this._absentValue)._untyped()}_mapRuns(e,t,n){let r=this._coords,i=this._values,a=i.getAxis()===B.Axis.Column,o=this._memberReader(t?{...this._optionsIterator,...t}:this._optionsIterator,!1),s=r.colEnd-r.colStart+1,c=r.rowEnd-r.rowStart+1,l=a?s:c,u=a?c:s,d=a?r.colStart:r.rowStart,f=a?r.rowStart:r.colStart,p=new XV(0,i,r,a,l,u,o,null,null,null,this._skipsOnGrid(t?{...this._optionsIterator,...t}:this._optionsIterator)),m=new Lo.Builder(void 0,0,0,!0),h,g=(e,t)=>({colIndex:a?e:t,rowIndex:a?t:e});ZV([p],l,u,(t,r,i)=>{if(!n)return;m.pushAbsentAt(d+t,f+r,i-r);let a=o(void 0);if(a!==void 0&&h===void 0){let t=e(a,YV,this);h=t===void 0?this._absentValue:t,m.setAbsentValue(h)}},(t,n,r,i)=>{let a=p.seg;if(i){let i=a.value;if(i===void 0)return;let o=e(i,YV,this);if(o===void 0)return;m.pushMultipleAt(d+t,f+n,new Ro([o],r-n+1));return}let s=a.list,c=a.base;for(let i=n;i<=r;i++){let n=o(s.at(i+c));if(n===void 0)continue;let r=e(n,g(t,i),this);r!==void 0&&m.pushAt(d+t,f+i,r)}}),h===void 0&&m.setAbsentValue(this._absentValue);let _=m.build(),v=_.absentValue??null;return _.tuples.length===0&&_.clears.length===0?(v===this._absentValue?this._self():this._newRange(i,r,this._optionsIterator,this._isLiteral,!1,v))._untyped():this._cloneFromRegion(_,null,!1,v)._untyped()}mask(e,t,n){let r=n?.misalignValue??V.BuiltIn.NA,i=n?.emptyValue??null,a=n?.isTrue,o=DB(this._runtime,U.Boolean),s=e?.isIRange?e:this._newRange(this._values,null),c=t?.isIRange?t:this._newRange(this._values,null);if(s.size===1){let e=s.getValueAt(0,0),t=pB(e),r=t===U.Boolean?e:o(e,t);return V.isError(r)?this.empty().replace([[r]]):(!0===r?c:this).fillEmpty(n?.emptyValue??null)}let l=s.getColumnCount(),u=s.getRowCount(),d=c.getColumnCount(),f=this.getColumnCount(),p=Math.max(d,f,l),m=c.getRowCount(),h=this.getRowCount(),g=Math.max(m,h,u);s=s.repeat(u===1?g:1,l===1?p:1);let _=s.getColumnCount(),v=s.getRowCount(),y=this;y=y.repeat(h===1?v:1,f===1?_:1),y=y.fillEmpty(i);let b=m===1,x=d===1,S=y.sparseBuilder(eH),C=Math.max(h===1?v:h,b?v:m),w=Math.max(f===1?_:f,x?_:d);s=s.resize(C,w,r),s.forEach((e,t)=>{let n;if(a)n=a(e,t);else if(!0===e)n=!0;else if(!1===e)n=!1;else{let t=pB(e);n=t===U.Boolean?e:o(e,t)}let s=t.rowIndex,l=t.colIndex,u=null;!1!==n&&(!0===n?u=!x&&l>=d||!b&&s>=m?r:c.getValueAt(b?0:s,x?0:l)??i:V.isError(n)&&(u=n),S.pushAt(s,l,u))},rH);let T=S.build();return T=T.resize(g,p,r),T}alignValues(e,t){let n=t?{...this._optionsIterator,...t}:this._optionsIterator,r=this._values.getAxis(),i=n.axis,a=i&&i!==`fastest`?i:r,o=a===B.Axis.Column,s=e=>{let t=e.iterator.next();if(t.done)return void(e.done=!0);let n=t.value;e.value=n[1]??null,e.rowRel=n[0].rowIndex-e.rowBase,e.colRel=n[0].colIndex-e.colBase},c=[],l=(e,t,n)=>{let r=t._coords??h.EmptyRange,i={slot:e,iterator:t._entries({...n,axis:a,bounds:r,reuseResult:!1}),done:!1,value:null,rowRel:0,colRel:0,rowBase:r.rowStart,colBase:r.colStart};s(i),c.push(i)};l(0,this,n);let u=[],d=e.length;for(let t=0;t<d;t++){let n=e[t];n===null?u.push(t+1):l(t+1,n,n._optionsIterator)}let f=d+1,p=c.length,m=u.length,g=o?this.getRowCount():this.getColumnCount();return{[Symbol.iterator](){return this},next:()=>{let e=0,t=0,n=!1;for(let r=0;r<p;r++){let i=c[r];i.done||(n?(o?i.colRel-t||i.rowRel-e:i.rowRel-e||i.colRel-t)<0&&(e=i.rowRel,t=i.colRel):(e=i.rowRel,t=i.colRel,n=!0))}if(!n)return yo;let r=Array(f).fill(null);for(let n=0;n<p;n++){let i=c[n];i.done||i.rowRel!==e||i.colRel!==t||(r[i.slot]=i.value,s(i))}if(m>0){let n=o?t*g+e+1:e*g+t+1;for(let e=0;e<m;e++)r[u[e]]=n}return{done:!1,value:[r,{rowIndex:e,colIndex:t}]}}}}alignReduce(e,t,n,r){if(!t)return n;let i=Array.isArray(e)?e:[e],a=this.alignValues(i,r),o=n,s=a.next(),c=r?.emptyFold;if(!c){for(;!s.done;){let[e,n]=s.value;o=t(o,e,n,this),s=a.next()}return o}let l=this.getRowCount(),u=this.getColumnCount(),d=0;for(;!s.done;){let[e,n]=s.value;n.rowIndex<l&&n.colIndex<u&&d++,o=t(o,e,n,this),s=a.next()}let f=l*u-d;return f>0?c(o,f):o}reduce(e,t,n){if(!e)return t;let r=this.entries(n),i=r.next(),a=t;for(;!i.done;){let t=i.value;a=e(a,t.value,t.coords,this),i=r.next()}return a}repeat(e,t){if(e===1&&t===1)return this._self();if(e<=0||t<=0)throw Error(`Invalid tile dimensions: ${e} x ${t}`);let n=this._coords;if(!n)return this._self();let r=this._values.cloneEmpty(),i=n.colStart,a=n.rowStart,o={colStart:0,rowStart:0,colEnd:0,rowEnd:0};this.forEach((n,s)=>{o.colStart=i+s.colIndex*t,o.rowStart=a+s.rowIndex*e,o.colEnd=o.colStart+t-1,o.rowEnd=o.rowStart+e-1,QV(r,o,n)});let s=this.getColumnCount(),c=this.getRowCount();return n={colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colStart+t*s-1,rowEnd:n.rowStart+e*c-1},this._newRange(r,n,this._optionsFresh())}reshape(e,t){let n=this.getRowCount(),r=this.getColumnCount();if(e===n&&t===r)return this._self();if(e<=0||t<=0||!Number.isFinite(e)||!Number.isFinite(t))throw Error(`Invalid reshape dimensions: ${e} x ${t}`);if(e*t<n*r)throw Error(`Cannot reshape ${n} x ${r} into ${e} x ${t}; the target holds fewer positions.`);let i=this._coords;if(!i)return this._self();let a=this._values.cloneEmpty(),o=i.rowStart,s=i.colStart;return this.forEach((e,n)=>{let i=n.rowIndex*r+n.colIndex;a.setValueAt(o+Math.trunc(i/t),s+i%t,e)}),this._newRange(a,{colStart:s,rowStart:o,colEnd:s+t-1,rowEnd:o+e-1},this._optionsFresh())}replace(e,t){let n;if(e?.isIRange)n=e;else{let t=RB(e,new Xc({axis:this._values.getAxis()}),this._coords);n=this._newRange(t.values,t.coords,this._optionsFresh(),t.isLiteral)}if(this.size===0)return n._self();if(n.size===0)return this._self();let r=n._absentValue!==null;n=n._materializeEmpty();let i=Math.max(this.getColumnCount(),n.getColumnCount()+(t?.colIndex??0)),a=Math.max(this.getRowCount(),n.getRowCount()+(t?.rowIndex??0));if(this._absentValue!==null&&(!r||i>this.getColumnCount()||a>this.getRowCount()))return this._materializeEmpty().replace(n,t);let o=this._values.clone(),s=n._values,c=n._coords??h.EmptyRange,l=this._coords??h.EmptyRange,u=l.colStart,d=l.rowStart,f=u+(t?.colIndex??0),p=d+(t?.rowIndex??0);s.copyTo(o,{colIndex:f,rowIndex:p},c);let m={colStart:u,rowStart:d,colEnd:u+i-1,rowEnd:d+a-1};return this._newRange(o,m,this._optionsIterator,!1,!1,this._absentValue)}resize(e,t,n=null){if(t<0||e<0)throw Error(`Invalid resize dimensions: ${t} x ${e}`);let r=this._coords,i=r?r.colStart:0,a=r?r.rowStart:0,o=r?r.colEnd:0,s=r?r.rowEnd:0;if(t===(r?o-i+1:0)&&e===(r?s-a+1:0))return this._self();let c=this._absentValue;if(c!==null&&n!==c)return this._materializeEmpty().resize(e,t,n);let l=i+t-1,u=a+e-1,d=this._values;d=d.clone(),(!r||l>o||u>s)&&$V(d,r,l,u,c===null?n:null);let f={colStart:i,rowStart:a,colEnd:l,rowEnd:u};return this._newRange(d,f,this._optionsIterator,!1,!1,c)}select(e,t,n,r,i){Array.isArray(e)||(e=[e]);let a=e.length,o=-1;return n!==void 0&&(t=[...t,n],o=t.length-1),this.choose(t,(t,n)=>{let i=n.colIndex,s=n.rowIndex;for(let o=0;o<a;o++){let a=e[o];if(a.isIRange){let e=a,t=e.getColumnCount(),n=e.getRowCount();i+1>t&&t===1&&(i=0),s+1>n&&n===1&&(s=0),a=e.getValueAt(s,i)}if(r){if(iH.colIndex=i,iH.rowIndex=s,r(t,n,a,iH,this))return o}else if(t===a)return o}return o},i)}slice(e){if(!e)return this._self();let t=this._absoluteCoords(e);return t?this._newRange(this._values,t,this._optionsIterator,!1,!1,this._absentValue):this.empty()}some(e,t){if(!e)return!1;let n=this.entries(t),r=n.next();for(;!r.done;){let t=r.value;if(e(t.value,t.coords,this))return!0;r=n.next()}return!1}sort(e=1,t=B.Axis.Row){let n=this.argsort(this,e,t);return this.take(n,t)}sparseBuilder(e){let t=this._values,n=this._axisFromOptions(e),r=t.getAxis(),i=n!==B.Axis.Row,a=n===r?new Lo.Builder:new Lo.TransposedBuilder,o=this,s=this._coords??h.EmptyRange,c=s.colStart,l=s.rowStart,u=i?c:l,d=i?l:c,f={pushAt(e,t,n){if(n===null)return f;let r=i?t:e,o=i?e:t;return a.pushAt(r+u,o+d,n),f},pushMultipleAt(e,t,n){let r;r=Array.isArray(n)?n:n.isIRange?n.getValuesFlat():[n];let o=i?t:e,s=i?e:t;return a.pushMultipleAt(o+u,s+d,r),f},build:()=>o._cloneFromBuilder(a)};return f}_takeSparse(e,t){let n=this.getRowCount(),r=this.getColumnCount(),i=t===B.Axis.Column,a=e.length,o=this.empty().resize(i?n:a,i?a:r,null).sparseBuilder(i?B.Axis.Column:B.Axis.Row);if(i)for(let t=0;t<a;t++){let r=e[t];for(let e=0;e<n;e++){let n=this.getValueAt(e,r);n!=null&&o.pushAt(e,t,n)}}else for(let t=0;t<a;t++){let n=e[t];for(let e=0;e<r;e++){let r=this.getValueAt(n,e);r!=null&&o.pushAt(t,e,r)}}return o.build()}_takeDense(e,t){let n=this.getRowCount(),r=this.getColumnCount(),i=t===B.Axis.Column,a=Array.from({length:r},()=>Array(n).fill(null)),o=this.entries(eH),s=o.next();for(;!s.done;){let{value:e,coords:t}=s.value;a[t.colIndex][t.rowIndex]=e,s=o.next()}let c=e.length,l=this.empty().resize(i?n:c,i?c:r,null).sparseBuilder(i?B.Axis.Column:B.Axis.Row);if(i)for(let t=0;t<c;t++){let r=a[e[t]];if(r)for(let e=0;e<n;e++){let n=r[e];n!=null&&l.pushAt(e,t,n)}}else for(let t=0;t<c;t++){let n=e[t];for(let e=0;e<r;e++){let r=a[e][n];r!=null&&l.pushAt(t,e,r)}}return l.build()}take(e,t=B.Axis.Row){let n=this.getRowCount(),r=this.getColumnCount();return e.length*r<r*n*.7?this._takeSparse(e,t):this._takeDense(e,t)}tile(e,t){if(e===1&&t===1)return this._self();if(e<=0||t<=0)throw Error(`Invalid tile dimensions: ${e} x ${t}`);let n=this._coords;if(!n)return this._self();if(this._absentValue!==null)return this._materializeEmpty().tile(e,t);let r=this._values,i=r.cloneEmpty(),a=this.getColumnCount(),o=this.getRowCount(),s=n.colStart,c=n.rowStart,l=0,u=0,d={rowIndex:0,colIndex:0};for(let f=0;f<e;f++){l=f*o;for(let e=0;e<t;e++)u=e*a,d.colIndex=s+u,d.rowIndex=c+l,r.copyTo(i,d,n)}return n={colStart:n.colStart,rowStart:n.rowStart,colEnd:n.colStart+t*a-1,rowEnd:n.rowStart+e*o-1},this._newRange(i,n,this._optionsFresh())}toScalar(){if(this.size!==1)throw Error(`Cannot convert to scalar, range size is ${this.size} not 1`);return this.getValueAt(0,0)}toType(e){let t=typeof e==`string`?{type:e}:e,n=this._optionsIterator;return n=n?{...n,...t}:t,this._newRange(this._values,this._coords,n,!1,!1,this._absentValue)}transpose(){if(this.size<=1)return this._self();let e=this._values,t=this._coords,n=e.getAxis(),r=this._entries({axis:n===B.Axis.Column?B.Axis.Row:B.Axis.Column,bounds:t,reuseResult:!0}),i=n===B.Axis.Column,a=new Lo.Builder,o=t.colStart,s=t.rowStart,c=r.next();for(;!c.done;){let e=c.value,t=e[0],n=t.colIndex-o,l=t.rowIndex-s,u=e[1];a.pushAt(i?l:n,i?n:l,u),c=r.next()}let l=this.empty()._cloneFromBuilder(a),u=t.colEnd-t.colStart+1,d=t.rowEnd-t.rowStart+1;return l.getRowCount()!==u||l.getColumnCount()!==d?l.resize(u,d):l}values(e){let t=this.entries(e);return{[Symbol.iterator](){return this},next(){let e=t.next();return e.done?yo:{done:!1,value:e.value.value}}}}zip(e,t,n){let r=n?{...this._optionsIterator,...n}:this._optionsIterator,i=r.type??null,a=i?this._coerceValue(null,i,r,U.Null):null,o=n?.misalignValue??V.BuiltIn.NA,s=n?.tile??!0,c=n?.blankRegions===`once`,l=this._values,u=l.getAxis()===B.Axis.Column,d=e.length+1,f=Array(d),p=Array(d),m=1,g=1;for(let t=0;t<d;t++){let n=t===0?this:e[t-1];if(p[t]=null,typeof n==`object`&&n&&!0===n.isIRange){let e=n;if(e.size>1){p[t]=e;let n=e.getRowCount(),r=e.getColumnCount();n>m&&(m=n),r>g&&(g=r);continue}let o=e.size===1?e.getValueAt(0,0):null;f[t]=(i?this._coerceValue(o,i,r):o)??a;continue}let o=n===void 0?null:n;f[t]=(i?this._coerceValue(o,i,r):o)??a}let _=u?g:m,v=u?m:g,y=[],b=[],x=[];for(let e=0;e<d;e++){let t=p[e];if(t===null)continue;let n=t._coords,c=t.getRowCount(),l=t.getColumnCount(),d=c===1&&s?m:c,f=l===1&&s?g:l,h=t._memberReader({...e===0?r:t._optionsIterator,type:i},!1),S=new XV(e,t._values,n,u,u?f:d,u?d:f,h,h(void 0)??a,o,a,t._skipsOnGrid(t._optionsIterator));y.push(S),S.majorExtent<_&&b.indexOf(S.majorExtent)<0&&b.push(S.majorExtent),S.minorExtent<v&&x.indexOf(S.minorExtent)<0&&x.push(S.minorExtent)}let S=y.length;b.sort((e,t)=>e-t),x.sort((e,t)=>e-t);let C=x.length+1,w=(e,t)=>{let n=0;for(;n<e.length&&e[n]<=t;)n++;return n},T=(e,t)=>{for(let n=0;n<S;n++){let r=y[n];f[r.slot]=r.covers?r.valueAt(t):e>=r.majorExtent||t>=r.minorExtent?r.pad:r.empty}},E=(e,t)=>{for(let n=0;n<S;n++){let r=y[n];f[r.slot]=e>=r.majorExtent||t>=r.minorExtent?r.pad:r.empty}},D=(e,t)=>({rowIndex:u?t:e,colIndex:u?e:t}),O=this._coords??h.EmptyRange,k=u?O.colStart:O.rowStart,A=u?O.rowStart:O.colStart,j=new Lo.Builder(void 0,0,0,!0),M=c?Array((b.length+1)*C):null,N;ZV(y,_,v,(e,n,r)=>{if(!c){for(let i=n;i<r;i++)E(e,i),j.pushAt(k+e,A+i,t(f,D(e,i),this));return}let i=w(b,e),a=n;for(;a<r;){let n=w(x,a),o=n<x.length?x[n]:v,s=Math.min(o,r),c=i*C+n;if(c===0)j.pushAbsentAt(k+e,A+a,s-a),N===void 0&&(E(e,a),N=t(f,YV,this)??null,j.setAbsentValue(N));else{let n=M[c];n===void 0&&(E(e,a),n=t(f,YV,this)??null,M[c]=n),j.pushMultipleAt(k+e,A+a,new Ro([n],s-a))}a=s}},(e,n,r,i)=>{if(i&&c){T(e,n);let i=t(f,YV,this);j.pushMultipleAt(k+e,A+n,new Ro([i],r-n+1))}else for(let i=n;i<=r;i++)T(e,i),j.pushAt(k+e,A+i,t(f,D(e,i),this))});let ee=j.build(),te=l.cloneEmpty();return this._applyRegion(te,ee,!0),this._newRange(te,{colStart:O.colStart,rowStart:O.rowStart,colEnd:O.colStart+g-1,rowEnd:O.rowStart+m-1},this._optionsIterator,!1,!1,ee.absentValue??null)._untyped()}_isLiteralArray(){return this._isLiteral}_isDirectScalarBox(){return this._isDirectScalar}isEmpty(){return this.size===0}get size(){let e=this._coords;return e?(e.colEnd-e.colStart+1)*(e.rowEnd-e.rowStart+1):0}[Symbol.iterator](){let e=this.entries();return{next(){let t=e.next();return t.done?yo:{done:!1,value:t.value.value}},[Symbol.iterator](){return this}}}toString(){let e=this._coords;return e?`${e.rowEnd-e.rowStart+1}x${e.colEnd-e.colStart+1}:${this._toStringValues()}`:`0x0:{}`}get[Symbol.toStringTag](){return`[Range]`}_validateCoords(e){}_axisFromOptions(e){let t=this._optionsIterator;if(!e)return t.axis;let n;return n=typeof e==`object`&&`axis`in e?e.axis:e,n?n===`fastest`?this._values.getAxis():n:t.axis}_toStringValues(e=39){let t=`{`,n=this.entries({includeEmpty:!0,axis:B.Axis.Row,onError:`value`}),r=n.next(),i=0,a=r.value?.coords.rowIndex??0;for(;!r.done&&t.length<e;){let e=r.value;e.coords.rowIndex>a?(t+=`;`,a=e.coords.rowIndex):i>0&&(t+=`,`),i++;let o=e.value;o===null?o=``:typeof o==`string`?o=`"${o}"`:typeof o==`boolean`&&(o=o?`TRUE`:`FALSE`),t+=o,r=n.next()}return r.done?t+=`}`:t+=`...`,t}_entries(e){let t=this._coords;if(!t)return bo;let n=this._values,r=this._optionsIterator,i=e?.axis===`fastest`?n.getAxis():e?.axis??r.axis,a=e?{...r,...e,axis:i}:r,o=n.entries(this._skipsOnGrid(a)),s=e?.type,c=this._absentValue;if(e?.includeEmpty||c!==null){if(a.bounds||(a={...a,bounds:t}),a.processRowSkip||a.processColumnSkip){let{processRowSkip:e,processColumnSkip:t,...n}=a;a=n}o=new Lc(o,a),s||c===null||(o=qV(o,c))}if(!s&&sg()&&(o=JV(o)),s){let t=o,n=this._memberReader(e,e?.includeEmpty??!1);o={[Symbol.iterator]:()=>o,next(){for(;;){let e=t.next();if(e.done)return yo;let r=e.value,i=r[1],a=n(i);if(a!==void 0)return a===i?e:{done:!1,value:[r[0],a]}}}}}return o}_memberReader(e,t){let n=this._absentValue,r=e?.type,i=sg();if(!r)return i?e=>e===void 0?n:pg(e):e=>e===void 0?n:e;let a=null;t&&(a=this._coerceValue(null,r,{...e,onError:`value`},U.Null));let o=e.errorOnInvalidCoercion??!1,s=e.onError??`throw`,c=s===`ignore`,l=!1,u=!1,d=null;c||(s===`throw`?l=!0:s===`value`?u=!0:typeof s==`function`&&(d=s));let f=this._runtime,p=this,m=DB(f,r),h=e.coerce,g;h&&(typeof h==`function`?(m=h,g=DB(f,r,GB)):Array.isArray(h)&&(m=DB(f,r,h)));let _=this._isDirectScalar,v=e=>{if(i&&(e=pg(e)),e===null&&c)return a;let n=pB(e,!0);if(_&&!m&&n!==r&&(e=OB(f,e,n,r,!0),n=pB(e,!0)),n===r)return e;let s=null;if(n===U.Error?s=e:m&&(s=m(e,n,g,p),o&&s===null&&e!==null&&(s=V.BuiltIn.Value)),V.isError(s)){if(c)s=null;else{if(l)throw s;u||d&&d(e)}}return s===null?t?null:void 0:s};if(n===null)return e=>e===void 0?a:v(e);if(d)return e=>v(e===void 0?n:e);let y,b,x=0;return e=>{if(e!==void 0)return v(e);if(x===0)try{y=v(n),x=1}catch(e){b=e,x=2}if(x===2)throw b;return y}}_absoluteCoords(e,t){let n=this._coords??h.EmptyRange,r=n.colStart,i=n.rowStart;UV.colStart=(e.colStart??0)+r,UV.rowStart=(e.rowStart??0)+i,UV.colEnd=(e.colEnd??n.colEnd-r)+r,UV.rowEnd=(e.rowEnd??n.rowEnd-i)+i;let a=h.intersectRanges(n,UV,t);return a&&this._validateCoords(a),a}_self(){return this._isLiteral?this.clone():this}_untyped(){let e=this._optionsIterator;if(!e?.type)return this;let{type:t,coerce:n,...r}=e;return this._newRange(this._values,this._coords,r,this._isLiteral,!1,this._absentValue)}_optionsFresh(){let e=this._optionsIterator;if(!e.processRowSkip&&!e.processColumnSkip)return e;let{processRowSkip:t,processColumnSkip:n,...r}=e;return r}_optionsAt(e){let t=this._optionsIterator,n=t.processRowSkip,r=t.processColumnSkip;if(!n&&!r)return t;let i=this._coords;if(!e||!i)return this._optionsFresh();let a=e.rowStart-i.rowStart,o=e.colStart-i.colStart,s=i.rowEnd-i.rowStart+1,c=i.colEnd-i.colStart+1,l=e.rowEnd-e.rowStart+1+a>s,u=e.colEnd-e.colStart+1+o>c;return a!==0||o!==0||l||u?{...t,processRowSkip:n?VV(n,a,s):void 0,processColumnSkip:r?VV(r,o,c):void 0}:t}_hasSkips(){let e=this._optionsIterator;return e.processRowSkip!==void 0||e.processColumnSkip!==void 0}_skipsOnGrid(e){let t=e.processRowSkip,n=e.processColumnSkip;if(!t&&!n)return e;let r=this._coords;return r?{...e,processRowSkip:t?BV(t,r.rowStart):void 0,processColumnSkip:n?BV(n,r.colStart):void 0}:e}_createBuilder(e){let t=this._coords??h.EmptyRange,n=this._values.getAxis(),r=e??n,i=r!==B.Axis.Row,a=i?t.colStart:t.rowStart,o=i?t.rowStart:t.colStart;return r===n?new Lo.Builder(null,a,o):new Lo.TransposedBuilder(null,a,o)}_applyRegion(e,t,n){if(!t)return;let r=t.clears;!n&&r&&KV(e,r),t.tuples.length>0&&e.setValues(t.tuples)}_cloneFromBuilder(e,t=null,n=!1,r=this._absentValue){return this._cloneFromRegion(e?e.build():null,t,n,r)}_cloneFromRegion(e,t=null,n=!1,r=this._absentValue){let i=e&&e.tuples.length>0?e:null,a=e?.clears;if(!(i||t||a&&a.length>0))return this._self();let o=this._values;o=n?o.cloneEmpty():o.clone();let s=o.getAxis()===B.Axis.Column;if(t){let e=t.done();for(let t of e)o.delete(t)}a&&!n&&KV(o,a);let c=this._coords;if(i){let e=Mc(i.bounds,s),t=c,n=t?t.colStart:0,r=t?t.rowStart:0,a=t?t.colEnd:0,l=t?t.rowEnd:0,u=e.colEnd,d=e.rowEnd;(u>a||d>l)&&$V(o,t,u,d),o.setValues(i.tuples),c={colStart:n,rowStart:r,colEnd:Math.max(u,a),rowEnd:Math.max(d,l)}}return this._newRange(o,c,this._optionsIterator,this._isLiteral,!1,r)}_coerceValue(e,t,n,r){if(!t)return e;let i=this._runtime,a=DB(i,t),o=n?.coerce,s;o&&(typeof o==`function`?(a=o,s=DB(i,t,GB)):Array.isArray(o)&&(a=DB(i,t,o))),r??=pB(e,!0),this._isDirectScalar&&r!==t&&(e=OB(this._runtime,e,r,t,!0),r=pB(e,!0));let c=null;if(r===t)c=e;else if(a?c=a(e,r,s,this):r===U.Error&&(c=e),V.isError(c)){let e=n?.onError??`throw`;if(e===`throw`)throw c;e===`value`||(e===`ignore`?c=null:typeof e==`function`&&e(c))}return c}_mergeIterators(e,t,n){let r=this._coords??h.EmptyRange,i=e._coords??h.EmptyRange,a=this._values.getAxis(),o=n?.axis===`fastest`?a:n?.axis??a,s=o!==B.Axis.Row,c=this._entries(n),l=this._entries(n),u=r.colStart,d=r.rowStart,f=u-i.colStart,p=d-i.rowStart,m=o===a?new Lo.Builder:new Lo.TransposedBuilder,g=new zc({...n,axis:o,bounds:r,comparator:(s?pD:mD)(r,i)},c,l),_=g.next();for(;!_.done;){let e=_.value,n=e[1],r=e[3],i=e[0],a=e[2],o=i?i.colIndex:a.colIndex+f,c=i?i.rowIndex:a.rowIndex+p,l=t(n,r,{colIndex:o-u,rowIndex:c-d},this),h=s?o:c,v=s?c:o;m.pushAt(h,v,l),_=g.next()}return m}_newRange(t,n,r=null,i=!1,a=!1,o=null){return r===this._optionsIterator&&n!==this._coords&&(r=this._optionsAt(n)),new e(this._runtime,t,n,r,i,a,o)}get isIRange(){return!0}},RV=class extends LV{constructor(e,t,n,r){super(e,t,n),this._visibleCoords=r}_getStats(e){return super._getStats(e).toLocalCoords(this._visibleCoords,e)}},zV=(e,t,n)=>{let r=e?.processRowSkip;if(r&&r(t)!==t)return!0;let i=e?.processColumnSkip;return i!==void 0&&i(n)!==n},BV=(e,t)=>t===0?e:(n,r)=>e(n-t,r)+t,VV=(e,t,n)=>(r,i)=>{let a=r+t;return a<0||a>=n?r:e(a,i)-t},HV={colStart:-(2**53-1),rowStart:-(2**53-1),colEnd:2**53-1,rowEnd:2**53-1},UV={colStart:-(2**53-1),rowStart:-(2**53-1),colEnd:2**53-1,rowEnd:2**53-1},WV=Object.freeze([Object.freeze([null])]),GV=Object.freeze({axis:B.Axis.Row}),KV=(e,t)=>{let n=e.getAxis()===B.Axis.Column;for(let r=0;r<t.length;r++){let i=t[r],a=i[0],o=i[1],s=o+i[2]-1;e.delete(n?{colStart:a,colEnd:a,rowStart:o,rowEnd:s}:{colStart:o,colEnd:s,rowStart:a,rowEnd:a})}},qV=(e,t)=>{let n={[Symbol.iterator]:()=>n,next(){let n=e.next();return n.done||n.value[1]!==void 0?n:{done:!1,value:[n.value[0],t]}}};return n},JV=e=>{let t={[Symbol.iterator]:()=>t,next(){let t=e.next();if(t.done)return t;let n=t.value[1],r=pg(n);return r===n?t:{done:!1,value:[t.value[0],r]}}};return t},YV=Object.freeze({rowIndex:-1,colIndex:-1}),XV=class{constructor(e,t,n,r,i,a,o,s,c,l,u){this.seg=null,this.covers=!1,this._replay=null,this._replayMajor=0,this._replayAt=0,this._queue=[],this._queueAt=0,this.slot=e,this.majorExtent=i,this.minorExtent=a,this.read=o,this.empty=s,this.pad=c,this.dropped=l,this._isColumn=r,this._majorBase=r?n.colStart:n.rowStart,this._minorBase=r?n.rowStart:n.colStart,this._minorStart=this._minorBase,this._minorEnd=r?n.rowEnd:n.colEnd;let d=1+(r?n.colEnd-n.colStart:n.rowEnd-n.rowStart),f=this._minorEnd-this._minorStart+1;this._minorTile=f===1&&a>1;let p=t.getAxis()===B.Axis.Column===r,m=u?.processRowSkip,h=u?.processColumnSkip,g=p&&!m&&!h;if(this._runs=g?t.getRuns({bounds:n,overflowRun:!0,reuseResult:!0}):null,this._cells=g?null:t.entries({axis:r?B.Axis.Column:B.Axis.Row,bounds:n,reuseResult:!0,processRowSkip:m,processColumnSkip:h}),d===1&&i>1){let e=[];for(;this._fill();){let t=this._queue;for(let n=this._queueAt;n<t.length;n++)e.push(t[n]);this._queueAt=t.length}this._replay=e,this._replayMajor=-1,this._replayAt=e.length}this.next()}valueAt(e){let t=this.seg,n=t.uniform?t.value:this.read(t.list.at(e+t.base));return n===void 0?this.dropped:n}next(){let e=this._replay;if(e!==null){if(this._replayAt>=e.length&&(this._replayMajor++,this._replayAt=0,this._replayMajor>=this.majorExtent||e.length===0))return void(this.seg=null);let t=e[this._replayAt++];t.major=this._replayMajor,t.from=t.start,this.seg=t}else this.seg=this._queueAt>=this._queue.length&&!this._fill()?null:this._queue[this._queueAt++]}_fill(){for(this._queue.length=0,this._queueAt=0;this._queue.length===0;){let e=this._runs;if(e!==null){let t=e.next();if(t.done)return!1;let n=t.value;this._pushRun(n[0]-this._majorBase,n[1],n[2])}else{let e=this._cells.next();if(e.done)return!1;let t=e.value,n=t[0],r=(this._isColumn?n.colIndex:n.rowIndex)-this._majorBase,i=this._isColumn?n.rowIndex:n.colIndex;if(i<this._minorStart||i>this._minorEnd)continue;this._push(r,i-this._minorBase,i-this._minorBase,!0,this.read(t[1]),null,0)}}return!0}_pushRun(e,t,n){let r=Math.max(t,this._minorStart),i=Math.min(t+n.length-1,this._minorEnd);if(r>i)return;let a=this._minorBase;if(this._minorTile)return void this._push(e,0,this.minorExtent-1,!0,this.read(n.at(r-t)),null,0);let o=t-a,s=n.getUniformRuns?.()??null;if(s===null)return void this._push(e,r-a,i-a,!1,void 0,n,-o);let c=r;for(let r=0;r<s.length;r++){let l=s[r],u=Math.max(t+l[0],c),d=Math.min(t+l[1],i);u>d||(c<u&&this._push(e,c-a,u-1-a,!1,void 0,n,-o),this._push(e,u-a,d-a,!0,this.read(l[2]),null,0),c=d+1)}c<=i&&this._push(e,c-a,i-a,!1,void 0,n,-o)}_push(e,t,n,r,i,a,o){this._queue.push({major:e,from:t,to:n,start:t,uniform:r,value:i,list:a,base:o})}},ZV=(e,t,n,r,i)=>{let a=e.length,o=0,s=0,c=(e,t)=>{for(;o<e;)s<n&&r(o,s,n),o++,s=0;s<t&&(r(o,s,t),s=t)};for(;;){let t=0,r=0,l=!1;for(let n=0;n<a;n++){let i=e[n].seg;i!==null&&(!l||i.major<t||i.major===t&&i.from<r)&&(t=i.major,r=i.from,l=!0)}if(!l)break;(t>o||r>s)&&c(t,r);let u=n-1,d=!0;for(let n=0;n<a;n++){let i=e[n],a=i.seg;if(a!==null&&a.major===t){if(a.from===r){i.covers=!0,a.to<u&&(u=a.to),a.uniform||(d=!1);continue}a.from-1<u&&(u=a.from-1)}i.covers=!1;let o=i.minorExtent;o>r&&o-1<u&&(u=o-1)}i(t,r,u,d);for(let t=0;t<a;t++){let n=e[t];if(!n.covers)continue;let r=n.seg;r.to<=u?n.next():r.from=u+1}s=u+1,s>=n?(o=t+1,s=0):o=t}c(t,0)},QV=(e,t,n)=>{if(n===null)return void e.delete(t);let r=e.getAxis()===B.Axis.Column,i=Vc(n,jc(t.colStart,t.rowStart,t.colEnd,t.rowEnd,r),r);e.setValues(i.tuples)},$V=(e,t,n,r,i=null)=>{if(!t)return HV.colStart=0,HV.rowStart=0,HV.colEnd=n,HV.rowEnd=r,void QV(e,HV,i);let a=t.colEnd,o=Math.max(n,a),s=t.rowEnd,c=Math.max(r,s);o>a&&(HV.colStart=a+1,HV.rowStart=t.rowStart,HV.colEnd=o,HV.rowEnd=c,QV(e,HV,i),o=a),c>s&&(HV.colStart=t.colStart,HV.rowStart=s+1,HV.colEnd=o,HV.rowEnd=c,QV(e,HV,i))},eH=Object.freeze({axis:`fastest`}),tH=64,nH=Object.freeze([U.Error]),rH=Object.freeze({axis:`fastest`,onError:`value`}),iH={colIndex:-(2**53-1),rowIndex:-(2**53-1)};function aH(e,t,n,r){let i=e==null,a=t==null;return i||a?i&&a?0:i?1:-1:$l.compare(e,t,r,r.collator)*n}function oH(e,t,n){return typeof e==`number`&&typeof t==`number`?e===t:$l.compare(e,t,n)===0}function sH(e,t,n){if(typeof t!=`string`)return e+hg(t);let r=n.get(t);return r===void 0&&(r=hg(t),n.set(t,r)),e+r}var cH=class e extends LV{constructor(e,t,n,r,i,a){if(super(e,t,n,r??null),this._errorIndex=null,this._onCoordsRead=null,this._getEntireCoords=i??uB,this._resolveScope=a,this._coords=lH(n,this._getEntireCoords()),!n)throw Error(`ReferenceRange requires a coords`);this._validateCoords(n)}getCoords(){this._onCoordsRead?.();let e=this._coords;if(e.scope){let t=this._resolveScope(e.scope);if(t==null)throw new V.Ref;e={...e,scope:t}}return e}get isIReferenceRange(){return!0}_setErrorIndex(e){this._errorIndex=e}_setCoordsReadHook(e){this._onCoordsRead=e}hasError(){let e=this._errorIndex;if(e===null||this.size<=1)return super.hasError();let t=e.hasErrorIn(this._coords);return t&&this._hasSkips()?super.hasError():t}slice(t){if(!t)return this._self();let n=this._absoluteCoords(t);if(!n)return this.empty();let r=this._coords.scope;r!==void 0&&n.scope===void 0&&(n={...n,scope:r});let i=new e(this._runtime,this._values,n,this._optionsAt(n),this._getEntireCoords,this._resolveScope);return i._errorIndex=this._errorIndex,i._onCoordsRead=this._onCoordsRead,i}clone(t,n=!1,r=!1){if(n||r)return super.clone(t,n,r);let i=new e(this._runtime,this._values,this._coords,t?{...this._optionsIterator,...t}:this._optionsIterator,this._getEntireCoords,this._resolveScope);return i._errorIndex=this._errorIndex,i._onCoordsRead=this._onCoordsRead,i}_toValueRange(){return new LV(this._runtime,this._values,this._coords,this._optionsIterator)}toType(t){let n=typeof t==`string`?{type:t}:t,r=new e(this._runtime,this._values,this._coords,n,this._getEntireCoords,this._resolveScope);return r._errorIndex=this._errorIndex,r._onCoordsRead=this._onCoordsRead,r}_validateCoords(e){let t=this._getEntireCoords?.();if(t&&(e.rowStart<t.rowStart&&e.rowStart!==-(2**53-1)||e.rowEnd>t.rowEnd&&e.rowEnd!==2**53-1||e.colStart<t.colStart&&e.colStart!==-(2**53-1)||e.colEnd>t.colEnd&&e.colEnd!==2**53-1))throw new w}get[Symbol.toStringTag](){return`[ReferenceRange]`}toString(){let e=this._coords,t=this._getEntireCoords();return e.scope&&(e={...e},e.scope=this._resolveScope(e.scope)??V.Label.Ref),`${Gd(e,t)}=>${super.toString()}`}},lH=(e,t)=>{let n=e.rowStart,r=e.rowEnd,i=e.colStart,a=e.colEnd,o=!1;return i===-(2**53-1)&&(i=t.colStart,o=!0),n===-(2**53-1)&&(n=t.rowStart,o=!0),r===2**53-1&&(r=t.rowEnd,o=!0),a===2**53-1&&(a=t.colEnd,o=!0),o?{rowStart:n,rowEnd:r,colStart:i,colEnd:a,scope:e.scope}:e};export{qa as $,lb as $i,i_ as $n,oS as $r,xf as $t,CD as A,vo as Aa,ZI as Ai,KC as An,fx as Ar,Mg as At,zB as B,iS as Bi,Xg as Bn,tx as Br,Za as Bt,Sd as C,gD as Ca,fl as Ci,qC as Cn,hg as Cr,kx as Ct,Eg as D,vb as Da,Hj as Di,qx as Dn,fS as Dr,AS as Dt,Su as E,gS as Ea,Kg as Ei,Yg as En,lB as Er,DR as Et,Pg as F,Rv as Fa,QA as Fi,Z as Fn,tS as Fr,Nc as Ft,IB as G,QD as Gi,mA as Gn,Ej as Gr,Lf as Gt,Hk as H,tz as Hi,Qt as Hn,EP as Hr,Zl as Ht,Ph as I,rn as Ii,GB as In,r_ as Ir,Ng as It,Vy as J,ed as Ji,mS as Jn,Tz as Jr,Lo as Jt,Vd as K,Qx as Ki,fM as Kn,Au as Kr,Lg as Kt,Aj as L,nv as Li,JC as Ln,rg as Lr,Nv as Lt,Tp as M,Rh as Ma,eS as Mi,Jg as Mn,tC as Mr,Dg as Mt,Cx as N,Pj as Na,n_ as Ni,Kx as Nn,QP as Nr,OB as Nt,Ep as O,vc as Oa,Jt as Oi,Yy as On,mg as Or,DV as Ot,Pc as P,Ro as Pa,nf as Pi,Jy as Pn,$j as Pr,jS as Pt,Fg as Q,l_ as Qi,gl as Qn,Ol as Qr,xd as Qt,Pm as R,ew as Ri,Jb as Rn,$A as Rr,Q as Rt,Sc as S,gC as Sa,fg as Si,Vx as Sn,pS as Sr,ju as St,vj as T,mM as Ta,VI as Ti,Yd as Tn,fA as Tr,DB as Tt,Hx as U,YP as Ui,Jx as Un,OS as Ur,Yx as Ut,Wg as V,sn as Vi,Zn as Vn,TB as Vr,Zg as Vt,zz as W,Xj as Wi,Xy as Wn,Ag as Wr,Ld as Wt,NS as X,sS as Xi,gd as Xn,Og as Xr,gR as Xt,AB as Y,sD as Yi,g_ as Yn,Oc as Yr,Lv as Yt,Ff as Z,iV as Zi,fj as Zn,wj as Zr,xc as Zt,zh as _,bg as _a,tj as _i,Bg as _n,$l as _r,DP as _t,Qa as a,_h as aa,dC as ai,wf as an,yu as ar,VA as at,zv as b,bo as ba,f_ as bi,RB as bn,d_ as br,jg as bt,Qh as c,hx as ca,pg as ci,LB as cn,sb as cr,Gg as ct,wV as d,Cg as da,Zj as di,Hd as dn,u_ as dr,Ig as dt,hC as ea,c_ as ei,Sn as en,hM as er,qc as et,kb as f,Cp as fa,t_ as fi,Hg as fn,ug as fr,Ih as ft,zd as g,bf as ga,af as gi,RS as gn,$y as gr,kA as gt,ku as h,bd as ha,a_ as hi,Bx as hn,$g as hr,Iv as ht,Q_ as i,__ as ia,dA as ii,SS as in,yo as ir,qy as it,Tc as j,Rf as ja,eO as ji,UI as jn,Qz as jr,Oj as jt,xz as k,vg as ka,Wx as ki,WA as kn,ml as kr,Mc as kt,Qu as l,vI as la,lj as li,LV as ln,oM as lr,Id as lt,An as m,vC as ma,eR as mi,Bk as mn,Zx as mr,Pk as mt,XC as n,pM as na,cl as ni,gz as nn,yg as nr,Uj as nt,Qd as o,_l as oa,cH as oi,wg as on,aS as or,BB as ot,kg as p,vA as pa,nn as pi,Rj as pn,Yj as pr,Mj as pt,Vv as q,e_ as qi,mO as qn,Ox as qr,Ll as qt,XS as r,hS as ra,ox as ri,SA as rn,hj as rr,Gx as rt,Qg as s,_o as sa,dS as si,wu as sn,s_ as sr,Gd as st,$ as t,hD as ta,cb as ti,xo as tn,yd as tr,qg as tt,Xx as u,Cc as ua,XI as ui,Hc as un,cS as ur,If as ut,Fj as v,bh as va,uC as vi,Ij as vn,sM as vr,kS as vt,Sf as w,pL as wa,HA as wi,Ya as wn,dj as wr,AA as wt,vM as x,pB as xa,fc as xi,zj as xn,dg as xr,Dj as xt,zu as y,gj as ya,cM as yi,Bv as yn,lS as yr,jc as yt,Mx as z,iC as zi,Xc as zn,rv as zr,YS as zt};
|