@rubytech/create-maxy-code 0.1.500 → 0.1.501

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 (184) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/lib/graph-style/dist/index.d.ts +9 -0
  3. package/payload/platform/lib/graph-style/dist/index.d.ts.map +1 -1
  4. package/payload/platform/lib/graph-style/dist/index.js +152 -6
  5. package/payload/platform/lib/graph-style/dist/index.js.map +1 -1
  6. package/payload/platform/lib/graph-style/src/__tests__/caption-coverage.test.ts +69 -0
  7. package/payload/platform/lib/graph-style/src/__tests__/coverage-source.ts +73 -0
  8. package/payload/platform/lib/graph-style/src/__tests__/icons.test.ts +20 -3
  9. package/payload/platform/lib/graph-style/src/index.ts +166 -5
  10. package/payload/platform/plugins/admin/PLUGIN.md +1 -0
  11. package/payload/platform/plugins/admin/skills/agent-builder/SKILL.md +15 -0
  12. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +51 -1
  13. package/payload/platform/plugins/admin/skills/summarise/SKILL.md +37 -0
  14. package/payload/platform/plugins/docs/references/admin-ui.md +50 -0
  15. package/payload/platform/plugins/docs/references/summarise-skill.md +7 -0
  16. package/payload/server/public/activity.html +6 -6
  17. package/payload/server/public/assets/{AdminLoginScreens-CKg_Dlpv.js → AdminLoginScreens-C3LZOPIY.js} +1 -1
  18. package/payload/server/public/assets/AdminShell-BlbUNAPc.js +2 -0
  19. package/payload/server/public/assets/{activity-CKUYOLd2.js → activity-CVdVSw5V.js} +1 -1
  20. package/payload/server/public/assets/admin-If1QLlS3.js +1 -0
  21. package/payload/server/public/assets/{arc-CpWWSum8.js → arc-CvlzUHOf.js} +1 -1
  22. package/payload/server/public/assets/architecture-YZFGNWBL-BQc779DH.js +1 -0
  23. package/payload/server/public/assets/{architectureDiagram-Q4EWVU46-D2EzaII0.js → architectureDiagram-Q4EWVU46-I1Hs0RJA.js} +1 -1
  24. package/payload/server/public/assets/{blockDiagram-DXYQGD6D-8kDpaNSZ.js → blockDiagram-DXYQGD6D-Df5jTGtl.js} +1 -1
  25. package/payload/server/public/assets/{bot-DESMpxSQ.js → bot-8b26IlQY.js} +1 -1
  26. package/payload/server/public/assets/{browser-CpLq_DIo.js → browser-F40DXfKA.js} +1 -1
  27. package/payload/server/public/assets/{c4Diagram-AHTNJAMY-CbwmZpK3.js → c4Diagram-AHTNJAMY-B6WY5IDv.js} +1 -1
  28. package/payload/server/public/assets/{calendar-ClOwyuz-.js → calendar-DZiHiBwV.js} +1 -1
  29. package/payload/server/public/assets/channel-AqnC3SHu.js +1 -0
  30. package/payload/server/public/assets/chat-uD28FVCS.js +1 -0
  31. package/payload/server/public/assets/chevron-left-lBxD57tD.js +1 -0
  32. package/payload/server/public/assets/chevron-right-C-lDig9Y.js +1 -0
  33. package/payload/server/public/assets/{chunk-2KRD3SAO-PFheZ9mw.js → chunk-2KRD3SAO-BsIIFDkc.js} +1 -1
  34. package/payload/server/public/assets/{chunk-336JU56O-CCFOp5VK.js → chunk-336JU56O-j9z1VtyC.js} +2 -2
  35. package/payload/server/public/assets/chunk-426QAEUC-CO02gU5d.js +1 -0
  36. package/payload/server/public/assets/{chunk-4BX2VUAB-Hz4JWOf2.js → chunk-4BX2VUAB-C9i7prxq.js} +1 -1
  37. package/payload/server/public/assets/{chunk-4TB4RGXK-4xeV0s85.js → chunk-4TB4RGXK-DH0QVGcv.js} +1 -1
  38. package/payload/server/public/assets/{chunk-55IACEB6-4QKgBpoh.js → chunk-55IACEB6-Dnd_YCPA.js} +1 -1
  39. package/payload/server/public/assets/{chunk-5FUZZQ4R-ms3K6Z5z.js → chunk-5FUZZQ4R-D5sSz3yN.js} +1 -1
  40. package/payload/server/public/assets/{chunk-5PVQY5BW-CIC4GIGi.js → chunk-5PVQY5BW-CJrwWjAT.js} +1 -1
  41. package/payload/server/public/assets/{chunk-67CJDMHE-B-XrWVmV.js → chunk-67CJDMHE-SjP6_hUw.js} +1 -1
  42. package/payload/server/public/assets/{chunk-7N4EOEYR-C7ECOUYQ.js → chunk-7N4EOEYR-fAuhVJD0.js} +1 -1
  43. package/payload/server/public/assets/{chunk-AA7GKIK3-DOZ6Fxwk.js → chunk-AA7GKIK3-DZxa7KVg.js} +1 -1
  44. package/payload/server/public/assets/{chunk-BSJP7CBP-4cJ_b0c6.js → chunk-BSJP7CBP-DjeG3eQ-.js} +1 -1
  45. package/payload/server/public/assets/{chunk-CIAEETIT--mhZipWM.js → chunk-CIAEETIT-RYQULNJm.js} +1 -1
  46. package/payload/server/public/assets/{chunk-EDXVE4YY-jZpVwob_.js → chunk-EDXVE4YY-Cahapnon.js} +1 -1
  47. package/payload/server/public/assets/{chunk-ENJZ2VHE-Nn-p-xIA.js → chunk-ENJZ2VHE-1146X1L4.js} +1 -1
  48. package/payload/server/public/assets/{chunk-FMBD7UC4-DyNpcKOS.js → chunk-FMBD7UC4-BCFumtcP.js} +1 -1
  49. package/payload/server/public/assets/{chunk-FOC6F5B3-C0P8q1uz.js → chunk-FOC6F5B3-CkrtX8Zt.js} +1 -1
  50. package/payload/server/public/assets/{chunk-ICPOFSXX-CdXQ5SfI.js → chunk-ICPOFSXX-Ba1y3DaW.js} +2 -2
  51. package/payload/server/public/assets/{chunk-K5T4RW27-BVZJKKsT.js → chunk-K5T4RW27-CF-PI3uQ.js} +1 -1
  52. package/payload/server/public/assets/{chunk-KGLVRYIC-QlVWTe0V.js → chunk-KGLVRYIC-SFFC6ZC-.js} +1 -1
  53. package/payload/server/public/assets/{chunk-LIHQZDEY-CpGVZutP.js → chunk-LIHQZDEY-DbOLEP4R.js} +1 -1
  54. package/payload/server/public/assets/{chunk-ORNJ4GCN-WVcS6fUC.js → chunk-ORNJ4GCN-VB963bkN.js} +1 -1
  55. package/payload/server/public/assets/{chunk-OYMX7WX6-B7hiSTed.js → chunk-OYMX7WX6-DWYY1pQa.js} +1 -1
  56. package/payload/server/public/assets/chunk-QZHKN3VN-BiFMbK8t.js +1 -0
  57. package/payload/server/public/assets/{chunk-U2HBQHQK-DJPnZxGy.js → chunk-U2HBQHQK-DAH1diYP.js} +1 -1
  58. package/payload/server/public/assets/{chunk-X2U36JSP-DilBs1Yc.js → chunk-X2U36JSP-Dmw9coXz.js} +1 -1
  59. package/payload/server/public/assets/{chunk-XPW4576I-B5-uyrJ0.js → chunk-XPW4576I-DaAUON1-.js} +1 -1
  60. package/payload/server/public/assets/{chunk-YZCP3GAM-BNO4z0Mv.js → chunk-YZCP3GAM-BUcfkEef.js} +1 -1
  61. package/payload/server/public/assets/{chunk-ZZ45TVLE-BzHMQpip.js → chunk-ZZ45TVLE-BLD-vFRO.js} +1 -1
  62. package/payload/server/public/assets/classDiagram-6PBFFD2Q-BdRqzScB.js +1 -0
  63. package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-ChPLgHbS.js +1 -0
  64. package/payload/server/public/assets/clock-DqRNsY40.js +1 -0
  65. package/payload/server/public/assets/clone-TKtrjWBC.js +1 -0
  66. package/payload/server/public/assets/{cose-bilkent-S5V4N54A-3DWYmn1o.js → cose-bilkent-S5V4N54A-CoZX0uki.js} +1 -1
  67. package/payload/server/public/assets/{dagre-Cpy31xJW.js → dagre-Bmjs8zJA.js} +1 -1
  68. package/payload/server/public/assets/{dagre-KV5264BT-C8fyxHFd.js → dagre-KV5264BT-BZCP2wnq.js} +1 -1
  69. package/payload/server/public/assets/data-BsFyBN85.js +1 -0
  70. package/payload/server/public/assets/{diagram-5BDNPKRD-ycyhnLvr.js → diagram-5BDNPKRD-8Nt9a4xX.js} +1 -1
  71. package/payload/server/public/assets/{diagram-G4DWMVQ6-BkeYicIt.js → diagram-G4DWMVQ6-vh5tcYqJ.js} +1 -1
  72. package/payload/server/public/assets/{diagram-MMDJMWI5-BcGZU-Q3.js → diagram-MMDJMWI5-DGf--jc8.js} +1 -1
  73. package/payload/server/public/assets/{diagram-TYMM5635-DuBDCFb_.js → diagram-TYMM5635-CsO7TIdw.js} +1 -1
  74. package/payload/server/public/assets/{dist-BYc_arNy.js → dist-cdnE4DqK.js} +1 -1
  75. package/payload/server/public/assets/{erDiagram-SMLLAGMA-DmkeOzvp.js → erDiagram-SMLLAGMA-4a78yV8_.js} +1 -1
  76. package/payload/server/public/assets/file-text-B1HjPFbM.js +1 -0
  77. package/payload/server/public/assets/{flatten-QjnJ1Gcl.js → flatten-BtIc9jX7.js} +1 -1
  78. package/payload/server/public/assets/{flowDiagram-DWJPFMVM-CkE-pjuB.js → flowDiagram-DWJPFMVM-BoQBXs6t.js} +1 -1
  79. package/payload/server/public/assets/{ganttDiagram-T4ZO3ILL-Cjiy3kvE.js → ganttDiagram-T4ZO3ILL-CvzqwCC8.js} +1 -1
  80. package/payload/server/public/assets/gitGraph-7Q5UKJZL-DfcaTE9L.js +1 -0
  81. package/payload/server/public/assets/{gitGraphDiagram-UUTBAWPF-CsI4lKZm.js → gitGraphDiagram-UUTBAWPF-D_nBxay_.js} +1 -1
  82. package/payload/server/public/assets/graph-CIC-mgKR.js +51 -0
  83. package/payload/server/public/assets/graph-labels-BnpHCHaQ.js +1 -0
  84. package/payload/server/public/assets/{graphlib-BkXxC6D5.js → graphlib-D0NdsKJI.js} +1 -1
  85. package/payload/server/public/assets/info-OMHHGYJF-CD-u6gw9.js +1 -0
  86. package/payload/server/public/assets/infoDiagram-42DDH7IO-C6gPQCvO.js +2 -0
  87. package/payload/server/public/assets/{isEmpty-BavJI9Cn.js → isEmpty-Bu4fZ8Kf.js} +1 -1
  88. package/payload/server/public/assets/{ishikawaDiagram-UXIWVN3A-D8lZtjRc.js → ishikawaDiagram-UXIWVN3A-auW-s0i0.js} +1 -1
  89. package/payload/server/public/assets/{journeyDiagram-VCZTEJTY-kLE7SiR_.js → journeyDiagram-VCZTEJTY-3Q6AWK4A.js} +1 -1
  90. package/payload/server/public/assets/{kanban-definition-6JOO6SKY-ove6JuD3.js → kanban-definition-6JOO6SKY-B4MPFp98.js} +1 -1
  91. package/payload/server/public/assets/{line-CZMSoxM6.js → line-26MdeG5Z.js} +1 -1
  92. package/payload/server/public/assets/{linear-Be8IK9hK.js → linear-Dq9s_bDO.js} +1 -1
  93. package/payload/server/public/assets/{maximize-2-BbzPm7o8.js → maximize-2-BL7QVTcQ.js} +1 -1
  94. package/payload/server/public/assets/{mermaid-parser.core-BBADqbnp.js → mermaid-parser.core-vLEpOXgf.js} +2 -2
  95. package/payload/server/public/assets/{mermaid.core-mH3N7K0I.js → mermaid.core-Durk4m6D.js} +3 -3
  96. package/payload/server/public/assets/{mindmap-definition-QFDTVHPH-BjwwwWil.js → mindmap-definition-QFDTVHPH-DOIg-TyG.js} +1 -1
  97. package/payload/server/public/assets/{operator-DglDYmdV.js → operator-B62h_TaC.js} +1 -1
  98. package/payload/server/public/assets/{ordinal-BHeIKG-K.js → ordinal-C2TEWKNu.js} +1 -1
  99. package/payload/server/public/assets/packet-4T2RLAQJ-BaLYeIrU.js +1 -0
  100. package/payload/server/public/assets/page-BUUBseJZ.js +32 -0
  101. package/payload/server/public/assets/page-Bw-tYjw7.js +1 -0
  102. package/payload/server/public/assets/{pdf-render-fJz4vym9.js → pdf-render-C257cidb.js} +1 -1
  103. package/payload/server/public/assets/pie-ZZUOXDRM-CL-XJtk-.js +1 -0
  104. package/payload/server/public/assets/{pieDiagram-DEJITSTG-D-lXWWta.js → pieDiagram-DEJITSTG-DtgBHZfi.js} +1 -1
  105. package/payload/server/public/assets/{public-DqJjXR4p.js → public-BI21tOkm.js} +1 -1
  106. package/payload/server/public/assets/{quadrantDiagram-34T5L4WZ-13QyG_AO.js → quadrantDiagram-34T5L4WZ-BTc5Qn2y.js} +1 -1
  107. package/payload/server/public/assets/radar-PYXPWWZC-Cn-g6F_h.js +1 -0
  108. package/payload/server/public/assets/{reduce-Fm685to3.js → reduce-BGpN5lgn.js} +1 -1
  109. package/payload/server/public/assets/{requirementDiagram-MS252O5E-Bx45Bgn4.js → requirementDiagram-MS252O5E-BNgOO5YW.js} +1 -1
  110. package/payload/server/public/assets/{rotate-ccw-L42fL8ey.js → rotate-ccw-C_20Bc3E.js} +1 -1
  111. package/payload/server/public/assets/routines-Ci3N8wqV.js +1 -0
  112. package/payload/server/public/assets/{sankeyDiagram-XADWPNL6-Cj-Gq25v.js → sankeyDiagram-XADWPNL6-MyUATmVt.js} +1 -1
  113. package/payload/server/public/assets/{sequenceDiagram-FGHM5R23-B8RDRq93.js → sequenceDiagram-FGHM5R23-CBJrF5Vi.js} +1 -1
  114. package/payload/server/public/assets/skills-CiflzOko.js +1 -0
  115. package/payload/server/public/assets/{src-D3VYuW_Z.js → src-DekKlUCp.js} +1 -1
  116. package/payload/server/public/assets/{stateDiagram-FHFEXIEX-DoyFF1Kl.js → stateDiagram-FHFEXIEX-6wbUjn1Q.js} +1 -1
  117. package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-BdMdfBeC.js +1 -0
  118. package/payload/server/public/assets/{tasks-GNtvZL8F.js → tasks-DC2Yf2Ev.js} +1 -1
  119. package/payload/server/public/assets/{time-entry-format-BreNpFLJ.js → time-entry-format-CNcjs2HV.js} +1 -1
  120. package/payload/server/public/assets/{timeline-definition-GMOUNBTQ-Df4RQXm6.js → timeline-definition-GMOUNBTQ-BHjTMCGY.js} +1 -1
  121. package/payload/server/public/assets/treeView-SZITEDCU-CmZoOGlC.js +1 -0
  122. package/payload/server/public/assets/treemap-W4RFUUIX-H27WFS-y.js +1 -0
  123. package/payload/server/public/assets/{triangle-alert-DumCWC08.js → triangle-alert-CngnWtjD.js} +1 -1
  124. package/payload/server/public/assets/{useCopyFeedback-DHCtz8qX.js → useCopyFeedback-DZ9Bw5CI.js} +1 -1
  125. package/payload/server/public/assets/{useSubAccountSwitcher-Bc7XHr0L.js → useSubAccountSwitcher-CHwQhkaI.js} +1 -1
  126. package/payload/server/public/assets/{useSubAccountSwitcher-DPHQJO7E.css → useSubAccountSwitcher-yFQqnpQ8.css} +1 -1
  127. package/payload/server/public/assets/useVoiceRecorder-C3G6aqZr.js +2 -0
  128. package/payload/server/public/assets/{vennDiagram-DHZGUBPP-D2o5og9l.js → vennDiagram-DHZGUBPP-yo3-cf0U.js} +1 -1
  129. package/payload/server/public/assets/wardley-RL74JXVD-DNpWIvU4.js +1 -0
  130. package/payload/server/public/assets/{wardleyDiagram-NUSXRM2D-BDueObbS.js → wardleyDiagram-NUSXRM2D-DZlyFzrg.js} +1 -1
  131. package/payload/server/public/assets/{wrench-iWkROE1V.js → wrench-dky2-13x.js} +1 -1
  132. package/payload/server/public/assets/{xychartDiagram-5P7HB3ND-BTYs4Fgh.js → xychartDiagram-5P7HB3ND-B5HV5h80.js} +1 -1
  133. package/payload/server/public/browser.html +5 -5
  134. package/payload/server/public/calendar.html +8 -8
  135. package/payload/server/public/chat.html +16 -15
  136. package/payload/server/public/data.html +13 -12
  137. package/payload/server/public/graph.html +10 -10
  138. package/payload/server/public/index.html +17 -16
  139. package/payload/server/public/operator.html +17 -16
  140. package/payload/server/public/public.html +16 -15
  141. package/payload/server/public/routines.html +7 -7
  142. package/payload/server/public/skills.html +19 -0
  143. package/payload/server/public/tasks.html +7 -7
  144. package/payload/server/server.js +672 -396
  145. package/payload/server/public/assets/AdminShell-BFVVkWFC.js +0 -2
  146. package/payload/server/public/assets/admin-wtSUU5N0.js +0 -1
  147. package/payload/server/public/assets/architecture-YZFGNWBL-D-AX2VuA.js +0 -1
  148. package/payload/server/public/assets/channel-DZ5sh6YQ.js +0 -1
  149. package/payload/server/public/assets/chat-DRuIxGtE.js +0 -1
  150. package/payload/server/public/assets/chevron-left-BzIg4in6.js +0 -1
  151. package/payload/server/public/assets/chevron-right-BcFSa9C3.js +0 -1
  152. package/payload/server/public/assets/chunk-426QAEUC-CcjBLp4a.js +0 -1
  153. package/payload/server/public/assets/chunk-QZHKN3VN-B2WjDYBE.js +0 -1
  154. package/payload/server/public/assets/classDiagram-6PBFFD2Q-CT3jNrze.js +0 -1
  155. package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-DJRsjAkC.js +0 -1
  156. package/payload/server/public/assets/clock-Dr3NGtjR.js +0 -1
  157. package/payload/server/public/assets/clone-FcEDnoMT.js +0 -1
  158. package/payload/server/public/assets/data-BdZCvyvN.js +0 -1
  159. package/payload/server/public/assets/gitGraph-7Q5UKJZL-D1uhnP9U.js +0 -1
  160. package/payload/server/public/assets/graph-B7niLM97.js +0 -51
  161. package/payload/server/public/assets/graph-labels-DykmXYHA.js +0 -1
  162. package/payload/server/public/assets/info-OMHHGYJF-oNm27GAV.js +0 -1
  163. package/payload/server/public/assets/infoDiagram-42DDH7IO-LxTftqyS.js +0 -2
  164. package/payload/server/public/assets/packet-4T2RLAQJ-eQNVGiK3.js +0 -1
  165. package/payload/server/public/assets/page-C-5sTAE-.js +0 -32
  166. package/payload/server/public/assets/page-C8G5p4jr.js +0 -1
  167. package/payload/server/public/assets/pie-ZZUOXDRM-E1u-48rt.js +0 -1
  168. package/payload/server/public/assets/radar-PYXPWWZC-Cn2cGN90.js +0 -1
  169. package/payload/server/public/assets/routines-JOV6xdYh.js +0 -1
  170. package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-Bml-X4-H.js +0 -1
  171. package/payload/server/public/assets/treeView-SZITEDCU-CimabhXy.js +0 -1
  172. package/payload/server/public/assets/treemap-W4RFUUIX-Cg264rpM.js +0 -1
  173. package/payload/server/public/assets/useVoiceRecorder-Cj-VZDKO.js +0 -2
  174. package/payload/server/public/assets/wardley-RL74JXVD-tbgfCg0E.js +0 -1
  175. /package/payload/server/public/assets/{_baseFor-Bvwvhrz4.js → _baseFor-Be3EKK3K.js} +0 -0
  176. /package/payload/server/public/assets/{array-D3d-WgFW.js → array-X0JlPOfd.js} +0 -0
  177. /package/payload/server/public/assets/{chunk-fQC6bEKA.js → chunk-CCr-iYLO.js} +0 -0
  178. /package/payload/server/public/assets/{cytoscape.esm-Cun-OM6a.js → cytoscape.esm-CI2IWMLB.js} +0 -0
  179. /package/payload/server/public/assets/{defaultLocale-CisKV5Ew.js → defaultLocale-B6RGN4id.js} +0 -0
  180. /package/payload/server/public/assets/{init-D9ZOVaZ3.js → init-BmUWJJHz.js} +0 -0
  181. /package/payload/server/public/assets/{katex-C-3ZDK8o.js → katex-BjZuzSQn.js} +0 -0
  182. /package/payload/server/public/assets/{path-BMOgQSLM.js → path-CoPyR7c2.js} +0 -0
  183. /package/payload/server/public/assets/{preload-helper-DL2DwvxV.js → preload-helper-BQrMkyGX.js} +0 -0
  184. /package/payload/server/public/assets/{rough.esm-BrTFrov0.js → rough.esm-jSt7UMyi.js} +0 -0
@@ -1,4 +1,4 @@
1
- import{t as e}from"./preload-helper-DL2DwvxV.js";var t={};t.d=(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n=globalThis.pdfjsLib={};t.d(n,{AbortException:()=>I,AnnotationEditorLayer:()=>Zr,AnnotationEditorParamsType:()=>f,AnnotationEditorType:()=>d,AnnotationEditorUIManager:()=>Be,AnnotationLayer:()=>Nr,AnnotationMode:()=>l,ColorPicker:()=>Hr,DOMSVGFactory:()=>tr,DrawLayer:()=>Qr,FeatureTest:()=>L,GlobalWorkerOptions:()=>Wt,ImageKind:()=>h,InvalidPDFException:()=>P,MissingPDFException:()=>F,OPS:()=>y,OutputScale:()=>je,PDFDataRangeTransport:()=>zn,PDFDateString:()=>Ee,PDFWorker:()=>Un,PasswordResponses:()=>b,PermissionFlag:()=>p,PixelsPerInch:()=>ge,RenderingCancelledException:()=>ye,TextLayer:()=>Tn,TouchManager:()=>He,UnexpectedResponseException:()=>ee,Util:()=>R,VerbosityLevel:()=>v,XfaLayer:()=>nr,build:()=>Xn,createValidAbsoluteUrl:()=>k,fetchData:()=>_e,getDocument:()=>Pn,getFilenameFromUrl:()=>Se,getPdfFilenameFromUrl:()=>Ce,getXfaPageViewport:()=>De,isDataScheme:()=>be,isPdfFile:()=>xe,noContextMenu:()=>B,normalizeUnicode:()=>fe,setLayerDimensions:()=>Ae,shadow:()=>A,stopEvent:()=>V,version:()=>Yn});var r=typeof process==`object`&&process+``==`[object process]`&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!==`browser`),i=[1,0,0,1,0,0],a=[.001,0,0,.001,0,0],o=1e7,s=1.35;.35/s;var c={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},l={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},u=`pdfjs_internal_editor_`,d={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},f={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},p={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},m={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},h={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},g={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},_={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},v={ERRORS:0,WARNINGS:1,INFOS:5},y={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},b={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},x=v.WARNINGS;function S(e){Number.isInteger(e)&&(x=e)}function C(){return x}function w(e){x>=v.INFOS&&console.log(`Info: ${e}`)}function T(e){x>=v.WARNINGS&&console.log(`Warning: ${e}`)}function E(e){throw Error(e)}function D(e,t){e||E(t)}function O(e){switch(e?.protocol){case`http:`:case`https:`:case`ftp:`:case`mailto:`:case`tel:`:return!0;default:return!1}}function k(e,t=null,n=null){if(!e)return null;try{if(n&&typeof e==`string`&&(n.addDefaultProtocol&&e.startsWith(`www.`)&&e.match(/\./g)?.length>=2&&(e=`http://${e}`),n.tryConvertEncoding))try{e=le(e)}catch{}let r=t?new URL(e,t):new URL(e);if(O(r))return r}catch{}return null}function A(e,t,n,r=!1){return Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}var j=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=Error(),e.constructor=e,e}(),M=class extends j{constructor(e,t){super(e,`PasswordException`),this.code=t}},N=class extends j{constructor(e,t){super(e,`UnknownErrorException`),this.details=t}},P=class extends j{constructor(e){super(e,`InvalidPDFException`)}},F=class extends j{constructor(e){super(e,`MissingPDFException`)}},ee=class extends j{constructor(e,t){super(e,`UnexpectedResponseException`),this.status=t}},te=class extends j{constructor(e){super(e,`FormatError`)}},I=class extends j{constructor(e){super(e,`AbortException`)}};function ne(e){(typeof e!=`object`||e?.length===void 0)&&E(`Invalid argument for bytesToString`);let t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);let r=[];for(let i=0;i<t;i+=n){let a=Math.min(i+n,t),o=e.subarray(i,a);r.push(String.fromCharCode.apply(null,o))}return r.join(``)}function re(e){typeof e!=`string`&&E(`Invalid argument for stringToBytes`);let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r)&255;return n}function ie(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255)}function ae(e){let t=Object.create(null);for(let[n,r]of e)t[n]=r;return t}function oe(){let e=new Uint8Array(4);return e[0]=1,new Uint32Array(e.buffer,0,1)[0]===1}function se(){try{return Function(``),!0}catch{return!1}}var L=class{static get isLittleEndian(){return A(this,`isLittleEndian`,oe())}static get isEvalSupported(){return A(this,`isEvalSupported`,se())}static get isOffscreenCanvasSupported(){return A(this,`isOffscreenCanvasSupported`,typeof OffscreenCanvas<`u`)}static get isImageDecoderSupported(){return A(this,`isImageDecoderSupported`,typeof ImageDecoder<`u`)}static get platform(){return typeof navigator<`u`&&typeof navigator?.platform==`string`?A(this,`platform`,{isMac:navigator.platform.includes(`Mac`),isWindows:navigator.platform.includes(`Win`),isFirefox:typeof navigator?.userAgent==`string`&&navigator.userAgent.includes(`Firefox`)}):A(this,`platform`,{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return A(this,`isCSSRoundSupported`,globalThis.CSS?.supports?.(`width: round(1.5px, 1px)`))}},ce=Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,`0`)),R=class{static makeHexColor(e,t,n){return`#${ce[e]}${ce[t]}${ce[n]}`}static scaleMinMax(e,t){let n;e[0]?(e[0]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[3],t[3]*=e[3]):(n=t[0],t[0]=t[1],t[1]=n,n=t[2],t[2]=t[3],t[3]=n,e[1]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[2],t[2]*=e[2]),t[0]+=e[4],t[1]+=e[5],t[2]+=e[4],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){let n=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){let n=this.applyTransform(e,t),r=this.applyTransform(e.slice(2,4),t),i=this.applyTransform([e[0],e[3]],t),a=this.applyTransform([e[2],e[1]],t);return[Math.min(n[0],r[0],i[0],a[0]),Math.min(n[1],r[1],i[1],a[1]),Math.max(n[0],r[0],i[0],a[0]),Math.max(n[1],r[1],i[1],a[1])]}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){let t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],r=e[0]*t[1]+e[1]*t[3],i=e[2]*t[0]+e[3]*t[2],a=e[2]*t[1]+e[3]*t[3],o=(n+a)/2,s=Math.sqrt((n+a)**2-4*(n*a-i*r))/2,c=o+s||1,l=o-s||1;return[Math.sqrt(c),Math.sqrt(l)]}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>r)return null;let i=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return i>a?null:[n,i,r,a]}static#e(e,t,n,r,i,a,o,s,c,l){if(c<=0||c>=1)return;let u=1-c,d=c*c,f=d*c,p=u*(u*(u*e+3*c*t)+3*d*n)+f*r,m=u*(u*(u*i+3*c*a)+3*d*o)+f*s;l[0]=Math.min(l[0],p),l[1]=Math.min(l[1],m),l[2]=Math.max(l[2],p),l[3]=Math.max(l[3],m)}static#t(e,t,n,r,i,a,o,s,c,l,u,d){if(Math.abs(c)<1e-12){Math.abs(l)>=1e-12&&this.#e(e,t,n,r,i,a,o,s,-u/l,d);return}let f=l**2-4*u*c;if(f<0)return;let p=Math.sqrt(f),m=2*c;this.#e(e,t,n,r,i,a,o,s,(-l+p)/m,d),this.#e(e,t,n,r,i,a,o,s,(-l-p)/m,d)}static bezierBoundingBox(e,t,n,r,i,a,o,s,c){return c?(c[0]=Math.min(c[0],e,o),c[1]=Math.min(c[1],t,s),c[2]=Math.max(c[2],e,o),c[3]=Math.max(c[3],t,s)):c=[Math.min(e,o),Math.min(t,s),Math.max(e,o),Math.max(t,s)],this.#t(e,n,i,o,t,r,a,s,3*(-e+3*(n-i)+o),6*(e-2*n+i),3*(n-e),c),this.#t(e,n,i,o,t,r,a,s,3*(-t+3*(r-a)+s),6*(t-2*r+a),3*(r-t),c),c}};function le(e){return decodeURIComponent(escape(e))}var ue=null,de=null;function fe(e){return ue||(ue=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,de=new Map([[`ſt`,`ſt`]])),e.replaceAll(ue,(e,t,n)=>t?t.normalize(`NFKC`):de.get(n))}function pe(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(32);return crypto.getRandomValues(e),ne(e)}var me=`pdfjs_internal_id_`;function he(e){return Uint8Array.prototype.toBase64?e.toBase64():btoa(ne(e))}typeof Promise.try!=`function`&&(Promise.try=function(e,...t){return new Promise(n=>{n(e(...t))})});var z=`http://www.w3.org/2000/svg`,ge=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function _e(e,t=`text`){if(Te(e,document.baseURI)){let n=await fetch(e);if(!n.ok)throw Error(n.statusText);switch(t){case`arraybuffer`:return n.arrayBuffer();case`blob`:return n.blob();case`json`:return n.json()}return n.text()}return new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(`GET`,e,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case`arraybuffer`:case`blob`:case`json`:n(i.response);return}n(i.responseText);return}r(Error(i.statusText))}},i.send(null)})}var ve=class e{constructor({viewBox:e,userUnit:t,scale:n,rotation:r,offsetX:i=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=t,this.scale=n,this.rotation=r,this.offsetX=i,this.offsetY=a,n*=t;let s=(e[2]+e[0])/2,c=(e[3]+e[1])/2,l,u,d,f;switch(r%=360,r<0&&(r+=360),r){case 180:l=-1,u=0,d=0,f=1;break;case 90:l=0,u=1,d=1,f=0;break;case 270:l=0,u=-1,d=-1,f=0;break;case 0:l=1,u=0,d=0,f=-1;break;default:throw Error(`PageViewport: Invalid rotation, must be a multiple of 90 degrees.`)}o&&(d=-d,f=-f);let p,m,h,g;l===0?(p=Math.abs(c-e[1])*n+i,m=Math.abs(s-e[0])*n+a,h=(e[3]-e[1])*n,g=(e[2]-e[0])*n):(p=Math.abs(s-e[0])*n+i,m=Math.abs(c-e[1])*n+a,h=(e[2]-e[0])*n,g=(e[3]-e[1])*n),this.transform=[l*n,u*n,d*n,f*n,p-l*n*s-d*n*c,m-u*n*s-f*n*c],this.width=h,this.height=g}get rawDims(){let{userUnit:e,viewBox:t}=this,n=t.map(t=>t*e);return A(this,`rawDims`,{pageWidth:n[2]-n[0],pageHeight:n[3]-n[1],pageX:n[0],pageY:n[1]})}clone({scale:t=this.scale,rotation:n=this.rotation,offsetX:r=this.offsetX,offsetY:i=this.offsetY,dontFlip:a=!1}={}){return new e({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:n,offsetX:r,offsetY:i,dontFlip:a})}convertToViewportPoint(e,t){return R.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){let t=R.applyTransform([e[0],e[1]],this.transform),n=R.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],n[0],n[1]]}convertToPdfPoint(e,t){return R.applyInverseTransform([e,t],this.transform)}},ye=class extends j{constructor(e,t=0){super(e,`RenderingCancelledException`),this.extraDelay=t}};function be(e){let t=e.length,n=0;for(;n<t&&e[n].trim()===``;)n++;return e.substring(n,n+5).toLowerCase()===`data:`}function xe(e){return typeof e==`string`&&/\.pdf$/i.test(e)}function Se(e){return[e]=e.split(/[#?]/,1),e.substring(e.lastIndexOf(`/`)+1)}function Ce(e,t=`document.pdf`){if(typeof e!=`string`)return t;if(be(e))return T(`getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.`),t;let n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,r=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=n.exec(e),a=r.exec(i[1])||r.exec(i[2])||r.exec(i[3]);if(a&&(a=a[0],a.includes(`%`)))try{a=r.exec(decodeURIComponent(a))[0]}catch{}return a||t}var we=class{started=Object.create(null);times=[];time(e){e in this.started&&T(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||T(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){let e=[],t=0;for(let{name:e}of this.times)t=Math.max(e.length,t);for(let{name:n,start:r,end:i}of this.times)e.push(`${n.padEnd(t)} ${i-r}ms\n`);return e.join(``)}};function Te(e,t){try{let{protocol:n}=t?new URL(e,t):new URL(e);return n===`http:`||n===`https:`}catch{return!1}}function B(e){e.preventDefault()}function V(e){e.preventDefault(),e.stopPropagation()}var Ee=class{static#e;static toDateObject(e){if(!e||typeof e!=`string`)return null;this.#e||=RegExp(`^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?`);let t=this.#e.exec(e);if(!t)return null;let n=parseInt(t[1],10),r=parseInt(t[2],10);r=r>=1&&r<=12?r-1:0;let i=parseInt(t[3],10);i=i>=1&&i<=31?i:1;let a=parseInt(t[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(t[5],10);o=o>=0&&o<=59?o:0;let s=parseInt(t[6],10);s=s>=0&&s<=59?s:0;let c=t[7]||`Z`,l=parseInt(t[8],10);l=l>=0&&l<=23?l:0;let u=parseInt(t[9],10)||0;return u=u>=0&&u<=59?u:0,c===`-`?(a+=l,o+=u):c===`+`&&(a-=l,o-=u),new Date(Date.UTC(n,r,i,a,o,s))}};function De(e,{scale:t=1,rotation:n=0}){let{width:r,height:i}=e.attributes.style;return new ve({viewBox:[0,0,parseInt(r),parseInt(i)],userUnit:1,scale:t,rotation:n})}function Oe(e){if(e.startsWith(`#`)){let t=parseInt(e.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return e.startsWith(`rgb(`)?e.slice(4,-1).split(`,`).map(e=>parseInt(e)):e.startsWith(`rgba(`)?e.slice(5,-1).split(`,`).map(e=>parseInt(e)).slice(0,3):(T(`Not a valid color format: "${e}"`),[0,0,0])}function ke(e){let t=document.createElement(`span`);t.style.visibility=`hidden`,document.body.append(t);for(let n of e.keys()){t.style.color=n;let r=window.getComputedStyle(t).color;e.set(n,Oe(r))}t.remove()}function H(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform();return[t,n,r,i,a,o]}function U(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform().invertSelf();return[t,n,r,i,a,o]}function Ae(e,t,n=!1,r=!0){if(t instanceof ve){let{pageWidth:r,pageHeight:i}=t.rawDims,{style:a}=e,o=L.isCSSRoundSupported,s=`var(--scale-factor) * ${r}px`,c=`var(--scale-factor) * ${i}px`,l=o?`round(down, ${s}, var(--scale-round-x, 1px))`:`calc(${s})`,u=o?`round(down, ${c}, var(--scale-round-y, 1px))`:`calc(${c})`;!n||t.rotation%180==0?(a.width=l,a.height=u):(a.width=u,a.height=l)}r&&e.setAttribute(`data-main-rotation`,t.rotation)}var je=class{constructor(){let e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}},Me=class e{#e=null;#t=null;#n;#r=null;#i=null;static#a=null;constructor(t){this.#n=t,e.#a||=Object.freeze({freetext:`pdfjs-editor-remove-freetext-button`,highlight:`pdfjs-editor-remove-highlight-button`,ink:`pdfjs-editor-remove-ink-button`,stamp:`pdfjs-editor-remove-stamp-button`})}render(){let t=this.#e=document.createElement(`div`);t.classList.add(`editToolbar`,`hidden`),t.setAttribute(`role`,`toolbar`);let n=this.#n._uiManager._signal;t.addEventListener(`contextmenu`,B,{signal:n}),t.addEventListener(`pointerdown`,e.#o,{signal:n});let r=this.#r=document.createElement(`div`);r.className=`buttons`,t.append(r);let i=this.#n.toolbarPosition;if(i){let{style:e}=t;e.insetInlineEnd=`${100*(this.#n._uiManager.direction===`ltr`?1-i[0]:i[0])}%`,e.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#u(),t}get div(){return this.#e}static#o(e){e.stopPropagation()}#s(e){this.#n._focusEventsAllowed=!1,V(e)}#c(e){this.#n._focusEventsAllowed=!0,V(e)}#l(e){let t=this.#n._uiManager._signal;e.addEventListener(`focusin`,this.#s.bind(this),{capture:!0,signal:t}),e.addEventListener(`focusout`,this.#c.bind(this),{capture:!0,signal:t}),e.addEventListener(`contextmenu`,B,{signal:t})}hide(){this.#e.classList.add(`hidden`),this.#t?.hideDropdown()}show(){this.#e.classList.remove(`hidden`),this.#i?.shown()}#u(){let{editorType:t,_uiManager:n}=this.#n,r=document.createElement(`button`);r.className=`delete`,r.tabIndex=0,r.setAttribute(`data-l10n-id`,e.#a[t]),this.#l(r),r.addEventListener(`click`,e=>{n.delete()},{signal:n._signal}),this.#r.append(r)}get#d(){let e=document.createElement(`div`);return e.className=`divider`,e}async addAltText(e){let t=await e.render();this.#l(t),this.#r.prepend(t,this.#d),this.#i=e}addColorPicker(e){this.#t=e;let t=e.renderButton();this.#l(t),this.#r.prepend(t,this.#d)}remove(){this.#e.remove(),this.#t?.destroy(),this.#t=null}},Ne=class{#e=null;#t=null;#n;constructor(e){this.#n=e}#r(){let e=this.#t=document.createElement(`div`);e.className=`editToolbar`,e.setAttribute(`role`,`toolbar`),e.addEventListener(`contextmenu`,B,{signal:this.#n._signal});let t=this.#e=document.createElement(`div`);return t.className=`buttons`,e.append(t),this.#a(),e}#i(e,t){let n=0,r=0;for(let i of e){let e=i.y+i.height;if(e<n)continue;let a=i.x+(t?i.width:0);if(e>n){r=a,n=e;continue}t?a>r&&(r=a):a<r&&(r=a)}return[t?1-r:r,n]}show(e,t,n){let[r,i]=this.#i(t,n),{style:a}=this.#t||=this.#r();e.append(this.#t),a.insetInlineEnd=`${100*r}%`,a.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){this.#t.remove()}#a(){let e=document.createElement(`button`);e.className=`highlightButton`,e.tabIndex=0,e.setAttribute(`data-l10n-id`,`pdfjs-highlight-floating-button1`);let t=document.createElement(`span`);e.append(t),t.className=`visuallyHidden`,t.setAttribute(`data-l10n-id`,`pdfjs-highlight-floating-button-label`);let n=this.#n._signal;e.addEventListener(`contextmenu`,B,{signal:n}),e.addEventListener(`click`,()=>{this.#n.highlightSelection(`floating_button`)},{signal:n}),this.#e.append(e)}};function Pe(e,t,n){for(let r of n)t.addEventListener(r,e[r].bind(e))}var Fe=class{#e=0;get id(){return`${u}${this.#e++}`}},Ie=class e{#e=pe();#t=0;#n=null;static get _isSVGFittingCanvas(){let e=new OffscreenCanvas(1,3).getContext(`2d`,{willReadFrequently:!0}),t=new Image;t.src=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>`;let n=t.decode().then(()=>(e.drawImage(t,0,0,1,1,0,0,1,3),new Uint32Array(e.getImageData(0,0,1,1).data.buffer)[0]===0));return A(this,`_isSVGFittingCanvas`,n)}async#r(t,n){this.#n||=new Map;let r=this.#n.get(t);if(r===null)return null;if(r?.bitmap)return r.refCounter+=1,r;try{r||={bitmap:null,id:`image_${this.#e}_${this.#t++}`,refCounter:0,isSvg:!1};let t;if(typeof n==`string`?(r.url=n,t=await _e(n,`blob`)):n instanceof File?t=r.file=n:n instanceof Blob&&(t=n),t.type===`image/svg+xml`){let n=e._isSVGFittingCanvas,i=new FileReader,a=new Image,o=new Promise((e,t)=>{a.onload=()=>{r.bitmap=a,r.isSvg=!0,e()},i.onload=async()=>{let e=r.svgUrl=i.result;a.src=await n?`${e}#svgView(preserveAspectRatio(none))`:e},a.onerror=i.onerror=t});i.readAsDataURL(t),await o}else r.bitmap=await createImageBitmap(t);r.refCounter=1}catch(e){T(e),r=null}return this.#n.set(t,r),r&&this.#n.set(r.id,r),r}async getFromFile(e){let{lastModified:t,name:n,size:r,type:i}=e;return this.#r(`${t}_${n}_${r}_${i}`,e)}async getFromUrl(e){return this.#r(e,e)}async getFromBlob(e,t){let n=await t;return this.#r(e,n)}async getFromId(e){this.#n||=new Map;let t=this.#n.get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){let{blobPromise:e}=t;return delete t.blobPromise,this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){this.#n||=new Map;let n=this.#n.get(e);if(n?.bitmap)return n.refCounter+=1,n;let r=new OffscreenCanvas(t.width,t.height);return r.getContext(`2d`).drawImage(t,0,0),n={bitmap:r.transferToImageBitmap(),id:`image_${this.#e}_${this.#t++}`,refCounter:1,isSvg:!1},this.#n.set(e,n),this.#n.set(n.id,n),n}getSvgUrl(e){let t=this.#n.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#n||=new Map;let t=this.#n.get(e);if(!t||(--t.refCounter,t.refCounter!==0))return;let{bitmap:n}=t;if(!t.url&&!t.file){let e=new OffscreenCanvas(n.width,n.height);e.getContext(`bitmaprenderer`).transferFromImageBitmap(n),t.blobPromise=e.convertToBlob()}n.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#e}_`)}},Le=class{#e=[];#t=!1;#n;#r=-1;constructor(e=128){this.#n=e}add({cmd:e,undo:t,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(r&&e(),this.#t)return;let s={cmd:e,undo:t,post:n,type:i};if(this.#r===-1){this.#e.length>0&&(this.#e.length=0),this.#r=0,this.#e.push(s);return}if(a&&this.#e[this.#r].type===i){o&&(s.undo=this.#e[this.#r].undo),this.#e[this.#r]=s;return}let c=this.#r+1;c===this.#n?this.#e.splice(0,1):(this.#r=c,c<this.#e.length&&this.#e.splice(c)),this.#e.push(s)}undo(){if(this.#r===-1)return;this.#t=!0;let{undo:e,post:t}=this.#e[this.#r];e(),t?.(),this.#t=!1,--this.#r}redo(){if(this.#r<this.#e.length-1){this.#r+=1,this.#t=!0;let{cmd:e,post:t}=this.#e[this.#r];e(),t?.(),this.#t=!1}}hasSomethingToUndo(){return this.#r!==-1}hasSomethingToRedo(){return this.#r<this.#e.length-1}cleanType(e){if(this.#r!==-1){for(let t=this.#r;t>=0;t--)if(this.#e[t].type!==e){this.#e.splice(t+1,this.#r-t),this.#r=t;return}this.#e.length=0,this.#r=-1}}destroy(){this.#e=null}},Re=class{constructor(e){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:t}=L.platform;for(let[n,r,i={}]of e)for(let e of n){let n=e.startsWith(`mac+`);t&&n?(this.callbacks.set(e.slice(4),{callback:r,options:i}),this.allKeys.add(e.split(`+`).at(-1))):!t&&!n&&(this.callbacks.set(e,{callback:r,options:i}),this.allKeys.add(e.split(`+`).at(-1)))}}#e(e){e.altKey&&this.buffer.push(`alt`),e.ctrlKey&&this.buffer.push(`ctrl`),e.metaKey&&this.buffer.push(`meta`),e.shiftKey&&this.buffer.push(`shift`),this.buffer.push(e.key);let t=this.buffer.join(`+`);return this.buffer.length=0,t}exec(e,t){if(!this.allKeys.has(t.key))return;let n=this.callbacks.get(this.#e(t));if(!n)return;let{callback:r,options:{bubbles:i=!1,args:a=[],checker:o=null}}=n;o&&!o(e,t)||(r.bind(e,...a,t)(),i||V(t))}},ze=class e{static _colorsMapping=new Map([[`CanvasText`,[0,0,0]],[`Canvas`,[255,255,255]]]);get _colors(){let e=new Map([[`CanvasText`,null],[`Canvas`,null]]);return ke(e),A(this,`_colors`,e)}convert(t){let n=Oe(t);if(!window.matchMedia(`(forced-colors: active)`).matches)return n;for(let[t,r]of this._colors)if(r.every((e,t)=>e===n[t]))return e._colorsMapping.get(t);return n}getHexCode(e){let t=this._colors.get(e);return t?R.makeHexColor(...t):e}},Be=class e{#e=new AbortController;#t=null;#n=new Map;#r=new Map;#i=null;#a=null;#o=null;#s=new Le;#c=null;#l=null;#u=0;#d=new Set;#f=null;#p=null;#m=new Set;_editorUndoBar=null;#h=!1;#g=!1;#_=!1;#v=null;#y=null;#b=null;#x=null;#S=!1;#C=null;#w=new Fe;#T=!1;#E=!1;#D=null;#O=null;#k=null;#A=null;#j=d.NONE;#M=new Set;#N=null;#P=null;#F=null;#I={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#L=[0,0];#R=null;#z=null;#B=null;#V=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=e.prototype,n=e=>e.#z.contains(document.activeElement)&&document.activeElement.tagName!==`BUTTON`&&e.hasSomethingToControl(),r=(e,{target:t})=>{if(t instanceof HTMLInputElement){let{type:e}=t;return e!==`text`&&e!==`number`}return!0},i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return A(this,`_keyboardManager`,new Re([[[`ctrl+a`,`mac+meta+a`],t.selectAll,{checker:r}],[[`ctrl+z`,`mac+meta+z`],t.undo,{checker:r}],[[`ctrl+y`,`ctrl+shift+z`,`mac+meta+shift+z`,`ctrl+shift+Z`,`mac+meta+shift+Z`],t.redo,{checker:r}],[[`Backspace`,`alt+Backspace`,`ctrl+Backspace`,`shift+Backspace`,`mac+Backspace`,`mac+alt+Backspace`,`mac+ctrl+Backspace`,`Delete`,`ctrl+Delete`,`shift+Delete`,`mac+Delete`],t.delete,{checker:r}],[[`Enter`,`mac+Enter`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#z.contains(t)&&!e.isEnterHandled}],[[` `,`mac+ `],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#z.contains(document.activeElement)}],[[`Escape`,`mac+Escape`],t.unselectAll],[[`ArrowLeft`,`mac+ArrowLeft`],t.translateSelectedEditors,{args:[-i,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t.translateSelectedEditors,{args:[-a,0],checker:n}],[[`ArrowRight`,`mac+ArrowRight`],t.translateSelectedEditors,{args:[i,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t.translateSelectedEditors,{args:[a,0],checker:n}],[[`ArrowUp`,`mac+ArrowUp`],t.translateSelectedEditors,{args:[0,-i],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t.translateSelectedEditors,{args:[0,-a],checker:n}],[[`ArrowDown`,`mac+ArrowDown`],t.translateSelectedEditors,{args:[0,i],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t.translateSelectedEditors,{args:[0,a],checker:n}]]))}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=this._signal=this.#e.signal;this.#z=e,this.#B=t,this.#i=n,this._eventBus=r,r._on(`editingaction`,this.onEditingAction.bind(this),{signal:p}),r._on(`pagechanging`,this.onPageChanging.bind(this),{signal:p}),r._on(`scalechanging`,this.onScaleChanging.bind(this),{signal:p}),r._on(`rotationchanging`,this.onRotationChanging.bind(this),{signal:p}),r._on(`setpreference`,this.onSetPreference.bind(this),{signal:p}),r._on(`switchannotationeditorparams`,e=>this.updateParams(e.type,e.value),{signal:p}),this.#q(),this.#ee(),this.#X(),this.#a=i.annotationStorage,this.#v=i.filterFactory,this.#P=a,this.#x=o||null,this.#h=s,this.#g=c,this.#_=l,this.#A=u||null,this.viewParameters={realScale:ge.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=d||null,this._supportsPinchToZoom=f!==!1}destroy(){this.#V?.resolve(),this.#V=null,this.#e?.abort(),this.#e=null,this._signal=null;for(let e of this.#r.values())e.destroy();this.#r.clear(),this.#n.clear(),this.#m.clear(),this.#t=null,this.#M.clear(),this.#s.destroy(),this.#i?.destroy(),this.#C?.hide(),this.#C=null,this.#y&&=(clearTimeout(this.#y),null),this.#R&&=(clearTimeout(this.#R),null),this._editorUndoBar?.destroy()}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#A}get useNewAltTextFlow(){return this.#g}get useNewAltTextWhenAddingImage(){return this.#_}get hcmFilter(){return A(this,`hcmFilter`,this.#P?this.#v.addHCMFilter(this.#P.foreground,this.#P.background):`none`)}get direction(){return A(this,`direction`,getComputedStyle(this.#z).direction)}get highlightColors(){return A(this,`highlightColors`,this.#x?new Map(this.#x.split(`,`).map(e=>e.split(`=`).map(e=>e.trim()))):null)}get highlightColorNames(){return A(this,`highlightColorNames`,this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#l=e}setMainHighlightColorPicker(e){this.#k=e}editAltText(e,t=!1){this.#i?.editAltText(this,e,t)}switchToMode(e,t){this._eventBus.on(`annotationeditormodechanged`,t,{once:!0,signal:this._signal}),this._eventBus.dispatch(`showannotationeditorui`,{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch(`setpreference`,{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){switch(e){case`enableNewAltTextWhenAddingImage`:this.#_=t;break}}onPageChanging({pageNumber:e}){this.#u=e-1}focusMainContainer(){this.#z.focus()}findParent(e,t){for(let n of this.#r.values()){let{x:r,y:i,width:a,height:o}=n.div.getBoundingClientRect();if(e>=r&&e<=r+a&&t>=i&&t<=i+o)return n}return null}disableUserSelect(e=!1){this.#B.classList.toggle(`noUserSelect`,e)}addShouldRescale(e){this.#m.add(e)}removeShouldRescale(e){this.#m.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*ge.PDF_TO_CSS_UNITS;for(let e of this.#m)e.onScaleChanging();this.#l?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#H({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#U(e){let{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(let t of this.#r.values())if(t.hasTextLayer(e))return t;return null}highlightSelection(e=``){let t=document.getSelection();if(!t||t.isCollapsed)return;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=t,o=t.toString(),s=this.#H(t).closest(`.textLayer`),c=this.getSelectionBoxes(s);if(!c)return;t.empty();let l=this.#U(s),u=this.#j===d.NONE,f=()=>{l?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:c,anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a,text:o}),u&&this.showAllEditors(`highlight`,!0,!0)};if(u){this.switchToMode(d.HIGHLIGHT,f);return}f()}#W(){let e=document.getSelection();if(!e||e.isCollapsed)return;let t=this.#H(e).closest(`.textLayer`),n=this.getSelectionBoxes(t);n&&(this.#C||=new Ne(this),this.#C.show(t,n,this.direction===`ltr`))}addToAnnotationStorage(e){!e.isEmpty()&&this.#a&&!this.#a.has(e.id)&&this.#a.setValue(e.id,e)}#G(){let e=document.getSelection();if(!e||e.isCollapsed){this.#N&&(this.#C?.hide(),this.#N=null,this.#te({hasSelectedText:!1}));return}let{anchorNode:t}=e;if(t===this.#N)return;let n=this.#H(e).closest(`.textLayer`);if(!n){this.#N&&(this.#C?.hide(),this.#N=null,this.#te({hasSelectedText:!1}));return}if(this.#C?.hide(),this.#N=t,this.#te({hasSelectedText:!0}),!(this.#j!==d.HIGHLIGHT&&this.#j!==d.NONE)&&(this.#j===d.HIGHLIGHT&&this.showAllEditors(`highlight`,!0,!0),this.#S=this.isShiftKeyDown,!this.isShiftKeyDown)){let e=this.#j===d.HIGHLIGHT?this.#U(n):null;e?.toggleDrawing();let t=new AbortController,r=this.combinedSignal(t),i=n=>{n.type===`pointerup`&&n.button!==0||(t.abort(),e?.toggleDrawing(!0),n.type===`pointerup`&&this.#K(`main_toolbar`))};window.addEventListener(`pointerup`,i,{signal:r}),window.addEventListener(`blur`,i,{signal:r})}}#K(e=``){this.#j===d.HIGHLIGHT?this.highlightSelection(e):this.#h&&this.#W()}#q(){document.addEventListener(`selectionchange`,this.#G.bind(this),{signal:this._signal})}#J(){if(this.#b)return;this.#b=new AbortController;let e=this.combinedSignal(this.#b);window.addEventListener(`focus`,this.focus.bind(this),{signal:e}),window.addEventListener(`blur`,this.blur.bind(this),{signal:e})}#Y(){this.#b?.abort(),this.#b=null}blur(){if(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#K(`main_toolbar`)),!this.hasSelection)return;let{activeElement:e}=document;for(let t of this.#M)if(t.div.contains(e)){this.#O=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#O)return;let[e,t]=this.#O;this.#O=null,t.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}#X(){if(this.#D)return;this.#D=new AbortController;let e=this.combinedSignal(this.#D);window.addEventListener(`keydown`,this.keydown.bind(this),{signal:e}),window.addEventListener(`keyup`,this.keyup.bind(this),{signal:e})}#Z(){this.#D?.abort(),this.#D=null}#Q(){if(this.#c)return;this.#c=new AbortController;let e=this.combinedSignal(this.#c);document.addEventListener(`copy`,this.copy.bind(this),{signal:e}),document.addEventListener(`cut`,this.cut.bind(this),{signal:e}),document.addEventListener(`paste`,this.paste.bind(this),{signal:e})}#$(){this.#c?.abort(),this.#c=null}#ee(){let e=this._signal;document.addEventListener(`dragover`,this.dragOver.bind(this),{signal:e}),document.addEventListener(`drop`,this.drop.bind(this),{signal:e})}addEditListeners(){this.#X(),this.#Q()}removeEditListeners(){this.#Z(),this.#$()}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let n of this.#p)if(n.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect=`copy`,e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let n of this.#p)if(n.isHandlingMimeForPasting(t.type)){n.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),this.#t?.commitOrRemove(),!this.hasSelection)return;let t=[];for(let e of this.#M){let n=e.serialize(!0);n&&t.push(n)}t.length!==0&&e.clipboardData.setData(`application/pdfjs`,JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();let{clipboardData:t}=e;for(let e of t.items)for(let t of this.#p)if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}let n=t.getData(`application/pdfjs`);if(!n)return;try{n=JSON.parse(n)}catch(e){T(`paste: "${e.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();let r=this.currentLayer;try{let e=[];for(let t of n){let n=await r.deserialize(t);if(!n)return;e.push(n)}this.addCommands({cmd:()=>{for(let t of e)this.#ae(t);this.#ce(e)},undo:()=>{for(let t of e)t.remove()},mustExec:!0})}catch(e){T(`paste: "${e.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key===`Shift`&&(this.isShiftKeyDown=!0),this.#j!==d.NONE&&!this.isEditorHandlingKeyboard&&e._keyboardManager.exec(this,t)}keyup(e){this.isShiftKeyDown&&e.key===`Shift`&&(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#K(`main_toolbar`)))}onEditingAction({name:e}){switch(e){case`undo`:case`redo`:case`delete`:case`selectAll`:this[e]();break;case`highlightSelection`:this.highlightSelection(`context_menu`);break}}#te(e){Object.entries(e).some(([e,t])=>this.#I[e]!==t)&&(this._eventBus.dispatch(`annotationeditorstateschanged`,{source:this,details:Object.assign(this.#I,e)}),this.#j===d.HIGHLIGHT&&e.hasSelectedEditor===!1&&this.#ne([[f.HIGHLIGHT_FREE,!0]]))}#ne(e){this._eventBus.dispatch(`annotationeditorparamschanged`,{source:this,details:e})}setEditingState(e){e?(this.#J(),this.#Q(),this.#te({isEditing:this.#j!==d.NONE,isEmpty:this.#se(),hasSomethingToUndo:this.#s.hasSomethingToUndo(),hasSomethingToRedo:this.#s.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Y(),this.#$(),this.#te({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#p){this.#p=e;for(let e of this.#p)this.#ne(e.defaultPropertiesToUpdate)}}getId(){return this.#w.id}get currentLayer(){return this.#r.get(this.#u)}getLayer(e){return this.#r.get(e)}get currentPageIndex(){return this.#u}addLayer(e){this.#r.set(e.pageIndex,e),this.#T?e.enable():e.disable()}removeLayer(e){this.#r.delete(e.pageIndex)}async updateMode(e,t=null,n=!1){if(this.#j!==e&&!(this.#V&&(await this.#V.promise,!this.#V))){if(this.#V=Promise.withResolvers(),this.#j=e,e===d.NONE){this.setEditingState(!1),this.#ie(),this._editorUndoBar?.hide(),this.#V.resolve();return}this.setEditingState(!0),await this.#re(),this.unselectAll();for(let t of this.#r.values())t.updateMode(e);if(!t){n&&this.addNewEditorFromKeyboard(),this.#V.resolve();return}for(let e of this.#n.values())e.annotationElementId===t?(this.setSelected(e),e.enterInEditMode()):e.unselect();this.#V.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==this.#j&&this._eventBus.dispatch(`switchannotationeditormode`,{source:this,mode:e})}updateParams(e,t){if(this.#p){switch(e){case f.CREATE:this.currentLayer.addNewEditor();return;case f.HIGHLIGHT_DEFAULT_COLOR:this.#k?.updateColor(t);break;case f.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:{type:`highlight`,action:`toggle_visibility`}}}),(this.#F||=new Map).set(e,t),this.showAllEditors(`highlight`,t);break}for(let n of this.#M)n.updateParams(e,t);for(let n of this.#p)n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){for(let n of this.#n.values())n.editorType===e&&n.show(t);(this.#F?.get(f.HIGHLIGHT_SHOW_ALL)??!0)!==t&&this.#ne([[f.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#E!==e){this.#E=e;for(let t of this.#r.values())e?t.disableClick():t.enableClick(),t.div.classList.toggle(`waiting`,e)}}async#re(){if(!this.#T){this.#T=!0;let e=[];for(let t of this.#r.values())e.push(t.enable());await Promise.all(e);for(let e of this.#n.values())e.enable()}}#ie(){if(this.unselectAll(),this.#T){this.#T=!1;for(let e of this.#r.values())e.disable();for(let e of this.#n.values())e.disable()}}getEditors(e){let t=[];for(let n of this.#n.values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return this.#n.get(e)}addEditor(e){this.#n.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.focusMainContainer(),this.#y=null},0)),this.#n.delete(e.id),this.unselect(e),(!e.annotationElementId||!this.#d.has(e.annotationElementId))&&this.#a?.remove(e.id)}addDeletedAnnotationElement(e){this.#d.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#d.has(e)}removeDeletedAnnotationElement(e){this.#d.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#ae(e){let t=this.#r.get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#t!==e&&(this.#t=e,e&&this.#ne(e.propertiesToUpdate))}get#oe(){let e=null;for(e of this.#M);return e}updateUI(e){this.#oe===e&&this.#ne(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#ne(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#M.has(e)){this.#M.delete(e),e.unselect(),this.#te({hasSelectedEditor:this.hasSelection});return}this.#M.add(e),e.select(),this.#ne(e.propertiesToUpdate),this.#te({hasSelectedEditor:!0})}setSelected(e){this.#l?.commitOrRemove();for(let t of this.#M)t!==e&&t.unselect();this.#M.clear(),this.#M.add(e),e.select(),this.#ne(e.propertiesToUpdate),this.#te({hasSelectedEditor:!0})}isSelected(e){return this.#M.has(e)}get firstSelectedEditor(){return this.#M.values().next().value}unselect(e){e.unselect(),this.#M.delete(e),this.#te({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#M.size!==0}get isEnterHandled(){return this.#M.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#s.undo(),this.#te({hasSomethingToUndo:this.#s.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#se()}),this._editorUndoBar?.hide()}redo(){this.#s.redo(),this.#te({hasSomethingToUndo:!0,hasSomethingToRedo:this.#s.hasSomethingToRedo(),isEmpty:this.#se()})}addCommands(e){this.#s.add(e),this.#te({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#se()})}cleanUndoStack(e){this.#s.cleanType(e)}#se(){if(this.#n.size===0)return!0;if(this.#n.size===1)for(let e of this.#n.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();let e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;let t=e?[e]:[...this.#M],n=()=>{this._editorUndoBar?.show(r,t.length===1?t[0].editorType:t.length);for(let e of t)e.remove()},r=()=>{for(let e of t)this.#ae(e)};this.addCommands({cmd:n,undo:r,mustExec:!0})}commitOrRemove(){this.#t?.commitOrRemove()}hasSomethingToControl(){return this.#t||this.hasSelection}#ce(e){for(let e of this.#M)e.unselect();this.#M.clear();for(let t of e)t.isEmpty()||(this.#M.add(t),t.select());this.#te({hasSelectedEditor:this.hasSelection})}selectAll(){for(let e of this.#M)e.commit();this.#ce(this.#n.values())}unselectAll(){if(!(this.#t&&(this.#t.commitOrRemove(),this.#j!==d.NONE))&&!this.#l?.commitOrRemove()&&this.hasSelection){for(let e of this.#M)e.unselect();this.#M.clear(),this.#te({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#L[0]+=e,this.#L[1]+=t;let[r,i]=this.#L,a=[...this.#M];this.#R&&clearTimeout(this.#R),this.#R=setTimeout(()=>{this.#R=null,this.#L[0]=this.#L[1]=0,this.addCommands({cmd:()=>{for(let e of a)this.#n.has(e.id)&&e.translateInPage(r,i)},undo:()=>{for(let e of a)this.#n.has(e.id)&&e.translateInPage(-r,-i)},mustExec:!1})},1e3);for(let n of a)n.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(let e of this.#M)this.#f.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);let e=this.#f;this.#f=null;let t=!1;for(let[{x:n,y:r,pageIndex:i},a]of e)a.newX=n,a.newY=r,a.newPageIndex=i,t||=n!==a.savedX||r!==a.savedY||i!==a.savedPageIndex;if(!t)return!1;let n=(e,t,n,r)=>{if(this.#n.has(e.id)){let i=this.#r.get(r);i?e._setParentAndPosition(i,t,n):(e.pageIndex=r,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(let[t,{newX:r,newY:i,newPageIndex:a}]of e)n(t,r,i,a)},undo:()=>{for(let[t,{savedX:r,savedY:i,savedPageIndex:a}]of e)n(t,r,i,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(this.#f)for(let n of this.#f.keys())n.drag(e,t)}rebuild(e){if(e.parent===null){let t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#M.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#t===e}getActive(){return this.#t}getMode(){return this.#j}get imageManager(){return A(this,`imageManager`,new Ie)}getSelectionBoxes(e){if(!e)return null;let t=document.getSelection();for(let n=0,r=t.rangeCount;n<r;n++)if(!e.contains(t.getRangeAt(n).commonAncestorContainer))return null;let{x:n,y:r,width:i,height:a}=e.getBoundingClientRect(),o;switch(e.getAttribute(`data-main-rotation`)){case`90`:o=(e,t,o,s)=>({x:(t-r)/a,y:1-(e+o-n)/i,width:s/a,height:o/i});break;case`180`:o=(e,t,o,s)=>({x:1-(e+o-n)/i,y:1-(t+s-r)/a,width:o/i,height:s/a});break;case`270`:o=(e,t,o,s)=>({x:1-(t+s-r)/a,y:(e-n)/i,width:s/a,height:o/i});break;default:o=(e,t,o,s)=>({x:(e-n)/i,y:(t-r)/a,width:o/i,height:s/a});break}let s=[];for(let e=0,n=t.rangeCount;e<n;e++){let n=t.getRangeAt(e);if(!n.collapsed)for(let{x:e,y:t,width:r,height:i}of n.getClientRects())r===0||i===0||s.push(o(e,t,r,i))}return s.length===0?null:s}addChangedExistingAnnotation({annotationElementId:e,id:t}){(this.#o||=new Map).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){this.#o?.delete(e)}renderAnnotationElement(e){let t=this.#o?.get(e.data.id);if(!t)return;let n=this.#a.getRawValue(t);n&&(this.#j===d.NONE&&!n.hasBeenModified||n.renderAnnotationElement(e))}},Ve=class e{#e=null;#t=!1;#n=null;#r=null;#i=null;#a=null;#o=!1;#s=null;#c=null;#l=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#c=t,this.#d=t._uiManager.useNewAltTextFlow,e.#f||=Object.freeze({added:`pdfjs-editor-new-alt-text-added-button`,"added-label":`pdfjs-editor-new-alt-text-added-button-label`,missing:`pdfjs-editor-new-alt-text-missing-button`,"missing-label":`pdfjs-editor-new-alt-text-missing-button-label`,review:`pdfjs-editor-new-alt-text-to-review-button`,"review-label":`pdfjs-editor-new-alt-text-to-review-button-label`})}static initialize(t){e._l10n??=t}async render(){let t=this.#n=document.createElement(`button`);t.className=`altText`,t.tabIndex=`0`;let n=this.#r=document.createElement(`span`);t.append(n),this.#d?(t.classList.add(`new`),t.setAttribute(`data-l10n-id`,e.#f.missing),n.setAttribute(`data-l10n-id`,e.#f[`missing-label`])):(t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button`),n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button-label`));let r=this.#c._uiManager._signal;t.addEventListener(`contextmenu`,B,{signal:r}),t.addEventListener(`pointerdown`,e=>e.stopPropagation(),{signal:r});let i=e=>{e.preventDefault(),this.#c._uiManager.editAltText(this.#c),this.#d&&this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_clicked`,data:{label:this.#p}})};return t.addEventListener(`click`,i,{capture:!0,signal:r}),t.addEventListener(`keydown`,e=>{e.target===t&&e.key===`Enter`&&(this.#o=!0,i(e))},{signal:r}),await this.#m(),t}get#p(){return this.#e&&`added`||this.#e===null&&this.guessedText&&`review`||`missing`}finish(){this.#n&&(this.#n.focus({focusVisible:this.#o}),this.#o=!1)}isEmpty(){return this.#d?this.#e===null:!this.#e&&!this.#t}hasData(){return this.#d?this.#e!==null||!!this.#l:this.isEmpty()}get guessedText(){return this.#l}async setGuessedText(t){this.#e===null&&(this.#l=t,this.#u=await e._l10n.get(`pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer`,{generatedAltText:t}),this.#m())}toggleAltTextBadge(e=!1){if(!this.#d||this.#e){this.#s?.remove(),this.#s=null;return}if(!this.#s){let e=this.#s=document.createElement(`div`);e.className=`noAltTextBadge`,this.#c.div.append(e)}this.#s.classList.toggle(`hidden`,!e)}serialize(e){let t=this.#e;return!e&&this.#l===t&&(t=this.#u),{altText:t,decorative:this.#t,guessedText:this.#l,textWithDisclaimer:this.#u}}get data(){return{altText:this.#e,decorative:this.#t}}set data({altText:e,decorative:t,guessedText:n,textWithDisclaimer:r,cancel:i=!1}){n&&(this.#l=n,this.#u=r),!(this.#e===e&&this.#t===t)&&(i||(this.#e=e,this.#t=t),this.#m())}toggle(e=!1){this.#n&&(!e&&this.#a&&(clearTimeout(this.#a),this.#a=null),this.#n.disabled=!e)}shown(){this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_displayed`,data:{label:this.#p}})}destroy(){this.#n?.remove(),this.#n=null,this.#r=null,this.#i=null,this.#s?.remove(),this.#s=null}async#m(){let t=this.#n;if(!t)return;if(this.#d){if(t.classList.toggle(`done`,!!this.#e),t.setAttribute(`data-l10n-id`,e.#f[this.#p]),this.#r?.setAttribute(`data-l10n-id`,e.#f[`${this.#p}-label`]),!this.#e){this.#i?.remove();return}}else{if(!this.#e&&!this.#t){t.classList.remove(`done`),this.#i?.remove();return}t.classList.add(`done`),t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-edit-button`)}let n=this.#i;if(!n){this.#i=n=document.createElement(`span`),n.className=`tooltip`,n.setAttribute(`role`,`tooltip`),n.id=`alt-text-tooltip-${this.#c.id}`;let e=this.#c._uiManager._signal;e.addEventListener(`abort`,()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),t.addEventListener(`mouseenter`,()=>{this.#a=setTimeout(()=>{this.#a=null,this.#i.classList.add(`show`),this.#c._reportTelemetry({action:`alt_text_tooltip`})},100)},{signal:e}),t.addEventListener(`mouseleave`,()=>{this.#a&&=(clearTimeout(this.#a),null),this.#i?.classList.remove(`show`)},{signal:e})}this.#t?n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-decorative-tooltip`):(n.removeAttribute(`data-l10n-id`),n.textContent=this.#e),n.parentNode||t.append(n),this.#c.getImageForAltText()?.setAttribute(`aria-describedby`,n.id)}},He=class e{#e;#t=!1;#n=null;#r;#i;#a;#o;#s;#c=null;#l;#u=null;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:i=null,onPinchEnd:a=null,signal:o}){this.#e=e,this.#n=n,this.#r=t,this.#i=r,this.#a=i,this.#o=a,this.#l=new AbortController,this.#s=AbortSignal.any([o,this.#l.signal]),e.addEventListener(`touchstart`,this.#d.bind(this),{passive:!1,signal:this.#s})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return A(this,`MIN_TOUCH_DISTANCE_TO_PINCH`,35/(window.devicePixelRatio||1))}#d(e){if(this.#r?.()||e.touches.length<2)return;if(!this.#u){this.#u=new AbortController;let e=AbortSignal.any([this.#s,this.#u.signal]),t=this.#e,n={signal:e,passive:!1};t.addEventListener(`touchmove`,this.#f.bind(this),n),t.addEventListener(`touchend`,this.#p.bind(this),n),t.addEventListener(`touchcancel`,this.#p.bind(this),n),this.#i?.()}if(V(e),e.touches.length!==2||this.#n?.()){this.#c=null;return}let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]),this.#c={touch0X:t.screenX,touch0Y:t.screenY,touch1X:n.screenX,touch1Y:n.screenY}}#f(t){if(!this.#c||t.touches.length!==2)return;let[n,r]=t.touches;n.identifier>r.identifier&&([n,r]=[r,n]);let{screenX:i,screenY:a}=n,{screenX:o,screenY:s}=r,c=this.#c,{touch0X:l,touch0Y:u,touch1X:d,touch1Y:f}=c,p=d-l,m=f-u,h=o-i,g=s-a,_=Math.hypot(h,g)||1,v=Math.hypot(p,m)||1;if(!this.#t&&Math.abs(v-_)<=e.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(c.touch0X=i,c.touch0Y=a,c.touch1X=o,c.touch1Y=s,t.preventDefault(),!this.#t){this.#t=!0;return}let y=[(i+o)/2,(a+s)/2];this.#a?.(y,v,_)}#p(e){this.#u.abort(),this.#u=null,this.#o?.(),this.#c&&(e.preventDefault(),this.#c=null,this.#t=!1)}destroy(){this.#l?.abort(),this.#l=null}},W=class e{#e=null;#t=null;#n=null;#r=!1;#i=null;#a=``;#o=!1;#s=null;#c=null;#l=null;#u=null;#d=``;#f=!1;#p=null;#m=!1;#h=!1;#g=!1;#_=null;#v=0;#y=0;#b=null;#x=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#S=!1;#C=e._zIndex++;static _borderLineWidth=-1;static _colorManager=new ze;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=e.prototype._resizeWithKeyboard,n=Be.TRANSLATE_SMALL,r=Be.TRANSLATE_BIG;return A(this,`_resizerKeyboardManager`,new Re([[[`ArrowLeft`,`mac+ArrowLeft`],t,{args:[-n,0]}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t,{args:[-r,0]}],[[`ArrowRight`,`mac+ArrowRight`],t,{args:[n,0]}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t,{args:[r,0]}],[[`ArrowUp`,`mac+ArrowUp`],t,{args:[0,-n]}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t,{args:[0,-r]}],[[`ArrowDown`,`mac+ArrowDown`],t,{args:[0,n]}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t,{args:[0,r]}],[[`Escape`,`mac+Escape`],e.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null;let{rotation:t,rawDims:{pageWidth:n,pageHeight:r,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,r],this.pageTranslation=[i,a];let[o,s]=this.parentDimensions;this.x=e.x/o,this.y=e.y/s,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return A(this,`_defaultLineColor`,this._colorManager.getHexCode(`CanvasText`))}static deleteAnnotationElement(e){let t=new Ue({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(t,n){if(e._l10n??=t,e._l10nResizer||=Object.freeze({topLeft:`pdfjs-editor-resizer-top-left`,topMiddle:`pdfjs-editor-resizer-top-middle`,topRight:`pdfjs-editor-resizer-top-right`,middleRight:`pdfjs-editor-resizer-middle-right`,bottomRight:`pdfjs-editor-resizer-bottom-right`,bottomMiddle:`pdfjs-editor-resizer-bottom-middle`,bottomLeft:`pdfjs-editor-resizer-bottom-left`,middleLeft:`pdfjs-editor-resizer-middle-left`}),e._borderLineWidth!==-1)return;let r=getComputedStyle(document.documentElement);e._borderLineWidth=parseFloat(r.getPropertyValue(`--outline-width`))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){E(`Not implemented`)}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#S}set _isDraggable(e){this.#S=e,this.div?.classList.toggle(`draggable`,e)}get isEnterHandled(){return!0}center(){let[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#C}setParent(e){e===null?this.#H():(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#f?this.#f=!1:this.parent.setSelected(this))}focusout(e){this._focusEventsAllowed&&this.isAttachedToDOM&&(e.relatedTarget?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove()))}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,r){let[i,a]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(e+n)/i,this.y=(t+r)/a,this.fixAndSetPosition()}#w([e,t],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/e,this.y+=r/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#w(this.parentDimensions,e,t)}translateInPage(e,t){this.#p||=[this.x,this.y,this.width,this.height],this.#w(this.pageDimensions,e,t),this.div.scrollIntoView({block:`nearest`})}drag(e,t){this.#p||=[this.x,this.y,this.width,this.height];let{div:n,parentDimensions:[r,i]}=this;if(this.x+=e/r,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this,[s,c]=this.getBaseTranslation();a+=s,o+=c;let{style:l}=n;l.left=`${(100*a).toFixed(2)}%`,l.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),n.scrollIntoView({block:`nearest`})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#p&&(this.#p[0]!==this.x||this.#p[1]!==this.y)}get _hasBeenResized(){return!!this.#p&&(this.#p[2]!==this.width||this.#p[3]!==this.height)}getBaseTranslation(){let[t,n]=this.parentDimensions,{_borderLineWidth:r}=e,i=r/t,a=r/n;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let{div:{style:t},pageDimensions:[n,r]}=this,{x:i,y:a,width:o,height:s}=this;if(o*=n,s*=r,i*=n,a*=r,this._mustFixPosition)switch(e){case 0:i=Math.max(0,Math.min(n-o,i)),a=Math.max(0,Math.min(r-s,a));break;case 90:i=Math.max(0,Math.min(n-s,i)),a=Math.min(r,Math.max(o,a));break;case 180:i=Math.min(n,Math.max(o,i)),a=Math.min(r,Math.max(s,a));break;case 270:i=Math.min(n,Math.max(s,i)),a=Math.max(0,Math.min(r-o,a));break}this.x=i/=n,this.y=a/=r;let[c,l]=this.getBaseTranslation();i+=c,a+=l,t.left=`${(100*i).toFixed(2)}%`,t.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}static#T(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(t,n){return e.#T(t,n,this.parentRotation)}pageTranslationToScreen(t,n){return e.#T(t,n,360-this.parentRotation)}#E(e){switch(e){case 90:{let[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:e,pageDimensions:[t,n]}=this;return[t*e,n*e]}setDims(e,t){let[n,r]=this.parentDimensions,{style:i}=this.div;i.width=`${(100*e/n).toFixed(2)}%`,this.#o||(i.height=`${(100*t/r).toFixed(2)}%`)}fixDims(){let{style:e}=this.div,{height:t,width:n}=e,r=n.endsWith(`%`),i=!this.#o&&t.endsWith(`%`);if(r&&i)return;let[a,o]=this.parentDimensions;r||(e.width=`${(100*parseFloat(n)/a).toFixed(2)}%`),!this.#o&&!i&&(e.height=`${(100*parseFloat(t)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#D(){if(this.#s)return;this.#s=document.createElement(`div`),this.#s.classList.add(`resizers`);let e=this._willKeepAspectRatio?[`topLeft`,`topRight`,`bottomRight`,`bottomLeft`]:[`topLeft`,`topMiddle`,`topRight`,`middleRight`,`bottomRight`,`bottomMiddle`,`bottomLeft`,`middleLeft`],t=this._uiManager._signal;for(let n of e){let e=document.createElement(`div`);this.#s.append(e),e.classList.add(`resizer`,n),e.setAttribute(`data-resizer-name`,n),e.addEventListener(`pointerdown`,this.#O.bind(this,n),{signal:t}),e.addEventListener(`contextmenu`,B,{signal:t}),e.tabIndex=-1}this.div.prepend(this.#s)}#O(e,t){t.preventDefault();let{isMac:n}=L.platform;if(t.button!==0||t.ctrlKey&&n)return;this.#n?.toggle(!1);let r=this._isDraggable;this._isDraggable=!1,this.#c=[t.screenX,t.screenY];let i=new AbortController,a=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener(`pointermove`,this.#j.bind(this,e),{passive:!0,capture:!0,signal:a}),window.addEventListener(`touchmove`,V,{passive:!1,signal:a}),window.addEventListener(`contextmenu`,B,{signal:a}),this.#l={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let o=this.parent.div.style.cursor,s=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;let c=()=>{i.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=o,this.div.style.cursor=s,this.#A()};window.addEventListener(`pointerup`,c,{signal:a}),window.addEventListener(`blur`,c,{signal:a})}#k(e,t,n,r){this.width=n,this.height=r,this.x=e,this.y=t;let[i,a]=this.parentDimensions;this.setDims(i*n,a*r),this.fixAndSetPosition(),this._onResized()}_onResized(){}#A(){if(!this.#l)return;let{savedX:e,savedY:t,savedWidth:n,savedHeight:r}=this.#l;this.#l=null;let i=this.x,a=this.y,o=this.width,s=this.height;i===e&&a===t&&o===n&&s===r||this.addCommands({cmd:this.#k.bind(this,i,a,o,s),undo:this.#k.bind(this,e,t,n,r),mustExec:!0})}static _round(e){return Math.round(e*1e4)/1e4}#j(t,n){let[r,i]=this.parentDimensions,a=this.x,o=this.y,s=this.width,c=this.height,l=e.MIN_SIZE/r,u=e.MIN_SIZE/i,d=this.#E(this.rotation),f=(e,t)=>[d[0]*e+d[2]*t,d[1]*e+d[3]*t],p=this.#E(360-this.rotation),m=(e,t)=>[p[0]*e+p[2]*t,p[1]*e+p[3]*t],h,g,_=!1,v=!1;switch(t){case`topLeft`:_=!0,h=(e,t)=>[0,0],g=(e,t)=>[e,t];break;case`topMiddle`:h=(e,t)=>[e/2,0],g=(e,t)=>[e/2,t];break;case`topRight`:_=!0,h=(e,t)=>[e,0],g=(e,t)=>[0,t];break;case`middleRight`:v=!0,h=(e,t)=>[e,t/2],g=(e,t)=>[0,t/2];break;case`bottomRight`:_=!0,h=(e,t)=>[e,t],g=(e,t)=>[0,0];break;case`bottomMiddle`:h=(e,t)=>[e/2,t],g=(e,t)=>[e/2,0];break;case`bottomLeft`:_=!0,h=(e,t)=>[0,t],g=(e,t)=>[e,0];break;case`middleLeft`:v=!0,h=(e,t)=>[0,t/2],g=(e,t)=>[e,t/2];break}let y=h(s,c),b=g(s,c),x=f(...b),S=e._round(a+x[0]),C=e._round(o+x[1]),w=1,T=1,E,D;if(n.fromKeyboard)({deltaX:E,deltaY:D}=n);else{let{screenX:e,screenY:t}=n,[r,i]=this.#c;[E,D]=this.screenToPageTranslation(e-r,t-i),this.#c[0]=e,this.#c[1]=t}if([E,D]=m(E/r,D/i),_){let e=Math.hypot(s,c);w=T=Math.max(Math.min(Math.hypot(b[0]-y[0]-E,b[1]-y[1]-D)/e,1/s,1/c),l/s,u/c)}else v?w=Math.max(l,Math.min(1,Math.abs(b[0]-y[0]-E)))/s:T=Math.max(u,Math.min(1,Math.abs(b[1]-y[1]-D)))/c;let O=e._round(s*w),k=e._round(c*T);x=f(...g(O,k));let A=S-x[0],j=C-x[1];this.#p||=[this.x,this.y,this.width,this.height],this.width=O,this.height=k,this.x=A,this.y=j,this.setDims(r*O,i*k),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}async addEditToolbar(){return this._editToolbar||this.#h?this._editToolbar:(this._editToolbar=new Me(this),this.div.append(this._editToolbar.render()),this.#n&&await this._editToolbar.addAltText(this.#n),this._editToolbar)}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#n?.destroy())}addContainer(e){let t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#n||(Ve.initialize(e._l10n),this.#n=new Ve(this),this.#e&&=(this.#n.data=this.#e,null),await this.addEditToolbar())}get altTextData(){return this.#n?.data}set altTextData(e){this.#n&&(this.#n.data=e)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(e){await this.#n?.setGuessedText(e)}serializeAltText(e){return this.#n?.serialize(e)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}render(){this.div=document.createElement(`div`),this.div.setAttribute(`data-editor-rotation`,(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute(`id`,this.id),this.div.tabIndex=this.#r?-1:0,this._isVisible||this.div.classList.add(`hidden`),this.setInForeground(),this.#L();let[e,t]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*t/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/t).toFixed(2)}%`);let[n,r]=this.getInitialTranslation();return this.translate(n,r),Pe(this,this.div,[`pointerdown`]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#x||=new He({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#M.bind(this),onPinching:this.#N.bind(this),onPinchEnd:this.#P.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#M(){this.#l={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#N(t,n,r){let i=.7,a=r/n*i+1-i;if(a===1)return;let o=this.#E(this.rotation),s=(e,t)=>[o[0]*e+o[2]*t,o[1]*e+o[3]*t],[c,l]=this.parentDimensions,u=this.x,d=this.y,f=this.width,p=this.height,m=e.MIN_SIZE/c,h=e.MIN_SIZE/l;a=Math.max(Math.min(a,1/f,1/p),m/f,h/p);let g=e._round(f*a),_=e._round(p*a);if(g===f&&_===p)return;this.#p||=[u,d,f,p];let v=s(f/2,p/2),y=e._round(u+v[0]),b=e._round(d+v[1]),x=s(g/2,_/2);this.x=y-x[0],this.y=b-x[1],this.width=g,this.height=_,this.setDims(c*g,l*_),this.fixAndSetPosition(),this._onResizing()}#P(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#A()}pointerdown(e){let{isMac:t}=L.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(this.#f=!0,this._isDraggable){this.#I(e);return}this.#F(e)}get isSelected(){return this._uiManager.isSelected(this)}#F(e){let{isMac:t}=L.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#I(e){let{isSelected:t}=this;this._uiManager.setUpDragSession();let n=!1,r=new AbortController,i=this._uiManager.combinedSignal(r),a={capture:!0,passive:!1,signal:i},o=e=>{r.abort(),this.#i=null,this.#f=!1,this._uiManager.endDragSession()||this.#F(e),n&&this._onStopDragging()};t&&(this.#v=e.clientX,this.#y=e.clientY,this.#i=e.pointerId,this.#a=e.pointerType,window.addEventListener(`pointermove`,e=>{n||(n=!0,this._onStartDragging());let{clientX:t,clientY:r,pointerId:i}=e;if(i!==this.#i){V(e);return}let[a,o]=this.screenToPageTranslation(t-this.#v,r-this.#y);this.#v=t,this.#y=r,this._uiManager.dragSelectedEditors(a,o)},a),window.addEventListener(`touchmove`,V,a),window.addEventListener(`pointerdown`,e=>{e.pointerType===this.#a&&(this.#x||e.isPrimary)&&o(e),V(e)},a));let s=e=>{if(!this.#i||this.#i===e.pointerId){o(e);return}V(e)};window.addEventListener(`pointerup`,s,{signal:i}),window.addEventListener(`blur`,s,{signal:i})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#_&&clearTimeout(this.#_),this.#_=setTimeout(()=>{this.#_=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,n=this.rotation){let r=this.parentScale,[i,a]=this.pageDimensions,[o,s]=this.pageTranslation,c=e/r,l=t/r,u=this.x*i,d=this.y*a,f=this.width*i,p=this.height*a;switch(n){case 0:return[u+c+o,a-d-l-p+s,u+c+f+o,a-d-l+s];case 90:return[u+l+o,a-d+c+s,u+l+p+o,a-d+c+f+s];case 180:return[u-c-f+o,a-d+l+s,u-c+o,a-d+l+p+s];case 270:return[u-l-p+o,a-d-c-f+s,u-l+o,a-d-c+s];default:throw Error(`Invalid rotation`)}}getRectInCurrentCoords(e,t){let[n,r,i,a]=e,o=i-n,s=a-r;switch(this.rotation){case 0:return[n,t-a,o,s];case 90:return[n,t-r,s,o];case 180:return[i,t-r,o,s];case 270:return[i,t-a,s,o];default:throw Error(`Invalid rotation`)}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){this.#h=!0}disableEditMode(){this.#h=!1}isInEditMode(){return this.#h}shouldGetKeyboardEvents(){return this.#g}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:e,left:t,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return t<a&&r>0&&e<i&&n>0}#L(){if(this.#u||!this.div)return;this.#u=new AbortController;let e=this._uiManager.combinedSignal(this.#u);this.div.addEventListener(`focusin`,this.focusin.bind(this),{signal:e}),this.div.addEventListener(`focusout`,this.focusout.bind(this),{signal:e})}rebuild(){this.#L()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||``}}serialize(e=!1,t=null){E(`An editor must be serializable`)}static async deserialize(e,t,n){let r=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:n});r.rotation=e.rotation,r.#e=e.accessibilityData;let[i,a]=r.pageDimensions,[o,s,c,l]=r.getRectInCurrentCoords(e.rect,a);return r.x=o/i,r.y=s/a,r.width=c/i,r.height=l/a,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#u?.abort(),this.#u=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#_&&=(clearTimeout(this.#_),null),this.#H(),this.removeEditToolbar(),this.#b){for(let e of this.#b.values())clearTimeout(e);this.#b=null}this.parent=null,this.#x?.destroy(),this.#x=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#D(),this.#s.classList.remove(`hidden`),Pe(this,this.div,[`keydown`]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!==`Enter`)return;this._uiManager.setSelected(this),this.#l={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let n=this.#s.children;if(!this.#t){this.#t=Array.from(n);let t=this.#R.bind(this),r=this.#z.bind(this),i=this._uiManager._signal;for(let n of this.#t){let a=n.getAttribute(`data-resizer-name`);n.setAttribute(`role`,`spinbutton`),n.addEventListener(`keydown`,t,{signal:i}),n.addEventListener(`blur`,r,{signal:i}),n.addEventListener(`focus`,this.#B.bind(this,a),{signal:i}),n.setAttribute(`data-l10n-id`,e._l10nResizer[a])}}let r=this.#t[0],i=0;for(let e of n){if(e===r)break;i++}let a=(360-this.rotation+this.parentRotation)%360/90*(this.#t.length/4);if(a!==i){if(a<i)for(let e=0;e<i-a;e++)this.#s.append(this.#s.firstChild);else if(a>i)for(let e=0;e<a-i;e++)this.#s.firstChild.before(this.#s.lastChild);let t=0;for(let r of n){let n=this.#t[t++].getAttribute(`data-resizer-name`);r.setAttribute(`data-l10n-id`,e._l10nResizer[n])}}this.#V(0),this.#g=!0,this.#s.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#R(t){e._resizerKeyboardManager.exec(this,t)}#z(e){this.#g&&e.relatedTarget?.parentNode!==this.#s&&this.#H()}#B(e){this.#d=this.#g?e:``}#V(e){if(this.#t)for(let t of this.#t)t.tabIndex=e}_resizeWithKeyboard(e,t){this.#g&&this.#j(this.#d,{deltaX:e,deltaY:t,fromKeyboard:!0})}#H(){this.#g=!1,this.#V(-1),this.#A()}_stopResizingWithKeyboard(){this.#H(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add(`selectedEditor`),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains(`selectedEditor`)&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}unselect(){this.#s?.classList.add(`hidden`),this.div?.classList.remove(`selectedEditor`),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0)}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#m}set isEditing(e){this.#m=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){this.#o=!0;let n=e/t,{style:r}=this.div;r.aspectRatio=n,r.height=`auto`}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:`added`}}get telemetryFinalData(){return null}_reportTelemetry(t,n=!1){if(n){this.#b||=new Map;let{action:n}=t,r=this.#b.get(n);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),this.#b.delete(n),this.#b.size===0&&(this.#b=null)},e._telemetryTimeout),this.#b.set(n,r);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:t}})}show(e=this._isVisible){this.div.classList.toggle(`hidden`,!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#r=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#r=!0}renderAnnotationElement(e){let t=e.container.querySelector(`.annotationContent`);if(!t)t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.container.prepend(t);else if(t.nodeName===`CANVAS`){let e=t;t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.before(t)}return t}resetAnnotationElement(e){let{firstChild:t}=e.container;t?.nodeName===`DIV`&&t.classList.contains(`annotationContent`)&&t.remove()}},Ue=class extends W{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},We=3285377520,G=4294901760,K=65535,Ge=class{constructor(e){this.h1=e?e&4294967295:We,this.h2=e?e&4294967295:We}update(e){let t,n;if(typeof e==`string`){t=new Uint8Array(e.length*2),n=0;for(let r=0,i=e.length;r<i;r++){let i=e.charCodeAt(r);i<=255?t[n++]=i:(t[n++]=i>>>8,t[n++]=i&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),n=t.byteLength;else throw Error(`Invalid data format, must be a string or TypedArray.`);let r=n>>2,i=n-r*4,a=new Uint32Array(t.buffer,0,r),o=0,s=0,c=this.h1,l=this.h2,u=3432918353,d=461845907,f=u&K,p=d&K;for(let e=0;e<r;e++)e&1?(o=a[e],o=o*u&G|o*f&K,o=o<<15|o>>>17,o=o*d&G|o*p&K,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(s=a[e],s=s*u&G|s*f&K,s=s<<15|s>>>17,s=s*d&G|s*p&K,l^=s,l=l<<13|l>>>19,l=l*5+3864292196);switch(o=0,i){case 3:o^=t[r*4+2]<<16;case 2:o^=t[r*4+1]<<8;case 1:o^=t[r*4],o=o*u&G|o*f&K,o=o<<15|o>>>17,o=o*d&G|o*p&K,r&1?c^=o:l^=o}this.h1=c,this.h2=l}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&G|e*36045&K,t=t*4283543511&G|((t<<16|e>>>16)*2950163797&G)>>>16,e^=t>>>1,e=e*444984403&G|e*60499&K,t=t*3301882366&G|((t<<16|e>>>16)*3120437893&G)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}},Ke=Object.freeze({map:null,hash:``,transfer:void 0}),qe=class{#e=!1;#t=null;#n=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){let n=this.#n.get(e);return n===void 0?t:Object.assign(t,n)}getRawValue(e){return this.#n.get(e)}remove(e){if(this.#n.delete(e),this.#n.size===0&&this.resetModified(),typeof this.onAnnotationEditor==`function`){for(let e of this.#n.values())if(e instanceof W)return;this.onAnnotationEditor(null)}}setValue(e,t){let n=this.#n.get(e),r=!1;if(n!==void 0)for(let[e,i]of Object.entries(t))n[e]!==i&&(r=!0,n[e]=i);else r=!0,this.#n.set(e,t);r&&this.#r(),t instanceof W&&typeof this.onAnnotationEditor==`function`&&this.onAnnotationEditor(t.constructor._type)}has(e){return this.#n.has(e)}getAll(){return this.#n.size>0?ae(this.#n):null}setAll(e){for(let[t,n]of Object.entries(e))this.setValue(t,n)}get size(){return this.#n.size}#r(){this.#e||(this.#e=!0,typeof this.onSetModified==`function`&&this.onSetModified())}resetModified(){this.#e&&(this.#e=!1,typeof this.onResetModified==`function`&&this.onResetModified())}get print(){return new Je(this)}get serializable(){if(this.#n.size===0)return Ke;let e=new Map,t=new Ge,n=[],r=Object.create(null),i=!1;for(let[n,a]of this.#n){let o=a instanceof W?a.serialize(!1,r):a;o&&(e.set(n,o),t.update(`${n}:${JSON.stringify(o)}`),i||=!!o.bitmap)}if(i)for(let t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:Ke}get editorStats(){let e=null,t=new Map;for(let n of this.#n.values()){if(!(n instanceof W))continue;let r=n.telemetryFinalData;if(!r)continue;let{type:i}=r;t.has(i)||t.set(i,Object.getPrototypeOf(n).constructor),e||=Object.create(null);let a=e[i]||=new Map;for(let[e,t]of Object.entries(r)){if(e===`type`)continue;let n=a.get(e);n||(n=new Map,a.set(e,n));let r=n.get(t)??0;n.set(t,r+1)}}for(let[n,r]of t)e[n]=r.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){this.#t=null}get modifiedIds(){if(this.#t)return this.#t;let e=[];for(let t of this.#n.values())!(t instanceof W)||!t.annotationElementId||!t.serialize()||e.push(t.annotationElementId);return this.#t={ids:new Set(e),hash:e.join(`,`)}}},Je=class extends qe{#e;constructor(e){super();let{map:t,hash:n,transfer:r}=e.serializable;this.#e={map:structuredClone(t,r?{transfer:r}:null),hash:n,transfer:r}}get print(){E(`Should not call PrintAnnotationStorage.print`)}get serializable(){return this.#e}get modifiedIds(){return A(this,`modifiedIds`,{ids:new Set,hash:``})}},Ye=class{#e=new Set;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement(`style`),this._document.documentElement.getElementsByTagName(`head`)[0].append(this.styleElement));let t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),this.#e.clear(),this.styleElement&&=(this.styleElement.remove(),null)}async loadSystemFont({systemFontInfo:e,_inspectFont:t}){if(!(!e||this.#e.has(e.loadedName))){if(D(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:n,src:r,style:i}=e,a=new FontFace(n,r,i);this.addNativeFontFace(a);try{await a.load(),this.#e.add(n),t?.(e)}catch{T(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}E(`Not implemented: loadSystemFont without the Font Loading API.`)}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){let t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(n){throw T(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(t=>{let n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)})}}get isFontLoadingAPISupported(){let e=!!this._document?.fonts;return A(this,`isFontLoadingAPISupported`,e)}get isSyncFontLoadingSupported(){let e=!1;return(r||typeof navigator<`u`&&typeof navigator?.userAgent==`string`&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),A(this,`isSyncFontLoadingSupported`,e)}_queueLoadingCallback(e){function t(){for(D(!r.done,`completeRequest() cannot be called twice.`),r.done=!0;n.length>0&&n[0].done;){let e=n.shift();setTimeout(e.callback,0)}}let{loadingRequests:n}=this,r={done:!1,complete:t,callback:e};return n.push(r),r}get _loadTestFont(){let e=atob(`T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==`);return A(this,`_loadTestFont`,e)}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3)&255}function r(e,t,n,r){let i=e.substring(0,t),a=e.substring(t+n);return i+r+a}let i,a,o=this._document.createElement(`canvas`);o.width=1,o.height=1;let s=o.getContext(`2d`),c=0;function l(e,t){if(++c>30){T(`Load test font never loaded.`),t();return}if(s.font=`30px `+e,s.fillText(`.`,0,20),s.getImageData(0,0,1,1).data[3]>0){t();return}setTimeout(l.bind(null,e,t))}let u=`lt${Date.now()}${this.loadTestFontId++}`,d=this._loadTestFont;d=r(d,976,u.length,u);let f=1482184792,p=n(d,16);for(i=0,a=u.length-3;i<a;i+=4)p=p-f+n(u,i)|0;i<u.length&&(p=p-f+n(u+`XXX`,i)|0),d=r(d,16,4,ie(p));let m=`@font-face {font-family:"${u}";src:${`url(data:font/opentype;base64,${btoa(d)});`}}`;this.insertRule(m);let h=this._document.createElement(`div`);h.style.visibility=`hidden`,h.style.width=h.style.height=`10px`,h.style.position=`absolute`,h.style.top=h.style.left=`0px`;for(let t of[e.loadedName,u]){let e=this._document.createElement(`span`);e.textContent=`Hi`,e.style.fontFamily=t,h.append(e)}this._document.body.append(h),l(u,()=>{h.remove(),t.complete()})}},Xe=class{constructor(e,{disableFontFace:t=!1,fontExtraProperties:n=!1,inspectFont:r=null}){this.compiledGlyphs=Object.create(null);for(let t in e)this[t]=e[t];this.disableFontFace=t===!0,this.fontExtraProperties=n===!0,this._inspectFont=r}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{let t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${he(this.data)});`,t;if(!this.cssFontInfo)t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${e}}`}return this._inspectFont?.(this,e),t}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let n=this.loadedName+`_path_`+t,r;try{r=e.get(n)}catch(e){T(`getPathGenerator - ignoring character: "${e}".`)}let i=new Path2D(r||``);return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[t]=i}},Ze={DATA:1,ERROR:2},q={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Qe(){}function J(e){if(e instanceof I||e instanceof P||e instanceof F||e instanceof M||e instanceof ee||e instanceof N)return e;switch(e instanceof Error||typeof e==`object`&&e||E(`wrapReason: Expected "reason" to be a (possibly cloned) Error.`),e.name){case`AbortException`:return new I(e.message);case`InvalidPDFException`:return new P(e.message);case`MissingPDFException`:return new F(e.message);case`PasswordException`:return new M(e.message,e.code);case`UnexpectedResponseException`:return new ee(e.message,e.status);case`UnknownErrorException`:return new N(e.message,e.details)}return new N(e.message,e.toString())}var $e=class{#e=new AbortController;constructor(e,t,n){this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),n.addEventListener(`message`,this.#t.bind(this),{signal:this.#e.signal})}#t({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){this.#r(e);return}if(e.callback){let t=e.callbackId,n=this.callbackCapabilities[t];if(!n)throw Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],e.callback===Ze.DATA)n.resolve(e.data);else if(e.callback===Ze.ERROR)n.reject(J(e.reason));else throw Error(`Unexpected callback case`);return}let t=this.actionHandler[e.action];if(!t)throw Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){let n=this.sourceName,r=e.sourceName,i=this.comObj;Promise.try(t,e.data).then(function(t){i.postMessage({sourceName:n,targetName:r,callback:Ze.DATA,callbackId:e.callbackId,data:t})},function(t){i.postMessage({sourceName:n,targetName:r,callback:Ze.ERROR,callbackId:e.callbackId,reason:J(t)})});return}if(e.streamId){this.#n(e);return}t(e.data)}on(e,t){let n=this.actionHandler;if(n[e])throw Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){let r=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[r]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:r,data:t},n)}catch(e){i.reject(e)}return i.promise}sendWithStream(e,t,n,r){let i=this.streamId++,a=this.sourceName,o=this.targetName,s=this.comObj;return new ReadableStream({start:n=>{let c=Promise.withResolvers();return this.streamControllers[i]={controller:n,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},s.postMessage({sourceName:a,targetName:o,action:e,streamId:i,data:t,desiredSize:n.desiredSize},r),c.promise},pull:e=>{let t=Promise.withResolvers();return this.streamControllers[i].pullCall=t,s.postMessage({sourceName:a,targetName:o,stream:q.PULL,streamId:i,desiredSize:e.desiredSize}),t.promise},cancel:e=>{D(e instanceof Error,`cancel must have a valid reason`);let t=Promise.withResolvers();return this.streamControllers[i].cancelCall=t,this.streamControllers[i].isClosed=!0,s.postMessage({sourceName:a,targetName:o,stream:q.CANCEL,streamId:i,reason:J(e)}),t.promise}},n)}#n(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this,o=this.actionHandler[e.action],s={enqueue(e,a=1,o){if(this.isCancelled)return;let s=this.desiredSize;this.desiredSize-=a,s>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:n,targetName:r,stream:q.ENQUEUE,streamId:t,chunk:e},o)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:q.CLOSE,streamId:t}),delete a.streamSinks[t])},error(e){D(e instanceof Error,`error must have a valid reason`),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:q.ERROR,streamId:t,reason:J(e)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};s.sinkCapability.resolve(),s.ready=s.sinkCapability.promise,this.streamSinks[t]=s,Promise.try(o,e.data,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.START_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.START_COMPLETE,streamId:t,reason:J(e)})})}#r(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this.streamControllers[t],o=this.streamSinks[t];switch(e.stream){case q.START_COMPLETE:e.success?a.startCall.resolve():a.startCall.reject(J(e.reason));break;case q.PULL_COMPLETE:e.success?a.pullCall.resolve():a.pullCall.reject(J(e.reason));break;case q.PULL:if(!o){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||Qe).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,reason:J(e)})});break;case q.ENQUEUE:if(D(a,`enqueue should have stream controller`),a.isClosed)break;a.controller.enqueue(e.chunk);break;case q.CLOSE:if(D(a,`close should have stream controller`),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#i(a,t);break;case q.ERROR:D(a,`error should have stream controller`),a.controller.error(J(e.reason)),this.#i(a,t);break;case q.CANCEL_COMPLETE:e.success?a.cancelCall.resolve():a.cancelCall.reject(J(e.reason)),this.#i(a,t);break;case q.CANCEL:if(!o)break;let s=J(e.reason);Promise.try(o.onCancel||Qe,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.CANCEL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.CANCEL_COMPLETE,streamId:t,reason:J(e)})}),o.sinkCapability.reject(s),o.isCancelled=!0,delete this.streamSinks[t];break;default:throw Error(`Unexpected stream case`)}}async#i(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]}destroy(){this.#e?.abort(),this.#e=null}},et=class{#e=!1;constructor({enableHWA:e=!1}){this.#e=e}create(e,t){if(e<=0||t<=0)throw Error(`Invalid canvas size`);let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext(`2d`,{willReadFrequently:!this.#e})}}reset(e,t,n){if(!e.canvas)throw Error(`Canvas is not specified`);if(t<=0||n<=0)throw Error(`Invalid canvas size`);e.canvas.width=t,e.canvas.height=n}destroy(e){if(!e.canvas)throw Error(`Canvas is not specified`);e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){E("Abstract method `_createCanvas` called.")}},tt=class extends et{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){let n=this._document.createElement(`canvas`);return n.width=e,n.height=t,n}},nt=class{constructor({baseUrl:e=null,isCompressed:t=!0}){this.baseUrl=e,this.isCompressed=t}async fetch({name:e}){if(!this.baseUrl)throw Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw Error(`CMap name must be specified.`);let t=this.baseUrl+e+(this.isCompressed?`.bcmap`:``);return this._fetch(t).then(e=>({cMapData:e,isCompressed:this.isCompressed})).catch(e=>{throw Error(`Unable to load ${this.isCompressed?`binary `:``}CMap at: ${t}`)})}async _fetch(e){E("Abstract method `_fetch` called.")}},rt=class extends nt{async _fetch(e){let t=await _e(e,this.isCompressed?`arraybuffer`:`text`);return t instanceof ArrayBuffer?new Uint8Array(t):re(t)}},it=class{addFilter(e){return`none`}addHCMFilter(e,t){return`none`}addAlphaFilter(e){return`none`}addLuminosityFilter(e){return`none`}addHighlightHCMFilter(e,t,n,r,i){return`none`}destroy(e=!1){}},at=class extends it{#e;#t;#n;#r;#i;#a;#o=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super(),this.#r=e,this.#i=t}get#s(){return this.#t||=new Map}get#c(){return this.#a||=new Map}get#l(){if(!this.#n){let e=this.#i.createElement(`div`),{style:t}=e;t.visibility=`hidden`,t.contain=`strict`,t.width=t.height=0,t.position=`absolute`,t.top=t.left=0,t.zIndex=-1;let n=this.#i.createElementNS(z,`svg`);n.setAttribute(`width`,0),n.setAttribute(`height`,0),this.#n=this.#i.createElementNS(z,`defs`),e.append(n),n.append(this.#n),this.#i.body.append(e)}return this.#n}#u(e){if(e.length===1){let t=e[0],n=Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;let r=n.join(`,`);return[r,r,r]}let[t,n,r]=e,i=Array(256),a=Array(256),o=Array(256);for(let e=0;e<256;e++)i[e]=t[e]/255,a[e]=n[e]/255,o[e]=r[e]/255;return[i.join(`,`),a.join(`,`),o.join(`,`)]}#d(e){if(this.#e===void 0){this.#e=``;let e=this.#i.URL;e!==this.#i.baseURI&&(be(e)?T(`#createUrl: ignore "data:"-URL for performance reasons.`):this.#e=e.split(`#`,1)[0])}return`url(${this.#e}#${e})`}addFilter(e){if(!e)return`none`;let t=this.#s.get(e);if(t)return t;let[n,r,i]=this.#u(e),a=e.length===1?n:`${n}${r}${i}`;if(t=this.#s.get(a),t)return this.#s.set(e,t),t;let o=`g_${this.#r}_transfer_map_${this.#o++}`,s=this.#d(o);this.#s.set(e,s),this.#s.set(a,s);let c=this.#m(o);return this.#g(n,r,i,c),s}addHCMFilter(e,t){let n=`${e}-${t}`,r=`base`,i=this.#c.get(r);if(i?.key===n||(i?(i.filter?.remove(),i.key=n,i.url=`none`,i.filter=null):(i={key:n,url:`none`,filter:null},this.#c.set(r,i)),!e||!t))return i.url;let a=this.#v(e);e=R.makeHexColor(...a);let o=this.#v(t);if(t=R.makeHexColor(...o),this.#l.style.color=``,e===`#000000`&&t===`#ffffff`||e===t)return i.url;let s=Array(256);for(let e=0;e<=255;e++){let t=e/255;s[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}let c=s.join(`,`),l=`g_${this.#r}_hcm_filter`,u=i.filter=this.#m(l);this.#g(c,c,c,u),this.#p(u);let d=(e,t)=>{let n=a[e]/255,r=o[e]/255,i=Array(t+1);for(let e=0;e<=t;e++)i[e]=n+e/t*(r-n);return i.join(`,`)};return this.#g(d(0,5),d(1,5),d(2,5),u),i.url=this.#d(l),i.url}addAlphaFilter(e){let t=this.#s.get(e);if(t)return t;let[n]=this.#u([e]),r=`alpha_${n}`;if(t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_alpha_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#_(n,o),a}addLuminosityFilter(e){let t=this.#s.get(e||`luminosity`);if(t)return t;let n,r;if(e?([n]=this.#u([e]),r=`luminosity_${n}`):r=`luminosity`,t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_luminosity_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#f(o),e&&this.#_(n,o),a}addHighlightHCMFilter(e,t,n,r,i){let a=`${t}-${n}-${r}-${i}`,o=this.#c.get(e);if(o?.key===a||(o?(o.filter?.remove(),o.key=a,o.url=`none`,o.filter=null):(o={key:a,url:`none`,filter:null},this.#c.set(e,o)),!t||!n))return o.url;let[s,c]=[t,n].map(this.#v.bind(this)),l=Math.round(.2126*s[0]+.7152*s[1]+.0722*s[2]),u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[d,f]=[r,i].map(this.#v.bind(this));u<l&&([l,u,d,f]=[u,l,f,d]),this.#l.style.color=``;let p=(e,t,n)=>{let r=Array(256),i=(u-l)/n,a=e/255,o=(t-e)/(255*n),s=0;for(let e=0;e<=n;e++){let t=Math.round(l+e*i),n=a+e*o;for(let e=s;e<=t;e++)r[e]=n;s=t+1}for(let e=s;e<256;e++)r[e]=r[s-1];return r.join(`,`)},m=`g_${this.#r}_hcm_${e}_filter`,h=o.filter=this.#m(m);return this.#p(h),this.#g(p(d[0],f[0],5),p(d[1],f[1],5),p(d[2],f[2],5),h),o.url=this.#d(m),o.url}destroy(e=!1){e&&this.#a?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#t?.clear(),this.#t=null,this.#a?.clear(),this.#a=null,this.#o=0)}#f(e){let t=this.#i.createElementNS(z,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.setAttribute(`values`,`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0`),e.append(t)}#p(e){let t=this.#i.createElementNS(z,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.setAttribute(`values`,`0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0`),e.append(t)}#m(e){let t=this.#i.createElementNS(z,`filter`);return t.setAttribute(`color-interpolation-filters`,`sRGB`),t.setAttribute(`id`,e),this.#l.append(t),t}#h(e,t,n){let r=this.#i.createElementNS(z,t);r.setAttribute(`type`,`discrete`),r.setAttribute(`tableValues`,n),e.append(r)}#g(e,t,n,r){let i=this.#i.createElementNS(z,`feComponentTransfer`);r.append(i),this.#h(i,`feFuncR`,e),this.#h(i,`feFuncG`,t),this.#h(i,`feFuncB`,n)}#_(e,t){let n=this.#i.createElementNS(z,`feComponentTransfer`);t.append(n),this.#h(n,`feFuncA`,e)}#v(e){return this.#l.style.color=e,Oe(getComputedStyle(this.#l).getPropertyValue(`color`))}},ot=class{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw Error(`Font filename must be specified.`);let t=`${this.baseUrl}${e}`;return this._fetch(t).catch(e=>{throw Error(`Unable to load font data at: ${t}`)})}async _fetch(e){E("Abstract method `_fetch` called.")}},st=class extends ot{async _fetch(e){let t=await _e(e,`arraybuffer`);return new Uint8Array(t)}};r&&T("Please use the `legacy` build in Node.js environments.");async function ct(e){let t=await process.getBuiltinModule(`fs`).promises.readFile(e);return new Uint8Array(t)}var lt=class extends it{},ut=class extends et{_createCanvas(e,t){return process.getBuiltinModule(`module`).createRequire(import.meta.url)(`@napi-rs/canvas`).createCanvas(e,t)}},dt=class extends nt{async _fetch(e){return ct(e)}},ft=class extends ot{async _fetch(e){return ct(e)}},Y={FILL:`Fill`,STROKE:`Stroke`,SHADING:`Shading`};function pt(e,t){if(!t)return;let n=t[2]-t[0],r=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],n,r),e.clip(i)}var mt=class{getPattern(){E("Abstract method `getPattern` called.")}},ht=class extends mt{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;this._type===`axial`?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type===`radial`&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let e of this._colorStops)t.addColorStop(e[0],e[1]);return t}getPattern(e,t,n,r){let i;if(r===Y.STROKE||r===Y.FILL){let a=t.current.getClippedPathBoundingBox(r,H(e))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,s=Math.ceil(a[3]-a[1])||1,c=t.cachedCanvases.getCanvas(`pattern`,o,s),l=c.context;l.clearRect(0,0,l.canvas.width,l.canvas.height),l.beginPath(),l.rect(0,0,l.canvas.width,l.canvas.height),l.translate(-a[0],-a[1]),n=R.transform(n,[1,0,0,1,a[0],a[1]]),l.transform(...t.baseTransform),this.matrix&&l.transform(...this.matrix),pt(l,this._bbox),l.fillStyle=this._createGradient(l),l.fill(),i=e.createPattern(c.canvas,`no-repeat`);let u=new DOMMatrix(n);i.setTransform(u)}else pt(e,this._bbox),i=this._createGradient(e);return i}};function gt(e,t,n,r,i,a,o,s){let c=t.coords,l=t.colors,u=e.data,d=e.width*4,f;c[n+1]>c[r+1]&&(f=n,n=r,r=f,f=a,a=o,o=f),c[r+1]>c[i+1]&&(f=r,r=i,i=f,f=o,o=s,s=f),c[n+1]>c[r+1]&&(f=n,n=r,r=f,f=a,a=o,o=f);let p=(c[n]+t.offsetX)*t.scaleX,m=(c[n+1]+t.offsetY)*t.scaleY,h=(c[r]+t.offsetX)*t.scaleX,g=(c[r+1]+t.offsetY)*t.scaleY,_=(c[i]+t.offsetX)*t.scaleX,v=(c[i+1]+t.offsetY)*t.scaleY;if(m>=v)return;let y=l[a],b=l[a+1],x=l[a+2],S=l[o],C=l[o+1],w=l[o+2],T=l[s],E=l[s+1],D=l[s+2],O=Math.round(m),k=Math.round(v),A,j,M,N,P,F,ee,te;for(let e=O;e<=k;e++){if(e<g){let t=e<m?0:(m-e)/(m-g);A=p-(p-h)*t,j=y-(y-S)*t,M=b-(b-C)*t,N=x-(x-w)*t}else{let t;t=e>v?1:g===v?0:(g-e)/(g-v),A=h-(h-_)*t,j=S-(S-T)*t,M=C-(C-E)*t,N=w-(w-D)*t}let t;t=e<m?0:e>v?1:(m-e)/(m-v),P=p-(p-_)*t,F=y-(y-T)*t,ee=b-(b-E)*t,te=x-(x-D)*t;let n=Math.round(Math.min(A,P)),r=Math.round(Math.max(A,P)),i=d*e+n*4;for(let e=n;e<=r;e++)t=(A-e)/(A-P),t<0?t=0:t>1&&(t=1),u[i++]=j-(j-F)*t|0,u[i++]=M-(M-ee)*t|0,u[i++]=N-(N-te)*t|0,u[i++]=255}}function _t(e,t,n){let r=t.coords,i=t.colors,a,o;switch(t.type){case`lattice`:let s=t.verticesPerRow,c=Math.floor(r.length/s)-1,l=s-1;for(a=0;a<c;a++){let t=a*s;for(let a=0;a<l;a++,t++)gt(e,n,r[t],r[t+1],r[t+s],i[t],i[t+1],i[t+s]),gt(e,n,r[t+s+1],r[t+1],r[t+s],i[t+s+1],i[t+1],i[t+s])}break;case`triangles`:for(a=0,o=r.length;a<o;a+=3)gt(e,n,r[a],r[a+1],r[a+2],i[a],i[a+1],i[a+2]);break;default:throw Error(`illegal figure`)}}var vt=class extends mt{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[7],this._background=e[8],this.matrix=null}_createMeshCanvas(e,t,n){let r=1.1,i=3e3,a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),s=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-o,l=Math.min(Math.ceil(Math.abs(s*e[0]*r)),i),u=Math.min(Math.ceil(Math.abs(c*e[1]*r)),i),d=s/l,f=c/u,p={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-o,scaleX:1/d,scaleY:1/f},m=l+4,h=u+4,g=n.getCanvas(`mesh`,m,h),_=g.context,v=_.createImageData(l,u);if(t){let e=v.data;for(let n=0,r=e.length;n<r;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=255}for(let e of this._figures)_t(v,e,p);return _.putImageData(v,2,2),{canvas:g.canvas,offsetX:a-2*d,offsetY:o-2*f,scaleX:d,scaleY:f}}getPattern(e,t,n,r){pt(e,this._bbox);let i;if(r===Y.SHADING)i=R.singularValueDecompose2dScale(H(e));else if(i=R.singularValueDecompose2dScale(t.baseTransform),this.matrix){let e=R.singularValueDecompose2dScale(this.matrix);i=[i[0]*e[0],i[1]*e[1]]}let a=this._createMeshCanvas(i,r===Y.SHADING?null:this._background,t.cachedCanvases);return r!==Y.SHADING&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(a.offsetX,a.offsetY),e.scale(a.scaleX,a.scaleY),e.createPattern(a.canvas,`no-repeat`)}},yt=class extends mt{getPattern(){return`hotpink`}};function bt(e){switch(e[0]){case`RadialAxial`:return new ht(e);case`Mesh`:return new vt(e);case`Dummy`:return new yt}throw Error(`Unknown IR type: ${e[0]}`)}var xt={COLORED:1,UNCOLORED:2},St=class e{static MAX_PATTERN_SIZE=3e3;constructor(e,t,n,r,i){this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.color=t,this.ctx=n,this.canvasGraphicsFactory=r,this.baseTransform=i}createPatternCanvas(e){let{bbox:t,operatorList:n,paintType:r,tilingType:i,color:a,canvasGraphicsFactory:o}=this,{xstep:s,ystep:c}=this;s=Math.abs(s),c=Math.abs(c),w(`TilingType: `+i);let l=t[0],u=t[1],d=t[2],f=t[3],p=d-l,m=f-u,h=R.singularValueDecompose2dScale(this.matrix),g=R.singularValueDecompose2dScale(this.baseTransform),_=h[0]*g[0],v=h[1]*g[1],y=p,b=m,x=!1,S=!1,C=Math.ceil(s*_),T=Math.ceil(c*v),E=Math.ceil(p*_),D=Math.ceil(m*v);C>=E?y=s:x=!0,T>=D?b=c:S=!0;let O=this.getSizeAndScale(y,this.ctx.canvas.width,_),k=this.getSizeAndScale(b,this.ctx.canvas.height,v),A=e.cachedCanvases.getCanvas(`pattern`,O.size,k.size),j=A.context,M=o.createCanvasGraphics(j);if(M.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(M,r,a),j.translate(-O.scale*l,-k.scale*u),M.transform(O.scale,0,0,k.scale,0,0),j.save(),this.clipBbox(M,l,u,d,f),M.baseTransform=H(M.ctx),M.executeOperatorList(n),M.endDrawing(),j.restore(),x||S){let t=A.canvas;x&&(y=s),S&&(b=c);let n=this.getSizeAndScale(y,this.ctx.canvas.width,_),r=this.getSizeAndScale(b,this.ctx.canvas.height,v),i=n.size,a=r.size,o=e.cachedCanvases.getCanvas(`pattern-workaround`,i,a),d=o.context,f=x?Math.floor(p/s):0,h=S?Math.floor(m/c):0;for(let e=0;e<=f;e++)for(let n=0;n<=h;n++)d.drawImage(t,i*e,a*n,i,a,0,0,i,a);return{canvas:o.canvas,scaleX:n.scale,scaleY:r.scale,offsetX:l,offsetY:u}}return{canvas:A.canvas,scaleX:O.scale,scaleY:k.scale,offsetX:l,offsetY:u}}getSizeAndScale(t,n,r){let i=Math.max(e.MAX_PATTERN_SIZE,n),a=Math.ceil(t*r);return a>=i?a=i:r=a/t,{scale:r,size:a}}clipBbox(e,t,n,r,i){let a=r-t,o=i-n;e.ctx.rect(t,n,a,o),e.current.updateRectMinMax(H(e.ctx),[t,n,r,i]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,n){let r=e.ctx,i=e.current;switch(t){case xt.COLORED:let e=this.ctx;r.fillStyle=e.fillStyle,r.strokeStyle=e.strokeStyle,i.fillColor=e.fillStyle,i.strokeColor=e.strokeStyle;break;case xt.UNCOLORED:let a=R.makeHexColor(n[0],n[1],n[2]);r.fillStyle=a,r.strokeStyle=a,i.fillColor=a,i.strokeColor=a;break;default:throw new te(`Unsupported paint type: ${t}`)}}getPattern(e,t,n,r){let i=n;r!==Y.SHADING&&(i=R.transform(i,t.baseTransform),this.matrix&&(i=R.transform(i,this.matrix)));let a=this.createPatternCanvas(t),o=new DOMMatrix(i);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);let s=e.createPattern(a.canvas,`repeat`);return s.setTransform(o),s}};function Ct({src:e,srcPos:t=0,dest:n,width:r,height:i,nonBlackColor:a=4294967295,inverseDecode:o=!1}){let s=L.isLittleEndian?4278190080:255,[c,l]=o?[a,s]:[s,a],u=r>>3,d=r&7,f=e.length;n=new Uint32Array(n.buffer);let p=0;for(let r=0;r<i;r++){for(let r=t+u;t<r;t++){let r=t<f?e[t]:255;n[p++]=r&128?l:c,n[p++]=r&64?l:c,n[p++]=r&32?l:c,n[p++]=r&16?l:c,n[p++]=r&8?l:c,n[p++]=r&4?l:c,n[p++]=r&2?l:c,n[p++]=r&1?l:c}if(d===0)continue;let r=t<f?e[t++]:255;for(let e=0;e<d;e++)n[p++]=r&1<<7-e?l:c}return{srcPos:t,destPos:p}}var wt=16,Tt=100,Et=15,Dt=10,Ot=1e3,X=16;function kt(e,t){if(e._removeMirroring)throw Error(`Context is already forwarding operations.`);e.__originalSave=e.save,e.__originalRestore=e.restore,e.__originalRotate=e.rotate,e.__originalScale=e.scale,e.__originalTranslate=e.translate,e.__originalTransform=e.transform,e.__originalSetTransform=e.setTransform,e.__originalResetTransform=e.resetTransform,e.__originalClip=e.clip,e.__originalMoveTo=e.moveTo,e.__originalLineTo=e.lineTo,e.__originalBezierCurveTo=e.bezierCurveTo,e.__originalRect=e.rect,e.__originalClosePath=e.closePath,e.__originalBeginPath=e.beginPath,e._removeMirroring=()=>{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(e,n){t.translate(e,n),this.__originalTranslate(e,n)},e.scale=function(e,n){t.scale(e,n),this.__originalScale(e,n)},e.transform=function(e,n,r,i,a,o){t.transform(e,n,r,i,a,o),this.__originalTransform(e,n,r,i,a,o)},e.setTransform=function(e,n,r,i,a,o){t.setTransform(e,n,r,i,a,o),this.__originalSetTransform(e,n,r,i,a,o)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(e){t.rotate(e),this.__originalRotate(e)},e.clip=function(e){t.clip(e),this.__originalClip(e)},e.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},e.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},e.bezierCurveTo=function(e,n,r,i,a,o){t.bezierCurveTo(e,n,r,i,a,o),this.__originalBezierCurveTo(e,n,r,i,a,o)},e.rect=function(e,n,r,i){t.rect(e,n,r,i),this.__originalRect(e,n,r,i)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}var At=class{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,n){let r;return this.cache[e]===void 0?(r=this.canvasFactory.create(t,n),this.cache[e]=r):(r=this.cache[e],this.canvasFactory.reset(r,t,n)),r}delete(e){delete this.cache[e]}clear(){for(let e in this.cache){let t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}};function jt(e,t,n,r,i,a,o,s,c,l){let[u,d,f,p,m,h]=H(e);if(d===0&&f===0){let g=o*u+m,_=Math.round(g),v=s*p+h,y=Math.round(v),b=(o+c)*u+m,x=Math.abs(Math.round(b)-_)||1,S=(s+l)*p+h,C=Math.abs(Math.round(S)-y)||1;return e.setTransform(Math.sign(u),0,0,Math.sign(p),_,y),e.drawImage(t,n,r,i,a,0,0,x,C),e.setTransform(u,d,f,p,m,h),[x,C]}if(u===0&&p===0){let g=s*f+m,_=Math.round(g),v=o*d+h,y=Math.round(v),b=(s+l)*f+m,x=Math.abs(Math.round(b)-_)||1,S=(o+c)*d+h,C=Math.abs(Math.round(S)-y)||1;return e.setTransform(0,Math.sign(d),Math.sign(f),0,_,y),e.drawImage(t,n,r,i,a,0,0,C,x),e.setTransform(u,d,f,p,m,h),[C,x]}e.drawImage(t,n,r,i,a,o,s,c,l);let g=Math.hypot(u,d),_=Math.hypot(f,p);return[g*c,_*l]}function Mt(e){let{width:t,height:n}=e;if(t>Ot||n>Ot)return null;let r=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),a=t+1,o=new Uint8Array(a*(n+1)),s,c,l,u=t+7&-8,d=new Uint8Array(u*n),f=0;for(let t of e.data){let e=128;for(;e>0;)d[f++]=t&e?0:255,e>>=1}let p=0;for(f=0,d[f]!==0&&(o[0]=1,++p),c=1;c<t;c++)d[f]!==d[f+1]&&(o[c]=d[f]?2:1,++p),f++;for(d[f]!==0&&(o[c]=2,++p),s=1;s<n;s++){f=s*u,l=s*a,d[f-u]!==d[f]&&(o[l]=d[f]?1:8,++p);let e=(d[f]?4:0)+(d[f-u]?8:0);for(c=1;c<t;c++)e=(e>>2)+(d[f+1]?4:0)+(d[f-u+1]?8:0),i[e]&&(o[l+c]=i[e],++p),f++;if(d[f-u]!==d[f]&&(o[l+c]=d[f]?2:4,++p),p>r)return null}for(f=u*(n-1),l=s*a,d[f]!==0&&(o[l]=8,++p),c=1;c<t;c++)d[f]!==d[f+1]&&(o[l+c]=d[f]?4:8,++p),f++;if(d[f]!==0&&(o[l+c]=4,++p),p>r)return null;let m=new Int32Array([0,a,-1,0,-a,0,0,0,1]),h=new Path2D;for(s=0;p&&s<=n;s++){let e=s*a,n=e+t;for(;e<n&&!o[e];)e++;if(e===n)continue;h.moveTo(e%a,s);let r=e,i=o[e];do{let t=m[i];do e+=t;while(!o[e]);let n=o[e];n!==5&&n!==10?(i=n,o[e]=0):(i=n&51*i>>4,o[e]&=i>>2|i<<2),h.lineTo(e%a,e/a|0),o[e]||--p}while(r!==e);--s}return d=null,o=null,function(e){e.save(),e.scale(1/t,-1/n),e.translate(0,-n),e.fill(h),e.beginPath(),e.restore()}}var Nt=class{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=i,this.textMatrixScale=1,this.fontMatrix=a,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=m.FILL,this.textRise=0,this.fillColor=`#000000`,this.strokeColor=`#000000`,this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps=`none`,this.startNewPathAndClipBox([0,0,e,t])}clone(){let e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,n){[t,n]=R.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(e,t){let n=R.applyTransform(t,e),r=R.applyTransform(t.slice(2),e),i=R.applyTransform([t[0],t[3]],e),a=R.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,n[0],r[0],i[0],a[0]),this.minY=Math.min(this.minY,n[1],r[1],i[1],a[1]),this.maxX=Math.max(this.maxX,n[0],r[0],i[0],a[0]),this.maxY=Math.max(this.maxY,n[1],r[1],i[1],a[1])}updateScalingPathMinMax(e,t){R.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.minY=Math.min(this.minY,t[1]),this.maxX=Math.max(this.maxX,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,r,i,a,o,s,c,l){let u=R.bezierBoundingBox(t,n,r,i,a,o,s,c,l);l||this.updateRectMinMax(e,u)}getPathBoundingBox(e=Y.FILL,t=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(e===Y.STROKE){t||E(`Stroke bounding box must include transform.`);let e=R.singularValueDecompose2dScale(t),r=e[0]*this.lineWidth/2,i=e[1]*this.lineWidth/2;n[0]-=r,n[1]-=i,n[2]+=r,n[3]+=i}return n}updateClipFromPath(){let e=R.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=Y.FILL,t=null){return R.intersect(this.clipBox,this.getPathBoundingBox(e,t))}};function Pt(e,t){if(t instanceof ImageData){e.putImageData(t,0,0);return}let n=t.height,r=t.width,i=n%X,a=(n-i)/X,o=i===0?a:a+1,s=e.createImageData(r,X),c=0,l,u=t.data,d=s.data,f,p,m,g;if(t.kind===h.GRAYSCALE_1BPP){let t=u.byteLength,n=new Uint32Array(d.buffer,0,d.byteLength>>2),h=n.length,g=r+7>>3,_=4294967295,v=L.isLittleEndian?4278190080:255;for(f=0;f<o;f++){for(m=f<a?X:i,l=0,p=0;p<m;p++){let e=t-c,i=0,a=e>g?r:e*8-7,o=a&-8,s=0,d=0;for(;i<o;i+=8)d=u[c++],n[l++]=d&128?_:v,n[l++]=d&64?_:v,n[l++]=d&32?_:v,n[l++]=d&16?_:v,n[l++]=d&8?_:v,n[l++]=d&4?_:v,n[l++]=d&2?_:v,n[l++]=d&1?_:v;for(;i<a;i++)s===0&&(d=u[c++],s=128),n[l++]=d&s?_:v,s>>=1}for(;l<h;)n[l++]=0;e.putImageData(s,0,f*X)}}else if(t.kind===h.RGBA_32BPP){for(p=0,g=r*X*4,f=0;f<a;f++)d.set(u.subarray(c,c+g)),c+=g,e.putImageData(s,0,p),p+=X;f<o&&(g=r*i*4,d.set(u.subarray(c,c+g)),e.putImageData(s,0,p))}else if(t.kind===h.RGB_24BPP)for(m=X,g=r*m,f=0;f<o;f++){for(f>=a&&(m=i,g=r*m),l=0,p=g;p--;)d[l++]=u[c++],d[l++]=u[c++],d[l++]=u[c++],d[l++]=255;e.putImageData(s,0,f*X)}else throw Error(`bad image kind: ${t.kind}`)}function Ft(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}let n=t.height,r=t.width,i=n%X,a=(n-i)/X,o=i===0?a:a+1,s=e.createImageData(r,X),c=0,l=t.data,u=s.data;for(let t=0;t<o;t++){let n=t<a?X:i;({srcPos:c}=Ct({src:l,srcPos:c,dest:u,width:r,height:n,nonBlackColor:0})),e.putImageData(s,0,t*X)}}function It(e,t){for(let n of[`strokeStyle`,`fillStyle`,`fillRule`,`globalAlpha`,`lineWidth`,`lineCap`,`lineJoin`,`miterLimit`,`globalCompositeOperation`,`font`,`filter`])e[n]!==void 0&&(t[n]=e[n]);e.setLineDash!==void 0&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function Lt(e){if(e.strokeStyle=e.fillStyle=`#000000`,e.fillRule=`nonzero`,e.globalAlpha=1,e.lineWidth=1,e.lineCap=`butt`,e.lineJoin=`miter`,e.miterLimit=10,e.globalCompositeOperation=`source-over`,e.font=`10px sans-serif`,e.setLineDash!==void 0&&(e.setLineDash([]),e.lineDashOffset=0),!r){let{filter:t}=e;t!==`none`&&t!==``&&(e.filter=`none`)}}function Rt(e,t){if(t)return!0;let n=R.singularValueDecompose2dScale(e);n[0]=Math.fround(n[0]),n[1]=Math.fround(n[1]);let r=Math.fround((globalThis.devicePixelRatio||1)*ge.PDF_TO_CSS_UNITS);return n[0]<=r&&n[1]<=r}var zt=[`butt`,`round`,`square`],Bt=[`miter`,`round`,`bevel`],Vt={},Ht={},Ut=class e{constructor(e,t,n,r,i,{optionalContentConfig:a,markedContentStack:o=null},s,c){this.ctx=e,this.current=new Nt(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=t,this.objs=n,this.canvasFactory=r,this.filterFactory=i,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedCanvases=new At(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=s,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,t=null){return typeof e==`string`?e.startsWith(`g_`)?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:r=null}){let i=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=r||`#ffffff`,this.ctx.fillRect(0,0,i,a),this.ctx.fillStyle=o,n){let e=this.cachedCanvases.getCanvas(`transparent`,i,a);this.compositeCtx=this.ctx,this.transparentCanvas=e.canvas,this.ctx=e.context,this.ctx.save(),this.ctx.transform(...H(this.compositeCtx))}this.ctx.save(),Lt(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=H(this.ctx)}executeOperatorList(e,t,n,r){let i=e.argsArray,a=e.fnArray,o=t||0,s=i.length;if(s===o)return o;let c=s-o>Dt&&typeof n==`function`,l=c?Date.now()+Et:0,u=0,d=this.commonObjs,f=this.objs,p;for(;;){if(r!==void 0&&o===r.nextBreakPoint)return r.breakIt(o,n),o;if(p=a[o],p!==y.dependency)this[p].apply(this,i[o]);else for(let e of i[o]){let t=e.startsWith(`g_`)?d:f;if(!t.has(e))return t.get(e,n),o}if(o++,o===s)return o;if(c&&++u>Dt){if(Date.now()>l)return n(),o;u=0}}}#e(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&=(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),null)}endDrawing(){this.#e(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let e of this._cachedBitmapsMap.values()){for(let t of e.values())typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),this.#t()}#t(){if(this.pageColors){let e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!==`none`){let t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}_scaleImage(e,t){let n=e.width??e.displayWidth,r=e.height??e.displayHeight,i=Math.max(Math.hypot(t[0],t[1]),1),a=Math.max(Math.hypot(t[2],t[3]),1),o=n,s=r,c=`prescale1`,l,u;for(;i>2&&o>1||a>2&&s>1;){let t=o,n=s;i>2&&o>1&&(t=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),i/=o/t),a>2&&s>1&&(n=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s)/2,a/=s/n),l=this.cachedCanvases.getCanvas(c,t,n),u=l.context,u.clearRect(0,0,t,n),u.drawImage(e,0,0,o,s,0,0,t,n),e=l.canvas,o=t,s=n,c=c===`prescale1`?`prescale2`:`prescale1`}return{img:e,paintWidth:o,paintHeight:s}}_createMaskCanvas(e){let t=this.ctx,{width:n,height:r}=e,i=this.current.fillColor,a=this.current.patternFill,o=H(t),s,c,l,u;if((e.bitmap||e.data)&&e.count>1){let t=e.bitmap||e.data.buffer;c=JSON.stringify(a?o:[o.slice(0,4),i]),s=this._cachedBitmapsMap.get(t),s||(s=new Map,this._cachedBitmapsMap.set(t,s));let n=s.get(c);if(n&&!a)return{canvas:n,offsetX:Math.round(Math.min(o[0],o[2])+o[4]),offsetY:Math.round(Math.min(o[1],o[3])+o[5])};l=n}l||(u=this.cachedCanvases.getCanvas(`maskCanvas`,n,r),Ft(u.context,e));let d=R.transform(o,[1/n,0,0,-1/r,0,0]);d=R.transform(d,[1,0,0,1,0,-r]);let[f,p,m,h]=R.getAxialAlignedBoundingBox([0,0,n,r],d),g=Math.round(m-f)||1,_=Math.round(h-p)||1,v=this.cachedCanvases.getCanvas(`fillCanvas`,g,_),y=v.context,b=f,x=p;y.translate(-b,-x),y.transform(...d),l||(l=this._scaleImage(u.canvas,U(y)),l=l.img,s&&a&&s.set(c,l)),y.imageSmoothingEnabled=Rt(H(y),e.interpolate),jt(y,l,0,0,l.width,l.height,0,0,n,r),y.globalCompositeOperation=`source-in`;let S=R.transform(U(y),[1,0,0,1,-b,-x]);return y.fillStyle=a?i.getPattern(t,this,S,Y.FILL):i,y.fillRect(0,0,n,r),s&&!a&&(this.cachedCanvases.delete(`fillCanvas`),s.set(c,v.canvas)),{canvas:v.canvas,offsetX:Math.round(b),offsetY:Math.round(x)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=zt[e]}setLineJoin(e){this.ctx.lineJoin=Bt[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){let n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(e),n.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,n]of e)switch(t){case`LW`:this.setLineWidth(n);break;case`LC`:this.setLineCap(n);break;case`LJ`:this.setLineJoin(n);break;case`ML`:this.setMiterLimit(n);break;case`D`:this.setDash(n[0],n[1]);break;case`RI`:this.setRenderingIntent(n);break;case`FL`:this.setFlatness(n);break;case`Font`:this.setFont(n[0],n[1]);break;case`CA`:this.current.strokeAlpha=n;break;case`ca`:this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case`BM`:this.ctx.globalCompositeOperation=n;break;case`SMask`:this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case`TR`:this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw Error(`beginSMaskMode called while already in smask mode`);let e=this.ctx.canvas.width,t=this.ctx.canvas.height,n=`smaskGroupAt`+this.groupLevel,r=this.cachedCanvases.getCanvas(n,e,t);this.suspendedCtx=this.ctx,this.ctx=r.context;let i=this.ctx;i.setTransform(...H(this.suspendedCtx)),It(this.suspendedCtx,i),kt(i,this.suspendedCtx),this.setGState([[`BM`,`source-over`],[`ca`,1],[`CA`,1]])}endSMaskMode(){if(!this.inSMaskMode)throw Error(`endSMaskMode called while not in smask mode`);this.ctx._removeMirroring(),It(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let t=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,t,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,t,n,r){let i=r[0],a=r[1],o=r[2]-i,s=r[3]-a;o===0||s===0||(this.genericComposeSMask(t.context,n,o,s,t.subtype,t.backdrop,t.transferMap,i,a,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation=`source-over`,e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,0,0),e.restore())}genericComposeSMask(e,t,n,r,i,a,o,s,c,l,u){let d=e.canvas,f=s-l,p=c-u;if(a){let t=R.makeHexColor(...a);if(f<0||p<0||f+n>d.width||p+r>d.height){let e=this.cachedCanvases.getCanvas(`maskExtension`,n,r),i=e.context;i.drawImage(d,-f,-p),i.globalCompositeOperation=`destination-atop`,i.fillStyle=t,i.fillRect(0,0,n,r),i.globalCompositeOperation=`source-over`,d=e.canvas,f=p=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);let i=new Path2D;i.rect(f,p,n,r),e.clip(i),e.globalCompositeOperation=`destination-atop`,e.fillStyle=t,e.fillRect(f,p,n,r),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),i===`Alpha`&&o?t.filter=this.filterFactory.addAlphaFilter(o):i===`Luminosity`&&(t.filter=this.filterFactory.addLuminosityFilter(o));let m=new Path2D;m.rect(s,c,n,r),t.clip(m),t.globalCompositeOperation=`destination-in`,t.drawImage(d,f,p,n,r,s,c,n,r),t.restore()}save(){this.inSMaskMode?(It(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),It(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,n,r,i,a){this.ctx.transform(e,t,n,r,i,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,n){let r=this.ctx,i=this.current,a=i.x,o=i.y,s,c,l=H(r),u=l[0]===0&&l[3]===0||l[1]===0&&l[2]===0,d=u?n.slice(0):null;for(let n=0,f=0,p=e.length;n<p;n++)switch(e[n]|0){case y.rectangle:a=t[f++],o=t[f++];let e=t[f++],n=t[f++],p=a+e,m=o+n;r.moveTo(a,o),e===0||n===0?r.lineTo(p,m):(r.lineTo(p,o),r.lineTo(p,m),r.lineTo(a,m)),u||i.updateRectMinMax(l,[a,o,p,m]),r.closePath();break;case y.moveTo:a=t[f++],o=t[f++],r.moveTo(a,o),u||i.updatePathMinMax(l,a,o);break;case y.lineTo:a=t[f++],o=t[f++],r.lineTo(a,o),u||i.updatePathMinMax(l,a,o);break;case y.curveTo:s=a,c=o,a=t[f+4],o=t[f+5],r.bezierCurveTo(t[f],t[f+1],t[f+2],t[f+3],a,o),i.updateCurvePathMinMax(l,s,c,t[f],t[f+1],t[f+2],t[f+3],a,o,d),f+=6;break;case y.curveTo2:s=a,c=o,r.bezierCurveTo(a,o,t[f],t[f+1],t[f+2],t[f+3]),i.updateCurvePathMinMax(l,s,c,a,o,t[f],t[f+1],t[f+2],t[f+3],d),a=t[f+2],o=t[f+3],f+=4;break;case y.curveTo3:s=a,c=o,a=t[f+2],o=t[f+3],r.bezierCurveTo(t[f],t[f+1],a,o,a,o),i.updateCurvePathMinMax(l,s,c,t[f],t[f+1],a,o,a,o,d),f+=4;break;case y.closePath:r.closePath();break}u&&i.updateScalingPathMinMax(l,d),i.setCurrentPoint(a,o)}closePath(){this.ctx.closePath()}stroke(e=!0){let t=this.ctx,n=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof n==`object`&&n?.getPattern?(t.save(),t.strokeStyle=n.getPattern(t,this,U(t),Y.STROKE),this.rescaleAndStroke(!1),t.restore()):this.rescaleAndStroke(!0)),e&&this.consumePath(this.current.getClippedPathBoundingBox()),t.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){let t=this.ctx,n=this.current.fillColor,r=this.current.patternFill,i=!1;r&&(t.save(),t.fillStyle=n.getPattern(t,this,U(t),Y.FILL),i=!0);let a=this.current.getClippedPathBoundingBox();this.contentVisible&&a!==null&&(this.pendingEOFill?(t.fill(`evenodd`),this.pendingEOFill=!1):t.fill()),i&&t.restore(),e&&this.consumePath(a)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Vt}eoClip(){this.pendingClip=Ht}beginText(){this.current.textMatrix=i,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let e=this.pendingTextPaths,t=this.ctx;if(e===void 0){t.beginPath();return}let n=new Path2D,r=t.getTransform().invertSelf();for(let{transform:t,x:i,y:a,fontSize:o,path:s}of e)n.addPath(s,new DOMMatrix(t).preMultiplySelf(r).translate(i,a).scale(o,-o));t.clip(n),t.beginPath(),delete this.pendingTextPaths}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){let n=this.commonObjs.get(e),r=this.current;if(!n)throw Error(`Can't find font for ${e}`);if(r.fontMatrix=n.fontMatrix||a,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&T(`Invalid font matrix for font `+e),t<0?(t=-t,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=t,n.isType3Font)return;let i=n.loadedName||`sans-serif`,o=n.systemFontInfo?.css||`"${i}", ${n.fallbackName}`,s=`normal`;n.black?s=`900`:n.bold&&(s=`bold`);let c=n.italic?`italic`:`normal`,l=t;t<wt?l=wt:t>Tt&&(l=Tt),this.current.fontSizeScale=t/l,this.ctx.font=`${c} ${s} ${l}px ${o}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,n,r,i,a){this.current.textMatrix=[e,t,n,r,i,a],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#n(e,t,n){let r=new Path2D;return r.addPath(e,new DOMMatrix(n).invertSelf().multiplySelf(t)),r}paintChar(e,t,n,r,i){let a=this.ctx,o=this.current,s=o.font,c=o.textRenderingMode,l=o.fontSize/o.fontSizeScale,u=c&m.FILL_STROKE_MASK,d=!!(c&m.ADD_TO_PATH_FLAG),f=o.patternFill&&!s.missingFile,p=o.patternStroke&&!s.missingFile,h;if((s.disableFontFace||d||f||p)&&(h=s.getPathGenerator(this.commonObjs,e)),s.disableFontFace||f||p){if(a.save(),a.translate(t,n),a.scale(l,-l),u===m.FILL||u===m.FILL_STROKE)if(r){let e=a.getTransform();a.setTransform(...r),a.fill(this.#n(h,e,r))}else a.fill(h);if(u===m.STROKE||u===m.FILL_STROKE)if(i){let e=a.getTransform();a.setTransform(...i),a.stroke(this.#n(h,e,i))}else a.lineWidth/=l,a.stroke(h);a.restore()}else (u===m.FILL||u===m.FILL_STROKE)&&a.fillText(e,t,n),(u===m.STROKE||u===m.FILL_STROKE)&&a.strokeText(e,t,n);d&&(this.pendingTextPaths||=[]).push({transform:H(a),x:t,y:n,fontSize:l,path:h})}get isFontSubpixelAAEnabled(){let{context:e}=this.cachedCanvases.getCanvas(`isFontSubpixelAAEnabled`,10,10);e.scale(1.5,1),e.fillText(`I`,0,10);let t=e.getImageData(0,0,10,10).data,n=!1;for(let e=3;e<t.length;e+=4)if(t[e]>0&&t[e]<255){n=!0;break}return A(this,`isFontSubpixelAAEnabled`,n)}showText(e){let t=this.current,n=t.font;if(n.isType3Font)return this.showType3Text(e);let r=t.fontSize;if(r===0)return;let i=this.ctx,a=t.fontSizeScale,o=t.charSpacing,s=t.wordSpacing,c=t.fontDirection,l=t.textHScale*c,u=e.length,d=n.vertical,f=d?1:-1,p=n.defaultVMetrics,h=r*t.fontMatrix[0],g=t.textRenderingMode===m.FILL&&!n.disableFontFace&&!t.patternFill;i.save(),i.transform(...t.textMatrix),i.translate(t.x,t.y+t.textRise),c>0?i.scale(l,-1):i.scale(l,1);let _,v;if(t.patternFill){i.save();let e=t.fillColor.getPattern(i,this,U(i),Y.FILL);_=H(i),i.restore(),i.fillStyle=e}if(t.patternStroke){i.save();let e=t.strokeColor.getPattern(i,this,U(i),Y.STROKE);v=H(i),i.restore(),i.strokeStyle=e}let y=t.lineWidth,b=t.textMatrixScale;if(b===0||y===0){let e=t.textRenderingMode&m.FILL_STROKE_MASK;(e===m.STROKE||e===m.FILL_STROKE)&&(y=this.getSinglePixelWidth())}else y/=b;if(a!==1&&(i.scale(a,a),y/=a),i.lineWidth=y,n.isInvalidPDFjsFont){let n=[],r=0;for(let t of e)n.push(t.unicode),r+=t.width;i.fillText(n.join(``),0,0),t.x+=r*h*l,i.restore(),this.compose();return}let x=0,S;for(S=0;S<u;++S){let t=e[S];if(typeof t==`number`){x+=f*t*r/1e3;continue}let l=!1,u=(t.isSpace?s:0)+o,m=t.fontChar,y=t.accent,b,C,w=t.width;if(d){let e=t.vmetric||p,n=-(t.vmetric?e[1]:w*.5)*h,r=e[2]*h;w=e?-e[0]:w,b=n/a,C=(x+r)/a}else b=x/a,C=0;if(n.remeasure&&w>0){let e=i.measureText(m).width*1e3/r*a;if(w<e&&this.isFontSubpixelAAEnabled){let t=w/e;l=!0,i.save(),i.scale(t,1),b/=t}else w!==e&&(b+=(w-e)/2e3*r/a)}if(this.contentVisible&&(t.isInFont||n.missingFile)){if(g&&!y)i.fillText(m,b,C);else if(this.paintChar(m,b,C,_,v),y){let e=b+r*y.offset.x/a,t=C-r*y.offset.y/a;this.paintChar(y.fontChar,e,t,_,v)}}let T=d?w*h-u*c:w*h+u*c;x+=T,l&&i.restore()}d?t.y-=x:t.x+=x*l,i.restore(),this.compose()}showType3Text(e){let t=this.ctx,n=this.current,r=n.font,i=n.fontSize,o=n.fontDirection,s=r.vertical?1:-1,c=n.charSpacing,l=n.wordSpacing,u=n.textHScale*o,d=n.fontMatrix||a,f=e.length,p=n.textRenderingMode===m.INVISIBLE,h,g,_,v;if(!(p||i===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,t.save(),t.transform(...n.textMatrix),t.translate(n.x,n.y),t.scale(u,o),h=0;h<f;++h){if(g=e[h],typeof g==`number`){v=s*g*i/1e3,this.ctx.translate(v,0),n.x+=v*u;continue}let a=(g.isSpace?l:0)+c,o=r.charProcOperatorList[g.operatorListId];if(!o){T(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),t.scale(i,i),t.transform(...d),this.executeOperatorList(o),this.restore()),_=R.applyTransform([g.width,0],d)[0]*i+a,t.translate(_,0),n.x+=_*u}t.restore(),this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,n,r,i,a){this.ctx.rect(n,r,i-n,a-r),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let n;if(t[0]===`TilingPattern`){let r=t[1],i=this.baseTransform||H(this.ctx);n=new St(t,r,this.ctx,{createCanvasGraphics:t=>new e(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})},i)}else n=this._getPattern(t[1],t[2]);return n}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,n){this.ctx.strokeStyle=this.current.strokeColor=R.makeHexColor(e,t,n),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor=`transparent`,this.current.patternStroke=!1}setFillRGBColor(e,t,n){this.ctx.fillStyle=this.current.fillColor=R.makeHexColor(e,t,n),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor=`transparent`,this.current.patternFill=!1}_getPattern(e,t=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=bt(this.getObject(e)),this.cachedPatterns.set(e,n)),t&&(n.matrix=t),n}shadingFill(e){if(!this.contentVisible)return;let t=this.ctx;this.save(),t.fillStyle=this._getPattern(e).getPattern(t,this,U(t),Y.SHADING);let n=U(t);if(n){let{width:e,height:r}=t.canvas,[i,a,o,s]=R.getAxialAlignedBoundingBox([0,0,e,r],n);this.ctx.fillRect(i,a,o-i,s-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){E(`Should not call beginInlineImage`)}beginImageData(){E(`Should not call beginImageData`)}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=H(this.ctx),t)){let e=t[2]-t[0],n=t[3]-t[1];this.ctx.rect(t[0],t[1],e,n),this.current.updateRectMinMax(H(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let t=this.ctx;e.isolated||w(`TODO: Support non-isolated groups.`),e.knockout&&T(`Knockout groups not supported.`);let n=H(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw Error(`Bounding box is required.`);let r=R.getAxialAlignedBoundingBox(e.bbox,H(t)),i=[0,0,t.canvas.width,t.canvas.height];r=R.intersect(r,i)||[0,0,0,0];let a=Math.floor(r[0]),o=Math.floor(r[1]),s=Math.max(Math.ceil(r[2])-a,1),c=Math.max(Math.ceil(r[3])-o,1);this.current.startNewPathAndClipBox([0,0,s,c]);let l=`groupAt`+this.groupLevel;e.smask&&(l+=`_smask_`+ this.smaskCounter++%2);let u=this.cachedCanvases.getCanvas(l,s,c),d=u.context;d.translate(-a,-o),d.transform(...n),e.smask?this.smaskStack.push({canvas:u.canvas,context:d,offsetX:a,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(a,o),t.save()),It(t,d),this.ctx=d,this.setGState([[`BM`,`source-over`],[`ca`,1],[`CA`,1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;let t=this.ctx;if(this.ctx=this.groupStack.pop(),this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let e=H(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...e);let n=R.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],e);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(e,t,n,r,i){if(this.#e(),Lt(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){let r=t[2]-t[0],a=t[3]-t[1];if(i&&this.annotationCanvasMap){n=n.slice(),n[4]-=t[0],n[5]-=t[1],t=t.slice(),t[0]=t[1]=0,t[2]=r,t[3]=a;let[i,o]=R.singularValueDecompose2dScale(H(this.ctx)),{viewportScale:s}=this,c=Math.ceil(r*this.outputScaleX*s),l=Math.ceil(a*this.outputScaleY*s);this.annotationCanvas=this.canvasFactory.create(c,l);let{canvas:u,context:d}=this.annotationCanvas;this.annotationCanvasMap.set(e,u),this.annotationCanvas.savedCtx=this.ctx,this.ctx=d,this.ctx.save(),this.ctx.setTransform(i,0,0,-o,0,a*o),Lt(this.ctx)}else Lt(this.ctx),this.endPath(),this.ctx.rect(t[0],t[1],r,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new Nt(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#t(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;let t=e.count;e=this.getObject(e.data,e),e.count=t;let n=this.ctx,r=this.processingType3;if(r&&(r.compiled===void 0&&(r.compiled=Mt(e)),r.compiled)){r.compiled(n);return}let i=this._createMaskCanvas(e),a=i.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(a,i.offsetX,i.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,n=0,r=0,i,a){if(!this.contentVisible)return;e=this.getObject(e.data,e);let o=this.ctx;o.save();let s=H(o);o.transform(t,n,r,i,0,0);let c=this._createMaskCanvas(e);o.setTransform(1,0,0,1,c.offsetX-s[4],c.offsetY-s[5]);for(let e=0,l=a.length;e<l;e+=2){let l=R.transform(s,[t,n,r,i,a[e],a[e+1]]),[u,d]=R.applyTransform([0,0],l);o.drawImage(c.canvas,u,d)}o.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;let t=this.ctx,n=this.current.fillColor,r=this.current.patternFill;for(let i of e){let{data:e,width:a,height:o,transform:s}=i,c=this.cachedCanvases.getCanvas(`maskCanvas`,a,o),l=c.context;l.save(),Ft(l,this.getObject(e,i)),l.globalCompositeOperation=`source-in`,l.fillStyle=r?n.getPattern(l,this,U(t),Y.FILL):n,l.fillRect(0,0,a,o),l.restore(),t.save(),t.transform(...s),t.scale(1,-1),jt(t,c.canvas,0,0,a,o,0,-1,1,1),t.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;let t=this.getObject(e);if(!t){T(`Dependent image isn't ready yet`);return}this.paintInlineImageXObject(t)}paintImageXObjectRepeat(e,t,n,r){if(!this.contentVisible)return;let i=this.getObject(e);if(!i){T(`Dependent image isn't ready yet`);return}let a=i.width,o=i.height,s=[];for(let e=0,i=r.length;e<i;e+=2)s.push({transform:[t,0,0,n,r[e],r[e+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(i,s)}applyTransferMapsToCanvas(e){return this.current.transferMaps!==`none`&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter=`none`),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps===`none`)return e.bitmap;let{bitmap:t,width:n,height:r}=e,i=this.cachedCanvases.getCanvas(`inlineImage`,n,r),a=i.context;return a.filter=this.current.transferMaps,a.drawImage(t,0,0),a.filter=`none`,i.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;let t=e.width,n=e.height,i=this.ctx;if(this.save(),!r){let{filter:e}=i;e!==`none`&&e!==``&&(i.filter=`none`)}i.scale(1/t,-1/n);let a;if(e.bitmap)a=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement==`function`&&e instanceof HTMLElement||!e.data)a=e;else{let r=this.cachedCanvases.getCanvas(`inlineImage`,t,n).context;Pt(r,e),a=this.applyTransferMapsToCanvas(r)}let o=this._scaleImage(a,U(i));i.imageSmoothingEnabled=Rt(H(i),e.interpolate),jt(i,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,t,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(e,t){if(!this.contentVisible)return;let n=this.ctx,r;if(e.bitmap)r=e.bitmap;else{let t=e.width,n=e.height,i=this.cachedCanvases.getCanvas(`inlineImage`,t,n).context;Pt(i,e),r=this.applyTransferMapsToCanvas(i)}for(let e of t)n.save(),n.transform(...e.transform),n.scale(1,-1),jt(n,r,e.x,e.y,e.w,e.h,0,-1,1,1),n.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){e===`OC`?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){let t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);let n=this.ctx;this.pendingClip&&=(t||(this.pendingClip===Ht?n.clip(`evenodd`):n.clip()),null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let e=H(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{let t=Math.abs(e[0]*e[3]-e[2]*e[1]),n=Math.hypot(e[0],e[2]),r=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(n,r)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:e}=this.current,{a:t,b:n,c:r,d:i}=this.ctx.getTransform(),a,o;if(n===0&&r===0){let n=Math.abs(t),r=Math.abs(i);if(n===r)if(e===0)a=o=1/n;else{let t=n*e;a=o=t<1?1/t:1}else if(e===0)a=1/n,o=1/r;else{let t=n*e,i=r*e;a=t<1?1/t:1,o=i<1?1/i:1}}else{let s=Math.abs(t*i-n*r),c=Math.hypot(t,n),l=Math.hypot(r,i);if(e===0)a=l/s,o=c/s;else{let t=e*s;a=l>t?l/t:1,o=c>t?c/t:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(e){let{ctx:t}=this,{lineWidth:n}=this.current,[r,i]=this.getScaleForStroking();if(t.lineWidth=n||1,r===1&&i===1){t.stroke();return}let a=t.getLineDash();if(e&&t.save(),t.scale(r,i),a.length>0){let e=Math.max(r,i);t.setLineDash(a.map(t=>t/e)),t.lineDashOffset/=e}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};for(let e in y)Ut.prototype[e]!==void 0&&(Ut.prototype[y[e]]=Ut.prototype[e]);var Wt=class{static#e=null;static#t=``;static get workerPort(){return this.#e}static set workerPort(e){if(!(typeof Worker<`u`&&e instanceof Worker)&&e!==null)throw Error("Invalid `workerPort` type.");this.#e=e}static get workerSrc(){return this.#t}static set workerSrc(e){if(typeof e!=`string`)throw Error("Invalid `workerSrc` type.");this.#t=e}},Gt=class{#e;#t;constructor({parsedData:e,rawData:t}){this.#e=e,this.#t=t}getRaw(){return this.#t}get(e){return this.#e.get(e)??null}getAll(){return ae(this.#e)}has(e){return this.#e.has(e)}},Kt=Symbol(`INTERNAL`),qt=class{#e=!1;#t=!1;#n=!1;#r=!0;constructor(e,{name:t,intent:n,usage:r,rbGroups:i}){this.#e=!!(e&c.DISPLAY),this.#t=!!(e&c.PRINT),this.name=t,this.intent=n,this.usage=r,this.rbGroups=i}get visible(){if(this.#n)return this.#r;if(!this.#r)return!1;let{print:e,view:t}=this.usage;return this.#e?t?.viewState!==`OFF`:this.#t?e?.printState!==`OFF`:!0}_setVisible(e,t,n=!1){e!==Kt&&E("Internal method `_setVisible` called."),this.#n=n,this.#r=t}},Jt=class{#e=null;#t=new Map;#n=null;#r=null;constructor(e,t=c.DISPLAY){if(this.renderingIntent=t,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,this.#r=e.order;for(let n of e.groups)this.#t.set(n.id,new qt(t,n));if(e.baseState===`OFF`)for(let e of this.#t.values())e._setVisible(Kt,!1);for(let t of e.on)this.#t.get(t)._setVisible(Kt,!0);for(let t of e.off)this.#t.get(t)._setVisible(Kt,!1);this.#n=this.getHash()}}#i(e){let t=e.length;if(t<2)return!0;let n=e[0];for(let r=1;r<t;r++){let t=e[r],i;if(Array.isArray(t))i=this.#i(t);else if(this.#t.has(t))i=this.#t.get(t).visible;else return T(`Optional content group not found: ${t}`),!0;switch(n){case`And`:if(!i)return!1;break;case`Or`:if(i)return!0;break;case`Not`:return!i;default:return!0}}return n===`And`}isVisible(e){if(this.#t.size===0)return!0;if(!e)return w(`Optional content group not defined.`),!0;if(e.type===`OCG`)return this.#t.has(e.id)?this.#t.get(e.id).visible:(T(`Optional content group not found: ${e.id}`),!0);if(e.type===`OCMD`){if(e.expression)return this.#i(e.expression);if(!e.policy||e.policy===`AnyOn`){for(let t of e.ids){if(!this.#t.has(t))return T(`Optional content group not found: ${t}`),!0;if(this.#t.get(t).visible)return!0}return!1}else if(e.policy===`AllOn`){for(let t of e.ids){if(!this.#t.has(t))return T(`Optional content group not found: ${t}`),!0;if(!this.#t.get(t).visible)return!1}return!0}else if(e.policy===`AnyOff`){for(let t of e.ids){if(!this.#t.has(t))return T(`Optional content group not found: ${t}`),!0;if(!this.#t.get(t).visible)return!0}return!1}else if(e.policy===`AllOff`){for(let t of e.ids){if(!this.#t.has(t))return T(`Optional content group not found: ${t}`),!0;if(this.#t.get(t).visible)return!1}return!0}return T(`Unknown optional content policy ${e.policy}.`),!0}return T(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,n=!0){let r=this.#t.get(e);if(!r){T(`Optional content group not found: ${e}`);return}if(n&&t&&r.rbGroups.length)for(let t of r.rbGroups)for(let n of t)n!==e&&this.#t.get(n)?._setVisible(Kt,!1,!0);r._setVisible(Kt,!!t,!0),this.#e=null}setOCGState({state:e,preserveRB:t}){let n;for(let r of e){switch(r){case`ON`:case`OFF`:case`Toggle`:n=r;continue}let e=this.#t.get(r);if(e)switch(n){case`ON`:this.setVisibility(r,!0,t);break;case`OFF`:this.setVisibility(r,!1,t);break;case`Toggle`:this.setVisibility(r,!e.visible,t);break}}this.#e=null}get hasInitialVisibility(){return this.#n===null||this.getHash()===this.#n}getOrder(){return this.#t.size?this.#r?this.#r.slice():[...this.#t.keys()]:null}getGroups(){return this.#t.size>0?ae(this.#t):null}getGroup(e){return this.#t.get(e)||null}getHash(){if(this.#e!==null)return this.#e;let e=new Ge;for(let[t,n]of this.#t)e.update(`${t}:${n.visible}`);return this.#e=e.hexdigest()}},Yt=class{constructor(e,{disableRange:t=!1,disableStream:n=!1}){D(e,`PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.`);let{length:r,initialData:i,progressiveDone:a,contentDispositionFilename:o}=e;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=o,i?.length>0){let e=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!n,this._isRangeSupported=!t,this._contentLength=r,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener((e,t)=>{this._onReceiveData({begin:e,chunk:t})}),e.addProgressListener((e,t)=>{this._onProgress({loaded:e,total:t})}),e.addProgressiveReadListener(e=>{this._onReceiveData({chunk:e})}),e.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),e.transportReady()}_onReceiveData({begin:e,chunk:t}){let n=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;e===void 0?this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n):D(this._rangeReaders.some(function(t){return t._begin===e?(t._enqueue(n),!0):!1}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(e){e.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:e.loaded}):this._fullRequestReader?.onProgress?.({loaded:e.loaded,total:e.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){let t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){D(!this._fullRequestReader,`PDFDataTransportStream.getFullReader can only be called once.`);let e=this._queuedChunks;return this._queuedChunks=null,new Xt(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new Zt(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeReaders.slice(0))t.cancel(e);this._pdfDataRangeTransport.abort()}},Xt=class{constructor(e,t,n=!1,r=null){this._stream=e,this._done=n||!1,this._filename=xe(r)?r:null,this._queuedChunks=t||[],this._loaded=0;for(let e of this._queuedChunks)this._loaded+=e.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||=!0}},Zt=class{constructor(e,t,n){this._stream=e,this._begin=t,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length===0)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}};function Qt(e){let t=!0,n=r(`filename\\*`,`i`).exec(e);if(n){n=n[1];let e=s(n);return e=unescape(e),e=c(e),e=l(e),a(e)}if(n=o(e),n)return a(l(n));if(n=r(`filename`,`i`).exec(e),n){n=n[1];let e=s(n);return e=l(e),a(e)}function r(e,t){return RegExp(`(?:^|;)\\s*`+e+`\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)`,t)}function i(e,n){if(e){if(!/^[\x00-\xFF]+$/.test(n))return n;try{let r=new TextDecoder(e,{fatal:!0}),i=re(n);n=r.decode(i),t=!1}catch{}}return n}function a(e){return t&&/[\x80-\xff]/.test(e)&&(e=i(`utf-8`,e),t&&(e=i(`iso-8859-1`,e))),e}function o(e){let t=[],n,i=r(`filename\\*((?!0\\d)\\d+)(\\*?)`,`ig`);for(;(n=i.exec(e))!==null;){let[,e,r,i]=n;if(e=parseInt(e,10),e in t){if(e===0)break;continue}t[e]=[r,i]}let a=[];for(let e=0;e<t.length&&e in t;++e){let[n,r]=t[e];r=s(r),n&&(r=unescape(r),e===0&&(r=c(r))),a.push(r)}return a.join(``)}function s(e){if(e.startsWith(`"`)){let t=e.slice(1).split(`\\"`);for(let e=0;e<t.length;++e){let n=t[e].indexOf(`"`);n!==-1&&(t[e]=t[e].slice(0,n),t.length=e+1),t[e]=t[e].replaceAll(/\\(.)/g,`$1`)}e=t.join(`"`)}return e}function c(e){let t=e.indexOf(`'`);return t===-1?e:i(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,``))}function l(e){return!e.startsWith(`=?`)||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(e,t,n,r){if(n===`q`||n===`Q`)return r=r.replaceAll(`_`,` `),r=r.replaceAll(/=([0-9a-fA-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}),i(t,r);try{r=atob(r)}catch{}return i(t,r)})}return``}function $t(e,t){let n=new Headers;if(!e||!t||typeof t!=`object`)return n;for(let e in t){let r=t[e];r!==void 0&&n.append(e,r)}return n}function en(e){try{return new URL(e).origin}catch{}return null}function tn({responseHeaders:e,isHttp:t,rangeChunkSize:n,disableRange:r}){let i={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(e.get(`Content-Length`),10);return!Number.isInteger(a)||(i.suggestedLength=a,a<=2*n)||r||!t||e.get(`Accept-Ranges`)!==`bytes`||(e.get(`Content-Encoding`)||`identity`)!==`identity`||(i.allowRangeRequests=!0),i}function nn(e){let t=e.get(`Content-Disposition`);if(t){let e=Qt(t);if(e.includes(`%`))try{e=decodeURIComponent(e)}catch{}if(xe(e))return e}return null}function rn(e,t){return e===404||e===0&&t.startsWith(`file:`)?new F(`Missing PDF "`+t+`".`):new ee(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)}function an(e){return e===200||e===206}function on(e,t,n){return{method:`GET`,headers:e,signal:n.signal,mode:`cors`,credentials:t?`include`:`same-origin`,redirect:`follow`}}function sn(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:(T(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}var cn=class{_responseOrigin=null;constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=$t(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return D(!this._fullRequestReader,`PDFFetchStream.getFullReader can only be called once.`),this._fullRequestReader=new ln(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new un(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},ln=class{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;let t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange;let n=new Headers(e.headers),r=t.url;fetch(r,on(n,this._withCredentials,this._abortController)).then(t=>{if(e._responseOrigin=en(t.url),!an(t.status))throw rn(t.status,r);this._reader=t.body.getReader(),this._headersCapability.resolve();let n=t.headers,{allowRangeRequests:i,suggestedLength:a}=tn({responseHeaders:n,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=a||this._contentLength,this._filename=nn(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new I(`Streaming is disabled.`))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;let{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:sn(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}},un=class{constructor(e,t,n){this._stream=e,this._reader=null,this._loaded=0;let r=e.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;let i=new Headers(e.headers);i.append(`Range`,`bytes=${t}-${n-1}`);let a=r.url;fetch(a,on(i,this._withCredentials,this._abortController)).then(t=>{let n=en(t.url);if(n!==e._responseOrigin)throw Error(`Expected range response-origin "${n}" to match "${e._responseOrigin}".`);if(!an(t.status))throw rn(t.status,a);this._readCapability.resolve(),this._reader=t.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded}),{value:sn(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}},dn=200,fn=206;function pn(e){let t=e.response;return typeof t==`string`?re(t).buffer:t}var mn=class{_responseOrigin=null;constructor({url:e,httpHeaders:t,withCredentials:n}){this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=$t(this.isHttp,t),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){let t=new XMLHttpRequest,n=this.currXhrId++,r=this.pendingRequests[n]={xhr:t};t.open(`GET`,this.url),t.withCredentials=this.withCredentials;for(let[e,n]of this.headers)t.setRequestHeader(e,n);return this.isHttp&&`begin`in e&&`end`in e?(t.setRequestHeader(`Range`,`bytes=${e.begin}-${e.end-1}`),r.expectedStatus=fn):r.expectedStatus=dn,t.responseType=`arraybuffer`,D(e.onError,"Expected `onError` callback to be provided."),t.onerror=()=>{e.onError(t.status)},t.onreadystatechange=this.onStateChange.bind(this,n),t.onprogress=this.onProgress.bind(this,n),r.onHeadersReceived=e.onHeadersReceived,r.onDone=e.onDone,r.onError=e.onError,r.onProgress=e.onProgress,t.send(null),n}onProgress(e,t){let n=this.pendingRequests[e];n&&n.onProgress?.(t)}onStateChange(e,t){let n=this.pendingRequests[e];if(!n)return;let r=n.xhr;if(r.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),r.readyState!==4||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],r.status===0&&this.isHttp){n.onError(r.status);return}let i=r.status||dn;if(!(i===dn&&n.expectedStatus===fn)&&i!==n.expectedStatus){n.onError(r.status);return}let a=pn(r);if(i===fn){let e=r.getResponseHeader(`Content-Range`),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);t?n.onDone({begin:parseInt(t[1],10),chunk:a}):(T(`Missing or invalid "Content-Range" header.`),n.onError(0))}else a?n.onDone({begin:0,chunk:a}):n.onError(r.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){let t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}},hn=class{constructor(e){this._source=e,this._manager=new mn(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){let t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return D(!this._fullRequestReader,`PDFNetworkStream.getFullReader can only be called once.`),this._fullRequestReader=new gn(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){let n=new _n(this._manager,e,t);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},gn=class{constructor(e,t){this._manager=e,this._url=t.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let e=this._fullRequestId,t=this._manager.getRequestXhr(e);this._manager._responseOrigin=en(t.responseURL);let n=t.getAllResponseHeaders(),r=new Headers(n?n.trimStart().replace(/[^\S ]+$/,``).split(/[\r\n]+/).map(e=>{let[t,...n]=e.split(`: `);return[t,n.join(`: `)]}):[]),{allowRangeRequests:i,suggestedLength:a}=tn({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=nn(r),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=rn(e,this._url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e);for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}},_n=class{constructor(e,t,n){this._manager=e,this._url=e.url,this._requestId=e.request({begin:t,end:n,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let e=en(this._manager.getRequestXhr(this._requestId)?.responseURL);e!==this._manager._responseOrigin&&(this._storedError=Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(e){let t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError??=rn(e,this._url);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){this.isStreamingSupported||this.onProgress?.({loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}},vn=/^[a-z][a-z0-9\-+.]+:/i;function yn(e){if(vn.test(e))return new URL(e);let t=process.getBuiltinModule(`url`);return new URL(t.pathToFileURL(e))}var bn=class{constructor(e){this.source=e,this.url=yn(e.url),D(this.url.protocol===`file:`,`PDFNodeStream only supports file:// URLs.`),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return D(!this._fullRequestReader,`PDFNodeStream.getFullReader can only be called once.`),this._fullRequestReader=new xn(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new Sn(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},xn=class{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;let t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();let n=process.getBuiltinModule(`fs`);n.promises.lstat(this._url).then(e=>{this._contentLength=e.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()},e=>{e.code===`ENOENT`&&(e=new F(`Missing PDF "${this._url}".`)),this._storedError=e,this._headersCapability.reject(e)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on(`readable`,()=>{this._readCapability.resolve()}),e.on(`end`,()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on(`error`,e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new I(`streaming is disabled`)),this._storedError&&this._readableStream.destroy(this._storedError)}},Sn=class{constructor(e,t,n){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!e.source.disableStream;let r=process.getBuiltinModule(`fs`);this._setReadableStream(r.createReadStream(this._url,{start:t,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on(`readable`,()=>{this._readCapability.resolve()}),e.on(`end`,()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on(`error`,e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}},Cn=1e5,Z=30,wn=.8,Tn=class e{#e=Promise.withResolvers();#t=null;#n=!1;#r=!!globalThis.FontInspector?.enabled;#i=null;#a=null;#o=0;#s=0;#c=null;#l=null;#u=0;#d=0;#f=Object.create(null);#p=[];#m=null;#h=[];#g=new WeakMap;#_=null;static#v=new Map;static#y=new Map;static#b=new WeakMap;static#x=null;static#S=new Set;constructor({textContentSource:t,container:n,viewport:r}){if(t instanceof ReadableStream)this.#m=t;else if(typeof t==`object`)this.#m=new ReadableStream({start(e){e.enqueue(t),e.close()}});else throw Error(`No "textContentSource" parameter specified.`);this.#t=this.#l=n,this.#d=r.scale*(globalThis.devicePixelRatio||1),this.#u=r.rotation,this.#a={div:null,properties:null,ctx:null};let{pageWidth:i,pageHeight:a,pageX:o,pageY:s}=r.rawDims;this.#_=[1,0,0,-1,-o,s+a],this.#s=i,this.#o=a,e.#O(),Ae(n,r),this.#e.promise.finally(()=>{e.#S.delete(this),this.#a=null,this.#f=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:e,isFirefox:t}=L.platform;return A(this,`fontFamilyMap`,new Map([[`sans-serif`,`${e&&t?`Calibri, `:``}sans-serif`],[`monospace`,`${e&&t?`Lucida Console, `:``}monospace`]]))}render(){let t=()=>{this.#c.read().then(({value:e,done:n})=>{if(n){this.#e.resolve();return}this.#i??=e.lang,Object.assign(this.#f,e.styles),this.#C(e.items),t()},this.#e.reject)};return this.#c=this.#m.getReader(),e.#S.add(this),t(),this.#e.promise}update({viewport:t,onBefore:n=null}){let r=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==this.#u&&(n?.(),this.#u=i,Ae(this.#l,{rotation:i})),r!==this.#d){n?.(),this.#d=r;let t={div:null,properties:null,ctx:e.#E(this.#i)};for(let e of this.#h)t.properties=this.#g.get(e),t.div=e,this.#T(t)}}cancel(){let e=new I(`TextLayer task cancelled.`);this.#c?.cancel(e).catch(()=>{}),this.#c=null,this.#e.reject(e)}get textDivs(){return this.#h}get textContentItemsStr(){return this.#p}#C(t){if(this.#n)return;this.#a.ctx??=e.#E(this.#i);let n=this.#h,r=this.#p;for(let e of t){if(n.length>Cn){T(`Ignoring additional textDivs for performance reasons.`),this.#n=!0;return}if(e.str===void 0){if(e.type===`beginMarkedContentProps`||e.type===`beginMarkedContent`){let t=this.#t;this.#t=document.createElement(`span`),this.#t.classList.add(`markedContent`),e.id!==null&&this.#t.setAttribute(`id`,`${e.id}`),t.append(this.#t)}else e.type===`endMarkedContent`&&(this.#t=this.#t.parentNode);continue}r.push(e.str),this.#w(e)}}#w(t){let n=document.createElement(`span`),r={angle:0,canvasWidth:0,hasText:t.str!==``,hasEOL:t.hasEOL,fontSize:0};this.#h.push(n);let i=R.transform(this.#_,t.transform),a=Math.atan2(i[1],i[0]),o=this.#f[t.fontName];o.vertical&&(a+=Math.PI/2);let s=this.#r&&o.fontSubstitution||o.fontFamily;s=e.fontFamilyMap.get(s)||s;let c=Math.hypot(i[2],i[3]),l=c*e.#k(s,this.#i),u,d;a===0?(u=i[4],d=i[5]-l):(u=i[4]+l*Math.sin(a),d=i[5]-l*Math.cos(a));let f=`calc(var(--scale-factor)*`,p=n.style;this.#t===this.#l?(p.left=`${(100*u/this.#s).toFixed(2)}%`,p.top=`${(100*d/this.#o).toFixed(2)}%`):(p.left=`${f}${u.toFixed(2)}px)`,p.top=`${f}${d.toFixed(2)}px)`),p.fontSize=`${f}${(e.#x*c).toFixed(2)}px)`,p.fontFamily=s,r.fontSize=c,n.setAttribute(`role`,`presentation`),n.textContent=t.str,n.dir=t.dir,this.#r&&(n.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),a!==0&&(r.angle=180/Math.PI*a);let m=!1;if(t.str.length>1)m=!0;else if(t.str!==` `&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),n=Math.abs(t.transform[3]);e!==n&&Math.max(e,n)/Math.min(e,n)>1.5&&(m=!0)}if(m&&(r.canvasWidth=o.vertical?t.height:t.width),this.#g.set(n,r),this.#a.div=n,this.#a.properties=r,this.#T(this.#a),r.hasText&&this.#t.append(n),r.hasEOL){let e=document.createElement(`br`);e.setAttribute(`role`,`presentation`),this.#t.append(e)}}#T(t){let{div:n,properties:r,ctx:i}=t,{style:a}=n,o=``;if(e.#x>1&&(o=`scale(${1/e.#x})`),r.canvasWidth!==0&&r.hasText){let{fontFamily:t}=a,{canvasWidth:s,fontSize:c}=r;e.#D(i,c*this.#d,t);let{width:l}=i.measureText(n.textContent);l>0&&(o=`scaleX(${s*this.#d/l}) ${o}`)}r.angle!==0&&(o=`rotate(${r.angle}deg) ${o}`),o.length>0&&(a.transform=o)}static cleanup(){if(!(this.#S.size>0)){this.#v.clear();for(let{canvas:e}of this.#y.values())e.remove();this.#y.clear()}}static#E(e=null){let t=this.#y.get(e||=``);if(!t){let n=document.createElement(`canvas`);n.className=`hiddenCanvasElement`,n.lang=e,document.body.append(n),t=n.getContext(`2d`,{alpha:!1,willReadFrequently:!0}),this.#y.set(e,t),this.#b.set(t,{size:0,family:``})}return t}static#D(e,t,n){let r=this.#b.get(e);t===r.size&&n===r.family||(e.font=`${t}px ${n}`,r.size=t,r.family=n)}static#O(){if(this.#x!==null)return;let e=document.createElement(`div`);e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize=`1px`,e.style.position=`absolute`,e.textContent=`X`,document.body.append(e),this.#x=e.getBoundingClientRect().height,e.remove()}static#k(e,t){let n=this.#v.get(e);if(n)return n;let r=this.#E(t);r.canvas.width=r.canvas.height=Z,this.#D(r,Z,e);let i=r.measureText(``),a=i.fontBoundingBoxAscent,o=Math.abs(i.fontBoundingBoxDescent);if(a){let t=a/(a+o);return this.#v.set(e,t),r.canvas.width=r.canvas.height=0,t}r.strokeStyle=`red`,r.clearRect(0,0,Z,Z),r.strokeText(`g`,0,0);let s=r.getImageData(0,0,Z,Z).data;o=0;for(let e=s.length-1-3;e>=0;e-=4)if(s[e]>0){o=Math.ceil(e/4/Z);break}r.clearRect(0,0,Z,Z),r.strokeText(`A`,0,Z),s=r.getImageData(0,0,Z,Z).data,a=0;for(let e=0,t=s.length;e<t;e+=4)if(s[e]>0){a=Z-Math.floor(e/4/Z);break}r.canvas.width=r.canvas.height=0;let c=a?a/(a+o):wn;return this.#v.set(e,c),c}},En=class e{static textContent(t){let n=[],r={items:n,styles:Object.create(null)};function i(t){if(!t)return;let r=null,a=t.name;if(a===`#text`)r=t.value;else if(e.shouldBuildText(a))t?.attributes?.textContent?r=t.attributes.textContent:t.value&&(r=t.value);else return;if(r!==null&&n.push({str:r}),t.children)for(let e of t.children)i(e)}return i(t),r}static shouldBuildText(e){return!(e===`textarea`||e===`input`||e===`option`||e===`select`)}},Dn=65536,On=100,kn=5e3,An=r?ut:tt,jn=r?dt:rt,Mn=r?lt:at,Nn=r?ft:st;function Pn(e={}){typeof e==`string`||e instanceof URL?e={url:e}:(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t=new Rn,{docId:n}=t,i=e.url?Fn(e.url):null,a=e.data?In(e.data):null,o=e.httpHeaders||null,s=e.withCredentials===!0,c=e.password??null,l=e.range instanceof zn?e.range:null,u=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:Dn,d=e.worker instanceof Un?e.worker:null,f=e.verbosity,p=typeof e.docBaseUrl==`string`&&!be(e.docBaseUrl)?e.docBaseUrl:null,m=typeof e.cMapUrl==`string`?e.cMapUrl:null,h=e.cMapPacked!==!1,g=e.CMapReaderFactory||jn,_=typeof e.standardFontDataUrl==`string`?e.standardFontDataUrl:null,v=e.StandardFontDataFactory||Nn,y=e.stopAtErrors!==!0,b=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,x=e.isEvalSupported!==!1,C=typeof e.isOffscreenCanvasSupported==`boolean`?e.isOffscreenCanvasSupported:!r,w=typeof e.isImageDecoderSupported==`boolean`?e.isImageDecoderSupported:!r&&(L.platform.isFirefox||!globalThis.chrome),T=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,E=typeof e.disableFontFace==`boolean`?e.disableFontFace:r,D=e.fontExtraProperties===!0,O=e.enableXfa===!0,k=e.ownerDocument||globalThis.document,A=e.disableRange===!0,j=e.disableStream===!0,M=e.disableAutoFetch===!0,N=e.pdfBug===!0,P=e.CanvasFactory||An,F=e.FilterFactory||Mn,ee=e.enableHWA===!0,te=l?l.length:e.length??NaN,I=typeof e.useSystemFonts==`boolean`?e.useSystemFonts:!r&&!E,ne=typeof e.useWorkerFetch==`boolean`?e.useWorkerFetch:g===rt&&v===st&&m&&_&&Te(m,document.baseURI)&&Te(_,document.baseURI);S(f);let re={canvasFactory:new P({ownerDocument:k,enableHWA:ee}),filterFactory:new F({docId:n,ownerDocument:k}),cMapReaderFactory:ne?null:new g({baseUrl:m,isCompressed:h}),standardFontDataFactory:ne?null:new v({baseUrl:_})};if(!d){let e={verbosity:f,port:Wt.workerPort};d=e.port?Un.fromPort(e):new Un(e),t._worker=d}let ie={docId:n,apiVersion:`4.10.38`,data:a,password:c,disableAutoFetch:M,rangeChunkSize:u,length:te,docBaseUrl:p,enableXfa:O,evaluatorOptions:{maxImageSize:b,disableFontFace:E,ignoreErrors:y,isEvalSupported:x,isOffscreenCanvasSupported:C,isImageDecoderSupported:w,canvasMaxAreaInBytes:T,fontExtraProperties:D,useSystemFonts:I,cMapUrl:ne?m:null,standardFontDataUrl:ne?_:null}},ae={disableFontFace:E,fontExtraProperties:D,ownerDocument:k,pdfBug:N,styleElement:null,loadingParams:{disableAutoFetch:M,enableXfa:O}};return d.promise.then(function(){if(t.destroyed)throw Error(`Loading aborted`);if(d.destroyed)throw Error(`Worker was destroyed`);let e=d.messageHandler.sendWithPromise(`GetDocRequest`,ie,a?[a.buffer]:null),c;if(l)c=new Yt(l,{disableRange:A,disableStream:j});else if(!a){if(!i)throw Error("getDocument - no `url` parameter provided.");let e;if(r)if(Te(i)){if(typeof fetch>`u`||typeof Response>`u`||!(`body`in Response.prototype))throw Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");e=cn}else e=bn;else e=Te(i)?cn:hn;c=new e({url:i,length:te,httpHeaders:o,withCredentials:s,rangeChunkSize:u,disableRange:A,disableStream:j})}return e.then(e=>{if(t.destroyed)throw Error(`Loading aborted`);if(d.destroyed)throw Error(`Worker was destroyed`);let r=new $e(n,e,d.port);t._transport=new Wn(r,t,c,ae,re),r.send(`Ready`,null)})}).catch(t._capability.reject),t}function Fn(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch{if(r&&typeof e==`string`)return e}throw Error(`Invalid PDF url data: either string or URL-object is expected in the url property.`)}function In(e){if(r&&typeof Buffer<`u`&&e instanceof Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if(typeof e==`string`)return re(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e==`object`&&!isNaN(e?.length))return new Uint8Array(e);throw Error(`Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.`)}function Ln(e){return typeof e==`object`&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0}var Rn=class e{static#e=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${e.#e++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(e){throw this._worker?.port&&delete this._worker._pendingDestroy,e}this._transport=null,this._worker?.destroy(),this._worker=null}},zn=class{constructor(e,t,n=!1,r=null){this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=r,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(let n of this._rangeListeners)n(e,t)}onDataProgress(e,t){this._readyCapability.promise.then(()=>{for(let n of this._progressListeners)n(e,t)})}onDataProgressiveRead(e){this._readyCapability.promise.then(()=>{for(let t of this._progressiveReadListeners)t(e)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let e of this._progressiveDoneListeners)e()})}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){E(`Abstract method PDFDataRangeTransport.requestDataRange`)}abort(){}},Bn=class{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return A(this,`isPureXfa`,!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e=`display`}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}},Vn=class{#e=null;#t=!1;constructor(e,t,n,r=!1){this._pageIndex=e,this._pageInfo=t,this._transport=n,this._stats=r?new we:null,this._pdfBug=r,this.commonObjs=n.commonObjs,this.objs=new Kn,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:n=0,offsetY:r=0,dontFlip:i=!1}={}){return new ve({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:r,dontFlip:i})}getAnnotations({intent:e=`display`}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return A(this,`isPureXfa`,!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,viewport:t,intent:n=`display`,annotationMode:r=l.ENABLE,transform:i=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:s=null,pageColors:u=null,printAnnotationStorage:d=null,isEditing:f=!1}){this._stats?.time(`Overall`);let p=this._transport.getRenderingIntent(n,r,d,f),{renderingIntent:m,cacheKey:h}=p;this.#t=!1,this.#r(),o||=this._transport.getOptionalContentConfig(m);let g=this._intentStates.get(h);g||(g=Object.create(null),this._intentStates.set(h,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);let _=!!(m&c.PRINT);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time(`Page Request`),this._pumpOperatorList(p));let v=e=>{g.renderTasks.delete(y),(this._maybeCleanupAfterRender||_)&&(this.#t=!0),this.#n(!_),e?(y.capability.reject(e),this._abortOperatorList({intentState:g,reason:e instanceof Error?e:Error(e)})):y.capability.resolve(),this._stats&&(this._stats.timeEnd(`Rendering`),this._stats.timeEnd(`Overall`),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},y=new Jn({callback:v,params:{canvasContext:e,viewport:t,transform:i,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:s,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!_,pdfBug:this._pdfBug,pageColors:u});(g.renderTasks||=new Set).add(y);let b=y.task;return Promise.all([g.displayReadyCapability.promise,o]).then(([e,t])=>{if(this.destroyed){v();return}if(this._stats?.time(`Rendering`),!(t.renderingIntent&m))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");y.initializeGraphics({transparency:e,optionalContentConfig:t}),y.operatorListChanged()}).catch(v),b}getOperatorList({intent:e=`display`,annotationMode:t=l.ENABLE,printAnnotationStorage:n=null,isEditing:r=!1}={}){function i(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(s))}let a=this._transport.getRenderingIntent(e,t,n,r,!0),o=this._intentStates.get(a.cacheKey);o||(o=Object.create(null),this._intentStates.set(a.cacheKey,o));let s;return o.opListReadCapability||(s=Object.create(null),s.operatorListChanged=i,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||=new Set).add(s),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time(`Page Request`),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream(`GetTextContent`,{pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:t===!0},{highWaterMark:100,size(e){return e.items.length}})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(e=>En.textContent(e));let t=this.streamTextContent(e);return new Promise(function(e,n){function r(){i.read().then(function({value:t,done:n}){if(n){e(a);return}a.lang??=t.lang,Object.assign(a.styles,t.styles),a.items.push(...t.items),r()},n)}let i=t.getReader(),a={items:[],styles:Object.create(null),lang:null};r()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let e=[];for(let t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:Error(`Page was destroyed.`),force:!0}),!t.opListReadCapability)for(let n of t.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),this.#t=!1,this.#r(),Promise.all(e)}cleanup(e=!1){this.#t=!0;let t=this.#n(!1);return e&&t&&(this._stats&&=new we),t}#n(e=!1){if(this.#r(),!this.#t||this.destroyed)return!1;if(e)return this.#e=setTimeout(()=>{this.#e=null,this.#n(!1)},kn),!1;for(let{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#t=!1,!0}#r(){this.#e&&=(clearTimeout(this.#e),null)}_startRenderPage(e,t){let n=this._intentStates.get(t);n&&(this._stats?.timeEnd(`Page Request`),n.displayReadyCapability?.resolve(e))}_renderPageChunk(e,t){for(let n=0,r=e.length;n<r;n++)t.operatorList.fnArray.push(e.fnArray[n]),t.operatorList.argsArray.push(e.argsArray[n]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(let e of t.renderTasks)e.operatorListChanged();e.lastChunk&&this.#n(!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:n,modifiedIds:r}){let{map:i,transfer:a}=n,o=this._transport.messageHandler.sendWithStream(`GetOperatorList`,{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:i,modifiedIds:r},a).getReader(),s=this._intentStates.get(t);s.streamReader=o;let c=()=>{o.read().then(({value:e,done:t})=>{if(t){s.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(e,s),c())},e=>{if(s.streamReader=null,!this._transport.destroyed){if(s.operatorList){s.operatorList.lastChunk=!0;for(let e of s.renderTasks)e.operatorListChanged();this.#n(!0)}if(s.displayReadyCapability)s.displayReadyCapability.reject(e);else if(s.opListReadCapability)s.opListReadCapability.reject(e);else throw e}})};c()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&=(clearTimeout(e.streamReaderCancelTimeout),null),!n){if(e.renderTasks.size>0)return;if(t instanceof ye){let n=On;t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},n);return}}if(e.streamReader.cancel(new I(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(let[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}},Hn=class{#e=new Map;#t=Promise.resolve();postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};this.#t.then(()=>{for(let[e]of this.#e)e.call(this,n)})}addEventListener(e,t,n=null){let r=null;if(n?.signal instanceof AbortSignal){let{signal:i}=n;if(i.aborted){T("LoopbackPort - cannot use an `aborted` signal.");return}let a=()=>this.removeEventListener(e,t);r=()=>i.removeEventListener(`abort`,a),i.addEventListener(`abort`,a)}this.#e.set(t,r)}removeEventListener(e,t){this.#e.get(t)?.(),this.#e.delete(t)}terminate(){for(let[,e]of this.#e)e?.();this.#e.clear()}},Un=class t{static#e=0;static#t=!1;static#n;static{r&&(this.#t=!0,Wt.workerSrc||=`./pdf.worker.mjs`),this._isSameOrigin=(e,t)=>{let n;try{if(n=new URL(e),!n.origin||n.origin===`null`)return!1}catch{return!1}let r=new URL(t,n);return n.origin===r.origin},this._createCDNWrapper=e=>{let t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:`text/javascript`}))}}constructor({name:e=null,port:n=null,verbosity:r=C()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=r,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,n){if(t.#n?.has(n))throw Error(`Cannot use more than one PDFWorker per port.`);(t.#n||=new WeakMap).set(n,this),this._initializeFromPort(n);return}this._initialize()}get promise(){return this._readyCapability.promise}#r(){this._readyCapability.resolve(),this._messageHandler.send(`configure`,{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new $e(`main`,`worker`,e),this._messageHandler.on(`ready`,function(){}),this.#r()}_initialize(){if(t.#t||t.#i){this._setupFakeWorker();return}let{workerSrc:e}=t;try{t._isSameOrigin(window.location.href,e)||(e=t._createCDNWrapper(new URL(e,window.location).href));let n=new Worker(e,{type:`module`}),r=new $e(`main`,`worker`,n),i=()=>{a.abort(),r.destroy(),n.terminate(),this.destroyed?this._readyCapability.reject(Error(`Worker was destroyed`)):this._setupFakeWorker()},a=new AbortController;n.addEventListener(`error`,()=>{this._webWorker||i()},{signal:a.signal}),r.on(`test`,e=>{if(a.abort(),this.destroyed||!e){i();return}this._messageHandler=r,this._port=n,this._webWorker=n,this.#r()}),r.on(`ready`,e=>{if(a.abort(),this.destroyed){i();return}try{o()}catch{this._setupFakeWorker()}});let o=()=>{let e=new Uint8Array;r.send(`test`,e,[e.buffer])};o();return}catch{w(`The worker has been disabled.`)}this._setupFakeWorker()}_setupFakeWorker(){t.#t||=(T(`Setting up fake worker.`),!0),t._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){this._readyCapability.reject(Error(`Worker was destroyed`));return}let n=new Hn;this._port=n;let r=`fake${t.#e++}`,i=new $e(r+`_worker`,r,n);e.setup(i,n),this._messageHandler=new $e(r,r+`_worker`,n),this.#r()}).catch(e=>{this._readyCapability.reject(Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,t.#n?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(e){if(!e?.port)throw Error(`PDFWorker.fromPort - invalid method signature.`);let n=this.#n?.get(e.port);if(n){if(n._pendingDestroy)throw Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return n}return new t(e)}static get workerSrc(){if(Wt.workerSrc)return Wt.workerSrc;throw Error(`No "GlobalWorkerOptions.workerSrc" specified.`)}static get#i(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return A(this,`_setupFakeWorkerGlobal`,(async()=>this.#i?this.#i:(await e(()=>import(this.workerSrc),[])).WorkerMessageHandler)())}},Wn=class{#e=new Map;#t=new Map;#n=new Map;#r=new Map;#i=null;constructor(e,t,n,r,i){this.messageHandler=e,this.loadingTask=t,this.commonObjs=new Kn,this.fontLoader=new Ye({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#a(e,t=null){let n=this.#e.get(e);if(n)return n;let r=this.messageHandler.sendWithPromise(e,t);return this.#e.set(e,r),r}get annotationStorage(){return A(this,`annotationStorage`,new qe)}getRenderingIntent(e,t=l.ENABLE,n=null,r=!1,i=!1){let a=c.DISPLAY,o=Ke;switch(e){case`any`:a=c.ANY;break;case`display`:break;case`print`:a=c.PRINT;break;default:T(`getRenderingIntent - invalid intent: ${e}`)}let s=a&c.PRINT&&n instanceof Je?n:this.annotationStorage;switch(t){case l.DISABLE:a+=c.ANNOTATIONS_DISABLE;break;case l.ENABLE:break;case l.ENABLE_FORMS:a+=c.ANNOTATIONS_FORMS;break;case l.ENABLE_STORAGE:a+=c.ANNOTATIONS_STORAGE,o=s.serializable;break;default:T(`getRenderingIntent - invalid annotationMode: ${t}`)}r&&(a+=c.IS_EDITING),i&&(a+=c.OPLIST);let{ids:u,hash:d}=s.modifiedIds,f=[a,o.hash,d];return{renderingIntent:a,cacheKey:f.join(`_`),annotationStorageSerializable:o,modifiedIds:u}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#i?.reject(Error(`Worker was destroyed during onPassword callback`));let e=[];for(let t of this.#t.values())e.push(t._destroy());this.#t.clear(),this.#n.clear(),this.#r.clear(),this.hasOwnProperty(`annotationStorage`)&&this.annotationStorage.resetModified();let t=this.messageHandler.sendWithPromise(`Terminate`,null);return e.push(t),Promise.all(e).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(),Tn.cleanup(),this._networkStream?.cancelAllRequests(new I(`Worker was terminated.`)),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:e,loadingTask:t}=this;e.on(`GetReader`,(e,t)=>{D(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}},t.onPull=()=>{this._fullReader.read().then(function({value:e,done:n}){if(n){t.close();return}D(e instanceof ArrayBuffer,`GetReader - expected an ArrayBuffer.`),t.enqueue(new Uint8Array(e),1,[e])}).catch(e=>{t.error(e)})},t.onCancel=e=>{this._fullReader.cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}}),e.on(`ReaderHeadersReady`,async e=>{await this._fullReader.headersReady;let{isStreamingSupported:n,isRangeSupported:r,contentLength:i}=this._fullReader;return(!n||!r)&&(this._lastProgress&&t.onProgress?.(this._lastProgress),this._fullReader.onProgress=e=>{t.onProgress?.({loaded:e.loaded,total:e.total})}),{isStreamingSupported:n,isRangeSupported:r,contentLength:i}}),e.on(`GetRangeReader`,(e,t)=>{D(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let n=this._networkStream.getRangeReader(e.begin,e.end);if(!n){t.close();return}t.onPull=()=>{n.read().then(function({value:e,done:n}){if(n){t.close();return}D(e instanceof ArrayBuffer,`GetRangeReader - expected an ArrayBuffer.`),t.enqueue(new Uint8Array(e),1,[e])}).catch(e=>{t.error(e)})},t.onCancel=e=>{n.cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}}),e.on(`GetDoc`,({pdfInfo:e})=>{this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,t._capability.resolve(new Bn(e,this))}),e.on(`DocException`,e=>{t._capability.reject(J(e))}),e.on(`PasswordRequest`,e=>{this.#i=Promise.withResolvers();try{if(!t.onPassword)throw J(e);t.onPassword(e=>{e instanceof Error?this.#i.reject(e):this.#i.resolve({password:e})},e.code)}catch(e){this.#i.reject(e)}return this.#i.promise}),e.on(`DataLoaded`,e=>{t.onProgress?.({loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)}),e.on(`StartRenderPage`,e=>{this.destroyed||this.#t.get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)}),e.on(`commonobj`,([t,n,r])=>{if(this.destroyed||this.commonObjs.has(t))return null;switch(n){case`Font`:let{disableFontFace:i,fontExtraProperties:a,pdfBug:o}=this._params;if(`error`in r){let e=r.error;T(`Error during font loading: ${e}`),this.commonObjs.resolve(t,e);break}let s=new Xe(r,{disableFontFace:i,fontExtraProperties:a,inspectFont:o&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null});this.fontLoader.bind(s).catch(()=>e.sendWithPromise(`FontFallback`,{id:t})).finally(()=>{!a&&s.data&&(s.data=null),this.commonObjs.resolve(t,s)});break;case`CopyLocalImage`:let{imageRef:c}=r;D(c,`The imageRef must be defined.`);for(let e of this.#t.values())for(let[,n]of e.objs)if(n?.ref===c)return n.dataLen?(this.commonObjs.resolve(t,structuredClone(n)),n.dataLen):null;break;case`FontPath`:case`Image`:case`Pattern`:this.commonObjs.resolve(t,r);break;default:throw Error(`Got unknown common object type ${n}`)}return null}),e.on(`obj`,([e,t,n,r])=>{if(this.destroyed)return;let i=this.#t.get(t);if(!i.objs.has(e)){if(i._intentStates.size===0){r?.bitmap?.close();return}switch(n){case`Image`:i.objs.resolve(e,r),r?.dataLen>o&&(i._maybeCleanupAfterRender=!0);break;case`Pattern`:i.objs.resolve(e,r);break;default:throw Error(`Got unknown object type ${n}`)}}}),e.on(`DocProgress`,e=>{this.destroyed||t.onProgress?.({loaded:e.loaded,total:e.total})}),e.on(`FetchBuiltInCMap`,async e=>{if(this.destroyed)throw Error(`Worker was destroyed.`);if(!this.cMapReaderFactory)throw Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(e)}),e.on(`FetchStandardFontData`,async e=>{if(this.destroyed)throw Error(`Worker was destroyed.`);if(!this.standardFontDataFactory)throw Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(e)})}getData(){return this.messageHandler.sendWithPromise(`GetData`,null)}saveDocument(){this.annotationStorage.size<=0&&T("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise(`SaveDocument`,{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:this._fullReader?.filename??null},t).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(Error(`Invalid page request.`));let t=e-1,n=this.#n.get(t);if(n)return n;let r=this.messageHandler.sendWithPromise(`GetPage`,{pageIndex:t}).then(n=>{if(this.destroyed)throw Error(`Transport destroyed`);n.refStr&&this.#r.set(n.refStr,e);let r=new Vn(t,n,this,this._params.pdfBug);return this.#t.set(t,r),r});return this.#n.set(t,r),r}getPageIndex(e){return Ln(e)?this.messageHandler.sendWithPromise(`GetPageIndex`,{num:e.num,gen:e.gen}):Promise.reject(Error(`Invalid pageIndex request.`))}getAnnotations(e,t){return this.messageHandler.sendWithPromise(`GetAnnotations`,{pageIndex:e,intent:t})}getFieldObjects(){return this.#a(`GetFieldObjects`)}hasJSActions(){return this.#a(`HasJSActions`)}getCalculationOrderIds(){return this.messageHandler.sendWithPromise(`GetCalculationOrderIds`,null)}getDestinations(){return this.messageHandler.sendWithPromise(`GetDestinations`,null)}getDestination(e){return typeof e==`string`?this.messageHandler.sendWithPromise(`GetDestination`,{id:e}):Promise.reject(Error(`Invalid destination request.`))}getPageLabels(){return this.messageHandler.sendWithPromise(`GetPageLabels`,null)}getPageLayout(){return this.messageHandler.sendWithPromise(`GetPageLayout`,null)}getPageMode(){return this.messageHandler.sendWithPromise(`GetPageMode`,null)}getViewerPreferences(){return this.messageHandler.sendWithPromise(`GetViewerPreferences`,null)}getOpenAction(){return this.messageHandler.sendWithPromise(`GetOpenAction`,null)}getAttachments(){return this.messageHandler.sendWithPromise(`GetAttachments`,null)}getDocJSActions(){return this.#a(`GetDocJSActions`)}getPageJSActions(e){return this.messageHandler.sendWithPromise(`GetPageJSActions`,{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise(`GetStructTree`,{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise(`GetOutline`,null)}getOptionalContentConfig(e){return this.#a(`GetOptionalContentConfig`).then(t=>new Jt(t,e))}getPermissions(){return this.messageHandler.sendWithPromise(`GetPermissions`,null)}getMetadata(){let e=`GetMetadata`,t=this.#e.get(e);if(t)return t;let n=this.messageHandler.sendWithPromise(e,null).then(e=>({info:e[0],metadata:e[1]?new Gt(e[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#e.set(e,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise(`GetMarkInfo`,null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise(`Cleanup`,null);for(let e of this.#t.values())if(!e.cleanup())throw Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(!0),Tn.cleanup()}}cachedPageNumber(e){if(!Ln(e))return null;let t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return this.#r.get(t)??null}},Gn=Symbol(`INITIAL_DATA`),Kn=class{#e=Object.create(null);#t(e){return this.#e[e]||={...Promise.withResolvers(),data:Gn}}get(e,t=null){if(t){let n=this.#t(e);return n.promise.then(()=>t(n.data)),null}let n=this.#e[e];if(!n||n.data===Gn)throw Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){let t=this.#e[e];return!!t&&t.data!==Gn}delete(e){let t=this.#e[e];return!t||t.data===Gn?!1:(delete this.#e[e],!0)}resolve(e,t=null){let n=this.#t(e);n.data=t,n.resolve()}clear(){for(let e in this.#e){let{data:t}=this.#e[e];t?.bitmap?.close()}this.#e=Object.create(null)}*[Symbol.iterator](){for(let e in this.#e){let{data:t}=this.#e[e];t!==Gn&&(yield[e,t])}}},qn=class{#e=null;constructor(e){this.#e=e,this.onContinue=null}get promise(){return this.#e.capability.promise}cancel(e=0){this.#e.cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=this.#e.operatorList;if(!e)return!1;let{annotationCanvasMap:t}=this.#e;return e.form||e.canvas&&t?.size>0}},Jn=class e{#e=null;static#t=new WeakSet;constructor({callback:e,params:t,objs:n,commonObjs:r,annotationCanvasMap:i,operatorList:a,pageIndex:o,canvasFactory:s,filterFactory:c,useRequestAnimationFrame:l=!1,pdfBug:u=!1,pageColors:d=null}){this.callback=e,this.params=t,this.objs=n,this.commonObjs=r,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=s,this.filterFactory=c,this._pdfBug=u,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=l===!0&&typeof window<`u`,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new qn(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:n}){if(this.cancelled)return;if(this._canvas){if(e.#t.has(this._canvas))throw Error(`Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.`);e.#t.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:r,viewport:i,transform:a,background:o}=this.params;this.gfx=new Ut(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:n},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:i,transparency:t,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,n=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#e&&=(window.cancelAnimationFrame(this.#e),null),e.#t.delete(this._canvas),this.callback(t||new ye(`Rendering cancelled, page ${this._pageIndex+1}`,n))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#e=window.requestAnimationFrame(()=>{this.#e=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),e.#t.delete(this._canvas),this.callback())))}},Yn=`4.10.38`,Xn=`f9bea397f`;function Zn(e){return Math.floor(Math.max(0,Math.min(1,e))*255).toString(16).padStart(2,`0`)}function Qn(e){return Math.max(0,Math.min(255,255*e))}var $n=class{static CMYK_G([e,t,n,r]){return[`G`,1-Math.min(1,.3*e+.59*n+.11*t+r)]}static G_CMYK([e]){return[`CMYK`,0,0,0,1-e]}static G_RGB([e]){return[`RGB`,e,e,e]}static G_rgb([e]){return e=Qn(e),[e,e,e]}static G_HTML([e]){let t=Zn(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return[`G`,.3*e+.59*t+.11*n]}static RGB_rgb(e){return e.map(Qn)}static RGB_HTML(e){return`#${e.map(Zn).join(``)}`}static T_HTML(){return`#00000000`}static T_rgb(){return[null]}static CMYK_RGB([e,t,n,r]){return[`RGB`,1-Math.min(1,e+r),1-Math.min(1,n+r),1-Math.min(1,t+r)]}static CMYK_rgb([e,t,n,r]){return[Qn(1-Math.min(1,e+r)),Qn(1-Math.min(1,n+r)),Qn(1-Math.min(1,t+r))]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){let r=1-e,i=1-t,a=1-n;return[`CMYK`,r,i,a,Math.min(r,i,a)]}},er=class{create(e,t,n=!1){if(e<=0||t<=0)throw Error(`Invalid SVG dimensions`);let r=this._createSVG(`svg:svg`);return r.setAttribute(`version`,`1.1`),n||(r.setAttribute(`width`,`${e}px`),r.setAttribute(`height`,`${t}px`)),r.setAttribute(`preserveAspectRatio`,`none`),r.setAttribute(`viewBox`,`0 0 ${e} ${t}`),r}createElement(e){if(typeof e!=`string`)throw Error(`Invalid SVG element type`);return this._createSVG(e)}_createSVG(e){E("Abstract method `_createSVG` called.")}},tr=class extends er{_createSVG(e){return document.createElementNS(z,e)}},nr=class{static setupStorage(e,t,n,r,i){let a=r.getValue(t,{value:null});switch(n.name){case`textarea`:if(a.value!==null&&(e.textContent=a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})});break;case`input`:if(n.attributes.type===`radio`||n.attributes.type===`checkbox`){if(a.value===n.attributes.xfaOn?e.setAttribute(`checked`,!0):a.value===n.attributes.xfaOff&&e.removeAttribute(`checked`),i===`print`)break;e.addEventListener(`change`,e=>{r.setValue(t,{value:e.target.checked?e.target.getAttribute(`xfaOn`):e.target.getAttribute(`xfaOff`)})})}else{if(a.value!==null&&e.setAttribute(`value`,a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})})}break;case`select`:if(a.value!==null){e.setAttribute(`value`,a.value);for(let e of n.children)e.attributes.value===a.value?e.attributes.selected=!0:e.attributes.hasOwnProperty(`selected`)&&delete e.attributes.selected}e.addEventListener(`input`,e=>{let n=e.target.options,i=n.selectedIndex===-1?``:n[n.selectedIndex].value;r.setValue(t,{value:i})});break}}static setAttributes({html:e,element:t,storage:n=null,intent:r,linkService:i}){let{attributes:a}=t,o=e instanceof HTMLAnchorElement;a.type===`radio`&&(a.name=`${a.name}-${r}`);for(let[t,n]of Object.entries(a))if(n!=null)switch(t){case`class`:n.length&&e.setAttribute(t,n.join(` `));break;case`dataId`:break;case`id`:e.setAttribute(`data-element-id`,n);break;case`style`:Object.assign(e.style,n);break;case`textContent`:e.textContent=n;break;default:(!o||t!==`href`&&t!==`newWindow`)&&e.setAttribute(t,n)}o&&i.addLinkAttributes(e,a.href,a.newWindow),n&&a.dataId&&this.setupStorage(e,a.dataId,t,n)}static render(e){let t=e.annotationStorage,n=e.linkService,r=e.xfaHtml,i=e.intent||`display`,a=document.createElement(r.name);r.attributes&&this.setAttributes({html:a,element:r,intent:i,linkService:n});let o=i!==`richText`,s=e.div;if(s.append(a),e.viewport){let t=`matrix(${e.viewport.transform.join(`,`)})`;s.style.transform=t}o&&s.setAttribute(`class`,`xfaLayer xfaFont`);let c=[];if(r.children.length===0){if(r.value){let e=document.createTextNode(r.value);a.append(e),o&&En.shouldBuildText(r.name)&&c.push(e)}return{textDivs:c}}let l=[[r,-1,a]];for(;l.length>0;){let[e,r,a]=l.at(-1);if(r+1===e.children.length){l.pop();continue}let s=e.children[++l.at(-1)[1]];if(s===null)continue;let{name:u}=s;if(u===`#text`){let e=document.createTextNode(s.value);c.push(e),a.append(e);continue}let d=s?.attributes?.xmlns?document.createElementNS(s.attributes.xmlns,u):document.createElement(u);if(a.append(d),s.attributes&&this.setAttributes({html:d,element:s,storage:t,intent:i,linkService:n}),s.children?.length>0)l.push([s,-1,d]);else if(s.value){let e=document.createTextNode(s.value);o&&En.shouldBuildText(u)&&c.push(e),d.append(e)}}for(let e of s.querySelectorAll(`.xfaNonInteractive input, .xfaNonInteractive textarea`))e.setAttribute(`readOnly`,!0);return{textDivs:c}}static update(e){let t=`matrix(${e.viewport.transform.join(`,`)})`;e.div.style.transform=t,e.div.hidden=!1}},rr=1e3,ir=9,ar=new WeakSet;function or(e){return{width:e[2]-e[0],height:e[3]-e[1]}}var sr=class{static create(e){switch(e.data.annotationType){case g.LINK:return new cr(e);case g.TEXT:return new lr(e);case g.WIDGET:switch(e.data.fieldType){case`Tx`:return new dr(e);case`Btn`:return e.data.radioButton?new mr(e):e.data.checkBox?new pr(e):new hr(e);case`Ch`:return new gr(e);case`Sig`:return new fr(e)}return new ur(e);case g.POPUP:return new _r(e);case g.FREETEXT:return new yr(e);case g.LINE:return new br(e);case g.SQUARE:return new xr(e);case g.CIRCLE:return new Sr(e);case g.POLYLINE:return new Cr(e);case g.CARET:return new Tr(e);case g.INK:return new Er(e);case g.POLYGON:return new wr(e);case g.HIGHLIGHT:return new Dr(e);case g.UNDERLINE:return new Or(e);case g.SQUIGGLY:return new kr(e);case g.STRIKEOUT:return new Ar(e);case g.STAMP:return new jr(e);case g.FILEATTACHMENT:return new Mr(e);default:return new Q(e)}}},Q=class e{#e=null;#t=!1;#n=null;constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:r=!1}={}){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(n)),r&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:n}){return!!(e?.str||t?.str||n?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return e._hasPopupData(this.data)}updateEdited(e){if(!this.container)return;this.#e||={rect:this.data.rect.slice(0)};let{rect:t}=e;t&&this.#r(t),this.#n?.popup.updateEdited(e)}resetEdited(){this.#e&&=(this.#r(this.#e.rect),this.#n?.popup.resetEdited(),null)}#r(e){let{container:{style:t},data:{rect:n,rotation:r},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:o,pageY:s}}}}=this;n?.splice(0,4,...e);let{width:c,height:l}=or(e);t.left=`${100*(e[0]-o)/i}%`,t.top=`${100*(a-e[3]+s)/a}%`,r===0?(t.width=`${100*c/i}%`,t.height=`${100*l/a}%`):this.setRotation(r)}_createContainer(e){let{data:t,parent:{page:n,viewport:r}}=this,i=document.createElement(`section`);i.setAttribute(`data-annotation-id`,t.id),this instanceof ur||(i.tabIndex=rr);let{style:a}=i;if(a.zIndex=this.parent.zIndex++,t.alternativeText&&(i.title=t.alternativeText),t.noRotate&&i.classList.add(`norotate`),!t.rect||this instanceof _r){let{rotation:e}=t;return!t.hasOwnCanvas&&e!==0&&this.setRotation(e,i),i}let{width:o,height:s}=or(t.rect);if(!e&&t.borderStyle.width>0){a.borderWidth=`${t.borderStyle.width}px`;let e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;switch(e>0||n>0?a.borderRadius=`calc(${e}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`:this instanceof mr&&(a.borderRadius=`calc(${o}px * var(--scale-factor)) / calc(${s}px * var(--scale-factor))`),t.borderStyle.style){case _.SOLID:a.borderStyle=`solid`;break;case _.DASHED:a.borderStyle=`dashed`;break;case _.BEVELED:T(`Unimplemented border style: beveled`);break;case _.INSET:T(`Unimplemented border style: inset`);break;case _.UNDERLINE:a.borderBottomStyle=`solid`;break;default:break}let r=t.borderColor||null;r?(this.#t=!0,a.borderColor=R.makeHexColor(r[0]|0,r[1]|0,r[2]|0)):a.borderWidth=0}let c=R.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]),{pageWidth:l,pageHeight:u,pageX:d,pageY:f}=r.rawDims;a.left=`${100*(c[0]-d)/l}%`,a.top=`${100*(c[1]-f)/u}%`;let{rotation:p}=t;return t.hasOwnCanvas||p===0?(a.width=`${100*o/l}%`,a.height=`${100*s/u}%`):this.setRotation(p,i),i}setRotation(e,t=this.container){if(!this.data.rect)return;let{pageWidth:n,pageHeight:r}=this.parent.viewport.rawDims,{width:i,height:a}=or(this.data.rect),o,s;e%180==0?(o=100*i/n,s=100*a/r):(o=100*a/n,s=100*i/r),t.style.width=`${o}%`,t.style.height=`${s}%`,t.setAttribute(`data-main-rotation`,(360-e)%360)}get _commonActions(){let e=(e,t,n)=>{let r=n.detail[e],i=r[0],a=r.slice(1);n.target.style[t]=$n[`${i}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[t]:$n[`${i}_rgb`](a)})};return A(this,`_commonActions`,{display:e=>{let{display:t}=e.detail,n=t%2==1;this.container.style.visibility=n?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:t===1||t===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{let{hidden:t}=e.detail;this.container.style.visibility=t?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e(`bgColor`,`backgroundColor`,t)},fillColor:t=>{e(`fillColor`,`backgroundColor`,t)},fgColor:t=>{e(`fgColor`,`color`,t)},textColor:t=>{e(`textColor`,`color`,t)},borderColor:t=>{e(`borderColor`,`borderColor`,t)},strokeColor:t=>{e(`strokeColor`,`borderColor`,t)},rotation:e=>{let t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){let n=this._commonActions;for(let r of Object.keys(t.detail))(e[r]||n[r])?.(t)}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let n=this._commonActions;for(let[r,i]of Object.entries(t)){let a=n[r];a&&(a({detail:{[r]:i},target:e}),delete t[r])}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[t,n,r,i]=this.data.rect.map(e=>Math.fround(e));if(e.length===8){let[a,o,s,c]=e.subarray(2,6);if(r===a&&i===o&&t===s&&n===c)return}let{style:a}=this.container,o;if(this.#t){let{borderColor:e,borderWidth:t}=a;a.borderWidth=0,o=[`url('data:image/svg+xml;utf8,`,`<svg xmlns="http://www.w3.org/2000/svg"`,` preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${e}" stroke-width="${t}">`],this.container.classList.add(`hasBorder`)}let s=r-t,c=i-n,{svgFactory:l}=this,u=l.createElement(`svg`);u.classList.add(`quadrilateralsContainer`),u.setAttribute(`width`,0),u.setAttribute(`height`,0);let d=l.createElement(`defs`);u.append(d);let f=l.createElement(`clipPath`),p=`clippath_${this.data.id}`;f.setAttribute(`id`,p),f.setAttribute(`clipPathUnits`,`objectBoundingBox`),d.append(f);for(let n=2,r=e.length;n<r;n+=8){let r=e[n],a=e[n+1],u=e[n+2],d=e[n+3],p=l.createElement(`rect`),m=(u-t)/s,h=(i-a)/c,g=(r-u)/s,_=(a-d)/c;p.setAttribute(`x`,m),p.setAttribute(`y`,h),p.setAttribute(`width`,g),p.setAttribute(`height`,_),f.append(p),o?.push(`<rect vector-effect="non-scaling-stroke" x="${m}" y="${h}" width="${g}" height="${_}"/>`)}this.#t&&(o.push(`</g></svg>')`),a.backgroundImage=o.join(``)),this.container.append(u),this.container.style.clipPath=`url(#${p})`}_createPopup(){let{data:e}=this,t=this.#n=new _r({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(t.render())}render(){E("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let n=[];if(this._fieldObjects){let r=this._fieldObjects[e];if(r)for(let{page:e,id:i,exportValues:a}of r){if(e===-1||i===t)continue;let r=typeof a==`string`?a:null,o=document.querySelector(`[data-element-id="${i}"]`);if(o&&!ar.has(o)){T(`_getElementsByName - element not allowed: ${i}`);continue}n.push({id:i,exportValue:r,domElement:o})}return n}for(let r of document.getElementsByName(e)){let{exportValue:e}=r,i=r.getAttribute(`data-element-id`);i!==t&&ar.has(r)&&n.push({id:i,exportValue:e,domElement:r})}return n}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(let t of e)t.classList.add(`highlightArea`);else e.classList.add(`highlightArea`)}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener(`dblclick`,()=>{this.linkService.eventBus?.dispatch(`switchannotationeditormode`,{source:this,mode:e,editId:t})})}},cr=class extends Q{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,n=document.createElement(`a`);n.setAttribute(`data-element-id`,e.id);let r=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(n,e.action),r=!0):e.attachment?(this.#t(n,e.attachment,e.attachmentDest),r=!0):e.setOCGState?(this.#n(n,e.setOCGState),r=!0):e.dest?(this._bindLink(n,e.dest),r=!0):(e.actions&&(e.actions.Action||e.actions[`Mouse Up`]||e.actions[`Mouse Down`])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),r=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,``),r=!0)),this.container.classList.add(`linkAnnotation`),r&&this.container.append(n),this.container}#e(){this.container.setAttribute(`data-internal-link`,``)}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||t===``)&&this.#e()}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),this.#e()}#t(e,t,n=null){e.href=this.linkService.getAnchorUrl(``),t.description&&(e.title=t.description),e.onclick=()=>(this.downloadManager?.openOrDownloadData(t.content,t.filename,n),!1),this.#e()}#n(e,t){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),this.#e()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl(``);let n=new Map([[`Action`,`onclick`],[`Mouse Up`,`onmouseup`],[`Mouse Down`,`onmousedown`]]);for(let r of Object.keys(t.actions)){let i=n.get(r);i&&(e[i]=()=>(this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t.id,name:r}}),!1))}e.onclick||=()=>!1,this.#e()}_bindResetFormAction(e,t){let n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl(``)),this.#e(),!this._fieldObjects){T('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(e.onclick=()=>!1);return}e.onclick=()=>{n?.();let{fields:e,refs:r,include:i}=t,a=[];if(e.length!==0||r.length!==0){let t=new Set(r);for(let n of e){let e=this._fieldObjects[n]||[];for(let{id:n}of e)t.add(n)}for(let e of Object.values(this._fieldObjects))for(let n of e)t.has(n.id)===i&&a.push(n)}else for(let e of Object.values(this._fieldObjects))a.push(...e);let o=this.annotationStorage,s=[];for(let e of a){let{id:t}=e;switch(s.push(t),e.type){case`text`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}case`checkbox`:case`radiobutton`:{let n=e.defaultValue===e.exportValues;o.setValue(t,{value:n});break}case`combobox`:case`listbox`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}default:continue}let n=document.querySelector(`[data-element-id="${t}"]`);if(n){if(!ar.has(n)){T(`_bindResetFormAction - element not allowed: ${t}`);continue}n.dispatchEvent(new Event(`resetform`))}}return this.enableScripting&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:`app`,ids:s,name:`ResetForm`}}),!1}}},lr=class extends Q{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add(`textAnnotation`);let e=document.createElement(`img`);return e.src=this.imageResourcesPath+`annotation-`+this.data.name.toLowerCase()+`.svg`,e.setAttribute(`data-l10n-id`,`pdfjs-text-annotation-type`),e.setAttribute(`data-l10n-args`,JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}},ur=class extends Q{render(){return this.container}showElementAndHideCanvas(e){this.data.hasOwnCanvas&&(e.previousSibling?.nodeName===`CANVAS`&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return L.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,n,r,i){n.includes(`mouse`)?e.addEventListener(n,e=>{this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})}):e.addEventListener(n,e=>{if(n===`blur`){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if(n===`focus`){if(t.focused)return;t.focused=!0}i&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e)}})})}_setEventListeners(e,t,n,r){for(let[i,a]of n)(a===`Action`||this.data.actions?.[a])&&((a===`Focus`||a===`Blur`)&&(t||={focused:!1}),this._setEventListener(e,t,i,a,r),a===`Focus`&&!this.data.actions?.Blur?this._setEventListener(e,t,`blur`,`Blur`,null):a===`Blur`&&!this.data.actions?.Focus&&this._setEventListener(e,t,`focus`,`Focus`,null))}_setBackgroundColor(e){let t=this.data.backgroundColor||null;e.style.backgroundColor=t===null?`transparent`:R.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){let t=[`left`,`center`,`right`],{fontColor:n}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||ir,i=e.style,a,o=e=>Math.round(10*e)/10;if(this.data.multiLine){let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(s*r))||1);a=Math.min(r,o(t/s))}else{let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(r,o(e/s))}i.fontSize=`calc(${a}px * var(--scale-factor))`,i.color=R.makeHexColor(n[0],n[1],n[2]),this.data.textAlignment!==null&&(i.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute(`required`,!0):e.removeAttribute(`required`),e.setAttribute(`aria-required`,t)}},dr=class extends ur{constructor(e){let t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,n,r){let i=this.annotationStorage;for(let a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[t]=n),i.setValue(a.id,{[r]:n})}render(){let e=this.annotationStorage,t=this.data.id;this.container.classList.add(`textWidgetAnnotation`);let n=null;if(this.renderForms){let r=e.getValue(t,{value:this.data.fieldValue}),i=r.value||``,a=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;a&&i.length>a&&(i=i.slice(0,a));let o=r.formattedValue||this.data.textContent?.join(`
1
+ import{t as e}from"./preload-helper-BQrMkyGX.js";var t={};t.d=(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n=globalThis.pdfjsLib={};t.d(n,{AbortException:()=>I,AnnotationEditorLayer:()=>Zr,AnnotationEditorParamsType:()=>f,AnnotationEditorType:()=>d,AnnotationEditorUIManager:()=>Be,AnnotationLayer:()=>Nr,AnnotationMode:()=>l,ColorPicker:()=>Hr,DOMSVGFactory:()=>tr,DrawLayer:()=>Qr,FeatureTest:()=>L,GlobalWorkerOptions:()=>Wt,ImageKind:()=>h,InvalidPDFException:()=>P,MissingPDFException:()=>F,OPS:()=>y,OutputScale:()=>je,PDFDataRangeTransport:()=>zn,PDFDateString:()=>Ee,PDFWorker:()=>Un,PasswordResponses:()=>b,PermissionFlag:()=>p,PixelsPerInch:()=>ge,RenderingCancelledException:()=>ye,TextLayer:()=>Tn,TouchManager:()=>He,UnexpectedResponseException:()=>ee,Util:()=>R,VerbosityLevel:()=>v,XfaLayer:()=>nr,build:()=>Xn,createValidAbsoluteUrl:()=>k,fetchData:()=>_e,getDocument:()=>Pn,getFilenameFromUrl:()=>Se,getPdfFilenameFromUrl:()=>Ce,getXfaPageViewport:()=>De,isDataScheme:()=>be,isPdfFile:()=>xe,noContextMenu:()=>B,normalizeUnicode:()=>fe,setLayerDimensions:()=>Ae,shadow:()=>A,stopEvent:()=>V,version:()=>Yn});var r=typeof process==`object`&&process+``==`[object process]`&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!==`browser`),i=[1,0,0,1,0,0],a=[.001,0,0,.001,0,0],o=1e7,s=1.35;.35/s;var c={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},l={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},u=`pdfjs_internal_editor_`,d={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},f={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},p={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},m={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},h={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},g={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},_={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},v={ERRORS:0,WARNINGS:1,INFOS:5},y={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},b={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},x=v.WARNINGS;function S(e){Number.isInteger(e)&&(x=e)}function C(){return x}function w(e){x>=v.INFOS&&console.log(`Info: ${e}`)}function T(e){x>=v.WARNINGS&&console.log(`Warning: ${e}`)}function E(e){throw Error(e)}function D(e,t){e||E(t)}function O(e){switch(e?.protocol){case`http:`:case`https:`:case`ftp:`:case`mailto:`:case`tel:`:return!0;default:return!1}}function k(e,t=null,n=null){if(!e)return null;try{if(n&&typeof e==`string`&&(n.addDefaultProtocol&&e.startsWith(`www.`)&&e.match(/\./g)?.length>=2&&(e=`http://${e}`),n.tryConvertEncoding))try{e=le(e)}catch{}let r=t?new URL(e,t):new URL(e);if(O(r))return r}catch{}return null}function A(e,t,n,r=!1){return Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}var j=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=Error(),e.constructor=e,e}(),M=class extends j{constructor(e,t){super(e,`PasswordException`),this.code=t}},N=class extends j{constructor(e,t){super(e,`UnknownErrorException`),this.details=t}},P=class extends j{constructor(e){super(e,`InvalidPDFException`)}},F=class extends j{constructor(e){super(e,`MissingPDFException`)}},ee=class extends j{constructor(e,t){super(e,`UnexpectedResponseException`),this.status=t}},te=class extends j{constructor(e){super(e,`FormatError`)}},I=class extends j{constructor(e){super(e,`AbortException`)}};function ne(e){(typeof e!=`object`||e?.length===void 0)&&E(`Invalid argument for bytesToString`);let t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);let r=[];for(let i=0;i<t;i+=n){let a=Math.min(i+n,t),o=e.subarray(i,a);r.push(String.fromCharCode.apply(null,o))}return r.join(``)}function re(e){typeof e!=`string`&&E(`Invalid argument for stringToBytes`);let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r)&255;return n}function ie(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255)}function ae(e){let t=Object.create(null);for(let[n,r]of e)t[n]=r;return t}function oe(){let e=new Uint8Array(4);return e[0]=1,new Uint32Array(e.buffer,0,1)[0]===1}function se(){try{return Function(``),!0}catch{return!1}}var L=class{static get isLittleEndian(){return A(this,`isLittleEndian`,oe())}static get isEvalSupported(){return A(this,`isEvalSupported`,se())}static get isOffscreenCanvasSupported(){return A(this,`isOffscreenCanvasSupported`,typeof OffscreenCanvas<`u`)}static get isImageDecoderSupported(){return A(this,`isImageDecoderSupported`,typeof ImageDecoder<`u`)}static get platform(){return typeof navigator<`u`&&typeof navigator?.platform==`string`?A(this,`platform`,{isMac:navigator.platform.includes(`Mac`),isWindows:navigator.platform.includes(`Win`),isFirefox:typeof navigator?.userAgent==`string`&&navigator.userAgent.includes(`Firefox`)}):A(this,`platform`,{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return A(this,`isCSSRoundSupported`,globalThis.CSS?.supports?.(`width: round(1.5px, 1px)`))}},ce=Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,`0`)),R=class{static makeHexColor(e,t,n){return`#${ce[e]}${ce[t]}${ce[n]}`}static scaleMinMax(e,t){let n;e[0]?(e[0]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[3],t[3]*=e[3]):(n=t[0],t[0]=t[1],t[1]=n,n=t[2],t[2]=t[3],t[3]=n,e[1]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[2],t[2]*=e[2]),t[0]+=e[4],t[1]+=e[5],t[2]+=e[4],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){let n=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){let n=this.applyTransform(e,t),r=this.applyTransform(e.slice(2,4),t),i=this.applyTransform([e[0],e[3]],t),a=this.applyTransform([e[2],e[1]],t);return[Math.min(n[0],r[0],i[0],a[0]),Math.min(n[1],r[1],i[1],a[1]),Math.max(n[0],r[0],i[0],a[0]),Math.max(n[1],r[1],i[1],a[1])]}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){let t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],r=e[0]*t[1]+e[1]*t[3],i=e[2]*t[0]+e[3]*t[2],a=e[2]*t[1]+e[3]*t[3],o=(n+a)/2,s=Math.sqrt((n+a)**2-4*(n*a-i*r))/2,c=o+s||1,l=o-s||1;return[Math.sqrt(c),Math.sqrt(l)]}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>r)return null;let i=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return i>a?null:[n,i,r,a]}static#e(e,t,n,r,i,a,o,s,c,l){if(c<=0||c>=1)return;let u=1-c,d=c*c,f=d*c,p=u*(u*(u*e+3*c*t)+3*d*n)+f*r,m=u*(u*(u*i+3*c*a)+3*d*o)+f*s;l[0]=Math.min(l[0],p),l[1]=Math.min(l[1],m),l[2]=Math.max(l[2],p),l[3]=Math.max(l[3],m)}static#t(e,t,n,r,i,a,o,s,c,l,u,d){if(Math.abs(c)<1e-12){Math.abs(l)>=1e-12&&this.#e(e,t,n,r,i,a,o,s,-u/l,d);return}let f=l**2-4*u*c;if(f<0)return;let p=Math.sqrt(f),m=2*c;this.#e(e,t,n,r,i,a,o,s,(-l+p)/m,d),this.#e(e,t,n,r,i,a,o,s,(-l-p)/m,d)}static bezierBoundingBox(e,t,n,r,i,a,o,s,c){return c?(c[0]=Math.min(c[0],e,o),c[1]=Math.min(c[1],t,s),c[2]=Math.max(c[2],e,o),c[3]=Math.max(c[3],t,s)):c=[Math.min(e,o),Math.min(t,s),Math.max(e,o),Math.max(t,s)],this.#t(e,n,i,o,t,r,a,s,3*(-e+3*(n-i)+o),6*(e-2*n+i),3*(n-e),c),this.#t(e,n,i,o,t,r,a,s,3*(-t+3*(r-a)+s),6*(t-2*r+a),3*(r-t),c),c}};function le(e){return decodeURIComponent(escape(e))}var ue=null,de=null;function fe(e){return ue||(ue=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,de=new Map([[`ſt`,`ſt`]])),e.replaceAll(ue,(e,t,n)=>t?t.normalize(`NFKC`):de.get(n))}function pe(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(32);return crypto.getRandomValues(e),ne(e)}var me=`pdfjs_internal_id_`;function he(e){return Uint8Array.prototype.toBase64?e.toBase64():btoa(ne(e))}typeof Promise.try!=`function`&&(Promise.try=function(e,...t){return new Promise(n=>{n(e(...t))})});var z=`http://www.w3.org/2000/svg`,ge=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function _e(e,t=`text`){if(Te(e,document.baseURI)){let n=await fetch(e);if(!n.ok)throw Error(n.statusText);switch(t){case`arraybuffer`:return n.arrayBuffer();case`blob`:return n.blob();case`json`:return n.json()}return n.text()}return new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(`GET`,e,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case`arraybuffer`:case`blob`:case`json`:n(i.response);return}n(i.responseText);return}r(Error(i.statusText))}},i.send(null)})}var ve=class e{constructor({viewBox:e,userUnit:t,scale:n,rotation:r,offsetX:i=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=t,this.scale=n,this.rotation=r,this.offsetX=i,this.offsetY=a,n*=t;let s=(e[2]+e[0])/2,c=(e[3]+e[1])/2,l,u,d,f;switch(r%=360,r<0&&(r+=360),r){case 180:l=-1,u=0,d=0,f=1;break;case 90:l=0,u=1,d=1,f=0;break;case 270:l=0,u=-1,d=-1,f=0;break;case 0:l=1,u=0,d=0,f=-1;break;default:throw Error(`PageViewport: Invalid rotation, must be a multiple of 90 degrees.`)}o&&(d=-d,f=-f);let p,m,h,g;l===0?(p=Math.abs(c-e[1])*n+i,m=Math.abs(s-e[0])*n+a,h=(e[3]-e[1])*n,g=(e[2]-e[0])*n):(p=Math.abs(s-e[0])*n+i,m=Math.abs(c-e[1])*n+a,h=(e[2]-e[0])*n,g=(e[3]-e[1])*n),this.transform=[l*n,u*n,d*n,f*n,p-l*n*s-d*n*c,m-u*n*s-f*n*c],this.width=h,this.height=g}get rawDims(){let{userUnit:e,viewBox:t}=this,n=t.map(t=>t*e);return A(this,`rawDims`,{pageWidth:n[2]-n[0],pageHeight:n[3]-n[1],pageX:n[0],pageY:n[1]})}clone({scale:t=this.scale,rotation:n=this.rotation,offsetX:r=this.offsetX,offsetY:i=this.offsetY,dontFlip:a=!1}={}){return new e({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:n,offsetX:r,offsetY:i,dontFlip:a})}convertToViewportPoint(e,t){return R.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){let t=R.applyTransform([e[0],e[1]],this.transform),n=R.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],n[0],n[1]]}convertToPdfPoint(e,t){return R.applyInverseTransform([e,t],this.transform)}},ye=class extends j{constructor(e,t=0){super(e,`RenderingCancelledException`),this.extraDelay=t}};function be(e){let t=e.length,n=0;for(;n<t&&e[n].trim()===``;)n++;return e.substring(n,n+5).toLowerCase()===`data:`}function xe(e){return typeof e==`string`&&/\.pdf$/i.test(e)}function Se(e){return[e]=e.split(/[#?]/,1),e.substring(e.lastIndexOf(`/`)+1)}function Ce(e,t=`document.pdf`){if(typeof e!=`string`)return t;if(be(e))return T(`getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.`),t;let n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,r=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=n.exec(e),a=r.exec(i[1])||r.exec(i[2])||r.exec(i[3]);if(a&&(a=a[0],a.includes(`%`)))try{a=r.exec(decodeURIComponent(a))[0]}catch{}return a||t}var we=class{started=Object.create(null);times=[];time(e){e in this.started&&T(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||T(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){let e=[],t=0;for(let{name:e}of this.times)t=Math.max(e.length,t);for(let{name:n,start:r,end:i}of this.times)e.push(`${n.padEnd(t)} ${i-r}ms\n`);return e.join(``)}};function Te(e,t){try{let{protocol:n}=t?new URL(e,t):new URL(e);return n===`http:`||n===`https:`}catch{return!1}}function B(e){e.preventDefault()}function V(e){e.preventDefault(),e.stopPropagation()}var Ee=class{static#e;static toDateObject(e){if(!e||typeof e!=`string`)return null;this.#e||=RegExp(`^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?`);let t=this.#e.exec(e);if(!t)return null;let n=parseInt(t[1],10),r=parseInt(t[2],10);r=r>=1&&r<=12?r-1:0;let i=parseInt(t[3],10);i=i>=1&&i<=31?i:1;let a=parseInt(t[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(t[5],10);o=o>=0&&o<=59?o:0;let s=parseInt(t[6],10);s=s>=0&&s<=59?s:0;let c=t[7]||`Z`,l=parseInt(t[8],10);l=l>=0&&l<=23?l:0;let u=parseInt(t[9],10)||0;return u=u>=0&&u<=59?u:0,c===`-`?(a+=l,o+=u):c===`+`&&(a-=l,o-=u),new Date(Date.UTC(n,r,i,a,o,s))}};function De(e,{scale:t=1,rotation:n=0}){let{width:r,height:i}=e.attributes.style;return new ve({viewBox:[0,0,parseInt(r),parseInt(i)],userUnit:1,scale:t,rotation:n})}function Oe(e){if(e.startsWith(`#`)){let t=parseInt(e.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return e.startsWith(`rgb(`)?e.slice(4,-1).split(`,`).map(e=>parseInt(e)):e.startsWith(`rgba(`)?e.slice(5,-1).split(`,`).map(e=>parseInt(e)).slice(0,3):(T(`Not a valid color format: "${e}"`),[0,0,0])}function ke(e){let t=document.createElement(`span`);t.style.visibility=`hidden`,document.body.append(t);for(let n of e.keys()){t.style.color=n;let r=window.getComputedStyle(t).color;e.set(n,Oe(r))}t.remove()}function H(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform();return[t,n,r,i,a,o]}function U(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform().invertSelf();return[t,n,r,i,a,o]}function Ae(e,t,n=!1,r=!0){if(t instanceof ve){let{pageWidth:r,pageHeight:i}=t.rawDims,{style:a}=e,o=L.isCSSRoundSupported,s=`var(--scale-factor) * ${r}px`,c=`var(--scale-factor) * ${i}px`,l=o?`round(down, ${s}, var(--scale-round-x, 1px))`:`calc(${s})`,u=o?`round(down, ${c}, var(--scale-round-y, 1px))`:`calc(${c})`;!n||t.rotation%180==0?(a.width=l,a.height=u):(a.width=u,a.height=l)}r&&e.setAttribute(`data-main-rotation`,t.rotation)}var je=class{constructor(){let e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}},Me=class e{#e=null;#t=null;#n;#r=null;#i=null;static#a=null;constructor(t){this.#n=t,e.#a||=Object.freeze({freetext:`pdfjs-editor-remove-freetext-button`,highlight:`pdfjs-editor-remove-highlight-button`,ink:`pdfjs-editor-remove-ink-button`,stamp:`pdfjs-editor-remove-stamp-button`})}render(){let t=this.#e=document.createElement(`div`);t.classList.add(`editToolbar`,`hidden`),t.setAttribute(`role`,`toolbar`);let n=this.#n._uiManager._signal;t.addEventListener(`contextmenu`,B,{signal:n}),t.addEventListener(`pointerdown`,e.#o,{signal:n});let r=this.#r=document.createElement(`div`);r.className=`buttons`,t.append(r);let i=this.#n.toolbarPosition;if(i){let{style:e}=t;e.insetInlineEnd=`${100*(this.#n._uiManager.direction===`ltr`?1-i[0]:i[0])}%`,e.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#u(),t}get div(){return this.#e}static#o(e){e.stopPropagation()}#s(e){this.#n._focusEventsAllowed=!1,V(e)}#c(e){this.#n._focusEventsAllowed=!0,V(e)}#l(e){let t=this.#n._uiManager._signal;e.addEventListener(`focusin`,this.#s.bind(this),{capture:!0,signal:t}),e.addEventListener(`focusout`,this.#c.bind(this),{capture:!0,signal:t}),e.addEventListener(`contextmenu`,B,{signal:t})}hide(){this.#e.classList.add(`hidden`),this.#t?.hideDropdown()}show(){this.#e.classList.remove(`hidden`),this.#i?.shown()}#u(){let{editorType:t,_uiManager:n}=this.#n,r=document.createElement(`button`);r.className=`delete`,r.tabIndex=0,r.setAttribute(`data-l10n-id`,e.#a[t]),this.#l(r),r.addEventListener(`click`,e=>{n.delete()},{signal:n._signal}),this.#r.append(r)}get#d(){let e=document.createElement(`div`);return e.className=`divider`,e}async addAltText(e){let t=await e.render();this.#l(t),this.#r.prepend(t,this.#d),this.#i=e}addColorPicker(e){this.#t=e;let t=e.renderButton();this.#l(t),this.#r.prepend(t,this.#d)}remove(){this.#e.remove(),this.#t?.destroy(),this.#t=null}},Ne=class{#e=null;#t=null;#n;constructor(e){this.#n=e}#r(){let e=this.#t=document.createElement(`div`);e.className=`editToolbar`,e.setAttribute(`role`,`toolbar`),e.addEventListener(`contextmenu`,B,{signal:this.#n._signal});let t=this.#e=document.createElement(`div`);return t.className=`buttons`,e.append(t),this.#a(),e}#i(e,t){let n=0,r=0;for(let i of e){let e=i.y+i.height;if(e<n)continue;let a=i.x+(t?i.width:0);if(e>n){r=a,n=e;continue}t?a>r&&(r=a):a<r&&(r=a)}return[t?1-r:r,n]}show(e,t,n){let[r,i]=this.#i(t,n),{style:a}=this.#t||=this.#r();e.append(this.#t),a.insetInlineEnd=`${100*r}%`,a.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){this.#t.remove()}#a(){let e=document.createElement(`button`);e.className=`highlightButton`,e.tabIndex=0,e.setAttribute(`data-l10n-id`,`pdfjs-highlight-floating-button1`);let t=document.createElement(`span`);e.append(t),t.className=`visuallyHidden`,t.setAttribute(`data-l10n-id`,`pdfjs-highlight-floating-button-label`);let n=this.#n._signal;e.addEventListener(`contextmenu`,B,{signal:n}),e.addEventListener(`click`,()=>{this.#n.highlightSelection(`floating_button`)},{signal:n}),this.#e.append(e)}};function Pe(e,t,n){for(let r of n)t.addEventListener(r,e[r].bind(e))}var Fe=class{#e=0;get id(){return`${u}${this.#e++}`}},Ie=class e{#e=pe();#t=0;#n=null;static get _isSVGFittingCanvas(){let e=new OffscreenCanvas(1,3).getContext(`2d`,{willReadFrequently:!0}),t=new Image;t.src=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>`;let n=t.decode().then(()=>(e.drawImage(t,0,0,1,1,0,0,1,3),new Uint32Array(e.getImageData(0,0,1,1).data.buffer)[0]===0));return A(this,`_isSVGFittingCanvas`,n)}async#r(t,n){this.#n||=new Map;let r=this.#n.get(t);if(r===null)return null;if(r?.bitmap)return r.refCounter+=1,r;try{r||={bitmap:null,id:`image_${this.#e}_${this.#t++}`,refCounter:0,isSvg:!1};let t;if(typeof n==`string`?(r.url=n,t=await _e(n,`blob`)):n instanceof File?t=r.file=n:n instanceof Blob&&(t=n),t.type===`image/svg+xml`){let n=e._isSVGFittingCanvas,i=new FileReader,a=new Image,o=new Promise((e,t)=>{a.onload=()=>{r.bitmap=a,r.isSvg=!0,e()},i.onload=async()=>{let e=r.svgUrl=i.result;a.src=await n?`${e}#svgView(preserveAspectRatio(none))`:e},a.onerror=i.onerror=t});i.readAsDataURL(t),await o}else r.bitmap=await createImageBitmap(t);r.refCounter=1}catch(e){T(e),r=null}return this.#n.set(t,r),r&&this.#n.set(r.id,r),r}async getFromFile(e){let{lastModified:t,name:n,size:r,type:i}=e;return this.#r(`${t}_${n}_${r}_${i}`,e)}async getFromUrl(e){return this.#r(e,e)}async getFromBlob(e,t){let n=await t;return this.#r(e,n)}async getFromId(e){this.#n||=new Map;let t=this.#n.get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){let{blobPromise:e}=t;return delete t.blobPromise,this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){this.#n||=new Map;let n=this.#n.get(e);if(n?.bitmap)return n.refCounter+=1,n;let r=new OffscreenCanvas(t.width,t.height);return r.getContext(`2d`).drawImage(t,0,0),n={bitmap:r.transferToImageBitmap(),id:`image_${this.#e}_${this.#t++}`,refCounter:1,isSvg:!1},this.#n.set(e,n),this.#n.set(n.id,n),n}getSvgUrl(e){let t=this.#n.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#n||=new Map;let t=this.#n.get(e);if(!t||(--t.refCounter,t.refCounter!==0))return;let{bitmap:n}=t;if(!t.url&&!t.file){let e=new OffscreenCanvas(n.width,n.height);e.getContext(`bitmaprenderer`).transferFromImageBitmap(n),t.blobPromise=e.convertToBlob()}n.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#e}_`)}},Le=class{#e=[];#t=!1;#n;#r=-1;constructor(e=128){this.#n=e}add({cmd:e,undo:t,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(r&&e(),this.#t)return;let s={cmd:e,undo:t,post:n,type:i};if(this.#r===-1){this.#e.length>0&&(this.#e.length=0),this.#r=0,this.#e.push(s);return}if(a&&this.#e[this.#r].type===i){o&&(s.undo=this.#e[this.#r].undo),this.#e[this.#r]=s;return}let c=this.#r+1;c===this.#n?this.#e.splice(0,1):(this.#r=c,c<this.#e.length&&this.#e.splice(c)),this.#e.push(s)}undo(){if(this.#r===-1)return;this.#t=!0;let{undo:e,post:t}=this.#e[this.#r];e(),t?.(),this.#t=!1,--this.#r}redo(){if(this.#r<this.#e.length-1){this.#r+=1,this.#t=!0;let{cmd:e,post:t}=this.#e[this.#r];e(),t?.(),this.#t=!1}}hasSomethingToUndo(){return this.#r!==-1}hasSomethingToRedo(){return this.#r<this.#e.length-1}cleanType(e){if(this.#r!==-1){for(let t=this.#r;t>=0;t--)if(this.#e[t].type!==e){this.#e.splice(t+1,this.#r-t),this.#r=t;return}this.#e.length=0,this.#r=-1}}destroy(){this.#e=null}},Re=class{constructor(e){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:t}=L.platform;for(let[n,r,i={}]of e)for(let e of n){let n=e.startsWith(`mac+`);t&&n?(this.callbacks.set(e.slice(4),{callback:r,options:i}),this.allKeys.add(e.split(`+`).at(-1))):!t&&!n&&(this.callbacks.set(e,{callback:r,options:i}),this.allKeys.add(e.split(`+`).at(-1)))}}#e(e){e.altKey&&this.buffer.push(`alt`),e.ctrlKey&&this.buffer.push(`ctrl`),e.metaKey&&this.buffer.push(`meta`),e.shiftKey&&this.buffer.push(`shift`),this.buffer.push(e.key);let t=this.buffer.join(`+`);return this.buffer.length=0,t}exec(e,t){if(!this.allKeys.has(t.key))return;let n=this.callbacks.get(this.#e(t));if(!n)return;let{callback:r,options:{bubbles:i=!1,args:a=[],checker:o=null}}=n;o&&!o(e,t)||(r.bind(e,...a,t)(),i||V(t))}},ze=class e{static _colorsMapping=new Map([[`CanvasText`,[0,0,0]],[`Canvas`,[255,255,255]]]);get _colors(){let e=new Map([[`CanvasText`,null],[`Canvas`,null]]);return ke(e),A(this,`_colors`,e)}convert(t){let n=Oe(t);if(!window.matchMedia(`(forced-colors: active)`).matches)return n;for(let[t,r]of this._colors)if(r.every((e,t)=>e===n[t]))return e._colorsMapping.get(t);return n}getHexCode(e){let t=this._colors.get(e);return t?R.makeHexColor(...t):e}},Be=class e{#e=new AbortController;#t=null;#n=new Map;#r=new Map;#i=null;#a=null;#o=null;#s=new Le;#c=null;#l=null;#u=0;#d=new Set;#f=null;#p=null;#m=new Set;_editorUndoBar=null;#h=!1;#g=!1;#_=!1;#v=null;#y=null;#b=null;#x=null;#S=!1;#C=null;#w=new Fe;#T=!1;#E=!1;#D=null;#O=null;#k=null;#A=null;#j=d.NONE;#M=new Set;#N=null;#P=null;#F=null;#I={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#L=[0,0];#R=null;#z=null;#B=null;#V=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=e.prototype,n=e=>e.#z.contains(document.activeElement)&&document.activeElement.tagName!==`BUTTON`&&e.hasSomethingToControl(),r=(e,{target:t})=>{if(t instanceof HTMLInputElement){let{type:e}=t;return e!==`text`&&e!==`number`}return!0},i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return A(this,`_keyboardManager`,new Re([[[`ctrl+a`,`mac+meta+a`],t.selectAll,{checker:r}],[[`ctrl+z`,`mac+meta+z`],t.undo,{checker:r}],[[`ctrl+y`,`ctrl+shift+z`,`mac+meta+shift+z`,`ctrl+shift+Z`,`mac+meta+shift+Z`],t.redo,{checker:r}],[[`Backspace`,`alt+Backspace`,`ctrl+Backspace`,`shift+Backspace`,`mac+Backspace`,`mac+alt+Backspace`,`mac+ctrl+Backspace`,`Delete`,`ctrl+Delete`,`shift+Delete`,`mac+Delete`],t.delete,{checker:r}],[[`Enter`,`mac+Enter`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#z.contains(t)&&!e.isEnterHandled}],[[` `,`mac+ `],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#z.contains(document.activeElement)}],[[`Escape`,`mac+Escape`],t.unselectAll],[[`ArrowLeft`,`mac+ArrowLeft`],t.translateSelectedEditors,{args:[-i,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t.translateSelectedEditors,{args:[-a,0],checker:n}],[[`ArrowRight`,`mac+ArrowRight`],t.translateSelectedEditors,{args:[i,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t.translateSelectedEditors,{args:[a,0],checker:n}],[[`ArrowUp`,`mac+ArrowUp`],t.translateSelectedEditors,{args:[0,-i],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t.translateSelectedEditors,{args:[0,-a],checker:n}],[[`ArrowDown`,`mac+ArrowDown`],t.translateSelectedEditors,{args:[0,i],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t.translateSelectedEditors,{args:[0,a],checker:n}]]))}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=this._signal=this.#e.signal;this.#z=e,this.#B=t,this.#i=n,this._eventBus=r,r._on(`editingaction`,this.onEditingAction.bind(this),{signal:p}),r._on(`pagechanging`,this.onPageChanging.bind(this),{signal:p}),r._on(`scalechanging`,this.onScaleChanging.bind(this),{signal:p}),r._on(`rotationchanging`,this.onRotationChanging.bind(this),{signal:p}),r._on(`setpreference`,this.onSetPreference.bind(this),{signal:p}),r._on(`switchannotationeditorparams`,e=>this.updateParams(e.type,e.value),{signal:p}),this.#q(),this.#ee(),this.#X(),this.#a=i.annotationStorage,this.#v=i.filterFactory,this.#P=a,this.#x=o||null,this.#h=s,this.#g=c,this.#_=l,this.#A=u||null,this.viewParameters={realScale:ge.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=d||null,this._supportsPinchToZoom=f!==!1}destroy(){this.#V?.resolve(),this.#V=null,this.#e?.abort(),this.#e=null,this._signal=null;for(let e of this.#r.values())e.destroy();this.#r.clear(),this.#n.clear(),this.#m.clear(),this.#t=null,this.#M.clear(),this.#s.destroy(),this.#i?.destroy(),this.#C?.hide(),this.#C=null,this.#y&&=(clearTimeout(this.#y),null),this.#R&&=(clearTimeout(this.#R),null),this._editorUndoBar?.destroy()}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#A}get useNewAltTextFlow(){return this.#g}get useNewAltTextWhenAddingImage(){return this.#_}get hcmFilter(){return A(this,`hcmFilter`,this.#P?this.#v.addHCMFilter(this.#P.foreground,this.#P.background):`none`)}get direction(){return A(this,`direction`,getComputedStyle(this.#z).direction)}get highlightColors(){return A(this,`highlightColors`,this.#x?new Map(this.#x.split(`,`).map(e=>e.split(`=`).map(e=>e.trim()))):null)}get highlightColorNames(){return A(this,`highlightColorNames`,this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#l=e}setMainHighlightColorPicker(e){this.#k=e}editAltText(e,t=!1){this.#i?.editAltText(this,e,t)}switchToMode(e,t){this._eventBus.on(`annotationeditormodechanged`,t,{once:!0,signal:this._signal}),this._eventBus.dispatch(`showannotationeditorui`,{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch(`setpreference`,{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){switch(e){case`enableNewAltTextWhenAddingImage`:this.#_=t;break}}onPageChanging({pageNumber:e}){this.#u=e-1}focusMainContainer(){this.#z.focus()}findParent(e,t){for(let n of this.#r.values()){let{x:r,y:i,width:a,height:o}=n.div.getBoundingClientRect();if(e>=r&&e<=r+a&&t>=i&&t<=i+o)return n}return null}disableUserSelect(e=!1){this.#B.classList.toggle(`noUserSelect`,e)}addShouldRescale(e){this.#m.add(e)}removeShouldRescale(e){this.#m.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*ge.PDF_TO_CSS_UNITS;for(let e of this.#m)e.onScaleChanging();this.#l?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#H({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#U(e){let{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(let t of this.#r.values())if(t.hasTextLayer(e))return t;return null}highlightSelection(e=``){let t=document.getSelection();if(!t||t.isCollapsed)return;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=t,o=t.toString(),s=this.#H(t).closest(`.textLayer`),c=this.getSelectionBoxes(s);if(!c)return;t.empty();let l=this.#U(s),u=this.#j===d.NONE,f=()=>{l?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:c,anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a,text:o}),u&&this.showAllEditors(`highlight`,!0,!0)};if(u){this.switchToMode(d.HIGHLIGHT,f);return}f()}#W(){let e=document.getSelection();if(!e||e.isCollapsed)return;let t=this.#H(e).closest(`.textLayer`),n=this.getSelectionBoxes(t);n&&(this.#C||=new Ne(this),this.#C.show(t,n,this.direction===`ltr`))}addToAnnotationStorage(e){!e.isEmpty()&&this.#a&&!this.#a.has(e.id)&&this.#a.setValue(e.id,e)}#G(){let e=document.getSelection();if(!e||e.isCollapsed){this.#N&&(this.#C?.hide(),this.#N=null,this.#te({hasSelectedText:!1}));return}let{anchorNode:t}=e;if(t===this.#N)return;let n=this.#H(e).closest(`.textLayer`);if(!n){this.#N&&(this.#C?.hide(),this.#N=null,this.#te({hasSelectedText:!1}));return}if(this.#C?.hide(),this.#N=t,this.#te({hasSelectedText:!0}),!(this.#j!==d.HIGHLIGHT&&this.#j!==d.NONE)&&(this.#j===d.HIGHLIGHT&&this.showAllEditors(`highlight`,!0,!0),this.#S=this.isShiftKeyDown,!this.isShiftKeyDown)){let e=this.#j===d.HIGHLIGHT?this.#U(n):null;e?.toggleDrawing();let t=new AbortController,r=this.combinedSignal(t),i=n=>{n.type===`pointerup`&&n.button!==0||(t.abort(),e?.toggleDrawing(!0),n.type===`pointerup`&&this.#K(`main_toolbar`))};window.addEventListener(`pointerup`,i,{signal:r}),window.addEventListener(`blur`,i,{signal:r})}}#K(e=``){this.#j===d.HIGHLIGHT?this.highlightSelection(e):this.#h&&this.#W()}#q(){document.addEventListener(`selectionchange`,this.#G.bind(this),{signal:this._signal})}#J(){if(this.#b)return;this.#b=new AbortController;let e=this.combinedSignal(this.#b);window.addEventListener(`focus`,this.focus.bind(this),{signal:e}),window.addEventListener(`blur`,this.blur.bind(this),{signal:e})}#Y(){this.#b?.abort(),this.#b=null}blur(){if(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#K(`main_toolbar`)),!this.hasSelection)return;let{activeElement:e}=document;for(let t of this.#M)if(t.div.contains(e)){this.#O=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#O)return;let[e,t]=this.#O;this.#O=null,t.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}#X(){if(this.#D)return;this.#D=new AbortController;let e=this.combinedSignal(this.#D);window.addEventListener(`keydown`,this.keydown.bind(this),{signal:e}),window.addEventListener(`keyup`,this.keyup.bind(this),{signal:e})}#Z(){this.#D?.abort(),this.#D=null}#Q(){if(this.#c)return;this.#c=new AbortController;let e=this.combinedSignal(this.#c);document.addEventListener(`copy`,this.copy.bind(this),{signal:e}),document.addEventListener(`cut`,this.cut.bind(this),{signal:e}),document.addEventListener(`paste`,this.paste.bind(this),{signal:e})}#$(){this.#c?.abort(),this.#c=null}#ee(){let e=this._signal;document.addEventListener(`dragover`,this.dragOver.bind(this),{signal:e}),document.addEventListener(`drop`,this.drop.bind(this),{signal:e})}addEditListeners(){this.#X(),this.#Q()}removeEditListeners(){this.#Z(),this.#$()}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let n of this.#p)if(n.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect=`copy`,e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let n of this.#p)if(n.isHandlingMimeForPasting(t.type)){n.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),this.#t?.commitOrRemove(),!this.hasSelection)return;let t=[];for(let e of this.#M){let n=e.serialize(!0);n&&t.push(n)}t.length!==0&&e.clipboardData.setData(`application/pdfjs`,JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();let{clipboardData:t}=e;for(let e of t.items)for(let t of this.#p)if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}let n=t.getData(`application/pdfjs`);if(!n)return;try{n=JSON.parse(n)}catch(e){T(`paste: "${e.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();let r=this.currentLayer;try{let e=[];for(let t of n){let n=await r.deserialize(t);if(!n)return;e.push(n)}this.addCommands({cmd:()=>{for(let t of e)this.#ae(t);this.#ce(e)},undo:()=>{for(let t of e)t.remove()},mustExec:!0})}catch(e){T(`paste: "${e.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key===`Shift`&&(this.isShiftKeyDown=!0),this.#j!==d.NONE&&!this.isEditorHandlingKeyboard&&e._keyboardManager.exec(this,t)}keyup(e){this.isShiftKeyDown&&e.key===`Shift`&&(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#K(`main_toolbar`)))}onEditingAction({name:e}){switch(e){case`undo`:case`redo`:case`delete`:case`selectAll`:this[e]();break;case`highlightSelection`:this.highlightSelection(`context_menu`);break}}#te(e){Object.entries(e).some(([e,t])=>this.#I[e]!==t)&&(this._eventBus.dispatch(`annotationeditorstateschanged`,{source:this,details:Object.assign(this.#I,e)}),this.#j===d.HIGHLIGHT&&e.hasSelectedEditor===!1&&this.#ne([[f.HIGHLIGHT_FREE,!0]]))}#ne(e){this._eventBus.dispatch(`annotationeditorparamschanged`,{source:this,details:e})}setEditingState(e){e?(this.#J(),this.#Q(),this.#te({isEditing:this.#j!==d.NONE,isEmpty:this.#se(),hasSomethingToUndo:this.#s.hasSomethingToUndo(),hasSomethingToRedo:this.#s.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Y(),this.#$(),this.#te({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#p){this.#p=e;for(let e of this.#p)this.#ne(e.defaultPropertiesToUpdate)}}getId(){return this.#w.id}get currentLayer(){return this.#r.get(this.#u)}getLayer(e){return this.#r.get(e)}get currentPageIndex(){return this.#u}addLayer(e){this.#r.set(e.pageIndex,e),this.#T?e.enable():e.disable()}removeLayer(e){this.#r.delete(e.pageIndex)}async updateMode(e,t=null,n=!1){if(this.#j!==e&&!(this.#V&&(await this.#V.promise,!this.#V))){if(this.#V=Promise.withResolvers(),this.#j=e,e===d.NONE){this.setEditingState(!1),this.#ie(),this._editorUndoBar?.hide(),this.#V.resolve();return}this.setEditingState(!0),await this.#re(),this.unselectAll();for(let t of this.#r.values())t.updateMode(e);if(!t){n&&this.addNewEditorFromKeyboard(),this.#V.resolve();return}for(let e of this.#n.values())e.annotationElementId===t?(this.setSelected(e),e.enterInEditMode()):e.unselect();this.#V.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==this.#j&&this._eventBus.dispatch(`switchannotationeditormode`,{source:this,mode:e})}updateParams(e,t){if(this.#p){switch(e){case f.CREATE:this.currentLayer.addNewEditor();return;case f.HIGHLIGHT_DEFAULT_COLOR:this.#k?.updateColor(t);break;case f.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:{type:`highlight`,action:`toggle_visibility`}}}),(this.#F||=new Map).set(e,t),this.showAllEditors(`highlight`,t);break}for(let n of this.#M)n.updateParams(e,t);for(let n of this.#p)n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){for(let n of this.#n.values())n.editorType===e&&n.show(t);(this.#F?.get(f.HIGHLIGHT_SHOW_ALL)??!0)!==t&&this.#ne([[f.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#E!==e){this.#E=e;for(let t of this.#r.values())e?t.disableClick():t.enableClick(),t.div.classList.toggle(`waiting`,e)}}async#re(){if(!this.#T){this.#T=!0;let e=[];for(let t of this.#r.values())e.push(t.enable());await Promise.all(e);for(let e of this.#n.values())e.enable()}}#ie(){if(this.unselectAll(),this.#T){this.#T=!1;for(let e of this.#r.values())e.disable();for(let e of this.#n.values())e.disable()}}getEditors(e){let t=[];for(let n of this.#n.values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return this.#n.get(e)}addEditor(e){this.#n.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.focusMainContainer(),this.#y=null},0)),this.#n.delete(e.id),this.unselect(e),(!e.annotationElementId||!this.#d.has(e.annotationElementId))&&this.#a?.remove(e.id)}addDeletedAnnotationElement(e){this.#d.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#d.has(e)}removeDeletedAnnotationElement(e){this.#d.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#ae(e){let t=this.#r.get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#t!==e&&(this.#t=e,e&&this.#ne(e.propertiesToUpdate))}get#oe(){let e=null;for(e of this.#M);return e}updateUI(e){this.#oe===e&&this.#ne(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#ne(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#M.has(e)){this.#M.delete(e),e.unselect(),this.#te({hasSelectedEditor:this.hasSelection});return}this.#M.add(e),e.select(),this.#ne(e.propertiesToUpdate),this.#te({hasSelectedEditor:!0})}setSelected(e){this.#l?.commitOrRemove();for(let t of this.#M)t!==e&&t.unselect();this.#M.clear(),this.#M.add(e),e.select(),this.#ne(e.propertiesToUpdate),this.#te({hasSelectedEditor:!0})}isSelected(e){return this.#M.has(e)}get firstSelectedEditor(){return this.#M.values().next().value}unselect(e){e.unselect(),this.#M.delete(e),this.#te({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#M.size!==0}get isEnterHandled(){return this.#M.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#s.undo(),this.#te({hasSomethingToUndo:this.#s.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#se()}),this._editorUndoBar?.hide()}redo(){this.#s.redo(),this.#te({hasSomethingToUndo:!0,hasSomethingToRedo:this.#s.hasSomethingToRedo(),isEmpty:this.#se()})}addCommands(e){this.#s.add(e),this.#te({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#se()})}cleanUndoStack(e){this.#s.cleanType(e)}#se(){if(this.#n.size===0)return!0;if(this.#n.size===1)for(let e of this.#n.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();let e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;let t=e?[e]:[...this.#M],n=()=>{this._editorUndoBar?.show(r,t.length===1?t[0].editorType:t.length);for(let e of t)e.remove()},r=()=>{for(let e of t)this.#ae(e)};this.addCommands({cmd:n,undo:r,mustExec:!0})}commitOrRemove(){this.#t?.commitOrRemove()}hasSomethingToControl(){return this.#t||this.hasSelection}#ce(e){for(let e of this.#M)e.unselect();this.#M.clear();for(let t of e)t.isEmpty()||(this.#M.add(t),t.select());this.#te({hasSelectedEditor:this.hasSelection})}selectAll(){for(let e of this.#M)e.commit();this.#ce(this.#n.values())}unselectAll(){if(!(this.#t&&(this.#t.commitOrRemove(),this.#j!==d.NONE))&&!this.#l?.commitOrRemove()&&this.hasSelection){for(let e of this.#M)e.unselect();this.#M.clear(),this.#te({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#L[0]+=e,this.#L[1]+=t;let[r,i]=this.#L,a=[...this.#M];this.#R&&clearTimeout(this.#R),this.#R=setTimeout(()=>{this.#R=null,this.#L[0]=this.#L[1]=0,this.addCommands({cmd:()=>{for(let e of a)this.#n.has(e.id)&&e.translateInPage(r,i)},undo:()=>{for(let e of a)this.#n.has(e.id)&&e.translateInPage(-r,-i)},mustExec:!1})},1e3);for(let n of a)n.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(let e of this.#M)this.#f.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);let e=this.#f;this.#f=null;let t=!1;for(let[{x:n,y:r,pageIndex:i},a]of e)a.newX=n,a.newY=r,a.newPageIndex=i,t||=n!==a.savedX||r!==a.savedY||i!==a.savedPageIndex;if(!t)return!1;let n=(e,t,n,r)=>{if(this.#n.has(e.id)){let i=this.#r.get(r);i?e._setParentAndPosition(i,t,n):(e.pageIndex=r,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(let[t,{newX:r,newY:i,newPageIndex:a}]of e)n(t,r,i,a)},undo:()=>{for(let[t,{savedX:r,savedY:i,savedPageIndex:a}]of e)n(t,r,i,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(this.#f)for(let n of this.#f.keys())n.drag(e,t)}rebuild(e){if(e.parent===null){let t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#M.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#t===e}getActive(){return this.#t}getMode(){return this.#j}get imageManager(){return A(this,`imageManager`,new Ie)}getSelectionBoxes(e){if(!e)return null;let t=document.getSelection();for(let n=0,r=t.rangeCount;n<r;n++)if(!e.contains(t.getRangeAt(n).commonAncestorContainer))return null;let{x:n,y:r,width:i,height:a}=e.getBoundingClientRect(),o;switch(e.getAttribute(`data-main-rotation`)){case`90`:o=(e,t,o,s)=>({x:(t-r)/a,y:1-(e+o-n)/i,width:s/a,height:o/i});break;case`180`:o=(e,t,o,s)=>({x:1-(e+o-n)/i,y:1-(t+s-r)/a,width:o/i,height:s/a});break;case`270`:o=(e,t,o,s)=>({x:1-(t+s-r)/a,y:(e-n)/i,width:s/a,height:o/i});break;default:o=(e,t,o,s)=>({x:(e-n)/i,y:(t-r)/a,width:o/i,height:s/a});break}let s=[];for(let e=0,n=t.rangeCount;e<n;e++){let n=t.getRangeAt(e);if(!n.collapsed)for(let{x:e,y:t,width:r,height:i}of n.getClientRects())r===0||i===0||s.push(o(e,t,r,i))}return s.length===0?null:s}addChangedExistingAnnotation({annotationElementId:e,id:t}){(this.#o||=new Map).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){this.#o?.delete(e)}renderAnnotationElement(e){let t=this.#o?.get(e.data.id);if(!t)return;let n=this.#a.getRawValue(t);n&&(this.#j===d.NONE&&!n.hasBeenModified||n.renderAnnotationElement(e))}},Ve=class e{#e=null;#t=!1;#n=null;#r=null;#i=null;#a=null;#o=!1;#s=null;#c=null;#l=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#c=t,this.#d=t._uiManager.useNewAltTextFlow,e.#f||=Object.freeze({added:`pdfjs-editor-new-alt-text-added-button`,"added-label":`pdfjs-editor-new-alt-text-added-button-label`,missing:`pdfjs-editor-new-alt-text-missing-button`,"missing-label":`pdfjs-editor-new-alt-text-missing-button-label`,review:`pdfjs-editor-new-alt-text-to-review-button`,"review-label":`pdfjs-editor-new-alt-text-to-review-button-label`})}static initialize(t){e._l10n??=t}async render(){let t=this.#n=document.createElement(`button`);t.className=`altText`,t.tabIndex=`0`;let n=this.#r=document.createElement(`span`);t.append(n),this.#d?(t.classList.add(`new`),t.setAttribute(`data-l10n-id`,e.#f.missing),n.setAttribute(`data-l10n-id`,e.#f[`missing-label`])):(t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button`),n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button-label`));let r=this.#c._uiManager._signal;t.addEventListener(`contextmenu`,B,{signal:r}),t.addEventListener(`pointerdown`,e=>e.stopPropagation(),{signal:r});let i=e=>{e.preventDefault(),this.#c._uiManager.editAltText(this.#c),this.#d&&this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_clicked`,data:{label:this.#p}})};return t.addEventListener(`click`,i,{capture:!0,signal:r}),t.addEventListener(`keydown`,e=>{e.target===t&&e.key===`Enter`&&(this.#o=!0,i(e))},{signal:r}),await this.#m(),t}get#p(){return this.#e&&`added`||this.#e===null&&this.guessedText&&`review`||`missing`}finish(){this.#n&&(this.#n.focus({focusVisible:this.#o}),this.#o=!1)}isEmpty(){return this.#d?this.#e===null:!this.#e&&!this.#t}hasData(){return this.#d?this.#e!==null||!!this.#l:this.isEmpty()}get guessedText(){return this.#l}async setGuessedText(t){this.#e===null&&(this.#l=t,this.#u=await e._l10n.get(`pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer`,{generatedAltText:t}),this.#m())}toggleAltTextBadge(e=!1){if(!this.#d||this.#e){this.#s?.remove(),this.#s=null;return}if(!this.#s){let e=this.#s=document.createElement(`div`);e.className=`noAltTextBadge`,this.#c.div.append(e)}this.#s.classList.toggle(`hidden`,!e)}serialize(e){let t=this.#e;return!e&&this.#l===t&&(t=this.#u),{altText:t,decorative:this.#t,guessedText:this.#l,textWithDisclaimer:this.#u}}get data(){return{altText:this.#e,decorative:this.#t}}set data({altText:e,decorative:t,guessedText:n,textWithDisclaimer:r,cancel:i=!1}){n&&(this.#l=n,this.#u=r),!(this.#e===e&&this.#t===t)&&(i||(this.#e=e,this.#t=t),this.#m())}toggle(e=!1){this.#n&&(!e&&this.#a&&(clearTimeout(this.#a),this.#a=null),this.#n.disabled=!e)}shown(){this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_displayed`,data:{label:this.#p}})}destroy(){this.#n?.remove(),this.#n=null,this.#r=null,this.#i=null,this.#s?.remove(),this.#s=null}async#m(){let t=this.#n;if(!t)return;if(this.#d){if(t.classList.toggle(`done`,!!this.#e),t.setAttribute(`data-l10n-id`,e.#f[this.#p]),this.#r?.setAttribute(`data-l10n-id`,e.#f[`${this.#p}-label`]),!this.#e){this.#i?.remove();return}}else{if(!this.#e&&!this.#t){t.classList.remove(`done`),this.#i?.remove();return}t.classList.add(`done`),t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-edit-button`)}let n=this.#i;if(!n){this.#i=n=document.createElement(`span`),n.className=`tooltip`,n.setAttribute(`role`,`tooltip`),n.id=`alt-text-tooltip-${this.#c.id}`;let e=this.#c._uiManager._signal;e.addEventListener(`abort`,()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),t.addEventListener(`mouseenter`,()=>{this.#a=setTimeout(()=>{this.#a=null,this.#i.classList.add(`show`),this.#c._reportTelemetry({action:`alt_text_tooltip`})},100)},{signal:e}),t.addEventListener(`mouseleave`,()=>{this.#a&&=(clearTimeout(this.#a),null),this.#i?.classList.remove(`show`)},{signal:e})}this.#t?n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-decorative-tooltip`):(n.removeAttribute(`data-l10n-id`),n.textContent=this.#e),n.parentNode||t.append(n),this.#c.getImageForAltText()?.setAttribute(`aria-describedby`,n.id)}},He=class e{#e;#t=!1;#n=null;#r;#i;#a;#o;#s;#c=null;#l;#u=null;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:i=null,onPinchEnd:a=null,signal:o}){this.#e=e,this.#n=n,this.#r=t,this.#i=r,this.#a=i,this.#o=a,this.#l=new AbortController,this.#s=AbortSignal.any([o,this.#l.signal]),e.addEventListener(`touchstart`,this.#d.bind(this),{passive:!1,signal:this.#s})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return A(this,`MIN_TOUCH_DISTANCE_TO_PINCH`,35/(window.devicePixelRatio||1))}#d(e){if(this.#r?.()||e.touches.length<2)return;if(!this.#u){this.#u=new AbortController;let e=AbortSignal.any([this.#s,this.#u.signal]),t=this.#e,n={signal:e,passive:!1};t.addEventListener(`touchmove`,this.#f.bind(this),n),t.addEventListener(`touchend`,this.#p.bind(this),n),t.addEventListener(`touchcancel`,this.#p.bind(this),n),this.#i?.()}if(V(e),e.touches.length!==2||this.#n?.()){this.#c=null;return}let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]),this.#c={touch0X:t.screenX,touch0Y:t.screenY,touch1X:n.screenX,touch1Y:n.screenY}}#f(t){if(!this.#c||t.touches.length!==2)return;let[n,r]=t.touches;n.identifier>r.identifier&&([n,r]=[r,n]);let{screenX:i,screenY:a}=n,{screenX:o,screenY:s}=r,c=this.#c,{touch0X:l,touch0Y:u,touch1X:d,touch1Y:f}=c,p=d-l,m=f-u,h=o-i,g=s-a,_=Math.hypot(h,g)||1,v=Math.hypot(p,m)||1;if(!this.#t&&Math.abs(v-_)<=e.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(c.touch0X=i,c.touch0Y=a,c.touch1X=o,c.touch1Y=s,t.preventDefault(),!this.#t){this.#t=!0;return}let y=[(i+o)/2,(a+s)/2];this.#a?.(y,v,_)}#p(e){this.#u.abort(),this.#u=null,this.#o?.(),this.#c&&(e.preventDefault(),this.#c=null,this.#t=!1)}destroy(){this.#l?.abort(),this.#l=null}},W=class e{#e=null;#t=null;#n=null;#r=!1;#i=null;#a=``;#o=!1;#s=null;#c=null;#l=null;#u=null;#d=``;#f=!1;#p=null;#m=!1;#h=!1;#g=!1;#_=null;#v=0;#y=0;#b=null;#x=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#S=!1;#C=e._zIndex++;static _borderLineWidth=-1;static _colorManager=new ze;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=e.prototype._resizeWithKeyboard,n=Be.TRANSLATE_SMALL,r=Be.TRANSLATE_BIG;return A(this,`_resizerKeyboardManager`,new Re([[[`ArrowLeft`,`mac+ArrowLeft`],t,{args:[-n,0]}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t,{args:[-r,0]}],[[`ArrowRight`,`mac+ArrowRight`],t,{args:[n,0]}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t,{args:[r,0]}],[[`ArrowUp`,`mac+ArrowUp`],t,{args:[0,-n]}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t,{args:[0,-r]}],[[`ArrowDown`,`mac+ArrowDown`],t,{args:[0,n]}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t,{args:[0,r]}],[[`Escape`,`mac+Escape`],e.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null;let{rotation:t,rawDims:{pageWidth:n,pageHeight:r,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,r],this.pageTranslation=[i,a];let[o,s]=this.parentDimensions;this.x=e.x/o,this.y=e.y/s,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return A(this,`_defaultLineColor`,this._colorManager.getHexCode(`CanvasText`))}static deleteAnnotationElement(e){let t=new Ue({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(t,n){if(e._l10n??=t,e._l10nResizer||=Object.freeze({topLeft:`pdfjs-editor-resizer-top-left`,topMiddle:`pdfjs-editor-resizer-top-middle`,topRight:`pdfjs-editor-resizer-top-right`,middleRight:`pdfjs-editor-resizer-middle-right`,bottomRight:`pdfjs-editor-resizer-bottom-right`,bottomMiddle:`pdfjs-editor-resizer-bottom-middle`,bottomLeft:`pdfjs-editor-resizer-bottom-left`,middleLeft:`pdfjs-editor-resizer-middle-left`}),e._borderLineWidth!==-1)return;let r=getComputedStyle(document.documentElement);e._borderLineWidth=parseFloat(r.getPropertyValue(`--outline-width`))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){E(`Not implemented`)}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#S}set _isDraggable(e){this.#S=e,this.div?.classList.toggle(`draggable`,e)}get isEnterHandled(){return!0}center(){let[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#C}setParent(e){e===null?this.#H():(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#f?this.#f=!1:this.parent.setSelected(this))}focusout(e){this._focusEventsAllowed&&this.isAttachedToDOM&&(e.relatedTarget?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove()))}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,r){let[i,a]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(e+n)/i,this.y=(t+r)/a,this.fixAndSetPosition()}#w([e,t],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/e,this.y+=r/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#w(this.parentDimensions,e,t)}translateInPage(e,t){this.#p||=[this.x,this.y,this.width,this.height],this.#w(this.pageDimensions,e,t),this.div.scrollIntoView({block:`nearest`})}drag(e,t){this.#p||=[this.x,this.y,this.width,this.height];let{div:n,parentDimensions:[r,i]}=this;if(this.x+=e/r,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this,[s,c]=this.getBaseTranslation();a+=s,o+=c;let{style:l}=n;l.left=`${(100*a).toFixed(2)}%`,l.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),n.scrollIntoView({block:`nearest`})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#p&&(this.#p[0]!==this.x||this.#p[1]!==this.y)}get _hasBeenResized(){return!!this.#p&&(this.#p[2]!==this.width||this.#p[3]!==this.height)}getBaseTranslation(){let[t,n]=this.parentDimensions,{_borderLineWidth:r}=e,i=r/t,a=r/n;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let{div:{style:t},pageDimensions:[n,r]}=this,{x:i,y:a,width:o,height:s}=this;if(o*=n,s*=r,i*=n,a*=r,this._mustFixPosition)switch(e){case 0:i=Math.max(0,Math.min(n-o,i)),a=Math.max(0,Math.min(r-s,a));break;case 90:i=Math.max(0,Math.min(n-s,i)),a=Math.min(r,Math.max(o,a));break;case 180:i=Math.min(n,Math.max(o,i)),a=Math.min(r,Math.max(s,a));break;case 270:i=Math.min(n,Math.max(s,i)),a=Math.max(0,Math.min(r-o,a));break}this.x=i/=n,this.y=a/=r;let[c,l]=this.getBaseTranslation();i+=c,a+=l,t.left=`${(100*i).toFixed(2)}%`,t.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}static#T(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(t,n){return e.#T(t,n,this.parentRotation)}pageTranslationToScreen(t,n){return e.#T(t,n,360-this.parentRotation)}#E(e){switch(e){case 90:{let[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:e,pageDimensions:[t,n]}=this;return[t*e,n*e]}setDims(e,t){let[n,r]=this.parentDimensions,{style:i}=this.div;i.width=`${(100*e/n).toFixed(2)}%`,this.#o||(i.height=`${(100*t/r).toFixed(2)}%`)}fixDims(){let{style:e}=this.div,{height:t,width:n}=e,r=n.endsWith(`%`),i=!this.#o&&t.endsWith(`%`);if(r&&i)return;let[a,o]=this.parentDimensions;r||(e.width=`${(100*parseFloat(n)/a).toFixed(2)}%`),!this.#o&&!i&&(e.height=`${(100*parseFloat(t)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#D(){if(this.#s)return;this.#s=document.createElement(`div`),this.#s.classList.add(`resizers`);let e=this._willKeepAspectRatio?[`topLeft`,`topRight`,`bottomRight`,`bottomLeft`]:[`topLeft`,`topMiddle`,`topRight`,`middleRight`,`bottomRight`,`bottomMiddle`,`bottomLeft`,`middleLeft`],t=this._uiManager._signal;for(let n of e){let e=document.createElement(`div`);this.#s.append(e),e.classList.add(`resizer`,n),e.setAttribute(`data-resizer-name`,n),e.addEventListener(`pointerdown`,this.#O.bind(this,n),{signal:t}),e.addEventListener(`contextmenu`,B,{signal:t}),e.tabIndex=-1}this.div.prepend(this.#s)}#O(e,t){t.preventDefault();let{isMac:n}=L.platform;if(t.button!==0||t.ctrlKey&&n)return;this.#n?.toggle(!1);let r=this._isDraggable;this._isDraggable=!1,this.#c=[t.screenX,t.screenY];let i=new AbortController,a=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener(`pointermove`,this.#j.bind(this,e),{passive:!0,capture:!0,signal:a}),window.addEventListener(`touchmove`,V,{passive:!1,signal:a}),window.addEventListener(`contextmenu`,B,{signal:a}),this.#l={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let o=this.parent.div.style.cursor,s=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;let c=()=>{i.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=o,this.div.style.cursor=s,this.#A()};window.addEventListener(`pointerup`,c,{signal:a}),window.addEventListener(`blur`,c,{signal:a})}#k(e,t,n,r){this.width=n,this.height=r,this.x=e,this.y=t;let[i,a]=this.parentDimensions;this.setDims(i*n,a*r),this.fixAndSetPosition(),this._onResized()}_onResized(){}#A(){if(!this.#l)return;let{savedX:e,savedY:t,savedWidth:n,savedHeight:r}=this.#l;this.#l=null;let i=this.x,a=this.y,o=this.width,s=this.height;i===e&&a===t&&o===n&&s===r||this.addCommands({cmd:this.#k.bind(this,i,a,o,s),undo:this.#k.bind(this,e,t,n,r),mustExec:!0})}static _round(e){return Math.round(e*1e4)/1e4}#j(t,n){let[r,i]=this.parentDimensions,a=this.x,o=this.y,s=this.width,c=this.height,l=e.MIN_SIZE/r,u=e.MIN_SIZE/i,d=this.#E(this.rotation),f=(e,t)=>[d[0]*e+d[2]*t,d[1]*e+d[3]*t],p=this.#E(360-this.rotation),m=(e,t)=>[p[0]*e+p[2]*t,p[1]*e+p[3]*t],h,g,_=!1,v=!1;switch(t){case`topLeft`:_=!0,h=(e,t)=>[0,0],g=(e,t)=>[e,t];break;case`topMiddle`:h=(e,t)=>[e/2,0],g=(e,t)=>[e/2,t];break;case`topRight`:_=!0,h=(e,t)=>[e,0],g=(e,t)=>[0,t];break;case`middleRight`:v=!0,h=(e,t)=>[e,t/2],g=(e,t)=>[0,t/2];break;case`bottomRight`:_=!0,h=(e,t)=>[e,t],g=(e,t)=>[0,0];break;case`bottomMiddle`:h=(e,t)=>[e/2,t],g=(e,t)=>[e/2,0];break;case`bottomLeft`:_=!0,h=(e,t)=>[0,t],g=(e,t)=>[e,0];break;case`middleLeft`:v=!0,h=(e,t)=>[0,t/2],g=(e,t)=>[e,t/2];break}let y=h(s,c),b=g(s,c),x=f(...b),S=e._round(a+x[0]),C=e._round(o+x[1]),w=1,T=1,E,D;if(n.fromKeyboard)({deltaX:E,deltaY:D}=n);else{let{screenX:e,screenY:t}=n,[r,i]=this.#c;[E,D]=this.screenToPageTranslation(e-r,t-i),this.#c[0]=e,this.#c[1]=t}if([E,D]=m(E/r,D/i),_){let e=Math.hypot(s,c);w=T=Math.max(Math.min(Math.hypot(b[0]-y[0]-E,b[1]-y[1]-D)/e,1/s,1/c),l/s,u/c)}else v?w=Math.max(l,Math.min(1,Math.abs(b[0]-y[0]-E)))/s:T=Math.max(u,Math.min(1,Math.abs(b[1]-y[1]-D)))/c;let O=e._round(s*w),k=e._round(c*T);x=f(...g(O,k));let A=S-x[0],j=C-x[1];this.#p||=[this.x,this.y,this.width,this.height],this.width=O,this.height=k,this.x=A,this.y=j,this.setDims(r*O,i*k),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}async addEditToolbar(){return this._editToolbar||this.#h?this._editToolbar:(this._editToolbar=new Me(this),this.div.append(this._editToolbar.render()),this.#n&&await this._editToolbar.addAltText(this.#n),this._editToolbar)}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#n?.destroy())}addContainer(e){let t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#n||(Ve.initialize(e._l10n),this.#n=new Ve(this),this.#e&&=(this.#n.data=this.#e,null),await this.addEditToolbar())}get altTextData(){return this.#n?.data}set altTextData(e){this.#n&&(this.#n.data=e)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(e){await this.#n?.setGuessedText(e)}serializeAltText(e){return this.#n?.serialize(e)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}render(){this.div=document.createElement(`div`),this.div.setAttribute(`data-editor-rotation`,(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute(`id`,this.id),this.div.tabIndex=this.#r?-1:0,this._isVisible||this.div.classList.add(`hidden`),this.setInForeground(),this.#L();let[e,t]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*t/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/t).toFixed(2)}%`);let[n,r]=this.getInitialTranslation();return this.translate(n,r),Pe(this,this.div,[`pointerdown`]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#x||=new He({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#M.bind(this),onPinching:this.#N.bind(this),onPinchEnd:this.#P.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#M(){this.#l={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#N(t,n,r){let i=.7,a=r/n*i+1-i;if(a===1)return;let o=this.#E(this.rotation),s=(e,t)=>[o[0]*e+o[2]*t,o[1]*e+o[3]*t],[c,l]=this.parentDimensions,u=this.x,d=this.y,f=this.width,p=this.height,m=e.MIN_SIZE/c,h=e.MIN_SIZE/l;a=Math.max(Math.min(a,1/f,1/p),m/f,h/p);let g=e._round(f*a),_=e._round(p*a);if(g===f&&_===p)return;this.#p||=[u,d,f,p];let v=s(f/2,p/2),y=e._round(u+v[0]),b=e._round(d+v[1]),x=s(g/2,_/2);this.x=y-x[0],this.y=b-x[1],this.width=g,this.height=_,this.setDims(c*g,l*_),this.fixAndSetPosition(),this._onResizing()}#P(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#A()}pointerdown(e){let{isMac:t}=L.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(this.#f=!0,this._isDraggable){this.#I(e);return}this.#F(e)}get isSelected(){return this._uiManager.isSelected(this)}#F(e){let{isMac:t}=L.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#I(e){let{isSelected:t}=this;this._uiManager.setUpDragSession();let n=!1,r=new AbortController,i=this._uiManager.combinedSignal(r),a={capture:!0,passive:!1,signal:i},o=e=>{r.abort(),this.#i=null,this.#f=!1,this._uiManager.endDragSession()||this.#F(e),n&&this._onStopDragging()};t&&(this.#v=e.clientX,this.#y=e.clientY,this.#i=e.pointerId,this.#a=e.pointerType,window.addEventListener(`pointermove`,e=>{n||(n=!0,this._onStartDragging());let{clientX:t,clientY:r,pointerId:i}=e;if(i!==this.#i){V(e);return}let[a,o]=this.screenToPageTranslation(t-this.#v,r-this.#y);this.#v=t,this.#y=r,this._uiManager.dragSelectedEditors(a,o)},a),window.addEventListener(`touchmove`,V,a),window.addEventListener(`pointerdown`,e=>{e.pointerType===this.#a&&(this.#x||e.isPrimary)&&o(e),V(e)},a));let s=e=>{if(!this.#i||this.#i===e.pointerId){o(e);return}V(e)};window.addEventListener(`pointerup`,s,{signal:i}),window.addEventListener(`blur`,s,{signal:i})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#_&&clearTimeout(this.#_),this.#_=setTimeout(()=>{this.#_=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,n=this.rotation){let r=this.parentScale,[i,a]=this.pageDimensions,[o,s]=this.pageTranslation,c=e/r,l=t/r,u=this.x*i,d=this.y*a,f=this.width*i,p=this.height*a;switch(n){case 0:return[u+c+o,a-d-l-p+s,u+c+f+o,a-d-l+s];case 90:return[u+l+o,a-d+c+s,u+l+p+o,a-d+c+f+s];case 180:return[u-c-f+o,a-d+l+s,u-c+o,a-d+l+p+s];case 270:return[u-l-p+o,a-d-c-f+s,u-l+o,a-d-c+s];default:throw Error(`Invalid rotation`)}}getRectInCurrentCoords(e,t){let[n,r,i,a]=e,o=i-n,s=a-r;switch(this.rotation){case 0:return[n,t-a,o,s];case 90:return[n,t-r,s,o];case 180:return[i,t-r,o,s];case 270:return[i,t-a,s,o];default:throw Error(`Invalid rotation`)}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){this.#h=!0}disableEditMode(){this.#h=!1}isInEditMode(){return this.#h}shouldGetKeyboardEvents(){return this.#g}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:e,left:t,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return t<a&&r>0&&e<i&&n>0}#L(){if(this.#u||!this.div)return;this.#u=new AbortController;let e=this._uiManager.combinedSignal(this.#u);this.div.addEventListener(`focusin`,this.focusin.bind(this),{signal:e}),this.div.addEventListener(`focusout`,this.focusout.bind(this),{signal:e})}rebuild(){this.#L()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||``}}serialize(e=!1,t=null){E(`An editor must be serializable`)}static async deserialize(e,t,n){let r=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:n});r.rotation=e.rotation,r.#e=e.accessibilityData;let[i,a]=r.pageDimensions,[o,s,c,l]=r.getRectInCurrentCoords(e.rect,a);return r.x=o/i,r.y=s/a,r.width=c/i,r.height=l/a,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#u?.abort(),this.#u=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#_&&=(clearTimeout(this.#_),null),this.#H(),this.removeEditToolbar(),this.#b){for(let e of this.#b.values())clearTimeout(e);this.#b=null}this.parent=null,this.#x?.destroy(),this.#x=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#D(),this.#s.classList.remove(`hidden`),Pe(this,this.div,[`keydown`]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!==`Enter`)return;this._uiManager.setSelected(this),this.#l={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let n=this.#s.children;if(!this.#t){this.#t=Array.from(n);let t=this.#R.bind(this),r=this.#z.bind(this),i=this._uiManager._signal;for(let n of this.#t){let a=n.getAttribute(`data-resizer-name`);n.setAttribute(`role`,`spinbutton`),n.addEventListener(`keydown`,t,{signal:i}),n.addEventListener(`blur`,r,{signal:i}),n.addEventListener(`focus`,this.#B.bind(this,a),{signal:i}),n.setAttribute(`data-l10n-id`,e._l10nResizer[a])}}let r=this.#t[0],i=0;for(let e of n){if(e===r)break;i++}let a=(360-this.rotation+this.parentRotation)%360/90*(this.#t.length/4);if(a!==i){if(a<i)for(let e=0;e<i-a;e++)this.#s.append(this.#s.firstChild);else if(a>i)for(let e=0;e<a-i;e++)this.#s.firstChild.before(this.#s.lastChild);let t=0;for(let r of n){let n=this.#t[t++].getAttribute(`data-resizer-name`);r.setAttribute(`data-l10n-id`,e._l10nResizer[n])}}this.#V(0),this.#g=!0,this.#s.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#R(t){e._resizerKeyboardManager.exec(this,t)}#z(e){this.#g&&e.relatedTarget?.parentNode!==this.#s&&this.#H()}#B(e){this.#d=this.#g?e:``}#V(e){if(this.#t)for(let t of this.#t)t.tabIndex=e}_resizeWithKeyboard(e,t){this.#g&&this.#j(this.#d,{deltaX:e,deltaY:t,fromKeyboard:!0})}#H(){this.#g=!1,this.#V(-1),this.#A()}_stopResizingWithKeyboard(){this.#H(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add(`selectedEditor`),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains(`selectedEditor`)&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}unselect(){this.#s?.classList.add(`hidden`),this.div?.classList.remove(`selectedEditor`),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0)}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#m}set isEditing(e){this.#m=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){this.#o=!0;let n=e/t,{style:r}=this.div;r.aspectRatio=n,r.height=`auto`}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:`added`}}get telemetryFinalData(){return null}_reportTelemetry(t,n=!1){if(n){this.#b||=new Map;let{action:n}=t,r=this.#b.get(n);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),this.#b.delete(n),this.#b.size===0&&(this.#b=null)},e._telemetryTimeout),this.#b.set(n,r);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:t}})}show(e=this._isVisible){this.div.classList.toggle(`hidden`,!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#r=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#r=!0}renderAnnotationElement(e){let t=e.container.querySelector(`.annotationContent`);if(!t)t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.container.prepend(t);else if(t.nodeName===`CANVAS`){let e=t;t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.before(t)}return t}resetAnnotationElement(e){let{firstChild:t}=e.container;t?.nodeName===`DIV`&&t.classList.contains(`annotationContent`)&&t.remove()}},Ue=class extends W{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},We=3285377520,G=4294901760,K=65535,Ge=class{constructor(e){this.h1=e?e&4294967295:We,this.h2=e?e&4294967295:We}update(e){let t,n;if(typeof e==`string`){t=new Uint8Array(e.length*2),n=0;for(let r=0,i=e.length;r<i;r++){let i=e.charCodeAt(r);i<=255?t[n++]=i:(t[n++]=i>>>8,t[n++]=i&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),n=t.byteLength;else throw Error(`Invalid data format, must be a string or TypedArray.`);let r=n>>2,i=n-r*4,a=new Uint32Array(t.buffer,0,r),o=0,s=0,c=this.h1,l=this.h2,u=3432918353,d=461845907,f=u&K,p=d&K;for(let e=0;e<r;e++)e&1?(o=a[e],o=o*u&G|o*f&K,o=o<<15|o>>>17,o=o*d&G|o*p&K,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(s=a[e],s=s*u&G|s*f&K,s=s<<15|s>>>17,s=s*d&G|s*p&K,l^=s,l=l<<13|l>>>19,l=l*5+3864292196);switch(o=0,i){case 3:o^=t[r*4+2]<<16;case 2:o^=t[r*4+1]<<8;case 1:o^=t[r*4],o=o*u&G|o*f&K,o=o<<15|o>>>17,o=o*d&G|o*p&K,r&1?c^=o:l^=o}this.h1=c,this.h2=l}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&G|e*36045&K,t=t*4283543511&G|((t<<16|e>>>16)*2950163797&G)>>>16,e^=t>>>1,e=e*444984403&G|e*60499&K,t=t*3301882366&G|((t<<16|e>>>16)*3120437893&G)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}},Ke=Object.freeze({map:null,hash:``,transfer:void 0}),qe=class{#e=!1;#t=null;#n=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){let n=this.#n.get(e);return n===void 0?t:Object.assign(t,n)}getRawValue(e){return this.#n.get(e)}remove(e){if(this.#n.delete(e),this.#n.size===0&&this.resetModified(),typeof this.onAnnotationEditor==`function`){for(let e of this.#n.values())if(e instanceof W)return;this.onAnnotationEditor(null)}}setValue(e,t){let n=this.#n.get(e),r=!1;if(n!==void 0)for(let[e,i]of Object.entries(t))n[e]!==i&&(r=!0,n[e]=i);else r=!0,this.#n.set(e,t);r&&this.#r(),t instanceof W&&typeof this.onAnnotationEditor==`function`&&this.onAnnotationEditor(t.constructor._type)}has(e){return this.#n.has(e)}getAll(){return this.#n.size>0?ae(this.#n):null}setAll(e){for(let[t,n]of Object.entries(e))this.setValue(t,n)}get size(){return this.#n.size}#r(){this.#e||(this.#e=!0,typeof this.onSetModified==`function`&&this.onSetModified())}resetModified(){this.#e&&(this.#e=!1,typeof this.onResetModified==`function`&&this.onResetModified())}get print(){return new Je(this)}get serializable(){if(this.#n.size===0)return Ke;let e=new Map,t=new Ge,n=[],r=Object.create(null),i=!1;for(let[n,a]of this.#n){let o=a instanceof W?a.serialize(!1,r):a;o&&(e.set(n,o),t.update(`${n}:${JSON.stringify(o)}`),i||=!!o.bitmap)}if(i)for(let t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:Ke}get editorStats(){let e=null,t=new Map;for(let n of this.#n.values()){if(!(n instanceof W))continue;let r=n.telemetryFinalData;if(!r)continue;let{type:i}=r;t.has(i)||t.set(i,Object.getPrototypeOf(n).constructor),e||=Object.create(null);let a=e[i]||=new Map;for(let[e,t]of Object.entries(r)){if(e===`type`)continue;let n=a.get(e);n||(n=new Map,a.set(e,n));let r=n.get(t)??0;n.set(t,r+1)}}for(let[n,r]of t)e[n]=r.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){this.#t=null}get modifiedIds(){if(this.#t)return this.#t;let e=[];for(let t of this.#n.values())!(t instanceof W)||!t.annotationElementId||!t.serialize()||e.push(t.annotationElementId);return this.#t={ids:new Set(e),hash:e.join(`,`)}}},Je=class extends qe{#e;constructor(e){super();let{map:t,hash:n,transfer:r}=e.serializable;this.#e={map:structuredClone(t,r?{transfer:r}:null),hash:n,transfer:r}}get print(){E(`Should not call PrintAnnotationStorage.print`)}get serializable(){return this.#e}get modifiedIds(){return A(this,`modifiedIds`,{ids:new Set,hash:``})}},Ye=class{#e=new Set;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement(`style`),this._document.documentElement.getElementsByTagName(`head`)[0].append(this.styleElement));let t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),this.#e.clear(),this.styleElement&&=(this.styleElement.remove(),null)}async loadSystemFont({systemFontInfo:e,_inspectFont:t}){if(!(!e||this.#e.has(e.loadedName))){if(D(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:n,src:r,style:i}=e,a=new FontFace(n,r,i);this.addNativeFontFace(a);try{await a.load(),this.#e.add(n),t?.(e)}catch{T(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}E(`Not implemented: loadSystemFont without the Font Loading API.`)}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){let t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(n){throw T(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(t=>{let n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)})}}get isFontLoadingAPISupported(){let e=!!this._document?.fonts;return A(this,`isFontLoadingAPISupported`,e)}get isSyncFontLoadingSupported(){let e=!1;return(r||typeof navigator<`u`&&typeof navigator?.userAgent==`string`&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),A(this,`isSyncFontLoadingSupported`,e)}_queueLoadingCallback(e){function t(){for(D(!r.done,`completeRequest() cannot be called twice.`),r.done=!0;n.length>0&&n[0].done;){let e=n.shift();setTimeout(e.callback,0)}}let{loadingRequests:n}=this,r={done:!1,complete:t,callback:e};return n.push(r),r}get _loadTestFont(){let e=atob(`T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==`);return A(this,`_loadTestFont`,e)}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3)&255}function r(e,t,n,r){let i=e.substring(0,t),a=e.substring(t+n);return i+r+a}let i,a,o=this._document.createElement(`canvas`);o.width=1,o.height=1;let s=o.getContext(`2d`),c=0;function l(e,t){if(++c>30){T(`Load test font never loaded.`),t();return}if(s.font=`30px `+e,s.fillText(`.`,0,20),s.getImageData(0,0,1,1).data[3]>0){t();return}setTimeout(l.bind(null,e,t))}let u=`lt${Date.now()}${this.loadTestFontId++}`,d=this._loadTestFont;d=r(d,976,u.length,u);let f=1482184792,p=n(d,16);for(i=0,a=u.length-3;i<a;i+=4)p=p-f+n(u,i)|0;i<u.length&&(p=p-f+n(u+`XXX`,i)|0),d=r(d,16,4,ie(p));let m=`@font-face {font-family:"${u}";src:${`url(data:font/opentype;base64,${btoa(d)});`}}`;this.insertRule(m);let h=this._document.createElement(`div`);h.style.visibility=`hidden`,h.style.width=h.style.height=`10px`,h.style.position=`absolute`,h.style.top=h.style.left=`0px`;for(let t of[e.loadedName,u]){let e=this._document.createElement(`span`);e.textContent=`Hi`,e.style.fontFamily=t,h.append(e)}this._document.body.append(h),l(u,()=>{h.remove(),t.complete()})}},Xe=class{constructor(e,{disableFontFace:t=!1,fontExtraProperties:n=!1,inspectFont:r=null}){this.compiledGlyphs=Object.create(null);for(let t in e)this[t]=e[t];this.disableFontFace=t===!0,this.fontExtraProperties=n===!0,this._inspectFont=r}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{let t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${he(this.data)});`,t;if(!this.cssFontInfo)t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${e}}`}return this._inspectFont?.(this,e),t}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let n=this.loadedName+`_path_`+t,r;try{r=e.get(n)}catch(e){T(`getPathGenerator - ignoring character: "${e}".`)}let i=new Path2D(r||``);return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[t]=i}},Ze={DATA:1,ERROR:2},q={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Qe(){}function J(e){if(e instanceof I||e instanceof P||e instanceof F||e instanceof M||e instanceof ee||e instanceof N)return e;switch(e instanceof Error||typeof e==`object`&&e||E(`wrapReason: Expected "reason" to be a (possibly cloned) Error.`),e.name){case`AbortException`:return new I(e.message);case`InvalidPDFException`:return new P(e.message);case`MissingPDFException`:return new F(e.message);case`PasswordException`:return new M(e.message,e.code);case`UnexpectedResponseException`:return new ee(e.message,e.status);case`UnknownErrorException`:return new N(e.message,e.details)}return new N(e.message,e.toString())}var $e=class{#e=new AbortController;constructor(e,t,n){this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),n.addEventListener(`message`,this.#t.bind(this),{signal:this.#e.signal})}#t({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){this.#r(e);return}if(e.callback){let t=e.callbackId,n=this.callbackCapabilities[t];if(!n)throw Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],e.callback===Ze.DATA)n.resolve(e.data);else if(e.callback===Ze.ERROR)n.reject(J(e.reason));else throw Error(`Unexpected callback case`);return}let t=this.actionHandler[e.action];if(!t)throw Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){let n=this.sourceName,r=e.sourceName,i=this.comObj;Promise.try(t,e.data).then(function(t){i.postMessage({sourceName:n,targetName:r,callback:Ze.DATA,callbackId:e.callbackId,data:t})},function(t){i.postMessage({sourceName:n,targetName:r,callback:Ze.ERROR,callbackId:e.callbackId,reason:J(t)})});return}if(e.streamId){this.#n(e);return}t(e.data)}on(e,t){let n=this.actionHandler;if(n[e])throw Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){let r=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[r]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:r,data:t},n)}catch(e){i.reject(e)}return i.promise}sendWithStream(e,t,n,r){let i=this.streamId++,a=this.sourceName,o=this.targetName,s=this.comObj;return new ReadableStream({start:n=>{let c=Promise.withResolvers();return this.streamControllers[i]={controller:n,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},s.postMessage({sourceName:a,targetName:o,action:e,streamId:i,data:t,desiredSize:n.desiredSize},r),c.promise},pull:e=>{let t=Promise.withResolvers();return this.streamControllers[i].pullCall=t,s.postMessage({sourceName:a,targetName:o,stream:q.PULL,streamId:i,desiredSize:e.desiredSize}),t.promise},cancel:e=>{D(e instanceof Error,`cancel must have a valid reason`);let t=Promise.withResolvers();return this.streamControllers[i].cancelCall=t,this.streamControllers[i].isClosed=!0,s.postMessage({sourceName:a,targetName:o,stream:q.CANCEL,streamId:i,reason:J(e)}),t.promise}},n)}#n(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this,o=this.actionHandler[e.action],s={enqueue(e,a=1,o){if(this.isCancelled)return;let s=this.desiredSize;this.desiredSize-=a,s>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:n,targetName:r,stream:q.ENQUEUE,streamId:t,chunk:e},o)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:q.CLOSE,streamId:t}),delete a.streamSinks[t])},error(e){D(e instanceof Error,`error must have a valid reason`),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:q.ERROR,streamId:t,reason:J(e)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};s.sinkCapability.resolve(),s.ready=s.sinkCapability.promise,this.streamSinks[t]=s,Promise.try(o,e.data,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.START_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.START_COMPLETE,streamId:t,reason:J(e)})})}#r(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this.streamControllers[t],o=this.streamSinks[t];switch(e.stream){case q.START_COMPLETE:e.success?a.startCall.resolve():a.startCall.reject(J(e.reason));break;case q.PULL_COMPLETE:e.success?a.pullCall.resolve():a.pullCall.reject(J(e.reason));break;case q.PULL:if(!o){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||Qe).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.PULL_COMPLETE,streamId:t,reason:J(e)})});break;case q.ENQUEUE:if(D(a,`enqueue should have stream controller`),a.isClosed)break;a.controller.enqueue(e.chunk);break;case q.CLOSE:if(D(a,`close should have stream controller`),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#i(a,t);break;case q.ERROR:D(a,`error should have stream controller`),a.controller.error(J(e.reason)),this.#i(a,t);break;case q.CANCEL_COMPLETE:e.success?a.cancelCall.resolve():a.cancelCall.reject(J(e.reason)),this.#i(a,t);break;case q.CANCEL:if(!o)break;let s=J(e.reason);Promise.try(o.onCancel||Qe,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:q.CANCEL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:q.CANCEL_COMPLETE,streamId:t,reason:J(e)})}),o.sinkCapability.reject(s),o.isCancelled=!0,delete this.streamSinks[t];break;default:throw Error(`Unexpected stream case`)}}async#i(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]}destroy(){this.#e?.abort(),this.#e=null}},et=class{#e=!1;constructor({enableHWA:e=!1}){this.#e=e}create(e,t){if(e<=0||t<=0)throw Error(`Invalid canvas size`);let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext(`2d`,{willReadFrequently:!this.#e})}}reset(e,t,n){if(!e.canvas)throw Error(`Canvas is not specified`);if(t<=0||n<=0)throw Error(`Invalid canvas size`);e.canvas.width=t,e.canvas.height=n}destroy(e){if(!e.canvas)throw Error(`Canvas is not specified`);e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){E("Abstract method `_createCanvas` called.")}},tt=class extends et{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){let n=this._document.createElement(`canvas`);return n.width=e,n.height=t,n}},nt=class{constructor({baseUrl:e=null,isCompressed:t=!0}){this.baseUrl=e,this.isCompressed=t}async fetch({name:e}){if(!this.baseUrl)throw Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw Error(`CMap name must be specified.`);let t=this.baseUrl+e+(this.isCompressed?`.bcmap`:``);return this._fetch(t).then(e=>({cMapData:e,isCompressed:this.isCompressed})).catch(e=>{throw Error(`Unable to load ${this.isCompressed?`binary `:``}CMap at: ${t}`)})}async _fetch(e){E("Abstract method `_fetch` called.")}},rt=class extends nt{async _fetch(e){let t=await _e(e,this.isCompressed?`arraybuffer`:`text`);return t instanceof ArrayBuffer?new Uint8Array(t):re(t)}},it=class{addFilter(e){return`none`}addHCMFilter(e,t){return`none`}addAlphaFilter(e){return`none`}addLuminosityFilter(e){return`none`}addHighlightHCMFilter(e,t,n,r,i){return`none`}destroy(e=!1){}},at=class extends it{#e;#t;#n;#r;#i;#a;#o=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super(),this.#r=e,this.#i=t}get#s(){return this.#t||=new Map}get#c(){return this.#a||=new Map}get#l(){if(!this.#n){let e=this.#i.createElement(`div`),{style:t}=e;t.visibility=`hidden`,t.contain=`strict`,t.width=t.height=0,t.position=`absolute`,t.top=t.left=0,t.zIndex=-1;let n=this.#i.createElementNS(z,`svg`);n.setAttribute(`width`,0),n.setAttribute(`height`,0),this.#n=this.#i.createElementNS(z,`defs`),e.append(n),n.append(this.#n),this.#i.body.append(e)}return this.#n}#u(e){if(e.length===1){let t=e[0],n=Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;let r=n.join(`,`);return[r,r,r]}let[t,n,r]=e,i=Array(256),a=Array(256),o=Array(256);for(let e=0;e<256;e++)i[e]=t[e]/255,a[e]=n[e]/255,o[e]=r[e]/255;return[i.join(`,`),a.join(`,`),o.join(`,`)]}#d(e){if(this.#e===void 0){this.#e=``;let e=this.#i.URL;e!==this.#i.baseURI&&(be(e)?T(`#createUrl: ignore "data:"-URL for performance reasons.`):this.#e=e.split(`#`,1)[0])}return`url(${this.#e}#${e})`}addFilter(e){if(!e)return`none`;let t=this.#s.get(e);if(t)return t;let[n,r,i]=this.#u(e),a=e.length===1?n:`${n}${r}${i}`;if(t=this.#s.get(a),t)return this.#s.set(e,t),t;let o=`g_${this.#r}_transfer_map_${this.#o++}`,s=this.#d(o);this.#s.set(e,s),this.#s.set(a,s);let c=this.#m(o);return this.#g(n,r,i,c),s}addHCMFilter(e,t){let n=`${e}-${t}`,r=`base`,i=this.#c.get(r);if(i?.key===n||(i?(i.filter?.remove(),i.key=n,i.url=`none`,i.filter=null):(i={key:n,url:`none`,filter:null},this.#c.set(r,i)),!e||!t))return i.url;let a=this.#v(e);e=R.makeHexColor(...a);let o=this.#v(t);if(t=R.makeHexColor(...o),this.#l.style.color=``,e===`#000000`&&t===`#ffffff`||e===t)return i.url;let s=Array(256);for(let e=0;e<=255;e++){let t=e/255;s[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}let c=s.join(`,`),l=`g_${this.#r}_hcm_filter`,u=i.filter=this.#m(l);this.#g(c,c,c,u),this.#p(u);let d=(e,t)=>{let n=a[e]/255,r=o[e]/255,i=Array(t+1);for(let e=0;e<=t;e++)i[e]=n+e/t*(r-n);return i.join(`,`)};return this.#g(d(0,5),d(1,5),d(2,5),u),i.url=this.#d(l),i.url}addAlphaFilter(e){let t=this.#s.get(e);if(t)return t;let[n]=this.#u([e]),r=`alpha_${n}`;if(t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_alpha_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#_(n,o),a}addLuminosityFilter(e){let t=this.#s.get(e||`luminosity`);if(t)return t;let n,r;if(e?([n]=this.#u([e]),r=`luminosity_${n}`):r=`luminosity`,t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_luminosity_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#f(o),e&&this.#_(n,o),a}addHighlightHCMFilter(e,t,n,r,i){let a=`${t}-${n}-${r}-${i}`,o=this.#c.get(e);if(o?.key===a||(o?(o.filter?.remove(),o.key=a,o.url=`none`,o.filter=null):(o={key:a,url:`none`,filter:null},this.#c.set(e,o)),!t||!n))return o.url;let[s,c]=[t,n].map(this.#v.bind(this)),l=Math.round(.2126*s[0]+.7152*s[1]+.0722*s[2]),u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[d,f]=[r,i].map(this.#v.bind(this));u<l&&([l,u,d,f]=[u,l,f,d]),this.#l.style.color=``;let p=(e,t,n)=>{let r=Array(256),i=(u-l)/n,a=e/255,o=(t-e)/(255*n),s=0;for(let e=0;e<=n;e++){let t=Math.round(l+e*i),n=a+e*o;for(let e=s;e<=t;e++)r[e]=n;s=t+1}for(let e=s;e<256;e++)r[e]=r[s-1];return r.join(`,`)},m=`g_${this.#r}_hcm_${e}_filter`,h=o.filter=this.#m(m);return this.#p(h),this.#g(p(d[0],f[0],5),p(d[1],f[1],5),p(d[2],f[2],5),h),o.url=this.#d(m),o.url}destroy(e=!1){e&&this.#a?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#t?.clear(),this.#t=null,this.#a?.clear(),this.#a=null,this.#o=0)}#f(e){let t=this.#i.createElementNS(z,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.setAttribute(`values`,`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0`),e.append(t)}#p(e){let t=this.#i.createElementNS(z,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.setAttribute(`values`,`0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0`),e.append(t)}#m(e){let t=this.#i.createElementNS(z,`filter`);return t.setAttribute(`color-interpolation-filters`,`sRGB`),t.setAttribute(`id`,e),this.#l.append(t),t}#h(e,t,n){let r=this.#i.createElementNS(z,t);r.setAttribute(`type`,`discrete`),r.setAttribute(`tableValues`,n),e.append(r)}#g(e,t,n,r){let i=this.#i.createElementNS(z,`feComponentTransfer`);r.append(i),this.#h(i,`feFuncR`,e),this.#h(i,`feFuncG`,t),this.#h(i,`feFuncB`,n)}#_(e,t){let n=this.#i.createElementNS(z,`feComponentTransfer`);t.append(n),this.#h(n,`feFuncA`,e)}#v(e){return this.#l.style.color=e,Oe(getComputedStyle(this.#l).getPropertyValue(`color`))}},ot=class{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw Error(`Font filename must be specified.`);let t=`${this.baseUrl}${e}`;return this._fetch(t).catch(e=>{throw Error(`Unable to load font data at: ${t}`)})}async _fetch(e){E("Abstract method `_fetch` called.")}},st=class extends ot{async _fetch(e){let t=await _e(e,`arraybuffer`);return new Uint8Array(t)}};r&&T("Please use the `legacy` build in Node.js environments.");async function ct(e){let t=await process.getBuiltinModule(`fs`).promises.readFile(e);return new Uint8Array(t)}var lt=class extends it{},ut=class extends et{_createCanvas(e,t){return process.getBuiltinModule(`module`).createRequire(import.meta.url)(`@napi-rs/canvas`).createCanvas(e,t)}},dt=class extends nt{async _fetch(e){return ct(e)}},ft=class extends ot{async _fetch(e){return ct(e)}},Y={FILL:`Fill`,STROKE:`Stroke`,SHADING:`Shading`};function pt(e,t){if(!t)return;let n=t[2]-t[0],r=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],n,r),e.clip(i)}var mt=class{getPattern(){E("Abstract method `getPattern` called.")}},ht=class extends mt{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;this._type===`axial`?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type===`radial`&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let e of this._colorStops)t.addColorStop(e[0],e[1]);return t}getPattern(e,t,n,r){let i;if(r===Y.STROKE||r===Y.FILL){let a=t.current.getClippedPathBoundingBox(r,H(e))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,s=Math.ceil(a[3]-a[1])||1,c=t.cachedCanvases.getCanvas(`pattern`,o,s),l=c.context;l.clearRect(0,0,l.canvas.width,l.canvas.height),l.beginPath(),l.rect(0,0,l.canvas.width,l.canvas.height),l.translate(-a[0],-a[1]),n=R.transform(n,[1,0,0,1,a[0],a[1]]),l.transform(...t.baseTransform),this.matrix&&l.transform(...this.matrix),pt(l,this._bbox),l.fillStyle=this._createGradient(l),l.fill(),i=e.createPattern(c.canvas,`no-repeat`);let u=new DOMMatrix(n);i.setTransform(u)}else pt(e,this._bbox),i=this._createGradient(e);return i}};function gt(e,t,n,r,i,a,o,s){let c=t.coords,l=t.colors,u=e.data,d=e.width*4,f;c[n+1]>c[r+1]&&(f=n,n=r,r=f,f=a,a=o,o=f),c[r+1]>c[i+1]&&(f=r,r=i,i=f,f=o,o=s,s=f),c[n+1]>c[r+1]&&(f=n,n=r,r=f,f=a,a=o,o=f);let p=(c[n]+t.offsetX)*t.scaleX,m=(c[n+1]+t.offsetY)*t.scaleY,h=(c[r]+t.offsetX)*t.scaleX,g=(c[r+1]+t.offsetY)*t.scaleY,_=(c[i]+t.offsetX)*t.scaleX,v=(c[i+1]+t.offsetY)*t.scaleY;if(m>=v)return;let y=l[a],b=l[a+1],x=l[a+2],S=l[o],C=l[o+1],w=l[o+2],T=l[s],E=l[s+1],D=l[s+2],O=Math.round(m),k=Math.round(v),A,j,M,N,P,F,ee,te;for(let e=O;e<=k;e++){if(e<g){let t=e<m?0:(m-e)/(m-g);A=p-(p-h)*t,j=y-(y-S)*t,M=b-(b-C)*t,N=x-(x-w)*t}else{let t;t=e>v?1:g===v?0:(g-e)/(g-v),A=h-(h-_)*t,j=S-(S-T)*t,M=C-(C-E)*t,N=w-(w-D)*t}let t;t=e<m?0:e>v?1:(m-e)/(m-v),P=p-(p-_)*t,F=y-(y-T)*t,ee=b-(b-E)*t,te=x-(x-D)*t;let n=Math.round(Math.min(A,P)),r=Math.round(Math.max(A,P)),i=d*e+n*4;for(let e=n;e<=r;e++)t=(A-e)/(A-P),t<0?t=0:t>1&&(t=1),u[i++]=j-(j-F)*t|0,u[i++]=M-(M-ee)*t|0,u[i++]=N-(N-te)*t|0,u[i++]=255}}function _t(e,t,n){let r=t.coords,i=t.colors,a,o;switch(t.type){case`lattice`:let s=t.verticesPerRow,c=Math.floor(r.length/s)-1,l=s-1;for(a=0;a<c;a++){let t=a*s;for(let a=0;a<l;a++,t++)gt(e,n,r[t],r[t+1],r[t+s],i[t],i[t+1],i[t+s]),gt(e,n,r[t+s+1],r[t+1],r[t+s],i[t+s+1],i[t+1],i[t+s])}break;case`triangles`:for(a=0,o=r.length;a<o;a+=3)gt(e,n,r[a],r[a+1],r[a+2],i[a],i[a+1],i[a+2]);break;default:throw Error(`illegal figure`)}}var vt=class extends mt{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[7],this._background=e[8],this.matrix=null}_createMeshCanvas(e,t,n){let r=1.1,i=3e3,a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),s=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-o,l=Math.min(Math.ceil(Math.abs(s*e[0]*r)),i),u=Math.min(Math.ceil(Math.abs(c*e[1]*r)),i),d=s/l,f=c/u,p={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-o,scaleX:1/d,scaleY:1/f},m=l+4,h=u+4,g=n.getCanvas(`mesh`,m,h),_=g.context,v=_.createImageData(l,u);if(t){let e=v.data;for(let n=0,r=e.length;n<r;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=255}for(let e of this._figures)_t(v,e,p);return _.putImageData(v,2,2),{canvas:g.canvas,offsetX:a-2*d,offsetY:o-2*f,scaleX:d,scaleY:f}}getPattern(e,t,n,r){pt(e,this._bbox);let i;if(r===Y.SHADING)i=R.singularValueDecompose2dScale(H(e));else if(i=R.singularValueDecompose2dScale(t.baseTransform),this.matrix){let e=R.singularValueDecompose2dScale(this.matrix);i=[i[0]*e[0],i[1]*e[1]]}let a=this._createMeshCanvas(i,r===Y.SHADING?null:this._background,t.cachedCanvases);return r!==Y.SHADING&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(a.offsetX,a.offsetY),e.scale(a.scaleX,a.scaleY),e.createPattern(a.canvas,`no-repeat`)}},yt=class extends mt{getPattern(){return`hotpink`}};function bt(e){switch(e[0]){case`RadialAxial`:return new ht(e);case`Mesh`:return new vt(e);case`Dummy`:return new yt}throw Error(`Unknown IR type: ${e[0]}`)}var xt={COLORED:1,UNCOLORED:2},St=class e{static MAX_PATTERN_SIZE=3e3;constructor(e,t,n,r,i){this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.color=t,this.ctx=n,this.canvasGraphicsFactory=r,this.baseTransform=i}createPatternCanvas(e){let{bbox:t,operatorList:n,paintType:r,tilingType:i,color:a,canvasGraphicsFactory:o}=this,{xstep:s,ystep:c}=this;s=Math.abs(s),c=Math.abs(c),w(`TilingType: `+i);let l=t[0],u=t[1],d=t[2],f=t[3],p=d-l,m=f-u,h=R.singularValueDecompose2dScale(this.matrix),g=R.singularValueDecompose2dScale(this.baseTransform),_=h[0]*g[0],v=h[1]*g[1],y=p,b=m,x=!1,S=!1,C=Math.ceil(s*_),T=Math.ceil(c*v),E=Math.ceil(p*_),D=Math.ceil(m*v);C>=E?y=s:x=!0,T>=D?b=c:S=!0;let O=this.getSizeAndScale(y,this.ctx.canvas.width,_),k=this.getSizeAndScale(b,this.ctx.canvas.height,v),A=e.cachedCanvases.getCanvas(`pattern`,O.size,k.size),j=A.context,M=o.createCanvasGraphics(j);if(M.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(M,r,a),j.translate(-O.scale*l,-k.scale*u),M.transform(O.scale,0,0,k.scale,0,0),j.save(),this.clipBbox(M,l,u,d,f),M.baseTransform=H(M.ctx),M.executeOperatorList(n),M.endDrawing(),j.restore(),x||S){let t=A.canvas;x&&(y=s),S&&(b=c);let n=this.getSizeAndScale(y,this.ctx.canvas.width,_),r=this.getSizeAndScale(b,this.ctx.canvas.height,v),i=n.size,a=r.size,o=e.cachedCanvases.getCanvas(`pattern-workaround`,i,a),d=o.context,f=x?Math.floor(p/s):0,h=S?Math.floor(m/c):0;for(let e=0;e<=f;e++)for(let n=0;n<=h;n++)d.drawImage(t,i*e,a*n,i,a,0,0,i,a);return{canvas:o.canvas,scaleX:n.scale,scaleY:r.scale,offsetX:l,offsetY:u}}return{canvas:A.canvas,scaleX:O.scale,scaleY:k.scale,offsetX:l,offsetY:u}}getSizeAndScale(t,n,r){let i=Math.max(e.MAX_PATTERN_SIZE,n),a=Math.ceil(t*r);return a>=i?a=i:r=a/t,{scale:r,size:a}}clipBbox(e,t,n,r,i){let a=r-t,o=i-n;e.ctx.rect(t,n,a,o),e.current.updateRectMinMax(H(e.ctx),[t,n,r,i]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,n){let r=e.ctx,i=e.current;switch(t){case xt.COLORED:let e=this.ctx;r.fillStyle=e.fillStyle,r.strokeStyle=e.strokeStyle,i.fillColor=e.fillStyle,i.strokeColor=e.strokeStyle;break;case xt.UNCOLORED:let a=R.makeHexColor(n[0],n[1],n[2]);r.fillStyle=a,r.strokeStyle=a,i.fillColor=a,i.strokeColor=a;break;default:throw new te(`Unsupported paint type: ${t}`)}}getPattern(e,t,n,r){let i=n;r!==Y.SHADING&&(i=R.transform(i,t.baseTransform),this.matrix&&(i=R.transform(i,this.matrix)));let a=this.createPatternCanvas(t),o=new DOMMatrix(i);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);let s=e.createPattern(a.canvas,`repeat`);return s.setTransform(o),s}};function Ct({src:e,srcPos:t=0,dest:n,width:r,height:i,nonBlackColor:a=4294967295,inverseDecode:o=!1}){let s=L.isLittleEndian?4278190080:255,[c,l]=o?[a,s]:[s,a],u=r>>3,d=r&7,f=e.length;n=new Uint32Array(n.buffer);let p=0;for(let r=0;r<i;r++){for(let r=t+u;t<r;t++){let r=t<f?e[t]:255;n[p++]=r&128?l:c,n[p++]=r&64?l:c,n[p++]=r&32?l:c,n[p++]=r&16?l:c,n[p++]=r&8?l:c,n[p++]=r&4?l:c,n[p++]=r&2?l:c,n[p++]=r&1?l:c}if(d===0)continue;let r=t<f?e[t++]:255;for(let e=0;e<d;e++)n[p++]=r&1<<7-e?l:c}return{srcPos:t,destPos:p}}var wt=16,Tt=100,Et=15,Dt=10,Ot=1e3,X=16;function kt(e,t){if(e._removeMirroring)throw Error(`Context is already forwarding operations.`);e.__originalSave=e.save,e.__originalRestore=e.restore,e.__originalRotate=e.rotate,e.__originalScale=e.scale,e.__originalTranslate=e.translate,e.__originalTransform=e.transform,e.__originalSetTransform=e.setTransform,e.__originalResetTransform=e.resetTransform,e.__originalClip=e.clip,e.__originalMoveTo=e.moveTo,e.__originalLineTo=e.lineTo,e.__originalBezierCurveTo=e.bezierCurveTo,e.__originalRect=e.rect,e.__originalClosePath=e.closePath,e.__originalBeginPath=e.beginPath,e._removeMirroring=()=>{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(e,n){t.translate(e,n),this.__originalTranslate(e,n)},e.scale=function(e,n){t.scale(e,n),this.__originalScale(e,n)},e.transform=function(e,n,r,i,a,o){t.transform(e,n,r,i,a,o),this.__originalTransform(e,n,r,i,a,o)},e.setTransform=function(e,n,r,i,a,o){t.setTransform(e,n,r,i,a,o),this.__originalSetTransform(e,n,r,i,a,o)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(e){t.rotate(e),this.__originalRotate(e)},e.clip=function(e){t.clip(e),this.__originalClip(e)},e.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},e.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},e.bezierCurveTo=function(e,n,r,i,a,o){t.bezierCurveTo(e,n,r,i,a,o),this.__originalBezierCurveTo(e,n,r,i,a,o)},e.rect=function(e,n,r,i){t.rect(e,n,r,i),this.__originalRect(e,n,r,i)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}var At=class{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,n){let r;return this.cache[e]===void 0?(r=this.canvasFactory.create(t,n),this.cache[e]=r):(r=this.cache[e],this.canvasFactory.reset(r,t,n)),r}delete(e){delete this.cache[e]}clear(){for(let e in this.cache){let t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}};function jt(e,t,n,r,i,a,o,s,c,l){let[u,d,f,p,m,h]=H(e);if(d===0&&f===0){let g=o*u+m,_=Math.round(g),v=s*p+h,y=Math.round(v),b=(o+c)*u+m,x=Math.abs(Math.round(b)-_)||1,S=(s+l)*p+h,C=Math.abs(Math.round(S)-y)||1;return e.setTransform(Math.sign(u),0,0,Math.sign(p),_,y),e.drawImage(t,n,r,i,a,0,0,x,C),e.setTransform(u,d,f,p,m,h),[x,C]}if(u===0&&p===0){let g=s*f+m,_=Math.round(g),v=o*d+h,y=Math.round(v),b=(s+l)*f+m,x=Math.abs(Math.round(b)-_)||1,S=(o+c)*d+h,C=Math.abs(Math.round(S)-y)||1;return e.setTransform(0,Math.sign(d),Math.sign(f),0,_,y),e.drawImage(t,n,r,i,a,0,0,C,x),e.setTransform(u,d,f,p,m,h),[C,x]}e.drawImage(t,n,r,i,a,o,s,c,l);let g=Math.hypot(u,d),_=Math.hypot(f,p);return[g*c,_*l]}function Mt(e){let{width:t,height:n}=e;if(t>Ot||n>Ot)return null;let r=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),a=t+1,o=new Uint8Array(a*(n+1)),s,c,l,u=t+7&-8,d=new Uint8Array(u*n),f=0;for(let t of e.data){let e=128;for(;e>0;)d[f++]=t&e?0:255,e>>=1}let p=0;for(f=0,d[f]!==0&&(o[0]=1,++p),c=1;c<t;c++)d[f]!==d[f+1]&&(o[c]=d[f]?2:1,++p),f++;for(d[f]!==0&&(o[c]=2,++p),s=1;s<n;s++){f=s*u,l=s*a,d[f-u]!==d[f]&&(o[l]=d[f]?1:8,++p);let e=(d[f]?4:0)+(d[f-u]?8:0);for(c=1;c<t;c++)e=(e>>2)+(d[f+1]?4:0)+(d[f-u+1]?8:0),i[e]&&(o[l+c]=i[e],++p),f++;if(d[f-u]!==d[f]&&(o[l+c]=d[f]?2:4,++p),p>r)return null}for(f=u*(n-1),l=s*a,d[f]!==0&&(o[l]=8,++p),c=1;c<t;c++)d[f]!==d[f+1]&&(o[l+c]=d[f]?4:8,++p),f++;if(d[f]!==0&&(o[l+c]=4,++p),p>r)return null;let m=new Int32Array([0,a,-1,0,-a,0,0,0,1]),h=new Path2D;for(s=0;p&&s<=n;s++){let e=s*a,n=e+t;for(;e<n&&!o[e];)e++;if(e===n)continue;h.moveTo(e%a,s);let r=e,i=o[e];do{let t=m[i];do e+=t;while(!o[e]);let n=o[e];n!==5&&n!==10?(i=n,o[e]=0):(i=n&51*i>>4,o[e]&=i>>2|i<<2),h.lineTo(e%a,e/a|0),o[e]||--p}while(r!==e);--s}return d=null,o=null,function(e){e.save(),e.scale(1/t,-1/n),e.translate(0,-n),e.fill(h),e.beginPath(),e.restore()}}var Nt=class{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=i,this.textMatrixScale=1,this.fontMatrix=a,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=m.FILL,this.textRise=0,this.fillColor=`#000000`,this.strokeColor=`#000000`,this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps=`none`,this.startNewPathAndClipBox([0,0,e,t])}clone(){let e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,n){[t,n]=R.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(e,t){let n=R.applyTransform(t,e),r=R.applyTransform(t.slice(2),e),i=R.applyTransform([t[0],t[3]],e),a=R.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,n[0],r[0],i[0],a[0]),this.minY=Math.min(this.minY,n[1],r[1],i[1],a[1]),this.maxX=Math.max(this.maxX,n[0],r[0],i[0],a[0]),this.maxY=Math.max(this.maxY,n[1],r[1],i[1],a[1])}updateScalingPathMinMax(e,t){R.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.minY=Math.min(this.minY,t[1]),this.maxX=Math.max(this.maxX,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,r,i,a,o,s,c,l){let u=R.bezierBoundingBox(t,n,r,i,a,o,s,c,l);l||this.updateRectMinMax(e,u)}getPathBoundingBox(e=Y.FILL,t=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(e===Y.STROKE){t||E(`Stroke bounding box must include transform.`);let e=R.singularValueDecompose2dScale(t),r=e[0]*this.lineWidth/2,i=e[1]*this.lineWidth/2;n[0]-=r,n[1]-=i,n[2]+=r,n[3]+=i}return n}updateClipFromPath(){let e=R.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=Y.FILL,t=null){return R.intersect(this.clipBox,this.getPathBoundingBox(e,t))}};function Pt(e,t){if(t instanceof ImageData){e.putImageData(t,0,0);return}let n=t.height,r=t.width,i=n%X,a=(n-i)/X,o=i===0?a:a+1,s=e.createImageData(r,X),c=0,l,u=t.data,d=s.data,f,p,m,g;if(t.kind===h.GRAYSCALE_1BPP){let t=u.byteLength,n=new Uint32Array(d.buffer,0,d.byteLength>>2),h=n.length,g=r+7>>3,_=4294967295,v=L.isLittleEndian?4278190080:255;for(f=0;f<o;f++){for(m=f<a?X:i,l=0,p=0;p<m;p++){let e=t-c,i=0,a=e>g?r:e*8-7,o=a&-8,s=0,d=0;for(;i<o;i+=8)d=u[c++],n[l++]=d&128?_:v,n[l++]=d&64?_:v,n[l++]=d&32?_:v,n[l++]=d&16?_:v,n[l++]=d&8?_:v,n[l++]=d&4?_:v,n[l++]=d&2?_:v,n[l++]=d&1?_:v;for(;i<a;i++)s===0&&(d=u[c++],s=128),n[l++]=d&s?_:v,s>>=1}for(;l<h;)n[l++]=0;e.putImageData(s,0,f*X)}}else if(t.kind===h.RGBA_32BPP){for(p=0,g=r*X*4,f=0;f<a;f++)d.set(u.subarray(c,c+g)),c+=g,e.putImageData(s,0,p),p+=X;f<o&&(g=r*i*4,d.set(u.subarray(c,c+g)),e.putImageData(s,0,p))}else if(t.kind===h.RGB_24BPP)for(m=X,g=r*m,f=0;f<o;f++){for(f>=a&&(m=i,g=r*m),l=0,p=g;p--;)d[l++]=u[c++],d[l++]=u[c++],d[l++]=u[c++],d[l++]=255;e.putImageData(s,0,f*X)}else throw Error(`bad image kind: ${t.kind}`)}function Ft(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}let n=t.height,r=t.width,i=n%X,a=(n-i)/X,o=i===0?a:a+1,s=e.createImageData(r,X),c=0,l=t.data,u=s.data;for(let t=0;t<o;t++){let n=t<a?X:i;({srcPos:c}=Ct({src:l,srcPos:c,dest:u,width:r,height:n,nonBlackColor:0})),e.putImageData(s,0,t*X)}}function It(e,t){for(let n of[`strokeStyle`,`fillStyle`,`fillRule`,`globalAlpha`,`lineWidth`,`lineCap`,`lineJoin`,`miterLimit`,`globalCompositeOperation`,`font`,`filter`])e[n]!==void 0&&(t[n]=e[n]);e.setLineDash!==void 0&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function Lt(e){if(e.strokeStyle=e.fillStyle=`#000000`,e.fillRule=`nonzero`,e.globalAlpha=1,e.lineWidth=1,e.lineCap=`butt`,e.lineJoin=`miter`,e.miterLimit=10,e.globalCompositeOperation=`source-over`,e.font=`10px sans-serif`,e.setLineDash!==void 0&&(e.setLineDash([]),e.lineDashOffset=0),!r){let{filter:t}=e;t!==`none`&&t!==``&&(e.filter=`none`)}}function Rt(e,t){if(t)return!0;let n=R.singularValueDecompose2dScale(e);n[0]=Math.fround(n[0]),n[1]=Math.fround(n[1]);let r=Math.fround((globalThis.devicePixelRatio||1)*ge.PDF_TO_CSS_UNITS);return n[0]<=r&&n[1]<=r}var zt=[`butt`,`round`,`square`],Bt=[`miter`,`round`,`bevel`],Vt={},Ht={},Ut=class e{constructor(e,t,n,r,i,{optionalContentConfig:a,markedContentStack:o=null},s,c){this.ctx=e,this.current=new Nt(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=t,this.objs=n,this.canvasFactory=r,this.filterFactory=i,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedCanvases=new At(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=s,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,t=null){return typeof e==`string`?e.startsWith(`g_`)?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:r=null}){let i=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=r||`#ffffff`,this.ctx.fillRect(0,0,i,a),this.ctx.fillStyle=o,n){let e=this.cachedCanvases.getCanvas(`transparent`,i,a);this.compositeCtx=this.ctx,this.transparentCanvas=e.canvas,this.ctx=e.context,this.ctx.save(),this.ctx.transform(...H(this.compositeCtx))}this.ctx.save(),Lt(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=H(this.ctx)}executeOperatorList(e,t,n,r){let i=e.argsArray,a=e.fnArray,o=t||0,s=i.length;if(s===o)return o;let c=s-o>Dt&&typeof n==`function`,l=c?Date.now()+Et:0,u=0,d=this.commonObjs,f=this.objs,p;for(;;){if(r!==void 0&&o===r.nextBreakPoint)return r.breakIt(o,n),o;if(p=a[o],p!==y.dependency)this[p].apply(this,i[o]);else for(let e of i[o]){let t=e.startsWith(`g_`)?d:f;if(!t.has(e))return t.get(e,n),o}if(o++,o===s)return o;if(c&&++u>Dt){if(Date.now()>l)return n(),o;u=0}}}#e(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&=(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),null)}endDrawing(){this.#e(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let e of this._cachedBitmapsMap.values()){for(let t of e.values())typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),this.#t()}#t(){if(this.pageColors){let e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!==`none`){let t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}_scaleImage(e,t){let n=e.width??e.displayWidth,r=e.height??e.displayHeight,i=Math.max(Math.hypot(t[0],t[1]),1),a=Math.max(Math.hypot(t[2],t[3]),1),o=n,s=r,c=`prescale1`,l,u;for(;i>2&&o>1||a>2&&s>1;){let t=o,n=s;i>2&&o>1&&(t=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),i/=o/t),a>2&&s>1&&(n=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s)/2,a/=s/n),l=this.cachedCanvases.getCanvas(c,t,n),u=l.context,u.clearRect(0,0,t,n),u.drawImage(e,0,0,o,s,0,0,t,n),e=l.canvas,o=t,s=n,c=c===`prescale1`?`prescale2`:`prescale1`}return{img:e,paintWidth:o,paintHeight:s}}_createMaskCanvas(e){let t=this.ctx,{width:n,height:r}=e,i=this.current.fillColor,a=this.current.patternFill,o=H(t),s,c,l,u;if((e.bitmap||e.data)&&e.count>1){let t=e.bitmap||e.data.buffer;c=JSON.stringify(a?o:[o.slice(0,4),i]),s=this._cachedBitmapsMap.get(t),s||(s=new Map,this._cachedBitmapsMap.set(t,s));let n=s.get(c);if(n&&!a)return{canvas:n,offsetX:Math.round(Math.min(o[0],o[2])+o[4]),offsetY:Math.round(Math.min(o[1],o[3])+o[5])};l=n}l||(u=this.cachedCanvases.getCanvas(`maskCanvas`,n,r),Ft(u.context,e));let d=R.transform(o,[1/n,0,0,-1/r,0,0]);d=R.transform(d,[1,0,0,1,0,-r]);let[f,p,m,h]=R.getAxialAlignedBoundingBox([0,0,n,r],d),g=Math.round(m-f)||1,_=Math.round(h-p)||1,v=this.cachedCanvases.getCanvas(`fillCanvas`,g,_),y=v.context,b=f,x=p;y.translate(-b,-x),y.transform(...d),l||(l=this._scaleImage(u.canvas,U(y)),l=l.img,s&&a&&s.set(c,l)),y.imageSmoothingEnabled=Rt(H(y),e.interpolate),jt(y,l,0,0,l.width,l.height,0,0,n,r),y.globalCompositeOperation=`source-in`;let S=R.transform(U(y),[1,0,0,1,-b,-x]);return y.fillStyle=a?i.getPattern(t,this,S,Y.FILL):i,y.fillRect(0,0,n,r),s&&!a&&(this.cachedCanvases.delete(`fillCanvas`),s.set(c,v.canvas)),{canvas:v.canvas,offsetX:Math.round(b),offsetY:Math.round(x)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=zt[e]}setLineJoin(e){this.ctx.lineJoin=Bt[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){let n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(e),n.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,n]of e)switch(t){case`LW`:this.setLineWidth(n);break;case`LC`:this.setLineCap(n);break;case`LJ`:this.setLineJoin(n);break;case`ML`:this.setMiterLimit(n);break;case`D`:this.setDash(n[0],n[1]);break;case`RI`:this.setRenderingIntent(n);break;case`FL`:this.setFlatness(n);break;case`Font`:this.setFont(n[0],n[1]);break;case`CA`:this.current.strokeAlpha=n;break;case`ca`:this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case`BM`:this.ctx.globalCompositeOperation=n;break;case`SMask`:this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case`TR`:this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw Error(`beginSMaskMode called while already in smask mode`);let e=this.ctx.canvas.width,t=this.ctx.canvas.height,n=`smaskGroupAt`+this.groupLevel,r=this.cachedCanvases.getCanvas(n,e,t);this.suspendedCtx=this.ctx,this.ctx=r.context;let i=this.ctx;i.setTransform(...H(this.suspendedCtx)),It(this.suspendedCtx,i),kt(i,this.suspendedCtx),this.setGState([[`BM`,`source-over`],[`ca`,1],[`CA`,1]])}endSMaskMode(){if(!this.inSMaskMode)throw Error(`endSMaskMode called while not in smask mode`);this.ctx._removeMirroring(),It(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let t=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,t,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,t,n,r){let i=r[0],a=r[1],o=r[2]-i,s=r[3]-a;o===0||s===0||(this.genericComposeSMask(t.context,n,o,s,t.subtype,t.backdrop,t.transferMap,i,a,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation=`source-over`,e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,0,0),e.restore())}genericComposeSMask(e,t,n,r,i,a,o,s,c,l,u){let d=e.canvas,f=s-l,p=c-u;if(a){let t=R.makeHexColor(...a);if(f<0||p<0||f+n>d.width||p+r>d.height){let e=this.cachedCanvases.getCanvas(`maskExtension`,n,r),i=e.context;i.drawImage(d,-f,-p),i.globalCompositeOperation=`destination-atop`,i.fillStyle=t,i.fillRect(0,0,n,r),i.globalCompositeOperation=`source-over`,d=e.canvas,f=p=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);let i=new Path2D;i.rect(f,p,n,r),e.clip(i),e.globalCompositeOperation=`destination-atop`,e.fillStyle=t,e.fillRect(f,p,n,r),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),i===`Alpha`&&o?t.filter=this.filterFactory.addAlphaFilter(o):i===`Luminosity`&&(t.filter=this.filterFactory.addLuminosityFilter(o));let m=new Path2D;m.rect(s,c,n,r),t.clip(m),t.globalCompositeOperation=`destination-in`,t.drawImage(d,f,p,n,r,s,c,n,r),t.restore()}save(){this.inSMaskMode?(It(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),It(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,n,r,i,a){this.ctx.transform(e,t,n,r,i,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,n){let r=this.ctx,i=this.current,a=i.x,o=i.y,s,c,l=H(r),u=l[0]===0&&l[3]===0||l[1]===0&&l[2]===0,d=u?n.slice(0):null;for(let n=0,f=0,p=e.length;n<p;n++)switch(e[n]|0){case y.rectangle:a=t[f++],o=t[f++];let e=t[f++],n=t[f++],p=a+e,m=o+n;r.moveTo(a,o),e===0||n===0?r.lineTo(p,m):(r.lineTo(p,o),r.lineTo(p,m),r.lineTo(a,m)),u||i.updateRectMinMax(l,[a,o,p,m]),r.closePath();break;case y.moveTo:a=t[f++],o=t[f++],r.moveTo(a,o),u||i.updatePathMinMax(l,a,o);break;case y.lineTo:a=t[f++],o=t[f++],r.lineTo(a,o),u||i.updatePathMinMax(l,a,o);break;case y.curveTo:s=a,c=o,a=t[f+4],o=t[f+5],r.bezierCurveTo(t[f],t[f+1],t[f+2],t[f+3],a,o),i.updateCurvePathMinMax(l,s,c,t[f],t[f+1],t[f+2],t[f+3],a,o,d),f+=6;break;case y.curveTo2:s=a,c=o,r.bezierCurveTo(a,o,t[f],t[f+1],t[f+2],t[f+3]),i.updateCurvePathMinMax(l,s,c,a,o,t[f],t[f+1],t[f+2],t[f+3],d),a=t[f+2],o=t[f+3],f+=4;break;case y.curveTo3:s=a,c=o,a=t[f+2],o=t[f+3],r.bezierCurveTo(t[f],t[f+1],a,o,a,o),i.updateCurvePathMinMax(l,s,c,t[f],t[f+1],a,o,a,o,d),f+=4;break;case y.closePath:r.closePath();break}u&&i.updateScalingPathMinMax(l,d),i.setCurrentPoint(a,o)}closePath(){this.ctx.closePath()}stroke(e=!0){let t=this.ctx,n=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof n==`object`&&n?.getPattern?(t.save(),t.strokeStyle=n.getPattern(t,this,U(t),Y.STROKE),this.rescaleAndStroke(!1),t.restore()):this.rescaleAndStroke(!0)),e&&this.consumePath(this.current.getClippedPathBoundingBox()),t.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){let t=this.ctx,n=this.current.fillColor,r=this.current.patternFill,i=!1;r&&(t.save(),t.fillStyle=n.getPattern(t,this,U(t),Y.FILL),i=!0);let a=this.current.getClippedPathBoundingBox();this.contentVisible&&a!==null&&(this.pendingEOFill?(t.fill(`evenodd`),this.pendingEOFill=!1):t.fill()),i&&t.restore(),e&&this.consumePath(a)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Vt}eoClip(){this.pendingClip=Ht}beginText(){this.current.textMatrix=i,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let e=this.pendingTextPaths,t=this.ctx;if(e===void 0){t.beginPath();return}let n=new Path2D,r=t.getTransform().invertSelf();for(let{transform:t,x:i,y:a,fontSize:o,path:s}of e)n.addPath(s,new DOMMatrix(t).preMultiplySelf(r).translate(i,a).scale(o,-o));t.clip(n),t.beginPath(),delete this.pendingTextPaths}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){let n=this.commonObjs.get(e),r=this.current;if(!n)throw Error(`Can't find font for ${e}`);if(r.fontMatrix=n.fontMatrix||a,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&T(`Invalid font matrix for font `+e),t<0?(t=-t,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=t,n.isType3Font)return;let i=n.loadedName||`sans-serif`,o=n.systemFontInfo?.css||`"${i}", ${n.fallbackName}`,s=`normal`;n.black?s=`900`:n.bold&&(s=`bold`);let c=n.italic?`italic`:`normal`,l=t;t<wt?l=wt:t>Tt&&(l=Tt),this.current.fontSizeScale=t/l,this.ctx.font=`${c} ${s} ${l}px ${o}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,n,r,i,a){this.current.textMatrix=[e,t,n,r,i,a],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#n(e,t,n){let r=new Path2D;return r.addPath(e,new DOMMatrix(n).invertSelf().multiplySelf(t)),r}paintChar(e,t,n,r,i){let a=this.ctx,o=this.current,s=o.font,c=o.textRenderingMode,l=o.fontSize/o.fontSizeScale,u=c&m.FILL_STROKE_MASK,d=!!(c&m.ADD_TO_PATH_FLAG),f=o.patternFill&&!s.missingFile,p=o.patternStroke&&!s.missingFile,h;if((s.disableFontFace||d||f||p)&&(h=s.getPathGenerator(this.commonObjs,e)),s.disableFontFace||f||p){if(a.save(),a.translate(t,n),a.scale(l,-l),u===m.FILL||u===m.FILL_STROKE)if(r){let e=a.getTransform();a.setTransform(...r),a.fill(this.#n(h,e,r))}else a.fill(h);if(u===m.STROKE||u===m.FILL_STROKE)if(i){let e=a.getTransform();a.setTransform(...i),a.stroke(this.#n(h,e,i))}else a.lineWidth/=l,a.stroke(h);a.restore()}else (u===m.FILL||u===m.FILL_STROKE)&&a.fillText(e,t,n),(u===m.STROKE||u===m.FILL_STROKE)&&a.strokeText(e,t,n);d&&(this.pendingTextPaths||=[]).push({transform:H(a),x:t,y:n,fontSize:l,path:h})}get isFontSubpixelAAEnabled(){let{context:e}=this.cachedCanvases.getCanvas(`isFontSubpixelAAEnabled`,10,10);e.scale(1.5,1),e.fillText(`I`,0,10);let t=e.getImageData(0,0,10,10).data,n=!1;for(let e=3;e<t.length;e+=4)if(t[e]>0&&t[e]<255){n=!0;break}return A(this,`isFontSubpixelAAEnabled`,n)}showText(e){let t=this.current,n=t.font;if(n.isType3Font)return this.showType3Text(e);let r=t.fontSize;if(r===0)return;let i=this.ctx,a=t.fontSizeScale,o=t.charSpacing,s=t.wordSpacing,c=t.fontDirection,l=t.textHScale*c,u=e.length,d=n.vertical,f=d?1:-1,p=n.defaultVMetrics,h=r*t.fontMatrix[0],g=t.textRenderingMode===m.FILL&&!n.disableFontFace&&!t.patternFill;i.save(),i.transform(...t.textMatrix),i.translate(t.x,t.y+t.textRise),c>0?i.scale(l,-1):i.scale(l,1);let _,v;if(t.patternFill){i.save();let e=t.fillColor.getPattern(i,this,U(i),Y.FILL);_=H(i),i.restore(),i.fillStyle=e}if(t.patternStroke){i.save();let e=t.strokeColor.getPattern(i,this,U(i),Y.STROKE);v=H(i),i.restore(),i.strokeStyle=e}let y=t.lineWidth,b=t.textMatrixScale;if(b===0||y===0){let e=t.textRenderingMode&m.FILL_STROKE_MASK;(e===m.STROKE||e===m.FILL_STROKE)&&(y=this.getSinglePixelWidth())}else y/=b;if(a!==1&&(i.scale(a,a),y/=a),i.lineWidth=y,n.isInvalidPDFjsFont){let n=[],r=0;for(let t of e)n.push(t.unicode),r+=t.width;i.fillText(n.join(``),0,0),t.x+=r*h*l,i.restore(),this.compose();return}let x=0,S;for(S=0;S<u;++S){let t=e[S];if(typeof t==`number`){x+=f*t*r/1e3;continue}let l=!1,u=(t.isSpace?s:0)+o,m=t.fontChar,y=t.accent,b,C,w=t.width;if(d){let e=t.vmetric||p,n=-(t.vmetric?e[1]:w*.5)*h,r=e[2]*h;w=e?-e[0]:w,b=n/a,C=(x+r)/a}else b=x/a,C=0;if(n.remeasure&&w>0){let e=i.measureText(m).width*1e3/r*a;if(w<e&&this.isFontSubpixelAAEnabled){let t=w/e;l=!0,i.save(),i.scale(t,1),b/=t}else w!==e&&(b+=(w-e)/2e3*r/a)}if(this.contentVisible&&(t.isInFont||n.missingFile)){if(g&&!y)i.fillText(m,b,C);else if(this.paintChar(m,b,C,_,v),y){let e=b+r*y.offset.x/a,t=C-r*y.offset.y/a;this.paintChar(y.fontChar,e,t,_,v)}}let T=d?w*h-u*c:w*h+u*c;x+=T,l&&i.restore()}d?t.y-=x:t.x+=x*l,i.restore(),this.compose()}showType3Text(e){let t=this.ctx,n=this.current,r=n.font,i=n.fontSize,o=n.fontDirection,s=r.vertical?1:-1,c=n.charSpacing,l=n.wordSpacing,u=n.textHScale*o,d=n.fontMatrix||a,f=e.length,p=n.textRenderingMode===m.INVISIBLE,h,g,_,v;if(!(p||i===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,t.save(),t.transform(...n.textMatrix),t.translate(n.x,n.y),t.scale(u,o),h=0;h<f;++h){if(g=e[h],typeof g==`number`){v=s*g*i/1e3,this.ctx.translate(v,0),n.x+=v*u;continue}let a=(g.isSpace?l:0)+c,o=r.charProcOperatorList[g.operatorListId];if(!o){T(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),t.scale(i,i),t.transform(...d),this.executeOperatorList(o),this.restore()),_=R.applyTransform([g.width,0],d)[0]*i+a,t.translate(_,0),n.x+=_*u}t.restore(),this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,n,r,i,a){this.ctx.rect(n,r,i-n,a-r),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let n;if(t[0]===`TilingPattern`){let r=t[1],i=this.baseTransform||H(this.ctx);n=new St(t,r,this.ctx,{createCanvasGraphics:t=>new e(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})},i)}else n=this._getPattern(t[1],t[2]);return n}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,n){this.ctx.strokeStyle=this.current.strokeColor=R.makeHexColor(e,t,n),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor=`transparent`,this.current.patternStroke=!1}setFillRGBColor(e,t,n){this.ctx.fillStyle=this.current.fillColor=R.makeHexColor(e,t,n),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor=`transparent`,this.current.patternFill=!1}_getPattern(e,t=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=bt(this.getObject(e)),this.cachedPatterns.set(e,n)),t&&(n.matrix=t),n}shadingFill(e){if(!this.contentVisible)return;let t=this.ctx;this.save(),t.fillStyle=this._getPattern(e).getPattern(t,this,U(t),Y.SHADING);let n=U(t);if(n){let{width:e,height:r}=t.canvas,[i,a,o,s]=R.getAxialAlignedBoundingBox([0,0,e,r],n);this.ctx.fillRect(i,a,o-i,s-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){E(`Should not call beginInlineImage`)}beginImageData(){E(`Should not call beginImageData`)}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=H(this.ctx),t)){let e=t[2]-t[0],n=t[3]-t[1];this.ctx.rect(t[0],t[1],e,n),this.current.updateRectMinMax(H(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let t=this.ctx;e.isolated||w(`TODO: Support non-isolated groups.`),e.knockout&&T(`Knockout groups not supported.`);let n=H(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw Error(`Bounding box is required.`);let r=R.getAxialAlignedBoundingBox(e.bbox,H(t)),i=[0,0,t.canvas.width,t.canvas.height];r=R.intersect(r,i)||[0,0,0,0];let a=Math.floor(r[0]),o=Math.floor(r[1]),s=Math.max(Math.ceil(r[2])-a,1),c=Math.max(Math.ceil(r[3])-o,1);this.current.startNewPathAndClipBox([0,0,s,c]);let l=`groupAt`+this.groupLevel;e.smask&&(l+=`_smask_`+ this.smaskCounter++%2);let u=this.cachedCanvases.getCanvas(l,s,c),d=u.context;d.translate(-a,-o),d.transform(...n),e.smask?this.smaskStack.push({canvas:u.canvas,context:d,offsetX:a,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(a,o),t.save()),It(t,d),this.ctx=d,this.setGState([[`BM`,`source-over`],[`ca`,1],[`CA`,1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;let t=this.ctx;if(this.ctx=this.groupStack.pop(),this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let e=H(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...e);let n=R.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],e);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(e,t,n,r,i){if(this.#e(),Lt(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){let r=t[2]-t[0],a=t[3]-t[1];if(i&&this.annotationCanvasMap){n=n.slice(),n[4]-=t[0],n[5]-=t[1],t=t.slice(),t[0]=t[1]=0,t[2]=r,t[3]=a;let[i,o]=R.singularValueDecompose2dScale(H(this.ctx)),{viewportScale:s}=this,c=Math.ceil(r*this.outputScaleX*s),l=Math.ceil(a*this.outputScaleY*s);this.annotationCanvas=this.canvasFactory.create(c,l);let{canvas:u,context:d}=this.annotationCanvas;this.annotationCanvasMap.set(e,u),this.annotationCanvas.savedCtx=this.ctx,this.ctx=d,this.ctx.save(),this.ctx.setTransform(i,0,0,-o,0,a*o),Lt(this.ctx)}else Lt(this.ctx),this.endPath(),this.ctx.rect(t[0],t[1],r,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new Nt(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#t(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;let t=e.count;e=this.getObject(e.data,e),e.count=t;let n=this.ctx,r=this.processingType3;if(r&&(r.compiled===void 0&&(r.compiled=Mt(e)),r.compiled)){r.compiled(n);return}let i=this._createMaskCanvas(e),a=i.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(a,i.offsetX,i.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,n=0,r=0,i,a){if(!this.contentVisible)return;e=this.getObject(e.data,e);let o=this.ctx;o.save();let s=H(o);o.transform(t,n,r,i,0,0);let c=this._createMaskCanvas(e);o.setTransform(1,0,0,1,c.offsetX-s[4],c.offsetY-s[5]);for(let e=0,l=a.length;e<l;e+=2){let l=R.transform(s,[t,n,r,i,a[e],a[e+1]]),[u,d]=R.applyTransform([0,0],l);o.drawImage(c.canvas,u,d)}o.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;let t=this.ctx,n=this.current.fillColor,r=this.current.patternFill;for(let i of e){let{data:e,width:a,height:o,transform:s}=i,c=this.cachedCanvases.getCanvas(`maskCanvas`,a,o),l=c.context;l.save(),Ft(l,this.getObject(e,i)),l.globalCompositeOperation=`source-in`,l.fillStyle=r?n.getPattern(l,this,U(t),Y.FILL):n,l.fillRect(0,0,a,o),l.restore(),t.save(),t.transform(...s),t.scale(1,-1),jt(t,c.canvas,0,0,a,o,0,-1,1,1),t.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;let t=this.getObject(e);if(!t){T(`Dependent image isn't ready yet`);return}this.paintInlineImageXObject(t)}paintImageXObjectRepeat(e,t,n,r){if(!this.contentVisible)return;let i=this.getObject(e);if(!i){T(`Dependent image isn't ready yet`);return}let a=i.width,o=i.height,s=[];for(let e=0,i=r.length;e<i;e+=2)s.push({transform:[t,0,0,n,r[e],r[e+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(i,s)}applyTransferMapsToCanvas(e){return this.current.transferMaps!==`none`&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter=`none`),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps===`none`)return e.bitmap;let{bitmap:t,width:n,height:r}=e,i=this.cachedCanvases.getCanvas(`inlineImage`,n,r),a=i.context;return a.filter=this.current.transferMaps,a.drawImage(t,0,0),a.filter=`none`,i.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;let t=e.width,n=e.height,i=this.ctx;if(this.save(),!r){let{filter:e}=i;e!==`none`&&e!==``&&(i.filter=`none`)}i.scale(1/t,-1/n);let a;if(e.bitmap)a=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement==`function`&&e instanceof HTMLElement||!e.data)a=e;else{let r=this.cachedCanvases.getCanvas(`inlineImage`,t,n).context;Pt(r,e),a=this.applyTransferMapsToCanvas(r)}let o=this._scaleImage(a,U(i));i.imageSmoothingEnabled=Rt(H(i),e.interpolate),jt(i,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,t,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(e,t){if(!this.contentVisible)return;let n=this.ctx,r;if(e.bitmap)r=e.bitmap;else{let t=e.width,n=e.height,i=this.cachedCanvases.getCanvas(`inlineImage`,t,n).context;Pt(i,e),r=this.applyTransferMapsToCanvas(i)}for(let e of t)n.save(),n.transform(...e.transform),n.scale(1,-1),jt(n,r,e.x,e.y,e.w,e.h,0,-1,1,1),n.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){e===`OC`?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){let t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);let n=this.ctx;this.pendingClip&&=(t||(this.pendingClip===Ht?n.clip(`evenodd`):n.clip()),null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let e=H(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{let t=Math.abs(e[0]*e[3]-e[2]*e[1]),n=Math.hypot(e[0],e[2]),r=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(n,r)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:e}=this.current,{a:t,b:n,c:r,d:i}=this.ctx.getTransform(),a,o;if(n===0&&r===0){let n=Math.abs(t),r=Math.abs(i);if(n===r)if(e===0)a=o=1/n;else{let t=n*e;a=o=t<1?1/t:1}else if(e===0)a=1/n,o=1/r;else{let t=n*e,i=r*e;a=t<1?1/t:1,o=i<1?1/i:1}}else{let s=Math.abs(t*i-n*r),c=Math.hypot(t,n),l=Math.hypot(r,i);if(e===0)a=l/s,o=c/s;else{let t=e*s;a=l>t?l/t:1,o=c>t?c/t:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(e){let{ctx:t}=this,{lineWidth:n}=this.current,[r,i]=this.getScaleForStroking();if(t.lineWidth=n||1,r===1&&i===1){t.stroke();return}let a=t.getLineDash();if(e&&t.save(),t.scale(r,i),a.length>0){let e=Math.max(r,i);t.setLineDash(a.map(t=>t/e)),t.lineDashOffset/=e}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};for(let e in y)Ut.prototype[e]!==void 0&&(Ut.prototype[y[e]]=Ut.prototype[e]);var Wt=class{static#e=null;static#t=``;static get workerPort(){return this.#e}static set workerPort(e){if(!(typeof Worker<`u`&&e instanceof Worker)&&e!==null)throw Error("Invalid `workerPort` type.");this.#e=e}static get workerSrc(){return this.#t}static set workerSrc(e){if(typeof e!=`string`)throw Error("Invalid `workerSrc` type.");this.#t=e}},Gt=class{#e;#t;constructor({parsedData:e,rawData:t}){this.#e=e,this.#t=t}getRaw(){return this.#t}get(e){return this.#e.get(e)??null}getAll(){return ae(this.#e)}has(e){return this.#e.has(e)}},Kt=Symbol(`INTERNAL`),qt=class{#e=!1;#t=!1;#n=!1;#r=!0;constructor(e,{name:t,intent:n,usage:r,rbGroups:i}){this.#e=!!(e&c.DISPLAY),this.#t=!!(e&c.PRINT),this.name=t,this.intent=n,this.usage=r,this.rbGroups=i}get visible(){if(this.#n)return this.#r;if(!this.#r)return!1;let{print:e,view:t}=this.usage;return this.#e?t?.viewState!==`OFF`:this.#t?e?.printState!==`OFF`:!0}_setVisible(e,t,n=!1){e!==Kt&&E("Internal method `_setVisible` called."),this.#n=n,this.#r=t}},Jt=class{#e=null;#t=new Map;#n=null;#r=null;constructor(e,t=c.DISPLAY){if(this.renderingIntent=t,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,this.#r=e.order;for(let n of e.groups)this.#t.set(n.id,new qt(t,n));if(e.baseState===`OFF`)for(let e of this.#t.values())e._setVisible(Kt,!1);for(let t of e.on)this.#t.get(t)._setVisible(Kt,!0);for(let t of e.off)this.#t.get(t)._setVisible(Kt,!1);this.#n=this.getHash()}}#i(e){let t=e.length;if(t<2)return!0;let n=e[0];for(let r=1;r<t;r++){let t=e[r],i;if(Array.isArray(t))i=this.#i(t);else if(this.#t.has(t))i=this.#t.get(t).visible;else return T(`Optional content group not found: ${t}`),!0;switch(n){case`And`:if(!i)return!1;break;case`Or`:if(i)return!0;break;case`Not`:return!i;default:return!0}}return n===`And`}isVisible(e){if(this.#t.size===0)return!0;if(!e)return w(`Optional content group not defined.`),!0;if(e.type===`OCG`)return this.#t.has(e.id)?this.#t.get(e.id).visible:(T(`Optional content group not found: ${e.id}`),!0);if(e.type===`OCMD`){if(e.expression)return this.#i(e.expression);if(!e.policy||e.policy===`AnyOn`){for(let t of e.ids){if(!this.#t.has(t))return T(`Optional content group not found: ${t}`),!0;if(this.#t.get(t).visible)return!0}return!1}else if(e.policy===`AllOn`){for(let t of e.ids){if(!this.#t.has(t))return T(`Optional content group not found: ${t}`),!0;if(!this.#t.get(t).visible)return!1}return!0}else if(e.policy===`AnyOff`){for(let t of e.ids){if(!this.#t.has(t))return T(`Optional content group not found: ${t}`),!0;if(!this.#t.get(t).visible)return!0}return!1}else if(e.policy===`AllOff`){for(let t of e.ids){if(!this.#t.has(t))return T(`Optional content group not found: ${t}`),!0;if(this.#t.get(t).visible)return!1}return!0}return T(`Unknown optional content policy ${e.policy}.`),!0}return T(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,n=!0){let r=this.#t.get(e);if(!r){T(`Optional content group not found: ${e}`);return}if(n&&t&&r.rbGroups.length)for(let t of r.rbGroups)for(let n of t)n!==e&&this.#t.get(n)?._setVisible(Kt,!1,!0);r._setVisible(Kt,!!t,!0),this.#e=null}setOCGState({state:e,preserveRB:t}){let n;for(let r of e){switch(r){case`ON`:case`OFF`:case`Toggle`:n=r;continue}let e=this.#t.get(r);if(e)switch(n){case`ON`:this.setVisibility(r,!0,t);break;case`OFF`:this.setVisibility(r,!1,t);break;case`Toggle`:this.setVisibility(r,!e.visible,t);break}}this.#e=null}get hasInitialVisibility(){return this.#n===null||this.getHash()===this.#n}getOrder(){return this.#t.size?this.#r?this.#r.slice():[...this.#t.keys()]:null}getGroups(){return this.#t.size>0?ae(this.#t):null}getGroup(e){return this.#t.get(e)||null}getHash(){if(this.#e!==null)return this.#e;let e=new Ge;for(let[t,n]of this.#t)e.update(`${t}:${n.visible}`);return this.#e=e.hexdigest()}},Yt=class{constructor(e,{disableRange:t=!1,disableStream:n=!1}){D(e,`PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.`);let{length:r,initialData:i,progressiveDone:a,contentDispositionFilename:o}=e;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=o,i?.length>0){let e=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!n,this._isRangeSupported=!t,this._contentLength=r,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener((e,t)=>{this._onReceiveData({begin:e,chunk:t})}),e.addProgressListener((e,t)=>{this._onProgress({loaded:e,total:t})}),e.addProgressiveReadListener(e=>{this._onReceiveData({chunk:e})}),e.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),e.transportReady()}_onReceiveData({begin:e,chunk:t}){let n=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;e===void 0?this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n):D(this._rangeReaders.some(function(t){return t._begin===e?(t._enqueue(n),!0):!1}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(e){e.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:e.loaded}):this._fullRequestReader?.onProgress?.({loaded:e.loaded,total:e.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){let t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){D(!this._fullRequestReader,`PDFDataTransportStream.getFullReader can only be called once.`);let e=this._queuedChunks;return this._queuedChunks=null,new Xt(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new Zt(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeReaders.slice(0))t.cancel(e);this._pdfDataRangeTransport.abort()}},Xt=class{constructor(e,t,n=!1,r=null){this._stream=e,this._done=n||!1,this._filename=xe(r)?r:null,this._queuedChunks=t||[],this._loaded=0;for(let e of this._queuedChunks)this._loaded+=e.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||=!0}},Zt=class{constructor(e,t,n){this._stream=e,this._begin=t,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length===0)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}};function Qt(e){let t=!0,n=r(`filename\\*`,`i`).exec(e);if(n){n=n[1];let e=s(n);return e=unescape(e),e=c(e),e=l(e),a(e)}if(n=o(e),n)return a(l(n));if(n=r(`filename`,`i`).exec(e),n){n=n[1];let e=s(n);return e=l(e),a(e)}function r(e,t){return RegExp(`(?:^|;)\\s*`+e+`\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)`,t)}function i(e,n){if(e){if(!/^[\x00-\xFF]+$/.test(n))return n;try{let r=new TextDecoder(e,{fatal:!0}),i=re(n);n=r.decode(i),t=!1}catch{}}return n}function a(e){return t&&/[\x80-\xff]/.test(e)&&(e=i(`utf-8`,e),t&&(e=i(`iso-8859-1`,e))),e}function o(e){let t=[],n,i=r(`filename\\*((?!0\\d)\\d+)(\\*?)`,`ig`);for(;(n=i.exec(e))!==null;){let[,e,r,i]=n;if(e=parseInt(e,10),e in t){if(e===0)break;continue}t[e]=[r,i]}let a=[];for(let e=0;e<t.length&&e in t;++e){let[n,r]=t[e];r=s(r),n&&(r=unescape(r),e===0&&(r=c(r))),a.push(r)}return a.join(``)}function s(e){if(e.startsWith(`"`)){let t=e.slice(1).split(`\\"`);for(let e=0;e<t.length;++e){let n=t[e].indexOf(`"`);n!==-1&&(t[e]=t[e].slice(0,n),t.length=e+1),t[e]=t[e].replaceAll(/\\(.)/g,`$1`)}e=t.join(`"`)}return e}function c(e){let t=e.indexOf(`'`);return t===-1?e:i(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,``))}function l(e){return!e.startsWith(`=?`)||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(e,t,n,r){if(n===`q`||n===`Q`)return r=r.replaceAll(`_`,` `),r=r.replaceAll(/=([0-9a-fA-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}),i(t,r);try{r=atob(r)}catch{}return i(t,r)})}return``}function $t(e,t){let n=new Headers;if(!e||!t||typeof t!=`object`)return n;for(let e in t){let r=t[e];r!==void 0&&n.append(e,r)}return n}function en(e){try{return new URL(e).origin}catch{}return null}function tn({responseHeaders:e,isHttp:t,rangeChunkSize:n,disableRange:r}){let i={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(e.get(`Content-Length`),10);return!Number.isInteger(a)||(i.suggestedLength=a,a<=2*n)||r||!t||e.get(`Accept-Ranges`)!==`bytes`||(e.get(`Content-Encoding`)||`identity`)!==`identity`||(i.allowRangeRequests=!0),i}function nn(e){let t=e.get(`Content-Disposition`);if(t){let e=Qt(t);if(e.includes(`%`))try{e=decodeURIComponent(e)}catch{}if(xe(e))return e}return null}function rn(e,t){return e===404||e===0&&t.startsWith(`file:`)?new F(`Missing PDF "`+t+`".`):new ee(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)}function an(e){return e===200||e===206}function on(e,t,n){return{method:`GET`,headers:e,signal:n.signal,mode:`cors`,credentials:t?`include`:`same-origin`,redirect:`follow`}}function sn(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:(T(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}var cn=class{_responseOrigin=null;constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=$t(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return D(!this._fullRequestReader,`PDFFetchStream.getFullReader can only be called once.`),this._fullRequestReader=new ln(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new un(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},ln=class{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;let t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange;let n=new Headers(e.headers),r=t.url;fetch(r,on(n,this._withCredentials,this._abortController)).then(t=>{if(e._responseOrigin=en(t.url),!an(t.status))throw rn(t.status,r);this._reader=t.body.getReader(),this._headersCapability.resolve();let n=t.headers,{allowRangeRequests:i,suggestedLength:a}=tn({responseHeaders:n,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=a||this._contentLength,this._filename=nn(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new I(`Streaming is disabled.`))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;let{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:sn(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}},un=class{constructor(e,t,n){this._stream=e,this._reader=null,this._loaded=0;let r=e.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;let i=new Headers(e.headers);i.append(`Range`,`bytes=${t}-${n-1}`);let a=r.url;fetch(a,on(i,this._withCredentials,this._abortController)).then(t=>{let n=en(t.url);if(n!==e._responseOrigin)throw Error(`Expected range response-origin "${n}" to match "${e._responseOrigin}".`);if(!an(t.status))throw rn(t.status,a);this._readCapability.resolve(),this._reader=t.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded}),{value:sn(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}},dn=200,fn=206;function pn(e){let t=e.response;return typeof t==`string`?re(t).buffer:t}var mn=class{_responseOrigin=null;constructor({url:e,httpHeaders:t,withCredentials:n}){this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=$t(this.isHttp,t),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){let t=new XMLHttpRequest,n=this.currXhrId++,r=this.pendingRequests[n]={xhr:t};t.open(`GET`,this.url),t.withCredentials=this.withCredentials;for(let[e,n]of this.headers)t.setRequestHeader(e,n);return this.isHttp&&`begin`in e&&`end`in e?(t.setRequestHeader(`Range`,`bytes=${e.begin}-${e.end-1}`),r.expectedStatus=fn):r.expectedStatus=dn,t.responseType=`arraybuffer`,D(e.onError,"Expected `onError` callback to be provided."),t.onerror=()=>{e.onError(t.status)},t.onreadystatechange=this.onStateChange.bind(this,n),t.onprogress=this.onProgress.bind(this,n),r.onHeadersReceived=e.onHeadersReceived,r.onDone=e.onDone,r.onError=e.onError,r.onProgress=e.onProgress,t.send(null),n}onProgress(e,t){let n=this.pendingRequests[e];n&&n.onProgress?.(t)}onStateChange(e,t){let n=this.pendingRequests[e];if(!n)return;let r=n.xhr;if(r.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),r.readyState!==4||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],r.status===0&&this.isHttp){n.onError(r.status);return}let i=r.status||dn;if(!(i===dn&&n.expectedStatus===fn)&&i!==n.expectedStatus){n.onError(r.status);return}let a=pn(r);if(i===fn){let e=r.getResponseHeader(`Content-Range`),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);t?n.onDone({begin:parseInt(t[1],10),chunk:a}):(T(`Missing or invalid "Content-Range" header.`),n.onError(0))}else a?n.onDone({begin:0,chunk:a}):n.onError(r.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){let t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}},hn=class{constructor(e){this._source=e,this._manager=new mn(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){let t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return D(!this._fullRequestReader,`PDFNetworkStream.getFullReader can only be called once.`),this._fullRequestReader=new gn(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){let n=new _n(this._manager,e,t);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},gn=class{constructor(e,t){this._manager=e,this._url=t.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let e=this._fullRequestId,t=this._manager.getRequestXhr(e);this._manager._responseOrigin=en(t.responseURL);let n=t.getAllResponseHeaders(),r=new Headers(n?n.trimStart().replace(/[^\S ]+$/,``).split(/[\r\n]+/).map(e=>{let[t,...n]=e.split(`: `);return[t,n.join(`: `)]}):[]),{allowRangeRequests:i,suggestedLength:a}=tn({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=nn(r),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=rn(e,this._url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e);for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}},_n=class{constructor(e,t,n){this._manager=e,this._url=e.url,this._requestId=e.request({begin:t,end:n,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let e=en(this._manager.getRequestXhr(this._requestId)?.responseURL);e!==this._manager._responseOrigin&&(this._storedError=Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(e){let t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError??=rn(e,this._url);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){this.isStreamingSupported||this.onProgress?.({loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}},vn=/^[a-z][a-z0-9\-+.]+:/i;function yn(e){if(vn.test(e))return new URL(e);let t=process.getBuiltinModule(`url`);return new URL(t.pathToFileURL(e))}var bn=class{constructor(e){this.source=e,this.url=yn(e.url),D(this.url.protocol===`file:`,`PDFNodeStream only supports file:// URLs.`),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return D(!this._fullRequestReader,`PDFNodeStream.getFullReader can only be called once.`),this._fullRequestReader=new xn(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new Sn(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},xn=class{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;let t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();let n=process.getBuiltinModule(`fs`);n.promises.lstat(this._url).then(e=>{this._contentLength=e.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()},e=>{e.code===`ENOENT`&&(e=new F(`Missing PDF "${this._url}".`)),this._storedError=e,this._headersCapability.reject(e)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on(`readable`,()=>{this._readCapability.resolve()}),e.on(`end`,()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on(`error`,e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new I(`streaming is disabled`)),this._storedError&&this._readableStream.destroy(this._storedError)}},Sn=class{constructor(e,t,n){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!e.source.disableStream;let r=process.getBuiltinModule(`fs`);this._setReadableStream(r.createReadStream(this._url,{start:t,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on(`readable`,()=>{this._readCapability.resolve()}),e.on(`end`,()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on(`error`,e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}},Cn=1e5,Z=30,wn=.8,Tn=class e{#e=Promise.withResolvers();#t=null;#n=!1;#r=!!globalThis.FontInspector?.enabled;#i=null;#a=null;#o=0;#s=0;#c=null;#l=null;#u=0;#d=0;#f=Object.create(null);#p=[];#m=null;#h=[];#g=new WeakMap;#_=null;static#v=new Map;static#y=new Map;static#b=new WeakMap;static#x=null;static#S=new Set;constructor({textContentSource:t,container:n,viewport:r}){if(t instanceof ReadableStream)this.#m=t;else if(typeof t==`object`)this.#m=new ReadableStream({start(e){e.enqueue(t),e.close()}});else throw Error(`No "textContentSource" parameter specified.`);this.#t=this.#l=n,this.#d=r.scale*(globalThis.devicePixelRatio||1),this.#u=r.rotation,this.#a={div:null,properties:null,ctx:null};let{pageWidth:i,pageHeight:a,pageX:o,pageY:s}=r.rawDims;this.#_=[1,0,0,-1,-o,s+a],this.#s=i,this.#o=a,e.#O(),Ae(n,r),this.#e.promise.finally(()=>{e.#S.delete(this),this.#a=null,this.#f=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:e,isFirefox:t}=L.platform;return A(this,`fontFamilyMap`,new Map([[`sans-serif`,`${e&&t?`Calibri, `:``}sans-serif`],[`monospace`,`${e&&t?`Lucida Console, `:``}monospace`]]))}render(){let t=()=>{this.#c.read().then(({value:e,done:n})=>{if(n){this.#e.resolve();return}this.#i??=e.lang,Object.assign(this.#f,e.styles),this.#C(e.items),t()},this.#e.reject)};return this.#c=this.#m.getReader(),e.#S.add(this),t(),this.#e.promise}update({viewport:t,onBefore:n=null}){let r=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==this.#u&&(n?.(),this.#u=i,Ae(this.#l,{rotation:i})),r!==this.#d){n?.(),this.#d=r;let t={div:null,properties:null,ctx:e.#E(this.#i)};for(let e of this.#h)t.properties=this.#g.get(e),t.div=e,this.#T(t)}}cancel(){let e=new I(`TextLayer task cancelled.`);this.#c?.cancel(e).catch(()=>{}),this.#c=null,this.#e.reject(e)}get textDivs(){return this.#h}get textContentItemsStr(){return this.#p}#C(t){if(this.#n)return;this.#a.ctx??=e.#E(this.#i);let n=this.#h,r=this.#p;for(let e of t){if(n.length>Cn){T(`Ignoring additional textDivs for performance reasons.`),this.#n=!0;return}if(e.str===void 0){if(e.type===`beginMarkedContentProps`||e.type===`beginMarkedContent`){let t=this.#t;this.#t=document.createElement(`span`),this.#t.classList.add(`markedContent`),e.id!==null&&this.#t.setAttribute(`id`,`${e.id}`),t.append(this.#t)}else e.type===`endMarkedContent`&&(this.#t=this.#t.parentNode);continue}r.push(e.str),this.#w(e)}}#w(t){let n=document.createElement(`span`),r={angle:0,canvasWidth:0,hasText:t.str!==``,hasEOL:t.hasEOL,fontSize:0};this.#h.push(n);let i=R.transform(this.#_,t.transform),a=Math.atan2(i[1],i[0]),o=this.#f[t.fontName];o.vertical&&(a+=Math.PI/2);let s=this.#r&&o.fontSubstitution||o.fontFamily;s=e.fontFamilyMap.get(s)||s;let c=Math.hypot(i[2],i[3]),l=c*e.#k(s,this.#i),u,d;a===0?(u=i[4],d=i[5]-l):(u=i[4]+l*Math.sin(a),d=i[5]-l*Math.cos(a));let f=`calc(var(--scale-factor)*`,p=n.style;this.#t===this.#l?(p.left=`${(100*u/this.#s).toFixed(2)}%`,p.top=`${(100*d/this.#o).toFixed(2)}%`):(p.left=`${f}${u.toFixed(2)}px)`,p.top=`${f}${d.toFixed(2)}px)`),p.fontSize=`${f}${(e.#x*c).toFixed(2)}px)`,p.fontFamily=s,r.fontSize=c,n.setAttribute(`role`,`presentation`),n.textContent=t.str,n.dir=t.dir,this.#r&&(n.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),a!==0&&(r.angle=180/Math.PI*a);let m=!1;if(t.str.length>1)m=!0;else if(t.str!==` `&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),n=Math.abs(t.transform[3]);e!==n&&Math.max(e,n)/Math.min(e,n)>1.5&&(m=!0)}if(m&&(r.canvasWidth=o.vertical?t.height:t.width),this.#g.set(n,r),this.#a.div=n,this.#a.properties=r,this.#T(this.#a),r.hasText&&this.#t.append(n),r.hasEOL){let e=document.createElement(`br`);e.setAttribute(`role`,`presentation`),this.#t.append(e)}}#T(t){let{div:n,properties:r,ctx:i}=t,{style:a}=n,o=``;if(e.#x>1&&(o=`scale(${1/e.#x})`),r.canvasWidth!==0&&r.hasText){let{fontFamily:t}=a,{canvasWidth:s,fontSize:c}=r;e.#D(i,c*this.#d,t);let{width:l}=i.measureText(n.textContent);l>0&&(o=`scaleX(${s*this.#d/l}) ${o}`)}r.angle!==0&&(o=`rotate(${r.angle}deg) ${o}`),o.length>0&&(a.transform=o)}static cleanup(){if(!(this.#S.size>0)){this.#v.clear();for(let{canvas:e}of this.#y.values())e.remove();this.#y.clear()}}static#E(e=null){let t=this.#y.get(e||=``);if(!t){let n=document.createElement(`canvas`);n.className=`hiddenCanvasElement`,n.lang=e,document.body.append(n),t=n.getContext(`2d`,{alpha:!1,willReadFrequently:!0}),this.#y.set(e,t),this.#b.set(t,{size:0,family:``})}return t}static#D(e,t,n){let r=this.#b.get(e);t===r.size&&n===r.family||(e.font=`${t}px ${n}`,r.size=t,r.family=n)}static#O(){if(this.#x!==null)return;let e=document.createElement(`div`);e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize=`1px`,e.style.position=`absolute`,e.textContent=`X`,document.body.append(e),this.#x=e.getBoundingClientRect().height,e.remove()}static#k(e,t){let n=this.#v.get(e);if(n)return n;let r=this.#E(t);r.canvas.width=r.canvas.height=Z,this.#D(r,Z,e);let i=r.measureText(``),a=i.fontBoundingBoxAscent,o=Math.abs(i.fontBoundingBoxDescent);if(a){let t=a/(a+o);return this.#v.set(e,t),r.canvas.width=r.canvas.height=0,t}r.strokeStyle=`red`,r.clearRect(0,0,Z,Z),r.strokeText(`g`,0,0);let s=r.getImageData(0,0,Z,Z).data;o=0;for(let e=s.length-1-3;e>=0;e-=4)if(s[e]>0){o=Math.ceil(e/4/Z);break}r.clearRect(0,0,Z,Z),r.strokeText(`A`,0,Z),s=r.getImageData(0,0,Z,Z).data,a=0;for(let e=0,t=s.length;e<t;e+=4)if(s[e]>0){a=Z-Math.floor(e/4/Z);break}r.canvas.width=r.canvas.height=0;let c=a?a/(a+o):wn;return this.#v.set(e,c),c}},En=class e{static textContent(t){let n=[],r={items:n,styles:Object.create(null)};function i(t){if(!t)return;let r=null,a=t.name;if(a===`#text`)r=t.value;else if(e.shouldBuildText(a))t?.attributes?.textContent?r=t.attributes.textContent:t.value&&(r=t.value);else return;if(r!==null&&n.push({str:r}),t.children)for(let e of t.children)i(e)}return i(t),r}static shouldBuildText(e){return!(e===`textarea`||e===`input`||e===`option`||e===`select`)}},Dn=65536,On=100,kn=5e3,An=r?ut:tt,jn=r?dt:rt,Mn=r?lt:at,Nn=r?ft:st;function Pn(e={}){typeof e==`string`||e instanceof URL?e={url:e}:(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t=new Rn,{docId:n}=t,i=e.url?Fn(e.url):null,a=e.data?In(e.data):null,o=e.httpHeaders||null,s=e.withCredentials===!0,c=e.password??null,l=e.range instanceof zn?e.range:null,u=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:Dn,d=e.worker instanceof Un?e.worker:null,f=e.verbosity,p=typeof e.docBaseUrl==`string`&&!be(e.docBaseUrl)?e.docBaseUrl:null,m=typeof e.cMapUrl==`string`?e.cMapUrl:null,h=e.cMapPacked!==!1,g=e.CMapReaderFactory||jn,_=typeof e.standardFontDataUrl==`string`?e.standardFontDataUrl:null,v=e.StandardFontDataFactory||Nn,y=e.stopAtErrors!==!0,b=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,x=e.isEvalSupported!==!1,C=typeof e.isOffscreenCanvasSupported==`boolean`?e.isOffscreenCanvasSupported:!r,w=typeof e.isImageDecoderSupported==`boolean`?e.isImageDecoderSupported:!r&&(L.platform.isFirefox||!globalThis.chrome),T=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,E=typeof e.disableFontFace==`boolean`?e.disableFontFace:r,D=e.fontExtraProperties===!0,O=e.enableXfa===!0,k=e.ownerDocument||globalThis.document,A=e.disableRange===!0,j=e.disableStream===!0,M=e.disableAutoFetch===!0,N=e.pdfBug===!0,P=e.CanvasFactory||An,F=e.FilterFactory||Mn,ee=e.enableHWA===!0,te=l?l.length:e.length??NaN,I=typeof e.useSystemFonts==`boolean`?e.useSystemFonts:!r&&!E,ne=typeof e.useWorkerFetch==`boolean`?e.useWorkerFetch:g===rt&&v===st&&m&&_&&Te(m,document.baseURI)&&Te(_,document.baseURI);S(f);let re={canvasFactory:new P({ownerDocument:k,enableHWA:ee}),filterFactory:new F({docId:n,ownerDocument:k}),cMapReaderFactory:ne?null:new g({baseUrl:m,isCompressed:h}),standardFontDataFactory:ne?null:new v({baseUrl:_})};if(!d){let e={verbosity:f,port:Wt.workerPort};d=e.port?Un.fromPort(e):new Un(e),t._worker=d}let ie={docId:n,apiVersion:`4.10.38`,data:a,password:c,disableAutoFetch:M,rangeChunkSize:u,length:te,docBaseUrl:p,enableXfa:O,evaluatorOptions:{maxImageSize:b,disableFontFace:E,ignoreErrors:y,isEvalSupported:x,isOffscreenCanvasSupported:C,isImageDecoderSupported:w,canvasMaxAreaInBytes:T,fontExtraProperties:D,useSystemFonts:I,cMapUrl:ne?m:null,standardFontDataUrl:ne?_:null}},ae={disableFontFace:E,fontExtraProperties:D,ownerDocument:k,pdfBug:N,styleElement:null,loadingParams:{disableAutoFetch:M,enableXfa:O}};return d.promise.then(function(){if(t.destroyed)throw Error(`Loading aborted`);if(d.destroyed)throw Error(`Worker was destroyed`);let e=d.messageHandler.sendWithPromise(`GetDocRequest`,ie,a?[a.buffer]:null),c;if(l)c=new Yt(l,{disableRange:A,disableStream:j});else if(!a){if(!i)throw Error("getDocument - no `url` parameter provided.");let e;if(r)if(Te(i)){if(typeof fetch>`u`||typeof Response>`u`||!(`body`in Response.prototype))throw Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");e=cn}else e=bn;else e=Te(i)?cn:hn;c=new e({url:i,length:te,httpHeaders:o,withCredentials:s,rangeChunkSize:u,disableRange:A,disableStream:j})}return e.then(e=>{if(t.destroyed)throw Error(`Loading aborted`);if(d.destroyed)throw Error(`Worker was destroyed`);let r=new $e(n,e,d.port);t._transport=new Wn(r,t,c,ae,re),r.send(`Ready`,null)})}).catch(t._capability.reject),t}function Fn(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch{if(r&&typeof e==`string`)return e}throw Error(`Invalid PDF url data: either string or URL-object is expected in the url property.`)}function In(e){if(r&&typeof Buffer<`u`&&e instanceof Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if(typeof e==`string`)return re(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e==`object`&&!isNaN(e?.length))return new Uint8Array(e);throw Error(`Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.`)}function Ln(e){return typeof e==`object`&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0}var Rn=class e{static#e=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${e.#e++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(e){throw this._worker?.port&&delete this._worker._pendingDestroy,e}this._transport=null,this._worker?.destroy(),this._worker=null}},zn=class{constructor(e,t,n=!1,r=null){this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=r,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(let n of this._rangeListeners)n(e,t)}onDataProgress(e,t){this._readyCapability.promise.then(()=>{for(let n of this._progressListeners)n(e,t)})}onDataProgressiveRead(e){this._readyCapability.promise.then(()=>{for(let t of this._progressiveReadListeners)t(e)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let e of this._progressiveDoneListeners)e()})}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){E(`Abstract method PDFDataRangeTransport.requestDataRange`)}abort(){}},Bn=class{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return A(this,`isPureXfa`,!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e=`display`}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}},Vn=class{#e=null;#t=!1;constructor(e,t,n,r=!1){this._pageIndex=e,this._pageInfo=t,this._transport=n,this._stats=r?new we:null,this._pdfBug=r,this.commonObjs=n.commonObjs,this.objs=new Kn,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:n=0,offsetY:r=0,dontFlip:i=!1}={}){return new ve({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:r,dontFlip:i})}getAnnotations({intent:e=`display`}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return A(this,`isPureXfa`,!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,viewport:t,intent:n=`display`,annotationMode:r=l.ENABLE,transform:i=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:s=null,pageColors:u=null,printAnnotationStorage:d=null,isEditing:f=!1}){this._stats?.time(`Overall`);let p=this._transport.getRenderingIntent(n,r,d,f),{renderingIntent:m,cacheKey:h}=p;this.#t=!1,this.#r(),o||=this._transport.getOptionalContentConfig(m);let g=this._intentStates.get(h);g||(g=Object.create(null),this._intentStates.set(h,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);let _=!!(m&c.PRINT);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time(`Page Request`),this._pumpOperatorList(p));let v=e=>{g.renderTasks.delete(y),(this._maybeCleanupAfterRender||_)&&(this.#t=!0),this.#n(!_),e?(y.capability.reject(e),this._abortOperatorList({intentState:g,reason:e instanceof Error?e:Error(e)})):y.capability.resolve(),this._stats&&(this._stats.timeEnd(`Rendering`),this._stats.timeEnd(`Overall`),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},y=new Jn({callback:v,params:{canvasContext:e,viewport:t,transform:i,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:s,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!_,pdfBug:this._pdfBug,pageColors:u});(g.renderTasks||=new Set).add(y);let b=y.task;return Promise.all([g.displayReadyCapability.promise,o]).then(([e,t])=>{if(this.destroyed){v();return}if(this._stats?.time(`Rendering`),!(t.renderingIntent&m))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");y.initializeGraphics({transparency:e,optionalContentConfig:t}),y.operatorListChanged()}).catch(v),b}getOperatorList({intent:e=`display`,annotationMode:t=l.ENABLE,printAnnotationStorage:n=null,isEditing:r=!1}={}){function i(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(s))}let a=this._transport.getRenderingIntent(e,t,n,r,!0),o=this._intentStates.get(a.cacheKey);o||(o=Object.create(null),this._intentStates.set(a.cacheKey,o));let s;return o.opListReadCapability||(s=Object.create(null),s.operatorListChanged=i,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||=new Set).add(s),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time(`Page Request`),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream(`GetTextContent`,{pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:t===!0},{highWaterMark:100,size(e){return e.items.length}})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(e=>En.textContent(e));let t=this.streamTextContent(e);return new Promise(function(e,n){function r(){i.read().then(function({value:t,done:n}){if(n){e(a);return}a.lang??=t.lang,Object.assign(a.styles,t.styles),a.items.push(...t.items),r()},n)}let i=t.getReader(),a={items:[],styles:Object.create(null),lang:null};r()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let e=[];for(let t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:Error(`Page was destroyed.`),force:!0}),!t.opListReadCapability)for(let n of t.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),this.#t=!1,this.#r(),Promise.all(e)}cleanup(e=!1){this.#t=!0;let t=this.#n(!1);return e&&t&&(this._stats&&=new we),t}#n(e=!1){if(this.#r(),!this.#t||this.destroyed)return!1;if(e)return this.#e=setTimeout(()=>{this.#e=null,this.#n(!1)},kn),!1;for(let{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#t=!1,!0}#r(){this.#e&&=(clearTimeout(this.#e),null)}_startRenderPage(e,t){let n=this._intentStates.get(t);n&&(this._stats?.timeEnd(`Page Request`),n.displayReadyCapability?.resolve(e))}_renderPageChunk(e,t){for(let n=0,r=e.length;n<r;n++)t.operatorList.fnArray.push(e.fnArray[n]),t.operatorList.argsArray.push(e.argsArray[n]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(let e of t.renderTasks)e.operatorListChanged();e.lastChunk&&this.#n(!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:n,modifiedIds:r}){let{map:i,transfer:a}=n,o=this._transport.messageHandler.sendWithStream(`GetOperatorList`,{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:i,modifiedIds:r},a).getReader(),s=this._intentStates.get(t);s.streamReader=o;let c=()=>{o.read().then(({value:e,done:t})=>{if(t){s.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(e,s),c())},e=>{if(s.streamReader=null,!this._transport.destroyed){if(s.operatorList){s.operatorList.lastChunk=!0;for(let e of s.renderTasks)e.operatorListChanged();this.#n(!0)}if(s.displayReadyCapability)s.displayReadyCapability.reject(e);else if(s.opListReadCapability)s.opListReadCapability.reject(e);else throw e}})};c()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&=(clearTimeout(e.streamReaderCancelTimeout),null),!n){if(e.renderTasks.size>0)return;if(t instanceof ye){let n=On;t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},n);return}}if(e.streamReader.cancel(new I(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(let[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}},Hn=class{#e=new Map;#t=Promise.resolve();postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};this.#t.then(()=>{for(let[e]of this.#e)e.call(this,n)})}addEventListener(e,t,n=null){let r=null;if(n?.signal instanceof AbortSignal){let{signal:i}=n;if(i.aborted){T("LoopbackPort - cannot use an `aborted` signal.");return}let a=()=>this.removeEventListener(e,t);r=()=>i.removeEventListener(`abort`,a),i.addEventListener(`abort`,a)}this.#e.set(t,r)}removeEventListener(e,t){this.#e.get(t)?.(),this.#e.delete(t)}terminate(){for(let[,e]of this.#e)e?.();this.#e.clear()}},Un=class t{static#e=0;static#t=!1;static#n;static{r&&(this.#t=!0,Wt.workerSrc||=`./pdf.worker.mjs`),this._isSameOrigin=(e,t)=>{let n;try{if(n=new URL(e),!n.origin||n.origin===`null`)return!1}catch{return!1}let r=new URL(t,n);return n.origin===r.origin},this._createCDNWrapper=e=>{let t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:`text/javascript`}))}}constructor({name:e=null,port:n=null,verbosity:r=C()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=r,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,n){if(t.#n?.has(n))throw Error(`Cannot use more than one PDFWorker per port.`);(t.#n||=new WeakMap).set(n,this),this._initializeFromPort(n);return}this._initialize()}get promise(){return this._readyCapability.promise}#r(){this._readyCapability.resolve(),this._messageHandler.send(`configure`,{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new $e(`main`,`worker`,e),this._messageHandler.on(`ready`,function(){}),this.#r()}_initialize(){if(t.#t||t.#i){this._setupFakeWorker();return}let{workerSrc:e}=t;try{t._isSameOrigin(window.location.href,e)||(e=t._createCDNWrapper(new URL(e,window.location).href));let n=new Worker(e,{type:`module`}),r=new $e(`main`,`worker`,n),i=()=>{a.abort(),r.destroy(),n.terminate(),this.destroyed?this._readyCapability.reject(Error(`Worker was destroyed`)):this._setupFakeWorker()},a=new AbortController;n.addEventListener(`error`,()=>{this._webWorker||i()},{signal:a.signal}),r.on(`test`,e=>{if(a.abort(),this.destroyed||!e){i();return}this._messageHandler=r,this._port=n,this._webWorker=n,this.#r()}),r.on(`ready`,e=>{if(a.abort(),this.destroyed){i();return}try{o()}catch{this._setupFakeWorker()}});let o=()=>{let e=new Uint8Array;r.send(`test`,e,[e.buffer])};o();return}catch{w(`The worker has been disabled.`)}this._setupFakeWorker()}_setupFakeWorker(){t.#t||=(T(`Setting up fake worker.`),!0),t._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){this._readyCapability.reject(Error(`Worker was destroyed`));return}let n=new Hn;this._port=n;let r=`fake${t.#e++}`,i=new $e(r+`_worker`,r,n);e.setup(i,n),this._messageHandler=new $e(r,r+`_worker`,n),this.#r()}).catch(e=>{this._readyCapability.reject(Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,t.#n?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(e){if(!e?.port)throw Error(`PDFWorker.fromPort - invalid method signature.`);let n=this.#n?.get(e.port);if(n){if(n._pendingDestroy)throw Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return n}return new t(e)}static get workerSrc(){if(Wt.workerSrc)return Wt.workerSrc;throw Error(`No "GlobalWorkerOptions.workerSrc" specified.`)}static get#i(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return A(this,`_setupFakeWorkerGlobal`,(async()=>this.#i?this.#i:(await e(()=>import(this.workerSrc),[])).WorkerMessageHandler)())}},Wn=class{#e=new Map;#t=new Map;#n=new Map;#r=new Map;#i=null;constructor(e,t,n,r,i){this.messageHandler=e,this.loadingTask=t,this.commonObjs=new Kn,this.fontLoader=new Ye({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#a(e,t=null){let n=this.#e.get(e);if(n)return n;let r=this.messageHandler.sendWithPromise(e,t);return this.#e.set(e,r),r}get annotationStorage(){return A(this,`annotationStorage`,new qe)}getRenderingIntent(e,t=l.ENABLE,n=null,r=!1,i=!1){let a=c.DISPLAY,o=Ke;switch(e){case`any`:a=c.ANY;break;case`display`:break;case`print`:a=c.PRINT;break;default:T(`getRenderingIntent - invalid intent: ${e}`)}let s=a&c.PRINT&&n instanceof Je?n:this.annotationStorage;switch(t){case l.DISABLE:a+=c.ANNOTATIONS_DISABLE;break;case l.ENABLE:break;case l.ENABLE_FORMS:a+=c.ANNOTATIONS_FORMS;break;case l.ENABLE_STORAGE:a+=c.ANNOTATIONS_STORAGE,o=s.serializable;break;default:T(`getRenderingIntent - invalid annotationMode: ${t}`)}r&&(a+=c.IS_EDITING),i&&(a+=c.OPLIST);let{ids:u,hash:d}=s.modifiedIds,f=[a,o.hash,d];return{renderingIntent:a,cacheKey:f.join(`_`),annotationStorageSerializable:o,modifiedIds:u}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#i?.reject(Error(`Worker was destroyed during onPassword callback`));let e=[];for(let t of this.#t.values())e.push(t._destroy());this.#t.clear(),this.#n.clear(),this.#r.clear(),this.hasOwnProperty(`annotationStorage`)&&this.annotationStorage.resetModified();let t=this.messageHandler.sendWithPromise(`Terminate`,null);return e.push(t),Promise.all(e).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(),Tn.cleanup(),this._networkStream?.cancelAllRequests(new I(`Worker was terminated.`)),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:e,loadingTask:t}=this;e.on(`GetReader`,(e,t)=>{D(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}},t.onPull=()=>{this._fullReader.read().then(function({value:e,done:n}){if(n){t.close();return}D(e instanceof ArrayBuffer,`GetReader - expected an ArrayBuffer.`),t.enqueue(new Uint8Array(e),1,[e])}).catch(e=>{t.error(e)})},t.onCancel=e=>{this._fullReader.cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}}),e.on(`ReaderHeadersReady`,async e=>{await this._fullReader.headersReady;let{isStreamingSupported:n,isRangeSupported:r,contentLength:i}=this._fullReader;return(!n||!r)&&(this._lastProgress&&t.onProgress?.(this._lastProgress),this._fullReader.onProgress=e=>{t.onProgress?.({loaded:e.loaded,total:e.total})}),{isStreamingSupported:n,isRangeSupported:r,contentLength:i}}),e.on(`GetRangeReader`,(e,t)=>{D(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let n=this._networkStream.getRangeReader(e.begin,e.end);if(!n){t.close();return}t.onPull=()=>{n.read().then(function({value:e,done:n}){if(n){t.close();return}D(e instanceof ArrayBuffer,`GetRangeReader - expected an ArrayBuffer.`),t.enqueue(new Uint8Array(e),1,[e])}).catch(e=>{t.error(e)})},t.onCancel=e=>{n.cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}}),e.on(`GetDoc`,({pdfInfo:e})=>{this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,t._capability.resolve(new Bn(e,this))}),e.on(`DocException`,e=>{t._capability.reject(J(e))}),e.on(`PasswordRequest`,e=>{this.#i=Promise.withResolvers();try{if(!t.onPassword)throw J(e);t.onPassword(e=>{e instanceof Error?this.#i.reject(e):this.#i.resolve({password:e})},e.code)}catch(e){this.#i.reject(e)}return this.#i.promise}),e.on(`DataLoaded`,e=>{t.onProgress?.({loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)}),e.on(`StartRenderPage`,e=>{this.destroyed||this.#t.get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)}),e.on(`commonobj`,([t,n,r])=>{if(this.destroyed||this.commonObjs.has(t))return null;switch(n){case`Font`:let{disableFontFace:i,fontExtraProperties:a,pdfBug:o}=this._params;if(`error`in r){let e=r.error;T(`Error during font loading: ${e}`),this.commonObjs.resolve(t,e);break}let s=new Xe(r,{disableFontFace:i,fontExtraProperties:a,inspectFont:o&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null});this.fontLoader.bind(s).catch(()=>e.sendWithPromise(`FontFallback`,{id:t})).finally(()=>{!a&&s.data&&(s.data=null),this.commonObjs.resolve(t,s)});break;case`CopyLocalImage`:let{imageRef:c}=r;D(c,`The imageRef must be defined.`);for(let e of this.#t.values())for(let[,n]of e.objs)if(n?.ref===c)return n.dataLen?(this.commonObjs.resolve(t,structuredClone(n)),n.dataLen):null;break;case`FontPath`:case`Image`:case`Pattern`:this.commonObjs.resolve(t,r);break;default:throw Error(`Got unknown common object type ${n}`)}return null}),e.on(`obj`,([e,t,n,r])=>{if(this.destroyed)return;let i=this.#t.get(t);if(!i.objs.has(e)){if(i._intentStates.size===0){r?.bitmap?.close();return}switch(n){case`Image`:i.objs.resolve(e,r),r?.dataLen>o&&(i._maybeCleanupAfterRender=!0);break;case`Pattern`:i.objs.resolve(e,r);break;default:throw Error(`Got unknown object type ${n}`)}}}),e.on(`DocProgress`,e=>{this.destroyed||t.onProgress?.({loaded:e.loaded,total:e.total})}),e.on(`FetchBuiltInCMap`,async e=>{if(this.destroyed)throw Error(`Worker was destroyed.`);if(!this.cMapReaderFactory)throw Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(e)}),e.on(`FetchStandardFontData`,async e=>{if(this.destroyed)throw Error(`Worker was destroyed.`);if(!this.standardFontDataFactory)throw Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(e)})}getData(){return this.messageHandler.sendWithPromise(`GetData`,null)}saveDocument(){this.annotationStorage.size<=0&&T("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise(`SaveDocument`,{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:this._fullReader?.filename??null},t).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(Error(`Invalid page request.`));let t=e-1,n=this.#n.get(t);if(n)return n;let r=this.messageHandler.sendWithPromise(`GetPage`,{pageIndex:t}).then(n=>{if(this.destroyed)throw Error(`Transport destroyed`);n.refStr&&this.#r.set(n.refStr,e);let r=new Vn(t,n,this,this._params.pdfBug);return this.#t.set(t,r),r});return this.#n.set(t,r),r}getPageIndex(e){return Ln(e)?this.messageHandler.sendWithPromise(`GetPageIndex`,{num:e.num,gen:e.gen}):Promise.reject(Error(`Invalid pageIndex request.`))}getAnnotations(e,t){return this.messageHandler.sendWithPromise(`GetAnnotations`,{pageIndex:e,intent:t})}getFieldObjects(){return this.#a(`GetFieldObjects`)}hasJSActions(){return this.#a(`HasJSActions`)}getCalculationOrderIds(){return this.messageHandler.sendWithPromise(`GetCalculationOrderIds`,null)}getDestinations(){return this.messageHandler.sendWithPromise(`GetDestinations`,null)}getDestination(e){return typeof e==`string`?this.messageHandler.sendWithPromise(`GetDestination`,{id:e}):Promise.reject(Error(`Invalid destination request.`))}getPageLabels(){return this.messageHandler.sendWithPromise(`GetPageLabels`,null)}getPageLayout(){return this.messageHandler.sendWithPromise(`GetPageLayout`,null)}getPageMode(){return this.messageHandler.sendWithPromise(`GetPageMode`,null)}getViewerPreferences(){return this.messageHandler.sendWithPromise(`GetViewerPreferences`,null)}getOpenAction(){return this.messageHandler.sendWithPromise(`GetOpenAction`,null)}getAttachments(){return this.messageHandler.sendWithPromise(`GetAttachments`,null)}getDocJSActions(){return this.#a(`GetDocJSActions`)}getPageJSActions(e){return this.messageHandler.sendWithPromise(`GetPageJSActions`,{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise(`GetStructTree`,{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise(`GetOutline`,null)}getOptionalContentConfig(e){return this.#a(`GetOptionalContentConfig`).then(t=>new Jt(t,e))}getPermissions(){return this.messageHandler.sendWithPromise(`GetPermissions`,null)}getMetadata(){let e=`GetMetadata`,t=this.#e.get(e);if(t)return t;let n=this.messageHandler.sendWithPromise(e,null).then(e=>({info:e[0],metadata:e[1]?new Gt(e[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#e.set(e,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise(`GetMarkInfo`,null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise(`Cleanup`,null);for(let e of this.#t.values())if(!e.cleanup())throw Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(!0),Tn.cleanup()}}cachedPageNumber(e){if(!Ln(e))return null;let t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return this.#r.get(t)??null}},Gn=Symbol(`INITIAL_DATA`),Kn=class{#e=Object.create(null);#t(e){return this.#e[e]||={...Promise.withResolvers(),data:Gn}}get(e,t=null){if(t){let n=this.#t(e);return n.promise.then(()=>t(n.data)),null}let n=this.#e[e];if(!n||n.data===Gn)throw Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){let t=this.#e[e];return!!t&&t.data!==Gn}delete(e){let t=this.#e[e];return!t||t.data===Gn?!1:(delete this.#e[e],!0)}resolve(e,t=null){let n=this.#t(e);n.data=t,n.resolve()}clear(){for(let e in this.#e){let{data:t}=this.#e[e];t?.bitmap?.close()}this.#e=Object.create(null)}*[Symbol.iterator](){for(let e in this.#e){let{data:t}=this.#e[e];t!==Gn&&(yield[e,t])}}},qn=class{#e=null;constructor(e){this.#e=e,this.onContinue=null}get promise(){return this.#e.capability.promise}cancel(e=0){this.#e.cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=this.#e.operatorList;if(!e)return!1;let{annotationCanvasMap:t}=this.#e;return e.form||e.canvas&&t?.size>0}},Jn=class e{#e=null;static#t=new WeakSet;constructor({callback:e,params:t,objs:n,commonObjs:r,annotationCanvasMap:i,operatorList:a,pageIndex:o,canvasFactory:s,filterFactory:c,useRequestAnimationFrame:l=!1,pdfBug:u=!1,pageColors:d=null}){this.callback=e,this.params=t,this.objs=n,this.commonObjs=r,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=s,this.filterFactory=c,this._pdfBug=u,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=l===!0&&typeof window<`u`,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new qn(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:n}){if(this.cancelled)return;if(this._canvas){if(e.#t.has(this._canvas))throw Error(`Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.`);e.#t.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:r,viewport:i,transform:a,background:o}=this.params;this.gfx=new Ut(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:n},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:i,transparency:t,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,n=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#e&&=(window.cancelAnimationFrame(this.#e),null),e.#t.delete(this._canvas),this.callback(t||new ye(`Rendering cancelled, page ${this._pageIndex+1}`,n))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#e=window.requestAnimationFrame(()=>{this.#e=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),e.#t.delete(this._canvas),this.callback())))}},Yn=`4.10.38`,Xn=`f9bea397f`;function Zn(e){return Math.floor(Math.max(0,Math.min(1,e))*255).toString(16).padStart(2,`0`)}function Qn(e){return Math.max(0,Math.min(255,255*e))}var $n=class{static CMYK_G([e,t,n,r]){return[`G`,1-Math.min(1,.3*e+.59*n+.11*t+r)]}static G_CMYK([e]){return[`CMYK`,0,0,0,1-e]}static G_RGB([e]){return[`RGB`,e,e,e]}static G_rgb([e]){return e=Qn(e),[e,e,e]}static G_HTML([e]){let t=Zn(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return[`G`,.3*e+.59*t+.11*n]}static RGB_rgb(e){return e.map(Qn)}static RGB_HTML(e){return`#${e.map(Zn).join(``)}`}static T_HTML(){return`#00000000`}static T_rgb(){return[null]}static CMYK_RGB([e,t,n,r]){return[`RGB`,1-Math.min(1,e+r),1-Math.min(1,n+r),1-Math.min(1,t+r)]}static CMYK_rgb([e,t,n,r]){return[Qn(1-Math.min(1,e+r)),Qn(1-Math.min(1,n+r)),Qn(1-Math.min(1,t+r))]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){let r=1-e,i=1-t,a=1-n;return[`CMYK`,r,i,a,Math.min(r,i,a)]}},er=class{create(e,t,n=!1){if(e<=0||t<=0)throw Error(`Invalid SVG dimensions`);let r=this._createSVG(`svg:svg`);return r.setAttribute(`version`,`1.1`),n||(r.setAttribute(`width`,`${e}px`),r.setAttribute(`height`,`${t}px`)),r.setAttribute(`preserveAspectRatio`,`none`),r.setAttribute(`viewBox`,`0 0 ${e} ${t}`),r}createElement(e){if(typeof e!=`string`)throw Error(`Invalid SVG element type`);return this._createSVG(e)}_createSVG(e){E("Abstract method `_createSVG` called.")}},tr=class extends er{_createSVG(e){return document.createElementNS(z,e)}},nr=class{static setupStorage(e,t,n,r,i){let a=r.getValue(t,{value:null});switch(n.name){case`textarea`:if(a.value!==null&&(e.textContent=a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})});break;case`input`:if(n.attributes.type===`radio`||n.attributes.type===`checkbox`){if(a.value===n.attributes.xfaOn?e.setAttribute(`checked`,!0):a.value===n.attributes.xfaOff&&e.removeAttribute(`checked`),i===`print`)break;e.addEventListener(`change`,e=>{r.setValue(t,{value:e.target.checked?e.target.getAttribute(`xfaOn`):e.target.getAttribute(`xfaOff`)})})}else{if(a.value!==null&&e.setAttribute(`value`,a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})})}break;case`select`:if(a.value!==null){e.setAttribute(`value`,a.value);for(let e of n.children)e.attributes.value===a.value?e.attributes.selected=!0:e.attributes.hasOwnProperty(`selected`)&&delete e.attributes.selected}e.addEventListener(`input`,e=>{let n=e.target.options,i=n.selectedIndex===-1?``:n[n.selectedIndex].value;r.setValue(t,{value:i})});break}}static setAttributes({html:e,element:t,storage:n=null,intent:r,linkService:i}){let{attributes:a}=t,o=e instanceof HTMLAnchorElement;a.type===`radio`&&(a.name=`${a.name}-${r}`);for(let[t,n]of Object.entries(a))if(n!=null)switch(t){case`class`:n.length&&e.setAttribute(t,n.join(` `));break;case`dataId`:break;case`id`:e.setAttribute(`data-element-id`,n);break;case`style`:Object.assign(e.style,n);break;case`textContent`:e.textContent=n;break;default:(!o||t!==`href`&&t!==`newWindow`)&&e.setAttribute(t,n)}o&&i.addLinkAttributes(e,a.href,a.newWindow),n&&a.dataId&&this.setupStorage(e,a.dataId,t,n)}static render(e){let t=e.annotationStorage,n=e.linkService,r=e.xfaHtml,i=e.intent||`display`,a=document.createElement(r.name);r.attributes&&this.setAttributes({html:a,element:r,intent:i,linkService:n});let o=i!==`richText`,s=e.div;if(s.append(a),e.viewport){let t=`matrix(${e.viewport.transform.join(`,`)})`;s.style.transform=t}o&&s.setAttribute(`class`,`xfaLayer xfaFont`);let c=[];if(r.children.length===0){if(r.value){let e=document.createTextNode(r.value);a.append(e),o&&En.shouldBuildText(r.name)&&c.push(e)}return{textDivs:c}}let l=[[r,-1,a]];for(;l.length>0;){let[e,r,a]=l.at(-1);if(r+1===e.children.length){l.pop();continue}let s=e.children[++l.at(-1)[1]];if(s===null)continue;let{name:u}=s;if(u===`#text`){let e=document.createTextNode(s.value);c.push(e),a.append(e);continue}let d=s?.attributes?.xmlns?document.createElementNS(s.attributes.xmlns,u):document.createElement(u);if(a.append(d),s.attributes&&this.setAttributes({html:d,element:s,storage:t,intent:i,linkService:n}),s.children?.length>0)l.push([s,-1,d]);else if(s.value){let e=document.createTextNode(s.value);o&&En.shouldBuildText(u)&&c.push(e),d.append(e)}}for(let e of s.querySelectorAll(`.xfaNonInteractive input, .xfaNonInteractive textarea`))e.setAttribute(`readOnly`,!0);return{textDivs:c}}static update(e){let t=`matrix(${e.viewport.transform.join(`,`)})`;e.div.style.transform=t,e.div.hidden=!1}},rr=1e3,ir=9,ar=new WeakSet;function or(e){return{width:e[2]-e[0],height:e[3]-e[1]}}var sr=class{static create(e){switch(e.data.annotationType){case g.LINK:return new cr(e);case g.TEXT:return new lr(e);case g.WIDGET:switch(e.data.fieldType){case`Tx`:return new dr(e);case`Btn`:return e.data.radioButton?new mr(e):e.data.checkBox?new pr(e):new hr(e);case`Ch`:return new gr(e);case`Sig`:return new fr(e)}return new ur(e);case g.POPUP:return new _r(e);case g.FREETEXT:return new yr(e);case g.LINE:return new br(e);case g.SQUARE:return new xr(e);case g.CIRCLE:return new Sr(e);case g.POLYLINE:return new Cr(e);case g.CARET:return new Tr(e);case g.INK:return new Er(e);case g.POLYGON:return new wr(e);case g.HIGHLIGHT:return new Dr(e);case g.UNDERLINE:return new Or(e);case g.SQUIGGLY:return new kr(e);case g.STRIKEOUT:return new Ar(e);case g.STAMP:return new jr(e);case g.FILEATTACHMENT:return new Mr(e);default:return new Q(e)}}},Q=class e{#e=null;#t=!1;#n=null;constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:r=!1}={}){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(n)),r&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:n}){return!!(e?.str||t?.str||n?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return e._hasPopupData(this.data)}updateEdited(e){if(!this.container)return;this.#e||={rect:this.data.rect.slice(0)};let{rect:t}=e;t&&this.#r(t),this.#n?.popup.updateEdited(e)}resetEdited(){this.#e&&=(this.#r(this.#e.rect),this.#n?.popup.resetEdited(),null)}#r(e){let{container:{style:t},data:{rect:n,rotation:r},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:o,pageY:s}}}}=this;n?.splice(0,4,...e);let{width:c,height:l}=or(e);t.left=`${100*(e[0]-o)/i}%`,t.top=`${100*(a-e[3]+s)/a}%`,r===0?(t.width=`${100*c/i}%`,t.height=`${100*l/a}%`):this.setRotation(r)}_createContainer(e){let{data:t,parent:{page:n,viewport:r}}=this,i=document.createElement(`section`);i.setAttribute(`data-annotation-id`,t.id),this instanceof ur||(i.tabIndex=rr);let{style:a}=i;if(a.zIndex=this.parent.zIndex++,t.alternativeText&&(i.title=t.alternativeText),t.noRotate&&i.classList.add(`norotate`),!t.rect||this instanceof _r){let{rotation:e}=t;return!t.hasOwnCanvas&&e!==0&&this.setRotation(e,i),i}let{width:o,height:s}=or(t.rect);if(!e&&t.borderStyle.width>0){a.borderWidth=`${t.borderStyle.width}px`;let e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;switch(e>0||n>0?a.borderRadius=`calc(${e}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`:this instanceof mr&&(a.borderRadius=`calc(${o}px * var(--scale-factor)) / calc(${s}px * var(--scale-factor))`),t.borderStyle.style){case _.SOLID:a.borderStyle=`solid`;break;case _.DASHED:a.borderStyle=`dashed`;break;case _.BEVELED:T(`Unimplemented border style: beveled`);break;case _.INSET:T(`Unimplemented border style: inset`);break;case _.UNDERLINE:a.borderBottomStyle=`solid`;break;default:break}let r=t.borderColor||null;r?(this.#t=!0,a.borderColor=R.makeHexColor(r[0]|0,r[1]|0,r[2]|0)):a.borderWidth=0}let c=R.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]),{pageWidth:l,pageHeight:u,pageX:d,pageY:f}=r.rawDims;a.left=`${100*(c[0]-d)/l}%`,a.top=`${100*(c[1]-f)/u}%`;let{rotation:p}=t;return t.hasOwnCanvas||p===0?(a.width=`${100*o/l}%`,a.height=`${100*s/u}%`):this.setRotation(p,i),i}setRotation(e,t=this.container){if(!this.data.rect)return;let{pageWidth:n,pageHeight:r}=this.parent.viewport.rawDims,{width:i,height:a}=or(this.data.rect),o,s;e%180==0?(o=100*i/n,s=100*a/r):(o=100*a/n,s=100*i/r),t.style.width=`${o}%`,t.style.height=`${s}%`,t.setAttribute(`data-main-rotation`,(360-e)%360)}get _commonActions(){let e=(e,t,n)=>{let r=n.detail[e],i=r[0],a=r.slice(1);n.target.style[t]=$n[`${i}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[t]:$n[`${i}_rgb`](a)})};return A(this,`_commonActions`,{display:e=>{let{display:t}=e.detail,n=t%2==1;this.container.style.visibility=n?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:t===1||t===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{let{hidden:t}=e.detail;this.container.style.visibility=t?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e(`bgColor`,`backgroundColor`,t)},fillColor:t=>{e(`fillColor`,`backgroundColor`,t)},fgColor:t=>{e(`fgColor`,`color`,t)},textColor:t=>{e(`textColor`,`color`,t)},borderColor:t=>{e(`borderColor`,`borderColor`,t)},strokeColor:t=>{e(`strokeColor`,`borderColor`,t)},rotation:e=>{let t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){let n=this._commonActions;for(let r of Object.keys(t.detail))(e[r]||n[r])?.(t)}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let n=this._commonActions;for(let[r,i]of Object.entries(t)){let a=n[r];a&&(a({detail:{[r]:i},target:e}),delete t[r])}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[t,n,r,i]=this.data.rect.map(e=>Math.fround(e));if(e.length===8){let[a,o,s,c]=e.subarray(2,6);if(r===a&&i===o&&t===s&&n===c)return}let{style:a}=this.container,o;if(this.#t){let{borderColor:e,borderWidth:t}=a;a.borderWidth=0,o=[`url('data:image/svg+xml;utf8,`,`<svg xmlns="http://www.w3.org/2000/svg"`,` preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${e}" stroke-width="${t}">`],this.container.classList.add(`hasBorder`)}let s=r-t,c=i-n,{svgFactory:l}=this,u=l.createElement(`svg`);u.classList.add(`quadrilateralsContainer`),u.setAttribute(`width`,0),u.setAttribute(`height`,0);let d=l.createElement(`defs`);u.append(d);let f=l.createElement(`clipPath`),p=`clippath_${this.data.id}`;f.setAttribute(`id`,p),f.setAttribute(`clipPathUnits`,`objectBoundingBox`),d.append(f);for(let n=2,r=e.length;n<r;n+=8){let r=e[n],a=e[n+1],u=e[n+2],d=e[n+3],p=l.createElement(`rect`),m=(u-t)/s,h=(i-a)/c,g=(r-u)/s,_=(a-d)/c;p.setAttribute(`x`,m),p.setAttribute(`y`,h),p.setAttribute(`width`,g),p.setAttribute(`height`,_),f.append(p),o?.push(`<rect vector-effect="non-scaling-stroke" x="${m}" y="${h}" width="${g}" height="${_}"/>`)}this.#t&&(o.push(`</g></svg>')`),a.backgroundImage=o.join(``)),this.container.append(u),this.container.style.clipPath=`url(#${p})`}_createPopup(){let{data:e}=this,t=this.#n=new _r({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(t.render())}render(){E("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let n=[];if(this._fieldObjects){let r=this._fieldObjects[e];if(r)for(let{page:e,id:i,exportValues:a}of r){if(e===-1||i===t)continue;let r=typeof a==`string`?a:null,o=document.querySelector(`[data-element-id="${i}"]`);if(o&&!ar.has(o)){T(`_getElementsByName - element not allowed: ${i}`);continue}n.push({id:i,exportValue:r,domElement:o})}return n}for(let r of document.getElementsByName(e)){let{exportValue:e}=r,i=r.getAttribute(`data-element-id`);i!==t&&ar.has(r)&&n.push({id:i,exportValue:e,domElement:r})}return n}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(let t of e)t.classList.add(`highlightArea`);else e.classList.add(`highlightArea`)}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener(`dblclick`,()=>{this.linkService.eventBus?.dispatch(`switchannotationeditormode`,{source:this,mode:e,editId:t})})}},cr=class extends Q{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,n=document.createElement(`a`);n.setAttribute(`data-element-id`,e.id);let r=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(n,e.action),r=!0):e.attachment?(this.#t(n,e.attachment,e.attachmentDest),r=!0):e.setOCGState?(this.#n(n,e.setOCGState),r=!0):e.dest?(this._bindLink(n,e.dest),r=!0):(e.actions&&(e.actions.Action||e.actions[`Mouse Up`]||e.actions[`Mouse Down`])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),r=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,``),r=!0)),this.container.classList.add(`linkAnnotation`),r&&this.container.append(n),this.container}#e(){this.container.setAttribute(`data-internal-link`,``)}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||t===``)&&this.#e()}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),this.#e()}#t(e,t,n=null){e.href=this.linkService.getAnchorUrl(``),t.description&&(e.title=t.description),e.onclick=()=>(this.downloadManager?.openOrDownloadData(t.content,t.filename,n),!1),this.#e()}#n(e,t){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),this.#e()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl(``);let n=new Map([[`Action`,`onclick`],[`Mouse Up`,`onmouseup`],[`Mouse Down`,`onmousedown`]]);for(let r of Object.keys(t.actions)){let i=n.get(r);i&&(e[i]=()=>(this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t.id,name:r}}),!1))}e.onclick||=()=>!1,this.#e()}_bindResetFormAction(e,t){let n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl(``)),this.#e(),!this._fieldObjects){T('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(e.onclick=()=>!1);return}e.onclick=()=>{n?.();let{fields:e,refs:r,include:i}=t,a=[];if(e.length!==0||r.length!==0){let t=new Set(r);for(let n of e){let e=this._fieldObjects[n]||[];for(let{id:n}of e)t.add(n)}for(let e of Object.values(this._fieldObjects))for(let n of e)t.has(n.id)===i&&a.push(n)}else for(let e of Object.values(this._fieldObjects))a.push(...e);let o=this.annotationStorage,s=[];for(let e of a){let{id:t}=e;switch(s.push(t),e.type){case`text`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}case`checkbox`:case`radiobutton`:{let n=e.defaultValue===e.exportValues;o.setValue(t,{value:n});break}case`combobox`:case`listbox`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}default:continue}let n=document.querySelector(`[data-element-id="${t}"]`);if(n){if(!ar.has(n)){T(`_bindResetFormAction - element not allowed: ${t}`);continue}n.dispatchEvent(new Event(`resetform`))}}return this.enableScripting&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:`app`,ids:s,name:`ResetForm`}}),!1}}},lr=class extends Q{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add(`textAnnotation`);let e=document.createElement(`img`);return e.src=this.imageResourcesPath+`annotation-`+this.data.name.toLowerCase()+`.svg`,e.setAttribute(`data-l10n-id`,`pdfjs-text-annotation-type`),e.setAttribute(`data-l10n-args`,JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}},ur=class extends Q{render(){return this.container}showElementAndHideCanvas(e){this.data.hasOwnCanvas&&(e.previousSibling?.nodeName===`CANVAS`&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return L.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,n,r,i){n.includes(`mouse`)?e.addEventListener(n,e=>{this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})}):e.addEventListener(n,e=>{if(n===`blur`){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if(n===`focus`){if(t.focused)return;t.focused=!0}i&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e)}})})}_setEventListeners(e,t,n,r){for(let[i,a]of n)(a===`Action`||this.data.actions?.[a])&&((a===`Focus`||a===`Blur`)&&(t||={focused:!1}),this._setEventListener(e,t,i,a,r),a===`Focus`&&!this.data.actions?.Blur?this._setEventListener(e,t,`blur`,`Blur`,null):a===`Blur`&&!this.data.actions?.Focus&&this._setEventListener(e,t,`focus`,`Focus`,null))}_setBackgroundColor(e){let t=this.data.backgroundColor||null;e.style.backgroundColor=t===null?`transparent`:R.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){let t=[`left`,`center`,`right`],{fontColor:n}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||ir,i=e.style,a,o=e=>Math.round(10*e)/10;if(this.data.multiLine){let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(s*r))||1);a=Math.min(r,o(t/s))}else{let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(r,o(e/s))}i.fontSize=`calc(${a}px * var(--scale-factor))`,i.color=R.makeHexColor(n[0],n[1],n[2]),this.data.textAlignment!==null&&(i.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute(`required`,!0):e.removeAttribute(`required`),e.setAttribute(`aria-required`,t)}},dr=class extends ur{constructor(e){let t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,n,r){let i=this.annotationStorage;for(let a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[t]=n),i.setValue(a.id,{[r]:n})}render(){let e=this.annotationStorage,t=this.data.id;this.container.classList.add(`textWidgetAnnotation`);let n=null;if(this.renderForms){let r=e.getValue(t,{value:this.data.fieldValue}),i=r.value||``,a=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;a&&i.length>a&&(i=i.slice(0,a));let o=r.formattedValue||this.data.textContent?.join(`
2
2
  `)||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,``));let s={userValue:i,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement(`textarea`),n.textContent=o??i,this.data.doNotScroll&&(n.style.overflowY=`hidden`)):(n=document.createElement(`input`),n.type=`text`,n.setAttribute(`value`,o??i),this.data.doNotScroll&&(n.style.overflowX=`hidden`)),this.data.hasOwnCanvas&&(n.hidden=!0),ar.add(n),n.setAttribute(`data-element-id`,t),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=rr,this._setRequired(n,this.data.required),a&&(n.maxLength=a),n.addEventListener(`input`,r=>{e.setValue(t,{value:r.target.value}),this.setPropertyOnSiblings(n,`value`,r.target.value,`value`),s.formattedValue=null}),n.addEventListener(`resetform`,e=>{let t=this.data.defaultFieldValue??``;n.value=s.userValue=t,s.formattedValue=null});let c=e=>{let{formattedValue:t}=s;t!=null&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener(`focus`,e=>{if(s.focused)return;let{target:t}=e;s.userValue&&(t.value=s.userValue),s.lastCommittedValue=t.value,s.commitKey=1,this.data.actions?.Focus||(s.focused=!0)}),n.addEventListener(`updatefromsandbox`,n=>{this.showElementAndHideCanvas(n.target),this._dispatchEventFromSandbox({value(n){s.userValue=n.detail.value??``,e.setValue(t,{value:s.userValue.toString()}),n.target.value=s.userValue},formattedValue(n){let{formattedValue:r}=n.detail;s.formattedValue=r,r!=null&&n.target!==document.activeElement&&(n.target.value=r),e.setValue(t,{formattedValue:r})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:n=>{let{charLimit:r}=n.detail,{target:i}=n;if(r===0){i.removeAttribute(`maxLength`);return}i.setAttribute(`maxLength`,r);let a=s.userValue;!a||a.length<=r||(a=a.slice(0,r),i.value=s.userValue=a,e.setValue(t,{value:a}),this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:a,willCommit:!0,commitKey:1,selStart:i.selectionStart,selEnd:i.selectionEnd}}))}},n)}),n.addEventListener(`keydown`,e=>{s.commitKey=1;let n=-1;if(e.key===`Escape`?n=0:e.key===`Enter`&&!this.data.multiLine?n=2:e.key===`Tab`&&(s.commitKey=3),n===-1)return;let{value:r}=e.target;s.lastCommittedValue!==r&&(s.lastCommittedValue=r,s.userValue=r,this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:r,willCommit:!0,commitKey:n,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))});let r=c;c=null,n.addEventListener(`blur`,e=>{if(!s.focused||!e.relatedTarget)return;this.data.actions?.Blur||(s.focused=!1);let{value:n}=e.target;s.userValue=n,s.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:n,willCommit:!0,commitKey:s.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}),r(e)}),this.data.actions?.Keystroke&&n.addEventListener(`beforeinput`,e=>{s.lastCommittedValue=null;let{data:n,target:r}=e,{value:i,selectionStart:a,selectionEnd:o}=r,c=a,l=o;switch(e.inputType){case`deleteWordBackward`:{let e=i.substring(0,a).match(/\w*[^\w]*$/);e&&(c-=e[0].length);break}case`deleteWordForward`:{let e=i.substring(a).match(/^[^\w]*\w*/);e&&(l+=e[0].length);break}case`deleteContentBackward`:a===o&&--c;break;case`deleteContentForward`:a===o&&(l+=1);break}e.preventDefault(),this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:i,change:n||``,willCommit:!1,selStart:c,selEnd:l}})}),this._setEventListeners(n,s,[[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.value)}if(c&&n.addEventListener(`blur`,c),this.data.comb){let e=(this.data.rect[2]-this.data.rect[0])/a;n.classList.add(`comb`),n.style.letterSpacing=`calc(${e}px * var(--scale-factor) - 1ch)`}}else n=document.createElement(`div`),n.textContent=this.data.fieldValue,n.style.verticalAlign=`middle`,n.style.display=`table-cell`,this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}},fr=class extends ur{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}},pr=class extends ur{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,n=t.id,r=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;typeof r==`string`&&(r=r!==`Off`,e.setValue(n,{value:r})),this.container.classList.add(`buttonWidgetAnnotation`,`checkBox`);let i=document.createElement(`input`);return ar.add(i),i.setAttribute(`data-element-id`,n),i.disabled=t.readOnly,this._setRequired(i,this.data.required),i.type=`checkbox`,i.name=t.fieldName,r&&i.setAttribute(`checked`,!0),i.setAttribute(`exportValue`,t.exportValue),i.tabIndex=rr,i.addEventListener(`change`,r=>{let{name:i,checked:a}=r.target;for(let r of this._getElementsByName(i,n)){let n=a&&r.exportValue===t.exportValue;r.domElement&&(r.domElement.checked=n),e.setValue(r.id,{value:n})}e.setValue(n,{value:a})}),i.addEventListener(`resetform`,e=>{let n=t.defaultFieldValue||`Off`;e.target.checked=n===t.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener(`updatefromsandbox`,t=>{this._dispatchEventFromSandbox({value(t){t.target.checked=t.detail.value!==`Off`,e.setValue(n,{value:t.target.checked})}},t)}),this._setEventListeners(i,null,[[`change`,`Validate`],[`change`,`Action`],[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.checked)),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},mr=class extends ur{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add(`buttonWidgetAnnotation`,`radioButton`);let e=this.annotationStorage,t=this.data,n=t.id,r=e.getValue(n,{value:t.fieldValue===t.buttonValue}).value;if(typeof r==`string`&&(r=r!==t.buttonValue,e.setValue(n,{value:r})),r)for(let r of this._getElementsByName(t.fieldName,n))e.setValue(r.id,{value:!1});let i=document.createElement(`input`);if(ar.add(i),i.setAttribute(`data-element-id`,n),i.disabled=t.readOnly,this._setRequired(i,this.data.required),i.type=`radio`,i.name=t.fieldName,r&&i.setAttribute(`checked`,!0),i.tabIndex=rr,i.addEventListener(`change`,t=>{let{name:r,checked:i}=t.target;for(let t of this._getElementsByName(r,n))e.setValue(t.id,{value:!1});e.setValue(n,{value:i})}),i.addEventListener(`resetform`,e=>{let n=t.defaultFieldValue;e.target.checked=n!=null&&n===t.buttonValue}),this.enableScripting&&this.hasJSActions){let r=t.buttonValue;i.addEventListener(`updatefromsandbox`,t=>{this._dispatchEventFromSandbox({value:t=>{let i=r===t.detail.value;for(let r of this._getElementsByName(t.target.name)){let t=i&&r.id===n;r.domElement&&(r.domElement.checked=t),e.setValue(r.id,{value:t})}}},t)}),this._setEventListeners(i,null,[[`change`,`Validate`],[`change`,`Action`],[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.checked)}return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},hr=class extends cr{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add(`buttonWidgetAnnotation`,`pushButton`);let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener(`updatefromsandbox`,e=>{this._dispatchEventFromSandbox({},e)})),e}},gr=class extends ur{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add(`choiceWidgetAnnotation`);let e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),r=document.createElement(`select`);ar.add(r),r.setAttribute(`data-element-id`,t),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=rr;let i=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener(`resetform`,e=>{let t=this.data.defaultFieldValue;for(let e of r.options)e.selected=e.value===t});for(let e of this.data.options){let t=document.createElement(`option`);t.textContent=e.displayValue,t.value=e.exportValue,n.value.includes(e.exportValue)&&(t.setAttribute(`selected`,!0),i=!1),r.append(t)}let a=null;if(i){let e=document.createElement(`option`);e.value=` `,e.setAttribute(`hidden`,!0),e.setAttribute(`selected`,!0),r.prepend(e),a=()=>{e.remove(),r.removeEventListener(`input`,a),a=null},r.addEventListener(`input`,a)}let o=e=>{let t=e?`value`:`textContent`,{options:n,multiple:i}=r;return i?Array.prototype.filter.call(n,e=>e.selected).map(e=>e[t]):n.selectedIndex===-1?null:n[n.selectedIndex][t]},s=o(!1),c=e=>{let t=e.target.options;return Array.prototype.map.call(t,e=>({displayValue:e.textContent,exportValue:e.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener(`updatefromsandbox`,n=>{this._dispatchEventFromSandbox({value(n){a?.();let i=n.detail.value,c=new Set(Array.isArray(i)?i:[i]);for(let e of r.options)e.selected=c.has(e.value);e.setValue(t,{value:o(!0)}),s=o(!1)},multipleSelection(e){r.multiple=!0},remove(n){let i=r.options,a=n.detail.remove;i[a].selected=!1,r.remove(a),i.length>0&&Array.prototype.findIndex.call(i,e=>e.selected)===-1&&(i[0].selected=!0),e.setValue(t,{value:o(!0),items:c(n)}),s=o(!1)},clear(n){for(;r.length!==0;)r.remove(0);e.setValue(t,{value:null,items:[]}),s=o(!1)},insert(n){let{index:i,displayValue:a,exportValue:l}=n.detail.insert,u=r.children[i],d=document.createElement(`option`);d.textContent=a,d.value=l,u?u.before(d):r.append(d),e.setValue(t,{value:o(!0),items:c(n)}),s=o(!1)},items(n){let{items:i}=n.detail;for(;r.length!==0;)r.remove(0);for(let e of i){let{displayValue:t,exportValue:n}=e,i=document.createElement(`option`);i.textContent=t,i.value=n,r.append(i)}r.options.length>0&&(r.options[0].selected=!0),e.setValue(t,{value:o(!0),items:c(n)}),s=o(!1)},indices(n){let r=new Set(n.detail.indices);for(let e of n.target.options)e.selected=r.has(e.index);e.setValue(t,{value:o(!0)}),s=o(!1)},editable(e){e.target.disabled=!e.detail.editable}},n)}),r.addEventListener(`input`,n=>{let r=o(!0),i=o(!1);e.setValue(t,{value:r}),n.preventDefault(),this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:s,change:i,changeEx:r,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(r,null,[[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`],[`input`,`Action`],[`input`,`Validate`]],e=>e.target.value)):r.addEventListener(`input`,function(n){e.setValue(t,{value:o(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}},_r=class extends Q{constructor(e){let{data:t,elements:n}=e;super(e,{isRenderable:Q._hasPopupData(t)}),this.elements=n,this.popup=null}render(){this.container.classList.add(`popupAnnotation`);let e=this.popup=new vr({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(let n of this.elements)n.popup=e,n.container.ariaHasPopup=`dialog`,t.push(n.data.id),n.addHighlightArea();return this.container.setAttribute(`aria-controls`,t.map(e=>`${me}${e}`).join(`,`)),this.container}},vr=class{#e=this.#C.bind(this);#t=this.#D.bind(this);#n=this.#E.bind(this);#r=this.#T.bind(this);#i=null;#a=null;#o=null;#s=null;#c=null;#l=null;#u=null;#d=!1;#f=null;#p=null;#m=null;#h=null;#g=null;#_=null;#v=!1;constructor({container:e,color:t,elements:n,titleObj:r,modificationDate:i,contentsObj:a,richText:o,parent:s,rect:c,parentRect:l,open:u}){this.#a=e,this.#g=r,this.#o=a,this.#h=o,this.#l=s,this.#i=t,this.#m=c,this.#u=l,this.#c=n,this.#s=Ee.toDateObject(i),this.trigger=n.flatMap(e=>e.getElementsToTriggerPopup());for(let e of this.trigger)e.addEventListener(`click`,this.#r),e.addEventListener(`mouseenter`,this.#n),e.addEventListener(`mouseleave`,this.#t),e.classList.add(`popupTriggerArea`);for(let e of n)e.container?.addEventListener(`keydown`,this.#e);this.#a.hidden=!0,u&&this.#T()}render(){if(this.#f)return;let e=this.#f=document.createElement(`div`);if(e.className=`popup`,this.#i){let t=e.style.outlineColor=R.makeHexColor(...this.#i);CSS.supports(`background-color`,`color-mix(in srgb, red 30%, white)`)?e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`:e.style.backgroundColor=R.makeHexColor(...this.#i.map(e=>Math.floor(.7*(255-e)+e)))}let t=document.createElement(`span`);t.className=`header`;let n=document.createElement(`h1`);if(t.append(n),{dir:n.dir,str:n.textContent}=this.#g,e.append(t),this.#s){let e=document.createElement(`span`);e.classList.add(`popupDate`),e.setAttribute(`data-l10n-id`,`pdfjs-annotation-date-time-string`),e.setAttribute(`data-l10n-args`,JSON.stringify({dateObj:this.#s.valueOf()})),t.append(e)}let r=this.#y;if(r)nr.render({xfaHtml:r,intent:`richText`,div:e}),e.lastChild.classList.add(`richText`,`popupContent`);else{let t=this._formatContents(this.#o);e.append(t)}this.#a.append(e)}get#y(){let e=this.#h,t=this.#o;return e?.str&&(!t?.str||t.str===e.str)&&this.#h.html||null}get#b(){return this.#y?.attributes?.style?.fontSize||0}get#x(){return this.#y?.attributes?.style?.color||null}#S(e){let t=[],n={str:e,html:{name:`div`,attributes:{dir:`auto`},children:[{name:`p`,children:t}]}},r={style:{color:this.#x,fontSize:this.#b?`calc(${this.#b}px * var(--scale-factor))`:``}};for(let n of e.split(`
3
3
  `))t.push({name:`span`,value:n,attributes:r});return n}_formatContents({str:e,dir:t}){let n=document.createElement(`p`);n.classList.add(`popupContent`),n.dir=t;let r=e.split(/(?:\r\n?|\n)/);for(let e=0,t=r.length;e<t;++e){let i=r[e];n.append(document.createTextNode(i)),e<t-1&&n.append(document.createElement(`br`))}return n}#C(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key===`Enter`||e.key===`Escape`&&this.#d)&&this.#T()}updateEdited({rect:e,popupContent:t}){this.#_||={contentsObj:this.#o,richText:this.#h},e&&(this.#p=null),t&&(this.#h=this.#S(t),this.#o=null),this.#f?.remove(),this.#f=null}resetEdited(){this.#_&&({contentsObj:this.#o,richText:this.#h}=this.#_,this.#_=null,this.#f?.remove(),this.#f=null,this.#p=null)}#w(){if(this.#p!==null)return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:r,pageY:i}}}=this.#l,a=!!this.#u,o=a?this.#u:this.#m;for(let e of this.#c)if(!o||R.intersect(e.data.rect,o)!==null){o=e.data.rect,a=!0;break}let s=R.normalizeRect([o[0],e[3]-o[1]+e[1],o[2],e[3]-o[3]+e[1]]),c=a?o[2]-o[0]+5:0,l=s[0]+c,u=s[1];this.#p=[100*(l-r)/t,100*(u-i)/n];let{style:d}=this.#a;d.left=`${this.#p[0]}%`,d.top=`${this.#p[1]}%`}#T(){this.#d=!this.#d,this.#d?(this.#E(),this.#a.addEventListener(`click`,this.#r),this.#a.addEventListener(`keydown`,this.#e)):(this.#D(),this.#a.removeEventListener(`click`,this.#r),this.#a.removeEventListener(`keydown`,this.#e))}#E(){this.#f||this.render(),this.isVisible?this.#d&&this.#a.classList.add(`focused`):(this.#w(),this.#a.hidden=!1,this.#a.style.zIndex=parseInt(this.#a.style.zIndex)+1e3)}#D(){this.#a.classList.remove(`focused`),!(this.#d||!this.isVisible)&&(this.#a.hidden=!0,this.#a.style.zIndex=parseInt(this.#a.style.zIndex)-1e3)}forceHide(){this.#v=this.isVisible,this.#v&&(this.#a.hidden=!0)}maybeShow(){this.#v&&(this.#f||this.#E(),this.#v=!1,this.#a.hidden=!1)}get isVisible(){return this.#a.hidden===!1}},yr=class extends Q{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=d.FREETEXT}render(){if(this.container.classList.add(`freeTextAnnotation`),this.textContent){let e=document.createElement(`div`);e.classList.add(`annotationTextContent`),e.setAttribute(`role`,`comment`);for(let t of this.textContent){let n=document.createElement(`span`);n.textContent=t,e.append(n)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},br=class extends Q{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add(`lineAnnotation`);let e=this.data,{width:t,height:n}=or(e.rect),r=this.svgFactory.create(t,n,!0),i=this.#e=this.svgFactory.createElement(`svg:line`);return i.setAttribute(`x1`,e.rect[2]-e.lineCoordinates[0]),i.setAttribute(`y1`,e.rect[3]-e.lineCoordinates[1]),i.setAttribute(`x2`,e.rect[2]-e.lineCoordinates[2]),i.setAttribute(`y2`,e.rect[3]-e.lineCoordinates[3]),i.setAttribute(`stroke-width`,e.borderStyle.width||1),i.setAttribute(`stroke`,`transparent`),i.setAttribute(`fill`,`transparent`),r.append(i),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}},xr=class extends Q{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add(`squareAnnotation`);let e=this.data,{width:t,height:n}=or(e.rect),r=this.svgFactory.create(t,n,!0),i=e.borderStyle.width,a=this.#e=this.svgFactory.createElement(`svg:rect`);return a.setAttribute(`x`,i/2),a.setAttribute(`y`,i/2),a.setAttribute(`width`,t-i),a.setAttribute(`height`,n-i),a.setAttribute(`stroke-width`,i||1),a.setAttribute(`stroke`,`transparent`),a.setAttribute(`fill`,`transparent`),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}},Sr=class extends Q{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add(`circleAnnotation`);let e=this.data,{width:t,height:n}=or(e.rect),r=this.svgFactory.create(t,n,!0),i=e.borderStyle.width,a=this.#e=this.svgFactory.createElement(`svg:ellipse`);return a.setAttribute(`cx`,t/2),a.setAttribute(`cy`,n/2),a.setAttribute(`rx`,t/2-i/2),a.setAttribute(`ry`,n/2-i/2),a.setAttribute(`stroke-width`,i||1),a.setAttribute(`stroke`,`transparent`),a.setAttribute(`fill`,`transparent`),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}},Cr=class extends Q{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName=`polylineAnnotation`,this.svgElementName=`svg:polyline`}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,vertices:t,borderStyle:n,popupRef:r}}=this;if(!t)return this.container;let{width:i,height:a}=or(e),o=this.svgFactory.create(i,a,!0),s=[];for(let n=0,r=t.length;n<r;n+=2){let r=t[n]-e[0],i=e[3]-t[n+1];s.push(`${r},${i}`)}s=s.join(` `);let c=this.#e=this.svgFactory.createElement(this.svgElementName);return c.setAttribute(`points`,s),c.setAttribute(`stroke-width`,n.width||1),c.setAttribute(`stroke`,`transparent`),c.setAttribute(`fill`,`transparent`),o.append(c),this.container.append(o),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}},wr=class extends Cr{constructor(e){super(e),this.containerClassName=`polygonAnnotation`,this.svgElementName=`svg:polygon`}},Tr=class extends Q{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add(`caretAnnotation`),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}},Er=class extends Q{#e=null;#t=[];constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName=`inkAnnotation`,this.svgElementName=`svg:polyline`,this.annotationEditorType=this.data.it===`InkHighlight`?d.HIGHLIGHT:d.INK}#n(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,rotation:t,inkLists:n,borderStyle:r,popupRef:i}}=this,{transform:a,width:o,height:s}=this.#n(t,e),c=this.svgFactory.create(o,s,!0),l=this.#e=this.svgFactory.createElement(`svg:g`);c.append(l),l.setAttribute(`stroke-width`,r.width||1),l.setAttribute(`stroke-linecap`,`round`),l.setAttribute(`stroke-linejoin`,`round`),l.setAttribute(`stroke-miterlimit`,10),l.setAttribute(`stroke`,`transparent`),l.setAttribute(`fill`,`transparent`),l.setAttribute(`transform`,a);for(let e=0,t=n.length;e<t;e++){let t=this.svgFactory.createElement(this.svgElementName);this.#t.push(t),t.setAttribute(`points`,n[e].join(`,`)),l.append(t)}return!i&&this.hasPopupData&&this._createPopup(),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);let{thickness:t,points:n,rect:r}=e,i=this.#e;if(t>=0&&i.setAttribute(`stroke-width`,t||1),n)for(let e=0,t=this.#t.length;e<t;e++)this.#t[e].setAttribute(`points`,n[e].join(`,`));if(r){let{transform:e,width:t,height:n}=this.#n(this.data.rotation,r);i.parentElement.setAttribute(`viewBox`,`0 0 ${t} ${n}`),i.setAttribute(`transform`,e)}}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add(`highlightArea`)}},Dr=class extends Q{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=d.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add(`highlightAnnotation`),this._editOnDoubleClick(),this.container}},Or=class extends Q{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add(`underlineAnnotation`),this.container}},kr=class extends Q{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add(`squigglyAnnotation`),this.container}},Ar=class extends Q{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add(`strikeoutAnnotation`),this.container}},jr=class extends Q{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=d.STAMP}render(){return this.container.classList.add(`stampAnnotation`),this.container.setAttribute(`role`,`img`),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},Mr=class extends Q{#e=null;constructor(e){super(e,{isRenderable:!0});let{file:t}=this.data;this.filename=t.filename,this.content=t.content,this.linkService.eventBus?.dispatch(`fileattachmentannotation`,{source:this,...t})}render(){this.container.classList.add(`fileAttachmentAnnotation`);let{container:e,data:t}=this,n;t.hasAppearance||t.fillAlpha===0?n=document.createElement(`div`):(n=document.createElement(`img`),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?`paperclip`:`pushpin`}.svg`,t.fillAlpha&&t.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(t.fillAlpha*100)}%);`)),n.addEventListener(`dblclick`,this.#t.bind(this)),this.#e=n;let{isMac:r}=L.platform;return e.addEventListener(`keydown`,e=>{e.key===`Enter`&&(r?e.metaKey:e.ctrlKey)&&this.#t()}),!t.popupRef&&this.hasPopupData?this._createPopup():n.classList.add(`popupTriggerArea`),e.append(n),e}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}#t(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}},Nr=class{#e=null;#t=null;#n=new Map;#r=null;constructor({div:e,accessibilityManager:t,annotationCanvasMap:n,annotationEditorUIManager:r,page:i,viewport:a,structTreeLayer:o}){this.div=e,this.#e=t,this.#t=n,this.#r=o||null,this.page=i,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=r}hasEditableAnnotations(){return this.#n.size>0}async#i(e,t){let n=e.firstChild||e,r=n.id=`${me}${t}`,i=await this.#r?.getAriaAttributes(r);if(i)for(let[e,t]of i)n.setAttribute(e,t);this.div.append(e),this.#e?.moveElementInDOM(this.div,e,n,!1)}async render(e){let{annotations:t}=e,n=this.div;Ae(n,this.viewport);let r=new Map,i={data:null,layer:n,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||``,renderForms:e.renderForms!==!1,svgFactory:new tr,annotationStorage:e.annotationStorage||new qe,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(let e of t){if(e.noHTML)continue;let t=e.annotationType===g.POPUP;if(t){let t=r.get(e.id);if(!t)continue;i.elements=t}else{let{width:t,height:n}=or(e.rect);if(t<=0||n<=0)continue}i.data=e;let n=sr.create(i);if(!n.isRenderable)continue;if(!t&&e.popupRef){let t=r.get(e.popupRef);t?t.push(n):r.set(e.popupRef,[n])}let a=n.render();e.hidden&&(a.style.visibility=`hidden`),await this.#i(a,e.id),n._isEditable&&(this.#n.set(n.data.id,n),this._annotationEditorUIManager?.renderAnnotationElement(n))}this.#a()}update({viewport:e}){let t=this.div;this.viewport=e,Ae(t,{rotation:e.rotation}),this.#a(),t.hidden=!1}#a(){if(!this.#t)return;let e=this.div;for(let[t,n]of this.#t){let r=e.querySelector(`[data-annotation-id="${t}"]`);if(!r)continue;n.className=`annotationContent`;let{firstChild:i}=r;i?i.nodeName===`CANVAS`?i.replaceWith(n):i.classList.contains(`annotationContent`)?i.after(n):i.before(n):r.append(n)}this.#t.clear()}getEditableAnnotations(){return Array.from(this.#n.values())}getEditableAnnotation(e){return this.#n.get(e)}},Pr=/\r\n?|\n/g,Fr=class e extends W{#e;#t=``;#n=`${this.id}-editor`;#r=null;#i;static _freeTextDefaultContent=``;static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=e.prototype,n=e=>e.isEmpty(),r=Be.TRANSLATE_SMALL,i=Be.TRANSLATE_BIG;return A(this,`_keyboardManager`,new Re([[[`ctrl+s`,`mac+meta+s`,`ctrl+p`,`mac+meta+p`],t.commitOrRemove,{bubbles:!0}],[[`ctrl+Enter`,`mac+meta+Enter`,`Escape`,`mac+Escape`],t.commitOrRemove],[[`ArrowLeft`,`mac+ArrowLeft`],t._translateEmpty,{args:[-r,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t._translateEmpty,{args:[-i,0],checker:n}],[[`ArrowRight`,`mac+ArrowRight`],t._translateEmpty,{args:[r,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t._translateEmpty,{args:[i,0],checker:n}],[[`ArrowUp`,`mac+ArrowUp`],t._translateEmpty,{args:[0,-r],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t._translateEmpty,{args:[0,-i],checker:n}],[[`ArrowDown`,`mac+ArrowDown`],t._translateEmpty,{args:[0,r],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t._translateEmpty,{args:[0,i],checker:n}]]))}static _type=`freetext`;static _editorType=d.FREETEXT;constructor(t){super({...t,name:`freeTextEditor`}),this.#e=t.color||e._defaultColor||W._defaultLineColor,this.#i=t.fontSize||e._defaultFontSize}static initialize(e,t){W.initialize(e,t);let n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue(`--freetext-padding`))}static updateDefaultParams(t,n){switch(t){case f.FREETEXT_SIZE:e._defaultFontSize=n;break;case f.FREETEXT_COLOR:e._defaultColor=n;break}}updateParams(e,t){switch(e){case f.FREETEXT_SIZE:this.#a(t);break;case f.FREETEXT_COLOR:this.#o(t);break}}static get defaultPropertiesToUpdate(){return[[f.FREETEXT_SIZE,e._defaultFontSize],[f.FREETEXT_COLOR,e._defaultColor||W._defaultLineColor]]}get propertiesToUpdate(){return[[f.FREETEXT_SIZE,this.#i],[f.FREETEXT_COLOR,this.#e]]}#a(e){let t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`,this.translate(0,-(e-this.#i)*this.parentScale),this.#i=e,this.#c()},n=this.#i;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:f.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#o(e){let t=e=>{this.#e=this.editorDiv.style.color=e},n=this.#e;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:f.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){let t=this.parentScale;return[-e._internalPadding*t,-(e._internalPadding+this.#i)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(d.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove(`enabled`),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute(`aria-activedescendant`),this.#r=new AbortController;let e=this._uiManager.combinedSignal(this.#r);this.editorDiv.addEventListener(`keydown`,this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener(`focus`,this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener(`blur`,this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener(`input`,this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener(`paste`,this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add(`enabled`),this.editorDiv.contentEditable=!1,this.div.setAttribute(`aria-activedescendant`,this.#n),this._isDraggable=!0,this.#r?.abort(),this.#r=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add(`freetextEditing`))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===``}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add(`freetextEditing`)),super.remove()}#s(){let t=[];this.editorDiv.normalize();let n=null;for(let r of this.editorDiv.childNodes)n?.nodeType===Node.TEXT_NODE&&r.nodeName===`BR`||(t.push(e.#l(r)),n=r);return t.join(`
4
4
  `)}#c(){let[e,t]=this.parentDimensions,n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{let{currentLayer:e,div:t}=this,r=t.style.display,i=t.classList.contains(`hidden`);t.classList.remove(`hidden`),t.style.display=`hidden`,e.div.append(this.div),n=t.getBoundingClientRect(),t.remove(),t.style.display=r,t.classList.toggle(`hidden`,i)}this.rotation%180==this.parentRotation%180?(this.width=n.width/e,this.height=n.height/t):(this.width=n.height/e,this.height=n.width/t),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=this.#t,t=this.#t=this.#s().trimEnd();if(e===t)return;let n=e=>{if(this.#t=e,!e){this.remove();return}this.#u(),this._uiManager.rebuild(this),this.#c()};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),this.#c()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&e.key===`Enter`&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(t){e._keyboardManager.exec(this,t)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle(`freetextEditing`,this.isEmpty())}disableEditing(){this.editorDiv.setAttribute(`role`,`comment`),this.editorDiv.removeAttribute(`aria-multiline`)}enableEditing(){this.editorDiv.setAttribute(`role`,`textbox`),this.editorDiv.setAttribute(`aria-multiline`,!0)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement(`div`),this.editorDiv.className=`internal`,this.editorDiv.setAttribute(`id`,this.#n),this.editorDiv.setAttribute(`data-l10n-id`,`pdfjs-free-text2`),this.editorDiv.setAttribute(`data-l10n-attrs`,`default-content`),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:n}=this.editorDiv;if(n.fontSize=`calc(${this.#i}px * var(--scale-factor))`,n.color=this.#e,this.div.append(this.editorDiv),this.overlayDiv=document.createElement(`div`),this.overlayDiv.classList.add(`overlay`,`enabled`),this.div.append(this.overlayDiv),Pe(this,this.div,[`dblclick`,`keydown`]),this.width){let[n,r]=this.parentDimensions;if(this.annotationElementId){let{position:i}=this._initialData,[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);let[s,c]=this.pageDimensions,[l,u]=this.pageTranslation,d,f;switch(this.rotation){case 0:d=e+(i[0]-l)/s,f=t+this.height-(i[1]-u)/c;break;case 90:d=e+(i[0]-l)/s,f=t-(i[1]-u)/c,[a,o]=[o,-a];break;case 180:d=e-this.width+(i[0]-l)/s,f=t-(i[1]-u)/c,[a,o]=[-a,-o];break;case 270:d=e+(i[0]-l-this.height*c)/s,f=t+(i[1]-u-this.width*s)/c,[a,o]=[-o,a];break}this.setAt(d*n,f*r,a,o)}else this.setAt(e*n,t*r,this.width*n,this.height*r);this.#u(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#l(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Pr,``)}editorDivPaste(t){let n=t.clipboardData||window.clipboardData,{types:r}=n;if(r.length===1&&r[0]===`text/plain`)return;t.preventDefault();let i=e.#f(n.getData(`text`)||``).replaceAll(Pr,`