@hussmartinez/pdf-sdk 0.0.0-stage → 0.1.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 (395) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +66 -0
  3. package/README.md +84 -2
  4. package/dist/assets/pdfjs/build/pdf.worker.min.mjs +28 -0
  5. package/dist/assets/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  6. package/dist/assets/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  7. package/dist/assets/pdfjs/cmaps/78-H.bcmap +0 -0
  8. package/dist/assets/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  9. package/dist/assets/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  10. package/dist/assets/pdfjs/cmaps/78-V.bcmap +0 -0
  11. package/dist/assets/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  12. package/dist/assets/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  13. package/dist/assets/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  14. package/dist/assets/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  15. package/dist/assets/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  16. package/dist/assets/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  17. package/dist/assets/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  18. package/dist/assets/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  19. package/dist/assets/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  20. package/dist/assets/pdfjs/cmaps/Add-H.bcmap +0 -0
  21. package/dist/assets/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  22. package/dist/assets/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  23. package/dist/assets/pdfjs/cmaps/Add-V.bcmap +0 -0
  24. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  25. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  26. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  27. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  28. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  29. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  30. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  31. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  32. package/dist/assets/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  33. package/dist/assets/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  34. package/dist/assets/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  35. package/dist/assets/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  36. package/dist/assets/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  37. package/dist/assets/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  38. package/dist/assets/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  39. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  40. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  41. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  42. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  43. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  44. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  45. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  46. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  47. package/dist/assets/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  48. package/dist/assets/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  49. package/dist/assets/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  50. package/dist/assets/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  51. package/dist/assets/pdfjs/cmaps/B5-H.bcmap +0 -0
  52. package/dist/assets/pdfjs/cmaps/B5-V.bcmap +0 -0
  53. package/dist/assets/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  54. package/dist/assets/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  55. package/dist/assets/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  56. package/dist/assets/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  57. package/dist/assets/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  58. package/dist/assets/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  59. package/dist/assets/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  60. package/dist/assets/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  61. package/dist/assets/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  62. package/dist/assets/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  63. package/dist/assets/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  64. package/dist/assets/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  65. package/dist/assets/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  66. package/dist/assets/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  67. package/dist/assets/pdfjs/cmaps/EUC-H.bcmap +0 -0
  68. package/dist/assets/pdfjs/cmaps/EUC-V.bcmap +0 -0
  69. package/dist/assets/pdfjs/cmaps/Ext-H.bcmap +0 -0
  70. package/dist/assets/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  71. package/dist/assets/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  72. package/dist/assets/pdfjs/cmaps/Ext-V.bcmap +0 -0
  73. package/dist/assets/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  74. package/dist/assets/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  75. package/dist/assets/pdfjs/cmaps/GB-H.bcmap +4 -0
  76. package/dist/assets/pdfjs/cmaps/GB-V.bcmap +0 -0
  77. package/dist/assets/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  78. package/dist/assets/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  79. package/dist/assets/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  80. package/dist/assets/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  81. package/dist/assets/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  82. package/dist/assets/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  83. package/dist/assets/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  84. package/dist/assets/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  85. package/dist/assets/pdfjs/cmaps/GBT-H.bcmap +0 -0
  86. package/dist/assets/pdfjs/cmaps/GBT-V.bcmap +0 -0
  87. package/dist/assets/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  88. package/dist/assets/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  89. package/dist/assets/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  90. package/dist/assets/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  91. package/dist/assets/pdfjs/cmaps/H.bcmap +0 -0
  92. package/dist/assets/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  93. package/dist/assets/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  94. package/dist/assets/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  95. package/dist/assets/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  96. package/dist/assets/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  97. package/dist/assets/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  98. package/dist/assets/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  99. package/dist/assets/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  100. package/dist/assets/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  101. package/dist/assets/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  102. package/dist/assets/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  103. package/dist/assets/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  104. package/dist/assets/pdfjs/cmaps/Hankaku.bcmap +0 -0
  105. package/dist/assets/pdfjs/cmaps/Hiragana.bcmap +0 -0
  106. package/dist/assets/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  107. package/dist/assets/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  108. package/dist/assets/pdfjs/cmaps/KSC-H.bcmap +0 -0
  109. package/dist/assets/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  110. package/dist/assets/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  111. package/dist/assets/pdfjs/cmaps/KSC-V.bcmap +0 -0
  112. package/dist/assets/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  113. package/dist/assets/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  114. package/dist/assets/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  115. package/dist/assets/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  116. package/dist/assets/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  117. package/dist/assets/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  118. package/dist/assets/pdfjs/cmaps/Katakana.bcmap +0 -0
  119. package/dist/assets/pdfjs/cmaps/LICENSE +36 -0
  120. package/dist/assets/pdfjs/cmaps/NWP-H.bcmap +0 -0
  121. package/dist/assets/pdfjs/cmaps/NWP-V.bcmap +0 -0
  122. package/dist/assets/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  123. package/dist/assets/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  124. package/dist/assets/pdfjs/cmaps/Roman.bcmap +0 -0
  125. package/dist/assets/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  126. package/dist/assets/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  127. package/dist/assets/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  128. package/dist/assets/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  129. package/dist/assets/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  130. package/dist/assets/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  131. package/dist/assets/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  132. package/dist/assets/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  133. package/dist/assets/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  134. package/dist/assets/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  135. package/dist/assets/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  136. package/dist/assets/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  137. package/dist/assets/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  138. package/dist/assets/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  139. package/dist/assets/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  140. package/dist/assets/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  141. package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  142. package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  143. package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  144. package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  145. package/dist/assets/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  146. package/dist/assets/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  147. package/dist/assets/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  148. package/dist/assets/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  149. package/dist/assets/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  150. package/dist/assets/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  151. package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  152. package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  153. package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  154. package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  155. package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  156. package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  157. package/dist/assets/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  158. package/dist/assets/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  159. package/dist/assets/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  160. package/dist/assets/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  161. package/dist/assets/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  162. package/dist/assets/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  163. package/dist/assets/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  164. package/dist/assets/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  165. package/dist/assets/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  166. package/dist/assets/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  167. package/dist/assets/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  168. package/dist/assets/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  169. package/dist/assets/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  170. package/dist/assets/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  171. package/dist/assets/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  172. package/dist/assets/pdfjs/cmaps/V.bcmap +0 -0
  173. package/dist/assets/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  174. package/dist/assets/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
  175. package/dist/assets/pdfjs/iccs/LICENSE +116 -0
  176. package/dist/assets/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  177. package/dist/assets/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  178. package/dist/assets/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  179. package/dist/assets/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  180. package/dist/assets/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  181. package/dist/assets/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  182. package/dist/assets/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  183. package/dist/assets/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  184. package/dist/assets/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  185. package/dist/assets/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  186. package/dist/assets/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  187. package/dist/assets/pdfjs/wasm/LICENSE_JBIG2 +196 -0
  188. package/dist/assets/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
  189. package/dist/assets/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  190. package/dist/assets/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  191. package/dist/assets/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
  192. package/dist/assets/pdfjs/wasm/LICENSE_QCMS +21 -0
  193. package/dist/assets/pdfjs/wasm/jbig2.wasm +0 -0
  194. package/dist/assets/pdfjs/wasm/openjpeg.wasm +0 -0
  195. package/dist/assets/pdfjs/wasm/qcms_bg.wasm +0 -0
  196. package/dist/assets/processing/processing.worker.js +57 -0
  197. package/dist/assets/processing/qpdf.wasm +0 -0
  198. package/dist/element.d.ts +12 -0
  199. package/dist/element.js +0 -0
  200. package/dist/index.d.ts +1286 -0
  201. package/dist/index.js +1 -0
  202. package/dist/lazy/78-EUC-H.bcmap-sYP3SMNV.js +3 -0
  203. package/dist/lazy/78-EUC-V.bcmap-w3SY_Y_q.js +3 -0
  204. package/dist/lazy/78-H.bcmap-CeA2DrtT.js +3 -0
  205. package/dist/lazy/78-RKSJ-H.bcmap-D4cLhL3_.js +3 -0
  206. package/dist/lazy/78-RKSJ-V.bcmap-DdK1ZiTU.js +3 -0
  207. package/dist/lazy/78-V.bcmap-CVoLO4i0.js +3 -0
  208. package/dist/lazy/78ms-RKSJ-H.bcmap-B20DW4UH.js +3 -0
  209. package/dist/lazy/78ms-RKSJ-V.bcmap-CLnY5REh.js +3 -0
  210. package/dist/lazy/83pv-RKSJ-H.bcmap-Ck3Sc38p.js +3 -0
  211. package/dist/lazy/90ms-RKSJ-H.bcmap-C-vgp7Oe.js +3 -0
  212. package/dist/lazy/90ms-RKSJ-V.bcmap-CnYvCBfH.js +3 -0
  213. package/dist/lazy/90msp-RKSJ-H.bcmap-BIx2U_Lw.js +3 -0
  214. package/dist/lazy/90msp-RKSJ-V.bcmap-LSpKnFnA.js +3 -0
  215. package/dist/lazy/90pv-RKSJ-H.bcmap-ohvXiazb.js +3 -0
  216. package/dist/lazy/90pv-RKSJ-V.bcmap-DiMSuPqu.js +3 -0
  217. package/dist/lazy/Add-H.bcmap-D50q_cPt.js +3 -0
  218. package/dist/lazy/Add-RKSJ-H.bcmap-DLQ79XiS.js +3 -0
  219. package/dist/lazy/Add-RKSJ-V.bcmap-DgMvx1Yl.js +3 -0
  220. package/dist/lazy/Add-V.bcmap-njFd39xE.js +3 -0
  221. package/dist/lazy/Adobe-CNS1-0.bcmap-DC9aIYc6.js +3 -0
  222. package/dist/lazy/Adobe-CNS1-1.bcmap-CjXhkA0W.js +3 -0
  223. package/dist/lazy/Adobe-CNS1-2.bcmap-BfDCyJYh.js +3 -0
  224. package/dist/lazy/Adobe-CNS1-3.bcmap-C5_dNXD-.js +3 -0
  225. package/dist/lazy/Adobe-CNS1-4.bcmap-DkB6y9PJ.js +3 -0
  226. package/dist/lazy/Adobe-CNS1-5.bcmap-13hTC0vp.js +3 -0
  227. package/dist/lazy/Adobe-CNS1-6.bcmap-CcQ66yT1.js +3 -0
  228. package/dist/lazy/Adobe-CNS1-UCS2.bcmap-jD7ZNdHN.js +3 -0
  229. package/dist/lazy/Adobe-GB1-0.bcmap-CwfHCw6h.js +3 -0
  230. package/dist/lazy/Adobe-GB1-1.bcmap-DRWrCran.js +3 -0
  231. package/dist/lazy/Adobe-GB1-2.bcmap-0nedEhcq.js +3 -0
  232. package/dist/lazy/Adobe-GB1-3.bcmap-Cq3lCVsW.js +3 -0
  233. package/dist/lazy/Adobe-GB1-4.bcmap-BzTb6Nsg.js +3 -0
  234. package/dist/lazy/Adobe-GB1-5.bcmap-BUHSmz5c.js +3 -0
  235. package/dist/lazy/Adobe-GB1-UCS2.bcmap-DUfIxWQW.js +3 -0
  236. package/dist/lazy/Adobe-Japan1-0.bcmap-BjG9GiRM.js +3 -0
  237. package/dist/lazy/Adobe-Japan1-1.bcmap-DQTj-iQt.js +3 -0
  238. package/dist/lazy/Adobe-Japan1-2.bcmap-BOsCSmmm.js +3 -0
  239. package/dist/lazy/Adobe-Japan1-3.bcmap-ChGf7g8t.js +3 -0
  240. package/dist/lazy/Adobe-Japan1-4.bcmap-CI6iUMgQ.js +3 -0
  241. package/dist/lazy/Adobe-Japan1-5.bcmap-kbwPceJO.js +3 -0
  242. package/dist/lazy/Adobe-Japan1-6.bcmap-CAvvqYpW.js +3 -0
  243. package/dist/lazy/Adobe-Japan1-UCS2.bcmap-DbZiEgfC.js +3 -0
  244. package/dist/lazy/Adobe-Korea1-0.bcmap-Der5jvBG.js +3 -0
  245. package/dist/lazy/Adobe-Korea1-1.bcmap-DafpcUyn.js +3 -0
  246. package/dist/lazy/Adobe-Korea1-2.bcmap-D1nh75yR.js +3 -0
  247. package/dist/lazy/Adobe-Korea1-UCS2.bcmap-CNeMfPHO.js +3 -0
  248. package/dist/lazy/B5-H.bcmap-gyhuoKf7.js +3 -0
  249. package/dist/lazy/B5-V.bcmap-BGqDqEjZ.js +3 -0
  250. package/dist/lazy/B5pc-H.bcmap-C8B_dVbb.js +3 -0
  251. package/dist/lazy/B5pc-V.bcmap-ETo7py2B.js +3 -0
  252. package/dist/lazy/CNS-EUC-H.bcmap-BgwyrNdN.js +3 -0
  253. package/dist/lazy/CNS-EUC-V.bcmap-BbC68G9k.js +3 -0
  254. package/dist/lazy/CNS1-H.bcmap-DZIguuvp.js +3 -0
  255. package/dist/lazy/CNS1-V.bcmap-DjthPwLF.js +3 -0
  256. package/dist/lazy/CNS2-H.bcmap-CTuiQP8Z.js +3 -0
  257. package/dist/lazy/CNS2-V.bcmap-BU5ZzL4C.js +3 -0
  258. package/dist/lazy/ETHK-B5-H.bcmap-AYx-kODg.js +3 -0
  259. package/dist/lazy/ETHK-B5-V.bcmap-C_2Sxwdm.js +3 -0
  260. package/dist/lazy/ETen-B5-H.bcmap-BAKuplan.js +3 -0
  261. package/dist/lazy/ETen-B5-V.bcmap-Dnm6aXlS.js +3 -0
  262. package/dist/lazy/ETenms-B5-H.bcmap-DZ8Y3Rnc.js +3 -0
  263. package/dist/lazy/ETenms-B5-V.bcmap-DPnnTEiA.js +3 -0
  264. package/dist/lazy/EUC-H.bcmap-B1COGDXX.js +3 -0
  265. package/dist/lazy/EUC-V.bcmap-BRvFq5yx.js +3 -0
  266. package/dist/lazy/Ext-H.bcmap-CNU3PCfs.js +3 -0
  267. package/dist/lazy/Ext-RKSJ-H.bcmap-T22CGXk4.js +3 -0
  268. package/dist/lazy/Ext-RKSJ-V.bcmap-K2DXeZ3P.js +3 -0
  269. package/dist/lazy/Ext-V.bcmap-3sNuPEfV.js +3 -0
  270. package/dist/lazy/FoxitDingbats.pfb-DVieKaw5.js +3 -0
  271. package/dist/lazy/FoxitFixed.pfb-Cxgpn9hN.js +3 -0
  272. package/dist/lazy/FoxitFixedBold.pfb-SBojmP3G.js +3 -0
  273. package/dist/lazy/FoxitFixedBoldItalic.pfb-DhsbZ2IP.js +3 -0
  274. package/dist/lazy/FoxitFixedItalic.pfb-Dm09mdyI.js +3 -0
  275. package/dist/lazy/FoxitSerif.pfb-DyMzSE_0.js +3 -0
  276. package/dist/lazy/FoxitSerifBold.pfb-DTzLt76W.js +3 -0
  277. package/dist/lazy/FoxitSerifBoldItalic.pfb-X3fHgghe.js +3 -0
  278. package/dist/lazy/FoxitSerifItalic.pfb-Nz1cnSKc.js +3 -0
  279. package/dist/lazy/FoxitSymbol.pfb-BL-rU8nS.js +3 -0
  280. package/dist/lazy/GB-EUC-H.bcmap-CsgH6-Rh.js +3 -0
  281. package/dist/lazy/GB-EUC-V.bcmap-DUouvrJu.js +3 -0
  282. package/dist/lazy/GB-H.bcmap-CuVli79K.js +3 -0
  283. package/dist/lazy/GB-V.bcmap-C3uPsDRC.js +3 -0
  284. package/dist/lazy/GBK-EUC-H.bcmap-BBDA5YUr.js +3 -0
  285. package/dist/lazy/GBK-EUC-V.bcmap-CjEpjWSW.js +3 -0
  286. package/dist/lazy/GBK2K-H.bcmap-DEJkj1gN.js +3 -0
  287. package/dist/lazy/GBK2K-V.bcmap-NYgNeNsu.js +3 -0
  288. package/dist/lazy/GBKp-EUC-H.bcmap-BIQuHkue.js +3 -0
  289. package/dist/lazy/GBKp-EUC-V.bcmap-BNBPmQ4v.js +3 -0
  290. package/dist/lazy/GBT-EUC-H.bcmap-D7OWs_0J.js +3 -0
  291. package/dist/lazy/GBT-EUC-V.bcmap-D_rNNyCu.js +3 -0
  292. package/dist/lazy/GBT-H.bcmap-B4SLNj_c.js +3 -0
  293. package/dist/lazy/GBT-V.bcmap-Cq6Niv8e.js +3 -0
  294. package/dist/lazy/GBTpc-EUC-H.bcmap-CX8SXrun.js +3 -0
  295. package/dist/lazy/GBTpc-EUC-V.bcmap-hM7BhuwC.js +3 -0
  296. package/dist/lazy/GBpc-EUC-H.bcmap-BIEXt7KG.js +3 -0
  297. package/dist/lazy/GBpc-EUC-V.bcmap-DWeqNOzl.js +3 -0
  298. package/dist/lazy/H.bcmap-DsMNeuh7.js +3 -0
  299. package/dist/lazy/HKdla-B5-H.bcmap-CI5u0d4T.js +3 -0
  300. package/dist/lazy/HKdla-B5-V.bcmap-yk9YM4CN.js +3 -0
  301. package/dist/lazy/HKdlb-B5-H.bcmap-DenLwP2C.js +3 -0
  302. package/dist/lazy/HKdlb-B5-V.bcmap-BKFxIrzq.js +3 -0
  303. package/dist/lazy/HKgccs-B5-H.bcmap-i607pEmt.js +3 -0
  304. package/dist/lazy/HKgccs-B5-V.bcmap-BA9Nvcnu.js +3 -0
  305. package/dist/lazy/HKm314-B5-H.bcmap-BamdAWrg.js +3 -0
  306. package/dist/lazy/HKm314-B5-V.bcmap-JIFeW7D_.js +3 -0
  307. package/dist/lazy/HKm471-B5-H.bcmap-CIOwD0zn.js +3 -0
  308. package/dist/lazy/HKm471-B5-V.bcmap-BkDoTPME.js +3 -0
  309. package/dist/lazy/HKscs-B5-H.bcmap--SdxOf4z.js +3 -0
  310. package/dist/lazy/HKscs-B5-V.bcmap-DmqMO-Th.js +3 -0
  311. package/dist/lazy/Hankaku.bcmap-B2fyvO8A.js +3 -0
  312. package/dist/lazy/Hiragana.bcmap-DP3YLVOE.js +3 -0
  313. package/dist/lazy/KSC-EUC-H.bcmap-DQ5YvjA7.js +3 -0
  314. package/dist/lazy/KSC-EUC-V.bcmap-BNvwGfQX.js +3 -0
  315. package/dist/lazy/KSC-H.bcmap-Ca-HYPS4.js +3 -0
  316. package/dist/lazy/KSC-Johab-H.bcmap-CfF2UvBc.js +3 -0
  317. package/dist/lazy/KSC-Johab-V.bcmap-LBN9I8dg.js +3 -0
  318. package/dist/lazy/KSC-V.bcmap-5U7FPho3.js +3 -0
  319. package/dist/lazy/KSCms-UHC-H.bcmap-CmoPtsRN.js +3 -0
  320. package/dist/lazy/KSCms-UHC-HW-H.bcmap-CVBsfTPV.js +3 -0
  321. package/dist/lazy/KSCms-UHC-HW-V.bcmap-Dv90XUw-.js +3 -0
  322. package/dist/lazy/KSCms-UHC-V.bcmap-BlaojGc1.js +3 -0
  323. package/dist/lazy/KSCpc-EUC-H.bcmap-FrupvwaV.js +3 -0
  324. package/dist/lazy/KSCpc-EUC-V.bcmap-MG3GiZE4.js +3 -0
  325. package/dist/lazy/Katakana.bcmap-C8Bmgyhi.js +3 -0
  326. package/dist/lazy/NWP-H.bcmap-CAdIwPDs.js +3 -0
  327. package/dist/lazy/NWP-V.bcmap-DJ8FpnB4.js +3 -0
  328. package/dist/lazy/RKSJ-H.bcmap-qGRAHcEF.js +3 -0
  329. package/dist/lazy/RKSJ-V.bcmap-Dg3ddxaN.js +3 -0
  330. package/dist/lazy/Roman.bcmap-D4SBc9em.js +3 -0
  331. package/dist/lazy/UniCNS-UCS2-H.bcmap-CAjdESaO.js +3 -0
  332. package/dist/lazy/UniCNS-UCS2-V.bcmap-BHZM4Vzw.js +3 -0
  333. package/dist/lazy/UniCNS-UTF16-H.bcmap-Cm4ZnlrX.js +3 -0
  334. package/dist/lazy/UniCNS-UTF16-V.bcmap-BP1BFVyb.js +3 -0
  335. package/dist/lazy/UniCNS-UTF32-H.bcmap-DGLG7zQ_.js +3 -0
  336. package/dist/lazy/UniCNS-UTF32-V.bcmap-C6v0CIVn.js +3 -0
  337. package/dist/lazy/UniCNS-UTF8-H.bcmap-97YD5l2o.js +3 -0
  338. package/dist/lazy/UniCNS-UTF8-V.bcmap-B_zdNm-u.js +3 -0
  339. package/dist/lazy/UniGB-UCS2-H.bcmap-BcioIbCK.js +3 -0
  340. package/dist/lazy/UniGB-UCS2-V.bcmap-Cu-XDS3_.js +3 -0
  341. package/dist/lazy/UniGB-UTF16-H.bcmap-DPDBbQj_.js +3 -0
  342. package/dist/lazy/UniGB-UTF16-V.bcmap-Bwwxp3b7.js +3 -0
  343. package/dist/lazy/UniGB-UTF32-H.bcmap-D-uBJmmw.js +3 -0
  344. package/dist/lazy/UniGB-UTF32-V.bcmap-CLe_N_q5.js +3 -0
  345. package/dist/lazy/UniGB-UTF8-H.bcmap-CadVYdlJ.js +3 -0
  346. package/dist/lazy/UniGB-UTF8-V.bcmap-B9mD6Kt7.js +3 -0
  347. package/dist/lazy/UniJIS-UCS2-H.bcmap-BaCSu9QA.js +3 -0
  348. package/dist/lazy/UniJIS-UCS2-HW-H.bcmap-CYQj9xSp.js +3 -0
  349. package/dist/lazy/UniJIS-UCS2-HW-V.bcmap-CDzIwh-J.js +3 -0
  350. package/dist/lazy/UniJIS-UCS2-V.bcmap-DqCxM_EZ.js +3 -0
  351. package/dist/lazy/UniJIS-UTF16-H.bcmap-9TPLuUCU.js +3 -0
  352. package/dist/lazy/UniJIS-UTF16-V.bcmap-D6-nIWTQ.js +3 -0
  353. package/dist/lazy/UniJIS-UTF32-H.bcmap-CzmUWSLA.js +3 -0
  354. package/dist/lazy/UniJIS-UTF32-V.bcmap--KhJJEJE.js +3 -0
  355. package/dist/lazy/UniJIS-UTF8-H.bcmap-BwrhFSFd.js +3 -0
  356. package/dist/lazy/UniJIS-UTF8-V.bcmap-DGwbFkaL.js +3 -0
  357. package/dist/lazy/UniJIS2004-UTF16-H.bcmap-CdsS_d3_.js +3 -0
  358. package/dist/lazy/UniJIS2004-UTF16-V.bcmap-BnlV29Vf.js +3 -0
  359. package/dist/lazy/UniJIS2004-UTF32-H.bcmap-DSULVyIs.js +3 -0
  360. package/dist/lazy/UniJIS2004-UTF32-V.bcmap-CzBB970E.js +3 -0
  361. package/dist/lazy/UniJIS2004-UTF8-H.bcmap-BBuoGqhC.js +3 -0
  362. package/dist/lazy/UniJIS2004-UTF8-V.bcmap-dXgQhdTV.js +3 -0
  363. package/dist/lazy/UniJISPro-UCS2-HW-V.bcmap-ePVViljk.js +3 -0
  364. package/dist/lazy/UniJISPro-UCS2-V.bcmap-b2Oljrl4.js +3 -0
  365. package/dist/lazy/UniJISPro-UTF8-V.bcmap-CbPXe9gt.js +3 -0
  366. package/dist/lazy/UniJISX0213-UTF32-H.bcmap-Blmknifg.js +3 -0
  367. package/dist/lazy/UniJISX0213-UTF32-V.bcmap-Dtggmq9y.js +3 -0
  368. package/dist/lazy/UniJISX02132004-UTF32-H.bcmap-3YBd8tyQ.js +3 -0
  369. package/dist/lazy/UniJISX02132004-UTF32-V.bcmap-B8VdB9qS.js +3 -0
  370. package/dist/lazy/UniKS-UCS2-H.bcmap-CIhkpKgh.js +3 -0
  371. package/dist/lazy/UniKS-UCS2-V.bcmap-Cg-GDuqq.js +3 -0
  372. package/dist/lazy/UniKS-UTF16-H.bcmap-EZHb2IFq.js +3 -0
  373. package/dist/lazy/UniKS-UTF16-V.bcmap-BhqhAhYP.js +3 -0
  374. package/dist/lazy/UniKS-UTF32-H.bcmap-Cgay0dIp.js +3 -0
  375. package/dist/lazy/UniKS-UTF32-V.bcmap-DYXyatLV.js +3 -0
  376. package/dist/lazy/UniKS-UTF8-H.bcmap-BvHYimUT.js +3 -0
  377. package/dist/lazy/UniKS-UTF8-V.bcmap-DStcP2w0.js +3 -0
  378. package/dist/lazy/V.bcmap-DuWGSyNm.js +3 -0
  379. package/dist/lazy/WP-Symbol.bcmap-GltcyRl-.js +3 -0
  380. package/dist/lazy/_virtual_hm-pdfjs-data-BSzhlxyq.js +194 -0
  381. package/dist/lazy/jbig2.wasm-CUnHTdWi.js +3 -0
  382. package/dist/lazy/openjpeg.wasm-bdyxAnqz.js +3 -0
  383. package/dist/lazy/processing-worker-CxoVSxEZ.js +30 -0
  384. package/dist/lazy/processing-worker-CxoVSxEZ.js.map +1 -0
  385. package/dist/lazy/render-worker-WgnZ-czI.js +30 -0
  386. package/dist/lazy/render-worker-WgnZ-czI.js.map +1 -0
  387. package/dist/lazy/runtime-G4hlayVF.js +22652 -0
  388. package/dist/lazy/runtime-G4hlayVF.js.map +1 -0
  389. package/dist/react.d.ts +1332 -0
  390. package/dist/react.js +899 -0
  391. package/dist/react.js.map +1 -0
  392. package/dist/shared/en-B0u26URn.js +1244 -0
  393. package/dist/shared/en-B0u26URn.js.map +1 -0
  394. package/dist/styles.css +335 -0
  395. package/package.json +107 -3
@@ -0,0 +1,1244 @@
1
+ import { SdkError, checkFile, coreLimits, createWorkerClient, defineLimits, defineMessages, isSdkError, plural, sdkCoreMessages, withProcessingTime } from "@hussmartinez/sdk-core";
2
+ // src/core/errors/pdf-error.ts
3
+ var PdfError = class extends SdkError {
4
+ name = "PdfError";
5
+ };
6
+ function isPdfError(value, code) {
7
+ return isSdkError(value, code) && value.name === "PdfError";
8
+ }
9
+ // src/core/errors/abort.ts
10
+ function asPdfError(reason, message = "PDF processing failed.") {
11
+ if (reason instanceof PdfError) return reason;
12
+ if (isSdkError(reason)) return new PdfError(reason.code, reason.message, {
13
+ ...reason.details === void 0 ? {} : { details: reason.details },
14
+ cause: reason
15
+ });
16
+ return new PdfError("PROCESSING_FAILED", message, { cause: reason });
17
+ }
18
+ function abortError(signal) {
19
+ const { reason } = signal;
20
+ if (reason instanceof PdfError) return reason;
21
+ if (isSdkError(reason)) return asPdfError(reason);
22
+ const timedOut = reason instanceof DOMException && reason.name === "TimeoutError";
23
+ return new PdfError(timedOut ? "TIMEOUT" : "ABORTED", timedOut ? "The operation timed out." : "The operation was cancelled.", { cause: reason });
24
+ }
25
+ function throwIfAborted(signal) {
26
+ if (signal?.aborted) throw abortError(signal);
27
+ }
28
+ // src/core/errors/pdf-limits.ts
29
+ var pdfLimitDefinitions = {
30
+ ...coreLimits,
31
+ maxPages: {
32
+ code: "TOO_MANY_PAGES",
33
+ unit: "count",
34
+ default: 5e3,
35
+ warning: 1e3
36
+ },
37
+ maxSessionSize: {
38
+ code: "SESSION_TOO_LARGE",
39
+ unit: "bytes",
40
+ default: 3e8,
41
+ warning: 15e7
42
+ },
43
+ maxImagePixels: {
44
+ code: "IMAGE_TOO_LARGE",
45
+ unit: "pixels",
46
+ default: 1e8
47
+ }
48
+ };
49
+ var pdfLimits = /* @__PURE__ */ defineLimits(pdfLimitDefinitions, { errorClass: PdfError });
50
+ // src/core/model/bytes.ts
51
+ function copyBytes(source) {
52
+ const view = source instanceof Uint8Array ? source : new Uint8Array(source);
53
+ return new Uint8Array(view);
54
+ }
55
+ function assertPageIndex(pageIndex, pageCount) {
56
+ if (!Number.isInteger(pageIndex) || pageIndex < 0 || pageIndex >= pageCount) throw new RangeError(`Page index ${pageIndex} is outside the document, which has ${pageCount} pages.`);
57
+ }
58
+ // src/core/model/geometry.ts
59
+ function addRotation(rotation, angle) {
60
+ if (!Number.isInteger(angle) || angle % 90 !== 0) throw new RangeError(`A rotation must be a multiple of 90 degrees, received ${angle}.`);
61
+ return ((rotation + angle) % 360 + 360) % 360;
62
+ }
63
+ // src/core/model/links.ts
64
+ var SAFE_PROTOCOLS = /* @__PURE__ */ new Set([
65
+ "http:",
66
+ "https:",
67
+ "mailto:"
68
+ ]);
69
+ function safeLinkUrl(url) {
70
+ if (typeof url !== "string" || url.length > 2048) return void 0;
71
+ let parsed;
72
+ try {
73
+ parsed = new URL(url);
74
+ } catch {
75
+ return;
76
+ }
77
+ if (!SAFE_PROTOCOLS.has(parsed.protocol)) return void 0;
78
+ if (parsed.username !== "" || parsed.password !== "") return void 0;
79
+ return parsed.href;
80
+ }
81
+ function linkDestination(url) {
82
+ const safe = safeLinkUrl(url);
83
+ if (!safe) return void 0;
84
+ const parsed = new URL(safe);
85
+ if (parsed.protocol === "mailto:") return decodeURIComponent(parsed.pathname) || void 0;
86
+ return parsed.hostname.replace(/^www\./, "");
87
+ }
88
+ // src/core/ports/pdf-engine.ts
89
+ var PDF_MAX_CANVAS_PIXELS = 16777216;
90
+ // src/adapters/assets-url.ts
91
+ function assetsBase(assetsUrl) {
92
+ if (assetsUrl === void 0) return void 0;
93
+ const base = new URL(String(assetsUrl), globalThis.location?.href).href;
94
+ return base.endsWith("/") ? base : `${base}/`;
95
+ }
96
+ // src/adapters/pdfjs/binary-data.ts
97
+ var NO_NETWORK_URL = "hm-pdf-no-network:/";
98
+ function decodeBase64(base64) {
99
+ const binary = atob(base64);
100
+ const bytes = new Uint8Array(binary.length);
101
+ for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
102
+ return bytes;
103
+ }
104
+ function createInlineDataFactory(listener) {
105
+ return class InlineDataFactory {
106
+ async fetch({ kind, filename }) {
107
+ listener?.(kind, filename);
108
+ const { pdfJsData } = await import("../lazy/_virtual_hm-pdfjs-data-BSzhlxyq.js");
109
+ const files = Object.hasOwn(pdfJsData, kind) ? pdfJsData[kind] : void 0;
110
+ const load = files && Object.hasOwn(files, filename) ? files[filename] : void 0;
111
+ if (!load) throw new Error(`The PDF SDK doesn't serve ${kind} data named ${filename}.`);
112
+ return decodeBase64(await load());
113
+ }
114
+ };
115
+ }
116
+ // src/adapters/pdfjs/errors.ts
117
+ var INVALID = /* @__PURE__ */ new Set([
118
+ "InvalidPDFException",
119
+ "FormatError",
120
+ "MissingPDFException"
121
+ ]);
122
+ function fromPdfJsError(reason, message) {
123
+ if (isPdfError(reason) || reason instanceof RangeError) return reason;
124
+ const name = typeof reason === "object" && reason !== null ? reason.name : void 0;
125
+ if (name === "PasswordException") return new PdfError("PASSWORD_REQUIRED", "The PDF is encrypted.", { cause: reason });
126
+ if (name !== void 0 && INVALID.has(name)) return new PdfError("INVALID_PDF", "The file isn't a readable PDF.", { cause: reason });
127
+ return new PdfError("PROCESSING_FAILED", message, { cause: reason });
128
+ }
129
+ // src/adapters/pdfjs/pdfjs-engine.ts
130
+ function toPageRect(viewport, box) {
131
+ const [x1 = 0, y1 = 0, x2 = 0, y2 = 0] = box;
132
+ const [ax = 0, ay = 0] = viewport.convertToViewportPoint(x1, y1);
133
+ const [bx = 0, by = 0] = viewport.convertToViewportPoint(x2, y2);
134
+ const left = clamp(Math.min(ax, bx) / viewport.width);
135
+ const top = clamp(Math.min(ay, by) / viewport.height);
136
+ return {
137
+ x: left,
138
+ y: top,
139
+ width: clamp(Math.max(ax, bx) / viewport.width) - left,
140
+ height: clamp(Math.max(ay, by) / viewport.height) - top
141
+ };
142
+ }
143
+ var CANCEL_TIMEOUT = 1e3;
144
+ function createPdfJsEngine(options = {}) {
145
+ return new PdfJsEngine(options);
146
+ }
147
+ var WorkerHost = class {
148
+ pdfWorker;
149
+ #worker;
150
+ #waiting = /* @__PURE__ */ new Set();
151
+ #failure;
152
+ constructor(worker, pdfWorker) {
153
+ this.#worker = worker;
154
+ this.pdfWorker = pdfWorker;
155
+ const crash = (event) => {
156
+ event.preventDefault();
157
+ this.fail(new PdfError("WORKER_CRASHED", "The PDF render worker failed."));
158
+ };
159
+ worker.addEventListener("error", crash);
160
+ worker.addEventListener("messageerror", crash);
161
+ }
162
+ get failure() {
163
+ return this.#failure;
164
+ }
165
+ watch(reject) {
166
+ if (this.#failure) {
167
+ reject(this.#failure);
168
+ return () => {};
169
+ }
170
+ this.#waiting.add(reject);
171
+ return () => this.#waiting.delete(reject);
172
+ }
173
+ fail(error) {
174
+ if (this.#failure) return;
175
+ this.#failure = error;
176
+ this.#worker.terminate();
177
+ this.pdfWorker.destroy();
178
+ for (const reject of this.#waiting) reject(error);
179
+ this.#waiting.clear();
180
+ }
181
+ };
182
+ function settle(host, promise, options) {
183
+ const { signal } = options;
184
+ return new Promise((resolve, reject) => {
185
+ if (signal?.aborted) {
186
+ options.onAbort?.();
187
+ reject(abortError(signal));
188
+ return;
189
+ }
190
+ const abort = () => {
191
+ options.onAbort?.();
192
+ reject(abortError(signal));
193
+ };
194
+ signal?.addEventListener("abort", abort, { once: true });
195
+ const unwatch = host.watch(reject);
196
+ promise.then(resolve, (reason) => reject(fromPdfJsError(reason, options.message)));
197
+ promise.catch(() => {}).finally(() => {
198
+ signal?.removeEventListener("abort", abort);
199
+ unwatch();
200
+ });
201
+ });
202
+ }
203
+ function takeBytes(source, transfer) {
204
+ if (transfer) {
205
+ const view = source instanceof Uint8Array ? source : new Uint8Array(source);
206
+ if (view.byteOffset === 0 && view.byteLength === view.buffer.byteLength && view.buffer instanceof ArrayBuffer) return view;
207
+ }
208
+ return copyBytes(source);
209
+ }
210
+ function normalizeRotation(rotation) {
211
+ return addRotation(0, Number.isInteger(rotation) && rotation % 90 === 0 ? rotation : 0);
212
+ }
213
+ var clamp = (value) => Math.min(1, Math.max(0, value));
214
+ var PdfJsEngine = class {
215
+ #options;
216
+ #runtime;
217
+ #host;
218
+ #documents = /* @__PURE__ */ new Set();
219
+ #destroyed = false;
220
+ constructor(options) {
221
+ this.#options = options;
222
+ }
223
+ async open(source, options = {}) {
224
+ if (this.#destroyed) throw new PdfError("WORKER_TERMINATED", "The PDF engine was destroyed.");
225
+ throwIfAborted(options.signal);
226
+ const data = takeBytes(source, options.transfer);
227
+ this.#runtime ??= import("../lazy/runtime-G4hlayVF.js").then((module) => module.pdfjs);
228
+ const pdfjs = await this.#runtime;
229
+ throwIfAborted(options.signal);
230
+ const host = await this.#ensureHost(pdfjs);
231
+ const base = this.#assetsBase();
232
+ const task = pdfjs.getDocument({
233
+ data,
234
+ worker: host.pdfWorker,
235
+ enableXfa: false,
236
+ maxImageSize: this.#options.maxImagePixels ?? pdfLimitDefinitions.maxImagePixels.default,
237
+ stopAtErrors: false,
238
+ verbosity: pdfjs.VerbosityLevel.ERRORS,
239
+ useWasm: true,
240
+ ...base ? {
241
+ useWorkerFetch: true,
242
+ cMapUrl: `${base}cmaps/`,
243
+ standardFontDataUrl: `${base}standard_fonts/`,
244
+ wasmUrl: `${base}wasm/`,
245
+ iccUrl: `${base}iccs/`
246
+ } : {
247
+ useWorkerFetch: false,
248
+ BinaryDataFactory: createInlineDataFactory(this.#options._onDataRequest),
249
+ wasmUrl: NO_NETWORK_URL
250
+ }
251
+ });
252
+ try {
253
+ const document = new PdfJsDocument(pdfjs, await settle(host, task.promise, {
254
+ signal: options.signal,
255
+ onAbort: () => this.#cancel(task, host),
256
+ message: "The PDF couldn't be opened."
257
+ }), task, host, () => this.#documents.delete(document));
258
+ this.#documents.add(document);
259
+ return document;
260
+ } catch (error) {
261
+ task.destroy().catch(() => {});
262
+ throw error;
263
+ }
264
+ }
265
+ async destroy() {
266
+ if (this.#destroyed) return;
267
+ this.#destroyed = true;
268
+ await Promise.all([...this.#documents].map((document) => document.destroy()));
269
+ this.#host?.fail(new PdfError("WORKER_TERMINATED", "The PDF engine was destroyed."));
270
+ this.#host = void 0;
271
+ }
272
+ async #ensureHost(pdfjs) {
273
+ if (this.#host && !this.#host.failure) return this.#host;
274
+ let worker;
275
+ try {
276
+ const base = this.#assetsBase();
277
+ worker = base ? new Worker(`${base}build/pdf.worker.min.mjs`, {
278
+ type: "module",
279
+ name: "hm-pdf-render"
280
+ }) : (await import("../lazy/render-worker-WgnZ-czI.js")).createInlineWorker();
281
+ } catch (cause) {
282
+ throw new PdfError("WORKER_START_FAILED", "The PDF render worker couldn't start.", { cause });
283
+ }
284
+ this.#host = new WorkerHost(worker, pdfjs.PDFWorker.create({ port: worker }));
285
+ return this.#host;
286
+ }
287
+ #assetsBase() {
288
+ const base = assetsBase(this.#options.assetsUrl);
289
+ return base === void 0 ? void 0 : `${base}pdfjs/`;
290
+ }
291
+ #cancel(task, host) {
292
+ const timer = setTimeout(() => host.fail(new PdfError("WORKER_TERMINATED", "The worker was stopped to cancel an operation.")), CANCEL_TIMEOUT);
293
+ task.destroy().catch(() => {}).finally(() => clearTimeout(timer));
294
+ }
295
+ };
296
+ var PdfJsDocument = class {
297
+ pageCount;
298
+ #pdfjs;
299
+ #proxy;
300
+ #task;
301
+ #host;
302
+ #onDestroy;
303
+ #destroyed = false;
304
+ constructor(pdfjs, proxy, task, host, onDestroy) {
305
+ this.#pdfjs = pdfjs;
306
+ this.#proxy = proxy;
307
+ this.#task = task;
308
+ this.#host = host;
309
+ this.#onDestroy = onDestroy;
310
+ this.pageCount = proxy.numPages;
311
+ }
312
+ async getPage(pageIndex, options = {}) {
313
+ const page = await this.#page(pageIndex, options);
314
+ const { width, height } = page.getViewport({
315
+ scale: 1,
316
+ rotation: 0
317
+ });
318
+ return {
319
+ width,
320
+ height,
321
+ rotation: normalizeRotation(page.rotate)
322
+ };
323
+ }
324
+ async renderPage(pageIndex, canvas, options) {
325
+ if (!(options.scale > 0) || !Number.isFinite(options.scale)) throw new RangeError(`The render scale must be a positive number, received ${options.scale}.`);
326
+ const page = await this.#page(pageIndex, options);
327
+ const rotation = addRotation(normalizeRotation(page.rotate), options.rotation ?? 0);
328
+ const viewport = page.getViewport({
329
+ scale: options.scale,
330
+ rotation
331
+ });
332
+ const area = viewport.width * viewport.height;
333
+ const wanted = Math.max(options.pixelRatio ?? 1, Number.MIN_VALUE);
334
+ const ratio = Math.min(wanted, Math.sqrt(PDF_MAX_CANVAS_PIXELS / Math.max(area, 1)));
335
+ canvas.width = Math.max(1, Math.floor(viewport.width * ratio));
336
+ canvas.height = Math.max(1, Math.floor(viewport.height * ratio));
337
+ canvas.style.width = `${viewport.width}px`;
338
+ canvas.style.height = `${viewport.height}px`;
339
+ const context = canvas.getContext("2d", { alpha: false });
340
+ if (!context) throw new PdfError("UNSUPPORTED_ENVIRONMENT", "The browser can't draw on a canvas.", { details: { feature: "CanvasRenderingContext2D" } });
341
+ const task = page.render({
342
+ canvas,
343
+ canvasContext: context,
344
+ viewport,
345
+ transform: [
346
+ canvas.width / viewport.width,
347
+ 0,
348
+ 0,
349
+ canvas.height / viewport.height,
350
+ 0,
351
+ 0
352
+ ],
353
+ annotationMode: this.#pdfjs.AnnotationMode.ENABLE
354
+ });
355
+ try {
356
+ await settle(this.#host, task.promise, {
357
+ signal: options.signal,
358
+ onAbort: () => task.cancel(),
359
+ message: "The page couldn't be drawn."
360
+ });
361
+ } finally {
362
+ page.cleanup();
363
+ }
364
+ }
365
+ async getTextContent(pageIndex, options = {}) {
366
+ const page = await this.#page(pageIndex, options);
367
+ const content = await settle(this.#host, page.getTextContent(), {
368
+ signal: options.signal,
369
+ message: "The page's text couldn't be read."
370
+ });
371
+ const viewport = page.getViewport({
372
+ scale: 1,
373
+ rotation: 0
374
+ });
375
+ const items = [];
376
+ for (const item of content.items) {
377
+ if (!("str" in item)) continue;
378
+ const { str, transform, width, hasEOL } = item;
379
+ const [a = 1, b = 0, c = 0, d = 1, e = 0, f = 0] = transform;
380
+ const fontHeight = Math.hypot(c, d);
381
+ items.push({
382
+ text: str,
383
+ rect: toPageRect(viewport, [
384
+ e,
385
+ f,
386
+ e + width,
387
+ f + fontHeight
388
+ ]),
389
+ angle: Math.atan2(b, a) * 180 / Math.PI,
390
+ endOfLine: hasEOL
391
+ });
392
+ }
393
+ return { items };
394
+ }
395
+ async getFormFields(pageIndex, options = {}) {
396
+ const page = await this.#page(pageIndex, options);
397
+ const annotations = await settle(this.#host, page.getAnnotations({ intent: "display" }), {
398
+ signal: options.signal,
399
+ message: "The page's form fields couldn't be read."
400
+ });
401
+ const viewport = page.getViewport({
402
+ scale: 1,
403
+ rotation: 0
404
+ });
405
+ const fields = /* @__PURE__ */ new Map();
406
+ for (const annotation of annotations) {
407
+ const name = annotation["fieldName"];
408
+ if (annotation["subtype"] !== "Widget" || typeof name !== "string" || fields.has(name)) continue;
409
+ const value = annotation["fieldValue"];
410
+ const type = annotation["fieldType"] === "Tx" ? "text" : annotation["fieldType"] === "Btn" && annotation["checkBox"] ? "checkbox" : void 0;
411
+ if (!type) continue;
412
+ fields.set(name, {
413
+ name,
414
+ type,
415
+ rect: toPageRect(viewport, annotation["rect"]),
416
+ value: type === "text" ? typeof value === "string" ? value : "" : typeof value === "string" && value !== "" && value !== "Off",
417
+ readOnly: annotation["readOnly"] === true
418
+ });
419
+ }
420
+ return [...fields.values()];
421
+ }
422
+ async getLinks(pageIndex, options = {}) {
423
+ const page = await this.#page(pageIndex, options);
424
+ const annotations = await settle(this.#host, page.getAnnotations({ intent: "display" }), {
425
+ signal: options.signal,
426
+ message: "The page's links couldn't be read."
427
+ });
428
+ const viewport = page.getViewport({
429
+ scale: 1,
430
+ rotation: 0
431
+ });
432
+ const links = [];
433
+ for (const annotation of annotations) {
434
+ if (annotation["subtype"] !== "Link" || typeof annotation["url"] !== "string") continue;
435
+ const url = safeLinkUrl(annotation["url"]);
436
+ if (url) links.push({
437
+ rect: toPageRect(viewport, annotation["rect"]),
438
+ url
439
+ });
440
+ }
441
+ return links;
442
+ }
443
+ async destroy() {
444
+ if (this.#destroyed) return;
445
+ this.#destroyed = true;
446
+ this.#onDestroy();
447
+ await this.#task.destroy().catch(() => {});
448
+ }
449
+ async #page(pageIndex, options) {
450
+ if (this.#destroyed) throw new PdfError("WORKER_TERMINATED", "The document was destroyed.");
451
+ assertPageIndex(pageIndex, this.pageCount);
452
+ throwIfAborted(options.signal);
453
+ return settle(this.#host, this.#proxy.getPage(pageIndex + 1), {
454
+ signal: options.signal,
455
+ message: "The page couldn't be read."
456
+ });
457
+ }
458
+ };
459
+ // src/adapters/qpdf/qpdf-processor.ts
460
+ function createPdfProcessor(options = {}) {
461
+ const base = assetsBase(options.assetsUrl);
462
+ let client;
463
+ let destroyed = false;
464
+ const start = () => {
465
+ client ??= createWorkerClient({
466
+ createWorker: () => {
467
+ if (base) return new Worker(`${base}processing/processing.worker.js`, {
468
+ type: "module",
469
+ name: "hm-pdf-processing"
470
+ });
471
+ if (!inlineWorker) throw new PdfError("WORKER_START_FAILED", "The processing worker hasn't loaded.");
472
+ return inlineWorker();
473
+ },
474
+ errorClasses: { PdfError }
475
+ });
476
+ return client;
477
+ };
478
+ let inlineWorker;
479
+ return {
480
+ async build(job, options = {}) {
481
+ if (destroyed) throw new PdfError("WORKER_TERMINATED", "The PDF processor was destroyed.");
482
+ if (!base) inlineWorker ??= (await import("../lazy/processing-worker-CxoVSxEZ.js")).createInlineWorker;
483
+ let outcome;
484
+ try {
485
+ outcome = await start().call("build", job, {
486
+ ...options.signal ? { signal: options.signal } : {},
487
+ ...options.onProgress ? { onProgress: options.onProgress } : {},
488
+ ...options.transfer ? { transfer: true } : {}
489
+ });
490
+ } catch (error) {
491
+ throw asPdfError(error, "The PDF couldn't be built.");
492
+ }
493
+ if (!outcome.ok) throw outcome.error === "RangeError" ? new RangeError(outcome.message) : new TypeError(outcome.message);
494
+ return outcome.bytes;
495
+ },
496
+ async destroy() {
497
+ destroyed = true;
498
+ client?.destroy();
499
+ client = void 0;
500
+ }
501
+ };
502
+ }
503
+ // src/core/model/plan.ts
504
+ var EMPTY_PLAN = Object.freeze({
505
+ pages: Object.freeze([]),
506
+ formValues: Object.freeze({})
507
+ });
508
+ // src/core/operations/commands.ts
509
+ function positions(plan, keys) {
510
+ if (keys.length === 0) throw new TypeError("A command needs at least one page.");
511
+ const wanted = new Set(keys);
512
+ if (wanted.size !== keys.length) throw new TypeError("A page appears twice in the command.");
513
+ const found = plan.pages.flatMap((page, index) => wanted.has(page.key) ? [index] : []);
514
+ if (found.length !== wanted.size) {
515
+ const known = new Set(plan.pages.map((page) => page.key));
516
+ const missing = keys.filter((key) => !known.has(key));
517
+ throw new TypeError(`The plan has no page ${missing.join(", ")}.`);
518
+ }
519
+ return found;
520
+ }
521
+ function withPages(plan, pages) {
522
+ return {
523
+ pages,
524
+ formValues: plan.formValues
525
+ };
526
+ }
527
+ function updatePage(plan, key, update) {
528
+ const [index] = positions(plan, [key]);
529
+ const pages = [...plan.pages];
530
+ pages[index] = update(plan.pages[index]);
531
+ return withPages(plan, pages);
532
+ }
533
+ function applyCommand(plan, command) {
534
+ switch (command.type) {
535
+ case "pdf.rotatePages": {
536
+ const at = new Set(positions(plan, command.pages));
537
+ addRotation(0, command.angle);
538
+ return {
539
+ plan: withPages(plan, plan.pages.map((page, index) => at.has(index) ? {
540
+ ...page,
541
+ rotation: addRotation(page.rotation, command.angle)
542
+ } : page)),
543
+ inverse: {
544
+ type: "pdf.rotatePages",
545
+ pages: command.pages,
546
+ angle: -command.angle
547
+ }
548
+ };
549
+ }
550
+ case "pdf.deletePages": {
551
+ const at = positions(plan, command.pages);
552
+ if (at.length === plan.pages.length) throw new RangeError("A document needs at least one page.");
553
+ const removed = new Set(at);
554
+ return {
555
+ plan: withPages(plan, plan.pages.filter((_, index) => !removed.has(index))),
556
+ inverse: {
557
+ type: "pdf.restorePages",
558
+ entries: at.map((index) => ({
559
+ index,
560
+ page: plan.pages[index]
561
+ }))
562
+ }
563
+ };
564
+ }
565
+ case "pdf.restorePages": {
566
+ const known = new Set(plan.pages.map((page) => page.key));
567
+ const pages = [...plan.pages];
568
+ let previous = -1;
569
+ for (const { index, page } of command.entries) {
570
+ if (known.has(page.key)) throw new TypeError(`The plan already has page ${page.key}.`);
571
+ if (!Number.isInteger(index) || index <= previous || index > pages.length) throw new RangeError(`Page ${page.key} can't be restored at position ${index}.`);
572
+ pages.splice(index, 0, page);
573
+ known.add(page.key);
574
+ previous = index;
575
+ }
576
+ if (command.entries.length === 0) throw new TypeError("A command needs at least one page.");
577
+ return {
578
+ plan: withPages(plan, pages),
579
+ inverse: {
580
+ type: "pdf.deletePages",
581
+ pages: command.entries.map(({ page }) => page.key)
582
+ }
583
+ };
584
+ }
585
+ case "pdf.movePages": {
586
+ const moved = new Set(positions(plan, command.pages));
587
+ const block = plan.pages.filter((_, index) => moved.has(index));
588
+ const rest = plan.pages.filter((_, index) => !moved.has(index));
589
+ if (!Number.isInteger(command.to) || command.to < 0 || command.to > rest.length) throw new RangeError(`Pages can't be moved to position ${command.to}.`);
590
+ return {
591
+ plan: withPages(plan, [
592
+ ...rest.slice(0, command.to),
593
+ ...block,
594
+ ...rest.slice(command.to)
595
+ ]),
596
+ inverse: {
597
+ type: "pdf.reorderPages",
598
+ order: plan.pages.map((page) => page.key)
599
+ }
600
+ };
601
+ }
602
+ case "pdf.reorderPages": {
603
+ const byKey = new Map(plan.pages.map((page) => [page.key, page]));
604
+ if (command.order.length !== plan.pages.length || new Set(command.order).size !== command.order.length || command.order.some((key) => !byKey.has(key))) throw new TypeError("A new order must list every page of the plan exactly once.");
605
+ return {
606
+ plan: withPages(plan, command.order.map((key) => byKey.get(key))),
607
+ inverse: {
608
+ type: "pdf.reorderPages",
609
+ order: plan.pages.map((page) => page.key)
610
+ }
611
+ };
612
+ }
613
+ case "pdf.insertPages": {
614
+ const { pageIndexes, keys, at } = command;
615
+ if (pageIndexes.length === 0 || keys.length !== pageIndexes.length) throw new TypeError("An insert needs one key for each of at least one page.");
616
+ if (!Number.isInteger(at) || at < 0 || at > plan.pages.length) throw new RangeError(`Pages can't be inserted at position ${at}.`);
617
+ const known = new Set(plan.pages.map((page) => page.key));
618
+ if (new Set(keys).size !== keys.length || keys.some((key) => known.has(key))) throw new TypeError("Inserted pages need keys the plan doesn't have.");
619
+ const inserted = pageIndexes.map((pageIndex, index) => ({
620
+ key: keys[index],
621
+ source: command.source,
622
+ pageIndex,
623
+ rotation: 0,
624
+ annotations: []
625
+ }));
626
+ return {
627
+ plan: withPages(plan, [
628
+ ...plan.pages.slice(0, at),
629
+ ...inserted,
630
+ ...plan.pages.slice(at)
631
+ ]),
632
+ inverse: {
633
+ type: "pdf.deletePages",
634
+ pages: keys
635
+ }
636
+ };
637
+ }
638
+ case "pdf.setFieldValue": {
639
+ const { source, field, value } = command;
640
+ const current = plan.formValues[source] ?? {};
641
+ const previous = Object.hasOwn(current, field) ? current[field] : null;
642
+ const next = { ...current };
643
+ if (value === null) delete next[field];
644
+ else next[field] = value;
645
+ const formValues = {
646
+ ...plan.formValues,
647
+ [source]: next
648
+ };
649
+ if (Object.keys(next).length === 0) delete formValues[source];
650
+ return {
651
+ plan: {
652
+ pages: plan.pages,
653
+ formValues
654
+ },
655
+ inverse: {
656
+ type: "pdf.setFieldValue",
657
+ source,
658
+ field,
659
+ value: previous
660
+ }
661
+ };
662
+ }
663
+ case "pdf.addAnnotation": {
664
+ const { annotation } = command;
665
+ return {
666
+ plan: updatePage(plan, command.page, (page) => {
667
+ if (page.annotations.some((existing) => existing.id === annotation.id)) throw new TypeError(`Page ${page.key} already has annotation ${annotation.id}.`);
668
+ const index = command.index ?? page.annotations.length;
669
+ if (!Number.isInteger(index) || index < 0 || index > page.annotations.length) throw new RangeError(`The annotation can't go at position ${index}.`);
670
+ const annotations = [...page.annotations];
671
+ annotations.splice(index, 0, annotation);
672
+ return {
673
+ ...page,
674
+ annotations
675
+ };
676
+ }),
677
+ inverse: {
678
+ type: "pdf.removeAnnotation",
679
+ page: command.page,
680
+ id: annotation.id
681
+ }
682
+ };
683
+ }
684
+ case "pdf.removeAnnotation": {
685
+ let removed;
686
+ const next = updatePage(plan, command.page, (page) => {
687
+ const index = page.annotations.findIndex((annotation) => annotation.id === command.id);
688
+ if (index < 0) throw new TypeError(`Page ${page.key} has no annotation ${command.id}.`);
689
+ removed = {
690
+ annotation: page.annotations[index],
691
+ index
692
+ };
693
+ return {
694
+ ...page,
695
+ annotations: page.annotations.filter((_, at) => at !== index)
696
+ };
697
+ });
698
+ const { annotation, index } = removed;
699
+ return {
700
+ plan: next,
701
+ inverse: {
702
+ type: "pdf.addAnnotation",
703
+ page: command.page,
704
+ annotation,
705
+ index
706
+ }
707
+ };
708
+ }
709
+ default: throw new TypeError(`Unknown command ${command.type}.`);
710
+ }
711
+ }
712
+ function applyCommands(plan, commands) {
713
+ let current = plan;
714
+ const inverses = [];
715
+ for (const command of commands) {
716
+ const applied = applyCommand(current, command);
717
+ current = applied.plan;
718
+ inverses.unshift(applied.inverse);
719
+ }
720
+ return {
721
+ plan: current,
722
+ inverses
723
+ };
724
+ }
725
+ // src/core/session/history.ts
726
+ var History = class {
727
+ #past = [];
728
+ #future = [];
729
+ #trimmed = false;
730
+ get canUndo() {
731
+ return this.#past.length > 0;
732
+ }
733
+ get canRedo() {
734
+ return this.#future.length > 0;
735
+ }
736
+ get trimmed() {
737
+ return this.#trimmed;
738
+ }
739
+ get steps() {
740
+ return [...this.#past, ...this.#future];
741
+ }
742
+ get dropOrder() {
743
+ return [...this.#future, ...this.#past];
744
+ }
745
+ push(step) {
746
+ this.#past.push(step);
747
+ this.#future = [];
748
+ }
749
+ undo() {
750
+ const step = this.#past.pop();
751
+ if (step) this.#future.push(step);
752
+ return step;
753
+ }
754
+ redo() {
755
+ const step = this.#future.pop();
756
+ if (step) this.#past.push(step);
757
+ return step;
758
+ }
759
+ restore(direction) {
760
+ if (direction === "undo") {
761
+ const step = this.#future.pop();
762
+ if (step) this.#past.push(step);
763
+ } else {
764
+ const step = this.#past.pop();
765
+ if (step) this.#future.push(step);
766
+ }
767
+ }
768
+ drop(count) {
769
+ if (count <= 0) return;
770
+ const fromFuture = Math.min(count, this.#future.length);
771
+ this.#future.splice(0, fromFuture);
772
+ this.#past.splice(0, count - fromFuture);
773
+ this.#trimmed = true;
774
+ }
775
+ clear() {
776
+ this.#past = [];
777
+ this.#future = [];
778
+ this.#trimmed = false;
779
+ }
780
+ };
781
+ // src/core/session/session.ts
782
+ function createPdfSession(options) {
783
+ const { engine } = options;
784
+ const policy = pdfLimits.resolve(options.filePolicy);
785
+ const history = new History();
786
+ const listeners = /* @__PURE__ */ new Set();
787
+ const sources = /* @__PURE__ */ new Map();
788
+ let plan = EMPTY_PLAN;
789
+ let status = "empty";
790
+ let error;
791
+ let warnings = [];
792
+ let busy = 0;
793
+ let selection = [];
794
+ let currentPage;
795
+ let navigation;
796
+ let nextKey = 0;
797
+ let nextSource = 0;
798
+ let loading;
799
+ const heldBytes = () => [...sources.values()].reduce((total, source) => total + source.byteLength, 0);
800
+ function referenced(steps) {
801
+ const ids = new Set(plan.pages.map((page) => page.source));
802
+ for (const { commands, inverses } of steps) for (const command of [...commands, ...inverses]) {
803
+ if (command.type === "pdf.insertPages") ids.add(command.source);
804
+ if (command.type === "pdf.restorePages") for (const { page } of command.entries) ids.add(page.source);
805
+ }
806
+ return ids;
807
+ }
808
+ function collect() {
809
+ const keep = referenced(history.steps);
810
+ for (const [id, source] of sources) {
811
+ if (keep.has(id)) continue;
812
+ sources.delete(id);
813
+ source.document.destroy().catch(() => {});
814
+ }
815
+ }
816
+ function stepsToDrop(extra) {
817
+ const { maximum } = policy.limits.maxSessionSize;
818
+ const order = history.dropOrder;
819
+ for (let count = 0; count <= order.length; count += 1) {
820
+ const kept = new Set(order.slice(count));
821
+ if ([...referenced(history.steps.filter((entry) => kept.has(entry)))].reduce((sum, id) => sum + (sources.get(id)?.byteLength ?? 0), 0) + extra <= maximum) return count;
822
+ }
823
+ }
824
+ let snapshot = makeSnapshot();
825
+ function sessionWarnings() {
826
+ const bytes = heldBytes();
827
+ const sessionWarning = bytes > 0 && bytes >= policy.limits.maxSessionSize.warning ? [{
828
+ limit: "maxSessionSize",
829
+ actual: bytes
830
+ }] : [];
831
+ return [...warnings, ...sessionWarning];
832
+ }
833
+ function makeSnapshot() {
834
+ return Object.freeze({
835
+ status,
836
+ plan,
837
+ sources: Object.freeze([...sources.values()].map(({ id, pageCount, byteLength }) => Object.freeze({
838
+ id,
839
+ pageCount,
840
+ byteLength
841
+ }))),
842
+ canUndo: history.canUndo,
843
+ canRedo: history.canRedo,
844
+ busy: busy > 0,
845
+ error,
846
+ warnings: Object.freeze(sessionWarnings()),
847
+ sessionBytes: heldBytes(),
848
+ historyTrimmed: history.trimmed,
849
+ selection: Object.freeze([...selection]),
850
+ currentPage,
851
+ navigation: navigation ? Object.freeze({ ...navigation }) : void 0
852
+ });
853
+ }
854
+ function changed() {
855
+ const keys = new Set(plan.pages.map((page) => page.key));
856
+ if (selection.some((key) => !keys.has(key))) selection = selection.filter((key) => keys.has(key));
857
+ if (currentPage !== void 0 && !keys.has(currentPage)) currentPage = plan.pages[0]?.key;
858
+ if (currentPage === void 0 && plan.pages.length > 0) currentPage = plan.pages[0]?.key;
859
+ if (navigation && !keys.has(navigation.page)) navigation = void 0;
860
+ snapshot = makeSnapshot();
861
+ for (const listener of [...listeners]) listener();
862
+ }
863
+ function emit(event) {
864
+ try {
865
+ options.onEvent?.(event);
866
+ } catch {}
867
+ }
868
+ async function load(file, signal) {
869
+ const found = [];
870
+ const warnAt = (limit, actual) => {
871
+ if (policy.check(limit, actual) === "warning") found.push({
872
+ limit,
873
+ actual
874
+ });
875
+ };
876
+ if (file instanceof Blob) {
877
+ if (checkFile(policy, file) === "warning") found.push({
878
+ limit: "maxFileSize",
879
+ actual: file.size
880
+ });
881
+ } else warnAt("maxFileSize", file.byteLength);
882
+ const bytes = file instanceof Blob ? new Uint8Array(await file.arrayBuffer()) : copyBytes(file);
883
+ throwIfAborted(signal);
884
+ const document = await withProcessingTime(policy, (limited) => engine.open(bytes, { signal: limited }), { signal }).catch((reason) => {
885
+ throw asPdfError(reason, "The PDF couldn't be opened.");
886
+ });
887
+ try {
888
+ throwIfAborted(signal);
889
+ warnAt("maxPages", document.pageCount);
890
+ } catch (reason) {
891
+ await document.destroy();
892
+ throw reason;
893
+ }
894
+ warnings = [...warnings.filter((warning) => warning.limit !== "maxFileSize"), ...found];
895
+ nextSource += 1;
896
+ return {
897
+ id: `s${nextSource}`,
898
+ pageCount: document.pageCount,
899
+ byteLength: bytes.byteLength,
900
+ bytes,
901
+ document
902
+ };
903
+ }
904
+ async function track(signal, replaces, run) {
905
+ if (replaces) loading?.abort(new PdfError("ABORTED", "A newer document replaced this one."));
906
+ const controller = new AbortController();
907
+ if (replaces) loading = controller;
908
+ const combined = signal ? AbortSignal.any([signal, controller.signal]) : controller.signal;
909
+ busy += 1;
910
+ changed();
911
+ try {
912
+ return await run(combined);
913
+ } finally {
914
+ busy -= 1;
915
+ if (loading === controller) loading = void 0;
916
+ changed();
917
+ }
918
+ }
919
+ async function release() {
920
+ const documents = [...sources.values()].map((source) => source.document);
921
+ sources.clear();
922
+ await Promise.all(documents.map((document) => document.destroy().catch(() => {})));
923
+ }
924
+ function pageFor(key) {
925
+ const page = plan.pages.find((entry) => entry.key === key);
926
+ const source = page && sources.get(page.source);
927
+ if (!page || !source) throw new TypeError(`The plan has no page ${key}.`);
928
+ return {
929
+ page,
930
+ source
931
+ };
932
+ }
933
+ function step(commands) {
934
+ const result = applyCommands(plan, commands);
935
+ plan = result.plan;
936
+ history.push({
937
+ commands,
938
+ inverses: result.inverses
939
+ });
940
+ collect();
941
+ }
942
+ return {
943
+ getSnapshot: () => snapshot,
944
+ subscribe(listener) {
945
+ listeners.add(listener);
946
+ return () => listeners.delete(listener);
947
+ },
948
+ async open(file, callOptions = {}) {
949
+ status = "opening";
950
+ error = void 0;
951
+ try {
952
+ const source = await track(callOptions.signal, true, async (signal) => {
953
+ policy.check("maxSessionSize", file instanceof Blob ? file.size : file.byteLength);
954
+ return load(file, signal);
955
+ });
956
+ await release();
957
+ sources.set(source.id, source);
958
+ history.clear();
959
+ plan = {
960
+ pages: Array.from({ length: source.pageCount }, (_, pageIndex) => {
961
+ nextKey += 1;
962
+ return {
963
+ key: `p${nextKey}`,
964
+ source: source.id,
965
+ pageIndex,
966
+ rotation: 0,
967
+ annotations: []
968
+ };
969
+ }),
970
+ formValues: {}
971
+ };
972
+ status = "ready";
973
+ changed();
974
+ emit({
975
+ type: "document_opened",
976
+ pageCount: source.pageCount
977
+ });
978
+ } catch (reason) {
979
+ const failure = asPdfError(reason, "The PDF couldn't be opened.");
980
+ if (failure.code === "ABORTED" && loading !== void 0) throw failure;
981
+ status = sources.size > 0 ? "ready" : "error";
982
+ error = failure;
983
+ changed();
984
+ emit({
985
+ type: "failed",
986
+ operation: "open",
987
+ code: failure.code
988
+ });
989
+ throw failure;
990
+ }
991
+ },
992
+ async insert(file, insertOptions = {}) {
993
+ if (status !== "ready") throw new PdfError("PROCESSING_FAILED", "Open a document before inserting another.");
994
+ error = void 0;
995
+ try {
996
+ const source = await track(insertOptions.signal, false, async (signal) => {
997
+ policy.check("maxFiles", sources.size + 1);
998
+ return load(file, signal);
999
+ });
1000
+ try {
1001
+ const pageIndexes = insertOptions.pageIndexes ?? Array.from({ length: source.pageCount }, (_, index) => index);
1002
+ for (const index of pageIndexes) if (!Number.isInteger(index) || index < 0 || index >= source.pageCount) throw new RangeError(`The inserted document has no page index ${index}.`);
1003
+ if (policy.check("maxPages", plan.pages.length + pageIndexes.length) === "warning") warnings = [...warnings.filter((warning) => warning.limit !== "maxPages"), {
1004
+ limit: "maxPages",
1005
+ actual: plan.pages.length + pageIndexes.length
1006
+ }];
1007
+ const keys = pageIndexes.map(() => {
1008
+ nextKey += 1;
1009
+ return `p${nextKey}`;
1010
+ });
1011
+ const drop = stepsToDrop(source.byteLength);
1012
+ if (drop === void 0) throw policy.error("maxSessionSize", heldBytes() + source.byteLength);
1013
+ history.drop(drop);
1014
+ collect();
1015
+ sources.set(source.id, source);
1016
+ step([{
1017
+ type: "pdf.insertPages",
1018
+ source: source.id,
1019
+ pageIndexes,
1020
+ at: insertOptions.at ?? plan.pages.length,
1021
+ keys
1022
+ }]);
1023
+ changed();
1024
+ emit({
1025
+ type: "pages_inserted",
1026
+ pageCount: pageIndexes.length
1027
+ });
1028
+ } catch (reason) {
1029
+ sources.delete(source.id);
1030
+ await source.document.destroy().catch(() => {});
1031
+ throw reason;
1032
+ }
1033
+ } catch (reason) {
1034
+ if (reason instanceof TypeError || reason instanceof RangeError) throw reason;
1035
+ const failure = asPdfError(reason, "The PDF couldn't be inserted.");
1036
+ error = failure;
1037
+ changed();
1038
+ emit({
1039
+ type: "failed",
1040
+ operation: "insert",
1041
+ code: failure.code
1042
+ });
1043
+ throw failure;
1044
+ }
1045
+ },
1046
+ execute(commands) {
1047
+ const list = Array.isArray(commands) ? commands : [commands];
1048
+ if (list.length === 0) return;
1049
+ step(list);
1050
+ changed();
1051
+ emit({
1052
+ type: "command",
1053
+ commands: list.map((command) => command.type)
1054
+ });
1055
+ },
1056
+ undo() {
1057
+ const entry = history.undo();
1058
+ if (!entry) return;
1059
+ try {
1060
+ plan = applyCommands(plan, entry.inverses).plan;
1061
+ } catch (reason) {
1062
+ history.restore("undo");
1063
+ throw reason;
1064
+ }
1065
+ changed();
1066
+ emit({ type: "undo" });
1067
+ },
1068
+ redo() {
1069
+ const entry = history.redo();
1070
+ if (!entry) return;
1071
+ try {
1072
+ plan = applyCommands(plan, entry.commands).plan;
1073
+ } catch (reason) {
1074
+ history.restore("redo");
1075
+ throw reason;
1076
+ }
1077
+ changed();
1078
+ emit({ type: "redo" });
1079
+ },
1080
+ async getPage(key, callOptions) {
1081
+ const { page, source } = pageFor(key);
1082
+ const info = await source.document.getPage(page.pageIndex, callOptions);
1083
+ return {
1084
+ ...info,
1085
+ rotation: addRotation(info.rotation, page.rotation)
1086
+ };
1087
+ },
1088
+ async renderPage(key, canvas, renderOptions) {
1089
+ const { page, source } = pageFor(key);
1090
+ await source.document.renderPage(page.pageIndex, canvas, {
1091
+ ...renderOptions,
1092
+ rotation: page.rotation
1093
+ });
1094
+ },
1095
+ async getTextContent(key, callOptions) {
1096
+ const { page, source } = pageFor(key);
1097
+ return source.document.getTextContent(page.pageIndex, callOptions);
1098
+ },
1099
+ async getFormFields(key, callOptions) {
1100
+ const { page, source } = pageFor(key);
1101
+ const fields = await source.document.getFormFields(page.pageIndex, callOptions);
1102
+ const values = plan.formValues[source.id] ?? {};
1103
+ return fields.map((field) => Object.hasOwn(values, field.name) ? {
1104
+ ...field,
1105
+ value: values[field.name]
1106
+ } : field);
1107
+ },
1108
+ async getLinks(key, callOptions) {
1109
+ const { page, source } = pageFor(key);
1110
+ return source.document.getLinks(page.pageIndex, callOptions);
1111
+ },
1112
+ async export(exportOptions = {}) {
1113
+ if (status !== "ready" && sources.size === 0) throw new PdfError("PROCESSING_FAILED", "Open a document before exporting it.");
1114
+ const pages = plan.pages;
1115
+ const job = {
1116
+ sources: [...new Set(pages.map((page) => page.source))].map((id) => {
1117
+ const values = plan.formValues[id];
1118
+ return {
1119
+ id,
1120
+ bytes: sources.get(id).bytes,
1121
+ ...values && Object.keys(values).length > 0 ? { formValues: values } : {}
1122
+ };
1123
+ }),
1124
+ pages: pages.map((page) => ({
1125
+ source: page.source,
1126
+ pageIndex: page.pageIndex,
1127
+ ...page.rotation === 0 ? {} : { rotation: page.rotation },
1128
+ ...page.annotations.length === 0 ? {} : { annotations: page.annotations }
1129
+ })),
1130
+ ...exportOptions.compress ? { compress: exportOptions.compress } : {},
1131
+ ...exportOptions.encrypt ? { encrypt: exportOptions.encrypt } : {}
1132
+ };
1133
+ const done = () => emit({
1134
+ type: "document_exported",
1135
+ pageCount: pages.length,
1136
+ compressed: Boolean(exportOptions.compress),
1137
+ encrypted: Boolean(exportOptions.encrypt)
1138
+ });
1139
+ const [only] = job.sources;
1140
+ const source = only && sources.get(only.id);
1141
+ if (job.sources.length === 1 && !only?.formValues && !job.compress && !job.encrypt && source && job.pages.length === source.pageCount && job.pages.every((page, index) => page.pageIndex === index && !page.rotation && !page.annotations)) {
1142
+ throwIfAborted(exportOptions.signal);
1143
+ done();
1144
+ return copyBytes(source.bytes);
1145
+ }
1146
+ const { processor } = options;
1147
+ if (!processor) throw new TypeError("Exporting an edited document needs a processor in createPdfSession.");
1148
+ busy += 1;
1149
+ changed();
1150
+ try {
1151
+ const output = await withProcessingTime(policy, (signal) => processor.build(job, {
1152
+ signal,
1153
+ ...exportOptions.onProgress ? { onProgress: exportOptions.onProgress } : {}
1154
+ }), exportOptions.signal ? { signal: exportOptions.signal } : {});
1155
+ done();
1156
+ return output;
1157
+ } catch (reason) {
1158
+ if (reason instanceof TypeError || reason instanceof RangeError) throw reason;
1159
+ const failure = asPdfError(reason, "The PDF couldn't be exported.");
1160
+ emit({
1161
+ type: "failed",
1162
+ operation: "export",
1163
+ code: failure.code
1164
+ });
1165
+ throw failure;
1166
+ } finally {
1167
+ busy -= 1;
1168
+ changed();
1169
+ }
1170
+ },
1171
+ select(keys) {
1172
+ const wanted = new Set(keys);
1173
+ const next = plan.pages.filter((page) => wanted.has(page.key)).map((page) => page.key);
1174
+ if (next.length === selection.length && next.every((key, index) => key === selection[index])) return;
1175
+ selection = next;
1176
+ changed();
1177
+ },
1178
+ setCurrentPage(key) {
1179
+ if (key === currentPage || !plan.pages.some((page) => page.key === key)) return;
1180
+ currentPage = key;
1181
+ changed();
1182
+ },
1183
+ goToPage(key) {
1184
+ if (!plan.pages.some((page) => page.key === key)) throw new TypeError(`The plan has no page ${key}.`);
1185
+ currentPage = key;
1186
+ navigation = {
1187
+ page: key,
1188
+ sequence: (navigation?.sequence ?? 0) + 1
1189
+ };
1190
+ changed();
1191
+ },
1192
+ async close() {
1193
+ loading?.abort(new PdfError("ABORTED", "The document was closed."));
1194
+ const hadDocument = status === "ready";
1195
+ await release();
1196
+ plan = EMPTY_PLAN;
1197
+ history.clear();
1198
+ warnings = [];
1199
+ error = void 0;
1200
+ status = "empty";
1201
+ changed();
1202
+ if (hadDocument) emit({ type: "document_closed" });
1203
+ }
1204
+ };
1205
+ }
1206
+ // src/messages/en.ts
1207
+ var pdfMessages = /* @__PURE__ */ defineMessages({
1208
+ ...sdkCoreMessages,
1209
+ "errors.INVALID_PDF": "This file isn't a PDF, or it's too damaged to open.",
1210
+ "errors.PASSWORD_REQUIRED": "This PDF is protected with a password.",
1211
+ "errors.PROCESSING_FAILED": "Something went wrong while processing this PDF. Please try again.",
1212
+ "errors.TOO_MANY_PAGES": "This document has {actual, number} pages, which is over the {maximum, number}-page limit.",
1213
+ "errors.SESSION_TOO_LARGE": "The open documents would use {actual, fileSize}, which is over the {maximum, fileSize} limit. Close a document, or clear the undo history, and try again.",
1214
+ "errors.IMAGE_TOO_LARGE": "Some images are too large to show. They're kept unchanged in the document.",
1215
+ "warnings.maxPages": /* @__PURE__ */ plural("actual", {
1216
+ one: "This document has {actual} page. Large documents may be slow.",
1217
+ other: "This document has {actual} pages. Large documents may be slow."
1218
+ }),
1219
+ "warnings.maxSessionSize": "The open documents use {actual, fileSize}. Clearing the undo history frees memory.",
1220
+ "warnings.maxImagePixels": "Some images are very large and may be slow to show.",
1221
+ "viewer.label": "Document",
1222
+ "viewer.empty": "No document is open.",
1223
+ "viewer.page": "Page {page} of {count}",
1224
+ "viewer.webLink": "Link to {destination}, opens in a new tab",
1225
+ "viewer.emailLink": "Email {destination}",
1226
+ "thumbnails.label": "Pages",
1227
+ "thumbnails.page": "Page {page} of {count}",
1228
+ "thumbnails.number": "{page}",
1229
+ "editor.label": "PDF editor",
1230
+ "editor.start.title": "Open a PDF to get started",
1231
+ "editor.start.retryTitle": "Try another PDF",
1232
+ "editor.start.choose": "Choose a PDF",
1233
+ "editor.start.retry": "Choose another PDF",
1234
+ "editor.start.hint": "Or drop one here. Your file stays on this device and is never uploaded.",
1235
+ "editor.opening": "Opening the PDF…",
1236
+ "editor.opened": /* @__PURE__ */ plural("count", {
1237
+ one: "Opened a PDF with {count} page.",
1238
+ other: "Opened a PDF with {count} pages."
1239
+ }),
1240
+ "editor.closed": "The PDF was closed."
1241
+ });
1242
+ export { PDF_MAX_CANVAS_PIXELS as a, addRotation as c, PdfError as d, isPdfError as f, createPdfJsEngine as i, pdfLimitDefinitions as l, createPdfSession as n, linkDestination as o, createPdfProcessor as r, safeLinkUrl as s, pdfMessages as t, pdfLimits as u };
1243
+
1244
+ //# sourceMappingURL=en-B0u26URn.js.map