@sheetxl/mcp 0.8.0-beta.15 → 0.8.0-beta.17
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/LICENSE.md +8 -7
- package/agent/instructions.md +15 -4
- package/assets/{Cf9LpgZz-W5blzy_.js → -cMvbaW1kvHslPKX.js} +3 -3
- package/assets/{BFdeov2e_xUQPEY_.js → 0kfwZuOHUkJmVjg6.js} +7 -7
- package/assets/{B7gUyrfLln3TiyKM.js → 1feDuXw6tBXu2XFg.js} +2 -2
- package/assets/{BbAmA46MhQSu3ZF_.js → 4qMP71Fe1Ep8kbOX.js} +2 -2
- package/assets/{CduNzsdbTigxH-ZK.js → 7TRx0dMYnL2i4tqL.js} +163 -163
- package/assets/{DEW2GxfGYqVFvrfg.js → 8cVPexxAVrFJ9QLX.js} +2 -2
- package/assets/{C4z2IilWTuu2TWXw.js → APP8AzsNgQXHTalA.js} +3 -3
- package/assets/{BleMG0hAQgjE8fTa.js → AnF1Kh3Vo2AniIYO.js} +3 -3
- package/assets/{C0CiMKC3lWK1z9p5.js → B2BfjRdJGZs6afVL.js} +3 -3
- package/assets/{BFXeoFUbuc4IKTz9.js → B2UxLSteMiPlg8Uu.js} +2 -2
- package/assets/{BJxfinOazQqqByc-.js → B3mh2tuvP-lMP6f_.js} +2 -2
- package/assets/{PpFbmF0DFeUdpb9I.js → B6NnxkSmEzCGZEZA.js} +2 -2
- package/assets/{xmTQJJVyCrcq77WR.js → B7Nqa7V-v0cxGBux.js} +2 -2
- package/assets/{DsCI_ZYm_jDjXF3J.js → B7OyFSpBb1eBvMVd.js} +52 -52
- package/assets/{ClNQN3vEg5b5qUDp.js → B8JX7a6VZlBNA_Bd.js} +2435 -2447
- package/assets/{DPCKMM7sgWbrtB8z.js → B9J8nV-dh6jHpzZI.js} +2 -2
- package/assets/{BuUEsifnQALe49uk.js → B9M_sgHpoc-op6FF.js} +2 -2
- package/assets/{BeLr36oL3jmeXFFi.js → BBC_WF8BcAH-k_cQ.js} +2 -2
- package/assets/{B5lHOOQ_rkP4Mi2r.js → BGZ_ltNFYvnAmbVR.js} +2 -2
- package/assets/{iujMYIEPx_v3sdPf.js → BJBoygm-gY68bLAP.js} +996 -995
- package/assets/BJdWgj1hv57eGVl4.js +2039 -0
- package/assets/{DcWTBOi_iBFc6U4J.js → BKRLtOdVOUTrLjQN.js} +8 -8
- package/assets/{DpdHDTFOeuzDVNEe.js → BKjovBsLpX2Fkhov.js} +78 -77
- package/assets/{BCy1zP97fsiIcvj6.js → BMJhHHX2LWgOJWGz.js} +2 -2
- package/assets/{fDMpDhXp36CatF-G.js → BOx4Ut_Rme7NH34X.js} +2 -2
- package/assets/{9U9XCqqdn-q3i2fj.js → BQYpVYbvfWuUJgdx.js} +2 -2
- package/assets/{DJiLWtmPR2OQNjzi.js → BS4ZsfH5D6aemSpO.js} +2 -2
- package/assets/{BlPubAFi7DY7VrAo.js → BSAdmOdx3brRE9LW.js} +2 -2
- package/assets/{BtjqpAKczftx91BQ.js → BSY9Tbmz6VEY_F_x.js} +2 -2
- package/assets/{S16s2h9qoYVBlVEa.js → BT8AGlSg2t7V1QNj.js} +1454 -1366
- package/assets/{Dz8UUJ7Xc2oN5PBG.js → BUV7BlOZcuPgDZ__.js} +2 -2
- package/assets/{B2udpZ-uIaql3AUh.js → BX5xFncPLyeN7TqA.js} +6 -6
- package/assets/{CGBGyaCGdlZFQYK0.js → Bcak_hZpcIkB2gJD.js} +2 -2
- package/assets/{vZZi_iKYHm05gAye.js → BdijGsy5W7yZ_I_n.js} +2 -2
- package/assets/{CMWAsUQ66V8fYrME.js → BebXDUnlrDDRGW60.js} +3 -3
- package/assets/{wfVh0olISLRWdv9Q.js → BgldX21zhey2aR9D.js} +2 -2
- package/assets/{SHZe9VOU1prGs1F9.js → BhCbCEPpDzhg5nqL.js} +2 -2
- package/assets/{ZuYfVKlp41IJnrOS.js → Bj4BFLBC9Tf6SGSt.js} +2 -2
- package/assets/BjhAYfsKC8iEbtgn.js +169 -0
- package/assets/BjnQVl1lb1KEbt2D.js +529 -0
- package/assets/{CWl6oHiJxkNKRixk.js → BlbxiLf1zD6_fWZs.js} +2 -2
- package/assets/{BjqQjxBuoXza8oqg.js → BmM-nHMAAuNatCcN.js} +3 -4
- package/assets/{DD8HNAUFroTCuD-b.js → Bni-y4FJS4rkFYtn.js} +3305 -2147
- package/assets/{Cfhv_Yw_LT8VzAMt.js → BodrfKIAhDFD-X3t.js} +2 -2
- package/assets/{D8J14MLlN2HRXdXB.js → BvDcHHJvQMRHthm-.js} +2 -2
- package/assets/{hulrR0PldUxMJm_F.js → Bw_FtA-1886HMCLJ.js} +4 -4
- package/assets/{BOPsJmq7v7HOKUkO.js → Bxkx8QokmRNyXbOI.js} +12 -12
- package/assets/{CNz3LdmvsOEJoLO9.js → Bz1ImBvJwPwBrA5j.js} +2 -2
- package/assets/C2NPIWe0pLs3PAZM.js +7 -0
- package/assets/{LEJp05fjmflKgyqF.js → C2ZX6ffXsMaEr2d2.js} +452 -448
- package/assets/{Bg95xYj5siqhHVEz.js → C3Q-fjiZZ15waCq_.js} +3 -3
- package/assets/{CJ5WQnaoCsdr5gf4.js → C46RpMrfF6FiEFI7.js} +2 -2
- package/assets/{ChWpsFGl-BYOnX_A.js → C4deMY87Q_haYyLF.js} +2 -2
- package/assets/C7iHn3y3HVBHflpA.js +2563 -0
- package/assets/{C7ONfuYIWRmDu_vs.js → CJF3P7U7yBQVF2Cg.js} +2 -2
- package/assets/{DvUUArnZwoYOKOuk.js → CLgvdaqeFlESLvbF.js} +2 -2
- package/assets/{Crt2kLdGIlBHANgg.js → CLze192iF2o-aETZ.js} +2 -2
- package/assets/{F_f0jJqM5MrXGbwC.js → CMRLNLqYkiqCLMRa.js} +4 -4
- package/assets/{D-ffk16w8c5w0mxI.js → COa691om4fLN4CUy.js} +2 -2
- package/assets/CSLLHl-zum7m1CJl.js +14 -0
- package/assets/{DVchxwp6w6lu2Ihu.js → CUbCBf24Ie4A2l4R.js} +3 -3
- package/assets/{xnhBSX6lAcmBM65y.js → CWLleOolFzyT0COW.js} +2 -2
- package/assets/{Cg51xaLRUkVOMdCZ.js → CaJ9j3l0cERnYqDS.js} +2 -2
- package/assets/{BQMDOjNBMjAx9WiW.js → CfA8o-FNret9-D6Y.js} +2 -2
- package/assets/{BbcUxIZe3YXywsQR.js → Cl7HHR6Vc9S4n3AP.js} +2 -2
- package/assets/{BG5kgbDRXMc0re6W.js → CqjNsZ2OB4Kx6J3s.js} +9 -9
- package/assets/{By-7OWXShMlFFejV.js → CqwEHSKivMYw7tRZ.js} +2 -2
- package/assets/{BTQhJQ3e0hsiousD.js → Cr6lm0oXZJaaoAmD.js} +2 -2
- package/assets/{CudNpUD78SrtJIiy.js → CshK6Ew7OQ7mngI3.js} +3 -3
- package/assets/{DoILAmhKUOlKWRVw.js → CsiIgnb_L2x2Go6g.js} +2 -2
- package/assets/{Bn8D2bebQ2tFfwQt.js → CtmrBbpapaNwjwNB.js} +47 -45
- package/assets/{Diee6f_qAmcZBd2_.js → CwRhhoL5ynbe78dB.js} +2 -2
- package/assets/{DDnwKPJSznyfYDZS.js → CyI1eGGzJX8nJXaT.js} +3 -3
- package/assets/{BRzp6DEIYUgM3NkN.js → Cz4H3Qge2u8er3Ny.js} +4 -4
- package/assets/{D7oUtYjetuykGhQ5.js → D0OQ6ka8so0BWPwL.js} +2 -2
- package/assets/{_fUXIv6nKvgZkhxn.js → D336KioeSjd-T8n3.js} +3 -3
- package/assets/D5L35C8cbX16BSCF.js +4676 -0
- package/assets/{jadLBUNBVR9mbZ35.js → D5VFuX1h50V2jLmZ.js} +830 -515
- package/assets/{Bh0PNKlrR4VAqnP8.js → D6ON3ZLcTAXV3fO6.js} +35694 -30239
- package/assets/{LyLlBk--VJD2V-f8.js → DDhPOQPc-lpyZrUJ.js} +34 -34
- package/assets/{FzNG48GE_wso6RII.js → DE4xC78p5UtS7wH6.js} +2 -2
- package/assets/{OVRdpPUzR0-ueTxE.js → DF7-oRscXc_vkMo8.js} +2 -2
- package/assets/{CMK6tIDVqYYvK4GZ.js → DMuOMpgIhVgB3eG8.js} +2 -2
- package/assets/{CecTe22WURiXbVdY.js → DPKeRb9GKmh_WCPv.js} +386 -372
- package/assets/{oxjm7Yr7u7MeaO5P.js → DSsH28SW8CMrSL-q.js} +2 -2
- package/assets/{Btys7KwtvV3hz2F6.js → DV6WSFmSEKfb3d2s.js} +109 -109
- package/assets/{JO3zH9hupFSV6vj2.js → DYJcfrNUUJQtxXWX.js} +2 -2
- package/assets/{BZPTaa0WjpoUAbgZ.js → D_peM8fbRgGaWvpq.js} +2 -2
- package/assets/{DTfl-4Iboi6TQU5m.js → DeEZvPW-VvlE28oE.js} +4 -4
- package/assets/Dgi2xwb2DN2Gybj3.js +7 -0
- package/assets/{Cf2dcwmmmf13Rywg.js → DidhZpf9qJAei29Y.js} +2 -2
- package/assets/{DB-tkqI6wFXDKEfB.js → Dkg-LQVsZlrHk7A8.js} +2 -2
- package/assets/DnTfXqCnRCe-1QYI.js +199 -0
- package/assets/{B9US2ZrF93KOjmAx.js → DoBvgI3Ry8DlGzwQ.js} +2 -2
- package/assets/{DH7sGHzxUqIQkDnd.js → DrHVew6gwOB6oxCn.js} +2 -2
- package/assets/{CvngwB17_ve4W49b.js → Dre79rTMoYYikNuB.js} +69 -69
- package/assets/{_d5XJ7dn1CKKYrep.js → DsCNtBR5jCeqmLBS.js} +3 -3
- package/assets/{jPUOH4FHF4b-rapv.js → Dzz3yrKbECzg6caR.js} +2 -2
- package/assets/{BrcQmHcE7Hcr1erJ.js → FvxN6PPps-rNPDo8.js} +2 -2
- package/assets/G2Wjyx_ETCAcofwm.js +7166 -0
- package/assets/{CXHslDxkWCuEcCSQ.js → IGAV8DdYH32cW8XU.js} +2 -2
- package/assets/{U1XXGEPuuqIAzYl1.js → Jd71-QCmFEcDcYSw.js} +2 -2
- package/assets/{B-MqXm_7luDLwazY.js → Ljri8sTW3dWT4clD.js} +2 -2
- package/assets/{BQbF1RkUH8WyXqSD.js → MW2nt7se27FlH9Yb.js} +25 -19
- package/assets/{FS9NbEKgQvz5wqvZ.js → Mgs_OJP41a-Nfac3.js} +2 -2
- package/assets/{DwLZpYUp85UHBE3H.js → OHBzl-tZOi9Ni8YV.js} +2 -2
- package/assets/{DA_ar3QKLKtJ9fJD.js → PbBzI4PlKpCgULLd.js} +2 -2
- package/assets/{C7Z1li2XjWi6bkrp.js → UH_biJmLrI9SvckA.js} +4 -4
- package/assets/{DlBdhv6NHgrNp5Yo.js → Xe7sA_mEwDQpJjcF.js} +3 -3
- package/assets/{D0CHDsemn0S31ltt.js → YFiGplEq1G4XdCJ2.js} +2 -2
- package/assets/{DKLm4nWzynGw1Kr9.js → YQtUMMGmb1_WFsh_.js} +2 -2
- package/assets/{B4VnJacrzr1x4PHR.js → dcvgOfBmWFTsXoT8.js} +5 -5
- package/assets/{C2OrZ8LZ-TI6eYG0.js → iBgLe32XErisaUSr.js} +2 -2
- package/assets/{B2Ek-DWpZMGJ0V1Z.js → kpS1vY0DcE9p8JnI.js} +3 -3
- package/assets/{CxjchwpiqxPM1XKd.js → lcIaYgz4tQGBlzlo.js} +80 -80
- package/assets/{CwPBmcY6xSP8dNlh.js → nQbVdQrfdz3osBdi.js} +12 -12
- package/assets/{DwWngYJTgC0KLbih.js → oJNJQJEDQCsjHSmo.js} +2 -2
- package/assets/{BPwmBu_aouERJjiW.js → qgW-p2sFhMtuu5yw.js} +2 -2
- package/assets/{C97xDe_wBbLZh_uW.js → z24-oIqP_fu2hsOt.js} +2 -2
- package/assets/{BsQZI1vXTRE63Zy-.js → z7nDK_gfX7G37XbZ.js} +345 -235
- package/index.js +1976 -1910
- package/lib.js +2 -2
- package/licenses/dependencies.txt +245 -180
- package/package.json +4 -9
- package/resources/locales/@sheetxl/sdk/de/model.msg.json +82 -1
- package/resources/locales/@sheetxl/sdk/en/model.msg.json +80 -1
- package/screenshot-page/assets/{CSUd8n1H0VBfREnk.js → -N4OYIMgf6f5vgNy.js} +1 -1
- package/screenshot-page/assets/7Xk_eQAcM_HgWrOC.js +1 -0
- package/screenshot-page/assets/B1W17rc9ilPFCh31.js +1 -0
- package/screenshot-page/assets/B8UkvH0o9n_G5UO9.js +3 -0
- package/screenshot-page/assets/{DQWHkaQeNXft9j8b.js → B8qybUclSjEYP5FJ.js} +2 -2
- package/screenshot-page/assets/{DXQLzGmxoyN3kfQi.js → BD96fN2dSVuoME09.js} +7 -7
- package/screenshot-page/assets/BE8ea8S0Q-qogeEs.js +2 -0
- package/screenshot-page/assets/{BUjI304IvdJnFXH3.js → BKwVcuWOKeH2xREA.js} +1 -1
- package/screenshot-page/assets/{BcOdl17EeFSxnAiq.js → BMf827t1Ul65MHd5.js} +1 -1
- package/screenshot-page/assets/BMwQInar0xVS5FRu.js +1 -0
- package/screenshot-page/assets/BNMBa8EZgWX2Eb3c.js +1 -0
- package/screenshot-page/assets/{Bf7xq8PyF4ohjMzP.js → BQCyH9YbEgnH78Ke.js} +2 -2
- package/screenshot-page/assets/{D6Jpaz2YkhOfzxDB.js → BYQZ8o8k3-MDoNat.js} +1 -1
- package/screenshot-page/assets/BcDxaEii3arJqOym.js +1 -0
- package/screenshot-page/assets/Be-rukvcufhLamH5.js +1 -0
- package/screenshot-page/assets/{CZf9s6otzzoaBlSs.js → BftXEPOuf5Uwxpud.js} +1 -1
- package/screenshot-page/assets/{TfhknTx8vxQkw4zV.js → Bh33WyohJvbKZVQN.js} +2 -2
- package/screenshot-page/assets/{CykecBozGGFl26KA.js → Btgo0VFTT0JxuaP3.js} +74 -68
- package/screenshot-page/assets/C2ty_K_uix4ooip6.js +1 -0
- package/screenshot-page/assets/{B-KIwD5F_5S-NsPg.js → C71ZZMVLfHdPl441.js} +1 -1
- package/screenshot-page/assets/C9mUKjQ3yEzRu9j2.js +2 -0
- package/screenshot-page/assets/{hp_-JA1DMK4Yoztn.js → CB2mQ5rbaSw2W4ik.js} +23 -23
- package/screenshot-page/assets/{CIged53b3hHKxa-o.js → CCVAsuUimIJOkBnk.js} +1 -1
- package/screenshot-page/assets/CFfgJlXaIS8QMx5O.js +1 -0
- package/screenshot-page/assets/{DGXDfjkGZjMRAXPg.js → CN8u05DjKwNHbUHN.js} +1 -1
- package/screenshot-page/assets/COoMVTzF50qBNFEu.js +39 -0
- package/screenshot-page/assets/CSMEGhAHxl5-4FxB.js +1 -0
- package/screenshot-page/assets/{BSdFVGZNhU6YHbMI.js → CT7cY57t9j1sBhAy.js} +1 -1
- package/screenshot-page/assets/{l32n8O_A78Qqduv3.js → CTjUtxDw6Z2I9OGc.js} +1 -1
- package/screenshot-page/assets/CUZobZ3mfNAdEisS.js +1 -0
- package/screenshot-page/assets/{DmbuCapSSCYIa3yk.js → C_OuKbe6z1it80cj.js} +1 -1
- package/screenshot-page/assets/{CpbohdgEaEsVDi9J.js → C_vPl50T1L5HWnhv.js} +1 -1
- package/screenshot-page/assets/Cbcv49b9jWyY4HKj.js +2 -0
- package/screenshot-page/assets/{CbUDukmvDZmVfhJH.js → CfkssmHURDicfYvR.js} +1 -1
- package/screenshot-page/assets/CtZFqwLoeJOvwFrl.js +42 -0
- package/screenshot-page/assets/Cz6KFmsp267l_VZS.js +1 -0
- package/screenshot-page/assets/{DDQWM8rNYCYzKa9R.js → D0koRjO2KnWQ1fNV.js} +1 -1
- package/screenshot-page/assets/D6CzedWHXTesD55R.js +1 -0
- package/screenshot-page/assets/DCP8JXEeiwAMiVD2.js +1 -0
- package/screenshot-page/assets/DEpn6VGd30cHEJOS.js +1 -0
- package/screenshot-page/assets/DQAZPADvH5lhlMnK.js +1 -0
- package/screenshot-page/assets/DQBUH0j44Vtrykua.js +13 -0
- package/screenshot-page/assets/{CqR3hGrC956TkCMj.js → DRncpwDkZZX8rL9S.js} +1 -1
- package/screenshot-page/assets/DSKOOgcJQeqIc9Us.js +3 -0
- package/screenshot-page/assets/DTrnAtpccj55fGg5.js +1 -0
- package/screenshot-page/assets/{Bj-vfAT28PK-tWWa.js → DXaM3CulPA3aPGV1.js} +2 -2
- package/screenshot-page/assets/{BFaiQZKle44Rhyou.js → D_rtIYQ7FDC2CoEn.js} +1 -1
- package/screenshot-page/assets/{BTboCICZ-951XWsi.js → DcUOAH274IbYOuK1.js} +1 -1
- package/screenshot-page/assets/{gG0AFZ45VxS_moMw.js → DdXSKhFUAsKUsQ1u.js} +1 -1
- package/screenshot-page/assets/{DyLWQxXXTw5uwPVy.js → DeyRZ5rprDbRbuf4.js} +1 -1
- package/screenshot-page/assets/{D47ePD4x1lVazNdl.js → DgtqX4DiBgkepVZZ.js} +1 -1
- package/screenshot-page/assets/Djl40tfWoPJSvqtv.js +1 -0
- package/screenshot-page/assets/{BUGXf2DEBog16Slb.js → DqXO_Zw1Cp7rAQ04.js} +2 -2
- package/screenshot-page/assets/{21oAESJyBGXeHegm.js → DtihumgXQ7ETaN0A.js} +2 -2
- package/screenshot-page/assets/DuYb_otrRZZDq6-f.js +2 -0
- package/screenshot-page/assets/{BHqg55S-4_OoAu3P.js → LYyM_ig973jLdOU0.js} +2 -2
- package/screenshot-page/assets/TCImIYUUdVD4Z35I.js +1 -0
- package/screenshot-page/assets/Tph2vYqw17-NBCtd.js +1 -0
- package/screenshot-page/assets/XgsioU5Px1T5gKAY.js +1 -0
- package/screenshot-page/assets/dQsis-90Up-pIkSq.js +4 -0
- package/screenshot-page/assets/dXn1GWWjYmuLb1HF.js +586 -0
- package/screenshot-page/assets/nM1r2xslndIMKlI2.js +2 -0
- package/screenshot-page/index.html +12 -12
- package/screenshot-page/resources/locales/@sheetxl/sdk/de/model.msg.json +82 -1
- package/screenshot-page/resources/locales/@sheetxl/sdk/en/model.msg.json +80 -1
- package/types/scripting-api.json +9967 -9497
- package/types/scripting-enums.json +27 -0
- package/types/scripting.d.ts +2282 -166
- package/assets/BBb_3gEGzmEzbTIk.js +0 -359
- package/assets/BSxTn2BhkEEeF9x_.js +0 -2346
- package/assets/CWVWdbY1B1-WLl9k.js +0 -199
- package/assets/CZTSZL3T_f-vSXqM.js +0 -7
- package/assets/DaoSWy3EFlqpZaLr.js +0 -4437
- package/assets/Dht2mcOSyYlPY32b.js +0 -14
- package/assets/DkibD_CEVePaoj_y.js +0 -7
- package/assets/jiEe5eKV3BFPBWfi.js +0 -6294
- package/screenshot-page/assets/0MTaPYjKud2Q9QG9.js +0 -1
- package/screenshot-page/assets/B2MJPcMcsuv6FekC.js +0 -1
- package/screenshot-page/assets/B4PbXdzBe9BsoZ0e.js +0 -2
- package/screenshot-page/assets/BQfe-XTIOGeUnD9B.js +0 -1
- package/screenshot-page/assets/BTMW3ukmc44U2fy7.js +0 -1
- package/screenshot-page/assets/B_W2QroTKADz3ABp.js +0 -2
- package/screenshot-page/assets/BksaQEoZr5OWq-_d.js +0 -3
- package/screenshot-page/assets/BnoVwUBEor8NgQNs.js +0 -4
- package/screenshot-page/assets/BzQ5GyiXq8gTz-H-.js +0 -1
- package/screenshot-page/assets/C2Wh2h27c7FUb8Yk.js +0 -1
- package/screenshot-page/assets/C81mK8aZKZAAS-AB.js +0 -1
- package/screenshot-page/assets/Ca6nxdhEuLLty3d7.js +0 -2
- package/screenshot-page/assets/CwqNb7JYzC03lCj0.js +0 -1
- package/screenshot-page/assets/CzhH7lTYQrYGHct6.js +0 -1
- package/screenshot-page/assets/D66vSE1ConAuENmB.js +0 -586
- package/screenshot-page/assets/DCVUZ_ayOXFwV2d_.js +0 -3
- package/screenshot-page/assets/DFE-fKq5NV7_O8V6.js +0 -1
- package/screenshot-page/assets/DK_QSosKV62NDcuT.js +0 -42
- package/screenshot-page/assets/DTFRGj188QuLKEXw.js +0 -1
- package/screenshot-page/assets/DXWWyJlMSWgDFxs1.js +0 -10
- package/screenshot-page/assets/DZDRRw-62D6Zw7qs.js +0 -1
- package/screenshot-page/assets/DeAKjatTVaZ0u_FY.js +0 -1
- package/screenshot-page/assets/Dsx0NUmGIxS7SvZ8.js +0 -1
- package/screenshot-page/assets/IRtoU5oVgBWu9rnK.js +0 -2
- package/screenshot-page/assets/Q5EKmzoJZCE81Om-.js +0 -2
- package/screenshot-page/assets/VvqAh6BWzaD5OUPF.js +0 -1
- package/screenshot-page/assets/fGlPAximvsxzPzGA.js +0 -1
- package/screenshot-page/assets/rPOkVKdPbFpTG6AY.js +0 -1
- package/screenshot-page/assets/sHBomL5R4-_px8rD.js +0 -1
- package/screenshot-page/assets/skRJ2qjA7kcmnOsh.js +0 -39
|
@@ -0,0 +1,2039 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license @sheetxl/mcp - MCP server exposing SheetXL spreadsheet operations as tools and resources. - v0.8.0-beta.17
|
|
3
|
+
*
|
|
4
|
+
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
5
|
+
* License: SheetXL EULA — https://www.sheetxl.com/eula
|
|
6
|
+
*/
|
|
7
|
+
import { p as e, tt as t } from "./CfA8o-FNret9-D6Y.js";
|
|
8
|
+
import { d as n, en as s, f as r, vt as o } from "./BJBoygm-gY68bLAP.js";
|
|
9
|
+
import { d as a } from "./MW2nt7se27FlH9Yb.js";
|
|
10
|
+
import { Bi as i, Dr as l, Dt as d, F as u, G as c, Gi as f, Hi as m, Hr as p, Ii as h, Ir as g, La as w, Oa as v, Oi as F, Pt as b, Qi as y, Qr as I, S as x, Ua as A, Vi as C, Vn as E, Xi as S, Y as P, Ya as k, Yi as M, _r as T, ai as O, at as R, dr as N, fn as L, ha as $, hr as _, ji as D, mt as V, n as U, w as H, xa as B, xn as z, yr as G, zi as j, zn as q } from "./D6ON3ZLcTAXV3fO6.js";
|
|
11
|
+
import { a as Q, i as K, n as J, o as W, r as Y } from "./BjhAYfsKC8iEbtgn.js";
|
|
12
|
+
var X = [
|
|
13
|
+
"Jan",
|
|
14
|
+
"Feb",
|
|
15
|
+
"Mar",
|
|
16
|
+
"Apr",
|
|
17
|
+
"May",
|
|
18
|
+
"Jun",
|
|
19
|
+
"Jul",
|
|
20
|
+
"Aug",
|
|
21
|
+
"Sep",
|
|
22
|
+
"Oct",
|
|
23
|
+
"Nov",
|
|
24
|
+
"Dec"
|
|
25
|
+
], Z = [
|
|
26
|
+
31,
|
|
27
|
+
29,
|
|
28
|
+
31,
|
|
29
|
+
30,
|
|
30
|
+
31,
|
|
31
|
+
30,
|
|
32
|
+
31,
|
|
33
|
+
31,
|
|
34
|
+
30,
|
|
35
|
+
31,
|
|
36
|
+
30,
|
|
37
|
+
31
|
|
38
|
+
], ee = (e, t, n, s) => {
|
|
39
|
+
if ("number" != typeof n) return null;
|
|
40
|
+
if (n < e.start) return 0;
|
|
41
|
+
const o = t - 1;
|
|
42
|
+
if (((e) => "numbers" === e.by || "days" === e.by && 1 !== (e.interval ?? 1))(e)) {
|
|
43
|
+
const s = Math.floor((n - e.start) / (e.interval ?? 1));
|
|
44
|
+
return s >= t - 2 ? n <= e.end ? t - 2 : o : s + 1;
|
|
45
|
+
}
|
|
46
|
+
if (n > e.end) return o;
|
|
47
|
+
const a = r(n, s, !0);
|
|
48
|
+
if (!a) return null;
|
|
49
|
+
switch (e.by) {
|
|
50
|
+
case "years": return Math.min(a.year - (r(e.start, s, !0)?.year ?? a.year) + 1, o);
|
|
51
|
+
case "quarters": return Math.floor((a.month - 1) / 3) + 1;
|
|
52
|
+
case "months": return a.month;
|
|
53
|
+
case "days": {
|
|
54
|
+
let e = a.day;
|
|
55
|
+
for (let t = 0; t < a.month - 1; t++) e += Z[t];
|
|
56
|
+
return e;
|
|
57
|
+
}
|
|
58
|
+
case "hours": return a.hour + 1;
|
|
59
|
+
case "minutes": return a.minute + 1;
|
|
60
|
+
case "seconds": return a.second + 1;
|
|
61
|
+
default: return null;
|
|
62
|
+
}
|
|
63
|
+
}, te = (e, t) => {
|
|
64
|
+
const n = e.fields ?? [], s = p(e.records, n.length);
|
|
65
|
+
if (!n.some(m)) return s;
|
|
66
|
+
const r = p(e.items, n.length), o = e.recordCount ?? 0, a = s.slice();
|
|
67
|
+
for (let e = 0; e < n.length; e++) {
|
|
68
|
+
const i = n[e];
|
|
69
|
+
if (!m(i)) continue;
|
|
70
|
+
const l = i.group, d = s[l.base] ?? [], u = r[l.base] ?? [], c = new Int32Array(u.length);
|
|
71
|
+
for (let e = 0; e < u.length; e++) {
|
|
72
|
+
const n = l.range ? ee(l.range, l.items.length, w(u[e]), t) : l.discrete?.[e] ?? null;
|
|
73
|
+
c[e] = n ?? -1;
|
|
74
|
+
}
|
|
75
|
+
const f = new Array(o);
|
|
76
|
+
for (let e = 0; e < o; e++) {
|
|
77
|
+
const t = c[d[e]];
|
|
78
|
+
if (void 0 === t || t < 0) return null;
|
|
79
|
+
f[e] = t;
|
|
80
|
+
}
|
|
81
|
+
a[e] = f;
|
|
82
|
+
}
|
|
83
|
+
return a;
|
|
84
|
+
}, ne = (e) => String(Number(e.toPrecision(12))), se = (e, t) => {
|
|
85
|
+
const n = r(e, t, !0);
|
|
86
|
+
return n ? `${n.month}/${n.day}/${n.year}` : String(e);
|
|
87
|
+
}, re = (e, t, n) => {
|
|
88
|
+
const s = e.range;
|
|
89
|
+
let o = 1 / 0, a = -1 / 0;
|
|
90
|
+
for (const e of t) {
|
|
91
|
+
if ("number" != typeof e) return null;
|
|
92
|
+
e < o && (o = e), e > a && (a = e);
|
|
93
|
+
}
|
|
94
|
+
if (0 === t.length) return e;
|
|
95
|
+
const i = { ...s };
|
|
96
|
+
s.fixedStart || (i.start = o), s.fixedEnd || (i.end = "numbers" !== s.by && Number.isInteger(a) ? a + 1 : a);
|
|
97
|
+
const { inner: l, endText: d } = ((e, t) => {
|
|
98
|
+
const { start: n, end: s } = e, o = e.interval ?? 1, a = se(s, t), i = (e, t) => Array.from({ length: e }, (e, n) => t(n));
|
|
99
|
+
switch (e.by) {
|
|
100
|
+
case "numbers": {
|
|
101
|
+
const e = Math.max(1, Math.ceil(Number(((s - n) / o).toPrecision(12)))), t = Number.isInteger(Number(((s - n) / o).toPrecision(12))), r = Number.isInteger(n) && Number.isInteger(o);
|
|
102
|
+
return {
|
|
103
|
+
inner: i(e, (a) => {
|
|
104
|
+
const i = n + a * o, l = a === e - 1 && t ? s : r ? i + o - 1 : i + o;
|
|
105
|
+
return `${ne(i)}-${ne(l)}`;
|
|
106
|
+
}),
|
|
107
|
+
endText: ne(t ? s : n + e * o)
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
case "days":
|
|
111
|
+
if (1 === o) {
|
|
112
|
+
const e = [];
|
|
113
|
+
return Z.forEach((t, n) => {
|
|
114
|
+
for (let s = 1; s <= t; s++) e.push(`${s}-${X[n]}`);
|
|
115
|
+
}), {
|
|
116
|
+
inner: e,
|
|
117
|
+
endText: a
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
inner: i(Math.max(1, Math.ceil((s - n) / o)), (e) => {
|
|
122
|
+
const r = n + e * o;
|
|
123
|
+
return `${se(r, t)} - ${se(Math.min(r + o - 1, s), t)}`;
|
|
124
|
+
}),
|
|
125
|
+
endText: a
|
|
126
|
+
};
|
|
127
|
+
case "months": return {
|
|
128
|
+
inner: X.slice(),
|
|
129
|
+
endText: a
|
|
130
|
+
};
|
|
131
|
+
case "quarters": return {
|
|
132
|
+
inner: [
|
|
133
|
+
"Qtr1",
|
|
134
|
+
"Qtr2",
|
|
135
|
+
"Qtr3",
|
|
136
|
+
"Qtr4"
|
|
137
|
+
],
|
|
138
|
+
endText: a
|
|
139
|
+
};
|
|
140
|
+
case "years": {
|
|
141
|
+
const e = r(n, t)?.year ?? 0;
|
|
142
|
+
return {
|
|
143
|
+
inner: i((r(s, t)?.year ?? e) - e + 1, (t) => String(e + t)),
|
|
144
|
+
endText: a
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
case "hours": return {
|
|
148
|
+
inner: i(24, (e) => `${e % 12 == 0 ? 12 : e % 12} ${e < 12 ? "AM" : "PM"}`),
|
|
149
|
+
endText: a
|
|
150
|
+
};
|
|
151
|
+
default: return {
|
|
152
|
+
inner: i(60, (e) => `:${String(e).padStart(2, "0")}`),
|
|
153
|
+
endText: a
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
})(i, n), u = "numbers" === i.by ? ne(i.start) : se(i.start, n);
|
|
157
|
+
return {
|
|
158
|
+
...e,
|
|
159
|
+
range: i,
|
|
160
|
+
items: [
|
|
161
|
+
`<${u}`,
|
|
162
|
+
...l,
|
|
163
|
+
`>${d}`
|
|
164
|
+
]
|
|
165
|
+
};
|
|
166
|
+
}, oe = (e, t) => {
|
|
167
|
+
let n = "", s = 0;
|
|
168
|
+
const r = () => {
|
|
169
|
+
let t = "";
|
|
170
|
+
for (s++; s < e.length;) {
|
|
171
|
+
if ("'" === e[s]) {
|
|
172
|
+
if ("'" !== e[s + 1]) {
|
|
173
|
+
s++;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
s++;
|
|
177
|
+
}
|
|
178
|
+
t += e[s++];
|
|
179
|
+
}
|
|
180
|
+
return t;
|
|
181
|
+
};
|
|
182
|
+
for (; s < e.length;) {
|
|
183
|
+
const o = e[s];
|
|
184
|
+
if ("\"" === o) {
|
|
185
|
+
const t = /^"(?:[^"]|"")*"/.exec(e.slice(s)), r = t ? t[0] : e.slice(s);
|
|
186
|
+
n += r, s += r.length;
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (/[0-9.]/.test(o)) {
|
|
190
|
+
const t = /^[0-9.]+(?:[eE][+-]?[0-9]+)?/.exec(e.slice(s))[0];
|
|
191
|
+
n += t, s += t.length;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const a = "'" === o, i = a ? null : /^[\p{L}_][\p{L}\p{N}_.]*/u.exec(e.slice(s))?.[0];
|
|
195
|
+
if (!a && !i) {
|
|
196
|
+
n += o, s++;
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
const l = a ? r() : i;
|
|
200
|
+
if (a || (s += l.length), "(" !== e[s]) {
|
|
201
|
+
if ("[" === e[s]) {
|
|
202
|
+
s++;
|
|
203
|
+
let o = "";
|
|
204
|
+
for ("'" === e[s] && (o = r()); s < e.length && "]" !== e[s];) o += e[s++];
|
|
205
|
+
s++;
|
|
206
|
+
const a = t(l, o);
|
|
207
|
+
if (null === a) return null;
|
|
208
|
+
n += a;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
n += t(l, null) ?? (a ? `'${l.replace(/'/g, "''")}'` : l);
|
|
212
|
+
} else n += l;
|
|
213
|
+
}
|
|
214
|
+
return n;
|
|
215
|
+
}, ae = (e) => {
|
|
216
|
+
let t = "";
|
|
217
|
+
for (let n = e + 1; n > 0; n = Math.floor((n - 1) / 26)) t = String.fromCharCode(65 + (n - 1) % 26) + t;
|
|
218
|
+
return `${t}1`;
|
|
219
|
+
}, ie = (e, t) => ({
|
|
220
|
+
rowStart: 0,
|
|
221
|
+
colStart: e,
|
|
222
|
+
rowEnd: t - 1,
|
|
223
|
+
colEnd: e
|
|
224
|
+
}), le = (e, t) => {
|
|
225
|
+
const n = [];
|
|
226
|
+
for (let s = 0; s < t; s++) n.push([s, [[0, e.map((e) => e[s] ?? null)]]]);
|
|
227
|
+
return n;
|
|
228
|
+
}, de = (e, t) => {
|
|
229
|
+
const n = t.fields ?? [], s = [], r = [], o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = (e, t) => {
|
|
230
|
+
if (o.has(e)) return !0;
|
|
231
|
+
if (t.includes(e)) return !1;
|
|
232
|
+
const l = [];
|
|
233
|
+
oe(n[e].formula, (e) => {
|
|
234
|
+
const t = n.findIndex((t) => h(t.name, e));
|
|
235
|
+
return t >= 0 && l.push(t), t >= 0 ? "" : null;
|
|
236
|
+
});
|
|
237
|
+
for (const r of l) if (B(n[r])) {
|
|
238
|
+
if (!i(r, [...t, e])) return !1;
|
|
239
|
+
} else s.includes(r) || s.push(r);
|
|
240
|
+
return o.set(e, r.length), a.set(e, n[e].formula), r.push({
|
|
241
|
+
field: e,
|
|
242
|
+
expression: ""
|
|
243
|
+
}), !0;
|
|
244
|
+
}, l = [];
|
|
245
|
+
for (const [t, s] of (e.dataFields ?? []).entries()) if (B(n[s.field])) {
|
|
246
|
+
if (!i(s.field, [])) return null;
|
|
247
|
+
l.push({
|
|
248
|
+
data: t,
|
|
249
|
+
formula: o.get(s.field)
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
const d = (e, t) => {
|
|
253
|
+
if (null !== t) return null;
|
|
254
|
+
const r = n.findIndex((t) => h(t.name, e));
|
|
255
|
+
return r >= 0 ? ae(B(n[a = r]) ? s.length + o.get(a) : s.indexOf(a)) : null;
|
|
256
|
+
var a;
|
|
257
|
+
};
|
|
258
|
+
for (const e of r) {
|
|
259
|
+
const t = oe(a.get(e.field), d);
|
|
260
|
+
if (null === t) return null;
|
|
261
|
+
e.expression = t;
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
operands: s,
|
|
265
|
+
formulas: r,
|
|
266
|
+
measures: l
|
|
267
|
+
};
|
|
268
|
+
}, ue = /* @__PURE__ */ new Set([
|
|
269
|
+
"sum",
|
|
270
|
+
"count",
|
|
271
|
+
"countNums"
|
|
272
|
+
]), ce = -2, fe = 4294967295, me = 4294967295, pe = {
|
|
273
|
+
sum: 0,
|
|
274
|
+
countNums: 1,
|
|
275
|
+
count: 11,
|
|
276
|
+
average: 3,
|
|
277
|
+
min: 4,
|
|
278
|
+
max: 5,
|
|
279
|
+
product: 6,
|
|
280
|
+
var: 7,
|
|
281
|
+
varp: 8,
|
|
282
|
+
stdDev: 9,
|
|
283
|
+
stdDevp: 10
|
|
284
|
+
}, he = [
|
|
285
|
+
"sum",
|
|
286
|
+
"countA",
|
|
287
|
+
"avg",
|
|
288
|
+
"max",
|
|
289
|
+
"min",
|
|
290
|
+
"product",
|
|
291
|
+
"count",
|
|
292
|
+
"stdDev",
|
|
293
|
+
"stdDevP",
|
|
294
|
+
"var",
|
|
295
|
+
"varP"
|
|
296
|
+
], ge = {
|
|
297
|
+
sum: 0,
|
|
298
|
+
countA: 13,
|
|
299
|
+
avg: 3,
|
|
300
|
+
max: 5,
|
|
301
|
+
min: 4,
|
|
302
|
+
product: 6,
|
|
303
|
+
count: 12,
|
|
304
|
+
stdDev: 9,
|
|
305
|
+
stdDevP: 10,
|
|
306
|
+
var: 7,
|
|
307
|
+
varP: 8
|
|
308
|
+
}, we = {
|
|
309
|
+
sum: "Sum",
|
|
310
|
+
countA: "Count",
|
|
311
|
+
avg: "Average",
|
|
312
|
+
max: "Max",
|
|
313
|
+
min: "Min",
|
|
314
|
+
product: "Product",
|
|
315
|
+
count: "Count",
|
|
316
|
+
stdDev: "StdDev",
|
|
317
|
+
stdDevP: "StdDevp",
|
|
318
|
+
var: "Var",
|
|
319
|
+
varP: "Varp"
|
|
320
|
+
}, ve = (e) => {
|
|
321
|
+
const t = e?.subtotals;
|
|
322
|
+
return t && !t.includes("default") ? he.filter((e) => t.includes(e)) : [];
|
|
323
|
+
}, Fe = (e, t) => {
|
|
324
|
+
const n = new Set(t.flatMap((t) => t.field === ce ? [] : ve(e.fields?.[t.field])));
|
|
325
|
+
return he.filter((e) => n.has(e));
|
|
326
|
+
}, be = (e, t) => {
|
|
327
|
+
const n = t.filter((e) => e.field !== ce).map((e) => e.field);
|
|
328
|
+
return !(n.length < 2 || t[t.length - 1].field === ce || n.slice(0, -1).some((t) => e.fields?.[t]?.items?.some((e) => e.collapsed)) || e.filters?.some((e) => void 0 !== e.dataField && n.includes(e.field)));
|
|
329
|
+
}, ye = {
|
|
330
|
+
normal: 0,
|
|
331
|
+
percentOfTotal: 1,
|
|
332
|
+
percentOfRow: 2,
|
|
333
|
+
percentOfCol: 3,
|
|
334
|
+
index: 4,
|
|
335
|
+
percentOfParentRow: 5,
|
|
336
|
+
percentOfParentCol: 6,
|
|
337
|
+
percentOfParent: 7,
|
|
338
|
+
runTotal: 8,
|
|
339
|
+
percentOfRunningTotal: 9,
|
|
340
|
+
rankAscending: 10,
|
|
341
|
+
rankDescending: 11,
|
|
342
|
+
difference: 12,
|
|
343
|
+
percent: 13,
|
|
344
|
+
percentDiff: 14
|
|
345
|
+
}, Ie = (e, t, n, s) => {
|
|
346
|
+
const r = c.peek(), o = e.fields, a = t.fields;
|
|
347
|
+
if (!r || !o || !a || o.length !== a.length) return null;
|
|
348
|
+
if (q(e)) return {
|
|
349
|
+
cells: [],
|
|
350
|
+
...V,
|
|
351
|
+
rowPageCount: 0,
|
|
352
|
+
columnPageCount: 0,
|
|
353
|
+
header: j(e),
|
|
354
|
+
rowLines: [],
|
|
355
|
+
columnLines: [],
|
|
356
|
+
viewValues: [],
|
|
357
|
+
firstKey: null,
|
|
358
|
+
...s?.roles ? { roles: /* @__PURE__ */ new Map() } : {}
|
|
359
|
+
};
|
|
360
|
+
const i = D(e, a), l = i ? s?.filters : null;
|
|
361
|
+
if (i && !l) return null;
|
|
362
|
+
const d = o.some((e) => e.items?.some((e) => e.calculated));
|
|
363
|
+
if (d && !l?.calculatedRecords) return null;
|
|
364
|
+
const u = de(e, t);
|
|
365
|
+
if (!u || u.measures.length > 0 && !l?.fieldValues) return null;
|
|
366
|
+
if ((e.dataFields ?? []).some((e) => void 0 === ye[e.showDataAs ?? "normal"] || void 0 === pe[e.subtotal ?? "sum"])) return null;
|
|
367
|
+
const f = xe(e, t, n, l?.calculatedRecords, u.operands);
|
|
368
|
+
if (!f) return null;
|
|
369
|
+
const { items: p, records: h, values: g, n: w } = f, v = (e) => !!e && (!e.noRecords || m(e)), F = e.form ?? "compact", b = (e) => {
|
|
370
|
+
const t = [];
|
|
371
|
+
for (const n of e ?? []) {
|
|
372
|
+
if (n === ce) {
|
|
373
|
+
t.push({
|
|
374
|
+
field: n,
|
|
375
|
+
form: F
|
|
376
|
+
});
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
const e = o[n], s = e?.subtotals;
|
|
380
|
+
if (!e || !v(a[n])) return null;
|
|
381
|
+
if (d && s && s.some((e) => "default" !== e)) return null;
|
|
382
|
+
t.push({
|
|
383
|
+
field: n,
|
|
384
|
+
form: e.form ?? "compact"
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
return t;
|
|
388
|
+
}, y = b(e.rowFields), I = b(e.columnFields), x = e.pageFields ?? [];
|
|
389
|
+
if (!y || !I || x.some((e) => !v(a[e.field]))) return null;
|
|
390
|
+
const C = A(e, s?.slicerFields);
|
|
391
|
+
return C.pageFields?.some((e) => !v(a[e.field])) ? null : Te(e, t, p, y, I, Se(r, C, p, h, g, y, I, w, l?.keep, l?.records, u.operands.length, l?.fieldValues, !0), n, !0 === s?.roles, "columns" === s?.cellOrder);
|
|
392
|
+
}, xe = (e, t, n, s, r = []) => {
|
|
393
|
+
const o = t.fields?.length ?? 0, a = G(t);
|
|
394
|
+
if (!t.records) return null;
|
|
395
|
+
const i = te(t, n.isDate1904());
|
|
396
|
+
if (!i) return null;
|
|
397
|
+
const l = !0 === t.fields?.some(m), d = l ? p(t.items, o) : a, u = l ? p(t.records, o) : i, c = t.recordCount ?? 0, f = s?.count ?? 0, h = c + f, g = (e, n) => {
|
|
398
|
+
const s = !t.fields?.[e]?.noRecords, r = s ? u[e] : i[e] ?? [], o = s ? d[e] : a[e], l = new Array(h);
|
|
399
|
+
for (let e = 0; e < c; e++) l[e] = w(o[r[e]]);
|
|
400
|
+
for (let e = 0; e < f; e++) l[c + e] = n?.[e] ?? null;
|
|
401
|
+
return l;
|
|
402
|
+
}, v = [...(e.dataFields ?? []).map((e, t) => g(e.field, s?.values[t])), ...r.map((e) => g(e))];
|
|
403
|
+
return {
|
|
404
|
+
items: a,
|
|
405
|
+
records: s ? i.map((e, t) => e.concat(s.ids[t] ?? [])) : i,
|
|
406
|
+
values: v,
|
|
407
|
+
n: h
|
|
408
|
+
};
|
|
409
|
+
}, Ae = async (e, t, n, s, r, o, a, i, l) => {
|
|
410
|
+
const d = c.peek(), u = e.dataFields?.[r];
|
|
411
|
+
if (!d || !e.fields || !u || void 0 === pe[u.subtotal ?? "sum"]) return null;
|
|
412
|
+
const f = [e.rowFields, e.columnFields].map((e) => (e ?? []).filter((e) => e !== ce)), m = f.findIndex((e) => e.includes(s)), p = f[m];
|
|
413
|
+
if (!p) return null;
|
|
414
|
+
const h = p.slice(0, p.indexOf(s)), g = e.fields.map((e) => {
|
|
415
|
+
const { blankRowAfter: t, showItemsWithNoData: n, sort: s, ...r } = e;
|
|
416
|
+
return {
|
|
417
|
+
...r,
|
|
418
|
+
items: e.items?.map((e) => {
|
|
419
|
+
if (!e.collapsed) return e;
|
|
420
|
+
const { collapsed: t, ...n } = e;
|
|
421
|
+
return n;
|
|
422
|
+
})
|
|
423
|
+
};
|
|
424
|
+
}), { columnGrandTotals: w, ...v } = e, { showDataAs: F, ...b } = u, y = {
|
|
425
|
+
...v,
|
|
426
|
+
fields: g,
|
|
427
|
+
rowFields: [...h, s],
|
|
428
|
+
columnFields: [],
|
|
429
|
+
dataFields: [b],
|
|
430
|
+
rowGrandTotals: !1
|
|
431
|
+
}, I = i ? {
|
|
432
|
+
...i,
|
|
433
|
+
values: [i.values[r] ?? []]
|
|
434
|
+
} : i, x = de(y, t);
|
|
435
|
+
if (!x || x.measures.length > 0 && !l) return null;
|
|
436
|
+
const A = xe(y, t, n, I, x.operands);
|
|
437
|
+
if (!A) return null;
|
|
438
|
+
const { items: C, records: E, values: S, n: P } = A, k = y.rowFields.map((e) => ({
|
|
439
|
+
field: e,
|
|
440
|
+
form: "compact"
|
|
441
|
+
}));
|
|
442
|
+
let M;
|
|
443
|
+
if (a) {
|
|
444
|
+
const e = 0 === m ? 1 : 2;
|
|
445
|
+
M = new Uint8Array(P);
|
|
446
|
+
for (let t = 0; t < P; t++) {
|
|
447
|
+
const n = a[t];
|
|
448
|
+
M[t] = (n & e ? 1 : 0) | (3 === n ? 2 : 0);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
const T = x.measures.length > 0 ? await Ee(d, x, y, C, E, S, k, [], P, o, M, l) : void 0, O = Se(d, y, C, E, S, k, [], P, o, M, x.operands.length, T), R = (t, n) => e.fields[t].items?.[n]?.item ?? n, N = /* @__PURE__ */ new Map(), L = O.columns.length;
|
|
452
|
+
return O.rows.forEach((e, t) => {
|
|
453
|
+
if (0 !== e.kind || e.path.length !== h.length + 1) return;
|
|
454
|
+
const n = h.map((t, n) => R(t, e.path[n])).join(",");
|
|
455
|
+
let r = N.get(n);
|
|
456
|
+
r || N.set(n, r = {
|
|
457
|
+
ids: [],
|
|
458
|
+
totals: []
|
|
459
|
+
}), r.ids.push(R(s, e.path[h.length])), r.totals.push(O.values[t * L]);
|
|
460
|
+
}), {
|
|
461
|
+
outer: h,
|
|
462
|
+
groups: N,
|
|
463
|
+
records: E
|
|
464
|
+
};
|
|
465
|
+
}, Ce = (e, t, n) => {
|
|
466
|
+
const s = new Uint32Array(t).fill(fe), r = new Uint8Array(t), o = e.items;
|
|
467
|
+
if (o) o.forEach((e, n) => {
|
|
468
|
+
void 0 === e.item || void 0 !== e.type || e.item >= t || (s[e.item] = n, r[e.item] = (e.hidden ? 1 : 0) | (e.collapsed ? 2 : 0));
|
|
469
|
+
});
|
|
470
|
+
else for (let e = 0; e < t; e++) s[e] = e;
|
|
471
|
+
if (n) for (let e = 0; e < t; e++) n[e] || (r[e] |= 1);
|
|
472
|
+
return {
|
|
473
|
+
ranks: s,
|
|
474
|
+
flags: r
|
|
475
|
+
};
|
|
476
|
+
}, Ee = async (e, t, n, s, r, o, i, l, d, u, c, f) => {
|
|
477
|
+
const { request: m, errors: p } = Pe(e, n, s, r, o, i, l, d, u, c, t.operands.length);
|
|
478
|
+
let h = 0;
|
|
479
|
+
const g = [];
|
|
480
|
+
try {
|
|
481
|
+
const s = m.operands(0, p.codeOf(a.BuiltIn.NA), p.codeOf(a.BuiltIn.Null));
|
|
482
|
+
try {
|
|
483
|
+
h = s.cell_count();
|
|
484
|
+
const r = n.dataFields?.length ?? 0;
|
|
485
|
+
t.operands.forEach((t, n) => {
|
|
486
|
+
const o = s.values(r + n);
|
|
487
|
+
try {
|
|
488
|
+
const t = K(e.wasm_memory().buffer, o, p), n = new Array(h);
|
|
489
|
+
for (let e = 0; e < h; e++) n[e] = t(e);
|
|
490
|
+
g.push(n);
|
|
491
|
+
} finally {
|
|
492
|
+
o.free();
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
} finally {
|
|
496
|
+
s.free();
|
|
497
|
+
}
|
|
498
|
+
} finally {
|
|
499
|
+
m.free();
|
|
500
|
+
}
|
|
501
|
+
return (async (e, t, n, s) => {
|
|
502
|
+
const r = n + 1, o = t.map((e) => {
|
|
503
|
+
const t = new Array(r);
|
|
504
|
+
for (let s = 0; s < n; s++) t[s] = e[s] ?? 0;
|
|
505
|
+
return t[n] = 0, t;
|
|
506
|
+
}), a = await s.evaluateBatch({
|
|
507
|
+
values: le(o, r),
|
|
508
|
+
formulas: e.formulas.map(({ expression: e }, n) => ({
|
|
509
|
+
expression: e,
|
|
510
|
+
coords: ie(t.length + n, r)
|
|
511
|
+
}))
|
|
512
|
+
}), i = /* @__PURE__ */ new Map();
|
|
513
|
+
for (const { data: t, formula: n } of e.measures) {
|
|
514
|
+
const e = new Array(r);
|
|
515
|
+
for (let t = 0; t < r; t++) e[t] = a[n].getValueAt(t, 0) ?? 0;
|
|
516
|
+
i.set(t, e);
|
|
517
|
+
}
|
|
518
|
+
return i;
|
|
519
|
+
})(t, g, h, f);
|
|
520
|
+
}, Se = (e, t, n, s, r, o, i, l, d, u, c = 0, f, m = !1) => {
|
|
521
|
+
const { request: p, errors: h } = Pe(e, t, n, s, r, o, i, l, d, u, c, f, m), g = h.codeOf(a.BuiltIn.NA), w = h.codeOf(a.BuiltIn.Null), v = p.lay_out(0, g, w);
|
|
522
|
+
try {
|
|
523
|
+
const n = ke(v.row_lines(), v.row_stride()), s = ke(v.column_lines(), v.column_stride()), r = v.states(), a = v.values();
|
|
524
|
+
try {
|
|
525
|
+
const l = K(e.wasm_memory().buffer, a, h), d = new Array(r.length);
|
|
526
|
+
for (let e = 0; e < r.length; e++) d[e] = 0 === r[e] ? l(e) : null;
|
|
527
|
+
return {
|
|
528
|
+
rows: n,
|
|
529
|
+
columns: s,
|
|
530
|
+
states: r,
|
|
531
|
+
values: d,
|
|
532
|
+
functions: m ? Fe(t, [...o, ...i]) : []
|
|
533
|
+
};
|
|
534
|
+
} finally {
|
|
535
|
+
a.free();
|
|
536
|
+
}
|
|
537
|
+
} finally {
|
|
538
|
+
v.free(), p.free();
|
|
539
|
+
}
|
|
540
|
+
}, Pe = (e, t, n, s, r, o, a, i, l, d, u = 0, c, f = !1) => {
|
|
541
|
+
const m = t.fields, p = new e.LayoutRequest(i), h = f ? Fe(t, [...o, ...a]) : [], g = [], w = (e, s) => {
|
|
542
|
+
for (const { field: r, form: o } of s) {
|
|
543
|
+
if (r === ce) {
|
|
544
|
+
p.add_values_slot(e, "tabular" === o);
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
const a = m[r], i = a.subtotals, l = (!i || i.includes("default") ? 1 : 0) | (!1 !== a.subtotalsOnTop ? 2 : 0) | (a.blankRowAfter ? 4 : 0) | (a.showItemsWithNoData ? 8 : 0) | ("tabular" === o ? 16 : 0), d = p.add_field(e, n[r].length, l), u = a.sort;
|
|
548
|
+
void 0 !== u?.dataField && p.set_field_sort(e, d, u.dataField, "descending" === u.order, new Uint32Array((u.scope?.items ?? []).map((e) => e.item)));
|
|
549
|
+
const c = f ? ve(a) : [];
|
|
550
|
+
if (c.length > 0) {
|
|
551
|
+
const n = s[s.length - 1].field === r && be(t, s);
|
|
552
|
+
p.set_field_functions(e, d, new Uint32Array(c.map((e) => h.indexOf(e))), n);
|
|
553
|
+
}
|
|
554
|
+
g.push({
|
|
555
|
+
axis: e,
|
|
556
|
+
slot: d,
|
|
557
|
+
field: r
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
w(0, o), w(1, a);
|
|
562
|
+
const v = (t.pageFields ?? []).map((e) => ({
|
|
563
|
+
page: e,
|
|
564
|
+
index: p.add_page(n[e.field].length)
|
|
565
|
+
})), F = r.map(() => p.add_values(127)), b = t.dataFields ?? [];
|
|
566
|
+
b.forEach((e, t) => {
|
|
567
|
+
p.add_measure(t, pe[e.subtotal ?? "sum"]);
|
|
568
|
+
const n = ye[e.showDataAs ?? "normal"];
|
|
569
|
+
if (!n) return;
|
|
570
|
+
let s = 2, r = o.findIndex((t) => t.field === e.baseField);
|
|
571
|
+
r >= 0 ? s = 0 : (r = a.findIndex((t) => t.field === e.baseField), r >= 0 && (s = 1));
|
|
572
|
+
const i = "previous" === e.baseItem ? 4294967294 : "next" === e.baseItem ? 4294967295 : e.baseItem ?? 0;
|
|
573
|
+
p.set_show_as(t, n, s, Math.max(r, 0), i);
|
|
574
|
+
});
|
|
575
|
+
for (let e = 0; e < u; e++) p.add_measure(b.length + e, pe.sum);
|
|
576
|
+
u > 0 && p.set_operand_measures(u);
|
|
577
|
+
for (const e of h) b.forEach((t, n) => p.add_measure(n, ge[e]));
|
|
578
|
+
h.length > 0 && p.set_functions(h.length);
|
|
579
|
+
const y = [...c ?? []].map(([e, t]) => ({
|
|
580
|
+
column: t,
|
|
581
|
+
ptr: p.add_calculated(e, t.length - 1, 127)
|
|
582
|
+
}));
|
|
583
|
+
p.set_grand(!1 !== t.rowGrandTotals, !1 !== t.columnGrandTotals);
|
|
584
|
+
const I = d ? p.record_keep() : null, x = e.wasm_memory().buffer;
|
|
585
|
+
d && null !== I && new Uint8Array(x, I, i).set(d.subarray(0, i));
|
|
586
|
+
for (const { axis: e, slot: t, field: r } of g) {
|
|
587
|
+
const o = n[r].length;
|
|
588
|
+
new Uint32Array(x, p.field_ids(e, t), i).set(s[r].slice(0, i));
|
|
589
|
+
const { ranks: a, flags: d } = Ce(m[r], o, l?.get(r));
|
|
590
|
+
new Uint32Array(x, p.field_ranks(e, t), o).set(a), new Uint8Array(x, p.field_flags(e, t), o).set(d);
|
|
591
|
+
}
|
|
592
|
+
for (const { page: e, index: t } of v) {
|
|
593
|
+
const r = n[e.field].length;
|
|
594
|
+
new Uint32Array(x, p.page_ids(t), i).set(s[e.field].slice(0, i));
|
|
595
|
+
const { ranks: o, flags: a } = Ce(m[e.field], r), d = new Uint8Array(x, p.page_keep(t), r), u = void 0 !== e.item ? m[e.field].items?.[e.item]?.item : void 0, c = e.slicer ? l?.get(e.field) : void 0;
|
|
596
|
+
for (let t = 0; t < r; t++) {
|
|
597
|
+
const n = void 0 !== u ? t === u : !(o[t] === fe && m[e.field].items || 1 & a[t]);
|
|
598
|
+
d[t] = !n || c && 0 === c[t] ? 0 : 1;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
const A = new J();
|
|
602
|
+
F.forEach((e, t) => {
|
|
603
|
+
const n = {
|
|
604
|
+
doubles: new Float64Array(x, e, i),
|
|
605
|
+
ints: new Int32Array(x, e, 2 * i),
|
|
606
|
+
types: new Uint8Array(x, e + 8 * i, i)
|
|
607
|
+
}, s = {
|
|
608
|
+
ok: !0,
|
|
609
|
+
numeric: !0
|
|
610
|
+
}, o = r[t];
|
|
611
|
+
for (let e = 0; e < i; e++) Y(n, e, o[e], A, s);
|
|
612
|
+
});
|
|
613
|
+
for (const { column: e, ptr: t } of y) {
|
|
614
|
+
const n = e.length, s = {
|
|
615
|
+
doubles: new Float64Array(x, t, n),
|
|
616
|
+
ints: new Int32Array(x, t, 2 * n),
|
|
617
|
+
types: new Uint8Array(x, t + 8 * n, n)
|
|
618
|
+
}, r = {
|
|
619
|
+
ok: !0,
|
|
620
|
+
numeric: !0
|
|
621
|
+
};
|
|
622
|
+
for (let t = 0; t < n; t++) Y(s, t, e[t], A, r);
|
|
623
|
+
}
|
|
624
|
+
return {
|
|
625
|
+
request: p,
|
|
626
|
+
errors: A
|
|
627
|
+
};
|
|
628
|
+
}, ke = (e, t) => {
|
|
629
|
+
const n = [], s = 7 + t;
|
|
630
|
+
for (let t = 0; t + s <= e.length; t += s) {
|
|
631
|
+
const s = e[t + 1], r = e[t + 3], o = e[t + 5];
|
|
632
|
+
n.push({
|
|
633
|
+
kind: e[t],
|
|
634
|
+
path: Array.from(e.subarray(t + 7, t + 7 + s)),
|
|
635
|
+
data: r === me ? null : r,
|
|
636
|
+
function: o === me ? null : o,
|
|
637
|
+
across: 1 === e[t + 6]
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
return n;
|
|
641
|
+
}, Me = (e, t) => {
|
|
642
|
+
let n = [];
|
|
643
|
+
return e.map((e) => {
|
|
644
|
+
const s = { items: [] };
|
|
645
|
+
if (0 === e.kind) {
|
|
646
|
+
let t = 0;
|
|
647
|
+
for (; t < e.path.length - 1 && t < n.length && e.path[t] === n[t];) t++;
|
|
648
|
+
t > 0 && (s.repeat = t), s.items = e.path.slice(t), n = e.path;
|
|
649
|
+
} else s.type = 1 === e.kind ? null !== e.function ? t[e.function] : "default" : 2 === e.kind ? "grand" : "blank", s.items = 2 === e.kind ? [0] : e.path.slice();
|
|
650
|
+
return null !== e.data && e.data > 0 && (s.dataField = e.data), s;
|
|
651
|
+
});
|
|
652
|
+
}, Te = (e, t, n, r, o, i, d, u, c) => {
|
|
653
|
+
const m = e.fields, p = t.fields, h = e.dataFields ?? [], F = (t) => t === ce ? e.valuesCaption ?? "Values" : m[t].name ?? p[t].name, b = (e, t) => {
|
|
654
|
+
if (e === ce) return h[t]?.name ?? "";
|
|
655
|
+
const s = m[e].items?.[t];
|
|
656
|
+
if (void 0 !== s?.name) return s.name;
|
|
657
|
+
const r = w(n[e][s?.item ?? t]);
|
|
658
|
+
return null === r ? v : r;
|
|
659
|
+
}, y = (e, t) => {
|
|
660
|
+
const n = b(e, t);
|
|
661
|
+
if ("number" == typeof n) {
|
|
662
|
+
const r = m[e].items?.[t]?.item ?? t, o = void 0 === (m[e].numberFormat ?? p[e].numberFormat) && I(p[e], r);
|
|
663
|
+
return s(d, o ? l(g(p[e], r), d) : ((e) => l(m[e].numberFormat ?? p[e].numberFormat, d))(e), n);
|
|
664
|
+
}
|
|
665
|
+
return a.isError(n) ? n.getLabel() : "boolean" == typeof n ? n ? "TRUE" : "FALSE" : String(n);
|
|
666
|
+
}, x = (e) => {
|
|
667
|
+
if (void 0 !== e.item) return b(e.field, e.item);
|
|
668
|
+
const t = m[e.field].items ?? [];
|
|
669
|
+
if (!t.some((e) => e.hidden)) return "(All)";
|
|
670
|
+
const n = t.flatMap((e, t) => k(e) && !e.hidden ? [t] : []);
|
|
671
|
+
return 1 === n.length ? b(e.field, n[0]) : "(Multiple Items)";
|
|
672
|
+
}, A = e.grandTotalCaption ?? "Grand Total", S = u ? /* @__PURE__ */ new Map() : null, P = (e, t) => e === ce ? {
|
|
673
|
+
kind: "dataCaption",
|
|
674
|
+
data: t
|
|
675
|
+
} : {
|
|
676
|
+
kind: "item",
|
|
677
|
+
field: e,
|
|
678
|
+
rank: t
|
|
679
|
+
}, M = (e) => e === ce ? null : {
|
|
680
|
+
kind: "fieldCaption",
|
|
681
|
+
field: e
|
|
682
|
+
}, T = (e, t) => 2 === e.kind && t === A ? { kind: "grandTotal" } : null, O = 0 === r.length && 0 === o.length && 0 === h.length, R = O ? {
|
|
683
|
+
firstHeaderRow: 0,
|
|
684
|
+
firstDataRow: 0,
|
|
685
|
+
firstDataCol: 0
|
|
686
|
+
} : j(e), N = O ? [] : Me(i.rows, i.functions), L = O ? [] : Me(i.columns, i.functions), $ = f({
|
|
687
|
+
...e,
|
|
688
|
+
header: R,
|
|
689
|
+
rowLines: N,
|
|
690
|
+
columnLines: L
|
|
691
|
+
}), D = i.columns.length, V = (e) => "row" === e ? r : o, U = (t) => {
|
|
692
|
+
switch (t.kind) {
|
|
693
|
+
case "pageCaption": {
|
|
694
|
+
const n = e.pageFields[t.page].field;
|
|
695
|
+
return [F(n), {
|
|
696
|
+
kind: "fieldCaption",
|
|
697
|
+
field: n
|
|
698
|
+
}];
|
|
699
|
+
}
|
|
700
|
+
case "pageItem": {
|
|
701
|
+
const n = e.pageFields[t.page];
|
|
702
|
+
return [x(n), {
|
|
703
|
+
kind: "pageItem",
|
|
704
|
+
page: t.page
|
|
705
|
+
}];
|
|
706
|
+
}
|
|
707
|
+
case "dataCaption": return [h[t.data]?.name ?? null, {
|
|
708
|
+
kind: "dataCaption",
|
|
709
|
+
data: t.data
|
|
710
|
+
}];
|
|
711
|
+
case "rowHeader": return [r.every((e) => e.field === ce) ? e.valuesCaption ?? "Values" : e.rowHeaderCaption ?? "Row Labels", { kind: "rowHeader" }];
|
|
712
|
+
case "columnHeader": return [e.columnHeaderCaption ?? "Column Labels", { kind: "columnHeader" }];
|
|
713
|
+
case "fieldCaption": {
|
|
714
|
+
const e = V(t.axis)[t.level].field;
|
|
715
|
+
return [F(e), M(e)];
|
|
716
|
+
}
|
|
717
|
+
case "label": {
|
|
718
|
+
const e = V(t.axis)[t.level].field, n = t.line.path[t.level];
|
|
719
|
+
return [b(e, n), P(e, n)];
|
|
720
|
+
}
|
|
721
|
+
case "total": {
|
|
722
|
+
const e = ("row" === t.axis ? i.rows : i.columns)[t.line.index], n = ((e, t) => {
|
|
723
|
+
const n = e.findIndex((e) => e.field === ce) >= t.path.length && null !== t.data, s = n ? h[t.data]?.name ?? "" : "";
|
|
724
|
+
if (2 === t.kind) return n ? `Total ${s}` : A;
|
|
725
|
+
const r = t.path.length - 1, o = e[r].field, a = y(o, t.path[r]);
|
|
726
|
+
if (null !== t.function) {
|
|
727
|
+
const e = we[i.functions[t.function]];
|
|
728
|
+
return (n || t.across) && null !== t.data ? `${a} ${e} of ${F(h[t.data].field)}` : `${a} ${e}`;
|
|
729
|
+
}
|
|
730
|
+
return m[o]?.subtotalCaption ?? (n ? `${a} ${s}` : `${a} Total`);
|
|
731
|
+
})(V(t.axis), e);
|
|
732
|
+
return [n, T(e, n)];
|
|
733
|
+
}
|
|
734
|
+
case "value": {
|
|
735
|
+
const n = t.row.index * D + t.column.index, s = i.states[n];
|
|
736
|
+
let r = null;
|
|
737
|
+
return 0 === s ? (r = i.values[n], e.showError && a.isError(r) && (r = e.errorCaption ?? "")) : 1 === s && (r = !1 === e.showEmpty ? 0 : ((e) => {
|
|
738
|
+
if (void 0 === e) return null;
|
|
739
|
+
const t = e.trim();
|
|
740
|
+
if (!/^[+-]?\d*(?:\.\d*)?$/.test(t)) return e;
|
|
741
|
+
const n = Number(t.replace(/^([+-]?)\.?$/, "$10"));
|
|
742
|
+
return Number.isFinite(n) ? n + 0 : e;
|
|
743
|
+
})(e.emptyCaption)), [r, null];
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}, H = new C.Builder(), B = $.top, z = $.pages.reduce((e, t) => Math.max(e, t.column + 2), 0), G = (e, t) => {
|
|
747
|
+
const n = _($, e, t);
|
|
748
|
+
if (!n) return;
|
|
749
|
+
const [s, r] = U(n);
|
|
750
|
+
((e, t, n) => {
|
|
751
|
+
S && n && S.set(e + "," + t, n);
|
|
752
|
+
})(e - B, t, r), null !== s && (c ? H.pushAt(t, e - B, s) : H.pushAt(e - B, t, s));
|
|
753
|
+
};
|
|
754
|
+
if (c) {
|
|
755
|
+
const e = Math.max(z, $.columns.length);
|
|
756
|
+
for (let t = 0; t < e; t++) for (let e = 0; e < $.rows.length; e++) t < (e < B ? z : $.columns.length) && G(e, t);
|
|
757
|
+
} else for (let e = 0; e < $.rows.length; e++) {
|
|
758
|
+
const t = e < B ? z : $.columns.length;
|
|
759
|
+
for (let n = 0; n < t; n++) G(e, n);
|
|
760
|
+
}
|
|
761
|
+
if (O) {
|
|
762
|
+
const t = E(e);
|
|
763
|
+
return {
|
|
764
|
+
cells: H.build()?.tuples ?? [],
|
|
765
|
+
rows: 1,
|
|
766
|
+
columns: 1,
|
|
767
|
+
rowPageCount: t.rows,
|
|
768
|
+
columnPageCount: t.columns,
|
|
769
|
+
header: R,
|
|
770
|
+
rowLines: [],
|
|
771
|
+
columnLines: [],
|
|
772
|
+
viewValues: [],
|
|
773
|
+
firstKey: null,
|
|
774
|
+
...S ? { roles: S } : {}
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
const q = (e, t) => {
|
|
778
|
+
const n = [];
|
|
779
|
+
return e.forEach((e, s) => {
|
|
780
|
+
e.field !== ce && n.push(s < t.path.length ? t.path[s] : -1);
|
|
781
|
+
}), n;
|
|
782
|
+
}, K = (e, t) => Q(e.data ?? t.data ?? 0, [...q(r, e), ...q(o, t)]), [J] = i.rows, [W] = i.columns, Y = J && W && 3 !== J.kind && 3 !== W.kind ? K(J, W) : null, X = [], Z = (e) => 1 === e.kind && null !== e.function;
|
|
783
|
+
i.rows.forEach((t, n) => {
|
|
784
|
+
3 === t.kind || Z(t) || (q(r, t), i.columns.forEach((s, r) => {
|
|
785
|
+
const o = i.states[n * D + r];
|
|
786
|
+
if (3 === s.kind || Z(s) || 0 !== o && 1 !== o) return;
|
|
787
|
+
let l = 0 === o ? i.values[n * D + r] : 0;
|
|
788
|
+
e.showError && a.isError(l) && (l = e.errorCaption || 0), X.push([K(t, s), l]);
|
|
789
|
+
}));
|
|
790
|
+
});
|
|
791
|
+
const ee = E(e);
|
|
792
|
+
return {
|
|
793
|
+
cells: H.build()?.tuples ?? [],
|
|
794
|
+
rows: $.rows.length - B,
|
|
795
|
+
columns: $.columns.length,
|
|
796
|
+
rowPageCount: ee.rows,
|
|
797
|
+
columnPageCount: ee.columns,
|
|
798
|
+
header: R,
|
|
799
|
+
rowLines: N,
|
|
800
|
+
columnLines: L,
|
|
801
|
+
viewValues: X,
|
|
802
|
+
firstKey: Y,
|
|
803
|
+
...S ? { roles: S } : {}
|
|
804
|
+
};
|
|
805
|
+
}, Oe = (e, t, n, r, o = !1, i, d) => {
|
|
806
|
+
const u = Ie(e, t, r, {
|
|
807
|
+
filters: i,
|
|
808
|
+
slicerFields: d
|
|
809
|
+
});
|
|
810
|
+
if (!u) return null;
|
|
811
|
+
const c = u.rowPageCount > 0 ? u.rowPageCount + 1 : 0, f = u.rowPageCount > 0 ? 3 * u.columnPageCount - 1 : 0, { rowStart: p, colStart: h } = n;
|
|
812
|
+
if (p - c < 0) return null;
|
|
813
|
+
const v = {
|
|
814
|
+
rowStart: p - c,
|
|
815
|
+
colStart: h,
|
|
816
|
+
rowEnd: p + u.rows - 1,
|
|
817
|
+
colEnd: h + Math.max(u.columns, f) - 1
|
|
818
|
+
}, F = e.fields, b = t.fields, y = G(t), x = (e, t) => {
|
|
819
|
+
const n = F[e], o = n.numberFormat ?? b[e].numberFormat, i = l(o, r), d = m(b[e]), u = y[e], c = (n.items ?? []).filter((e) => void 0 !== e.item && void 0 === e.type), f = c.length > 0 ? c : u.map((e, t) => ({ item: t })), p = f.map((t) => {
|
|
820
|
+
const n = w(u[t.item]), c = I(b[e], t.item), f = null === n ? "(blank)" : "number" == typeof n ? s(r, c ? (m = t.item, void 0 === o ? l(g(b[e], m), r) : i) : i, n) : a.isError(n) ? n.getLabel() : "boolean" == typeof n ? n ? "TRUE" : "FALSE" : String(n);
|
|
821
|
+
var m;
|
|
822
|
+
const p = d && c ? f : n;
|
|
823
|
+
return void 0 !== t.name ? {
|
|
824
|
+
value: p,
|
|
825
|
+
text: f,
|
|
826
|
+
name: t.name
|
|
827
|
+
} : {
|
|
828
|
+
value: p,
|
|
829
|
+
text: f
|
|
830
|
+
};
|
|
831
|
+
}), h = {
|
|
832
|
+
name: n.name ?? b[e].name,
|
|
833
|
+
items: p
|
|
834
|
+
};
|
|
835
|
+
if (t) {
|
|
836
|
+
const e = void 0 !== t.item ? (n.items ?? [])[t.item]?.item : void 0;
|
|
837
|
+
h.page = void 0 !== e ? f.findIndex((t) => t.item === e) : -1;
|
|
838
|
+
}
|
|
839
|
+
return h;
|
|
840
|
+
}, A = (e) => (e ?? []).filter((e) => -2 !== e);
|
|
841
|
+
return {
|
|
842
|
+
view: {
|
|
843
|
+
range: v,
|
|
844
|
+
dataFields: (e.dataFields ?? []).map((e) => ({
|
|
845
|
+
name: e.name,
|
|
846
|
+
sourceName: b[e.field].name
|
|
847
|
+
})),
|
|
848
|
+
fields: [
|
|
849
|
+
...A(e.rowFields).map((e) => x(e)),
|
|
850
|
+
...A(e.columnFields).map((e) => x(e)),
|
|
851
|
+
...(e.pageFields ?? []).map((e) => x(e.field, e))
|
|
852
|
+
],
|
|
853
|
+
values: u.viewValues,
|
|
854
|
+
block: {
|
|
855
|
+
anchor: {
|
|
856
|
+
row: p,
|
|
857
|
+
column: h
|
|
858
|
+
},
|
|
859
|
+
...o ? { blocked: !0 } : {},
|
|
860
|
+
...null !== u.firstKey ? { first: u.firstKey } : {}
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
size: {
|
|
864
|
+
rows: u.rows,
|
|
865
|
+
columns: u.columns
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
}, Re = async (e, t, n, r) => {
|
|
869
|
+
const o = /* @__PURE__ */ new Map(), d = (e.filters ?? []).filter((t) => R(t) || e.rowFields?.includes(t.field) || e.columnFields?.includes(t.field)), u = e.fields?.some((e) => e.items?.some((e) => e.calculated)), f = e.dataFields?.some((e) => B(t.fields?.[e.field]));
|
|
870
|
+
if (0 === d.length && !u && !f) return { keep: o };
|
|
871
|
+
const m = G(t);
|
|
872
|
+
for (const s of d.filter(R)) {
|
|
873
|
+
const a = s.field, l = m[a];
|
|
874
|
+
if (!l) continue;
|
|
875
|
+
const d = i(s.condition) ? $e(e, t, l, a, n) : null, u = new Array(l.length);
|
|
876
|
+
for (let e = 0; e < l.length; e++) u[e] = d ? d[e] : w(l[e]);
|
|
877
|
+
const c = await Le(s.condition, u, n, r), f = o.get(a);
|
|
878
|
+
if (f) for (let e = 0; e < c.length; e++) f[e] &= c[e];
|
|
879
|
+
else o.set(a, c);
|
|
880
|
+
}
|
|
881
|
+
const p = u && r ? await (async (e, t, n, r, o) => {
|
|
882
|
+
const i = t.fields ?? [], d = e.fields ?? [], u = i.flatMap((e, t) => e.calculatedItems?.length ? [t] : []), c = e.dataFields ?? [];
|
|
883
|
+
if (1 !== u.length || c.some((e) => B(i[e.field]) || !ue.has(e.subtotal ?? "sum"))) return null;
|
|
884
|
+
const f = u[0], m = i[f].calculatedItems, p = te(t, n.isDate1904());
|
|
885
|
+
if (!p) return null;
|
|
886
|
+
const g = G(t), F = G({
|
|
887
|
+
...t,
|
|
888
|
+
fields: i.map(({ group: e, ...t }) => t)
|
|
889
|
+
}), b = (e.rowFields ?? []).filter((e) => e >= 0), y = (e.columnFields ?? []).filter((e) => e >= 0), x = b.includes(f) ? b : y.includes(f) ? y : null;
|
|
890
|
+
if (!x) return null;
|
|
891
|
+
const A = x.slice(0, x.indexOf(f)), C = [...x.slice(x.indexOf(f) + 1), ...x === b ? y : b], E = [...A, ...C], S = t.recordCount ?? 0, P = (e, t) => {
|
|
892
|
+
const n = d[e]?.items, s = n?.find((e) => e.item === t && void 0 === e.type);
|
|
893
|
+
return !(n && (!s || s.hidden) || o?.get(e) && 0 === o.get(e)[t]);
|
|
894
|
+
}, k = (e, t) => {
|
|
895
|
+
const n = d[e.field]?.items;
|
|
896
|
+
if (void 0 !== e.item) return n?.[e.item]?.item === t;
|
|
897
|
+
const s = n?.find((e) => e.item === t && void 0 === e.type);
|
|
898
|
+
return !n || !!s && !s.hidden;
|
|
899
|
+
}, M = e.pageFields ?? [], T = l(i[f].numberFormat ?? 14, n), O = (e) => g[f].findIndex((t, r) => {
|
|
900
|
+
const o = w(t);
|
|
901
|
+
return "number" == typeof o && (i[f].dates || I(i[f], r)) ? h(s(n, T, o), e) : h(null === o ? v : H(o), e);
|
|
902
|
+
}), R = /* @__PURE__ */ new Map(), N = new Map(m.map((e) => [e.item, e.formula])), L = (e) => {
|
|
903
|
+
let t = R.get(e);
|
|
904
|
+
return void 0 === t && R.set(e, t = R.size), t;
|
|
905
|
+
};
|
|
906
|
+
for (const e of m) if (null === oe(e.formula, (e, t) => {
|
|
907
|
+
if (null === t || !h(i[f].name, e)) return null;
|
|
908
|
+
const n = O(t);
|
|
909
|
+
return n < 0 ? null : (N.has(n) || L(n), "");
|
|
910
|
+
})) return null;
|
|
911
|
+
const $ = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), D = c.map((e) => ({
|
|
912
|
+
column: p[e.field],
|
|
913
|
+
values: F[e.field],
|
|
914
|
+
fold: e.subtotal ?? "sum"
|
|
915
|
+
})), V = R.size;
|
|
916
|
+
for (let e = 0; e < S; e++) {
|
|
917
|
+
if (!M.every((t) => k(t, p[t.field][e]))) continue;
|
|
918
|
+
if (!E.every((t) => P(t, p[t][e]))) continue;
|
|
919
|
+
let t = "";
|
|
920
|
+
for (const n of A) t += p[n][e] + ",";
|
|
921
|
+
_.has(t) || _.set(t, e);
|
|
922
|
+
const n = R.get(p[f][e]);
|
|
923
|
+
if (void 0 === n) continue;
|
|
924
|
+
let s = t;
|
|
925
|
+
for (const t of C) s += p[t][e] + ",";
|
|
926
|
+
let r = $.get(s);
|
|
927
|
+
r || (r = {
|
|
928
|
+
sums: c.map(() => new Array(V).fill(0)),
|
|
929
|
+
errors: c.map(() => new Array(V).fill(void 0))
|
|
930
|
+
}, $.set(s, r));
|
|
931
|
+
const { sums: o, errors: i } = r;
|
|
932
|
+
D.forEach(({ column: t, values: s, fold: r }, l) => {
|
|
933
|
+
const d = w(s[t[e]]);
|
|
934
|
+
"sum" === r ? "number" == typeof d ? o[l][n] += d : a.isError(d) && (i[l][n] ??= d) : ("countNums" === r ? "number" == typeof d : null !== d) && (o[l][n] += 1);
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
const U = C.map((e) => {
|
|
938
|
+
const t = d[e]?.items;
|
|
939
|
+
return t ? t.flatMap((t) => void 0 !== t.item && void 0 === t.type && !t.missing && P(e, t.item) ? [t.item] : []) : g[e].map((e, t) => t);
|
|
940
|
+
});
|
|
941
|
+
if (U.reduce((e, t) => e * t.length, _.size) > 5e5) return null;
|
|
942
|
+
const z = [];
|
|
943
|
+
for (const [e, t] of _) {
|
|
944
|
+
const n = (e, s, r) => {
|
|
945
|
+
if (e !== U.length) for (const t of U[e]) n(e + 1, [...s, t], r + t + ",");
|
|
946
|
+
else z.push({
|
|
947
|
+
exemplar: t,
|
|
948
|
+
path: s,
|
|
949
|
+
key: r
|
|
950
|
+
});
|
|
951
|
+
};
|
|
952
|
+
n(0, [], e);
|
|
953
|
+
}
|
|
954
|
+
const j = z.length;
|
|
955
|
+
if (0 === j) return {
|
|
956
|
+
count: 0,
|
|
957
|
+
ids: i.map(() => []),
|
|
958
|
+
values: c.map(() => [])
|
|
959
|
+
};
|
|
960
|
+
const q = c.length * V, Q = (e, t) => e * V + t, K = (e, t) => q + e * m.length + t, J = [];
|
|
961
|
+
for (let e = 0; e < c.length; e++) for (let t = 0; t < V; t++) J.push(z.map(({ key: n }) => {
|
|
962
|
+
const s = $.get(n);
|
|
963
|
+
return s ? s.errors[e][t] ?? s.sums[e][t] : 0;
|
|
964
|
+
}));
|
|
965
|
+
const W = [];
|
|
966
|
+
for (let e = 0; e < c.length; e++) for (let t = 0; t < m.length; t++) {
|
|
967
|
+
const n = oe(m[t].formula, (t, n) => {
|
|
968
|
+
if (null === n) return null;
|
|
969
|
+
const s = O(n), r = m.findIndex((e) => e.item === s);
|
|
970
|
+
return ae(r >= 0 ? K(e, r) : Q(e, R.get(s)));
|
|
971
|
+
});
|
|
972
|
+
if (null === n) return null;
|
|
973
|
+
W.push({
|
|
974
|
+
expression: n,
|
|
975
|
+
coords: ie(K(e, t), j)
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
const Y = await r.evaluateBatch({
|
|
979
|
+
values: le(J, j),
|
|
980
|
+
formulas: W
|
|
981
|
+
}), X = i.map(() => []), Z = c.map(() => []), ee = (e, t, n, s) => {
|
|
982
|
+
p.forEach((n, s) => {
|
|
983
|
+
const r = C.indexOf(s);
|
|
984
|
+
X[s].push(s === f ? t : r >= 0 ? e.path[r] : n[e.exemplar] ?? 0);
|
|
985
|
+
}), Z.forEach((e, t) => {
|
|
986
|
+
e.push(t === n ? s : null);
|
|
987
|
+
});
|
|
988
|
+
};
|
|
989
|
+
return z.forEach((e, t) => {
|
|
990
|
+
m.forEach(({ item: n }, s) => {
|
|
991
|
+
c.forEach((r, o) => {
|
|
992
|
+
const a = Y[o * m.length + s].getValueAt(t, 0) ?? 0;
|
|
993
|
+
if ("sum" !== (r.subtotal ?? "sum") && "number" == typeof a) for (let t = 0; t < Math.round(a); t++) ee(e, n, o, 1);
|
|
994
|
+
else ee(e, n, o, a);
|
|
995
|
+
});
|
|
996
|
+
});
|
|
997
|
+
}), {
|
|
998
|
+
count: X[0]?.length ?? 0,
|
|
999
|
+
ids: X,
|
|
1000
|
+
values: Z
|
|
1001
|
+
};
|
|
1002
|
+
})(e, t, n, r, o) : void 0, g = d.filter((e) => !R(e)).map((e, t) => ({
|
|
1003
|
+
filter: e,
|
|
1004
|
+
index: t
|
|
1005
|
+
})).sort((e, t) => (e.filter.evalOrder ?? -1) - (t.filter.evalOrder ?? -1) || e.index - t.index), F = (t.recordCount ?? 0) + (p?.count ?? 0);
|
|
1006
|
+
let b;
|
|
1007
|
+
const y = e.rowFields ?? [];
|
|
1008
|
+
for (const { filter: s } of g) {
|
|
1009
|
+
const a = await Ae(e, t, n, s.field, s.dataField, o, b, p, r);
|
|
1010
|
+
if (!a) continue;
|
|
1011
|
+
const i = /* @__PURE__ */ new Set();
|
|
1012
|
+
for (const [e, t] of a.groups) {
|
|
1013
|
+
const o = await Le(s.condition, t.totals, n, r);
|
|
1014
|
+
t.ids.forEach((t, n) => {
|
|
1015
|
+
o[n] || i.add(`${e}|${t}`);
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
if (0 === i.size) continue;
|
|
1019
|
+
b ??= new Uint8Array(F).fill(3);
|
|
1020
|
+
const l = a.outer.map((e) => a.records[e]), d = a.records[s.field], u = y.includes(s.field) ? 1 : 2;
|
|
1021
|
+
for (let e = 0; e < F; e++) {
|
|
1022
|
+
if (!(b[e] & u)) continue;
|
|
1023
|
+
let t = "";
|
|
1024
|
+
for (let n = 0; n < l.length; n++) t += (n > 0 ? "," : "") + l[n][e];
|
|
1025
|
+
i.has(`${t}|${d[e]}`) && (b[e] &= ~u);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
const x = f && r ? await (async (e, t, n, s, r, o, a) => {
|
|
1029
|
+
const i = c.peek(), l = de(e, t);
|
|
1030
|
+
if (!i || !l) return null;
|
|
1031
|
+
const d = xe(e, t, n, a, l.operands);
|
|
1032
|
+
if (!d) return null;
|
|
1033
|
+
const u = (t) => (t ?? []).map((t) => ({
|
|
1034
|
+
field: t,
|
|
1035
|
+
form: t === ce ? e.form ?? "compact" : e.fields?.[t]?.form ?? "compact"
|
|
1036
|
+
}));
|
|
1037
|
+
return Ee(i, l, e, d.items, d.records, d.values, u(e.rowFields), u(e.columnFields), d.n, r, o, s);
|
|
1038
|
+
})(e, t, n, r, o, b, p) : void 0;
|
|
1039
|
+
return {
|
|
1040
|
+
keep: o,
|
|
1041
|
+
...b ? { records: b } : {},
|
|
1042
|
+
...p ? { calculatedRecords: p } : {},
|
|
1043
|
+
...x ? { fieldValues: x } : {}
|
|
1044
|
+
};
|
|
1045
|
+
}, Ne = (e, t) => {
|
|
1046
|
+
const n = e.filters;
|
|
1047
|
+
if (!n) return e;
|
|
1048
|
+
let s = !1;
|
|
1049
|
+
const r = n.map((e) => {
|
|
1050
|
+
const n = e.condition && F(e.condition, t);
|
|
1051
|
+
return n === e.condition ? e : (s = !0, {
|
|
1052
|
+
...e,
|
|
1053
|
+
condition: n
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1056
|
+
return s ? {
|
|
1057
|
+
...e,
|
|
1058
|
+
filters: r
|
|
1059
|
+
} : e;
|
|
1060
|
+
}, Le = async (e, t, n, s) => {
|
|
1061
|
+
const r = t.length, o = new Uint8Array(r);
|
|
1062
|
+
if (0 === r) return o;
|
|
1063
|
+
const a = new x();
|
|
1064
|
+
for (let e = 0; e < r; e++) null !== t[e] && a.setValueAt(e, 0, t[e]);
|
|
1065
|
+
let i = !1;
|
|
1066
|
+
return await T({
|
|
1067
|
+
conditions: [e],
|
|
1068
|
+
runtime: n,
|
|
1069
|
+
calculation: s ?? null,
|
|
1070
|
+
values: a,
|
|
1071
|
+
coords: {
|
|
1072
|
+
rowStart: 0,
|
|
1073
|
+
rowEnd: r - 1,
|
|
1074
|
+
colStart: 0,
|
|
1075
|
+
colEnd: 0
|
|
1076
|
+
},
|
|
1077
|
+
onTrue: (e) => {
|
|
1078
|
+
i = !0, o[e.rowIndex] = 1;
|
|
1079
|
+
},
|
|
1080
|
+
onFalse: () => {
|
|
1081
|
+
i = !0;
|
|
1082
|
+
},
|
|
1083
|
+
onBlank: (e) => {
|
|
1084
|
+
i = !0;
|
|
1085
|
+
for (let n = 0; n < r; n++) null === t[n] && e(n, 0) && (o[n] = 1);
|
|
1086
|
+
}
|
|
1087
|
+
}), i || o.fill(1), o;
|
|
1088
|
+
}, $e = (e, t, n, r, o) => {
|
|
1089
|
+
const i = e.fields?.[r], d = /* @__PURE__ */ new Map();
|
|
1090
|
+
for (const e of i?.items ?? []) void 0 !== e.item && void 0 === e.type && void 0 !== e.name && d.set(e.item, e.name);
|
|
1091
|
+
const u = i?.numberFormat ?? t.fields?.[r]?.numberFormat, c = l(u, o), f = (e) => void 0 === u ? l(g(t.fields?.[r], e), o) : c, m = new Array(n.length);
|
|
1092
|
+
for (let e = 0; e < n.length; e++) {
|
|
1093
|
+
const i = d.get(e);
|
|
1094
|
+
if (void 0 !== i) {
|
|
1095
|
+
m[e] = i;
|
|
1096
|
+
continue;
|
|
1097
|
+
}
|
|
1098
|
+
const l = w(n[e]);
|
|
1099
|
+
null === l ? m[e] = v : "number" == typeof l ? m[e] = s(o, I(t.fields?.[r], e) ? f(e) : c, l) : "boolean" == typeof l ? m[e] = l ? "TRUE" : "FALSE" : a.isError(l) ? m[e] = l.getLabel() : m[e] = String(l);
|
|
1100
|
+
}
|
|
1101
|
+
return m;
|
|
1102
|
+
}, _e = (e) => {
|
|
1103
|
+
const t = e.getCoords(), n = t.colEnd - t.colStart + 1, s = t.rowEnd - t.rowStart, r = e.getWorksheet(), o = r.getRange({
|
|
1104
|
+
rowStart: t.rowStart,
|
|
1105
|
+
rowEnd: t.rowStart,
|
|
1106
|
+
colStart: t.colStart,
|
|
1107
|
+
colEnd: t.colEnd
|
|
1108
|
+
}).getValues()[0] ?? [], a = [];
|
|
1109
|
+
for (let e = 0; e < n; e++) {
|
|
1110
|
+
const n = o[e] ?? null, i = new W(), l = new Uint32Array(s);
|
|
1111
|
+
let d, u, c = !1, f = i.values;
|
|
1112
|
+
if (s > 0) {
|
|
1113
|
+
const n = r.getRange({
|
|
1114
|
+
rowStart: t.rowStart + 1,
|
|
1115
|
+
rowEnd: t.rowEnd,
|
|
1116
|
+
colStart: t.colStart + e,
|
|
1117
|
+
colEnd: t.colStart + e
|
|
1118
|
+
});
|
|
1119
|
+
i.fill(n.getValuesRange(), l), d = Ve(n, s);
|
|
1120
|
+
const o = Ue(n, t.rowStart + 1, l, i.values);
|
|
1121
|
+
c = o.dates, u = o.dateIds, f = o.values;
|
|
1122
|
+
}
|
|
1123
|
+
a.push({
|
|
1124
|
+
header: De(n),
|
|
1125
|
+
ids: l,
|
|
1126
|
+
values: f,
|
|
1127
|
+
numberFormat: d,
|
|
1128
|
+
dates: c,
|
|
1129
|
+
...u ? { dateIds: u } : {}
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
return {
|
|
1133
|
+
columns: a,
|
|
1134
|
+
recordCount: s
|
|
1135
|
+
};
|
|
1136
|
+
}, De = (e) => null == e ? "" : "boolean" == typeof e ? e ? "TRUE" : "FALSE" : a.isError(e) ? e.getLabel() : String(e), Ve = (e, t) => {
|
|
1137
|
+
const n = [...e.getRegions("numberFormat")];
|
|
1138
|
+
if (1 !== n.length || n[0].getRowCount() !== t) return;
|
|
1139
|
+
const s = n[0].getCell().getStyle().getNumberFormat();
|
|
1140
|
+
return s && "General" !== s ? s : void 0;
|
|
1141
|
+
}, Ue = (e, t, n, s) => {
|
|
1142
|
+
const r = [];
|
|
1143
|
+
for (const n of e.getRegions("dateFormat")) {
|
|
1144
|
+
const { rowStart: e, rowEnd: s } = n.getCoords();
|
|
1145
|
+
r.push([e - t, s - t]);
|
|
1146
|
+
}
|
|
1147
|
+
if (0 === r.length) return {
|
|
1148
|
+
dates: !1,
|
|
1149
|
+
values: s
|
|
1150
|
+
};
|
|
1151
|
+
r.sort((e, t) => e[0] - t[0]);
|
|
1152
|
+
let o = !1, a = !1;
|
|
1153
|
+
for (let e = 0; e < n.length && (!o || !a); e++) "number" == typeof s[n[e]] && (He(r, e) ? o = !0 : a = !0);
|
|
1154
|
+
if (!o || !a) return {
|
|
1155
|
+
dates: o,
|
|
1156
|
+
values: s
|
|
1157
|
+
};
|
|
1158
|
+
const i = s.slice(), l = /* @__PURE__ */ new Map();
|
|
1159
|
+
for (let e = 0; e < n.length; e++) {
|
|
1160
|
+
const t = n[e];
|
|
1161
|
+
if ("number" != typeof s[t] || !He(r, e)) continue;
|
|
1162
|
+
let o = l.get(t);
|
|
1163
|
+
void 0 === o && (o = i.length, i.push(s[t]), l.set(t, o)), n[e] = o;
|
|
1164
|
+
}
|
|
1165
|
+
return {
|
|
1166
|
+
dates: !1,
|
|
1167
|
+
dateIds: new Set(l.values()),
|
|
1168
|
+
values: i
|
|
1169
|
+
};
|
|
1170
|
+
}, He = (e, t) => {
|
|
1171
|
+
let n = 0, s = e.length - 1;
|
|
1172
|
+
for (; n <= s;) {
|
|
1173
|
+
const r = n + s >> 1, [o, a] = e[r];
|
|
1174
|
+
if (t < o) s = r - 1;
|
|
1175
|
+
else {
|
|
1176
|
+
if (!(t > a)) return !0;
|
|
1177
|
+
n = r + 1;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
return !1;
|
|
1181
|
+
}, Be = (e) => null == e ? {
|
|
1182
|
+
t: "z",
|
|
1183
|
+
v: 0
|
|
1184
|
+
} : a.isError(e) ? {
|
|
1185
|
+
t: "e",
|
|
1186
|
+
v: e.getCode()
|
|
1187
|
+
} : e, ze = (e, t) => (t && "number" == typeof e ? "date:" : "") + S(w(e)), Ge = (e, t, n, s = !1) => {
|
|
1188
|
+
const r = e.fields ?? [], o = p(e.items, r.length), a = /\smissingItemsLimit="0"/.test(e.rest ?? ""), i = ((e) => {
|
|
1189
|
+
const t = /* @__PURE__ */ new Set();
|
|
1190
|
+
return e.map((e, n) => {
|
|
1191
|
+
const s = "" === e ? `Field${n + 1}` : e;
|
|
1192
|
+
let r = s;
|
|
1193
|
+
for (let e = 2; t.has(r.toLocaleLowerCase()); e++) r = `${s}${e}`;
|
|
1194
|
+
return t.add(r.toLocaleLowerCase()), r;
|
|
1195
|
+
});
|
|
1196
|
+
})(t.columns.map((e) => e.header)), l = /* @__PURE__ */ new Map();
|
|
1197
|
+
r.forEach((e, t) => {
|
|
1198
|
+
const n = e.name.toLocaleLowerCase();
|
|
1199
|
+
e.noRecords || l.has(n) || l.set(n, t);
|
|
1200
|
+
});
|
|
1201
|
+
const d = t.recordCount, u = r.map(() => -1), c = r.map((e, t) => o[t].map(() => -1)), f = [], h = [], g = [], v = [], F = [], b = [], y = [], x = (e, t, n) => {
|
|
1202
|
+
v[t] = n.items, b[t] = n.items.length, y[t] = !0, c[e] = ((e, t) => {
|
|
1203
|
+
const n = /* @__PURE__ */ new Map();
|
|
1204
|
+
return t.forEach((e, t) => {
|
|
1205
|
+
n.set(e, t);
|
|
1206
|
+
}), e.map((s, r) => 0 === r ? 0 : r === e.length - 1 ? t.length - 1 : n.get(s) ?? -1);
|
|
1207
|
+
})(r[e].group.items, n.items);
|
|
1208
|
+
};
|
|
1209
|
+
t.columns.forEach((e, t) => {
|
|
1210
|
+
const n = l.get(i[t].toLocaleLowerCase());
|
|
1211
|
+
void 0 !== n && (l.delete(i[t].toLocaleLowerCase()), u[n] = t);
|
|
1212
|
+
const p = new Int32Array(e.values.length).fill(-1), A = [], C = [], E = new Array(d);
|
|
1213
|
+
for (let t = 0; t < d; t++) {
|
|
1214
|
+
const n = e.ids[t];
|
|
1215
|
+
let s = p[n];
|
|
1216
|
+
s < 0 && (s = p[n] = A.length, A.push(Be(e.values[n])), C.push(e.dates || !!e.dateIds?.has(n))), E[t] = s;
|
|
1217
|
+
}
|
|
1218
|
+
const S = (e) => void 0 !== n && (!!r[n].dates || I(r[n], e)), P = A.length, k = void 0 !== n ? !0 === r[n].inline : A.every((e) => "number" == typeof e || "object" == typeof e && "z" === e?.t), M = [];
|
|
1219
|
+
if (void 0 !== n && k) {
|
|
1220
|
+
const e = /* @__PURE__ */ new Map();
|
|
1221
|
+
for (let t = 0; t < P; t++) e.set(ze(A[t], C[t]), t);
|
|
1222
|
+
o[n].forEach((t, s) => {
|
|
1223
|
+
c[n][s] = e.get(ze(t, S(s))) ?? -1;
|
|
1224
|
+
});
|
|
1225
|
+
} else if (void 0 !== n) {
|
|
1226
|
+
const e = /* @__PURE__ */ new Map();
|
|
1227
|
+
for (let t = 0; t < P; t++) e.set(ze(A[t], C[t]), t);
|
|
1228
|
+
const t = new Set(r[n].calculatedItems?.map((e) => e.item));
|
|
1229
|
+
o[n].forEach((s, r) => {
|
|
1230
|
+
if (t.has(r)) return;
|
|
1231
|
+
const o = ze(s, S(r));
|
|
1232
|
+
let i = e.get(o);
|
|
1233
|
+
void 0 !== i || a || S(r) || (i = A.length, A.push(s), C.push(S(r)), M.push(i), e.set(o, i)), c[n][r] = i ?? -1;
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
const T = { name: i[t] };
|
|
1237
|
+
k && (T.inline = !0), void 0 !== e.numberFormat && (T.numberFormat = e.numberFormat);
|
|
1238
|
+
const O = [];
|
|
1239
|
+
let R = !1;
|
|
1240
|
+
A.forEach((e, t) => {
|
|
1241
|
+
"number" == typeof e && (C[t] ? O.push(t) : R = !0);
|
|
1242
|
+
}), O.length > 0 && !R ? T.dates = !0 : O.length > 0 && (T.dateItems = O), F[t] = T.dateItems ? new Set(T.dateItems) : void 0, M.length > 0 && (T.unused = M);
|
|
1243
|
+
const N = void 0 !== n ? r[n].rest : void 0;
|
|
1244
|
+
N && (T.rest = N);
|
|
1245
|
+
const L = void 0 !== n ? r[n].calculatedItems : void 0;
|
|
1246
|
+
L?.length && (T.calculatedItems = L.map(({ item: e, formula: t }) => {
|
|
1247
|
+
const s = A.length;
|
|
1248
|
+
return A.push(o[n][e]), c[n][e] = s, {
|
|
1249
|
+
item: s,
|
|
1250
|
+
formula: t
|
|
1251
|
+
};
|
|
1252
|
+
})), f.push(T), h.push([t, [[0, A]]]), g.push([t, [[0, E]]]), v.push(A), b.push(P), y.push(!1);
|
|
1253
|
+
const $ = void 0 !== n ? r[n].group : void 0;
|
|
1254
|
+
if ($?.range && $.base === n) {
|
|
1255
|
+
const e = re($, A.slice(0, P).map(w), s);
|
|
1256
|
+
e ? (T.group = {
|
|
1257
|
+
...e,
|
|
1258
|
+
base: t
|
|
1259
|
+
}, x(n, t, e)) : c[n] = o[n].map(() => -1);
|
|
1260
|
+
} else $ && !m(r[n]) && (T.group = $);
|
|
1261
|
+
}), r.forEach((e, t) => {
|
|
1262
|
+
if (!e.noRecords) return;
|
|
1263
|
+
if (B(e)) return u[t] = f.length, f.push(e), v.push([]), b.push(0), void y.push(!1);
|
|
1264
|
+
const n = e.group;
|
|
1265
|
+
if (!n) return;
|
|
1266
|
+
const r = u[n.base];
|
|
1267
|
+
if (void 0 === r || r < 0) return;
|
|
1268
|
+
const o = v[r];
|
|
1269
|
+
let a, i = [];
|
|
1270
|
+
if (n.range) a = re(n, o.slice(0, b[r]).map(w), s);
|
|
1271
|
+
else {
|
|
1272
|
+
const e = je(n, c[n.base], o, f[r]);
|
|
1273
|
+
a = e.group, i = e.itemMap;
|
|
1274
|
+
}
|
|
1275
|
+
if (!a) return;
|
|
1276
|
+
const l = f.length;
|
|
1277
|
+
u[t] = l, f.push({
|
|
1278
|
+
...e,
|
|
1279
|
+
group: {
|
|
1280
|
+
...a,
|
|
1281
|
+
base: r
|
|
1282
|
+
}
|
|
1283
|
+
}), v.push(a.items), F[l] = a.dateItems ? new Set(a.dateItems) : void 0, b.push(a.items.length), y.push(!1), n.range ? x(t, l, a) : c[t] = i;
|
|
1284
|
+
}), f.forEach((e, t) => {
|
|
1285
|
+
const n = e.group;
|
|
1286
|
+
if (void 0 === n?.parent) return;
|
|
1287
|
+
const s = u[n.parent], { parent: r, ...o } = n;
|
|
1288
|
+
void 0 !== s && s >= 0 ? e.group = {
|
|
1289
|
+
...n,
|
|
1290
|
+
parent: s
|
|
1291
|
+
} : m(e) ? e.group = o : delete e.group, e.group && !m(e) && (e.group = {
|
|
1292
|
+
...e.group,
|
|
1293
|
+
base: t
|
|
1294
|
+
});
|
|
1295
|
+
});
|
|
1296
|
+
const { cacheId: A, part: C, partFormats: E, fields: S, items: P, records: k, ...M } = e;
|
|
1297
|
+
return {
|
|
1298
|
+
model: {
|
|
1299
|
+
...M,
|
|
1300
|
+
source: n ?? e.source,
|
|
1301
|
+
fields: f,
|
|
1302
|
+
items: h,
|
|
1303
|
+
records: g,
|
|
1304
|
+
recordCount: d
|
|
1305
|
+
},
|
|
1306
|
+
remap: {
|
|
1307
|
+
fields: u,
|
|
1308
|
+
items: c,
|
|
1309
|
+
newItems: v,
|
|
1310
|
+
usedCounts: b,
|
|
1311
|
+
inItemOrder: y,
|
|
1312
|
+
dateItems: F
|
|
1313
|
+
}
|
|
1314
|
+
};
|
|
1315
|
+
}, je = (e, t, n, s) => {
|
|
1316
|
+
const r = /* @__PURE__ */ new Set(), o = new Array(n.length).fill(-1);
|
|
1317
|
+
(e.discrete ?? []).forEach((e, n) => {
|
|
1318
|
+
const s = t?.[n] ?? -1;
|
|
1319
|
+
s < 0 || (o[s] = e, r.add(e));
|
|
1320
|
+
});
|
|
1321
|
+
const a = [], i = [], l = new Set(e.dateItems), d = e.items.map((e, t) => r.has(t) ? (l.has(t) && i.push(a.length), a.push(e), a.length - 1) : -1), u = o.map((e, t) => e >= 0 ? d[e] : ((s.dates || I(s, t)) && i.push(a.length), a.push(n[t]), a.length - 1)), { dateItems: c, ...f } = e;
|
|
1322
|
+
return {
|
|
1323
|
+
group: {
|
|
1324
|
+
...f,
|
|
1325
|
+
items: a,
|
|
1326
|
+
discrete: u,
|
|
1327
|
+
...i.length > 0 ? { dateItems: i } : {}
|
|
1328
|
+
},
|
|
1329
|
+
itemMap: d
|
|
1330
|
+
};
|
|
1331
|
+
}, qe = (e, t, n = !1, s = !1) => {
|
|
1332
|
+
const r = (e, t) => null === e ? 5 : "number" == typeof e ? t ? 3 : 0 : "string" == typeof e ? 1 : "boolean" == typeof e ? 2 : 4, o = r(e, n), a = r(t, s);
|
|
1333
|
+
return o !== a ? o - a : 0 === o || 3 === o ? e - t : 1 === o ? e.localeCompare(t, void 0, { sensitivity: "base" }) : 2 === o ? Number(e) - Number(t) : 4 === o ? e.getCode() - t.getCode() : 0;
|
|
1334
|
+
}, Qe = (e, t) => {
|
|
1335
|
+
const n = e.fields ?? [], s = t.newItems.length, r = (e) => e < 0 ? e : t.fields[e] ?? -1, o = (e) => e < 0 || r(e) >= 0, a = e.dataFields ?? [], i = [], l = [];
|
|
1336
|
+
a.forEach((e) => {
|
|
1337
|
+
if (!o(e.field)) return void i.push(-1);
|
|
1338
|
+
i.push(l.length);
|
|
1339
|
+
const t = {
|
|
1340
|
+
...e,
|
|
1341
|
+
field: r(e.field)
|
|
1342
|
+
};
|
|
1343
|
+
void 0 !== e.baseField && (o(e.baseField) ? t.baseField = r(e.baseField) : delete t.baseField), l.push(t);
|
|
1344
|
+
});
|
|
1345
|
+
const d = n.map(() => null), u = [];
|
|
1346
|
+
for (let e = 0; e < s; e++) u.push({});
|
|
1347
|
+
n.forEach((e, n) => {
|
|
1348
|
+
const s = r(n);
|
|
1349
|
+
if (s < 0) return;
|
|
1350
|
+
const o = { ...e };
|
|
1351
|
+
if (void 0 !== e.sort?.dataField) {
|
|
1352
|
+
const t = i[e.sort.dataField];
|
|
1353
|
+
o.sort = t >= 0 ? {
|
|
1354
|
+
...e.sort,
|
|
1355
|
+
dataField: t
|
|
1356
|
+
} : { order: e.sort.order };
|
|
1357
|
+
}
|
|
1358
|
+
if (e.items) {
|
|
1359
|
+
const { items: r, positions: a } = Je(e, t.items[n], t.newItems[s], t.usedCounts[s], t.inItemOrder[s], t.dateItems[s]);
|
|
1360
|
+
o.items = r, d[n] = a;
|
|
1361
|
+
}
|
|
1362
|
+
u[s] = o;
|
|
1363
|
+
}), n.forEach((e, t) => {
|
|
1364
|
+
const n = e.sort?.scope, s = r(t);
|
|
1365
|
+
if (!n || s < 0 || void 0 === u[s].sort?.scope) return;
|
|
1366
|
+
const o = n.items.map((e) => ({
|
|
1367
|
+
field: r(e.field),
|
|
1368
|
+
item: d[e.field]?.[e.item] ?? -1
|
|
1369
|
+
}));
|
|
1370
|
+
o.some((e) => e.field < 0 || e.item < 0) ? delete u[s].sort : u[s].sort = {
|
|
1371
|
+
...u[s].sort,
|
|
1372
|
+
scope: {
|
|
1373
|
+
...n,
|
|
1374
|
+
items: o
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
});
|
|
1378
|
+
const c = (e) => {
|
|
1379
|
+
if (!e) return;
|
|
1380
|
+
let t = e.filter(o).map(r);
|
|
1381
|
+
return l.length < 2 && (t = t.filter((e) => -2 !== e)), t.length > 0 ? t : void 0;
|
|
1382
|
+
}, f = {
|
|
1383
|
+
...e,
|
|
1384
|
+
fields: u
|
|
1385
|
+
};
|
|
1386
|
+
Ke(f, "rowFields", c(e.rowFields)), Ke(f, "columnFields", c(e.columnFields)), Ke(f, "dataFields", l.length > 0 ? l : void 0), a.forEach((e, t) => {
|
|
1387
|
+
const n = i[t];
|
|
1388
|
+
if (n < 0 || void 0 === e.baseField || "number" != typeof e.baseItem) return;
|
|
1389
|
+
const s = d[e.baseField]?.[e.baseItem];
|
|
1390
|
+
void 0 !== s && s >= 0 && (l[n].baseItem = s);
|
|
1391
|
+
});
|
|
1392
|
+
const m = (e.pageFields ?? []).flatMap((e) => {
|
|
1393
|
+
if (!o(e.field)) return [];
|
|
1394
|
+
const t = { field: r(e.field) };
|
|
1395
|
+
if (void 0 !== e.item) {
|
|
1396
|
+
const n = Ye(u[t.field].items ?? [], d[e.field]?.[e.item] ?? -1);
|
|
1397
|
+
void 0 !== n && (t.item = n);
|
|
1398
|
+
}
|
|
1399
|
+
return [t];
|
|
1400
|
+
});
|
|
1401
|
+
Ke(f, "pageFields", m.length > 0 ? m : void 0);
|
|
1402
|
+
const p = (e.filters ?? []).flatMap((e) => {
|
|
1403
|
+
if (!o(e.field)) return [];
|
|
1404
|
+
const t = {
|
|
1405
|
+
...e,
|
|
1406
|
+
field: r(e.field)
|
|
1407
|
+
};
|
|
1408
|
+
if (void 0 !== e.dataField) {
|
|
1409
|
+
const n = i[e.dataField];
|
|
1410
|
+
if (void 0 === n || n < 0) return [];
|
|
1411
|
+
t.dataField = n;
|
|
1412
|
+
}
|
|
1413
|
+
return [t];
|
|
1414
|
+
});
|
|
1415
|
+
Ke(f, "filters", p.length > 0 ? p : void 0);
|
|
1416
|
+
const h = (e) => Xe(e, r, o, d, i), g = (e.formats ?? []).flatMap((e) => {
|
|
1417
|
+
const t = h(e.area);
|
|
1418
|
+
return t ? [{
|
|
1419
|
+
...e,
|
|
1420
|
+
area: t
|
|
1421
|
+
}] : [];
|
|
1422
|
+
});
|
|
1423
|
+
Ke(f, "formats", g.length > 0 ? g : void 0);
|
|
1424
|
+
const w = (e.conditionalFormats ?? []).flatMap((e) => {
|
|
1425
|
+
const t = e.areas.flatMap((e) => {
|
|
1426
|
+
const t = h(e);
|
|
1427
|
+
return t ? [t] : [];
|
|
1428
|
+
});
|
|
1429
|
+
return t.length > 0 ? [{
|
|
1430
|
+
...e,
|
|
1431
|
+
areas: t
|
|
1432
|
+
}] : [];
|
|
1433
|
+
});
|
|
1434
|
+
return Ke(f, "conditionalFormats", w.length > 0 ? w : void 0), f;
|
|
1435
|
+
}, Ke = (e, t, n) => {
|
|
1436
|
+
void 0 === n ? delete e[t] : e[t] = n;
|
|
1437
|
+
}, Je = (e, t, n, s, r = !1, o) => {
|
|
1438
|
+
const a = e.items ?? [], i = [], l = [], d = /* @__PURE__ */ new Set();
|
|
1439
|
+
for (const e of a) {
|
|
1440
|
+
if (!k(e)) {
|
|
1441
|
+
l.push(i.length), i.push(e);
|
|
1442
|
+
continue;
|
|
1443
|
+
}
|
|
1444
|
+
const n = t[e.item] ?? -1;
|
|
1445
|
+
if (n < 0) {
|
|
1446
|
+
l.push(-1);
|
|
1447
|
+
continue;
|
|
1448
|
+
}
|
|
1449
|
+
d.add(n);
|
|
1450
|
+
const r = {
|
|
1451
|
+
...e,
|
|
1452
|
+
item: n
|
|
1453
|
+
};
|
|
1454
|
+
n >= s && !e.calculated ? r.missing = !0 : delete r.missing, l.push(i.length), i.push(r);
|
|
1455
|
+
}
|
|
1456
|
+
const u = [];
|
|
1457
|
+
for (let e = 0; e < n.length; e++) d.has(e) || u.push(e);
|
|
1458
|
+
if (r) {
|
|
1459
|
+
const t = void 0 === e.sort?.dataField && "descending" === e.sort?.order, n = !e.includeNewItemsInFilter && a.some((e) => e.hidden), s = i.map((e, t) => ({
|
|
1460
|
+
item: e,
|
|
1461
|
+
at: t
|
|
1462
|
+
})), r = s.filter((e) => !k(e.item)), o = [...[...s.filter((e) => k(e.item)), ...u.map((e) => ({
|
|
1463
|
+
item: n ? {
|
|
1464
|
+
item: e,
|
|
1465
|
+
hidden: !0
|
|
1466
|
+
} : { item: e },
|
|
1467
|
+
at: -1
|
|
1468
|
+
}))].sort((e, n) => t ? n.item.item - e.item.item : e.item.item - n.item.item), ...r], d = new Map(o.map((e, t) => [e.at, t]));
|
|
1469
|
+
return {
|
|
1470
|
+
items: o.map((e) => e.item),
|
|
1471
|
+
positions: l.map((e) => e < 0 ? e : d.get(e) ?? -1)
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
if (0 === u.length) return {
|
|
1475
|
+
items: i,
|
|
1476
|
+
positions: l
|
|
1477
|
+
};
|
|
1478
|
+
const c = !e.includeNewItemsInFilter && a.some((e) => e.hidden), f = (e) => c ? {
|
|
1479
|
+
item: e,
|
|
1480
|
+
hidden: !0
|
|
1481
|
+
} : { item: e };
|
|
1482
|
+
if (e.sort && void 0 === e.sort.dataField) {
|
|
1483
|
+
const t = "descending" === e.sort.order, s = (e, t) => qe(N(e, n), w(n[t]), void 0 === e.name && o?.has(e.item), o?.has(t));
|
|
1484
|
+
for (const e of u) {
|
|
1485
|
+
const n = f(e);
|
|
1486
|
+
let r = i.findIndex((n) => k(n) && (t ? s(n, e) < 0 : s(n, e) > 0));
|
|
1487
|
+
r < 0 && (r = We(i)), i.splice(r, 0, n);
|
|
1488
|
+
for (let e = 0; e < l.length; e++) l[e] >= r && l[e]++;
|
|
1489
|
+
}
|
|
1490
|
+
} else {
|
|
1491
|
+
const e = We(i);
|
|
1492
|
+
i.splice(e, 0, ...u.map(f));
|
|
1493
|
+
for (let t = 0; t < l.length; t++) l[t] >= e && (l[t] += u.length);
|
|
1494
|
+
}
|
|
1495
|
+
return {
|
|
1496
|
+
items: i,
|
|
1497
|
+
positions: l
|
|
1498
|
+
};
|
|
1499
|
+
}, We = (e) => {
|
|
1500
|
+
const t = e.findIndex((e) => !k(e));
|
|
1501
|
+
return t < 0 ? e.length : t;
|
|
1502
|
+
}, Ye = (e, t) => {
|
|
1503
|
+
if (!(t < 0)) for (let n = 0; n < e.length; n++) {
|
|
1504
|
+
const s = (t + n) % e.length, r = e[s];
|
|
1505
|
+
if (k(r) && !r.missing) return s;
|
|
1506
|
+
}
|
|
1507
|
+
}, Xe = (e, t, n, s, r) => {
|
|
1508
|
+
const o = { ...e };
|
|
1509
|
+
if (void 0 !== e.field) {
|
|
1510
|
+
if (!n(e.field)) return null;
|
|
1511
|
+
o.field = t(e.field);
|
|
1512
|
+
}
|
|
1513
|
+
if (e.references) {
|
|
1514
|
+
const a = [];
|
|
1515
|
+
for (const o of e.references) {
|
|
1516
|
+
if (!n(o.field)) return null;
|
|
1517
|
+
const e = {
|
|
1518
|
+
...o,
|
|
1519
|
+
field: t(o.field)
|
|
1520
|
+
};
|
|
1521
|
+
if (o.items && !o.byPosition && !o.relative) {
|
|
1522
|
+
const t = -2 === o.field ? r : s[o.field];
|
|
1523
|
+
if (t) {
|
|
1524
|
+
const n = o.items.map((e) => t[e] ?? -1);
|
|
1525
|
+
if (n.some((e) => e < 0)) return null;
|
|
1526
|
+
e.items = n;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
a.push(e);
|
|
1530
|
+
}
|
|
1531
|
+
o.references = a;
|
|
1532
|
+
}
|
|
1533
|
+
return o;
|
|
1534
|
+
}, Ze = (e, t, n) => {
|
|
1535
|
+
const s = e.fields ?? [], r = s[t]?.items ?? [], o = new Array(r.length);
|
|
1536
|
+
n.forEach((e, t) => {
|
|
1537
|
+
o[e] = t;
|
|
1538
|
+
});
|
|
1539
|
+
const a = {
|
|
1540
|
+
...e,
|
|
1541
|
+
fields: s.map((e, s) => {
|
|
1542
|
+
if (s === t) return {
|
|
1543
|
+
...e,
|
|
1544
|
+
items: n.map((e) => r[e])
|
|
1545
|
+
};
|
|
1546
|
+
const a = e.sort?.scope;
|
|
1547
|
+
if (!a?.items.some((e) => e.field === t)) return e;
|
|
1548
|
+
const i = a.items.map((e) => e.field === t ? {
|
|
1549
|
+
...e,
|
|
1550
|
+
item: o[e.item] ?? e.item
|
|
1551
|
+
} : e);
|
|
1552
|
+
return {
|
|
1553
|
+
...e,
|
|
1554
|
+
sort: {
|
|
1555
|
+
...e.sort,
|
|
1556
|
+
scope: {
|
|
1557
|
+
...a,
|
|
1558
|
+
items: i
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
};
|
|
1562
|
+
})
|
|
1563
|
+
};
|
|
1564
|
+
e.pageFields?.some((e) => e.field === t && void 0 !== e.item) && (a.pageFields = e.pageFields.map((e) => e.field === t && void 0 !== e.item ? {
|
|
1565
|
+
...e,
|
|
1566
|
+
item: o[e.item]
|
|
1567
|
+
} : e)), e.dataFields?.some((e) => e.baseField === t && "number" == typeof e.baseItem) && (a.dataFields = e.dataFields.map((e) => e.baseField === t && "number" == typeof e.baseItem ? {
|
|
1568
|
+
...e,
|
|
1569
|
+
baseItem: o[e.baseItem] ?? e.baseItem
|
|
1570
|
+
} : e));
|
|
1571
|
+
const i = s.map((e, n) => n === t ? o : null), l = (e.dataFields ?? []).map((e, t) => t), d = (e) => Xe(e, (e) => e, () => !0, i, l) ?? e;
|
|
1572
|
+
return e.formats && (a.formats = e.formats.map((e) => ({
|
|
1573
|
+
...e,
|
|
1574
|
+
area: d(e.area)
|
|
1575
|
+
}))), e.conditionalFormats && (a.conditionalFormats = e.conditionalFormats.map((e) => ({
|
|
1576
|
+
...e,
|
|
1577
|
+
areas: e.areas.map(d)
|
|
1578
|
+
}))), a;
|
|
1579
|
+
}, et = (e, t, n, s) => {
|
|
1580
|
+
const r = (e.fields ?? [])[n]?.items ?? [], o = G(t)[n] ?? [], a = t.fields?.[n], i = void 0 !== a?.group?.range, l = (e) => void 0 === e.name && I(a, e.item), d = r.map((e, t) => ({
|
|
1581
|
+
item: e,
|
|
1582
|
+
at: t
|
|
1583
|
+
})), u = d.filter((e) => k(e.item));
|
|
1584
|
+
u.sort((e, t) => i ? e.item.item - t.item.item : qe(N(e.item, o), N(t.item, o), l(e.item), l(t.item))), "descending" === s && u.reverse();
|
|
1585
|
+
let c = 0;
|
|
1586
|
+
const f = Ze(e, n, d.map((e) => k(e.item) ? u[c++] : e).map((e) => e.at));
|
|
1587
|
+
return {
|
|
1588
|
+
...f,
|
|
1589
|
+
fields: f.fields.map((e, t) => t === n ? {
|
|
1590
|
+
...e,
|
|
1591
|
+
sort: { order: s }
|
|
1592
|
+
} : e)
|
|
1593
|
+
};
|
|
1594
|
+
}, tt = (n, s, r) => {
|
|
1595
|
+
const o = n.fields?.[s]?.items?.[r];
|
|
1596
|
+
if (!o || !k(o)) throw new t(e("error.pivotTable.changePart"));
|
|
1597
|
+
return o;
|
|
1598
|
+
}, nt = (n, s, r, o, a) => {
|
|
1599
|
+
const i = tt(n, r, o), l = n.fields[r].items, d = G(s)[r] ?? [], u = (e) => {
|
|
1600
|
+
const t = w(d[e.item]);
|
|
1601
|
+
return null === t ? v : H(t);
|
|
1602
|
+
};
|
|
1603
|
+
if (l.some((e, t) => t !== o && k(e) && h(e.name ?? u(e), a))) throw new t(e("error.pivotTable.itemNameExists", { name: a }));
|
|
1604
|
+
const { name: c, ...f } = i, m = a === u(i) ? f : {
|
|
1605
|
+
...i,
|
|
1606
|
+
name: a
|
|
1607
|
+
};
|
|
1608
|
+
if (m.name === i.name) return n;
|
|
1609
|
+
const p = {
|
|
1610
|
+
...n,
|
|
1611
|
+
fields: n.fields.map((e, t) => t === r ? {
|
|
1612
|
+
...e,
|
|
1613
|
+
items: l.map((e, t) => t === o ? m : e)
|
|
1614
|
+
} : e)
|
|
1615
|
+
}, g = n.fields[r].sort;
|
|
1616
|
+
return g && void 0 === g.dataField ? et(p, s, r, g.order) : p;
|
|
1617
|
+
}, st = (e, t, n, s) => {
|
|
1618
|
+
tt(e, t, n);
|
|
1619
|
+
const r = e.fields[t].items.map((e, t) => t).filter((e) => e !== n);
|
|
1620
|
+
r.splice(s, 0, n);
|
|
1621
|
+
const o = e.fields[t].sort;
|
|
1622
|
+
if (!o && r.every((e, t) => e === t)) return e;
|
|
1623
|
+
const a = Ze(e, t, r);
|
|
1624
|
+
return o ? {
|
|
1625
|
+
...a,
|
|
1626
|
+
fields: a.fields.map((e, n) => {
|
|
1627
|
+
if (n !== t) return e;
|
|
1628
|
+
const { sort: s, ...r } = e;
|
|
1629
|
+
return r;
|
|
1630
|
+
})
|
|
1631
|
+
} : a;
|
|
1632
|
+
}, rt = (n, s, r, o) => {
|
|
1633
|
+
const a = H(o), i = n.fields, l = s.fields, u = n.dataFields ?? [], c = G(s), f = (e, t) => {
|
|
1634
|
+
if (void 0 !== t.name) return t.name;
|
|
1635
|
+
const n = w(c[e][t.item]);
|
|
1636
|
+
return null === n ? v : H(n);
|
|
1637
|
+
}, m = (r) => {
|
|
1638
|
+
if (void 0 !== r.field && a === (i[r.field].name ?? l[r.field].name)) return;
|
|
1639
|
+
const o = void 0 === r.field ? n : {
|
|
1640
|
+
...n,
|
|
1641
|
+
fields: i.map((e, t) => t === r.field ? {
|
|
1642
|
+
...e,
|
|
1643
|
+
name: "\0"
|
|
1644
|
+
} : e)
|
|
1645
|
+
};
|
|
1646
|
+
if (d(o, s, a, r.data) !== a) throw new t(e("error.pivotTable.fieldNameExists"));
|
|
1647
|
+
};
|
|
1648
|
+
switch (r.kind) {
|
|
1649
|
+
case "item": {
|
|
1650
|
+
const { field: e, rank: t } = r;
|
|
1651
|
+
tt(n, e, t);
|
|
1652
|
+
const o = i[e].items.findIndex((n, s) => s !== t && k(n) && h(f(e, n), a));
|
|
1653
|
+
return o >= 0 ? st(n, e, o, t) : nt(n, s, e, t, a);
|
|
1654
|
+
}
|
|
1655
|
+
case "fieldCaption": {
|
|
1656
|
+
const { field: e } = r;
|
|
1657
|
+
return m({ field: e }), ((e, t) => ({
|
|
1658
|
+
...n,
|
|
1659
|
+
fields: i.map((n, s) => s === e ? t(n) : n)
|
|
1660
|
+
}))(e, (t) => {
|
|
1661
|
+
const { name: n, ...s } = t;
|
|
1662
|
+
return a === l[e].name ? s : {
|
|
1663
|
+
...t,
|
|
1664
|
+
name: a
|
|
1665
|
+
};
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
case "dataCaption": {
|
|
1669
|
+
const { data: e } = r;
|
|
1670
|
+
return m({ data: e }), {
|
|
1671
|
+
...n,
|
|
1672
|
+
dataFields: u.map((t, n) => n === e ? {
|
|
1673
|
+
...t,
|
|
1674
|
+
name: a
|
|
1675
|
+
} : t)
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
case "rowHeader": return {
|
|
1679
|
+
...n,
|
|
1680
|
+
rowHeaderCaption: a
|
|
1681
|
+
};
|
|
1682
|
+
case "columnHeader": return {
|
|
1683
|
+
...n,
|
|
1684
|
+
columnHeaderCaption: a
|
|
1685
|
+
};
|
|
1686
|
+
case "grandTotal": return {
|
|
1687
|
+
...n,
|
|
1688
|
+
grandTotalCaption: a
|
|
1689
|
+
};
|
|
1690
|
+
case "pageItem": {
|
|
1691
|
+
const s = n.pageFields, o = s[r.page];
|
|
1692
|
+
let l;
|
|
1693
|
+
if (!h(a, "(All)") && (l = (i[o.field].items ?? []).findIndex((e) => k(e) && h(f(o.field, e), a)), l < 0)) throw new t(e("error.pivotTable.notAnItem", { name: a }));
|
|
1694
|
+
const { item: d, ...u } = o, c = void 0 === l ? u : {
|
|
1695
|
+
...o,
|
|
1696
|
+
item: l
|
|
1697
|
+
};
|
|
1698
|
+
return {
|
|
1699
|
+
...n,
|
|
1700
|
+
pageFields: s.map((e, t) => t === r.page ? c : e)
|
|
1701
|
+
};
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
}, ot = (e, t, n) => Ge({
|
|
1705
|
+
cacheId: 0,
|
|
1706
|
+
fields: []
|
|
1707
|
+
}, e, t, n).model, at = (e, t) => t.some((t) => e.fields?.[t]?.inline) ? {
|
|
1708
|
+
...e,
|
|
1709
|
+
fields: e.fields.map((e, n) => {
|
|
1710
|
+
if (!e.inline || !t.includes(n)) return e;
|
|
1711
|
+
const { inline: s, ...r } = e;
|
|
1712
|
+
return r;
|
|
1713
|
+
})
|
|
1714
|
+
} : e, it = (e) => [
|
|
1715
|
+
...e.rowFields ?? [],
|
|
1716
|
+
...e.columnFields ?? [],
|
|
1717
|
+
...(e.pageFields ?? []).map((e) => e.field)
|
|
1718
|
+
].filter((e) => e >= 0), lt = (e, t) => {
|
|
1719
|
+
const n = e.fields[t], s = G(e)[t], r = s.map((e, t) => t);
|
|
1720
|
+
m(n) || r.sort((e, t) => qe(w(s[e]), w(s[t]), I(n, e), I(n, t)));
|
|
1721
|
+
const o = new Set(n.calculatedItems?.map((e) => e.item)), a = new Set(n.unused);
|
|
1722
|
+
return [...r.map((e) => ({
|
|
1723
|
+
item: e,
|
|
1724
|
+
...o.has(e) ? { calculated: !0 } : {},
|
|
1725
|
+
...a.has(e) ? { missing: !0 } : {}
|
|
1726
|
+
})), { type: "default" }];
|
|
1727
|
+
}, dt = (s) => {
|
|
1728
|
+
if (!("number" == typeof s ? void 0 !== o(s) : "" !== s && n.isValidFormat(s))) throw new t(e("error.pivotTable.notANumberFormat", { name: String(s) }));
|
|
1729
|
+
}, ut = (n, s, r, o) => {
|
|
1730
|
+
const a = o?.function ?? ((e, t) => "number" === O(e, t) ? "sum" : "count")(s.fields[r], G(s)[r]), i = z[a];
|
|
1731
|
+
if (!i) throw new t(e("error.pivotTable.notAFunction", { name: a }));
|
|
1732
|
+
let l = o?.name;
|
|
1733
|
+
if (void 0 === l) l = d(n, s, `${i} of ${u(n, s, r)}`);
|
|
1734
|
+
else if (d(n, s, l) !== l) throw new t(e("error.pivotTable.fieldNameExists"));
|
|
1735
|
+
const c = {
|
|
1736
|
+
name: l,
|
|
1737
|
+
field: r,
|
|
1738
|
+
baseField: 0,
|
|
1739
|
+
baseItem: 0
|
|
1740
|
+
};
|
|
1741
|
+
return "sum" !== a && (c.subtotal = a), void 0 !== o?.numberFormat && (dt(o.numberFormat), c.numberFormat = o.numberFormat), c;
|
|
1742
|
+
}, ct = (n, s) => {
|
|
1743
|
+
const r = n.fields ?? [], o = (n) => {
|
|
1744
|
+
const s = r.findIndex((e) => h(e.name, n));
|
|
1745
|
+
if (s < 0) throw new t(e("error.pivotTable.notAField", { name: n }));
|
|
1746
|
+
return s;
|
|
1747
|
+
}, a = /* @__PURE__ */ new Map(), i = (e, t) => {
|
|
1748
|
+
for (const n of e ?? []) {
|
|
1749
|
+
const e = o(n);
|
|
1750
|
+
a.delete(e), a.set(e, t);
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
i(s?.rows, "row"), i(s?.columns, "column"), i(s?.pages, "page");
|
|
1754
|
+
const l = (e) => [...a].filter(([, t]) => t === e).map(([e]) => e), d = [];
|
|
1755
|
+
for (const e of s?.values ?? []) {
|
|
1756
|
+
const { field: t, ...s } = "string" == typeof e ? { field: e } : e;
|
|
1757
|
+
d.push(ut({ dataFields: d }, n, o(t), s));
|
|
1758
|
+
}
|
|
1759
|
+
const u = new Set(d.map((e) => e.field)), c = s?.form && "compact" !== s.form ? s.form : void 0, f = r.map((e, t) => {
|
|
1760
|
+
const s = {}, r = a.get(t);
|
|
1761
|
+
return r && (s.axis = r, s.items = lt(n, t)), u.has(t) && (s.dataField = !0), c && (s.form = c), e.dates && void 0 !== e.numberFormat && (s.numberFormat = e.numberFormat), s;
|
|
1762
|
+
}), m = l("column");
|
|
1763
|
+
d.length > 1 && m.push(-2);
|
|
1764
|
+
const p = {
|
|
1765
|
+
fields: f,
|
|
1766
|
+
style: {
|
|
1767
|
+
name: s?.style ?? "PivotStyleLight16",
|
|
1768
|
+
showRowHeaders: !0,
|
|
1769
|
+
showColumnHeaders: !0,
|
|
1770
|
+
showRowStripes: !1,
|
|
1771
|
+
showColumnStripes: !1,
|
|
1772
|
+
showLastColumn: !0
|
|
1773
|
+
}
|
|
1774
|
+
}, g = l("row");
|
|
1775
|
+
g.length > 0 && (p.rowFields = g), m.length > 0 && (p.columnFields = m);
|
|
1776
|
+
const w = l("page");
|
|
1777
|
+
return w.length > 0 && (p.pageFields = w.map((e) => ({ field: e }))), d.length > 0 && (p.dataFields = d), c && (p.form = c), p;
|
|
1778
|
+
}, ft = (e, t) => t.map((t) => {
|
|
1779
|
+
const n = t.sort?.scope;
|
|
1780
|
+
if (!n) return t;
|
|
1781
|
+
const s = ((t.axis === U.Axis.Row ? e.columnFields : t.axis === U.Axis.Column ? e.rowFields : void 0) ?? []).filter((e) => -2 !== e);
|
|
1782
|
+
if (!n.items.every((e, t) => s[t] === e.field)) {
|
|
1783
|
+
const { sort: e, ...n } = t;
|
|
1784
|
+
return n;
|
|
1785
|
+
}
|
|
1786
|
+
const { subtotal: r, ...o } = n;
|
|
1787
|
+
return {
|
|
1788
|
+
...t,
|
|
1789
|
+
sort: {
|
|
1790
|
+
...t.sort,
|
|
1791
|
+
scope: n.items.length < s.length ? {
|
|
1792
|
+
...o,
|
|
1793
|
+
subtotal: !0
|
|
1794
|
+
} : o
|
|
1795
|
+
}
|
|
1796
|
+
};
|
|
1797
|
+
}), mt = (n, s, r, o, a) => {
|
|
1798
|
+
const i = U.Axis, l = s.fields?.[r], d = n.fields?.[r]?.axis ?? null;
|
|
1799
|
+
if (o === i.Values) throw new t(e("error.pivotTable.valuesNotAnAxis"));
|
|
1800
|
+
if (null === o) {
|
|
1801
|
+
if (null === d) return n;
|
|
1802
|
+
} else if (void 0 !== l?.formula || o === i.Page && (l?.calculatedItems?.length ?? 0) > 0) throw new t(e("error.pivotTable.fieldNotPlaceable"));
|
|
1803
|
+
const u = o ? $(n, o).filter((e) => e !== r) : [];
|
|
1804
|
+
if (void 0 !== a && (!Number.isInteger(a) || a < 1 || a > u.length + 1)) throw new t(e("error.pivotTable.fieldPosition"));
|
|
1805
|
+
const c = (a ?? u.length + 1) - 1;
|
|
1806
|
+
if (o === d && (void 0 === a || $(n, o)[c] === r)) return n;
|
|
1807
|
+
u.splice(c, 0, r);
|
|
1808
|
+
const { rowFields: f, columnFields: m, pageFields: p, ...h } = n, g = {}, w = (e) => (e ?? []).filter((e) => e !== r), v = o === i.Row ? u : w(n.rowFields), F = o === i.Column ? u : w(n.columnFields), b = o === i.Page ? u.map((e) => n.pageFields?.find((t) => t.field === e) ?? { field: e }) : (n.pageFields ?? []).filter((e) => e.field !== r);
|
|
1809
|
+
v.length > 0 && (g.rowFields = v), F.length > 0 && (g.columnFields = F), b.length > 0 && (g.pageFields = b);
|
|
1810
|
+
let I = {
|
|
1811
|
+
...h,
|
|
1812
|
+
...g
|
|
1813
|
+
};
|
|
1814
|
+
o === i.Page && d !== i.Page && (I = y(I, r, () => !0));
|
|
1815
|
+
const x = { ...n.fields?.[r] };
|
|
1816
|
+
o ? x.axis = o : delete x.axis, o && !x.items && l && (x.items = M(lt(s, r), x.subtotals)), o && void 0 === x.numberFormat && l?.dates && void 0 !== l.numberFormat && (x.numberFormat = l.numberFormat), o === i.Page && x.items?.some((e) => e.hidden) && (x.multipleItemSelection = !0);
|
|
1817
|
+
const A = (n.fields ?? []).map((e, t) => t === r ? x : e);
|
|
1818
|
+
if (I = {
|
|
1819
|
+
...I,
|
|
1820
|
+
fields: ft(I, A)
|
|
1821
|
+
}, null === o && n.formats?.some((e) => e.area.references?.some((e) => e.field === r))) {
|
|
1822
|
+
const e = n.formats.filter((e) => !e.area.references?.some((e) => e.field === r)), { formats: t, ...s } = I;
|
|
1823
|
+
I = e.length > 0 ? {
|
|
1824
|
+
...s,
|
|
1825
|
+
formats: e
|
|
1826
|
+
} : s;
|
|
1827
|
+
}
|
|
1828
|
+
return I;
|
|
1829
|
+
}, pt = -2, ht = /* @__PURE__ */ new Set([
|
|
1830
|
+
"percentOfTotal",
|
|
1831
|
+
"percentOfRow",
|
|
1832
|
+
"percentOfCol",
|
|
1833
|
+
"percentOfParentRow",
|
|
1834
|
+
"percentOfParentCol",
|
|
1835
|
+
"percentOfParent",
|
|
1836
|
+
"percentOfRunningTotal",
|
|
1837
|
+
"percent",
|
|
1838
|
+
"percentDiff"
|
|
1839
|
+
]), gt = /* @__PURE__ */ new Set([
|
|
1840
|
+
"index",
|
|
1841
|
+
"rankAscending",
|
|
1842
|
+
"rankDescending"
|
|
1843
|
+
]), wt = /* @__PURE__ */ new Set([
|
|
1844
|
+
...ht,
|
|
1845
|
+
...gt,
|
|
1846
|
+
"runTotal",
|
|
1847
|
+
"difference"
|
|
1848
|
+
]), vt = (e, t) => {
|
|
1849
|
+
const n = 1 === e.references?.length ? e.references[0] : null;
|
|
1850
|
+
return !1 === e.outline && n?.field === pt && 1 === n.items?.length && n.items[0] === t && void 0 === n.selected && !e.type && !e.labelOnly && void 0 === e.dataOnly;
|
|
1851
|
+
}, Ft = (e, t) => {
|
|
1852
|
+
if (!e.formats?.some((e) => vt(e.area, t))) return e;
|
|
1853
|
+
const n = e.formats.filter((e) => !vt(e.area, t)), { formats: s, ...r } = e;
|
|
1854
|
+
return n.length > 0 ? {
|
|
1855
|
+
...r,
|
|
1856
|
+
formats: n
|
|
1857
|
+
} : r;
|
|
1858
|
+
}, bt = (e, t, n) => ({
|
|
1859
|
+
...e,
|
|
1860
|
+
dataFields: e.dataFields.map((e, s) => s === t ? n(e) : e)
|
|
1861
|
+
}), yt = (e, t) => {
|
|
1862
|
+
const { numberFormat: n, ...s } = e;
|
|
1863
|
+
return void 0 === t ? s : {
|
|
1864
|
+
...s,
|
|
1865
|
+
numberFormat: t
|
|
1866
|
+
};
|
|
1867
|
+
}, It = (e, t, n) => {
|
|
1868
|
+
const s = new Set(t.map((e) => e.field)), r = (e.fields ?? []).map((e, t) => {
|
|
1869
|
+
let r = e;
|
|
1870
|
+
if (void 0 !== e.sort?.dataField) {
|
|
1871
|
+
const t = n[e.sort.dataField];
|
|
1872
|
+
if (t < 0) {
|
|
1873
|
+
const { sort: e, ...t } = r;
|
|
1874
|
+
r = t;
|
|
1875
|
+
} else t !== e.sort.dataField && (r = {
|
|
1876
|
+
...r,
|
|
1877
|
+
sort: {
|
|
1878
|
+
...e.sort,
|
|
1879
|
+
dataField: t
|
|
1880
|
+
}
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
if (!!e.dataField !== s.has(t)) {
|
|
1884
|
+
const { dataField: e, ...n } = r;
|
|
1885
|
+
r = s.has(t) ? {
|
|
1886
|
+
...n,
|
|
1887
|
+
dataField: !0
|
|
1888
|
+
} : n;
|
|
1889
|
+
}
|
|
1890
|
+
return r;
|
|
1891
|
+
}), { dataFields: o, filters: a, formats: i, conditionalFormats: l, ...d } = e, u = {
|
|
1892
|
+
...d,
|
|
1893
|
+
fields: r
|
|
1894
|
+
};
|
|
1895
|
+
t.length > 0 && (u.dataFields = t);
|
|
1896
|
+
const c = (e.filters ?? []).flatMap((e) => {
|
|
1897
|
+
if (void 0 === e.dataField) return [e];
|
|
1898
|
+
const t = n[e.dataField];
|
|
1899
|
+
return t < 0 ? [] : [{
|
|
1900
|
+
...e,
|
|
1901
|
+
dataField: t
|
|
1902
|
+
}];
|
|
1903
|
+
});
|
|
1904
|
+
c.length > 0 && (u.filters = c);
|
|
1905
|
+
const f = (e) => Xe(e, (e) => e, () => !0, [], n), m = (e.formats ?? []).flatMap((e) => {
|
|
1906
|
+
const t = f(e.area);
|
|
1907
|
+
return t ? [{
|
|
1908
|
+
...e,
|
|
1909
|
+
area: t
|
|
1910
|
+
}] : [];
|
|
1911
|
+
});
|
|
1912
|
+
m.length > 0 && (u.formats = m);
|
|
1913
|
+
const p = (e.conditionalFormats ?? []).flatMap((e) => {
|
|
1914
|
+
const t = e.areas.flatMap((e) => f(e) ?? []);
|
|
1915
|
+
return t.length > 0 ? [{
|
|
1916
|
+
...e,
|
|
1917
|
+
areas: t
|
|
1918
|
+
}] : [];
|
|
1919
|
+
});
|
|
1920
|
+
return p.length > 0 && (u.conditionalFormats = p), ((e) => {
|
|
1921
|
+
const t = e.dataFields?.length ?? 0, n = e.rowFields?.includes(pt), s = e.columnFields?.includes(pt), { valuesPosition: r, ...o } = e;
|
|
1922
|
+
if (t < 2 && (n || s)) {
|
|
1923
|
+
const t = n ? "rowFields" : "columnFields", s = e[t], r = s.indexOf(pt), a = s.filter((e) => e !== pt), i = {
|
|
1924
|
+
...o,
|
|
1925
|
+
...r < a.length ? { valuesPosition: r } : {}
|
|
1926
|
+
};
|
|
1927
|
+
return a.length > 0 ? i[t] = a : delete i[t], i;
|
|
1928
|
+
}
|
|
1929
|
+
if (t >= 2 && !n && !s) {
|
|
1930
|
+
const t = e.valuesOnRows ? "rowFields" : "columnFields", n = [...e[t] ?? []];
|
|
1931
|
+
return n.splice(Math.min(r ?? n.length, n.length), 0, pt), {
|
|
1932
|
+
...o,
|
|
1933
|
+
[t]: n
|
|
1934
|
+
};
|
|
1935
|
+
}
|
|
1936
|
+
return e;
|
|
1937
|
+
})(u);
|
|
1938
|
+
}, xt = (e, t, n, s) => {
|
|
1939
|
+
const r = mt(e, t, n, null), o = r.dataFields?.length ?? 0, a = ut(r, t, n, s);
|
|
1940
|
+
return It(r, [...r.dataFields ?? [], a], Array.from({ length: o }, (e, t) => t));
|
|
1941
|
+
}, At = (e, t) => {
|
|
1942
|
+
const n = e.dataFields ?? [], s = [], r = [];
|
|
1943
|
+
return n.forEach((e, n) => {
|
|
1944
|
+
void 0 !== t && n !== t ? (s.push(r.length), r.push(e)) : s.push(-1);
|
|
1945
|
+
}), It(e, r, s);
|
|
1946
|
+
}, Ct = (n, s, r) => {
|
|
1947
|
+
const o = n.dataFields ?? [];
|
|
1948
|
+
if (!Number.isInteger(r) || r < 1 || r > o.length) throw new t(e("error.pivotTable.valuePosition"));
|
|
1949
|
+
if (r - 1 === s) return n;
|
|
1950
|
+
const a = o.map((e, t) => t).filter((e) => e !== s);
|
|
1951
|
+
a.splice(r - 1, 0, s);
|
|
1952
|
+
const i = [];
|
|
1953
|
+
return a.forEach((e, t) => {
|
|
1954
|
+
i[e] = t;
|
|
1955
|
+
}), It(n, a.map((e) => o[e]), i);
|
|
1956
|
+
}, Et = (e, t, n, s) => {
|
|
1957
|
+
const r = P(e, t, n, s);
|
|
1958
|
+
return (e.dataFields[n].subtotal ?? "sum") === s ? e : bt(e, n, (e) => {
|
|
1959
|
+
const { subtotal: t, ...n } = e, o = {
|
|
1960
|
+
...n,
|
|
1961
|
+
name: r
|
|
1962
|
+
};
|
|
1963
|
+
return "sum" !== s && (o.subtotal = s), o;
|
|
1964
|
+
});
|
|
1965
|
+
}, St = (n, s, r, o) => {
|
|
1966
|
+
const a = n.dataFields[r], i = a.showDataAs ?? "normal", l = o?.kind ?? "normal";
|
|
1967
|
+
if (o && !wt.has(o.kind)) throw new t(e("error.pivotTable.notAShowAs", { name: o.kind }));
|
|
1968
|
+
const { showDataAs: d, baseField: c, baseItem: f, ...m } = a, p = { ...m };
|
|
1969
|
+
"normal" !== l && (p.showDataAs = l);
|
|
1970
|
+
let g = a.baseField, w = a.baseItem;
|
|
1971
|
+
if (void 0 !== o?.baseField) {
|
|
1972
|
+
const r = o.baseField, a = (s.fields ?? []).findIndex((e, t) => h(u(n, s, t), r));
|
|
1973
|
+
if (a < 0) throw new t(e("error.pivotTable.notAField", { name: r }));
|
|
1974
|
+
a !== g && (g = a, w = 0);
|
|
1975
|
+
}
|
|
1976
|
+
if (void 0 !== o?.baseItem) {
|
|
1977
|
+
const r = g ?? 0;
|
|
1978
|
+
if (h(o.baseItem, "(previous)")) w = "previous";
|
|
1979
|
+
else if (h(o.baseItem, "(next)")) w = "next";
|
|
1980
|
+
else {
|
|
1981
|
+
const a = n.fields?.[r]?.items ? n : { fields: (n.fields ?? []).map((e, t) => t === r ? {
|
|
1982
|
+
...e,
|
|
1983
|
+
items: lt(s, r)
|
|
1984
|
+
} : e) }, i = L(a, s, r).findIndex((e) => null !== e && h(e, o.baseItem));
|
|
1985
|
+
if (i < 0) throw new t(e("error.pivotTable.notAnItem", { name: o.baseItem }));
|
|
1986
|
+
w = i;
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
if (void 0 !== g && (p.baseField = g), void 0 !== w && (p.baseItem = w), l === i) return p.baseField === a.baseField && p.baseItem === a.baseItem ? n : bt(n, r, () => p);
|
|
1990
|
+
const v = ((e, t, n) => {
|
|
1991
|
+
if (gt.has(n)) return gt.has(t) ? e : void 0;
|
|
1992
|
+
const s = ((e) => b(e).replace(/"[^"]*"|\\./g, "").includes("%"))(e);
|
|
1993
|
+
return ht.has(n) ? ht.has(t) || s ? e : 10 : ht.has(t) && s ? void 0 : e;
|
|
1994
|
+
})(a.numberFormat, i, l);
|
|
1995
|
+
return v === a.numberFormat ? bt(n, r, () => p) : bt(Ft(n, r), r, () => yt(p, v));
|
|
1996
|
+
}, Pt = (e, t, n) => {
|
|
1997
|
+
dt(n);
|
|
1998
|
+
const s = b(n), r = e.dataFields[t], o = e.formats?.[e.formats.length - 1];
|
|
1999
|
+
if (b(r.numberFormat) === s && o && vt(o.area, t) && o.style.numberFormat === s) return e;
|
|
2000
|
+
const a = bt(Ft(e, t), t, (e) => yt(e, "General" === s ? void 0 : n));
|
|
2001
|
+
return {
|
|
2002
|
+
...a,
|
|
2003
|
+
formats: [...a.formats ?? [], {
|
|
2004
|
+
style: { numberFormat: s },
|
|
2005
|
+
area: {
|
|
2006
|
+
outline: !1,
|
|
2007
|
+
references: [{
|
|
2008
|
+
field: pt,
|
|
2009
|
+
items: [t]
|
|
2010
|
+
}]
|
|
2011
|
+
}
|
|
2012
|
+
}]
|
|
2013
|
+
};
|
|
2014
|
+
}, kt = (n, s, r) => {
|
|
2015
|
+
if (null === s) return At(n);
|
|
2016
|
+
const o = U.Axis;
|
|
2017
|
+
if (s !== o.Row && s !== o.Column) throw new t(e("error.pivotTable.fieldNotPlaceable"));
|
|
2018
|
+
const a = n.rowFields?.includes(pt) ? o.Row : n.columnFields?.includes(pt) ? o.Column : null;
|
|
2019
|
+
if (!a) throw new t(e("error.pivotTable.fieldPosition"));
|
|
2020
|
+
const i = $(n, s).filter((e) => e !== pt);
|
|
2021
|
+
if (void 0 !== r && (!Number.isInteger(r) || r < 1 || r > i.length + 1)) throw new t(e("error.pivotTable.fieldPosition"));
|
|
2022
|
+
const l = (r ?? i.length + 1) - 1;
|
|
2023
|
+
if (s === a && (void 0 === r || $(n, s)[l] === pt)) return n;
|
|
2024
|
+
i.splice(l, 0, pt);
|
|
2025
|
+
const { rowFields: d, columnFields: u, valuesOnRows: c, ...f } = n, m = $(n, s === o.Row ? o.Column : o.Row).filter((e) => e !== pt), p = { ...f }, h = s === o.Row ? i : m, g = s === o.Column ? i : m;
|
|
2026
|
+
return h.length > 0 && (p.rowFields = [...h]), g.length > 0 && (p.columnFields = [...g]), s === o.Row && (p.valuesOnRows = !0), p;
|
|
2027
|
+
}, Mt = (n, s, r) => {
|
|
2028
|
+
if (r === (n.valuesCaption ?? "Values")) return n;
|
|
2029
|
+
const { valuesCaption: o, ...a } = n, i = {
|
|
2030
|
+
...a,
|
|
2031
|
+
valuesCaption: "\0"
|
|
2032
|
+
};
|
|
2033
|
+
if (d(i, s, r) !== r) throw new t(e("error.pivotTable.fieldNameExists"));
|
|
2034
|
+
return "Values" === r ? a : {
|
|
2035
|
+
...a,
|
|
2036
|
+
valuesCaption: r
|
|
2037
|
+
};
|
|
2038
|
+
};
|
|
2039
|
+
export { xt as addPivotDataField, Ne as anchorPivotPeriods, dt as assertNumberFormat, it as axisFieldsOf, Oe as buildPivotView, Re as evaluatePivotFilters, R as isItemFilter, Ie as layOutPivot, lt as listedItemsOf, Ct as movePivotDataField, mt as movePivotField, st as movePivotItem, kt as movePivotValues, ot as newPivotCache, ct as newPivotTable, _e as readPivotSource, Ge as refreshPivotCache, Qe as remapPivotTable, At as removePivotDataField, nt as renamePivotItem, Mt as renamePivotValues, Ze as reorderPivotItems, Et as setPivotDataFunction, Pt as setPivotDataNumberFormat, St as setPivotDataShowAs, et as sortPivotItemsByLabel, rt as typeOverPivot, at as withListedFields };
|