@sheetxl/studio-vanilla 0.7.28-beta.4 → 0.8.0-beta.10

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.
Files changed (539) hide show
  1. package/browser/esm/-LoBx7J6imeqaxCq.mjs +236 -0
  2. package/browser/esm/8-jmVNNbOHuXFdVQ.mjs +392 -0
  3. package/{cdn/assets/DJSXXWTUJGbXqLLx.js → browser/esm/B00ixdmb8-O5ijEp.mjs} +1 -1
  4. package/browser/esm/{ByJMrAYRARLc7uZQ2.mjs → B0Wjc3lwtjKMwnvn.mjs} +27 -29
  5. package/browser/esm/B3Ii8x6RquHW1jMc.mjs +299 -0
  6. package/{cdn/assets/BF9yh58xfvR0KbSo.js → browser/esm/B7iV5qzlmJlM2nQv.mjs} +179 -202
  7. package/{cdn/assets/C7xBBqvPqat9oEft2.js → browser/esm/BAH_cWcQEIBKWnl6.mjs} +101 -55
  8. package/browser/esm/BAdRecWK1maKGOZd.mjs +142 -0
  9. package/browser/esm/BBjgqNlHm-ssbSAG.mjs +47 -0
  10. package/browser/esm/BCWTI3jdTPG37r8W.mjs +46 -0
  11. package/{cdn/assets/CJGlwQusOCSy9ZAb.js → browser/esm/BMlPFJ1glExv-70Z.mjs} +5 -5
  12. package/browser/esm/{BrUe0MnOhxzeOngn2.mjs → BN2d5U1nw7pRtOrn.mjs} +1 -1
  13. package/browser/esm/BNIInlJQbJjH8B6G.mjs +84250 -0
  14. package/browser/esm/BPrHgyAsm2Htx15h.mjs +67 -0
  15. package/browser/esm/BRfat1fV3oGLwvin.mjs +76 -0
  16. package/browser/esm/{CXDtDYyREwoFwtMJ2.mjs → BSCja5yvevmKZPBB.mjs} +1 -1
  17. package/browser/esm/BThOwSja2ra4xejQ.mjs +6306 -0
  18. package/browser/esm/BVJUL2HhoedhbwVy.mjs +77 -0
  19. package/{cdn/assets/MHuhAgQAA8zcnWkd2.js → browser/esm/BWo1N4YbK_zGU0nu.mjs} +1 -1
  20. package/browser/esm/B_HB4y7AA88Z775Z.mjs +91 -0
  21. package/browser/esm/BaEZmurTZnX_yfKD.mjs +1082 -0
  22. package/browser/esm/BeMLfv6hWo15VCIL.mjs +239 -0
  23. package/browser/esm/{BjYIAiuzZbD-dk822.mjs → BhkeuRcx8RlLCQ5E.mjs} +1 -1
  24. package/browser/esm/Bi5-feQLtwpV6Ai8.mjs +57 -0
  25. package/browser/esm/BlPn_DXaEXOPxMxC.mjs +540 -0
  26. package/{cdn/assets/DY9zG4TdF0FAs_QP2.js → browser/esm/BsUrrzAgfyAdcCJW.mjs} +28 -13
  27. package/{cdn/assets/CBC_MJL6Bwk7bzQz2.js → browser/esm/BtGmrIqU9W1L8zfZ.mjs} +1 -1
  28. package/browser/esm/BtdRr6IbtO6Gypsk.mjs +27 -0
  29. package/browser/esm/BwOxnbR61WFJwy0A.mjs +607 -0
  30. package/browser/esm/BxhKgo_rPQ2d12HT.mjs +35 -0
  31. package/browser/esm/By3a43qwWICwXRmw.mjs +8035 -0
  32. package/browser/esm/{Cd8G1nX1dKzp-mho2.mjs → ByUcqyCNfqi5Mm7w.mjs} +2 -2
  33. package/{cdn/assets/DP9sLYfGGWMDI7hL2.js → browser/esm/ByqhqEMBLrnkaPKE.mjs} +26 -26
  34. package/browser/esm/{5LJ1sC7IPn109Ien.mjs → C-0viTjg1dT2F-sk.mjs} +2 -2
  35. package/browser/esm/{DnMUizHKSRwWpO_7.mjs → C3r_9RqlWrEmlXZ1.mjs} +37 -3
  36. package/browser/esm/C4VT6lNbpaDXCpBb.mjs +8820 -0
  37. package/browser/esm/{B3tC7wY_kUGXf5sb2.mjs → C5EKgE9Owsc_juw-.mjs} +1 -1
  38. package/{cdn/assets/BzktrYJH7SQ9GyUI2.js → browser/esm/C9NyIoUahFiyRCxP.mjs} +2 -2
  39. package/{cdn/assets/D5BuXc-kVnr6Xiae2.js → browser/esm/CBdNC7BOfc5TewHU.mjs} +1 -1
  40. package/browser/esm/CCd192S7yVpc6iOe.mjs +118 -0
  41. package/browser/esm/{Eszk9OugmYOhaS2s.mjs → CDsuiN--qdALFyql.mjs} +179 -202
  42. package/{cdn/assets/DtkqR-Hu7K4agnCs2.js → browser/esm/CFvKDDbrL3wpXnQH.mjs} +1 -1
  43. package/browser/esm/{DjS4iUli-T3uuUfK.mjs → CHMqT9DzYKTxPfP6.mjs} +2 -2
  44. package/{cdn/assets/BetL7yI63lEdQ0gM2.js → browser/esm/CMxbiQ5J79M3n1tk.mjs} +604 -405
  45. package/{cdn/assets/B4fSPDN923nqCDVE.js → browser/esm/CQOyeq_-pg3CM-uA.mjs} +6 -7
  46. package/browser/esm/CQuv-nk5jtXUfu7C.mjs +7 -0
  47. package/browser/esm/CRAzVh3CaAa16avf.mjs +521 -0
  48. package/browser/esm/{g8dDbkwbYjhKWJM22.mjs → CSEMxasVyGCekxKf.mjs} +6 -7
  49. package/browser/esm/CTI-mCJbJzitJZwj.mjs +25 -0
  50. package/browser/esm/{DrKUGkrCTKZHu8XC.mjs → CTdFZ_I-41Vr6Dy4.mjs} +1 -1
  51. package/browser/esm/CVcCUfSRsiZ1-6hs.mjs +119 -0
  52. package/browser/esm/CVxlfyE-gnJM8hOz.mjs +177 -0
  53. package/browser/esm/CWJzHmEgahdOfNjH.mjs +527 -0
  54. package/browser/esm/CWoPWWRwMgkGPFFP.mjs +7393 -0
  55. package/browser/esm/CZOJogyZqMfUxcXj.mjs +1141 -0
  56. package/{cdn/assets/Dy5Z2XIqS7-0tdjc2.js → browser/esm/CaS8_J5HfBRk5_Nw.mjs} +86 -86
  57. package/browser/esm/CdeXXPCp5cCYvGyD.mjs +14 -0
  58. package/browser/esm/{B9t9fF8FNCLomgK_.mjs → CfltjY8hY-RPwwpd.mjs} +582 -551
  59. package/browser/esm/Chr_TXM-48IsK8Va.mjs +155 -0
  60. package/browser/esm/{Ca6NSkWoi9DvRJjQ.mjs → ClJvUf8aR8vNC_3Z.mjs} +6 -6
  61. package/browser/esm/Clx8vvGDOTWK_M2l.mjs +484 -0
  62. package/browser/esm/CnWNviK4qlX2GVl6.mjs +73 -0
  63. package/browser/esm/{BsP1iPcd49wYIIoP.mjs → Cpza4AeltEVHASij.mjs} +3 -3
  64. package/browser/esm/{Dwko6HB2zePBBeBu2.mjs → CqoHxlGpZ3yzPj5V.mjs} +22 -21
  65. package/browser/esm/{XBb7Mxqf0beXaSJt.mjs → CtZPEkaldpJpoGtW.mjs} +2197 -2011
  66. package/browser/esm/CvWGtHslTdesJik-.mjs +69 -0
  67. package/browser/esm/Cw-4uoMuq_m7ziA3.mjs +36 -0
  68. package/browser/esm/CxCipDFamYSOctBo.mjs +299 -0
  69. package/browser/esm/Cy00y9b9j17Txyv1.mjs +466 -0
  70. package/browser/esm/D-55MlIn7Wo_hdjI.mjs +905 -0
  71. package/browser/esm/D-9f1NKcpuYSgond.mjs +412 -0
  72. package/browser/esm/D-KZpU6HMaP4VUva.mjs +357 -0
  73. package/browser/esm/D0r2MPlWLnStWJNW.mjs +622 -0
  74. package/browser/esm/{CXlA71yGA1Hqvp_S.mjs → D2aQPiGg0ZoMYzuf.mjs} +22 -21
  75. package/{cdn/assets/KJzdwvEWwCwAXuo4.js → browser/esm/D2coM-dNrlLpnUu5.mjs} +1000 -1010
  76. package/browser/esm/D7CGuQcwpkiuesEI.mjs +229 -0
  77. package/browser/esm/{BQt5lpPjssz4Lvhs.mjs → D7DWH3-5fBNx8jtc.mjs} +182 -132
  78. package/browser/esm/D7kkzIFPqKBK94kO.mjs +17952 -0
  79. package/browser/esm/D88StfSjZJi5E8Xb.mjs +5153 -0
  80. package/browser/esm/D8exjrado9TJrBp-.mjs +1946 -0
  81. package/browser/esm/DAE3Kv0Vs0VuBecT.mjs +32 -0
  82. package/browser/esm/DAprxR00V9qvNLL2.mjs +6607 -0
  83. package/browser/esm/DEvZj68igS7Q8SZE.mjs +763 -0
  84. package/browser/esm/DG3BfxRsbjey-B7E.mjs +441 -0
  85. package/browser/esm/DGCOPbZbEmt0x9z0.mjs +155 -0
  86. package/browser/esm/DGcvio2uhlrsE3ZY.mjs +236 -0
  87. package/browser/esm/DGuynZFJ9tqziqQs.mjs +92 -0
  88. package/browser/esm/DJqj66SnUcx0QmSN.mjs +15 -0
  89. package/browser/esm/DLhK_oSGg71ry6-m.mjs +86 -0
  90. package/browser/esm/{B_U_UpQXdbjNRthb.mjs → DLqc11Pf8vaE4Q5B.mjs} +2 -2
  91. package/browser/esm/DNCqTF9EbT-U1TdV.mjs +20 -0
  92. package/browser/esm/{DM4g0nYgYXgI44dL2.mjs → DNaPo7BQu6hr1fWq.mjs} +1 -1
  93. package/{cdn/assets/DRAYZ0SGlbCLkftR.js → browser/esm/DQEjvIGMgEkiaP6J.mjs} +1 -1
  94. package/browser/esm/{Ykh10IaXTKA2XWot.mjs → DQIRFXG4MveFkK3I.mjs} +1 -1
  95. package/{cdn/assets/DJk14sSSnSHiEXZ7.js → browser/esm/DRm1R4uVOkaMfXNI.mjs} +51 -11
  96. package/browser/esm/DSf-Db1h8rlW2A6n.mjs +122 -0
  97. package/browser/esm/DSviq1TNoiIAGW7W.mjs +32 -0
  98. package/{cdn/assets/CuIUyLNDoHvYMJaQ2.js → browser/esm/DTn9oYyiIYgyijAk.mjs} +110 -83
  99. package/browser/esm/{BxecIrskOMQZB-Xc.mjs → DVpi1vC8ixXvUQG_.mjs} +3 -3
  100. package/browser/esm/{esX6dx06TUUL-cRt.mjs → DWgp4t9N9u0eWthH.mjs} +1 -1
  101. package/browser/esm/{DLArQtAbWAarI8od2.mjs → DXo8mR6t5HGsmTcu.mjs} +1 -1
  102. package/browser/esm/DZRmBfjn2TgOTu5e.mjs +3604 -0
  103. package/browser/esm/{BJQfvwvEke-uN0_02.mjs → D_7BWdsu8yejhUxy.mjs} +184 -11
  104. package/browser/esm/D_thhK0vSez8Yfle.mjs +798 -0
  105. package/browser/esm/DaMKWQQTgIF08cT7.mjs +105 -0
  106. package/browser/esm/Db6Tvr45TS9J5Qsb.mjs +259 -0
  107. package/browser/esm/{Bc2Dp6W4U_22cv7c.mjs → Dc2ZwgbIEgYWwAsF.mjs} +1 -1
  108. package/{cdn/assets/BGWyNjrM55ce-D1o.js → browser/esm/DeUXRggj8Oz9ru_i.mjs} +2 -2
  109. package/{cdn/assets/CmYCYFWjq9KP6xw7.js → browser/esm/DfESVLC8CAi8m8A7.mjs} +6 -6
  110. package/browser/esm/{hsy1zALC1oNNm5Sf.mjs → DjdkGy-EI1kSo226.mjs} +7 -5
  111. package/browser/esm/DjtXfgbmXjUAoG0y.mjs +58 -0
  112. package/browser/esm/DlOVZD0OiAjouS6-.mjs +3563 -0
  113. package/browser/esm/Dme0qpRinBnhzp53.mjs +519 -0
  114. package/browser/esm/DnyZmrwPxShyeUjm.mjs +849 -0
  115. package/browser/esm/DoS1sE431fEhdOQb.mjs +216 -0
  116. package/browser/esm/DqBj-9o7UdXu4qhb.mjs +33 -0
  117. package/{cdn/assets/FVJ1akngxeMiYwPa.js → browser/esm/DrI_S0A9TQvriTua.mjs} +1 -1
  118. package/browser/esm/Dv2z0548SZRGTN3l.mjs +149 -0
  119. package/browser/esm/{Bjx-9lUaScF5-Hki2.mjs → Dv8aQFTTaQBJKDDk.mjs} +2 -5
  120. package/browser/esm/DvWCBuY0jAL-RmJV.mjs +3363 -0
  121. package/browser/esm/Dwxz0s23ra1tRtsH.mjs +7 -0
  122. package/{cdn/assets/D4aK0uTRJQpM63922.js → browser/esm/DxcRLd7wmBGDgJsA.mjs} +1 -1
  123. package/{cdn/assets/CIgn8uIPaadIJP4a2.js → browser/esm/DxwprgjYhcmfDbXH.mjs} +24 -24
  124. package/browser/esm/{DENx9Ts-f8adXw3Y2.mjs → Dy44qJVkwNseMG-3.mjs} +1 -1
  125. package/browser/esm/DyeY6XwMQ_XNUHiW.mjs +89 -0
  126. package/browser/esm/{BOMct7uvqiNJIS63.mjs → ErIXJFPDFXwGEL8V.mjs} +2 -2
  127. package/browser/esm/{C4vqrW3EmJDy1otX.mjs → FO1Jezau486fH4kN.mjs} +7 -6
  128. package/browser/esm/FjNOhkR7-JAIaRP6.mjs +19 -0
  129. package/browser/esm/H-JnJQMcZQbpvjdb.mjs +2706 -0
  130. package/browser/esm/J9i3r1fU0H10b2hX.mjs +1001 -0
  131. package/browser/esm/LAbUYeLiPG8z9cmA.mjs +277 -0
  132. package/browser/esm/M7RYrx20B_Yl_euJ.mjs +400 -0
  133. package/browser/esm/{PzCXbVRf1jOHVOAw.mjs → PtGiIWFBYP-ujLmf.mjs} +1 -1
  134. package/browser/esm/RLU85PsAYtKPUf6N.mjs +71 -0
  135. package/browser/esm/{CTwLETvNO4KeXbkK2.mjs → RfHd1JATBlcsfLPv.mjs} +5 -5
  136. package/{cdn/assets/Bce8ZTUCpXr5Y_zl2.js → browser/esm/SNze-adFJwKuGSQW.mjs} +48 -2
  137. package/browser/esm/UTZcodQydbuMfCOS.mjs +171 -0
  138. package/{cdn/assets/BGAXiHOiX_PZ1ww1.js → browser/esm/VwGokBaawZfZiV2X.mjs} +1 -1
  139. package/browser/esm/WMYR09ZOR8JbZEnx.mjs +4748 -0
  140. package/browser/esm/{DOIVDuyf7YyJZjcD.mjs → ZbGPiRN9j0629JJQ.mjs} +2 -2
  141. package/{cdn/assets/BPAEbeXV75XIAS4n.js → browser/esm/ZxsFYopF0_WWqw4Q.mjs} +1 -1
  142. package/browser/esm/_MPToH4oMe4rhTdZ.mjs +63 -0
  143. package/browser/esm/{L6LjzOx1G9Idjtxa2.mjs → _t0Mx-mUFVtmVNkU.mjs} +2 -2
  144. package/{cdn/assets/CgsQuAbp76UOAPHm2.js → browser/esm/_zRV52yhE4gPf3XI.mjs} +211 -189
  145. package/browser/esm/aUREGNA8H7p4BpMK.mjs +33 -0
  146. package/browser/esm/cwuYkcKwsKkPe3gG.mjs +598 -0
  147. package/browser/esm/{CY4ANhbzXqZMJPnL2.mjs → djM9mJznx8GzVq51.mjs} +16 -15
  148. package/browser/esm/{6A8iYjFWJzx5PaTP2.mjs → f1OJemsiZnbwnds-.mjs} +16 -15
  149. package/{cdn/assets/DOsKUeLPwFIdzQv32.js → browser/esm/i0P63Wd0RRlgJotb.mjs} +1 -1
  150. package/browser/esm/{BZSAb1WGbwagUKGv2.mjs → iC69oOND5T8khIWf.mjs} +18 -17
  151. package/browser/esm/index.mjs +644 -48
  152. package/browser/esm/{pFBVGSvmImMMDMuJ.mjs → kVBPUUnVyZfb8pf3.mjs} +52 -52
  153. package/browser/esm/{BZkd8LNLgEd5WQXO2.mjs → lqknEt3DTma5Juxs.mjs} +69 -4
  154. package/browser/esm/mZ92wNrHVpYdli1U.mjs +182 -0
  155. package/browser/esm/{CBuulf8RrSItPZJi.mjs → pKc_RPdZPLAgvNDh.mjs} +2 -2
  156. package/{cdn/assets/D2Ls6urWeByV5W-B.js → browser/esm/pc49xtHdprXZLW2X.mjs} +1 -1
  157. package/browser/esm/px-aQ8dMjiWag_pV.mjs +167 -0
  158. package/browser/esm/qYca4mdySLkACfo1.mjs +37 -0
  159. package/browser/esm/r2Az2Yc4_qj2-sn0.mjs +398 -0
  160. package/browser/esm/{CHmSnCPoww1StSta.mjs → rY-dC3WB558TIbum.mjs} +4 -4
  161. package/browser/esm/rkTVQiYG3wd8oPom.mjs +2452 -0
  162. package/browser/esm/sDVzjXC1mS5rucF5.mjs +2447 -0
  163. package/browser/esm/sxxbiJiCMOW2Eivd.mjs +24952 -0
  164. package/{cdn/assets/BZXvEddjoz4C8y4w.js → browser/esm/vGKTE7yjY8y-XnsW.mjs} +16 -11
  165. package/{cdn/assets/BRBHACVjnV1_6VLQ.js → browser/esm/x6GcENwqoUVbd60j.mjs} +1 -1
  166. package/{cdn/assets/CsKCqLuggHhYC93k.js → browser/esm/ycmpAs4kQfeh78Pa.mjs} +1 -1
  167. package/browser/esm/ztqpWR65YYMZ3EPk.mjs +811 -0
  168. package/cdn/assets/0vqRTRN0wEzWao1c.js +522 -0
  169. package/cdn/assets/514mXPTuNvdNgw35.js +412 -0
  170. package/{browser/esm/B6bX01HNxwBooBTX2.mjs → cdn/assets/7Sg0ht_ZCMJkPurt.js} +89 -87
  171. package/cdn/assets/{CY7qR8ENX314HrrD.js → 7i4WSxDsu2ApJJ2_.js} +6 -6
  172. package/cdn/assets/AjMG7Fb9r4Fk7Hsf.js +78 -0
  173. package/{browser/esm/DJSXXWTUJGbXqLLx.mjs → cdn/assets/B00ixdmb8-O5ijEp.js} +1 -1
  174. package/cdn/assets/{ByJMrAYRARLc7uZQ.js → B0Wjc3lwtjKMwnvn.js} +27 -29
  175. package/cdn/assets/B27vTQlxbHhSQJx8.js +24953 -0
  176. package/cdn/assets/B3NWCYKXucbHhOix.js +93 -0
  177. package/{browser/esm/C7xBBqvPqat9oEft.mjs → cdn/assets/BAH_cWcQEIBKWnl6.js} +101 -55
  178. package/cdn/assets/BAdRecWK1maKGOZd.js +142 -0
  179. package/cdn/assets/BB4MW8sSYEXjPvvf.js +64 -0
  180. package/cdn/assets/BBjgqNlHm-ssbSAG.js +47 -0
  181. package/cdn/assets/BI6afPOpgNYkzIWv.js +6609 -0
  182. package/cdn/assets/{Dgt8kua8CYlMRfdw.js → BIsbcP5RXRU2XPfx.js} +2 -2
  183. package/{browser/esm/CJGlwQusOCSy9ZAb2.mjs → cdn/assets/BMlPFJ1glExv-70Z.js} +5 -5
  184. package/cdn/assets/{BrUe0MnOhxzeOngn.js → BN2d5U1nw7pRtOrn.js} +1 -1
  185. package/cdn/assets/BNsqqoZY7a4N1wWC.js +905 -0
  186. package/cdn/assets/BPrHgyAsm2Htx15h.js +67 -0
  187. package/cdn/assets/{CXDtDYyREwoFwtMJ.js → BSCja5yvevmKZPBB.js} +1 -1
  188. package/{browser/esm/MHuhAgQAA8zcnWkd.mjs → cdn/assets/BWo1N4YbK_zGU0nu.js} +1 -1
  189. package/cdn/assets/B_3Musz0q2MSZ5H-.js +799 -0
  190. package/cdn/assets/Ba8taVvLslFcKS72.js +119 -0
  191. package/cdn/assets/{B0N6rTGGJN2DZPaf.js → BeQ95CzwR65il0CK.js} +2 -2
  192. package/cdn/assets/BelX6bvQPsGuo-x3.js +7 -0
  193. package/cdn/assets/{DGWhm91XZlY1GWHe2.js → Bgbi7BFR3rN5qj51.js} +22 -21
  194. package/cdn/assets/BgyY4zVPZSXljoCZ.js +14 -0
  195. package/cdn/assets/{BjYIAiuzZbD-dk82.js → BhkeuRcx8RlLCQ5E.js} +1 -1
  196. package/cdn/assets/BlIZ30huelIxNo6S.js +91 -0
  197. package/cdn/assets/BlPn_DXaEXOPxMxC.js +540 -0
  198. package/cdn/assets/BoFx07POTorOb5g-.js +7393 -0
  199. package/cdn/assets/{hClmI7sWeaBbHo3W2.js → BpZ7P0CO148rR4zW.js} +24 -23
  200. package/cdn/assets/BsTFy_iJXJYmaO3Z.js +763 -0
  201. package/cdn/assets/{DiKc6jzGM1isrN02.js → Bsn-tUx172sEG2kR.js} +59 -47
  202. package/{browser/esm/CBC_MJL6Bwk7bzQz.mjs → cdn/assets/BtGmrIqU9W1L8zfZ.js} +1 -1
  203. package/cdn/assets/BuYS_ZjSlcvWZ1JC.js +8035 -0
  204. package/cdn/assets/BvlfKrfrDhE9Jw4d.js +598 -0
  205. package/cdn/assets/BwOxnbR61WFJwy0A.js +607 -0
  206. package/cdn/assets/BxqXOiOyI_XiOmvN.js +156 -0
  207. package/cdn/assets/{Cd8G1nX1dKzp-mho.js → ByUcqyCNfqi5Mm7w.js} +2 -2
  208. package/{browser/esm/D8zyGG6yt4CsyA8K.mjs → cdn/assets/BzbP4jaN13wC9aSi.js} +58 -55
  209. package/cdn/assets/{5LJ1sC7IPn109Ien.js → C-0viTjg1dT2F-sk.js} +2 -2
  210. package/cdn/assets/C0CeCYdLWLjySEFe.js +123 -0
  211. package/cdn/assets/{DjfBSoaKM-vtbeqT.js → C32co-XulWTkEKrW.js} +2 -2
  212. package/cdn/assets/{DnMUizHKSRwWpO_72.js → C3r_9RqlWrEmlXZ1.js} +37 -3
  213. package/cdn/assets/{B3tC7wY_kUGXf5sb.js → C5EKgE9Owsc_juw-.js} +1 -1
  214. package/cdn/assets/C6INLvBy8kdzFpsX.js +2447 -0
  215. package/cdn/assets/C7fu6LrSMBlHqwUy.js +46 -0
  216. package/{browser/esm/BzktrYJH7SQ9GyUI.mjs → cdn/assets/C9NyIoUahFiyRCxP.js} +2 -2
  217. package/{browser/esm/D5BuXc-kVnr6Xiae.mjs → cdn/assets/CBdNC7BOfc5TewHU.js} +1 -1
  218. package/cdn/assets/{DJHOKENCVOJMx3aE2.js → CCvBdPu7W2ZF6A9J.js} +9 -9
  219. package/{browser/esm/DmqS0kz7jvlOw3qr.mjs → cdn/assets/CDAYVaQYywqaxg4O.js} +28 -13
  220. package/cdn/assets/CEYyp6Qrr_IopxpL.js +22597 -0
  221. package/cdn/assets/CFBgmXap8kmumhoz.js +622 -0
  222. package/{browser/esm/DtkqR-Hu7K4agnCs.mjs → cdn/assets/CFvKDDbrL3wpXnQH.js} +1 -1
  223. package/{browser/esm/BBhB25AlKEzdoI0V.mjs → cdn/assets/CHMqT9DzYKTxPfP6.js} +2 -2
  224. package/cdn/assets/CILUMtSddGz7WXEv.js +240 -0
  225. package/cdn/assets/{BynqRVXFRplO7XgC.js → CIyaijfp6itgRpFM.js} +95 -87
  226. package/cdn/assets/{DpNYiOK112bFC3KK2.js → CL6Tgu_rUO6G-fyq.js} +183 -10
  227. package/cdn/assets/CMVTwWHsRgyfSEDM.js +300 -0
  228. package/{browser/esm/BetL7yI63lEdQ0gM.mjs → cdn/assets/CMxbiQ5J79M3n1tk.js} +604 -405
  229. package/cdn/assets/COMOqucXq7X1vi0P.js +230 -0
  230. package/{browser/esm/B4fSPDN923nqCDVE2.mjs → cdn/assets/CQOyeq_-pg3CM-uA.js} +6 -7
  231. package/cdn/assets/{DaX0_AkJxkaUnNT7.js → CRXSrbGNABtzf532.js} +141 -126
  232. package/cdn/assets/{g8dDbkwbYjhKWJM2.js → CSEMxasVyGCekxKf.js} +6 -7
  233. package/cdn/assets/CSIZpJClc66_20kP.js +849 -0
  234. package/cdn/assets/CTI-mCJbJzitJZwj.js +25 -0
  235. package/cdn/assets/{DrKUGkrCTKZHu8XC.js → CTdFZ_I-41Vr6Dy4.js} +1 -1
  236. package/cdn/assets/CTvPIYWTcjwlJeEA.js +237 -0
  237. package/cdn/assets/CU5cKipVT1X8Xz7F.js +156 -0
  238. package/cdn/assets/CVcCUfSRsiZ1-6hs.js +119 -0
  239. package/cdn/assets/CWJzHmEgahdOfNjH.js +527 -0
  240. package/cdn/assets/CZOJogyZqMfUxcXj.js +1141 -0
  241. package/{browser/esm/DER7-kADXFnTmK-32.mjs → cdn/assets/CakrxSS_RXtKmcUX.js} +123 -94
  242. package/cdn/assets/{Bj8bWbLg1IY965tK.js → CbTN0q6XnYGJqyEp.js} +2215 -2029
  243. package/cdn/assets/{DQhvG3cP0HPB6giA2.js → Cfg4Dtndwurxv9LM.js} +8 -8
  244. package/{browser/esm/BgwHVPZp494SgQ0d2.mjs → cdn/assets/ChAKLV5zrGAHAof2.js} +44 -42
  245. package/cdn/assets/{BO2NRW9sjHGE9tg-2.js → CsrTRThObSryov1b.js} +182 -132
  246. package/cdn/assets/Cv5PLuhEmh5IDHjb.js +75 -0
  247. package/cdn/assets/Cw-4uoMuq_m7ziA3.js +36 -0
  248. package/cdn/assets/Cw7AJWd0S2sjRmr6.js +6309 -0
  249. package/cdn/assets/CwqRA5h1u92Cyit-.js +7 -0
  250. package/cdn/assets/Cy00y9b9j17Txyv1.js +466 -0
  251. package/cdn/assets/{CnfGgjuCEyX-PYs_2.js → D-bNmX0QsA8SuT0m.js} +33 -32
  252. package/{browser/esm/PAu9erpoOTNzgNbN.mjs → cdn/assets/D-yz3V2UC54rwctD.js} +16 -11
  253. package/cdn/assets/D32D_biNXRCZ24vG.js +87 -0
  254. package/cdn/assets/D8DghdqjOtBzO2Wx.js +35 -0
  255. package/cdn/assets/DAE3Kv0Vs0VuBecT.js +32 -0
  256. package/cdn/assets/DCnWyVXikb_8Dat3.js +61 -0
  257. package/cdn/assets/DHH_uKVzQ_kRYO2N.js +57 -0
  258. package/cdn/assets/DHugYwX4_ZyqGn-C.js +1947 -0
  259. package/cdn/assets/DJqj66SnUcx0QmSN.js +15 -0
  260. package/cdn/assets/{DM4g0nYgYXgI44dL.js → DNaPo7BQu6hr1fWq.js} +1 -1
  261. package/cdn/assets/DOHh3pUXxMM09UY5.js +3604 -0
  262. package/cdn/assets/DONxZZT2Iwu7psS5.js +27 -0
  263. package/{browser/esm/DRAYZ0SGlbCLkftR2.mjs → cdn/assets/DQEjvIGMgEkiaP6J.js} +1 -1
  264. package/cdn/assets/{Ykh10IaXTKA2XWot2.js → DQIRFXG4MveFkK3I.js} +1 -1
  265. package/cdn/assets/DQjxp9lDP9DzP8ah.js +357 -0
  266. package/{browser/esm/DJk14sSSnSHiEXZ72.mjs → cdn/assets/DRm1R4uVOkaMfXNI.js} +51 -11
  267. package/cdn/assets/DSXJHEORGmMQX_Mb.js +8391 -0
  268. package/cdn/assets/DSviq1TNoiIAGW7W.js +32 -0
  269. package/cdn/assets/{BxecIrskOMQZB-Xc.js → DVpi1vC8ixXvUQG_.js} +3 -3
  270. package/cdn/assets/{esX6dx06TUUL-cRt.js → DWgp4t9N9u0eWthH.js} +1 -1
  271. package/cdn/assets/{DLArQtAbWAarI8od.js → DXo8mR6t5HGsmTcu.js} +1 -1
  272. package/cdn/assets/DYvBgX17ZerZSHEJ.js +300 -0
  273. package/cdn/assets/DZRm4H75lnEtOG8e.js +260 -0
  274. package/cdn/assets/D_pMOq6FdH4RSBLc.js +3364 -0
  275. package/cdn/assets/{Bc2Dp6W4U_22cv7c2.js → Dc2ZwgbIEgYWwAsF.js} +1 -1
  276. package/cdn/assets/DckmFyHxGX4Y1gOq.js +70 -0
  277. package/cdn/assets/{D-tQc4bi3FzGVnFg.js → De2z8LdHaWRFiR5T.js} +179 -202
  278. package/{browser/esm/BGWyNjrM55ce-D1o2.mjs → cdn/assets/DeUXRggj8Oz9ru_i.js} +2 -2
  279. package/{browser/esm/CmYCYFWjq9KP6xw72.mjs → cdn/assets/DfESVLC8CAi8m8A7.js} +6 -6
  280. package/cdn/assets/DicTo_3G-KZyWDiE.js +1084 -0
  281. package/cdn/assets/{hsy1zALC1oNNm5Sf.js → DjdkGy-EI1kSo226.js} +7 -5
  282. package/cdn/assets/DjtXfgbmXjUAoG0y.js +58 -0
  283. package/cdn/assets/DlpgIJxNq2V4gdDq.js +74 -0
  284. package/cdn/assets/{Bh4hZt6639QZusIG.js → Dp-GJXOMz_b8qAxD.js} +2 -2
  285. package/cdn/assets/DqBj-9o7UdXu4qhb.js +33 -0
  286. package/{browser/esm/FVJ1akngxeMiYwPa.mjs → cdn/assets/DrI_S0A9TQvriTua.js} +1 -1
  287. package/cdn/assets/DuAbY54w5gJpQgss.js +84250 -0
  288. package/cdn/assets/{Bjx-9lUaScF5-Hki.js → Dv8aQFTTaQBJKDDk.js} +2 -5
  289. package/cdn/assets/DviEoeWW0EvDg1hr.js +149 -0
  290. package/{browser/esm/D4aK0uTRJQpM6392.mjs → cdn/assets/DxcRLd7wmBGDgJsA.js} +1 -1
  291. package/cdn/assets/DxisV9_27l_WU-nk.js +21 -0
  292. package/cdn/assets/{DENx9Ts-f8adXw3Y.js → Dy44qJVkwNseMG-3.js} +1 -1
  293. package/cdn/assets/ENtt4kmaU9mJfVEp.js +236 -0
  294. package/cdn/assets/{C4vqrW3EmJDy1otX.js → FO1Jezau486fH4kN.js} +7 -6
  295. package/cdn/assets/FjNOhkR7-JAIaRP6.js +19 -0
  296. package/{browser/esm/BmTSjuGI87QqMA-a.mjs → cdn/assets/G5z0uVlyF6CLw_PA.js} +179 -202
  297. package/cdn/assets/H-JnJQMcZQbpvjdb.js +2706 -0
  298. package/cdn/assets/J3hutJxqQiHENpIe.js +392 -0
  299. package/cdn/assets/J9i3r1fU0H10b2hX.js +1001 -0
  300. package/cdn/assets/{PzCXbVRf1jOHVOAw.js → PtGiIWFBYP-ujLmf.js} +1 -1
  301. package/cdn/assets/PzWqv-oXxEuzKdaT.js +484 -0
  302. package/cdn/assets/QJ4AkDD269D1MzmI.js +89 -0
  303. package/cdn/assets/{CTwLETvNO4KeXbkK.js → RfHd1JATBlcsfLPv.js} +5 -5
  304. package/{browser/esm/Bce8ZTUCpXr5Y_zl.mjs → cdn/assets/SNze-adFJwKuGSQW.js} +48 -2
  305. package/cdn/assets/UTZcodQydbuMfCOS.js +171 -0
  306. package/{browser/esm/DSWdYe7SDB5cYWo5.mjs → cdn/assets/VCiu_neIjCTg2NUa.js} +998 -1006
  307. package/{browser/esm/BGAXiHOiX_PZ1ww12.mjs → cdn/assets/VwGokBaawZfZiV2X.js} +1 -1
  308. package/cdn/assets/W1d6GQyySAHrtjEu.js +3563 -0
  309. package/cdn/assets/ZSYS1J3uR7UQuHwZ.js +217 -0
  310. package/{browser/esm/BPAEbeXV75XIAS4n2.mjs → cdn/assets/ZxsFYopF0_WWqw4Q.js} +1 -1
  311. package/cdn/assets/{L6LjzOx1G9Idjtxa.js → _t0Mx-mUFVtmVNkU.js} +2 -2
  312. package/cdn/assets/aHTKr1ijZ6bRi3Zg.js +33 -0
  313. package/cdn/assets/anQDUZhHMDPi1eha.js +812 -0
  314. package/cdn/assets/{Dr1U0I01_KIa9vgR2.js → dn69mDhY7Xcc91kF.js} +20 -19
  315. package/cdn/assets/fm3mUdTDo-STB36M.js +4749 -0
  316. package/cdn/assets/gpQ4FdJMbIScKnS_.js +400 -0
  317. package/cdn/assets/{DeFts-aGqB-RDuV1.js → hg8WYI0Yy4WPPPoP.js} +28 -27
  318. package/{browser/esm/DOsKUeLPwFIdzQv32.mjs → cdn/assets/i0P63Wd0RRlgJotb.js} +1 -1
  319. package/cdn/assets/lWY3TbG2NDscy9He.js +72 -0
  320. package/cdn/assets/{BZkd8LNLgEd5WQXO.js → lqknEt3DTma5Juxs.js} +69 -4
  321. package/cdn/assets/mK8HcIZyXkOTvL6E.js +2453 -0
  322. package/{browser/esm/D2Ls6urWeByV5W-B2.mjs → cdn/assets/pc49xtHdprXZLW2X.js} +1 -1
  323. package/cdn/assets/px-aQ8dMjiWag_pV.js +167 -0
  324. package/cdn/assets/qYca4mdySLkACfo1.js +37 -0
  325. package/{browser/esm/DHQcJqD-EtJ0Efug2.mjs → cdn/assets/w5IQWbJETgHhqMsY.js} +33 -31
  326. package/cdn/assets/wM7DzeOpoEGBVDBe.js +441 -0
  327. package/{browser/esm/BRBHACVjnV1_6VLQ2.mjs → cdn/assets/x6GcENwqoUVbd60j.js} +1 -1
  328. package/cdn/assets/xlXDq-qoj7eOE6_T.js +5153 -0
  329. package/{browser/esm/CsKCqLuggHhYC93k2.mjs → cdn/assets/ycmpAs4kQfeh78Pa.js} +1 -1
  330. package/cdn/index.js +2 -2
  331. package/package.json +13 -14
  332. package/browser/cjs/1XrWGMP3GmsQOMIX.cjs +0 -1
  333. package/browser/cjs/49_x589Na12sizKK2.cjs +0 -1
  334. package/browser/cjs/4nReftSsKWmnRdtf2.cjs +0 -1
  335. package/browser/cjs/507hQYooKKjnRzsZ2.cjs +0 -1
  336. package/browser/cjs/B4JJfKSI4ppwU8552.cjs +0 -1
  337. package/browser/cjs/B7_pDFYCVzt-3hUs.cjs +0 -1
  338. package/browser/cjs/BAxVLKkxFgI6cXnR2.cjs +0 -1
  339. package/browser/cjs/BClFnd-voK5qaz1I.cjs +0 -88
  340. package/browser/cjs/BEJFcqVMDMKOvs11.cjs +0 -1
  341. package/browser/cjs/BF-38Z7Z0FZOPl192.cjs +0 -1
  342. package/browser/cjs/BF14ZEAnaqxXroSj.cjs +0 -1
  343. package/browser/cjs/BFdq8CHyR6FQvmQA2.cjs +0 -1
  344. package/browser/cjs/BK0SCfN_VZYqBxoQ2.cjs +0 -1
  345. package/browser/cjs/BKXFdLiztqEHIjQ_2.cjs +0 -1
  346. package/browser/cjs/BVN0uo1XwTCtE2mh.cjs +0 -7
  347. package/browser/cjs/BWDfauDHqB6U_2ka2.cjs +0 -1
  348. package/browser/cjs/B_WV3e3yexp3dKaz.cjs +0 -9
  349. package/browser/cjs/BbEwESVyRYXzMlW7.cjs +0 -5
  350. package/browser/cjs/BjgiE9MBDkKiRL6q.cjs +0 -3
  351. package/browser/cjs/BnccBYHCCq9TGFx4.cjs +0 -8
  352. package/browser/cjs/Btc0Nzu40VYOpzLX2.cjs +0 -1
  353. package/browser/cjs/BvG8N7G_8CXIAlT-.cjs +0 -1
  354. package/browser/cjs/BwLx9ix5Sq7suAYP2.cjs +0 -1
  355. package/browser/cjs/Byl4bQWpLnjthChn2.cjs +0 -7
  356. package/browser/cjs/BzsAbsb35hYT3xUc.cjs +0 -5
  357. package/browser/cjs/C-bW8lKUTFFUVap4.cjs +0 -1
  358. package/browser/cjs/C0hGnOYkvrwxaGrw.cjs +0 -1
  359. package/browser/cjs/C2uDl8VIJqh58YF_2.cjs +0 -1
  360. package/browser/cjs/C7GpcB_YgM-RLa2P.cjs +0 -1
  361. package/browser/cjs/C8GZf3UAOhfisYCs.cjs +0 -1
  362. package/browser/cjs/C9C-pr-T_ThweQX9.cjs +0 -1
  363. package/browser/cjs/C9L-xibuJ434Mqqq2.cjs +0 -1
  364. package/browser/cjs/CEXs4eRDOv4EjbSw2.cjs +0 -1
  365. package/browser/cjs/CEpXnHhrczUmIwMa2.cjs +0 -1
  366. package/browser/cjs/CHFOXPbNUaeZbrXn.cjs +0 -1
  367. package/browser/cjs/CHMgm0vAbEBS1mVW.cjs +0 -1
  368. package/browser/cjs/CJYewYJ5Z3iojl7J.cjs +0 -1
  369. package/browser/cjs/CLXzYSmhCHV5LQh7.cjs +0 -1
  370. package/browser/cjs/CN-dCAHVcxuMSyFz.cjs +0 -1
  371. package/browser/cjs/CPcBvw4ZPwHVTUZF.cjs +0 -1
  372. package/browser/cjs/CRx1WvmgBjT8WVyB2.cjs +0 -1
  373. package/browser/cjs/CV4KQsHluMqo1I2Q2.cjs +0 -1
  374. package/browser/cjs/CW-b31_-r-_raT8Y.cjs +0 -1
  375. package/browser/cjs/CXlzsh_WHCOsErJ12.cjs +0 -1
  376. package/browser/cjs/CZfNBCd62H_Jpkhl.cjs +0 -12
  377. package/browser/cjs/C_7w8EJZpHw8ueuq.cjs +0 -1
  378. package/browser/cjs/C_IEgjM-hSJCv6Gm.cjs +0 -1
  379. package/browser/cjs/CbLXP9WY38wTcGn5.cjs +0 -10
  380. package/browser/cjs/CeF0DZ-k4DB8M47I.cjs +0 -1
  381. package/browser/cjs/Ck7Tc5npWk73wrF3.cjs +0 -57
  382. package/browser/cjs/Clu7XiAsCB48GDXN.cjs +0 -1
  383. package/browser/cjs/CnZfa45XxA-9Jhmp.cjs +0 -1
  384. package/browser/cjs/CnjaTz8HJXStwuH8.cjs +0 -1
  385. package/browser/cjs/CoiPEZabJyiXxLta.cjs +0 -1
  386. package/browser/cjs/CpJJh4UnFl1_qFui.cjs +0 -1
  387. package/browser/cjs/CrZlUtdX1h2RUnCP.cjs +0 -1
  388. package/browser/cjs/Cty5pi0fwToP1GWe.cjs +0 -7
  389. package/browser/cjs/Cu0UCwSpRK4OnCuP.cjs +0 -1
  390. package/browser/cjs/CxWeFfNAUvhHe9F-.cjs +0 -21
  391. package/browser/cjs/D-o-mlG9tYSuZrvy2.cjs +0 -1
  392. package/browser/cjs/D8-KovdJ0LjxqCe2.cjs +0 -1
  393. package/browser/cjs/DAA0zpvkrMOLDPxr.cjs +0 -1
  394. package/browser/cjs/DAXgAEDtRrsWAePT.cjs +0 -1
  395. package/browser/cjs/DCIlWcGDrp-5PDoA2.cjs +0 -1
  396. package/browser/cjs/DDPxHIqx8aIbqTRE.cjs +0 -1
  397. package/browser/cjs/DDnGLOLTqLFsdUDS.cjs +0 -1
  398. package/browser/cjs/DEOu_cHJ1FfTA9R_2.cjs +0 -1
  399. package/browser/cjs/DG-AY_xO8RKHtEBE.cjs +0 -2
  400. package/browser/cjs/DG2kqsWRUtVugjay.cjs +0 -1
  401. package/browser/cjs/DIbdDzNf_3S2RYZN.cjs +0 -1
  402. package/browser/cjs/DLYEQZzAGuSAmJsp.cjs +0 -6
  403. package/browser/cjs/DM7-R_ltoLbA9jde2.cjs +0 -1
  404. package/browser/cjs/DMp9wql2kbZKAbGe.cjs +0 -3
  405. package/browser/cjs/DNCC-QNp2I7saV-I.cjs +0 -1
  406. package/browser/cjs/DNKyaSruDogoBd2H.cjs +0 -1
  407. package/browser/cjs/DQTBgNqDHInvxrwS.cjs +0 -1
  408. package/browser/cjs/DYqvGm5rx1DB53p7.cjs +0 -1
  409. package/browser/cjs/DZSvmqU8nRas1uz62.cjs +0 -1
  410. package/browser/cjs/DcHxh5QxfVitzdhv.cjs +0 -1
  411. package/browser/cjs/DgGGzl7jq3i7Cqfi.cjs +0 -1
  412. package/browser/cjs/Dkgu60euhL6wPoYa2.cjs +0 -1
  413. package/browser/cjs/DsFZgtSQpC75d1M02.cjs +0 -1
  414. package/browser/cjs/DsgqbxMOVQmAFSDy2.cjs +0 -1
  415. package/browser/cjs/DtaFdoK4CppKRF6F2.cjs +0 -20
  416. package/browser/cjs/Dtc_8P-koQRmNT2s.cjs +0 -33
  417. package/browser/cjs/Du4jBiFxRIF1OjD42.cjs +0 -1
  418. package/browser/cjs/Dx79LP1-YCQg8B87.cjs +0 -1
  419. package/browser/cjs/EeOVMRq7TuptFKTc2.cjs +0 -1
  420. package/browser/cjs/FUM_3mQlC-6WPjkT.cjs +0 -4
  421. package/browser/cjs/IbciPMJP2Pam3ERm.cjs +0 -1
  422. package/browser/cjs/J7LQgueGGNUE9emR.cjs +0 -1
  423. package/browser/cjs/JfM6P_qoQQTWakZf2.cjs +0 -1
  424. package/browser/cjs/Kvn916ebqGc4t6hv2.cjs +0 -1
  425. package/browser/cjs/M19oMY91yZxf2WAR.cjs +0 -1
  426. package/browser/cjs/NcNz8RfT5V889CMT.cjs +0 -10
  427. package/browser/cjs/NzAMMcPT7SETmqPg.cjs +0 -2
  428. package/browser/cjs/QK9BfdSZPLmyRpGi2.cjs +0 -1
  429. package/browser/cjs/X1LnR885SNQaK5HZ.cjs +0 -1
  430. package/browser/cjs/Y78-VwYSNffwXRVz2.cjs +0 -2
  431. package/browser/cjs/Ytzw6iUYx5f19wfK.cjs +0 -9
  432. package/browser/cjs/aONv0Ys3C8xmnaR8.cjs +0 -1
  433. package/browser/cjs/bM25C5avKgBAJVfk2.cjs +0 -1
  434. package/browser/cjs/bpcQTcfzGVBK-rfT2.cjs +0 -1
  435. package/browser/cjs/fqTQ_p3ehzUvc1tF2.cjs +0 -1
  436. package/browser/cjs/h3dw1jAp2J5Pu4p32.cjs +0 -1
  437. package/browser/cjs/index.cjs +0 -79
  438. package/browser/cjs/iyvcAhhnDFxkR8tW.cjs +0 -1
  439. package/browser/cjs/jIxFDc3EQDDXisAC2.cjs +0 -1
  440. package/browser/cjs/jev6VGWTdgEgm4Yk2.cjs +0 -1
  441. package/browser/cjs/kqP-W5qRIy-d-ChZ.cjs +0 -1
  442. package/browser/cjs/lEQC21-Sk4lwHy2r2.cjs +0 -1
  443. package/browser/cjs/mXzhcays1ok40iiU.cjs +0 -1
  444. package/browser/cjs/n4ZQ0-3uSrEsInbg.cjs +0 -1
  445. package/browser/cjs/ppSJKdLn646BZOzg.cjs +0 -1
  446. package/browser/cjs/sFD2bsTPq558FCMx.cjs +0 -126
  447. package/browser/cjs/stXrcKZOIHl0fq5U2.cjs +0 -2
  448. package/browser/cjs/xQ6-wbTw5UzZUM1Y.cjs +0 -1
  449. package/browser/cjs/zEytED4Eleo5DVvS.cjs +0 -1
  450. package/browser/cjs/z_rZE1OHFPpdGBh42.cjs +0 -1
  451. package/browser/esm/-9NsA_4pZqcEQBX7.mjs +0 -383
  452. package/browser/esm/B-dSKzg5shPDd733.mjs +0 -25
  453. package/browser/esm/BPwpFe7c1-F62aAU.mjs +0 -518
  454. package/browser/esm/BT2mYkpZGrhWovkv2.mjs +0 -238
  455. package/browser/esm/BUKNpzG26V0YaAzW.mjs +0 -219
  456. package/browser/esm/BaIe3fLfPLw3FbYP2.mjs +0 -1149
  457. package/browser/esm/BgNWvKfVoVgVVDB4.mjs +0 -134
  458. package/browser/esm/Bj3gyDL2ZJUDcxt72.mjs +0 -82
  459. package/browser/esm/BkBT2LB95lonIiBu.mjs +0 -152
  460. package/browser/esm/BqMvXD8dX4ksYjnj.mjs +0 -53
  461. package/browser/esm/Bz3-FDGVU67Izdnv2.mjs +0 -106
  462. package/browser/esm/C3dXBjR3SrDCdJlm.mjs +0 -105
  463. package/browser/esm/CElACTFuqPAnCAMJ.mjs +0 -99
  464. package/browser/esm/CFVzVz9BCRBowBea.mjs +0 -6104
  465. package/browser/esm/CFtsbobCiLpZIzCh.mjs +0 -34
  466. package/browser/esm/CJ-lOo2cXlcYrg2P.mjs +0 -8255
  467. package/browser/esm/CRsnKeHAnKrWvuG52.mjs +0 -6713
  468. package/browser/esm/CbJ_xQftC08KrH3E2.mjs +0 -20
  469. package/browser/esm/CfjG7gHJ4oN60Clj.mjs +0 -4423
  470. package/browser/esm/CpEgh9EOkeMvwAuj.mjs +0 -304
  471. package/browser/esm/CxKAnYBWCYMkUpnr.mjs +0 -824
  472. package/browser/esm/Cye91DfKIFwRdDpF.mjs +0 -224
  473. package/browser/esm/DFQGftDcmDwUGxV8.mjs +0 -27
  474. package/browser/esm/DGfzktq0BrIwcb8j.mjs +0 -7813
  475. package/browser/esm/D_8B8jIlshd3eTIO2.mjs +0 -471
  476. package/browser/esm/DdaO25i-WWFSh1W0.mjs +0 -3188
  477. package/browser/esm/DdtDlBp6KJZjL28o.mjs +0 -4745
  478. package/browser/esm/DhW7Cqyuxk7D6zsW.mjs +0 -509
  479. package/browser/esm/DhgwMDb052opCiAA.mjs +0 -11273
  480. package/browser/esm/DimkHq0_x-d4uNdV.mjs +0 -50758
  481. package/browser/esm/DnCkPg9-xb3RvxD-.mjs +0 -44
  482. package/browser/esm/DuJ_gK9f35IbKDd6.mjs +0 -3651
  483. package/browser/esm/Duo6t8_BzIiBDrFm.mjs +0 -28435
  484. package/browser/esm/DxxlSejA2S6YUPWD.mjs +0 -2211
  485. package/browser/esm/DygUxASTETZM60uN2.mjs +0 -47
  486. package/browser/esm/FAHIw2t7_M_rvRio.mjs +0 -149
  487. package/browser/esm/HFqcMD9nTL0jdLxT.mjs +0 -15
  488. package/browser/esm/N-koparnupMSl92y.mjs +0 -2687
  489. package/browser/esm/O982fBwJ80FSdhad.mjs +0 -615
  490. package/browser/esm/evPbHV86yom22yGf2.mjs +0 -16301
  491. package/browser/esm/ohVj-y1gCC9PEHJI.mjs +0 -87
  492. package/browser/esm/s4trFf5sOSGNEzr3.mjs +0 -235
  493. package/cdn/assets/6L6HfOFw1xzxXtf22.js +0 -2211
  494. package/cdn/assets/B-dSKzg5shPDd733.js +0 -25
  495. package/cdn/assets/B2BvBxjz3Kfii_Gn2.js +0 -6715
  496. package/cdn/assets/B3ZyfwskutLZMYfl2.js +0 -44
  497. package/cdn/assets/B4492m5zRjz4JWIo2.js +0 -4745
  498. package/cdn/assets/B6Y_HasaiihQLVYz2.js +0 -3188
  499. package/cdn/assets/B8ok93z6wOu1Mo5H.js +0 -27
  500. package/cdn/assets/BIPjogMyMmLRly43.js +0 -106
  501. package/cdn/assets/BOTU30yJHbaNehFS.js +0 -176
  502. package/cdn/assets/B_U_UpQXdbjNRthb.js +0 -24
  503. package/cdn/assets/BaIe3fLfPLw3FbYP2.js +0 -1149
  504. package/cdn/assets/BdhFhDEa7Xed6dFE.js +0 -28436
  505. package/cdn/assets/BdmCBWTVHb7KuHxO2.js +0 -2687
  506. package/cdn/assets/Bfd3T36ocASPZddR.js +0 -3651
  507. package/cdn/assets/BjN8kU7URKZwGlmk2.js +0 -4423
  508. package/cdn/assets/BouCHi6QnBrUDYkx.js +0 -16301
  509. package/cdn/assets/CDqMmEdh_CPaFCCi2.js +0 -2199
  510. package/cdn/assets/CLhSKL0Xdm8miSTy.js +0 -34
  511. package/cdn/assets/CSkSOhGT8E29E2Nh2.js +0 -99
  512. package/cdn/assets/CXrcgTVB77CopjOJ.js +0 -518
  513. package/cdn/assets/Cb71rZAQvCk3wnfp.js +0 -220
  514. package/cdn/assets/CbJ_xQftC08KrH3E.js +0 -20
  515. package/cdn/assets/CblzazoiTtSuaAkj.js +0 -225
  516. package/cdn/assets/CdPxVRKpCOqCDHI8.js +0 -824
  517. package/cdn/assets/CimYGZTVXcjbjrBU2.js +0 -83
  518. package/cdn/assets/CpEgh9EOkeMvwAuj.js +0 -304
  519. package/cdn/assets/D57KcDfTbBzf_NGr.js +0 -150
  520. package/cdn/assets/DEFEOS3OuA23llF92.js +0 -472
  521. package/cdn/assets/DEyeWdXLwDRo2yYf2.js +0 -107
  522. package/cdn/assets/DW2yQm-sEcHogX7E.js +0 -8258
  523. package/cdn/assets/Dhq9e6LCpmlIkFod.js +0 -220
  524. package/cdn/assets/DjS4iUli-T3uuUfK.js +0 -24
  525. package/cdn/assets/DjS4iUli-T3uuUfK2.js +0 -24
  526. package/cdn/assets/DlLXCXDokJ72EW-E.js +0 -236
  527. package/cdn/assets/DoJfPxuL3zziG4p62.js +0 -134
  528. package/cdn/assets/Dq7WxMef5CTJ47QI2.js +0 -48
  529. package/cdn/assets/HFqcMD9nTL0jdLxT2.js +0 -15
  530. package/cdn/assets/HeznPoDlSj26Q4lq.js +0 -11274
  531. package/cdn/assets/JL1xk8XqkuTOA_as2.js +0 -239
  532. package/cdn/assets/NZO3-fDBtqhmCsbB2.js +0 -50758
  533. package/cdn/assets/Wb48SedqaKMZnxym.js +0 -7404
  534. package/cdn/assets/Wsgx1I_j1chJ6hwn.js +0 -152
  535. package/cdn/assets/XSUr59k0gaFIS1Qf2.js +0 -53
  536. package/cdn/assets/llvXNxZaCMnYqvSm.js +0 -6104
  537. package/cdn/assets/omgRvCRxe7suvog8.js +0 -510
  538. package/cdn/assets/xMskoOI2CK9-AmBF2.js +0 -44
  539. package/cdn/assets/zrS_ERBQML_OXJ4J.js +0 -87
@@ -1,3188 +0,0 @@
1
- /**
2
- * @license @sheetxl/studio-vanilla - SheetXL Studio - Vanilla entry point for integrating SheetXL UI. - v0.7.28-beta.4
3
- *
4
- * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
- * License: The license can be found at https://www.sheetxl.com/license.
6
- */
7
- import { A as e, C as t, F as n, O as r, P as i, T as a, V as o, _ as s, d as c, l, m as u, r as d, s as f, t as p, v as m } from "./BetL7yI63lEdQ0gM2.js";
8
- import { r as h } from "./BzktrYJH7SQ9GyUI2.js";
9
- import { a as g, n as _ } from "./C7xBBqvPqat9oEft2.js";
10
- import { $ as v, $t as y, B as b, Bt as x, C as S, Ct as C, D as w, Dt as ee, E as T, Et as E, F as te, Ft as ne, Gt as D, H as re, J as ie, Kt as ae, L as O, Lt as oe, Nt as se, O as ce, P as le, Q as k, Qt as ue, S as de, St as fe, Tt as A, Ut as j, Wt as pe, X as me, Xt as he, Y as ge, Zt as _e, at as M, cn as ve, ct as ye, dn as N, dt as be, en as P, fn as F, ft as xe, g as I, gt as L, i as Se, in as Ce, j as R, kt as we, lt as Te, mt as Ee, nn as De, nt as Oe, on as ke, ot as Ae, p as je, pn as Me, s as Ne, sn as Pe, st as Fe, tt as Ie, u as Le, vt as Re, w as ze, wt as Be, x as Ve, yt as He, zt as Ue } from "./NZO3-fDBtqhmCsbB2.js";
11
- import { r as We } from "./BjN8kU7URKZwGlmk2.js";
12
- var Ge;
13
- Ge ||= {};
14
- var Ke = class extends u {
15
- constructor(e, t = 50) {
16
- super(t), this._transactions = e, this._floorId = e ? e.getCurrentCommit(!1).getId() : null, this._removeListener = e?.addListener({ onCommitChange: () => this._notifyOnStackChange() });
17
- }
18
- _undoCommits(e = this.maxStack) {
19
- let t = this._transactions;
20
- if (!t) return [];
21
- let n = t.getLog(t.getCurrentCommit(!1).getId(), 2 ** 53 - 1), r = [];
22
- for (let t = 0; t < n.length && r.length < e; t++) {
23
- let e = n[t];
24
- if (e.getId() === this._floorId || t === n.length - 1) break;
25
- e.getDescription() && r.push(e);
26
- }
27
- return r;
28
- }
29
- _redoCommits(e = this.maxStack) {
30
- let t = this._transactions;
31
- if (!t) return [];
32
- let n = t.getCurrentCommit(!1).getId(), r = t.getTipCommit().getId();
33
- if (r === n) return [];
34
- let i = t.getLog(r, 2 ** 53 - 1), a = [], o = !1;
35
- for (let e of i) {
36
- if (e.getId() === n) {
37
- o = !0;
38
- break;
39
- }
40
- a.push(e);
41
- }
42
- if (!o) return [];
43
- a.reverse();
44
- let s = [];
45
- for (let t of a) if (t.getDescription() && s.push(t), s.length >= e) break;
46
- return s;
47
- }
48
- undo(e = 1) {
49
- let t = this._transactions;
50
- if (!t) return;
51
- let n = !1;
52
- try {
53
- for (let r = 0; r < e; r++) {
54
- let [e] = this._undoCommits(1);
55
- if (!e) break;
56
- t.revert(e.getId()), n = !0;
57
- }
58
- } finally {
59
- n && this._notifyOnStackChange();
60
- }
61
- }
62
- redo(e = 1) {
63
- let t = this._transactions;
64
- if (!t) return;
65
- let n = !1;
66
- try {
67
- for (let r = 0; r < e; r++) {
68
- let [e] = this._redoCommits(1);
69
- if (!e) {
70
- r === 0 && this._repeatOperation?.repeat();
71
- break;
72
- }
73
- t.restore(e.getId()), n = !0;
74
- }
75
- } finally {
76
- n && this._notifyOnStackChange();
77
- }
78
- }
79
- hasUndo() {
80
- return this._undoCommits(1).length > 0;
81
- }
82
- hasRedo() {
83
- return this._redoCommits(1).length > 0 || this._repeatOperation !== null;
84
- }
85
- getTopUndoDescription() {
86
- return this._undoCommits(1)[0]?.getDescription() ?? null;
87
- }
88
- getTopRedoDescription() {
89
- return this._repeatOperation === null ? this._redoCommits(1)[0]?.getDescription() ?? null : this._repeatOperation.description;
90
- }
91
- getUndoDescriptions() {
92
- return this._undoCommits().map((e) => e.getDescription());
93
- }
94
- getRedoDescriptions() {
95
- let e = this._redoCommits().map((e) => e.getDescription());
96
- return e.length === 0 && this._repeatOperation !== null && e.push(this._repeatOperation.description), Object.freeze(e);
97
- }
98
- addUndoOperation() {
99
- throw Error("TransactionUndoManager derives its stack from the commit log; commit a described transaction instead.");
100
- }
101
- clear(e = !0) {
102
- this._transactions && (this._floorId = this._transactions.getCurrentCommit(!1).getId()), super.clear(e);
103
- }
104
- close() {
105
- this._removeListener?.();
106
- }
107
- }, qe = class {
108
- constructor(e, t) {
109
- this._dirty = !1, this._store = e, this._savedCommitId = e.getCurrentCommit()?.getId() ?? null, this._emitter = new A(this);
110
- let n = this;
111
- this._removeStoreListener = e.addListener({
112
- onCommitEnd() {
113
- n._recompute();
114
- },
115
- onCommitChange() {
116
- n._recompute();
117
- }
118
- }), this._removeCommitListener = t?.addCommitListener({ onCommit(e) {
119
- e.store === n._store && n.markSaved(e.commitId);
120
- } });
121
- }
122
- getStore() {
123
- return this._store;
124
- }
125
- isDirty() {
126
- return (this._store.getCurrentCommit()?.getId() ?? null) !== this._savedCommitId;
127
- }
128
- getSavedCommitId() {
129
- return this._savedCommitId;
130
- }
131
- markSaved(e = this._store.getCurrentCommit()?.getId() ?? null) {
132
- e !== this._savedCommitId && (this._savedCommitId = e ?? null, this._recompute());
133
- }
134
- addListeners(e, t) {
135
- return this._emitter.addListeners(e, t);
136
- }
137
- _recompute() {
138
- let e = this.isDirty();
139
- e !== this._dirty && (this._dirty = e, this._emitter.notify(e ? "onDirty" : "onClean", { transactional: !1 }));
140
- }
141
- close() {
142
- this._removeStoreListener?.(), this._removeCommitListener?.(), this._emitter.close();
143
- }
144
- }, z = class e {
145
- constructor(t, n = {}) {
146
- this._password = null, this._emitter = new A(this), this._path = t ?? null, this._name = n.name ?? null, this._format = n.format ?? null, this._size = n.size ?? null, this._canWrite = n.canWrite ?? e._defaultCanWrite(this._path), this._encryption = n.encryption ?? null;
147
- }
148
- static _defaultCanWrite(e) {
149
- return !!e && !/^(https?:|data:|blob:)/i.test(e);
150
- }
151
- _cleanPath() {
152
- return this._path ? this._path.split(/[?#]/)[0] : null;
153
- }
154
- getName() {
155
- if (this._name !== null && this._name !== void 0) return this._name;
156
- let e = this._cleanPath();
157
- return e && L(e) || null;
158
- }
159
- getPath() {
160
- return this._path;
161
- }
162
- getFormat() {
163
- return this._format ? this._format : this.getExtension();
164
- }
165
- getExtension() {
166
- let e = this._cleanPath();
167
- if (!e) return null;
168
- let t = E(e);
169
- return t ? t.toLowerCase() : null;
170
- }
171
- getEncryption() {
172
- return this._encryption;
173
- }
174
- isEncrypted() {
175
- return this._encryption !== null || this._password !== null;
176
- }
177
- setPassword(e) {
178
- this._password !== (e ?? null) && (this._password = e ?? null, this._password === null && (this._encryption = null), this._emitter.notify("onChange"));
179
- }
180
- getPassword() {
181
- return this._password;
182
- }
183
- getSize() {
184
- return this._size;
185
- }
186
- canWrite() {
187
- return this._canWrite;
188
- }
189
- setName(e) {
190
- this.update({ name: e });
191
- }
192
- update(e) {
193
- let t = !1;
194
- return e.path !== void 0 && e.path !== this._path && (this._path = e.path, t = !0), e.name !== void 0 && e.name !== this._name && (this._name = e.name, t = !0), e.format !== void 0 && e.format !== this._format && (this._format = e.format, t = !0), e.size !== void 0 && e.size !== this._size && (this._size = e.size, t = !0), e.canWrite !== void 0 && e.canWrite !== this._canWrite && (this._canWrite = e.canWrite, t = !0), e.encryption !== void 0 && e.encryption !== this._encryption && (this._encryption = e.encryption, t = !0), t && this._emitter.notify("onChange"), this;
195
- }
196
- addListeners(e, t) {
197
- return this._emitter.addListeners(e, t);
198
- }
199
- get [Symbol.toStringTag]() {
200
- return "[Origin]";
201
- }
202
- toString() {
203
- let e = this._cleanPath(), t = e ? e.split(/[/\\]/).pop() || e : this._name ?? "(unbound)", n = this._size;
204
- if (n == null) return t;
205
- if (n < 1024) return `${t} ${n}B`;
206
- let r = Math.floor(Math.log(n) / Math.log(1024)), i = [
207
- "B",
208
- "KB",
209
- "MB",
210
- "GB",
211
- "TB"
212
- ];
213
- return `${t} ${(n / 1024 ** r).toFixed(2)}${i[Math.min(r, i.length - 1)]}`;
214
- }
215
- }, Je = class {
216
- constructor() {
217
- this._defaultStringSourceType = "filepath";
218
- }
219
- async read(e) {
220
- let t = e.options ?? {}, r = e.source;
221
- if (typeof r == "function" && (r = r()), r && typeof r == "object" && typeof r.then == "function" && (r = await Promise.resolve(r)), r == null && (r = await this.resolveSource(e), r == null)) return null;
222
- let i = t.format, a = this._detectSourceType(r);
223
- if (!a) throw Error("Unable to detect source type from provided input.");
224
- let o, s, c = !1;
225
- if (a === "filepath") {
226
- let e = typeof r == "string" && r.startsWith("file://") ? r.slice(7) : r;
227
- r = await this.filePathToFile(e), a = "file", c = !0;
228
- }
229
- switch (a) {
230
- case "file": {
231
- let e = r, t = e?.name, n = t ? `${L(t)}` : "";
232
- o = await e.arrayBuffer(), s = {
233
- format: i,
234
- ext: E(t),
235
- name: n,
236
- absolutePath: t,
237
- size: e.size,
238
- canWrite: c && this._canWriteLocalPath()
239
- };
240
- break;
241
- }
242
- case "blob": {
243
- let e = r;
244
- o = await e.arrayBuffer(), s = {
245
- format: i,
246
- size: e.size
247
- };
248
- break;
249
- }
250
- case "base64": {
251
- let e;
252
- if (r && typeof r == "object" && "base64" in r) e = r.base64;
253
- else if (typeof r == "string" && r.startsWith("data:")) {
254
- let [, t] = r.split(",");
255
- e = t;
256
- } else e = r;
257
- o = n.base64ToArrayBuffer(e), s = {
258
- format: i,
259
- size: e.length
260
- };
261
- break;
262
- }
263
- case "fetch": {
264
- let e, t, n;
265
- if (typeof r == "string") e = r;
266
- else {
267
- if (!r || typeof r != "object" || !("input" in r)) throw Error("Invalid fetch source provided.");
268
- {
269
- let i = r;
270
- e = i.input, t = i.init, n = i.timeout;
271
- }
272
- }
273
- let a = n || 3e4, c = new AbortController(), l = setTimeout(() => c.abort(), a), u = typeof e == "string" ? e : e.toString(), d = E(u);
274
- try {
275
- let n = await fetch(e, {
276
- ...t,
277
- signal: c.signal
278
- });
279
- if (clearTimeout(l), !n.ok) throw Error(`Failed to fetch: ${n.status} ${n.statusText}`);
280
- let r = await n.arrayBuffer();
281
- if (!r) throw Error(`Unable to fetched content: ${u}`);
282
- o = r, s = {
283
- format: i,
284
- ext: d,
285
- name: L(u, !0),
286
- absolutePath: u
287
- };
288
- } catch (e) {
289
- throw clearTimeout(l), e.name === "AbortError" ? Error(`Fetch timeout after ${a}ms: ${u}`) : e;
290
- }
291
- break;
292
- }
293
- case "buffer":
294
- o = r, s = { format: i };
295
- break;
296
- case "stream": {
297
- let e = r.getReader(), t = [], n = 0;
298
- try {
299
- for (;;) {
300
- let { done: r, value: i } = await e.read();
301
- if (r) break;
302
- t.push(i), n += i.length;
303
- }
304
- } finally {
305
- e.releaseLock();
306
- }
307
- let a = new ArrayBuffer(n), c = new Uint8Array(a), l = 0;
308
- for (let e of t) c.set(e, l), l += e.length;
309
- o = a, s = { format: i };
310
- break;
311
- }
312
- default: throw Error(`Unsupported source type: ${a}`);
313
- }
314
- let l = await e.decode(o, {
315
- sourceType: a,
316
- ...s
317
- });
318
- return l ? (await this.onWorkbookRead(l, r), l) : null;
319
- }
320
- async resolveSource(e) {
321
- return null;
322
- }
323
- async onWorkbookRead(e, t) {}
324
- _canWriteLocalPath() {
325
- return !1;
326
- }
327
- _detectSourceType(e) {
328
- if (e && typeof e == "object" && "base64" in e) return "base64";
329
- if (e && typeof e == "object" && "input" in e) return "fetch";
330
- if (typeof e == "string") {
331
- if (e.startsWith("data:")) return "base64";
332
- if (e.startsWith("http://") || e.startsWith("https://")) return "fetch";
333
- if (e.startsWith("file://")) return "filepath";
334
- let t = this._defaultStringSourceType;
335
- return e.startsWith("./") || e.startsWith("../") || e.startsWith("/") || /^[a-zA-Z]:[/\\]/.test(e), t;
336
- }
337
- if (typeof File < "u" && e instanceof File) return "file";
338
- if (typeof Blob < "u" && e instanceof Blob) return "blob";
339
- let t = e instanceof ArrayBuffer || Object.prototype.toString.call(e) === "[object ArrayBuffer]", r = ArrayBuffer.isView(e), i = n.isNodeBuffer(e);
340
- return t || r || i ? "buffer" : typeof ReadableStream < "u" && e instanceof ReadableStream || Object.prototype.toString.call(e) === "[object ReadableStream]" || e && typeof e.getReader == "function" && e.locked !== void 0 ? "stream" : null;
341
- }
342
- }, Ye = class extends Je {
343
- constructor(e, t) {
344
- super(), this._getWriteFormats = e, this._getReadFormats = t, this._defaultStringSourceType = "fetch", this._handleCache = /* @__PURE__ */ new WeakMap(), this._pendingOpenHandle = null;
345
- }
346
- async read(e) {
347
- let t = e.source;
348
- return t && t.kind === "file" && typeof t.getFile == "function" ? (this._pendingOpenHandle = t, super.read({
349
- ...e,
350
- source: await t.getFile()
351
- })) : super.read(e);
352
- }
353
- async resolveSource() {
354
- let e = await this._getReadFormats?.() ?? [];
355
- if (typeof globalThis.showOpenFilePicker == "function") try {
356
- let t = function(e) {
357
- let t = Xe(e);
358
- if (t.length <= 1) return t;
359
- let n = /* @__PURE__ */ new Set(), r = {};
360
- for (let e of t) for (let [t, i] of Object.entries(e.accept)) for (let e of i) n.has(e) || (n.add(e), (r[t] ??= []).push(e));
361
- return [{
362
- description: "All Supported",
363
- accept: r
364
- }, ...t];
365
- }(e), [n] = await globalThis.showOpenFilePicker(t.length ? { types: t } : void 0);
366
- return this._pendingOpenHandle = n, await n.getFile();
367
- } catch (e) {
368
- if (e?.name === "AbortError") return null;
369
- throw e;
370
- }
371
- let t = e.flatMap((e) => e.exts.map((e) => "." + e)).join(", ");
372
- return p.openFileDialog(t);
373
- }
374
- async onWorkbookRead(e) {
375
- if (this._pendingOpenHandle) {
376
- let t = e.getOrigin?.();
377
- t && (this._handleCache.set(t, this._pendingOpenHandle), t instanceof z && t.update({ canWrite: !0 })), this._pendingOpenHandle = null;
378
- }
379
- }
380
- async filePathToFile(e) {
381
- throw Error(`Cannot read local file path '${e}' in browser environment. Use a file input element or fetch for remote URLs.`);
382
- }
383
- async write(e) {
384
- let { origin: t, suggestedName: n, format: r, encode: i, prompt: a } = e, o = [r, ...(await this._getWriteFormats()).filter((e) => e.key !== r.key)], s = typeof globalThis.showSaveFilePicker == "function", c = !a && t.canWrite() ? this._handleCache.get(t) : void 0;
385
- if (c?.name) {
386
- let e = t.getPath()?.split(/[/\\]/).pop();
387
- e && c.name !== e && (c = void 0);
388
- }
389
- let l = !!c;
390
- if (s) try {
391
- if (c) {
392
- let e = await async function(e) {
393
- try {
394
- if (typeof e.queryPermission != "function") return "granted";
395
- let t = { mode: "readwrite" };
396
- return await e.queryPermission(t) === "granted" || await e.requestPermission(t) === "granted" ? "granted" : "denied";
397
- } catch {
398
- return "unavailable";
399
- }
400
- }(c);
401
- if (e === "denied") return null;
402
- e !== "granted" && (c = void 0);
403
- }
404
- c ||= await globalThis.showSaveFilePicker({
405
- suggestedName: n,
406
- types: Xe(o)
407
- });
408
- let e = Qe(c.name ?? n), a = o.find((t) => t.exts.some((t) => t.toLowerCase() === e)) ?? r, s = await i(a.key), u = new Blob([Ze(s)], { type: a.mimeType || "application/octet-stream" }), d = await c.createWritable();
409
- return await d.write(u), await d.close(), this._handleCache.set(t, c), t instanceof z && t.update({
410
- size: u.size,
411
- ...l ? null : {
412
- path: c.name ?? n,
413
- name: null,
414
- format: a.key,
415
- canWrite: !0
416
- }
417
- }), t;
418
- } catch (e) {
419
- if (e?.name === "AbortError") return null;
420
- }
421
- let u = await i(r.key), d = new Blob([Ze(u)], { type: r.mimeType || "application/octet-stream" }), f = t.getPath(), p = f ? f.split(/[/\\]/).pop() : null, m = p && Qe(p) ? p : n;
422
- return function(e, t) {
423
- let n = URL.createObjectURL(e), r = document.createElement("a");
424
- r.style.display = "none", r.href = n, r.download = t, document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(n);
425
- }(d, m), t instanceof z && t.update({
426
- size: d.size,
427
- ...t.getPath() === m ? null : {
428
- path: m,
429
- name: null,
430
- format: r.key,
431
- canWrite: !1
432
- }
433
- }), t;
434
- }
435
- };
436
- function Xe(e) {
437
- return e.map((e) => {
438
- let t = e.mimeType && e.mimeType.includes("/") ? e.mimeType : "application/octet-stream";
439
- return {
440
- description: e.description ?? e.key,
441
- accept: { [t]: e.exts.map((e) => "." + e) }
442
- };
443
- });
444
- }
445
- function Ze(e) {
446
- if (typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) {
447
- let t = new ArrayBuffer(e.byteLength);
448
- return new Uint8Array(t).set(new Uint8Array(e)), t;
449
- }
450
- return e;
451
- }
452
- function Qe(e) {
453
- let t = e.lastIndexOf(".");
454
- return t >= 0 ? e.slice(t + 1).toLowerCase() : "";
455
- }
456
- var $e = class {
457
- constructor(e) {
458
- this._private = { input: e }, typeof e == "string" ? this._private.name = e : Object.assign(this._private, e);
459
- }
460
- toJSON() {
461
- return this._private.input;
462
- }
463
- getFamily() {
464
- return this._private.name;
465
- }
466
- getPitch() {
467
- return this._private.pitch;
468
- }
469
- getPanose() {
470
- return this._private.panose;
471
- }
472
- toString() {
473
- return typeof this._private.input == "string" ? this._private.input : JSON.stringify(this._private.input);
474
- }
475
- get isIFont() {
476
- return !0;
477
- }
478
- }, et = h({
479
- findBestMatch: () => at,
480
- getFontList: () => rt,
481
- setFontList: () => U
482
- }), tt = [
483
- "Arial",
484
- "Arial Black",
485
- "Brush Script MT",
486
- "Calibri",
487
- "Comic Sans MS",
488
- "Courier New",
489
- "Garamond",
490
- "Georgia",
491
- "Impact",
492
- "Luminari",
493
- "Palatino Linotype",
494
- "Tahoma",
495
- "Times New Roman",
496
- "Trebuchet MS",
497
- "Verdana"
498
- ], B = /* @__PURE__ */ new Map();
499
- B.set(k.GenericName.Serif, ["Tahoma"]), B.set(k.GenericName.SanSerif, ["Calibri"]), B.set(k.GenericName.MonoSpace, ["Courier New"]), B.set(k.GenericName.Cursive, ["Comic Sans MS"]), B.set(k.GenericName.Fantasy, ["Luminari"]), B.set(k.GenericName.UISystem, ["Arial"]), B.set(k.GenericName.UISerif, ["Tahoma"]), B.set(k.GenericName.UISanSerif, ["Arial"]), B.set(k.GenericName.UIMonoSpace, ["Courier New"]), B.set(k.GenericName.UIRounded, ["Arial"]), B.set(k.GenericName.Math, []), B.set(k.GenericName.Emoji, []), B.set(k.GenericName.Fangsong, []);
500
- var V = /* @__PURE__ */ new Map(), H = [];
501
- U(tt);
502
- var nt = eval;
503
- function U(e) {
504
- e || U(tt);
505
- let t = [];
506
- for (let n = 0; n < e.length; n++) {
507
- let r = e[n];
508
- typeof r == "string" && (r = new $e(r));
509
- let i = !0;
510
- try {
511
- i = nt(`document.fonts.check('12px ${r.getFamily()}')`);
512
- } catch {}
513
- let a = {
514
- fontRef: r,
515
- loaded: i
516
- };
517
- t.push(a), V.set(r.getFamily(), a);
518
- }
519
- H = Object.freeze(t);
520
- }
521
- function rt() {
522
- return H;
523
- }
524
- var W, G, K, it, q = /* @__PURE__ */ new Map();
525
- function at(e, t) {
526
- let n = q.get(e);
527
- if (n) return n.fontRef === null ? null : n;
528
- let r = [e];
529
- t?.fallbacks && (r = r.concat(t.fallbacks));
530
- let i = null;
531
- for (let e = 0; !i && e < r.length; e++) {
532
- let t = r[e];
533
- if (i = V.get(t), !i) {
534
- let e = B.get(t);
535
- if (e) for (let t = 0; !i && t < e.length; t++) i = V.get(e[t]);
536
- }
537
- }
538
- return i ? q.set(e, i) : q.set(e, {
539
- fontRef: null,
540
- loaded: !1
541
- }), i;
542
- }
543
- var ot = h({
544
- DefaultFontSizes: () => st,
545
- findNextFontSize: () => ct
546
- }), st = Object.freeze([
547
- 8,
548
- 9,
549
- 10,
550
- 11,
551
- 12,
552
- 14,
553
- 16,
554
- 18,
555
- 20,
556
- 22,
557
- 24,
558
- 26,
559
- 28,
560
- 30,
561
- 36,
562
- 48,
563
- 72
564
- ]);
565
- function ct(t, n = !0, r = st) {
566
- if (!r || r.length === 0) return t;
567
- if (t === void 0) return r[0];
568
- if (n && t >= r[r.length - 1] || !n && t <= r[0]) return t;
569
- let i = e.findEqualOrGreater(r, t);
570
- return n ? (r[i] === t && (i += 1), r[i] || --i, r[i]) : (--i, r[i]);
571
- }
572
- (W ||= {}).SortOn = {
573
- Value: "value",
574
- FillColor: "fillColor",
575
- FontColor: "fontColor",
576
- Icon: "icon"
577
- }, (K = G ||= {}).Compound = {
578
- Single: "sng",
579
- Double: "dbl",
580
- ThickThin: "thickThin",
581
- ThinThick: "thinThick",
582
- Triple: "tri"
583
- }, K.Align = {
584
- Center: "ctr",
585
- Inset: "in",
586
- Outset: "outset"
587
- }, K.LineCap = {
588
- Butt: "butt",
589
- Round: "round",
590
- Square: "square"
591
- }, K.LineJoin = {
592
- Bevel: "bevel",
593
- Miter: "miter",
594
- Round: "round"
595
- }, K.PresetMarkerShape = {
596
- Single: "none",
597
- Double: "double",
598
- ThickThin: "thickThin",
599
- ThinThick: "thickThin"
600
- }, K.StrokeStyle = {
601
- None: "none",
602
- Dashed: "dashed",
603
- Dotted: "dotted",
604
- LargeDash: "lgDash",
605
- LargeDashDot: "lgDashDot",
606
- LargeDashDotDot: "lgDashDotDot",
607
- Solid: "solid",
608
- SysDash: "sysDash",
609
- SysDashDot: "sysDashDot",
610
- SysDashDotDot: "sysDashDotDot",
611
- SysDot: "sysDot"
612
- }, (it ||= {}).Type = {
613
- OuterShadow: "outerShadow",
614
- InnerShadow: "innerShadow",
615
- PresetShadow: "presetShadow",
616
- Glow: "glow",
617
- SoftEdge: "softEdge",
618
- Reflection: "reflection"
619
- };
620
- var lt, ut, dt, ft, J = Fe.BuiltInName, pt = {
621
- [J.Normal]: m("style.builtin.normal"),
622
- [J.Comma]: m("style.builtin.comma"),
623
- [J.Currency]: m("style.builtin.currency"),
624
- [J.Percent]: m("style.builtin.percent"),
625
- [J.Comma0]: m("style.builtin.comma0"),
626
- [J.Currency0]: m("style.builtin.currency0"),
627
- [J.Hyperlink]: m("style.builtin.hyperlink"),
628
- [J.FollowedHyperlink]: m("style.builtin.followedHyperlink"),
629
- [J.Note]: m("style.builtin.note"),
630
- [J.WarningText]: m("style.builtin.warningText"),
631
- [J.Title]: m("style.builtin.title"),
632
- [J.Input]: m("style.builtin.input"),
633
- [J.Output]: m("style.builtin.output"),
634
- [J.Calculation]: m("style.builtin.calculation"),
635
- [J.CheckCell]: m("style.builtin.checkCell"),
636
- [J.LinkedCell]: m("style.builtin.linkedCell"),
637
- [J.Total]: m("style.builtin.total"),
638
- [J.Good]: m("style.builtin.good"),
639
- [J.Bad]: m("style.builtin.bad"),
640
- [J.Neutral]: m("style.builtin.neutral"),
641
- [J.ExplanatoryText]: m("style.builtin.explanatoryText")
642
- }, mt = m("style.builtin.heading"), ht = m("style.builtin.accent"), gt = m("style.builtin.accentTint"), _t = /^Heading ([1-4])$/, vt = /^Accent([1-6])$/, yt = /^(20|40|60)% - Accent([1-6])$/;
643
- function bt(e) {
644
- let t = pt[e];
645
- if (t) return { key: t };
646
- let n = _t.exec(e);
647
- return n ? {
648
- key: mt,
649
- params: { n: +n[1] }
650
- } : (n = vt.exec(e), n ? {
651
- key: ht,
652
- params: { n: +n[1] }
653
- } : (n = yt.exec(e), n ? {
654
- key: gt,
655
- params: {
656
- pct: +n[1],
657
- n: +n[2]
658
- }
659
- } : null));
660
- }
661
- var xt = (e, t, n, r, i) => {
662
- let a = JSON.parse(JSON.stringify(e.definition));
663
- a.adjs ||= [];
664
- let o = "", c = 0, l = 0;
665
- t > 0 ? (l = t, c = 100 - t, o = s("op.lighterPercent", { percent: t })) : t < 0 && (c = 100 + t, o = s("op.darkerPercent", { percent: -t })), c && a.adjs.push({ [T.AdjustmentType.LumMod]: c }), l && a.adjs.push({ [T.AdjustmentType.LumOff]: l });
666
- let u = new j({
667
- val: a.val,
668
- adjs: a.adjs
669
- }, n), d = u.toString();
670
- r?.set(d, u);
671
- let f = u.toRGBA().toString();
672
- return i?.set(f, u), {
673
- description: e.description + ", " + o,
674
- definition: a
675
- };
676
- };
677
- function St(e) {
678
- let t, n = e.trim();
679
- if (!n) return;
680
- try {
681
- let e = We.shared().tokenize(n, !1);
682
- if (e.errors.length > 0) return;
683
- t = e.tokens;
684
- } catch {
685
- return;
686
- }
687
- let r = 0, i = 0;
688
- if (t.length === 2) {
689
- let e = t[0].tokenType?.name;
690
- e === "MinOp" ? (r = -1, i = 1) : e === "PlusOp" && (r = 1, i = 1);
691
- }
692
- if (t.length - i !== 1) return;
693
- let a = t[i], o = a.image;
694
- try {
695
- switch (a.tokenType?.name) {
696
- case "NumberToken":
697
- case "ScientificDigit":
698
- case "DigitToken": {
699
- let e = te(o).value;
700
- return r === 0 ? e : r * e;
701
- }
702
- case "StringToken": return r === 0 ? ge(o).value : void 0;
703
- case "BooleanToken": return r === 0 ? Ie(o).value : void 0;
704
- case "LiteralError":
705
- case "RefError": return r === 0 ? S(o).value : void 0;
706
- default: return;
707
- }
708
- } catch {
709
- return;
710
- }
711
- }
712
- function Ct(e, t) {
713
- let n = wt(e), r = wt(t);
714
- return n === r ? e === t ? 0 : typeof e == "number" && typeof t == "number" ? e < t ? -1 : 1 : typeof e == "string" && typeof t == "string" ? e < t ? -1 : +(e > t) : typeof e == "boolean" ? e ? 1 : -1 : g.isError(e) && g.isError(t) ? e.getCode() - t.getCode() : 0 : n - r;
715
- }
716
- function wt(e) {
717
- if (e === null) return 0;
718
- switch (typeof e) {
719
- case "number": return 1;
720
- case "string": return 2;
721
- case "boolean": return 3;
722
- default: return g.isError(e) ? 4 : 5;
723
- }
724
- }
725
- (lt ||= {}).buildPalette = function(e, t, n, r) {
726
- let i = [];
727
- for (let a = 0; a < e.length; a++) {
728
- let o = [];
729
- i.push(o);
730
- let s = (i) => {
731
- for (let s = 0; s < i.length; s++) o.push(xt(e[a], i[s], t, n, r));
732
- }, c = new j({
733
- val: e[a].definition.val,
734
- adjs: e[a].definition.adjs
735
- }, t).toHSLA().lum;
736
- s(c === 0 ? [
737
- 50,
738
- 35,
739
- 25,
740
- 15,
741
- 5
742
- ] : c === 100 ? [
743
- -5,
744
- -15,
745
- -25,
746
- -35,
747
- -50
748
- ] : c <= 20 ? [
749
- 90,
750
- 75,
751
- 50,
752
- 25,
753
- 10
754
- ] : c >= 80 ? [
755
- -10,
756
- -25,
757
- -50,
758
- -75,
759
- -90
760
- ] : [
761
- 80,
762
- 60,
763
- 40,
764
- -25,
765
- -50
766
- ]);
767
- }
768
- return i;
769
- }, ut ||= {}, dt ||= {}, ft ||= {};
770
- var Tt = class {
771
- constructor(e) {
772
- this._children = e;
773
- }
774
- getSize() {
775
- let e = this._children, t = e.length, n = 0;
776
- for (let r = 0; r < t; r++) n += e[r].getSize();
777
- return n;
778
- }
779
- getCount() {
780
- let e = this._children, t = e.length, n = 0;
781
- for (let r = 0; r < t; r++) n += e[r].getCount();
782
- return n;
783
- }
784
- getAggregates(e) {
785
- if (e) return this._mergeAggregates(e);
786
- let t = this._aggregates;
787
- return t || (t = this._mergeAggregates(), this._aggregates = t), t;
788
- }
789
- getSnappedSum(e) {
790
- let t = e ?? this.getAggregates().sum ?? 0, n = this._children;
791
- for (let e = n.length - 1; e >= 0; e--) if (n[e].getAggregates().numericalCount > 0) return n[e].getSnappedSum(t);
792
- return t;
793
- }
794
- getSortedNumbers() {
795
- let e = this._sortedNumbers;
796
- if (!e) {
797
- let t = this._children, n = t.length, r = [];
798
- for (let e = 0; e < n; e++) {
799
- let n = t[e].getSortedNumbers().getValues();
800
- n.length > 0 && r.push(n);
801
- }
802
- e = new Be(function(e) {
803
- let t = e.length;
804
- if (t === 0) return Et;
805
- if (t === 1) return e[0];
806
- let n = e[0];
807
- for (let r = 1; r < t; r++) n = Dt(n, e[r]);
808
- return Object.freeze(n);
809
- }(r)), this._sortedNumbers = e;
810
- }
811
- return e;
812
- }
813
- getRanked(e) {
814
- return ne(this._children, e, Ct)[Symbol.iterator]();
815
- }
816
- getFrequencies(e) {
817
- if (e) return this._mergeFrequencies(e);
818
- let t = this._frequencies;
819
- return t || (t = this._mergeFrequencies(), this._frequencies = t), t;
820
- }
821
- _mergeFrequencies(e) {
822
- let t = e?.keyFn ?? ce, n = e?.limit, r = /* @__PURE__ */ new Map(), i = this._children, a = i.length, o = 0, s = 0, c = !1;
823
- for (let l = 0; l < a; l++) {
824
- let a = i[l].getFrequencies(e);
825
- o += a.getVisitedCount(), s += a.getTotalCount(), c ||= a.isTruncated();
826
- let u = a.getValueCounts(), d = u.next();
827
- for (; !d.done;) {
828
- let [e, i] = d.value, a = t(e), o = r.get(a);
829
- o ? o.count += i : n === void 0 || r.size < n ? r.set(a, {
830
- value: e,
831
- count: i
832
- }) : c = !0, d = u.next();
833
- }
834
- }
835
- return ae.fromGroups(r, t, e, Ct, o, s, c);
836
- }
837
- getTypedCounts(e) {
838
- let t = this._typedCounts;
839
- if (!t) {
840
- let e = {
841
- [_.Number]: 0,
842
- [_.String]: 0,
843
- [_.Boolean]: 0,
844
- [_.Error]: 0,
845
- [_.RichData]: 0,
846
- [_.Null]: 0
847
- }, n = this._children, r = n.length;
848
- for (let t = 0; t < r; t++) {
849
- let r = n[t].getTypedCounts();
850
- e[_.Number] += r[_.Number] ?? 0, e[_.String] += r[_.String] ?? 0, e[_.Boolean] += r[_.Boolean] ?? 0, e[_.Error] += r[_.Error] ?? 0, e[_.RichData] += r[_.RichData] ?? 0, e[_.Null] += r[_.Null] ?? 0;
851
- }
852
- t = Object.freeze(e), this._typedCounts = t;
853
- }
854
- if (e === void 0) return t;
855
- let n = {}, r = e.length;
856
- for (let i = 0; i < r; i++) n[e[i]] = t[e[i]] ?? 0;
857
- return n;
858
- }
859
- get isIRangeStats() {
860
- return !0;
861
- }
862
- _mergeAggregates(e) {
863
- let t = this._children, n = t.length, r = {
864
- count: 0,
865
- min: void 0,
866
- max: void 0,
867
- numericalCount: 0,
868
- sum: 0,
869
- sumSq: 0,
870
- typed: {
871
- [_.Number]: 0,
872
- [_.String]: 0,
873
- [_.Boolean]: 0,
874
- [_.Error]: 0,
875
- [_.RichData]: 0,
876
- [_.Null]: 0
877
- }
878
- };
879
- for (let i = 0; i < n; i++) {
880
- let n = t[i].getAggregates(e);
881
- r.count += n.count;
882
- let a = n.numericalCount;
883
- a <= 0 || (r.numericalCount += a, r.sum += n.sum, r.sumSq += n.varP * a + n.sum * n.sum / a, (r.min === void 0 || n.min < r.min) && (r.min = n.min), (r.max === void 0 || n.max > r.max) && (r.max = n.max));
884
- }
885
- return Ee(r);
886
- }
887
- }, Et = Object.freeze([]);
888
- function Dt(e, t) {
889
- let n = e.length, r = t.length, i = Array(n + r), a = 0, o = 0, s = 0;
890
- for (; a < n && o < r;) i[s++] = e[a] <= t[o] ? e[a++] : t[o++];
891
- for (; a < n;) i[s++] = e[a++];
892
- for (; o < r;) i[s++] = t[o++];
893
- return i;
894
- }
895
- var Ot = class {
896
- constructor(e) {
897
- this.isIExternalBook = !0, this._json = e;
898
- }
899
- getIdentity() {
900
- return this._json.identity;
901
- }
902
- getSheetNames() {
903
- return this._json.sheetNames;
904
- }
905
- getDefinedNames() {
906
- return this._json.definedNames ?? [];
907
- }
908
- getSheetData(e) {
909
- return this._json.sheetDataSet?.find((t) => t.sheetIndex === e) ?? null;
910
- }
911
- toJSON() {
912
- return this._json;
913
- }
914
- }, kt = class {
915
- constructor(e) {
916
- this.isIExternalBookCollection = !0, this._items = (e?.json ?? []).map((e) => e ? new Ot(e) : null);
917
- }
918
- [Symbol.iterator]() {
919
- return this.getItems()[Symbol.iterator]();
920
- }
921
- getItems() {
922
- let e = [], t = this._items.length;
923
- for (let n = 0; n < t; n++) {
924
- let t = this._items[n];
925
- t && e.push(t);
926
- }
927
- return e;
928
- }
929
- getCount() {
930
- return this.getItems().length;
931
- }
932
- getByIndex(e) {
933
- return this._items[e - 1] ?? null;
934
- }
935
- toJSON() {
936
- return this._items.length === 0 ? null : this._items.map((e) => e?.toJSON() ?? null);
937
- }
938
- }, At = class {
939
- constructor(e) {
940
- this._closed = !1, this._options = { ...e };
941
- let t = this;
942
- this._transactions = this._options.transactions ?? new fe({ transient: !0 }), this._stateId = this._transactions.create(), this._transactionsRemoveListener = this._transactions.addStateListener(this._stateId, { onAfterStateChange(e, n, r) {
943
- t._emitter.notify("onCollectionChange");
944
- } }), this._emitter = new A(this, this._transactions), this._initState(e?.initial);
945
- }
946
- add(e, t, n) {
947
- let r = this;
948
- t && t.addListeners({ onDelete: (t) => {
949
- r._updateState((t) => {
950
- if (!t.modules[e]) return;
951
- let n = t.modules[e];
952
- if (n) {
953
- let i = { ...t };
954
- return r._options.onRemove?.(e, n), r._emitter.notify("onCollectionChange"), delete i.modules[e], i;
955
- }
956
- return t;
957
- }, m("op.deleteModule"));
958
- } }, { once: !0 });
959
- let i = this._getState()?.modules, a = i?.[e], o = n?.replace ?? !1;
960
- if (a && !o) throw Error(`Already existing '${e}'`);
961
- let s = { ...i };
962
- t ? (s[e] = t, r._options.onAdd?.(e, t), this._updateState({ modules: s }, m(o ? "op.saveScripts" : "op.addScript"))) : (delete s[e], r._options.onRemove?.(e, null), this._updateState({ modules: s }, m("op.removeScript"))), r._emitter.notify("onCollectionChange");
963
- }
964
- *[Symbol.iterator]() {
965
- yield* this.getItems();
966
- }
967
- getItems(t) {
968
- let n = this._getState();
969
- if (!n) return e.EmptyArray;
970
- let r = n.modules, i = Object.keys(r), a = i.length;
971
- if (a === 0) return e.EmptyArray;
972
- let o = [], s = t?.name ? t.name.toUpperCase() : null;
973
- for (let e = 0; e < a; e++) {
974
- let t = i[e], n = r[t], a = !0;
975
- s && s !== t.toUpperCase() && (a = !1), a && o.push(n);
976
- }
977
- return o ?? e.EmptyArray;
978
- }
979
- getByName(e) {
980
- if (!e) return null;
981
- let t = this._getState();
982
- if (!t) return null;
983
- let n = e.toUpperCase(), r = t.modules, i = Object.keys(r), a = i.length;
984
- for (let e = 0; e < a; e++) {
985
- let t = i[e];
986
- if (n === t.toUpperCase()) return r[t];
987
- }
988
- return null;
989
- }
990
- getCount() {
991
- let e = this._getState();
992
- return e ? Object.keys(e.modules).length : 0;
993
- }
994
- beginCommit(e) {
995
- return this._beginCommit(e);
996
- }
997
- _getState() {
998
- if (this._closed) throw Error(s("error.model.modelClosed"));
999
- return this._transactions.getState(this._stateId);
1000
- }
1001
- _beginCommit(e) {
1002
- return this._transactions.beginCommit(typeof e == "string" ? { description: e } : e);
1003
- }
1004
- _updateState(e, t = m("op.update"), n) {
1005
- if (!e) return;
1006
- let r = this._beginCommit(t);
1007
- try {
1008
- r.updateState(this._stateId, e), r.commit(n);
1009
- } catch (e) {
1010
- throw r.rollback(), e;
1011
- }
1012
- }
1013
- _initState(e) {
1014
- let t = e ?? {};
1015
- this._updateState({ modules: t }, m("op.initialize"), { forceAmend: !0 });
1016
- let n = this._options.onAdd;
1017
- if (n) {
1018
- let e = Object.keys(t), r = e.length;
1019
- for (let i = 0; i < r; i++) {
1020
- let r = e[i];
1021
- n(r, t[r]);
1022
- }
1023
- }
1024
- }
1025
- addListeners(e, t) {
1026
- return this._emitter.addListeners(e, t);
1027
- }
1028
- toJSON() {
1029
- let t = this._getState();
1030
- if (!t) return e.EmptyArray;
1031
- let n = t.modules, r = Object.keys(n), i = r.length, a = {};
1032
- for (let e = 0; e < i; e++) {
1033
- let t = r[e];
1034
- a[t] = n[t].toJSON();
1035
- }
1036
- return a;
1037
- }
1038
- isClosed() {
1039
- return this._closed;
1040
- }
1041
- close() {
1042
- this._closed || (this._emitter.notify("onClose"), this._closed = !0, this._transactionsRemoveListener?.());
1043
- }
1044
- get isFunctionCollection() {
1045
- return !0;
1046
- }
1047
- }, jt = class {
1048
- constructor(e) {
1049
- this._options = e, this._emitter = new A(this), this._initState();
1050
- }
1051
- _initState() {}
1052
- getModules() {
1053
- return this._modules;
1054
- }
1055
- _builtInNames() {
1056
- try {
1057
- let t = this._options.getBuiltInFunctions?.();
1058
- if (!t) return e.EmptyArray;
1059
- let n = [];
1060
- for (let e of t.getItems()) e.isBuiltIn() && n.push(e.getName());
1061
- return n;
1062
- } catch {
1063
- return e.EmptyArray;
1064
- }
1065
- }
1066
- async createModule(e) {
1067
- let t = await (await import("./B3ZyfwskutLZMYfl2.js").then((e) => e.t)).ScriptCompiler.compile({
1068
- builtInNames: this._builtInNames(),
1069
- ...e
1070
- });
1071
- return t.module ? await P("scripts", t.module, e?.declarationsOnly ?? !1, t.diagnostics) : null;
1072
- }
1073
- addModule(e, t, n) {
1074
- this._modules.add(e, t, n);
1075
- }
1076
- async addModuleFromJSON(e, t, n) {
1077
- let r = await P(e, t);
1078
- return this.addModule(e, r, n), r;
1079
- }
1080
- executeMacro(e, t, n) {
1081
- let r = this._modules.getItems({ name: t }), i = r.length;
1082
- for (let t = 0; t < i; t++) {
1083
- let i = r[t].getFunctions().getByName(e);
1084
- if (i) return i.execute(this._options.workbook, {
1085
- applyResult: !0,
1086
- ...n
1087
- });
1088
- }
1089
- throw Error(`No macro ${e} found.`);
1090
- }
1091
- async run(e, t) {
1092
- try {
1093
- let n = typeof e == "string" ? await this.createModule({ source: e }) : await P("scripts", e), r = typeof e == "string" ? e : e?.source ?? "";
1094
- return await this._runModule(n, r, t);
1095
- } catch (e) {
1096
- return {
1097
- ok: !1,
1098
- error: e
1099
- };
1100
- }
1101
- }
1102
- async _runModule(e, t, n) {
1103
- let r = this._options?.workbook;
1104
- if (!e) return {
1105
- ok: !1,
1106
- error: Error("The script did not compile to a module.")
1107
- };
1108
- let i = e.getDiagnostics(), a = i.filter((e) => e.severity === "error");
1109
- if (a.length > 0) {
1110
- let e = Error(((e, t) => {
1111
- let n = [0];
1112
- for (let t = 0; t < e.length; t++) e[t] === "\n" && n.push(t + 1);
1113
- let r = t.map((e) => ` ${((e) => {
1114
- let t = 0, r = n.length - 1;
1115
- for (; t < r;) {
1116
- let i = t + r + 1 >> 1;
1117
- n[i] <= e ? t = i : r = i - 1;
1118
- }
1119
- return `${t + 1}:${e - n[t] + 1}`;
1120
- })(e.start)} ${e.code}: ${e.message}`), i = t.length;
1121
- return `Script has ${i} compile error${i === 1 ? "" : "s"}:\n${r.join("\n")}`;
1122
- })(t, a));
1123
- return e.diagnostics = a, {
1124
- ok: !1,
1125
- error: e,
1126
- diagnostics: i
1127
- };
1128
- }
1129
- let o = e.getFunctions(), s = (await o.search({ type: "autoRun" }))[0] ?? (await o.search({ type: "macro" }))[0] ?? null;
1130
- if (!s) return {
1131
- ok: !1,
1132
- error: Error("The script has no runnable entry. Export a default function taking the script context, e.g. `export default function run(ctx: IScript.ScriptContext) { ... }` (the workbook is `ctx.wb`; a macro may instead take its target first, e.g. `(sheet: ISheet, ctx)`).")
1133
- };
1134
- let c = await s.execute(r, n);
1135
- return {
1136
- ok: !0,
1137
- result: c?.results,
1138
- commitId: c?.commitId,
1139
- diagnostics: i
1140
- };
1141
- }
1142
- async _searchable(e) {
1143
- let t = [];
1144
- if (e?.includeBuiltIn) {
1145
- await this._options.workbook?.getCalculation()?.start();
1146
- let e = this._options.getBuiltInFunctions?.();
1147
- e && t.push(e);
1148
- }
1149
- let n = this._modules;
1150
- if (!n || n.getCount() === 0) return t;
1151
- let r = e?.moduleName, i = r ? n.getItems({ name: r }) : n.getItems(), a = i.length;
1152
- for (let e = 0; e < a; e++) t.push(i[e].getFunctions());
1153
- return t;
1154
- }
1155
- async searchFunctions(t) {
1156
- await this._emitter.notify("onBeforeSearch", { async: !0 });
1157
- let n = await this._searchable(t);
1158
- if (n.length === 0) return e.EmptyArray;
1159
- let r, i = t?.limit, a = i === void 0 ? t : {
1160
- ...t,
1161
- limit: void 0
1162
- }, o = /* @__PURE__ */ new Set();
1163
- for (let e = 0; e < n.length; e++) {
1164
- let t = await n[e].search(a);
1165
- if (t.length !== 0) {
1166
- r ||= [];
1167
- for (let e = 0; e < t.length; e++) {
1168
- let n = t[e], i = n.getName().toUpperCase();
1169
- o.has(i) || (o.add(i), r.push(n));
1170
- }
1171
- }
1172
- }
1173
- if (!r || r.length === 0) return e.EmptyArray;
1174
- let s = t?.text ? t.text.trim().toUpperCase() : null;
1175
- return s && n.length > 1 && ye(r, s), i !== void 0 && r.length > i ? r.slice(0, i) : r;
1176
- }
1177
- async getFunctionCategories(t) {
1178
- await this._emitter.notify("onBeforeSearch", { async: !0 });
1179
- let n = await this._searchable(t);
1180
- if (n.length === 0) return e.EmptyArray;
1181
- if (n.length === 1) return n[0].getCategories(t);
1182
- let r = t?.includeDeprecated ?? !1, i = /* @__PURE__ */ new Map(), a = (e) => {
1183
- let t = e.toUpperCase(), n = i.get(t);
1184
- n ? n.count++ : i.set(t, {
1185
- name: e,
1186
- count: 1
1187
- });
1188
- };
1189
- for (let e of await n[0].getCategories(t)) i.set(e.name.toUpperCase(), {
1190
- name: e.name,
1191
- count: e.count
1192
- });
1193
- for (let e = 1; e < n.length; e++) {
1194
- let i = await n[e].search(t?.type ? { type: t.type } : void 0);
1195
- for (let t = 0; t < i.length; t++) {
1196
- let o = i[t], s = o.getName().toUpperCase(), c = !1;
1197
- for (let t = 0; t < e && !c; t++) c = !!n[t].getByName(s);
1198
- if (c) continue;
1199
- let l = await o.getDescriptor().catch(() => null);
1200
- !r && l?.isDeprecated() || a(l?.getCategory() ?? "Uncategorized");
1201
- }
1202
- }
1203
- let o = Array.from(i.values());
1204
- return o.sort((e, t) => e.name.localeCompare(t.name)), o;
1205
- }
1206
- async start() {
1207
- if (!this._modules) return this._startPromise || (this._startPromise = this._doStart(), this._startPromise.catch(() => {
1208
- this._startPromise = void 0;
1209
- })), this._startPromise;
1210
- }
1211
- async _doStart() {
1212
- let t = this._options?.workbook, n = this._options?.json, r = {};
1213
- if (n) {
1214
- let e = Object.keys(n);
1215
- for (let t = 0; t < e.length; t++) {
1216
- let i = e[t], a = n[i];
1217
- try {
1218
- r[i] = await P(i, a);
1219
- } catch (e) {
1220
- o.error(`Could not load script '${i}'; it will be unavailable.`, e);
1221
- }
1222
- }
1223
- }
1224
- let i = this, a = new At({
1225
- transactions: this._options?.transactions,
1226
- initial: r,
1227
- onRemove: (e, t) => {
1228
- i._options?.onRemove?.(e, t);
1229
- },
1230
- onAdd: (e, t) => {
1231
- i._emitter.notify("onChange"), i._options?.onAdd?.(e, t);
1232
- }
1233
- });
1234
- this._modules = a;
1235
- let s = a.getItems();
1236
- if (s.length === 0) return Promise.resolve(e.EmptyArray);
1237
- let c = s.length;
1238
- for (let e = 0; e < c; e++) {
1239
- let n = s[e];
1240
- try {
1241
- let e = await n.getFunctions().search({ type: "autoRun" }), r = e.length;
1242
- for (let n = 0; n < r; n++) await e[n].execute(t);
1243
- } catch (e) {
1244
- o.error("Error executing autoRun script:", e);
1245
- }
1246
- }
1247
- }
1248
- addListeners(e, t) {
1249
- return this._emitter.addListeners(e, t);
1250
- }
1251
- isReadOnly() {
1252
- return !1 === this._options.workbook?.getProtection().isStructureAllowed();
1253
- }
1254
- toJSON() {
1255
- this._emitter.notify("onBeforeSave");
1256
- let e = this._modules;
1257
- if (!e) throw Error("Scripts is initializing.");
1258
- return e.toJSON();
1259
- }
1260
- }, Mt = class {
1261
- constructor(e, t, n, r) {
1262
- this._mergedReading = [], this._colsReading = [], this._rowsReading = [], this._styles = n, this._topLeft = t ?? l.EmptyCell, this._sheet = new D({
1263
- runtime: e,
1264
- styles: this._styles,
1265
- container: {
1266
- getName: () => r,
1267
- getIndex: () => 1
1268
- }
1269
- }), this._builder = this._sheet.getEntireRange().createSparseBuilder();
1270
- }
1271
- applyCSSStyle(e, t) {
1272
- let n = !1;
1273
- e.style || (e.style = {}, n = !0);
1274
- let r = e.style, i = { ...t };
1275
- if (t.msoIgnore) {
1276
- let e = t.msoIgnore.split(","), n = Object.keys(i);
1277
- for (let t = 0; t < n.length; t++) {
1278
- let r = n[t];
1279
- e.includes(r) && delete i[r];
1280
- }
1281
- }
1282
- let a = Te(i.fontFamily);
1283
- r.font = {}, a && (r.font.family = a.family, r.font.fallbacks = a.fallbacks, r.font.size = a.size), r.font.size = i.fontSize, r.font.weight = i.fontWeight, r.font.style = i.fontStyle, r.font.color = i.color;
1284
- let o = y(i.textDecoration);
1285
- r.font.underline = o.underline, r.font.strike = o.strike, i.textUnderlineStyle && (r.font.underline = Ue(i.textUnderlineStyle)), r.alignment = {}, i?.textAlign && (r.alignment.horizontal = me(i.textAlign)), i?.textAlign && !r.alignment.horizontal && i?.textAlign !== "general" && (i.textAlign === "center-across" ? r.alignment.horizontal = N.HorizontalAlignment.CenterContinuous : i.textAlign === "fill" ? r.alignment.horizontal = N.HorizontalAlignment.Fill : i.textAlign === "121" || i.textAlign === "010" ? (r.alignment.horizontal = N.HorizontalAlignment.Distributed, r.alignment.justifyLastLine = i.textAlign === "121") : console.warn("unknown text-align", i.textAlign)), i.verticalAlign && (i.verticalAlign.toLowerCase() === "super" ? r.font.verticalAlign = k.VerticalAlignment.Super : i.verticalAlign.toLowerCase() === "sup" ? r.font.verticalAlign = k.VerticalAlignment.Sub : r.alignment.vertical = Le(i.verticalAlign), r.alignment.vertical || (i.verticalAlign === "121" ? r.alignment.vertical = N.VerticalAlignment.Distributed : console.warn("unknown vertical-align", i.verticalAlign))), i.msoCharIndentCount && (r.alignment.indent = i.msoCharIndentCount), i.whiteSpace && (r.alignment.overflow = i.whiteSpace === "no-wrap" || i.whiteSpace === "nowrap" ? N.Overflow.Visible : N.Overflow.Wrap), i.msoTextControl === "shrinktofit" && (r.alignment.overflow = N.Overflow.Shrink);
1286
- let s = null;
1287
- if (i.background ? s = i.background : i.backgroundColor && (s = i.backgroundColor), s && (r.fill = { color: s }), i.msoPattern) {
1288
- let e = w(i.msoPattern);
1289
- e && (e.patternType === be.BuiltInSheetPattern.Solid ? r.fill = { color: e.foreground } : e.patternType !== be.BuiltInSheetPattern.None && (s && (e.background = s), r.fill = e));
1290
- }
1291
- i.msoRotate !== void 0 && (r.alignment.rotation = xe(i.msoRotate));
1292
- let c = (e, t) => {
1293
- e && (r.border ||= {}, r.border[e] = t);
1294
- };
1295
- i.border && i.border !== "none" && (c("top", i.border), c("left", i.border), c("right", i.border), c("bottom", i.border)), i.borderTop && c("top", i.borderTop), i.borderLeft && c("left", i.borderLeft), i.borderRight && c("right", i.borderRight), i.borderBottom && c("bottom", i.borderBottom), i.msoDiagonalUp && c("diagonalUp", i.msoDiagonalUp), i.msoDiagonalDown && c("diagonalDown", i.msoDiagonalDown);
1296
- let l = r.numberFormat;
1297
- i.msoNumberFormat && (l = he(i.msoNumberFormat), l.includes("\\") ? l = null : l === "Fixed" ? l = M.Styles.lookupStyle(r.numberFormat).formatType === M.Type.Number ? null : M.Type.Number : l === "Percent" && (l = M.Styles.lookupStyle(r.numberFormat).formatType === M.Type.Percentage ? null : M.Type.Percentage)), l && (r.numberFormat = l), e.style = this._styles.normalize(r), n && Object.keys(e.style).length === 0 && delete e.style;
1298
- }
1299
- onCell(e, t, n, r, i) {
1300
- let a = r(i), o = { value: t === void 0 ? n ?? "" : t };
1301
- if (typeof o.value == "string" && o.value.length === 0 && (o.value = void 0), a && this.applyCSSStyle(o, a), i?.tagName.toUpperCase() === "TD") {
1302
- let e = o.style, t = e?.font ?? {};
1303
- (i.querySelectorAll("s").length > 0 || i.querySelectorAll("strike").length > 0) && (t.strike = !0), i.querySelectorAll("sub").length > 0 && (t.verticalAlign = k.VerticalAlignment.Sub), i.querySelectorAll("sup").length > 0 && (t.verticalAlign = k.VerticalAlignment.Super), (i.querySelectorAll("b").length > 0 || i.querySelectorAll("strong").length > 0) && (t.weight = 700), i.querySelectorAll("i").length > 0 && (t.style = k.Style.Italic), i.querySelectorAll("u").length > 0 && (t.underline = k.UnderlineStyle.Single), Object.keys(t).length > 0 && (e || (e = {}, o.style = e), e.font ||= t);
1304
- let n = i.querySelectorAll("a");
1305
- if (n.length > 0) {
1306
- let e = n[0].getAttribute("href");
1307
- e && (o.hyperlink = e);
1308
- }
1309
- }
1310
- if (!l.isSingleCell(e)) {
1311
- let t = {
1312
- rowStart: this._topLeft.rowIndex + e.rowStart,
1313
- colStart: this._topLeft.colIndex + e.colStart,
1314
- rowEnd: this._topLeft.rowIndex + e.rowEnd,
1315
- colEnd: this._topLeft.colIndex + e.colEnd
1316
- };
1317
- this._mergedReading.push(t);
1318
- }
1319
- if (o.value === void 0 && !o.style && Object.keys(o).length <= 1) return;
1320
- let s = this._builder, c = this._topLeft;
1321
- if (s.pushAt(c.rowIndex + e.rowStart, c.colIndex + e.colStart, o), !l.isSingleCell(e) && a.msoIgnore) {
1322
- if (a.msoIgnore.includes("colspan")) {
1323
- let t = {};
1324
- a && this.applyCSSStyle(t, a);
1325
- let n = e.colEnd - e.colStart, r = c.rowIndex + e.rowStart;
1326
- for (let i = 1; i <= n; i++) s.pushAt(r, c.colIndex + e.colStart + i, t);
1327
- e = {
1328
- ...e,
1329
- colEnd: e.colStart
1330
- };
1331
- }
1332
- a.msoIgnore.includes("rowspan") && (e = {
1333
- ...e,
1334
- rowEnd: e.rowStart
1335
- });
1336
- }
1337
- }
1338
- onNoTable(e, t, n) {
1339
- this.onCell({
1340
- rowStart: this._topLeft.rowIndex,
1341
- colStart: this._topLeft.colIndex,
1342
- rowEnd: this._topLeft.rowIndex,
1343
- colEnd: this._topLeft.colIndex
1344
- }, e, null, t, n);
1345
- }
1346
- onRowStart(e, t, n, r) {
1347
- let i = n(r);
1348
- if (i.msoHeightSource !== "userset" || !r) return;
1349
- let a = r.getAttribute("height") ?? i.height, o = null;
1350
- if (a && (o = v(a, this._styles.getNormal().getFont().getSize(), "px")), o === null) for (let e = 0; e < r.cells.length; e++) {
1351
- let t = r.cells[e], i = v(t.getAttribute("height") ?? n(t).height, this._styles.getNormal().getFont().getSize(), "px");
1352
- i !== null && (o = Math.max(i, o ?? 0));
1353
- }
1354
- o !== null && this._rowsReading.push({
1355
- address: {
1356
- min: this._topLeft.rowIndex + e,
1357
- max: this._topLeft.rowIndex + e + t - 1
1358
- },
1359
- update: { size: o * k.getDeviceScale() }
1360
- });
1361
- }
1362
- onColumn(e, t, n, r) {
1363
- let i = n(r);
1364
- if (i.msoWidthSource !== "userset" || !r) return;
1365
- let a = r.getAttribute("width") ?? i.width, o = null;
1366
- a && (o = v(a, this._styles.getNormal().getFont().getSize(), "px")), o !== null && this._colsReading.push({
1367
- address: {
1368
- min: this._topLeft.colIndex + e,
1369
- max: this._topLeft.colIndex + e + t - 1
1370
- },
1371
- update: { size: o * k.getDeviceScale() }
1372
- });
1373
- }
1374
- onDone() {
1375
- this._colsReading.length > 0 && this._sheet.getColumnHeaders().updateHeaderPairs(this._colsReading), this._rowsReading.length > 0 && this._sheet.getRowHeaders().updateHeaderPairs(this._rowsReading), this._sheet.doBatch(() => {
1376
- this._builder.apply();
1377
- }), this._mergedReading.length > 0 && this._sheet.getRanges(this._mergedReading).merge();
1378
- }
1379
- sheet() {
1380
- return this._sheet;
1381
- }
1382
- }, Nt = class {
1383
- constructor(e) {
1384
- if (!e) throw new r("snapshot is required.");
1385
- this._snapshot = e;
1386
- }
1387
- getItemType() {
1388
- return "range";
1389
- }
1390
- getItem() {
1391
- return this._snapshot;
1392
- }
1393
- editMode() {
1394
- return this._snapshot?.getMarkOptions().editMode ?? null;
1395
- }
1396
- isCut() {
1397
- return this._snapshot?.getMarkOptions().isCut ?? !1;
1398
- }
1399
- getName() {
1400
- return this._snapshot.getName();
1401
- }
1402
- toText() {
1403
- return this._snapshot.toText();
1404
- }
1405
- toHtml() {
1406
- return this._snapshot.toHtml();
1407
- }
1408
- toImage() {
1409
- return this._snapshot.toImage();
1410
- }
1411
- get isClipboardItem() {
1412
- return !0;
1413
- }
1414
- }, Pt = class {
1415
- constructor(e, t, n, i, a) {
1416
- if (this._parsed = void 0, this._runtime = e, !t) throw new r("nativeItems are required.");
1417
- this._topLeft = n ?? l.EmptyCell, this._native = t, this._markOptions = Object.freeze(i ?? {}), this._styles = a;
1418
- }
1419
- getItemType() {
1420
- return "range";
1421
- }
1422
- isCut() {
1423
- return !1;
1424
- }
1425
- toText() {
1426
- return this._native?.text;
1427
- }
1428
- toHtml() {
1429
- return this._native?.html?.documentElement.outerHTML || null;
1430
- }
1431
- toImage() {
1432
- return this._native?.image;
1433
- }
1434
- getItem() {
1435
- let e = this._parsed;
1436
- if (e === void 0) throw Error("Must call 'parse()' before getItem().");
1437
- if (e === null) return null;
1438
- if (this._snapshot) return this._snapshot;
1439
- let t = this;
1440
- return this._snapshot = {
1441
- copyTo: (n, r) => e.copyTo(n, {
1442
- ...t._markOptions,
1443
- ...r
1444
- }),
1445
- getMarkOptions: () => t._markOptions,
1446
- getName: () => e?.getName() ?? "Clipboard Data",
1447
- getCoords: () => e?.getCoords?.() ?? null,
1448
- toText: () => t.toText(),
1449
- toHtml: () => t.toHtml(),
1450
- toImage: () => t.toImage(),
1451
- getSource: () => e?.getSource?.() ?? null,
1452
- isISnapshot: !0
1453
- }, this._snapshot;
1454
- }
1455
- async parse() {
1456
- let e, t = this._native?.text, n = this._native.html;
1457
- if (n === null && t && t.includes("<table")) try {
1458
- let e = new DOMParser().parseFromString(t, d.Html), r = e.querySelector("parsererror");
1459
- if (r) throw new f("Unable to parse: " + r);
1460
- n = e, t = null;
1461
- } catch {
1462
- console.warn("Discovered text as html table but could could not parse.");
1463
- }
1464
- try {
1465
- let r = new Mt(this._runtime, this._topLeft, this._styles, n ? "HTML" : "Text");
1466
- await r.sheet().getCalculation().ready(), await r.sheet().getCalculation().stop();
1467
- let i, a = await Promise.resolve(t ? ue(t) : [[]]);
1468
- if (we(n, a, r) ? (e = r.sheet(), i = e.getUsedRange()) : n = null, i) return this._parsed = {
1469
- copyTo: async (e, t) => (await e.copyFrom(i, t))?.getCoords() ?? null,
1470
- getCoords: () => i.getCoords(),
1471
- getSource: () => e,
1472
- getName: () => e.getName()
1473
- }, !0;
1474
- } catch (e) {
1475
- throw e;
1476
- }
1477
- if (!t && !n && this._native.image) {
1478
- let e = this;
1479
- return this._parsed = {
1480
- async copyTo(t, n) {
1481
- let r = t.getSheet(), i = await e._native.image.arrayBuffer(), a = await r.getMovables().addPicture({ source: { buffer: i } }, {
1482
- type: "picture",
1483
- description: m("op.copyImageFromClipboard")
1484
- });
1485
- return r.getView().selectMovables([a]), null;
1486
- },
1487
- getName: () => "Image"
1488
- }, !0;
1489
- }
1490
- return !1;
1491
- }
1492
- get isClipboardItem() {
1493
- return !0;
1494
- }
1495
- }, Y = {
1496
- showFormulaBar: !0,
1497
- showTabs: !0,
1498
- tabRatio: 600,
1499
- showHorizontalScrollbar: !0,
1500
- showVerticalScrollbar: !0,
1501
- showStatusBar: !0,
1502
- activeSheetId: 0
1503
- }, Ft = class {
1504
- constructor(e) {
1505
- this._emitter = new A(this), this._state = { ...Y }, e?.json && this._fromJSON(e?.json);
1506
- }
1507
- isShowFormulaBar() {
1508
- return this._state.showFormulaBar;
1509
- }
1510
- setShowFormulaBar(e) {
1511
- return this._state.showFormulaBar = e, this._emitter.notify("onViewChange"), this;
1512
- }
1513
- isShowTabs() {
1514
- return this._state.showTabs;
1515
- }
1516
- setShowTabs(e) {
1517
- return this._state.showTabs = e, this._emitter.notify("onViewChange"), this;
1518
- }
1519
- getTabRatio() {
1520
- return this._state.tabRatio;
1521
- }
1522
- setTabRatio(e) {
1523
- return this._state.tabRatio = e, this._emitter.notify("onViewChange"), this;
1524
- }
1525
- isShowHorizontalScrollbar() {
1526
- return this._state.showHorizontalScrollbar;
1527
- }
1528
- setShowHorizontalScrollbar(e) {
1529
- return this._state.showHorizontalScrollbar = e, this._emitter.notify("onViewChange"), this;
1530
- }
1531
- isShowVerticalScrollbar() {
1532
- return this._state.showVerticalScrollbar;
1533
- }
1534
- setShowVerticalScrollbar(e) {
1535
- return this._state.showVerticalScrollbar = e, this._emitter.notify("onViewChange"), this;
1536
- }
1537
- isShowStatusBar() {
1538
- return this._state.showStatusBar;
1539
- }
1540
- setShowStatusBar(e) {
1541
- return this._state.showStatusBar = e, this._emitter.notify("onViewChange"), this;
1542
- }
1543
- getActiveSheetId() {
1544
- return this._state.activeSheetId;
1545
- }
1546
- setActiveSheetId(e) {
1547
- let t = this._state, n = t.activeSheetId;
1548
- return t.activeSheetId = e, n !== e && this._emitter.notify("onViewChange"), this;
1549
- }
1550
- addListeners(e, t) {
1551
- return this._emitter.addListeners(e, t);
1552
- }
1553
- toJSON() {
1554
- let e = {}, t = Object.keys(this._state), n = t.length;
1555
- for (let r = 0; r < n; r++) {
1556
- let n = t[r], i = this._state[n];
1557
- i != null && i !== Y[n] && (e[n] = i);
1558
- }
1559
- return Object.keys(e).length === 0 && (e = null), e;
1560
- }
1561
- _fromJSON(e, t = !0) {
1562
- let n = e || {};
1563
- this.update(n, t);
1564
- }
1565
- update(e, t = !0) {
1566
- this._state = {
1567
- ...Y,
1568
- ...this._state,
1569
- ...e
1570
- }, t && this._emitter.notify("onViewChange");
1571
- }
1572
- get [Symbol.toStringTag]() {
1573
- return "[WorkbookView]";
1574
- }
1575
- toString() {
1576
- let e = this.toJSON();
1577
- return e ? JSON.stringify(e) : "DefaultWorkbookView";
1578
- }
1579
- }, It = Object.freeze({
1580
- structure: !1,
1581
- windows: !1,
1582
- revision: !1,
1583
- password: null,
1584
- revisionsPassword: null
1585
- }), Lt = class extends _e {
1586
- isWindowsAllowed() {
1587
- return this._isPropertyAllowed("windows");
1588
- }
1589
- isRevisionAllowed() {
1590
- return this._isPropertyAllowed("revision");
1591
- }
1592
- isStructureAllowed() {
1593
- return this._isPropertyAllowed("structure");
1594
- }
1595
- _fromJSON(e) {
1596
- this._properties = e;
1597
- }
1598
- _toJSON(e) {
1599
- let t = this._properties;
1600
- if (t) {
1601
- e = {
1602
- ...e,
1603
- ...t
1604
- };
1605
- let n = Object.keys(t), r = n.length;
1606
- for (let i = 0; i < r; i++) {
1607
- let r = n[i], a = t[r];
1608
- a != null && a !== It[r] && (e[r] = a);
1609
- }
1610
- }
1611
- return super._toJSON(e);
1612
- }
1613
- get [Symbol.toStringTag]() {
1614
- return "[WorkbookProtection]";
1615
- }
1616
- };
1617
- function X(e) {
1618
- return s("error.workbook.invalidSheetKey", { key: e });
1619
- }
1620
- var Rt, zt, Bt = class {
1621
- constructor(e, t) {
1622
- this._add = e, this._get = t;
1623
- }
1624
- add(e) {
1625
- return this._add(e);
1626
- }
1627
- *[Symbol.iterator]() {
1628
- yield* this.getItems();
1629
- }
1630
- getItems(e) {
1631
- return this._get(e?.name, e?.visibility);
1632
- }
1633
- getByName(e) {
1634
- return this._get(e)?.[0] ?? null;
1635
- }
1636
- getCount() {
1637
- return this._get().length;
1638
- }
1639
- }, Z = /* @__PURE__ */ new RegExp(/[\\/\\*?:[\]]+/), Vt = /* @__PURE__ */ new RegExp(/\(((\d+)(?!.*\d))\)$/, "g");
1640
- function Ht(e) {
1641
- let t = s(m("workbook.defaultSheetName"), { n: e + 1 });
1642
- return t === "workbook.defaultSheetName" ? `Sheet${e + 1}` : t;
1643
- }
1644
- function Q(e, t) {
1645
- return {
1646
- ...Se,
1647
- getSheet: () => null,
1648
- toString: () => O(e, t)
1649
- };
1650
- }
1651
- function Ut(e, t = !1) {
1652
- if (!e) throw Error(s("error.workbook.sheetNameBlank"));
1653
- if (Z.test(e)) {
1654
- if (!t) throw Error(function(e) {
1655
- return e ? s("error.workbook.sheetNameInvalidCharsNamed", { sheetName: e }) : s("error.workbook.sheetNameInvalidChars");
1656
- }(e));
1657
- e = e.replace(Z, "");
1658
- }
1659
- if (e.length === 0) throw Error(s("error.workbook.sheetNameBlank"));
1660
- let n = e.length;
1661
- if (n > 31) {
1662
- if (!t) throw Error(s("error.workbook.sheetNameTooLong"));
1663
- e = e.substring(0, 31);
1664
- }
1665
- if (e.charAt(0) === "'" || e.charAt(n - 1) === "'") {
1666
- if (!t) throw Error(s("error.workbook.sheetNameQuotes"));
1667
- e = e.replace(/^'|'$/g, "");
1668
- }
1669
- return e;
1670
- }
1671
- var Wt, $ = class e extends ee {
1672
- constructor(e, t, n, r) {
1673
- super(e, t, r), this._workbook = n;
1674
- }
1675
- getSource() {
1676
- return this._workbook;
1677
- }
1678
- _createRanges(t, n) {
1679
- let r = this._options;
1680
- return n && (r = {
1681
- ...this._options,
1682
- getOptions: x(this._options?.getOptions, n)
1683
- }), new e(t, this._internal, this._workbook, r);
1684
- }
1685
- _createRange(e, t) {
1686
- let n = e ? { ...e } : null, r = n ? this._workbook._getSheetRef(n.scope, R.Visibility.VeryHidden) : null;
1687
- if (!r) {
1688
- let e = this._workbook.getSelectedSheet();
1689
- return delete n?.scope, Q(n, n ? {
1690
- scope: Pe,
1691
- ...e.getEntireRange().getCoords()
1692
- } : null);
1693
- }
1694
- let i = this._options;
1695
- return t && (i = {
1696
- ...this._options,
1697
- getOptions: x(this._options.getOptions, t)
1698
- }), new Gt(e, I(r.sheet), this._workbook, i);
1699
- }
1700
- async select(e) {
1701
- let t = [], n = null, r = this.getCoords();
1702
- for (let e = 0; e < r.length; e++) {
1703
- let i = r[e];
1704
- i && (n ||= i.scope, i && i.scope === n && t.push(i));
1705
- }
1706
- n ||= this._workbook.getSelectedSheet().getName();
1707
- let i = this._workbook.getSheets().getByName(n);
1708
- if (!i) return;
1709
- let a = await i.getRanges(t).select(e), o = this._workbook._rangesAddressToCoords(a.getCoords());
1710
- return this._createRanges(o);
1711
- }
1712
- addListener(e, t) {
1713
- if (!this.getCoords()) return () => {};
1714
- let n = this._workbook._sheetToWBEvent(e);
1715
- return super.addListener(n, t);
1716
- }
1717
- get [Symbol.toStringTag]() {
1718
- return "[WorkbookRanges]";
1719
- }
1720
- getAddress(e) {
1721
- let t = this._internal.getSheet(), n = t.getEntireRange().getCoords();
1722
- return Me(this.getCoords(), {
1723
- ...n,
1724
- scope: t.getName()
1725
- }, O, je, e);
1726
- }
1727
- toString() {
1728
- return this.getAddress();
1729
- }
1730
- }, Gt = class e extends oe {
1731
- constructor(e, t, n, r) {
1732
- super(e, t, r), this._workbook = n;
1733
- }
1734
- _createRanges(e, t) {
1735
- let n = this._options;
1736
- return t && (n = {
1737
- ...this._options,
1738
- getOptions: x(this._options?.getOptions, t)
1739
- }), new $(e, this._internal, this._workbook, n);
1740
- }
1741
- _createRange(t, n) {
1742
- let r = this._internal;
1743
- if (!t) return F(r.getSheet(), r.getSheet().getEntireCoords());
1744
- if (r.validateCoords(t), r.getSheet().isClosed()) return F(null, r.getSheet().getEntireCoords(), t);
1745
- let i = this._options;
1746
- return n && (i = {
1747
- ...this._options,
1748
- getOptions: x(this._options?.getOptions, n)
1749
- }), new e(t, this._internal, this._workbook, i);
1750
- }
1751
- addListener(e, t) {
1752
- if (!this.getCoords()) return () => {};
1753
- let n = this._workbook._sheetToWBEvent(e);
1754
- return super.addListener(n, t);
1755
- }
1756
- get [Symbol.toStringTag]() {
1757
- return "[WorkbookRange]";
1758
- }
1759
- getAddress(e) {
1760
- let t = this._internal.getSheet(), n = t?.getEntireRange().getCoords() ?? null;
1761
- return O(this.getCoords(), {
1762
- ...n,
1763
- scope: t.getName()
1764
- });
1765
- }
1766
- toString() {
1767
- return this.getAddress();
1768
- }
1769
- }, Kt = class {
1770
- constructor(t) {
1771
- this._lastTransactionUUID = null, this._closed = !1, this._listenerOrigin = null, this._lastOriginName = null, this._initializing = !0, this._isDate1904 = !1, this._locale = null, this._localeOverrides = null;
1772
- let n = typeof t == "string" ? { origin: t } : { ...t }, r = n.origin;
1773
- this._origin = typeof r == "string" ? new z(null, { name: r }) : r ?? new z(null), delete n.origin, this._lastOriginName = this._origin.getName(), this._listenerOrigin = this._origin.addListeners({ onChange: () => {
1774
- if (this._closed) return;
1775
- let e = this._origin.getName();
1776
- e !== this._lastOriginName && (this._lastOriginName = e, this._emitter.notify("onNameChange"));
1777
- } });
1778
- let i = n.json;
1779
- delete n.json, this._transactions = n.transactions ?? new fe(), this._id = this._transactions.create(), this._ownTransactions = !n.transactions, this._emitter = new A(this, this._transactions), this._runtime = n.runtime ?? new ve("Workbook Runtime", {
1780
- isDate1904: () => this._isDate1904,
1781
- getLocale: () => this._locale ?? He() ?? ke(),
1782
- getLocaleOverrides: () => this._localeOverrides
1783
- }), this._listenerLanguage = c.addChangeListener(() => {
1784
- this._locale !== null || this._closed || this._notifyAllChange();
1785
- });
1786
- let a = this, o = this._beginCommit({ description: m(i ? "op.openWorkbook" : "op.newWorkbook") });
1787
- try {
1788
- this._strings = n.strings ?? new se(), this._ownStrings = !n.strings, this._externalBooks = new kt({ json: i?.externalBooks }), this._resources = n.resources ?? new b(), this._ownResources = !n.resources, this._createSheetName = n.createSheetNameCallback ?? Ht;
1789
- let t = n.createSheetCallback;
1790
- t ||= (e) => new D(e), this._sheetOnNameChange = /* @__PURE__ */ new Map(), this._sheetOnVisibilityChange = /* @__PURE__ */ new Map(), this._sheetOnIndexChange = /* @__PURE__ */ new Map(), this._createSheet = (e, n, r, i, o) => {
1791
- let s = null, c = {
1792
- runtime: a._runtime,
1793
- readonly: a._options.readonly ?? !1,
1794
- disableLoadAutoFit: a._options.disableLoadAutoFit ?? !1,
1795
- formulaTransform: a._options.formulaTransform,
1796
- opener: a._options.opener,
1797
- transactions: a._transactions,
1798
- styles: a._styles,
1799
- strings: a._strings,
1800
- resources: a._resources,
1801
- names: a._names,
1802
- workbook: a,
1803
- calculation: a._calculation,
1804
- resolveRange: (e) => a._options.resolveRange?.(e) ?? a.getRange(e),
1805
- container: {
1806
- beforeFromJSON: (t) => {
1807
- s = t, a._addSheetRef({
1808
- name: n,
1809
- id: e,
1810
- visibility: r ?? R.Visibility.Visible,
1811
- sheet: t
1812
- }, i);
1813
- },
1814
- getName: () => {
1815
- let e = a._getSheetRef(s);
1816
- return e ? e.name : n;
1817
- },
1818
- setName: (e, t) => {
1819
- a._getSheetRef(s) && a._setSheetName(s, e, t);
1820
- },
1821
- setNameChangeCallback: (t) => {
1822
- a._sheetOnNameChange.set(e, t);
1823
- },
1824
- getVisibility: () => {
1825
- let e = a._getSheetRef(s);
1826
- return e ? e.visibility : R.Visibility.Visible;
1827
- },
1828
- setVisibility: (e, t) => {
1829
- a._setSheetVisibility(s, e, t);
1830
- },
1831
- setVisibilityCallback: (t) => {
1832
- a._sheetOnVisibilityChange.set(e, t);
1833
- },
1834
- duplicate: () => a._duplicateSheet(s),
1835
- getIndex: () => {
1836
- let e = a._getSheetRef(s);
1837
- return e ? a._getOffsetForId(e.id, a._getSheetRefs(R.Visibility.VeryHidden)) : i;
1838
- },
1839
- setIndex: (e, t) => {
1840
- let n = a._getSheetRef(s, R.Visibility.VeryHidden);
1841
- return !!n && (a._moveSheet(n, e, t), !0);
1842
- },
1843
- setIndexCallback: (t) => {
1844
- a._sheetOnIndexChange.set(e, t);
1845
- },
1846
- requestSelect: async () => (a._setSelectedSheet(s), await this._emitter.notify("onRequestSelect", {
1847
- source: a,
1848
- params: s,
1849
- async: !0
1850
- }), a.getSelectedSheet() === s)
1851
- }
1852
- };
1853
- return o && (c.json = o), s = t(c, n, i, r), s;
1854
- }, this._namedTableSource = new Ae({
1855
- getSheets: () => a._sheets ? a.getSheets().getItems() : e.EmptyArray,
1856
- addSheetsListener: (e, t) => a.addListeners({ onSheetsChange: e }, t)
1857
- }), this._names = n.names ?? new C({
1858
- addressToRanges: (e) => a.getRanges(e),
1859
- getCurrentScope: () => a.getSelectedSheet().getName(),
1860
- isReadOnly: () => a._options.readonly ?? !1,
1861
- transactions: a._transactions,
1862
- getSources: () => a._calculation ? [a._calculation.getNamedFormulas(), a._namedTableSource] : e.EmptyArray
1863
- }), this._ownNames = !n.names, this._calculation = n.calculation ?? new Ne({
1864
- runtime: a._runtime,
1865
- functions: n.functions,
1866
- json: i?.calc,
1867
- getActiveCell: () => {
1868
- let e = a.getSelectedSheet(), t = e?.getSelectedRange()?.getCoords();
1869
- return t ? {
1870
- rowIndex: t.rowStart,
1871
- colIndex: t.colStart,
1872
- scope: e.getId()
1873
- } : null;
1874
- },
1875
- getRange: a.getRange.bind(a),
1876
- getRanges: a.getRanges.bind(a),
1877
- createGraphRanges: (e, t) => a._createGraphRanges(e, t),
1878
- getSheetIndex: (e) => {
1879
- if (e === void 0) {
1880
- let e = a.getSelectedSheet();
1881
- return e ? this._getSheetRefs(R.Visibility.VeryHidden).findIndex((t) => t.sheet === e) : -1;
1882
- }
1883
- let t = this._getSheetRefs(R.Visibility.VeryHidden);
1884
- e = e.toLowerCase();
1885
- let n = t.length;
1886
- for (let r = 0; r < n; r++) if (t[r].name.toLowerCase() === e) return r;
1887
- try {
1888
- qt.address = e;
1889
- let t = this._names.getItems(qt);
1890
- if (!t || t.length === 0) return -1;
1891
- let n = t[0].getRanges?.()?.getCoords()?.[0]?.scope;
1892
- if (!n) return -1;
1893
- let r = this._getSheetRefs(R.Visibility.VeryHidden);
1894
- n = n.toLowerCase();
1895
- let i = r.length;
1896
- for (let e = 0; e < i; e++) if (r[e].name.toLowerCase() === n) return e;
1897
- } catch {
1898
- return -1;
1899
- }
1900
- return -1;
1901
- },
1902
- getSheetCount: () => a.getSheets().getItems({ visibility: R.Visibility.VeryHidden }).length,
1903
- getSheetById: (e) => {
1904
- let t = a.getSheets().getItems({ visibility: R.Visibility.VeryHidden }), n = t.length;
1905
- for (let r = 0; r < n; r++) if (t[r].getId() === e) return t[r];
1906
- return null;
1907
- },
1908
- getSheetByName: (e) => {
1909
- try {
1910
- return a.getSheets().getByName(e) ?? null;
1911
- } catch {
1912
- return null;
1913
- }
1914
- },
1915
- namedCollection: a._names,
1916
- strings: a._strings,
1917
- transactions: a._transactions,
1918
- names: i?.names,
1919
- formulaTransform: n.formulaTransform
1920
- }), this._ownCalculation = !n.calculation, this._scripts = this._createScripts(), this._ownNames = !n.names, this._options = Object.freeze({ ...n });
1921
- let r = async () => {
1922
- this._ownCalculation && await this._calculation.start(), await this._scripts.start(), this._starting = null;
1923
- };
1924
- this._starting = r(), this._starting?.catch(() => {}), i ? this._fromJSON(i) : (this._initState(), this._addSheet(!1)), this._sheets = new Bt((e) => a._addSheetOptions(e), (t, n) => {
1925
- if (t) {
1926
- let r = this._getSheetRef(t, n);
1927
- return r ? [r.sheet] : e.EmptyArray;
1928
- }
1929
- return this._getSheets(n);
1930
- }), this._ownCalculation && this._calculation.hydrateNames(), this._emitter.notify("onLoad"), o.commit({ forceAmend: this._ownTransactions });
1931
- } catch (e) {
1932
- throw o.rollback(), e;
1933
- }
1934
- this._initializing = !1;
1935
- }
1936
- _initState() {
1937
- let e = this._getSheetRefs();
1938
- for (let t = (e ? e.length : 0) - 1; t >= 0; t--);
1939
- let t = this._options;
1940
- this._isDate1904 = t.runtime?.isDate1904() ?? !1, this._locale = null, this._localeOverrides = null, this._theme = t.theme ?? new ze().getDefaultTheme(), this._styles = t?.styles ?? new De(this._theme), this._ownStyles = !t.styles, this._styles.getTheme() || this._styles.setTheme(this.getTheme()), this._activeSheetOffset = 0, this.setView(new Ft()), this._listenerProtection?.(), this._protection = new Lt(void 0, this._options.readonly ?? !1), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
1941
- n._emitter.notify("onProtectionChange");
1942
- } });
1943
- let n = this;
1944
- this._transactionsRemoveListener = this._transactions.addStateListener(this._id, {
1945
- async onAfterStateChange(e, t, r) {
1946
- if (t && t.activeSheetId !== void 0 && t.view === n.getView() && r.getId() === n._lastTransactionUUID && await n._getSheetRef({ id: t.activeSheetId })?.sheet.select(), t && r.getId() !== n._lastTransactionUUID) {
1947
- let r = n.getView().getActiveSheetId();
1948
- t.view === n.getView() && (r = t.activeSheetId);
1949
- let i = 0;
1950
- try {
1951
- i = n._getOffsetForId(r, e.sheetRefsVisible);
1952
- } catch {}
1953
- n._adjustRemoveSelectionIfRequired(i, r);
1954
- }
1955
- n._lastTransactionUUID = r.getId(), n._notifyAllChange();
1956
- },
1957
- onRestoreOrRevert() {
1958
- n._ownCalculation, n._emitter.notify("onInvalidated");
1959
- }
1960
- });
1961
- let r = this._getState();
1962
- r?.listenersSheets && (r?.listenersSheets.forEach((e) => {
1963
- e();
1964
- }), r?.listenersSheets.clear()), this._updateState({
1965
- sheetRefsAll: [],
1966
- sheetRefsVisibleAndHidden: [],
1967
- sheetRefsVisible: [],
1968
- refsById: /* @__PURE__ */ new Map(),
1969
- sheetsById: /* @__PURE__ */ new Map(),
1970
- refsByLowerCaseName: /* @__PURE__ */ new Map(),
1971
- sheetsByLowerCaseName: /* @__PURE__ */ new Map(),
1972
- refsByInstance: /* @__PURE__ */ new Map(),
1973
- lastId: -1,
1974
- sheetsCreated: /* @__PURE__ */ new Set(),
1975
- listenersSheets: /* @__PURE__ */ new Map()
1976
- });
1977
- }
1978
- getId() {
1979
- return this._id;
1980
- }
1981
- getVersionId() {
1982
- return this._transactions.getVersionId(this._id);
1983
- }
1984
- getName() {
1985
- return this._closed ? null : this._origin.getName();
1986
- }
1987
- getOrigin() {
1988
- return this._origin;
1989
- }
1990
- getView() {
1991
- return this._view;
1992
- }
1993
- setView(e) {
1994
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
1995
- if (!e) throw new f(s("error.sheet.emptyView"));
1996
- this._listenerWorkbookView?.();
1997
- let t = this, n = -1;
1998
- return this._listenerWorkbookView = e.addListeners({ onViewChange: (e) => {
1999
- let r = t._getState(), i = this._view.getActiveSheetId(), a = r.sheetRefsVisible, o = this._getOffsetForId(i, a);
2000
- this._activeSheetOffset = o, t._emitter.notify("onViewChange"), n !== i && (t._emitter.notify("onSelectionChange"), t._emitter.notify("onSelectedSheetChange")), n = i;
2001
- } }), this._view = e, t._emitter.notify("onViewChange"), this;
2002
- }
2003
- getRuntime() {
2004
- return this._runtime;
2005
- }
2006
- setDate1904(e) {
2007
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2008
- return this._isDate1904 = e, this._notifyAllChange(), this;
2009
- }
2010
- getLocale() {
2011
- return this._runtime.getLocale();
2012
- }
2013
- getPinnedLocale() {
2014
- return this._locale;
2015
- }
2016
- setLocale(e) {
2017
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2018
- if (e) try {
2019
- new Intl.Locale(e);
2020
- } catch {
2021
- throw Error(s("error.workbook.invalidLocale", { locale: e }));
2022
- }
2023
- return this._locale === e || (this._locale = e, this._notifyAllChange()), this;
2024
- }
2025
- getLocaleOverrides() {
2026
- return this._localeOverrides;
2027
- }
2028
- setLocaleOverrides(e) {
2029
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2030
- let t = e && Object.keys(e).length > 0 ? e : null;
2031
- return this._localeOverrides = t, this._notifyAllChange(), this;
2032
- }
2033
- getStyles() {
2034
- return this._styles;
2035
- }
2036
- getResources() {
2037
- return this._resources;
2038
- }
2039
- getTransactions() {
2040
- return this._transactions;
2041
- }
2042
- getStrings() {
2043
- return this._strings;
2044
- }
2045
- getExternalBooks() {
2046
- return this._externalBooks;
2047
- }
2048
- getTheme() {
2049
- return this._theme;
2050
- }
2051
- setTheme(e) {
2052
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2053
- if (!e) throw new f(s("error.workbook.notSetValue"));
2054
- let t = this._theme;
2055
- return this._theme = e, this.getStyles().setTheme(e), this._emitter.notify("onThemeChange"), t;
2056
- }
2057
- getSelectedSheetIndex() {
2058
- return this._activeSheetOffset;
2059
- }
2060
- getSelectedSheet() {
2061
- let e = this._getSheetRef(this.getSelectedSheetIndex());
2062
- return e ? e?.sheet : null;
2063
- }
2064
- getSheet(e, n = R.Visibility.Visible) {
2065
- if (e === void 0) return this.getSelectedSheet();
2066
- if (!e) throw Error(s("error.workbook.sheetNameNotProvided"));
2067
- let r = this._getSheetRef(e, n);
2068
- if (!r) throw new t(s("error.workbook.sheetNameNotFound", { sheetName: e }));
2069
- return r.sheet;
2070
- }
2071
- getSheetAt(e, n = R.Visibility.Visible) {
2072
- let r = this._getSheetRef(e, n);
2073
- if (!r) throw new t(function(e) {
2074
- return s("error.workbook.sheetIndexNotFound", { index: e });
2075
- }(e));
2076
- return r.sheet;
2077
- }
2078
- getSheets() {
2079
- return this._sheets;
2080
- }
2081
- addSheet(e) {
2082
- return this.getSheets().add(e);
2083
- }
2084
- _getSheets(e = R.Visibility.Visible) {
2085
- let t = this._getSheetRefs(e), n = [], r = t.length;
2086
- for (let e = 0; e < r; e++) n.push(t[e].sheet);
2087
- return n;
2088
- }
2089
- _getSheetRefs(t = R.Visibility.Visible) {
2090
- let n = this._getState();
2091
- return n ? t === R.Visibility.Visible ? n.sheetRefsVisible : t === R.Visibility.Hidden ? n.sheetRefsVisibleAndHidden : t === R.Visibility.VeryHidden ? n.sheetRefsAll : e.EmptyArray : [];
2092
- }
2093
- _getSheetRef(e, t = R.Visibility.Visible) {
2094
- let n = null;
2095
- return typeof e == "number" ? this._getSheetRefs(t)[e] : (typeof e == "string" ? n = this._getState().refsByLowerCaseName.get(e.toLowerCase()) : e instanceof D ? n = this._getState().refsByInstance.get(e) : e?.id !== void 0 && (n = this._getState().refsById.get(e.id)), n);
2096
- }
2097
- _validateNewSheetName(e, t = !0) {
2098
- if (e == null) return e;
2099
- if (Ut(e), t && this._getState().sheetsByLowerCaseName.has(e.toLowerCase())) throw new f(s("error.workbook.nameTaken"));
2100
- return e.substring(0, 31);
2101
- }
2102
- findValidSheetName(e) {
2103
- e &&= Ut(e, !0);
2104
- try {
2105
- return function(e, t) {
2106
- try {
2107
- if (t(e)) return e;
2108
- } catch {}
2109
- let n, r, i = Vt.exec(e);
2110
- for (i === null ? (n = e + " ", r = 1) : (n = e.substring(0, i.index), r = parseFloat(i[1])); r < 256;) {
2111
- r++;
2112
- let e = "(" + r + ")", i = n.substring(0, 31 - e.length) + e;
2113
- try {
2114
- if (t(i)) return i;
2115
- } catch {}
2116
- }
2117
- throw Error(e + " is not a valid sheet name");
2118
- }(e, (e) => this._validateNewSheetName(e));
2119
- } catch {
2120
- return this._nextSheetName();
2121
- }
2122
- }
2123
- isValidSheetNameCharacter(e) {
2124
- return !Z.test(e);
2125
- }
2126
- _addSheetOptions(e) {
2127
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2128
- if (!this.getProtection().isStructureAllowed()) throw new f(s("error.workbook.protection"));
2129
- let t, n = null;
2130
- t = typeof e == "string" ? { name: e } : typeof e == "number" ? { index: e } : e, t = {
2131
- ...t,
2132
- description: t?.description ?? m("op.addSheet")
2133
- };
2134
- let r = this.beginCommit(t);
2135
- try {
2136
- let e = t?.autoSelect ?? !1;
2137
- n = this._addSheet(!0, t.name, t.index ?? null);
2138
- let i, a, o = this.getView().getActiveSheetId();
2139
- if (!1 !== e) {
2140
- let t = this.getView().getActiveSheetId();
2141
- t = this._getSheetRef(n).id, e && (i = {
2142
- view: this.getView(),
2143
- activeSheetId: o
2144
- }, a = {
2145
- view: this.getView(),
2146
- activeSheetId: t
2147
- });
2148
- }
2149
- if (r.commit({
2150
- description: s("op.addSheetNamed", { name: n.getName() }),
2151
- viewBefore: i,
2152
- viewAfter: a
2153
- }), !1 !== e) {
2154
- let t = typeof e == "boolean" ? void 0 : e;
2155
- n.select(t);
2156
- }
2157
- } catch (e) {
2158
- throw r.rollback(), e;
2159
- }
2160
- return n;
2161
- }
2162
- _nextSheetName(e = null) {
2163
- let t = e ? e.toLowerCase() : null, n = this._getState(), r = n.sheetsByLowerCaseName;
2164
- if (e && r.has(t)) throw new f(function(e) {
2165
- return s("error.workbook.nameDuplicate", { sheetName: e });
2166
- }(e));
2167
- t = (e = this._validateNewSheetName(e)) ? e.toLowerCase() : null;
2168
- let i = n.lastId + 1;
2169
- for (; !e;) {
2170
- let t = this._createSheetName(i), n = t.toLowerCase();
2171
- r.has(n) ? i++ : e = t;
2172
- }
2173
- return this._updateState({ lastId: i }), e;
2174
- }
2175
- _addSheet(e, t = null, n = null) {
2176
- t = this._nextSheetName(t);
2177
- let r = this._getState(), i = this._createSheet(r.lastId, t, R.Visibility.Visible, n, null);
2178
- if (!i) throw new f(s("error.workbook.sheetNameBlank"));
2179
- return e && this._emitter.notify("onSheetsChange"), i;
2180
- }
2181
- _updateSheetRefStates(e) {
2182
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2183
- if (!this._initializing && !this.getProtection().isStructureAllowed()) throw new f(s("error.workbook.protection"));
2184
- let t = e, n = [], r = [], i = t.length;
2185
- for (let e = 0; e < i; e++) t[e].visibility === R.Visibility.Visible ? (n.push(t[e]), r.push(t[e])) : t[e].visibility === R.Visibility.Hidden && r.push(t[e]);
2186
- this._updateState({
2187
- sheetRefsAll: t,
2188
- sheetRefsVisible: n,
2189
- sheetRefsVisibleAndHidden: r
2190
- });
2191
- }
2192
- _addSheetRef(e, t = null) {
2193
- let n = this._getState(), r = n.sheetRefsAll, i = Math.max(0, Math.min(r.length, t ?? r.length)), a = [
2194
- ...r.slice(0, i),
2195
- e,
2196
- ...r.slice(i)
2197
- ];
2198
- this._updateSheetRefStates(a);
2199
- let o = e.sheet, c = e.name.toLowerCase(), l = new Map(n.refsById);
2200
- l.set(e.id, e);
2201
- let u = new Map(n.refsByLowerCaseName);
2202
- u.set(c, e);
2203
- let d = new Map(n.refsByInstance);
2204
- d.set(o, e);
2205
- let f = new Map(n.sheetsById);
2206
- f.set(e.id, o);
2207
- let p = new Map(n.sheetsByLowerCaseName);
2208
- p.set(c, o);
2209
- let m = this, h = n.listenersSheets;
2210
- if (o !== void 0) {
2211
- let t = o.addListeners({
2212
- onBeforeDelete: (e) => {
2213
- m._validateDeleteSheet(e);
2214
- },
2215
- onDelete(e) {
2216
- let t = m._getSheetRef(e, R.Visibility.VeryHidden);
2217
- if (!t) return;
2218
- let n = m._beginCommit({ description: s("op.deleteSheet", { name: t.name }) });
2219
- try {
2220
- let r = m._getState(), i = r.sheetRefsAll, a = m._getOffsetForId(t.id, i), s = [...i];
2221
- s.splice(a, 1), m._updateSheetRefStates(s);
2222
- let c = new Map(r.refsById);
2223
- c.delete(t.id);
2224
- let l = new Map(r.sheetsById);
2225
- l.delete(t.id);
2226
- let u = t.name.toLowerCase(), d = new Map(r.refsByLowerCaseName);
2227
- d.delete(u);
2228
- let f = new Map(r.sheetsByLowerCaseName);
2229
- f.delete(u);
2230
- let p = new Map(r.refsByInstance);
2231
- p.delete(e), r.listenersSheets.get(t.id)();
2232
- let h = new Map(r.listenersSheets);
2233
- h.delete(t.id), m._adjustRemoveSelectionIfRequired(a, t.id), m._adjustSheetNamesIfRequired(), m._sheetOnNameChange.delete(t.id), m._sheetOnVisibilityChange.delete(t.id), m._sheetOnIndexChange.delete(t.id), m._emitter.notify("onSheetsChange");
2234
- let g = new Set(r.sheetsCreated);
2235
- g.has(o) && g.delete(o), m._updateState({
2236
- refsById: c,
2237
- sheetsById: l,
2238
- refsByLowerCaseName: d,
2239
- sheetsByLowerCaseName: f,
2240
- refsByInstance: p,
2241
- sheetsCreated: g,
2242
- listenersSheets: h
2243
- }), n.commit();
2244
- } catch (e) {
2245
- throw n.rollback(), e;
2246
- }
2247
- }
2248
- }), r = o.addListeners({ onSelectionChange: (e) => {
2249
- m.getView().getActiveSheetId() === m._getSheetRef(e)?.id && m._emitter.notify("onSelectionChange", {
2250
- source: m,
2251
- params: e
2252
- });
2253
- } }, { transactional: !1 });
2254
- h = new Map(n.listenersSheets), h.set(e.id, () => {
2255
- t(), r();
2256
- });
2257
- }
2258
- let g = n.lastId;
2259
- g !== -1 && (g = Math.max(g, e.id)), this._updateState({ lastId: g }), this._updateState({
2260
- refsById: l,
2261
- refsByLowerCaseName: u,
2262
- refsByInstance: d,
2263
- sheetsById: f,
2264
- sheetsByLowerCaseName: p,
2265
- listenersSheets: h
2266
- }), this._adjustSheetNamesIfRequired();
2267
- let _ = new Set(this._getState().sheetsCreated);
2268
- return _.add(e.sheet), this._updateState({ sheetsCreated: _ }), e;
2269
- }
2270
- _adjustRemoveSelectionIfRequired(e, t) {
2271
- if (this._view.getActiveSheetId() === t) {
2272
- let t, n = this._getState().sheetRefsVisible;
2273
- t = e < n.length ? n[e].id : n[e - 1].id, this._view.setActiveSheetId(t);
2274
- }
2275
- }
2276
- _adjustSheetNamesIfRequired() {
2277
- let e = this._getState(), t = e.lastId;
2278
- if (t === -1) return;
2279
- let n = this._view.getActiveSheetId();
2280
- n ??= (this._view.setActiveSheetId(t), t);
2281
- let r = e.refsById.get(n);
2282
- r || (this._view.setActiveSheetId(t), r = e.refsById.get(t), n = t), r.visibility === R.Visibility.Visible && (this._activeSheetOffset = this._getOffsetForId(n, e.sheetRefsVisible));
2283
- }
2284
- _validateDeleteSheet(e) {
2285
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2286
- if (!this.getProtection().isStructureAllowed()) throw new f(s("error.workbook.protection"));
2287
- let t = this._getSheetRef(e);
2288
- if (!t) throw new f(function(e) {
2289
- return s("error.workbook.deleteKey", { key: e });
2290
- }(e));
2291
- let n = this._getState().sheetRefsVisible;
2292
- if (n.length === 1 && n[0].id === t.id) throw new f(s("error.workbook.sheetOne"));
2293
- }
2294
- _getOffsetForId(e, t) {
2295
- let n = t.length;
2296
- for (let r = 0; r < n; r++) if (t[r].id === e) return r;
2297
- throw new f(s("error.workbook.noVisibleRefs"));
2298
- }
2299
- find(e) {
2300
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2301
- let t = this._getSheets();
2302
- if (t.length === 1) return t[0].find(e);
2303
- typeof e == "string" && (e = { text: e });
2304
- let n = !e?.reverse, r = e?.disableWrap ?? !1, i = this.getSelectedSheetIndex(), a = i, o = t[a], c = !1;
2305
- e = {
2306
- ...e,
2307
- disableWrap: !0
2308
- };
2309
- let u, d = o.find(e), f = d.next(), p = !1;
2310
- if (e?.from) {
2311
- let t = this._rangesAddressToCoords(e?.from);
2312
- u = {
2313
- colIndex: t[0].colStart,
2314
- rowIndex: t[0].rowStart
2315
- };
2316
- }
2317
- let m = l.createCellComparator(e?.axis, e?.reverse);
2318
- delete (e = { ...e }).from;
2319
- let h = () => {
2320
- if (!p && f.done && (c && a === i ? p = !0 : n ? (a++, a > t.length - 1 && (a = 0, c = !0)) : (a--, a < 0 && (a = t.length - 1, c = !0)), r && c && (p = !0), p || u || !c || a !== i || (p = !0), !p)) {
2321
- o = t[a], d = o.find(e);
2322
- let n = f;
2323
- return f = d.next(), n;
2324
- }
2325
- if (!p && c && a === i && (f.done || !u || !f.done && m(f.value.getCoords(), u) >= 0) && (p = !0), p) {
2326
- let e = f;
2327
- return f = Ve, e;
2328
- }
2329
- let s = f;
2330
- return f = d.next(), s;
2331
- };
2332
- return { next: () => {
2333
- let e = h();
2334
- for (; !p && e.done;) e = h();
2335
- return e;
2336
- } };
2337
- }
2338
- replace(e, t, n) {
2339
- let r = 0, i = null, a = typeof t == "function", o = n?.maxCount ?? 2 ** 53 - 1, c = !n?.maxCount, l = "", u = typeof t == "string" ? Re(t) : null, d = n?.description ?? m("op.replace"), f = this._transactions.beginCommit({ description: d });
2340
- try {
2341
- let d = null, p = null, h = e.next();
2342
- for (; !h.done && r < o;) {
2343
- let o = h.value, s = o.getSheet();
2344
- s !== d && (d = s, p !== null && p.apply(), p = d.getEntireRange().createSparseBuilder({
2345
- axis: n?.axis,
2346
- allowUnorderedWrites: !0
2347
- }));
2348
- let c = a ? t(o) : t;
2349
- c !== void 0 && c !== o && (p.push(o, c), r++, i = o), h = e.next();
2350
- }
2351
- p?.apply(), r === 1 && o === 1 && i && (l = i.getAddress()), r === 0 ? f.rollback() : f.commit({
2352
- description: n?.description ?? (c ? u === null ? m("op.replaceAll") : s("op.replaceAllWith", { value: u }) : l ? u === null ? s("op.replaceAt", { address: l }) : s("op.replaceAtWith", {
2353
- address: l,
2354
- value: u
2355
- }) : u === null ? m("op.replace") : s("op.replaceWith", { value: u })),
2356
- viewAfter: { selection: null }
2357
- });
2358
- } catch (e) {
2359
- throw f.rollback(), e;
2360
- }
2361
- return {
2362
- count: r,
2363
- last: i
2364
- };
2365
- }
2366
- _nextSheetIndex(e, t = this._getSheetRefs()) {
2367
- let n = t.length;
2368
- return n === 1 ? 0 : (e === void 0 && (e = this.getSelectedSheetIndex()), (e = Math.max(0, Math.min(e, n - 1))) >= n - 1 ? 0 : e + 1);
2369
- }
2370
- _prevSheetIndex(e, t = this._getSheetRefs()) {
2371
- let n = t.length;
2372
- return n === 1 ? 0 : (e === void 0 && (e = this.getSelectedSheetIndex()), (e = Math.max(0, Math.min(e, n - 1))) <= 0 ? n - 1 : e - 1);
2373
- }
2374
- getNextSheet(e) {
2375
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2376
- let t = this._getSheetRefs();
2377
- return t[this._nextSheetIndex(e, t)]?.sheet ?? null;
2378
- }
2379
- getPreviousSheet(e) {
2380
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2381
- let t = this._getSheetRefs();
2382
- return t[this._prevSheetIndex(e, t)]?.sheet ?? null;
2383
- }
2384
- async _duplicateSheet(e) {
2385
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2386
- if (!this.getProtection().isStructureAllowed()) throw new f(s("error.workbook.protection"));
2387
- let t = this._getSheetRefs(), n = this.getSelectedSheetIndex(), r = null;
2388
- if (e) {
2389
- if (r = this._getSheetRef(e), !r) throw new f(X(r));
2390
- } else r = t[n];
2391
- if (!r) return null;
2392
- let i = r.sheet, a = this._strings.beginPersist(), o = this.getResources().beginPersist(), c = this.getStyles().beginPersist(), l = null, u = this.beginCommit(s("op.duplicateNamed", { name: i.getName() }));
2393
- try {
2394
- let e = this._getState().refsByInstance.get(i), r = await i.toJSON(), a = t.length + 1, o = this.findValidSheetName(e.name), s = this._createSheet(a, o, e.visibility, n, r);
2395
- this._emitter.notify("onSheetsChange"), l = s, u.commit();
2396
- } catch (e) {
2397
- throw u.rollback(), e;
2398
- } finally {
2399
- c.endPersist(), o.endPersist(), a.endPersist();
2400
- }
2401
- return l;
2402
- }
2403
- _createRange(e, t) {
2404
- let n = e ? { ...e } : null, r = n ? this._getSheetRef(n.scope, R.Visibility.VeryHidden) : null;
2405
- if (!r) {
2406
- let e = this.getSelectedSheet();
2407
- return e ? (delete n?.scope, Q(n, n ? {
2408
- scope: Pe,
2409
- ...e.getEntireRange().getCoords()
2410
- } : null)) : void console.warn(s("error.workbook.noVisibleRefs"));
2411
- }
2412
- let i = r.sheet, a = null;
2413
- return t && (a = { getOptions: t }), new Gt(e, I(i), this, a);
2414
- }
2415
- _createRanges(e, t) {
2416
- let n = this.getSelectedSheet(), r = null;
2417
- return t && (r = { getOptions: t }), new $(e, I(n), this, r);
2418
- }
2419
- getRange(e, n) {
2420
- if (e === void 0) return this.getSelectedRange(n);
2421
- try {
2422
- let t = this._rangesAddressToCoords(e);
2423
- if (t.length !== 1) throw new f(s("error.address.singleRangeOnlyAlt"));
2424
- return this._createRange(t[0], n);
2425
- } catch (n) {
2426
- throw n instanceof t ? new t(n.message) : new f(n.message ?? Ce(e));
2427
- }
2428
- }
2429
- getCell(e) {
2430
- if (e === void 0) return this.getSelectedCell();
2431
- let t = this.getRange(e);
2432
- if (t.size > 1) throw new f(s("error.address.singleCellOnly"));
2433
- return t.getCell();
2434
- }
2435
- getRanges(e, t) {
2436
- let n = this._rangesAddressToCoords(e);
2437
- if (n.length === 0) throw new f(Ce(e));
2438
- return this._createRanges(n, t);
2439
- }
2440
- _createGraphRanges(e, t) {
2441
- let n = [];
2442
- for (let e = 0; e < t.length; e++) {
2443
- let r = t[e], i = (r.sheetName ? this._getSheetRef(r.sheetName, R.Visibility.VeryHidden) : null)?.sheet ?? this.getSelectedSheet();
2444
- i && n.push(new pe(r, I(i), null));
2445
- }
2446
- for (let t = 0; t < e.length; t++) n.push(e[t]);
2447
- return n.length === 0 ? null : new $(n, I(this.getSelectedSheet()), this, null);
2448
- }
2449
- getStats(e) {
2450
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2451
- let t = this._getSheets(R.Visibility.VeryHidden), n = t.length;
2452
- if (n === 1) return t[0].getStats(e);
2453
- let r = Array(n);
2454
- for (let i = 0; i < n; i++) r[i] = t[i].getStats(e);
2455
- return new Tt(r);
2456
- }
2457
- _activeRangeCoords() {
2458
- let e = this.getSelectedSheet(), t = e.getSelection().getRanges().getCoords(), n = e.getName(), r = t.length, i = Array(r);
2459
- for (let e = 0; e < r; e++) {
2460
- let r = t[e];
2461
- i[e] = {
2462
- colStart: r.colStart,
2463
- colEnd: r.colEnd,
2464
- rowStart: r.rowStart,
2465
- rowEnd: r.rowEnd,
2466
- scope: n
2467
- };
2468
- }
2469
- return i;
2470
- }
2471
- getSelectedRange(e) {
2472
- return this.getRange(this._activeRangeCoords()[0], e);
2473
- }
2474
- getSelectedRanges(e) {
2475
- return this.getRanges(this._activeRangeCoords(), e);
2476
- }
2477
- getSelectedCell() {
2478
- return this.getSelectedSheet().getSelectedCell();
2479
- }
2480
- _rangesAddressToCoords(e, t = !0, n = R.Visibility.Hidden) {
2481
- if (!e) throw new f(s("error.address.noAddress"));
2482
- let r = this.getSelectedSheet(), i = { ...r?.getEntireRange().getCoords() }, a = r?.getName();
2483
- if (a && (i.scope = a), typeof e == "string") {
2484
- let t = e.trim().toLowerCase();
2485
- if (t === "r" || t === "c") {
2486
- let n = this.getSelectedCell().getCoords(), r = {};
2487
- t === "r" ? r.rowStart = r.rowEnd = n.rowIndex : r.colStart = r.colEnd = n.colIndex, e = r;
2488
- }
2489
- }
2490
- let o = this, c = de(e, i, le, (e) => {
2491
- if (!t) return null;
2492
- if (typeof e == "string") {
2493
- let t = o.getNames().getByName(e)?.getRanges?.();
2494
- if (t) return t.getCoords();
2495
- }
2496
- throw new f(`Invalid sheet reference '${e}'.`);
2497
- }), l = c.length;
2498
- for (let e = 0; e < l; e++) this._validateCoords(c[e], n);
2499
- return c;
2500
- }
2501
- _validateCoords(e, n = R.Visibility.Visible, r = s("error.sheet.oobRange")) {
2502
- if (e === null) return;
2503
- let i = this.getSheet(e.scope, n).getEntireRange().getCoords();
2504
- if (!l.isRangeWithinRange(e, i)) throw new t(r);
2505
- if (e.rowEnd < e.rowStart || e.colEnd < e.colStart) throw new f(s("error.address.invalidRangeInverted"));
2506
- }
2507
- _updateSheetRef(e, t) {
2508
- let n = this._getState(), r = [...n.sheetRefsAll];
2509
- r[this._getOffsetForId(e.id, n.sheetRefsAll)] = t, this._updateSheetRefStates(r);
2510
- let i = new Map(n.refsById);
2511
- i.set(e.id, t);
2512
- let a = e.name.toLowerCase(), o = t.name.toLowerCase(), s = new Map(n.refsByLowerCaseName);
2513
- s.delete(a), s.set(o, t);
2514
- let c = new Map(n.sheetsByLowerCaseName), l = c.get(a);
2515
- c.delete(a), c.set(o, l);
2516
- let u = new Map(n.refsByInstance);
2517
- return u.set(l, t), this._updateState({
2518
- refsById: i,
2519
- refsByLowerCaseName: s,
2520
- sheetsByLowerCaseName: c,
2521
- refsByInstance: u
2522
- }), t;
2523
- }
2524
- _setSheetName(e, t, n) {
2525
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2526
- if (!this.getProtection().isStructureAllowed()) throw new f(s("error.workbook.protection"));
2527
- let r = this._getSheetRef(e);
2528
- if (!r) throw new f(X(e));
2529
- if (t === r.name) return r.sheet;
2530
- if ((t = this._validateNewSheetName(t)) == null) throw new f(s("error.workbook.sheetNameNotProvided"));
2531
- let i = Object.freeze({
2532
- ...r,
2533
- name: t
2534
- }), a = null, o = this.beginCommit(m("op.renameSheet"));
2535
- try {
2536
- let e = this._updateSheetRef(r, i);
2537
- this._adjustSheetNamesIfRequired(), this._sheetOnNameChange.forEach((e, t) => {
2538
- r.id === t && e();
2539
- }), this._emitter.notify("onSheetsChange"), r.id === this.getView().getActiveSheetId() && this._emitter.notify("onSelectionChange"), a = e.sheet, o.commit(n);
2540
- } catch (e) {
2541
- throw o.rollback(), e;
2542
- }
2543
- return a;
2544
- }
2545
- _setSheetVisibility(e, t = R.Visibility.Visible, n) {
2546
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2547
- if (!this.getProtection().isStructureAllowed()) throw new f(s("error.workbook.protection"));
2548
- let r = this._getSheetRef(e, R.Visibility.VeryHidden);
2549
- if (!r) return null;
2550
- if (t === r.visibility) return;
2551
- let i = null, a = "";
2552
- t === R.Visibility.Visible ? a = m("op.unhideSheet") : t === R.Visibility.Hidden ? a = m("op.hideSheet") : t === R.Visibility.VeryHidden && (a = m("op.veryHideSheet"));
2553
- let o = this.beginCommit(a);
2554
- try {
2555
- let e = this._getState().sheetRefsVisible;
2556
- if (t !== R.Visibility.Visible && e.length === 1 && e[0].id === r.id) throw new f(s("error.workbook.sheetOne"));
2557
- let a = {
2558
- ...r,
2559
- visibility: t
2560
- }, c = -1;
2561
- t !== R.Visibility.Visible && (c = this._getOffsetForId(r.id, e)), i = this._updateSheetRef(r, a).sheet, t !== R.Visibility.Visible && this._adjustRemoveSelectionIfRequired(c, r.id), this._adjustSheetNamesIfRequired(), o.commit(n);
2562
- } catch (e) {
2563
- throw o.rollback(), e;
2564
- }
2565
- return this._sheetOnVisibilityChange.forEach((e, t) => {
2566
- r.id === t && e();
2567
- }), this._emitter.notify("onSheetsChange"), i;
2568
- }
2569
- _moveSheet(e, t, n) {
2570
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2571
- if (!this.getProtection().isStructureAllowed()) throw new f(s("error.workbook.protection"));
2572
- let r = null, i = this.beginCommit(s("op.moveSheetNamed", { name: e.name }));
2573
- try {
2574
- let a = this._getState(), o = a.sheetRefsVisible;
2575
- if (t < 0 || t > o.length - 1) throw new f(`Invalid to index: ${t}`);
2576
- let s = {
2577
- view: this.getView(),
2578
- activeSheetId: this.getView().getActiveSheetId()
2579
- }, c = a.sheetRefsAll, l = this._getOffsetForId(e.id, c), u = this._getOffsetForId(o[t].id, c);
2580
- if (l === u) return;
2581
- let d = c[l], p = [...c];
2582
- p.splice(l, 1), p.splice(u, 0, d), this._updateSheetRefStates(p), this._adjustSheetNamesIfRequired(), this._sheetOnIndexChange.forEach((e, t) => {
2583
- t >= l && t <= u && e();
2584
- }), this._emitter.notify("onSheetsChange"), r = d.sheet, i.commit({
2585
- ...n,
2586
- viewBefore: s,
2587
- viewAfter: {
2588
- view: this.getView(),
2589
- activeSheetId: this.getView().getActiveSheetId()
2590
- }
2591
- });
2592
- } catch (e) {
2593
- throw i.rollback(), e;
2594
- }
2595
- return r;
2596
- }
2597
- _setSelectedSheet(e) {
2598
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2599
- let t = this._getSheetRef(e);
2600
- if (!t) throw new f(X(e));
2601
- let n = null;
2602
- return t.visibility !== R.Visibility.Visible && this._setSheetVisibility(t, R.Visibility.Visible), this._view.setActiveSheetId(t.id), n = t.sheet, n;
2603
- }
2604
- getProtection() {
2605
- return this._protection;
2606
- }
2607
- getNames() {
2608
- return this._names;
2609
- }
2610
- getCalculation() {
2611
- return this._calculation;
2612
- }
2613
- createFormula(e, t) {
2614
- return this.getCalculation().createFormula(e, t);
2615
- }
2616
- evaluate(e, t) {
2617
- return this.getCalculation().evaluate(e, t);
2618
- }
2619
- whenCalculationReady() {
2620
- return this.getCalculation().ready();
2621
- }
2622
- getScripts() {
2623
- return this._scripts ||= this._createScripts(), this._scripts;
2624
- }
2625
- _notifyAllChange() {
2626
- this._emitter.notify("onSheetsChange"), this._emitter.notify("onSelectedSheetChange"), this._emitter.notify("onViewChange");
2627
- }
2628
- addListeners(e, t) {
2629
- return this._emitter.addListeners(e, t);
2630
- }
2631
- _sheetToWBEvent(e) {
2632
- let t = this;
2633
- return (n) => {
2634
- let r = () => {
2635
- let e = n.getSource();
2636
- if (e.isICellRanges) {
2637
- let n = [...e.getCoords()], r = n.length;
2638
- for (let t = 0; t < r; t++) {
2639
- let r = n[t];
2640
- !r.scope && e.getSheet().getName() && (n[t] = {
2641
- ...r,
2642
- scope: e.getSheet().getName()
2643
- });
2644
- }
2645
- return t.getRanges(n);
2646
- }
2647
- if (e.isICellRange) {
2648
- let n = e.getCoords(), r = e.getSheet().getName();
2649
- return t.getRange({
2650
- ...n,
2651
- scope: r
2652
- });
2653
- }
2654
- };
2655
- e({
2656
- getSource: r,
2657
- trigger: n.trigger,
2658
- getFrom: () => t.getRanges(n.getFrom()),
2659
- getTo: () => t.getRange(n.getTo()),
2660
- isDataChange: n.isDataChange,
2661
- getTransactionId: n.getTransactionId,
2662
- isUndo: n.isUndo,
2663
- toString: () => `WorkbookRangeEvent: ('${n.trigger}', ${r().toString()})`,
2664
- timeStamp: Date.now()
2665
- });
2666
- };
2667
- }
2668
- _fromJSON(e) {
2669
- if (this._emitter.notify("onBeforeLoad", { params: e }), this._initState(), !e.sheets || e.sheets.length === 0) throw new f(s("error.workbook.sheetOne"));
2670
- e.theme && (this._theme = new re(e.theme), this._styles.setTheme(this._theme));
2671
- let t = this._strings.beginPersist(), n = this._resources.beginPersist(), r = this._styles.beginPersist();
2672
- try {
2673
- t.fromJSON(e.strings), n.fromJSON(e.resources), r.fromJSON(e.styles), e.date1904 && (this._isDate1904 = !0), e.locale && (this._locale = e.locale), e.localeOverrides && (this._localeOverrides = e.localeOverrides), e.view ||= {};
2674
- let i = e.sheets, a = i.length, o = e.view.activeSheetId ?? null;
2675
- o !== null && (o = Math.min(Math.max(0, o), a - 1));
2676
- let s = null, c = null, l = -1;
2677
- for (let e = 0; e < a; e++) {
2678
- let t = i[e], n = t.visibility || R.Visibility.Visible, r = e;
2679
- c = r, n === R.Visibility.Visible ? (l++, s === null && (s = r)) : o !== null && o === r && (o = null), this._createSheet(r, t.name, n, l, t.sheet);
2680
- }
2681
- this._updateState({ lastId: c }), e.view.activeSheetId = o ?? s, this.setView(new Ft({ json: e.view })), this._adjustSheetNamesIfRequired(), this._listenerProtection?.();
2682
- let u = this;
2683
- this._protection = new Lt(e?.protection, this._options?.readonly), this._listenerProtection = this._protection.addListeners({ onChange: (e) => {
2684
- u._emitter.notify("onProtectionChange", { source: e });
2685
- } }), e.scripts && (this._scripts = this._createScripts(e.scripts)), this._emitter.notify("onLoad");
2686
- } finally {
2687
- r.endPersist(), n.endPersist(), t.endPersist();
2688
- }
2689
- }
2690
- _createScripts(e) {
2691
- let t = this;
2692
- return new jt({
2693
- transactions: this._transactions,
2694
- json: e,
2695
- workbook: t,
2696
- getBuiltInFunctions: () => t._calculation?.getFunctions(),
2697
- onAdd: (e, n) => {
2698
- let r = t._calculation;
2699
- r.getStatus() !== ie.Status.Off && r.start().then(async () => {
2700
- let e = n.getFunctions().getItems({ type: "formula" }), t = e.length;
2701
- for (let n = 0; n < t; n++) {
2702
- let t = e[n];
2703
- try {
2704
- await this._calculation.getFunctions().add(t);
2705
- } catch (e) {
2706
- o.error(e?.message ?? String(e), e);
2707
- }
2708
- }
2709
- }).catch(() => {});
2710
- },
2711
- onRemove: (e, t) => {}
2712
- });
2713
- }
2714
- async toJSON(e) {
2715
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2716
- await Promise.resolve(this._starting), await this._emitter.notify("onBeforeSave", { async: !0 });
2717
- let t = { sheets: [] }, n = e?.ignoreStyles ?? !1;
2718
- if (!n) {
2719
- let e = this._theme.toJSON();
2720
- (e ? Object.keys(e).length : 0) > 0 && (t.theme = e);
2721
- }
2722
- if (this._scripts) {
2723
- let e = this._scripts.toJSON();
2724
- e && Object.keys(e).length > 0 && (t.scripts = e);
2725
- }
2726
- this._isDate1904 && (t.date1904 = !0), this._locale && (t.locale = this._locale), this._localeOverrides && (t.localeOverrides = this._localeOverrides);
2727
- let r = e?.ignoreResources ?? !1, i = this._strings.beginPersist(), a = r ? null : this._resources.beginPersist(), o = this._styles.beginPersist();
2728
- try {
2729
- let s = this._getSheetRef(this.getSelectedSheetIndex()).id, c = s, l = null, u = this._getState(), d = u.sheetRefsAll, f = u.sheetsById, p = d.length;
2730
- for (let n = 0; n < p; n++) {
2731
- let r = d[n], i = n + 1, a = await f.get(r.id).toJSON(e), o = {
2732
- name: r.name,
2733
- sheet: a
2734
- };
2735
- r.visibility === R.Visibility.Visible ? l === null && (l = i) : o.visibility = r.visibility, r.id === s && (c = i), t.sheets.push(o);
2736
- }
2737
- if (!n) {
2738
- let e = o.toJSON();
2739
- e && Object.keys(e).length > 0 && (t.styles = e);
2740
- }
2741
- let m = this.getProtection().toJSON();
2742
- m && (t.protection = m);
2743
- let h = this._calculation.toJSON();
2744
- Object.keys(h).length > 0 && (t.calc = h);
2745
- let g = await i.toJSONAsync();
2746
- g && g.length > 0 && (t.strings = g);
2747
- let _ = this._externalBooks.toJSON();
2748
- if (_ && (t.externalBooks = _), !r) {
2749
- let e = await a.toJSONAsync();
2750
- e && e.length > 0 && (t.resources = e);
2751
- }
2752
- let v = this._calculation.getNamedFormulas().toJSON();
2753
- v && v.length > 0 && (t.names = v);
2754
- let y = this._view.toJSON();
2755
- y && (c === l ? delete y.activeSheetId : y.activeSheetId = c, Object.keys(y).length > 0 && (t.view = y));
2756
- } finally {
2757
- o.endPersist(), r || a.endPersist(), i.endPersist();
2758
- }
2759
- return this._emitter.notify("onSave", { params: t }), t;
2760
- }
2761
- isClosed() {
2762
- return this._closed;
2763
- }
2764
- close() {
2765
- if (this._closed) return;
2766
- this._emitter.notify("onClose");
2767
- let e = this._getState();
2768
- e.listenersSheets.forEach((e) => {
2769
- e();
2770
- }), e.listenersSheets.clear();
2771
- let t = e.sheetRefsAll;
2772
- for (let e = t.length - 1; e >= 0; e--) try {
2773
- t[e].sheet.close();
2774
- } catch (e) {
2775
- console.warn("error on close", e);
2776
- }
2777
- this._ownResources, this._ownNames && this._names.close(), this._ownCalculation && this._calculation.close(), this._ownStyles, this._transactionsRemoveListener?.(), this._listenerLanguage?.(), this._listenerOrigin?.(), this._closed = !0;
2778
- }
2779
- beginCommit(e) {
2780
- if (this._closed) throw Error(s("error.workbook.modelClosed"));
2781
- return this._beginCommit(typeof e == "string" ? { description: e } : e);
2782
- }
2783
- doBatch(e, t) {
2784
- let n = this;
2785
- return t = typeof t == "string" ? { description: t } : {
2786
- description: m("op.updateWorkbook"),
2787
- ...t
2788
- }, this._transactions.doBatch(e, t, (e, t) => {
2789
- e.getDepth() === 0 && (n._lastTransactionUUID = e.getId());
2790
- });
2791
- }
2792
- _beginCommit(e) {
2793
- let t = this;
2794
- return this._transactions.beginCommit(typeof e == "string" ? { description: e } : e, (e) => {
2795
- e.getDepth() === 0 && (t._lastTransactionUUID = e.getId());
2796
- });
2797
- }
2798
- _getState() {
2799
- return this._transactions.getState(this._id);
2800
- }
2801
- _updateState(e, t = m("op.updateWorkbook"), n) {
2802
- if (!e) return;
2803
- let r = this._beginCommit(t);
2804
- try {
2805
- r.updateState(this._id, e), r.commit(n);
2806
- } catch (e) {
2807
- throw r.rollback(), e;
2808
- }
2809
- }
2810
- get options() {
2811
- return this._options;
2812
- }
2813
- get [Symbol.toStringTag]() {
2814
- return "[Workbook]";
2815
- }
2816
- toString() {
2817
- return `[${this.getName() ?? "(untitled)"}]`;
2818
- }
2819
- get isIWorkbook() {
2820
- return !0;
2821
- }
2822
- }, qt = { address: null }, Jt = class {
2823
- constructor() {
2824
- this._readFormats = [], this._writeFormats = [], this._encryptions = [];
2825
- }
2826
- async registerReadFormat(e) {
2827
- this._readFormats = await this._registerFormatType(e, this._readFormats);
2828
- }
2829
- async registerWriteFormat(e) {
2830
- this._writeFormats = await this._registerFormatType(e, this._writeFormats);
2831
- }
2832
- async registerEncryption(e) {
2833
- if (!e) throw Error("encryption must be provided.");
2834
- if (!e.key) throw Error("encryption.key must be provided.");
2835
- let t = e.key.toLowerCase(), n = this._encryptions.findIndex((e) => e.key.toLowerCase() === t);
2836
- if (n !== -1) {
2837
- let t = [...this._encryptions];
2838
- t[n] = e, this._encryptions = Object.freeze(t);
2839
- return;
2840
- }
2841
- this._encryptions = Object.freeze([...this._encryptions, e]);
2842
- }
2843
- async getEncryption(e) {
2844
- return this.peekEncryption(e);
2845
- }
2846
- peekEncryption(e) {
2847
- if (!e) return this._encryptions[0] ?? null;
2848
- let t = e.toLowerCase();
2849
- return this._encryptions.find((e) => e.key.toLowerCase() === t) ?? null;
2850
- }
2851
- async detectEncryption(e) {
2852
- for (let t of this._encryptions) if (await t.detect(e)) return t;
2853
- return null;
2854
- }
2855
- async getReadFormats(e) {
2856
- return e ? this._filterFormats(e, this._readFormats) : [...this._readFormats];
2857
- }
2858
- async getWriteFormats(e) {
2859
- return this._writeFormats ? e ? this._filterFormats(e, this._writeFormats) : [...this._writeFormats] : [];
2860
- }
2861
- async _registerFormatType(e, t) {
2862
- return this._registerFormatTypeSync(e, t);
2863
- }
2864
- _registerFormatTypeSync(e, t) {
2865
- if (!e) throw Error("format must be provided.");
2866
- if (!e.key) throw Error("format.key must be provided.");
2867
- let n = e.key.toLowerCase(), r = t.findIndex((e) => e.key.toLowerCase() === n);
2868
- if (r !== -1) {
2869
- let n = [...t];
2870
- return n[r] = e, Object.freeze(n);
2871
- }
2872
- return Object.freeze([...t, e]);
2873
- }
2874
- _filterFormats(e, t, n) {
2875
- if (!e || Object.keys(e).length === 0) {
2876
- if (!n) return [...t];
2877
- e = { ext: n };
2878
- }
2879
- let r = e.search?.toLocaleLowerCase();
2880
- return t.filter((t) => {
2881
- if (r) {
2882
- let e = t.key.toLocaleLowerCase().includes(r), n = !!t.exts && t.exts.some((e) => e.toLocaleLowerCase().includes(r)), i = !!t.mimeType && t.mimeType.toLocaleLowerCase().includes(r), a = !!t.tags && t.tags.some((e) => e.toLocaleLowerCase().includes(r)), o = !!t.description && t.description.toLocaleLowerCase().includes(r);
2883
- if (!(e || n || i || a || o)) return !1;
2884
- }
2885
- let i = e.ext || n;
2886
- if (i) {
2887
- let e = i.toLocaleLowerCase();
2888
- if (!t.exts.some((t) => t.toLocaleLowerCase() === e)) return !1;
2889
- }
2890
- if (e.mimeType && t.mimeType !== e.mimeType || e.key && t.key.toLocaleLowerCase() !== e.key.toLocaleLowerCase()) return !1;
2891
- if (e.tags) {
2892
- let n = t.tags || [];
2893
- if (!(typeof e.tags == "string" ? [e.tags] : e.tags).every((e) => n.includes(e))) return !1;
2894
- }
2895
- return !0;
2896
- });
2897
- }
2898
- }, Yt = (e) => !!e && typeof e == "object" && typeof e.getPath == "function" && typeof e.canWrite == "function", Xt = new class {
2899
- constructor() {
2900
- this._setInstalled = /* @__PURE__ */ new WeakSet(), this._backingStore = null, this._emitter = new A(this), this._registry = new Jt(), this._defaultStore = new Ye(() => this.getWriteFormats(), () => this.getReadFormats());
2901
- }
2902
- getBackingStore() {
2903
- return this._backingStore ?? this._defaultStore;
2904
- }
2905
- setBackingStore(e) {
2906
- this._backingStore = e ?? null;
2907
- }
2908
- canWrite() {
2909
- return typeof this.getBackingStore().write == "function";
2910
- }
2911
- canRead() {
2912
- return typeof this.getBackingStore().read == "function";
2913
- }
2914
- async install(e) {
2915
- this._setInstalled.has(e) || (await e.register(this._registry), this._setInstalled.add(e));
2916
- }
2917
- addListeners(e, t) {
2918
- return this._emitter.addListeners(e, t);
2919
- }
2920
- addCommitListener(e) {
2921
- return this._emitter.addListeners({ onWrite: (t, n) => {
2922
- n.save && e.onCommit?.({
2923
- store: n.workbook.getTransactions(),
2924
- commitId: n.commitId
2925
- });
2926
- } });
2927
- }
2928
- async getReadFormats(e) {
2929
- return this._registry.getReadFormats(e);
2930
- }
2931
- async getWriteFormats(e) {
2932
- return this._registry.getWriteFormats(e);
2933
- }
2934
- getOrigin(e) {
2935
- return new z(e);
2936
- }
2937
- async read(e) {
2938
- let t = null;
2939
- if (typeof e == "string") e = { source: e };
2940
- else if (Yt(e)) {
2941
- let n = e.getPath();
2942
- if (!n) throw Error("Cannot read from an unbound origin (no path).");
2943
- t = e, e = { source: n };
2944
- }
2945
- let n = e ?? {}, { source: r = null, ...i } = n, a = this.getBackingStore();
2946
- return (a.read ? a : this._defaultStore).read({
2947
- source: r,
2948
- options: i,
2949
- decode: (e, r) => this._decodeBuffer(e, r, n, t)
2950
- });
2951
- }
2952
- async _decodeBuffer(e, t = {}, n, r = null) {
2953
- let i = t.format, a = t.ext;
2954
- if (!i && !a) throw Error("Either format or file extension must be provided to determine read type.");
2955
- let o = (await this._registry.getReadFormats({
2956
- search: i,
2957
- ext: a
2958
- }))[0];
2959
- if (!o) throw new f(s("error.io.readFormatUnavailable", { format: i ?? a }));
2960
- let c = n?.typedCreateWorkbookOptions, l = c ? Object.keys(c).find((e) => e.toLowerCase() === o.key.toLowerCase()) : void 0, u = {
2961
- ...n,
2962
- ...l === void 0 ? void 0 : c[l]
2963
- };
2964
- delete u.typedCreateWorkbookOptions, delete u.source;
2965
- let d = r ?? new z(t.absolutePath ?? null, {
2966
- name: t.name ?? null,
2967
- format: o.key,
2968
- size: t.size ?? null,
2969
- canWrite: t.canWrite ?? !1
2970
- });
2971
- r instanceof z && r.update({
2972
- format: o.key,
2973
- size: t.size ?? null
2974
- }), u.createWorkbookOptions = {
2975
- ...u.createWorkbookOptions || {},
2976
- origin: d
2977
- }, u.readonly !== void 0 && (u.createWorkbookOptions = {
2978
- readonly: u.readonly,
2979
- ...u.createWorkbookOptions
2980
- }, delete u.readonly), u.calcOnly && (u.createWorkbookOptions = {
2981
- disableLoadAutoFit: !0,
2982
- ...u.createWorkbookOptions
2983
- });
2984
- let p = await this._decrypt(e, d, u);
2985
- if (p === null) return null;
2986
- e = p.bytes;
2987
- let m = u?.progress?.onStart?.bind(u.progress);
2988
- m && await Promise.resolve(m(d, t.size));
2989
- try {
2990
- let t = await this._readArrayBuffer(e, o, u);
2991
- return p.password !== null && d.setPassword(p.password), u?.progress?.onComplete?.(d), this._emitter.notify("onRead", {
2992
- params: {
2993
- workbook: t,
2994
- origin: d
2995
- },
2996
- transactional: !1
2997
- }), t;
2998
- } catch (e) {
2999
- throw u?.progress?.onError?.(e), u?.progress?.onComplete?.(null), e;
3000
- }
3001
- }
3002
- async _decrypt(e, t, n) {
3003
- let r = await this._registry.detectEncryption(e);
3004
- if (t instanceof z && t.update({ encryption: r ? r.key : null }), !r) return {
3005
- bytes: e,
3006
- password: null
3007
- };
3008
- let o = null, c = async (t) => {
3009
- try {
3010
- return o = await r.decode(e, t), !0;
3011
- } catch (e) {
3012
- if (!(e instanceof i)) throw e;
3013
- return !1;
3014
- }
3015
- };
3016
- if (n?.password && await c(n.password)) return {
3017
- bytes: o,
3018
- password: n.password
3019
- };
3020
- if (!n?.onPassword) {
3021
- let e = t.getName();
3022
- throw new a(e ? s("error.io.passwordRequired", { name: e }) : s("error.io.passwordRequiredUnnamed"));
3023
- }
3024
- let l = await Promise.resolve(n.onPassword({
3025
- origin: t,
3026
- encryption: r.key,
3027
- validate: c
3028
- }));
3029
- if (l == null) return null;
3030
- if (o !== null || await c(l)) return {
3031
- bytes: o,
3032
- password: l
3033
- };
3034
- throw new i(s("error.io.passwordIncorrect"));
3035
- }
3036
- async writeArrayBuffer(e, t) {
3037
- if (!t?.format) throw Error("A format must be specified to write to an ArrayBuffer (e.g. { format: 'xlsx' }).");
3038
- let n = (await this._registry.getWriteFormats({ search: t.format }))[0];
3039
- if (!n) throw new f(s("error.io.writeFormatUnavailable", { format: t.format }));
3040
- return this._writeArrayBuffer(e, n, t);
3041
- }
3042
- async write(e, t, n) {
3043
- if (!e) throw Error("Workbook must be provided.");
3044
- if (!e.isIWorkbook) throw Error("Invalid workbook model provided. Must be an instance of IWorkbook.");
3045
- let r = n, i = null;
3046
- typeof t == "string" ? i = this.getOrigin(t) : Yt(t) ? i = t : t && (r = t);
3047
- let o, c = !i, l = i ?? e.getOrigin(), u = l.getFormat();
3048
- if ((r?.format || u) && (o = (await this._registry.getWriteFormats({ search: r?.format ?? u ?? void 0 }))[0]), o || l.getPath() && l.canWrite() && l.getExtension() || (o = (await this._registry.getWriteFormats({ ext: "sxl" }))[0] ?? (await this._registry.getWriteFormats())[0]), !o) throw new f(s("error.io.writeFormatUnresolved"));
3049
- if (i && typeof t == "string") {
3050
- let e = i.getPath();
3051
- e && !E(e) && i.update?.({ path: `${e}.${o.exts[0]}` });
3052
- }
3053
- let d = l.getEncryption(), p = e.getOrigin?.(), m = (l instanceof z ? l.getPassword() : null) ?? (p instanceof z ? p.getPassword() : null), h = l.isEncrypted() || (p?.isEncrypted() ?? !1), g = r?.password === void 0 ? m ?? (h ? void 0 : null) : r.password, _ = null;
3054
- if (g === void 0) {
3055
- if (h) {
3056
- let e = l.getName();
3057
- throw new a(e ? s("error.io.passwordRequiredSave", { name: e }) : s("error.io.passwordRequiredSaveUnnamed"));
3058
- }
3059
- } else if (g !== null && (_ = await this._registry.getEncryption(d), !_)) throw new f(s("error.io.encryptionUnavailable"));
3060
- let v = `${l.getName() ?? s("workbook.defaultName")}.${o.exts[0]}`, y = r?.progress, b = !1, x = this, S = null, C = {
3061
- workbook: e,
3062
- format: o,
3063
- origin: l,
3064
- suggestedName: v,
3065
- prompt: r?.prompt,
3066
- async encode(t) {
3067
- await (async () => {
3068
- b || (b = !0, y?.onStart && await Promise.resolve(y.onStart(l)));
3069
- })(), S = e.getTransactions?.()?.getCurrentCommit() ?? S;
3070
- let n = t ? (await x._registry.getWriteFormats({ search: t }))[0] ?? o : o, i = await x._writeArrayBuffer(e, n, r);
3071
- return _ ? _.encode(i, g) : i;
3072
- }
3073
- }, w = null;
3074
- try {
3075
- let t = this.getBackingStore();
3076
- if (!t.write) throw Error("The active backing store is read-only (no write implementation).");
3077
- if (w = await t.write(C), w) {
3078
- g !== void 0 && w instanceof z && (w.setPassword(g), w.update({ encryption: _ ? _.key : null }));
3079
- let t = S ?? e.getTransactions?.()?.getCurrentCommit() ?? null;
3080
- this._emitter.notify("onWrite", {
3081
- params: {
3082
- workbook: e,
3083
- origin: w,
3084
- commitId: t?.getId() ?? null,
3085
- save: c
3086
- },
3087
- transactional: !1
3088
- });
3089
- }
3090
- y?.onComplete && await Promise.resolve(y.onComplete(w));
3091
- } catch (e) {
3092
- let t = e instanceof Error ? e : Error(String(e));
3093
- throw y?.onError && await Promise.resolve(y.onError(t)), y?.onComplete && await Promise.resolve(y.onComplete(null)), t instanceof f ? t : Error(s("error.io.writeFailed", { reason: t.message }), { cause: e });
3094
- }
3095
- return w;
3096
- }
3097
- async writeAs(e, t, n) {
3098
- if (!t) throw Error("A target must be provided for writeAs (use write(workbook) for a plain save).");
3099
- let r = e?.getOrigin?.();
3100
- if (!(r instanceof z)) return this.write(e, t, n);
3101
- let i = typeof t == "string" ? t : t.getPath(), a = i && E(i)?.toLowerCase() || null, o = a ? (await this._registry.getWriteFormats({ search: a }))[0]?.key ?? a : null, s = {
3102
- path: r.getPath(),
3103
- name: r.getName(),
3104
- format: r.getFormat(),
3105
- canWrite: r.canWrite()
3106
- };
3107
- r.update({
3108
- path: i,
3109
- name: typeof t == "string" ? null : t.getName(),
3110
- format: o,
3111
- canWrite: i != null
3112
- });
3113
- let c = null;
3114
- try {
3115
- c = await this.write(e, void 0, n);
3116
- } finally {
3117
- c || r.update(s);
3118
- }
3119
- return c;
3120
- }
3121
- _stripExtension(e) {
3122
- let t = E(e);
3123
- return t ? e.slice(0, e.length - t.length - 1) : e;
3124
- }
3125
- _baseName(e) {
3126
- if (!e) return null;
3127
- let t = e.split(/[?#]/)[0], n = t.split(/[/\\]/).pop() ?? t;
3128
- return this._stripExtension(n) || null;
3129
- }
3130
- async _writeArrayBuffer(e, t, n) {
3131
- if (!t) throw Error("A write format must be provided.");
3132
- let r = t.handler;
3133
- if (!r) throw Error(`Unable to resolve a write handler for '${t.key}'.`);
3134
- return r(e, {
3135
- ...n,
3136
- format: t.key
3137
- });
3138
- }
3139
- async _readArrayBuffer(e, t, n) {
3140
- if (!e) throw Error("ArrayBuffer must be specified.");
3141
- if (!t) throw Error("format must be specified.");
3142
- if (e.byteLength === 0) return new Kt(n?.createWorkbookOptions);
3143
- let r, i = t.handler;
3144
- if (!i) throw Error(`Unable to resolve a read handler for '${t.key}'.`);
3145
- try {
3146
- r = await i(e, n);
3147
- } catch (e) {
3148
- throw e instanceof f ? e : new f(s("error.io.readFailed", {
3149
- format: t.description ?? t.key,
3150
- reason: e?.message ?? String(e)
3151
- }), { cause: e });
3152
- }
3153
- return r;
3154
- }
3155
- }();
3156
- [
3157
- ".woff2",
3158
- ".woff",
3159
- ".ttf",
3160
- ".otf",
3161
- ".ttc"
3162
- ].map((e) => ({
3163
- suffix: e,
3164
- place: (e, t) => t ? `${t}/${e}` : e
3165
- })), Rt ||= {}, zt ||= {};
3166
- var Zt = h({ nowWithPrecision: () => Qt });
3167
- function Qt(e = 6e4) {
3168
- return new Date(Math.floor(Date.now() / e) * e);
3169
- }
3170
- Wt ||= {};
3171
- var $t = class extends Oe {
3172
- constructor(e) {
3173
- super(e);
3174
- }
3175
- _initializeOptions(e) {
3176
- return e = {
3177
- ...e,
3178
- coords: {
3179
- colStart: 0,
3180
- rowStart: 0,
3181
- colEnd: (e?.size?.width ?? 5) - 1,
3182
- rowEnd: (e?.size?.height ?? 5) - 1
3183
- },
3184
- getRanges: (e) => null
3185
- }, super._initializeOptions(e);
3186
- }
3187
- };
3188
- export { Ke as _, bt as a, ot as c, lt as d, Pt as f, St as g, et as h, G as i, qe as l, Kt as m, W as n, it as o, Nt as p, $t as r, Xt as s, Zt as t, z as u };