js.documents 1.57.0 → 1.58.0

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 (454) hide show
  1. package/README.md +38 -0
  2. package/dist/blr-types-CYYC3yYU.d.cts +35 -0
  3. package/dist/blr-types-CYYC3yYU.d.ts +35 -0
  4. package/dist/cell-CNHPsDEk.d.cts +17 -0
  5. package/dist/cell-CNHPsDEk.d.ts +17 -0
  6. package/dist/color-71eoF1Up.d.cts +2 -0
  7. package/dist/color-Bo228AY2.d.ts +2 -0
  8. package/dist/convert/codec.cjs +51 -0
  9. package/dist/convert/codec.d.cts +13 -0
  10. package/dist/convert/codec.d.ts +13 -0
  11. package/dist/convert/codec.js +42 -0
  12. package/dist/convert/convert.cjs +443 -0
  13. package/dist/convert/convert.d.cts +55 -0
  14. package/dist/convert/convert.d.ts +55 -0
  15. package/dist/convert/convert.js +419 -0
  16. package/dist/convert/local.cjs +393 -0
  17. package/dist/convert/local.d.cts +5 -0
  18. package/dist/convert/local.d.ts +5 -0
  19. package/dist/convert/local.js +392 -0
  20. package/dist/convert/port.cjs +0 -0
  21. package/dist/convert/port.d.cts +34 -0
  22. package/dist/convert/port.d.ts +34 -0
  23. package/dist/convert/port.js +0 -0
  24. package/dist/edit/docx/content.cjs +71 -0
  25. package/dist/edit/docx/content.d.cts +6 -0
  26. package/dist/edit/docx/content.d.ts +6 -0
  27. package/dist/edit/docx/content.js +70 -0
  28. package/dist/edit/docx/editor.cjs +116 -0
  29. package/dist/edit/docx/editor.d.cts +23 -0
  30. package/dist/edit/docx/editor.d.ts +23 -0
  31. package/dist/edit/docx/editor.js +113 -0
  32. package/dist/edit/docx/image.cjs +74 -0
  33. package/dist/edit/docx/image.d.cts +2 -0
  34. package/dist/edit/docx/image.d.ts +2 -0
  35. package/dist/edit/docx/image.js +72 -0
  36. package/dist/edit/docx/paragraph.cjs +132 -0
  37. package/dist/edit/docx/paragraph.d.cts +40 -0
  38. package/dist/edit/docx/paragraph.d.ts +40 -0
  39. package/dist/edit/docx/paragraph.js +130 -0
  40. package/dist/edit/docx/props.cjs +132 -0
  41. package/dist/edit/docx/props.d.cts +20 -0
  42. package/dist/edit/docx/props.d.ts +20 -0
  43. package/dist/edit/docx/props.js +117 -0
  44. package/dist/edit/docx/run.cjs +143 -0
  45. package/dist/edit/docx/run.d.cts +2 -0
  46. package/dist/edit/docx/run.d.ts +2 -0
  47. package/dist/edit/docx/run.js +141 -0
  48. package/dist/edit/docx/scaffold.cjs +97 -0
  49. package/dist/edit/docx/scaffold.d.cts +5 -0
  50. package/dist/edit/docx/scaffold.d.ts +5 -0
  51. package/dist/edit/docx/scaffold.js +96 -0
  52. package/dist/edit/docx/table.cjs +99 -0
  53. package/dist/edit/docx/table.d.cts +34 -0
  54. package/dist/edit/docx/table.d.ts +34 -0
  55. package/dist/edit/docx/table.js +95 -0
  56. package/dist/edit/odg/content.cjs +65 -0
  57. package/dist/edit/odg/content.d.cts +6 -0
  58. package/dist/edit/odg/content.d.ts +6 -0
  59. package/dist/edit/odg/content.js +64 -0
  60. package/dist/edit/odg/editor.cjs +96 -0
  61. package/dist/edit/odg/editor.d.cts +19 -0
  62. package/dist/edit/odg/editor.d.ts +19 -0
  63. package/dist/edit/odg/editor.js +93 -0
  64. package/dist/edit/odg/page.cjs +70 -0
  65. package/dist/edit/odg/page.d.cts +34 -0
  66. package/dist/edit/odg/page.d.ts +34 -0
  67. package/dist/edit/odg/page.js +69 -0
  68. package/dist/edit/odg/scaffold.cjs +106 -0
  69. package/dist/edit/odg/scaffold.d.cts +7 -0
  70. package/dist/edit/odg/scaffold.d.ts +7 -0
  71. package/dist/edit/odg/scaffold.js +103 -0
  72. package/dist/edit/odg/style.cjs +83 -0
  73. package/dist/edit/odg/style.d.cts +14 -0
  74. package/dist/edit/odg/style.d.ts +14 -0
  75. package/dist/edit/odg/style.js +78 -0
  76. package/dist/edit/odg/svg-path.cjs +30 -0
  77. package/dist/edit/odg/svg-path.d.cts +7 -0
  78. package/dist/edit/odg/svg-path.d.ts +7 -0
  79. package/dist/edit/odg/svg-path.js +27 -0
  80. package/dist/edit/odg/vector.cjs +208 -0
  81. package/dist/edit/odg/vector.d.cts +2 -0
  82. package/dist/edit/odg/vector.d.ts +2 -0
  83. package/dist/edit/odg/vector.js +201 -0
  84. package/dist/edit/odp/content.cjs +42 -0
  85. package/dist/edit/odp/content.d.cts +6 -0
  86. package/dist/edit/odp/content.d.ts +6 -0
  87. package/dist/edit/odp/content.js +41 -0
  88. package/dist/edit/odp/editor.cjs +113 -0
  89. package/dist/edit/odp/editor.d.cts +20 -0
  90. package/dist/edit/odp/editor.d.ts +20 -0
  91. package/dist/edit/odp/editor.js +110 -0
  92. package/dist/edit/odp/image.cjs +10 -0
  93. package/dist/edit/odp/image.d.cts +2 -0
  94. package/dist/edit/odp/image.d.ts +2 -0
  95. package/dist/edit/odp/image.js +9 -0
  96. package/dist/edit/odp/scaffold.cjs +108 -0
  97. package/dist/edit/odp/scaffold.d.cts +7 -0
  98. package/dist/edit/odp/scaffold.d.ts +7 -0
  99. package/dist/edit/odp/scaffold.js +105 -0
  100. package/dist/edit/odp/shape.cjs +133 -0
  101. package/dist/edit/odp/shape.d.cts +2 -0
  102. package/dist/edit/odp/shape.d.ts +2 -0
  103. package/dist/edit/odp/shape.js +130 -0
  104. package/dist/edit/odp/slide.cjs +80 -0
  105. package/dist/edit/odp/slide.d.cts +31 -0
  106. package/dist/edit/odp/slide.d.ts +31 -0
  107. package/dist/edit/odp/slide.js +79 -0
  108. package/dist/edit/ods/address.cjs +108 -0
  109. package/dist/edit/ods/address.d.cts +15 -0
  110. package/dist/edit/ods/address.d.ts +15 -0
  111. package/dist/edit/ods/address.js +97 -0
  112. package/dist/edit/ods/cell.cjs +177 -0
  113. package/dist/edit/ods/cell.d.cts +2 -0
  114. package/dist/edit/ods/cell.d.ts +2 -0
  115. package/dist/edit/ods/cell.js +176 -0
  116. package/dist/edit/ods/content.cjs +26 -0
  117. package/dist/edit/ods/content.d.cts +6 -0
  118. package/dist/edit/ods/content.d.ts +6 -0
  119. package/dist/edit/ods/content.js +25 -0
  120. package/dist/edit/ods/editor.cjs +84 -0
  121. package/dist/edit/ods/editor.d.cts +17 -0
  122. package/dist/edit/ods/editor.d.ts +17 -0
  123. package/dist/edit/ods/editor.js +81 -0
  124. package/dist/edit/ods/print-settings.cjs +90 -0
  125. package/dist/edit/ods/print-settings.d.cts +7 -0
  126. package/dist/edit/ods/print-settings.d.ts +7 -0
  127. package/dist/edit/ods/print-settings.js +88 -0
  128. package/dist/edit/ods/scaffold.cjs +129 -0
  129. package/dist/edit/ods/scaffold.d.cts +9 -0
  130. package/dist/edit/ods/scaffold.d.ts +9 -0
  131. package/dist/edit/ods/scaffold.js +124 -0
  132. package/dist/edit/ods/sheet.cjs +70 -0
  133. package/dist/edit/ods/sheet.d.cts +22 -0
  134. package/dist/edit/ods/sheet.d.ts +22 -0
  135. package/dist/edit/ods/sheet.js +69 -0
  136. package/dist/edit/odt/automatic-styles.cjs +49 -0
  137. package/dist/edit/odt/automatic-styles.d.cts +8 -0
  138. package/dist/edit/odt/automatic-styles.d.ts +8 -0
  139. package/dist/edit/odt/automatic-styles.js +45 -0
  140. package/dist/edit/odt/content.cjs +110 -0
  141. package/dist/edit/odt/content.d.cts +9 -0
  142. package/dist/edit/odt/content.d.ts +9 -0
  143. package/dist/edit/odt/content.js +108 -0
  144. package/dist/edit/odt/editor.cjs +98 -0
  145. package/dist/edit/odt/editor.d.cts +25 -0
  146. package/dist/edit/odt/editor.d.ts +25 -0
  147. package/dist/edit/odt/editor.js +95 -0
  148. package/dist/edit/odt/list.cjs +82 -0
  149. package/dist/edit/odt/list.d.cts +2 -0
  150. package/dist/edit/odt/list.d.ts +2 -0
  151. package/dist/edit/odt/list.js +79 -0
  152. package/dist/edit/odt/paragraph.cjs +84 -0
  153. package/dist/edit/odt/paragraph.d.cts +2 -0
  154. package/dist/edit/odt/paragraph.d.ts +2 -0
  155. package/dist/edit/odt/paragraph.js +82 -0
  156. package/dist/edit/odt/props.cjs +26 -0
  157. package/dist/edit/odt/props.d.cts +7 -0
  158. package/dist/edit/odt/props.d.ts +7 -0
  159. package/dist/edit/odt/props.js +23 -0
  160. package/dist/edit/odt/run.cjs +82 -0
  161. package/dist/edit/odt/run.d.cts +2 -0
  162. package/dist/edit/odt/run.d.ts +2 -0
  163. package/dist/edit/odt/run.js +80 -0
  164. package/dist/edit/odt/scaffold.cjs +109 -0
  165. package/dist/edit/odt/scaffold.d.cts +5 -0
  166. package/dist/edit/odt/scaffold.d.ts +5 -0
  167. package/dist/edit/odt/scaffold.js +108 -0
  168. package/dist/edit/odt/table.cjs +123 -0
  169. package/dist/edit/odt/table.d.cts +37 -0
  170. package/dist/edit/odt/table.d.ts +37 -0
  171. package/dist/edit/odt/table.js +119 -0
  172. package/dist/edit/pptx/content.cjs +49 -0
  173. package/dist/edit/pptx/content.d.cts +6 -0
  174. package/dist/edit/pptx/content.d.ts +6 -0
  175. package/dist/edit/pptx/content.js +48 -0
  176. package/dist/edit/pptx/editor.cjs +187 -0
  177. package/dist/edit/pptx/editor.d.cts +20 -0
  178. package/dist/edit/pptx/editor.d.ts +20 -0
  179. package/dist/edit/pptx/editor.js +184 -0
  180. package/dist/edit/pptx/image.cjs +27 -0
  181. package/dist/edit/pptx/image.d.cts +2 -0
  182. package/dist/edit/pptx/image.d.ts +2 -0
  183. package/dist/edit/pptx/image.js +26 -0
  184. package/dist/edit/pptx/scaffold.cjs +292 -0
  185. package/dist/edit/pptx/scaffold.d.cts +13 -0
  186. package/dist/edit/pptx/scaffold.d.ts +13 -0
  187. package/dist/edit/pptx/scaffold.js +283 -0
  188. package/dist/edit/pptx/shape.cjs +182 -0
  189. package/dist/edit/pptx/shape.d.cts +2 -0
  190. package/dist/edit/pptx/shape.d.ts +2 -0
  191. package/dist/edit/pptx/shape.js +179 -0
  192. package/dist/edit/pptx/slide.cjs +146 -0
  193. package/dist/edit/pptx/slide.d.cts +33 -0
  194. package/dist/edit/pptx/slide.d.ts +33 -0
  195. package/dist/edit/pptx/slide.js +145 -0
  196. package/dist/firebird/backup.cjs +150 -0
  197. package/dist/firebird/backup.d.cts +21 -0
  198. package/dist/firebird/backup.d.ts +21 -0
  199. package/dist/firebird/backup.js +145 -0
  200. package/dist/firebird/blr-types.cjs +118 -0
  201. package/dist/firebird/blr-types.d.cts +2 -0
  202. package/dist/firebird/blr-types.d.ts +2 -0
  203. package/dist/firebird/blr-types.js +90 -0
  204. package/dist/firebird/data.cjs +231 -0
  205. package/dist/firebird/data.d.cts +17 -0
  206. package/dist/firebird/data.d.ts +17 -0
  207. package/dist/firebird/data.js +228 -0
  208. package/dist/firebird/date.cjs +63 -0
  209. package/dist/firebird/date.d.cts +17 -0
  210. package/dist/firebird/date.d.ts +17 -0
  211. package/dist/firebird/date.js +58 -0
  212. package/dist/firebird/reader.cjs +157 -0
  213. package/dist/firebird/reader.d.cts +2 -0
  214. package/dist/firebird/reader.d.ts +2 -0
  215. package/dist/firebird/reader.js +154 -0
  216. package/dist/firebird/schema.cjs +91 -0
  217. package/dist/firebird/schema.d.cts +2 -0
  218. package/dist/firebird/schema.d.ts +2 -0
  219. package/dist/firebird/schema.js +89 -0
  220. package/dist/geometry-DvwdrIij.d.cts +5 -0
  221. package/dist/geometry-DvwdrIij.d.ts +5 -0
  222. package/dist/hsqldb/cache.cjs +88 -0
  223. package/dist/hsqldb/cache.d.cts +13 -0
  224. package/dist/hsqldb/cache.d.ts +13 -0
  225. package/dist/hsqldb/cache.js +84 -0
  226. package/dist/hsqldb/rowformat.cjs +222 -0
  227. package/dist/hsqldb/rowformat.d.cts +21 -0
  228. package/dist/hsqldb/rowformat.d.ts +21 -0
  229. package/dist/hsqldb/rowformat.js +218 -0
  230. package/dist/hsqldb/script.cjs +450 -0
  231. package/dist/hsqldb/script.d.cts +19 -0
  232. package/dist/hsqldb/script.d.ts +19 -0
  233. package/dist/hsqldb/script.js +447 -0
  234. package/dist/image-B-xQWYYS.d.ts +16 -0
  235. package/dist/image-BZDy72Jb.d.cts +16 -0
  236. package/dist/image-BfRLAD9B.d.cts +18 -0
  237. package/dist/image-BfRLAD9B.d.ts +18 -0
  238. package/dist/image-CeqwL-Qs.d.ts +14 -0
  239. package/dist/image-DWX6cNOD.d.cts +14 -0
  240. package/dist/index.cjs +201 -10863
  241. package/dist/index.d.cts +71 -1406
  242. package/dist/index.d.ts +71 -1406
  243. package/dist/index.js +67 -10727
  244. package/dist/layout/drawing.cjs +117 -0
  245. package/dist/layout/drawing.d.cts +13 -0
  246. package/dist/layout/drawing.d.ts +13 -0
  247. package/dist/layout/drawing.js +116 -0
  248. package/dist/layout/engine.cjs +216 -0
  249. package/dist/layout/engine.d.cts +19 -0
  250. package/dist/layout/engine.d.ts +19 -0
  251. package/dist/layout/engine.js +215 -0
  252. package/dist/layout/reconstruct.cjs +809 -0
  253. package/dist/layout/reconstruct.d.cts +12 -0
  254. package/dist/layout/reconstruct.d.ts +12 -0
  255. package/dist/layout/reconstruct.js +805 -0
  256. package/dist/layout/shared.cjs +104 -0
  257. package/dist/layout/shared.d.cts +15 -0
  258. package/dist/layout/shared.d.ts +15 -0
  259. package/dist/layout/shared.js +96 -0
  260. package/dist/layout/sheets.cjs +413 -0
  261. package/dist/layout/sheets.d.cts +14 -0
  262. package/dist/layout/sheets.d.ts +14 -0
  263. package/dist/layout/sheets.js +414 -0
  264. package/dist/layout/slides.cjs +194 -0
  265. package/dist/layout/slides.d.cts +25 -0
  266. package/dist/layout/slides.d.ts +25 -0
  267. package/dist/layout/slides.js +192 -0
  268. package/dist/list-BuBM9rwQ.d.cts +24 -0
  269. package/dist/list-CvKxhy3y.d.ts +24 -0
  270. package/dist/mathml/compose.cjs +53 -0
  271. package/dist/mathml/compose.d.cts +8 -0
  272. package/dist/mathml/compose.d.ts +8 -0
  273. package/dist/mathml/compose.js +49 -0
  274. package/dist/mathml/layout-types.cjs +0 -0
  275. package/dist/mathml/layout-types.d.cts +50 -0
  276. package/dist/mathml/layout-types.d.ts +50 -0
  277. package/dist/mathml/layout-types.js +0 -0
  278. package/dist/mathml/layout.cjs +373 -0
  279. package/dist/mathml/layout.d.cts +24 -0
  280. package/dist/mathml/layout.d.ts +24 -0
  281. package/dist/mathml/layout.js +371 -0
  282. package/dist/mathml/length.cjs +41 -0
  283. package/dist/mathml/length.d.cts +4 -0
  284. package/dist/mathml/length.d.ts +4 -0
  285. package/dist/mathml/length.js +40 -0
  286. package/dist/mathml/metrics.cjs +0 -0
  287. package/dist/mathml/metrics.d.cts +44 -0
  288. package/dist/mathml/metrics.d.ts +44 -0
  289. package/dist/mathml/metrics.js +0 -0
  290. package/dist/mathml/nodes.cjs +39 -0
  291. package/dist/mathml/nodes.d.cts +2 -0
  292. package/dist/mathml/nodes.d.ts +2 -0
  293. package/dist/mathml/nodes.js +32 -0
  294. package/dist/mathml/operators.cjs +189 -0
  295. package/dist/mathml/operators.d.cts +13 -0
  296. package/dist/mathml/operators.d.ts +13 -0
  297. package/dist/mathml/operators.js +188 -0
  298. package/dist/mathml/radical.cjs +46 -0
  299. package/dist/mathml/radical.d.cts +10 -0
  300. package/dist/mathml/radical.d.ts +10 -0
  301. package/dist/mathml/radical.js +45 -0
  302. package/dist/mathml/variant.cjs +1160 -0
  303. package/dist/mathml/variant.d.cts +7 -0
  304. package/dist/mathml/variant.d.ts +7 -0
  305. package/dist/mathml/variant.js +1157 -0
  306. package/dist/model/bytes.cjs +88 -0
  307. package/dist/model/bytes.d.cts +12 -0
  308. package/dist/model/bytes.d.ts +12 -0
  309. package/dist/model/bytes.js +80 -0
  310. package/dist/model/color.cjs +26 -0
  311. package/dist/model/color.d.cts +2 -0
  312. package/dist/model/color.d.ts +2 -0
  313. package/dist/model/color.js +2 -0
  314. package/dist/model/content.cjs +34 -0
  315. package/dist/model/content.d.cts +362 -0
  316. package/dist/model/content.d.ts +362 -0
  317. package/dist/model/content.js +32 -0
  318. package/dist/model/formula.cjs +0 -0
  319. package/dist/model/formula.d.cts +8 -0
  320. package/dist/model/formula.d.ts +8 -0
  321. package/dist/model/formula.js +0 -0
  322. package/dist/model/geometry.cjs +55 -0
  323. package/dist/model/geometry.d.cts +2 -0
  324. package/dist/model/geometry.d.ts +2 -0
  325. package/dist/model/geometry.js +12 -0
  326. package/dist/model/style.cjs +20 -0
  327. package/dist/model/style.d.cts +2 -0
  328. package/dist/model/style.d.ts +2 -0
  329. package/dist/model/style.js +2 -0
  330. package/dist/model/units.cjs +55 -0
  331. package/dist/model/units.d.cts +20 -0
  332. package/dist/model/units.d.ts +20 -0
  333. package/dist/model/units.js +38 -0
  334. package/dist/nodes-pArN9ilm.d.cts +27 -0
  335. package/dist/nodes-pArN9ilm.d.ts +27 -0
  336. package/dist/odb/csv.cjs +48 -0
  337. package/dist/odb/csv.d.cts +14 -0
  338. package/dist/odb/csv.d.ts +14 -0
  339. package/dist/odb/csv.js +45 -0
  340. package/dist/odb/read.cjs +87 -0
  341. package/dist/odb/read.d.cts +15 -0
  342. package/dist/odb/read.d.ts +15 -0
  343. package/dist/odb/read.js +85 -0
  344. package/dist/odb/spreadsheet.cjs +68 -0
  345. package/dist/odb/spreadsheet.d.cts +6 -0
  346. package/dist/odb/spreadsheet.d.ts +6 -0
  347. package/dist/odb/spreadsheet.js +67 -0
  348. package/dist/odf/formula/detect.cjs +29 -0
  349. package/dist/odf/formula/detect.d.cts +12 -0
  350. package/dist/odf/formula/detect.d.ts +12 -0
  351. package/dist/odf/formula/detect.js +28 -0
  352. package/dist/odf/formula/placeholder.cjs +37 -0
  353. package/dist/odf/formula/placeholder.d.cts +14 -0
  354. package/dist/odf/formula/placeholder.d.ts +14 -0
  355. package/dist/odf/formula/placeholder.js +36 -0
  356. package/dist/odf/formula/read.cjs +32 -0
  357. package/dist/odf/formula/read.d.cts +11 -0
  358. package/dist/odf/formula/read.d.ts +11 -0
  359. package/dist/odf/formula/read.js +30 -0
  360. package/dist/odf/odg/read.cjs +15 -0
  361. package/dist/odf/odg/read.d.cts +6 -0
  362. package/dist/odf/odg/read.d.ts +6 -0
  363. package/dist/odf/odg/read.js +14 -0
  364. package/dist/odf/odp/read.cjs +45 -0
  365. package/dist/odf/odp/read.d.cts +11 -0
  366. package/dist/odf/odp/read.d.ts +11 -0
  367. package/dist/odf/odp/read.js +44 -0
  368. package/dist/odf/ods/read.cjs +15 -0
  369. package/dist/odf/ods/read.d.cts +6 -0
  370. package/dist/odf/ods/read.d.ts +6 -0
  371. package/dist/odf/ods/read.js +14 -0
  372. package/dist/odf/odt/read.cjs +43 -0
  373. package/dist/odf/odt/read.d.cts +11 -0
  374. package/dist/odf/odt/read.d.ts +11 -0
  375. package/dist/odf/odt/read.js +42 -0
  376. package/dist/odf-package/manifest.cjs +62 -0
  377. package/dist/odf-package/manifest.d.cts +2 -0
  378. package/dist/odf-package/manifest.d.ts +2 -0
  379. package/dist/odf-package/manifest.js +2 -0
  380. package/dist/odf-package/media.cjs +34 -0
  381. package/dist/odf-package/media.d.cts +8 -0
  382. package/dist/odf-package/media.d.ts +8 -0
  383. package/dist/odf-package/media.js +34 -0
  384. package/dist/ooxml/docx/read.cjs +15 -0
  385. package/dist/ooxml/docx/read.d.cts +6 -0
  386. package/dist/ooxml/docx/read.d.ts +6 -0
  387. package/dist/ooxml/docx/read.js +14 -0
  388. package/dist/ooxml/pptx/read.cjs +15 -0
  389. package/dist/ooxml/pptx/read.d.cts +6 -0
  390. package/dist/ooxml/pptx/read.d.ts +6 -0
  391. package/dist/ooxml/pptx/read.js +14 -0
  392. package/dist/opc/content-types.cjs +47 -0
  393. package/dist/opc/content-types.d.cts +7 -0
  394. package/dist/opc/content-types.d.ts +7 -0
  395. package/dist/opc/content-types.js +44 -0
  396. package/dist/opc/media.cjs +45 -0
  397. package/dist/opc/media.d.cts +10 -0
  398. package/dist/opc/media.d.ts +10 -0
  399. package/dist/opc/media.js +44 -0
  400. package/dist/opc/paths.cjs +28 -0
  401. package/dist/opc/paths.d.cts +5 -0
  402. package/dist/opc/paths.d.ts +5 -0
  403. package/dist/opc/paths.js +26 -0
  404. package/dist/opc/rels.cjs +47 -0
  405. package/dist/opc/rels.d.cts +10 -0
  406. package/dist/opc/rels.d.ts +10 -0
  407. package/dist/opc/rels.js +46 -0
  408. package/dist/paragraph-BXbXKPy3.d.cts +30 -0
  409. package/dist/paragraph-CoUi_88j.d.ts +30 -0
  410. package/dist/ports/abort.cjs +7 -0
  411. package/dist/ports/abort.d.cts +4 -0
  412. package/dist/ports/abort.d.ts +4 -0
  413. package/dist/ports/abort.js +6 -0
  414. package/dist/ports/clock.cjs +9 -0
  415. package/dist/ports/clock.d.cts +8 -0
  416. package/dist/ports/clock.d.ts +8 -0
  417. package/dist/ports/clock.js +7 -0
  418. package/dist/reader-DP0Mbaj4.d.cts +41 -0
  419. package/dist/reader-DP0Mbaj4.d.ts +41 -0
  420. package/dist/run-B3GNScJH.d.cts +38 -0
  421. package/dist/run-CJfh8rv3.d.ts +38 -0
  422. package/dist/run-D2rTWHbt.d.ts +38 -0
  423. package/dist/run-F8JN7Vy4.d.cts +38 -0
  424. package/dist/schema-Acco3Ezi.d.cts +22 -0
  425. package/dist/schema-VkAA6pF5.d.ts +22 -0
  426. package/dist/shape-BUfjw5eZ.d.cts +35 -0
  427. package/dist/shape-BfN3m52m.d.ts +30 -0
  428. package/dist/shape-CN2ycxOo.d.cts +30 -0
  429. package/dist/shape-CTkl6kt8.d.ts +35 -0
  430. package/dist/style-DkamR3aY.d.cts +2 -0
  431. package/dist/style-DkamR3aY.d.ts +2 -0
  432. package/dist/vector-ClohqsOe.d.cts +76 -0
  433. package/dist/vector-ClohqsOe.d.ts +76 -0
  434. package/dist/xml/edit.cjs +65 -0
  435. package/dist/xml/edit.d.cts +12 -0
  436. package/dist/xml/edit.d.ts +12 -0
  437. package/dist/xml/edit.js +57 -0
  438. package/dist/xml/entities.cjs +12 -0
  439. package/dist/xml/entities.d.cts +5 -0
  440. package/dist/xml/entities.d.ts +5 -0
  441. package/dist/xml/entities.js +10 -0
  442. package/dist/xml/fragment.cjs +22 -0
  443. package/dist/xml/fragment.d.cts +6 -0
  444. package/dist/xml/fragment.d.ts +6 -0
  445. package/dist/xml/fragment.js +20 -0
  446. package/dist/xml/odf-text.cjs +53 -0
  447. package/dist/xml/odf-text.d.cts +6 -0
  448. package/dist/xml/odf-text.d.ts +6 -0
  449. package/dist/xml/odf-text.js +51 -0
  450. package/dist/xml/query.cjs +33 -0
  451. package/dist/xml/query.d.cts +12 -0
  452. package/dist/xml/query.d.ts +12 -0
  453. package/dist/xml/query.js +29 -0
  454. package/package.json +9 -1
@@ -0,0 +1,805 @@
1
+ import "../model/content.js";
2
+ import { flipY } from "../model/geometry.js";
3
+ import { throwIfAborted } from "../ports/abort.js";
4
+ import { STANDARD_METRICS, resolveStandardFont } from "pdf-codec";
5
+ //#region src/layout/reconstruct.ts
6
+ const ZERO_MARGINS = {
7
+ topPt: 0,
8
+ rightPt: 0,
9
+ bottomPt: 0,
10
+ leftPt: 0
11
+ };
12
+ const LINE_BASELINE_TOLERANCE_FACTOR = .5;
13
+ function clusterIntoLines(items) {
14
+ const sorted = [...items].sort((a, b) => b.yPt - a.yPt || a.xPt - b.xPt);
15
+ const working = [];
16
+ for (const item of sorted) {
17
+ const tolerance = LINE_BASELINE_TOLERANCE_FACTOR * item.sizePt;
18
+ const line = working.find((l) => Math.abs(l.baselineY - item.yPt) <= tolerance);
19
+ if (line === void 0) working.push({
20
+ items: [item],
21
+ baselineY: item.yPt
22
+ });
23
+ else line.items.push(item);
24
+ }
25
+ for (const line of working) line.items.sort((a, b) => a.xPt - b.xPt);
26
+ working.sort((a, b) => b.baselineY - a.baselineY);
27
+ return working;
28
+ }
29
+ function textItemVerticalExtent(item) {
30
+ const { standardName } = resolveStandardFont(item.font.family, item.font.weight === "bold", item.font.style === "italic");
31
+ const metrics = STANDARD_METRICS[standardName];
32
+ return {
33
+ ascentPt: metrics.ascender / 1e3 * item.sizePt,
34
+ descentPt: Math.abs(metrics.descender) / 1e3 * item.sizePt
35
+ };
36
+ }
37
+ function textItemToContentRun(item) {
38
+ return {
39
+ text: item.text,
40
+ bold: item.font.weight === "bold" ? true : void 0,
41
+ italic: item.font.style === "italic" ? true : void 0,
42
+ fontFamily: item.font.family,
43
+ sizePt: item.sizePt,
44
+ color: item.color
45
+ };
46
+ }
47
+ const MIN_WORD_GAP_PT = .5;
48
+ function pushRunsForLine(runs, line) {
49
+ line.items.forEach((item, itemIndex) => {
50
+ if (itemIndex > 0) {
51
+ const prevItem = line.items[itemIndex - 1];
52
+ const gap = item.xPt - (prevItem.xPt + (prevItem.widthPt ?? 0));
53
+ if (gap > LARGE_GAP_EM_MULTIPLIER * item.sizePt) runs.push({ text: " " });
54
+ else if (gap > MIN_WORD_GAP_PT) runs[runs.length - 1].text += " ";
55
+ }
56
+ runs.push(textItemToContentRun(item));
57
+ });
58
+ }
59
+ function bucketCounts(values, bucketSize) {
60
+ const counts = /* @__PURE__ */ new Map();
61
+ for (const v of values) {
62
+ const bucket = Math.round(v / bucketSize) * bucketSize;
63
+ counts.set(bucket, (counts.get(bucket) ?? 0) + 1);
64
+ }
65
+ return counts;
66
+ }
67
+ function modeOf(values, bucketSize) {
68
+ if (values.length === 0) return 0;
69
+ const counts = bucketCounts(values, bucketSize);
70
+ let bestBucket = values[0];
71
+ let bestCount = 0;
72
+ for (const [bucket, count] of counts) if (count > bestCount) {
73
+ bestBucket = bucket;
74
+ bestCount = count;
75
+ }
76
+ return bestBucket;
77
+ }
78
+ function modalLineGap(gaps) {
79
+ const counts = bucketCounts(gaps, .5);
80
+ let bestBucket = gaps[0];
81
+ let bestCount = 0;
82
+ for (const [bucket, count] of counts) if (count > bestCount) {
83
+ bestBucket = bucket;
84
+ bestCount = count;
85
+ }
86
+ return bestCount > 1 ? bestBucket : Math.min(...gaps);
87
+ }
88
+ const LARGE_GAP_EM_MULTIPLIER = 2;
89
+ const PARAGRAPH_GAP_MULTIPLIER = 1.25;
90
+ const NOMINAL_LINE_SPACING_RATIO = 1.2;
91
+ const MIN_LINES_FOR_GAP_MODE = 3;
92
+ function estimateModalLineSpacing(lines) {
93
+ if (lines.length < MIN_LINES_FOR_GAP_MODE) return modeOf(lines.map((l) => l.items[0].sizePt), .5) * NOMINAL_LINE_SPACING_RATIO;
94
+ const gaps = [];
95
+ for (let i = 1; i < lines.length; i++) gaps.push(lines[i - 1].baselineY - lines[i].baselineY);
96
+ return modalLineGap(gaps);
97
+ }
98
+ function reconstructWordprocessing(doc, options) {
99
+ const signal = options?.signal;
100
+ const sections = [];
101
+ let currentGroup = [];
102
+ for (const page of doc.pages) {
103
+ throwIfAborted(signal);
104
+ if (currentGroup.length > 0 && !samePageSize(currentGroup[0], page)) {
105
+ sections.push(buildSection(currentGroup, doc.images));
106
+ currentGroup = [];
107
+ }
108
+ currentGroup.push(page);
109
+ }
110
+ if (currentGroup.length > 0) sections.push(buildSection(currentGroup, doc.images));
111
+ return {
112
+ kind: "wordprocessing",
113
+ formatVersion: 1,
114
+ metadata: doc.metadata,
115
+ sections
116
+ };
117
+ }
118
+ function samePageSize(a, b) {
119
+ return a.widthPt === b.widthPt && a.heightPt === b.heightPt;
120
+ }
121
+ function buildSection(pages, images) {
122
+ const blocks = [];
123
+ pages.forEach((page, i) => {
124
+ if (i > 0) blocks.push({ kind: "pageBreak" });
125
+ blocks.push(...reconstructPageBlocks(page, images));
126
+ });
127
+ return {
128
+ pageSize: {
129
+ widthPt: pages[0].widthPt,
130
+ heightPt: pages[0].heightPt
131
+ },
132
+ margins: ZERO_MARGINS,
133
+ blocks
134
+ };
135
+ }
136
+ function reconstructPageBlocks(page, images) {
137
+ const textItems = page.items.filter((i) => i.kind === "text");
138
+ const imageItems = page.items.filter((i) => i.kind === "image");
139
+ const paragraphs = clusterIntoParagraphs(clusterIntoLines(textItems));
140
+ const positioned = [];
141
+ for (const paragraph of paragraphs) positioned.push({
142
+ yPt: paragraph.lines[0].baselineY,
143
+ block: paragraphToContentParagraph(paragraph)
144
+ });
145
+ for (const img of imageItems) {
146
+ const asset = images[img.imageId];
147
+ if (asset !== void 0) positioned.push({
148
+ yPt: img.yPt,
149
+ block: {
150
+ kind: "image",
151
+ format: asset.format,
152
+ base64: asset.base64,
153
+ widthPt: img.widthPt,
154
+ heightPt: img.heightPt
155
+ }
156
+ });
157
+ }
158
+ positioned.sort((a, b) => b.yPt - a.yPt);
159
+ return positioned.map((p) => p.block);
160
+ }
161
+ function clusterIntoParagraphs(lines) {
162
+ if (lines.length === 0) return [];
163
+ const modalSpacing = estimateModalLineSpacing(lines);
164
+ const dominantLeftX = modeOf(lines.map((l) => l.items[0].xPt), 1);
165
+ const paragraphs = [{ lines: [lines[0]] }];
166
+ for (let i = 1; i < lines.length; i++) {
167
+ const prev = lines[i - 1];
168
+ const next = lines[i];
169
+ if (startsNewParagraph(prev, next, modalSpacing, dominantLeftX)) paragraphs.push({ lines: [next] });
170
+ else paragraphs[paragraphs.length - 1].lines.push(next);
171
+ }
172
+ return paragraphs;
173
+ }
174
+ function startsNewParagraph(prev, next, modalSpacing, dominantLeftX) {
175
+ if (prev.baselineY - next.baselineY > PARAGRAPH_GAP_MULTIPLIER * modalSpacing) return true;
176
+ const nextLeft = next.items[0].xPt;
177
+ const prevLeft = prev.items[0].xPt;
178
+ const emPt = next.items[0].sizePt;
179
+ const nextIndented = Math.abs(nextLeft - dominantLeftX) > emPt;
180
+ const prevAtMargin = Math.abs(prevLeft - dominantLeftX) <= emPt;
181
+ return nextIndented && prevAtMargin;
182
+ }
183
+ const LEFT_ALIGN_TOLERANCE_PT = 2;
184
+ function paragraphToContentParagraph(paragraph) {
185
+ const dominantLeftX = modeOf(paragraph.lines.map((l) => l.items[0].xPt), 1);
186
+ const alignment = paragraph.lines.every((l) => Math.abs(l.items[0].xPt - dominantLeftX) <= LEFT_ALIGN_TOLERANCE_PT) ? "left" : void 0;
187
+ const runs = [];
188
+ paragraph.lines.forEach((line, lineIndex) => {
189
+ if (lineIndex > 0) {
190
+ const lastRun = runs[runs.length - 1];
191
+ if (lastRun !== void 0) lastRun.text += " ";
192
+ }
193
+ pushRunsForLine(runs, line);
194
+ });
195
+ return {
196
+ kind: "paragraph",
197
+ runs,
198
+ alignment
199
+ };
200
+ }
201
+ function reconstructPresentation(doc, options) {
202
+ const signal = options?.signal;
203
+ const slides = doc.pages.map((page) => {
204
+ throwIfAborted(signal);
205
+ return reconstructSlide(page, doc.images);
206
+ });
207
+ return {
208
+ kind: "presentation",
209
+ formatVersion: 1,
210
+ metadata: doc.metadata,
211
+ slides
212
+ };
213
+ }
214
+ function reconstructSlide(page, images) {
215
+ const textItems = page.items.filter((i) => i.kind === "text");
216
+ const imageItems = page.items.filter((i) => i.kind === "image");
217
+ const textShapes = clusterIntoBlocks(clusterIntoLines(textItems)).map((block) => blockToShape(block, page.heightPt));
218
+ const imageShapes = [];
219
+ for (const img of imageItems) {
220
+ const shape = imageToShape(img, page.heightPt, images);
221
+ if (shape !== void 0) imageShapes.push(shape);
222
+ }
223
+ return {
224
+ size: {
225
+ widthPt: page.widthPt,
226
+ heightPt: page.heightPt
227
+ },
228
+ shapes: [...imageShapes, ...textShapes],
229
+ notes: page.notes ?? ""
230
+ };
231
+ }
232
+ function splitLineByLargeGaps(line) {
233
+ const segments = [];
234
+ let current = [];
235
+ line.items.forEach((item, i) => {
236
+ if (i > 0) {
237
+ const prev = line.items[i - 1];
238
+ if (item.xPt - (prev.xPt + (prev.widthPt ?? 0)) > LARGE_GAP_EM_MULTIPLIER * item.sizePt) {
239
+ segments.push({
240
+ items: current,
241
+ baselineY: line.baselineY
242
+ });
243
+ current = [];
244
+ }
245
+ }
246
+ current.push(item);
247
+ });
248
+ if (current.length > 0) segments.push({
249
+ items: current,
250
+ baselineY: line.baselineY
251
+ });
252
+ return segments;
253
+ }
254
+ const FONT_SIZE_CLOSE_TOLERANCE_PT = 1;
255
+ const FONT_SIZE_CLOSE_TOLERANCE_RATIO = .15;
256
+ function fontSizesClose(a, b) {
257
+ return Math.abs(a - b) <= FONT_SIZE_CLOSE_TOLERANCE_PT || Math.abs(a - b) / Math.max(a, b) <= FONT_SIZE_CLOSE_TOLERANCE_RATIO;
258
+ }
259
+ function clusterIntoBlocks(pageLines) {
260
+ const segments = pageLines.flatMap(splitLineByLargeGaps);
261
+ const blocks = [];
262
+ for (const segment of segments) {
263
+ const leftX = segment.items[0].xPt;
264
+ const sizePt = segment.items[0].sizePt;
265
+ const matched = blocks.find((block) => {
266
+ const lastLine = block.lines[block.lines.length - 1];
267
+ const lastLeftX = lastLine.items[0].xPt;
268
+ const lastSizePt = lastLine.items[0].sizePt;
269
+ const gap = lastLine.baselineY - segment.baselineY;
270
+ if (gap <= 0) return false;
271
+ return Math.abs(leftX - lastLeftX) <= LEFT_ALIGN_TOLERANCE_PT && fontSizesClose(sizePt, lastSizePt) && gap <= PARAGRAPH_GAP_MULTIPLIER * lastSizePt;
272
+ });
273
+ if (matched !== void 0) matched.lines.push(segment);
274
+ else blocks.push({ lines: [segment] });
275
+ }
276
+ return blocks;
277
+ }
278
+ function computeBlockFrame(block, slideHeightPt) {
279
+ let minX = Number.POSITIVE_INFINITY;
280
+ let maxX = Number.NEGATIVE_INFINITY;
281
+ let minY = Number.POSITIVE_INFINITY;
282
+ let maxY = Number.NEGATIVE_INFINITY;
283
+ for (const line of block.lines) for (const item of line.items) {
284
+ const { ascentPt, descentPt } = textItemVerticalExtent(item);
285
+ minX = Math.min(minX, item.xPt);
286
+ maxX = Math.max(maxX, item.xPt + (item.widthPt ?? 0));
287
+ minY = Math.min(minY, item.yPt - descentPt);
288
+ maxY = Math.max(maxY, item.yPt + ascentPt);
289
+ }
290
+ return flipY({
291
+ xPt: minX,
292
+ yPt: minY,
293
+ widthPt: maxX - minX,
294
+ heightPt: maxY - minY
295
+ }, slideHeightPt);
296
+ }
297
+ function lineToParagraph(line) {
298
+ const runs = [];
299
+ pushRunsForLine(runs, line);
300
+ return {
301
+ kind: "paragraph",
302
+ runs
303
+ };
304
+ }
305
+ function blockToShape(block, slideHeightPt) {
306
+ return {
307
+ frame: computeBlockFrame(block, slideHeightPt),
308
+ insetLeftPt: 0,
309
+ insetTopPt: 0,
310
+ insetRightPt: 0,
311
+ insetBottomPt: 0,
312
+ blocks: block.lines.map(lineToParagraph)
313
+ };
314
+ }
315
+ function imageToShape(img, slideHeightPt, images) {
316
+ const asset = images[img.imageId];
317
+ if (asset === void 0) return;
318
+ return {
319
+ frame: flipY({
320
+ xPt: img.xPt,
321
+ yPt: img.yPt,
322
+ widthPt: img.widthPt,
323
+ heightPt: img.heightPt
324
+ }, slideHeightPt),
325
+ rotationDeg: img.rotationDeg !== void 0 ? -img.rotationDeg : void 0,
326
+ insetLeftPt: 0,
327
+ insetTopPt: 0,
328
+ insetRightPt: 0,
329
+ insetBottomPt: 0,
330
+ blocks: [{
331
+ kind: "image",
332
+ format: asset.format,
333
+ base64: asset.base64,
334
+ widthPt: img.widthPt,
335
+ heightPt: img.heightPt
336
+ }]
337
+ };
338
+ }
339
+ function reconstructDrawing(doc, options) {
340
+ const signal = options?.signal;
341
+ const pages = doc.pages.map((page) => {
342
+ throwIfAborted(signal);
343
+ return reconstructDrawPage(page, doc.images);
344
+ });
345
+ return {
346
+ kind: "drawing",
347
+ formatVersion: 1,
348
+ metadata: doc.metadata,
349
+ pages
350
+ };
351
+ }
352
+ function reconstructDrawPage(page, images) {
353
+ const vectors = [];
354
+ const shapes = [];
355
+ for (const item of page.items) if (item.kind === "rect") vectors.push(layoutRectToVector(item, page.heightPt));
356
+ else if (item.kind === "ellipse") vectors.push(layoutEllipseToVector(item, page.heightPt));
357
+ else if (item.kind === "line") vectors.push(layoutLineToVector(item, page.heightPt));
358
+ else if (item.kind === "path") vectors.push(layoutPathToVector(item, page.heightPt));
359
+ else if (item.kind === "text") shapes.push(layoutTextToShape(item, page.heightPt));
360
+ else if (item.kind === "image") {
361
+ const shape = imageToShape(item, page.heightPt, images);
362
+ if (shape !== void 0) shapes.push(shape);
363
+ }
364
+ return {
365
+ size: {
366
+ widthPt: page.widthPt,
367
+ heightPt: page.heightPt
368
+ },
369
+ shapes,
370
+ vectors
371
+ };
372
+ }
373
+ function layoutRectToVector(item, pageHeightPt) {
374
+ return {
375
+ kind: "rect",
376
+ frame: flipY({
377
+ xPt: item.xPt,
378
+ yPt: item.yPt,
379
+ widthPt: item.widthPt,
380
+ heightPt: item.heightPt
381
+ }, pageHeightPt),
382
+ fill: item.fill,
383
+ stroke: item.stroke,
384
+ sourcePath: item.sourcePath
385
+ };
386
+ }
387
+ function layoutEllipseToVector(item, pageHeightPt) {
388
+ return {
389
+ kind: "ellipse",
390
+ frame: flipY({
391
+ xPt: item.xPt,
392
+ yPt: item.yPt,
393
+ widthPt: item.widthPt,
394
+ heightPt: item.heightPt
395
+ }, pageHeightPt),
396
+ fill: item.fill,
397
+ stroke: item.stroke,
398
+ sourcePath: item.sourcePath
399
+ };
400
+ }
401
+ function layoutLineToVector(item, pageHeightPt) {
402
+ return {
403
+ kind: "line",
404
+ from: {
405
+ xPt: item.x1Pt,
406
+ yPt: pageHeightPt - item.y1Pt
407
+ },
408
+ to: {
409
+ xPt: item.x2Pt,
410
+ yPt: pageHeightPt - item.y2Pt
411
+ },
412
+ stroke: {
413
+ color: item.color,
414
+ widthPt: item.widthPt
415
+ },
416
+ sourcePath: item.sourcePath
417
+ };
418
+ }
419
+ function collectPathPoints(subpaths) {
420
+ const points = [];
421
+ for (const subpath of subpaths) {
422
+ points.push({
423
+ xPt: subpath.startXPt,
424
+ yPt: subpath.startYPt
425
+ });
426
+ for (const segment of subpath.segments) {
427
+ if (segment.kind === "cubic") {
428
+ points.push({
429
+ xPt: segment.c1xPt,
430
+ yPt: segment.c1yPt
431
+ });
432
+ points.push({
433
+ xPt: segment.c2xPt,
434
+ yPt: segment.c2yPt
435
+ });
436
+ }
437
+ points.push({
438
+ xPt: segment.xPt,
439
+ yPt: segment.yPt
440
+ });
441
+ }
442
+ }
443
+ return points;
444
+ }
445
+ function pathBoundingFrame(points, pageHeightPt) {
446
+ if (points.length === 0) return {
447
+ xPt: 0,
448
+ yPt: 0,
449
+ widthPt: 0,
450
+ heightPt: 0
451
+ };
452
+ let minX = Number.POSITIVE_INFINITY;
453
+ let maxX = Number.NEGATIVE_INFINITY;
454
+ let minYDown = Number.POSITIVE_INFINITY;
455
+ let maxYDown = Number.NEGATIVE_INFINITY;
456
+ for (const point of points) {
457
+ const yDown = pageHeightPt - point.yPt;
458
+ minX = Math.min(minX, point.xPt);
459
+ maxX = Math.max(maxX, point.xPt);
460
+ minYDown = Math.min(minYDown, yDown);
461
+ maxYDown = Math.max(maxYDown, yDown);
462
+ }
463
+ return {
464
+ xPt: minX,
465
+ yPt: minYDown,
466
+ widthPt: maxX - minX,
467
+ heightPt: maxYDown - minYDown
468
+ };
469
+ }
470
+ function localizePathPoint(frame, point, pageHeightPt) {
471
+ return {
472
+ xPt: point.xPt - frame.xPt,
473
+ yPt: pageHeightPt - frame.yPt - point.yPt
474
+ };
475
+ }
476
+ function layoutPathToVector(item, pageHeightPt) {
477
+ const frame = pathBoundingFrame(collectPathPoints(item.subpaths), pageHeightPt);
478
+ return {
479
+ kind: "path",
480
+ frame,
481
+ subpaths: item.subpaths.map((subpath) => ({
482
+ start: localizePathPoint(frame, {
483
+ xPt: subpath.startXPt,
484
+ yPt: subpath.startYPt
485
+ }, pageHeightPt),
486
+ closed: subpath.closed,
487
+ segments: subpath.segments.map((segment) => {
488
+ if (segment.kind === "line") return {
489
+ kind: "line",
490
+ to: localizePathPoint(frame, {
491
+ xPt: segment.xPt,
492
+ yPt: segment.yPt
493
+ }, pageHeightPt)
494
+ };
495
+ return {
496
+ kind: "cubic",
497
+ control1: localizePathPoint(frame, {
498
+ xPt: segment.c1xPt,
499
+ yPt: segment.c1yPt
500
+ }, pageHeightPt),
501
+ control2: localizePathPoint(frame, {
502
+ xPt: segment.c2xPt,
503
+ yPt: segment.c2yPt
504
+ }, pageHeightPt),
505
+ to: localizePathPoint(frame, {
506
+ xPt: segment.xPt,
507
+ yPt: segment.yPt
508
+ }, pageHeightPt)
509
+ };
510
+ })
511
+ })),
512
+ fill: item.fill,
513
+ fillRule: item.fillRule,
514
+ stroke: item.stroke,
515
+ sourcePath: item.sourcePath
516
+ };
517
+ }
518
+ function layoutTextToShape(item, pageHeightPt) {
519
+ return {
520
+ frame: computeBlockFrame({ lines: [{
521
+ items: [item],
522
+ baselineY: item.yPt
523
+ }] }, pageHeightPt),
524
+ rotationDeg: item.rotationDeg !== void 0 ? -item.rotationDeg : void 0,
525
+ insetLeftPt: 0,
526
+ insetTopPt: 0,
527
+ insetRightPt: 0,
528
+ insetBottomPt: 0,
529
+ blocks: [{
530
+ kind: "paragraph",
531
+ runs: [textItemToContentRun(item)]
532
+ }]
533
+ };
534
+ }
535
+ function extractLineCandidates(items) {
536
+ const segments = [];
537
+ for (const item of items) {
538
+ if (item.kind === "line") {
539
+ segments.push({
540
+ x1Pt: item.x1Pt,
541
+ y1Pt: item.y1Pt,
542
+ x2Pt: item.x2Pt,
543
+ y2Pt: item.y2Pt
544
+ });
545
+ continue;
546
+ }
547
+ if (item.kind === "path" && item.stroke !== void 0 && item.subpaths.length === 1) {
548
+ const subpath = item.subpaths[0];
549
+ if (subpath.segments.length === 1 && subpath.segments[0].kind === "line") {
550
+ const segment = subpath.segments[0];
551
+ segments.push({
552
+ x1Pt: subpath.startXPt,
553
+ y1Pt: subpath.startYPt,
554
+ x2Pt: segment.xPt,
555
+ y2Pt: segment.yPt
556
+ });
557
+ }
558
+ }
559
+ }
560
+ return segments;
561
+ }
562
+ const AXIS_ALIGNMENT_TOLERANCE_PT = .5;
563
+ const MIN_GRIDLINE_LENGTH_PT = 4;
564
+ function classifyAxisLine(seg) {
565
+ const dx = Math.abs(seg.x2Pt - seg.x1Pt);
566
+ const dy = Math.abs(seg.y2Pt - seg.y1Pt);
567
+ if (dy <= AXIS_ALIGNMENT_TOLERANCE_PT && dx >= MIN_GRIDLINE_LENGTH_PT) return {
568
+ axis: "horizontal",
569
+ position: (seg.y1Pt + seg.y2Pt) / 2,
570
+ spanPt: dx
571
+ };
572
+ if (dx <= AXIS_ALIGNMENT_TOLERANCE_PT && dy >= MIN_GRIDLINE_LENGTH_PT) return {
573
+ axis: "vertical",
574
+ position: (seg.x1Pt + seg.x2Pt) / 2,
575
+ spanPt: dy
576
+ };
577
+ }
578
+ const POSITION_DEDUPE_TOLERANCE_PT = .5;
579
+ function dedupeAxisLines(lines, descending) {
580
+ const sorted = [...lines].sort((a, b) => descending ? b.position - a.position : a.position - b.position);
581
+ const result = [];
582
+ for (const candidate of sorted) {
583
+ const last = result[result.length - 1];
584
+ if (last !== void 0 && Math.abs(candidate.position - last.position) <= POSITION_DEDUPE_TOLERANCE_PT) last.spanPt = Math.max(last.spanPt, candidate.spanPt);
585
+ else result.push({
586
+ position: candidate.position,
587
+ spanPt: candidate.spanPt
588
+ });
589
+ }
590
+ return result;
591
+ }
592
+ const MIN_GRIDLINE_COUNT_PER_AXIS = 3;
593
+ const GRID_SPAN_CONSISTENCY_RATIO = .9;
594
+ function isRegularLattice(lines) {
595
+ if (lines.length < MIN_GRIDLINE_COUNT_PER_AXIS) return false;
596
+ const maxSpanPt = Math.max(...lines.map((l) => l.spanPt));
597
+ return lines.filter((l) => l.spanPt >= maxSpanPt * GRID_SPAN_CONSISTENCY_RATIO).length >= MIN_GRIDLINE_COUNT_PER_AXIS;
598
+ }
599
+ function detectGridLattice(items) {
600
+ const horizontal = [];
601
+ const vertical = [];
602
+ for (const seg of extractLineCandidates(items)) {
603
+ const classified = classifyAxisLine(seg);
604
+ if (classified === void 0) continue;
605
+ (classified.axis === "horizontal" ? horizontal : vertical).push(classified);
606
+ }
607
+ const rowBoundaries = dedupeAxisLines(horizontal, true);
608
+ const columnBoundaries = dedupeAxisLines(vertical, false);
609
+ if (!isRegularLattice(rowBoundaries) || !isRegularLattice(columnBoundaries)) return;
610
+ return {
611
+ rowBoundariesDescPt: rowBoundaries.map((l) => l.position),
612
+ columnBoundariesAscPt: columnBoundaries.map((l) => l.position)
613
+ };
614
+ }
615
+ const OUTER_EDGE_TOLERANCE_PT = 3;
616
+ function findRowIndex(rowBoundariesDescPt, yPt) {
617
+ const lastIndex = rowBoundariesDescPt.length - 1;
618
+ if (yPt > rowBoundariesDescPt[0] + OUTER_EDGE_TOLERANCE_PT || yPt < rowBoundariesDescPt[lastIndex] - OUTER_EDGE_TOLERANCE_PT) return;
619
+ for (let i = 0; i < lastIndex; i++) if (yPt > rowBoundariesDescPt[i + 1]) return i;
620
+ return lastIndex - 1;
621
+ }
622
+ function findColumnIndex(columnBoundariesAscPt, xPt) {
623
+ const lastIndex = columnBoundariesAscPt.length - 1;
624
+ if (xPt < columnBoundariesAscPt[0] - OUTER_EDGE_TOLERANCE_PT || xPt > columnBoundariesAscPt[lastIndex] + OUTER_EDGE_TOLERANCE_PT) return;
625
+ for (let j = 0; j < lastIndex; j++) if (xPt < columnBoundariesAscPt[j + 1]) return j;
626
+ return lastIndex - 1;
627
+ }
628
+ function joinCellText(items) {
629
+ const sorted = [...items].sort((a, b) => a.xPt - b.xPt);
630
+ let text = "";
631
+ sorted.forEach((item, i) => {
632
+ if (i > 0) {
633
+ const prev = sorted[i - 1];
634
+ if (item.xPt - (prev.xPt + (prev.widthPt ?? 0)) > MIN_WORD_GAP_PT) text += " ";
635
+ }
636
+ text += item.text;
637
+ });
638
+ return text;
639
+ }
640
+ function groupKey(row, column) {
641
+ return `${row},${column}`;
642
+ }
643
+ function addToGroup(groups, row, column, item) {
644
+ const key = groupKey(row, column);
645
+ const existing = groups.get(key);
646
+ if (existing === void 0) groups.set(key, [item]);
647
+ else existing.push(item);
648
+ }
649
+ function buildCellsFromGroups(groups) {
650
+ const cells = [];
651
+ for (const [key, items] of groups) {
652
+ const displayText = joinCellText(items);
653
+ if (displayText.length === 0) continue;
654
+ const [rowPart, columnPart] = key.split(",");
655
+ cells.push({
656
+ row: Number(rowPart),
657
+ column: Number(columnPart),
658
+ value: {
659
+ kind: "string",
660
+ value: displayText
661
+ },
662
+ displayText
663
+ });
664
+ }
665
+ cells.sort((a, b) => a.row - b.row || a.column - b.column);
666
+ return cells;
667
+ }
668
+ function buildGridFromLattice(textItems, lattice) {
669
+ const groups = /* @__PURE__ */ new Map();
670
+ for (const item of textItems) {
671
+ const row = findRowIndex(lattice.rowBoundariesDescPt, item.yPt);
672
+ const column = findColumnIndex(lattice.columnBoundariesAscPt, item.xPt);
673
+ if (row === void 0 || column === void 0) continue;
674
+ addToGroup(groups, row, column, item);
675
+ }
676
+ const columns = [];
677
+ for (let j = 0; j < lattice.columnBoundariesAscPt.length - 1; j++) columns.push({
678
+ index: j,
679
+ widthPt: lattice.columnBoundariesAscPt[j + 1] - lattice.columnBoundariesAscPt[j]
680
+ });
681
+ const rows = [];
682
+ for (let i = 0; i < lattice.rowBoundariesDescPt.length - 1; i++) rows.push({
683
+ index: i,
684
+ heightPt: lattice.rowBoundariesDescPt[i] - lattice.rowBoundariesDescPt[i + 1]
685
+ });
686
+ return {
687
+ cells: buildCellsFromGroups(groups),
688
+ columns,
689
+ rows,
690
+ gridlines: true
691
+ };
692
+ }
693
+ const COLUMN_ALIGNMENT_TOLERANCE_PT = 3;
694
+ const MIN_COLUMN_RECURRENCE = 2;
695
+ function detectColumnPositions(segmentsByLine) {
696
+ const allXs = segmentsByLine.flatMap((segments) => segments.map((segment) => segment.items[0].xPt));
697
+ if (allXs.length === 0) return [];
698
+ const counts = bucketCounts(allXs, COLUMN_ALIGNMENT_TOLERANCE_PT);
699
+ const recurring = [...counts.entries()].filter(([, count]) => count >= MIN_COLUMN_RECURRENCE).map(([bucket]) => bucket);
700
+ const positions = recurring.length > 0 ? recurring : [...counts.keys()];
701
+ positions.sort((a, b) => a - b);
702
+ return positions;
703
+ }
704
+ function nearestColumnIndex(positions, xPt) {
705
+ let bestIndex = 0;
706
+ let bestDistancePt = Number.POSITIVE_INFINITY;
707
+ positions.forEach((position, index) => {
708
+ const distancePt = Math.abs(position - xPt);
709
+ if (distancePt < bestDistancePt) {
710
+ bestDistancePt = distancePt;
711
+ bestIndex = index;
712
+ }
713
+ });
714
+ return bestIndex;
715
+ }
716
+ const DEFAULT_COLUMN_WIDTH_FALLBACK_PT = 40;
717
+ function lastColumnWidthPt(groups, columnIndex, anchorXPt) {
718
+ let maxWidthPt = 0;
719
+ for (const [key, items] of groups) {
720
+ const [, columnPart] = key.split(",");
721
+ if (Number(columnPart) !== columnIndex) continue;
722
+ for (const item of items) maxWidthPt = Math.max(maxWidthPt, item.xPt + (item.widthPt ?? 0) - anchorXPt);
723
+ }
724
+ return maxWidthPt > 0 ? maxWidthPt : DEFAULT_COLUMN_WIDTH_FALLBACK_PT;
725
+ }
726
+ function buildGridFromTextClustering(textItems) {
727
+ const lines = clusterIntoLines(textItems);
728
+ if (lines.length === 0) return {
729
+ cells: [],
730
+ columns: [],
731
+ rows: [],
732
+ gridlines: false
733
+ };
734
+ const segmentsByLine = lines.map((l) => splitLineByLargeGaps(l));
735
+ const columnPositions = detectColumnPositions(segmentsByLine);
736
+ const groups = /* @__PURE__ */ new Map();
737
+ segmentsByLine.forEach((segments, rowIndex) => {
738
+ for (const segment of segments) {
739
+ const key = groupKey(rowIndex, nearestColumnIndex(columnPositions, segment.items[0].xPt));
740
+ const existing = groups.get(key);
741
+ if (existing === void 0) groups.set(key, [...segment.items]);
742
+ else existing.push(...segment.items);
743
+ }
744
+ });
745
+ const nominalRowHeightPt = estimateModalLineSpacing(lines);
746
+ const rows = lines.map((line, i) => {
747
+ const nextBaselineY = lines[i + 1]?.baselineY;
748
+ const heightPt = nextBaselineY !== void 0 ? line.baselineY - nextBaselineY : nominalRowHeightPt;
749
+ return {
750
+ index: i,
751
+ heightPt: heightPt > 0 ? heightPt : nominalRowHeightPt
752
+ };
753
+ });
754
+ const columns = columnPositions.map((position, j) => {
755
+ const nextPosition = columnPositions[j + 1];
756
+ return {
757
+ index: j,
758
+ widthPt: nextPosition !== void 0 ? nextPosition - position : lastColumnWidthPt(groups, j, position)
759
+ };
760
+ });
761
+ return {
762
+ cells: buildCellsFromGroups(groups),
763
+ columns,
764
+ rows,
765
+ gridlines: false
766
+ };
767
+ }
768
+ function reconstructSheet(page, pageIndex) {
769
+ const textItems = page.items.filter((i) => i.kind === "text");
770
+ const lattice = detectGridLattice(page.items);
771
+ const grid = lattice !== void 0 ? buildGridFromLattice(textItems, lattice) : buildGridFromTextClustering(textItems);
772
+ const printSettings = {
773
+ pageSize: {
774
+ widthPt: page.widthPt,
775
+ heightPt: page.heightPt
776
+ },
777
+ margins: ZERO_MARGINS,
778
+ gridlines: grid.gridlines,
779
+ headers: false,
780
+ pageOrder: "downThenOver"
781
+ };
782
+ return {
783
+ name: `Sheet${pageIndex + 1}`,
784
+ cells: grid.cells,
785
+ columns: grid.columns,
786
+ rows: grid.rows,
787
+ images: [],
788
+ printSettings
789
+ };
790
+ }
791
+ function reconstructSpreadsheet(doc, options) {
792
+ const signal = options?.signal;
793
+ const sheets = doc.pages.map((page, index) => {
794
+ throwIfAborted(signal);
795
+ return reconstructSheet(page, index);
796
+ });
797
+ return {
798
+ kind: "spreadsheet",
799
+ formatVersion: 1,
800
+ metadata: doc.metadata,
801
+ sheets
802
+ };
803
+ }
804
+ //#endregion
805
+ export { reconstructDrawing, reconstructPresentation, reconstructSpreadsheet, reconstructWordprocessing };