@rowsncolumns/toolkit 24.4.1

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 (456) hide show
  1. package/LICENSE.md +100 -0
  2. package/Readme.md +27 -0
  3. package/dist/cjs/autofilter-condition.d.ts +43 -0
  4. package/dist/cjs/autofilter-condition.d.ts.map +1 -0
  5. package/dist/cjs/autofilter-condition.js +155 -0
  6. package/dist/cjs/csv-export.d.ts +49 -0
  7. package/dist/cjs/csv-export.d.ts.map +1 -0
  8. package/dist/cjs/csv-export.js +142 -0
  9. package/dist/cjs/csv-import-worker.d.ts +16 -0
  10. package/dist/cjs/csv-import-worker.d.ts.map +1 -0
  11. package/dist/cjs/csv-import-worker.js +60 -0
  12. package/dist/cjs/csv-import.d.ts +38 -0
  13. package/dist/cjs/csv-import.d.ts.map +1 -0
  14. package/dist/cjs/csv-import.js +166 -0
  15. package/dist/cjs/csv-parser/helpers.d.ts +14 -0
  16. package/dist/cjs/csv-parser/helpers.d.ts.map +1 -0
  17. package/dist/cjs/csv-parser/helpers.js +145 -0
  18. package/dist/cjs/csv-parser/types.d.ts +66 -0
  19. package/dist/cjs/csv-parser/types.d.ts.map +1 -0
  20. package/dist/cjs/csv-parser/types.js +14 -0
  21. package/dist/cjs/csv-parser/worker.d.ts +2 -0
  22. package/dist/cjs/csv-parser/worker.d.ts.map +1 -0
  23. package/dist/cjs/csv-parser/worker.js +200 -0
  24. package/dist/cjs/excel-export.d.ts +11 -0
  25. package/dist/cjs/excel-export.d.ts.map +1 -0
  26. package/dist/cjs/excel-export.js +22 -0
  27. package/dist/cjs/excel-import-session.d.ts +51 -0
  28. package/dist/cjs/excel-import-session.d.ts.map +1 -0
  29. package/dist/cjs/excel-import-session.js +307 -0
  30. package/dist/cjs/excel-import-worker.d.ts +7 -0
  31. package/dist/cjs/excel-import-worker.d.ts.map +1 -0
  32. package/dist/cjs/excel-import-worker.js +119 -0
  33. package/dist/cjs/excel-parser/builtin-numfmts.d.ts +24 -0
  34. package/dist/cjs/excel-parser/builtin-numfmts.d.ts.map +1 -0
  35. package/dist/cjs/excel-parser/builtin-numfmts.js +63 -0
  36. package/dist/cjs/excel-parser/cfb-decryptor.d.ts +53 -0
  37. package/dist/cjs/excel-parser/cfb-decryptor.d.ts.map +1 -0
  38. package/dist/cjs/excel-parser/cfb-decryptor.js +553 -0
  39. package/dist/cjs/excel-parser/cfb-encryptor.d.ts +23 -0
  40. package/dist/cjs/excel-parser/cfb-encryptor.d.ts.map +1 -0
  41. package/dist/cjs/excel-parser/cfb-encryptor.js +200 -0
  42. package/dist/cjs/excel-parser/dv-cell-stamp.d.ts +29 -0
  43. package/dist/cjs/excel-parser/dv-cell-stamp.d.ts.map +1 -0
  44. package/dist/cjs/excel-parser/dv-cell-stamp.js +239 -0
  45. package/dist/cjs/excel-parser/helpers.d.ts +28 -0
  46. package/dist/cjs/excel-parser/helpers.d.ts.map +1 -0
  47. package/dist/cjs/excel-parser/helpers.js +188 -0
  48. package/dist/cjs/excel-parser/interface.d.ts +179 -0
  49. package/dist/cjs/excel-parser/interface.d.ts.map +1 -0
  50. package/dist/cjs/excel-parser/interface.js +1 -0
  51. package/dist/cjs/excel-parser/plugins/base/index.d.ts +31 -0
  52. package/dist/cjs/excel-parser/plugins/base/index.d.ts.map +1 -0
  53. package/dist/cjs/excel-parser/plugins/base/index.js +101 -0
  54. package/dist/cjs/excel-parser/plugins/ods/conditional-formatting.d.ts +16 -0
  55. package/dist/cjs/excel-parser/plugins/ods/conditional-formatting.d.ts.map +1 -0
  56. package/dist/cjs/excel-parser/plugins/ods/conditional-formatting.js +488 -0
  57. package/dist/cjs/excel-parser/plugins/ods/data-validations.d.ts +15 -0
  58. package/dist/cjs/excel-parser/plugins/ods/data-validations.d.ts.map +1 -0
  59. package/dist/cjs/excel-parser/plugins/ods/data-validations.js +353 -0
  60. package/dist/cjs/excel-parser/plugins/ods/formula.d.ts +8 -0
  61. package/dist/cjs/excel-parser/plugins/ods/formula.d.ts.map +1 -0
  62. package/dist/cjs/excel-parser/plugins/ods/formula.js +82 -0
  63. package/dist/cjs/excel-parser/plugins/ods/index.d.ts +122 -0
  64. package/dist/cjs/excel-parser/plugins/ods/index.d.ts.map +1 -0
  65. package/dist/cjs/excel-parser/plugins/ods/index.js +3642 -0
  66. package/dist/cjs/excel-parser/plugins/ods/sparklines.d.ts +25 -0
  67. package/dist/cjs/excel-parser/plugins/ods/sparklines.d.ts.map +1 -0
  68. package/dist/cjs/excel-parser/plugins/ods/sparklines.js +221 -0
  69. package/dist/cjs/excel-parser/plugins/ods/styles.d.ts +60 -0
  70. package/dist/cjs/excel-parser/plugins/ods/styles.d.ts.map +1 -0
  71. package/dist/cjs/excel-parser/plugins/ods/styles.js +808 -0
  72. package/dist/cjs/excel-parser/plugins/ods/types.d.ts +7 -0
  73. package/dist/cjs/excel-parser/plugins/ods/types.d.ts.map +1 -0
  74. package/dist/cjs/excel-parser/plugins/ods/types.js +1 -0
  75. package/dist/cjs/excel-parser/plugins/xls/index.d.ts +5 -0
  76. package/dist/cjs/excel-parser/plugins/xls/index.d.ts.map +1 -0
  77. package/dist/cjs/excel-parser/plugins/xls/index.js +19 -0
  78. package/dist/cjs/excel-parser/plugins/xlsb/biff-record-reader.d.ts +13 -0
  79. package/dist/cjs/excel-parser/plugins/xlsb/biff-record-reader.d.ts.map +1 -0
  80. package/dist/cjs/excel-parser/plugins/xlsb/biff-record-reader.js +49 -0
  81. package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts +117 -0
  82. package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts.map +1 -0
  83. package/dist/cjs/excel-parser/plugins/xlsb/index.js +2972 -0
  84. package/dist/cjs/excel-parser/plugins/xlsb/rgce-parser.d.ts +18 -0
  85. package/dist/cjs/excel-parser/plugins/xlsb/rgce-parser.d.ts.map +1 -0
  86. package/dist/cjs/excel-parser/plugins/xlsb/rgce-parser.js +527 -0
  87. package/dist/cjs/excel-parser/plugins/xlsm/index.d.ts +5 -0
  88. package/dist/cjs/excel-parser/plugins/xlsm/index.d.ts.map +1 -0
  89. package/dist/cjs/excel-parser/plugins/xlsm/index.js +10 -0
  90. package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts +60 -0
  91. package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts.map +1 -0
  92. package/dist/cjs/excel-parser/plugins/xlsx/charts.js +2178 -0
  93. package/dist/cjs/excel-parser/plugins/xlsx/conditional-formatting.d.ts +18 -0
  94. package/dist/cjs/excel-parser/plugins/xlsx/conditional-formatting.d.ts.map +1 -0
  95. package/dist/cjs/excel-parser/plugins/xlsx/conditional-formatting.js +620 -0
  96. package/dist/cjs/excel-parser/plugins/xlsx/data-validations.d.ts +4 -0
  97. package/dist/cjs/excel-parser/plugins/xlsx/data-validations.d.ts.map +1 -0
  98. package/dist/cjs/excel-parser/plugins/xlsx/data-validations.js +515 -0
  99. package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts +39 -0
  100. package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -0
  101. package/dist/cjs/excel-parser/plugins/xlsx/drawing.js +941 -0
  102. package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts +320 -0
  103. package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts.map +1 -0
  104. package/dist/cjs/excel-parser/plugins/xlsx/index.js +6056 -0
  105. package/dist/cjs/excel-parser/plugins/xlsx/numfmt.d.ts +2 -0
  106. package/dist/cjs/excel-parser/plugins/xlsx/numfmt.d.ts.map +1 -0
  107. package/dist/cjs/excel-parser/plugins/xlsx/numfmt.js +3 -0
  108. package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts +40 -0
  109. package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -0
  110. package/dist/cjs/excel-parser/plugins/xlsx/pivots.js +342 -0
  111. package/dist/cjs/excel-parser/plugins/xlsx/relationships.d.ts +8 -0
  112. package/dist/cjs/excel-parser/plugins/xlsx/relationships.d.ts.map +1 -0
  113. package/dist/cjs/excel-parser/plugins/xlsx/relationships.js +26 -0
  114. package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.d.ts +26 -0
  115. package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.d.ts.map +1 -0
  116. package/dist/cjs/excel-parser/plugins/xlsx/sheet-views.js +59 -0
  117. package/dist/cjs/excel-parser/plugins/xlsx/styles.d.ts +44 -0
  118. package/dist/cjs/excel-parser/plugins/xlsx/styles.d.ts.map +1 -0
  119. package/dist/cjs/excel-parser/plugins/xlsx/styles.js +1377 -0
  120. package/dist/cjs/excel-parser/plugins/xlsx/theme.d.ts +50 -0
  121. package/dist/cjs/excel-parser/plugins/xlsx/theme.d.ts.map +1 -0
  122. package/dist/cjs/excel-parser/plugins/xlsx/theme.js +150 -0
  123. package/dist/cjs/excel-parser/plugins/xlsx/threaded-comments.d.ts +47 -0
  124. package/dist/cjs/excel-parser/plugins/xlsx/threaded-comments.d.ts.map +1 -0
  125. package/dist/cjs/excel-parser/plugins/xlsx/threaded-comments.js +141 -0
  126. package/dist/cjs/excel-parser/plugins/xlsx/value-type-detection.d.ts +44 -0
  127. package/dist/cjs/excel-parser/plugins/xlsx/value-type-detection.d.ts.map +1 -0
  128. package/dist/cjs/excel-parser/plugins/xlsx/value-type-detection.js +407 -0
  129. package/dist/cjs/excel-parser/registry.d.ts +5 -0
  130. package/dist/cjs/excel-parser/registry.d.ts.map +1 -0
  131. package/dist/cjs/excel-parser/registry.js +21 -0
  132. package/dist/cjs/excel-parser/style-registry.d.ts +51 -0
  133. package/dist/cjs/excel-parser/style-registry.d.ts.map +1 -0
  134. package/dist/cjs/excel-parser/style-registry.js +175 -0
  135. package/dist/cjs/excel-parser/theme-default.d.ts +3 -0
  136. package/dist/cjs/excel-parser/theme-default.d.ts.map +1 -0
  137. package/dist/cjs/excel-parser/theme-default.js +19 -0
  138. package/dist/cjs/excel-parser/types.d.ts +365 -0
  139. package/dist/cjs/excel-parser/types.d.ts.map +1 -0
  140. package/dist/cjs/excel-parser/types.js +59 -0
  141. package/dist/cjs/excel-parser/utils.d.ts +6 -0
  142. package/dist/cjs/excel-parser/utils.d.ts.map +1 -0
  143. package/dist/cjs/excel-parser/utils.js +30 -0
  144. package/dist/cjs/excel-parser/workbook.d.ts +51 -0
  145. package/dist/cjs/excel-parser/workbook.d.ts.map +1 -0
  146. package/dist/cjs/excel-parser/workbook.js +317 -0
  147. package/dist/cjs/excel-parser/worker.d.ts +2 -0
  148. package/dist/cjs/excel-parser/worker.d.ts.map +1 -0
  149. package/dist/cjs/excel-parser/worker.js +1149 -0
  150. package/dist/cjs/excel-parser/zip-parser-streaming.d.ts +13 -0
  151. package/dist/cjs/excel-parser/zip-parser-streaming.d.ts.map +1 -0
  152. package/dist/cjs/excel-parser/zip-parser-streaming.js +200 -0
  153. package/dist/cjs/excel-parser/zip-parser.d.ts +11 -0
  154. package/dist/cjs/excel-parser/zip-parser.d.ts.map +1 -0
  155. package/dist/cjs/excel-parser/zip-parser.js +49 -0
  156. package/dist/cjs/exporter/invalid-data-validation.d.ts +19 -0
  157. package/dist/cjs/exporter/invalid-data-validation.d.ts.map +1 -0
  158. package/dist/cjs/exporter/invalid-data-validation.js +39 -0
  159. package/dist/cjs/exporter/ods/ods-export.d.ts +26 -0
  160. package/dist/cjs/exporter/ods/ods-export.d.ts.map +1 -0
  161. package/dist/cjs/exporter/ods/ods-export.js +3714 -0
  162. package/dist/cjs/exporter/ods/sparkline-builder.d.ts +33 -0
  163. package/dist/cjs/exporter/ods/sparkline-builder.d.ts.map +1 -0
  164. package/dist/cjs/exporter/ods/sparkline-builder.js +221 -0
  165. package/dist/cjs/exporter/xlsx/chart-builder.d.ts +3 -0
  166. package/dist/cjs/exporter/xlsx/chart-builder.d.ts.map +1 -0
  167. package/dist/cjs/exporter/xlsx/chart-builder.js +1901 -0
  168. package/dist/cjs/exporter/xlsx/chart-templates.d.ts +1781 -0
  169. package/dist/cjs/exporter/xlsx/chart-templates.d.ts.map +1 -0
  170. package/dist/cjs/exporter/xlsx/chart-templates.js +1798 -0
  171. package/dist/cjs/exporter/xlsx/future-functions.d.ts +10 -0
  172. package/dist/cjs/exporter/xlsx/future-functions.d.ts.map +1 -0
  173. package/dist/cjs/exporter/xlsx/future-functions.js +264 -0
  174. package/dist/cjs/exporter/xlsx/pivot-builder.d.ts +58 -0
  175. package/dist/cjs/exporter/xlsx/pivot-builder.d.ts.map +1 -0
  176. package/dist/cjs/exporter/xlsx/pivot-builder.js +277 -0
  177. package/dist/cjs/exporter/xlsx/power-query-builder.d.ts +26 -0
  178. package/dist/cjs/exporter/xlsx/power-query-builder.d.ts.map +1 -0
  179. package/dist/cjs/exporter/xlsx/power-query-builder.js +306 -0
  180. package/dist/cjs/exporter/xlsx/slicer-builder.d.ts +11 -0
  181. package/dist/cjs/exporter/xlsx/slicer-builder.d.ts.map +1 -0
  182. package/dist/cjs/exporter/xlsx/slicer-builder.js +87 -0
  183. package/dist/cjs/exporter/xlsx/sparkline-builder.d.ts +61 -0
  184. package/dist/cjs/exporter/xlsx/sparkline-builder.d.ts.map +1 -0
  185. package/dist/cjs/exporter/xlsx/sparkline-builder.js +489 -0
  186. package/dist/cjs/exporter/xlsx/style-builder.d.ts +93 -0
  187. package/dist/cjs/exporter/xlsx/style-builder.d.ts.map +1 -0
  188. package/dist/cjs/exporter/xlsx/style-builder.js +813 -0
  189. package/dist/cjs/exporter/xlsx/threaded-comments-builder.d.ts +58 -0
  190. package/dist/cjs/exporter/xlsx/threaded-comments-builder.d.ts.map +1 -0
  191. package/dist/cjs/exporter/xlsx/threaded-comments-builder.js +189 -0
  192. package/dist/cjs/exporter/xlsx/xlsx-export.d.ts +121 -0
  193. package/dist/cjs/exporter/xlsx/xlsx-export.d.ts.map +1 -0
  194. package/dist/cjs/exporter/xlsx/xlsx-export.js +4596 -0
  195. package/dist/cjs/helpers/theme-xml-generator.d.ts +8 -0
  196. package/dist/cjs/helpers/theme-xml-generator.d.ts.map +1 -0
  197. package/dist/cjs/helpers/theme-xml-generator.js +33 -0
  198. package/dist/cjs/helpers.d.ts +34 -0
  199. package/dist/cjs/helpers.d.ts.map +1 -0
  200. package/dist/cjs/helpers.js +189 -0
  201. package/dist/cjs/index.d.ts +16 -0
  202. package/dist/cjs/index.d.ts.map +1 -0
  203. package/dist/cjs/index.js +15 -0
  204. package/dist/cjs/indexed-colors.d.ts +2 -0
  205. package/dist/cjs/indexed-colors.d.ts.map +1 -0
  206. package/dist/cjs/indexed-colors.js +75 -0
  207. package/dist/cjs/ods-export.d.ts +24 -0
  208. package/dist/cjs/ods-export.d.ts.map +1 -0
  209. package/dist/cjs/ods-export.js +23 -0
  210. package/dist/cjs/parse.d.ts +24 -0
  211. package/dist/cjs/parse.d.ts.map +1 -0
  212. package/dist/cjs/parse.js +68 -0
  213. package/dist/cjs/power-query.d.ts +41 -0
  214. package/dist/cjs/power-query.d.ts.map +1 -0
  215. package/dist/cjs/power-query.js +22 -0
  216. package/dist/cjs/server.d.ts +9 -0
  217. package/dist/cjs/server.d.ts.map +1 -0
  218. package/dist/cjs/server.js +8 -0
  219. package/dist/cjs/theme1.d.ts +3 -0
  220. package/dist/cjs/theme1.d.ts.map +1 -0
  221. package/dist/cjs/theme1.js +2 -0
  222. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
  223. package/dist/cjs/types.d.ts +14 -0
  224. package/dist/cjs/types.d.ts.map +1 -0
  225. package/dist/cjs/types.js +14 -0
  226. package/dist/cjs/vitest.config.d.ts +3 -0
  227. package/dist/cjs/vitest.config.d.ts.map +1 -0
  228. package/dist/cjs/vitest.config.js +16 -0
  229. package/dist/esm/autofilter-condition.d.ts +43 -0
  230. package/dist/esm/autofilter-condition.d.ts.map +1 -0
  231. package/dist/esm/autofilter-condition.js +145 -0
  232. package/dist/esm/csv-export.d.ts +49 -0
  233. package/dist/esm/csv-export.d.ts.map +1 -0
  234. package/dist/esm/csv-export.js +126 -0
  235. package/dist/esm/csv-import-worker.d.ts +16 -0
  236. package/dist/esm/csv-import-worker.d.ts.map +1 -0
  237. package/dist/esm/csv-import-worker.js +60 -0
  238. package/dist/esm/csv-import.d.ts +38 -0
  239. package/dist/esm/csv-import.d.ts.map +1 -0
  240. package/dist/esm/csv-import.js +132 -0
  241. package/dist/esm/csv-parser/helpers.d.ts +14 -0
  242. package/dist/esm/csv-parser/helpers.d.ts.map +1 -0
  243. package/dist/esm/csv-parser/helpers.js +0 -0
  244. package/dist/esm/csv-parser/types.d.ts +66 -0
  245. package/dist/esm/csv-parser/types.d.ts.map +1 -0
  246. package/dist/esm/csv-parser/types.js +14 -0
  247. package/dist/esm/csv-parser/worker.d.ts +2 -0
  248. package/dist/esm/csv-parser/worker.d.ts.map +1 -0
  249. package/dist/esm/csv-parser/worker.js +154 -0
  250. package/dist/esm/excel-export.d.ts +11 -0
  251. package/dist/esm/excel-export.d.ts.map +1 -0
  252. package/dist/esm/excel-export.js +13 -0
  253. package/dist/esm/excel-import-session.d.ts +51 -0
  254. package/dist/esm/excel-import-session.d.ts.map +1 -0
  255. package/dist/esm/excel-import-session.js +255 -0
  256. package/dist/esm/excel-import-worker.d.ts +7 -0
  257. package/dist/esm/excel-import-worker.d.ts.map +1 -0
  258. package/dist/esm/excel-import-worker.js +116 -0
  259. package/dist/esm/excel-parser/builtin-numfmts.d.ts +24 -0
  260. package/dist/esm/excel-parser/builtin-numfmts.d.ts.map +1 -0
  261. package/dist/esm/excel-parser/builtin-numfmts.js +59 -0
  262. package/dist/esm/excel-parser/cfb-decryptor.d.ts +53 -0
  263. package/dist/esm/excel-parser/cfb-decryptor.d.ts.map +1 -0
  264. package/dist/esm/excel-parser/cfb-decryptor.js +493 -0
  265. package/dist/esm/excel-parser/cfb-encryptor.d.ts +23 -0
  266. package/dist/esm/excel-parser/cfb-encryptor.d.ts.map +1 -0
  267. package/dist/esm/excel-parser/cfb-encryptor.js +181 -0
  268. package/dist/esm/excel-parser/dv-cell-stamp.d.ts +29 -0
  269. package/dist/esm/excel-parser/dv-cell-stamp.d.ts.map +1 -0
  270. package/dist/esm/excel-parser/dv-cell-stamp.js +155 -0
  271. package/dist/esm/excel-parser/helpers.d.ts +28 -0
  272. package/dist/esm/excel-parser/helpers.d.ts.map +1 -0
  273. package/dist/esm/excel-parser/helpers.js +160 -0
  274. package/dist/esm/excel-parser/interface.d.ts +179 -0
  275. package/dist/esm/excel-parser/interface.d.ts.map +1 -0
  276. package/dist/esm/excel-parser/interface.js +1 -0
  277. package/dist/esm/excel-parser/plugins/base/index.d.ts +31 -0
  278. package/dist/esm/excel-parser/plugins/base/index.d.ts.map +1 -0
  279. package/dist/esm/excel-parser/plugins/base/index.js +64 -0
  280. package/dist/esm/excel-parser/plugins/ods/conditional-formatting.d.ts +16 -0
  281. package/dist/esm/excel-parser/plugins/ods/conditional-formatting.d.ts.map +1 -0
  282. package/dist/esm/excel-parser/plugins/ods/conditional-formatting.js +405 -0
  283. package/dist/esm/excel-parser/plugins/ods/data-validations.d.ts +15 -0
  284. package/dist/esm/excel-parser/plugins/ods/data-validations.d.ts.map +1 -0
  285. package/dist/esm/excel-parser/plugins/ods/data-validations.js +331 -0
  286. package/dist/esm/excel-parser/plugins/ods/formula.d.ts +8 -0
  287. package/dist/esm/excel-parser/plugins/ods/formula.d.ts.map +1 -0
  288. package/dist/esm/excel-parser/plugins/ods/formula.js +82 -0
  289. package/dist/esm/excel-parser/plugins/ods/index.d.ts +122 -0
  290. package/dist/esm/excel-parser/plugins/ods/index.d.ts.map +1 -0
  291. package/dist/esm/excel-parser/plugins/ods/index.js +2896 -0
  292. package/dist/esm/excel-parser/plugins/ods/sparklines.d.ts +25 -0
  293. package/dist/esm/excel-parser/plugins/ods/sparklines.d.ts.map +1 -0
  294. package/dist/esm/excel-parser/plugins/ods/sparklines.js +188 -0
  295. package/dist/esm/excel-parser/plugins/ods/styles.d.ts +60 -0
  296. package/dist/esm/excel-parser/plugins/ods/styles.d.ts.map +1 -0
  297. package/dist/esm/excel-parser/plugins/ods/styles.js +732 -0
  298. package/dist/esm/excel-parser/plugins/ods/types.d.ts +7 -0
  299. package/dist/esm/excel-parser/plugins/ods/types.d.ts.map +1 -0
  300. package/dist/esm/excel-parser/plugins/ods/types.js +1 -0
  301. package/dist/esm/excel-parser/plugins/xls/index.d.ts +5 -0
  302. package/dist/esm/excel-parser/plugins/xls/index.d.ts.map +1 -0
  303. package/dist/esm/excel-parser/plugins/xls/index.js +7 -0
  304. package/dist/esm/excel-parser/plugins/xlsb/biff-record-reader.d.ts +13 -0
  305. package/dist/esm/excel-parser/plugins/xlsb/biff-record-reader.d.ts.map +1 -0
  306. package/dist/esm/excel-parser/plugins/xlsb/biff-record-reader.js +48 -0
  307. package/dist/esm/excel-parser/plugins/xlsb/index.d.ts +117 -0
  308. package/dist/esm/excel-parser/plugins/xlsb/index.d.ts.map +1 -0
  309. package/dist/esm/excel-parser/plugins/xlsb/index.js +2339 -0
  310. package/dist/esm/excel-parser/plugins/xlsb/rgce-parser.d.ts +18 -0
  311. package/dist/esm/excel-parser/plugins/xlsb/rgce-parser.d.ts.map +1 -0
  312. package/dist/esm/excel-parser/plugins/xlsb/rgce-parser.js +522 -0
  313. package/dist/esm/excel-parser/plugins/xlsm/index.d.ts +5 -0
  314. package/dist/esm/excel-parser/plugins/xlsm/index.d.ts.map +1 -0
  315. package/dist/esm/excel-parser/plugins/xlsm/index.js +6 -0
  316. package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts +60 -0
  317. package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts.map +1 -0
  318. package/dist/esm/excel-parser/plugins/xlsx/charts.js +2036 -0
  319. package/dist/esm/excel-parser/plugins/xlsx/conditional-formatting.d.ts +18 -0
  320. package/dist/esm/excel-parser/plugins/xlsx/conditional-formatting.d.ts.map +1 -0
  321. package/dist/esm/excel-parser/plugins/xlsx/conditional-formatting.js +621 -0
  322. package/dist/esm/excel-parser/plugins/xlsx/data-validations.d.ts +4 -0
  323. package/dist/esm/excel-parser/plugins/xlsx/data-validations.d.ts.map +1 -0
  324. package/dist/esm/excel-parser/plugins/xlsx/data-validations.js +493 -0
  325. package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts +39 -0
  326. package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -0
  327. package/dist/esm/excel-parser/plugins/xlsx/drawing.js +905 -0
  328. package/dist/esm/excel-parser/plugins/xlsx/index.d.ts +320 -0
  329. package/dist/esm/excel-parser/plugins/xlsx/index.d.ts.map +1 -0
  330. package/dist/esm/excel-parser/plugins/xlsx/index.js +4654 -0
  331. package/dist/esm/excel-parser/plugins/xlsx/numfmt.d.ts +2 -0
  332. package/dist/esm/excel-parser/plugins/xlsx/numfmt.d.ts.map +1 -0
  333. package/dist/esm/excel-parser/plugins/xlsx/numfmt.js +3 -0
  334. package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts +40 -0
  335. package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -0
  336. package/dist/esm/excel-parser/plugins/xlsx/pivots.js +254 -0
  337. package/dist/esm/excel-parser/plugins/xlsx/relationships.d.ts +8 -0
  338. package/dist/esm/excel-parser/plugins/xlsx/relationships.d.ts.map +1 -0
  339. package/dist/esm/excel-parser/plugins/xlsx/relationships.js +13 -0
  340. package/dist/esm/excel-parser/plugins/xlsx/sheet-views.d.ts +26 -0
  341. package/dist/esm/excel-parser/plugins/xlsx/sheet-views.d.ts.map +1 -0
  342. package/dist/esm/excel-parser/plugins/xlsx/sheet-views.js +64 -0
  343. package/dist/esm/excel-parser/plugins/xlsx/styles.d.ts +44 -0
  344. package/dist/esm/excel-parser/plugins/xlsx/styles.d.ts.map +1 -0
  345. package/dist/esm/excel-parser/plugins/xlsx/styles.js +1365 -0
  346. package/dist/esm/excel-parser/plugins/xlsx/theme.d.ts +50 -0
  347. package/dist/esm/excel-parser/plugins/xlsx/theme.d.ts.map +1 -0
  348. package/dist/esm/excel-parser/plugins/xlsx/theme.js +127 -0
  349. package/dist/esm/excel-parser/plugins/xlsx/threaded-comments.d.ts +47 -0
  350. package/dist/esm/excel-parser/plugins/xlsx/threaded-comments.d.ts.map +1 -0
  351. package/dist/esm/excel-parser/plugins/xlsx/threaded-comments.js +103 -0
  352. package/dist/esm/excel-parser/plugins/xlsx/value-type-detection.d.ts +44 -0
  353. package/dist/esm/excel-parser/plugins/xlsx/value-type-detection.d.ts.map +1 -0
  354. package/dist/esm/excel-parser/plugins/xlsx/value-type-detection.js +399 -0
  355. package/dist/esm/excel-parser/registry.d.ts +5 -0
  356. package/dist/esm/excel-parser/registry.d.ts.map +1 -0
  357. package/dist/esm/excel-parser/registry.js +20 -0
  358. package/dist/esm/excel-parser/style-registry.d.ts +51 -0
  359. package/dist/esm/excel-parser/style-registry.d.ts.map +1 -0
  360. package/dist/esm/excel-parser/style-registry.js +163 -0
  361. package/dist/esm/excel-parser/theme-default.d.ts +3 -0
  362. package/dist/esm/excel-parser/theme-default.d.ts.map +1 -0
  363. package/dist/esm/excel-parser/theme-default.js +19 -0
  364. package/dist/esm/excel-parser/types.d.ts +365 -0
  365. package/dist/esm/excel-parser/types.d.ts.map +1 -0
  366. package/dist/esm/excel-parser/types.js +59 -0
  367. package/dist/esm/excel-parser/utils.d.ts +6 -0
  368. package/dist/esm/excel-parser/utils.d.ts.map +1 -0
  369. package/dist/esm/excel-parser/utils.js +25 -0
  370. package/dist/esm/excel-parser/workbook.d.ts +51 -0
  371. package/dist/esm/excel-parser/workbook.d.ts.map +1 -0
  372. package/dist/esm/excel-parser/workbook.js +192 -0
  373. package/dist/esm/excel-parser/worker.d.ts +2 -0
  374. package/dist/esm/excel-parser/worker.d.ts.map +1 -0
  375. package/dist/esm/excel-parser/worker.js +862 -0
  376. package/dist/esm/excel-parser/zip-parser-streaming.d.ts +13 -0
  377. package/dist/esm/excel-parser/zip-parser-streaming.d.ts.map +1 -0
  378. package/dist/esm/excel-parser/zip-parser-streaming.js +119 -0
  379. package/dist/esm/excel-parser/zip-parser.d.ts +11 -0
  380. package/dist/esm/excel-parser/zip-parser.d.ts.map +1 -0
  381. package/dist/esm/excel-parser/zip-parser.js +43 -0
  382. package/dist/esm/exporter/invalid-data-validation.d.ts +19 -0
  383. package/dist/esm/exporter/invalid-data-validation.d.ts.map +1 -0
  384. package/dist/esm/exporter/invalid-data-validation.js +37 -0
  385. package/dist/esm/exporter/ods/ods-export.d.ts +26 -0
  386. package/dist/esm/exporter/ods/ods-export.d.ts.map +1 -0
  387. package/dist/esm/exporter/ods/ods-export.js +3238 -0
  388. package/dist/esm/exporter/ods/sparkline-builder.d.ts +33 -0
  389. package/dist/esm/exporter/ods/sparkline-builder.d.ts.map +1 -0
  390. package/dist/esm/exporter/ods/sparkline-builder.js +165 -0
  391. package/dist/esm/exporter/xlsx/chart-builder.d.ts +3 -0
  392. package/dist/esm/exporter/xlsx/chart-builder.d.ts.map +1 -0
  393. package/dist/esm/exporter/xlsx/chart-builder.js +1805 -0
  394. package/dist/esm/exporter/xlsx/chart-templates.d.ts +1781 -0
  395. package/dist/esm/exporter/xlsx/chart-templates.d.ts.map +1 -0
  396. package/dist/esm/exporter/xlsx/chart-templates.js +1798 -0
  397. package/dist/esm/exporter/xlsx/future-functions.d.ts +10 -0
  398. package/dist/esm/exporter/xlsx/future-functions.d.ts.map +1 -0
  399. package/dist/esm/exporter/xlsx/future-functions.js +264 -0
  400. package/dist/esm/exporter/xlsx/pivot-builder.d.ts +58 -0
  401. package/dist/esm/exporter/xlsx/pivot-builder.d.ts.map +1 -0
  402. package/dist/esm/exporter/xlsx/pivot-builder.js +230 -0
  403. package/dist/esm/exporter/xlsx/power-query-builder.d.ts +26 -0
  404. package/dist/esm/exporter/xlsx/power-query-builder.d.ts.map +1 -0
  405. package/dist/esm/exporter/xlsx/power-query-builder.js +257 -0
  406. package/dist/esm/exporter/xlsx/slicer-builder.d.ts +11 -0
  407. package/dist/esm/exporter/xlsx/slicer-builder.d.ts.map +1 -0
  408. package/dist/esm/exporter/xlsx/slicer-builder.js +84 -0
  409. package/dist/esm/exporter/xlsx/sparkline-builder.d.ts +61 -0
  410. package/dist/esm/exporter/xlsx/sparkline-builder.d.ts.map +1 -0
  411. package/dist/esm/exporter/xlsx/sparkline-builder.js +437 -0
  412. package/dist/esm/exporter/xlsx/style-builder.d.ts +93 -0
  413. package/dist/esm/exporter/xlsx/style-builder.d.ts.map +1 -0
  414. package/dist/esm/exporter/xlsx/style-builder.js +795 -0
  415. package/dist/esm/exporter/xlsx/threaded-comments-builder.d.ts +58 -0
  416. package/dist/esm/exporter/xlsx/threaded-comments-builder.d.ts.map +1 -0
  417. package/dist/esm/exporter/xlsx/threaded-comments-builder.js +175 -0
  418. package/dist/esm/exporter/xlsx/xlsx-export.d.ts +121 -0
  419. package/dist/esm/exporter/xlsx/xlsx-export.d.ts.map +1 -0
  420. package/dist/esm/exporter/xlsx/xlsx-export.js +4062 -0
  421. package/dist/esm/helpers/theme-xml-generator.d.ts +8 -0
  422. package/dist/esm/helpers/theme-xml-generator.d.ts.map +1 -0
  423. package/dist/esm/helpers/theme-xml-generator.js +33 -0
  424. package/dist/esm/helpers.d.ts +34 -0
  425. package/dist/esm/helpers.d.ts.map +1 -0
  426. package/dist/esm/helpers.js +182 -0
  427. package/dist/esm/index.d.ts +16 -0
  428. package/dist/esm/index.d.ts.map +1 -0
  429. package/dist/esm/index.js +15 -0
  430. package/dist/esm/indexed-colors.d.ts +2 -0
  431. package/dist/esm/indexed-colors.d.ts.map +1 -0
  432. package/dist/esm/indexed-colors.js +75 -0
  433. package/dist/esm/ods-export.d.ts +24 -0
  434. package/dist/esm/ods-export.d.ts.map +1 -0
  435. package/dist/esm/ods-export.js +12 -0
  436. package/dist/esm/parse.d.ts +24 -0
  437. package/dist/esm/parse.d.ts.map +1 -0
  438. package/dist/esm/parse.js +55 -0
  439. package/dist/esm/power-query.d.ts +41 -0
  440. package/dist/esm/power-query.d.ts.map +1 -0
  441. package/dist/esm/power-query.js +19 -0
  442. package/dist/esm/server.d.ts +9 -0
  443. package/dist/esm/server.d.ts.map +1 -0
  444. package/dist/esm/server.js +8 -0
  445. package/dist/esm/theme1.d.ts +3 -0
  446. package/dist/esm/theme1.d.ts.map +1 -0
  447. package/dist/esm/theme1.js +2 -0
  448. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
  449. package/dist/esm/types.d.ts +14 -0
  450. package/dist/esm/types.d.ts.map +1 -0
  451. package/dist/esm/types.js +14 -0
  452. package/dist/esm/vitest.config.d.ts +3 -0
  453. package/dist/esm/vitest.config.d.ts.map +1 -0
  454. package/dist/esm/vitest.config.js +16 -0
  455. package/package.json +62 -0
  456. package/xlsx.d.ts +52 -0
@@ -0,0 +1,3642 @@
1
+ import { __assign, __asyncGenerator, __await, __awaiter, __extends, __generator, __read, __spreadArray, __values } from "tslib";
2
+ import { addressToCell, cellToAddress, getCellXfsKey, uuid, } from "@rowsncolumns/utils";
3
+ import { XMLParser } from "fast-xml-parser";
4
+ import { get } from "lodash-es";
5
+ import { Unescape } from "../../utils";
6
+ import { ZipParser } from "../../zip-parser";
7
+ import { SheetDataValidationStamper } from "../../dv-cell-stamp";
8
+ import { BaseWorkbookPlugin } from "../base/index";
9
+ import { detectValueTypeAndPattern } from "../xlsx/value-type-detection";
10
+ import { extractConditionalFormats } from "./conditional-formatting";
11
+ import { extractDataValidations } from "./data-validations";
12
+ import { convertOdsFormulaToExcel } from "./formula";
13
+ import { extractSparklines, extractSparklineData, } from "./sparklines";
14
+ import { OdsStyles } from "./styles";
15
+ var ODS_XML_OPTIONS = {
16
+ ignoreAttributes: false,
17
+ attributeNamePrefix: "@_",
18
+ ignoreDeclaration: true,
19
+ // We keep namespaces because ODS relies on them (table:, office:, text:)
20
+ removeNSPrefix: false,
21
+ // Disable entity processing to avoid expansion limits on large files,
22
+ // then decode the bounded set of entities ourselves (same approach as
23
+ // the XLSX plugin's XMLTagProcessor) so text and attribute values don't
24
+ // keep literal &/</
 sequences.
25
+ processEntities: false,
26
+ tagValueProcessor: function (_name, value) { return Unescape(value); },
27
+ attributeValueProcessor: function (_name, value) { return Unescape(value); },
28
+ };
29
+ var ODS_ORDERED_XML_OPTIONS = __assign(__assign({}, ODS_XML_OPTIONS), { preserveOrder: true });
30
+ var DISPLAY_CURRENCY_REGEX = /[$€¥£₹]/;
31
+ function findChild(children, tagName) {
32
+ return children === null || children === void 0 ? void 0 : children.find(function (child) { return child[tagName]; });
33
+ }
34
+ function getChildren(node, tagName) {
35
+ var found = findChild(node, tagName);
36
+ return found ? found[tagName] : undefined;
37
+ }
38
+ function getAttribute(node, attributeName) {
39
+ if (!node)
40
+ return undefined;
41
+ if (node["@_".concat(attributeName)] !== undefined) {
42
+ return node["@_".concat(attributeName)];
43
+ }
44
+ if (node[":@"] && node[":@"]["@_".concat(attributeName)] !== undefined) {
45
+ return node[":@"]["@_".concat(attributeName)];
46
+ }
47
+ return undefined;
48
+ }
49
+ function fastMergeCellFormats() {
50
+ var e_1, _a;
51
+ var formats = [];
52
+ for (var _i = 0; _i < arguments.length; _i++) {
53
+ formats[_i] = arguments[_i];
54
+ }
55
+ var result;
56
+ try {
57
+ for (var formats_1 = __values(formats), formats_1_1 = formats_1.next(); !formats_1_1.done; formats_1_1 = formats_1.next()) {
58
+ var format = formats_1_1.value;
59
+ if (!format)
60
+ continue;
61
+ if (!result) {
62
+ result = __assign({}, format);
63
+ continue;
64
+ }
65
+ // Merge properties
66
+ if (format.backgroundColor !== undefined)
67
+ result.backgroundColor = format.backgroundColor;
68
+ if (format.horizontalAlignment !== undefined)
69
+ result.horizontalAlignment = format.horizontalAlignment;
70
+ if (format.verticalAlignment !== undefined)
71
+ result.verticalAlignment = format.verticalAlignment;
72
+ if (format.wrapStrategy !== undefined)
73
+ result.wrapStrategy = format.wrapStrategy;
74
+ if (format.textRotation !== undefined)
75
+ result.textRotation = format.textRotation;
76
+ if (format.indent !== undefined)
77
+ result.indent = format.indent;
78
+ // Objects
79
+ if (format.textFormat) {
80
+ result.textFormat = result.textFormat
81
+ ? __assign(__assign({}, result.textFormat), format.textFormat) : __assign({}, format.textFormat);
82
+ }
83
+ if (format.numberFormat) {
84
+ result.numberFormat = __assign({}, format.numberFormat);
85
+ }
86
+ if (format.borders) {
87
+ result.borders = result.borders
88
+ ? __assign({}, result.borders) : __assign({}, format.borders);
89
+ if (format.borders.top)
90
+ result.borders.top = format.borders.top;
91
+ if (format.borders.bottom)
92
+ result.borders.bottom = format.borders.bottom;
93
+ if (format.borders.left)
94
+ result.borders.left = format.borders.left;
95
+ if (format.borders.right)
96
+ result.borders.right = format.borders.right;
97
+ }
98
+ }
99
+ }
100
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
101
+ finally {
102
+ try {
103
+ if (formats_1_1 && !formats_1_1.done && (_a = formats_1.return)) _a.call(formats_1);
104
+ }
105
+ finally { if (e_1) throw e_1.error; }
106
+ }
107
+ return result;
108
+ }
109
+ // Inverse of the exporter's mapConditionToFilterCondition: ODS
110
+ // <table:filter-condition table:operator> -> in-app condition type. "=" is
111
+ // intentionally absent — it round-trips as a value-list (the common case),
112
+ // which yields the same visible rows as NUMBER_EQ.
113
+ var ODS_OPERATOR_TO_CONDITION = {
114
+ "!=": "NUMBER_NOT_EQ",
115
+ "<>": "NUMBER_NOT_EQ",
116
+ ">": "NUMBER_GREATER",
117
+ ">=": "NUMBER_GREATER_THAN_EQ",
118
+ "<": "NUMBER_LESS",
119
+ "<=": "NUMBER_LESS_THAN_EQ",
120
+ between: "NUMBER_BETWEEN",
121
+ "not-between": "NUMBER_NOT_BETWEEN",
122
+ contains: "TEXT_CONTAINS",
123
+ "does-not-contain": "TEXT_NOT_CONTAINS",
124
+ "begins-with": "TEXT_STARTS_WITH",
125
+ begins: "TEXT_STARTS_WITH",
126
+ "ends-with": "TEXT_ENDS_WITH",
127
+ endswith: "TEXT_ENDS_WITH",
128
+ empty: "BLANK",
129
+ "non-empty": "NOT_BLANK",
130
+ };
131
+ var OdsPlugin = /** @class */ (function (_super) {
132
+ __extends(OdsPlugin, _super);
133
+ function OdsPlugin() {
134
+ var _this = _super.call(this) || this;
135
+ _this.cellXfs = new Map();
136
+ _this.sharedStrings = [];
137
+ _this.richSharedStringRuns = new Map();
138
+ _this.sharedStringIndexByValue = new Map();
139
+ _this.sheetCache = null;
140
+ _this.sparklinesBySheet = new Map();
141
+ _this.zipParser = new ZipParser();
142
+ _this.xmlParser = new XMLParser(ODS_XML_OPTIONS);
143
+ _this.xmlOrderedParser = new XMLParser(ODS_ORDERED_XML_OPTIONS);
144
+ _this.odsStyles = new OdsStyles();
145
+ return _this;
146
+ }
147
+ OdsPlugin.prototype.load = function (buffer, password) {
148
+ return __awaiter(this, void 0, void 0, function () {
149
+ var source, _a, content, styles, parsedStyles, settings;
150
+ return __generator(this, function (_b) {
151
+ switch (_b.label) {
152
+ case 0:
153
+ if (!(buffer instanceof File)) return [3 /*break*/, 2];
154
+ return [4 /*yield*/, buffer.arrayBuffer()];
155
+ case 1:
156
+ _a = _b.sent();
157
+ return [3 /*break*/, 3];
158
+ case 2:
159
+ _a = buffer;
160
+ _b.label = 3;
161
+ case 3:
162
+ source = _a;
163
+ return [4 /*yield*/, this.zipParser.load(source, password)];
164
+ case 4:
165
+ _b.sent();
166
+ this.cellXfs.clear();
167
+ this.odsStyles.reset();
168
+ this.sharedStrings = [];
169
+ this.richSharedStringRuns = new Map();
170
+ this.sharedStringIndexByValue.clear();
171
+ this.sheetCache = null;
172
+ this.sparklinesBySheet = new Map();
173
+ this.settingsXml = null;
174
+ try {
175
+ content = this.zipParser.Get("content.xml");
176
+ if (content) {
177
+ this.contentXml = this.xmlParser.parse(content);
178
+ this.contentXmlOrdered = this.xmlOrderedParser.parse(content);
179
+ this.odsStyles.parseContentXml(this.contentXml);
180
+ }
181
+ styles = this.zipParser.Get("styles.xml");
182
+ if (styles) {
183
+ parsedStyles = this.xmlParser.parse(styles);
184
+ this.odsStyles.parseStylesXml(parsedStyles);
185
+ }
186
+ settings = this.zipParser.Get("settings.xml");
187
+ if (settings) {
188
+ this.settingsXml = this.xmlParser.parse(settings);
189
+ }
190
+ }
191
+ catch (e) {
192
+ console.error("Failed to parse ODS content.xml", e);
193
+ }
194
+ return [2 /*return*/];
195
+ }
196
+ });
197
+ });
198
+ };
199
+ OdsPlugin.prototype.getCellXfs = function () {
200
+ return this.cellXfs;
201
+ };
202
+ OdsPlugin.prototype.getSharedStrings = function () {
203
+ return this.sharedStrings;
204
+ };
205
+ OdsPlugin.prototype.getOrCreateSharedStringIndex = function (value, runs) {
206
+ var key = (runs === null || runs === void 0 ? void 0 : runs.length) ? JSON.stringify({ value: value, runs: runs }) : value;
207
+ var existing = this.sharedStringIndexByValue.get(key);
208
+ if (existing !== undefined) {
209
+ return existing;
210
+ }
211
+ var index = this.sharedStrings.length;
212
+ this.sharedStrings.push(value);
213
+ if (runs === null || runs === void 0 ? void 0 : runs.length) {
214
+ this.richSharedStringRuns.set(index, runs);
215
+ }
216
+ this.sharedStringIndexByValue.set(key, index);
217
+ return index;
218
+ };
219
+ OdsPlugin.prototype.registerFormat = function (format) {
220
+ var key = getCellXfsKey(format);
221
+ if (!this.cellXfs.has(key)) {
222
+ this.cellXfs.set(key, format);
223
+ }
224
+ return key;
225
+ };
226
+ OdsPlugin.prototype.dispose = function () {
227
+ this.zipParser.Dispose();
228
+ this.contentXml = null;
229
+ this.contentXmlOrdered = null;
230
+ this.settingsXml = null;
231
+ this.sheetCache = null;
232
+ };
233
+ OdsPlugin.prototype.getSpreadsheetNode = function () {
234
+ if (!this.contentXml)
235
+ return undefined;
236
+ return (get(this.contentXml, "office:document-content.office:body.office:spreadsheet") || get(this.contentXml, "document-content.body.spreadsheet"));
237
+ };
238
+ OdsPlugin.prototype.getTables = function () {
239
+ var body = this.getSpreadsheetNode();
240
+ if (!body)
241
+ return [];
242
+ var tables = get(body, "table:table") || get(body, "table");
243
+ return Array.isArray(tables) ? tables : tables ? [tables] : [];
244
+ };
245
+ OdsPlugin.prototype.getSheetCount = function () {
246
+ return this.getTables().length;
247
+ };
248
+ OdsPlugin.prototype.ensureSheetCache = function () {
249
+ if (this.sheetCache) {
250
+ return this.sheetCache;
251
+ }
252
+ var cache = this.buildSheetCache();
253
+ this.sheetCache = cache;
254
+ return cache;
255
+ };
256
+ OdsPlugin.prototype.buildSheetCache = function () {
257
+ var e_2, _a;
258
+ var _this = this;
259
+ var _b, _c;
260
+ var tables = this.getTables();
261
+ var sheets = [];
262
+ var sheetContexts = [];
263
+ tables.forEach(function (table, index) {
264
+ var e_3, _a, e_4, _b;
265
+ var _c, _d, _e, _f;
266
+ var name = table["@_table:name"] ||
267
+ table["@_name"] ||
268
+ table["table:name"] ||
269
+ table["name"] ||
270
+ "Sheet".concat(index + 1);
271
+ var sheet = {
272
+ sheetId: index + 1,
273
+ title: name,
274
+ hidden: ((_c = table["@_table:style-name"]) === null || _c === void 0 ? void 0 : _c.includes("hidden")) ||
275
+ ((_d = table["table:style-name"]) === null || _d === void 0 ? void 0 : _d.includes("hidden")) ||
276
+ false,
277
+ rowMetadata: [],
278
+ columnMetadata: [],
279
+ merges: [],
280
+ };
281
+ // Column metadata from table-column elements
282
+ var columnNodes = get(table, "table:table-column") || get(table, "table-column") || [];
283
+ var allColumns = Array.isArray(columnNodes)
284
+ ? columnNodes
285
+ : columnNodes
286
+ ? [columnNodes]
287
+ : [];
288
+ var currentColumnIndex = 1;
289
+ var detectedColumnCount = 0;
290
+ var defaultColumnWidth;
291
+ var defaultColumnStyleName;
292
+ try {
293
+ for (var allColumns_1 = __values(allColumns), allColumns_1_1 = allColumns_1.next(); !allColumns_1_1.done; allColumns_1_1 = allColumns_1.next()) {
294
+ var column = allColumns_1_1.value;
295
+ if (!column)
296
+ continue;
297
+ var colsRepeated = parseInt(getAttribute(column, "table:number-columns-repeated") ||
298
+ getAttribute(column, "number-columns-repeated") ||
299
+ "1", 10);
300
+ var styleName = getAttribute(column, "table:style-name") ||
301
+ getAttribute(column, "style-name");
302
+ var visibility = getAttribute(column, "table:visibility") ||
303
+ getAttribute(column, "visibility");
304
+ var columnStyle = styleName
305
+ ? _this.odsStyles.getColumnStyle(styleName)
306
+ : undefined;
307
+ var width = columnStyle === null || columnStyle === void 0 ? void 0 : columnStyle.width;
308
+ var isHidden = visibility === "collapse" ||
309
+ visibility === "hidden" ||
310
+ visibility === "none" ||
311
+ (columnStyle === null || columnStyle === void 0 ? void 0 : columnStyle.hidden);
312
+ for (var c = 0; c < colsRepeated; c++) {
313
+ var props = {};
314
+ var shouldAssign = false;
315
+ if (typeof width === "number") {
316
+ props.size = width;
317
+ if (defaultColumnWidth === undefined) {
318
+ defaultColumnWidth = width;
319
+ defaultColumnStyleName = styleName;
320
+ }
321
+ var widthDiffers = defaultColumnWidth === undefined
322
+ ? true
323
+ : Math.abs(width - defaultColumnWidth) > 0.5;
324
+ var styleDiffers = styleName &&
325
+ defaultColumnStyleName &&
326
+ styleName !== defaultColumnStyleName;
327
+ if (widthDiffers || styleDiffers) {
328
+ props.resizedByUser = true;
329
+ }
330
+ shouldAssign = true;
331
+ }
332
+ if (isHidden) {
333
+ props.hiddenByUser = true;
334
+ shouldAssign = true;
335
+ }
336
+ if (shouldAssign) {
337
+ sheet.columnMetadata[currentColumnIndex] = props;
338
+ }
339
+ currentColumnIndex++;
340
+ }
341
+ detectedColumnCount = Math.max(detectedColumnCount, currentColumnIndex - 1);
342
+ }
343
+ }
344
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
345
+ finally {
346
+ try {
347
+ if (allColumns_1_1 && !allColumns_1_1.done && (_a = allColumns_1.return)) _a.call(allColumns_1);
348
+ }
349
+ finally { if (e_3) throw e_3.error; }
350
+ }
351
+ // Row metadata from table-row elements
352
+ var rowNodes = get(table, "table:table-row") || get(table, "table-row") || [];
353
+ var allRows = Array.isArray(rowNodes) ? rowNodes : [rowNodes];
354
+ // DO NOT DELETE
355
+ // console.log("allRows", allRows);
356
+ var currentRowIndex = 1;
357
+ var defaultRowHeight;
358
+ var defaultRowStyleName;
359
+ var detectedRowCount = 0;
360
+ try {
361
+ for (var allRows_1 = __values(allRows), allRows_1_1 = allRows_1.next(); !allRows_1_1.done; allRows_1_1 = allRows_1.next()) {
362
+ var row = allRows_1_1.value;
363
+ if (!row)
364
+ continue;
365
+ var rowsRepeated = parseInt(getAttribute(row, "table:number-rows-repeated") ||
366
+ getAttribute(row, "number-rows-repeated") ||
367
+ "1", 10);
368
+ var styleName = getAttribute(row, "table:style-name") ||
369
+ getAttribute(row, "style-name");
370
+ var visibility = getAttribute(row, "table:visibility") ||
371
+ getAttribute(row, "visibility");
372
+ var rowStyle = styleName
373
+ ? _this.odsStyles.getRowStyle(styleName)
374
+ : undefined;
375
+ var height = rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.height;
376
+ var isHidden = visibility === "collapse" ||
377
+ visibility === "hidden" ||
378
+ visibility === "none" ||
379
+ (rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.hidden);
380
+ var effectiveRepeats = Math.min(rowsRepeated, 10000);
381
+ var shouldProcessRowMetadata = typeof height === "number" || isHidden;
382
+ if (!shouldProcessRowMetadata) {
383
+ currentRowIndex += effectiveRepeats;
384
+ detectedRowCount = Math.max(detectedRowCount, currentRowIndex - 1);
385
+ continue;
386
+ }
387
+ for (var r = 0; r < effectiveRepeats; r++) {
388
+ var props = {};
389
+ var shouldAssign = false;
390
+ if (typeof height === "number") {
391
+ props.size = height;
392
+ if (defaultRowHeight === undefined) {
393
+ defaultRowHeight = height;
394
+ defaultRowStyleName = styleName;
395
+ }
396
+ var heightDiffers = defaultRowHeight === undefined
397
+ ? true
398
+ : Math.abs(height - defaultRowHeight) > 0.5;
399
+ var styleDiffers = styleName &&
400
+ defaultRowStyleName &&
401
+ styleName !== defaultRowStyleName;
402
+ if (heightDiffers || styleDiffers) {
403
+ props.resizedByUser = true;
404
+ }
405
+ shouldAssign = true;
406
+ }
407
+ if (isHidden) {
408
+ props.hiddenByUser = true;
409
+ shouldAssign = true;
410
+ }
411
+ if (shouldAssign) {
412
+ sheet.rowMetadata[currentRowIndex] = props;
413
+ }
414
+ currentRowIndex++;
415
+ }
416
+ detectedRowCount = Math.max(detectedRowCount, currentRowIndex - 1);
417
+ }
418
+ }
419
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
420
+ finally {
421
+ try {
422
+ if (allRows_1_1 && !allRows_1_1.done && (_b = allRows_1.return)) _b.call(allRows_1);
423
+ }
424
+ finally { if (e_4) throw e_4.error; }
425
+ }
426
+ if (detectedRowCount > 0) {
427
+ sheet.rowCount = Math.max((_e = sheet.rowCount) !== null && _e !== void 0 ? _e : 0, detectedRowCount);
428
+ }
429
+ if (detectedColumnCount > 0) {
430
+ sheet.columnCount = Math.max((_f = sheet.columnCount) !== null && _f !== void 0 ? _f : 0, detectedColumnCount);
431
+ }
432
+ sheets.push(sheet);
433
+ sheetContexts.push({ node: table, sheetId: sheet.sheetId, name: name });
434
+ });
435
+ var sheetNameMap = this.buildSheetNameMap(sheetContexts);
436
+ var spreadsheetNode = this.getSpreadsheetNode();
437
+ var tableViews = this.extractTableViews(sheetContexts);
438
+ var conditionalFormatting = extractConditionalFormats({
439
+ sheetContexts: sheetContexts,
440
+ sheetNameMap: sheetNameMap,
441
+ odsStyles: this.odsStyles,
442
+ getAttributes: this.getAttributes.bind(this),
443
+ parseRangeList: this.parseRangeList.bind(this),
444
+ normalizeExpression: this.normalizeExpression.bind(this),
445
+ normalizeConditionExpression: this.normalizeConditionExpression.bind(this),
446
+ toArray: this.toArray.bind(this),
447
+ });
448
+ var dataValidations = extractDataValidations({
449
+ sheetContexts: sheetContexts,
450
+ sheetNameMap: sheetNameMap,
451
+ spreadsheetNode: spreadsheetNode,
452
+ getAttributes: this.getAttributes.bind(this),
453
+ parseRangeList: this.parseRangeList.bind(this),
454
+ normalizeConditionExpression: this.normalizeConditionExpression.bind(this),
455
+ parseBooleanAttribute: this.parseBooleanAttribute.bind(this),
456
+ mapAlertStyle: this.mapAlertStyle.bind(this),
457
+ toArray: this.toArray.bind(this),
458
+ });
459
+ var namedRanges = this.extractNamedRanges(sheetContexts);
460
+ var _d = this.extractEmbeddedObjects(sheetContexts, sheetNameMap), drawings = _d.drawings, charts = _d.charts;
461
+ // Extract LibreOffice sparklines (calcext:sparkline-groups)
462
+ this.sparklinesBySheet = extractSparklines({
463
+ sheetContexts: sheetContexts,
464
+ sheetNameMap: sheetNameMap,
465
+ getAttributes: this.getAttributes.bind(this),
466
+ toArray: this.toArray.bind(this),
467
+ });
468
+ var mergesMap = this.extractMerges(sheetContexts);
469
+ this.extractOutlineGroups(sheets);
470
+ var sheetSettings = this.extractSheetSettings(sheetContexts);
471
+ var basicFilters = this.extractBasicFilters(sheetContexts, sheetNameMap, spreadsheetNode);
472
+ try {
473
+ for (var sheets_1 = __values(sheets), sheets_1_1 = sheets_1.next(); !sheets_1_1.done; sheets_1_1 = sheets_1.next()) {
474
+ var sheet = sheets_1_1.value;
475
+ sheet.merges = (_c = (_b = mergesMap.get(sheet.sheetId)) !== null && _b !== void 0 ? _b : sheet.merges) !== null && _c !== void 0 ? _c : [];
476
+ var settings = sheetSettings.get(sheet.sheetId);
477
+ if (settings) {
478
+ if (settings.frozenRowCount !== undefined) {
479
+ sheet.frozenRowCount = settings.frozenRowCount;
480
+ }
481
+ if (settings.frozenColumnCount !== undefined) {
482
+ sheet.frozenColumnCount = settings.frozenColumnCount;
483
+ }
484
+ if (settings.showGridLines !== undefined) {
485
+ sheet.showGridLines = settings.showGridLines;
486
+ }
487
+ if (settings.tabColor) {
488
+ sheet.tabColor = settings.tabColor;
489
+ }
490
+ }
491
+ var filter = basicFilters.get(sheet.sheetId);
492
+ if (filter) {
493
+ sheet.basicFilter = filter;
494
+ }
495
+ }
496
+ }
497
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
498
+ finally {
499
+ try {
500
+ if (sheets_1_1 && !sheets_1_1.done && (_a = sheets_1.return)) _a.call(sheets_1);
501
+ }
502
+ finally { if (e_2) throw e_2.error; }
503
+ }
504
+ return {
505
+ sheets: sheets,
506
+ tables: tableViews,
507
+ conditionalFormatting: conditionalFormatting,
508
+ dataValidations: dataValidations,
509
+ namedRanges: namedRanges,
510
+ drawings: drawings,
511
+ charts: charts,
512
+ };
513
+ };
514
+ OdsPlugin.prototype.extractTableViews = function (sheetContexts) {
515
+ var e_5, _a, e_6, _b, e_7, _c;
516
+ if (!sheetContexts.length)
517
+ return [];
518
+ var spreadsheet = this.getSpreadsheetNode();
519
+ if (!spreadsheet)
520
+ return [];
521
+ var sheetNameMap = this.buildSheetNameMap(sheetContexts);
522
+ var tableViews = [];
523
+ var globalRanges = this.toArray(get(spreadsheet, "table:database-ranges.table:database-range") ||
524
+ get(spreadsheet, "database-ranges.database-range"));
525
+ try {
526
+ for (var globalRanges_1 = __values(globalRanges), globalRanges_1_1 = globalRanges_1.next(); !globalRanges_1_1.done; globalRanges_1_1 = globalRanges_1.next()) {
527
+ var node = globalRanges_1_1.value;
528
+ var tableView = this.convertDatabaseRangeNode(node, sheetNameMap, undefined, sheetContexts);
529
+ if (tableView) {
530
+ tableViews.push(tableView);
531
+ }
532
+ }
533
+ }
534
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
535
+ finally {
536
+ try {
537
+ if (globalRanges_1_1 && !globalRanges_1_1.done && (_a = globalRanges_1.return)) _a.call(globalRanges_1);
538
+ }
539
+ finally { if (e_5) throw e_5.error; }
540
+ }
541
+ try {
542
+ for (var sheetContexts_1 = __values(sheetContexts), sheetContexts_1_1 = sheetContexts_1.next(); !sheetContexts_1_1.done; sheetContexts_1_1 = sheetContexts_1.next()) {
543
+ var context = sheetContexts_1_1.value;
544
+ var inlineRanges = this.toArray(get(context.node, "table:database-range") ||
545
+ get(context.node, "database-range"));
546
+ try {
547
+ for (var inlineRanges_1 = (e_7 = void 0, __values(inlineRanges)), inlineRanges_1_1 = inlineRanges_1.next(); !inlineRanges_1_1.done; inlineRanges_1_1 = inlineRanges_1.next()) {
548
+ var node = inlineRanges_1_1.value;
549
+ var tableView = this.convertDatabaseRangeNode(node, sheetNameMap, context, sheetContexts);
550
+ if (tableView) {
551
+ tableViews.push(tableView);
552
+ }
553
+ }
554
+ }
555
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
556
+ finally {
557
+ try {
558
+ if (inlineRanges_1_1 && !inlineRanges_1_1.done && (_c = inlineRanges_1.return)) _c.call(inlineRanges_1);
559
+ }
560
+ finally { if (e_7) throw e_7.error; }
561
+ }
562
+ }
563
+ }
564
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
565
+ finally {
566
+ try {
567
+ if (sheetContexts_1_1 && !sheetContexts_1_1.done && (_b = sheetContexts_1.return)) _b.call(sheetContexts_1);
568
+ }
569
+ finally { if (e_6) throw e_6.error; }
570
+ }
571
+ return tableViews;
572
+ };
573
+ OdsPlugin.prototype.convertDatabaseRangeNode = function (node, sheetNameMap, context, sheetContexts) {
574
+ var attrs = this.getAttributes(node);
575
+ if (!attrs)
576
+ return undefined;
577
+ var rangeAttr = attrs["@_table:target-range-address"] ||
578
+ attrs["@_target-range-address"] ||
579
+ attrs["@_table:cell-range-address"];
580
+ var ranges = this.parseRangeList(rangeAttr, sheetNameMap, context);
581
+ if (!ranges.length)
582
+ return undefined;
583
+ var _a = __read(ranges, 1), range = _a[0];
584
+ var title = attrs["@_table:display-label"] ||
585
+ attrs["@_table:name"] ||
586
+ attrs["@_name"] ||
587
+ "Table".concat(range.sheetId);
588
+ var tableView = {
589
+ id: attrs["@_table:id"] || attrs["@_id"] || title,
590
+ sheetId: range.sheetId,
591
+ title: title,
592
+ range: range,
593
+ };
594
+ var headerRow = this.parseBooleanAttribute(attrs["@_table:contains-header"] || attrs["@_contains-header"]);
595
+ if (headerRow !== undefined) {
596
+ tableView.headerRow = headerRow;
597
+ }
598
+ var totalRow = this.parseBooleanAttribute(attrs["@_table:contains-total-row"] || attrs["@_contains-total-row"]);
599
+ if (totalRow !== undefined) {
600
+ tableView.totalRow = totalRow;
601
+ }
602
+ var filterButton = this.parseBooleanAttribute(attrs["@_table:display-filter-buttons"] ||
603
+ attrs["@_display-filter-buttons"]);
604
+ if (filterButton !== undefined) {
605
+ tableView.filterButton = filterButton;
606
+ }
607
+ var showRowStripes = this.parseBooleanAttribute(attrs["@_table:use-banding-rows"] || attrs["@_use-banding-rows"]);
608
+ if (showRowStripes !== undefined) {
609
+ tableView.showRowStripes = showRowStripes;
610
+ }
611
+ var showColumnStripes = this.parseBooleanAttribute(attrs["@_table:use-banding-columns"] || attrs["@_use-banding-columns"]);
612
+ if (showColumnStripes !== undefined) {
613
+ tableView.showColumnStripes = showColumnStripes;
614
+ }
615
+ var effectiveContext = context !== null && context !== void 0 ? context : sheetContexts === null || sheetContexts === void 0 ? void 0 : sheetContexts.find(function (entry) { return entry.sheetId === range.sheetId; });
616
+ var columns = this.extractTableColumnsFromHeader(range, effectiveContext, tableView.headerRow !== false);
617
+ if (columns === null || columns === void 0 ? void 0 : columns.length) {
618
+ tableView.columns = columns;
619
+ }
620
+ return tableView;
621
+ };
622
+ OdsPlugin.prototype.extractNamedRanges = function (sheetContexts) {
623
+ var e_8, _a, e_9, _b, e_10, _c;
624
+ var _this = this;
625
+ var spreadsheet = this.getSpreadsheetNode();
626
+ if (!spreadsheet)
627
+ return [];
628
+ var sheetNameMap = this.buildSheetNameMap(sheetContexts);
629
+ var namedRanges = [];
630
+ var processContainer = function (container, context) {
631
+ var e_11, _a, e_12, _b, e_13, _c;
632
+ if (!container)
633
+ return;
634
+ var rangeNodes = _this.toArray(get(container, "table:named-range") || get(container, "named-range"));
635
+ try {
636
+ for (var rangeNodes_1 = __values(rangeNodes), rangeNodes_1_1 = rangeNodes_1.next(); !rangeNodes_1_1.done; rangeNodes_1_1 = rangeNodes_1.next()) {
637
+ var node = rangeNodes_1_1.value;
638
+ var attrs = _this.getAttributes(node);
639
+ if (!attrs)
640
+ continue;
641
+ var name_1 = attrs["@_table:name"] ||
642
+ attrs["@_name"] ||
643
+ attrs["@_table:display-name"];
644
+ if (!name_1)
645
+ continue;
646
+ var addressAttr = attrs["@_table:cell-range-address"] ||
647
+ attrs["@_cell-range-address"] ||
648
+ attrs["@_table:base-cell-address"] ||
649
+ attrs["@_base-cell-address"];
650
+ var ranges = _this.parseRangeList(addressAttr, sheetNameMap, context);
651
+ try {
652
+ for (var ranges_1 = (e_12 = void 0, __values(ranges)), ranges_1_1 = ranges_1.next(); !ranges_1_1.done; ranges_1_1 = ranges_1.next()) {
653
+ var range = ranges_1_1.value;
654
+ namedRanges.push({
655
+ namedRangeId: uuid(),
656
+ name: name_1,
657
+ range: range,
658
+ });
659
+ }
660
+ }
661
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
662
+ finally {
663
+ try {
664
+ if (ranges_1_1 && !ranges_1_1.done && (_b = ranges_1.return)) _b.call(ranges_1);
665
+ }
666
+ finally { if (e_12) throw e_12.error; }
667
+ }
668
+ }
669
+ }
670
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
671
+ finally {
672
+ try {
673
+ if (rangeNodes_1_1 && !rangeNodes_1_1.done && (_a = rangeNodes_1.return)) _a.call(rangeNodes_1);
674
+ }
675
+ finally { if (e_11) throw e_11.error; }
676
+ }
677
+ var expressionNodes = _this.toArray(get(container, "table:named-expression") ||
678
+ get(container, "named-expression"));
679
+ try {
680
+ for (var expressionNodes_1 = __values(expressionNodes), expressionNodes_1_1 = expressionNodes_1.next(); !expressionNodes_1_1.done; expressionNodes_1_1 = expressionNodes_1.next()) {
681
+ var node = expressionNodes_1_1.value;
682
+ var attrs = _this.getAttributes(node);
683
+ if (!attrs)
684
+ continue;
685
+ var name_2 = attrs["@_table:name"] ||
686
+ attrs["@_name"] ||
687
+ attrs["@_table:display-name"];
688
+ if (!name_2)
689
+ continue;
690
+ var expressionAttr = attrs["@_table:expression"] || attrs["@_expression"];
691
+ var excelFormula = _this.normalizeExpression(expressionAttr);
692
+ if (excelFormula) {
693
+ namedRanges.push({
694
+ namedRangeId: uuid(),
695
+ name: name_2,
696
+ value: excelFormula,
697
+ });
698
+ }
699
+ }
700
+ }
701
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
702
+ finally {
703
+ try {
704
+ if (expressionNodes_1_1 && !expressionNodes_1_1.done && (_c = expressionNodes_1.return)) _c.call(expressionNodes_1);
705
+ }
706
+ finally { if (e_13) throw e_13.error; }
707
+ }
708
+ };
709
+ var globalContainers = this.toArray(get(spreadsheet, "table:named-expressions") ||
710
+ get(spreadsheet, "named-expressions"));
711
+ try {
712
+ for (var globalContainers_1 = __values(globalContainers), globalContainers_1_1 = globalContainers_1.next(); !globalContainers_1_1.done; globalContainers_1_1 = globalContainers_1.next()) {
713
+ var container = globalContainers_1_1.value;
714
+ processContainer(container);
715
+ }
716
+ }
717
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
718
+ finally {
719
+ try {
720
+ if (globalContainers_1_1 && !globalContainers_1_1.done && (_a = globalContainers_1.return)) _a.call(globalContainers_1);
721
+ }
722
+ finally { if (e_8) throw e_8.error; }
723
+ }
724
+ try {
725
+ for (var sheetContexts_2 = __values(sheetContexts), sheetContexts_2_1 = sheetContexts_2.next(); !sheetContexts_2_1.done; sheetContexts_2_1 = sheetContexts_2.next()) {
726
+ var context = sheetContexts_2_1.value;
727
+ var containers = this.toArray(get(context.node, "table:named-expressions") ||
728
+ get(context.node, "named-expressions"));
729
+ try {
730
+ for (var containers_1 = (e_10 = void 0, __values(containers)), containers_1_1 = containers_1.next(); !containers_1_1.done; containers_1_1 = containers_1.next()) {
731
+ var container = containers_1_1.value;
732
+ processContainer(container, context);
733
+ }
734
+ }
735
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
736
+ finally {
737
+ try {
738
+ if (containers_1_1 && !containers_1_1.done && (_c = containers_1.return)) _c.call(containers_1);
739
+ }
740
+ finally { if (e_10) throw e_10.error; }
741
+ }
742
+ }
743
+ }
744
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
745
+ finally {
746
+ try {
747
+ if (sheetContexts_2_1 && !sheetContexts_2_1.done && (_b = sheetContexts_2.return)) _b.call(sheetContexts_2);
748
+ }
749
+ finally { if (e_9) throw e_9.error; }
750
+ }
751
+ return namedRanges;
752
+ };
753
+ OdsPlugin.prototype.extractBasicFilters = function (sheetContexts, sheetNameMap, spreadsheetNode) {
754
+ var e_14, _a, e_15, _b, e_16, _c;
755
+ var _this = this;
756
+ var filters = new Map();
757
+ if (!sheetContexts.length) {
758
+ return filters;
759
+ }
760
+ var processNode = function (node, context) {
761
+ if (!node)
762
+ return;
763
+ var filterNode = get(node, "table:filter") || get(node, "filter");
764
+ if (!filterNode)
765
+ return;
766
+ var attrs = _this.getAttributes(node);
767
+ if (!attrs)
768
+ return;
769
+ var rangeAttr = attrs["@_table:target-range-address"] ||
770
+ attrs["@_target-range-address"] ||
771
+ attrs["@_table:cell-range-address"] ||
772
+ attrs["@_cell-range-address"];
773
+ var ranges = _this.parseRangeList(rangeAttr, sheetNameMap, context);
774
+ if (!ranges.length)
775
+ return;
776
+ var filterSpecs = _this.convertFilterNodeToSpecs(filterNode);
777
+ if (!filterSpecs.length)
778
+ return;
779
+ var _a = __read(ranges, 1), range = _a[0];
780
+ var filterView = {
781
+ id: attrs["@_table:name"] || attrs["@_name"] || uuid(),
782
+ title: attrs["@_table:display-label"] ||
783
+ attrs["@_table:name"] ||
784
+ attrs["@_name"],
785
+ range: range,
786
+ filterSpecs: filterSpecs,
787
+ };
788
+ filters.set(range.sheetId, filterView);
789
+ };
790
+ if (spreadsheetNode) {
791
+ var globalRanges = this.toArray(get(spreadsheetNode, "table:database-ranges.table:database-range") ||
792
+ get(spreadsheetNode, "database-ranges.database-range"));
793
+ try {
794
+ for (var globalRanges_2 = __values(globalRanges), globalRanges_2_1 = globalRanges_2.next(); !globalRanges_2_1.done; globalRanges_2_1 = globalRanges_2.next()) {
795
+ var node = globalRanges_2_1.value;
796
+ processNode(node);
797
+ }
798
+ }
799
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
800
+ finally {
801
+ try {
802
+ if (globalRanges_2_1 && !globalRanges_2_1.done && (_a = globalRanges_2.return)) _a.call(globalRanges_2);
803
+ }
804
+ finally { if (e_14) throw e_14.error; }
805
+ }
806
+ }
807
+ try {
808
+ for (var sheetContexts_3 = __values(sheetContexts), sheetContexts_3_1 = sheetContexts_3.next(); !sheetContexts_3_1.done; sheetContexts_3_1 = sheetContexts_3.next()) {
809
+ var context = sheetContexts_3_1.value;
810
+ var inlineRanges = this.toArray(get(context.node, "table:database-range") ||
811
+ get(context.node, "database-range"));
812
+ try {
813
+ for (var inlineRanges_2 = (e_16 = void 0, __values(inlineRanges)), inlineRanges_2_1 = inlineRanges_2.next(); !inlineRanges_2_1.done; inlineRanges_2_1 = inlineRanges_2.next()) {
814
+ var node = inlineRanges_2_1.value;
815
+ processNode(node, context);
816
+ }
817
+ }
818
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
819
+ finally {
820
+ try {
821
+ if (inlineRanges_2_1 && !inlineRanges_2_1.done && (_c = inlineRanges_2.return)) _c.call(inlineRanges_2);
822
+ }
823
+ finally { if (e_16) throw e_16.error; }
824
+ }
825
+ }
826
+ }
827
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
828
+ finally {
829
+ try {
830
+ if (sheetContexts_3_1 && !sheetContexts_3_1.done && (_b = sheetContexts_3.return)) _b.call(sheetContexts_3);
831
+ }
832
+ finally { if (e_15) throw e_15.error; }
833
+ }
834
+ return filters;
835
+ };
836
+ OdsPlugin.prototype.convertFilterNodeToSpecs = function (filterNode) {
837
+ var e_17, _a, e_18, _b;
838
+ var _this = this;
839
+ var specMap = new Map();
840
+ var addConditions = function (container) {
841
+ var e_19, _a;
842
+ var conditions = _this.toArray(get(container, "table:filter-condition") ||
843
+ get(container, "filter-condition"));
844
+ try {
845
+ for (var conditions_1 = __values(conditions), conditions_1_1 = conditions_1.next(); !conditions_1_1.done; conditions_1_1 = conditions_1.next()) {
846
+ var condition = conditions_1_1.value;
847
+ _this.applyFilterCondition(condition, specMap);
848
+ }
849
+ }
850
+ catch (e_19_1) { e_19 = { error: e_19_1 }; }
851
+ finally {
852
+ try {
853
+ if (conditions_1_1 && !conditions_1_1.done && (_a = conditions_1.return)) _a.call(conditions_1);
854
+ }
855
+ finally { if (e_19) throw e_19.error; }
856
+ }
857
+ };
858
+ addConditions(filterNode);
859
+ var andNodes = this.toArray(get(filterNode, "table:filter-and") || get(filterNode, "filter-and"));
860
+ try {
861
+ for (var andNodes_1 = __values(andNodes), andNodes_1_1 = andNodes_1.next(); !andNodes_1_1.done; andNodes_1_1 = andNodes_1.next()) {
862
+ var node = andNodes_1_1.value;
863
+ addConditions(node);
864
+ }
865
+ }
866
+ catch (e_17_1) { e_17 = { error: e_17_1 }; }
867
+ finally {
868
+ try {
869
+ if (andNodes_1_1 && !andNodes_1_1.done && (_a = andNodes_1.return)) _a.call(andNodes_1);
870
+ }
871
+ finally { if (e_17) throw e_17.error; }
872
+ }
873
+ var orNodes = this.toArray(get(filterNode, "table:filter-or") || get(filterNode, "filter-or"));
874
+ try {
875
+ for (var orNodes_1 = __values(orNodes), orNodes_1_1 = orNodes_1.next(); !orNodes_1_1.done; orNodes_1_1 = orNodes_1.next()) {
876
+ var node = orNodes_1_1.value;
877
+ addConditions(node);
878
+ }
879
+ }
880
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
881
+ finally {
882
+ try {
883
+ if (orNodes_1_1 && !orNodes_1_1.done && (_b = orNodes_1.return)) _b.call(orNodes_1);
884
+ }
885
+ finally { if (e_18) throw e_18.error; }
886
+ }
887
+ return Array.from(specMap.values()).sort(function (a, b) { return a.columnIndex - b.columnIndex; });
888
+ };
889
+ OdsPlugin.prototype.applyFilterCondition = function (node, specMap) {
890
+ var _a, _b, _c, _d;
891
+ var attrs = this.getAttributes(node);
892
+ if (!attrs)
893
+ return;
894
+ var field = attrs["@_table:field-number"] ||
895
+ attrs["@_field-number"] ||
896
+ attrs["@_table:column-number"] ||
897
+ attrs["@_column-number"];
898
+ if (field === undefined)
899
+ return;
900
+ var columnIndex = parseInt(field, 10);
901
+ if (isNaN(columnIndex))
902
+ return;
903
+ var operator = String((_b = (_a = attrs["@_table:operator"]) !== null && _a !== void 0 ? _a : attrs["@_operator"]) !== null && _b !== void 0 ? _b : "=");
904
+ var value = (_c = attrs["@_table:value"]) !== null && _c !== void 0 ? _c : attrs["@_value"];
905
+ var value2 = (_d = attrs["@_table:value2"]) !== null && _d !== void 0 ? _d : attrs["@_value2"];
906
+ var spec = specMap.get(columnIndex);
907
+ if (!spec) {
908
+ spec = {
909
+ columnIndex: columnIndex,
910
+ filterCriteria: {},
911
+ };
912
+ specMap.set(columnIndex, spec);
913
+ }
914
+ // A non-"=" operator is a CONDITION filter (greater-than / contains /
915
+ // between / blank / …). Map it back to filterCriteria.condition so it
916
+ // survives the round-trip instead of being flattened into a value list.
917
+ var conditionType = ODS_OPERATOR_TO_CONDITION[operator];
918
+ if (conditionType) {
919
+ var conditionValues = [];
920
+ if (value !== undefined) {
921
+ conditionValues.push({ userEnteredValue: String(value) });
922
+ }
923
+ if (value2 !== undefined) {
924
+ conditionValues.push({ userEnteredValue: String(value2) });
925
+ }
926
+ spec.filterCriteria.condition = {
927
+ type: conditionType,
928
+ values: conditionValues,
929
+ };
930
+ return;
931
+ }
932
+ // operator "=" (or unknown) -> value-list entry.
933
+ if (value === undefined)
934
+ return;
935
+ if (!spec.filterCriteria.visibleValues) {
936
+ spec.filterCriteria.visibleValues = [];
937
+ }
938
+ spec.filterCriteria.visibleValues.push(String(value));
939
+ };
940
+ OdsPlugin.prototype.extractTextContent = function (node) {
941
+ var _this = this;
942
+ if (node === null || node === undefined)
943
+ return "";
944
+ var primitiveTypes = ["string", "number", "boolean"];
945
+ if (primitiveTypes.includes(typeof node)) {
946
+ return String(node);
947
+ }
948
+ if (Array.isArray(node)) {
949
+ return node.map(function (entry) { return _this.extractTextContent(entry); }).join("");
950
+ }
951
+ var result = "";
952
+ if (node["text:s"]) {
953
+ result += this.extractSpaceNodes(node["text:s"], node);
954
+ }
955
+ if (node["text:line-break"]) {
956
+ var breaks = this.toArray(node["text:line-break"]);
957
+ result += "\n".repeat(breaks.length || 1);
958
+ }
959
+ if (node["text:span"]) {
960
+ result += this.extractTextContent(node["text:span"]);
961
+ }
962
+ if (node["text:a"]) {
963
+ result += this.extractTextContent(node["text:a"]);
964
+ }
965
+ if (node["text:p"]) {
966
+ result += this.extractTextContent(node["text:p"]);
967
+ }
968
+ if (node["#text"] !== undefined && node["#text"] !== null) {
969
+ var textValue = node["#text"];
970
+ if (typeof textValue === "string" ||
971
+ typeof textValue === "number" ||
972
+ typeof textValue === "boolean") {
973
+ result += String(textValue);
974
+ }
975
+ }
976
+ return result;
977
+ };
978
+ OdsPlugin.prototype.extractTextContentWithRuns = function (node) {
979
+ var _this = this;
980
+ var text = "";
981
+ var runs = [];
982
+ var hasFormat = function (format) {
983
+ return !!format && Object.keys(format).length > 0;
984
+ };
985
+ var mergeFormat = function (base, next) { return (base || next ? __assign(__assign({}, (base !== null && base !== void 0 ? base : {})), (next !== null && next !== void 0 ? next : {})) : undefined); };
986
+ var appendText = function (value) {
987
+ if (typeof value === "string" ||
988
+ typeof value === "number" ||
989
+ typeof value === "boolean") {
990
+ text += String(value);
991
+ }
992
+ };
993
+ var walk = function (value, inherited) {
994
+ var e_20, _a;
995
+ var _b;
996
+ if (value === null || value === undefined)
997
+ return;
998
+ if (Array.isArray(value)) {
999
+ value.forEach(function (entry) { return walk(entry, inherited); });
1000
+ return;
1001
+ }
1002
+ if (typeof value === "string" ||
1003
+ typeof value === "number" ||
1004
+ typeof value === "boolean") {
1005
+ appendText(value);
1006
+ return;
1007
+ }
1008
+ if (value["text:s"]) {
1009
+ text += _this.extractSpaceNodes(value["text:s"], value);
1010
+ }
1011
+ if (value["text:line-break"]) {
1012
+ var breaks = _this.toArray(value["text:line-break"]);
1013
+ text += "\n".repeat(breaks.length || 1);
1014
+ }
1015
+ if (value["#text"] !== undefined && value["#text"] !== null) {
1016
+ appendText(value["#text"]);
1017
+ }
1018
+ var spanNodes = value["text:span"];
1019
+ if (spanNodes) {
1020
+ try {
1021
+ for (var _c = __values(_this.toArray(spanNodes)), _d = _c.next(); !_d.done; _d = _c.next()) {
1022
+ var span = _d.value;
1023
+ var attrs = (_b = _this.getAttributes(span)) !== null && _b !== void 0 ? _b : {};
1024
+ var styleName = attrs["@_text:style-name"] || attrs["@_style-name"];
1025
+ var spanFormat = mergeFormat(inherited, _this.odsStyles.getTextFormat(styleName));
1026
+ var startIndex = text.length;
1027
+ walk(span, spanFormat);
1028
+ if (hasFormat(spanFormat) && text.length > startIndex) {
1029
+ var format = spanFormat;
1030
+ runs.push({
1031
+ startIndex: startIndex,
1032
+ endIndex: text.length,
1033
+ format: format,
1034
+ nodeType: "text",
1035
+ });
1036
+ }
1037
+ }
1038
+ }
1039
+ catch (e_20_1) { e_20 = { error: e_20_1 }; }
1040
+ finally {
1041
+ try {
1042
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
1043
+ }
1044
+ finally { if (e_20) throw e_20.error; }
1045
+ }
1046
+ }
1047
+ if (value["text:a"]) {
1048
+ walk(value["text:a"], inherited);
1049
+ }
1050
+ if (value["text:p"]) {
1051
+ walk(value["text:p"], inherited);
1052
+ }
1053
+ };
1054
+ walk(node);
1055
+ return { text: text, runs: runs };
1056
+ };
1057
+ OdsPlugin.prototype.normalizeInternalHyperlinkLocation = function (href) {
1058
+ var location = href.trim();
1059
+ if (location.startsWith("#")) {
1060
+ location = location.slice(1);
1061
+ }
1062
+ else if (location.startsWith("sheet://")) {
1063
+ location = location.slice("sheet://".length);
1064
+ }
1065
+ else if (location.startsWith("vnd.sun.star.sheet:")) {
1066
+ location = location.slice("vnd.sun.star.sheet:".length);
1067
+ }
1068
+ if (location.includes("!")) {
1069
+ return location;
1070
+ }
1071
+ var match = location.match(/^(.*)\.([A-Za-z]+[0-9].*)$/);
1072
+ if (match) {
1073
+ return "".concat(match[1], "!").concat(match[2]);
1074
+ }
1075
+ return location;
1076
+ };
1077
+ OdsPlugin.prototype.extractHyperlinkValue = function (node) {
1078
+ var e_21, _a, e_22, _b, e_23, _c;
1079
+ if (node === null || node === undefined)
1080
+ return undefined;
1081
+ if (Array.isArray(node)) {
1082
+ try {
1083
+ for (var node_1 = __values(node), node_1_1 = node_1.next(); !node_1_1.done; node_1_1 = node_1.next()) {
1084
+ var entry = node_1_1.value;
1085
+ var result = this.extractHyperlinkValue(entry);
1086
+ if (result)
1087
+ return result;
1088
+ }
1089
+ }
1090
+ catch (e_21_1) { e_21 = { error: e_21_1 }; }
1091
+ finally {
1092
+ try {
1093
+ if (node_1_1 && !node_1_1.done && (_a = node_1.return)) _a.call(node_1);
1094
+ }
1095
+ finally { if (e_21) throw e_21.error; }
1096
+ }
1097
+ return undefined;
1098
+ }
1099
+ if (typeof node !== "object") {
1100
+ return undefined;
1101
+ }
1102
+ if (node["text:a"]) {
1103
+ var anchors = Array.isArray(node["text:a"])
1104
+ ? node["text:a"]
1105
+ : [node["text:a"]];
1106
+ try {
1107
+ for (var anchors_1 = __values(anchors), anchors_1_1 = anchors_1.next(); !anchors_1_1.done; anchors_1_1 = anchors_1.next()) {
1108
+ var anchor = anchors_1_1.value;
1109
+ var attrs = (anchor === null || anchor === void 0 ? void 0 : anchor[":@"]) || anchor;
1110
+ var href = (attrs === null || attrs === void 0 ? void 0 : attrs["@_xlink:href"]) || (attrs === null || attrs === void 0 ? void 0 : attrs["@_href"]);
1111
+ if (!href) {
1112
+ continue;
1113
+ }
1114
+ var display = this.extractTextContent(anchor);
1115
+ if (href.startsWith("#") ||
1116
+ href.startsWith("sheet://") ||
1117
+ href.startsWith("vnd.sun.star.sheet:")) {
1118
+ return __assign({ kind: "internal", location: this.normalizeInternalHyperlinkLocation(href) }, (display ? { display: display } : {}));
1119
+ }
1120
+ return __assign({ kind: "external", url: href }, (display ? { display: display } : {}));
1121
+ }
1122
+ }
1123
+ catch (e_22_1) { e_22 = { error: e_22_1 }; }
1124
+ finally {
1125
+ try {
1126
+ if (anchors_1_1 && !anchors_1_1.done && (_b = anchors_1.return)) _b.call(anchors_1);
1127
+ }
1128
+ finally { if (e_22) throw e_22.error; }
1129
+ }
1130
+ }
1131
+ try {
1132
+ for (var _d = __values(Object.values(node)), _e = _d.next(); !_e.done; _e = _d.next()) {
1133
+ var value = _e.value;
1134
+ var result = this.extractHyperlinkValue(value);
1135
+ if (result)
1136
+ return result;
1137
+ }
1138
+ }
1139
+ catch (e_23_1) { e_23 = { error: e_23_1 }; }
1140
+ finally {
1141
+ try {
1142
+ if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
1143
+ }
1144
+ finally { if (e_23) throw e_23.error; }
1145
+ }
1146
+ return undefined;
1147
+ };
1148
+ OdsPlugin.prototype.extractSpaceNodes = function (node, fallback) {
1149
+ var _this = this;
1150
+ var nodes = this.toArray(node);
1151
+ if (!nodes.length) {
1152
+ var fallbackAttrs = this.getAttributes(fallback);
1153
+ if (!fallbackAttrs)
1154
+ return " ";
1155
+ var repeat = this.getSpaceRepeatCount(fallbackAttrs);
1156
+ return " ".repeat(repeat);
1157
+ }
1158
+ return nodes
1159
+ .map(function (entry) {
1160
+ var attrs = _this.getAttributes(entry);
1161
+ var repeat = _this.getSpaceRepeatCount(attrs);
1162
+ return " ".repeat(repeat);
1163
+ })
1164
+ .join("");
1165
+ };
1166
+ OdsPlugin.prototype.getSpaceRepeatCount = function (attrs) {
1167
+ if (!attrs)
1168
+ return 1;
1169
+ var rawCount = attrs["@_text:c"] || attrs["@_c"] || attrs["@_text:count"];
1170
+ if (rawCount === undefined) {
1171
+ return 1;
1172
+ }
1173
+ var count = parseInt(rawCount, 10);
1174
+ if (isNaN(count) || count < 0) {
1175
+ return 1;
1176
+ }
1177
+ return Math.max(1, count + 1);
1178
+ };
1179
+ OdsPlugin.prototype.extractEmbeddedObjects = function (sheetContexts, sheetNameMap) {
1180
+ var e_24, _a, e_25, _b, e_26, _c;
1181
+ var _d;
1182
+ var tables = this.getOrderedTableWrappers();
1183
+ if (!tables.length || !sheetContexts.length) {
1184
+ return { drawings: [], charts: [] };
1185
+ }
1186
+ var drawings = [];
1187
+ var charts = [];
1188
+ var chartAnchors = new Set();
1189
+ var imageCache = new Map();
1190
+ var tableCount = Math.min(tables.length, sheetContexts.length);
1191
+ for (var sheetIndex = 0; sheetIndex < tableCount; sheetIndex++) {
1192
+ var tableWrapper = tables[sheetIndex];
1193
+ var tableNameKey = tableWrapper["table:table"]
1194
+ ? "table:table"
1195
+ : "table";
1196
+ var tableChildren = tableWrapper[tableNameKey];
1197
+ if (!tableChildren)
1198
+ continue;
1199
+ var rows = tableChildren.filter(function (child) { return child["table:table-row"] || child["table-row"]; });
1200
+ var currentRowIndex = 1;
1201
+ var sheetContext = sheetContexts[sheetIndex];
1202
+ var sheetId = (_d = sheetContext === null || sheetContext === void 0 ? void 0 : sheetContext.sheetId) !== null && _d !== void 0 ? _d : sheetIndex + 1;
1203
+ try {
1204
+ for (var rows_1 = (e_24 = void 0, __values(rows)), rows_1_1 = rows_1.next(); !rows_1_1.done; rows_1_1 = rows_1.next()) {
1205
+ var rowWrapper = rows_1_1.value;
1206
+ var rowNameKey = rowWrapper["table:table-row"]
1207
+ ? "table:table-row"
1208
+ : "table-row";
1209
+ var rowChildren = rowWrapper[rowNameKey];
1210
+ var rowAttrs = rowWrapper[":@"] || {};
1211
+ var rowsRepeated = parseInt(rowAttrs["@_table:number-rows-repeated"] ||
1212
+ rowAttrs["@_number-rows-repeated"] ||
1213
+ "1", 10);
1214
+ var effectiveRepeats = Math.min(rowsRepeated, 10000);
1215
+ for (var repeat = 0; repeat < effectiveRepeats; repeat++) {
1216
+ var columnIndex = 1;
1217
+ var normalizedRowChildren = rowChildren
1218
+ ? this.expandRowCells(rowChildren)
1219
+ : null;
1220
+ if (normalizedRowChildren) {
1221
+ try {
1222
+ for (var normalizedRowChildren_1 = (e_25 = void 0, __values(normalizedRowChildren)), normalizedRowChildren_1_1 = normalizedRowChildren_1.next(); !normalizedRowChildren_1_1.done; normalizedRowChildren_1_1 = normalizedRowChildren_1.next()) {
1223
+ var cellWrapper = normalizedRowChildren_1_1.value;
1224
+ var isCell = !!cellWrapper["table:table-cell"];
1225
+ var isCovered = !!cellWrapper["table:covered-table-cell"];
1226
+ if (!isCell && !isCovered)
1227
+ continue;
1228
+ var cellKey = isCell
1229
+ ? "table:table-cell"
1230
+ : "table:covered-table-cell";
1231
+ var cellChildren = cellWrapper[cellKey];
1232
+ var cellAttrs = cellWrapper[":@"] || {};
1233
+ var colsRepeated = parseInt(cellAttrs["@_table:number-columns-repeated"] ||
1234
+ cellAttrs["@_number-columns-repeated"] ||
1235
+ "1", 10);
1236
+ if (isCovered) {
1237
+ columnIndex += colsRepeated;
1238
+ continue;
1239
+ }
1240
+ var frameNodes = this.collectFrameNodes(cellChildren, cellAttrs);
1241
+ if (frameNodes.length) {
1242
+ for (var c = 0; c < colsRepeated; c++) {
1243
+ var anchorColumnIndex = columnIndex + c;
1244
+ try {
1245
+ for (var frameNodes_1 = (e_26 = void 0, __values(frameNodes)), frameNodes_1_1 = frameNodes_1.next(); !frameNodes_1_1.done; frameNodes_1_1 = frameNodes_1.next()) {
1246
+ var _e = frameNodes_1_1.value, frame = _e.frame, frameCellAttrs = _e.cellAttrs;
1247
+ var chart = this.convertFrameToEmbeddedChart(frame, sheetContext, sheetId, currentRowIndex, anchorColumnIndex, sheetNameMap, frameCellAttrs);
1248
+ if (chart) {
1249
+ chartAnchors.add(this.buildAnchorKey(sheetId, currentRowIndex, anchorColumnIndex));
1250
+ charts.push(chart);
1251
+ continue;
1252
+ }
1253
+ var anchorKey = this.buildAnchorKey(sheetId, currentRowIndex, anchorColumnIndex);
1254
+ if (chartAnchors.has(anchorKey)) {
1255
+ continue;
1256
+ }
1257
+ var embedded = this.convertFrameToEmbeddedObject(frame, sheetId, currentRowIndex, anchorColumnIndex, imageCache, frameCellAttrs);
1258
+ if (embedded) {
1259
+ drawings.push(embedded);
1260
+ }
1261
+ }
1262
+ }
1263
+ catch (e_26_1) { e_26 = { error: e_26_1 }; }
1264
+ finally {
1265
+ try {
1266
+ if (frameNodes_1_1 && !frameNodes_1_1.done && (_c = frameNodes_1.return)) _c.call(frameNodes_1);
1267
+ }
1268
+ finally { if (e_26) throw e_26.error; }
1269
+ }
1270
+ }
1271
+ }
1272
+ columnIndex += colsRepeated;
1273
+ }
1274
+ }
1275
+ catch (e_25_1) { e_25 = { error: e_25_1 }; }
1276
+ finally {
1277
+ try {
1278
+ if (normalizedRowChildren_1_1 && !normalizedRowChildren_1_1.done && (_b = normalizedRowChildren_1.return)) _b.call(normalizedRowChildren_1);
1279
+ }
1280
+ finally { if (e_25) throw e_25.error; }
1281
+ }
1282
+ }
1283
+ currentRowIndex++;
1284
+ }
1285
+ }
1286
+ }
1287
+ catch (e_24_1) { e_24 = { error: e_24_1 }; }
1288
+ finally {
1289
+ try {
1290
+ if (rows_1_1 && !rows_1_1.done && (_a = rows_1.return)) _a.call(rows_1);
1291
+ }
1292
+ finally { if (e_24) throw e_24.error; }
1293
+ }
1294
+ }
1295
+ return { drawings: drawings, charts: charts };
1296
+ };
1297
+ OdsPlugin.prototype.buildAnchorKey = function (sheetId, rowIndex, columnIndex) {
1298
+ return "".concat(sheetId, ":").concat(rowIndex, ":").concat(columnIndex);
1299
+ };
1300
+ /**
1301
+ * Walk the ordered content XML for each table and assign outline
1302
+ * level + collapsed/hiddenByGroup state on `rowMetadata` and
1303
+ * `columnMetadata`. ODS encodes outline as `<table:table-row-group>`
1304
+ * / `<table:table-column-group>` wrappers (nest for level > 1); a
1305
+ * group is collapsed when its `table:display="false"`. Cells inside
1306
+ * a collapsed wrapper get `hiddenByGroup`; the summary cell (per
1307
+ * `outlinePr.summaryBelow`/`summaryRight`, default true = below /
1308
+ * right of the group) gets `collapsed = true`.
1309
+ */
1310
+ OdsPlugin.prototype.extractOutlineGroups = function (sheets) {
1311
+ var _a, _b, _c, _d, _e, _f;
1312
+ if (!this.contentXmlOrdered || !sheets.length)
1313
+ return;
1314
+ var docContent = ((_a = this.contentXmlOrdered[0]) === null || _a === void 0 ? void 0 : _a["office:document-content"]) ||
1315
+ ((_b = this.contentXmlOrdered[0]) === null || _b === void 0 ? void 0 : _b["document-content"]);
1316
+ if (!docContent)
1317
+ return;
1318
+ var body = getChildren(docContent, "office:body") || getChildren(docContent, "body");
1319
+ if (!body)
1320
+ return;
1321
+ var spreadsheet = getChildren(body, "office:spreadsheet") ||
1322
+ getChildren(body, "spreadsheet");
1323
+ if (!spreadsheet)
1324
+ return;
1325
+ var tables = spreadsheet.filter(function (child) { return child["table:table"] || child["table"]; });
1326
+ var tableCount = Math.min(tables.length, sheets.length);
1327
+ var _loop_1 = function (sheetIndex) {
1328
+ var tableWrapper = tables[sheetIndex];
1329
+ var tableNameKey = tableWrapper["table:table"]
1330
+ ? "table:table"
1331
+ : "table";
1332
+ var tableChildren = tableWrapper[tableNameKey];
1333
+ if (!Array.isArray(tableChildren))
1334
+ return "continue";
1335
+ var sheet = sheets[sheetIndex];
1336
+ if (!sheet)
1337
+ return "continue";
1338
+ var summaryBelow = ((_c = sheet.outlinePr) === null || _c === void 0 ? void 0 : _c.summaryBelow) !== false;
1339
+ var summaryRight = ((_d = sheet.outlinePr) === null || _d === void 0 ? void 0 : _d.summaryRight) !== false;
1340
+ var rowMetadata = ((_e = sheet.rowMetadata) !== null && _e !== void 0 ? _e : []);
1341
+ var columnMetadata = ((_f = sheet.columnMetadata) !== null && _f !== void 0 ? _f : []);
1342
+ var setMeta = function (meta, index, patch) {
1343
+ if (!meta[index])
1344
+ meta[index] = {};
1345
+ Object.assign(meta[index], patch);
1346
+ };
1347
+ var walk = function (nodes, itemTag, groupTag, meta, repeatAttrs, summaryAfter) {
1348
+ var cursor = 1;
1349
+ var openStack = [];
1350
+ var collapsedDepth = function () { return openStack.some(function (g) { return g.collapsed; }); };
1351
+ var currentLevel = function () { return openStack.length; };
1352
+ var visit = function (children) {
1353
+ var e_27, _a, e_28, _b;
1354
+ var _c;
1355
+ try {
1356
+ for (var children_1 = (e_27 = void 0, __values(children)), children_1_1 = children_1.next(); !children_1_1.done; children_1_1 = children_1.next()) {
1357
+ var child = children_1_1.value;
1358
+ if (!child)
1359
+ continue;
1360
+ if (child[groupTag]) {
1361
+ var attrs = child[":@"] || {};
1362
+ var display = (_c = attrs["@_table:display"]) !== null && _c !== void 0 ? _c : attrs["@_display"];
1363
+ var collapsed = display === "false" || display === false;
1364
+ var startIndex = cursor;
1365
+ openStack.push({
1366
+ level: openStack.length + 1,
1367
+ startIndex: startIndex,
1368
+ collapsed: collapsed,
1369
+ });
1370
+ visit(child[groupTag] || []);
1371
+ var closing = openStack.pop();
1372
+ if (closing.collapsed) {
1373
+ var summaryIndex = summaryAfter
1374
+ ? cursor
1375
+ : closing.startIndex - 1;
1376
+ if (summaryIndex >= 1) {
1377
+ setMeta(meta, summaryIndex, { collapsed: true });
1378
+ }
1379
+ }
1380
+ }
1381
+ else if (child[itemTag]) {
1382
+ var attrs = child[":@"] || {};
1383
+ var repeat = 1;
1384
+ try {
1385
+ for (var repeatAttrs_1 = (e_28 = void 0, __values(repeatAttrs)), repeatAttrs_1_1 = repeatAttrs_1.next(); !repeatAttrs_1_1.done; repeatAttrs_1_1 = repeatAttrs_1.next()) {
1386
+ var attrName = repeatAttrs_1_1.value;
1387
+ var raw = attrs["@_".concat(attrName)];
1388
+ if (raw !== undefined) {
1389
+ repeat = Math.max(1, parseInt(String(raw), 10) || 1);
1390
+ break;
1391
+ }
1392
+ }
1393
+ }
1394
+ catch (e_28_1) { e_28 = { error: e_28_1 }; }
1395
+ finally {
1396
+ try {
1397
+ if (repeatAttrs_1_1 && !repeatAttrs_1_1.done && (_b = repeatAttrs_1.return)) _b.call(repeatAttrs_1);
1398
+ }
1399
+ finally { if (e_28) throw e_28.error; }
1400
+ }
1401
+ repeat = Math.min(repeat, 10000);
1402
+ var level = currentLevel();
1403
+ var hidden = collapsedDepth();
1404
+ if (level > 0 || hidden) {
1405
+ for (var r = 0; r < repeat; r++) {
1406
+ var patch = {};
1407
+ if (level > 0)
1408
+ patch.outlineLevel = level;
1409
+ if (hidden)
1410
+ patch.hiddenByGroup = true;
1411
+ setMeta(meta, cursor + r, patch);
1412
+ }
1413
+ }
1414
+ cursor += repeat;
1415
+ }
1416
+ }
1417
+ }
1418
+ catch (e_27_1) { e_27 = { error: e_27_1 }; }
1419
+ finally {
1420
+ try {
1421
+ if (children_1_1 && !children_1_1.done && (_a = children_1.return)) _a.call(children_1);
1422
+ }
1423
+ finally { if (e_27) throw e_27.error; }
1424
+ }
1425
+ };
1426
+ visit(nodes);
1427
+ };
1428
+ walk(tableChildren, "table:table-column", "table:table-column-group", columnMetadata, ["table:number-columns-repeated", "number-columns-repeated"], summaryRight);
1429
+ walk(tableChildren, "table:table-row", "table:table-row-group", rowMetadata, ["table:number-rows-repeated", "number-rows-repeated"], summaryBelow);
1430
+ if (columnMetadata.length > 0)
1431
+ sheet.columnMetadata = columnMetadata;
1432
+ if (rowMetadata.length > 0)
1433
+ sheet.rowMetadata = rowMetadata;
1434
+ };
1435
+ for (var sheetIndex = 0; sheetIndex < tableCount; sheetIndex++) {
1436
+ _loop_1(sheetIndex);
1437
+ }
1438
+ };
1439
+ OdsPlugin.prototype.extractMerges = function (sheetContexts) {
1440
+ var e_29, _a, e_30, _b;
1441
+ var _c, _d, _e, _f;
1442
+ var merges = new Map();
1443
+ if (!this.contentXmlOrdered || !sheetContexts.length) {
1444
+ return merges;
1445
+ }
1446
+ var docContent = ((_c = this.contentXmlOrdered[0]) === null || _c === void 0 ? void 0 : _c["office:document-content"]) ||
1447
+ ((_d = this.contentXmlOrdered[0]) === null || _d === void 0 ? void 0 : _d["document-content"]);
1448
+ if (!docContent)
1449
+ return merges;
1450
+ var body = getChildren(docContent, "office:body") || getChildren(docContent, "body");
1451
+ if (!body)
1452
+ return merges;
1453
+ var spreadsheet = getChildren(body, "office:spreadsheet") ||
1454
+ getChildren(body, "spreadsheet");
1455
+ if (!spreadsheet)
1456
+ return merges;
1457
+ var tables = spreadsheet.filter(function (child) { return child["table:table"] || child["table"]; });
1458
+ var tableCount = Math.min(tables.length, sheetContexts.length);
1459
+ var seen = new Set();
1460
+ for (var sheetIndex = 0; sheetIndex < tableCount; sheetIndex++) {
1461
+ var tableWrapper = tables[sheetIndex];
1462
+ var tableNameKey = tableWrapper["table:table"]
1463
+ ? "table:table"
1464
+ : "table";
1465
+ var tableChildren = tableWrapper[tableNameKey];
1466
+ if (!tableChildren)
1467
+ continue;
1468
+ var rows = tableChildren.filter(function (child) { return child["table:table-row"] || child["table-row"]; });
1469
+ var sheetId = (_f = (_e = sheetContexts[sheetIndex]) === null || _e === void 0 ? void 0 : _e.sheetId) !== null && _f !== void 0 ? _f : sheetIndex + 1;
1470
+ var currentRowIndex = 1;
1471
+ try {
1472
+ for (var rows_2 = (e_29 = void 0, __values(rows)), rows_2_1 = rows_2.next(); !rows_2_1.done; rows_2_1 = rows_2.next()) {
1473
+ var rowWrapper = rows_2_1.value;
1474
+ var rowNameKey = rowWrapper["table:table-row"]
1475
+ ? "table:table-row"
1476
+ : "table-row";
1477
+ var rowChildren = rowWrapper[rowNameKey];
1478
+ var rowAttrs = rowWrapper[":@"] || {};
1479
+ var rowsRepeated = parseInt(rowAttrs["@_table:number-rows-repeated"] ||
1480
+ rowAttrs["@_number-rows-repeated"] ||
1481
+ "1", 10);
1482
+ var effectiveRepeats = Math.min(rowsRepeated, 10000);
1483
+ for (var repeat = 0; repeat < effectiveRepeats; repeat++) {
1484
+ var columnIndex = 1;
1485
+ if (rowChildren) {
1486
+ try {
1487
+ for (var rowChildren_1 = (e_30 = void 0, __values(rowChildren)), rowChildren_1_1 = rowChildren_1.next(); !rowChildren_1_1.done; rowChildren_1_1 = rowChildren_1.next()) {
1488
+ var cellWrapper = rowChildren_1_1.value;
1489
+ var isCell = !!cellWrapper["table:table-cell"];
1490
+ var isCovered = !!cellWrapper["table:covered-table-cell"];
1491
+ if (!isCell && !isCovered)
1492
+ continue;
1493
+ var cellKey = isCell
1494
+ ? "table:table-cell"
1495
+ : "table:covered-table-cell";
1496
+ var cellAttrs = cellWrapper[":@"] || {};
1497
+ var colsRepeated = parseInt(cellAttrs["@_table:number-columns-repeated"] ||
1498
+ cellAttrs["@_number-columns-repeated"] ||
1499
+ "1", 10);
1500
+ if (isCovered) {
1501
+ columnIndex += colsRepeated;
1502
+ continue;
1503
+ }
1504
+ var rowsSpannedRaw = parseInt(cellAttrs["@_table:number-rows-spanned"] ||
1505
+ cellAttrs["@_number-rows-spanned"] ||
1506
+ "1", 10);
1507
+ var colsSpannedRaw = parseInt(cellAttrs["@_table:number-columns-spanned"] ||
1508
+ cellAttrs["@_number-columns-spanned"] ||
1509
+ "1", 10);
1510
+ var rowsSpanned = Math.max(1, rowsSpannedRaw || 1);
1511
+ var colsSpanned = Math.max(1, colsSpannedRaw || 1);
1512
+ if (rowsSpanned > 1 || colsSpanned > 1) {
1513
+ for (var colOffset = 0; colOffset < colsRepeated; colOffset++) {
1514
+ var startColumnIndex = columnIndex + colOffset;
1515
+ var range = {
1516
+ sheetId: sheetId,
1517
+ startRowIndex: currentRowIndex,
1518
+ endRowIndex: currentRowIndex + rowsSpanned - 1,
1519
+ startColumnIndex: startColumnIndex,
1520
+ endColumnIndex: startColumnIndex + colsSpanned - 1,
1521
+ };
1522
+ var key = "".concat(range.sheetId, ":").concat(range.startRowIndex, ":").concat(range.endRowIndex, ":").concat(range.startColumnIndex, ":").concat(range.endColumnIndex);
1523
+ if (!seen.has(key)) {
1524
+ seen.add(key);
1525
+ if (!merges.has(sheetId)) {
1526
+ merges.set(sheetId, []);
1527
+ }
1528
+ merges.get(sheetId).push(range);
1529
+ }
1530
+ }
1531
+ }
1532
+ columnIndex += colsRepeated;
1533
+ }
1534
+ }
1535
+ catch (e_30_1) { e_30 = { error: e_30_1 }; }
1536
+ finally {
1537
+ try {
1538
+ if (rowChildren_1_1 && !rowChildren_1_1.done && (_b = rowChildren_1.return)) _b.call(rowChildren_1);
1539
+ }
1540
+ finally { if (e_30) throw e_30.error; }
1541
+ }
1542
+ }
1543
+ currentRowIndex++;
1544
+ }
1545
+ }
1546
+ }
1547
+ catch (e_29_1) { e_29 = { error: e_29_1 }; }
1548
+ finally {
1549
+ try {
1550
+ if (rows_2_1 && !rows_2_1.done && (_a = rows_2.return)) _a.call(rows_2);
1551
+ }
1552
+ finally { if (e_29) throw e_29.error; }
1553
+ }
1554
+ }
1555
+ return merges;
1556
+ };
1557
+ OdsPlugin.prototype.getOrderedTableWrappers = function () {
1558
+ var _a, _b;
1559
+ if (!this.contentXmlOrdered)
1560
+ return [];
1561
+ var docContent = ((_a = this.contentXmlOrdered[0]) === null || _a === void 0 ? void 0 : _a["office:document-content"]) ||
1562
+ ((_b = this.contentXmlOrdered[0]) === null || _b === void 0 ? void 0 : _b["document-content"]);
1563
+ if (!docContent)
1564
+ return [];
1565
+ var body = getChildren(docContent, "office:body") || getChildren(docContent, "body");
1566
+ if (!body)
1567
+ return [];
1568
+ var spreadsheet = getChildren(body, "office:spreadsheet") ||
1569
+ getChildren(body, "spreadsheet");
1570
+ if (!spreadsheet)
1571
+ return [];
1572
+ return spreadsheet.filter(function (child) { return child["table:table"] || child["table"]; });
1573
+ };
1574
+ OdsPlugin.prototype.findOrderedTableWrapperForContext = function (sheetContext, sheetId) {
1575
+ var e_31, _a;
1576
+ var tables = this.getOrderedTableWrappers();
1577
+ if (!tables.length)
1578
+ return undefined;
1579
+ if (sheetContext === null || sheetContext === void 0 ? void 0 : sheetContext.name) {
1580
+ var normalizedTarget = this.normalizeSheetName(sheetContext.name);
1581
+ try {
1582
+ for (var tables_1 = __values(tables), tables_1_1 = tables_1.next(); !tables_1_1.done; tables_1_1 = tables_1.next()) {
1583
+ var tableWrapper = tables_1_1.value;
1584
+ var attrs = tableWrapper[":@"] || {};
1585
+ var rawName = attrs["@_table:name"] ||
1586
+ attrs["@_name"] ||
1587
+ attrs["@_table:display-name"];
1588
+ var normalizedCandidate = this.normalizeSheetName(rawName);
1589
+ if ((rawName && rawName === sheetContext.name) ||
1590
+ (normalizedCandidate &&
1591
+ normalizedTarget &&
1592
+ normalizedCandidate === normalizedTarget)) {
1593
+ return tableWrapper;
1594
+ }
1595
+ }
1596
+ }
1597
+ catch (e_31_1) { e_31 = { error: e_31_1 }; }
1598
+ finally {
1599
+ try {
1600
+ if (tables_1_1 && !tables_1_1.done && (_a = tables_1.return)) _a.call(tables_1);
1601
+ }
1602
+ finally { if (e_31) throw e_31.error; }
1603
+ }
1604
+ }
1605
+ if (sheetId && tables[sheetId - 1]) {
1606
+ return tables[sheetId - 1];
1607
+ }
1608
+ return tables[0];
1609
+ };
1610
+ OdsPlugin.prototype.extractTableColumnsFromHeader = function (range, sheetContext, useHeaderRow) {
1611
+ var e_32, _a, e_33, _b;
1612
+ var _c, _d, _e;
1613
+ if (useHeaderRow === void 0) { useHeaderRow = true; }
1614
+ var startColumn = Math.max(1, (_c = range.startColumnIndex) !== null && _c !== void 0 ? _c : 1);
1615
+ var endColumn = Math.max(startColumn, (_d = range.endColumnIndex) !== null && _d !== void 0 ? _d : startColumn);
1616
+ var columnCount = Math.max(1, endColumn - startColumn + 1);
1617
+ var buildDefaultColumns = function () {
1618
+ return Array.from({ length: columnCount }, function (_, index) { return ({
1619
+ name: "Column ".concat(index + 1),
1620
+ }); });
1621
+ };
1622
+ if (!useHeaderRow) {
1623
+ return buildDefaultColumns();
1624
+ }
1625
+ var tableWrapper = this.findOrderedTableWrapperForContext(sheetContext, range.sheetId);
1626
+ if (!tableWrapper) {
1627
+ return buildDefaultColumns();
1628
+ }
1629
+ var tableNameKey = tableWrapper["table:table"] ? "table:table" : "table";
1630
+ var tableChildren = tableWrapper[tableNameKey];
1631
+ if (!tableChildren) {
1632
+ return buildDefaultColumns();
1633
+ }
1634
+ var rows = tableChildren.filter(function (child) { return child["table:table-row"] || child["table-row"]; });
1635
+ if (!rows.length) {
1636
+ return buildDefaultColumns();
1637
+ }
1638
+ var headerRowIndex = Math.max(1, (_e = range.startRowIndex) !== null && _e !== void 0 ? _e : 1);
1639
+ var headerValues = [];
1640
+ var currentRowIndex = 1;
1641
+ try {
1642
+ outer: for (var rows_3 = __values(rows), rows_3_1 = rows_3.next(); !rows_3_1.done; rows_3_1 = rows_3.next()) {
1643
+ var rowWrapper = rows_3_1.value;
1644
+ var rowNameKey = rowWrapper["table:table-row"]
1645
+ ? "table:table-row"
1646
+ : "table-row";
1647
+ var rowChildren = rowWrapper[rowNameKey];
1648
+ var rowAttrs = rowWrapper[":@"] || {};
1649
+ var rowsRepeated = parseInt(rowAttrs["@_table:number-rows-repeated"] ||
1650
+ rowAttrs["@_number-rows-repeated"] ||
1651
+ "1", 10);
1652
+ var effectiveRepeats = Math.min(rowsRepeated, 10000);
1653
+ var normalizedRowChildren = rowChildren
1654
+ ? this.expandRowCells(rowChildren)
1655
+ : null;
1656
+ for (var repeat = 0; repeat < effectiveRepeats; repeat++) {
1657
+ if (currentRowIndex === headerRowIndex) {
1658
+ var columnIndex = 1;
1659
+ if (normalizedRowChildren) {
1660
+ try {
1661
+ for (var normalizedRowChildren_2 = (e_33 = void 0, __values(normalizedRowChildren)), normalizedRowChildren_2_1 = normalizedRowChildren_2.next(); !normalizedRowChildren_2_1.done; normalizedRowChildren_2_1 = normalizedRowChildren_2.next()) {
1662
+ var cellWrapper = normalizedRowChildren_2_1.value;
1663
+ var isCell = !!cellWrapper["table:table-cell"];
1664
+ var isCovered = !!cellWrapper["table:covered-table-cell"];
1665
+ if (!isCell && !isCovered) {
1666
+ continue;
1667
+ }
1668
+ var cellNameKey = isCell
1669
+ ? "table:table-cell"
1670
+ : "table:covered-table-cell";
1671
+ var cellChildren = cellWrapper[cellNameKey];
1672
+ var cellAttrs = cellWrapper[":@"] || {};
1673
+ var colsRepeated = parseInt(cellAttrs["@_table:number-columns-repeated"] ||
1674
+ cellAttrs["@_number-columns-repeated"] ||
1675
+ "1", 10);
1676
+ if (isCovered) {
1677
+ columnIndex += colsRepeated;
1678
+ continue;
1679
+ }
1680
+ var displayValue = "";
1681
+ if (cellChildren) {
1682
+ var textWrapper = findChild(cellChildren, "text:p") ||
1683
+ findChild(cellChildren, "p");
1684
+ if (textWrapper) {
1685
+ var key = textWrapper["text:p"] ? "text:p" : "p";
1686
+ displayValue = this.extractTextContent(textWrapper[key]);
1687
+ }
1688
+ else {
1689
+ displayValue = this.extractTextContent(cellChildren);
1690
+ }
1691
+ }
1692
+ for (var c = 0; c < colsRepeated; c++) {
1693
+ var targetColumnIndex = columnIndex;
1694
+ if (targetColumnIndex >= startColumn &&
1695
+ targetColumnIndex <= endColumn) {
1696
+ var relativeIndex = headerValues.length;
1697
+ var fallbackName = "Column ".concat(relativeIndex + 1);
1698
+ var trimmed = displayValue === null || displayValue === void 0 ? void 0 : displayValue.trim();
1699
+ headerValues.push(trimmed && trimmed.length ? trimmed : fallbackName);
1700
+ if (headerValues.length >= columnCount) {
1701
+ break;
1702
+ }
1703
+ }
1704
+ columnIndex++;
1705
+ }
1706
+ if (headerValues.length >= columnCount) {
1707
+ break;
1708
+ }
1709
+ }
1710
+ }
1711
+ catch (e_33_1) { e_33 = { error: e_33_1 }; }
1712
+ finally {
1713
+ try {
1714
+ if (normalizedRowChildren_2_1 && !normalizedRowChildren_2_1.done && (_b = normalizedRowChildren_2.return)) _b.call(normalizedRowChildren_2);
1715
+ }
1716
+ finally { if (e_33) throw e_33.error; }
1717
+ }
1718
+ }
1719
+ break outer;
1720
+ }
1721
+ currentRowIndex++;
1722
+ }
1723
+ if (currentRowIndex > headerRowIndex) {
1724
+ break;
1725
+ }
1726
+ }
1727
+ }
1728
+ catch (e_32_1) { e_32 = { error: e_32_1 }; }
1729
+ finally {
1730
+ try {
1731
+ if (rows_3_1 && !rows_3_1.done && (_a = rows_3.return)) _a.call(rows_3);
1732
+ }
1733
+ finally { if (e_32) throw e_32.error; }
1734
+ }
1735
+ if (!headerValues.length) {
1736
+ return buildDefaultColumns();
1737
+ }
1738
+ var columns = [];
1739
+ for (var i = 0; i < columnCount; i++) {
1740
+ var label = headerValues[i];
1741
+ columns.push({
1742
+ name: label && label.trim().length ? label : "Column ".concat(i + 1),
1743
+ });
1744
+ }
1745
+ return columns;
1746
+ };
1747
+ OdsPlugin.prototype.collectFrameNodes = function (cellChildren, cellAttrs) {
1748
+ var e_34, _a, e_35, _b;
1749
+ if (!cellChildren)
1750
+ return [];
1751
+ var children = Array.isArray(cellChildren)
1752
+ ? cellChildren
1753
+ : [cellChildren];
1754
+ var frames = [];
1755
+ try {
1756
+ for (var children_2 = __values(children), children_2_1 = children_2.next(); !children_2_1.done; children_2_1 = children_2.next()) {
1757
+ var child = children_2_1.value;
1758
+ if (!child || typeof child !== "object")
1759
+ continue;
1760
+ var frameNode = child["draw:frame"] || child["frame"];
1761
+ if (!frameNode)
1762
+ continue;
1763
+ if (Array.isArray(frameNode)) {
1764
+ try {
1765
+ for (var frameNode_1 = (e_35 = void 0, __values(frameNode)), frameNode_1_1 = frameNode_1.next(); !frameNode_1_1.done; frameNode_1_1 = frameNode_1.next()) {
1766
+ var node = frameNode_1_1.value;
1767
+ frames.push({ frame: node, cellAttrs: child[":@"] || cellAttrs });
1768
+ }
1769
+ }
1770
+ catch (e_35_1) { e_35 = { error: e_35_1 }; }
1771
+ finally {
1772
+ try {
1773
+ if (frameNode_1_1 && !frameNode_1_1.done && (_b = frameNode_1.return)) _b.call(frameNode_1);
1774
+ }
1775
+ finally { if (e_35) throw e_35.error; }
1776
+ }
1777
+ }
1778
+ else {
1779
+ frames.push({ frame: frameNode, cellAttrs: child[":@"] || cellAttrs });
1780
+ }
1781
+ }
1782
+ }
1783
+ catch (e_34_1) { e_34 = { error: e_34_1 }; }
1784
+ finally {
1785
+ try {
1786
+ if (children_2_1 && !children_2_1.done && (_a = children_2.return)) _a.call(children_2);
1787
+ }
1788
+ finally { if (e_34) throw e_34.error; }
1789
+ }
1790
+ return frames;
1791
+ };
1792
+ OdsPlugin.prototype.extractSheetSettings = function (sheetContexts) {
1793
+ var e_36, _a, e_37, _b;
1794
+ var _this = this;
1795
+ var map = new Map();
1796
+ if (!this.settingsXml || !sheetContexts.length) {
1797
+ return map;
1798
+ }
1799
+ var documentSettings = get(this.settingsXml, "office:document-settings") ||
1800
+ get(this.settingsXml, "document-settings");
1801
+ if (!documentSettings)
1802
+ return map;
1803
+ var settingsNode = get(documentSettings, "office:settings") ||
1804
+ get(documentSettings, "settings");
1805
+ if (!settingsNode)
1806
+ return map;
1807
+ var nameMap = new Map();
1808
+ var traverse = function (node) {
1809
+ var e_38, _a, e_39, _b;
1810
+ if (!node || typeof node !== "object")
1811
+ return;
1812
+ var entries = _this.toArray(node["config:config-item-map-entry"] || node["config-item-map-entry"]);
1813
+ try {
1814
+ for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
1815
+ var entry = entries_1_1.value;
1816
+ var attrs = _this.getAttributes(entry);
1817
+ var entryName = (attrs === null || attrs === void 0 ? void 0 : attrs["@_config:name"]) ||
1818
+ (attrs === null || attrs === void 0 ? void 0 : attrs["@_name"]) ||
1819
+ (attrs === null || attrs === void 0 ? void 0 : attrs["@_table:name"]);
1820
+ if (entryName) {
1821
+ var parsed = _this.parseConfigItemEntry(entry);
1822
+ if (parsed) {
1823
+ var existing = nameMap.get(entryName) || {};
1824
+ var combined = __assign(__assign({}, existing), parsed);
1825
+ nameMap.set(entryName, combined);
1826
+ var normalized = _this.normalizeSheetName(entryName);
1827
+ if (normalized) {
1828
+ nameMap.set(normalized, combined);
1829
+ nameMap.set("'".concat(normalized, "'"), combined);
1830
+ }
1831
+ }
1832
+ }
1833
+ traverse(entry);
1834
+ }
1835
+ }
1836
+ catch (e_38_1) { e_38 = { error: e_38_1 }; }
1837
+ finally {
1838
+ try {
1839
+ if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
1840
+ }
1841
+ finally { if (e_38) throw e_38.error; }
1842
+ }
1843
+ var namedMaps = _this.toArray(node["config:config-item-map-named"] || node["config-item-map-named"]);
1844
+ try {
1845
+ for (var namedMaps_1 = __values(namedMaps), namedMaps_1_1 = namedMaps_1.next(); !namedMaps_1_1.done; namedMaps_1_1 = namedMaps_1.next()) {
1846
+ var named = namedMaps_1_1.value;
1847
+ traverse(named);
1848
+ }
1849
+ }
1850
+ catch (e_39_1) { e_39 = { error: e_39_1 }; }
1851
+ finally {
1852
+ try {
1853
+ if (namedMaps_1_1 && !namedMaps_1_1.done && (_b = namedMaps_1.return)) _b.call(namedMaps_1);
1854
+ }
1855
+ finally { if (e_39) throw e_39.error; }
1856
+ }
1857
+ };
1858
+ var itemSets = this.toArray(get(settingsNode, "config:config-item-set") ||
1859
+ get(settingsNode, "config-item-set"));
1860
+ try {
1861
+ for (var itemSets_1 = __values(itemSets), itemSets_1_1 = itemSets_1.next(); !itemSets_1_1.done; itemSets_1_1 = itemSets_1.next()) {
1862
+ var set = itemSets_1_1.value;
1863
+ traverse(set);
1864
+ }
1865
+ }
1866
+ catch (e_36_1) { e_36 = { error: e_36_1 }; }
1867
+ finally {
1868
+ try {
1869
+ if (itemSets_1_1 && !itemSets_1_1.done && (_a = itemSets_1.return)) _a.call(itemSets_1);
1870
+ }
1871
+ finally { if (e_36) throw e_36.error; }
1872
+ }
1873
+ try {
1874
+ for (var sheetContexts_4 = __values(sheetContexts), sheetContexts_4_1 = sheetContexts_4.next(); !sheetContexts_4_1.done; sheetContexts_4_1 = sheetContexts_4.next()) {
1875
+ var context = sheetContexts_4_1.value;
1876
+ var normalized = this.normalizeSheetName(context.name);
1877
+ var settings = nameMap.get(context.name) ||
1878
+ (normalized ? nameMap.get(normalized) : undefined);
1879
+ if (settings) {
1880
+ map.set(context.sheetId, settings);
1881
+ }
1882
+ }
1883
+ }
1884
+ catch (e_37_1) { e_37 = { error: e_37_1 }; }
1885
+ finally {
1886
+ try {
1887
+ if (sheetContexts_4_1 && !sheetContexts_4_1.done && (_b = sheetContexts_4.return)) _b.call(sheetContexts_4);
1888
+ }
1889
+ finally { if (e_37) throw e_37.error; }
1890
+ }
1891
+ return map;
1892
+ };
1893
+ OdsPlugin.prototype.parseConfigItemEntry = function (entry) {
1894
+ var e_40, _a;
1895
+ var configItems = this.toArray(get(entry, "config:config-item") || get(entry, "config-item"));
1896
+ if (!configItems.length)
1897
+ return undefined;
1898
+ var settings = {};
1899
+ try {
1900
+ for (var configItems_1 = __values(configItems), configItems_1_1 = configItems_1.next(); !configItems_1_1.done; configItems_1_1 = configItems_1.next()) {
1901
+ var item = configItems_1_1.value;
1902
+ var attrs = this.getAttributes(item);
1903
+ if (!attrs)
1904
+ continue;
1905
+ var name_3 = attrs["@_config:name"] || attrs["@_name"];
1906
+ if (!name_3)
1907
+ continue;
1908
+ var value = this.getNodeText(item);
1909
+ if (value === undefined)
1910
+ continue;
1911
+ var normalized = value.trim();
1912
+ if (!normalized.length)
1913
+ continue;
1914
+ if (name_3 === "ShowGrid" || name_3 === "ShowGridLines") {
1915
+ var parsed = this.parseBooleanAttribute(normalized);
1916
+ if (parsed !== undefined) {
1917
+ settings.showGridLines = parsed;
1918
+ }
1919
+ continue;
1920
+ }
1921
+ if (name_3 === "FreezeCell") {
1922
+ var freeze = this.parseFreezeCoordinates(normalized);
1923
+ if (freeze) {
1924
+ Object.assign(settings, freeze);
1925
+ }
1926
+ continue;
1927
+ }
1928
+ if (name_3 === "VerticalSplitPosition") {
1929
+ var parsed = this.parseIntegerValue(normalized);
1930
+ if (parsed !== undefined) {
1931
+ settings.frozenRowCount = parsed;
1932
+ }
1933
+ continue;
1934
+ }
1935
+ if (name_3 === "HorizontalSplitPosition") {
1936
+ var parsed = this.parseIntegerValue(normalized);
1937
+ if (parsed !== undefined) {
1938
+ settings.frozenColumnCount = parsed;
1939
+ }
1940
+ continue;
1941
+ }
1942
+ if (name_3 === "TabColor") {
1943
+ var color = this.normalizeOdsColor(normalized);
1944
+ if (color) {
1945
+ settings.tabColor = color;
1946
+ }
1947
+ }
1948
+ }
1949
+ }
1950
+ catch (e_40_1) { e_40 = { error: e_40_1 }; }
1951
+ finally {
1952
+ try {
1953
+ if (configItems_1_1 && !configItems_1_1.done && (_a = configItems_1.return)) _a.call(configItems_1);
1954
+ }
1955
+ finally { if (e_40) throw e_40.error; }
1956
+ }
1957
+ return Object.keys(settings).length ? settings : undefined;
1958
+ };
1959
+ OdsPlugin.prototype.parseFreezeCoordinates = function (value) {
1960
+ var normalized = value.replace(/\$/g, "").trim();
1961
+ if (!normalized)
1962
+ return undefined;
1963
+ var cell = addressToCell(normalized.toUpperCase());
1964
+ if (!cell)
1965
+ return undefined;
1966
+ return {
1967
+ frozenRowCount: Math.max(0, cell.rowIndex - 1),
1968
+ frozenColumnCount: Math.max(0, cell.columnIndex - 1),
1969
+ };
1970
+ };
1971
+ OdsPlugin.prototype.convertFrameToEmbeddedObject = function (frameNode, sheetId, rowIndex, columnIndex, imageCache, cellAttrs) {
1972
+ var frameAttrs = this.getAttributes(frameNode);
1973
+ var imageNode = this.findFrameImageNode(frameNode);
1974
+ var imageAttrs = this.getAttributes(imageNode);
1975
+ var imagePath = this.normalizeImagePath((imageAttrs === null || imageAttrs === void 0 ? void 0 : imageAttrs["@_xlink:href"]) ||
1976
+ (imageAttrs === null || imageAttrs === void 0 ? void 0 : imageAttrs["@_href"]) ||
1977
+ (frameAttrs === null || frameAttrs === void 0 ? void 0 : frameAttrs["@_xlink:href"]) ||
1978
+ (frameAttrs === null || frameAttrs === void 0 ? void 0 : frameAttrs["@_href"]));
1979
+ if (!imagePath)
1980
+ return undefined;
1981
+ var imageUrl = this.getImageDataUrl(imagePath, imageCache);
1982
+ if (!imageUrl)
1983
+ return undefined;
1984
+ var _a = this.buildOverlayPlacement(frameAttrs, cellAttrs, rowIndex, columnIndex), overlayPosition = _a.overlayPosition, isInsideCell = _a.isInsideCell;
1985
+ var description = (frameAttrs === null || frameAttrs === void 0 ? void 0 : frameAttrs["@_draw:name"]) || (cellAttrs === null || cellAttrs === void 0 ? void 0 : cellAttrs["@_draw:name"]) || undefined;
1986
+ return {
1987
+ embedId: uuid(),
1988
+ spec: {
1989
+ type: "image",
1990
+ imageUrl: imageUrl,
1991
+ description: description,
1992
+ },
1993
+ position: {
1994
+ sheetId: sheetId,
1995
+ overlayPosition: overlayPosition,
1996
+ },
1997
+ draggable: true,
1998
+ lockAspectRatio: true,
1999
+ isInsideCell: isInsideCell,
2000
+ };
2001
+ };
2002
+ OdsPlugin.prototype.convertFrameToEmbeddedChart = function (frameNode, sheetContext, sheetId, rowIndex, columnIndex, sheetNameMap, cellAttrs) {
2003
+ var frameAttrs = this.getAttributes(frameNode);
2004
+ var inlineChart = this.findInlineChartNode(frameNode);
2005
+ var chartNode = inlineChart;
2006
+ if (!chartNode) {
2007
+ var objectNode = this.findFrameObjectNode(frameNode);
2008
+ var chartFromObject = this.loadChartNodeFromObject(objectNode, frameAttrs);
2009
+ chartNode = chartFromObject;
2010
+ }
2011
+ if (!chartNode)
2012
+ return undefined;
2013
+ var spec = this.convertChartNodeToSpec(chartNode, sheetNameMap, sheetContext);
2014
+ if (!spec)
2015
+ return undefined;
2016
+ var overlayPosition = this.buildOverlayPlacement(frameAttrs, cellAttrs, rowIndex, columnIndex).overlayPosition;
2017
+ var chartId = uuid();
2018
+ return {
2019
+ chartId: chartId,
2020
+ spec: spec,
2021
+ position: {
2022
+ sheetId: sheetId,
2023
+ overlayPosition: overlayPosition,
2024
+ },
2025
+ draggable: true,
2026
+ resizable: true,
2027
+ };
2028
+ };
2029
+ OdsPlugin.prototype.findInlineChartNode = function (frameNode) {
2030
+ var e_41, _a;
2031
+ if (!frameNode)
2032
+ return undefined;
2033
+ if (Array.isArray(frameNode)) {
2034
+ try {
2035
+ for (var frameNode_2 = __values(frameNode), frameNode_2_1 = frameNode_2.next(); !frameNode_2_1.done; frameNode_2_1 = frameNode_2.next()) {
2036
+ var entry = frameNode_2_1.value;
2037
+ var found = this.findInlineChartNode(entry);
2038
+ if (found)
2039
+ return found;
2040
+ }
2041
+ }
2042
+ catch (e_41_1) { e_41 = { error: e_41_1 }; }
2043
+ finally {
2044
+ try {
2045
+ if (frameNode_2_1 && !frameNode_2_1.done && (_a = frameNode_2.return)) _a.call(frameNode_2);
2046
+ }
2047
+ finally { if (e_41) throw e_41.error; }
2048
+ }
2049
+ return undefined;
2050
+ }
2051
+ var chartNode = frameNode["chart:chart"] || frameNode["chart"];
2052
+ if (chartNode) {
2053
+ return Array.isArray(chartNode) ? chartNode[0] : chartNode;
2054
+ }
2055
+ return undefined;
2056
+ };
2057
+ OdsPlugin.prototype.findFrameObjectNode = function (frameNode) {
2058
+ var e_42, _a;
2059
+ if (!frameNode)
2060
+ return undefined;
2061
+ if (Array.isArray(frameNode)) {
2062
+ try {
2063
+ for (var frameNode_3 = __values(frameNode), frameNode_3_1 = frameNode_3.next(); !frameNode_3_1.done; frameNode_3_1 = frameNode_3.next()) {
2064
+ var entry = frameNode_3_1.value;
2065
+ var found = this.findFrameObjectNode(entry);
2066
+ if (found)
2067
+ return found;
2068
+ }
2069
+ }
2070
+ catch (e_42_1) { e_42 = { error: e_42_1 }; }
2071
+ finally {
2072
+ try {
2073
+ if (frameNode_3_1 && !frameNode_3_1.done && (_a = frameNode_3.return)) _a.call(frameNode_3);
2074
+ }
2075
+ finally { if (e_42) throw e_42.error; }
2076
+ }
2077
+ return undefined;
2078
+ }
2079
+ var objectNode = frameNode["draw:object"] || frameNode["object"];
2080
+ if (objectNode) {
2081
+ return Array.isArray(objectNode) ? objectNode[0] : objectNode;
2082
+ }
2083
+ return undefined;
2084
+ };
2085
+ OdsPlugin.prototype.findFrameImageNode = function (frameNode) {
2086
+ var e_43, _a;
2087
+ if (!frameNode)
2088
+ return undefined;
2089
+ if (Array.isArray(frameNode)) {
2090
+ try {
2091
+ for (var frameNode_4 = __values(frameNode), frameNode_4_1 = frameNode_4.next(); !frameNode_4_1.done; frameNode_4_1 = frameNode_4.next()) {
2092
+ var entry = frameNode_4_1.value;
2093
+ var found = this.findFrameImageNode(entry);
2094
+ if (found)
2095
+ return found;
2096
+ }
2097
+ }
2098
+ catch (e_43_1) { e_43 = { error: e_43_1 }; }
2099
+ finally {
2100
+ try {
2101
+ if (frameNode_4_1 && !frameNode_4_1.done && (_a = frameNode_4.return)) _a.call(frameNode_4);
2102
+ }
2103
+ finally { if (e_43) throw e_43.error; }
2104
+ }
2105
+ return undefined;
2106
+ }
2107
+ var direct = frameNode["draw:image"] || frameNode["image"] || frameNode["draw:object"];
2108
+ if (direct) {
2109
+ return Array.isArray(direct) ? direct[0] : direct;
2110
+ }
2111
+ return undefined;
2112
+ };
2113
+ OdsPlugin.prototype.loadChartNodeFromObject = function (objectNode, frameAttrs) {
2114
+ if (!objectNode)
2115
+ return undefined;
2116
+ var objectAttrs = this.getAttributes(objectNode);
2117
+ var href = (objectAttrs === null || objectAttrs === void 0 ? void 0 : objectAttrs["@_xlink:href"]) ||
2118
+ (objectAttrs === null || objectAttrs === void 0 ? void 0 : objectAttrs["@_href"]) ||
2119
+ (frameAttrs === null || frameAttrs === void 0 ? void 0 : frameAttrs["@_xlink:href"]) ||
2120
+ (frameAttrs === null || frameAttrs === void 0 ? void 0 : frameAttrs["@_href"]);
2121
+ return this.loadChartNodeFromHref(href);
2122
+ };
2123
+ OdsPlugin.prototype.loadChartNodeFromHref = function (href) {
2124
+ var path = this.resolveObjectPath(href);
2125
+ if (!path)
2126
+ return undefined;
2127
+ try {
2128
+ var content = this.zipParser.Get(path);
2129
+ var chartDoc = this.xmlParser.parse(content);
2130
+ this.odsStyles.parseContentXml(chartDoc);
2131
+ return this.findChartNodeInDocument(chartDoc);
2132
+ }
2133
+ catch (_a) {
2134
+ return undefined;
2135
+ }
2136
+ };
2137
+ OdsPlugin.prototype.resolveObjectPath = function (href) {
2138
+ var e_44, _a;
2139
+ if (!href)
2140
+ return undefined;
2141
+ var normalized = href.trim();
2142
+ if (!normalized)
2143
+ return undefined;
2144
+ if (normalized.startsWith("#")) {
2145
+ normalized = normalized.slice(1);
2146
+ }
2147
+ normalized = normalized.replace(/^\.\/+/, "");
2148
+ while (normalized.startsWith("../")) {
2149
+ normalized = normalized.slice(3);
2150
+ }
2151
+ if (!normalized)
2152
+ return undefined;
2153
+ var candidates = new Set();
2154
+ if (normalized.endsWith(".xml")) {
2155
+ candidates.add(normalized);
2156
+ candidates.add("ObjectReplacements/".concat(normalized));
2157
+ }
2158
+ else {
2159
+ candidates.add("".concat(normalized, "/content.xml"));
2160
+ candidates.add("".concat(normalized, "/Content.xml"));
2161
+ candidates.add("".concat(normalized, ".xml"));
2162
+ candidates.add("ObjectReplacements/".concat(normalized, "/content.xml"));
2163
+ candidates.add("ObjectReplacements/".concat(normalized, "/Content.xml"));
2164
+ }
2165
+ try {
2166
+ for (var candidates_1 = __values(candidates), candidates_1_1 = candidates_1.next(); !candidates_1_1.done; candidates_1_1 = candidates_1.next()) {
2167
+ var candidate = candidates_1_1.value;
2168
+ if (!candidate)
2169
+ continue;
2170
+ if (this.zipParser.Has(candidate)) {
2171
+ return candidate;
2172
+ }
2173
+ }
2174
+ }
2175
+ catch (e_44_1) { e_44 = { error: e_44_1 }; }
2176
+ finally {
2177
+ try {
2178
+ if (candidates_1_1 && !candidates_1_1.done && (_a = candidates_1.return)) _a.call(candidates_1);
2179
+ }
2180
+ finally { if (e_44) throw e_44.error; }
2181
+ }
2182
+ return undefined;
2183
+ };
2184
+ OdsPlugin.prototype.findChartNodeInDocument = function (doc) {
2185
+ if (!doc)
2186
+ return undefined;
2187
+ var chartNode = get(doc, "office:document-content.office:body.office:chart.chart:chart") ||
2188
+ get(doc, "office:document-content.office:body.chart:chart") ||
2189
+ get(doc, "chart:chart");
2190
+ if (chartNode) {
2191
+ return Array.isArray(chartNode) ? chartNode[0] : chartNode;
2192
+ }
2193
+ return this.findNodeRecursive(doc, "chart:chart");
2194
+ };
2195
+ OdsPlugin.prototype.findNodeRecursive = function (node, key) {
2196
+ var e_45, _a, e_46, _b;
2197
+ if (!node || typeof node !== "object")
2198
+ return undefined;
2199
+ if (node[key]) {
2200
+ return Array.isArray(node[key]) ? node[key][0] : node[key];
2201
+ }
2202
+ try {
2203
+ for (var _c = __values(Object.values(node)), _d = _c.next(); !_d.done; _d = _c.next()) {
2204
+ var value = _d.value;
2205
+ if (Array.isArray(value)) {
2206
+ try {
2207
+ for (var value_1 = (e_46 = void 0, __values(value)), value_1_1 = value_1.next(); !value_1_1.done; value_1_1 = value_1.next()) {
2208
+ var entry = value_1_1.value;
2209
+ var found = this.findNodeRecursive(entry, key);
2210
+ if (found)
2211
+ return found;
2212
+ }
2213
+ }
2214
+ catch (e_46_1) { e_46 = { error: e_46_1 }; }
2215
+ finally {
2216
+ try {
2217
+ if (value_1_1 && !value_1_1.done && (_b = value_1.return)) _b.call(value_1);
2218
+ }
2219
+ finally { if (e_46) throw e_46.error; }
2220
+ }
2221
+ }
2222
+ else if (typeof value === "object") {
2223
+ var found = this.findNodeRecursive(value, key);
2224
+ if (found)
2225
+ return found;
2226
+ }
2227
+ }
2228
+ }
2229
+ catch (e_45_1) { e_45 = { error: e_45_1 }; }
2230
+ finally {
2231
+ try {
2232
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
2233
+ }
2234
+ finally { if (e_45) throw e_45.error; }
2235
+ }
2236
+ return undefined;
2237
+ };
2238
+ OdsPlugin.prototype.convertChartNodeToSpec = function (chartNode, sheetNameMap, context) {
2239
+ var e_47, _a;
2240
+ if (!chartNode)
2241
+ return undefined;
2242
+ var chartAttrs = this.getAttributes(chartNode);
2243
+ var chartType = this.mapOdsChartClassToType((chartAttrs === null || chartAttrs === void 0 ? void 0 : chartAttrs["@_chart:class"]) || (chartAttrs === null || chartAttrs === void 0 ? void 0 : chartAttrs["@_class"]));
2244
+ var titleNode = get(chartNode, "chart:title.chart:title-text") ||
2245
+ get(chartNode, "chart:title") ||
2246
+ get(chartNode, "title");
2247
+ var rawTitle = titleNode ? this.extractTextContent(titleNode) : "";
2248
+ var title = (rawTitle === null || rawTitle === void 0 ? void 0 : rawTitle.trim()) ? rawTitle.trim() : undefined;
2249
+ var plotArea = get(chartNode, "chart:plot-area") || get(chartNode, "plot-area");
2250
+ if (!plotArea)
2251
+ return undefined;
2252
+ var seriesNodes = this.toArray(get(plotArea, "chart:series") ||
2253
+ get(plotArea, "chart:data-series") ||
2254
+ get(plotArea, "series"));
2255
+ if (!seriesNodes.length)
2256
+ return undefined;
2257
+ var domains = [];
2258
+ var series = [];
2259
+ var seriesIndex = 1;
2260
+ try {
2261
+ for (var seriesNodes_1 = __values(seriesNodes), seriesNodes_1_1 = seriesNodes_1.next(); !seriesNodes_1_1.done; seriesNodes_1_1 = seriesNodes_1.next()) {
2262
+ var seriesNode = seriesNodes_1_1.value;
2263
+ var domainNode = get(seriesNode, "chart:domain") ||
2264
+ get(seriesNode, "domain") ||
2265
+ get(seriesNode, "chart:categories");
2266
+ if (domainNode) {
2267
+ var domainAddress = this.findRangeString(domainNode);
2268
+ if (domainAddress) {
2269
+ var chartData = this.createChartDataFromAddress(domainAddress, sheetNameMap, context);
2270
+ if (chartData) {
2271
+ domains.push(chartData);
2272
+ }
2273
+ }
2274
+ }
2275
+ var valueAddress = this.findRangeString(seriesNode, new Set(["chart:domain", "domain", "chart:categories"]));
2276
+ if (valueAddress) {
2277
+ var seriesData = this.createChartDataFromAddress(valueAddress, sheetNameMap, context);
2278
+ if (seriesData) {
2279
+ var label = this.extractSeriesLabel(seriesNode);
2280
+ seriesData.dataLabel = label || "Series ".concat(seriesIndex);
2281
+ var color = this.extractChartSeriesColor(seriesNode);
2282
+ if (color) {
2283
+ seriesData.color = color;
2284
+ }
2285
+ series.push(seriesData);
2286
+ seriesIndex++;
2287
+ }
2288
+ }
2289
+ }
2290
+ }
2291
+ catch (e_47_1) { e_47 = { error: e_47_1 }; }
2292
+ finally {
2293
+ try {
2294
+ if (seriesNodes_1_1 && !seriesNodes_1_1.done && (_a = seriesNodes_1.return)) _a.call(seriesNodes_1);
2295
+ }
2296
+ finally { if (e_47) throw e_47.error; }
2297
+ }
2298
+ if (!series.length) {
2299
+ return undefined;
2300
+ }
2301
+ var finalizedDomains = domains.length ? domains : [series[0]];
2302
+ return {
2303
+ chartType: chartType,
2304
+ title: title,
2305
+ domains: finalizedDomains,
2306
+ series: series,
2307
+ };
2308
+ };
2309
+ OdsPlugin.prototype.extractSeriesLabel = function (seriesNode) {
2310
+ if (!seriesNode)
2311
+ return undefined;
2312
+ var labelNode = get(seriesNode, "chart:label") ||
2313
+ get(seriesNode, "label") ||
2314
+ get(seriesNode, "chart:series-label");
2315
+ var label = labelNode ? this.extractTextContent(labelNode) : undefined;
2316
+ return (label === null || label === void 0 ? void 0 : label.trim()) || undefined;
2317
+ };
2318
+ OdsPlugin.prototype.extractChartSeriesColor = function (seriesNode) {
2319
+ var e_48, _a, e_49, _b, e_50, _c;
2320
+ if (!seriesNode)
2321
+ return undefined;
2322
+ var attrs = this.getAttributes(seriesNode);
2323
+ var styleCandidates = [
2324
+ attrs === null || attrs === void 0 ? void 0 : attrs["@_chart:style-name"],
2325
+ attrs === null || attrs === void 0 ? void 0 : attrs["@_chart:data-style-name"],
2326
+ attrs === null || attrs === void 0 ? void 0 : attrs["@_style-name"],
2327
+ ];
2328
+ try {
2329
+ for (var styleCandidates_1 = __values(styleCandidates), styleCandidates_1_1 = styleCandidates_1.next(); !styleCandidates_1_1.done; styleCandidates_1_1 = styleCandidates_1.next()) {
2330
+ var candidate = styleCandidates_1_1.value;
2331
+ var color = this.odsStyles.getChartStyleColor(candidate);
2332
+ if (color) {
2333
+ return typeof color === "string" ? color : undefined;
2334
+ }
2335
+ }
2336
+ }
2337
+ catch (e_48_1) { e_48 = { error: e_48_1 }; }
2338
+ finally {
2339
+ try {
2340
+ if (styleCandidates_1_1 && !styleCandidates_1_1.done && (_a = styleCandidates_1.return)) _a.call(styleCandidates_1);
2341
+ }
2342
+ finally { if (e_48) throw e_48.error; }
2343
+ }
2344
+ var seriesProps = get(seriesNode, "chart:data-point-properties") ||
2345
+ get(seriesNode, "chart:series-properties");
2346
+ var inlineColor = this.extractColorFromChartProperties(seriesProps);
2347
+ if (inlineColor) {
2348
+ return inlineColor;
2349
+ }
2350
+ var dataPoints = this.toArray(get(seriesNode, "chart:data-point") ||
2351
+ get(seriesNode, "chart:data-points") ||
2352
+ get(seriesNode, "data-point"));
2353
+ try {
2354
+ for (var dataPoints_1 = __values(dataPoints), dataPoints_1_1 = dataPoints_1.next(); !dataPoints_1_1.done; dataPoints_1_1 = dataPoints_1.next()) {
2355
+ var dataPoint = dataPoints_1_1.value;
2356
+ var pointAttrs = this.getAttributes(dataPoint);
2357
+ var pointStyleCandidates = [
2358
+ pointAttrs === null || pointAttrs === void 0 ? void 0 : pointAttrs["@_chart:style-name"],
2359
+ pointAttrs === null || pointAttrs === void 0 ? void 0 : pointAttrs["@_chart:data-style-name"],
2360
+ pointAttrs === null || pointAttrs === void 0 ? void 0 : pointAttrs["@_style-name"],
2361
+ ];
2362
+ try {
2363
+ for (var pointStyleCandidates_1 = (e_50 = void 0, __values(pointStyleCandidates)), pointStyleCandidates_1_1 = pointStyleCandidates_1.next(); !pointStyleCandidates_1_1.done; pointStyleCandidates_1_1 = pointStyleCandidates_1.next()) {
2364
+ var candidate = pointStyleCandidates_1_1.value;
2365
+ var color = this.odsStyles.getChartStyleColor(candidate);
2366
+ if (color)
2367
+ return typeof color === "string" ? color : undefined;
2368
+ }
2369
+ }
2370
+ catch (e_50_1) { e_50 = { error: e_50_1 }; }
2371
+ finally {
2372
+ try {
2373
+ if (pointStyleCandidates_1_1 && !pointStyleCandidates_1_1.done && (_c = pointStyleCandidates_1.return)) _c.call(pointStyleCandidates_1);
2374
+ }
2375
+ finally { if (e_50) throw e_50.error; }
2376
+ }
2377
+ var pointColor = this.extractColorFromChartProperties(get(dataPoint, "chart:data-point-properties") || dataPoint);
2378
+ if (pointColor)
2379
+ return pointColor;
2380
+ }
2381
+ }
2382
+ catch (e_49_1) { e_49 = { error: e_49_1 }; }
2383
+ finally {
2384
+ try {
2385
+ if (dataPoints_1_1 && !dataPoints_1_1.done && (_b = dataPoints_1.return)) _b.call(dataPoints_1);
2386
+ }
2387
+ finally { if (e_49) throw e_49.error; }
2388
+ }
2389
+ return undefined;
2390
+ };
2391
+ OdsPlugin.prototype.extractColorFromChartProperties = function (node) {
2392
+ if (!node)
2393
+ return undefined;
2394
+ var attrs = this.getAttributes(node);
2395
+ if (!attrs)
2396
+ return undefined;
2397
+ var rawValue = attrs["@_draw:fill-color"] ||
2398
+ attrs["@_svg:fill-color"] ||
2399
+ attrs["@_chart:color"] ||
2400
+ attrs["@_fo:background-color"] ||
2401
+ attrs["@_style:background-color"];
2402
+ if (!rawValue)
2403
+ return undefined;
2404
+ var normalized = this.normalizeOdsColor(rawValue);
2405
+ if (normalized &&
2406
+ normalized.toLowerCase() !== "none" &&
2407
+ normalized.toLowerCase() !== "transparent") {
2408
+ return normalized;
2409
+ }
2410
+ return undefined;
2411
+ };
2412
+ OdsPlugin.prototype.mapOdsChartClassToType = function (value) {
2413
+ var normalized = (value === null || value === void 0 ? void 0 : value.toLowerCase()) || "";
2414
+ if (normalized.includes("line") || normalized.includes("scatter")) {
2415
+ return "line";
2416
+ }
2417
+ if (normalized.includes("pie")) {
2418
+ return "pie";
2419
+ }
2420
+ if (normalized.includes("area")) {
2421
+ return "area";
2422
+ }
2423
+ return "bar";
2424
+ };
2425
+ OdsPlugin.prototype.findRangeString = function (node, skipKeys) {
2426
+ var e_51, _a, e_52, _b;
2427
+ if (!node)
2428
+ return undefined;
2429
+ var stack = [node];
2430
+ while (stack.length) {
2431
+ var current = stack.shift();
2432
+ if (current === undefined || current === null)
2433
+ continue;
2434
+ if (typeof current === "string") {
2435
+ if (this.looksLikeCellRangeAddress(current)) {
2436
+ return current;
2437
+ }
2438
+ continue;
2439
+ }
2440
+ if (Array.isArray(current)) {
2441
+ stack.unshift.apply(stack, __spreadArray([], __read(current), false));
2442
+ continue;
2443
+ }
2444
+ if (typeof current === "object") {
2445
+ var attrs = current[":@"] || current;
2446
+ try {
2447
+ for (var _c = (e_51 = void 0, __values(Object.entries(attrs))), _d = _c.next(); !_d.done; _d = _c.next()) {
2448
+ var _e = __read(_d.value, 2), key = _e[0], attrValue = _e[1];
2449
+ if (key.startsWith("@_") &&
2450
+ typeof attrValue === "string" &&
2451
+ this.looksLikeCellRangeAddress(attrValue)) {
2452
+ return attrValue;
2453
+ }
2454
+ }
2455
+ }
2456
+ catch (e_51_1) { e_51 = { error: e_51_1 }; }
2457
+ finally {
2458
+ try {
2459
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
2460
+ }
2461
+ finally { if (e_51) throw e_51.error; }
2462
+ }
2463
+ try {
2464
+ for (var _f = (e_52 = void 0, __values(Object.entries(current))), _g = _f.next(); !_g.done; _g = _f.next()) {
2465
+ var _h = __read(_g.value, 2), childKey = _h[0], childValue = _h[1];
2466
+ if (childKey === ":@")
2467
+ continue;
2468
+ if (skipKeys && skipKeys.has(childKey))
2469
+ continue;
2470
+ stack.push(childValue);
2471
+ }
2472
+ }
2473
+ catch (e_52_1) { e_52 = { error: e_52_1 }; }
2474
+ finally {
2475
+ try {
2476
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
2477
+ }
2478
+ finally { if (e_52) throw e_52.error; }
2479
+ }
2480
+ }
2481
+ }
2482
+ return undefined;
2483
+ };
2484
+ OdsPlugin.prototype.looksLikeCellRangeAddress = function (value) {
2485
+ if (!value)
2486
+ return false;
2487
+ var trimmed = value.trim();
2488
+ if (!trimmed)
2489
+ return false;
2490
+ if (trimmed.includes("#REF"))
2491
+ return false;
2492
+ if (!/[A-Za-z]/.test(trimmed) || !/\d/.test(trimmed))
2493
+ return false;
2494
+ return trimmed.includes(".") || trimmed.includes(":");
2495
+ };
2496
+ OdsPlugin.prototype.createChartDataFromAddress = function (address, sheetNameMap, context) {
2497
+ if (!address)
2498
+ return undefined;
2499
+ var ranges = this.parseRangeList(address, sheetNameMap, context);
2500
+ if (!ranges.length && (context === null || context === void 0 ? void 0 : context.name)) {
2501
+ var augmented = "'".concat(context.name, "'.").concat(address);
2502
+ ranges = this.parseRangeList(augmented, sheetNameMap, context);
2503
+ }
2504
+ if (!ranges.length)
2505
+ return undefined;
2506
+ return {
2507
+ sources: ranges,
2508
+ };
2509
+ };
2510
+ OdsPlugin.prototype.buildOverlayPlacement = function (frameAttrs, cellAttrs, rowIndex, columnIndex) {
2511
+ var widthPixels = this.convertLengthToPixels((frameAttrs === null || frameAttrs === void 0 ? void 0 : frameAttrs["@_svg:width"]) ||
2512
+ (frameAttrs === null || frameAttrs === void 0 ? void 0 : frameAttrs["@_width"]) ||
2513
+ (cellAttrs === null || cellAttrs === void 0 ? void 0 : cellAttrs["@_svg:width"]) ||
2514
+ (cellAttrs === null || cellAttrs === void 0 ? void 0 : cellAttrs["@_width"]));
2515
+ var heightPixels = this.convertLengthToPixels((frameAttrs === null || frameAttrs === void 0 ? void 0 : frameAttrs["@_svg:height"]) ||
2516
+ (frameAttrs === null || frameAttrs === void 0 ? void 0 : frameAttrs["@_height"]) ||
2517
+ (cellAttrs === null || cellAttrs === void 0 ? void 0 : cellAttrs["@_svg:height"]) ||
2518
+ (cellAttrs === null || cellAttrs === void 0 ? void 0 : cellAttrs["@_height"]));
2519
+ var offsetXPixels = this.convertLengthToPixels((frameAttrs === null || frameAttrs === void 0 ? void 0 : frameAttrs["@_svg:x"]) ||
2520
+ (frameAttrs === null || frameAttrs === void 0 ? void 0 : frameAttrs["@_x"]) ||
2521
+ (cellAttrs === null || cellAttrs === void 0 ? void 0 : cellAttrs["@_svg:x"]) ||
2522
+ (cellAttrs === null || cellAttrs === void 0 ? void 0 : cellAttrs["@_x"]));
2523
+ var offsetYPixels = this.convertLengthToPixels((frameAttrs === null || frameAttrs === void 0 ? void 0 : frameAttrs["@_svg:y"]) ||
2524
+ (frameAttrs === null || frameAttrs === void 0 ? void 0 : frameAttrs["@_y"]) ||
2525
+ (cellAttrs === null || cellAttrs === void 0 ? void 0 : cellAttrs["@_svg:y"]) ||
2526
+ (cellAttrs === null || cellAttrs === void 0 ? void 0 : cellAttrs["@_y"]));
2527
+ var overlayPosition = {
2528
+ anchorCell: { rowIndex: rowIndex, columnIndex: columnIndex },
2529
+ };
2530
+ if (typeof widthPixels === "number") {
2531
+ overlayPosition.widthPixels = widthPixels;
2532
+ }
2533
+ if (typeof heightPixels === "number") {
2534
+ overlayPosition.heightPixels = heightPixels;
2535
+ }
2536
+ if (typeof offsetXPixels === "number") {
2537
+ overlayPosition.offsetXPixels = offsetXPixels;
2538
+ }
2539
+ if (typeof offsetYPixels === "number") {
2540
+ overlayPosition.offsetYPixels = offsetYPixels;
2541
+ }
2542
+ var DEFAULT_CELL_IMAGE_MAX_SIZE = 60;
2543
+ var exceedsCellSize = (typeof widthPixels === "number" &&
2544
+ widthPixels > DEFAULT_CELL_IMAGE_MAX_SIZE) ||
2545
+ (typeof heightPixels === "number" &&
2546
+ heightPixels > DEFAULT_CELL_IMAGE_MAX_SIZE);
2547
+ var isInsideCell = !exceedsCellSize &&
2548
+ (offsetXPixels === undefined || Math.abs(offsetXPixels) < 0.01) &&
2549
+ (offsetYPixels === undefined || Math.abs(offsetYPixels) < 0.01);
2550
+ return { overlayPosition: overlayPosition, isInsideCell: isInsideCell };
2551
+ };
2552
+ OdsPlugin.prototype.getImageDataUrl = function (imagePath, cache) {
2553
+ if (cache.has(imagePath)) {
2554
+ return cache.get(imagePath);
2555
+ }
2556
+ try {
2557
+ var binary = this.zipParser.GetBinary(imagePath);
2558
+ var dataUrl = this.createDataUrlFromBytes(binary, this.getImageMimeType(imagePath));
2559
+ cache.set(imagePath, dataUrl);
2560
+ return dataUrl;
2561
+ }
2562
+ catch (_a) {
2563
+ return undefined;
2564
+ }
2565
+ };
2566
+ OdsPlugin.prototype.normalizeImagePath = function (href) {
2567
+ if (!href)
2568
+ return undefined;
2569
+ var normalized = href.trim();
2570
+ if (!normalized || normalized.startsWith("#"))
2571
+ return undefined;
2572
+ normalized = normalized.replace(/^\.\/+/, "");
2573
+ while (normalized.startsWith("../")) {
2574
+ normalized = normalized.slice(3);
2575
+ }
2576
+ normalized = normalized.replace(/^\/+/, "");
2577
+ return normalized;
2578
+ };
2579
+ OdsPlugin.prototype.getImageMimeType = function (path) {
2580
+ var _a;
2581
+ var extension = (_a = path.split(".").pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
2582
+ switch (extension) {
2583
+ case "jpg":
2584
+ case "jpeg":
2585
+ return "image/jpeg";
2586
+ case "gif":
2587
+ return "image/gif";
2588
+ case "bmp":
2589
+ return "image/bmp";
2590
+ case "svg":
2591
+ return "image/svg+xml";
2592
+ case "webp":
2593
+ return "image/webp";
2594
+ default:
2595
+ return "image/png";
2596
+ }
2597
+ };
2598
+ OdsPlugin.prototype.createDataUrlFromBytes = function (data, mimeType) {
2599
+ var base64 = this.bytesToBase64(data);
2600
+ return "data:".concat(mimeType, ";base64,").concat(base64);
2601
+ };
2602
+ OdsPlugin.prototype.bytesToBase64 = function (data) {
2603
+ var globalRef = typeof globalThis !== "undefined" ? globalThis : undefined;
2604
+ if (globalRef === null || globalRef === void 0 ? void 0 : globalRef.Buffer) {
2605
+ return globalRef.Buffer.from(data).toString("base64");
2606
+ }
2607
+ var chunkSize = 0x8000;
2608
+ var binary = "";
2609
+ for (var i = 0; i < data.length; i += chunkSize) {
2610
+ var chunk = data.subarray(i, i + chunkSize);
2611
+ binary += String.fromCharCode.apply(String, __spreadArray([], __read(Array.from(chunk)), false));
2612
+ }
2613
+ if (typeof btoa === "function") {
2614
+ return btoa(binary);
2615
+ }
2616
+ if (globalRef === null || globalRef === void 0 ? void 0 : globalRef.btoa) {
2617
+ return globalRef.btoa(binary);
2618
+ }
2619
+ throw new Error("Unable to encode image data");
2620
+ };
2621
+ OdsPlugin.prototype.convertLengthToPixels = function (value) {
2622
+ var _a;
2623
+ if (!value)
2624
+ return undefined;
2625
+ var match = value
2626
+ .toString()
2627
+ .trim()
2628
+ .match(/^(-?\d+(?:\.\d+)?)(cm|mm|in|pt|pc|px)?$/i);
2629
+ if (!match)
2630
+ return undefined;
2631
+ var amount = parseFloat(match[1]);
2632
+ var unit = (match[2] || "px").toLowerCase();
2633
+ var unitMap = {
2634
+ px: 1,
2635
+ cm: 37.7952755906,
2636
+ mm: 3.77952755906,
2637
+ in: 96,
2638
+ pt: 96 / 72,
2639
+ pc: 16,
2640
+ };
2641
+ var factor = (_a = unitMap[unit]) !== null && _a !== void 0 ? _a : 1;
2642
+ return amount * factor;
2643
+ };
2644
+ OdsPlugin.prototype.normalizeOdsColor = function (value) {
2645
+ if (!value)
2646
+ return undefined;
2647
+ var trimmed = value.trim();
2648
+ if (!trimmed)
2649
+ return undefined;
2650
+ if (trimmed.startsWith("#")) {
2651
+ return trimmed.toUpperCase();
2652
+ }
2653
+ if (/^\d+$/.test(trimmed)) {
2654
+ var numeric = parseInt(trimmed, 10);
2655
+ if (!isNaN(numeric)) {
2656
+ return "#".concat((numeric & 0xffffff)
2657
+ .toString(16)
2658
+ .padStart(6, "0")
2659
+ .toUpperCase());
2660
+ }
2661
+ }
2662
+ return trimmed;
2663
+ };
2664
+ OdsPlugin.prototype.parseIntegerValue = function (value) {
2665
+ if (value === undefined || value === null)
2666
+ return undefined;
2667
+ var parsed = parseInt(value, 10);
2668
+ return isNaN(parsed) ? undefined : parsed;
2669
+ };
2670
+ OdsPlugin.prototype.getNodeText = function (node) {
2671
+ if (node === undefined || node === null)
2672
+ return undefined;
2673
+ if (typeof node === "string")
2674
+ return node;
2675
+ if (typeof node["#text"] === "string")
2676
+ return node["#text"];
2677
+ if (typeof node["_text"] === "string")
2678
+ return node["_text"];
2679
+ return undefined;
2680
+ };
2681
+ OdsPlugin.prototype.buildSheetNameMap = function (sheetContexts) {
2682
+ var e_53, _a;
2683
+ var map = new Map();
2684
+ try {
2685
+ for (var sheetContexts_5 = __values(sheetContexts), sheetContexts_5_1 = sheetContexts_5.next(); !sheetContexts_5_1.done; sheetContexts_5_1 = sheetContexts_5.next()) {
2686
+ var context = sheetContexts_5_1.value;
2687
+ this.registerSheetNameVariants(map, context.name, context.sheetId);
2688
+ }
2689
+ }
2690
+ catch (e_53_1) { e_53 = { error: e_53_1 }; }
2691
+ finally {
2692
+ try {
2693
+ if (sheetContexts_5_1 && !sheetContexts_5_1.done && (_a = sheetContexts_5.return)) _a.call(sheetContexts_5);
2694
+ }
2695
+ finally { if (e_53) throw e_53.error; }
2696
+ }
2697
+ return map;
2698
+ };
2699
+ OdsPlugin.prototype.registerSheetNameVariants = function (map, name, sheetId) {
2700
+ if (!name)
2701
+ return;
2702
+ map.set(name, sheetId);
2703
+ var normalized = this.normalizeSheetName(name);
2704
+ if (normalized && normalized !== name) {
2705
+ map.set(normalized, sheetId);
2706
+ }
2707
+ if (normalized) {
2708
+ map.set("'".concat(normalized, "'"), sheetId);
2709
+ }
2710
+ };
2711
+ OdsPlugin.prototype.normalizeSheetName = function (name) {
2712
+ if (!name)
2713
+ return undefined;
2714
+ var normalized = name.trim();
2715
+ normalized = normalized.replace(/^'+|'+$/g, "");
2716
+ normalized = normalized.replace(/^"+|"+$/g, "");
2717
+ normalized = normalized.replace(/^\$+/, "");
2718
+ return normalized;
2719
+ };
2720
+ OdsPlugin.prototype.parseRangeList = function (addresses, sheetNameMap, context) {
2721
+ var e_54, _a;
2722
+ if (!addresses)
2723
+ return [];
2724
+ var segments = this.splitAddressSegments(addresses);
2725
+ var ranges = [];
2726
+ try {
2727
+ for (var segments_1 = __values(segments), segments_1_1 = segments_1.next(); !segments_1_1.done; segments_1_1 = segments_1.next()) {
2728
+ var segment = segments_1_1.value;
2729
+ var range = this.parseRange(segment, sheetNameMap, context);
2730
+ if (range) {
2731
+ ranges.push(range);
2732
+ }
2733
+ }
2734
+ }
2735
+ catch (e_54_1) { e_54 = { error: e_54_1 }; }
2736
+ finally {
2737
+ try {
2738
+ if (segments_1_1 && !segments_1_1.done && (_a = segments_1.return)) _a.call(segments_1);
2739
+ }
2740
+ finally { if (e_54) throw e_54.error; }
2741
+ }
2742
+ return ranges;
2743
+ };
2744
+ OdsPlugin.prototype.splitAddressSegments = function (addresses) {
2745
+ var segments = [];
2746
+ var buffer = "";
2747
+ var inQuotes = false;
2748
+ for (var i = 0; i < addresses.length; i++) {
2749
+ var char = addresses[i];
2750
+ if (char === "'") {
2751
+ if (inQuotes && addresses[i + 1] === "'") {
2752
+ buffer += "''";
2753
+ i++;
2754
+ continue;
2755
+ }
2756
+ inQuotes = !inQuotes;
2757
+ buffer += char;
2758
+ continue;
2759
+ }
2760
+ if (!inQuotes && (char === "," || /\s/.test(char))) {
2761
+ if (buffer.trim()) {
2762
+ segments.push(buffer.trim());
2763
+ buffer = "";
2764
+ }
2765
+ continue;
2766
+ }
2767
+ buffer += char;
2768
+ }
2769
+ if (buffer.trim()) {
2770
+ segments.push(buffer.trim());
2771
+ }
2772
+ return segments;
2773
+ };
2774
+ OdsPlugin.prototype.parseRange = function (address, sheetNameMap, context) {
2775
+ var _a, _b;
2776
+ if (!address)
2777
+ return undefined;
2778
+ var normalized = address.replace(/\$/g, "");
2779
+ var _c = __read(normalized.split(":"), 2), startRef = _c[0], endRef = _c[1];
2780
+ var start = this.parseCellReference(startRef, sheetNameMap, context);
2781
+ if (!start)
2782
+ return undefined;
2783
+ var end = this.parseCellReference(endRef !== null && endRef !== void 0 ? endRef : startRef, sheetNameMap, context) ||
2784
+ start;
2785
+ var sheetId = (_b = (_a = end.sheetId) !== null && _a !== void 0 ? _a : start.sheetId) !== null && _b !== void 0 ? _b : context === null || context === void 0 ? void 0 : context.sheetId;
2786
+ if (!sheetId)
2787
+ return undefined;
2788
+ return {
2789
+ sheetId: sheetId,
2790
+ startRowIndex: Math.min(start.rowIndex, end.rowIndex),
2791
+ endRowIndex: Math.max(start.rowIndex, end.rowIndex),
2792
+ startColumnIndex: Math.min(start.columnIndex, end.columnIndex),
2793
+ endColumnIndex: Math.max(start.columnIndex, end.columnIndex),
2794
+ };
2795
+ };
2796
+ OdsPlugin.prototype.parseCellReference = function (reference, sheetNameMap, context) {
2797
+ var _a, _b;
2798
+ if (!reference)
2799
+ return undefined;
2800
+ var ref = reference.trim();
2801
+ if (!ref)
2802
+ return undefined;
2803
+ ref = ref.replace(/\$/g, "");
2804
+ var sheetName;
2805
+ var cellPart = ref;
2806
+ var dotMatch = ref.match(/^(.*)[.!]([A-Za-z]+\d+)$/);
2807
+ if (dotMatch) {
2808
+ sheetName = dotMatch[1];
2809
+ cellPart = dotMatch[2];
2810
+ }
2811
+ var bangMatch = ref.match(/^(.*)!([A-Za-z]+\d+)$/);
2812
+ if (!sheetName && bangMatch) {
2813
+ sheetName = bangMatch[1];
2814
+ cellPart = bangMatch[2];
2815
+ }
2816
+ var quotedMatch = ref.match(/^'([^']+)'\.([A-Za-z]+\d+)$/);
2817
+ if (!sheetName && quotedMatch) {
2818
+ sheetName = quotedMatch[1];
2819
+ cellPart = quotedMatch[2];
2820
+ }
2821
+ var cell = addressToCell(cellPart.toUpperCase());
2822
+ if (!cell)
2823
+ return undefined;
2824
+ var normalizedSheet = sheetName
2825
+ ? this.normalizeSheetName(sheetName)
2826
+ : undefined;
2827
+ var sheetId = (_b = (_a = (normalizedSheet && sheetNameMap.get(normalizedSheet))) !== null && _a !== void 0 ? _a : (sheetName && sheetNameMap.get(sheetName))) !== null && _b !== void 0 ? _b : context === null || context === void 0 ? void 0 : context.sheetId;
2828
+ return {
2829
+ rowIndex: cell.rowIndex,
2830
+ columnIndex: cell.columnIndex,
2831
+ sheetId: sheetId,
2832
+ };
2833
+ };
2834
+ OdsPlugin.prototype.parseBooleanAttribute = function (value) {
2835
+ if (value === undefined || value === null)
2836
+ return undefined;
2837
+ if (typeof value === "boolean")
2838
+ return value;
2839
+ var normalized = value.toString().toLowerCase();
2840
+ if (normalized === "true" || normalized === "1")
2841
+ return true;
2842
+ if (normalized === "false" || normalized === "0")
2843
+ return false;
2844
+ return undefined;
2845
+ };
2846
+ OdsPlugin.prototype.normalizeConditionExpression = function (expression) {
2847
+ if (!expression)
2848
+ return undefined;
2849
+ var normalized = expression.trim();
2850
+ if (!normalized)
2851
+ return undefined;
2852
+ if (normalized.startsWith("of:=")) {
2853
+ normalized = normalized.slice(4);
2854
+ }
2855
+ else if (normalized.startsWith("of:")) {
2856
+ normalized = normalized.slice(3);
2857
+ }
2858
+ if (!normalized.startsWith("=")) {
2859
+ normalized = "=".concat(normalized);
2860
+ }
2861
+ return normalized;
2862
+ };
2863
+ OdsPlugin.prototype.normalizeExpression = function (expression) {
2864
+ if (!expression)
2865
+ return undefined;
2866
+ var normalized = expression.trim();
2867
+ if (!normalized)
2868
+ return undefined;
2869
+ normalized = convertOdsFormulaToExcel(normalized);
2870
+ normalized = normalized.trim();
2871
+ if (!normalized)
2872
+ return undefined;
2873
+ return normalized.startsWith("=") ? normalized : "=".concat(normalized);
2874
+ };
2875
+ OdsPlugin.prototype.toArray = function (value) {
2876
+ if (!value)
2877
+ return [];
2878
+ return Array.isArray(value) ? value : [value];
2879
+ };
2880
+ OdsPlugin.prototype.expandRowCells = function (rowChildren) {
2881
+ var e_55, _a;
2882
+ if (!rowChildren) {
2883
+ return [];
2884
+ }
2885
+ var entries = Array.isArray(rowChildren) ? rowChildren : [rowChildren];
2886
+ var normalized = [];
2887
+ try {
2888
+ for (var entries_2 = __values(entries), entries_2_1 = entries_2.next(); !entries_2_1.done; entries_2_1 = entries_2.next()) {
2889
+ var entry = entries_2_1.value;
2890
+ if (!entry)
2891
+ continue;
2892
+ if (entry["table:table-cell"] || entry["table:covered-table-cell"]) {
2893
+ normalized.push(entry);
2894
+ continue;
2895
+ }
2896
+ var normalizedEntry = this.wrapRawCellEntry(entry);
2897
+ if (normalizedEntry) {
2898
+ normalized.push(normalizedEntry);
2899
+ }
2900
+ }
2901
+ }
2902
+ catch (e_55_1) { e_55 = { error: e_55_1 }; }
2903
+ finally {
2904
+ try {
2905
+ if (entries_2_1 && !entries_2_1.done && (_a = entries_2.return)) _a.call(entries_2);
2906
+ }
2907
+ finally { if (e_55) throw e_55.error; }
2908
+ }
2909
+ return normalized;
2910
+ };
2911
+ OdsPlugin.prototype.wrapRawCellEntry = function (entry) {
2912
+ if (entry === undefined || entry === null)
2913
+ return undefined;
2914
+ var _a = this.extractAttributesFromNode(entry), attributes = _a.attributes, childNodes = _a.childNodes;
2915
+ var wrapper = {
2916
+ "table:table-cell": childNodes.length ? childNodes : [],
2917
+ };
2918
+ if (Object.keys(attributes).length) {
2919
+ wrapper[":@"] = attributes;
2920
+ }
2921
+ return wrapper;
2922
+ };
2923
+ OdsPlugin.prototype.extractAttributesFromNode = function (node) {
2924
+ var e_56, _a, _b;
2925
+ var attributes = {};
2926
+ var childNodes = [];
2927
+ if (node === undefined || node === null) {
2928
+ return { attributes: attributes, childNodes: childNodes };
2929
+ }
2930
+ if (typeof node !== "object" || Array.isArray(node)) {
2931
+ childNodes.push(typeof node === "object" ? node : { "#text": node !== null && node !== void 0 ? node : "" });
2932
+ return { attributes: attributes, childNodes: childNodes };
2933
+ }
2934
+ try {
2935
+ for (var _c = __values(Object.entries(node)), _d = _c.next(); !_d.done; _d = _c.next()) {
2936
+ var _e = __read(_d.value, 2), key = _e[0], value = _e[1];
2937
+ if (key === ":@") {
2938
+ if (value && typeof value === "object") {
2939
+ Object.assign(attributes, value);
2940
+ }
2941
+ continue;
2942
+ }
2943
+ if (key.startsWith("@_")) {
2944
+ attributes[key] = value;
2945
+ continue;
2946
+ }
2947
+ childNodes.push((_b = {}, _b[key] = value, _b));
2948
+ }
2949
+ }
2950
+ catch (e_56_1) { e_56 = { error: e_56_1 }; }
2951
+ finally {
2952
+ try {
2953
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
2954
+ }
2955
+ finally { if (e_56) throw e_56.error; }
2956
+ }
2957
+ return { attributes: attributes, childNodes: childNodes };
2958
+ };
2959
+ OdsPlugin.prototype.getAttributes = function (node) {
2960
+ if (!node)
2961
+ return undefined;
2962
+ if (Array.isArray(node)) {
2963
+ return node.length ? this.getAttributes(node[0]) : undefined;
2964
+ }
2965
+ return node[":@"] || node;
2966
+ };
2967
+ OdsPlugin.prototype.mapAlertStyle = function (value) {
2968
+ if (!value)
2969
+ return undefined;
2970
+ var normalized = value.toLowerCase();
2971
+ if (normalized.includes("warn"))
2972
+ return "warning";
2973
+ if (normalized.includes("info"))
2974
+ return "information";
2975
+ return "stop";
2976
+ };
2977
+ OdsPlugin.prototype.getSheets = function () {
2978
+ return __awaiter(this, arguments, void 0, function (minRowCount, minColumnCount) {
2979
+ var cache, sheets;
2980
+ if (minRowCount === void 0) { minRowCount = 0; }
2981
+ if (minColumnCount === void 0) { minColumnCount = 0; }
2982
+ return __generator(this, function (_a) {
2983
+ cache = this.ensureSheetCache();
2984
+ if (!minRowCount && !minColumnCount) {
2985
+ return [2 /*return*/, [cache.sheets, cache.tables]];
2986
+ }
2987
+ sheets = cache.sheets.map(function (sheet) {
2988
+ var _a, _b;
2989
+ var rowCount = Math.max((_a = sheet.rowCount) !== null && _a !== void 0 ? _a : 0, minRowCount);
2990
+ var columnCount = Math.max((_b = sheet.columnCount) !== null && _b !== void 0 ? _b : 0, minColumnCount);
2991
+ if (rowCount === sheet.rowCount && columnCount === sheet.columnCount) {
2992
+ return sheet;
2993
+ }
2994
+ return __assign(__assign({}, sheet), { rowCount: rowCount, columnCount: columnCount });
2995
+ });
2996
+ return [2 /*return*/, [sheets, cache.tables]];
2997
+ });
2998
+ });
2999
+ };
3000
+ OdsPlugin.prototype.getConditionalFormatting = function () {
3001
+ return __awaiter(this, void 0, void 0, function () {
3002
+ return __generator(this, function (_a) {
3003
+ return [2 /*return*/, this.ensureSheetCache().conditionalFormatting];
3004
+ });
3005
+ });
3006
+ };
3007
+ OdsPlugin.prototype.getDrawings = function () {
3008
+ return __awaiter(this, void 0, void 0, function () {
3009
+ return __generator(this, function (_a) {
3010
+ return [2 /*return*/, this.ensureSheetCache().drawings];
3011
+ });
3012
+ });
3013
+ };
3014
+ OdsPlugin.prototype.getCharts = function () {
3015
+ return __awaiter(this, void 0, void 0, function () {
3016
+ return __generator(this, function (_a) {
3017
+ return [2 /*return*/, this.ensureSheetCache().charts];
3018
+ });
3019
+ });
3020
+ };
3021
+ OdsPlugin.prototype.getDataValidations = function () {
3022
+ return __awaiter(this, void 0, void 0, function () {
3023
+ return __generator(this, function (_a) {
3024
+ return [2 /*return*/, this.ensureSheetCache().dataValidations];
3025
+ });
3026
+ });
3027
+ };
3028
+ OdsPlugin.prototype.getNamedRanges = function () {
3029
+ return this.ensureSheetCache().namedRanges;
3030
+ };
3031
+ OdsPlugin.prototype.findCalculationSettings = function (node) {
3032
+ var e_57, _a;
3033
+ if (!node)
3034
+ return undefined;
3035
+ if (Array.isArray(node)) {
3036
+ try {
3037
+ for (var node_2 = __values(node), node_2_1 = node_2.next(); !node_2_1.done; node_2_1 = node_2.next()) {
3038
+ var child = node_2_1.value;
3039
+ var found = this.findCalculationSettings(child);
3040
+ if (found)
3041
+ return found;
3042
+ }
3043
+ }
3044
+ catch (e_57_1) { e_57 = { error: e_57_1 }; }
3045
+ finally {
3046
+ try {
3047
+ if (node_2_1 && !node_2_1.done && (_a = node_2.return)) _a.call(node_2);
3048
+ }
3049
+ finally { if (e_57) throw e_57.error; }
3050
+ }
3051
+ return undefined;
3052
+ }
3053
+ if (node["table:calculation-settings"]) {
3054
+ var settingsNode = node["table:calculation-settings"];
3055
+ if (Array.isArray(settingsNode)) {
3056
+ return settingsNode[0];
3057
+ }
3058
+ return settingsNode;
3059
+ }
3060
+ return (this.findCalculationSettings(node["office:spreadsheet"]) ||
3061
+ this.findCalculationSettings(node["office:body"]) ||
3062
+ this.findCalculationSettings(node["office:document-content"]));
3063
+ };
3064
+ OdsPlugin.prototype.getIterativeCalculationOptions = function () {
3065
+ var _a;
3066
+ try {
3067
+ var calcSettings = (_a = this.findCalculationSettings(this.contentXml)) !== null && _a !== void 0 ? _a : this.findCalculationSettings(this.contentXmlOrdered);
3068
+ if (!calcSettings)
3069
+ return undefined;
3070
+ var enabledAttr = getAttribute(calcSettings, "table:use-iteration");
3071
+ var maxIterationsAttr = getAttribute(calcSettings, "table:iteration-count");
3072
+ var maxChangeAttr = getAttribute(calcSettings, "table:minimum-step");
3073
+ if (enabledAttr === undefined &&
3074
+ maxIterationsAttr === undefined &&
3075
+ maxChangeAttr === undefined) {
3076
+ return undefined;
3077
+ }
3078
+ var enabled = enabledAttr === "true" || enabledAttr === true || enabledAttr === "1";
3079
+ var options = { enabled: enabled };
3080
+ if (maxIterationsAttr !== undefined) {
3081
+ var parsed = Number(maxIterationsAttr);
3082
+ if (!Number.isNaN(parsed)) {
3083
+ options.maxIterations = parsed;
3084
+ }
3085
+ }
3086
+ if (maxChangeAttr !== undefined) {
3087
+ var parsed = Number(maxChangeAttr);
3088
+ if (!Number.isNaN(parsed)) {
3089
+ options.maxChange = parsed;
3090
+ }
3091
+ }
3092
+ return options;
3093
+ }
3094
+ catch (_b) {
3095
+ return undefined;
3096
+ }
3097
+ };
3098
+ OdsPlugin.prototype.processSheetData = function () {
3099
+ return __asyncGenerator(this, arguments, function processSheetData_1(chunkSize, enableCellXfsRegistry, enableSharedStrings) {
3100
+ var docContent, body, spreadsheet, tables, totalSheets, currentSheetIndex, tableWrapper, tableNameKey, tableChildren, tableAttrs, name_4, sheetId, tableStyleName, tableCellFormat, rows, columnWrappers, columnFormats, formattedColumnIndex, columnWrappers_1, columnWrappers_1_1, columnWrapper, columnAttrs, colsRepeated, columnStyleName, columnStyle, columnCellFormat, col, chunkIndex, currentChunk, currentChunkRowIndices, currentRowIndex, dvStamper, _a, rows_4, rows_4_1, rowWrapper, rowNameKey, rowChildren, rowAttrs, rowsRepeated, rowStyleName, rowStyle, rowCellFormat, rowBaseFormat, effectiveRepeats, r, rowData, columnIndex, normalizedRowChildren, normalizedRowChildren_3, normalizedRowChildren_3_1, cellWrapper, isCell, isCovered, cellNameKey, cellChildren, cellAttrs, colsRepeated, valueType, cellValue, displayValue, textFormatRuns, textPWrapper, textPKey, richText, hyperlinkValue, cellData, formula, isSharedString, excelFormula, matrixCols, matrixRows, cols, rows_5, start, end, cellStyleName, cellFormat, hasCellValue, c, targetColumnIndex, mergedFormat, alignment, needsDefaultRightAlign, displaySuggestsCurrency, currencySymbol, pattern, shouldInferNumberFormat, detectionSource, _b, detectedValueType, detectedNumberFormatType, detectedPattern, shouldOverrideExistingFormat, finalCellData, styleId, sheetSparklines, rowSparklines, _c, _d, _e, colIndex, sparkline, existingCell, sparklineData, sparklineOptions, cellData, isRowEmpty, e_58_1, _f, _g, trailing, e_59_1, error_1;
3101
+ var e_60, _h, e_58, _j, e_61, _k, e_62, _l, e_59, _m;
3102
+ var _o, _p, _q, _r;
3103
+ if (chunkSize === void 0) { chunkSize = 100; }
3104
+ if (enableCellXfsRegistry === void 0) { enableCellXfsRegistry = false; }
3105
+ if (enableSharedStrings === void 0) { enableSharedStrings = true; }
3106
+ return __generator(this, function (_s) {
3107
+ switch (_s.label) {
3108
+ case 0:
3109
+ _s.trys.push([0, 37, , 38]);
3110
+ if (!!this.contentXmlOrdered) return [3 /*break*/, 2];
3111
+ return [4 /*yield*/, __await(void 0)];
3112
+ case 1: return [2 /*return*/, _s.sent()];
3113
+ case 2:
3114
+ docContent = ((_o = this.contentXmlOrdered[0]) === null || _o === void 0 ? void 0 : _o["office:document-content"]) ||
3115
+ ((_p = this.contentXmlOrdered[0]) === null || _p === void 0 ? void 0 : _p["document-content"]);
3116
+ if (!!docContent) return [3 /*break*/, 4];
3117
+ return [4 /*yield*/, __await(void 0)];
3118
+ case 3: return [2 /*return*/, _s.sent()];
3119
+ case 4:
3120
+ body = getChildren(docContent, "office:body") ||
3121
+ getChildren(docContent, "body");
3122
+ if (!!body) return [3 /*break*/, 6];
3123
+ return [4 /*yield*/, __await(void 0)];
3124
+ case 5: return [2 /*return*/, _s.sent()];
3125
+ case 6:
3126
+ spreadsheet = getChildren(body, "office:spreadsheet") ||
3127
+ getChildren(body, "spreadsheet");
3128
+ if (!!spreadsheet) return [3 /*break*/, 8];
3129
+ return [4 /*yield*/, __await(void 0)];
3130
+ case 7: return [2 /*return*/, _s.sent()];
3131
+ case 8:
3132
+ tables = spreadsheet.filter(function (child) { return child["table:table"] || child["table"]; });
3133
+ totalSheets = tables.length;
3134
+ currentSheetIndex = 0;
3135
+ _s.label = 9;
3136
+ case 9:
3137
+ if (!(currentSheetIndex < totalSheets)) return [3 /*break*/, 36];
3138
+ tableWrapper = tables[currentSheetIndex];
3139
+ tableNameKey = tableWrapper["table:table"]
3140
+ ? "table:table"
3141
+ : "table";
3142
+ tableChildren = tableWrapper[tableNameKey];
3143
+ tableAttrs = tableWrapper[":@"] || {};
3144
+ name_4 = tableAttrs["@_table:name"] ||
3145
+ tableAttrs["@_name"] ||
3146
+ "Sheet".concat(currentSheetIndex + 1);
3147
+ sheetId = currentSheetIndex + 1;
3148
+ tableStyleName = tableAttrs["@_table:style-name"] || tableAttrs["@_style-name"];
3149
+ tableCellFormat = tableStyleName
3150
+ ? this.odsStyles.getTableCellFormat(tableStyleName)
3151
+ : undefined;
3152
+ rows = tableChildren.filter(function (child) { return child["table:table-row"] || child["table-row"]; });
3153
+ columnWrappers = tableChildren.filter(function (child) { return child["table:table-column"] || child["table-column"]; });
3154
+ columnFormats = new Map();
3155
+ formattedColumnIndex = 1;
3156
+ try {
3157
+ for (columnWrappers_1 = (e_60 = void 0, __values(columnWrappers)), columnWrappers_1_1 = columnWrappers_1.next(); !columnWrappers_1_1.done; columnWrappers_1_1 = columnWrappers_1.next()) {
3158
+ columnWrapper = columnWrappers_1_1.value;
3159
+ columnAttrs = columnWrapper[":@"] || {};
3160
+ colsRepeated = parseInt(columnAttrs["@_table:number-columns-repeated"] ||
3161
+ columnAttrs["@_number-columns-repeated"] ||
3162
+ "1", 10);
3163
+ columnStyleName = columnAttrs["@_table:style-name"] || columnAttrs["@_style-name"];
3164
+ columnStyle = columnStyleName
3165
+ ? this.odsStyles.getColumnStyle(columnStyleName)
3166
+ : undefined;
3167
+ columnCellFormat = columnStyle === null || columnStyle === void 0 ? void 0 : columnStyle.format;
3168
+ for (col = 0; col < colsRepeated; col++) {
3169
+ if (columnCellFormat) {
3170
+ columnFormats.set(formattedColumnIndex, columnCellFormat);
3171
+ }
3172
+ formattedColumnIndex++;
3173
+ }
3174
+ }
3175
+ }
3176
+ catch (e_60_1) { e_60 = { error: e_60_1 }; }
3177
+ finally {
3178
+ try {
3179
+ if (columnWrappers_1_1 && !columnWrappers_1_1.done && (_h = columnWrappers_1.return)) _h.call(columnWrappers_1);
3180
+ }
3181
+ finally { if (e_60) throw e_60.error; }
3182
+ }
3183
+ chunkIndex = 0;
3184
+ currentChunk = [];
3185
+ currentChunkRowIndices = [];
3186
+ currentRowIndex = 1;
3187
+ _a = SheetDataValidationStamper.bind;
3188
+ return [4 /*yield*/, __await(this.getDataValidations())];
3189
+ case 10:
3190
+ dvStamper = new (_a.apply(SheetDataValidationStamper, [void 0, _s.sent(), sheetId]))();
3191
+ _s.label = 11;
3192
+ case 11:
3193
+ _s.trys.push([11, 19, 20, 21]);
3194
+ rows_4 = (e_58 = void 0, __values(rows)), rows_4_1 = rows_4.next();
3195
+ _s.label = 12;
3196
+ case 12:
3197
+ if (!!rows_4_1.done) return [3 /*break*/, 18];
3198
+ rowWrapper = rows_4_1.value;
3199
+ rowNameKey = rowWrapper["table:table-row"]
3200
+ ? "table:table-row"
3201
+ : "table-row";
3202
+ rowChildren = rowWrapper[rowNameKey];
3203
+ rowAttrs = rowWrapper[":@"] || {};
3204
+ rowsRepeated = parseInt(rowAttrs["@_table:number-rows-repeated"] ||
3205
+ rowAttrs["@_number-rows-repeated"] ||
3206
+ "1");
3207
+ rowStyleName = rowAttrs["@_table:style-name"] || rowAttrs["@_style-name"];
3208
+ rowStyle = rowStyleName
3209
+ ? this.odsStyles.getRowStyle(rowStyleName)
3210
+ : undefined;
3211
+ rowCellFormat = rowStyle === null || rowStyle === void 0 ? void 0 : rowStyle.format;
3212
+ rowBaseFormat = fastMergeCellFormats(tableCellFormat, rowCellFormat);
3213
+ effectiveRepeats = Math.min(rowsRepeated, 10000);
3214
+ r = 0;
3215
+ _s.label = 13;
3216
+ case 13:
3217
+ if (!(r < effectiveRepeats)) return [3 /*break*/, 17];
3218
+ rowData = {
3219
+ values: [],
3220
+ };
3221
+ columnIndex = 1;
3222
+ normalizedRowChildren = rowChildren
3223
+ ? this.expandRowCells(rowChildren)
3224
+ : null;
3225
+ if (normalizedRowChildren) {
3226
+ try {
3227
+ for (normalizedRowChildren_3 = (e_61 = void 0, __values(normalizedRowChildren)), normalizedRowChildren_3_1 = normalizedRowChildren_3.next(); !normalizedRowChildren_3_1.done; normalizedRowChildren_3_1 = normalizedRowChildren_3.next()) {
3228
+ cellWrapper = normalizedRowChildren_3_1.value;
3229
+ isCell = !!cellWrapper["table:table-cell"];
3230
+ isCovered = !!cellWrapper["table:covered-table-cell"];
3231
+ if (!isCell && !isCovered)
3232
+ continue;
3233
+ cellNameKey = isCell
3234
+ ? "table:table-cell"
3235
+ : "table:covered-table-cell";
3236
+ cellChildren = cellWrapper[cellNameKey];
3237
+ cellAttrs = cellWrapper[":@"] || {};
3238
+ colsRepeated = parseInt(cellAttrs["@_table:number-columns-repeated"] ||
3239
+ cellAttrs["@_number-columns-repeated"] ||
3240
+ "1");
3241
+ if (isCovered) {
3242
+ columnIndex += colsRepeated;
3243
+ continue;
3244
+ }
3245
+ valueType = cellAttrs["@_office:value-type"] || cellAttrs["@_value-type"];
3246
+ cellValue = null;
3247
+ displayValue = "";
3248
+ textFormatRuns = void 0;
3249
+ textPWrapper = findChild(cellChildren, "text:p") ||
3250
+ findChild(cellChildren, "p");
3251
+ if (textPWrapper) {
3252
+ textPKey = textPWrapper["text:p"] ? "text:p" : "p";
3253
+ richText = this.extractTextContentWithRuns(textPWrapper[textPKey]);
3254
+ displayValue = richText.text;
3255
+ if (richText.runs.length > 0) {
3256
+ textFormatRuns = richText.runs;
3257
+ }
3258
+ }
3259
+ hyperlinkValue = this.extractHyperlinkValue(cellChildren);
3260
+ if (valueType === "float" ||
3261
+ valueType === "currency" ||
3262
+ valueType === "percentage") {
3263
+ cellValue = parseFloat(cellAttrs["@_office:value"] || cellAttrs["@_value"]);
3264
+ }
3265
+ else if (valueType === "date") {
3266
+ cellValue =
3267
+ cellAttrs["@_office:date-value"] ||
3268
+ cellAttrs["@_date-value"];
3269
+ }
3270
+ else if (valueType === "string") {
3271
+ cellValue =
3272
+ cellAttrs["@_office:string-value"] ||
3273
+ cellAttrs["@_string-value"] ||
3274
+ displayValue;
3275
+ }
3276
+ else {
3277
+ cellValue = displayValue;
3278
+ }
3279
+ cellData = {};
3280
+ if (hyperlinkValue) {
3281
+ cellData.hyperlink = hyperlinkValue;
3282
+ }
3283
+ if (cellValue !== null && cellValue !== "") {
3284
+ formula = cellAttrs["@_table:formula"] || cellAttrs["@_formula"];
3285
+ isSharedString = enableSharedStrings &&
3286
+ !formula &&
3287
+ valueType === "string" &&
3288
+ typeof cellValue === "string";
3289
+ if (isSharedString) {
3290
+ cellData.ss = String(this.getOrCreateSharedStringIndex(String(cellValue), textFormatRuns));
3291
+ }
3292
+ else {
3293
+ if (valueType === "float" ||
3294
+ valueType === "currency" ||
3295
+ valueType === "percentage") {
3296
+ cellData.ev = { nv: cellValue };
3297
+ }
3298
+ else {
3299
+ cellData.ev = { sv: String(cellValue) };
3300
+ }
3301
+ if (formula) {
3302
+ excelFormula = convertOdsFormulaToExcel(formula);
3303
+ cellData.ue = { fv: excelFormula };
3304
+ matrixCols = parseInt(cellAttrs["@_table:number-matrix-columns-spanned"] ||
3305
+ cellAttrs["@_number-matrix-columns-spanned"] ||
3306
+ "0");
3307
+ matrixRows = parseInt(cellAttrs["@_table:number-matrix-rows-spanned"] ||
3308
+ cellAttrs["@_number-matrix-rows-spanned"] ||
3309
+ "0");
3310
+ if (matrixCols > 0 || matrixRows > 0) {
3311
+ cols = Math.max(matrixCols, 1);
3312
+ rows_5 = Math.max(matrixRows, 1);
3313
+ start = cellToAddress({
3314
+ rowIndex: currentRowIndex,
3315
+ columnIndex: columnIndex,
3316
+ });
3317
+ end = cellToAddress({
3318
+ rowIndex: currentRowIndex + rows_5 - 1,
3319
+ columnIndex: columnIndex + cols - 1,
3320
+ });
3321
+ if (start && end) {
3322
+ cellData.af = "".concat(start, ":").concat(end);
3323
+ }
3324
+ }
3325
+ }
3326
+ else {
3327
+ cellData.ue = cellData.ev;
3328
+ }
3329
+ // Skip persisted `fv` for formula cells — renderer
3330
+ // derives the formatted value at paint time.
3331
+ if (!formula) {
3332
+ cellData.fv = displayValue;
3333
+ }
3334
+ }
3335
+ }
3336
+ cellStyleName = cellAttrs["@_table:style-name"] || cellAttrs["@_style-name"];
3337
+ cellFormat = cellStyleName
3338
+ ? this.odsStyles.getStyle(cellStyleName)
3339
+ : undefined;
3340
+ hasCellValue = Object.keys(cellData).length > 0;
3341
+ // Fill repeated columns
3342
+ for (c = 0; c < colsRepeated; c++) {
3343
+ targetColumnIndex = columnIndex;
3344
+ mergedFormat = fastMergeCellFormats(rowBaseFormat, columnFormats.get(targetColumnIndex), cellFormat);
3345
+ if (mergedFormat) {
3346
+ if (mergedFormat.__alignValueType) {
3347
+ alignment = valueType === "float" ||
3348
+ valueType === "currency" ||
3349
+ valueType === "percentage"
3350
+ ? "right"
3351
+ : "left";
3352
+ mergedFormat.horizontalAlignment = alignment;
3353
+ delete mergedFormat.__alignValueType;
3354
+ }
3355
+ }
3356
+ needsDefaultRightAlign = (valueType === "float" ||
3357
+ valueType === "currency" ||
3358
+ valueType === "percentage" ||
3359
+ valueType === "date") &&
3360
+ (!mergedFormat || !mergedFormat.horizontalAlignment);
3361
+ if (needsDefaultRightAlign) {
3362
+ mergedFormat = mergedFormat
3363
+ ? __assign({}, mergedFormat) : {};
3364
+ mergedFormat.horizontalAlignment = "right";
3365
+ }
3366
+ displaySuggestsCurrency = typeof displayValue === "string" &&
3367
+ DISPLAY_CURRENCY_REGEX.test(displayValue);
3368
+ if (valueType === "currency") {
3369
+ mergedFormat = mergedFormat
3370
+ ? __assign({}, mergedFormat) : {};
3371
+ currencySymbol = cellAttrs["@_office:currency"] ||
3372
+ cellAttrs["@_currency"] ||
3373
+ "$";
3374
+ if (!mergedFormat.numberFormat ||
3375
+ mergedFormat.numberFormat.type === "NUMBER") {
3376
+ pattern = ((_q = mergedFormat.numberFormat) === null || _q === void 0 ? void 0 : _q.pattern) || "#,##0.00";
3377
+ mergedFormat.numberFormat = {
3378
+ type: "CURRENCY",
3379
+ pattern: pattern.includes(currencySymbol)
3380
+ ? pattern
3381
+ : "".concat(currencySymbol).concat(pattern.startsWith("#") || pattern.startsWith("0")
3382
+ ? " "
3383
+ : "").concat(pattern),
3384
+ };
3385
+ }
3386
+ }
3387
+ shouldInferNumberFormat = valueType === "float" &&
3388
+ (!mergedFormat ||
3389
+ !mergedFormat.numberFormat ||
3390
+ displaySuggestsCurrency);
3391
+ if (shouldInferNumberFormat) {
3392
+ detectionSource = typeof displayValue === "string" &&
3393
+ displayValue.trim() !== ""
3394
+ ? displayValue
3395
+ : cellValue;
3396
+ if (detectionSource !== undefined) {
3397
+ _b = __read(detectValueTypeAndPattern(detectionSource, undefined), 4), detectedValueType = _b[0], detectedNumberFormatType = _b[1], detectedPattern = _b[3];
3398
+ if (detectedValueType === "numberValue" &&
3399
+ detectedNumberFormatType) {
3400
+ shouldOverrideExistingFormat = !mergedFormat ||
3401
+ !mergedFormat.numberFormat ||
3402
+ mergedFormat.numberFormat.type === "NUMBER" ||
3403
+ (displaySuggestsCurrency &&
3404
+ detectedNumberFormatType === "CURRENCY");
3405
+ if (shouldOverrideExistingFormat) {
3406
+ mergedFormat = mergedFormat
3407
+ ? __assign({}, mergedFormat) : {};
3408
+ mergedFormat.numberFormat = __assign({ type: detectedNumberFormatType }, (detectedPattern
3409
+ ? { pattern: detectedPattern }
3410
+ : {}));
3411
+ }
3412
+ }
3413
+ }
3414
+ }
3415
+ if (!hasCellValue && !mergedFormat) {
3416
+ columnIndex++;
3417
+ continue;
3418
+ }
3419
+ finalCellData = hasCellValue
3420
+ ? __assign({}, cellData) : {};
3421
+ if (mergedFormat) {
3422
+ if (enableCellXfsRegistry) {
3423
+ styleId = this.registerFormat(mergedFormat);
3424
+ finalCellData.ef = { sid: styleId };
3425
+ finalCellData.uf = { sid: styleId };
3426
+ }
3427
+ else {
3428
+ finalCellData.userEnteredFormat = mergedFormat;
3429
+ }
3430
+ }
3431
+ rowData.values[targetColumnIndex] = finalCellData;
3432
+ columnIndex++;
3433
+ }
3434
+ }
3435
+ }
3436
+ catch (e_61_1) { e_61 = { error: e_61_1 }; }
3437
+ finally {
3438
+ try {
3439
+ if (normalizedRowChildren_3_1 && !normalizedRowChildren_3_1.done && (_k = normalizedRowChildren_3.return)) _k.call(normalizedRowChildren_3);
3440
+ }
3441
+ finally { if (e_61) throw e_61.error; }
3442
+ }
3443
+ }
3444
+ sheetSparklines = this.sparklinesBySheet.get(sheetId);
3445
+ if (sheetSparklines) {
3446
+ rowSparklines = sheetSparklines.get(currentRowIndex);
3447
+ if (rowSparklines) {
3448
+ try {
3449
+ for (_c = (e_62 = void 0, __values(rowSparklines.entries())), _d = _c.next(); !_d.done; _d = _c.next()) {
3450
+ _e = __read(_d.value, 2), colIndex = _e[0], sparkline = _e[1];
3451
+ existingCell = rowData.values[colIndex];
3452
+ // Only set formula if cell doesn't already have one
3453
+ if ((_r = existingCell === null || existingCell === void 0 ? void 0 : existingCell.ue) === null || _r === void 0 ? void 0 : _r.fv) {
3454
+ continue;
3455
+ }
3456
+ sparklineData = extractSparklineData(sparkline, currentRowIndex, rowData.values);
3457
+ sparklineOptions = {};
3458
+ if (sparkline.chartType !== "line") {
3459
+ sparklineOptions.charttype = sparkline.chartType;
3460
+ }
3461
+ if (sparkline.color) {
3462
+ sparklineOptions.color = sparkline.color;
3463
+ }
3464
+ cellData = __assign(__assign({}, existingCell), { ue: { fv: sparkline.formula } });
3465
+ // Only set effective value if we have enough data points
3466
+ if (sparklineData.length >= 2) {
3467
+ cellData.ev = {
3468
+ structuredValue: {
3469
+ kind: "sparkline",
3470
+ data: sparklineData,
3471
+ options: sparklineOptions,
3472
+ },
3473
+ };
3474
+ }
3475
+ rowData.values[colIndex] = cellData;
3476
+ }
3477
+ }
3478
+ catch (e_62_1) { e_62 = { error: e_62_1 }; }
3479
+ finally {
3480
+ try {
3481
+ if (_d && !_d.done && (_l = _c.return)) _l.call(_c);
3482
+ }
3483
+ finally { if (e_62) throw e_62.error; }
3484
+ }
3485
+ // Clean up processed sparklines
3486
+ sheetSparklines.delete(currentRowIndex);
3487
+ }
3488
+ }
3489
+ dvStamper.stampRow(currentRowIndex, rowData.values);
3490
+ isRowEmpty = rowData.values.length === 0;
3491
+ if (isRowEmpty) {
3492
+ currentRowIndex++;
3493
+ if (r === 0 && effectiveRepeats > 1) {
3494
+ currentRowIndex += effectiveRepeats - 1;
3495
+ return [3 /*break*/, 17];
3496
+ }
3497
+ return [3 /*break*/, 16];
3498
+ }
3499
+ currentChunk.push(rowData);
3500
+ currentChunkRowIndices.push(currentRowIndex);
3501
+ currentRowIndex++;
3502
+ if (!(currentChunk.length >= chunkSize)) return [3 /*break*/, 16];
3503
+ return [4 /*yield*/, __await({
3504
+ sheetId: sheetId,
3505
+ title: name_4,
3506
+ currentSheetIndex: currentSheetIndex,
3507
+ totalSheets: totalSheets,
3508
+ chunkIndex: chunkIndex,
3509
+ rows: currentChunk,
3510
+ rowIndices: currentChunkRowIndices,
3511
+ startRowIndex: currentChunkRowIndices[0],
3512
+ endRowIndex: currentChunkRowIndices[currentChunk.length - 1],
3513
+ totalRows: -1,
3514
+ isLastChunk: false,
3515
+ cellXfs: enableCellXfsRegistry ? this.cellXfs : new Map(),
3516
+ })];
3517
+ case 14: return [4 /*yield*/, _s.sent()];
3518
+ case 15:
3519
+ _s.sent();
3520
+ currentChunk = [];
3521
+ currentChunkRowIndices = [];
3522
+ chunkIndex++;
3523
+ _s.label = 16;
3524
+ case 16:
3525
+ r++;
3526
+ return [3 /*break*/, 13];
3527
+ case 17:
3528
+ rows_4_1 = rows_4.next();
3529
+ return [3 /*break*/, 12];
3530
+ case 18: return [3 /*break*/, 21];
3531
+ case 19:
3532
+ e_58_1 = _s.sent();
3533
+ e_58 = { error: e_58_1 };
3534
+ return [3 /*break*/, 21];
3535
+ case 20:
3536
+ try {
3537
+ if (rows_4_1 && !rows_4_1.done && (_j = rows_4.return)) _j.call(rows_4);
3538
+ }
3539
+ finally { if (e_58) throw e_58.error; }
3540
+ return [7 /*endfinally*/];
3541
+ case 21:
3542
+ _s.trys.push([21, 27, 28, 29]);
3543
+ _f = (e_59 = void 0, __values(dvStamper.trailingRows())), _g = _f.next();
3544
+ _s.label = 22;
3545
+ case 22:
3546
+ if (!!_g.done) return [3 /*break*/, 26];
3547
+ trailing = _g.value;
3548
+ currentChunk.push({ values: trailing.values });
3549
+ currentChunkRowIndices.push(trailing.rowIndex);
3550
+ if (!(currentChunk.length >= chunkSize)) return [3 /*break*/, 25];
3551
+ return [4 /*yield*/, __await({
3552
+ sheetId: sheetId,
3553
+ title: name_4,
3554
+ currentSheetIndex: currentSheetIndex,
3555
+ totalSheets: totalSheets,
3556
+ chunkIndex: chunkIndex,
3557
+ rows: currentChunk,
3558
+ rowIndices: currentChunkRowIndices,
3559
+ startRowIndex: currentChunkRowIndices[0],
3560
+ endRowIndex: currentChunkRowIndices[currentChunk.length - 1],
3561
+ totalRows: -1,
3562
+ isLastChunk: false,
3563
+ cellXfs: enableCellXfsRegistry ? this.cellXfs : new Map(),
3564
+ })];
3565
+ case 23: return [4 /*yield*/, _s.sent()];
3566
+ case 24:
3567
+ _s.sent();
3568
+ currentChunk = [];
3569
+ currentChunkRowIndices = [];
3570
+ chunkIndex++;
3571
+ _s.label = 25;
3572
+ case 25:
3573
+ _g = _f.next();
3574
+ return [3 /*break*/, 22];
3575
+ case 26: return [3 /*break*/, 29];
3576
+ case 27:
3577
+ e_59_1 = _s.sent();
3578
+ e_59 = { error: e_59_1 };
3579
+ return [3 /*break*/, 29];
3580
+ case 28:
3581
+ try {
3582
+ if (_g && !_g.done && (_m = _f.return)) _m.call(_f);
3583
+ }
3584
+ finally { if (e_59) throw e_59.error; }
3585
+ return [7 /*endfinally*/];
3586
+ case 29:
3587
+ if (!(currentChunk.length > 0)) return [3 /*break*/, 32];
3588
+ return [4 /*yield*/, __await({
3589
+ sheetId: sheetId,
3590
+ title: name_4,
3591
+ currentSheetIndex: currentSheetIndex,
3592
+ totalSheets: totalSheets,
3593
+ chunkIndex: chunkIndex,
3594
+ rows: currentChunk,
3595
+ rowIndices: currentChunkRowIndices,
3596
+ startRowIndex: currentChunkRowIndices[0],
3597
+ endRowIndex: currentChunkRowIndices[currentChunk.length - 1],
3598
+ totalRows: currentRowIndex - 1,
3599
+ isLastChunk: true,
3600
+ cellXfs: enableCellXfsRegistry ? this.cellXfs : new Map(),
3601
+ })];
3602
+ case 30: return [4 /*yield*/, _s.sent()];
3603
+ case 31:
3604
+ _s.sent();
3605
+ return [3 /*break*/, 35];
3606
+ case 32: return [4 /*yield*/, __await({
3607
+ sheetId: sheetId,
3608
+ title: name_4,
3609
+ currentSheetIndex: currentSheetIndex,
3610
+ totalSheets: totalSheets,
3611
+ chunkIndex: chunkIndex,
3612
+ rows: [],
3613
+ rowIndices: [],
3614
+ startRowIndex: 0,
3615
+ endRowIndex: 0,
3616
+ totalRows: 0,
3617
+ isLastChunk: true,
3618
+ cellXfs: enableCellXfsRegistry ? this.cellXfs : new Map(),
3619
+ })];
3620
+ case 33:
3621
+ // Empty sheet
3622
+ return [4 /*yield*/, _s.sent()];
3623
+ case 34:
3624
+ // Empty sheet
3625
+ _s.sent();
3626
+ _s.label = 35;
3627
+ case 35:
3628
+ currentSheetIndex++;
3629
+ return [3 /*break*/, 9];
3630
+ case 36: return [3 /*break*/, 38];
3631
+ case 37:
3632
+ error_1 = _s.sent();
3633
+ console.error("Error processing ODS sheet data", error_1);
3634
+ throw error_1;
3635
+ case 38: return [2 /*return*/];
3636
+ }
3637
+ });
3638
+ });
3639
+ };
3640
+ return OdsPlugin;
3641
+ }(BaseWorkbookPlugin));
3642
+ export { OdsPlugin };