@poe-platform/safe-bash 0.1.813 → 0.1.815

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 (528) hide show
  1. package/dist/image-ast/index.js +1 -1
  2. package/dist/mp4-ast/index.d.ts +3 -0
  3. package/dist/mp4-ast/mp4-fragment-source.d.ts +35 -0
  4. package/dist/mp4-ast/mp4-sample-source.d.ts +55 -0
  5. package/dist/mp4-ast/mp4-source.d.ts +32 -0
  6. package/dist/mp4-ast/types.d.ts +11 -0
  7. package/dist/office-xml/retained-xml-document.d.ts +6 -0
  8. package/dist/pdf-ast/content/evaluator.d.ts +4 -0
  9. package/dist/pdf-ast/cos/object-reader.d.ts +8 -0
  10. package/dist/pdf-ast/cos/value-parser.d.ts +1 -0
  11. package/dist/pdf-ast/edit/forms.d.ts +1 -0
  12. package/dist/pdf-ast/edit/retained-form-appearances.d.ts +10 -0
  13. package/dist/pdf-ast/edit/retained-form-data.d.ts +9 -0
  14. package/dist/pdf-ast/edit/retained-graph.d.ts +6 -0
  15. package/dist/pdf-ast/edit/retained-info-updates.d.ts +33 -0
  16. package/dist/pdf-ast/index.d.ts +2 -1
  17. package/dist/pdf-ast/index.js +895 -139
  18. package/dist/pdf-ast/retained-document.d.ts +5 -0
  19. package/dist/safe-bash/command-chunks/biff-A7XPBWAK-DCLG5QKF.js +5417 -0
  20. package/dist/safe-bash/command-chunks/{chunk-34G2SQX2.js → chunk-2BLTUQNK.js} +2 -2
  21. package/dist/safe-bash/command-chunks/{chunk-LLU2IQEJ.js → chunk-2BNGPR6Z.js} +2 -2
  22. package/dist/safe-bash/command-chunks/{chunk-XIDGHIGB.js → chunk-2PKBXGXD.js} +5 -5
  23. package/dist/safe-bash/command-chunks/{chunk-6SRHWVEB.js → chunk-2VVJRVYM.js} +1 -1
  24. package/dist/safe-bash/command-chunks/{chunk-G5QVZQCO.js → chunk-3EASXF5D.js} +5 -5
  25. package/dist/safe-bash/command-chunks/{chunk-U3SBHEKH.js → chunk-3EB2FSAN.js} +9 -9
  26. package/dist/safe-bash/command-chunks/{chunk-VB2TUPO2.js → chunk-3EW7GYHM.js} +9 -9
  27. package/dist/safe-bash/command-chunks/{chunk-GVWVRPG6.js → chunk-3GRMU7TM.js} +6 -6
  28. package/dist/safe-bash/command-chunks/{chunk-6L4IYQAT.js → chunk-3MG5EAMX.js} +4 -4
  29. package/dist/safe-bash/command-chunks/{chunk-RASQPOSV.js → chunk-3SPLP2DB.js} +1 -1
  30. package/dist/safe-bash/command-chunks/{chunk-K5COUQAQ.js → chunk-3VGQTLO6.js} +1 -1
  31. package/dist/safe-bash/command-chunks/{chunk-K7CV55K5.js → chunk-3YEQI5B7.js} +10 -10
  32. package/dist/safe-bash/command-chunks/{chunk-KCE5D4Z4.js → chunk-3ZRCL756.js} +3 -3
  33. package/dist/safe-bash/command-chunks/{chunk-SOFM3GPG.js → chunk-42MEXZBJ.js} +1 -1
  34. package/dist/safe-bash/command-chunks/{chunk-PKLJRB7W.js → chunk-44F5TOHZ.js} +219 -90
  35. package/dist/safe-bash/command-chunks/{chunk-GQ2ZSPZ3.js → chunk-46AMTJPE.js} +10 -10
  36. package/dist/safe-bash/command-chunks/{chunk-MTWZEPAR.js → chunk-47IAU25U.js} +2 -2
  37. package/dist/safe-bash/command-chunks/{chunk-6GI3NTCW.js → chunk-4B2ZUGLT.js} +4 -4
  38. package/dist/safe-bash/command-chunks/{chunk-X64XGIXZ.js → chunk-4EHY6J2Z.js} +5 -5
  39. package/dist/safe-bash/command-chunks/{chunk-QQVACHZA.js → chunk-4EZJV4FZ.js} +1 -1
  40. package/dist/safe-bash/command-chunks/{chunk-SSKMPDN4.js → chunk-4GQKCUS5.js} +15 -15
  41. package/dist/safe-bash/command-chunks/{chunk-UOBW5K3M.js → chunk-4RRYWHED.js} +7 -7
  42. package/dist/safe-bash/command-chunks/{chunk-PINR7QET.js → chunk-4UPKVQWH.js} +8 -8
  43. package/dist/safe-bash/command-chunks/{chunk-I4GMCWAT.js → chunk-4YLACJHE.js} +6 -6
  44. package/dist/safe-bash/command-chunks/{chunk-P3WU3PSL.js → chunk-5L4YGRQU.js} +3 -3
  45. package/dist/safe-bash/command-chunks/{chunk-WPVBUVFK.js → chunk-5LFGXN3D.js} +6 -6
  46. package/dist/safe-bash/command-chunks/{chunk-YXD6VGVG.js → chunk-5OM3UIK3.js} +3 -3
  47. package/dist/safe-bash/command-chunks/{chunk-RLCQ7BN3.js → chunk-6CDDKNNA.js} +4 -3
  48. package/dist/safe-bash/command-chunks/{chunk-TQEB4DH4.js → chunk-6EINUY5G.js} +149 -165
  49. package/dist/safe-bash/command-chunks/{chunk-C5QDEB3I.js → chunk-6LPSKLLD.js} +3 -3
  50. package/dist/safe-bash/command-chunks/{chunk-XLYIVBAR.js → chunk-6QYSF7I2.js} +7 -7
  51. package/dist/safe-bash/command-chunks/{chunk-6IWE7PTK.js → chunk-6VBDJC6V.js} +6 -6
  52. package/dist/safe-bash/command-chunks/{chunk-6N5GHM72.js → chunk-6WNVGCXD.js} +8 -8
  53. package/dist/safe-bash/command-chunks/{chunk-PSCOXGCA.js → chunk-6XES7Z4G.js} +12 -12
  54. package/dist/safe-bash/command-chunks/{chunk-AFROLW6S.js → chunk-6XGDWFNQ.js} +4 -4
  55. package/dist/safe-bash/command-chunks/{chunk-WTE23QXN.js → chunk-6ZGCKUAM.js} +3 -3
  56. package/dist/safe-bash/command-chunks/{chunk-RIV6XN7K.js → chunk-7DOLY7IV.js} +2 -2
  57. package/dist/safe-bash/command-chunks/{chunk-ET2VPDUA.js → chunk-7KZ5LWV2.js} +1 -1
  58. package/dist/safe-bash/command-chunks/{chunk-NGR5KOPQ.js → chunk-A347DLRB.js} +3 -3
  59. package/dist/safe-bash/command-chunks/{chunk-ZM2Y4Z3C.js → chunk-A45UG4KT.js} +4 -4
  60. package/dist/safe-bash/command-chunks/{chunk-2Z3WRRFT.js → chunk-ADHFF2IM.js} +9 -9
  61. package/dist/safe-bash/command-chunks/{chunk-ATI464W3.js → chunk-AG2SNMP5.js} +1 -1
  62. package/dist/safe-bash/command-chunks/{chunk-HCKYUQ3L.js → chunk-AM5LANIE.js} +7 -7
  63. package/dist/safe-bash/command-chunks/{chunk-RBTC7OFT.js → chunk-AVOGFREX.js} +5 -5
  64. package/dist/safe-bash/command-chunks/{chunk-G3RUXKVY.js → chunk-AWPI4DZR.js} +3 -3
  65. package/dist/safe-bash/command-chunks/{chunk-FYMNHG7R.js → chunk-AXXZNB7U.js} +13 -13
  66. package/dist/safe-bash/command-chunks/{chunk-2E2H7MBH.js → chunk-AY3KQ4EN.js} +7 -7
  67. package/dist/safe-bash/command-chunks/{chunk-DMCI6T6N.js → chunk-BLGGAHQW.js} +1 -1
  68. package/dist/safe-bash/command-chunks/{chunk-CU4DLVME.js → chunk-BLIFGBIO.js} +2 -2
  69. package/dist/safe-bash/command-chunks/{chunk-2V6FOLXV.js → chunk-BS3ZEQGT.js} +14 -14
  70. package/dist/safe-bash/command-chunks/{chunk-WFVSUXJL.js → chunk-BS5JEUEW.js} +8 -8
  71. package/dist/safe-bash/command-chunks/{chunk-X53AEG36.js → chunk-BZMNC7Q5.js} +7 -7
  72. package/dist/safe-bash/command-chunks/{chunk-5KGEZ3RW.js → chunk-CCMAHM3I.js} +2 -2
  73. package/dist/safe-bash/command-chunks/{chunk-PK36TVXB.js → chunk-CFMJXJS5.js} +1 -1
  74. package/dist/safe-bash/command-chunks/{chunk-3LJAXFH5.js → chunk-CIRDVCAZ.js} +7 -7
  75. package/dist/safe-bash/command-chunks/{chunk-UZL7G57V.js → chunk-CKEMZUE3.js} +7 -7
  76. package/dist/safe-bash/command-chunks/{chunk-S2N2V5U4.js → chunk-CQBACD2V.js} +2 -2
  77. package/dist/safe-bash/command-chunks/{chunk-G7NENPYV.js → chunk-CSE4VQKG.js} +12 -1
  78. package/dist/safe-bash/command-chunks/{chunk-X6RHJ6YN.js → chunk-CXME4YHU.js} +23 -0
  79. package/dist/safe-bash/command-chunks/{chunk-FTLDRH47.js → chunk-CZ5K2YPU.js} +16 -16
  80. package/dist/safe-bash/command-chunks/{chunk-7PRL6RJ6.js → chunk-DBLQUZGN.js} +2 -2
  81. package/dist/safe-bash/command-chunks/{chunk-5VQVZPP3.js → chunk-DBNJEXHK.js} +3 -3
  82. package/dist/safe-bash/command-chunks/{chunk-ZO5WBWLL.js → chunk-DN6MSXY7.js} +2 -2
  83. package/dist/safe-bash/command-chunks/{chunk-GXLXWZWH.js → chunk-DZH54L3F.js} +3 -3
  84. package/dist/safe-bash/command-chunks/{chunk-6CY5BHBS.js → chunk-EBHOZIBS.js} +6 -6
  85. package/dist/safe-bash/command-chunks/{chunk-3Y5EME26.js → chunk-ENEIE44W.js} +2 -2
  86. package/dist/safe-bash/command-chunks/{chunk-TKRLZIFI.js → chunk-EQWFKNHJ.js} +17 -17
  87. package/dist/safe-bash/command-chunks/{chunk-YV72XQKL.js → chunk-ETXPMVR6.js} +13 -13
  88. package/dist/safe-bash/command-chunks/{chunk-4Z6W5EOC.js → chunk-EV5G535P.js} +8 -8
  89. package/dist/safe-bash/command-chunks/{chunk-PZMU3Z4L.js → chunk-EVYKV3QI.js} +5 -5
  90. package/dist/safe-bash/command-chunks/{chunk-D6UMSC45.js → chunk-F4YFTO2K.js} +11 -11
  91. package/dist/safe-bash/command-chunks/{chunk-QM2HZJSJ.js → chunk-F762XDNG.js} +3 -3
  92. package/dist/safe-bash/command-chunks/{chunk-SGPCXAG7.js → chunk-FOONI6BD.js} +7 -7
  93. package/dist/safe-bash/command-chunks/{chunk-DYLNU57U.js → chunk-FSVJ67G5.js} +1 -1
  94. package/dist/safe-bash/command-chunks/{chunk-CLKOGAR3.js → chunk-FSYMSWJU.js} +8 -8
  95. package/dist/safe-bash/command-chunks/{chunk-FWPVQGYK.js → chunk-FUQMEUAT.js} +6 -6
  96. package/dist/safe-bash/command-chunks/{chunk-KXPCSVAT.js → chunk-FXCSPPYE.js} +20 -20
  97. package/dist/safe-bash/command-chunks/{chunk-7QZ2HP2F.js → chunk-FYYFV6PW.js} +6 -6
  98. package/dist/safe-bash/command-chunks/{chunk-3OETVNJA.js → chunk-G2COZLXX.js} +9 -9
  99. package/dist/safe-bash/command-chunks/{chunk-MKX4JAZ6.js → chunk-GCHB7VNX.js} +17 -17
  100. package/dist/safe-bash/command-chunks/{chunk-4Y6O2K35.js → chunk-GLAF45M7.js} +1 -1
  101. package/dist/safe-bash/command-chunks/chunk-GPGLTWNR.js +271 -0
  102. package/dist/safe-bash/command-chunks/{chunk-PI6MOMHA.js → chunk-GXMPXMDP.js} +11 -11
  103. package/dist/safe-bash/command-chunks/{chunk-57DDYKE5.js → chunk-GYM5ICK4.js} +7 -7
  104. package/dist/safe-bash/command-chunks/{chunk-5MFDRSGG.js → chunk-H33D4R26.js} +4 -4
  105. package/dist/safe-bash/command-chunks/{chunk-3ZDANXIC.js → chunk-HELAVGZH.js} +3 -3
  106. package/dist/safe-bash/command-chunks/{chunk-S4QH5BXZ.js → chunk-HGIMFVI2.js} +4 -4
  107. package/dist/safe-bash/command-chunks/{chunk-35IPOBWL.js → chunk-HI6ZYH3W.js} +10 -10
  108. package/dist/safe-bash/command-chunks/{chunk-RGOQKIG6.js → chunk-HK6MSB7Z.js} +5 -5
  109. package/dist/safe-bash/command-chunks/{chunk-IHSOOSNC.js → chunk-HQ2UN2L2.js} +17 -17
  110. package/dist/safe-bash/command-chunks/{chunk-7ZE3VIAN.js → chunk-IB5QP4LF.js} +2 -2
  111. package/dist/safe-bash/command-chunks/{chunk-UCR5YDV3.js → chunk-IBYMPAUW.js} +1 -1
  112. package/dist/safe-bash/command-chunks/{chunk-LABOWPFB.js → chunk-IHXZMAMY.js} +9 -9
  113. package/dist/safe-bash/command-chunks/{chunk-PVGZMLC6.js → chunk-IWHNRYER.js} +3 -3
  114. package/dist/safe-bash/command-chunks/{chunk-PPO7YUZF.js → chunk-JGKSWDGP.js} +1 -1
  115. package/dist/safe-bash/command-chunks/{chunk-GKILM4HZ.js → chunk-JR3Q6QNL.js} +7 -7
  116. package/dist/safe-bash/command-chunks/{chunk-D55REQA3.js → chunk-JUHOL5KB.js} +1 -1
  117. package/dist/safe-bash/command-chunks/{chunk-3O2YEI47.js → chunk-JVKE7YZN.js} +3 -3
  118. package/dist/safe-bash/command-chunks/{chunk-6NATRKUJ.js → chunk-JW6WVNTM.js} +1 -1
  119. package/dist/safe-bash/command-chunks/{chunk-IK6K2HCG.js → chunk-JWORWL72.js} +1 -1
  120. package/dist/safe-bash/command-chunks/{chunk-N32GSM3J.js → chunk-K2WOMJOQ.js} +1 -1
  121. package/dist/safe-bash/command-chunks/{chunk-73NYFNAS.js → chunk-KASXIRKD.js} +12 -9
  122. package/dist/safe-bash/command-chunks/{chunk-HKOMXGJS.js → chunk-KBAQHE5Y.js} +2 -2
  123. package/dist/safe-bash/command-chunks/{chunk-T3E5RV3U.js → chunk-KCLJGRU7.js} +12 -12
  124. package/dist/safe-bash/command-chunks/chunk-KHUT7BB5.js +65 -0
  125. package/dist/safe-bash/command-chunks/{chunk-TUDFMNPP.js → chunk-KINIV2SV.js} +1 -1
  126. package/dist/safe-bash/command-chunks/{chunk-43TRBJ2N.js → chunk-KPHLESD4.js} +4 -4
  127. package/dist/safe-bash/command-chunks/{chunk-C5KLFZGT.js → chunk-KSBNZTAZ.js} +6 -6
  128. package/dist/safe-bash/command-chunks/{chunk-4Y34ZG4T.js → chunk-KUOCGGEU.js} +11 -11
  129. package/dist/safe-bash/command-chunks/{chunk-ML5R5JML.js → chunk-KY4LCHUF.js} +1 -1
  130. package/dist/safe-bash/command-chunks/{chunk-KBUBSMCQ.js → chunk-LDW3RF7Y.js} +12 -12
  131. package/dist/safe-bash/command-chunks/{chunk-U27XPNLP.js → chunk-LEO4VRIN.js} +2 -2
  132. package/dist/safe-bash/command-chunks/{chunk-GZ3VIWNN.js → chunk-LKGTH2Q7.js} +7 -7
  133. package/dist/safe-bash/command-chunks/{chunk-TODWFDYB.js → chunk-LNTEV56A.js} +2 -2
  134. package/dist/safe-bash/command-chunks/{chunk-DVGXLBUW.js → chunk-LZ2JFMKT.js} +10 -10
  135. package/dist/safe-bash/command-chunks/{chunk-6D2BMAF4.js → chunk-MEM2ZPMI.js} +2 -2
  136. package/dist/safe-bash/command-chunks/{chunk-GNXTMSYN.js → chunk-MGMTRGKM.js} +4 -4
  137. package/dist/safe-bash/command-chunks/{chunk-B3NLITWP.js → chunk-MKK6FM5H.js} +7 -7
  138. package/dist/safe-bash/command-chunks/{chunk-BK7ISUJL.js → chunk-MKOIPOXX.js} +3 -3
  139. package/dist/safe-bash/command-chunks/chunk-MLOYUXUV.js +244 -0
  140. package/dist/safe-bash/command-chunks/{chunk-CBNKHBLD.js → chunk-MNK3DDH6.js} +2 -2
  141. package/dist/safe-bash/command-chunks/{chunk-JVGUVHWI.js → chunk-MPXMRTMY.js} +10 -10
  142. package/dist/safe-bash/command-chunks/{chunk-EJTNVXWF.js → chunk-MVLVIMJ6.js} +6 -6
  143. package/dist/safe-bash/command-chunks/{chunk-TY4WDAHM.js → chunk-MYZ46FQL.js} +1 -1
  144. package/dist/safe-bash/command-chunks/{chunk-TBAIMDGL.js → chunk-N4MUBJCT.js} +1 -1
  145. package/dist/safe-bash/command-chunks/{chunk-NPLVFAD6.js → chunk-N6G3345Q.js} +8 -8
  146. package/dist/safe-bash/command-chunks/{chunk-4PBNMKAT.js → chunk-NEMUPUUB.js} +7 -7
  147. package/dist/safe-bash/command-chunks/{chunk-MUUWBZIC.js → chunk-NEVQWOU6.js} +10 -10
  148. package/dist/safe-bash/command-chunks/{chunk-7NXTEWPR.js → chunk-NEYITAAO.js} +208 -254
  149. package/dist/safe-bash/command-chunks/{chunk-KZ5ODST6.js → chunk-NFGCBQN3.js} +2 -2
  150. package/dist/safe-bash/command-chunks/{chunk-LD7BONZY.js → chunk-NFII726L.js} +2 -2
  151. package/dist/safe-bash/command-chunks/{chunk-JQPNA77Y.js → chunk-NHNZYWPW.js} +2 -2
  152. package/dist/safe-bash/command-chunks/{chunk-ZYLGNIGA.js → chunk-NQINS4XY.js} +1 -1
  153. package/dist/safe-bash/command-chunks/{chunk-UAF4IX5H.js → chunk-NRFTYZ2R.js} +6 -6
  154. package/dist/safe-bash/command-chunks/{chunk-THMZLJQD.js → chunk-NYFYTL5G.js} +18 -18
  155. package/dist/safe-bash/command-chunks/{chunk-SMSGLRIH.js → chunk-OTF2AJ5M.js} +6 -6
  156. package/dist/safe-bash/command-chunks/{chunk-NPFHUS4X.js → chunk-OVQP6KH5.js} +6 -6
  157. package/dist/safe-bash/command-chunks/{chunk-QFF5KBOM.js → chunk-P2LT6TGR.js} +9 -9
  158. package/dist/safe-bash/command-chunks/{chunk-BEHUSUOY.js → chunk-PLMF35XK.js} +4 -4
  159. package/dist/safe-bash/command-chunks/{chunk-PXWS3Q7L.js → chunk-PLR5IULU.js} +5 -5
  160. package/dist/safe-bash/command-chunks/{chunk-DBLHCJJU.js → chunk-PS5GDFIP.js} +2 -2
  161. package/dist/safe-bash/command-chunks/{chunk-P7EL2FWW.js → chunk-Q5PWYPQV.js} +7 -7
  162. package/dist/safe-bash/command-chunks/{chunk-AJI55RS7.js → chunk-Q7TVCBU2.js} +1 -1
  163. package/dist/safe-bash/command-chunks/{chunk-EHTOHOTR.js → chunk-QB72X7FF.js} +9 -9
  164. package/dist/safe-bash/command-chunks/{chunk-GOBUDKZ3.js → chunk-QDVDBN2N.js} +4 -4
  165. package/dist/safe-bash/command-chunks/{chunk-F3GP3EXE.js → chunk-RGDOYWOD.js} +2 -2
  166. package/dist/safe-bash/command-chunks/{chunk-MNHBQBF6.js → chunk-RHDERFMR.js} +5 -5
  167. package/dist/safe-bash/command-chunks/{chunk-3KMOXEGH.js → chunk-RHU44OMN.js} +2 -2
  168. package/dist/safe-bash/command-chunks/{chunk-XG6UWQV5.js → chunk-RIVKF77R.js} +6 -6
  169. package/dist/safe-bash/command-chunks/{chunk-UOR6PXZZ.js → chunk-ROL5AEX6.js} +1 -1
  170. package/dist/safe-bash/command-chunks/{chunk-3TYDSGAH.js → chunk-RQYPFLZJ.js} +6 -6
  171. package/dist/safe-bash/command-chunks/{chunk-3Y4XZB24.js → chunk-RTNI47C5.js} +4 -4
  172. package/dist/safe-bash/command-chunks/{chunk-W5LLKV5H.js → chunk-RV5AGXOV.js} +2 -2
  173. package/dist/safe-bash/command-chunks/{chunk-JUJHYPYL.js → chunk-RXQ2G2YK.js} +9 -9
  174. package/dist/safe-bash/command-chunks/{chunk-EVU7FLDA.js → chunk-S2QNBAN6.js} +7 -7
  175. package/dist/safe-bash/command-chunks/{chunk-YE6OAKK7.js → chunk-S43QRKDC.js} +7 -7
  176. package/dist/safe-bash/command-chunks/{chunk-774GLJAO.js → chunk-S7HIOT7Z.js} +4 -4
  177. package/dist/safe-bash/command-chunks/{chunk-3D24WDND.js → chunk-SEPUP6TZ.js} +1 -1
  178. package/dist/safe-bash/command-chunks/{chunk-JPMYPOYZ.js → chunk-SUTHGUD3.js} +28 -28
  179. package/dist/safe-bash/command-chunks/{chunk-D6WJY6QO.js → chunk-SWAKALDJ.js} +10 -10
  180. package/dist/safe-bash/command-chunks/{chunk-WGH3RLJY.js → chunk-T5S4SJGO.js} +9 -9
  181. package/dist/safe-bash/command-chunks/{chunk-7JEIWA3A.js → chunk-TID5TSQW.js} +5 -5
  182. package/dist/safe-bash/command-chunks/{chunk-EZ4NQIPL.js → chunk-TJLXSENN.js} +1 -1
  183. package/dist/safe-bash/command-chunks/{chunk-HVW53ARH.js → chunk-TKCUGMRZ.js} +24 -20
  184. package/dist/safe-bash/command-chunks/{chunk-5P6I2T63.js → chunk-TXPDKEGY.js} +8 -8
  185. package/dist/safe-bash/command-chunks/{chunk-CTDC4LJT.js → chunk-U3C6IT2C.js} +55 -36
  186. package/dist/safe-bash/command-chunks/{chunk-MPKY37QR.js → chunk-UJERQEJB.js} +1 -1
  187. package/dist/safe-bash/command-chunks/{chunk-V37D6AHO.js → chunk-USGZN2KE.js} +5 -5
  188. package/dist/safe-bash/command-chunks/{chunk-JAHJWVGF.js → chunk-UYGQEQIP.js} +5 -5
  189. package/dist/safe-bash/command-chunks/{chunk-MPORWUTU.js → chunk-V5XC43BX.js} +8 -8
  190. package/dist/safe-bash/command-chunks/{chunk-AIMSZBWP.js → chunk-V7E3PZOK.js} +9 -9
  191. package/dist/safe-bash/command-chunks/{chunk-CNHRVUHA.js → chunk-VDTFVRYX.js} +1 -1
  192. package/dist/safe-bash/command-chunks/{chunk-M3Z5PU2M.js → chunk-VT2PHQ63.js} +15 -15
  193. package/dist/safe-bash/command-chunks/{chunk-QDVI2YB6.js → chunk-VUWXLH3E.js} +2 -2
  194. package/dist/safe-bash/command-chunks/{chunk-O675URF4.js → chunk-W3ZSWK76.js} +8 -8
  195. package/dist/safe-bash/command-chunks/{chunk-T6C5QP7T.js → chunk-WAT2562G.js} +6039 -5958
  196. package/dist/safe-bash/command-chunks/{chunk-JPA2PUYI.js → chunk-WBKB7HBZ.js} +8 -8
  197. package/dist/safe-bash/command-chunks/{chunk-6244HYJY.js → chunk-WJ2ERUCQ.js} +1 -1
  198. package/dist/safe-bash/command-chunks/{chunk-U5TWQFZY.js → chunk-WTVJLHMG.js} +1 -1
  199. package/dist/safe-bash/command-chunks/{chunk-SLQWQKXP.js → chunk-WWHMI4S3.js} +9 -9
  200. package/dist/safe-bash/command-chunks/{chunk-2UBZALAK.js → chunk-WYZG3DRR.js} +1 -1
  201. package/dist/safe-bash/command-chunks/{chunk-T5ERNELL.js → chunk-WZRFS5OY.js} +4 -4
  202. package/dist/safe-bash/command-chunks/{chunk-2DGJOOXM.js → chunk-X6OHFKBL.js} +8 -8
  203. package/dist/safe-bash/command-chunks/{chunk-S6ZTBXYO.js → chunk-XKAUKLF7.js} +13 -13
  204. package/dist/safe-bash/command-chunks/{chunk-NKTULXVD.js → chunk-XM5QJCPD.js} +8 -8
  205. package/dist/safe-bash/command-chunks/{chunk-BBAB7LC4.js → chunk-XMTR7QGL.js} +4 -4
  206. package/dist/safe-bash/command-chunks/{chunk-5IFRAI7Y.js → chunk-XNGM3W5R.js} +1 -1
  207. package/dist/safe-bash/command-chunks/{chunk-Z5BIM5B7.js → chunk-XTEIT5CI.js} +1 -1
  208. package/dist/safe-bash/command-chunks/{chunk-4DLIUTQV.js → chunk-XU6S3XUZ.js} +11 -11
  209. package/dist/safe-bash/command-chunks/{chunk-EXOQGXEU.js → chunk-XUJAQA3S.js} +30 -30
  210. package/dist/safe-bash/command-chunks/{chunk-VVWXY6IA.js → chunk-Y42KSX63.js} +6 -6
  211. package/dist/safe-bash/command-chunks/{chunk-R2BMZAHG.js → chunk-Y54L4P4J.js} +5 -5
  212. package/dist/safe-bash/command-chunks/{chunk-6WQD7LRA.js → chunk-YAD7EV4N.js} +14 -14
  213. package/dist/safe-bash/command-chunks/{chunk-YUXTK3XA.js → chunk-YRPXBGRX.js} +3 -3
  214. package/dist/safe-bash/command-chunks/{chunk-JORIVUPM.js → chunk-YW2VYN4V.js} +34 -15
  215. package/dist/safe-bash/command-chunks/{chunk-NMPED6L5.js → chunk-Z2WNYEPD.js} +4 -4
  216. package/dist/safe-bash/command-chunks/{chunk-7PZHWMK6.js → chunk-Z7QOSXQC.js} +7 -7
  217. package/dist/safe-bash/command-chunks/{chunk-7UC2Q6Z6.js → chunk-ZIGENXGC.js} +248 -6
  218. package/dist/safe-bash/command-chunks/{chunk-VQOINPVF.js → chunk-ZQM37BGE.js} +2 -2
  219. package/dist/safe-bash/command-chunks/{chunk-W3HV45CI.js → chunk-ZSQZHFWS.js} +9 -9
  220. package/dist/safe-bash/command-chunks/{chunk-IDJQP3A6.js → chunk-ZTMZO4IT.js} +1 -1
  221. package/dist/safe-bash/command-chunks/{chunk-V6XBEYPC.js → chunk-ZU2KJMXO.js} +8 -8
  222. package/dist/safe-bash/command-chunks/{chunk-YXKNJ6EM.js → chunk-ZXELXF2H.js} +5 -5
  223. package/dist/safe-bash/command-chunks/{clipboard-BBDK33GP-VB22F7GI.js → clipboard-BBDK33GP-QZ4ERNQX.js} +2 -2
  224. package/dist/safe-bash/command-chunks/{command-engine-X3OLN7N6.js → command-engine-M7S4QIXV.js} +942 -683
  225. package/dist/safe-bash/command-chunks/{engine-XUCIFZ7V-LJFGZM6O.js → engine-YUYZJIB4-NZUDFEHL.js} +1 -1
  226. package/dist/safe-bash/command-chunks/{gnumeric-UJPXWBVR-YPXTNEDZ.js → gnumeric-UJPXWBVR-7VOHQAPM.js} +2 -2
  227. package/dist/safe-bash/command-chunks/{model-store-E7BHBFJC.js → model-store-UB5DWMAP.js} +24 -24
  228. package/dist/safe-bash-command-awk/awk-runtime.js +3 -3
  229. package/dist/safe-bash-command-awk/awk.js +4 -4
  230. package/dist/safe-bash-command-awk/index.js +4 -4
  231. package/dist/safe-bash-command-diff/diff.js +2 -2
  232. package/dist/safe-bash-command-diff/index.js +3 -3
  233. package/dist/safe-bash-command-diff/sync.js +2 -2
  234. package/dist/safe-bash-command-du/du.js +2 -2
  235. package/dist/safe-bash-command-du/index.js +2 -2
  236. package/dist/safe-bash-command-ffmpeg/index.js +1 -1
  237. package/dist/safe-bash-command-ffprobe/index.js +2 -2
  238. package/dist/safe-bash-command-ffprobe/media.d.ts +8 -2
  239. package/dist/safe-bash-command-ffprobe/media.js +4 -2
  240. package/dist/safe-bash-command-html-to-markdown/index.js +3 -234
  241. package/dist/safe-bash-command-html-to-markdown/stored-text.d.ts +50 -0
  242. package/dist/safe-bash-command-html-to-markdown/stored-text.js +12 -0
  243. package/dist/safe-bash-command-htmlq/contracts.d.ts +5 -0
  244. package/dist/safe-bash-command-htmlq/index.js +1715 -292
  245. package/dist/safe-bash-command-htmlq/selectors.d.ts +38 -1
  246. package/dist/safe-bash-command-htmlq/serializer.d.ts +1 -0
  247. package/dist/safe-bash-command-htmlq/tree.d.ts +1 -0
  248. package/dist/safe-bash-command-iconv/command.js +2 -2
  249. package/dist/safe-bash-command-iconv/index.js +2 -2
  250. package/dist/safe-bash-command-llm/command.js +3 -3
  251. package/dist/safe-bash-command-llm/index.js +9 -9
  252. package/dist/safe-bash-command-llm/openai.js +2 -2
  253. package/dist/safe-bash-command-llm/providers/index.js +2 -2
  254. package/dist/safe-bash-command-llm/providers/openai.js +2 -2
  255. package/dist/safe-bash-command-node/commands/node/browser.js +2 -2
  256. package/dist/safe-bash-command-node/commands/node/default-runtime.js +2 -2
  257. package/dist/safe-bash-command-node/commands/node/safejs.js +2 -2
  258. package/dist/safe-bash-command-pandoc/command.js +4 -4
  259. package/dist/safe-bash-command-pandoc/index.js +40 -40
  260. package/dist/safe-bash-command-patch/index.js +7 -6
  261. package/dist/safe-bash-command-patch/patch-formats.d.ts +7 -1
  262. package/dist/safe-bash-command-patch/patch-formats.js +7 -4
  263. package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +7 -7
  264. package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +2 -2
  265. package/dist/safe-bash-command-patch/patch-gnu-reject.js +3 -2
  266. package/dist/safe-bash-command-patch/patch-publication.js +3 -2
  267. package/dist/safe-bash-command-patch/patch-text.d.ts +13 -0
  268. package/dist/safe-bash-command-patch/patch.js +7 -6
  269. package/dist/safe-bash-command-patch/stored-patch.d.ts +51 -0
  270. package/dist/safe-bash-command-patch/stored-target.d.ts +41 -0
  271. package/dist/safe-bash-command-patch/unified.d.ts +28 -9
  272. package/dist/safe-bash-command-patch/unified.js +4 -1
  273. package/dist/safe-bash-command-pdftk/index.js +758 -433
  274. package/dist/safe-bash-command-playwright-cli/index.js +26 -26
  275. package/dist/safe-bash-command-playwright-cli/playwright/abilities.js +10 -10
  276. package/dist/safe-bash-command-playwright-cli/playwright/controller.js +14 -14
  277. package/dist/safe-bash-command-playwright-cli/playwright/index.js +23 -23
  278. package/dist/safe-bash-command-playwright-cli/playwright/snapshot.js +2 -2
  279. package/dist/safe-bash-command-playwright-cli/playwright/standard-capabilities.js +6 -6
  280. package/dist/safe-bash-command-playwright-cli/playwright/storage-capabilities.js +4 -4
  281. package/dist/safe-bash-command-pptx/command-engine.d.ts +2 -1
  282. package/dist/safe-bash-command-pptx/engine.js +1 -1
  283. package/dist/safe-bash-command-pptx/index.d.ts +1 -1
  284. package/dist/safe-bash-command-pptx/index.js +163 -17
  285. package/dist/safe-bash-command-pptx/streaming-inputs.d.ts +7 -2
  286. package/dist/safe-bash-command-python/executor.js +5 -5
  287. package/dist/safe-bash-command-python/index.js +5 -5
  288. package/dist/safe-bash-command-python/jspi.js +2 -2
  289. package/dist/safe-bash-command-soffice/index.js +1 -1
  290. package/dist/safe-bash-command-sort/index.js +3 -3
  291. package/dist/safe-bash-command-ssconvert/index.js +2 -2
  292. package/dist/safe-bash-command-tar/create.js +2 -2
  293. package/dist/safe-bash-command-tar/extract.js +2 -2
  294. package/dist/safe-bash-command-tar/index.js +8 -8
  295. package/dist/safe-bash-command-tar/modes.js +4 -4
  296. package/dist/safe-bash-command-timeout/index.js +3 -3
  297. package/dist/safe-bash-command-tree/index.js +2 -2
  298. package/dist/safe-bash-command-tree/tree.js +2 -2
  299. package/dist/safe-bash-command-xz/index.js +5 -5
  300. package/dist/safe-bash-compression-engine/files.js +2 -2
  301. package/dist/safe-bash-compression-engine/operand.js +4 -4
  302. package/dist/safe-bash-contracts/diagnostics.js +3 -3
  303. package/dist/safe-bash-contracts/escaping.js +10 -10
  304. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  305. package/dist/safe-bash-contracts/filesystem-output.js +6 -6
  306. package/dist/safe-bash-contracts/index.js +33 -33
  307. package/dist/safe-bash-contracts/io.js +2 -2
  308. package/dist/safe-bash-contracts/output.js +3 -3
  309. package/dist/safe-bash-docx-engine/ancillary-resources.js +5 -5
  310. package/dist/safe-bash-docx-engine/batch-operations.js +63 -63
  311. package/dist/safe-bash-docx-engine/batch-result-schema.js +74 -74
  312. package/dist/safe-bash-docx-engine/batch.js +74 -74
  313. package/dist/safe-bash-docx-engine/bookmarks.js +13 -13
  314. package/dist/safe-bash-docx-engine/charts.js +6 -6
  315. package/dist/safe-bash-docx-engine/command-option-rules.js +3 -3
  316. package/dist/safe-bash-docx-engine/comments.js +21 -21
  317. package/dist/safe-bash-docx-engine/control-bindings.js +16 -16
  318. package/dist/safe-bash-docx-engine/control-repeat.js +16 -16
  319. package/dist/safe-bash-docx-engine/controls.js +14 -14
  320. package/dist/safe-bash-docx-engine/create.js +8 -8
  321. package/dist/safe-bash-docx-engine/diagrams.js +6 -6
  322. package/dist/safe-bash-docx-engine/diff.js +8 -8
  323. package/dist/safe-bash-docx-engine/document-properties.js +12 -12
  324. package/dist/safe-bash-docx-engine/equations.js +12 -12
  325. package/dist/safe-bash-docx-engine/extract.js +9 -9
  326. package/dist/safe-bash-docx-engine/fields.js +18 -18
  327. package/dist/safe-bash-docx-engine/font-inventory.js +13 -13
  328. package/dist/safe-bash-docx-engine/font-resources.js +3 -3
  329. package/dist/safe-bash-docx-engine/image-batch-operations.js +11 -11
  330. package/dist/safe-bash-docx-engine/image-insertion.js +17 -17
  331. package/dist/safe-bash-docx-engine/image-layout.js +14 -14
  332. package/dist/safe-bash-docx-engine/image-replacement.js +19 -19
  333. package/dist/safe-bash-docx-engine/images.js +14 -14
  334. package/dist/safe-bash-docx-engine/index.js +102 -102
  335. package/dist/safe-bash-docx-engine/inspection.js +15 -15
  336. package/dist/safe-bash-docx-engine/invocation.js +4 -4
  337. package/dist/safe-bash-docx-engine/io.js +6 -6
  338. package/dist/safe-bash-docx-engine/links.js +17 -17
  339. package/dist/safe-bash-docx-engine/lists.js +16 -16
  340. package/dist/safe-bash-docx-engine/locations.js +10 -10
  341. package/dist/safe-bash-docx-engine/notes.js +18 -18
  342. package/dist/safe-bash-docx-engine/objects.js +14 -14
  343. package/dist/safe-bash-docx-engine/pack.js +9 -9
  344. package/dist/safe-bash-docx-engine/package-view-batch-operations.js +19 -19
  345. package/dist/safe-bash-docx-engine/pandoc-adapter.js +25 -25
  346. package/dist/safe-bash-docx-engine/paragraph-edit.js +21 -21
  347. package/dist/safe-bash-docx-engine/publication.js +6 -6
  348. package/dist/safe-bash-docx-engine/removal.js +16 -16
  349. package/dist/safe-bash-docx-engine/revision-decisions.js +16 -16
  350. package/dist/safe-bash-docx-engine/revision-edit.js +15 -15
  351. package/dist/safe-bash-docx-engine/revisions.js +12 -12
  352. package/dist/safe-bash-docx-engine/run-format.js +15 -15
  353. package/dist/safe-bash-docx-engine/sanitize.js +29 -29
  354. package/dist/safe-bash-docx-engine/sections.js +15 -15
  355. package/dist/safe-bash-docx-engine/settings.js +6 -6
  356. package/dist/safe-bash-docx-engine/shape-edit.js +16 -16
  357. package/dist/safe-bash-docx-engine/signatures.js +11 -11
  358. package/dist/safe-bash-docx-engine/stories.js +18 -18
  359. package/dist/safe-bash-docx-engine/structure-model-batch-operations.js +34 -34
  360. package/dist/safe-bash-docx-engine/style-model-batch-operations.js +24 -24
  361. package/dist/safe-bash-docx-engine/style-model-result-schema.js +39 -39
  362. package/dist/safe-bash-docx-engine/styles.js +14 -14
  363. package/dist/safe-bash-docx-engine/table-edit.js +23 -23
  364. package/dist/safe-bash-docx-engine/table-read.js +11 -11
  365. package/dist/safe-bash-docx-engine/template.js +17 -17
  366. package/dist/safe-bash-docx-engine/text-replace.js +15 -15
  367. package/dist/safe-bash-docx-engine/text-resource-read.js +11 -11
  368. package/dist/safe-bash-docx-engine/text.js +11 -11
  369. package/dist/safe-bash-docx-engine/validation.js +4 -4
  370. package/dist/safe-bash-docx-engine/xml-parts.js +17 -17
  371. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +4 -4
  372. package/dist/safe-bash-line-ending-engine/command.js +3 -3
  373. package/dist/safe-bash-line-ending-engine/convert.js +2 -2
  374. package/dist/safe-bash-line-ending-engine/index.js +6 -6
  375. package/dist/safe-bash-line-ending-engine/info.js +2 -2
  376. package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
  377. package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
  378. package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
  379. package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
  380. package/dist/safe-bash-markdown-engine/index.js +5 -5
  381. package/dist/safe-bash-network-engine/transfer.js +3 -3
  382. package/dist/safe-bash-presentation-engine/accessibility.js +30 -30
  383. package/dist/safe-bash-presentation-engine/animation-editing.js +15 -15
  384. package/dist/safe-bash-presentation-engine/animations.js +15 -15
  385. package/dist/safe-bash-presentation-engine/backgrounds.js +16 -16
  386. package/dist/safe-bash-presentation-engine/bytes.js +3 -3
  387. package/dist/safe-bash-presentation-engine/chart-editing.js +33 -33
  388. package/dist/safe-bash-presentation-engine/chart-object-operations.js +24 -24
  389. package/dist/safe-bash-presentation-engine/charts.js +30 -30
  390. package/dist/safe-bash-presentation-engine/command-placeholder.js +58 -58
  391. package/dist/safe-bash-presentation-engine/comments.js +16 -16
  392. package/dist/safe-bash-presentation-engine/connector-operations.js +31 -31
  393. package/dist/safe-bash-presentation-engine/connectors.js +28 -28
  394. package/dist/safe-bash-presentation-engine/content-types.js +4 -4
  395. package/dist/safe-bash-presentation-engine/creation.js +6 -6
  396. package/dist/safe-bash-presentation-engine/diff.js +31 -31
  397. package/dist/safe-bash-presentation-engine/drawing-format.js +19 -19
  398. package/dist/safe-bash-presentation-engine/drawing-operations.js +30 -30
  399. package/dist/safe-bash-presentation-engine/drawing-schema.js +20 -20
  400. package/dist/safe-bash-presentation-engine/equations.js +16 -16
  401. package/dist/safe-bash-presentation-engine/errors.js +2 -2
  402. package/dist/safe-bash-presentation-engine/fields.js +16 -16
  403. package/dist/safe-bash-presentation-engine/font-metrics.js +3 -3
  404. package/dist/safe-bash-presentation-engine/image-extraction.js +19 -19
  405. package/dist/safe-bash-presentation-engine/image-formatting.js +31 -31
  406. package/dist/safe-bash-presentation-engine/image-insertion.js +17 -17
  407. package/dist/safe-bash-presentation-engine/image-replacement.js +20 -20
  408. package/dist/safe-bash-presentation-engine/image-value.js +4 -4
  409. package/dist/safe-bash-presentation-engine/images.js +18 -18
  410. package/dist/safe-bash-presentation-engine/index.js +114 -114
  411. package/dist/safe-bash-presentation-engine/layouts.js +15 -15
  412. package/dist/safe-bash-presentation-engine/length.js +3 -3
  413. package/dist/safe-bash-presentation-engine/links.js +15 -15
  414. package/dist/safe-bash-presentation-engine/masters.js +14 -14
  415. package/dist/safe-bash-presentation-engine/media-editing.js +23 -23
  416. package/dist/safe-bash-presentation-engine/media-extraction.js +16 -16
  417. package/dist/safe-bash-presentation-engine/media.js +15 -15
  418. package/dist/safe-bash-presentation-engine/memberships.js +14 -14
  419. package/dist/safe-bash-presentation-engine/notes.d.ts +1 -0
  420. package/dist/safe-bash-presentation-engine/notes.js +21 -15
  421. package/dist/safe-bash-presentation-engine/ole-enum.js +4 -4
  422. package/dist/safe-bash-presentation-engine/ole-insertion.js +19 -19
  423. package/dist/safe-bash-presentation-engine/opaque-objects.js +9 -9
  424. package/dist/safe-bash-presentation-engine/package-reader.js +5 -5
  425. package/dist/safe-bash-presentation-engine/package-tools.js +18 -18
  426. package/dist/safe-bash-presentation-engine/package-uri.js +3 -3
  427. package/dist/safe-bash-presentation-engine/package-writer.js +4 -4
  428. package/dist/safe-bash-presentation-engine/presentation-model.js +57 -57
  429. package/dist/safe-bash-presentation-engine/presentation-settings.js +13 -13
  430. package/dist/safe-bash-presentation-engine/properties.js +15 -15
  431. package/dist/safe-bash-presentation-engine/relationships.js +4 -4
  432. package/dist/safe-bash-presentation-engine/resource-limits.js +1 -1
  433. package/dist/safe-bash-presentation-engine/retained-frame-formatting.d.ts +14 -0
  434. package/dist/safe-bash-presentation-engine/retained-inspection.js +13 -13
  435. package/dist/safe-bash-presentation-engine/retained-notes.d.ts +27 -0
  436. package/dist/safe-bash-presentation-engine/retained-package.js +5 -5
  437. package/dist/safe-bash-presentation-engine/retained-text.d.ts +9 -2
  438. package/dist/safe-bash-presentation-engine/retained-text.js +130 -31
  439. package/dist/safe-bash-presentation-engine/retained-xml-document.d.ts +1 -0
  440. package/dist/safe-bash-presentation-engine/sanitize.js +16 -16
  441. package/dist/safe-bash-presentation-engine/selectors.js +10 -10
  442. package/dist/safe-bash-presentation-engine/shape-groups.js +30 -30
  443. package/dist/safe-bash-presentation-engine/shape-operations.js +29 -29
  444. package/dist/safe-bash-presentation-engine/shape-path-operations.js +31 -31
  445. package/dist/safe-bash-presentation-engine/shape-paths.js +15 -15
  446. package/dist/safe-bash-presentation-engine/shape-presets.js +3 -3
  447. package/dist/safe-bash-presentation-engine/shape-selection.js +30 -30
  448. package/dist/safe-bash-presentation-engine/shape-transforms.js +17 -17
  449. package/dist/safe-bash-presentation-engine/shapes.js +26 -26
  450. package/dist/safe-bash-presentation-engine/slide-copy.js +16 -16
  451. package/dist/safe-bash-presentation-engine/slide-import.js +17 -17
  452. package/dist/safe-bash-presentation-engine/slide-merge-split.js +19 -19
  453. package/dist/safe-bash-presentation-engine/slide-model.js +42 -42
  454. package/dist/safe-bash-presentation-engine/slide-removal.js +17 -17
  455. package/dist/safe-bash-presentation-engine/slide-transfer-budget.js +9 -9
  456. package/dist/safe-bash-presentation-engine/slides.js +18 -18
  457. package/dist/safe-bash-presentation-engine/table-operations.js +32 -32
  458. package/dist/safe-bash-presentation-engine/table-spans.js +31 -31
  459. package/dist/safe-bash-presentation-engine/tables.js +30 -30
  460. package/dist/safe-bash-presentation-engine/tags.js +15 -15
  461. package/dist/safe-bash-presentation-engine/template-bindings.js +32 -32
  462. package/dist/safe-bash-presentation-engine/template-repeat.js +39 -39
  463. package/dist/safe-bash-presentation-engine/text-fitting.js +26 -26
  464. package/dist/safe-bash-presentation-engine/text-frames.d.ts +13 -0
  465. package/dist/safe-bash-presentation-engine/text-frames.js +28 -26
  466. package/dist/safe-bash-presentation-engine/text-paragraphs.js +26 -26
  467. package/dist/safe-bash-presentation-engine/text-reading.js +11 -11
  468. package/dist/safe-bash-presentation-engine/text-replacement.js +16 -16
  469. package/dist/safe-bash-presentation-engine/text-runs.js +19 -19
  470. package/dist/safe-bash-presentation-engine/themes.js +15 -15
  471. package/dist/safe-bash-presentation-engine/transitions.js +15 -15
  472. package/dist/safe-bash-presentation-engine/validation.js +9 -9
  473. package/dist/safe-bash-presentation-engine/xml-parts.js +18 -18
  474. package/dist/safe-bash-presentation-engine/xml-view.js +3 -3
  475. package/dist/safe-bash-presentation-engine/xml.js +3 -3
  476. package/dist/safe-bash-query-engine/index.js +4 -4
  477. package/dist/safe-bash-query-engine/interpreter.js +2 -2
  478. package/dist/safe-bash-query-engine/query-core.js +4 -4
  479. package/dist/safe-bash-xml-engine/document.js +3 -3
  480. package/dist/safe-bash-xml-engine/evaluate.js +1 -1
  481. package/dist/safe-bash-xml-engine/index.js +6 -6
  482. package/dist/safe-bash-xml-engine/query.js +2 -2
  483. package/dist/safe-bash-xml-engine/stored-document.d.ts +2 -2
  484. package/dist/safe-bash-xml-engine/stored-document.js +1 -1
  485. package/dist/safe-bash-xml-engine/stored-evaluate.js +1 -1
  486. package/dist/safe-bash-zip-engine/zip/repair.js +3 -3
  487. package/dist/safe-bash-zip-engine/zip/volumes.js +3 -3
  488. package/dist/spreadsheet-engine/datasource.js +16 -2
  489. package/dist/spreadsheet-engine/formulas/diagnostics.d.ts +2 -1
  490. package/dist/spreadsheet-engine/formulas/diagnostics.js +2 -2
  491. package/dist/spreadsheet-engine/formulas/evaluator.d.ts +1 -1
  492. package/dist/spreadsheet-engine/formulas/evaluator.js +2 -1
  493. package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +7 -6
  494. package/dist/spreadsheet-format-xls/biff-properties-merge.js +41 -22
  495. package/dist/spreadsheet-format-xls/biff-properties.js +94 -109
  496. package/dist/spreadsheet-format-xls/biff-property-dictionary.d.ts +5 -0
  497. package/dist/spreadsheet-format-xls/biff-property-dictionary.js +75 -0
  498. package/dist/spreadsheet-format-xls/biff-property-range.d.ts +17 -3
  499. package/dist/spreadsheet-format-xls/biff-property-range.js +178 -37
  500. package/dist/spreadsheet-format-xls/biff-property-values.d.ts +31 -0
  501. package/dist/spreadsheet-format-xls/biff-property-values.js +158 -0
  502. package/package.json +5 -2
  503. package/dist/safe-bash/command-chunks/biff-4ALVARRF-7SRX6R6N.js +0 -5192
  504. package/dist/safe-bash/command-chunks/chunk-63EMPQ7Z.js +0 -115
  505. package/dist/safe-bash/command-chunks/{chunk-X2HVVMTW.js → chunk-AW4Q3GZW.js} +6 -6
  506. package/dist/safe-bash/command-chunks/{chunk-JC2EV66U.js → chunk-BJXADHRT.js} +3 -3
  507. package/dist/safe-bash/command-chunks/{chunk-XI2LETBJ.js → chunk-BXU5Y7I5.js} +3 -3
  508. package/dist/safe-bash/command-chunks/{chunk-PVLPWVRH.js → chunk-D3HW7R2N.js} +3 -3
  509. package/dist/safe-bash/command-chunks/{chunk-OLK3DCJD.js → chunk-DYERIXPU.js} +3 -3
  510. package/dist/safe-bash/command-chunks/{chunk-WYBCSJFG.js → chunk-FWCUEZ3K.js} +3 -3
  511. package/dist/safe-bash/command-chunks/{chunk-FF2SQ2GP.js → chunk-GGH376XQ.js} +3 -3
  512. package/dist/safe-bash/command-chunks/{chunk-D66Q7QJ3.js → chunk-JRSZ5IGD.js} +6 -6
  513. package/dist/safe-bash/command-chunks/{chunk-3JST2Q7G.js → chunk-KRRG4MGH.js} +3 -3
  514. package/dist/safe-bash/command-chunks/{chunk-Z3YB4EVE.js → chunk-KSM5CCHT.js} +8 -8
  515. package/dist/safe-bash/command-chunks/{chunk-NJ4NTTCR.js → chunk-LNLACEAN.js} +8 -8
  516. package/dist/safe-bash/command-chunks/{chunk-NBTG6NF6.js → chunk-LTJRUMK6.js} +3 -3
  517. package/dist/safe-bash/command-chunks/{chunk-XCYTG7CR.js → chunk-NJGL5JQ6.js} +3 -3
  518. package/dist/safe-bash/command-chunks/{chunk-SZ66JC25.js → chunk-Q7J2NTH2.js} +3 -3
  519. package/dist/safe-bash/command-chunks/{chunk-MDV7W5AS.js → chunk-SKNI2XQA.js} +3 -3
  520. package/dist/safe-bash/command-chunks/{chunk-7ZWACKCG.js → chunk-T6OXG7QQ.js} +3 -3
  521. package/dist/safe-bash/command-chunks/{chunk-ECDEPKKW.js → chunk-W25EIKDJ.js} +3 -3
  522. package/dist/safe-bash/command-chunks/{chunk-4YSBUQPV.js → chunk-W2FKFEVY.js} +3 -3
  523. package/dist/safe-bash/command-chunks/{chunk-2CIDPOUV.js → chunk-WSNHJZQ5.js} +3 -3
  524. package/dist/safe-bash/command-chunks/{chunk-4H3TYOVC.js → chunk-Y7AXMCFV.js} +3 -3
  525. package/dist/safe-bash/command-chunks/{chunk-U6IEK2CI.js → chunk-YPG55QTP.js} +7 -7
  526. package/dist/safe-bash/command-chunks/{chunk-252L5YC5.js → chunk-Z37OM247.js} +6 -6
  527. package/dist/safe-bash/command-chunks/{pln-DFS7VLVS-JATX6FS7.js → pln-DFS7VLVS-OVOBS4QX.js} +3 -3
  528. package/dist/safe-bash/command-chunks/{psion-YBI6JEQI-6OMC2PGC.js → psion-YBI6JEQI-GY4S6ZLC.js} +3 -3
@@ -28310,7 +28310,7 @@ function* parseValueSteps(lexer, maxDepth, repair = false, maxNodes = Infinity,
28310
28310
  continue;
28311
28311
  }
28312
28312
  if (tok.kind === "dict-start") {
28313
- const backed = options.dictionaryStorage && (parent?.kind === "dict" && options.storedDictionaryKeys?.includes(parent.key.decoded) || !parent && options.storeRootDictionary);
28313
+ const backed = options.dictionaryStorage && (parent?.kind === "dict" && !parent.storedEntries && options.storedDictionaryKeys?.includes(parent.key.decoded) || !parent && options.storeRootDictionary);
28314
28314
  yield* push({
28315
28315
  kind: "dict",
28316
28316
  path: ancestorPath(parent),
@@ -43006,6 +43006,13 @@ function* resolveEvaluationDict(node, arrayPathPrefix) {
43006
43006
  const resolved = yield* resolveEvaluationNode(node, false, arrayPathPrefix);
43007
43007
  return resolved?.kind === "dict" ? resolved : resolved?.kind === "stream" ? resolved.dict : void 0;
43008
43008
  }
43009
+ function* lookupEvaluationDictionary(dict, key) {
43010
+ if (!dict) return void 0;
43011
+ if (!dict.storedEntries) return dictGet(dict, key);
43012
+ const result = yield { kind: "dictionary-value", dict, key };
43013
+ if (!result || !("kind" in result) || result.kind !== "resolved") throw new TypeError("Expected a PDF dictionary value");
43014
+ return result.node;
43015
+ }
43009
43016
  function* resolveEvaluationArray(node, storeRootArray = false, arrayPathPrefix) {
43010
43017
  const resolved = yield* resolveEvaluationNode(node, storeRootArray, arrayPathPrefix);
43011
43018
  return resolved?.kind === "array" ? resolved : void 0;
@@ -43853,8 +43860,8 @@ function* evaluateContentSteps(params) {
43853
43860
  let resolvedMcid = node.mcid;
43854
43861
  let resolvedActualText = node.actualText ?? node.storedActualText;
43855
43862
  if (typeof node.properties === "string" && activeResources) {
43856
- const propsMap = yield* resolveEvaluationDict(dictGet(activeResources, "Properties"));
43857
- const propRefOrNode = propsMap ? dictGet(propsMap, node.properties) : void 0;
43863
+ const propsMap = yield* resolveEvaluationDict(dictGet(activeResources, "Properties"), ["Properties"]);
43864
+ const propRefOrNode = yield* lookupEvaluationDictionary(propsMap, node.properties);
43858
43865
  if (propRefOrNode) {
43859
43866
  const propDict = yield* resolveEvaluationDict(propRefOrNode);
43860
43867
  const propType = propDict ? yield* resolveEvaluationNode(dictGet(propDict, "Type")) : void 0;
@@ -44037,8 +44044,8 @@ function* evaluateContentSteps(params) {
44037
44044
  case "xobject": {
44038
44045
  const st = curState();
44039
44046
  if (activeResources) {
44040
- const xobjDict = yield* resolveEvaluationDict(dictGet(activeResources, "XObject"));
44041
- const xobjNode = xobjDict ? yield* resolveEvaluationNode(dictGet(xobjDict, node.name)) : void 0;
44047
+ const xobjDict = yield* resolveEvaluationDict(dictGet(activeResources, "XObject"), ["XObject"]);
44048
+ const xobjNode = xobjDict ? yield* resolveEvaluationNode(yield* lookupEvaluationDictionary(xobjDict, node.name)) : void 0;
44042
44049
  if (xobjNode?.kind === "stream") {
44043
44050
  if (!(yield* optionalContentVisibilitySteps(dictGet(xobjNode.dict, "OC")))) {
44044
44051
  break;
@@ -44439,7 +44446,7 @@ function* evaluateContentStreamSteps(params) {
44439
44446
  else exhausted = true;
44440
44447
  }
44441
44448
  step = work.next(next.done ? void 0 : next.value);
44442
- } else if (step.value.kind === "dash-array" || step.value.kind === "array-reference" || step.value.kind === "array-item" || step.value.kind === "string-bytes" || step.value.kind === "font-width" || step.value.kind === "font-unicode" || step.value.kind === "cmap-lookup" || step.value.kind === "cmap-character" || step.value.kind === "truetype-number" || step.value.kind === "truetype-path" || step.value.kind === "cid-gid" || step.value.kind === "frame-push" || step.value.kind === "frame-pop" || step.value.kind === "capture-append" || step.value.kind === "transform-path" || step.value.kind === "append-clip" || step.value.kind === "path-append" || step.value.kind === "path-finish") {
44449
+ } else if (step.value.kind === "dictionary-value" || step.value.kind === "dash-array" || step.value.kind === "array-reference" || step.value.kind === "array-item" || step.value.kind === "string-bytes" || step.value.kind === "font-width" || step.value.kind === "font-unicode" || step.value.kind === "cmap-lookup" || step.value.kind === "cmap-character" || step.value.kind === "truetype-number" || step.value.kind === "truetype-path" || step.value.kind === "cid-gid" || step.value.kind === "frame-push" || step.value.kind === "frame-pop" || step.value.kind === "capture-append" || step.value.kind === "transform-path" || step.value.kind === "append-clip" || step.value.kind === "path-append" || step.value.kind === "path-finish") {
44443
44450
  throw new PdfError("E_CAPABILITY", "Stored PDF paths require an asynchronous source driver");
44444
44451
  } else if (step.value.kind === "shading") {
44445
44452
  if (!params.cosDoc) throw new PdfError("E_CAPABILITY", "PDF shading requires a source driver");
@@ -44631,7 +44638,8 @@ function* preparePageAppearanceSteps(pageDict, pageRes, evalResourcesDict, hideA
44631
44638
  const sub = yield* resolveDict3(entry.value, [entry.key.decoded]);
44632
44639
  if (sub) {
44633
44640
  onAllocation?.(64 + sub.entries.length * 64);
44634
- const clonedSub = sub.storedEntries ? yield { kind: "dictionary-merge", destination: sub } : cosDict({});
44641
+ const shareBacking = entry.key.decoded === "XObject" || entry.key.decoded === "Properties";
44642
+ const clonedSub = sub.storedEntries ? shareBacking ? { ...sub, entries: [] } : yield { kind: "dictionary-merge", destination: sub } : cosDict({});
44635
44643
  if (!sub.storedEntries) for (const se of sub.entries) dictSet(clonedSub, se.key.decoded, se.value);
44636
44644
  dictSet(evalResourcesDict, entry.key.decoded, clonedSub);
44637
44645
  } else {
@@ -49283,54 +49291,6 @@ async function openPdfCrossReference(source, storage, options = {}) {
49283
49291
  }
49284
49292
  }
49285
49293
 
49286
- // packages/pdf-ast/src/cos/filter-dictionary.ts
49287
- async function resolvePdfStreamDictionary(dict, lookup, active, options) {
49288
- let remaining = options.maxNodes ?? 65536;
49289
- const resolve2 = async (node, depth) => {
49290
- if (--remaining < 0 || depth >= (options.maxRecursionDepth ?? 100)) throw new PdfError("E_LIMIT", "PDF filter resolution limit exceeded");
49291
- if (node.kind === "ref") {
49292
- if (active.has(node.objectNumber)) throw new PdfError("E_PARSE", "PDF filter reference cycle");
49293
- const object = await lookup(node);
49294
- if (!object) throw new PdfError("E_PARSE", "Missing PDF filter reference");
49295
- active.add(node.objectNumber);
49296
- try {
49297
- return await resolve2(object.value, depth + 1);
49298
- } finally {
49299
- active.delete(node.objectNumber);
49300
- }
49301
- }
49302
- if (node.kind === "array") {
49303
- const items = [];
49304
- const { storedItems, ...ordinary } = node;
49305
- if (storedItems) {
49306
- const reader = readStoredItems(storedItems, options.signal);
49307
- try {
49308
- for (; ; ) {
49309
- const item = await reader.next().catch((error) => {
49310
- options.onBackingError?.(error);
49311
- throw error;
49312
- });
49313
- if (item.done) break;
49314
- items.push(await resolve2(item.value, depth + 1));
49315
- }
49316
- } finally {
49317
- await reader.return();
49318
- }
49319
- } else for (const item of node.items) items.push(await resolve2(item, depth + 1));
49320
- return { ...ordinary, items };
49321
- }
49322
- if (node.kind === "dict") {
49323
- const entries2 = [];
49324
- for (const entry of node.entries) entries2.push({ ...entry, value: await resolve2(entry.value, depth + 1) });
49325
- return { ...node, entries: entries2 };
49326
- }
49327
- return node;
49328
- };
49329
- const entries = [];
49330
- for (const entry of dict.entries) entries.push(["Filter", "F", "DecodeParms", "DP", "Type"].includes(entry.key.decoded) ? { ...entry, value: await resolve2(entry.value, 0) } : entry);
49331
- return { ...dict, entries };
49332
- }
49333
-
49334
49294
  // packages/pdf-ast/src/cos/reference-set.ts
49335
49295
  var PdfReferenceSet = class {
49336
49296
  constructor(storage, maximum10 = Infinity, signal) {
@@ -49345,12 +49305,16 @@ var PdfReferenceSet = class {
49345
49305
  tail = /* @__PURE__ */ new Set();
49346
49306
  levels = [];
49347
49307
  closed = false;
49348
- async add(number) {
49308
+ async has(number) {
49349
49309
  if (this.closed) throw new PdfError("E_CAPABILITY", "PDF reference set is closed");
49350
49310
  this.signal?.throwIfAborted();
49351
49311
  if (!Number.isSafeInteger(number) || number < 0) throw new RangeError("Invalid PDF reference number");
49352
- if (this.tail.has(number)) return false;
49353
- for (const level2 of this.levels) if (await level2?.get(number, this.signal)) return false;
49312
+ if (this.tail.has(number)) return true;
49313
+ for (const level of this.levels) if (await level?.get(number, this.signal)) return true;
49314
+ return false;
49315
+ }
49316
+ async add(number) {
49317
+ if (await this.has(number)) return false;
49354
49318
  this.tail.add(number);
49355
49319
  if (this.tail.size < 64) return true;
49356
49320
  let level = 0;
@@ -49398,6 +49362,82 @@ var PdfReferenceSet = class {
49398
49362
  }
49399
49363
  };
49400
49364
 
49365
+ // packages/pdf-ast/src/cos/filter-dictionary.ts
49366
+ async function resolvePdfStreamDictionary(dict, lookup, active, options) {
49367
+ let remaining = options.maxNodes ?? 65536;
49368
+ const resolve2 = async (node, depth, parent = options.referencePath) => {
49369
+ let path = parent, owned, failed = false;
49370
+ try {
49371
+ for (; ; ) {
49372
+ options.signal?.throwIfAborted();
49373
+ if (--remaining < 0 || depth >= (options.maxRecursionDepth ?? 100)) throw new PdfError("E_LIMIT", "PDF filter resolution limit exceeded");
49374
+ if (node.kind !== "ref") break;
49375
+ if (active.has(node.objectNumber)) throw new PdfError("E_PARSE", "PDF filter reference cycle");
49376
+ for (let ancestor = path; ancestor; ancestor = ancestor.parent) {
49377
+ const seen = await ancestor.seen.has(node.objectNumber).catch((error) => {
49378
+ options.onBackingError?.(error);
49379
+ throw error;
49380
+ });
49381
+ if (seen) throw new PdfError("E_PARSE", "PDF filter reference cycle");
49382
+ }
49383
+ owned ??= { seen: new PdfReferenceSet(options.referenceStorage, options.maxTraversalStagingBytes, options.signal), parent, depth: 0 };
49384
+ path = owned;
49385
+ const object = await lookup(node, path);
49386
+ if (!object) throw new PdfError("E_PARSE", "Missing PDF filter reference");
49387
+ await path.seen.add(node.objectNumber).catch((error) => {
49388
+ options.onBackingError?.(error);
49389
+ throw error;
49390
+ });
49391
+ path.depth++;
49392
+ depth++;
49393
+ node = object.value;
49394
+ if (path.depth % 256 === 0) await new Promise((resolve3) => setTimeout(resolve3, 0));
49395
+ }
49396
+ if (node.kind === "array") {
49397
+ const items = [];
49398
+ const { storedItems, ...ordinary } = node;
49399
+ if (storedItems) {
49400
+ const reader = readStoredItems(storedItems, options.signal);
49401
+ try {
49402
+ for (; ; ) {
49403
+ const item = await reader.next().catch((error) => {
49404
+ options.onBackingError?.(error);
49405
+ throw error;
49406
+ });
49407
+ if (item.done) break;
49408
+ items.push(await resolve2(item.value, depth + 1, path));
49409
+ }
49410
+ } finally {
49411
+ await reader.return();
49412
+ }
49413
+ } else for (const item of node.items) items.push(await resolve2(item, depth + 1, path));
49414
+ return { ...ordinary, items };
49415
+ }
49416
+ if (node.kind === "dict") {
49417
+ const entries2 = [];
49418
+ for (const entry of node.entries) entries2.push({ ...entry, value: await resolve2(entry.value, depth + 1, path) });
49419
+ return { ...node, entries: entries2 };
49420
+ }
49421
+ return node;
49422
+ } catch (error) {
49423
+ failed = true;
49424
+ throw error;
49425
+ } finally {
49426
+ try {
49427
+ await owned?.seen.close();
49428
+ } catch (error) {
49429
+ if (!failed) {
49430
+ options.onBackingError?.(error);
49431
+ await Promise.reject(error);
49432
+ }
49433
+ }
49434
+ }
49435
+ };
49436
+ const entries = [];
49437
+ for (const entry of dict.entries) entries.push(["Filter", "F", "DecodeParms", "DP", "Type"].includes(entry.key.decoded) ? { ...entry, value: await resolve2(entry.value, 0) } : entry);
49438
+ return { ...dict, entries };
49439
+ }
49440
+
49401
49441
  // packages/pdf-ast/src/cos/recovered-reference.ts
49402
49442
  async function* recoveredBodies(source, index2, storage, options) {
49403
49443
  const visited = new PdfReferenceSet(storage, options.index?.maxStagingBytes, options.signal);
@@ -49527,6 +49567,7 @@ var PdfObjectReader = class {
49527
49567
  this.capacity = integer2(options.objectStreamCacheEntries ?? 2, "objectStreamCacheEntries", 1);
49528
49568
  this.stagingLimit = maximum2(options.maxStagingBytes, "maxStagingBytes");
49529
49569
  maximum2(options.maxObjectStreamMembers, "maxObjectStreamMembers");
49570
+ maximum2(options.maxTraversalStagingBytes, "maxTraversalStagingBytes");
49530
49571
  this.options = {
49531
49572
  maxNodes: 65536,
49532
49573
  maxTokenBytes: 1048576,
@@ -49543,6 +49584,7 @@ var PdfObjectReader = class {
49543
49584
  // Recursive length/object-stream lookups share one failure identity so an
49544
49585
  // outer recovery pass cannot mistake a caller-storage error for PDF syntax.
49545
49586
  backingFailures = /* @__PURE__ */ new WeakMap();
49587
+ referencePaths = /* @__PURE__ */ new WeakMap();
49546
49588
  repairedOffsets = /* @__PURE__ */ new Map();
49547
49589
  options;
49548
49590
  capacity;
@@ -49572,10 +49614,7 @@ var PdfObjectReader = class {
49572
49614
  const object2 = await this.load(objectNumber, generationNumber, /* @__PURE__ */ new Set());
49573
49615
  if (object2?.value.kind !== "dict" || !object2.stream) throw new PdfError("E_PARSE", "Expected an indexed PDF stream");
49574
49616
  const active = /* @__PURE__ */ new Set([objectNumber]);
49575
- return { object: object2, dict: await resolvePdfStreamDictionary(object2.value, (ref) => this.load(ref.objectNumber, ref.generationNumber, active), active, { ...this.options, onBackingError: (error) => {
49576
- this.backingFailures.set(active, { error });
49577
- this.options.onBackingError?.(error);
49578
- } }) };
49617
+ return { object: object2, dict: await this.resolveStreamDictionary(object2.value, active) };
49579
49618
  });
49580
49619
  const span = object.stream;
49581
49620
  const input = () => this.source.stream(span.start, span.end - span.start, this.options.signal);
@@ -49583,10 +49622,96 @@ var PdfObjectReader = class {
49583
49622
  const decodeOptions = { ...this.options, stopBeforeImageCodec: options.stopBeforeImageCodec ?? false, raw: options.raw ?? false };
49584
49623
  yield* security ? decodePdfEncryptedStreamChunks(security, objectNumber, generationNumber, dict, input, decodeOptions) : decodePdfStreamChunks(dict, input, decodeOptions);
49585
49624
  }
49586
- async load(objectNumber, generationNumber, active, arrays = this.options.valueArrays ?? {}) {
49625
+ resolveStreamDictionary(dict, active) {
49626
+ return resolvePdfStreamDictionary(dict, async (ref, path) => {
49627
+ const parent = this.referencePaths.get(active);
49628
+ this.referencePaths.set(active, path);
49629
+ try {
49630
+ return await this.load(ref.objectNumber, ref.generationNumber, active);
49631
+ } finally {
49632
+ if (parent) this.referencePaths.set(active, parent);
49633
+ else this.referencePaths.delete(active);
49634
+ }
49635
+ }, active, {
49636
+ ...this.options,
49637
+ referenceStorage: this.storage,
49638
+ referencePath: this.referencePaths.get(active),
49639
+ onBackingError: (error) => {
49640
+ this.backingFailures.set(active, { error });
49641
+ this.options.onBackingError?.(error);
49642
+ }
49643
+ });
49644
+ }
49645
+ /** A stream-valued /Length is invalid as a length, but its references still
49646
+ * need cycle, admission and backing-error validation. Walk those discarded
49647
+ * values in source order instead of retaining one parser and AST per link. */
49648
+ async resolveLength(reference, active) {
49649
+ const path = {
49650
+ seen: new PdfReferenceSet(this.storage, this.options.maxTraversalStagingBytes, this.options.signal),
49651
+ parent: this.referencePaths.get(active),
49652
+ depth: 0
49653
+ };
49654
+ this.referencePaths.set(active, path);
49655
+ let next = reference, result, failed = false;
49656
+ try {
49657
+ while (next) {
49658
+ const current = next;
49659
+ next = void 0;
49660
+ const object = await this.load(
49661
+ current.objectNumber,
49662
+ current.generationNumber,
49663
+ active,
49664
+ this.options.valueArrays ?? {},
49665
+ async (child) => {
49666
+ next = child;
49667
+ return void 0;
49668
+ }
49669
+ );
49670
+ if (path.depth === 0 && object?.value.kind === "number") result = object.value.value;
49671
+ try {
49672
+ await path.seen.add(current.objectNumber);
49673
+ } catch (error) {
49674
+ this.backingFailures.set(active, { error });
49675
+ this.options.onBackingError?.(error);
49676
+ throw error;
49677
+ }
49678
+ path.depth++;
49679
+ }
49680
+ return result;
49681
+ } catch (error) {
49682
+ failed = true;
49683
+ throw error;
49684
+ } finally {
49685
+ if (path.parent) this.referencePaths.set(active, path.parent);
49686
+ else this.referencePaths.delete(active);
49687
+ try {
49688
+ await path.seen.close();
49689
+ } catch (error) {
49690
+ if (!failed) {
49691
+ this.backingFailures.set(active, { error });
49692
+ this.options.onBackingError?.(error);
49693
+ await Promise.reject(error);
49694
+ }
49695
+ }
49696
+ }
49697
+ }
49698
+ async load(objectNumber, generationNumber, active, arrays = this.options.valueArrays ?? {}, resolveLength) {
49587
49699
  this.options.signal?.throwIfAborted();
49588
49700
  if (active.has(objectNumber)) throw new PdfError("E_PARSE", "PDF indirect object cycle");
49589
- if (active.size >= this.options.maxRecursionDepth) throw new PdfError("E_LIMIT", "PDF object resolution depth limit exceeded");
49701
+ let depth = active.size;
49702
+ for (let path = this.referencePaths.get(active); path; path = path.parent) {
49703
+ let seen;
49704
+ try {
49705
+ seen = await path.seen.has(objectNumber);
49706
+ } catch (error) {
49707
+ this.backingFailures.set(active, { error });
49708
+ this.options.onBackingError?.(error);
49709
+ throw error;
49710
+ }
49711
+ if (seen) throw new PdfError("E_PARSE", "PDF indirect object cycle");
49712
+ depth += path.depth;
49713
+ }
49714
+ if (depth >= this.options.maxRecursionDepth) throw new PdfError("E_LIMIT", "PDF object resolution depth limit exceeded");
49590
49715
  const entry = await this.index.get(objectNumber, this.options.signal);
49591
49716
  if (!entry || entry.type === "free" || generationNumber !== (entry.generationNumber ?? 0)) return void 0;
49592
49717
  active.add(objectNumber);
@@ -49611,18 +49736,18 @@ var PdfObjectReader = class {
49611
49736
  return { objectNumber, generationNumber, value: parsed.value, span: { start, end: parsed.offset } };
49612
49737
  }
49613
49738
  let object;
49739
+ let pendingLength;
49614
49740
  try {
49615
49741
  object = await parseCosRangeObject(this.source, this.repairedOffsets.get(objectNumber) ?? entry.offset, {
49616
49742
  ...this.options,
49617
49743
  ...arrays,
49618
49744
  onBackingError,
49619
- resolveLength: async (reference) => {
49620
- const resolved = await this.load(reference.objectNumber, reference.generationNumber, active);
49621
- return resolved?.value.kind === "number" ? resolved.value.value : void 0;
49622
- }
49745
+ resolveLength: (reference) => pendingLength = resolveLength ? resolveLength(reference) : this.resolveLength(reference, active)
49623
49746
  });
49624
49747
  if (object.objectNumber !== objectNumber || object.generationNumber !== generationNumber) throw new PdfError("E_PARSE", "Indirect object identity does not match xref");
49625
49748
  } catch (error) {
49749
+ await pendingLength?.catch(() => {
49750
+ });
49626
49751
  this.options.signal?.throwIfAborted();
49627
49752
  const backingFailure = this.backingFailures.get(active);
49628
49753
  if (backingFailure && Object.is(backingFailure.error, error)) throw error;
@@ -49694,10 +49819,7 @@ var PdfObjectReader = class {
49694
49819
  active.add(number);
49695
49820
  let dict;
49696
49821
  try {
49697
- dict = await resolvePdfStreamDictionary(object.value, (ref) => this.load(ref.objectNumber, ref.generationNumber, active), active, { ...this.options, onBackingError: (error) => {
49698
- this.backingFailures.set(active, { error });
49699
- this.options.onBackingError?.(error);
49700
- } });
49822
+ dict = await this.resolveStreamDictionary(object.value, active);
49701
49823
  } finally {
49702
49824
  active.delete(number);
49703
49825
  }
@@ -54950,7 +55072,7 @@ async function resolveRetainedFont(document2, storage, resources, name, options
54950
55072
  }
54951
55073
  let value;
54952
55074
  if (step.value.kind === "resolve") {
54953
- const retained = await document2.lookup(step.value.node, options.resourceStorage ? { dictionaryStorage: options.resourceStorage, storedDictionaryKeys: ["Font"], storeRootDictionary: step.value.storeRootDictionary ?? false, arrayStorage: options.resourceStorage, storedArrayKeys: ["Widths", "W", "Differences"], storeRootArray: step.value.storeRootArray ?? false } : {});
55075
+ const retained = await document2.lookup(step.value.node, options.resourceStorage ? { dictionaryStorage: options.resourceStorage, storedDictionaryKeys: ["Font", "XObject", "Properties"], storeRootDictionary: step.value.storeRootDictionary ?? false, arrayStorage: options.resourceStorage, storedArrayKeys: ["Widths", "W", "Differences"], storeRootArray: step.value.storeRootArray ?? false } : {});
54954
55076
  value = retained?.value;
54955
55077
  if (retained?.stream) {
54956
55078
  if (retained.value.kind !== "dict" || !retained.reference) throw new PdfError("E_PARSE", "Font stream has no retained identity");
@@ -55290,6 +55412,9 @@ async function* evaluateRetainedContentSteps(document2, content, params, storage
55290
55412
  reply = { kind: "dash-array", value: await storeDashArray(request.array, request.storage, request.resolveReferences ? resolve2 : async (node) => node, signal) };
55291
55413
  break;
55292
55414
  }
55415
+ case "dictionary-value":
55416
+ reply = { kind: "resolved", node: await readPdfDictionaryValue(request.dict, request.key, signal) };
55417
+ break;
55293
55418
  case "array-reference":
55294
55419
  reply = { kind: "resolved", node: cosBool(await memberships.has(request.items, request.objectNumber)) };
55295
55420
  break;
@@ -56106,7 +56231,7 @@ function* generateDocumentFormAppearancesSteps(doc) {
56106
56231
  function generateDocumentFormAppearances(doc) {
56107
56232
  return drainWork(generateDocumentFormAppearancesSteps(doc));
56108
56233
  }
56109
- function decodeXmlEntities(text) {
56234
+ function decodeFormDataEntities(text) {
56110
56235
  let out = "";
56111
56236
  let i = 0;
56112
56237
  while (i < text.length) {
@@ -56170,7 +56295,7 @@ function extractAttributeValue(tagBody, attrName) {
56170
56295
  if (quote !== '"' && quote !== "'") return void 0;
56171
56296
  const end = tagBody.indexOf(quote, after + 1);
56172
56297
  if (end === -1) return void 0;
56173
- return decodeXmlEntities(tagBody.slice(after + 1, end));
56298
+ return decodeFormDataEntities(tagBody.slice(after + 1, end));
56174
56299
  }
56175
56300
  function parseXfdfString(text, out) {
56176
56301
  const fieldStack = [];
@@ -56202,7 +56327,7 @@ function parseXfdfString(text, out) {
56202
56327
  } else if (tagName === "value" && !selfClosing && fieldStack.length > 0) {
56203
56328
  const closeVal = text.indexOf("</value>", pos);
56204
56329
  if (closeVal !== -1) {
56205
- const rawVal = decodeXmlEntities(text.slice(pos, closeVal));
56330
+ const rawVal = decodeFormDataEntities(text.slice(pos, closeVal));
56206
56331
  const fullFieldName = fieldStack.filter(Boolean).join(".");
56207
56332
  if (fullFieldName) {
56208
56333
  if (rawVal === "Off") out.set(fullFieldName, false);
@@ -56410,9 +56535,9 @@ function parseFormDataBytes(bytes) {
56410
56535
  if (line.startsWith("FieldType:")) {
56411
56536
  curType = line.slice("FieldType:".length).trim();
56412
56537
  } else if (line.startsWith("FieldName:")) {
56413
- curName = decodeXmlEntities(line.slice("FieldName:".length).trim());
56538
+ curName = decodeFormDataEntities(line.slice("FieldName:".length).trim());
56414
56539
  } else if (line.startsWith("FieldValue:") && curName) {
56415
- const val = decodeXmlEntities(line.slice("FieldValue:".length).trim());
56540
+ const val = decodeFormDataEntities(line.slice("FieldValue:".length).trim());
56416
56541
  if (val === "Yes" || val === "On") {
56417
56542
  out.set(curName, true);
56418
56543
  } else if (val === "Off" || val === "false" || curType === "Button" && val === "") {
@@ -58358,7 +58483,7 @@ var PdfMergeOutlines = class {
58358
58483
  if (node.kind === "ref" && !await seen.add(node.objectNumber)) continue;
58359
58484
  const dict = (await document2.lookup(node))?.value;
58360
58485
  if (dict?.kind !== "dict") continue;
58361
- yield dict;
58486
+ yield { dict, level: depth + 1 };
58362
58487
  if (outlines) {
58363
58488
  await push(dictGet(dict, "Next"), depth);
58364
58489
  await push(dictGet(dict, "First"), depth + 1);
@@ -58380,7 +58505,7 @@ var PdfMergeOutlines = class {
58380
58505
  }
58381
58506
  }
58382
58507
  }
58383
- async append(document2, pageOffset, includeUntitled = false) {
58508
+ async append(document2, pageOffset, includeUntitled = false, includeNameTitles = false) {
58384
58509
  const resolve2 = async (node) => (await document2.lookup(node))?.value;
58385
58510
  const catalog = await resolve2(document2.crossReference.rootRef);
58386
58511
  if (catalog?.kind !== "dict") return;
@@ -58391,7 +58516,7 @@ var PdfMergeOutlines = class {
58391
58516
  const legacy = await resolve2(dictGet(catalog, "Dests")), direct = legacy?.kind === "dict" ? dictGet(legacy, name) : void 0;
58392
58517
  if (direct) return direct;
58393
58518
  const names = await resolve2(dictGet(catalog, "Names"));
58394
- if (names?.kind === "dict") for await (const tree of this.walk(document2, dictGet(names, "Dests"), false)) {
58519
+ if (names?.kind === "dict") for await (const { dict: tree } of this.walk(document2, dictGet(names, "Dests"), false)) {
58395
58520
  const pairs = await resolve2(dictGet(tree, "Names"));
58396
58521
  if (pairs?.kind === "array") for (let i = 0; i + 1 < pairs.items.length; i += 2) {
58397
58522
  await this.checkpoint();
@@ -58424,10 +58549,10 @@ var PdfMergeOutlines = class {
58424
58549
  return number?.kind === "number" && number.value >= 0 && number.value < pageCount ? Math.round(number.value) : 0;
58425
58550
  };
58426
58551
  try {
58427
- for await (const outline of this.walk(document2, dictGet(outlines, "First"), true)) {
58428
- const title = await resolve2(dictGet(outline, "Title")), text = title?.kind === "string" ? decodePdfString(title) : "";
58552
+ for await (const { dict: outline, level } of this.walk(document2, dictGet(outlines, "First"), true)) {
58553
+ const title = await resolve2(dictGet(outline, "Title")), text = title?.kind === "string" ? decodePdfString(title) : includeNameTitles && title?.kind === "name" ? title.decoded : "";
58429
58554
  const index2 = await destination(dictGet(outline, "Dest") ?? dictGet(outline, "A"));
58430
- if (text || includeUntitled) await this.objects.set({ objectNumber: ++this.count, generationNumber: 0, value: cosDict({ Title: cosString(text), Page: cosNumber(pageOffset + index2) }) });
58555
+ if (text || includeUntitled) await this.objects.set({ objectNumber: ++this.count, generationNumber: 0, value: cosDict({ Title: cosString(text), Page: cosNumber(pageOffset + index2), Level: cosNumber(level) }) });
58431
58556
  }
58432
58557
  } catch (error) {
58433
58558
  failed = true;
@@ -58439,11 +58564,14 @@ var PdfMergeOutlines = class {
58439
58564
  }
58440
58565
  }
58441
58566
  async *entries() {
58567
+ for await (const { title, pageIndex } of this.details()) yield { title, pageIndex };
58568
+ }
58569
+ async *details() {
58442
58570
  for await (const object of this.objects.objects()) {
58443
58571
  await this.checkpoint();
58444
- const row = object.value, title = dictGet(row, "Title"), index2 = dictGet(row, "Page");
58572
+ const row = object.value, title = dictGet(row, "Title"), index2 = dictGet(row, "Page"), level = dictGet(row, "Level");
58445
58573
  if (title?.kind !== "string" || index2?.kind !== "number") throw new PdfError("E_PARSE", "Invalid staged outline summary");
58446
- yield { title: decodePdfString(title), pageIndex: index2.value };
58574
+ yield { title: decodePdfString(title), pageIndex: index2.value, level: level?.kind === "number" ? level.value : 1 };
58447
58575
  }
58448
58576
  }
58449
58577
  async finish(target, catalog, pageCount, page2) {
@@ -58569,7 +58697,7 @@ async function openStoredPdfObjectReader(store, storage, options) {
58569
58697
  validateIdentity(number, generation);
58570
58698
  const object = number === 0 ? void 0 : await store.get(number);
58571
58699
  if (object?.generationNumber !== generation || !object.stream || object.value.kind !== "dict") throw new PdfError("E_PARSE", "Expected an indexed PDF stream");
58572
- const dict = await resolvePdfStreamDictionary(object.value, (ref) => reader.get(ref.objectNumber, ref.generationNumber), /* @__PURE__ */ new Set([number]), options);
58700
+ const dict = await resolvePdfStreamDictionary(object.value, (ref) => reader.get(ref.objectNumber, ref.generationNumber), /* @__PURE__ */ new Set([number]), { ...options, referenceStorage: storage });
58573
58701
  const snapshot = object.stream;
58574
58702
  async function* input() {
58575
58703
  for await (const bytes of snapshot.chunks) {
@@ -59539,7 +59667,7 @@ async function markedText(document2, page2, mcid, storage, options) {
59539
59667
  var boundary = boundary2, scan = scan2;
59540
59668
  source = await PdfFileSource.fromStream(storage.fs, storage.directory, input(), { chunkBytes, cacheBytes: chunkBytes, maxInputBytes: maximum10, ...signal ? { signal } : {} });
59541
59669
  const resources = (await document2.lookup(dictGet(page2, "Resources")))?.value;
59542
- const properties = resources?.kind === "dict" ? (await document2.lookup(dictGet(resources, "Properties")))?.value : void 0;
59670
+ const properties = resources?.kind === "dict" ? (await document2.lookup(dictGet(resources, "Properties"), void 0, ["Properties"]))?.value : void 0;
59543
59671
  const operators2 = parseContentRangeOperators(source, storage, { chunkBytes, maxStagingBytes: maximum10 - source.size, ...signal ? { signal } : {} });
59544
59672
  let pending, matching = false, inText = false, part = 0, recorded = false;
59545
59673
  async function* fragments(command) {
@@ -59568,7 +59696,7 @@ async function markedText(document2, page2, mcid, storage, options) {
59568
59696
  await marks.push({ kind: "boolean", value: matching });
59569
59697
  if (operator !== "q") {
59570
59698
  const property = operands[1];
59571
- const dict = property?.kind === "name" && properties?.kind === "dict" ? (await document2.lookup(dictGet(properties, property.decoded)))?.value : property;
59699
+ const dict = property?.kind === "name" && properties?.kind === "dict" ? (await document2.lookup(await readPdfDictionaryValue(properties, property.decoded, signal)))?.value : property;
59572
59700
  const number = dict?.kind === "dict" ? (await document2.lookup(dictGet(dict, "MCID")))?.value : void 0;
59573
59701
  if (number?.kind === "number") matching = number.value === mcid;
59574
59702
  }
@@ -59967,8 +60095,8 @@ async function* walkRetainedImages(document2, storage, options) {
59967
60095
  const decodeOptions = { chunkBytes, ...options.maxDecodedBytes === void 0 ? {} : { maxDecodedBytes: options.maxDecodedBytes }, ...options.signal ? { signal: options.signal } : {} };
59968
60096
  let imageIndex = 0;
59969
60097
  let stagedBytes = 0;
59970
- async function dictionary(node) {
59971
- const value = await document2.lookup(node);
60098
+ async function dictionary(node, resourceKey) {
60099
+ const value = await document2.lookup(node, void 0, resourceKey ? [resourceKey] : void 0);
59972
60100
  return value?.value.kind === "dict" && !value.stream ? value.value : void 0;
59973
60101
  }
59974
60102
  async function number(node, fallback) {
@@ -60067,8 +60195,8 @@ async function* walkRetainedImages(document2, storage, options) {
60067
60195
  } else if (op.operator === "Do") {
60068
60196
  const name = op.operands[0];
60069
60197
  if (name?.kind !== "name") continue;
60070
- const objects = await dictionary(dictGet(activeResources, "XObject"));
60071
- const target = await document2.lookup(objects ? dictGet(objects, name.decoded) : void 0);
60198
+ const objects = await dictionary(dictGet(activeResources, "XObject"), "XObject");
60199
+ const target = await document2.lookup(objects ? await readPdfDictionaryValue(objects, name.decoded, options.signal) : void 0);
60072
60200
  if (target?.value.kind !== "dict" || !target.stream || !target.reference) continue;
60073
60201
  const subtype = (await document2.lookup(dictGet(target.value, "Subtype")))?.value;
60074
60202
  if (subtype?.kind !== "name") continue;
@@ -60129,8 +60257,8 @@ async function* walkRetainedImages(document2, storage, options) {
60129
60257
  yield* content(page2.streamContents(), resources, identity, /* @__PURE__ */ new Set(), 0);
60130
60258
  const patterns = await dictionary(dictGet(resources, "Pattern"));
60131
60259
  if (patterns) for (const entry of patterns.entries) yield* auxiliary(entry.value, resources);
60132
- const fonts = await dictionary(dictGet(resources, "Font"));
60133
- if (fonts) for (const entry of fonts.entries) {
60260
+ const fonts = await dictionary(dictGet(resources, "Font"), "Font");
60261
+ if (fonts) for await (const entry of readPdfDictionaryEntries(fonts, options.signal)) {
60134
60262
  const font = await dictionary(entry.value);
60135
60263
  if (!font) continue;
60136
60264
  const subtype = (await document2.lookup(dictGet(font, "Subtype")))?.value;
@@ -60145,8 +60273,8 @@ async function* walkRetainedImages(document2, storage, options) {
60145
60273
  const appearance = annotation ? await dictionary(dictGet(annotation, "AP")) : void 0;
60146
60274
  if (appearance) yield* auxiliary(dictGet(appearance, "N"), resources);
60147
60275
  }
60148
- const objects = await dictionary(dictGet(resources, "XObject"));
60149
- if (objects) for (const entry of objects.entries) {
60276
+ const objects = await dictionary(dictGet(resources, "XObject"), "XObject");
60277
+ if (objects) for await (const entry of readPdfDictionaryEntries(objects, options.signal)) {
60150
60278
  const ref = entry.value;
60151
60279
  if (ref.kind === "ref" && !(await seen.intern(`${ref.objectNumber}:${ref.generationNumber}`)).added) continue;
60152
60280
  const target = await document2.lookup(ref);
@@ -60183,8 +60311,8 @@ async function* walkRetainedFonts(document2, storage, options) {
60183
60311
  const last = options.lastPage ?? Infinity;
60184
60312
  if (!Number.isSafeInteger(first) || first < 1 || last !== Infinity && (!Number.isSafeInteger(last) || last < first)) throw new RangeError("Invalid PDF font page range");
60185
60313
  let failed = false;
60186
- async function dictionary(node) {
60187
- const resolved = await document2.lookup(node);
60314
+ async function dictionary(node, resourceKey) {
60315
+ const resolved = await document2.lookup(node, void 0, resourceKey ? [resourceKey] : void 0);
60188
60316
  return resolved?.value.kind === "dict" && !resolved.stream ? resolved.value : void 0;
60189
60317
  }
60190
60318
  async function* font(node, key, depth) {
@@ -60220,8 +60348,8 @@ async function* walkRetainedFonts(document2, storage, options) {
60220
60348
  options.signal?.throwIfAborted();
60221
60349
  if (!value) return;
60222
60350
  if (depth > options.maxDepth) throw new PdfError("E_LIMIT", "PDF font resource depth limit exceeded");
60223
- const fonts = await dictionary(dictGet(value, "Font"));
60224
- if (fonts) for (const entry of fonts.entries) yield* font(entry.value, entry.key.decoded, depth);
60351
+ const fonts = await dictionary(dictGet(value, "Font"), "Font");
60352
+ if (fonts) for await (const entry of readPdfDictionaryEntries(fonts, options.signal)) yield* font(entry.value, entry.key.decoded, depth);
60225
60353
  const states = await dictionary(dictGet(value, "ExtGState"));
60226
60354
  if (states) for (const entry of states.entries) {
60227
60355
  const state = await dictionary(entry.value);
@@ -60229,9 +60357,9 @@ async function* walkRetainedFonts(document2, storage, options) {
60229
60357
  if (gsFont?.kind === "array" && gsFont.items[0]) yield* font(gsFont.items[0], `ExtGS_${entry.key.decoded}`, depth);
60230
60358
  }
60231
60359
  for (const key of ["XObject", "Pattern"]) {
60232
- const objects = await dictionary(dictGet(value, key));
60360
+ const objects = await dictionary(dictGet(value, key), key);
60233
60361
  if (!objects) continue;
60234
- for (const entry of objects.entries) {
60362
+ for await (const entry of readPdfDictionaryEntries(objects, options.signal)) {
60235
60363
  if (entry.value.kind === "ref" && !(await names.intern(`form:${entry.value.objectNumber}`)).added) continue;
60236
60364
  const resolved = await document2.lookup(entry.value);
60237
60365
  if (!resolved?.stream || resolved.value.kind !== "dict") continue;
@@ -60815,6 +60943,29 @@ var PdfRetainedDocument = class _PdfRetainedDocument {
60815
60943
  const work = visit(this);
60816
60944
  return work;
60817
60945
  }
60946
+ outlineDetails() {
60947
+ async function* visit(doc) {
60948
+ doc.assertOpen();
60949
+ doc.walks.add(work);
60950
+ const storage = new PdfStagingStorage(doc.storage, doc.options.maxTraversalStagingBytes);
60951
+ const outlines = new PdfMergeOutlines(storage, doc.options.signal, Infinity);
60952
+ let failed = false;
60953
+ try {
60954
+ await outlines.append(doc, 0, false, true);
60955
+ yield* outlines.details();
60956
+ } catch (error) {
60957
+ failed = true;
60958
+ throw error;
60959
+ } finally {
60960
+ doc.walks.delete(work);
60961
+ await outlines.close().catch((error) => {
60962
+ if (!failed) throw error;
60963
+ });
60964
+ }
60965
+ }
60966
+ const work = visit(this);
60967
+ return work;
60968
+ }
60818
60969
  pageLabels() {
60819
60970
  async function* visit(doc) {
60820
60971
  doc.assertOpen();
@@ -62280,6 +62431,9 @@ async function* saveRetainedDocumentChunks(document2, storage, options = {}) {
62280
62431
  }
62281
62432
  }
62282
62433
 
62434
+ // packages/pdf-ast/src/edit/retained-info-updates.ts
62435
+ import { PagedStorage as PagedStorage14 } from "@poe-platform/safe-fs/storage";
62436
+
62283
62437
  // packages/pdf-ast/src/edit/retained-bookmarks.ts
62284
62438
  import { PagedStorage as PagedStorage13 } from "@poe-platform/safe-fs/storage";
62285
62439
  async function setRetainedBookmarks(store, storage, root, pageCount, pageReference, bookmarks, signal, maxDepth = Infinity) {
@@ -62357,6 +62511,126 @@ async function setRetainedBookmarks(store, storage, root, pageCount, pageReferen
62357
62511
  }
62358
62512
  }
62359
62513
 
62514
+ // packages/pdf-ast/src/edit/retained-info-updates.ts
62515
+ async function applyRetainedInfoUpdates(document2, store, storage, count, getPage, updates, signal, maxDepth) {
62516
+ const pages = new PagedStorage14({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
62517
+ const base = pages.allocate(count * 4 * 48), heads = [-1, -1, -1, -1], tails = [-1, -1, -1, -1];
62518
+ const labels = new PdfMutableObjectStore(storage, { signal }), bookmarks = new PdfMutableObjectStore(storage, { signal });
62519
+ let infoRef = document2.crossReference.infoRef, idArray = document2.crossReference.idArray, labelCount = 0, work = 0, failed = false;
62520
+ const rootRef = document2.crossReference.rootRef;
62521
+ async function checkpoint() {
62522
+ signal.throwIfAborted();
62523
+ if (++work % 64 === 0) await new Promise((resolve2) => setTimeout(resolve2, 0));
62524
+ signal.throwIfAborted();
62525
+ }
62526
+ const position = (group, index2) => base + (group * count + index2) * 48;
62527
+ try {
62528
+ for await (const update of updates) {
62529
+ await checkpoint();
62530
+ if (update.kind === "info") {
62531
+ const standard = ["Title", "Author", "Subject", "Keywords", "Creator", "Producer"].includes(update.key);
62532
+ let info3 = infoRef ? await store.get(infoRef.objectNumber) : void 0;
62533
+ if (infoRef && info3?.value.kind !== "dict") {
62534
+ const resolved = await document2.lookup(infoRef);
62535
+ if (resolved?.value.kind === "dict" && resolved.reference) info3 = await store.get(resolved.reference.objectNumber);
62536
+ }
62537
+ if (!infoRef || standard && info3?.value.kind !== "dict") {
62538
+ infoRef = await store.allocate(cosDict(!standard ? { Title: cosString("") } : {}));
62539
+ info3 = await store.get(infoRef.objectNumber);
62540
+ }
62541
+ if (info3?.value.kind === "dict") {
62542
+ dictSet(info3.value, update.key, cosString(update.value));
62543
+ await store.set(info3);
62544
+ }
62545
+ } else if (update.kind === "id") {
62546
+ if (idArray === document2.crossReference.idArray) {
62547
+ const first = await document2.lookup(idArray?.items[0]), second = await document2.lookup(idArray?.items[1]);
62548
+ const a = first?.value.kind === "string" ? first.value.bytes : new Uint8Array(16), b = second?.value.kind === "string" ? second.value.bytes : a;
62549
+ idArray = cosArray([cosHexString(a), cosHexString(b)]);
62550
+ }
62551
+ idArray.items[update.index] = cosHexString(new Uint8Array(update.bytes));
62552
+ } else if (update.kind === "page") {
62553
+ const index2 = update.pageNumber - 1;
62554
+ if (!Number.isSafeInteger(index2) || index2 < 0 || index2 >= count) continue;
62555
+ const group = ["rotation", "dimensions", "media", "crop"].indexOf(update.property), size = group === 0 ? 1 : group === 1 ? 2 : 4;
62556
+ if (update.values.length !== size || !update.values.every(Number.isFinite)) throw new RangeError("Invalid page property values");
62557
+ const offset = position(group, index2), bytes = await pages.read(offset, 48), view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
62558
+ if (!view.getFloat64(0)) {
62559
+ view.setFloat64(0, 1);
62560
+ view.setFloat64(8, -1);
62561
+ if (tails[group] >= 0) {
62562
+ const link2 = new Uint8Array(8);
62563
+ new DataView(link2.buffer).setFloat64(0, index2);
62564
+ await pages.write(position(group, tails[group]) + 8, link2);
62565
+ } else heads[group] = index2;
62566
+ tails[group] = index2;
62567
+ }
62568
+ for (let i = 0; i < size; i++) view.setFloat64(16 + i * 8, update.values[i]);
62569
+ await pages.write(offset, bytes);
62570
+ } else if (update.kind === "label") {
62571
+ const value = cosDict({ St: cosNumber(update.start) });
62572
+ if (update.prefix) dictSet(value, "P", cosString(update.prefix));
62573
+ if (update.style) dictSet(value, "S", cosName(update.style));
62574
+ await labels.allocate(cosArray([cosNumber(update.index), value]));
62575
+ labelCount++;
62576
+ } else await bookmarks.allocate(cosArray([cosString(update.title), cosNumber(update.level), cosNumber(update.pageNumber)]));
62577
+ }
62578
+ for (let group = 0; group < 4; group++) for (let index2 = heads[group]; index2 >= 0; ) {
62579
+ await checkpoint();
62580
+ const bytes = await pages.read(position(group, index2), 48), view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length), page2 = await getPage(index2);
62581
+ if (group === 0) dictSet(page2.dict, "Rotate", cosNumber((Math.round(view.getFloat64(16) / 90) * 90 % 360 + 360) % 360));
62582
+ else {
62583
+ const values = group === 1 ? [0, 0, view.getFloat64(16), view.getFloat64(24)] : [16, 24, 32, 40].map((offset) => view.getFloat64(offset));
62584
+ dictSet(page2.dict, group === 3 ? "CropBox" : "MediaBox", cosArray(values.map((value) => cosNumber(value))));
62585
+ }
62586
+ await store.set({ objectNumber: page2.reference.objectNumber, generationNumber: page2.reference.generationNumber, value: page2.dict });
62587
+ index2 = view.getFloat64(8);
62588
+ }
62589
+ if (labelCount) {
62590
+ const root = await store.get(rootRef.objectNumber);
62591
+ if (root?.value.kind === "dict") {
62592
+ const ref = await store.allocate(cosDict({}));
62593
+ dictSet(root.value, "PageLabels", ref);
62594
+ await store.set(root);
62595
+ async function* chunks() {
62596
+ const encoder = new TextEncoder();
62597
+ yield encoder.encode("<<\n/Nums [ ");
62598
+ for await (const object of labels.objects()) {
62599
+ await checkpoint();
62600
+ if (object.value.kind !== "array") throw new Error("Invalid label record");
62601
+ for (const node of object.value.items) {
62602
+ yield* serializeCosNodeChunks(node, { signal });
62603
+ yield encoder.encode(" ");
62604
+ }
62605
+ }
62606
+ yield encoder.encode("]\n>>");
62607
+ }
62608
+ let length = 0;
62609
+ for await (const bytes of chunks()) length += bytes.length;
62610
+ await store.setSerializedValue({ objectNumber: ref.objectNumber, generationNumber: 0, body: { length, chunks: chunks() } });
62611
+ }
62612
+ }
62613
+ async function* outlineUpdates() {
62614
+ for await (const object of bookmarks.objects()) {
62615
+ await checkpoint();
62616
+ const value = object.value;
62617
+ if (value.kind !== "array" || value.items[0]?.kind !== "string" || value.items[1]?.kind !== "number" || value.items[2]?.kind !== "number") throw new Error("Invalid bookmark record");
62618
+ yield { title: decodePdfString(value.items[0]), level: value.items[1].value, pageNumber: value.items[2].value };
62619
+ }
62620
+ }
62621
+ await setRetainedBookmarks(store, storage, rootRef, count, async (index2) => (await getPage(index2)).reference, outlineUpdates(), signal, maxDepth);
62622
+ return { infoRef, idArray };
62623
+ } catch (error) {
62624
+ failed = true;
62625
+ throw error;
62626
+ } finally {
62627
+ const results = await Promise.allSettled([pages.close(), labels.close(), bookmarks.close()]);
62628
+ if (!failed) {
62629
+ for (const result of results) if (result.status === "rejected") await Promise.reject(result.reason);
62630
+ }
62631
+ }
62632
+ }
62633
+
62360
62634
  // packages/pdf-ast/src/edit/retained-append-attachments.ts
62361
62635
  async function appendRetainedAttachments(document2, target, storage, attachments, options = {}) {
62362
62636
  const signal = options.signal ?? new AbortController().signal, appended = new PdfMutableObjectStore(storage, { signal });
@@ -62481,7 +62755,7 @@ async function appendRetainedAttachments(document2, target, storage, attachments
62481
62755
  }
62482
62756
 
62483
62757
  // packages/pdf-ast/src/edit/retained-form-appearances.ts
62484
- import { IntegerTable as IntegerTable8, PagedStorage as PagedStorage14 } from "@poe-platform/safe-fs/storage";
62758
+ import { IntegerTable as IntegerTable8, PagedStorage as PagedStorage15 } from "@poe-platform/safe-fs/storage";
62485
62759
 
62486
62760
  // packages/pdf-ast/src/edit/form-appearance-chunks.ts
62487
62761
  function* serializeFormAppearanceChunks(text, options) {
@@ -62567,10 +62841,11 @@ function* operators(text, options) {
62567
62841
  }
62568
62842
 
62569
62843
  // packages/pdf-ast/src/edit/retained-form-appearances.ts
62570
- async function generateRetainedFormAppearances(document2, store, storage, signal) {
62844
+ async function generateRetainedFormAppearances(document2, store, storage, signal, update) {
62571
62845
  if (!document2.crossReference.rootRef) return;
62572
- const backing = new PagedStorage14({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), active = new IntegerTable8(backing);
62846
+ const backing = new PagedStorage15({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), active = new IntegerTable8(backing);
62573
62847
  let head = -1, failed = false, work = 0;
62848
+ let matched = false;
62574
62849
  let defaultAppearance;
62575
62850
  async function checkpoint(depth = 0) {
62576
62851
  signal.throwIfAborted();
@@ -62615,6 +62890,7 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
62615
62890
  const source = await PdfFileSource.fromStream(storage.fs, storage.directory, chunks, { signal });
62616
62891
  let failed2 = false;
62617
62892
  try {
62893
+ if (update && dict.kind === "dict") dictSet(dict, "Length", cosNumber(source.size));
62618
62894
  const ref = await store.allocate();
62619
62895
  await store.set({ objectNumber: ref.objectNumber, generationNumber: 0, value: dict, stream: { length: source.size, chunks: source.stream(0, source.size, signal), decoded: true } });
62620
62896
  return ref;
@@ -62672,14 +62948,30 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
62672
62948
  return "Yes";
62673
62949
  }
62674
62950
  try {
62675
- const form = await locate(formLocation);
62951
+ let form = await locate(formLocation);
62952
+ if (update && form?.value.kind !== "dict") {
62953
+ const catalog = await locate(root);
62954
+ if (catalog?.value.kind !== "dict") return;
62955
+ dictSet(catalog.value, "AcroForm", await store.allocate(cosDict({ Fields: cosArray([]), NeedAppearances: cosBool(true) })));
62956
+ await store.set(catalog.owner);
62957
+ form = await locate(formLocation);
62958
+ }
62676
62959
  if (form?.value.kind !== "dict") return;
62960
+ if (update) {
62961
+ dictSet(form.value, "NeedAppearances", cosBool(true));
62962
+ await store.set(form.owner);
62963
+ const fields3 = await locate(child(form.location, "Fields"));
62964
+ if (fields3?.value.kind !== "array") {
62965
+ dictSet(form.value, "Fields", cosArray([]));
62966
+ await store.set(form.owner);
62967
+ }
62968
+ }
62677
62969
  defaultAppearance = dictGet(form.value, "DA");
62678
62970
  const need = await resolve2(dictGet(form.value, "NeedAppearances")), force = need?.kind === "boolean" && need.value;
62679
62971
  const fields2 = await locate(child(form.location, "Fields"));
62680
62972
  if (fields2?.value.kind === "array") for (let i = fields2.value.items.length - 1; i >= 0; i--) {
62681
62973
  await checkpoint();
62682
- await push({ location: itemLocation(fields2.location, i, fields2.value.items[i]), named: false, ft: "", ff: 0, q: 0, depth: 0 });
62974
+ await push({ location: itemLocation(fields2.location, i, fields2.value.items[i]), named: "", ft: "", ff: 0, q: 0, depth: 0 });
62683
62975
  }
62684
62976
  while (head !== -1) {
62685
62977
  const record = await readStoredRecord(backing, head, signal);
@@ -62699,7 +62991,8 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
62699
62991
  await push({ exit: id });
62700
62992
  }
62701
62993
  const name = await resolve2(dictGet(field2.value, "T")), ft = await resolve2(dictGet(field2.value, "FT"));
62702
- const named = frame.named || (name?.kind === "name" ? !!name.decoded : name?.kind === "string" ? !!decodePdfString(name) : false);
62994
+ const partial = name?.kind === "name" ? name.decoded : name?.kind === "string" ? decodePdfString(name) : "";
62995
+ const named = update ? frame.named && partial ? `${frame.named}.${partial}` : partial || frame.named : frame.named || partial ? "1" : "";
62703
62996
  const inherited = { ...frame, named, ft: ft?.kind === "name" ? ft.decoded : frame.ft, ff: await number(dictGet(field2.value, "Ff"), frame.ff), q: await number(dictGet(field2.value, "Q"), frame.q) };
62704
62997
  const maxLen = await resolve2(dictGet(field2.value, "MaxLen"));
62705
62998
  if (maxLen?.kind === "number") inherited.maxLen = maxLen.value;
@@ -62723,6 +63016,70 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
62723
63016
  }
62724
63017
  }
62725
63018
  if (!named) continue;
63019
+ if (update) {
63020
+ if (named !== update.name) continue;
63021
+ matched = true;
63022
+ const value2 = update.value;
63023
+ if (typeof value2 === "boolean" || inherited.ft === "Btn") {
63024
+ const on = await onValue(field2.location);
63025
+ const checked = typeof value2 === "boolean" ? value2 : value2 !== "Off" && value2 !== "false" && value2 !== "0" && value2 !== "";
63026
+ const chosen = typeof value2 === "string" && value2 !== "true" && value2 !== "false" && value2 !== "Off" ? value2 : on;
63027
+ const state = cosName(checked ? chosen : "Off");
63028
+ dictSet(field2.value, "FT", cosName("Btn"));
63029
+ dictSet(field2.value, "V", state);
63030
+ dictSet(field2.value, "AS", state);
63031
+ await store.set(field2.owner);
63032
+ if (kids?.value.kind === "array") for (let i = 0; i < kids.value.items.length; i++) {
63033
+ await checkpoint();
63034
+ const kid = await locate(itemLocation(kids.location, i, kids.value.items[i]));
63035
+ if (kid?.value.kind !== "dict") continue;
63036
+ const normal = await locate(child(child(kid.location, "AP"), "N"));
63037
+ const selected2 = normal?.value.kind === "dict" && normal.value.entries.length ? cosName(checked && dictGet(normal.value, chosen) !== void 0 ? chosen : "Off") : state;
63038
+ dictSet(kid.value, "AS", selected2);
63039
+ await store.set(kid.owner);
63040
+ }
63041
+ continue;
63042
+ }
63043
+ if (!inherited.ft) dictSet(field2.value, "FT", cosName("Tx"));
63044
+ let text2 = String(value2);
63045
+ const multi = inherited.ft === "Ch" && !!(inherited.ff & 1 << 21) && text2.includes(",");
63046
+ const selected = multi ? text2.split(",").map((value3) => value3.trim()).filter(Boolean) : [text2];
63047
+ dictSet(field2.value, "V", multi ? cosArray(selected.map((value3) => cosString(value3))) : cosString(text2));
63048
+ if (inherited.ft === "Ch") {
63049
+ const choices = await resolve2(dictGet(field2.value, "Opt")), indices = [];
63050
+ if (choices?.kind === "array") for (let i = 0; i < choices.items.length; i++) {
63051
+ await checkpoint();
63052
+ const option = await resolve2(choices.items[i]);
63053
+ let exported = "", label = "", valid = false;
63054
+ if (option?.kind === "string") {
63055
+ exported = decodePdfString(option);
63056
+ label = exported;
63057
+ valid = true;
63058
+ } else if (option?.kind === "array" && option.items.length >= 2) {
63059
+ const first = await resolve2(option.items[0]), second = await resolve2(option.items[1]);
63060
+ exported = first?.kind === "string" ? decodePdfString(first) : "";
63061
+ label = second?.kind === "string" ? decodePdfString(second) : "";
63062
+ valid = true;
63063
+ }
63064
+ if (valid && (selected.includes(exported) || selected.includes(label))) {
63065
+ indices.push(i);
63066
+ if (!multi) {
63067
+ if (label) text2 = label;
63068
+ break;
63069
+ }
63070
+ }
63071
+ }
63072
+ if (indices.length) dictSet(field2.value, "I", cosArray(indices.map((value3) => cosNumber(value3))));
63073
+ }
63074
+ await store.set(field2.owner);
63075
+ await synthesize(field2.location, text2, inherited);
63076
+ if (kids?.value.kind === "array") for (let i = 0; i < kids.value.items.length; i++) {
63077
+ await checkpoint();
63078
+ const kid = await locate(itemLocation(kids.location, i, kids.value.items[i]));
63079
+ if (kid?.value.kind === "dict" && !dictGet(kid.value, "T")) await synthesize(kid.location, text2, inherited);
63080
+ }
63081
+ continue;
63082
+ }
62726
63083
  const value = await resolve2(dictGet(field2.value, "V"));
62727
63084
  if (!value) continue;
62728
63085
  const appearance = await resolve2(dictGet(field2.value, "AP")), hasNormal = appearance?.kind === "dict" && dictGet(appearance, "N") !== void 0;
@@ -62760,9 +63117,18 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
62760
63117
  if (kid?.value.kind === "dict" && !dictGet(kid.value, "T")) await synthesize(kid.location, text, inherited);
62761
63118
  }
62762
63119
  }
63120
+ if (update && !matched) {
63121
+ const fields3 = await locate(child(formLocation, "Fields"));
63122
+ if (fields3?.value.kind === "array") {
63123
+ const value = update.value;
63124
+ const field2 = typeof value === "boolean" ? cosDict({ FT: cosName("Btn"), T: cosString(update.name), V: cosName(value ? "Yes" : "Off"), AS: cosName(value ? "Yes" : "Off") }) : cosDict({ FT: cosName("Tx"), T: cosString(update.name), V: cosString(value) });
63125
+ fields3.value.items.push(await store.allocate(field2));
63126
+ await store.set(fields3.owner);
63127
+ }
63128
+ }
62763
63129
  const latest = await locate(formLocation);
62764
63130
  if (latest?.value.kind === "dict") {
62765
- dictSet(latest.value, "NeedAppearances", cosBool(false));
63131
+ dictSet(latest.value, "NeedAppearances", cosBool(!!update));
62766
63132
  await store.set(latest.owner);
62767
63133
  }
62768
63134
  } catch (error) {
@@ -62776,16 +63142,16 @@ async function generateRetainedFormAppearances(document2, store, storage, signal
62776
63142
  }
62777
63143
 
62778
63144
  // packages/pdf-ast/src/edit/retained-flatten-annotations.ts
62779
- import { IntegerTable as IntegerTable10, PagedStorage as PagedStorage18 } from "@poe-platform/safe-fs/storage";
63145
+ import { IntegerTable as IntegerTable10, PagedStorage as PagedStorage19 } from "@poe-platform/safe-fs/storage";
62780
63146
 
62781
63147
  // packages/pdf-ast/src/edit/retained-content-edit.ts
62782
- import { IntegerTable as IntegerTable9, PagedStorage as PagedStorage15 } from "@poe-platform/safe-fs/storage";
63148
+ import { IntegerTable as IntegerTable9, PagedStorage as PagedStorage16 } from "@poe-platform/safe-fs/storage";
62783
63149
  var RetainedContentEditor = class _RetainedContentEditor {
62784
63150
  constructor(store, storage, signal) {
62785
63151
  this.store = store;
62786
63152
  this.storage = storage;
62787
63153
  this.signal = signal;
62788
- this.backing = new PagedStorage15({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
63154
+ this.backing = new PagedStorage16({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
62789
63155
  this.counts = new IntegerTable9(this.backing);
62790
63156
  this.identities = new PdfNameIndex(storage, Infinity, signal);
62791
63157
  }
@@ -62857,14 +63223,14 @@ var RetainedContentEditor = class _RetainedContentEditor {
62857
63223
  };
62858
63224
 
62859
63225
  // packages/pdf-ast/src/edit/retained-name-replacement.ts
62860
- import { PagedStorage as PagedStorage16 } from "@poe-platform/safe-fs/storage";
63226
+ import { PagedStorage as PagedStorage17 } from "@poe-platform/safe-fs/storage";
62861
63227
  async function* replaceRetainedPdfName(input, oldName, newName, storage, options = {}) {
62862
63228
  const chunkBytes = options.chunkBytes ?? 16384, maximum10 = options.maxOutputBytes ?? Infinity;
62863
63229
  if (!Number.isSafeInteger(chunkBytes) || chunkBytes < 1) throw new RangeError("Invalid name replacement chunk size");
62864
63230
  if (maximum10 !== Infinity && (!Number.isSafeInteger(maximum10) || maximum10 < 0)) throw new RangeError("Invalid name replacement output limit");
62865
63231
  const signal = options.signal ?? new AbortController().signal;
62866
63232
  signal.throwIfAborted();
62867
- const table = new PagedStorage16({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), length = oldName.length + 1;
63233
+ const table = new PagedStorage17({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), length = oldName.length + 1;
62868
63234
  const base = table.allocate(length * 8), record = new Uint8Array(8), view = new DataView(record.buffer);
62869
63235
  const pattern = (at) => at ? oldName.charCodeAt(at - 1) : 47;
62870
63236
  let buffer = new Uint8Array(chunkBytes), used = 0, total = 0, work = 0, failed = false;
@@ -62942,10 +63308,10 @@ async function* replaceRetainedPdfName(input, oldName, newName, storage, options
62942
63308
  }
62943
63309
 
62944
63310
  // packages/pdf-ast/src/edit/retained-draw-text.ts
62945
- import { PagedStorage as PagedStorage17 } from "@poe-platform/safe-fs/storage";
63311
+ import { PagedStorage as PagedStorage18 } from "@poe-platform/safe-fs/storage";
62946
63312
  async function drawRetainedAnnotationText(page2, editor, storage, text, x, y, isolated, font, signal) {
62947
63313
  const source = await PdfFileSource.fromStream(storage.fs, storage.directory, page2.streamContents(), { signal });
62948
- const backing = new PagedStorage17({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
63314
+ const backing = new PagedStorage18({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
62949
63315
  let failed = false;
62950
63316
  try {
62951
63317
  const name = await font(), position = backing.allocate(text.length);
@@ -63021,7 +63387,7 @@ async function flattenRetainedAnnotations(document2, store, storage, mode, signa
63021
63387
  for await (const page2 of document2.pages()) {
63022
63388
  const annotations = await array(dictGet(page2.dict, "Annots"));
63023
63389
  if (!annotations) continue;
63024
- const survivorStorage = new PagedStorage18({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
63390
+ const survivorStorage = new PagedStorage19({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
63025
63391
  const survivorBase = survivorStorage.allocate(0);
63026
63392
  let pageFailed = false;
63027
63393
  try {
@@ -63107,7 +63473,7 @@ async function flattenRetainedAnnotations(document2, store, storage, mode, signa
63107
63473
  }
63108
63474
  if (normal?.stream && normal.reference && normal.value.kind === "dict") {
63109
63475
  let content = await PdfFileSource.fromStream(storage.fs, storage.directory, document2.objects.decodeStream(normal.reference.objectNumber, normal.reference.generationNumber), { signal });
63110
- const backing = new PagedStorage18({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), renames = new IntegerTable10(backing), names = new PdfNameIndex(storage, Infinity, signal);
63476
+ const backing = new PagedStorage19({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), renames = new IntegerTable10(backing), names = new PdfNameIndex(storage, Infinity, signal);
63111
63477
  let appearanceFailed = false, count = 0;
63112
63478
  try {
63113
63479
  if (content.size) {
@@ -63226,11 +63592,11 @@ q ${scaleX} 0 0 ${scaleY} ${tx} ${ty} cm${matSuffix}
63226
63592
  }
63227
63593
 
63228
63594
  // packages/pdf-ast/src/edit/retained-name-map.ts
63229
- import { PagedStorage as PagedStorage19 } from "@poe-platform/safe-fs/storage";
63595
+ import { PagedStorage as PagedStorage20 } from "@poe-platform/safe-fs/storage";
63230
63596
  async function* replaceRetainedPdfNames(input, names, storage, options = {}) {
63231
63597
  const signal = options.signal ?? new AbortController().signal, size = options.chunkBytes ?? 16384;
63232
63598
  if (!Number.isSafeInteger(size) || size < 1) throw new RangeError("Invalid name replacement chunk size");
63233
- const trie = new PagedStorage19({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), pending = new PagedStorage19({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
63599
+ const trie = new PagedStorage20({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), pending = new PagedStorage20({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
63234
63600
  const root = trie.allocate(40), prefixBase = pending.allocate(0);
63235
63601
  let output = new Uint8Array(size), used = 0, failed = false, work = 0;
63236
63602
  const body = (byte3) => byte3 >= 48 && byte3 <= 57 || byte3 >= 65 && byte3 <= 90 || byte3 >= 97 && byte3 <= 122 || [95, 46, 43, 45].includes(byte3);
@@ -63512,7 +63878,7 @@ async function preserveRetainedStamp(document2, source, page2, other, store, edi
63512
63878
  }
63513
63879
 
63514
63880
  // packages/pdf-ast/src/edit/retained-stamps.ts
63515
- import { IntegerTable as IntegerTable11, PagedStorage as PagedStorage20 } from "@poe-platform/safe-fs/storage";
63881
+ import { IntegerTable as IntegerTable11, PagedStorage as PagedStorage21 } from "@poe-platform/safe-fs/storage";
63516
63882
  async function stampRetainedPages(document2, store, storage, getPage, stamps, signal) {
63517
63883
  const editor = await RetainedContentEditor.open(store, storage, signal);
63518
63884
  let counter = 1, failed = false, work = 0;
@@ -63523,7 +63889,7 @@ async function stampRetainedPages(document2, store, storage, getPage, stamps, si
63523
63889
  try {
63524
63890
  for await (const stamp of stamps) {
63525
63891
  const source = await editRetainedDocument(stamp.source, storage, { signal });
63526
- const backing = new PagedStorage20({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), memo = new IntegerTable11(backing);
63892
+ const backing = new PagedStorage21({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), memo = new IntegerTable11(backing);
63527
63893
  let stampFailed = false;
63528
63894
  async function clone(node, depth = 0) {
63529
63895
  await checkpoint();
@@ -63709,12 +64075,12 @@ ${fmt6(s)} 0 0 ${fmt6(s)} ${fmt4(tx)} ${fmt4(ty)} cm
63709
64075
  }
63710
64076
 
63711
64077
  // packages/pdf-ast/src/edit/retained-inline-images.ts
63712
- import { PagedStorage as PagedStorage21 } from "@poe-platform/safe-fs/storage";
64078
+ import { PagedStorage as PagedStorage22 } from "@poe-platform/safe-fs/storage";
63713
64079
  async function externalizeRetainedInlineImages(document2, store, storage, options, signal) {
63714
64080
  const minimum = options.minBytes ?? 1024;
63715
64081
  if (!Number.isSafeInteger(minimum) || minimum < 0) throw new RangeError("Invalid inline-image minimum size");
63716
64082
  const editor = await RetainedContentEditor.open(store, storage, signal);
63717
- const paths = new PagedStorage21({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
64083
+ const paths = new PagedStorage22({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
63718
64084
  const keys = { BPC: "BitsPerComponent", CS: "ColorSpace", D: "Decode", DP: "DecodeParms", F: "Filter", H: "Height", IM: "ImageMask", I: "Interpolate", W: "Width" };
63719
64085
  const colors = { G: "DeviceGray", RGB: "DeviceRGB", CMYK: "DeviceCMYK", I: "Indexed" };
63720
64086
  const filters = { AHx: "ASCIIHexDecode", A85: "ASCII85Decode", LZW: "LZWDecode", Fl: "FlateDecode", RL: "RunLengthDecode", CCF: "CCITTFaxDecode", DCT: "DCTDecode" };
@@ -63806,7 +64172,7 @@ async function externalizeRetainedInlineImages(document2, store, storage, option
63806
64172
  }
63807
64173
 
63808
64174
  // packages/pdf-ast/src/edit/retained-resource-pruning.ts
63809
- import { IntegerTable as IntegerTable12, PagedStorage as PagedStorage22 } from "@poe-platform/safe-fs/storage";
64175
+ import { IntegerTable as IntegerTable12, PagedStorage as PagedStorage23 } from "@poe-platform/safe-fs/storage";
63810
64176
  async function collectNames(input, names, found, signal) {
63811
64177
  const iterator = input[Symbol.asyncIterator](), pending = [];
63812
64178
  let chunk = new Uint8Array(), at = 0, ended = false, changed = false, work = 0, failed = false;
@@ -63888,7 +64254,7 @@ async function pruneRetainedResources(document2, store, storage, signal) {
63888
64254
  return { ...found2, value: same(page2.reference) ? page2.dict : same(resources?.reference) ? resources.value : found2.value };
63889
64255
  }
63890
64256
  const names = new PdfNameIndex(storage, Infinity, signal), visitedNames = new PdfNameIndex(storage, Infinity, signal);
63891
- const backing = new PagedStorage22({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), found = new IntegerTable12(backing);
64257
+ const backing = new PagedStorage23({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), found = new IntegerTable12(backing);
63892
64258
  let failed = false;
63893
64259
  try {
63894
64260
  const referenced = async (name) => await found.get(BigInt((await names.intern(name)).index)) !== void 0;
@@ -64018,7 +64384,7 @@ async function flattenRetainedRotations(document2, store, storage, signal) {
64018
64384
  }
64019
64385
 
64020
64386
  // packages/pdf-ast/src/edit/retained-attachment-edits.ts
64021
- import { IntegerTable as IntegerTable13, PagedStorage as PagedStorage23 } from "@poe-platform/safe-fs/storage";
64387
+ import { IntegerTable as IntegerTable13, PagedStorage as PagedStorage24 } from "@poe-platform/safe-fs/storage";
64022
64388
  var PdfDuplicateAttachment = class extends PdfError {
64023
64389
  constructor(key) {
64024
64390
  super("E_CAPABILITY", `Duplicate attachment key: ${key}`);
@@ -64029,7 +64395,7 @@ var PdfDuplicateAttachment = class extends PdfError {
64029
64395
  async function editRetainedAttachments(document2, target, storage, remove, additions, signal, preserveTree = false) {
64030
64396
  const pairs = new PdfMutableObjectStore(storage, { signal });
64031
64397
  const names = new PdfNameIndex(storage, Infinity, signal), removed = new PdfNameIndex(storage, Infinity, signal);
64032
- const backing = new PagedStorage23({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), first = new IntegerTable13(backing), removals = new IntegerTable13(backing);
64398
+ const backing = new PagedStorage24({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), first = new IntegerTable13(backing), removals = new IntegerTable13(backing);
64033
64399
  let failed = false, count = 0, work = 0;
64034
64400
  async function checkpoint() {
64035
64401
  signal.throwIfAborted();
@@ -64231,13 +64597,13 @@ async function* retainedAttachmentNameTokens(document2, storage, root, signal, r
64231
64597
  }
64232
64598
 
64233
64599
  // packages/pdf-ast/src/edit/retained-graph.ts
64234
- import { PagedStorage as PagedStorage24 } from "@poe-platform/safe-fs/storage";
64600
+ import { PagedStorage as PagedStorage25 } from "@poe-platform/safe-fs/storage";
64235
64601
  async function editRetainedDocument(source, storage, options = {}) {
64236
64602
  if (options.maxPages !== void 0 && options.maxPages !== Infinity && (!Number.isSafeInteger(options.maxPages) || options.maxPages < 0)) throw new RangeError("Invalid page limit");
64237
64603
  if (options.maxRecursionDepth !== void 0 && options.maxRecursionDepth !== Infinity && (!Number.isSafeInteger(options.maxRecursionDepth) || options.maxRecursionDepth < 1)) throw new RangeError("Invalid edit depth");
64238
64604
  const signal = options.signal ?? new AbortController().signal;
64239
64605
  const store = new PdfMutableObjectStore(storage, { ...options, signal });
64240
- const pages = new PagedStorage24({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
64606
+ const pages = new PagedStorage25({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
64241
64607
  const base = pages.allocate(0);
64242
64608
  let count = 0, document2;
64243
64609
  let closing;
@@ -64286,6 +64652,14 @@ async function editRetainedDocument(source, storage, options = {}) {
64286
64652
  ...options.maxRecursionDepth === void 0 ? {} : { maxRecursionDepth: options.maxRecursionDepth }
64287
64653
  };
64288
64654
  document2 = await PdfRetainedDocument.openStore(store, storage, { ...configured, ...infoRef ? { infoRef } : {} });
64655
+ if (options.infoUpdates) {
64656
+ const updated = await applyRetainedInfoUpdates(document2, store, storage, count, getPage, options.infoUpdates, signal, options.maxRecursionDepth);
64657
+ infoRef = updated.infoRef;
64658
+ if (updated.idArray) configured.idArray = updated.idArray;
64659
+ await document2.close();
64660
+ document2 = await PdfRetainedDocument.openStore(store, storage, { ...configured, ...infoRef ? { infoRef } : {} });
64661
+ addedObjects = true;
64662
+ }
64289
64663
  for await (const edit of options.rotations ?? []) {
64290
64664
  signal.throwIfAborted();
64291
64665
  if (!Number.isSafeInteger(edit.pageIndex) || edit.pageIndex < 0 || edit.pageIndex >= count) throw new RangeError("Page index out of bounds");
@@ -64348,13 +64722,17 @@ async function editRetainedDocument(source, storage, options = {}) {
64348
64722
  await setRetainedBookmarks(store, storage, source.crossReference.rootRef, count, reference, options.bookmarks, signal, options.maxRecursionDepth);
64349
64723
  addedObjects = true;
64350
64724
  }
64725
+ for await (const update of options.formUpdates ?? []) {
64726
+ await generateRetainedFormAppearances(document2, store, storage, signal, update);
64727
+ addedObjects = true;
64728
+ }
64351
64729
  if (options.generateAppearances && !options.removeAcroform) {
64352
64730
  await generateRetainedFormAppearances(document2, store, storage, signal);
64353
64731
  addedObjects = true;
64354
64732
  }
64355
64733
  if (options.removeInfo) {
64356
64734
  await removeRoot(["Metadata"]);
64357
- const found = await document2.lookup(source.crossReference.infoRef);
64735
+ const found = await document2.lookup(infoRef);
64358
64736
  if (found?.value.kind === "dict" && !found.stream && found.reference) {
64359
64737
  const date = dictGet(found.value, "ModDate");
64360
64738
  found.value.entries.length = 0;
@@ -64459,9 +64837,9 @@ async function* copyRetainedAttachments(document2, storage, options = {}) {
64459
64837
  }
64460
64838
 
64461
64839
  // packages/pdf-ast/src/cos/retained-object-order.ts
64462
- import { IntegerTable as IntegerTable14, PagedStorage as PagedStorage25 } from "@poe-platform/safe-fs/storage";
64840
+ import { IntegerTable as IntegerTable14, PagedStorage as PagedStorage26 } from "@poe-platform/safe-fs/storage";
64463
64841
  async function* retainedObjectOrder(document2, source, storage, signal) {
64464
- const backing = new PagedStorage25({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
64842
+ const backing = new PagedStorage26({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
64465
64843
  const seen = new IntegerTable14(backing), streams = new IntegerTable14(backing);
64466
64844
  let failed = false, work = 0;
64467
64845
  async function candidate(number) {
@@ -64598,12 +64976,12 @@ async function* encryptRetainedPdfChunks(source, storage, options = {}) {
64598
64976
  }
64599
64977
 
64600
64978
  // packages/pdf-ast/src/cos/qpdf-json-values.ts
64601
- import { IntegerTable as IntegerTable15, PagedStorage as PagedStorage26 } from "@poe-platform/safe-fs/storage";
64979
+ import { IntegerTable as IntegerTable15, PagedStorage as PagedStorage27 } from "@poe-platform/safe-fs/storage";
64602
64980
  var QpdfJsonValues = class _QpdfJsonValues {
64603
64981
  constructor(tree, storage, signal) {
64604
64982
  this.tree = tree;
64605
64983
  this.signal = signal;
64606
- this.scratch = new PagedStorage26({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
64984
+ this.scratch = new PagedStorage27({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
64607
64985
  this.first = new IntegerTable15(this.scratch, 64);
64608
64986
  this.next = new IntegerTable15(this.scratch, 64);
64609
64987
  }
@@ -64996,13 +65374,13 @@ var QpdfJsonValues = class _QpdfJsonValues {
64996
65374
  };
64997
65375
 
64998
65376
  // packages/pdf-ast/src/cos/qpdf-json-document.ts
64999
- import { IntegerTable as IntegerTable16, PagedStorage as PagedStorage27 } from "@poe-platform/safe-fs/storage";
65377
+ import { IntegerTable as IntegerTable16, PagedStorage as PagedStorage28 } from "@poe-platform/safe-fs/storage";
65000
65378
  var QpdfJsonDocument = class _QpdfJsonDocument {
65001
65379
  constructor(storage, options = {}) {
65002
65380
  this.storage = storage;
65003
65381
  this.signal = options.signal ? AbortSignal.any([options.signal, this.controller.signal]) : this.controller.signal;
65004
65382
  this.store = new PdfMutableObjectStore(storage, { signal: this.signal });
65005
- this.backing = new PagedStorage27(
65383
+ this.backing = new PagedStorage28(
65006
65384
  { fs: storage.fs, cwd: storage.directory, env: {}, signal: this.signal },
65007
65385
  4
65008
65386
  );
@@ -65071,7 +65449,7 @@ var QpdfJsonDocument = class _QpdfJsonDocument {
65071
65449
  env: {},
65072
65450
  signal: this.signal
65073
65451
  };
65074
- const tape = new PagedStorage27(context, 4), scratch = new PagedStorage27(context, 4);
65452
+ const tape = new PagedStorage28(context, 4), scratch = new PagedStorage28(context, 4);
65075
65453
  let values, failed = false, work = 0;
65076
65454
  const cooperate = async (units = 1) => {
65077
65455
  this.signal.throwIfAborted();
@@ -65292,6 +65670,382 @@ var QpdfJsonDocument = class _QpdfJsonDocument {
65292
65670
  })();
65293
65671
  }
65294
65672
  };
65673
+
65674
+ // packages/pdf-ast/src/edit/retained-form-data.ts
65675
+ import { IntegerTable as IntegerTable18, PagedStorage as PagedStorage30 } from "@poe-platform/safe-fs/storage";
65676
+
65677
+ // packages/pdf-ast/src/edit/retained-form-data-fdf.ts
65678
+ import { IntegerTable as IntegerTable17, PagedStorage as PagedStorage29 } from "@poe-platform/safe-fs/storage";
65679
+ async function parseRetainedFdf(source, storage, set, signal) {
65680
+ const backing = new PagedStorage29({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), tokens = new IntegerTable17(backing), starts = new IntegerTable17(backing), children = new IntegerTable17(backing), visited = new IntegerTable17(backing), names = new PdfNameIndex(storage, Infinity, signal);
65681
+ let count = 0, cursor = 0, head = -1, work = 0, failed = false;
65682
+ const cache = /* @__PURE__ */ new Map();
65683
+ async function checkpoint() {
65684
+ signal.throwIfAborted();
65685
+ if (++work % 128 === 0) {
65686
+ await new Promise((resolve2) => setTimeout(resolve2, 0));
65687
+ signal.throwIfAborted();
65688
+ }
65689
+ }
65690
+ async function token2(index2) {
65691
+ if (index2 < 0 || index2 >= count) return;
65692
+ const cached = cache.get(index2);
65693
+ if (cached) return cached;
65694
+ const at = Number(await tokens.get(BigInt(index2))) - 1, result = (await readStoredRecord(backing, at, signal)).value;
65695
+ if (cache.size >= 8) cache.delete(cache.keys().next().value);
65696
+ cache.set(index2, result);
65697
+ return result;
65698
+ }
65699
+ async function objectKey(object) {
65700
+ return BigInt((await names.intern(String(object))).index);
65701
+ }
65702
+ async function push(frame) {
65703
+ head = await appendStoredRecord(backing, { frame, previous: head }, -1, signal);
65704
+ }
65705
+ function dict(prefix) {
65706
+ return { kind: "dict", prefix, partial: "", value: "", hasValue: false, children: -1 };
65707
+ }
65708
+ function text(token3) {
65709
+ return token3.kind === "name" ? token3.decoded : token3.kind === "string" || token3.kind === "hex-string" ? decodePdfString({ kind: "string", bytes: token3.bytes, encoding: token3.kind === "string" ? "literal" : "hex" }) : "";
65710
+ }
65711
+ async function reference(index2) {
65712
+ const a = await token2(index2), b = await token2(index2 + 1), c = await token2(index2 + 2);
65713
+ return a?.kind === "number" && b?.kind === "number" && c?.kind === "keyword" && c.value === "R" ? a.value : void 0;
65714
+ }
65715
+ try {
65716
+ const lexer = new CosRangeLexer(source, { signal, compactNumbers: true });
65717
+ for (let next = await lexer.nextToken(); next; next = await lexer.nextToken()) {
65718
+ await checkpoint();
65719
+ const at = await appendStoredRecord(backing, next, -1, signal);
65720
+ await tokens.set(BigInt(count++), BigInt(at + 1));
65721
+ }
65722
+ for (let i = 0; i < count; i++) {
65723
+ await checkpoint();
65724
+ const a = await token2(i), b = await token2(i + 1), c = await token2(i + 2), d = await token2(i + 3);
65725
+ if (a?.kind === "number" && b?.kind === "number" && c?.kind === "keyword" && c.value === "obj" && d?.kind === "dict-start") await starts.set(await objectKey(a.value), BigInt(i + 5));
65726
+ if (a?.kind === "name" && a.decoded === "Kids" && b?.kind === "array-start") {
65727
+ let depth = 1;
65728
+ for (let k = i + 2; k < count && depth > 0; k++) {
65729
+ await checkpoint();
65730
+ const next = await token2(k);
65731
+ if (next?.kind === "array-start") depth++;
65732
+ else if (next?.kind === "array-end") depth--;
65733
+ else if (depth === 1) {
65734
+ const ref = await reference(k);
65735
+ if (ref !== void 0) {
65736
+ await children.set(await objectKey(ref), 1n);
65737
+ k += 2;
65738
+ }
65739
+ }
65740
+ }
65741
+ }
65742
+ }
65743
+ await push({ kind: "scan" });
65744
+ while (head !== -1) {
65745
+ await checkpoint();
65746
+ const record = await readStoredRecord(backing, head, signal);
65747
+ head = record.value.previous;
65748
+ const frame = record.value.frame;
65749
+ if (frame.kind === "restore") {
65750
+ cursor = frame.cursor;
65751
+ continue;
65752
+ }
65753
+ if (frame.kind === "ref") {
65754
+ const key = await objectKey(frame.object), start = await starts.get(key);
65755
+ if (start && !await visited.get(key)) {
65756
+ await visited.set(key, 1n);
65757
+ cursor = Number(start) - 1;
65758
+ await push(dict(frame.prefix));
65759
+ }
65760
+ continue;
65761
+ }
65762
+ if (frame.kind === "children") {
65763
+ let ref = frame.refs;
65764
+ while (ref !== -1) {
65765
+ const row = await readStoredRecord(backing, ref, signal);
65766
+ await push({ kind: "ref", object: row.value.object, prefix: frame.prefix });
65767
+ ref = row.value.previous;
65768
+ }
65769
+ cursor = frame.start;
65770
+ await push({ kind: "range", end: frame.end, prefix: frame.prefix });
65771
+ continue;
65772
+ }
65773
+ if (frame.kind === "scan" || frame.kind === "range") {
65774
+ const end = frame.kind === "range" ? frame.end : count;
65775
+ while (cursor < end) {
65776
+ await checkpoint();
65777
+ const a = await token2(cursor);
65778
+ if (frame.kind === "scan" && a?.kind === "number") {
65779
+ const b = await token2(cursor + 1), c = await token2(cursor + 2);
65780
+ if (b?.kind === "number" && c?.kind === "keyword" && c.value === "obj") {
65781
+ const key = await objectKey(a.value);
65782
+ if (await children.get(key) || await visited.get(key)) {
65783
+ cursor += 3;
65784
+ while (cursor < count) {
65785
+ await checkpoint();
65786
+ const t = await token2(cursor++);
65787
+ if (t?.kind === "keyword" && t.value === "endobj") break;
65788
+ }
65789
+ continue;
65790
+ }
65791
+ }
65792
+ }
65793
+ cursor++;
65794
+ if (a?.kind === "dict-start") {
65795
+ await push(frame);
65796
+ await push(dict(frame.kind === "range" ? frame.prefix : ""));
65797
+ break;
65798
+ }
65799
+ }
65800
+ continue;
65801
+ }
65802
+ let nested = false;
65803
+ while (cursor < count) {
65804
+ await checkpoint();
65805
+ const next = await token2(cursor++);
65806
+ if (next?.kind === "dict-end") break;
65807
+ if (next?.kind === "dict-start") {
65808
+ await push(frame);
65809
+ await push(dict(frame.prefix && frame.partial ? `${frame.prefix}.${frame.partial}` : frame.partial || frame.prefix));
65810
+ nested = true;
65811
+ break;
65812
+ }
65813
+ if (next?.kind !== "name") continue;
65814
+ const value = await token2(cursor);
65815
+ if (next.decoded === "T" && (value?.kind === "string" || value?.kind === "hex-string" || value?.kind === "name")) {
65816
+ frame.partial = text(value);
65817
+ cursor++;
65818
+ } else if (next.decoded === "V" && value) {
65819
+ if (value.kind === "string" || value.kind === "hex-string" || value.kind === "name") {
65820
+ const decoded = text(value);
65821
+ frame.value = value.kind === "name" ? decoded === "Off" ? false : decoded === "Yes" || decoded === "On" ? true : decoded : decoded;
65822
+ frame.hasValue = true;
65823
+ cursor++;
65824
+ } else if (value.kind === "number" || value.kind === "boolean") {
65825
+ frame.value = value.kind === "number" ? String(value.value) : value.value;
65826
+ frame.hasValue = true;
65827
+ cursor++;
65828
+ } else if (value.kind === "array-start") {
65829
+ cursor++;
65830
+ let depth = 1, joined = "", items = 0;
65831
+ while (cursor < count && depth > 0) {
65832
+ await checkpoint();
65833
+ const t = await token2(cursor++);
65834
+ if (t?.kind === "array-start") depth++;
65835
+ else if (t?.kind === "array-end") depth--;
65836
+ else if (depth === 1 && t && (t.kind === "string" || t.kind === "hex-string" || t.kind === "name")) {
65837
+ joined += (items++ ? "," : "") + text(t);
65838
+ }
65839
+ }
65840
+ frame.value = joined;
65841
+ frame.hasValue = true;
65842
+ }
65843
+ } else if ((next.decoded === "Kids" || next.decoded === "Fields") && value?.kind === "array-start") {
65844
+ cursor++;
65845
+ const start = cursor;
65846
+ let depth = 1, refs = -1;
65847
+ while (cursor < count && depth > 0) {
65848
+ await checkpoint();
65849
+ const t = await token2(cursor++);
65850
+ if (t?.kind === "array-start") depth++;
65851
+ else if (t?.kind === "array-end") depth--;
65852
+ else if (depth === 1) {
65853
+ const ref = await reference(cursor - 1);
65854
+ if (ref !== void 0) {
65855
+ refs = await appendStoredRecord(backing, { object: ref, previous: refs }, -1, signal);
65856
+ cursor += 2;
65857
+ }
65858
+ }
65859
+ }
65860
+ frame.children = await appendStoredRecord(backing, { start, end: cursor - 1, refs, previous: frame.children }, -1, signal);
65861
+ }
65862
+ }
65863
+ if (nested) continue;
65864
+ const name = frame.prefix && frame.partial ? `${frame.prefix}.${frame.partial}` : frame.partial || frame.prefix;
65865
+ if (name && frame.hasValue) await set(name, frame.value);
65866
+ if (frame.children !== -1) {
65867
+ await push({ kind: "restore", cursor });
65868
+ let child = frame.children;
65869
+ while (child !== -1) {
65870
+ const row = (await readStoredRecord(backing, child, signal)).value;
65871
+ await push({ kind: "children", start: row.start, end: row.end, refs: row.refs, prefix: name });
65872
+ child = row.previous;
65873
+ }
65874
+ }
65875
+ }
65876
+ } catch (error) {
65877
+ failed = true;
65878
+ throw error;
65879
+ } finally {
65880
+ const results = await Promise.allSettled([backing.close(), names.close()]);
65881
+ if (!failed) {
65882
+ for (const result of results) if (result.status === "rejected") await Promise.reject(result.reason);
65883
+ }
65884
+ }
65885
+ }
65886
+
65887
+ // packages/pdf-ast/src/edit/retained-form-data.ts
65888
+ var FormText = class {
65889
+ constructor(backing, signal) {
65890
+ this.backing = backing;
65891
+ this.signal = signal;
65892
+ this.base = backing.allocate(0);
65893
+ }
65894
+ backing;
65895
+ signal;
65896
+ length = 0;
65897
+ base;
65898
+ async load(source) {
65899
+ const decoder = new TextDecoder();
65900
+ const append = async (text) => {
65901
+ for (let start = 0; start < text.length; start += 4096) {
65902
+ this.signal.throwIfAborted();
65903
+ const length = Math.min(4096, text.length - start), bytes = new Uint8Array(length * 2), view = new DataView(bytes.buffer);
65904
+ for (let i = 0; i < length; i++) view.setUint16(i * 2, text.charCodeAt(start + i), true);
65905
+ await this.backing.write(this.backing.allocate(bytes.length), bytes);
65906
+ this.length += length;
65907
+ }
65908
+ };
65909
+ for await (const chunk of source.stream(0, source.size, this.signal)) await append(decoder.decode(chunk, { stream: true }));
65910
+ await append(decoder.decode());
65911
+ }
65912
+ async read(start, end) {
65913
+ let result = "";
65914
+ for (let at = start; at < end; at += 4096) {
65915
+ this.signal.throwIfAborted();
65916
+ const length = Math.min(4096, end - at), bytes = await this.backing.read(this.base + at * 2, length * 2), view = new DataView(bytes.buffer, bytes.byteOffset, bytes.length);
65917
+ const units = [];
65918
+ for (let i = 0; i < length; i++) units.push(view.getUint16(i * 2, true));
65919
+ result += String.fromCharCode(...units);
65920
+ }
65921
+ return result;
65922
+ }
65923
+ async indexOf(needle, start = 0) {
65924
+ for (let at = start; at < this.length; at += 4096) {
65925
+ const part = await this.read(at, Math.min(this.length, at + 4096 + needle.length - 1)), index2 = part.indexOf(needle);
65926
+ if (index2 >= 0) return at + index2;
65927
+ }
65928
+ return -1;
65929
+ }
65930
+ async prefix() {
65931
+ for (let at = 0; at < this.length; at += 4096) {
65932
+ const part = await this.read(at, Math.min(this.length, at + 4096)), trimmed = part.trimStart();
65933
+ if (trimmed) return this.read(at + part.length - trimmed.length, Math.min(this.length, at + part.length - trimmed.length + 5));
65934
+ }
65935
+ return "";
65936
+ }
65937
+ };
65938
+ async function* parseRetainedFormData(source, storage, options = {}) {
65939
+ const signal = options.signal ?? new AbortController().signal, context = { fs: storage.fs, cwd: storage.directory, env: {}, signal };
65940
+ const textBacking = new PagedStorage30(context, 2), state = new PagedStorage30(context, 4), names = new PdfNameIndex(storage, Infinity, signal), values = new IntegerTable18(state);
65941
+ const text = new FormText(textBacking, signal);
65942
+ let count = 0, failed = false, work = 0;
65943
+ async function checkpoint() {
65944
+ signal.throwIfAborted();
65945
+ if (++work % 64 === 0) {
65946
+ await new Promise((resolve2) => setTimeout(resolve2, 0));
65947
+ signal.throwIfAborted();
65948
+ }
65949
+ }
65950
+ async function set(name, value, append = false) {
65951
+ await checkpoint();
65952
+ const key = await names.intern(name), at = await values.get(BigInt(key.index));
65953
+ if (key.added) count++;
65954
+ if (append && typeof value === "string" && at) {
65955
+ const previous = (await readStoredRecord(state, Number(at) - 1, signal)).value.value;
65956
+ if (typeof previous === "string" && previous.length) value = `${previous},${value}`;
65957
+ }
65958
+ const offset = await appendStoredRecord(state, { name, value }, -1, signal);
65959
+ await values.set(BigInt(key.index), BigInt(offset + 1));
65960
+ }
65961
+ try {
65962
+ await text.load(source);
65963
+ const prefix = await text.prefix();
65964
+ if (prefix === "%FDF-" || await text.indexOf("/FDF") >= 0 && await text.indexOf("/Fields") >= 0) await parseRetainedFdf(source, storage, set, signal);
65965
+ else if (prefix === "<?xml" || prefix === "<xfdf" || await text.indexOf("<fields") >= 0) {
65966
+ let position = 0, head = -1, field2 = "";
65967
+ while (position < text.length) {
65968
+ await checkpoint();
65969
+ const lt = await text.indexOf("<", position);
65970
+ if (lt < 0) break;
65971
+ const gt = await text.indexOf(">", lt + 1);
65972
+ if (gt < 0) break;
65973
+ const raw = (await text.read(lt + 1, gt)).trim();
65974
+ position = gt + 1;
65975
+ if (raw.startsWith("?") || raw.startsWith("!")) continue;
65976
+ if (raw.startsWith("/")) {
65977
+ if (raw.slice(1).trim().toLowerCase() === "field" && head !== -1) {
65978
+ const row = (await readStoredRecord(state, head, signal)).value;
65979
+ field2 = row.field;
65980
+ head = row.previous;
65981
+ }
65982
+ continue;
65983
+ }
65984
+ const selfClosing = raw.endsWith("/"), tag = selfClosing ? raw.slice(0, -1).trim() : raw, space = tag.indexOf(" "), name = (space < 0 ? tag : tag.slice(0, space)).toLowerCase();
65985
+ if (name === "field") {
65986
+ let part = "";
65987
+ const at = tag.indexOf("name=");
65988
+ if (at >= 0) {
65989
+ const quote = tag[at + 5];
65990
+ if (quote === '"' || quote === "'") {
65991
+ const end = tag.indexOf(quote, at + 6);
65992
+ if (end >= 0) part = decodeFormDataEntities(tag.slice(at + 6, end));
65993
+ }
65994
+ }
65995
+ if (!selfClosing) {
65996
+ head = await appendStoredRecord(state, { field: field2, previous: head }, -1, signal);
65997
+ field2 = field2 && part ? `${field2}.${part}` : field2 || part;
65998
+ }
65999
+ } else if (name === "value" && !selfClosing && head !== -1) {
66000
+ const close = await text.indexOf("</value>", position);
66001
+ if (close >= 0) {
66002
+ const value = decodeFormDataEntities(await text.read(position, close));
66003
+ if (field2) await set(field2, value === "Off" ? false : value === "Yes" || value === "On" ? true : value, true);
66004
+ position = close + 8;
66005
+ }
66006
+ }
66007
+ }
66008
+ } else {
66009
+ const report = await text.indexOf("FieldName:") >= 0;
66010
+ let position = 0, name = "", type = "";
66011
+ while (position < text.length) {
66012
+ await checkpoint();
66013
+ const newline = await text.indexOf("\n", position), end = newline < 0 ? text.length : newline, line = (await text.read(position, end)).trim();
66014
+ position = end + 1;
66015
+ if (report) {
66016
+ if (line === "---") {
66017
+ name = "";
66018
+ type = "";
66019
+ } else if (line.startsWith("FieldType:")) type = line.slice(10).trim();
66020
+ else if (line.startsWith("FieldName:")) name = decodeFormDataEntities(line.slice(10).trim());
66021
+ else if (line.startsWith("FieldValue:") && name) {
66022
+ const value = decodeFormDataEntities(line.slice(11).trim());
66023
+ await set(name, value === "Yes" || value === "On" ? true : value === "Off" || value === "false" || type === "Button" && value === "" ? false : value, true);
66024
+ }
66025
+ } else {
66026
+ if (!line || line.startsWith("#")) continue;
66027
+ const equals = line.indexOf("="), colon = line.indexOf(":"), separator = equals >= 0 ? equals : colon;
66028
+ if (separator > 0) {
66029
+ const name2 = line.slice(0, separator).trim(), value = line.slice(separator + 1).trim();
66030
+ await set(name2, value === "true" || value === "Yes" || value === "On" ? true : value === "false" || value === "Off" ? false : value);
66031
+ }
66032
+ }
66033
+ }
66034
+ }
66035
+ for (let index2 = 0; index2 < count; index2++) {
66036
+ await checkpoint();
66037
+ yield (await readStoredRecord(state, Number(await values.get(BigInt(index2))) - 1, signal)).value;
66038
+ }
66039
+ } catch (error) {
66040
+ failed = true;
66041
+ throw error;
66042
+ } finally {
66043
+ const results = await Promise.allSettled([textBacking.close(), state.close(), names.close()]);
66044
+ if (!failed) {
66045
+ for (const result of results) if (result.status === "rejected") await Promise.reject(result.reason);
66046
+ }
66047
+ }
66048
+ }
65295
66049
  export {
65296
66050
  CosByteLexer,
65297
66051
  CosRangeLexer,
@@ -65357,6 +66111,7 @@ export {
65357
66111
  decodeCcittFax,
65358
66112
  decodeCcittFaxChunks,
65359
66113
  decodeFlate,
66114
+ decodeFormDataEntities,
65360
66115
  decodeInlineImageNodeToRgba,
65361
66116
  decodeInlineImageNodeToRgbaSteps,
65362
66117
  decodeJbig2ToRgba,
@@ -65480,6 +66235,7 @@ export {
65480
66235
  parseCosRangeObject,
65481
66236
  parseCosRangeValue,
65482
66237
  parseFormDataBytes,
66238
+ parseRetainedFormData,
65483
66239
  parseToUnicodeCMap,
65484
66240
  parseToUnicodeCMapSteps,
65485
66241
  parseTrueTypeFont,