@k2b/ui 0.50.0 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (420) hide show
  1. package/dist/base.css +35 -1
  2. package/dist/browser/actions/Button.js.map +1 -1
  3. package/dist/browser/actions/CommandList.js +861 -0
  4. package/dist/browser/actions/CommandList.js.map +1 -0
  5. package/dist/browser/actions/CommandMenu.js +237 -0
  6. package/dist/browser/actions/CommandMenu.js.map +1 -0
  7. package/dist/browser/actions/Dropdown.js +43 -10
  8. package/dist/browser/actions/Dropdown.js.map +1 -1
  9. package/dist/browser/actions/Toolbar.js +8 -2
  10. package/dist/browser/actions/Toolbar.js.map +1 -1
  11. package/dist/browser/actions/command-dock.js +47 -0
  12. package/dist/browser/actions/command-dock.js.map +1 -0
  13. package/dist/browser/actions/command-items.js +84 -0
  14. package/dist/browser/actions/command-items.js.map +1 -0
  15. package/dist/browser/actions/command-messages.js +42 -0
  16. package/dist/browser/actions/command-messages.js.map +1 -0
  17. package/dist/browser/actions/index.js +1 -0
  18. package/dist/browser/actions/index.js.map +1 -1
  19. package/dist/browser/charts/core/area.js +3 -5
  20. package/dist/browser/charts/core/area.js.map +1 -1
  21. package/dist/browser/charts/core/bar-labels.js +5 -0
  22. package/dist/browser/charts/core/bar-labels.js.map +1 -0
  23. package/dist/browser/charts/core/bubble.js +166 -0
  24. package/dist/browser/charts/core/bubble.js.map +1 -0
  25. package/dist/browser/charts/core/calendar.js +1 -1
  26. package/dist/browser/charts/core/calendar.js.map +1 -1
  27. package/dist/browser/charts/core/chart-messages.js +17 -0
  28. package/dist/browser/charts/core/chart-messages.js.map +1 -0
  29. package/dist/browser/charts/core/default-styles.js +83 -0
  30. package/dist/browser/charts/core/default-styles.js.map +1 -0
  31. package/dist/browser/charts/core/funnel-layout.js +79 -0
  32. package/dist/browser/charts/core/funnel-layout.js.map +1 -0
  33. package/dist/browser/charts/core/funnel.js +27 -0
  34. package/dist/browser/charts/core/funnel.js.map +1 -0
  35. package/dist/browser/charts/core/hbar-layout.js +118 -0
  36. package/dist/browser/charts/core/hbar-layout.js.map +1 -0
  37. package/dist/browser/charts/core/hbar.js +39 -0
  38. package/dist/browser/charts/core/hbar.js.map +1 -0
  39. package/dist/browser/charts/core/index.js +12 -2
  40. package/dist/browser/charts/core/index.js.map +1 -1
  41. package/dist/browser/charts/core/map.js +116 -0
  42. package/dist/browser/charts/core/map.js.map +1 -0
  43. package/dist/browser/charts/core/pareto.js +120 -0
  44. package/dist/browser/charts/core/pareto.js.map +1 -0
  45. package/dist/browser/charts/core/radar.js +101 -0
  46. package/dist/browser/charts/core/radar.js.map +1 -0
  47. package/dist/browser/charts/core/registry.js +33 -16
  48. package/dist/browser/charts/core/registry.js.map +1 -1
  49. package/dist/browser/charts/core/render-size.js +15 -0
  50. package/dist/browser/charts/core/render-size.js.map +1 -0
  51. package/dist/browser/charts/core/render.js +39 -10
  52. package/dist/browser/charts/core/render.js.map +1 -1
  53. package/dist/browser/charts/core/snapshot.js +4 -4
  54. package/dist/browser/charts/core/snapshot.js.map +1 -1
  55. package/dist/browser/charts/core/svg-barGauge.js +67 -0
  56. package/dist/browser/charts/core/svg-barGauge.js.map +1 -0
  57. package/dist/browser/charts/core/svg-boxplot.js +127 -0
  58. package/dist/browser/charts/core/svg-boxplot.js.map +1 -0
  59. package/dist/browser/charts/core/svg-common.js +1065 -0
  60. package/dist/browser/charts/core/svg-common.js.map +1 -0
  61. package/dist/browser/charts/core/svg-gauge.js +185 -0
  62. package/dist/browser/charts/core/svg-gauge.js.map +1 -0
  63. package/dist/browser/charts/core/svg-heatmap.js +80 -0
  64. package/dist/browser/charts/core/svg-heatmap.js.map +1 -0
  65. package/dist/browser/charts/core/svg-histogram.js +73 -0
  66. package/dist/browser/charts/core/svg-histogram.js.map +1 -0
  67. package/dist/browser/charts/core/svg-renderers.js +638 -0
  68. package/dist/browser/charts/core/svg-renderers.js.map +1 -0
  69. package/dist/browser/charts/core/svg-scatter.js +114 -0
  70. package/dist/browser/charts/core/svg-scatter.js.map +1 -0
  71. package/dist/browser/charts/core/svg.js +4 -2525
  72. package/dist/browser/charts/core/svg.js.map +1 -1
  73. package/dist/browser/charts/core/treemap.js +138 -0
  74. package/dist/browser/charts/core/treemap.js.map +1 -0
  75. package/dist/browser/charts/core/types.js +0 -2
  76. package/dist/browser/charts/core/types.js.map +1 -1
  77. package/dist/browser/charts/core/waterfall.js +162 -0
  78. package/dist/browser/charts/core/waterfall.js.map +1 -0
  79. package/dist/browser/charts/description.js +2 -0
  80. package/dist/browser/charts/description.js.map +1 -0
  81. package/dist/browser/charts.js.map +1 -1
  82. package/dist/browser/content/Chart.js +14 -628
  83. package/dist/browser/content/Chart.js.map +1 -1
  84. package/dist/browser/content/ChartRoot.js +646 -0
  85. package/dist/browser/content/ChartRoot.js.map +1 -0
  86. package/dist/browser/content/ChartSnapshotView.js +4 -1
  87. package/dist/browser/content/ChartSnapshotView.js.map +1 -1
  88. package/dist/browser/content/ChartSparkline.js +24 -0
  89. package/dist/browser/content/ChartSparkline.js.map +1 -0
  90. package/dist/browser/content/DataTable.js +186 -193
  91. package/dist/browser/content/DataTable.js.map +1 -1
  92. package/dist/browser/content/FileView.js +111 -61
  93. package/dist/browser/content/FileView.js.map +1 -1
  94. package/dist/browser/content/Lightbox.js +62 -30
  95. package/dist/browser/content/Lightbox.js.map +1 -1
  96. package/dist/browser/content/MapView.js +30 -28
  97. package/dist/browser/content/MapView.js.map +1 -1
  98. package/dist/browser/content/PdfPreview.js +84 -52
  99. package/dist/browser/content/PdfPreview.js.map +1 -1
  100. package/dist/browser/content/PdfViewer.js +588 -0
  101. package/dist/browser/content/PdfViewer.js.map +1 -0
  102. package/dist/browser/content/ThumbnailStrip.js +174 -0
  103. package/dist/browser/content/ThumbnailStrip.js.map +1 -0
  104. package/dist/browser/content/chart-bar.js +344 -16
  105. package/dist/browser/content/chart-bar.js.map +1 -1
  106. package/dist/browser/content/chart-inspection-core.js +50 -29
  107. package/dist/browser/content/chart-inspection-core.js.map +1 -1
  108. package/dist/browser/content/chart-line-gaps.js +1 -1
  109. package/dist/browser/content/chart-line-gaps.js.map +1 -1
  110. package/dist/browser/content/chart-message-catalog.js +28 -0
  111. package/dist/browser/content/chart-message-catalog.js.map +1 -1
  112. package/dist/browser/content/chart-state-timeline.js +1 -1
  113. package/dist/browser/content/chart-state-timeline.js.map +1 -1
  114. package/dist/browser/content/chart-svg.js +2 -1
  115. package/dist/browser/content/chart-svg.js.map +1 -1
  116. package/dist/browser/content/index.js +2 -0
  117. package/dist/browser/content/index.js.map +1 -1
  118. package/dist/browser/content/pdf-document.js +29 -0
  119. package/dist/browser/content/pdf-document.js.map +1 -0
  120. package/dist/browser/content/pdf-limits.js +31 -0
  121. package/dist/browser/content/pdf-limits.js.map +1 -0
  122. package/dist/browser/content/pdf-messages.js +34 -2
  123. package/dist/browser/content/pdf-messages.js.map +1 -1
  124. package/dist/browser/content/pdf-viewer-engine.js +57 -0
  125. package/dist/browser/content/pdf-viewer-worker.js +28 -0
  126. package/dist/browser/content/thumbnail-strip-messages.js +24 -0
  127. package/dist/browser/content/thumbnail-strip-messages.js.map +1 -0
  128. package/dist/browser/inputs/ChoiceInputs.js +150 -76
  129. package/dist/browser/inputs/ChoiceInputs.js.map +1 -1
  130. package/dist/browser/inputs/ChoiceSlider.js +75 -58
  131. package/dist/browser/inputs/ChoiceSlider.js.map +1 -1
  132. package/dist/browser/inputs/DatePicker.js +113 -98
  133. package/dist/browser/inputs/DatePicker.js.map +1 -1
  134. package/dist/browser/inputs/PeriodPicker.js +874 -0
  135. package/dist/browser/inputs/PeriodPicker.js.map +1 -0
  136. package/dist/browser/inputs/index.js +5 -1
  137. package/dist/browser/inputs/index.js.map +1 -1
  138. package/dist/browser/inputs/input-messages.js +8 -2
  139. package/dist/browser/inputs/input-messages.js.map +1 -1
  140. package/dist/browser/inputs/markdown/MarkdownEditor.js +14 -10
  141. package/dist/browser/inputs/markdown/MarkdownEditor.js.map +1 -1
  142. package/dist/browser/inputs/markdown/MarkdownSelectionToolbar.js +330 -0
  143. package/dist/browser/inputs/markdown/MarkdownSelectionToolbar.js.map +1 -0
  144. package/dist/browser/inputs/markdown/SlashCommands.js +402 -0
  145. package/dist/browser/inputs/markdown/SlashCommands.js.map +1 -0
  146. package/dist/browser/inputs/period-picker-messages.js +71 -0
  147. package/dist/browser/inputs/period-picker-messages.js.map +1 -0
  148. package/dist/browser/inputs/period.js +263 -0
  149. package/dist/browser/inputs/period.js.map +1 -0
  150. package/dist/browser/internal/field.js +96 -77
  151. package/dist/browser/internal/field.js.map +1 -1
  152. package/dist/browser/layout/AppWorkspace.js +7 -5
  153. package/dist/browser/layout/AppWorkspace.js.map +1 -1
  154. package/dist/browser/layout/DetailPanel.js +147 -120
  155. package/dist/browser/layout/DetailPanel.js.map +1 -1
  156. package/dist/browser/layout/Discussion.js +101 -108
  157. package/dist/browser/layout/Discussion.js.map +1 -1
  158. package/dist/browser/layout/PanelDialog.js +92 -68
  159. package/dist/browser/layout/PanelDialog.js.map +1 -1
  160. package/dist/browser/layout/index.js.map +1 -1
  161. package/dist/browser/surfaces/DescriptionList.js +5 -2
  162. package/dist/browser/surfaces/DescriptionList.js.map +1 -1
  163. package/dist/browser/surfaces/StatCell.js +95 -78
  164. package/dist/browser/surfaces/StatCell.js.map +1 -1
  165. package/dist/browser/surfaces/delta-badge.js +16 -2
  166. package/dist/browser/surfaces/delta-badge.js.map +1 -1
  167. package/dist/browser/surfaces/stat-cell-messages.js +4 -2
  168. package/dist/browser/surfaces/stat-cell-messages.js.map +1 -1
  169. package/dist/browser/widgets/DashboardFrame.js +315 -0
  170. package/dist/browser/widgets/DashboardFrame.js.map +1 -0
  171. package/dist/browser/widgets/index.js +1 -0
  172. package/dist/browser/widgets/index.js.map +1 -1
  173. package/dist/licenses/pdfjs-dist.txt +177 -0
  174. package/dist/ssr/actions/Button.js.map +1 -1
  175. package/dist/ssr/actions/CommandList.js +638 -0
  176. package/dist/ssr/actions/CommandList.js.map +1 -0
  177. package/dist/ssr/actions/CommandMenu.js +197 -0
  178. package/dist/ssr/actions/CommandMenu.js.map +1 -0
  179. package/dist/ssr/actions/Dropdown.js +43 -10
  180. package/dist/ssr/actions/Dropdown.js.map +1 -1
  181. package/dist/ssr/actions/Toolbar.js +8 -2
  182. package/dist/ssr/actions/Toolbar.js.map +1 -1
  183. package/dist/ssr/actions/command-dock.js +47 -0
  184. package/dist/ssr/actions/command-dock.js.map +1 -0
  185. package/dist/ssr/actions/command-items.js +84 -0
  186. package/dist/ssr/actions/command-items.js.map +1 -0
  187. package/dist/ssr/actions/command-messages.js +42 -0
  188. package/dist/ssr/actions/command-messages.js.map +1 -0
  189. package/dist/ssr/actions/index.js +1 -0
  190. package/dist/ssr/actions/index.js.map +1 -1
  191. package/dist/ssr/charts/core/area.js +3 -5
  192. package/dist/ssr/charts/core/area.js.map +1 -1
  193. package/dist/ssr/charts/core/bar-labels.js +5 -0
  194. package/dist/ssr/charts/core/bar-labels.js.map +1 -0
  195. package/dist/ssr/charts/core/bubble.js +166 -0
  196. package/dist/ssr/charts/core/bubble.js.map +1 -0
  197. package/dist/ssr/charts/core/calendar.js +1 -1
  198. package/dist/ssr/charts/core/calendar.js.map +1 -1
  199. package/dist/ssr/charts/core/chart-messages.js +17 -0
  200. package/dist/ssr/charts/core/chart-messages.js.map +1 -0
  201. package/dist/ssr/charts/core/default-styles.js +83 -0
  202. package/dist/ssr/charts/core/default-styles.js.map +1 -0
  203. package/dist/ssr/charts/core/funnel-layout.js +79 -0
  204. package/dist/ssr/charts/core/funnel-layout.js.map +1 -0
  205. package/dist/ssr/charts/core/funnel.js +27 -0
  206. package/dist/ssr/charts/core/funnel.js.map +1 -0
  207. package/dist/ssr/charts/core/hbar-layout.js +118 -0
  208. package/dist/ssr/charts/core/hbar-layout.js.map +1 -0
  209. package/dist/ssr/charts/core/hbar.js +39 -0
  210. package/dist/ssr/charts/core/hbar.js.map +1 -0
  211. package/dist/ssr/charts/core/index.js +12 -2
  212. package/dist/ssr/charts/core/index.js.map +1 -1
  213. package/dist/ssr/charts/core/map.js +116 -0
  214. package/dist/ssr/charts/core/map.js.map +1 -0
  215. package/dist/ssr/charts/core/pareto.js +120 -0
  216. package/dist/ssr/charts/core/pareto.js.map +1 -0
  217. package/dist/ssr/charts/core/radar.js +101 -0
  218. package/dist/ssr/charts/core/radar.js.map +1 -0
  219. package/dist/ssr/charts/core/registry.js +33 -16
  220. package/dist/ssr/charts/core/registry.js.map +1 -1
  221. package/dist/ssr/charts/core/render-size.js +15 -0
  222. package/dist/ssr/charts/core/render-size.js.map +1 -0
  223. package/dist/ssr/charts/core/render.js +39 -10
  224. package/dist/ssr/charts/core/render.js.map +1 -1
  225. package/dist/ssr/charts/core/snapshot.js +4 -4
  226. package/dist/ssr/charts/core/snapshot.js.map +1 -1
  227. package/dist/ssr/charts/core/svg-barGauge.js +67 -0
  228. package/dist/ssr/charts/core/svg-barGauge.js.map +1 -0
  229. package/dist/ssr/charts/core/svg-boxplot.js +127 -0
  230. package/dist/ssr/charts/core/svg-boxplot.js.map +1 -0
  231. package/dist/ssr/charts/core/svg-common.js +1065 -0
  232. package/dist/ssr/charts/core/svg-common.js.map +1 -0
  233. package/dist/ssr/charts/core/svg-gauge.js +185 -0
  234. package/dist/ssr/charts/core/svg-gauge.js.map +1 -0
  235. package/dist/ssr/charts/core/svg-heatmap.js +80 -0
  236. package/dist/ssr/charts/core/svg-heatmap.js.map +1 -0
  237. package/dist/ssr/charts/core/svg-histogram.js +73 -0
  238. package/dist/ssr/charts/core/svg-histogram.js.map +1 -0
  239. package/dist/ssr/charts/core/svg-renderers.js +638 -0
  240. package/dist/ssr/charts/core/svg-renderers.js.map +1 -0
  241. package/dist/ssr/charts/core/svg-scatter.js +114 -0
  242. package/dist/ssr/charts/core/svg-scatter.js.map +1 -0
  243. package/dist/ssr/charts/core/svg.js +4 -2525
  244. package/dist/ssr/charts/core/svg.js.map +1 -1
  245. package/dist/ssr/charts/core/treemap.js +138 -0
  246. package/dist/ssr/charts/core/treemap.js.map +1 -0
  247. package/dist/ssr/charts/core/types.js +0 -2
  248. package/dist/ssr/charts/core/types.js.map +1 -1
  249. package/dist/ssr/charts/core/waterfall.js +162 -0
  250. package/dist/ssr/charts/core/waterfall.js.map +1 -0
  251. package/dist/ssr/charts/description.js +2 -0
  252. package/dist/ssr/charts/description.js.map +1 -0
  253. package/dist/ssr/charts.js.map +1 -1
  254. package/dist/ssr/content/Chart.js +14 -471
  255. package/dist/ssr/content/Chart.js.map +1 -1
  256. package/dist/ssr/content/ChartRoot.js +489 -0
  257. package/dist/ssr/content/ChartRoot.js.map +1 -0
  258. package/dist/ssr/content/ChartSnapshotView.js +1 -0
  259. package/dist/ssr/content/ChartSnapshotView.js.map +1 -1
  260. package/dist/ssr/content/ChartSparkline.js +24 -0
  261. package/dist/ssr/content/ChartSparkline.js.map +1 -0
  262. package/dist/ssr/content/DataTable.js +12 -16
  263. package/dist/ssr/content/DataTable.js.map +1 -1
  264. package/dist/ssr/content/FileView.js +56 -7
  265. package/dist/ssr/content/FileView.js.map +1 -1
  266. package/dist/ssr/content/Lightbox.js +39 -10
  267. package/dist/ssr/content/Lightbox.js.map +1 -1
  268. package/dist/ssr/content/MapView.js +9 -9
  269. package/dist/ssr/content/MapView.js.map +1 -1
  270. package/dist/ssr/content/PdfPreview.js +49 -20
  271. package/dist/ssr/content/PdfPreview.js.map +1 -1
  272. package/dist/ssr/content/PdfViewer.js +484 -0
  273. package/dist/ssr/content/PdfViewer.js.map +1 -0
  274. package/dist/ssr/content/ThumbnailStrip.js +103 -0
  275. package/dist/ssr/content/ThumbnailStrip.js.map +1 -0
  276. package/dist/ssr/content/chart-bar.js +344 -16
  277. package/dist/ssr/content/chart-bar.js.map +1 -1
  278. package/dist/ssr/content/chart-inspection-core.js +50 -29
  279. package/dist/ssr/content/chart-inspection-core.js.map +1 -1
  280. package/dist/ssr/content/chart-line-gaps.js +1 -1
  281. package/dist/ssr/content/chart-line-gaps.js.map +1 -1
  282. package/dist/ssr/content/chart-message-catalog.js +28 -0
  283. package/dist/ssr/content/chart-message-catalog.js.map +1 -1
  284. package/dist/ssr/content/chart-state-timeline.js +1 -1
  285. package/dist/ssr/content/chart-state-timeline.js.map +1 -1
  286. package/dist/ssr/content/chart-svg.js +2 -1
  287. package/dist/ssr/content/chart-svg.js.map +1 -1
  288. package/dist/ssr/content/index.js +2 -0
  289. package/dist/ssr/content/index.js.map +1 -1
  290. package/dist/ssr/content/pdf-document.js +29 -0
  291. package/dist/ssr/content/pdf-document.js.map +1 -0
  292. package/dist/ssr/content/pdf-limits.js +31 -0
  293. package/dist/ssr/content/pdf-limits.js.map +1 -0
  294. package/dist/ssr/content/pdf-messages.js +34 -2
  295. package/dist/ssr/content/pdf-messages.js.map +1 -1
  296. package/dist/ssr/content/thumbnail-strip-messages.js +24 -0
  297. package/dist/ssr/content/thumbnail-strip-messages.js.map +1 -0
  298. package/dist/ssr/inputs/ChoiceInputs.js +69 -17
  299. package/dist/ssr/inputs/ChoiceInputs.js.map +1 -1
  300. package/dist/ssr/inputs/ChoiceSlider.js +17 -12
  301. package/dist/ssr/inputs/ChoiceSlider.js.map +1 -1
  302. package/dist/ssr/inputs/DatePicker.js +14 -9
  303. package/dist/ssr/inputs/DatePicker.js.map +1 -1
  304. package/dist/ssr/inputs/PeriodPicker.js +598 -0
  305. package/dist/ssr/inputs/PeriodPicker.js.map +1 -0
  306. package/dist/ssr/inputs/index.js +5 -1
  307. package/dist/ssr/inputs/index.js.map +1 -1
  308. package/dist/ssr/inputs/input-messages.js +8 -2
  309. package/dist/ssr/inputs/input-messages.js.map +1 -1
  310. package/dist/ssr/inputs/markdown/MarkdownEditor.js +3 -2
  311. package/dist/ssr/inputs/markdown/MarkdownEditor.js.map +1 -1
  312. package/dist/ssr/inputs/markdown/MarkdownSelectionToolbar.js +293 -0
  313. package/dist/ssr/inputs/markdown/MarkdownSelectionToolbar.js.map +1 -0
  314. package/dist/ssr/inputs/markdown/SlashCommands.js +339 -0
  315. package/dist/ssr/inputs/markdown/SlashCommands.js.map +1 -0
  316. package/dist/ssr/inputs/period-picker-messages.js +71 -0
  317. package/dist/ssr/inputs/period-picker-messages.js.map +1 -0
  318. package/dist/ssr/inputs/period.js +263 -0
  319. package/dist/ssr/inputs/period.js.map +1 -0
  320. package/dist/ssr/internal/field.js +36 -24
  321. package/dist/ssr/internal/field.js.map +1 -1
  322. package/dist/ssr/layout/AppWorkspace.js +5 -1
  323. package/dist/ssr/layout/AppWorkspace.js.map +1 -1
  324. package/dist/ssr/layout/DetailPanel.js +27 -4
  325. package/dist/ssr/layout/DetailPanel.js.map +1 -1
  326. package/dist/ssr/layout/Discussion.js +16 -2
  327. package/dist/ssr/layout/Discussion.js.map +1 -1
  328. package/dist/ssr/layout/PanelDialog.js +40 -26
  329. package/dist/ssr/layout/PanelDialog.js.map +1 -1
  330. package/dist/ssr/layout/index.js.map +1 -1
  331. package/dist/ssr/surfaces/DescriptionList.js +1 -1
  332. package/dist/ssr/surfaces/DescriptionList.js.map +1 -1
  333. package/dist/ssr/surfaces/StatCell.js +31 -21
  334. package/dist/ssr/surfaces/StatCell.js.map +1 -1
  335. package/dist/ssr/surfaces/delta-badge.js +16 -2
  336. package/dist/ssr/surfaces/delta-badge.js.map +1 -1
  337. package/dist/ssr/surfaces/stat-cell-messages.js +4 -2
  338. package/dist/ssr/surfaces/stat-cell-messages.js.map +1 -1
  339. package/dist/ssr/widgets/DashboardFrame.js +195 -0
  340. package/dist/ssr/widgets/DashboardFrame.js.map +1 -0
  341. package/dist/ssr/widgets/index.js +1 -0
  342. package/dist/ssr/widgets/index.js.map +1 -1
  343. package/dist/styles.css +1 -1
  344. package/dist/types/actions/Button.d.ts +1 -1
  345. package/dist/types/actions/CommandList.d.ts +120 -0
  346. package/dist/types/actions/CommandMenu.d.ts +39 -0
  347. package/dist/types/actions/Dropdown.d.ts +17 -0
  348. package/dist/types/actions/Toolbar.d.ts +2 -0
  349. package/dist/types/actions/command-dock.d.ts +8 -0
  350. package/dist/types/actions/command-items.d.ts +134 -0
  351. package/dist/types/actions/command-messages.d.ts +19 -0
  352. package/dist/types/actions/index.d.ts +3 -0
  353. package/dist/types/charts/core/bar-labels.d.ts +1 -0
  354. package/dist/types/charts/core/bubble.d.ts +66 -0
  355. package/dist/types/charts/core/calendar.d.ts +1 -1
  356. package/dist/types/charts/core/chart-messages.d.ts +5 -0
  357. package/dist/types/charts/core/default-styles.d.ts +1 -0
  358. package/dist/types/charts/core/funnel-layout.d.ts +43 -0
  359. package/dist/types/charts/core/funnel.d.ts +13 -0
  360. package/dist/types/charts/core/hbar-layout.d.ts +74 -0
  361. package/dist/types/charts/core/hbar.d.ts +13 -0
  362. package/dist/types/charts/core/index.d.ts +12 -2
  363. package/dist/types/charts/core/map.d.ts +3 -0
  364. package/dist/types/charts/core/pareto.d.ts +40 -0
  365. package/dist/types/charts/core/radar.d.ts +47 -0
  366. package/dist/types/charts/core/registry.d.ts +27 -11
  367. package/dist/types/charts/core/render-size.d.ts +7 -0
  368. package/dist/types/charts/core/render.d.ts +1 -4
  369. package/dist/types/charts/core/snapshot.d.ts +2 -2
  370. package/dist/types/charts/core/svg-barGauge.d.ts +3 -0
  371. package/dist/types/charts/core/svg-boxplot.d.ts +18 -0
  372. package/dist/types/charts/core/svg-common.d.ts +612 -0
  373. package/dist/types/charts/core/svg-gauge.d.ts +6 -0
  374. package/dist/types/charts/core/svg-heatmap.d.ts +6 -0
  375. package/dist/types/charts/core/svg-histogram.d.ts +16 -0
  376. package/dist/types/charts/core/svg-renderers.d.ts +118 -0
  377. package/dist/types/charts/core/svg-scatter.d.ts +23 -0
  378. package/dist/types/charts/core/svg.d.ts +4 -698
  379. package/dist/types/charts/core/treemap.d.ts +45 -0
  380. package/dist/types/charts/core/types.d.ts +1 -12
  381. package/dist/types/charts/core/waterfall.d.ts +68 -0
  382. package/dist/types/charts/description.d.ts +289 -0
  383. package/dist/types/charts.d.ts +1 -0
  384. package/dist/types/content/Chart.d.ts +3 -91
  385. package/dist/types/content/ChartRoot.d.ts +92 -0
  386. package/dist/types/content/ChartSparkline.d.ts +5 -0
  387. package/dist/types/content/Lightbox.d.ts +2 -0
  388. package/dist/types/content/PdfViewer.d.ts +32 -0
  389. package/dist/types/content/ThumbnailStrip.d.ts +29 -0
  390. package/dist/types/content/chart-bar.d.ts +131 -2
  391. package/dist/types/content/chart-inspection-core.d.ts +7 -0
  392. package/dist/types/content/chart-inspection.d.ts +1 -0
  393. package/dist/types/content/chart-message-catalog.d.ts +8 -0
  394. package/dist/types/content/index.d.ts +3 -0
  395. package/dist/types/content/pdf-document.d.ts +5 -0
  396. package/dist/types/content/pdf-engine.d.ts +9 -0
  397. package/dist/types/content/pdf-limits.d.ts +43 -0
  398. package/dist/types/content/pdf-messages.d.ts +16 -0
  399. package/dist/types/content/thumbnail-strip-messages.d.ts +10 -0
  400. package/dist/types/inputs/ChoiceInputs.d.ts +6 -0
  401. package/dist/types/inputs/ChoiceSlider.d.ts +12 -0
  402. package/dist/types/inputs/DatePicker.d.ts +22 -0
  403. package/dist/types/inputs/PeriodPicker.d.ts +24 -0
  404. package/dist/types/inputs/index.d.ts +10 -2
  405. package/dist/types/inputs/input-messages.d.ts +3 -0
  406. package/dist/types/inputs/markdown/MarkdownEditor.d.ts +5 -0
  407. package/dist/types/inputs/markdown/MarkdownSelectionToolbar.d.ts +19 -0
  408. package/dist/types/inputs/markdown/SlashCommands.d.ts +20 -0
  409. package/dist/types/inputs/period-picker-messages.d.ts +34 -0
  410. package/dist/types/inputs/period.d.ts +134 -0
  411. package/dist/types/internal/field.d.ts +2 -0
  412. package/dist/types/layout/DetailPanel.d.ts +12 -0
  413. package/dist/types/layout/PanelDialog.d.ts +5 -0
  414. package/dist/types/layout/index.d.ts +1 -1
  415. package/dist/types/surfaces/DescriptionList.d.ts +5 -0
  416. package/dist/types/surfaces/StatCell.d.ts +6 -1
  417. package/dist/types/surfaces/stat-cell-messages.d.ts +1 -0
  418. package/dist/types/widgets/DashboardFrame.d.ts +61 -0
  419. package/dist/types/widgets/index.d.ts +1 -0
  420. package/package.json +3 -2
@@ -0,0 +1,57 @@
1
+ var Zr={9306(t,e,s){var i=s(4901),n=s(6823),r=TypeError;t.exports=function(a){if(i(a))return a;throw new r(n(a)+" is not a function")}},3506(t,e,s){var i=s(3925),n=String,r=TypeError;t.exports=function(a){if(i(a))return a;throw new r("Can't set "+n(a)+" as a prototype")}},7080(t,e,s){var i=s(4402).has;t.exports=function(n){return i(n),n}},3463(t){var e=TypeError;t.exports=function(s){if(typeof s=="string")return s;throw new e("Argument is not a string")}},4328(t,e,s){var i=s(4995),n=new i.WeakMap,{set:r,remove:a}=i;t.exports=function(o){return r(n,o,1),a(n,o),o}},6557(t,e,s){var i=s(4995).has;t.exports=function(n){return i(n),n}},6469(t,e,s){var i=s(8227),n=s(2360),r=s(4913).f,a=i("unscopables"),o=Array.prototype;if(o[a]===void 0)r(o,a,{configurable:!0,value:n(null)});t.exports=function(l){o[a][l]=!0}},679(t,e,s){var i=s(1625),n=TypeError;t.exports=function(r,a){if(i(a,r))return r;throw new n("Incorrect invocation")}},3972(t,e,s){var i=s(34),n=String,r=TypeError;t.exports=function(a){if(a===void 0||i(a))return a;throw new r(n(a)+" is not an object or undefined")}},8551(t,e,s){var i=s(34),n=String,r=TypeError;t.exports=function(a){if(i(a))return a;throw new r(n(a)+" is not an object")}},4154(t,e,s){var i=s(6955),n=TypeError;t.exports=function(r){if(i(r)==="Uint8Array")return r;throw new n("Argument is not an Uint8Array")}},7811(t){t.exports=typeof ArrayBuffer<"u"&&typeof DataView<"u"},7394(t,e,s){var i=s(4576),n=s(6706),r=s(2195),{ArrayBuffer:a,TypeError:o}=i;t.exports=a&&n(a.prototype,"byteLength","get")||function(l){if(r(l)!=="ArrayBuffer")throw new o("ArrayBuffer expected");return l.byteLength}},3238(t,e,s){var i=s(4576),n=s(7811),r=s(7394),a=i.DataView;t.exports=function(o){if(!n||r(o)!==0)return!1;try{return new a(o),!1}catch(l){return!0}}},5169(t,e,s){var i=s(3238),n=TypeError;t.exports=function(r){if(i(r))throw new n("ArrayBuffer is detached");return r}},4644(t,e,s){var i=s(7811),n=s(3724),r=s(4576),a=s(4901),o=s(34),l=s(9297),h=s(6955),c=s(6823),d=s(6699),u=s(6840),f=s(2106),p=s(1625),g=s(2787),m=s(2967),v=s(8227),y=s(3392),S=s(1181),{enforce:A,get:b}=S,w=r.Int8Array,x=w&&w.prototype,T=r.Uint8ClampedArray,E=T&&T.prototype,I=w&&g(w),C=x&&g(x),O=Object.prototype,D=r.TypeError,k=v("toStringTag"),R=y("TYPED_ARRAY_TAG"),M="TypedArrayConstructor",_=i&&!!m&&h(r.opera)!=="Opera",U=!1,G,it,rt,J={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},et={BigInt64Array:8,BigUint64Array:8},ht=function(Z){if(!o(Z))return!1;var lt=h(Z);return lt==="DataView"||l(J,lt)||l(et,lt)},Rt=function(V){var Z=g(V);if(!o(Z))return;var lt=b(Z);return lt&&l(lt,M)?lt[M]:Rt(Z)},N=function(V){if(!o(V))return!1;var Z=h(V);return l(J,Z)||l(et,Z)},P=function(V){if(N(V))return V;throw new D("Target is not a typed array")},F=function(V){if(a(V)&&(!m||p(I,V)))return V;throw new D(c(V)+" is not a typed array constructor")},X=function(V,Z,lt,xt){if(!n)return;if(lt)for(var Et in J){var vt=r[Et];if(vt&&l(vt.prototype,V))try{delete vt.prototype[V]}catch($t){try{vt.prototype[V]=Z}catch(Me){}}}if(!C[V]||lt)u(C,V,lt?Z:_&&x[V]||Z,xt)},nt=function(V,Z,lt){var xt,Et;if(!n)return;if(m){if(lt){for(xt in J)if(Et=r[xt],Et&&l(Et,V))try{delete Et[V]}catch(vt){}}if(!I[V]||lt)try{return u(I,V,lt?Z:_&&I[V]||Z)}catch(vt){}else return}for(xt in J)if(Et=r[xt],Et&&(!Et[V]||lt))u(Et,V,Z)};for(G in J)if(it=r[G],rt=it&&it.prototype,rt)A(rt)[M]=it;else _=!1;for(G in et)if(it=r[G],rt=it&&it.prototype,rt)A(rt)[M]=it;if(!_||!a(I)||I===Function.prototype){if(I=function(){throw new D("Incorrect invocation")},_){for(G in J)if(r[G])m(r[G],I)}}if(!_||!C||C===O){if(C=I.prototype,_){for(G in J)if(r[G])m(r[G].prototype,C)}}if(_&&g(E)!==C)m(E,C);if(n&&!l(C,k)){U=!0,f(C,k,{configurable:!0,get:function(){return o(this)?this[R]:void 0}});for(G in J)if(r[G])d(r[G].prototype,R,G)}t.exports={NATIVE_ARRAY_BUFFER_VIEWS:_,TYPED_ARRAY_TAG:U&&R,aTypedArray:P,aTypedArrayConstructor:F,exportTypedArrayMethod:X,exportTypedArrayStaticMethod:nt,getTypedArrayConstructor:Rt,isView:ht,isTypedArray:N,TypedArray:I,TypedArrayPrototype:C}},5370(t,e,s){var i=s(6198);t.exports=function(n,r,a){var o=0,l=arguments.length>2?a:i(r),h=new n(l);while(l>o)h[o]=r[o++];return h}},9617(t,e,s){var i=s(5397),n=s(5610),r=s(6198),a=function(o){return function(l,h,c){var d=i(l),u=r(d);if(u===0)return!o&&-1;var f=n(c,u),p;if(o&&h!==h){while(u>f)if(p=d[f++],p!==p)return!0}else for(;u>f;f++)if((o||(f in d))&&d[f]===h)return o||f||0;return!o&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}},4527(t,e,s){var i=s(3724),n=s(4376),r=TypeError,a=Object.getOwnPropertyDescriptor,o=i&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(l){return l instanceof TypeError}}();t.exports=o?function(l,h){if(n(l)&&!a(l,"length").writable)throw new r("Cannot set read only .length");return l.length=h}:function(l,h){return l.length=h}},7680(t,e,s){var i=s(9504);t.exports=i([].slice)},2804(t){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=e+"+/",i=e+"-_",n=function(r){var a={},o=0;for(;o<64;o++)a[r.charAt(o)]=o;return a};t.exports={i2c:s,c2i:n(s),i2cUrl:i,c2iUrl:n(i)}},6319(t,e,s){var i=s(8551),n=s(9539);t.exports=function(r,a,o,l){try{return l?a(i(o)[0],o[1]):a(o)}catch(h){n(r,"throw",h)}}},2195(t,e,s){var i=s(9504),n=i({}.toString),r=i("".slice);t.exports=function(a){return r(n(a),8,-1)}},6955(t,e,s){var i=s(2140),n=s(4901),r=s(2195),a=s(8227),o=a("toStringTag"),l=Object,h=r(function(){return arguments}())==="Arguments",c=function(d,u){try{return d[u]}catch(f){}};t.exports=i?r:function(d){var u,f,p;return d===void 0?"Undefined":d===null?"Null":typeof(f=c(u=l(d),o))=="string"?f:h?r(u):(p=r(u))==="Object"&&n(u.callee)?"Arguments":p}},7740(t,e,s){var i=s(9297),n=s(5031),r=s(7347),a=s(4913);t.exports=function(o,l,h){var c=n(l),d=a.f,u=r.f;for(var f=0;f<c.length;f++){var p=c[f];if(!i(o,p)&&!(h&&i(h,p)))d(o,p,u(l,p))}}},2211(t,e,s){var i=s(9039);t.exports=!i(function(){function n(){}return n.prototype.constructor=null,Object.getPrototypeOf(new n)!==n.prototype})},2529(t){t.exports=function(e,s){return{value:e,done:s}}},6699(t,e,s){var i=s(3724),n=s(4913),r=s(6980);t.exports=i?function(a,o,l){return n.f(a,o,r(1,l))}:function(a,o,l){return a[o]=l,a}},6980(t){t.exports=function(e,s){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:s}}},4659(t,e,s){var i=s(3724),n=s(4913),r=s(6980);t.exports=function(a,o,l){if(i)n.f(a,o,r(0,l));else a[o]=l}},2106(t,e,s){var i=s(283),n=s(4913);t.exports=function(r,a,o){if(o.get)i(o.get,a,{getter:!0});if(o.set)i(o.set,a,{setter:!0});return n.f(r,a,o)}},6840(t,e,s){var i=s(4901),n=s(4913),r=s(283),a=s(9433);t.exports=function(o,l,h,c){if(!c)c={};var d=c.enumerable,u=c.name!==void 0?c.name:l;if(i(h))r(h,u,c);if(c.global)if(d)o[l]=h;else a(l,h);else{try{if(!c.unsafe)delete o[l];else if(o[l])d=!0}catch(f){}if(d)o[l]=h;else n.f(o,l,{value:h,enumerable:!1,configurable:!c.nonConfigurable,writable:!c.nonWritable})}return o}},6279(t,e,s){var i=s(6840);t.exports=function(n,r,a){for(var o in r)i(n,o,r[o],a);return n}},9433(t,e,s){var i=s(4576),n=Object.defineProperty;t.exports=function(r,a){try{n(i,r,{value:a,configurable:!0,writable:!0})}catch(o){i[r]=a}return a}},3724(t,e,s){var i=s(9039);t.exports=!i(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})},4055(t,e,s){var i=s(4576),n=s(34),r=i.document,a=n(r)&&n(r.createElement);t.exports=function(o){return a?r.createElement(o):{}}},6837(t){var e=TypeError,s=9007199254740991;t.exports=function(i){if(i>s)throw new e("Maximum allowed index exceeded");return i}},5002(t){t.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},8727(t){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2839(t,e,s){var i=s(4576),n=i.navigator,r=n&&n.userAgent;t.exports=r?String(r):""},9519(t,e,s){var i=s(4576),n=s(2839),{process:r,Deno:a}=i,o=r&&r.versions||a&&a.version,l=o&&o.v8,h,c;if(l)h=l.split("."),c=h[0]>0&&h[0]<4?1:+(h[0]+h[1]);if(!c&&n){if(h=n.match(/Edge\/(\d+)/),!h||h[1]>=74){if(h=n.match(/Chrome\/(\d+)/),h)c=+h[1]}}t.exports=c},6193(t,e,s){var i=s(9504),n=Error,r=i("".replace),a=function(h){return String(new n(h).stack)}("zxcasd"),o=/\n\s*at [^:]*:[^\n]*/,l=o.test(a);t.exports=function(h,c){if(l&&typeof h=="string"&&!n.prepareStackTrace)while(c--)h=r(h,o,"");return h}},6518(t,e,s){var i=s(4576),n=s(7347).f,r=s(6699),a=s(6840),o=s(9433),l=s(7740),h=s(2796);t.exports=function(c,d){var{target:u,global:f,stat:p}=c,g,m,v,y,S,A;if(f)m=i;else if(p)m=i[u]||o(u,{});else m=i[u]&&i[u].prototype;if(m)for(v in d){if(S=d[v],c.dontCallGetSet)A=n(m,v),y=A&&A.value;else y=m[v];if(g=h(f?v:u+(p?".":"#")+v,c.forced),!g&&y!==void 0){if(typeof S==typeof y)continue;l(S,y)}if(c.sham||y&&y.sham)r(S,"sham",!0);a(m,v,S,c)}}},9039(t){t.exports=function(e){try{return!!e()}catch(s){return!0}}},8745(t,e,s){var i=s(616),n=Function.prototype,{apply:r,call:a}=n;t.exports=typeof Reflect=="object"&&Reflect.apply||(i?a.bind(r):function(){return a.apply(r,arguments)})},6080(t,e,s){var i=s(7476),n=s(9306),r=s(616),a=i(i.bind);t.exports=function(o,l){return n(o),l===void 0?o:r?a(o,l):function(){return o.apply(l,arguments)}}},616(t,e,s){var i=s(9039);t.exports=!i(function(){var n=function(){}.bind();return typeof n!="function"||n.hasOwnProperty("prototype")})},9565(t,e,s){var i=s(616),n=Function.prototype.call;t.exports=i?n.bind(n):function(){return n.apply(n,arguments)}},350(t,e,s){var i=s(3724),n=s(9297),r=Function.prototype,a=i&&Object.getOwnPropertyDescriptor,o=n(r,"name"),l=o&&function(){}.name==="something",h=o&&(!i||i&&a(r,"name").configurable);t.exports={EXISTS:o,PROPER:l,CONFIGURABLE:h}},6706(t,e,s){var i=s(9504),n=s(9306);t.exports=function(r,a,o){try{return i(n(Object.getOwnPropertyDescriptor(r,a)[o]))}catch(l){}}},7476(t,e,s){var i=s(2195),n=s(9504);t.exports=function(r){if(i(r)==="Function")return n(r)}},9504(t,e,s){var i=s(616),n=Function.prototype,r=n.call,a=i&&n.bind.bind(r,r);t.exports=i?a:function(o){return function(){return r.apply(o,arguments)}}},944(t){var e=TypeError;t.exports=function(s){var i=s&&s.alphabet;if(i===void 0||i==="base64"||i==="base64url")return i||"base64";throw new e("Incorrect `alphabet` option")}},7751(t,e,s){var i=s(4576),n=s(4901),r=function(a){return n(a)?a:void 0};t.exports=function(a,o){return arguments.length<2?r(i[a]):i[a]&&i[a][o]}},1767(t){t.exports=function(e){return{iterator:e,next:e.next,done:!1}}},8646(t,e,s){var i=s(9565),n=s(8551),r=s(1767),a=s(3085);t.exports=function(o,l){if(!l||typeof o!=="string")n(o);var h=a(o);return r(n(h!==void 0?i(h,o):o))}},8563(t,e,s){var i=s(9565),n=s(4901),r=s(8551),a=s(6823),o=s(3085),l=TypeError;t.exports=function(h,c){var d=arguments.length<2?o(h):c;if(n(d))return r(i(d,h));throw new l(a(h)+" is not iterable")}},3085(t,e,s){var i=s(2195),n=s(4117),r=s(5966),a=s(8227),o=a("iterator"),l=Array.prototype;t.exports=function(h){if(!n(h))return r(h,o)||r(h,"@@iterator")||(i(h)==="Arguments"?l[o]:void 0)}},5966(t,e,s){var i=s(9306),n=s(4117);t.exports=function(r,a){var o=r[a];return n(o)?void 0:i(o)}},3789(t,e,s){var i=s(9306),n=s(8551),r=s(9565),a=s(1291),o=s(1767),l="Invalid size",h=RangeError,c=TypeError,d=Math.max,u=function(f,p){this.set=f,this.size=d(p,0),this.has=i(f.has),this.keys=i(f.keys)};u.prototype={getIterator:function(){return o(n(r(this.keys,this.set)))},includes:function(f){return r(this.has,this.set,f)}},t.exports=function(f){n(f);var p=+f.size;if(p!==p)throw new c(l);var g=a(p);if(g<0)throw new h(l);return new u(f,g)}},4576(t){var e=function(s){return s&&s.Math===Math&&s};t.exports=e(typeof globalThis=="object"&&globalThis)||e(typeof window=="object"&&window)||e(typeof self=="object"&&self)||e(typeof global=="object"&&global)||e(typeof this=="object"&&this)||function(){return this}()||Function("return this")()},9297(t,e,s){var i=s(9504),n=s(8981),r=i({}.hasOwnProperty);t.exports=Object.hasOwn||function(o,l){return r(n(o),l)}},421(t){t.exports={}},397(t,e,s){var i=s(7751);t.exports=i("document","documentElement")},5917(t,e,s){var i=s(3724),n=s(9039),r=s(4055);t.exports=!i&&!n(function(){return Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a!==7})},7055(t,e,s){var i=s(9504),n=s(9039),r=s(2195),a=Object,o=i("".split);t.exports=n(function(){return!a("z").propertyIsEnumerable(0)})?function(l){return r(l)==="String"?o(l,""):a(l)}:a},3167(t,e,s){var i=s(4901),n=s(34),r=s(2967);t.exports=function(a,o,l){var h,c;if(r&&i(h=o.constructor)&&h!==l&&n(c=h.prototype)&&c!==l.prototype)r(a,c);return a}},3706(t,e,s){var i=s(9504),n=s(4901),r=s(7629),a=i(Function.toString);if(!n(r.inspectSource))r.inspectSource=function(o){return a(o)};t.exports=r.inspectSource},1181(t,e,s){var i=s(8622),n=s(4576),r=s(34),a=s(6699),o=s(9297),l=s(7629),h=s(6119),c=s(421),d="Object already initialized",{TypeError:u,WeakMap:f}=n,p,g,m,v=function(b){return m(b)?g(b):p(b,{})},y=function(b){return function(w){var x;if(!r(w)||(x=g(w)).type!==b)throw new u("Incompatible receiver, "+b+" required");return x}};if(i||l.state){var S=l.state||(l.state=new f);S.get=S.get,S.has=S.has,S.set=S.set,p=function(b,w){if(S.has(b))throw new u(d);return w.facade=b,S.set(b,w),w},g=function(b){return S.get(b)||{}},m=function(b){return S.has(b)}}else{var A=h("state");c[A]=!0,p=function(b,w){if(o(b,A))throw new u(d);return w.facade=b,a(b,A,w),w},g=function(b){return o(b,A)?b[A]:{}},m=function(b){return o(b,A)}}t.exports={set:p,get:g,has:m,enforce:v,getterFor:y}},4209(t,e,s){var i=s(8227),n=s(6269),r=i("iterator"),a=Array.prototype;t.exports=function(o){return o!==void 0&&(n.Array===o||a[r]===o)}},4376(t,e,s){var i=s(2195);t.exports=Array.isArray||function(r){return i(r)==="Array"}},1108(t,e,s){var i=s(6955);t.exports=function(n){var r=i(n);return r==="BigInt64Array"||r==="BigUint64Array"}},4901(t){var e=typeof document=="object"&&document.all;t.exports=typeof e>"u"&&e!==void 0?function(s){return typeof s=="function"||s===e}:function(s){return typeof s=="function"}},2796(t,e,s){var i=s(9039),n=s(4901),r=/#|\.prototype\./,a=function(d,u){var f=l[o(d)];return f===c?!0:f===h?!1:n(u)?i(u):!!u},o=a.normalize=function(d){return String(d).replace(r,".").toLowerCase()},l=a.data={},h=a.NATIVE="N",c=a.POLYFILL="P";t.exports=a},4117(t){t.exports=function(e){return e===null||e===void 0}},34(t,e,s){var i=s(4901);t.exports=function(n){return typeof n=="object"?n!==null:i(n)}},3925(t,e,s){var i=s(34);t.exports=function(n){return i(n)||n===null}},6395(t){t.exports=!1},5810(t,e,s){var i=s(34),n=s(1181).get;t.exports=function(a){if(!i(a))return!1;var o=n(a);return!!o&&o.type==="RawJSON"}},757(t,e,s){var i=s(7751),n=s(4901),r=s(1625),a=s(7040),o=Object;t.exports=a?function(l){return typeof l=="symbol"}:function(l){var h=i("Symbol");return n(h)&&r(h.prototype,o(l))}},507(t,e,s){var i=s(9565);t.exports=function(n,r,a){var o=a?n:n.iterator,l=n.next,h,c;while(!(h=i(l,o)).done)if(c=r(h.value),c!==void 0)return c}},2652(t,e,s){var i=s(6080),n=s(9565),r=s(8551),a=s(6823),o=s(4209),l=s(6198),h=s(1625),c=s(8563),d=s(3085),u=s(9539),f=TypeError,p=function(m,v){this.stopped=m,this.result=v},g=p.prototype;t.exports=function(m,v,y){var S=y&&y.that,A=!!(y&&y.AS_ENTRIES),b=!!(y&&y.IS_RECORD),w=!!(y&&y.IS_ITERATOR),x=!!(y&&y.INTERRUPTED),T=i(v,S),E,I,C,O,D,k,R,M=function(G){var it=E;if(E=void 0,it)u(it,"normal");return new p(!0,G)},_=function(G){if(A)return r(G),x?T(G[0],G[1],M):T(G[0],G[1]);return x?T(G,M):T(G)};if(b)E=m.iterator;else if(w)E=m;else{if(I=d(m),!I)throw new f(a(m)+" is not iterable");if(o(I)){for(C=0,O=l(m);O>C;C++)if(D=_(m[C]),D&&h(g,D))return D;return new p(!1)}E=c(m,I)}k=b?m.next:E.next;while(!(R=n(k,E)).done){var U=R.value;try{D=_(U)}catch(G){if(E)u(E,"throw",G);else throw G}if(typeof D=="object"&&D&&h(g,D))return D}return new p(!1)}},6859(t){t.exports=function(e){e.iterator=e.next=e.nextHandler=e.mapper=e.predicate=e.inner=e.iterables=e.iters=e.openIters=e.padding=e.finishResults=e.buffer=null}},1385(t,e,s){var i=s(9539);t.exports=function(n,r,a){for(var o=n.length-1;o>=0;o--){if(n[o]===void 0)continue;try{a=i(n[o].iterator,r,a)}catch(l){r="throw",a=l}}if(r==="throw")throw a;return a}},9539(t,e,s){var i=s(9565),n=s(8551),r=s(5966);t.exports=function(a,o,l){var h,c;n(a);try{if(h=r(a,"return"),!h){if(o==="throw")throw l;return l}h=i(h,a)}catch(d){c=!0,h=d}if(o==="throw")throw l;if(c)throw h;return n(h),l}},9462(t,e,s){var i=s(9565),n=s(2360),r=s(6699),a=s(6279),o=s(8227),l=s(1181),h=s(5966),c=s(7657).IteratorPrototype,d=s(2529),u=s(9539),f=s(1385),p=s(6859),g=o("toStringTag"),m="IteratorHelper",v="WrapForValidIterator",y="normal",S="throw",A=l.set,b=function(T){var E=l.getterFor(T?v:m);return a(n(c),{next:function(){var C=E(this);if(T)return C.nextHandler();if(C.done)return d(void 0,!0);try{var O=C.nextHandler();if(C.done)p(C);return C.returnHandlerResult?O:d(O,C.done)}catch(D){throw C.done=!0,p(C),D}},return:function(){var I=E(this),{iterator:C,inner:O,openIters:D,done:k}=I;if(I.done=!0,T){var R=h(C,"return");return R?i(R,C):d(void 0,!0)}if(p(I),k)return d(void 0,!0);if(O)try{u(O.iterator,y)}catch(M){return u(C,S,M)}if(D)try{f(D,y)}catch(M){if(C)return u(C,S,M);throw M}if(C)u(C,y);return d(void 0,!0)}})},w=b(!0),x=b(!1);r(x,g,"Iterator Helper"),t.exports=function(T,E,I){var C=function(D,k){if(k)k.iterator=D.iterator,k.next=D.next;else k=D;k.type=E?v:m,k.returnHandlerResult=!!I,k.nextHandler=T,k.counter=0,k.done=!1,A(this,k)};return C.prototype=E?w:x,C}},684(t){t.exports=function(e,s){var i=typeof Iterator=="function"&&Iterator.prototype[e];if(i)try{i.call({next:null},s).next()}catch(n){return!0}}},4549(t,e,s){var i=s(4576);t.exports=function(n,r){var a=i.Iterator,o=a&&a.prototype,l=o&&o[n],h=!1;if(l)try{l.call({next:function(){return{done:!0}},return:function(){h=!0}},-1)}catch(c){if(!(c instanceof r))h=!1}if(!h)return l}},7657(t,e,s){var i=s(9039),n=s(4901),r=s(34),a=s(2360),o=s(2787),l=s(6840),h=s(8227),c=s(6395),d=h("iterator"),u=!1,f,p,g;if([].keys){if(g=[].keys(),!("next"in g))u=!0;else if(p=o(o(g)),p!==Object.prototype)f=p}var m=!r(f)||i(function(){var v={};return f[d].call(v)!==v});if(m)f={};else if(c)f=a(f);if(!n(f[d]))l(f,d,function(){return this});t.exports={IteratorPrototype:f,BUGGY_SAFARI_ITERATORS:u}},6269(t){t.exports=Object.create?Object.create(null):{}},6198(t,e,s){var i=s(8014);t.exports=function(n){return i(n.length)}},283(t,e,s){var i=s(9504),n=s(9039),r=s(4901),a=s(9297),o=s(3724),l=s(350).CONFIGURABLE,h=s(3706),c=s(1181),{enforce:d,get:u}=c,f=String,p=Object.defineProperty,g=i("".slice),m=i("".replace),v=i([].join),y=o&&!n(function(){return p(function(){},"length",{value:8}).length!==8}),S=String(String).split("String"),A=t.exports=function(b,w,x){if(g(f(w),0,7)==="Symbol(")w="["+m(f(w),/^Symbol\(([^)]*)\).*$/,"$1")+"]";if(x&&x.getter)w="get "+w;if(x&&x.setter)w="set "+w;if(!a(b,"name")||l&&b.name!==w)if(o)p(b,"name",{value:w,configurable:!0});else b.name=w;if(y&&x&&a(x,"arity")&&b.length!==x.arity)p(b,"length",{value:x.arity});try{if(x&&a(x,"constructor")&&x.constructor){if(o)p(b,"prototype",{writable:!1})}else if(b.prototype)b.prototype=void 0}catch(E){}var T=d(b);if(!a(T,"source"))T.source=v(S,typeof w=="string"?w:"");return b};Function.prototype.toString=A(function(){return r(this)&&u(this).source||h(this)},"toString")},2248(t,e,s){var i=s(9504),n=Map.prototype;t.exports={Map,set:i(n.set),get:i(n.get),has:i(n.has),remove:i(n.delete),proto:n}},741(t){var{ceil:e,floor:s}=Math;t.exports=Math.trunc||function(n){var r=+n;return(r>0?s:e)(r)}},7819(t,e,s){var i=s(9039);t.exports=!i(function(){var n="9007199254740993",r=JSON.rawJSON(n);return!JSON.isRawJSON(r)||JSON.stringify(r)!==n})},6043(t,e,s){var i=s(9306),n=TypeError,r=function(a){var o,l;this.promise=new a(function(h,c){if(o!==void 0||l!==void 0)throw new n("Bad Promise constructor");o=h,l=c}),this.resolve=i(o),this.reject=i(l)};t.exports.f=function(a){return new r(a)}},2603(t,e,s){var i=s(655);t.exports=function(n,r){return n===void 0?arguments.length<2?"":r:i(n)}},4149(t){var e=RangeError;t.exports=function(s){if(s===s)return s;throw new e("NaN is not allowed")}},2360(t,e,s){var i=s(8551),n=s(6801),r=s(8727),a=s(421),o=s(397),l=s(4055),h=s(6119),c=">",d="<",u="prototype",f="script",p=h("IE_PROTO"),g=function(){},m=function(b){return d+f+c+b+d+"/"+f+c},v=function(b){b.write(m("")),b.close();var w=b.parentWindow.Object;return b=null,w},y=function(){var b=l("iframe"),w="java"+f+":",x;return b.style.display="none",o.appendChild(b),b.src=String(w),x=b.contentWindow.document,x.open(),x.write(m("document.F=Object")),x.close(),x.F},S,A=function(){try{S=new ActiveXObject("htmlfile")}catch(w){}A=typeof document<"u"?document.domain&&S?v(S):y():v(S);var b=r.length;while(b--)delete A[u][r[b]];return A()};a[p]=!0,t.exports=Object.create||function(w,x){var T;if(w!==null)g[u]=i(w),T=new g,g[u]=null,T[p]=w;else T=A();return x===void 0?T:n.f(T,x)}},6801(t,e,s){var i=s(3724),n=s(8686),r=s(4913),a=s(8551),o=s(5397),l=s(1072);e.f=i&&!n?Object.defineProperties:function(c,d){a(c);var u=o(d),f=l(d),p=f.length,g=0,m;while(p>g)r.f(c,m=f[g++],u[m]);return c}},4913(t,e,s){var i=s(3724),n=s(5917),r=s(8686),a=s(8551),o=s(6969),l=TypeError,{defineProperty:h,getOwnPropertyDescriptor:c}=Object,d="enumerable",u="configurable",f="writable";e.f=i?r?function(g,m,v){if(a(g),m=o(m),a(v),typeof g==="function"&&m==="prototype"&&"value"in v&&f in v&&!v[f]){var y=c(g,m);if(y&&y[f])g[m]=v.value,v={configurable:u in v?v[u]:y[u],enumerable:d in v?v[d]:y[d],writable:!1}}return h(g,m,v)}:h:function(g,m,v){if(a(g),m=o(m),a(v),n)try{return h(g,m,v)}catch(y){}if("get"in v||"set"in v)throw new l("Accessors not supported");if("value"in v)g[m]=v.value;return g}},7347(t,e,s){var i=s(3724),n=s(9565),r=s(8773),a=s(6980),o=s(5397),l=s(6969),h=s(9297),c=s(5917),d=Object.getOwnPropertyDescriptor;e.f=i?d:function(f,p){if(f=o(f),p=l(p),c)try{return d(f,p)}catch(g){}if(h(f,p))return a(!n(r.f,f,p),f[p])}},8480(t,e,s){var i=s(1828),n=s(8727),r=n.concat("length","prototype");e.f=Object.getOwnPropertyNames||function(o){return i(o,r)}},3717(t,e){e.f=Object.getOwnPropertySymbols},2787(t,e,s){var i=s(9297),n=s(4901),r=s(8981),a=s(6119),o=s(2211),l=a("IE_PROTO"),h=Object,c=h.prototype;t.exports=o?h.getPrototypeOf:function(d){var u=r(d);if(i(u,l))return u[l];var f=u.constructor;if(n(f)&&u instanceof f)return f.prototype;return u instanceof h?c:null}},1625(t,e,s){var i=s(9504);t.exports=i({}.isPrototypeOf)},1828(t,e,s){var i=s(9504),n=s(9297),r=s(5397),a=s(9617).indexOf,o=s(421),l=i([].push);t.exports=function(h,c){var d=r(h),u=0,f=[],p;for(p in d)!n(o,p)&&n(d,p)&&l(f,p);while(c.length>u)if(n(d,p=c[u++]))~a(f,p)||l(f,p);return f}},1072(t,e,s){var i=s(1828),n=s(8727);t.exports=Object.keys||function(a){return i(a,n)}},8773(t,e){var s={}.propertyIsEnumerable,i=Object.getOwnPropertyDescriptor,n=i&&!s.call({1:2},1);e.f=n?function(a){var o=i(this,a);return!!o&&o.enumerable}:s},2967(t,e,s){var i=s(6706),n=s(34),r=s(7750),a=s(3506);t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var o=!1,l={},h;try{h=i(Object.prototype,"__proto__","set"),h(l,[]),o=l instanceof Array}catch(c){}return function(d,u){if(r(d),a(u),!n(d))return d;if(o)h(d,u);else d.__proto__=u;return d}}():void 0)},4270(t,e,s){var i=s(9565),n=s(4901),r=s(34),a=TypeError;t.exports=function(o,l){var h,c;if(l==="string"&&n(h=o.toString)&&!r(c=i(h,o)))return c;if(n(h=o.valueOf)&&!r(c=i(h,o)))return c;if(l!=="string"&&n(h=o.toString)&&!r(c=i(h,o)))return c;throw new a("Can't convert object to primitive value")}},5031(t,e,s){var i=s(7751),n=s(9504),r=s(8480),a=s(3717),o=s(8551),l=n([].concat);t.exports=i("Reflect","ownKeys")||function(c){var d=r.f(o(c)),u=a.f;return u?l(d,u(c)):d}},8235(t,e,s){var i=s(9504),n=s(9297),r=SyntaxError,a=parseInt,o=String.fromCharCode,l=i("".charAt),h=i("".slice),c=i(/./.exec),d={"\\\"":'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
2
+ `,"\\r":"\r","\\t":"\t"},u=/^[\da-f]{4}$/i,f=/^[\u0000-\u001F]$/;t.exports=function(p,g){var m=!0,v="";while(g<p.length){var y=l(p,g);if(y==="\\"){var S=h(p,g,g+2);if(n(d,S))v+=d[S],g+=2;else if(S==="\\u"){g+=2;var A=h(p,g,g+4);if(!c(u,A))throw new r("Bad Unicode escape at: "+g);v+=o(a(A,16)),g+=4}else throw new r('Unknown escape sequence: "'+S+'"')}else if(y==='"'){m=!1,g++;break}else{if(c(f,y))throw new r("Bad control character in string literal at: "+g);v+=y,g++}}if(m)throw new r("Unterminated string at: "+g);return{value:v,end:g}}},1103(t){t.exports=function(e){try{return{error:!1,value:e()}}catch(s){return{error:!0,value:s}}}},3438(t,e,s){var i=s(8551),n=s(34),r=s(6043);t.exports=function(a,o){if(i(a),n(o)&&o.constructor===a)return o;var l=r.f(a),h=l.resolve;return h(o),l.promise}},7750(t,e,s){var i=s(4117),n=TypeError;t.exports=function(r){if(i(r))throw new n("Can't call method on "+r);return r}},9286(t,e,s){var i=s(4402),n=s(8469),{Set:r,add:a}=i;t.exports=function(o){var l=new r;return n(o,function(h){a(l,h)}),l}},3440(t,e,s){var i=s(7080),n=s(4402),r=s(9286),a=s(5170),o=s(3789),l=s(8469),h=s(507),{has:c,remove:d}=n;t.exports=function(f){var p=i(this),g=o(f),m=r(p);if(a(m)<=g.size)l(m,function(v){if(g.includes(v))d(m,v)});else h(g.getIterator(),function(v){if(c(m,v))d(m,v)});return m}},4402(t,e,s){var i=s(9504),n=Set.prototype;t.exports={Set,add:i(n.add),has:i(n.has),remove:i(n.delete),proto:n}},8750(t,e,s){var i=s(7080),n=s(4402),r=s(5170),a=s(3789),o=s(8469),l=s(507),{Set:h,add:c,has:d}=n;t.exports=function(f){var p=i(this),g=a(f),m=new h;if(r(p)>g.size)l(g.getIterator(),function(v){if(d(p,v))c(m,v)});else o(p,function(v){if(g.includes(v))c(m,v)});return m}},4449(t,e,s){var i=s(7080),n=s(4402).has,r=s(5170),a=s(3789),o=s(8469),l=s(507),h=s(9539);t.exports=function(d){var u=i(this),f=a(d);if(r(u)<=f.size)return o(u,function(g){if(f.includes(g))return!1},!0)!==!1;var p=f.getIterator();return l(p,function(g){if(n(u,g))return h(p.iterator,"normal",!1)})!==!1}},3838(t,e,s){var i=s(7080),n=s(5170),r=s(8469),a=s(3789);t.exports=function(l){var h=i(this),c=a(l);if(n(h)>c.size)return!1;return r(h,function(d){if(!c.includes(d))return!1},!0)!==!1}},8527(t,e,s){var i=s(7080),n=s(4402).has,r=s(5170),a=s(3789),o=s(507),l=s(9539);t.exports=function(c){var d=i(this),u=a(c);if(r(d)<u.size)return!1;var f=u.getIterator();return o(f,function(p){if(!n(d,p))return l(f.iterator,"normal",!1)})!==!1}},8469(t,e,s){var i=s(9504),n=s(507),r=s(4402),{Set:a,proto:o}=r,l=i(o.forEach),h=i(o.keys),c=h(new a).next;t.exports=function(d,u,f){return f?n({iterator:h(d),next:c},u):l(d,u)}},4916(t,e,s){var i=s(7751),n=function(a){return{size:a,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},r=function(a){return{size:a,has:function(){return!0},keys:function(){throw Error("e")}}};t.exports=function(a,o){var l=i("Set");try{new l()[a](n(0));try{return new l()[a](n(-1)),!1}catch(c){if(!o)return!0;try{return new l()[a](r(-1/0)),!1}catch(d){var h=new l([1,2]);return o(h[a](r(1/0)))}}}catch(c){return!1}}},9835(t){t.exports=function(e){try{var s=new Set,i={size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){return s.clear(),s.add(4),function(){return{done:!0}}}})}},n=s[e](i);return n.size===1&&n.values().next().value===4}catch(r){return!1}}},5170(t,e,s){var i=s(6706),n=s(4402);t.exports=i(n.proto,"size","get")||function(r){return r.size}},3650(t,e,s){var i=s(7080),n=s(4402),r=s(9286),a=s(3789),o=s(507),{add:l,has:h,remove:c}=n;t.exports=function(u){var f=i(this),p=a(u).getIterator(),g=r(f);return o(p,function(m){if(h(f,m))c(g,m);else l(g,m)}),g}},4204(t,e,s){var i=s(7080),n=s(4402).add,r=s(9286),a=s(3789),o=s(507);t.exports=function(h){var c=i(this),d=a(h).getIterator(),u=r(c);return o(d,function(f){n(u,f)}),u}},6119(t,e,s){var i=s(5745),n=s(3392),r=i("keys");t.exports=function(a){return r[a]||(r[a]=n(a))}},7629(t,e,s){var i=s(6395),n=s(4576),r=s(9433),a="__core-js_shared__",o=t.exports=n[a]||r(a,{});(o.versions||(o.versions=[])).push({version:"3.50.0",mode:i?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.50.0/LICENSE",source:"https://github.com/zloirock/core-js"})},5745(t,e,s){var i=s(7629),n=Object.create||Object;t.exports=function(r,a){return i[r]||(i[r]=a||n(null))}},4495(t,e,s){var i=s(9519),n=s(9039),r=s(4576),a=r.String;t.exports=!!Object.getOwnPropertySymbols&&!n(function(){var o=Symbol("symbol detection");return!a(o)||!(Object(o)instanceof Symbol)||!Symbol.sham&&i&&i<41})},1240(t,e,s){var i=s(9504);t.exports=i(1.1 .valueOf)},5610(t,e,s){var i=s(1291),{max:n,min:r}=Math;t.exports=function(a,o){var l=i(a);return l<0?n(l+o,0):r(l,o)}},5854(t,e,s){var i=s(2777),n=TypeError;t.exports=function(r){var a=i(r,"number");if(typeof a=="number")throw new n("Can't convert number to bigint");return BigInt(a)}},5397(t,e,s){var i=s(7055),n=s(7750);t.exports=function(r){return i(n(r))}},1291(t,e,s){var i=s(741);t.exports=function(n){var r=+n;return r!==r||r===0?0:i(r)}},8014(t,e,s){var i=s(1291),n=Math.min;t.exports=function(r){var a=i(r);return a>0?n(a,9007199254740991):0}},8981(t,e,s){var i=s(7750),n=Object;t.exports=function(r){return n(i(r))}},9590(t,e,s){var i=s(1291),n=RangeError;t.exports=function(r){var a=i(r);if(a<0)throw new n("The argument can't be less than 0");return a}},2777(t,e,s){var i=s(9565),n=s(34),r=s(757),a=s(5966),o=s(4270),l=s(8227),h=TypeError,c=l("toPrimitive");t.exports=function(d,u){if(!n(d)||r(d))return d;var f=a(d,c),p;if(f){if(u===void 0)u="default";if(p=i(f,d,u),!n(p)||r(p))return p;throw new h("Can't convert object to primitive value")}if(u===void 0)u="number";return o(d,u)}},6969(t,e,s){var i=s(2777),n=s(757);t.exports=function(r){var a=i(r,"string");return n(a)?a:a+""}},2140(t,e,s){var i=s(8227),n=i("toStringTag"),r={};r[n]="z",t.exports=String(r)==="[object z]"},655(t,e,s){var i=s(6955),n=String;t.exports=function(r){if(i(r)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return n(r)}},6823(t){var e=String;t.exports=function(s){try{return e(s)}catch(i){return"Object"}}},3392(t,e,s){var i=s(9504),n=0,r=Math.random(),a=i(1.1 .toString);t.exports=function(o){return"Symbol("+(o===void 0?"":o)+")_"+a(++n+r,36)}},9143(t,e,s){var i=s(4576),n=s(9504),r=s(3972),a=s(3463),o=s(9297),l=s(2804),h=s(944),c=s(5169),{c2i:d,c2iUrl:u}=l,{SyntaxError:f,TypeError:p,Array:g}=i,m=n("".charAt),v=Math.floor,y=function(b,w){var x=b.length;for(;w<x;w++){var T=m(b,w);if(T!==" "&&T!=="\t"&&T!==`
3
+ `&&T!=="\f"&&T!=="\r")break}return w},S=function(b,w,x){var T=b.length;if(T<4)b+=T===2?"AA":"A";var E=(w[m(b,0)]<<18)+(w[m(b,1)]<<12)+(w[m(b,2)]<<6)+w[m(b,3)],I=[E>>16&255,E>>8&255,E&255];if(T===2){if(x&&I[1]!==0)throw new f("Extra bits");return[I[0]]}if(T===3){if(x&&I[2]!==0)throw new f("Extra bits");return[I[0],I[1]]}return I},A=function(b,w,x){var T=w.length;for(var E=0;E<T;E++)b[x+E]=w[E];return x+T};t.exports=function(b,w,x,T){a(b),r(w);var E=h(w)==="base64"?d:u,I=w?w.lastChunkHandling:void 0;if(I===void 0)I="loose";if(I!=="loose"&&I!=="strict"&&I!=="stop-before-partial")throw new p("Incorrect `lastChunkHandling` option");if(x)c(x.buffer);var C=b.length,O=x||g(v(C*3/4)),D=0,k=0,R="",M=0;if(T)while(!0){if(M=y(b,M),M===C){if(R.length>0){if(I==="stop-before-partial")break;if(I==="loose"){if(R.length===1)throw new f("Malformed padding: exactly one additional character");D=A(O,S(R,E,!1),D)}else throw new f("Missing padding")}k=C;break}var _=m(b,M);if(++M,_==="="){if(R.length<2)throw new f("Padding is too early");if(M=y(b,M),R.length===2){if(M===C){if(I==="stop-before-partial")break;throw new f("Malformed padding: only one =")}if(m(b,M)==="=")++M,M=y(b,M)}if(M<C)throw new f("Unexpected character after padding");D=A(O,S(R,E,I==="strict"),D),k=C;break}if(!o(E,_))throw new f("Unexpected character");var U=T-D;if(U===1&&R.length===2||U===2&&R.length===3)break;if(R+=_,R.length===4){if(D=A(O,S(R,E,!1),D),R="",k=M,D===T)break}}if(!x)O.length=D;return{bytes:O,read:k,written:D}}},2303(t,e,s){var i=s(4576),n=s(9504),{Uint8Array:r,SyntaxError:a}=i,o=Math.min,l=n("".match);t.exports=function(h,c){var d=h.length;if(d%2!==0)throw new a("String should be an even number of characters");var u=c?o(c.length,d/2):d/2,f=c||new r(u),p=l(h,/[\S\s]{2}/g),g=0;for(;g<u;g++){var m=+("0x"+p[g]+"0");if(m!==m)throw new a("String should only contain hex characters");f[g]=m>>4}return{bytes:f,read:g<<1}}},7416(t,e,s){var i=s(9039),n=s(8227),r=s(3724),a=s(6395),o=n("iterator");t.exports=!i(function(){var l=new URL("b?a=1&b=2&c=3","https://a"),h=l.searchParams,c=new URLSearchParams("a=1&a=2&b=3"),d="";return l.pathname="c%20d",h.forEach(function(u,f){h.delete("b"),d+=f+u}),c.delete("a",2),c.delete("b",void 0),a&&(!l.toJSON||!c.has("a",1)||c.has("a",2)||!c.has("a",void 0)||c.has("b"))||!h.size&&(a||!r)||!h.sort||l.href!=="https://a/c%20d?a=1&c=3"||h.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!h[o]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("https://тест").host!=="xn--e1aybc"||new URL("https://a#б").hash!=="#%D0%B1"||d!=="a1c3"||new URL("https://x",void 0).host!=="x"})},7040(t,e,s){var i=s(4495);t.exports=i&&!Symbol.sham&&typeof Symbol.iterator=="symbol"},8686(t,e,s){var i=s(3724),n=s(9039);t.exports=i&&n(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})},2812(t){var e=TypeError;t.exports=function(s,i){if(s<i)throw new e("Not enough arguments");return s}},8622(t,e,s){var i=s(4576),n=s(4901),r=i.WeakMap;t.exports=n(r)&&/native code/.test(String(r))},4995(t,e,s){var i=s(9504),n=WeakMap.prototype;t.exports={WeakMap,set:i(n.set),get:i(n.get),has:i(n.has),remove:i(n.delete)}},8227(t,e,s){var i=s(4576),n=s(5745),r=s(9297),a=s(3392),o=s(4495),l=s(7040),h=i.Symbol,c=n("wks"),d=l?h.for||h:h&&h.withoutSetter||a;t.exports=function(u){if(!r(c,u))c[u]=o&&r(h,u)?h[u]:d("Symbol."+u);return c[u]}},4423(t,e,s){var i=s(6518),n=s(9617).includes,r=s(9039),a=s(6469),o=r(function(){return!Array(1).includes()}),l=r(function(){return[,1].includes(void 0,1)});i({target:"Array",proto:!0,forced:o||l},{includes:function(c){return n(this,c,arguments.length>1?arguments[1]:void 0)}}),a("includes")},4114(t,e,s){var i=s(6518),n=s(8981),r=s(6198),a=s(4527),o=s(6837),l=s(9039),h=l(function(){return[].push.call({length:4294967296},1)!==4294967297}),c=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(u){return u instanceof TypeError}},d=h||!c();i({target:"Array",proto:!0,arity:1,forced:d},{push:function(f){var p=n(this),g=r(p),m=arguments.length;o(g+m);for(var v=0;v<m;v++)p[g]=arguments[v],g++;return a(p,g),g}})},8111(t,e,s){var i=s(6518),n=s(4576),r=s(679),a=s(8551),o=s(4901),l=s(2787),h=s(2106),c=s(4659),d=s(9039),u=s(9297),f=s(8227),p=s(7657).IteratorPrototype,g=s(3724),m=s(6395),v="constructor",y="Iterator",S=f("toStringTag"),A=TypeError,b=n[y],w=m||!o(b)||b.prototype!==p||!d(function(){b({})}),x=function(){if(r(this,p),l(this)===p)throw new A("Abstract class Iterator not directly constructable")},T=function(E,I){if(g)h(p,E,{configurable:!0,get:function(){return I},set:function(C){if(a(this),this===p)throw new A("You can't redefine this property");if(u(this,E))this[E]=C;else c(this,E,C)}});else p[E]=I};if(!u(p,S))T(S,y);if(w||!u(p,v)||p[v]===Object)T(v,x);x.prototype=p,i({global:!0,constructor:!0,forced:w},{Iterator:x})},9314(t,e,s){var i=s(6518),n=s(9565),r=s(8551),a=s(1767),o=s(4149),l=s(9590),h=s(9539),c=s(9462),d=s(684),u=s(4549),f=s(6395),p=RangeError,g=1/0,m=!f&&!d("drop",0),v=!f&&!m&&u("drop",RangeError),y=f||m||v||!function(){try{Iterator.prototype.drop.call({next:function(){return{done:!0}}},9007199254740992)}catch(A){return A instanceof p}}(),S=c(function(){var A=this.iterator,b=this.next,w,x;while(this.remaining)if(this.remaining--,w=r(n(b,A)),x=this.done=!!w.done,x)return;if(w=r(n(b,A)),x=this.done=!!w.done,!x)return w.value});i({target:"Iterator",proto:!0,real:!0,forced:y},{drop:function(b){r(this);var w;try{if(w=l(o(+b)),w>9007199254740991&&w!==g)throw new p("The argument should be a safe integer")}catch(x){h(this,"throw",x)}if(v)return n(v,this,w);return new S(a(this),{remaining:w})}})},1148(t,e,s){var i=s(6518),n=s(9565),r=s(2652),a=s(9306),o=s(8551),l=s(1767),h=s(9539),c=s(4549),d=c("every",TypeError);i({target:"Iterator",proto:!0,real:!0,forced:d},{every:function(f){o(this);try{a(f)}catch(m){h(this,"throw",m)}if(d)return n(d,this,f);var p=l(this),g=0;return!r(p,function(m,v){if(!f(m,g++))return v()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},2489(t,e,s){var i=s(6518),n=s(9565),r=s(9306),a=s(8551),o=s(1767),l=s(9462),h=s(6319),c=s(6395),d=s(9539),u=s(684),f=s(4549),p=!c&&!u("filter",function(){}),g=!c&&!p&&f("filter",TypeError),m=c||p||g,v=l(function(){var y=this.iterator,S=this.predicate,A=this.next,b,w,x;while(!0){if(b=a(n(A,y)),w=this.done=!!b.done,w)return;if(x=b.value,h(y,S,[x,this.counter++],!0))return x}});i({target:"Iterator",proto:!0,real:!0,forced:m},{filter:function(S){a(this);try{r(S)}catch(A){d(this,"throw",A)}if(g)return n(g,this,S);return new v(o(this),{predicate:S})}})},116(t,e,s){var i=s(6518),n=s(9565),r=s(2652),a=s(9306),o=s(8551),l=s(1767),h=s(9539),c=s(4549),d=c("find",TypeError);i({target:"Iterator",proto:!0,real:!0,forced:d},{find:function(f){o(this);try{a(f)}catch(m){h(this,"throw",m)}if(d)return n(d,this,f);var p=l(this),g=0;return r(p,function(m,v){if(f(m,g++))return v(m)},{IS_RECORD:!0,INTERRUPTED:!0}).result}})},531(t,e,s){var i=s(6518),n=s(9565),r=s(9306),a=s(8551),o=s(1767),l=s(8646),h=s(9462),c=s(9539),d=s(9039),u=s(6395),f=s(684),p=s(4549),g=!u&&d(function(){return[1].values().flatMap(function(){return[1]}).find(function(){return!0})!==1}),m=!u&&!g&&!f("flatMap",function(){}),v=!u&&!g&&!m&&p("flatMap",TypeError),y=u||g||m||v,S=h(function(){var A=this.iterator,b=this.mapper,w,x;while(!0){if(x=this.inner)try{if(w=a(n(x.next,x.iterator)),!w.done)return w.value;this.inner=null}catch(T){c(A,"throw",T)}if(w=a(n(this.next,A)),this.done=!!w.done)return;try{this.inner=l(b(w.value,this.counter++),!1)}catch(T){c(A,"throw",T)}}});i({target:"Iterator",proto:!0,real:!0,forced:y},{flatMap:function(b){a(this);try{r(b)}catch(w){c(this,"throw",w)}if(v)return n(v,this,b);return new S(o(this),{mapper:b,inner:null})}})},7588(t,e,s){var i=s(6518),n=s(9565),r=s(2652),a=s(9306),o=s(8551),l=s(1767),h=s(9539),c=s(4549),d=c("forEach",TypeError);i({target:"Iterator",proto:!0,real:!0,forced:d},{forEach:function(f){o(this);try{a(f)}catch(m){h(this,"throw",m)}if(d)return n(d,this,f);var p=l(this),g=0;r(p,function(m){f(m,g++)},{IS_RECORD:!0})}})},1701(t,e,s){var i=s(6518),n=s(9565),r=s(9306),a=s(8551),o=s(1767),l=s(9462),h=s(6319),c=s(9539),d=s(684),u=s(4549),f=s(6395),p=!f&&!d("map",function(){}),g=!f&&!p&&u("map",TypeError),m=f||p||g,v=l(function(){var y=this.iterator,S=a(n(this.next,y)),A=this.done=!!S.done;if(!A)return h(y,this.mapper,[S.value,this.counter++],!0)});i({target:"Iterator",proto:!0,real:!0,forced:m},{map:function(S){a(this);try{r(S)}catch(A){c(this,"throw",A)}if(g)return n(g,this,S);return new v(o(this),{mapper:S})}})},3579(t,e,s){var i=s(6518),n=s(9565),r=s(2652),a=s(9306),o=s(8551),l=s(1767),h=s(9539),c=s(4549),d=c("some",TypeError);i({target:"Iterator",proto:!0,real:!0,forced:d},{some:function(f){o(this);try{a(f)}catch(m){h(this,"throw",m)}if(d)return n(d,this,f);var p=l(this),g=0;return r(p,function(m,v){if(f(m,g++))return v()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},4972(t,e,s){var i=s(6518),n=s(9565),r=s(8551),a=s(1767),o=s(4149),l=s(9590),h=s(9462),c=s(9539),d=s(684),u=s(4549),f=s(6395),p=RangeError,g=1/0,m=!f&&!d("take",1),v=!f&&!m&&u("take",RangeError),y=f||m||v||!function(){try{Iterator.prototype.take.call({next:function(){return{done:!0}}},9007199254740992)}catch(A){return A instanceof p}}(),S=h(function(){var A=this.iterator;if(!this.remaining--)return this.done=!0,c(A,"normal",void 0);var b=r(n(this.next,A)),w=this.done=!!b.done;if(!w)return b.value});i({target:"Iterator",proto:!0,real:!0,forced:y},{take:function(b){r(this);var w;try{if(w=l(o(+b)),w>9007199254740991&&w!==g)throw new p("The argument should be a safe integer")}catch(x){c(this,"throw",x)}if(v)return n(v,this,w);return new S(a(this),{remaining:w})}})},1806(t,e,s){var i=s(6518),n=s(8551),r=s(4659),a=s(2652),o=s(1767);i({target:"Iterator",proto:!0,real:!0},{toArray:function(){var h=[],c=0;return a(o(n(this)),function(d){r(h,c++,d)},{IS_RECORD:!0}),h}})},9112(t,e,s){var i=s(6518),n=s(3724),r=s(4576),a=s(7751),o=s(9504),l=s(9565),h=s(4901),c=s(34),d=s(4376),u=s(9297),f=s(655),p=s(6198),g=s(4659),m=s(9039),v=s(8235),y=s(4495),{JSON:S,Number:A,SyntaxError:b}=r,w=S&&S.parse,x=a("Object","keys"),T=Object.getOwnPropertyDescriptor,E=o("".charAt),I=o("".slice),C=o(/./.exec),O=o([].push),D=/^\d$/,k=/^[1-9]$/,R=/^[\d-]$/,M=/^[\t\n\r ]$/,_=0,U=1,G=function(N,P){N=f(N);var F=new et(N,0),X=F.parse(),nt=X.value,V=F.skip(M,X.end);if(V<N.length)throw new b('Unexpected extra character: "'+E(N,V)+'" after the parsed data at: '+V);return h(P)?it({"":nt},"",P,X):nt},it=function(N,P,F,X){var nt=N[P],V=X&&nt===X.value,Z=V&&typeof X.source=="string"?{source:X.source}:{},lt,xt,Et,vt,$t;if(c(nt)){var Me=d(nt),ye=V?X.nodes:Me?[]:{};if(Me){lt=ye.length,Et=p(nt);for(vt=0;vt<Et;vt++)rt(nt,vt,it(nt,""+vt,F,vt<lt?ye[vt]:void 0))}else{xt=x(nt),Et=p(xt);for(vt=0;vt<Et;vt++)$t=xt[vt],rt(nt,$t,it(nt,$t,F,u(ye,$t)?ye[$t]:void 0))}}return l(F,N,P,nt,Z)},rt=function(N,P,F){if(n){var X=T(N,P);if(X&&!X.configurable)return}if(F===void 0)delete N[P];else g(N,P,F)},J=function(N,P,F,X){this.value=N,this.end=P,this.source=F,this.nodes=X},et=function(N,P){this.source=N,this.index=P};et.prototype={fork:function(N){return new et(this.source,N)},parse:function(){var N=this.source,P=this.skip(M,this.index),F=this.fork(P),X=E(N,P);if(C(R,X))return F.number();switch(X){case"{":return F.object();case"[":return F.array();case'"':return F.string();case"t":return F.keyword(!0);case"f":return F.keyword(!1);case"n":return F.keyword(null)}throw new b('Unexpected character: "'+X+'" at: '+P)},node:function(N,P,F,X,nt){return new J(P,X,N?null:I(this.source,F,X),nt)},object:function(){var N=this.source,P=this.index+1,F=!1,X={},nt={},V=!1;while(P<N.length){if(P=this.until(['"',"}"],P),E(N,P)==="}"&&!F){P++,V=!0;break}var Z=this.fork(P).string(),lt=Z.value;P=Z.end,P=this.until([":"],P)+1,P=this.skip(M,P),Z=this.fork(P).parse(),g(nt,lt,Z),g(X,lt,Z.value),P=this.until([",","}"],Z.end);var xt=E(N,P);if(xt===",")F=!0,P++;else if(xt==="}"){P++,V=!0;break}}if(!V)throw new b("Unterminated object at: "+P);return this.node(U,X,this.index,P,nt)},array:function(){var N=this.source,P=this.index+1,F=!1,X=[],nt=[],V=!1;while(P<N.length){if(P=this.skip(M,P),E(N,P)==="]"&&!F){P++,V=!0;break}var Z=this.fork(P).parse();if(O(nt,Z),O(X,Z.value),P=this.until([",","]"],Z.end),E(N,P)===",")F=!0,P++;else if(E(N,P)==="]"){P++,V=!0;break}}if(!V)throw new b("Unterminated array at: "+P);return this.node(U,X,this.index,P,nt)},string:function(){var N=this.index,P=v(this.source,this.index+1);return this.node(_,P.value,N,P.end)},number:function(){var N=this.source,P=this.index,F=P;if(E(N,F)==="-")F++;if(E(N,F)==="0")F++;else if(C(k,E(N,F)))F=this.skip(D,F+1);else throw new b("Failed to parse number at: "+F);if(E(N,F)==="."){var X=F+1;if(F=this.skip(D,X),X===F)throw new b("Failed to parse number's fraction at: "+F)}if(E(N,F)==="e"||E(N,F)==="E"){if(F++,E(N,F)==="+"||E(N,F)==="-")F++;var nt=F;if(F=this.skip(D,F),nt===F)throw new b("Failed to parse number's exponent value at: "+F)}return this.node(_,A(I(N,P,F)),P,F)},keyword:function(N){var P=""+N,F=this.index,X=F+P.length;if(I(this.source,F,X)!==P)throw new b("Failed to parse value at: "+F);return this.node(_,N,F,X)},skip:function(N,P){var F=this.source;for(;P<F.length;P++)if(!C(N,E(F,P)))break;return P},until:function(N,P){P=this.skip(M,P);var F=E(this.source,P);for(var X=0;X<N.length;X++)if(N[X]===F)return P;throw new b('Unexpected character: "'+F+'" at: '+P)}};var ht=m(function(){var N="9007199254740993",P;return w(N,function(F,X,nt){P=nt.source}),P!==N}),Rt=y&&!m(function(){return 1/w("-0 \t")!==-1/0});i({target:"JSON",stat:!0,forced:ht},{parse:function(P,F){return Rt&&!h(F)?w(P):G(P,F)}})},3110(t,e,s){var i=s(6518),n=s(7751),r=s(9565),a=s(9504),o=s(9039),l=s(4376),h=s(4901),c=s(34),d=s(2360),u=s(5810),f=s(757),p=s(2195),g=s(1240),m=s(9617).includes,v=s(9297),y=s(655),S=s(8235),A=s(3392),b=s(4495),w=s(7819),x=String,T=TypeError,E=n("JSON","stringify"),I=n("BigInt"),C=a("".valueOf),O=a((!0).valueOf),D=I&&a(I.prototype.valueOf),k=a(/./.exec),R=a("".charAt),M=a("".charCodeAt),_=a("".replace),U=a("".slice),G=a([].push),it=a([].pop),rt=a(1.1 .toString),J=/[\uD800-\uDFFF]/g,et=/^[\uD800-\uDBFF]$/,ht=/^[\uDC00-\uDFFF]$/,Rt=/^\d+$/,N=A(),P=A(),F=A(),X=N.length,nt=P.length,V=!b||o(function(){var tt=n("Symbol")("stringify detection");return E([tt])!=="[null]"||E({a:tt})!=="{}"||E(Object(tt))!=="{}"}),Z=o(function(){return E("\uDF06\uD834")!=='"\\udf06\\ud834"'||E("\uDEAD")!=='"\\udead"'}),lt=w?n("JSON","isRawJSON"):u,xt=V?function(tt,ct,pt){return E(tt,function(It,Pt){var St=r(ct,this,It,Pt);if(!f(St))return St},pt)}:E,Et=function(tt,ct,pt){var It=R(pt,ct-1),Pt=R(pt,ct+1);if(k(et,tt)&&!k(ht,Pt)||k(ht,tt)&&!k(et,It))return"\\u"+rt(M(tt,0),16);return tt},vt=function(tt){if(!l(tt))return;var ct=tt.length,pt=[],It=d(null);for(var Pt=0;Pt<ct;Pt++){var St=tt[Pt],Gt;if(typeof St=="string")Gt=St;else if(typeof St=="number"||p(St)==="Number"||p(St)==="String")Gt=y(St);else continue;if(!v(It,Gt))It[Gt]=!0,G(pt,Gt)}return pt},$t=function(tt,ct){try{return tt(ct),!0}catch(pt){return!1}},Me=function(tt){var ct=p(tt);return ct==="Number"&&$t(g,tt)||ct==="String"&&$t(C,tt)||ct==="Boolean"&&$t(O,tt)||!!D&&ct==="BigInt"&&$t(D,tt)},ye=function(tt){if(!c(tt)||h(tt)||l(tt))return!1;try{return!Me(tt)}catch(ct){return!0}},Yr=function(tt,ct){return{toJSON:function(){var pt=tt[ct];if(c(pt)||typeof pt=="bigint"){var It=pt.toJSON;if(h(It))pt=r(It,pt,ct)}return pt}}},Kr=function(tt){for(var ct=0,pt=tt.length;ct<pt;ct++)if(k(Rt,tt[ct]))return P;return""},Jr=function(tt,ct,pt){var It=d(null);for(var Pt=0,St=ct.length;Pt<St;Pt++){var Gt=ct[Pt];It[pt+Gt]=Yr(tt,Gt)}return It[F]=null,It};if(E)i({target:"JSON",stat:!0,arity:3,forced:V||Z||!w},{stringify:function(ct,pt,It){var Pt=h(pt)?pt:void 0,St=Pt?void 0:vt(pt),Gt=St&&Kr(St),Ni=[],js=[],Fi=[],ts,$s=!1,Bi=!0,qt=xt(ct,function(De,Xt){if(De=x(De),St){if(De===F){it(js),ts=it(Fi);return}if(Bi)Bi=!1;else if(this!==ts&&!l(this)&&!m(St,De))return}else if(Pt)Xt=r(Pt,this,De,Xt);if(lt(Xt)){if(w)return Xt;return $s=!0,N+(G(Ni,Xt.rawJSON)-1)}if(St&&ye(Xt)){if(m(js,Xt))throw new T("Converting circular structure to JSON");var Ui=Jr(Xt,St,Gt);if(G(js,Xt),G(Fi,ts),ts=Ui,Gt)$s=!0;return Ui}return Xt},It);if(typeof qt!="string")return qt;if(Z)qt=_(qt,J,Et);if(!$s)return qt;var Oe="",Qr=qt.length;for(var be=0;be<Qr;be++){var _i=R(qt,be);if(_i==='"'){var Hi=S(qt,++be).end-1,Re=U(qt,be,Hi);if(U(Re,0,X)===N)Oe+=Ni[U(Re,X)];else if(U(Re,0,nt)===P)Oe+='"'+U(Re,nt)+'"';else Oe+='"'+Re+'"';be=Hi}else Oe+=_i}return Oe}})},2731(t,e,s){var i=s(6518),n=s(9306),r=s(2248),a=s(6395),{get:o,has:l,set:h}=r;i({target:"Map",proto:!0,real:!0,forced:a},{getOrInsertComputed:function(d,u){var f=l(this,d);if(n(u),f)return o(this,d);if(d===0&&1/d===-1/0)d=0;var p=u(d);return h(this,d,p),p}})},5367(t,e,s){var i=s(6518),n=s(2248),r=s(6395),{get:a,has:o,set:l}=n;i({target:"Map",proto:!0,real:!0,forced:r},{getOrInsert:function(c,d){if(o(this,c))return a(this,c);return l(this,c,d),d}})},3068(t,e,s){var i=s(6518),n=s(9504),r=s(2652),a=RangeError,o=TypeError,l=1/0,h=NaN,{abs:c,pow:d}=Math,u=n([].push),f=d(2,1023),p=d(2,53)-1,g=Number.MAX_VALUE,m=d(2,971),v={},y={},S={},A={},b={},w=function(x,T){var E=x+T,I=T-(E-x);return{hi:E,lo:I}};i({target:"Math",stat:!0},{sumPrecise:function(T){var E=[],I=0,C=A;switch(r(T,function(N){if(++I>p)throw new a("Maximum allowed index exceeded");if(typeof N!="number")throw new o("Value is not a number");if(C!==v){if(N!==N)C=v;else if(N===l)C=C===y?v:S;else if(N===-l)C=C===S?v:y;else if((N!==0||1/N===l)&&(C===A||C===b))C=b,u(E,N)}}),C){case v:return h;case y:return-l;case S:return l;case A:return-0}var O=[],D=0,k,R,M,_,U,G;for(var it=0;it<E.length;it++){k=E[it];var rt=0;for(var J=0;J<O.length;J++){if(R=O[J],c(k)<c(R))G=k,k=R,R=G;if(M=w(k,R),_=M.hi,U=M.lo,c(_)===l){var et=_===l?1:-1;if(D+=et,k=k-et*f-et*f,c(k)<c(R))G=k,k=R,R=G;M=w(k,R),_=M.hi,U=M.lo}if(U!==0)O[rt++]=U;k=_}if(O.length=rt,k!==0)u(O,k)}var ht=O.length-1;if(_=0,U=0,D!==0){var Rt=ht>=0?O[ht]:0;if(ht--,c(D)>1||D>0&&Rt>0||D<0&&Rt<0)return D>0?l:-l;if(M=w(D*f,Rt/2),_=M.hi,U=M.lo,U*=2,c(2*_)===l){if(_>0)return _===f&&U===-(m/2)&&ht>=0&&O[ht]<0?g:l;return _===-f&&U===m/2&&ht>=0&&O[ht]>0?-g:-l}if(U!==0)O[++ht]=U,U=0;_*=2}while(ht>=0)if(M=w(_,O[ht--]),_=M.hi,U=M.lo,U!==0)break;if(ht>=0&&(U<0&&O[ht]<0||U>0&&O[ht]>0)){if(R=U*2,k=_+R,R===k-_)_=k}return _}})},1689(t,e,s){var i=s(6518),n=s(4576),r=s(8745),a=s(7680),o=s(3438),l=s(6043),h=s(9306),c=s(1103),d=s(9039),u=n.Promise,f=!1,p=!u||!u.try||d(function(){var g=u.resolve();return u.try(function(m){return f=m===8,g},8)!==g})||!f;i({target:"Promise",stat:!0,forced:p},{try:function(g){var m=arguments.length>1?a(arguments,1):[],v=c(function(){return r(h(g),void 0,m)});if(!v.error)return o(this,v.value);var y=l.f(this),S=y.reject;return S(v.value),y.promise}})},7642(t,e,s){var i=s(6518),n=s(3440),r=s(9039),a=s(4916),o=!a("difference",function(h){return h.size===0}),l=o||r(function(){var h={size:1,has:function(){return!0},keys:function(){var d=0;return{next:function(){var u=d++>1;if(c.has(1))c.clear();return{done:u,value:2}}}}},c=new Set([1,2,3,4]);return c.difference(h).size!==3});i({target:"Set",proto:!0,real:!0,forced:l},{difference:n})},8004(t,e,s){var i=s(6518),n=s(9039),r=s(8750),a=s(4916),o=!a("intersection",function(l){return l.size===2&&l.has(1)&&l.has(2)})||n(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});i({target:"Set",proto:!0,real:!0,forced:o},{intersection:r})},3853(t,e,s){var i=s(6518),n=s(4449),r=s(4916),a=!r("isDisjointFrom",function(o){return!o});i({target:"Set",proto:!0,real:!0,forced:a},{isDisjointFrom:n})},5876(t,e,s){var i=s(6518),n=s(3838),r=s(4916),a=!r("isSubsetOf",function(o){return o});i({target:"Set",proto:!0,real:!0,forced:a},{isSubsetOf:n})},2475(t,e,s){var i=s(6518),n=s(8527),r=s(4916),a=!r("isSupersetOf",function(o){return!o});i({target:"Set",proto:!0,real:!0,forced:a},{isSupersetOf:n})},5024(t,e,s){var i=s(6518),n=s(3650),r=s(9835),a=s(4916),o=!a("symmetricDifference")||!r("symmetricDifference");i({target:"Set",proto:!0,real:!0,forced:o},{symmetricDifference:n})},1698(t,e,s){var i=s(6518),n=s(4204),r=s(9835),a=s(4916),o=!a("union")||!r("union");i({target:"Set",proto:!0,real:!0,forced:o},{union:n})},9577(t,e,s){var i=s(4644),n=s(1108),r=s(6198),a=s(1291),o=s(5854),{aTypedArray:l,getTypedArrayConstructor:h,exportTypedArrayMethod:c}=i,d=RangeError,u=function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(p){return p===8}}(),f=u&&function(){try{new Int8Array(1).with(-0.5,1)}catch(p){return!0}}();c("with",function(p,g){var m=l(this),v=r(m),y=a(p),S=y<0?v+y:y,A=n(m)?o(g):+g;if(S>=v||S<0)throw new d("Incorrect index");var b=new(h(m))(v),w=0;for(;w<v;w++)b[w]=w===S?A:m[w];return b},!u||f)},5213(t,e,s){var i=s(6518),n=s(4576),r=s(5370),a=s(9143),o=n.Uint8Array,l=!o||!o.fromBase64||!function(){try{o.fromBase64("a");return}catch(h){}try{o.fromBase64("",null)}catch(h){return!0}}();if(o)i({target:"Uint8Array",stat:!0,forced:l},{fromBase64:function(c){var d=a(c,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return r(o,d.bytes)}})},6632(t,e,s){var i=s(6518),n=s(4576),r=s(9143),a=s(4154),o=n.Uint8Array,l=!o||!o.prototype.setFromBase64||!function(){var h=new o([255,255,255,255,255]);try{h.setFromBase64("",null);return}catch(c){}try{h.setFromBase64("a");return}catch(c){}try{h.setFromBase64("MjYyZg===")}catch(c){return h[0]===50&&h[1]===54&&h[2]===50&&h[3]===255&&h[4]===255}}();if(o)i({target:"Uint8Array",proto:!0,forced:l},{setFromBase64:function(c){a(this);var d=r(c,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:d.read,written:d.written}}})},4226(t,e,s){var i=s(6518),n=s(4576),r=s(3463),a=s(4154),o=s(5169),l=s(2303);function h(){try{var c=new ArrayBuffer(16,{maxByteLength:1024});new Uint8Array(c).setFromHex("cafed00d")}catch(d){return!0}}if(n.Uint8Array)i({target:"Uint8Array",proto:!0,forced:h()},{setFromHex:function(d){a(this),r(d),o(this.buffer);var u=l(d,this).read;return{read:u,written:u/2}}})},9486(t,e,s){var i=s(6518),n=s(4576),r=s(9504),a=s(3972),o=s(4154),l=s(5169),h=s(2804),c=s(944),{i2c:d,i2cUrl:u}=h,{floor:f,ceil:p}=Math,g=r("".charAt),{Uint8Array:m,Array:v}=n,y=r([].join),S=!m||!m.prototype.toBase64||!function(){try{var A=new m;A.toBase64(null)}catch(b){return!0}}();if(m)i({target:"Uint8Array",proto:!0,forced:S},{toBase64:function(){var b=o(this),w=arguments.length?a(arguments[0]):void 0,x=c(w)==="base64"?d:u,T=!!w&&!!w.omitPadding;l(this.buffer);var E=0,I=b.length,C=v(T?f(I/3)*4+(I%3?I%3+1:0):p(I/3)*4),O=0,D,k=function(R){return g(x,D>>6*R&63)};for(;E+2<I;E+=3)D=(b[E]<<16)+(b[E+1]<<8)+b[E+2],C[O++]=k(3),C[O++]=k(2),C[O++]=k(1),C[O++]=k(0);if(E+2===I){if(D=(b[E]<<16)+(b[E+1]<<8),C[O++]=k(3),C[O++]=k(2),C[O++]=k(1),!T)C[O++]="="}else if(E+1===I){if(D=b[E]<<16,C[O++]=k(3),C[O++]=k(2),!T)C[O++]="=",C[O++]="="}return y(C,"")}})},456(t,e,s){var i=s(6518),n=s(4576),r=s(9504),a=s(4154),o=s(5169),l=r(1.1 .toString),h=r([].join),c=Array,d=n.Uint8Array,u=!d||!d.prototype.toHex||!function(){try{var f=new d([255,255,255,255,255,255,255,255]);return f.toHex()==="ffffffffffffffff"}catch(p){return!1}}();if(d)i({target:"Uint8Array",proto:!0,forced:u},{toHex:function(){a(this),o(this.buffer);var p=c(this.length);for(var g=0,m=this.length;g<m;g++){var v=l(this[g],16);p[g]=v.length===1?"0"+v:v}return h(p,"")}})},9452(t,e,s){var i=s(6518),n=s(9306),r=s(6557),a=s(4328),o=s(4995),l=s(6395),{get:h,has:c,set:d}=o,u=l||!function(){try{if(WeakMap.prototype.getOrInsertComputed)new WeakMap().getOrInsertComputed(1,function(){throw 1})}catch(f){return f instanceof TypeError}}();i({target:"WeakMap",proto:!0,real:!0,forced:u},{getOrInsertComputed:function(p,g){if(!l)r(this);if(a(p),n(g),c(this,p))return h(this,p);var m=g(p);return d(this,p,m),m}})},8454(t,e,s){var i=s(6518),n=s(4995),r=s(6395),{get:a,has:o,set:l}=n;i({target:"WeakMap",proto:!0,real:!0,forced:r},{getOrInsert:function(c,d){if(o(this,c))return a(this,c);return l(this,c,d),d}})},4979(t,e,s){var i=s(6518),n=s(4576),r=s(7751),a=s(6980),o=s(4913).f,l=s(9297),h=s(679),c=s(3167),d=s(2603),u=s(5002),f=s(6193),p=s(3724),g=s(6395),m="DOMException",v=r("Error"),y=r(m),S=function(){h(this,A);var M=arguments.length,_=d(M<1?void 0:arguments[0]),U=d(M<2?void 0:arguments[1],"Error"),G=new y(_,U),it=new v(_);return it.name=m,o(G,"stack",a(1,f(it.stack,1))),c(G,this,S),G},A=S.prototype=y.prototype,b="stack"in new v(m),w="stack"in new y(1,2),x=y&&p&&Object.getOwnPropertyDescriptor(n,m),T=!!x&&!(x.writable&&x.configurable),E=b&&!T&&!w;i({global:!0,constructor:!0,forced:g||E},{DOMException:E?S:y});var I=r(m),C=I.prototype;if(C.constructor!==I){if(!g)o(C,"constructor",a(1,I));for(var O in u)if(l(u,O)){var D=u[O],k=D.s;if(!l(I,k))o(I,k,a(6,D.c))}}},5781(t,e,s){var i=s(6518),n=s(7751),r=s(2812),a=s(655),o=s(7416),l=n("URL");i({target:"URL",stat:!0,forced:!o},{parse:function(c){var d=r(arguments.length,1),u=a(c),f=d<2||arguments[1]===void 0?void 0:a(arguments[1]);try{return new l(u,f)}catch(p){return null}}})}};var ji={};function K(t){let e=ji[t];if(e!==void 0)return e.exports;let s=ji[t]={exports:{}};return Zr[t].call(s.exports,s,s.exports,K),s.exports}(()=>{K.d=(t,e)=>{if(Array.isArray(e)){var s=0;while(s<e.length){var i=e[s++],n=e[s++];if(!K.o(t,i))if(n===0)Object.defineProperty(t,i,{enumerable:!0,value:e[s++]});else Object.defineProperty(t,i,{enumerable:!0,get:n});else if(n===0)s++}}else for(var i in e)if(K.o(e,i)&&!K.o(t,i))Object.defineProperty(t,i,{enumerable:!0,get:e[i]})}})();(()=>{K.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e)})();var Ja=K(4423),Qa=K(4114),Za=K(8111),qa=K(2489),to=K(5367),eo=K(2731),so=K(7642),io=K(8004),no=K(3853),ro=K(5876),ao=K(2475),oo=K(5024),lo=K(1698),ho=K(9577),co=K(6632),uo=K(4226),fo=K(9486),po=K(456),go=K(5781),Nt=typeof process==="object"&&process+""==="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),ee=[1/0,1/0,-1/0,-1/0],de=new Float32Array(ee),Ys=[0.001,0,0,0.001,0,0];var Mt="http://www.w3.org/2000/svg",Lt={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},ne={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},xe="pdfjs_internal_id_",Ce="pdfjs_internal_editor_",Y={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},q={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},qr={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};var bt={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},hs={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},gt={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,RICHMEDIA:27};var Se={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};var xs={ERRORS:0,WARNINGS:1,INFOS:5},Qt={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,rawFillPath:94},ke={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},ta={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Es=xs.WARNINGS;function ea(t){if(Number.isInteger(t))Es=t}function sa(){return Es}function Ts(t){if(Es>=xs.INFOS)console.info(`Info: ${t}`)}function z(t){if(Es>=xs.WARNINGS)console.warn(`Warning: ${t}`)}function st(t){throw Error(t)}function mt(t,e){if(!t)st(e)}function ia(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function mn(t,e=null,s=null){if(!t)return null;if(s&&typeof t==="string"){if(s.addDefaultProtocol&&t.startsWith("www.")){if(t.match(/\./g)?.length>=2)t=`http://${t}`}if(s.tryConvertEncoding)try{t=ra(t)}catch{}}let i=e?URL.parse(t,e):URL.parse(t);return ia(i)?i:null}function vn(t,e,s=!1){let i=URL.parse(t);if(i)return i.hash=e,i.href;if(s&&mn(t,"http://example.com"))return t.split("#",1)[0]+`${e?`#${e}`:""}`;return""}function Ks(t){return t.substring(t.lastIndexOf("/")+1)}function j(t,e,s,i=!1){return Object.defineProperty(t,e,{value:s,enumerable:!i,configurable:!0,writable:!1}),s}var ve=function(){function e(s,i){this.message=s,this.name=i}return e.prototype=Error(),e.constructor=e,e}();class fs extends ve{constructor(t,e){super(t,"PasswordException");this.code=e}}class cs extends ve{constructor(t,e){super(t,"UnknownErrorException");this.details=e}}class ps extends ve{constructor(t){super(t,"InvalidPDFException")}}class Ue extends ve{constructor(t,e,s){super(t,"ResponseException");this.status=e,this.missing=s}}class yn extends ve{constructor(t){super(t,"FormatError")}}class se extends ve{constructor(t){super(t,"AbortException")}}function na(t){if(typeof t!=="object"||t?.length===void 0)st("Invalid argument for bytesToString");let e=t.length,s=8192;if(e<s)return String.fromCharCode.apply(null,t);let i=[];for(let n=0;n<e;n+=s){let r=Math.min(n+s,e),a=t.subarray(n,r);i.push(String.fromCharCode.apply(null,a))}return i.join("")}function Cs(t){if(typeof t!=="string")st("Invalid argument for stringToBytes");let e=t.length,s=new Uint8Array(e);for(let i=0;i<e;++i)s[i]=t.charCodeAt(i)&255;return s}class ot{static get isLittleEndian(){let t=new Uint8Array(4);t[0]=1;let e=new Uint32Array(t.buffer,0,1);return j(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return j(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return j(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return j(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return j(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){let{platform:t,userAgent:e}=navigator;return j(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;if(this.isOffscreenCanvasSupported)t=new OffscreenCanvas(1,1).getContext("2d");else if(typeof document<"u")t=document.createElement("canvas").getContext("2d");return j(this,"isCanvasFilterSupported",t?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return j(this,"isAlphaColorInputSupported",!1);let t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",j(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return j(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}class L{static get hexNums(){return j(this,"hexNums",Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){let i=t[s],n=t[s+1];t[s]=i*e[0]+n*e[2]+e[4],t[s+1]=i*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){let i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let h=0;h<6;h+=2){let c=t[s+h],d=t[s+h+1];t[s+h]=c*i+d*r+o,t[s+h+1]=c*n+d*a+l}}static applyInverseTransform(t,e){let s=t[0],i=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,s){let i=e[0],n=e[1],r=e[2],a=e[3],o=e[4],l=e[5],h=t[0],c=t[1],d=t[2],u=t[3],f=i*h+o,p=f,g=i*d+o,m=g,v=a*c+l,y=v,S=a*u+l,A=S;if(n!==0||r!==0){let b=n*h,w=n*d,x=r*c,T=r*u;f+=x,m+=x,g+=T,p+=T,v+=b,A+=b,S+=w,y+=w}s[0]=Math.min(s[0],f,g,p,m),s[1]=Math.min(s[1],v,S,y,A),s[2]=Math.max(s[2],f,g,p,m),s[3]=Math.max(s[3],v,S,y,A)}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){let s=t[0],i=t[1],n=t[2],r=t[3],a=s**2+i**2,o=s*n+i*r,l=n**2+r**2,h=(a+l)/2,c=Math.sqrt(h**2-(a*l-o**2));e[0]=Math.sqrt(h+c||1),e[1]=Math.sqrt(h-c||1)}static normalizeRect(t){let e=t.slice(0);if(t[0]>t[2])e[0]=t[2],e[2]=t[0];if(t[1]>t[3])e[1]=t[3],e[3]=t[1];return e}static intersect(t,e){let s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;let n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));if(n>r)return null;return[s,n,i,r]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,n){n[0]=Math.min(n[0],t,s),n[1]=Math.min(n[1],e,i),n[2]=Math.max(n[2],t,s),n[3]=Math.max(n[3],e,i)}static#t(t,e,s,i,n,r,a,o,l,h){if(l<=0||l>=1)return;let c=1-l,d=l*l,u=d*l,f=c*(c*(c*t+3*l*e)+3*d*s)+u*i,p=c*(c*(c*n+3*l*r)+3*d*a)+u*o;h[0]=Math.min(h[0],f),h[1]=Math.min(h[1],p),h[2]=Math.max(h[2],f),h[3]=Math.max(h[3],p)}static#e(t,e,s,i,n,r,a,o,l,h,c,d){if(Math.abs(l)<0.000000000001){if(Math.abs(h)>=0.000000000001)this.#t(t,e,s,i,n,r,a,o,-c/h,d);return}let u=h**2-4*c*l;if(u<0)return;let f=Math.sqrt(u),p=2*l;this.#t(t,e,s,i,n,r,a,o,(-h+f)/p,d),this.#t(t,e,s,i,n,r,a,o,(-h-f)/p,d)}static bezierBoundingBox(t,e,s,i,n,r,a,o,l){l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o),this.#e(t,s,n,a,e,i,r,o,3*(-t+3*(s-n)+a),6*(t-2*s+n),3*(s-t),l),this.#e(t,s,n,a,e,i,r,o,3*(-e+3*(i-r)+o),6*(e-2*i+r),3*(i-e),l)}}function ra(t){return decodeURIComponent(escape(t))}var Gs=null,$i=null;function aa(t){if(!Gs)Gs=/([\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,$i=new Map([["ſt","ſt"]]);return t.replaceAll(Gs,(e,s,i)=>s?s.normalize("NFKC"):$i.get(i))}function bn(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();let t=new Uint8Array(32);return crypto.getRandomValues(t),na(t)}function oa(t,e,s){if(!Array.isArray(s)||s.length<2)return!1;let[i,n,...r]=s;if(!t(i)&&!Number.isInteger(i))return!1;if(!e(n))return!1;let a=r.length,o=!0;switch(n.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(let l of r){if(typeof l==="number"||o&&l===null)continue;return!1}return!0}var Ie=()=>[],ai=()=>new Map,Js=()=>Object.create(null),la=()=>new Set;if(typeof Blob.prototype.bytes!=="function")Blob.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())};if(typeof Response.prototype.bytes!=="function")Response.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())};if(typeof Iterator.prototype.join!=="function")Iterator.prototype.join=function(t){return[...this].join(t)};var mo=K(1701);function ut(t,e,s){return Math.min(Math.max(t,e),s)}class Xe{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=r,s*=e;let o=(t[2]+t[0])/2,l=(t[3]+t[1])/2,h,c,d,u;if(i%=360,i<0)i+=360;switch(i){case 180:h=-1,c=0,d=0,u=1;break;case 90:h=0,c=1,d=1,u=0;break;case 270:h=0,c=-1,d=-1,u=0;break;case 0:h=1,c=0,d=0,u=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}if(a)d=-d,u=-u;let f,p,g,m;if(h===0)f=Math.abs(l-t[1])*s+n,p=Math.abs(o-t[0])*s+r,g=(t[3]-t[1])*s,m=(t[2]-t[0])*s;else f=Math.abs(o-t[0])*s+n,p=Math.abs(l-t[1])*s+r,g=(t[2]-t[0])*s,m=(t[3]-t[1])*s;this.transform=[h*s,c*s,d*s,u*s,f-h*s*o-d*s*l,p-c*s*o-u*s*l],this.width=g,this.height=m}get rawDims(){let t=this.viewBox;return j(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new Xe({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){let s=[t,e];return L.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){let s=[t,e];return L.applyInverseTransform(s,this.transform),s}}class je{static textContent(t){let e=[],s={items:e,styles:Object.create(null)};function i(n){if(!n)return;let r=null,a=n.name;if(a==="#text")r=n.value;else if(!je.shouldBuildText(a))return;else if(n?.attributes?.textContent)r=n.attributes.textContent;else if(n.value)r=n.value;if(r!==null)e.push({str:r});if(!n.children)return;for(let o of n.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}var ha=/url\(|image-set\(/i,ca=/^on/i;class oi{static get _allowedHtmlElements(){return j(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return j(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return j(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return j(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return j(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(t,e,s,i,n){let r=i.getValue(e,{value:null});switch(s.name){case"textarea":if(r.value!==null)t.textContent=r.value;if(n==="print")break;t.addEventListener("input",(a)=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(r.value===s.attributes.xfaOn)t.setAttribute("checked",!0);else if(r.value===s.attributes.xfaOff)t.removeAttribute("checked");if(n==="print")break;t.addEventListener("change",(a)=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(r.value!==null)t.setAttribute("value",r.value);if(n==="print")break;t.addEventListener("input",(a)=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(r.value!==null){t.setAttribute("value",r.value);for(let a of s.children)if(a.attributes.value===r.value)a.attributes.selected=!0;else if(Object.hasOwn(a.attributes,"selected"))delete a.attributes.selected}t.addEventListener("input",(a)=>{let o=a.target.options,l=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:l})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){let{attributes:r}=e,a=t instanceof HTMLAnchorElement;if(r.type==="radio")r.name=`${r.name}-${i}`;for(let[o,l]of Object.entries(r)){if(l===null||l===void 0)continue;if(ca.test(o))continue;if(i==="richText"&&!this._allowedRichTextAttributes.has(o))continue;switch(o){case"class":if(l.length)t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":if(i==="richText"){let h=this._allowedRichTextStyles;for(let[c,d]of Object.entries(l))if(h.has(c)&&!ha.test(d))t.style[c]=d}else Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:if(!a||o!=="href"&&o!=="newWindow")t.setAttribute(o,l)}}if(a)n?.addLinkAttributes(t,r.href,r.newWindow);if(s&&r.dataId)this.setupStorage(t,r.dataId,e,s)}static#t(t,e,s){if(s==="richText")return!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null;if(e)return e===Mt&&this._allowedSvgElements.has(t)?document.createElementNS(Mt,t):null;return this._allowedHtmlElements.has(t)?document.createElement(t):null}static render(t){let{annotationStorage:e,linkService:s,xfaHtml:i}=t,n=t.intent||"display",r=this.#t(i.name,i.attributes?.xmlns,n)??document.createElement("div");if(i.attributes)this.setAttributes({html:r,element:i,intent:n,linkService:s});let a=n!=="richText",o=t.div;if(o.append(r),t.viewport){let c=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=c}if(a)o.setAttribute("class","xfaLayer xfaFont");let l=[];if(i.children.length===0){if(i.value){let c=document.createTextNode(i.value);if(r.append(c),a&&je.shouldBuildText(i.name))l.push(c)}return{textDivs:l}}let h=[[i,-1,r]];while(h.length>0){let[c,d,u]=h.at(-1);if(d+1===c.children.length){h.pop();continue}let f=c.children[++h.at(-1)[1]];if(f===null)continue;let{name:p}=f;if(p==="#text"){let m=document.createTextNode(f.value);l.push(m),u.append(m);continue}let g=this.#t(p,f.attributes?.xmlns,n);if(!g)continue;if(u.append(g),f.attributes)this.setAttributes({html:g,element:f,storage:e,intent:n,linkService:s});if(f.children?.length>0)h.push([f,-1,g]);else if(f.value){let m=document.createTextNode(f.value);if(a&&je.shouldBuildText(p))l.push(m);g.append(m)}}for(let c of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))c.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){let{width:i,height:n}=t.attributes.style;return new Xe({viewBox:[0,0,parseInt(i,10),parseInt(n,10)],userUnit:1,scale:e,rotation:s})}}class pe{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function li(t,e="text"){if(Be(t,document.baseURI)){let s=await fetch(t);if(!s.ok)throw Error(s.statusText);switch(e){case"blob":return s.blob();case"bytes":return s.bytes();case"json":return s.json()}return s.text()}return new Promise((s,i)=>{let n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e==="bytes"?"arraybuffer":e,n.onreadystatechange=()=>{if(n.readyState!==XMLHttpRequest.DONE)return;if(n.status===200||n.status===0){switch(e){case"bytes":s(new Uint8Array(n.response));return;case"blob":case"json":s(n.response);return}s(n.responseText);return}i(Error(n.statusText))},n.send(null)})}class Is extends ve{constructor(t,e=0){super(t,"RenderingCancelledException");this.extraDelay=e}}function Ps(t){let e=t.length,s=0;while(s<e&&t[s].trim()==="")s++;return t.substring(s,s+5).toLowerCase()==="data:"}function hi(t){return typeof t==="string"&&/\.pdf$/i.test(t)}function da(t){return[t]=t.split(/[#?]/,1),Ks(t)}function ua(t,e="document.pdf"){if(typeof t!=="string")return e;if(Ps(t))return z('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let i=((o)=>{try{return new URL(o)}catch{}try{return new URL(decodeURIComponent(o))}catch{}try{return new URL(o,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{}return null})(t);if(!i)return e;let n=(o)=>{try{let l=decodeURIComponent(o);if(l.includes("/")){if(l=Ks(l),l.length===4&&r.test(l))return o}return l}catch{return o}},r=/\.pdf$/i,a=Ks(i.pathname);if(r.test(a))return n(a);if(i.searchParams.size>0){let o=(h)=>[...h].findLast((c)=>r.test(c)),l=o(i.searchParams.values())??o(i.searchParams.keys());if(l)return n(l)}if(i.hash){let{hash:o}=i,l=-1;for(let{index:h}of o.matchAll(/\.pdf\b/gi))l=h;if(l>0){let h=l;while(h>0&&!"/?#=".includes(o[h-1]))h--;if(h<l)return n(o.slice(h,l+4))}}return e}class Qs{#t=new Map;times=[];time(t){if(this.#t.has(t))z(`Timer is already running for ${t}`);this.#t.set(t,Date.now())}timeEnd(t){if(!this.#t.has(t))z(`Timer has not been started for ${t}`);this.times.push({name:t,start:this.#t.get(t),end:Date.now()}),this.#t.delete(t)}toString(){let t=Math.max(...this.times.map((e)=>e.name.length));return this.times.map((e)=>`${e.name.padEnd(t)} ${e.end-e.start}ms
4
+ `).join("")}}function Be(t,e){let s=e?URL.parse(t,e):URL.parse(t);return/https?:/.test(s?.protocol??"")}function zt(t){t.preventDefault()}function At(t){t.preventDefault(),t.stopPropagation()}class gs{static#t;static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!=="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#t.exec(t);if(!e)return null;let s=parseInt(e[1],10),i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;let l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let c=parseInt(e[9],10)||0;if(c=c>=0&&c<=59?c:0,l==="-")r+=h,a+=c;else if(l==="+")r-=h,a-=c;return new Date(Date.UTC(s,i,n,r,a,o))}}function Ye(t){if(t.startsWith("#")){let s=t.slice(1);return[parseInt(s.slice(0,2),16),parseInt(s.slice(2,4),16),parseInt(s.slice(4,6),16),s.length>=8?parseInt(s.slice(6,8),16)/255:1]}if(t.startsWith("rgb(")){let[s,i,n]=t.slice(4,-1).split(",").map((r)=>parseInt(r,10));return[s,i,n,1]}if(t.startsWith("rgba(")){let s=t.slice(5,-1).split(",");return[parseInt(s[0],10),parseInt(s[1],10),parseInt(s[2],10),parseFloat(s[3])]}let e=t.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);if(e)return[Math.round(parseFloat(e[1])*255),Math.round(parseFloat(e[2])*255),Math.round(parseFloat(e[3])*255),e[4]!==void 0&&e[4]!=="none"?parseFloat(e[4]):1];return null}function Ke(t){let e=Ye(t);if(!e)return z(`Not a valid color format: "${t}"`),[0,0,0];return e.slice(0,3)}function fa(t){let e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(let s of t.keys()){e.style.color=s;let i=window.getComputedStyle(e).color;t.set(s,Ke(i))}e.remove()}function dt(t){let{a:e,b:s,c:i,d:n,e:r,f:a}=t.getTransform();return[e,s,i,n,r,a]}function Yt(t){let{a:e,b:s,c:i,d:n,e:r,f:a}=t.getTransform().invertSelf();return[e,s,i,n,r,a]}function ge(t,e,s=!1,i=!0){if(e instanceof Xe){let{pageWidth:n,pageHeight:r}=e.rawDims,{style:a}=t,o=`round(down, var(--total-scale-factor) * ${n}px, var(--scale-round-x))`,l=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-y))`;if(!s||e.rotation%180===0)a.width=o,a.height=l;else a.width=l,a.height=o}if(i)t.setAttribute("data-main-rotation",e.rotation)}class Wt{constructor(){let{pixelRatio:t}=Wt;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,n=-1){let r=1/0,a=1/0,o=1/0;if(s=Wt.capPixels(s,n),s>0)r=Math.sqrt(s/(t*e));if(i!==-1)a=i/t,o=i/e;let l=Math.min(r,a,o);if(this.sx>l||this.sy>l)return this.sx=l,this.sy=l,!0;return!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){let s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}var Zs=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class An{static get isDarkMode(){return j(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class Sn{static get commentForegroundColor(){let t=document.createElement("span");t.classList.add("comment","sidebar");let{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);let{color:s}=window.getComputedStyle(t);return t.remove(),j(this,"commentForegroundColor",Ke(s))}}function pa(t,e){e=ut(e??1,0,1);let s=255*(1-e);return t.map((i)=>Math.round(i*e+s))}function Gi(t,e){let s=t[0]/255,i=t[1]/255,n=t[2]/255,r=Math.max(s,i,n),a=Math.min(s,i,n),o=(r+a)/2;if(r===a)e[0]=e[1]=0;else{let l=r-a;switch(e[1]=o<0.5?l/(r+a):l/(2-r-a),r){case s:e[0]=((i-n)/l+(i<n?6:0))*60;break;case i:e[0]=((n-s)/l+2)*60;break;case n:e[0]=((s-i)/l+4)*60;break}}e[2]=o}function qs(t,e){let s=t[0],i=t[1],n=t[2],r=(1-Math.abs(2*n-1))*i,a=r*(1-Math.abs(s/60%2-1)),o=n-r/2;switch(Math.floor(s/60)){case 0:e[0]=r+o,e[1]=a+o,e[2]=o;break;case 1:e[0]=a+o,e[1]=r+o,e[2]=o;break;case 2:e[0]=o,e[1]=r+o,e[2]=a+o;break;case 3:e[0]=o,e[1]=a+o,e[2]=r+o;break;case 4:e[0]=a+o,e[1]=o,e[2]=r+o;break;case 5:case 6:e[0]=r+o,e[1]=o,e[2]=a+o;break}}function ti(t){return t<=0.03928?t/12.92:((t+0.055)/1.055)**2.4}function Vi(t,e,s){qs(t,s),s.map(ti);let i=0.2126*s[0]+0.7152*s[1]+0.0722*s[2];qs(e,s),s.map(ti);let n=0.2126*s[0]+0.7152*s[1]+0.0722*s[2];return i>n?(i+0.05)/(n+0.05):(n+0.05)/(i+0.05)}var zi=new Map;function ga(t,e){let s=t[0]+t[1]*256+t[2]*65536+e[0]*16777216+e[1]*4294967296+e[2]*1099511627776,i=zi.get(s);if(i)return i;let n=new Float32Array(9),r=n.subarray(0,3),a=n.subarray(3,6);Gi(t,a);let o=n.subarray(6,9);Gi(e,o);let l=o[2]<0.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),Vi(a,o,r)<h){let c,d;if(l)c=a[2],d=1;else c=0,d=a[2];let u=0.005;while(d-c>u){let f=a[2]=(c+d)/2;if(l===Vi(a,o,r)<h)c=f;else d=f}a[2]=l?d:c}return qs(a,r),i=L.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),zi.set(s,i),i}function wn({html:t,dir:e,className:s},i){let n=document.createDocumentFragment();if(typeof t==="string"){let r=document.createElement("p");r.dir=e||"auto";let a=t.split(/\r\n?|\n/);for(let o=0,l=a.length;o<l;++o){let h=a[o];if(r.append(document.createTextNode(h)),o<l-1)r.append(document.createElement("br"))}n.append(r)}else oi.render({xfaHtml:t,div:n,intent:"richText"});n.firstElementChild.classList.add("richText",s),i.append(n)}function xn(t){let e=new Path2D;if(!t)return e;for(let s=0,i=t.length;s<i;)switch(t[s++]){case ke.moveTo:e.moveTo(t[s++],t[s++]);break;case ke.lineTo:e.lineTo(t[s++],t[s++]);break;case ke.curveTo:e.bezierCurveTo(t[s++],t[s++],t[s++],t[s++],t[s++],t[s++]);break;case ke.quadraticCurveTo:e.quadraticCurveTo(t[s++],t[s++],t[s++],t[s++]);break;case ke.closePath:e.closePath();break;default:z(`Unrecognized drawing path operator: ${t[s-1]}`);break}return e}var vo=K(4972),yo=K(8454),bo=K(9452),Ao=K(4979),So=K(3579),wo=K(3110),xo=K(9314),Eo=K(1148),To=K(116),Co=K(9112);class _e{#t=null;#e=null;#s;#i=null;#n=null;#a=null;#r=null;#o=null;static#l=null;constructor(t){this.#s=t,_e.#l||=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",signature:"pdfjs-editor-remove-signature-button"})}render(){let t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#s._uiManager._signal;if(e instanceof AbortSignal&&!e.aborted)t.addEventListener("contextmenu",zt,{signal:e}),t.addEventListener("pointerdown",_e.#h,{signal:e});let s=this.#i=document.createElement("div");s.className="buttons",t.append(s);let i=this.#s.toolbarPosition;if(i){let{style:n}=t,r=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#t}static#h(t){t.stopPropagation()}#u(t){this.#s._focusEventsAllowed=!1,At(t)}#d(t){this.#s._focusEventsAllowed=!0,At(t)}#f(t){let e=this.#s._uiManager._signal;if(!(e instanceof AbortSignal)||e.aborted)return!1;return t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",zt,{signal:e}),!0}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#n?.shown(),this.#a?.shown()}addDeleteButton(){let{editorType:t,_uiManager:e}=this.#s,s=document.createElement("button");if(s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",_e.#l[t]),this.#f(s))s.addEventListener("click",(i)=>{e.delete()},{signal:e._signal});this.#i.append(s)}get#g(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#f(e),this.#i.append(e,this.#g),this.#n=t}addComment(t,e=null){if(this.#a)return;let s=t.renderForToolbar();if(!s)return;this.#f(s);let i=this.#r=this.#g;if(!e)this.#i.append(s,i);else this.#i.insertBefore(s,e),this.#i.insertBefore(i,e);this.#a=t,t.toolbar=this}addColorPicker(t){if(this.#e)return;this.#e=t;let e=t.renderButton();this.#f(e),this.#i.append(e,this.#g)}async addEditSignatureButton(t){let e=this.#o=await t.renderEditButton(this.#s);this.#f(e),this.#i.append(e,this.#g)}removeButton(t){switch(t){case"comment":this.#a?.removeToolbarCommentButton(),this.#a=null,this.#r?.remove(),this.#r=null;break}}async addButton(t,e){switch(t){case"colorPicker":if(e)this.addColorPicker(e);break;case"altText":if(e)await this.addAltText(e);break;case"editSignature":if(e)await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":if(e)this.addComment(e);break}}async addButtonBefore(t,e,s){if(!e&&t==="comment")return;let i=this.#i.querySelector(s);if(!i)return;if(t==="comment")this.addComment(e,i)}updateEditSignatureButton(t){if(this.#o)this.#o.title=t}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class En{#t=null;#e=null;#s;constructor(t){this.#s=t}#i(){let t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.dir=this.#s.direction;let e=this.#s._signal;if(e instanceof AbortSignal&&!e.aborted)t.addEventListener("contextmenu",zt,{signal:e});let s=this.#t=document.createElement("div");if(s.className="buttons",t.append(s),this.#s.hasCommentManager())this.#a("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#s.commentSelection("floating_button")});return this.#a("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#s.highlightSelection("floating_button")}),t}#n(t,e){let s=0,i=0;for(let n of t){let r=n.y+n.height;if(r<s)continue;let a=n.x+(e?n.width:0);if(r>s){i=a,s=r;continue}if(e){if(a>i)i=a}else if(a<i)i=a}return[e?1-i:i,s]}show(t,e,s){let[i,n]=this.#n(e,s),{style:r}=this.#e||=this.#i();t.append(this.#e),r.insetInlineEnd=`${100*i}%`,r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#a(t,e,s,i){let n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",e);let r=document.createElement("span");n.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",s);let a=this.#s._signal;if(a instanceof AbortSignal&&!a.aborted)n.addEventListener("contextmenu",zt,{signal:a}),n.addEventListener("click",i,{signal:a});this.#t.append(n)}}var ma="59968104-cc61-4cf9-b570-014b35b3709c",Vs=Object.freeze({internal:ma});function Tn(t,e,s){for(let i of s)e.addEventListener(i,t[i].bind(t))}class at{static#t=NaN;static#e=null;static#s=NaN;static#i=null;static initializeAndAddPointerId(t){(at.#e||=new Set).add(t)}static setPointer(t,e){at.#t||=e,at.#i??=t}static setTimeStamp(t){at.#s=t}static isSamePointerId(t){return at.#t===t}static isSamePointerIdOrRemove(t){if(at.#t===t)return!0;return at.#e?.delete(t),!1}static isSamePointerType(t){return at.#i===t}static isInitializedAndDifferentPointerType(t){return at.#i!==null&&!at.isSamePointerType(t)}static isSameTimeStamp(t){return at.#s===t}static isUsingMultiplePointers(){return at.#e?.size>=1}static clearPointerType(){at.#i=null}static clearPointerIds(){at.#t=NaN,at.#e=null}static clearTimeStamp(){at.#s=NaN}}class Cn{#t=0;get id(){return`${Ce}${this.#t++}`}}class ci{#t=bn();#e=0;#s=null;static get _isSVGFittingCanvas(){let t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${Mt}"><rect width="1" height="1" style="fill:red;"/></svg>`,s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;let n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return j(this,"_isSVGFittingCanvas",n)}async#i(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let i;if(typeof e==="string")s.url=e,i=await li(e,"blob");else if(e instanceof File)i=s.file=e;else if(e instanceof Blob)i=e;if(i.type==="image/svg+xml"){let n=ci._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise((l,h)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,l()},r.onload=async()=>{let c=s.svgUrl=r.result;a.src=await n?`${c}#svgView(preserveAspectRatio(none))`:c},a.onerror=r.onerror=h});r.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){z(i),s=null}if(this.#s.set(t,s),s)this.#s.set(s.id,s);return s}async getFromFile(t){let{lastModified:e,name:s,size:i,type:n}=t;return this.#i(`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return this.#i(t,t)}async getFromBlob(t,e){let s=await e;return this.#i(t,s)}async getFromId(t){this.#s||=new Map;let e=this.#s.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s?.bitmap)return s.refCounter+=1,s;let i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#s.set(t,s),this.#s.set(s.id,s),s}getSvgUrl(t){let e=this.#s.get(t);if(!e?.isSvg)return null;return e.svgUrl}deleteId(t){this.#s||=new Map;let e=this.#s.get(t);if(!e)return;if(e.refCounter-=1,e.refCounter!==0)return;let{bitmap:s}=e;if(!e.url&&!e.file){let i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=i.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class In{#t=[];#e=!1;#s;#i=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(i)t();if(this.#e)return;let o={cmd:t,undo:e,post:s,type:n};if(this.#i===-1){if(this.#t.length>0)this.#t.length=0;this.#i=0,this.#t.push(o);return}if(r&&this.#t[this.#i].type===n){if(a)o.undo=this.#t[this.#i].undo;this.#t[this.#i]=o;return}let l=this.#i+1;if(l===this.#s)this.#t.splice(0,1);else if(this.#i=l,l<this.#t.length)this.#t.splice(l);this.#t.push(o)}undo(){if(this.#i===-1)return;this.#e=!0;let{undo:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1,this.#i-=1}redo(){if(this.#i<this.#t.length-1){this.#i+=1,this.#e=!0;let{cmd:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#i!==-1}hasSomethingToRedo(){return this.#i<this.#t.length-1}cleanType(t){if(this.#i===-1)return;for(let e=this.#i;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#i-e),this.#i=e;return}this.#t.length=0,this.#i=-1}destroy(){this.#t=null}}class Ft{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;let{isMac:e}=ot.platform;for(let[s,i,n={}]of t){let r=s.some((a)=>a.startsWith("mac+"));for(let a of s){let o=a;if(r){let c=a.startsWith("mac+");if(e!==c)continue;if(c)o=a.slice(4)}let[l,h]=Ft.#t(o);if(l===null)continue;this.callbacks.getOrInsertComputed(l,Ie).push({callback:i,options:n,modifiers:h})}}}static#t(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;let n=i.toUpperCase(),r=Ft[n];if(r){s|=r;continue}if(e!==null){z(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=n==="SPACE"?" ":i}if(e===null)z(`KeyboardManager: no key found in shortcut "${t}"`);return[e,s]}static#e(t){let e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);if(!e)return null;return e[1]?.toLowerCase()??e[2]}exec(t,e){let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;let h=Ft.#e(e.code);if(h===null||h===e.key)return;if(s=this.callbacks.get(h),!s)return}let i=(e.altKey?Ft.ALT:0)|(e.ctrlKey?Ft.CTRL:0)|(e.metaKey?Ft.META:0)|(e.shiftKey?Ft.SHIFT:0),n=s.find((h)=>h.modifiers===i);if(!n)return;let{callback:r,options:{bubbles:a=!1,args:o=[],checker:l=null}}=n;if(l&&!l(t,e))return;if(r.bind(t,...o,e)(),!a)At(e)}}class di{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]);return fa(t),j(this,"_colors",t)}convert(t){let e=Ke(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[s,i]of this._colors)if(i.every((n,r)=>n===e[r]))return di._colorsMapping.get(s);return e}getHexCode(t){let e=this._colors.get(t);if(!e)return t;return L.makeHexColor(...e)}}class ae{#t=new AbortController;#e=null;#s=null;#i=new Map;#n=new Map;#a=null;#r=null;#o=null;#l=null;#h=null;#u=new In;#d=null;#f=null;#g=null;#m=0;#c=new Set;#p=null;#v=null;#y=new Set;_editorUndoBar=null;#b=!1;#A=!1;#x=!1;#w=null;#E=null;#T=null;#O=null;#P=!1;#I=null;#D=new Cn;#R=!1;#k=!1;#U=!1;#L=null;#F=null;#V=null;#B=null;#j=null;#C=Y.NONE;#S=new Set;#_=null;#$=null;#z=null;#J=null;#Y=null;#K={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#N=[0,0];#W=null;#X=null;#tt=null;#et=null;#H=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=ae.prototype,e=(r)=>r.#X.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&r.hasSomethingToControl(),s=(r,{target:a})=>{if(a instanceof HTMLInputElement){let{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return j(this,"_keyboardManager",new Ft([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["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:s}],[["Enter"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#X.contains(a)&&!r.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(r,{target:a})=>!(a instanceof HTMLButtonElement)&&r.#X.contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,s,i,n,r,a,o,l,h,c,d,u,f,p,g){let m=this._signal=this.#t.signal;this.#X=t,this.#tt=e,this.#et=s,this.#o=i,this.#d=n,this.#$=r,this.#Y=o,this._eventBus=a;let v={signal:m,...Vs};a.on("editingaction",this.onEditingAction.bind(this),v),a.on("pagechanging",this.onPageChanging.bind(this),v),a.on("scalechanging",this.onScaleChanging.bind(this),v),a.on("rotationchanging",this.onRotationChanging.bind(this),v),a.on("setpreference",this.onSetPreference.bind(this),v),a.on("switchannotationeditorparams",(y)=>this.updateParams(y.type,y.value),v),window.addEventListener("pointerdown",()=>{this.#k=!0},{capture:!0,signal:m}),window.addEventListener("pointerup",()=>{this.#k=!1},{capture:!0,signal:m}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:m}),this.#lt(),this.#pt(),this.#it(),this.#l=o.annotationStorage,this.#w=o.filterFactory,this.#z=l,this.#O=h||null,this.#b=c,this.#A=d,this.#x=u,this.#j=f||null,this.viewParameters={realScale:pe.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=p||null,this._supportsPinchToZoom=g!==!1,n?.setSidebarUiManager(this)}destroy(){this.#H?.resolve(),this.#H=null,this.#t?.abort(),this.#t=null,this._signal=null;for(let t of this.#n.values())t.destroy();if(this.#n.clear(),this.#i.clear(),this.#y.clear(),this.#B?.clear(),this.#e=null,this.#S.clear(),this.#u.destroy(),this.#o?.destroy(),this.#d?.destroy(),this.#$?.destroy(),this.#I?.hide(),this.#I=null,this.#V?.destroy(),this.#V=null,this.#s=null,this.#E)clearTimeout(this.#E),this.#E=null;if(this.#W)clearTimeout(this.#W),this.#W=null;this._editorUndoBar?.destroy(),this.#Y=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#j}get useNewAltTextFlow(){return this.#A}get useNewAltTextWhenAddingImage(){return this.#x}get hcmFilter(){return j(this,"hcmFilter",this.#z?this.#w.addHCMFilter(this.#z.foreground,this.#z.background):"none")}get direction(){return j(this,"direction",getComputedStyle(this.#X).direction)}get _highlightColors(){return j(this,"_highlightColors",this.#O?new Map(this.#O.split(",").map((t)=>(t=t.split("=").map((e)=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){let{_highlightColors:t}=this;if(!t)return j(this,"highlightColors",null);let e=new Map,s=!!this.#z;for(let[i,n]of t){let r=i.endsWith("_HCM");if(s&&r){e.set(i.replace("_HCM",""),n);continue}if(!s&&!r)e.set(i,n)}return j(this,"highlightColors",e)}get highlightColorNames(){return j(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t)=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;let e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){if(t)this.unselectAll(),this.disableUserSelect(!0);else this.disableUserSelect(!1);this.#g=t}setMainHighlightColorPicker(t){this.#V=t}editAltText(t,e=!1){this.#o?.editAltText(this,t,e)}hasCommentManager(){return!!this.#d}editComment(t,e,s,i){this.#d?.showDialog(this,t,e,s,i)}selectComment(t,e){this.#n.get(t)?.getEditorByUID(e)?.toggleComment(!0,!0)}updateComment(t){this.#d?.updateComment(t.getData())}updatePopupColor(t){this.#d?.updatePopupColor(t)}removeComment(t){this.#d?.removeComments([t.uid])}deleteComment(t,e){let s=()=>{t.comment=e},i=()=>{this._editorUndoBar?.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){this.#d?.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){return t&&this.#d?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#d?.dialogElement||null}async waitForEditorsRendered(t){if(this.#n.has(t-1))return;let{resolve:e,promise:s}=Promise.withResolvers(),i=(n)=>{if(n.pageNumber===t)this._eventBus.off("editorsrendered",i),e()};this._eventBus.on("editorsrendered",i,Vs),await s}getSignature(t){this.#$?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#$}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...Vs}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":this.#x=e;break}}onPageChanging({pageNumber:t}){this.#m=t-1}deletePage(t){for(let e of this.getEditors(t))e.remove();if(this.#n.delete(t),this.#m===t)this.#m=0}focusMainContainer(){this.#X.focus()}findParent(t,e){for(let s of this.#n.values()){let{x:i,y:n,width:r,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+r&&e>=n&&e<=n+a)return s}return null}disableUserSelect(t=!1){this.#tt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#y.add(t)}removeShouldRescale(t){this.#y.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*pe.PDF_TO_CSS_UNITS;for(let e of this.#y)e.onScaleChanging();this.#g?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#q({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#st(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let s of this.#n.values())if(s.hasTextLayer(t))return s;return null}highlightSelection(t="",e=!1){let s=document.getSelection();if(!s||s.isCollapsed)return;let{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:a}=s,o=s.toString(),h=this.#q(s).closest(".textLayer"),c=this.getSelectionBoxes(h);if(!c)return;s.empty();let d=this.#st(h),u=this.#C===Y.NONE,f=()=>{let p=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:c,anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:a,text:o});if(u)this.showAllEditors("highlight",!0,!0);if(e)p?.editComment()};if(u){this.switchToMode(Y.HIGHLIGHT,f);return}f()}commentSelection(t=""){this.highlightSelection(t,!0)}endCurrentEditing(){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#at(){let t=document.getSelection();if(!t||t.isCollapsed)return;let s=this.#q(t).closest(".textLayer"),i=this.getSelectionBoxes(s);if(!i)return;this.#I||=new En(this),this.#I.show(s,i,this.direction==="ltr")}getAndRemoveDataFromAnnotationStorage(t){if(!this.#l)return null;let e=`${Ce}${t}`,s=this.#l.getRawValue(e);if(s)this.#l.remove(e);return s}addToAnnotationStorage(t){if(!t.isEmpty()&&this.#l&&!this.#l.has(t.id))this.#l.setValue(t.id,t)}a11yAlert(t,e=null){let s=this.#et;if(!s)return;if(s.setAttribute("data-l10n-id",t),e)s.setAttribute("data-l10n-args",JSON.stringify(e));else s.removeAttribute("data-l10n-args")}#ot(){let t=document.getSelection();if(!t||t.isCollapsed){if(this.#_)this.#I?.hide(),this.#_=null,this.#M({hasSelectedText:!1});return}let{anchorNode:e}=t;if(e===this.#_)return;let i=this.#q(t).closest(".textLayer");if(!i){if(this.#_)this.#I?.hide(),this.#_=null,this.#M({hasSelectedText:!1});return}if(this.#I?.hide(),this.#_=e,this.#M({hasSelectedText:!0}),this.#C!==Y.HIGHLIGHT&&this.#C!==Y.NONE)return;if(this.#C===Y.HIGHLIGHT)this.showAllEditors("highlight",!0,!0);if(this.#P=this.isShiftKeyDown,!this.isShiftKeyDown){let n=this.#C===Y.HIGHLIGHT?this.#st(i):null;if(n?.toggleDrawing(),this.#k){let r=new AbortController,a=this.combinedSignal(r),o=(l)=>{if(l.type==="pointerup"&&l.button!==0)return;if(r.abort(),n?.toggleDrawing(!0),l.type==="pointerup")this.#Q("main_toolbar")};window.addEventListener("pointerup",o,{signal:a}),window.addEventListener("blur",o,{signal:a})}else n?.toggleDrawing(!0),this.#Q("main_toolbar")}}#Q(t=""){if(this.#C===Y.HIGHLIGHT)this.highlightSelection(t);else if(this.#b)this.#at()}#lt(){document.addEventListener("selectionchange",this.#ot.bind(this),{signal:this._signal})}#ht(){if(this.#T)return;this.#T=new AbortController;let t=this.combinedSignal(this.#T);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#ct(){this.#T?.abort(),this.#T=null}blur(){if(this.isShiftKeyDown=!1,this.#P)this.#P=!1,this.#Q("main_toolbar");if(!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#S)if(e.div.contains(t)){this.#F=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#F)return;let[t,e]=this.#F;this.#F=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#it(){if(this.#L)return;this.#L=new AbortController;let t=this.combinedSignal(this.#L);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#dt(){this.#L?.abort(),this.#L=null}#ut(){if(this.#f)return;this.#f=new AbortController;let t=this.combinedSignal(this.#f);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#ft(){this.#f?.abort(),this.#f=null}#pt(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#it(),this.setEditingState(!0)}removeEditListeners(){this.#dt(),this.setEditingState(!1)}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let s of this.#v)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let s of this.#v)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let s of this.#S){let i=s.serialize(!0);if(i)e.push(i)}if(e.length===0)return;t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let n of e.items)for(let r of this.#v)if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){z(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();let i=this.currentLayer;try{let n=[];for(let o of s){let l=await i.deserialize(o);if(!l)return;n.push(l)}let r=()=>{for(let o of n)this.#nt(o);this.#rt(n)},a=()=>{for(let o of n)o.remove()};this.addCommands({cmd:r,undo:a,mustExec:!0})}catch(n){z(`paste: "${n.message}".`)}}keydown(t){if(!this.isShiftKeyDown&&t.key==="Shift")this.isShiftKeyDown=!0;if(this.#C!==Y.NONE&&!this.isEditorHandlingKeyboard)ae._keyboardManager.exec(this,t)}keyup(t){if(this.isShiftKeyDown&&t.key==="Shift"){if(this.isShiftKeyDown=!1,this.#P)this.#P=!1,this.#Q("main_toolbar")}}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}updatePageIndex(t,e){for(let i of this.#r.get(t)||[])i.pageIndex=e;let s=this.#a.get(t);if(s)if(s.pageIndex=e,this.#n.set(e,s),this.#R)s.enable();else s.disable()}startUpdatePages(){this.#a=new Map(this.#n),this.#n.clear();let t=this.#r=new Map,e=(s)=>{t.getOrInsertComputed(s.pageIndex,Ie).push(s)};for(let s of this.#i.values())e(s);for(let[s,i]of this.#l)if(s.startsWith(Ce)&&!this.#i.has(s)&&Number.isInteger(i?.pageIndex))e(i)}endUpdatePages(){this.#a=null,this.#r=null}clonePage(t,e){for(let s of this.getEditors(t)){let i=s.serialize(s.mode!==Y.HIGHLIGHT);if(!i)continue;i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,this.#l.setValue(i.id,i)}}findClonesForPage(t){let e=[],{pageIndex:s}=t;for(let[i,n]of this.#l)if(n.pageIndex===s&&n.isClone)this.#l.remove(i),e.push(t.deserialize(n).then((r)=>{if(r)r.isClone=!0,t.addOrRebuild(r)}));return Promise.all(e)}#M(t){if(Object.entries(t).some(([s,i])=>this.#K[s]!==i)){if(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#K,t)}),this.#C===Y.HIGHLIGHT&&t.hasSelectedEditor===!1)this.#G([[q.HIGHLIGHT_FREE,!0]])}}#G(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){if(t)this.#ht(),this.#ut(),this.#M({isEditing:this.#C!==Y.NONE,isEmpty:this.#Z(),hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:this.#u.hasSomethingToRedo(),hasSelectedEditor:!1});else this.#ct(),this.#ft(),this.#M({isEditing:!1}),this.disableUserSelect(!1)}registerEditorTypes(t){if(this.#v)return;this.#v=t;for(let e of this.#v)this.#G(e.defaultPropertiesToUpdate)}getId(){return this.#D.id}get currentLayer(){return this.#n.get(this.#m)}getLayer(t){return this.#n.get(t)}get currentPageIndex(){return this.#m}addLayer(t){if(this.#n.set(t.pageIndex,t),this.#R)t.enable();else t.disable()}removeLayer(t){this.#n.delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,n=!1,r=!1){if(this.#C===t)return;if(this.#H){if(await this.#H.promise,!this.#H)return}if(this.#H=Promise.withResolvers(),this.#g?.commitOrRemove(),this.#C===Y.POPUP)this.#d?.hideSidebar();if(this.#d?.destroyPopup(),this.#C=t,t===Y.NONE){this.setEditingState(!1),this.#mt();for(let a of this.#i.values())a.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#H.resolve();return}for(let a of this.#i.values())a.addStandaloneCommentButton();if(t===Y.SIGNATURE)await this.#$?.loadSignatures();if(s)at.clearPointerType();this.setEditingState(!0),await this.#gt(),this.unselectAll();for(let a of this.#n.values())a.updateMode(t);if(t===Y.POPUP){this.#s||=await this.#Y.getAnnotationsByType(new Set(this.#v.map((l)=>l._editorType)));let a=new Set,o=[];for(let l of this.#i.values()){let{annotationElementId:h,hasComment:c,deleted:d}=l;if(h)a.add(h);if(c&&!d)o.push(l.getData())}for(let l of this.#s){let{id:h,popupRef:c,contentsObj:d}=l;if(c&&d?.str&&!a.has(h)&&!this.#c.has(h))o.push(l)}this.#d?.showSidebar(o)}if(!e){if(i)this.addNewEditorFromKeyboard();this.#H.resolve();return}for(let a of this.#i.values())if(a.uid===e)if(this.setSelected(a),r)a.editComment();else if(n)a.enterInEditMode();else a.focus();else a.unselect();this.#H.resolve()}addNewEditorFromKeyboard(){if(this.currentLayer.canCreateNewEmptyEditor())this.currentLayer.addNewEditor()}updateToolbar(t){if(t.mode===this.#C)return;this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(!this.#v)return;switch(t){case q.CREATE:this.currentLayer.addNewEditor(e);return;case q.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#J||=new Map).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(let s of this.#S)s.updateParams(t,e);else for(let s of this.#v)s.updateDefaultParams(t,e)}showAllEditors(t,e,s=!1){for(let n of this.#i.values())if(n.editorType===t)n.show(e);if((this.#J?.get(q.HIGHLIGHT_SHOW_ALL)??!0)!==e)this.#G([[q.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#U===t)return;this.#U=t;for(let e of this.#n.values()){if(t)e.disableClick();else e.enableClick();e.div.classList.toggle("waiting",t)}}async#gt(){if(!this.#R){this.#R=!0;let t=[];for(let e of this.#n.values())t.push(e.enable());await Promise.all(t);for(let e of this.#i.values())e.enable()}}#mt(){if(this.unselectAll(),this.#R){this.#R=!1;for(let t of this.#n.values())t.disable();for(let t of this.#i.values())t.disable()}}*getEditors(t){for(let e of this.#i.values())if(e.pageIndex===t)yield e}getEditor(t){return this.#i.get(t)}addEditor(t){this.#i.set(t.id,t)}removeEditor(t){if(t.div.contains(document.activeElement)){if(this.#E)clearTimeout(this.#E);this.#E=setTimeout(()=>{this.focusMainContainer(),this.#E=null},0)}if(this.#i.delete(t.id),t.annotationElementId)this.#B?.delete(t.annotationElementId);if(this.unselect(t),!t.annotationElementId||!this.#c.has(t.annotationElementId))this.#l?.remove(t.id)}addDeletedAnnotationElement(t){this.#c.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#c.has(t)}removeDeletedAnnotationElement(t){this.#c.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#nt(t){let e=this.#n.get(t.pageIndex);if(e)e.addOrRebuild(t);else this.addEditor(t),this.addToAnnotationStorage(t)}setActiveEditor(t){if(this.#e===t)return;if(this.#e=t,t)this.#G(t.propertiesToUpdate)}get#vt(){let t=null;for(t of this.#S);return t}updateUI(t){if(this.#vt===t)this.#G(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#G(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#S.has(t)){this.#S.delete(t),t.unselect(),this.#M({hasSelectedEditor:this.hasSelection});return}this.#S.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#M({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#g?.commitOrRemove();for(let e of this.#S)if(e!==t)e.unselect();this.#d?.destroyPopup(),this.#S.clear(),this.#S.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#M({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#S.values().next().value}unselect(t){t.unselect(),this.#S.delete(t),this.#M({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#S.size!==0}get isEnterHandled(){return this.#S.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#u.undo(),this.#M({hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Z()}),this._editorUndoBar?.hide()}redo(){this.#u.redo(),this.#M({hasSomethingToUndo:!0,hasSomethingToRedo:this.#u.hasSomethingToRedo(),isEmpty:this.#Z()})}addCommands(t){this.#u.add(t),this.#M({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Z()})}cleanUndoStack(t){this.#u.cleanType(t)}#Z(){if(this.#i.size===0)return!0;if(this.#i.size===1)for(let t of this.#i.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#S],s=()=>{this._editorUndoBar?.show(i,e.length===1?e[0].editorType:e.length);for(let n of e)n.remove()},i=()=>{for(let n of e)this.#nt(n)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#rt(t){for(let e of this.#S)e.unselect();this.#S.clear();for(let e of t){if(e.isEmpty())continue;this.#S.add(e),e.select()}this.#M({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#S)t.commit();this.#rt(this.#i.values())}unselectAll(){if(this.#e){if(this.#e.commitOrRemove(),this.#C!==Y.NONE)return}if(this.#g?.commitOrRemove())return;if(this.#d?.destroyPopup(),!this.hasSelection)return;for(let t of this.#S)t.unselect();this.#S.clear(),this.#M({hasSelectedEditor:!1})}translateSelectedEditors(t,e,s=!1){if(!s)this.commitOrRemove();if(!this.hasSelection)return;this.#N[0]+=t,this.#N[1]+=e;let[i,n]=this.#N,r=[...this.#S],a=1000;if(this.#W)clearTimeout(this.#W);this.#W=setTimeout(()=>{this.#W=null,this.#N[0]=this.#N[1]=0,this.addCommands({cmd:()=>{for(let o of r)if(this.#i.has(o.id))o.translateInPage(i,n),o.translationDone()},undo:()=>{for(let o of r)if(this.#i.has(o.id))o.translateInPage(-i,-n),o.translationDone()},mustExec:!1})},a);for(let o of r)o.translateInPage(t,e),o.translationDone()}setUpDragSession(){if(!this.hasSelection)return;this.disableUserSelect(!0),this.#p=new Map;for(let t of this.#S)this.#p.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#p)return!1;this.disableUserSelect(!1);let t=this.#p;this.#p=null;let e=!1;for(let[{x:i,y:n,pageIndex:r},a]of t)a.newX=i,a.newY=n,a.newPageIndex=r,e||=i!==a.savedX||n!==a.savedY||r!==a.savedPageIndex;if(!e)return!1;let s=(i,n,r,a)=>{if(this.#i.has(i.id)){let o=this.#n.get(a);if(o)i._setParentAndPosition(o,n,r);else i.pageIndex=a,i.x=n,i.y=r}};return this.addCommands({cmd:()=>{for(let[i,{newX:n,newY:r,newPageIndex:a}]of t)s(i,n,r,a)},undo:()=>{for(let[i,{savedX:n,savedY:r,savedPageIndex:a}]of t)s(i,n,r,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(!this.#p)return;for(let s of this.#p.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){let e=this.getLayer(t.pageIndex);if(e)e.changeParent(t),e.addOrRebuild(t);else this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild()}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#S.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#C}isEditingMode(){return this.#C!==Y.NONE}get imageManager(){return j(this,"imageManager",new ci)}getSelectionBoxes(t){if(!t)return null;let e=document.getSelection();for(let l=0,h=e.rangeCount;l<h;l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;let{x:s,y:i,width:n,height:r}=t.getBoundingClientRect(),a;switch(t.getAttribute("data-main-rotation")){case"90":a=(l,h,c,d)=>({x:(h-i)/r,y:1-(l+c-s)/n,width:d/r,height:c/n});break;case"180":a=(l,h,c,d)=>({x:1-(l+c-s)/n,y:1-(h+d-i)/r,width:c/n,height:d/r});break;case"270":a=(l,h,c,d)=>({x:1-(h+d-i)/r,y:(l-s)/n,width:d/r,height:c/n});break;default:a=(l,h,c,d)=>({x:(l-s)/n,y:(h-i)/r,width:c/n,height:d/r});break}let o=[];for(let l=0,h=e.rangeCount;l<h;l++){let c=e.getRangeAt(l);if(c.collapsed)continue;for(let{x:d,y:u,width:f,height:p}of c.getClientRects()){if(f===0||p===0)continue;o.push(a(d,u,f,p))}}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#h||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#h?.delete(t)}renderAnnotationElement(t){let e=this.#h?.get(t.data.id);if(!e)return;let s=this.#l.getRawValue(e);if(!s)return;if(this.#C===Y.NONE&&!s.hasBeenModified)return;s.renderAnnotationElement(t)}setMissingCanvas(t,e,s){let i=this.#B?.get(t);if(!i)return;i.setCanvas(e,s),this.#B.delete(t)}addMissingCanvas(t,e){(this.#B||=new Map).set(t,e)}}class Zt{#t=null;#e=!1;#s=null;#i=null;#n=null;#a=null;#r=!1;#o=null;#l=null;#h=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#l=t,this.#d=t._uiManager.useNewAltTextFlow,Zt.#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){Zt._l10n??=t}async render(){let t=this.#s=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#i=document.createElement("span");if(t.append(e),this.#d)t.classList.add("new"),t.setAttribute("data-l10n-id",Zt.#f.missing),e.setAttribute("data-l10n-id",Zt.#f["missing-label"]);else t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label");let s=this.#l._uiManager._signal;t.addEventListener("contextmenu",zt,{signal:s}),t.addEventListener("pointerdown",(n)=>n.stopPropagation(),{signal:s});let i=(n)=>{if(n.preventDefault(),this.#l._uiManager.editAltText(this.#l),this.#d)this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#g}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",(n)=>{if(n.target===t&&n.key==="Enter")this.#r=!0,i(n)},{signal:s}),await this.#m(),t}get#g(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){if(!this.#s)return;this.#s.focus({focusVisible:this.#r}),this.#r=!1}isEmpty(){return this.#d?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#d?this.#t!==null||!!this.#h:this.isEmpty()}get guessedText(){return this.#h}async setGuessedText(t){if(this.#t!==null)return;this.#h=t,this.#u=await Zt._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#m()}toggleAltTextBadge(t=!1){if(!this.#d||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){let e=this.#o=document.createElement("div");e.className="noAltTextBadge",this.#l.div.append(e)}this.#o.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;if(!t&&this.#h===e)e=this.#u;return{altText:e,decorative:this.#e,guessedText:this.#h,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){if(s)this.#h=s,this.#u=i;if(this.#t===t&&this.#e===e)return;if(!n)this.#t=t,this.#e=e;this.#m()}toggle(t=!1){if(!this.#s)return;if(!t&&this.#a)clearTimeout(this.#a),this.#a=null;this.#s.disabled=!t}shown(){this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#g}})}destroy(){this.#s?.remove(),this.#s=null,this.#i=null,this.#n=null,this.#o?.remove(),this.#o=null}async#m(){let t=this.#s;if(!t)return;if(this.#d){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",Zt.#f[this.#g]),this.#i?.setAttribute("data-l10n-id",Zt.#f[`${this.#g}-label`]),!this.#t){this.#n?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#n?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#n;if(!e){this.#n=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#l.id}`;let i=100,n=this.#l._uiManager._signal;n.addEventListener("abort",()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#a=setTimeout(()=>{this.#a=null,this.#n.classList.add("show"),this.#l._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:n}),t.addEventListener("mouseleave",()=>{if(this.#a)clearTimeout(this.#a),this.#a=null;this.#n?.classList.remove("show")},{signal:n})}if(this.#e)e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip");else e.removeAttribute("data-l10n-id"),e.textContent=this.#t;if(!e.parentNode)t.append(e);this.#l.getElementForAltText()?.setAttribute("aria-describedby",e.id)}}class Fe{#t=null;#e=null;#s=!1;#i=null;#n=null;#a=null;#r=null;#o=null;#l=!1;#h=null;constructor(t){this.#i=t}renderForToolbar(){let t=this.#e=document.createElement("button");return t.className="comment",this.#u(t,!1)}renderForStandalone(){let t=this.#t=document.createElement("button");t.className="annotationCommentButton";let e=this.#i.commentButtonPosition;if(e){let{style:s}=t;s.insetInlineEnd=`calc(${100*(this.#i._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;let i=this.#i.commentButtonColor;if(i)s.backgroundColor=i}return this.#u(t,!0)}focusButton(){setTimeout(()=>{(this.#t??this.#e)?.focus()},0)}onUpdatedColor(){if(!this.#t)return;let t=this.#i.commentButtonColor;if(t)this.#t.style.backgroundColor=t;this.#i._uiManager.updatePopupColor(this.#i)}get commentButtonWidth(){return(this.#t?.getBoundingClientRect().width??0)/this.#i.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#h)return this.#h;if(!this.#t)return null;let{x:t,y:e,height:s}=this.#t.getBoundingClientRect(),{x:i,y:n,width:r,height:a}=this.#i.parent.boundingClientRect;return[(t-i)/r,(e+s-n)/a]}set commentPopupPositionInLayer(t){this.#h=t}hasDefaultPopupPosition(){return this.#h===null}removeStandaloneCommentButton(){this.#t?.remove(),this.#t=null}removeToolbarCommentButton(){this.#e?.remove(),this.#e=null}setCommentButtonStates({selected:t,hasPopup:e}){if(!this.#t)return;this.#t.classList.toggle("selected",t),this.#t.ariaExpanded=e}#u(t,e){if(!this.#i._uiManager.hasCommentManager())return null;if(t.tabIndex="0",t.ariaHasPopup="dialog",e)t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button");else t.ariaControlsElements=[this.#i._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button");let s=this.#i._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;if(t.addEventListener("contextmenu",zt,{signal:s}),e)t.addEventListener("focusin",(n)=>{this.#i._focusEventsAllowed=!1,At(n)},{capture:!0,signal:s}),t.addEventListener("focusout",(n)=>{this.#i._focusEventsAllowed=!0,At(n)},{capture:!0,signal:s});t.addEventListener("pointerdown",(n)=>n.stopPropagation(),{signal:s});let i=(n)=>{if(n.preventDefault(),t===this.#e)this.edit();else this.#i.toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",(n)=>{if(n.target===t&&n.key==="Enter")this.#s=!0,i(n)},{signal:s}),t.addEventListener("pointerenter",()=>{this.#i.toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{this.#i.toggleComment(!1,!1)},{signal:s}),t}edit(t){let e=this.commentPopupPositionInLayer,s,i;if(e)[s,i]=e;else{[s,i]=this.#i.commentButtonPosition;let{width:h,height:c,x:d,y:u}=this.#i;s=d+s*h,i=u+i*c}let n=this.#i.parent.boundingClientRect,{x:r,y:a,width:o,height:l}=n;this.#i._uiManager.editComment(this.#i,r+s*o,a+i*l,{...t,parentDimensions:n})}finish(){if(!this.#e)return;this.#e.focus({focusVisible:this.#s}),this.#s=!1}isDeleted(){return this.#l||this.#r===""}isEmpty(){return this.#r===null}hasBeenEdited(){return this.isDeleted()||this.#r!==this.#n}serialize(){return this.data}get data(){return{text:this.#r,richText:this.#a,date:this.#o,deleted:this.isDeleted()}}set data(t){if(t!==this.#r)this.#a=null;if(t===null){this.#r="",this.#l=!0;return}this.#r=t,this.#o=new Date,this.#l=!1}restoreData({text:t,richText:e,date:s}){this.#r=t,this.#a=e,this.#o=s,this.#l=!1}setInitialText(t,e=null){this.#n=t,this.data=t,this.#o=null,this.#a=e}shown(){}destroy(){this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null,this.#r="",this.#a=null,this.#o=null,this.#i=null,this.#s=!1,this.#l=!1}}function Wi(t){t.preventDefault()}var Xi=0.0001;function zs(t){if(t.cancelable)return At(t),!0;return t.stopPropagation(),!1}class ui{#t;#e=!1;#s=null;#i;#n;#a;#r;#o;#l=!1;#h=null;#u;#d=new Set;#f=null;#g;#m=null;#c=0;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:n=null,onPinchEnd:r=null,onPanning:a=null,signal:o}){this.#t=t,this.#s=s,this.#i=e,this.#n=i,this.#a=n,this.#r=r,this.#o=a,this.#g=new AbortController,this.#u=AbortSignal.any([o,this.#g.signal]),t.addEventListener("touchstart",this.#p.bind(this),{passive:!1,signal:this.#u})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Wt.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/Wt.pixelRatio}#p(t){if(this.#i?.())return;this.#y(t);let e=this.#d;for(let{identifier:s}of t.changedTouches)e.add(s);if(e.size===1){this.#v();return}if(!this.#m){this.#m=new AbortController;let s=AbortSignal.any([this.#u,this.#m.signal]),i=this.#t,n={signal:s,capture:!1,passive:!1};i.addEventListener("touchmove",this.#x.bind(this),n);let r=this.#w.bind(this);i.addEventListener("touchend",r,n),i.addEventListener("touchcancel",r,n),n.capture=!0,i.addEventListener("pointerdown",At,n),i.addEventListener("pointermove",At,n),i.addEventListener("pointercancel",Wi,n),i.addEventListener("pointerup",Wi,n),this.#n?.()}this.#l=zs(t),this.#A(t)}#v(){if(this.#h)return;let t=this.#h=new AbortController,e=AbortSignal.any([this.#u,t.signal]),s=this.#t,i={capture:!0,signal:e,passive:!1},n=(r)=>{if(r.pointerType==="touch")this.#h?.abort(),this.#h=null};s.addEventListener("pointerdown",(r)=>{if(r.pointerType==="touch")At(r),n(r)},i),s.addEventListener("pointerup",n,i),s.addEventListener("pointercancel",n,i)}#y(t){let e=this.#d;if(e.size===0)return;let s=this.#d=new Set;for(let{identifier:i}of t.touches)if(e.has(i))s.add(i)}#b(t){let e=this.#d,s=[];for(let i of t.touches)if(e.has(i.identifier))s.push(i);return s}#A(t){let e=this.#b(t);if(e.length!==2||this.#s?.()){this.#f=null;return}let[s,i]=e;this.#f={touch0X:s.screenX,touch0Y:s.screenY,touch1X:i.screenX,touch1Y:i.screenY,panX:(s.clientX+i.clientX)/2,panY:(s.clientY+i.clientY)/2,screenPanX:(s.screenX+i.screenX)/2,screenPanY:(s.screenY+i.screenY)/2}}#x(t){if(!this.#f)return;let e=this.#b(t);if(e.length!==2)return;let s=this.#l;if(this.#l=zs(t),!this.#l)return;if(!s){this.#A(t);return}let[i,n]=e,{screenX:r,screenY:a}=i,{screenX:o,screenY:l}=n,h=this.#f,{touch0X:c,touch0Y:d,touch1X:u,touch1Y:f,panX:p,panY:g}=h,m=u-c,v=f-d,y=o-r,S=l-a,A=(i.clientX+n.clientX)/2,b=(i.clientY+n.clientY)/2;h.panX=A,h.panY=b;let w=A-p,x=b-g,T=(r+o)/2,E=(a+l)/2,I=Math.hypot(T-h.screenPanX,E-h.screenPanY);h.screenPanX=T,h.screenPanY=E;let C=Math.hypot(y,S),O=Math.hypot(m,v),D=this.#e?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*I;if(C<Xi||O<Xi||Math.abs(O-C)<=D){if(w||x)this.#o?.(w,x);return}h.touch0X=r,h.touch0Y=a,h.touch1X=o,h.touch1Y=l;let k=Math.sign(C-O);if(!this.#e){if(this.#e=!0,this.#c=k,w||x)this.#o?.(w,x);return}if(this.#c){let R=this.#c;if(this.#c=0,k!==R&&Math.abs(C-O)<=2*I){if(this.#e=!1,w||x)this.#o?.(w,x);return}}this.#a?.([p,g],O,C,w,x)}#w(t){if(this.#y(t),this.#d.size>=2){this.#A(t);return}let e=!!this.#f;if(this.#E(),this.#d.size===1)this.#v();if(e)zs(t)}#E(){if(this.#f=null,this.#e=!1,this.#c=0,this.#l=!1,this.#m)this.#m.abort(),this.#m=null,this.#r?.()}destroy(){this.#E(),this.#d.clear(),this.#g?.abort(),this.#g=null,this.#h?.abort(),this.#h=null}}class H{#t=null;#e=null;#s=null;#i=null;#n=null;#a=!1;#r=null;#o="";#l=null;#h=null;#u=null;#d=null;#f=null;#g="";#m=!1;#c=null;#p=!1;#v=!1;#y=!1;#b=null;#A=0;#x=0;#w=null;#E=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#T=!1;#O=H._zIndex++;static _borderLineWidth=-1;static _colorManager=new di;static _zIndex=1;static _telemetryTimeout=1000;static get _resizerKeyboardManager(){let t=H.prototype._resizeWithKeyboard,{TRANSLATE_SMALL:e,TRANSLATE_BIG:s}=ae;return j(this,"_resizerKeyboardManager",new Ft([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape"],H.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;let{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,r];let[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return j(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new Pn({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(H._l10n??=t,H._l10nAlert??=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"}),H._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"}),H._borderLineWidth!==-1)return;let s=getComputedStyle(document.documentElement);H._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){st("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#T}set _isDraggable(t){this.#T=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#O}setParent(t){if(t!==null)this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions;else this.#N(),this.#d?.remove(),this.#d=null;this.parent=t}focusin(t){if(!this._focusEventsAllowed)return;if(!this.#m)this.parent.setSelected(this);else this.#m=!1}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;if(t.relatedTarget?.closest(`#${this.id}`))return;if(t.preventDefault(),!this.parent?.isMultipleSelection)this.commitOrRemove()}commitOrRemove(){if(this.isEmpty())this.remove();else this.commit()}commit(){if(!this.isInEditMode())return;this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){let[n,r]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}let[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}#P([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#P(this.parentDimensions,t,e)}translateInPage(t,e){this.#c||=[this.x,this.y,this.width,this.height],this.#P(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#c||=[this.x,this.y,this.width,this.height];let{div:s,parentDimensions:[i,n]}=this;if(this.x+=t/i,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:c,y:d}=this.div.getBoundingClientRect();if(this.parent.findNewParent(this,c,d))this.x-=Math.floor(this.x),this.y-=Math.floor(this.y)}let{x:r,y:a}=this,[o,l]=this.getBaseTranslation();r+=o,a+=l;let{style:h}=s;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a)}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#c&&(this.#c[0]!==this.x||this.#c[1]!==this.y)}get _hasBeenResized(){return!!this.#c&&(this.#c[2]!==this.width||this.#c[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:s}=H,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[s,i]}=this,{x:n,y:r,width:a,height:o}=this;if(a*=s,o*=i,n*=s,r*=i,this._mustFixPosition)switch(t){case 0:n=ut(n,0,s-a),r=ut(r,0,i-o);break;case 90:n=ut(n,0,s-o),r=ut(r,a,i);break;case 180:n=ut(n,a,s),r=ut(r,o,i);break;case 270:n=ut(n,o,s),r=ut(r,0,i-a);break}this.x=n/=s,this.y=r/=i;let[l,h]=this.getBaseTranslation();n+=l,r+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#I(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return H.#I(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return H.#I(t,e,360-this.parentRotation)}#D(t){switch(t){case 90:{let[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,s]=this.pageDimensions;return[0,e/s,-s/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:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){let{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#R(){if(this.#l)return;this.#l=document.createElement("div"),this.#l.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let s of t){let i=document.createElement("div");this.#l.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#k.bind(this,s),{signal:e}),i.addEventListener("contextmenu",zt,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#l)}#k(t,e){e.preventDefault();let{isMac:s}=ot.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);let i=this._isDraggable;this._isDraggable=!1,this.#h=[e.screenX,e.screenY];let n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#F.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",At,{passive:!1,signal:r}),window.addEventListener("contextmenu",zt,{signal:r}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#L()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#U(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#L(){if(!this.#u)return;let{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#u;this.#u=null;let n=this.x,r=this.y,a=this.width,o=this.height;if(n===t&&r===e&&a===s&&o===i)return;this.addCommands({cmd:this.#U.bind(this,n,r,a,o),undo:this.#U.bind(this,t,e,s,i),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#F(t,e){let[s,i]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=H.MIN_SIZE/s,h=H.MIN_SIZE/i,c=this.#D(this.rotation),d=(R,M)=>[c[0]*R+c[2]*M,c[1]*R+c[3]*M],u=this.#D(360-this.rotation),f=(R,M)=>[u[0]*R+u[2]*M,u[1]*R+u[3]*M],p,g,m=!1,v=!1;switch(t){case"topLeft":m=!0,p=(R,M)=>[0,0],g=(R,M)=>[R,M];break;case"topMiddle":p=(R,M)=>[R/2,0],g=(R,M)=>[R/2,M];break;case"topRight":m=!0,p=(R,M)=>[R,0],g=(R,M)=>[0,M];break;case"middleRight":v=!0,p=(R,M)=>[R,M/2],g=(R,M)=>[0,M/2];break;case"bottomRight":m=!0,p=(R,M)=>[R,M],g=(R,M)=>[0,0];break;case"bottomMiddle":p=(R,M)=>[R/2,M],g=(R,M)=>[R/2,0];break;case"bottomLeft":m=!0,p=(R,M)=>[0,M],g=(R,M)=>[R,0];break;case"middleLeft":v=!0,p=(R,M)=>[0,M/2],g=(R,M)=>[R,M/2];break}let y=p(a,o),S=g(a,o),A=d(...S),b=H._round(n+A[0]),w=H._round(r+A[1]),x=1,T=1,E,I;if(!e.fromKeyboard){let{screenX:R,screenY:M}=e,[_,U]=this.#h;[E,I]=this.screenToPageTranslation(R-_,M-U),this.#h[0]=R,this.#h[1]=M}else({deltaX:E,deltaY:I}=e);if([E,I]=f(E/s,I/i),m){let R=Math.hypot(a,o);x=T=Math.max(Math.min(Math.hypot(S[0]-y[0]-E,S[1]-y[1]-I)/R,1/a,1/o),l/a,h/o)}else if(v)x=ut(Math.abs(S[0]-y[0]-E),l,1)/a;else T=ut(Math.abs(S[1]-y[1]-I),h,1)/o;let C=H._round(a*x),O=H._round(o*T);A=d(...g(C,O));let D=b-A[0],k=w-A[1];this.#c||=[this.x,this.y,this.width,this.height],this.width=C,this.height=O,this.x=D,this.y=k,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#s?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#v)return this._editToolbar;this._editToolbar=new _e(this),this.div.append(this._editToolbar.render());let{toolbarButtons:t}=this;if(t)for(let[e,s]of t)await this._editToolbar.addButton(e,s);if(!this.hasComment)this._editToolbar.addButton("comment",this.addCommentButton());return this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#s?.destroy()}addContainer(t){let e=this._editToolbar?.div;if(e)e.before(t);else this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){if(!this.#s){if(Zt.initialize(H._l10n),this.#s=new Zt(this),this.#t)this.#s.data=this.#t,this.#t=null}return this.#s}get altTextData(){return this.#s?.data}set altTextData(t){if(!this.#s)return;this.#s.data=t}get guessedAltText(){return this.#s?.guessedText}async setGuessedAltText(t){await this.#s?.setGuessedText(t)}serializeAltText(t){return this.#s?.serialize(t)}hasAltText(){return!!this.#s&&!this.#s.isEmpty()}hasAltTextData(){return this.#s?.hasData()??!1}focusCommentButton(){this.#i?.focusButton()}addCommentButton(){return this.canAddComment?this.#i||=new Fe(this):null}addStandaloneCommentButton(){if(!this._uiManager.hasCommentManager())return;if(this.#n){if(this._uiManager.isEditingMode())this.#n.classList.remove("hidden");return}if(!this.hasComment)return;this.#n=this.#i.renderForStandalone(),this.div.append(this.#n)}removeStandaloneCommentButton(){this.#i.removeStandaloneCommentButton(),this.#n=null}hideStandaloneCommentButton(){this.#n?.classList.add("hidden")}get comment(){if(!this.#i)return null;let{data:{richText:t,text:e,date:s,deleted:i}}=this.#i;return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){if(this.#i||=new Fe(this),typeof t==="object"&&t!==null)this.#i.restoreData(t);else this.#i.data=t;if(this.hasComment)this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this);else this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this)}setCommentData({comment:t,popupRef:e,richText:s}){if(!e)return;if(this.#i||=new Fe(this),this.#i.setInitialText(t,s),!this.annotationElementId)return;let i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);if(i)this.updateFromAnnotationLayer(i)}get hasEditedComment(){return this.#i?.hasBeenEdited()}get hasDeletedComment(){return this.#i?.isDeleted()}get hasComment(){return!!this.#i&&!this.#i.isEmpty()&&!this.#i.isDeleted()}async editComment(t){this.#i||=new Fe(this),this.#i.edit(t)}toggleComment(t,e=void 0){if(this.hasComment)this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#i.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){let[,,,i]=t.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,a=r+n+1,o=i-100,l=a+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,l,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#i.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let t=this.div=document.createElement("div");if(t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#a?-1:0,t.setAttribute("role","application"),this.defaultL10nId)t.setAttribute("data-l10n-id",this.defaultL10nId);if(!this._isVisible)t.classList.add("hidden");this.setInForeground(),this.#_();let[e,s]=this.parentDimensions;if(this.parentRotation%180!==0)t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`;let[i,n]=this.getInitialTranslation();return this.translate(i,n),Tn(this,t,["keydown","pointerdown","dblclick"]),this.#$(),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#V(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#s?.toggle(!1),this.parent.togglePointerEvents(!1)}#B(t,e,s){let n=0.7*(s/e)+1-0.7;if(n===1)return;let r=this.#D(this.rotation),a=(b,w)=>[r[0]*b+r[2]*w,r[1]*b+r[3]*w],[o,l]=this.parentDimensions,h=this.x,c=this.y,d=this.width,u=this.height,f=H.MIN_SIZE/o,p=H.MIN_SIZE/l;n=Math.max(Math.min(n,1/d,1/u),f/d,p/u);let g=H._round(d*n),m=H._round(u*n);if(g===d&&m===u)return;this.#c||=[h,c,d,u];let v=a(d/2,u/2),y=H._round(h+v[0]),S=H._round(c+v[1]),A=a(g/2,m/2);this.x=y-A[0],this.y=S-A[1],this.width=g,this.height=m,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#j(){this.#s?.toggle(!0),this.parent.togglePointerEvents(!0),this.#L()}pointerdown(t){let{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#S(t);return}this.#C(t)}#C(t){let{isMac:e}=ot.platform;if(t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e)this.parent.toggleSelected(this);else this.parent.setSelected(this)}#S(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1,i=new AbortController,n=this._uiManager.combinedSignal(i),r={capture:!0,passive:!1,signal:n},a=(l)=>{if(i.abort(),this.#r=null,this.#m=!1,!this._uiManager.endDragSession())this.#C(l);if(s)this._onStopDragging()};if(e)this.#A=t.clientX,this.#x=t.clientY,this.#r=t.pointerId,this.#o=t.pointerType,window.addEventListener("pointermove",(l)=>{if(!s)s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging();let{clientX:h,clientY:c,pointerId:d}=l;if(d!==this.#r){At(l);return}let[u,f]=this.screenToPageTranslation(h-this.#A,c-this.#x);this.#A=h,this.#x=c,this._uiManager.dragSelectedEditors(u,f),this.div.scrollIntoView({block:"nearest"})},r),window.addEventListener("touchmove",At,r),window.addEventListener("pointerdown",(l)=>{if(l.pointerType===this.#o){if(this.#E||l.isPrimary)a(l)}At(l)},r);let o=(l)=>{if(!this.#r||this.#r===l.pointerId){a(l);return}At(l)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){if(this.#b)clearTimeout(this.#b);this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){let i=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/i,h=e/i,c=this.x*n,d=this.y*r,u=this.width*n,f=this.height*r;switch(s){case 0:return[c+l+a,r-d-h-f+o,c+l+u+a,r-d-h+o];case 90:return[c+h+a,r-d+l+o,c+h+f+a,r-d+l+u+o];case 180:return[c-l-u+a,r-d+h+o,c-l+a,r-d+h+f+o];case 270:return[c-h-f+a,r-d-l-u+o,c-h+a,r-d-l+o];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[s,i,n,r]=t,a=n-s,o=r-i;switch(this.rotation){case 0:return[s,e-r,a,o];case 90:return[s,e-i,o,a];case 180:return[n,e-i,a,o];case 270:return[n,e-r,o,a];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&H._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#i?.onUpdatedColor()}getData(){let{comment:{text:t,color:e,date:s,opacity:i,deleted:n,richText:r},uid:a,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:l,modificationDate:s||h,popupRef:!n,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){if(this.isInEditMode())return!1;return this.parent.setEditingState(!1),this.#v=!0,!0}disableEditMode(){if(!this.isInEditMode())return!1;return this.parent.setEditingState(!0),this.#v=!1,!0}isInEditMode(){return this.#v}shouldGetKeyboardEvents(){return this.#y}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&i>0&&t<n&&s>0}#_(){if(this.#f||!this.div)return;this.#f=new AbortController;let t=this._uiManager.combinedSignal(this.#f);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}#$(){if(this.#E||!this.div||!this.isResizable||!this._uiManager._supportsPinchToZoom)return;this.#E=new ui({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#V.bind(this),onPinching:this.#B.bind(this),onPinchEnd:this.#j.bind(this),signal:this._uiManager._signal})}rebuild(){this.#_(),this.#$()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,s){let i=new this.prototype.constructor({parent:e,id:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,i.#t=t.accessibilityData,i._isCopy=t.isCopy||!1;let[n,r]=i.pageDimensions,[a,o,l,h]=i.getRectInCurrentCoords(t.rect,r);return i.x=a/n,i.y=o/r,i.width=l/n,i.height=h/r,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#f?.abort(),this.#f=null,!this.isEmpty())this.commit();if(this.#E?.destroy(),this.#E=null,this.parent)this.parent.remove(this);else this._uiManager.removeEditor(this);if(this.hideCommentPopup(),this.#b)clearTimeout(this.#b),this.#b=null;if(this.#N(),this.removeEditToolbar(),this.#w){for(let t of this.#w.values())clearTimeout(t);this.#w=null}this.parent=null,this.#d?.remove(),this.#d=null}get isResizable(){return!1}makeResizable(){if(this.isResizable)this.#R(),this.#l.classList.remove("hidden")}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,e]}=this,[s,i,n,r]=this.getPDFRect();return[H._round(s+(n-s)*t),H._round(i+(r-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#i.commentPopupPositionInLayer}set commentPopupPosition(t){this.#i.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#i.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#i.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#i?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#l.children;if(!this.#e){this.#e=Array.from(e);let r=this.#z.bind(this),a=this.#J.bind(this),o=this._uiManager._signal;for(let l of this.#e){let h=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",r,{signal:o}),l.addEventListener("blur",a,{signal:o}),l.addEventListener("focus",this.#Y.bind(this,h),{signal:o}),l.setAttribute("data-l10n-id",H._l10nResizer[h])}}let s=this.#e[0],i=0;for(let r of e){if(r===s)break;i++}let n=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(n!==i){if(n<i)for(let a=0;a<i-n;a++)this.#l.append(this.#l.firstElementChild);else if(n>i)for(let a=0;a<n-i;a++)this.#l.firstElementChild.before(this.#l.lastElementChild);let r=0;for(let a of e){let l=this.#e[r++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",H._l10nResizer[l])}}this.#K(0),this.#y=!0,this.#l.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#z(t){H._resizerKeyboardManager.exec(this,t)}#J(t){if(this.#y&&t.relatedTarget?.parentNode!==this.#l)this.#N()}#Y(t){this.#g=this.#y?t:""}#K(t){if(!this.#e)return;for(let e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){if(!this.#y)return;this.#F(this.#g,{deltaX:t,deltaY:e,fromKeyboard:!0})}#N(){this.#y=!1,this.#K(-1),this.#L()}_stopResizingWithKeyboard(){this.#N(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{if(this.div?.classList.contains("selectedEditor"))this._editToolbar?.show()});return}this._editToolbar?.show(),this.#s?.toggleAltTextBadge(!1)}focus(){if(this.div&&!this.div.contains(document.activeElement))setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){if(!this.isSelected)return;if(this.isSelected=!1,this.#l?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement))this._uiManager.currentLayer.div.focus({preventScroll:!0});this._editToolbar?.hide(),this.#s?.toggleAltTextBadge(!0),this.hideCommentPopup()}hideCommentPopup(){if(this.hasComment)this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){if(!this.canChangeContent)return;this.enableEditMode(),this.div.focus()}dblclick(t){if(t.target.nodeName==="BUTTON")return;this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){if(this.#p=t,!this.parent)return;if(t)this.parent.setSelected(this),this.parent.setActiveEditor(this);else this.parent.setActiveEditor(null)}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#w||=new Map;let{action:s}=t,i=this.#w.get(s);if(i)clearTimeout(i);i=setTimeout(()=>{if(this._reportTelemetry(t),this.#w.delete(s),this.#w.size===0)this.#w=null},H._telemetryTimeout),this.#w.set(s,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){if(this.div)this.div.tabIndex=0;this.#a=!1}disable(){if(this.div)this.div.tabIndex=-1;this.#a=!0}updateFakeAnnotationElement(t){if(!this.#d&&!this.deleted){this.#d=t.addFakeAnnotation(this);return}if(this.deleted){this.#d.remove(),this.#d=null;return}if(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)this.#d.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){let s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){let{firstElementChild:e}=t.container;if(e?.nodeName==="DIV"&&e.classList.contains("annotationContent"))e.remove()}}class Pn extends H{constructor(t){super(t);this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}var Yi=3285377520,_t=4294901760,Kt=65535;class ms{constructor(t){this.h1=t?t&4294967295:Yi,this.h2=t?t&4294967295:Yi}update(t){let e,s;if(typeof t==="string"){e=new Uint8Array(t.length*2),s=0;for(let p=0,g=t.length;p<g;p++){let m=t.charCodeAt(p);if(m<=255)e[s++]=m;else e[s++]=m>>>8,e[s++]=m&255}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let i=s>>2,n=s-i*4,r=new Uint32Array(e.buffer,0,i),a=0,o=0,l=this.h1,h=this.h2,c=3432918353,d=461845907,u=c&Kt,f=d&Kt;for(let p=0;p<i;p++)if(p&1)a=r[p],a=a*c&_t|a*u&Kt,a=a<<15|a>>>17,a=a*d&_t|a*f&Kt,l^=a,l=l<<13|l>>>19,l=l*5+3864292196;else o=r[p],o=o*c&_t|o*u&Kt,o=o<<15|o>>>17,o=o*d&_t|o*f&Kt,h^=o,h=h<<13|h>>>19,h=h*5+3864292196;switch(a=0,n){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:if(a^=e[i*4],a=a*c&_t|a*u&Kt,a=a<<15|a>>>17,a=a*d&_t|a*f&Kt,i&1)l^=a;else h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&_t|t*36045&Kt,e=e*4283543511&_t|((e<<16|t>>>16)*2950163797&_t)>>>16,t^=e>>>1,t=t*444984403&_t|t*60499&Kt,e=e*3301882366&_t|((e<<16|t>>>16)*3120437893&_t)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}var $e=Object.freeze({map:null,hash:"",transfer:void 0});class Ms{#t=!1;#e=null;#s=null;#i=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){let s=this.#i.get(t);if(s===void 0)return e;return Object.assign(e,s)}getRawValue(t){return this.#i.get(t)}remove(t){let e=this.#i.get(t);if(e===void 0)return;if(e instanceof H)this.#s.delete(e.annotationElementId);if(this.#i.delete(t),this.#i.size===0)this.resetModified();if(this.#i.values().some((s)=>s instanceof H))return;this.onAnnotationEditor?.(null)}setValue(t,e){let s=this.#i.get(t),i=!1;if(s!==void 0){for(let[n,r]of Object.entries(e))if(s[n]!==r)i=!0,s[n]=r}else i=!0,this.#i.set(t,e);if(i)this.#n();if(e instanceof H)(this.#s||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type)}has(t){return this.#i.has(t)}get size(){return this.#i.size}#n(){if(!this.#t)this.#t=!0,this.onSetModified?.()}resetModified(){if(this.#t)this.#t=!1,this.onResetModified?.()}get print(){return new fi(this)}get serializable(){if(this.#i.size===0)return $e;let t=new Map,e=new ms,s=[],i=Object.create(null),n=!1;for(let[r,a]of this.#i){let o=a instanceof H?a.serialize(!1,i):a;if(a.page)a.pageIndex=a.page._pageIndex,delete a.page;if(o)t.set(r,o),e.update(`${r}:${JSON.stringify(o)}`),n||=!!o.bitmap}if(n){for(let r of t.values())if(r.bitmap)s.push(r.bitmap)}return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:$e}get editorStats(){let t=null,e=new Map,s=0,i=0;for(let n of this.#i.values()){if(!(n instanceof H)){if(n.popup)if(n.popup.deleted)i+=1;else s+=1;continue}if(n.isCommentDeleted)i+=1;else if(n.hasEditedComment)s+=1;let r=n.telemetryFinalData;if(!r)continue;let{type:a}=r;e.getOrInsertComputed(a,()=>Object.getPrototypeOf(n).constructor),t||=Object.create(null);let o=t[a]||=new Map;for(let[l,h]of Object.entries(r)){if(l==="type")continue;let c=o.getOrInsertComputed(l,ai);c.set(h,(c.get(h)??0)+1)}}if(i>0||s>0)t||=Object.create(null),t.comments={deleted:i,edited:s};if(!t)return null;for(let[n,r]of e)t[n]=r.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){this.#e=null}updateEditor(t,e){let s=this.#s?.get(t);if(s)return s.updateFromAnnotationLayer(e),!0;return!1}getEditor(t){return this.#s?.get(t)||null}get modifiedIds(){if(this.#e)return this.#e;let t=[];if(this.#s)for(let s of this.#s.values()){if(!s.serialize())continue;t.push(s.annotationElementId)}let e="";if(t.length){let s=new ms;s.update(t.join(",")),e=s.hexdigest()}return this.#e={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#i.entries()}}class fi extends Ms{#t=$e;constructor(t){super();let{serializable:e}=t;if(e===$e)return;let{map:s,hash:i,transfer:n}=e,r=structuredClone(s,n?{transfer:n}:null);this.#t={map:r,hash:i,transfer:[]}}get print(){st("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return j(this,"modifiedIds",{ids:new Set,hash:""})}}var Io=K(7588),Ae="__forcedDependency",{floor:Ki,ceil:Ji}=Math;function Qi(t,e,s,i,n,r){t[e*4+0]=Math.min(t[e*4+0],s),t[e*4+1]=Math.min(t[e*4+1],i),t[e*4+2]=Math.max(t[e*4+2],n),t[e*4+3]=Math.max(t[e*4+3],r)}function va(t,e,s,i,n){let r;if(t){if(t<0)r=n[0],n[0]=n[2],n[2]=r;if(n[0]*=t,n[2]*=t,e<0)r=n[1],n[1]=n[3],n[3]=r;n[1]*=e,n[3]*=e}else n.fill(0);n[0]+=s,n[1]+=i,n[2]+=s,n[3]+=i}var ei=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class Mn{#t;#e;constructor(t,e){this.#t=t,this.#e=e}get length(){return this.#t.length}isEmpty(t){return this.#t[t]===ei}minX(t){return this.#e[t*4+0]/256}minY(t){return this.#e[t*4+1]/256}maxX(t){return(this.#e[t*4+2]+1)/256}maxY(t){return(this.#e[t*4+3]+1)/256}}var Zi=(t,e)=>t?.getOrInsertComputed(e,()=>({dependencies:new Set,isRenderingOperation:!1}));class On{#t=[[1,0,0,1,0,0]];#e=[-1/0,-1/0,1/0,1/0];#s=new Float64Array(ee);_pendingBBoxIdx=-1;#i;#n;#a;#r;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#i=t.width,this.#n=t.height,this.#o(e)}growOperationsCount(t){if(t>=this.#r.length)this.#o(t,this.#r)}#o(t,e){let s=new ArrayBuffer(t*4);if(this.#a=new Uint8ClampedArray(s),this.#r=new Uint32Array(s),e&&e.length>0)this.#r.set(e),this.#r.fill(ei,e.length);else this.#r.fill(ei)}get clipBox(){return this.#e}save(t){return this.#e={__proto__:this.#e},this._savesStack.push(t),this}restore(t,e){let s=Object.getPrototypeOf(this.#e);if(s===null)return this;this.#e=s;let i=this._savesStack.pop();if(i!==void 0)e?.(i,t),this.#r[t]=this.#r[i];return this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){let s=this._savesStack.pop();if(s!==void 0)e?.(s,t),this.#r[t]=this.#r[s];return this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){let s=this._markedContentStack.pop();if(s!==void 0)e?.(s,t),this.#r[t]=this.#r[s];return this}pushBaseTransform(t){return this.#t.push(L.multiplyByDOMMatrix(this.#t.at(-1),t.getTransform())),this}popBaseTransform(){if(this.#t.length>1)this.#t.pop();return this}resetBBox(t){if(this._pendingBBoxIdx!==t)this._pendingBBoxIdx=t,this.#s.set(ee,0);return this}recordClipBox(t,e,s,i,n,r){let a=L.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform()),o=ee.slice();L.axialAlignedBoundingBox([s,n,i,r],a,o);let l=L.intersect(this.#e,o);if(l)this.#e[0]=l[0],this.#e[1]=l[1],this.#e[2]=l[2],this.#e[3]=l[3];else this.#e[0]=this.#e[1]=1/0,this.#e[2]=this.#e[3]=-1/0;return this}recordBBox(t,e,s,i,n,r){let a=this.#e;if(a[0]===1/0)return this;let o=L.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform());if(a[0]===-1/0)return L.axialAlignedBoundingBox([s,n,i,r],o,this.#s),this;let l=ee.slice();return L.axialAlignedBoundingBox([s,n,i,r],o,l),this.#s[0]=ut(l[0],a[0],this.#s[0]),this.#s[1]=ut(l[1],a[1],this.#s[1]),this.#s[2]=ut(l[2],this.#s[2],a[2]),this.#s[3]=ut(l[3],this.#s[3],a[3]),this}recordFullPageBBox(t){return this.#s[0]=Math.max(0,this.#e[0]),this.#s[1]=Math.max(0,this.#e[1]),this.#s[2]=Math.min(this.#i,this.#e[2]),this.#s[3]=Math.min(this.#n,this.#e[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;let i=Ki(this.#s[0]*256/this.#i),n=Ki(this.#s[1]*256/this.#n),r=Ji(this.#s[2]*256/this.#i),a=Ji(this.#s[3]*256/this.#n);if(Qi(this.#a,t,i,n,r,a),s){for(let o of s)for(let l of o)if(l!==t)Qi(this.#a,l,i,n,r,a)}if(!e)this._pendingBBoxIdx=-1;return this}bboxToClipBoxDropOperation(t){if(this._pendingBBoxIdx===t)this._pendingBBoxIdx=-1,this.#e[0]=Math.max(this.#e[0],this.#s[0]),this.#e[1]=Math.max(this.#e[1],this.#s[1]),this.#e[2]=Math.min(this.#e[2],this.#s[2]),this.#e[3]=Math.min(this.#e[3],this.#s[3]);return this}take(){return new Mn(this.#r,this.#a)}takeDebugMetadata(){throw Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,i=1,n=0,r=0,a){return this}getSimpleIndex(t){return}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}class Rn{#t={__proto__:null};#e={__proto__:null,transform:[],moveText:[],sameLineText:[],[Ae]:[]};#s=new Map;#i=new Set;#n=new Map;#a;#r;#o;constructor(t,e=!1){if(this.#o=t,e)this.#a=new Map,this.#r=(s,i)=>{Zi(this.#a,i).dependencies.add(s)}}get clipBox(){return this.#o.clipBox}growOperationsCount(t){this.#o.growOperationsCount(t)}save(t){return this.#t={__proto__:this.#t},this.#e={__proto__:this.#e,transform:{__proto__:this.#e.transform},moveText:{__proto__:this.#e.moveText},sameLineText:{__proto__:this.#e.sameLineText},[Ae]:{__proto__:this.#e[Ae]}},this.#o.save(t),this}restore(t){this.#o.restore(t,this.#r);let e=Object.getPrototypeOf(this.#t);if(e===null)return this;return this.#t=e,this.#e=Object.getPrototypeOf(this.#e),this}recordOpenMarker(t){return this.#o.recordOpenMarker(t,this.#r),this}getOpenMarker(){return this.#o.getOpenMarker()}recordCloseMarker(t){return this.#o.recordCloseMarker(t,this.#r),this}beginMarkedContent(t){return this.#o.beginMarkedContent(t),this}endMarkedContent(t){return this.#o.endMarkedContent(t,this.#r),this}pushBaseTransform(t){return this.#o.pushBaseTransform(t),this}popBaseTransform(){return this.#o.popBaseTransform(),this}recordSimpleData(t,e){return this.#t[t]=e,this}recordIncrementalData(t,e){return this.#e[t].push(e),this}resetIncrementalData(t,e){return this.#e[t].length=0,this}recordNamedData(t,e){return this.#s.set(t,e),this}recordSimpleDataFromNamed(t,e,s){this.#t[t]=this.#s.get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Ae,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(let e of t)if(e in this.#t)this.recordFutureForcedDependency(e,this.#t[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let t of this.#i)this.recordFutureForcedDependency(Ae,t);return this}resetBBox(t){return this.#o.resetBBox(t),this}recordClipBox(t,e,s,i,n,r){return this.#o.recordClipBox(t,e,s,i,n,r),this}recordBBox(t,e,s,i,n,r){return this.#o.recordBBox(t,e,s,i,n,r),this}recordCharacterBBox(t,e,s,i=1,n=0,r=0,a){let o=s.bbox,l,h;if(o){if(l=o[2]!==o[0]&&o[3]!==o[1]&&this.#n.get(s),l!==!1){if(h=[0,0,0,0],L.axialAlignedBoundingBox(o,s.fontMatrix,h),i!==1||n!==0||r!==0)va(i,-i,n,r,h);if(l)return this.recordBBox(t,e,h[0],h[2],h[1],h[3])}}if(!a)return this.recordFullPageBBox(t);let c=a();if(o&&h&&l===void 0){if(l=h[0]<=n-c.actualBoundingBoxLeft&&h[2]>=n+c.actualBoundingBoxRight&&h[1]<=r-c.actualBoundingBoxAscent&&h[3]>=r+c.actualBoundingBoxDescent,this.#n.set(s,l),l)return this.recordBBox(t,e,h[0],h[2],h[1],h[3])}return this.recordBBox(t,e,n-c.actualBoundingBoxLeft,n+c.actualBoundingBoxRight,r-c.actualBoundingBoxAscent,r+c.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#o.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#t[t]}recordDependencies(t,e){let s=this.#i,i=this.#t,n=this.#e;for(let r of e)if(r in this.#t)s.add(i[r]);else if(r in n)n[r].forEach(s.add,s);return this}recordNamedDependency(t,e){if(this.#s.has(e))this.#i.add(this.#s.get(e));return this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Ae]),this.#a){let i=Zi(this.#a,t),{dependencies:n}=i;this.#i.forEach(n.add,n),this.#o._savesStack.forEach(n.add,n),this.#o._markedContentStack.forEach(n.add,n),n.delete(t),i.isRenderingOperation=!0}let s=!e&&t===this.#o._pendingBBoxIdx;if(this.#o.recordOperation(t,e,[this.#i,this.#o._savesStack,this.#o._markedContentStack]),s)this.#i.clear();return this}recordShowTextOperation(t,e=!1){let s=Array.from(this.#i);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(let i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){let s=!e&&t===this.#o._pendingBBoxIdx;if(this.#o.bboxToClipBoxDropOperation(t),s)this.#i.clear();return this}take(){return this.#n.clear(),this.#o.take()}takeDebugMetadata(){return this.#a}}class Ge{#t;#e;#s;#i=0;#n=0;constructor(t,e,s){if(t instanceof Ge&&t.#s===!!s)return t;this.#t=t,this.#e=e,this.#s=!!s}get clipBox(){return this.#t.clipBox}growOperationsCount(){throw Error("Unreachable")}save(t){return this.#n++,this.#t.save(this.#e),this}restore(t){if(this.#n>0)this.#t.restore(this.#e),this.#n--;return this}recordOpenMarker(t){return this.#i++,this}getOpenMarker(){return this.#i>0?this.#e:this.#t.getOpenMarker()}recordCloseMarker(t){return this.#i--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#t.pushBaseTransform(t),this}popBaseTransform(){return this.#t.popBaseTransform(),this}recordSimpleData(t,e){return this.#t.recordSimpleData(t,this.#e),this}recordIncrementalData(t,e){return this.#t.recordIncrementalData(t,this.#e),this}resetIncrementalData(t,e){return this.#t.resetIncrementalData(t,this.#e),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this.#t.recordSimpleDataFromNamed(t,e,this.#e),this}recordFutureForcedDependency(t,e){return this.#t.recordFutureForcedDependency(t,this.#e),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#t.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#t.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){if(!this.#s)this.#t.resetBBox(this.#e);return this}recordClipBox(t,e,s,i,n,r){if(!this.#s)this.#t.recordClipBox(this.#e,e,s,i,n,r);return this}recordBBox(t,e,s,i,n,r){if(!this.#s)this.#t.recordBBox(this.#e,e,s,i,n,r);return this}recordCharacterBBox(t,e,s,i,n,r,a){if(!this.#s)this.#t.recordCharacterBBox(this.#e,e,s,i,n,r,a);return this}recordFullPageBBox(t){if(!this.#s)this.#t.recordFullPageBBox(this.#e);return this}getSimpleIndex(t){return this.#t.getSimpleIndex(t)}recordDependencies(t,e){return this.#t.recordDependencies(this.#e,e),this}recordNamedDependency(t,e){return this.#t.recordNamedDependency(this.#e,e),this}recordOperation(t){return this.#t.recordOperation(this.#e,!0),this}recordShowTextOperation(t){return this.#t.recordShowTextOperation(this.#e,!0),this}bboxToClipBoxDropOperation(t){if(!this.#s)this.#t.bboxToClipBoxDropOperation(this.#e,!0);return this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}var Ht={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};class vs{#t;#e;#s=4;#i=0;#n=new vs.#a(this.#s*6);static#a=ot.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#t=t.width,this.#e=t.height}record(t,e,s,i){if(this.#i===this.#s){this.#s*=2;let a=new vs.#a(this.#s*6);a.set(this.#n),this.#n=a}let n=dt(t),r;if(i[0]!==1/0){let a=ee.slice();L.axialAlignedBoundingBox([0,-s,e,0],n,a);let o=L.intersect(i,a);if(!o)return;let[l,h,c,d]=o;if(l!==a[0]||h!==a[1]||c!==a[2]||d!==a[3]){let u=Math.atan2(n[1],n[0]),f=Math.abs(Math.sin(u)),p=Math.abs(Math.cos(u));if(f<0.000001||p<0.000001||Math.abs(f-p)<0.000001)r=[l,h,l,d,c,h];else{let g=c-l,m=d-h,v=f*f,y=p*p,S=p*f,A=y-v,b=(m*y-g*S)/A,w=(m*S-g*v)/A;r=[l+w,h,l,h+b,c,d-b]}}}if(!r)r=[0,-s,0,0,e,-s],L.applyTransform(r,n,0),L.applyTransform(r,n,2),L.applyTransform(r,n,4);r[0]/=this.#t,r[1]/=this.#e,r[2]/=this.#t,r[3]/=this.#e,r[4]/=this.#t,r[5]/=this.#e,this.#n.set(r,this.#i*6),this.#i++}take(){return this.#n.subarray(0,this.#i*6)}}var qi=/\p{Cc}/u;function ya(t){let e=t[0];if(t.length<2||e!=='"'&&e!=="'"||t.at(-1)!==e)return!1;let s=t.length-1;for(let i=1;i<s;i++){let n=t[i];if(n===e||qi.test(n))return!1;if(n==="\\"){if(++i>=s||qi.test(t[i]))return!1}}return!0}function tn(t){if(ya(t))return t;return`"${t.replaceAll(/["\\\p{Cc}]/gu,(s)=>s==='"'||s==="\\"?`\\${s}`:`\\${s.codePointAt(0).toString(16)} `)}"`}class Dn{#t=new Set;#e=null;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){let e=this.#s();e.insertRule(t,e.cssRules.length)}#s(){if(this.#e)return this.#e;let t=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&t){let{adoptedStyleSheets:e}=this._document;if(e){let s=new t;return e.push(s),this.#e=s}}if(!this.styleElement)this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement);return this.#e=this.styleElement.sheet}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);if(this.nativeFontFaces.clear(),this.#t.clear(),this.#e){let{adoptedStyleSheets:t}=this._document;if(t?.includes(this.#e))this._document.adoptedStyleSheets=t.filter((e)=>e!==this.#e);this.#e=null}if(this.styleElement)this.styleElement.remove(),this.styleElement=null}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!t||this.#t.has(t.loadedName))return;if(mt(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:i,src:n,style:r}=t,a=new FontFace(i,n,r);this.addNativeFontFace(a);try{await a.load(),this.#t.add(i),s?.(t)}catch{z(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}st("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){let s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw z(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((s)=>{let i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){let t=!!this._document?.fonts;return j(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return j(this,"isSyncFontLoadingSupported",Nt||ot.platform.isFirefox)}_queueLoadingCallback(t){function e(){mt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;while(s.length>0&&s[0].done){let n=s.shift();setTimeout(n.callback,0)}}let{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){let t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return j(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(A,b){return A.charCodeAt(b)<<24|A.charCodeAt(b+1)<<16|A.charCodeAt(b+2)<<8|A.charCodeAt(b+3)&255}function i(A){return String.fromCharCode(A>>24&255,A>>16&255,A>>8&255,A&255)}function n(A,b,w,x){let T=A.substring(0,b),E=A.substring(b+w);return T+x+E}let r,a,o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0;function c(A,b){if(++h>30){z("Load test font never loaded."),b();return}if(l.font="30px "+A,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){b();return}setTimeout(c.bind(null,A,b))}let d=`lt${Date.now()}${this.loadTestFontId++}`,u=this._loadTestFont;u=n(u,976,d.length,d);let p=16,g=1482184792,m=s(u,p);for(r=0,a=d.length-3;r<a;r+=4)m=m-g+s(d,r)|0;if(r<d.length)m=m-g+s(d+"XXX",r)|0;u=n(u,p,4,i(m));let v=`url(data:font/opentype;base64,${btoa(u)});`,y=`@font-face {font-family:"${d}";src:${v}}`;this.insertRule(y);let S=this._document.createElement("div");S.style.visibility="hidden",S.style.width=S.style.height="10px",S.style.position="absolute",S.style.top=S.style.left="0px";for(let A of[t.loadedName,d]){let b=this._document.createElement("span");b.textContent="Hi",b.style.fontFamily=A,S.append(b)}this._document.body.append(S),c(d,()=>{S.remove(),e.complete()})}}class kn{compiledGlyphs=Object.create(null);#t;constructor(t,e=null,s,i){if(this.#t=t,this._inspectFont=e,s)this.charProcOperatorList=s;if(i)Object.assign(this,i)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{let e={weight:this.cssFontInfo.fontWeight};if(this.cssFontInfo.italicAngle)e.style=`oblique ${this.cssFontInfo.italicAngle}deg`;t=new FontFace(tn(this.cssFontInfo.fontFamily),this.data,e)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let t=`url(data:${this.mimetype};base64,${this.data.toBase64()});`,e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;if(this.cssFontInfo.italicAngle)s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`;e=`@font-face {font-family:${tn(this.cssFontInfo.fontFamily)};${s}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let s=this.loadedName+"_path_"+e,i;try{i=t.get(s)}catch(r){z(`getPathGenerator - ignoring character: "${r}".`)}let n=xn(i?.path);if(!this.fontExtraProperties)t.delete(s);return this.compiledGlyphs[e]=n}get black(){return this.#t.black}get bold(){return this.#t.bold}get disableFontFace(){return this.#t.disableFontFace}set disableFontFace(t){j(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#t.fontExtraProperties}get isInvalidPDFjsFont(){return this.#t.isInvalidPDFjsFont}get isType3Font(){return this.#t.isType3Font}get italic(){return this.#t.italic}get missingFile(){return this.#t.missingFile}get remeasure(){return this.#t.remeasure}get vertical(){return this.#t.vertical}get ascent(){return this.#t.ascent}get defaultWidth(){return this.#t.defaultWidth}get descent(){return this.#t.descent}get bbox(){return this.#t.bbox}get fontMatrix(){return this.#t.fontMatrix}get fallbackName(){return this.#t.fallbackName}get loadedName(){return this.#t.loadedName}get mimetype(){return this.#t.mimetype}get name(){return this.#t.name}get data(){return this.#t.data}clearData(){this.#t.clearData()}get cssFontInfo(){return this.#t.cssFontInfo}get systemFontInfo(){return this.#t.systemFontInfo}get defaultVMetrics(){return this.#t.defaultVMetrics}}class Ln{static strings=["fontFamily","fontWeight","italicAngle"]}class Nn{static strings=["css","loadedName","baseFontName","src"]}class Ut{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(this.bools.length*2/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+this.numbers.length*8;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class ie{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class Ve{static get decoder(){return j(this,"decoder",new TextDecoder)}static get encoder(){return j(this,"encoder",new TextEncoder)}}class Fn{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#s(t){mt(t<Ln.strings.length,"Invalid string index");let{decoder:e}=Ve,s=0;for(let n=0;n<t;n++)s+=this.#e.getUint32(s)+4;let i=this.#e.getUint32(s);return e.decode(new Uint8Array(this.#t,s+4,i))}get fontFamily(){return this.#s(0)}get fontWeight(){return this.#s(1)}get italicAngle(){return this.#s(2)}}class Bn{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}get guessFallback(){return this.#e.getUint8(0)!==0}#s(t){mt(t<Nn.strings.length,"Invalid string index");let{decoder:e}=Ve,s=5;for(let n=0;n<t;n++)s+=this.#e.getUint32(s)+4;let i=this.#e.getUint32(s);return e.decode(new Uint8Array(this.#t,s+4,i))}get css(){return this.#s(0)}get loadedName(){return this.#s(1)}get baseFontName(){return this.#s(2)}get src(){return this.#s(3)}get style(){let{decoder:t}=Ve,e=1;e+=4+this.#e.getUint32(e);let s=this.#e.getUint32(e),i=t.decode(new Uint8Array(this.#t,e+4,s));e+=4+s;let n=this.#e.getUint32(e),r=t.decode(new Uint8Array(this.#t,e+4,n));return{style:i,weight:r}}}class _n{#t;#e;constructor({buffer:t,extra:e}){if(this.#t=t,this.#e=new DataView(t),e)Object.assign(this,e)}#s(t){mt(t<Ut.bools.length,"Invalid boolean index");let e=Math.floor(t/4),s=t*2%8,i=this.#e.getUint8(e)>>s&3;return i===0?void 0:i===2}get black(){return this.#s(0)}get bold(){return this.#s(1)}get disableFontFace(){return this.#s(2)}get fontExtraProperties(){return this.#s(3)}get isInvalidPDFjsFont(){return this.#s(4)}get isType3Font(){return this.#s(5)}get italic(){return this.#s(6)}get missingFile(){return this.#s(7)}get remeasure(){return this.#s(8)}get vertical(){return this.#s(9)}#i(t){return mt(t<Ut.numbers.length,"Invalid number index"),this.#e.getFloat64(Ut.OFFSET_NUMBERS+t*8)}get ascent(){return this.#i(0)}get defaultWidth(){return this.#i(1)}get descent(){return this.#i(2)}#n(t,e,s,i){let n=this.#e.getUint8(t);if(n===0)return;mt(n===e,"Invalid array length."),t+=1;let r=Array(n);for(let a=0;a<n;a++)r[a]=this.#e[s](t,!0),t+=i;return r}get bbox(){return this.#n(Ut.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#n(Ut.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#n(Ut.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#a(t){mt(t<Ut.strings.length,"Invalid string index");let{decoder:e}=Ve,s=Ut.OFFSET_STRINGS+4;for(let n=0;n<t;n++)s+=this.#e.getUint32(s)+4;let i=this.#e.getUint32(s);return e.decode(new Uint8Array(this.#t,s+4,i))}get fallbackName(){return this.#a(0)}get loadedName(){return this.#a(1)}get mimetype(){return this.#a(2)}get name(){return this.#a(3)}#r(){let t=Ut.OFFSET_STRINGS,e=this.#e.getUint32(t);t+=4+e;let s=this.#e.getUint32(t);t+=4+s;let i=this.#e.getUint32(t);t+=4+i;let n=this.#e.getUint32(t);return{offset:t,length:n}}get data(){let{offset:t,length:e}=this.#r();return e===0?void 0:new Uint8Array(this.#t,t+4,e)}clearData(){let{offset:t,length:e}=this.#r();if(e===0)return;this.#e.setUint32(t,0),this.#t=new Uint8Array(this.#t,0,t+4).slice().buffer,this.#e=new DataView(this.#t)}get cssFontInfo(){let t=Ut.OFFSET_STRINGS,e=this.#e.getUint32(t);t+=4+e;let s=this.#e.getUint32(t);t+=4+s;let i=this.#e.getUint32(t);if(i===0)return null;let n=new Uint8Array(i);return n.set(new Uint8Array(this.#t,t+4,i)),new Fn(n.buffer)}get systemFontInfo(){let t=Ut.OFFSET_STRINGS,e=this.#e.getUint32(t);t+=4+e;let s=this.#e.getUint32(t);if(s===0)return null;let i=new Uint8Array(s);return i.set(new Uint8Array(this.#t,t+4,s)),new Bn(i.buffer)}}class Hn{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){let t=this.view,e=this.data[ie.KIND],s=!!this.data[ie.HAS_BBOX],i=!!this.data[ie.HAS_BACKGROUND],n=t.getUint32(ie.N_COORD,!0),r=t.getUint32(ie.N_COLOR,!0),a=t.getUint32(ie.N_STOP,!0),o=20,l=new Float32Array(this.buffer,o,n*2);o+=n*8;let h=new Uint8Array(this.buffer,o,r*4);o+=r*4;let c=[];for(let f=0;f<a;++f){let p=t.getFloat32(o,!0);o+=4;let g=t.getUint32(o,!0);o+=4,c.push([p,`#${g.toString(16).padStart(6,"0")}`])}let d=null;if(s){d=[];for(let f=0;f<4;++f)d.push(t.getFloat32(o,!0)),o+=4}let u=null;if(i)u=new Uint8Array(this.buffer,o,3),o+=3;if(e===1)return["RadialAxial","axial",d,c,Array.from(l.slice(0,2)),Array.from(l.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",d,c,[l[0],l[1]],[l[3],l[4]],l[2],l[5]];if(e===3){let f=this.data[ie.SHADING_TYPE],p=null;if(l.length>0){p=ee.slice();for(let g=0,m=l.length;g<m;g+=2)L.pointBoundingBox(l[g],l[g+1],p)}return["Mesh",f,l,h,n,p,d,u]}throw Error(`Unsupported pattern kind: ${e}`)}}class Un{#t;constructor(t){this.#t=t}get path(){if(ot.isFloat16ArraySupported)return new Float16Array(this.#t);return new Float32Array(this.#t)}}function ba(t){if(t instanceof URL)return t;if(typeof t==="string"){if(Nt){if(/^[a-z][a-z0-9\-+.]+:/i.test(t))return new URL(t);let s=process.getBuiltinModule("url");return new URL(s.pathToFileURL(t))}let e=URL.parse(t,window.location);if(e)return e}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Aa(t){if(Nt&&typeof Buffer<"u"&&t instanceof Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if(typeof t==="string")return Cs(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||typeof t==="object"&&!isNaN(t?.length))return new Uint8Array(t);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function es(t){if(typeof t!=="string")return null;if(t.endsWith("/"))return t;throw Error(`Invalid factory url: "${t}" must include trailing slash.`)}var si=(t)=>typeof t==="object"&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,Sa=(t)=>typeof t==="object"&&typeof t?.name==="string",wa=oa.bind(null,si,Sa);class jn{#t=new Map;#e=Promise.resolve();postMessage(t,e){let s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(let[i]of this.#t)i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if(s?.signal instanceof AbortSignal){let{signal:n}=s;if(n.aborted){z("LoopbackPort - cannot use an `aborted` signal.");return}let r=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#t.set(e,i)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(let[,t]of this.#t)t?.();this.#t.clear()}}var Po=K(1689),ss={DATA:1,ERROR:2},yt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function en(){}function Dt(t){if(t instanceof se||t instanceof ps||t instanceof fs||t instanceof Ue||t instanceof cs)return t;if(!(t instanceof Error||typeof t==="object"&&t!==null))st('wrapReason: Expected "reason" to be a (possibly cloned) Error.');switch(t.name){case"AbortException":return new se(t.message);case"InvalidPDFException":return new ps(t.message);case"PasswordException":return new fs(t.message,t.code);case"ResponseException":return new Ue(t.message,t.status,t.missing);case"UnknownErrorException":return new cs(t.message,t.details)}return new cs(t.message,t.toString())}class Ee{#t=new AbortController;constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,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),s.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#i(t);return}if(t.callback){let s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===ss.DATA)i.resolve(t.data);else if(t.callback===ss.ERROR)i.reject(Dt(t.reason));else throw Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let s=this.sourceName,i=t.sourceName,n=this.comObj;Promise.try(e,t.data).then(function(r){n.postMessage({sourceName:s,targetName:i,callback:ss.DATA,callbackId:t.callbackId,data:r})},function(r){n.postMessage({sourceName:s,targetName:i,callback:ss.ERROR,callbackId:t.callbackId,reason:Dt(r)})});return}if(t.streamId){this.#s(t);return}e(t.data)}on(t,e){let s=this.actionHandler;if(s[t])throw Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){let i=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(r){n.reject(r)}return n.promise}sendWithStream(t,e,s,i){let n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:(l)=>{let h=Promise.withResolvers();return this.streamControllers[n]={controller:l,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:l.desiredSize},i),h.promise},pull:(l)=>{let h=Promise.withResolvers();return this.streamControllers[n].pullCall=h,o.postMessage({sourceName:r,targetName:a,stream:yt.PULL,streamId:n,desiredSize:l.desiredSize}),h.promise},cancel:(l)=>{mt(l instanceof Error,"cancel must have a valid reason");let h=Promise.withResolvers();return this.streamControllers[n].cancelCall=h,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:yt.CANCEL,streamId:n,reason:Dt(l)}),h.promise}},s)}#s(t){let e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(l,h=1,c){if(this.isCancelled)return;let d=this.desiredSize;if(this.desiredSize-=h,d>0&&this.desiredSize<=0)this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise;n.postMessage({sourceName:s,targetName:i,stream:yt.ENQUEUE,streamId:e,chunk:l},c)},close(){if(this.isCancelled)return;this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:yt.CLOSE,streamId:e}),delete r.streamSinks[e]},error(l){if(mt(l instanceof Error,"error must have a valid reason"),this.isCancelled)return;this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:yt.ERROR,streamId:e,reason:Dt(l)})},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then(function(){n.postMessage({sourceName:s,targetName:i,stream:yt.START_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:yt.START_COMPLETE,streamId:e,reason:Dt(l)})})}#i(t){let e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case yt.START_COMPLETE:if(t.success)r.startCall.resolve();else r.startCall.reject(Dt(t.reason));break;case yt.PULL_COMPLETE:if(t.success)r.pullCall.resolve();else r.pullCall.reject(Dt(t.reason));break;case yt.PULL:if(!a){n.postMessage({sourceName:s,targetName:i,stream:yt.PULL_COMPLETE,streamId:e,success:!0});break}if(a.desiredSize<=0&&t.desiredSize>0)a.sinkCapability.resolve();a.desiredSize=t.desiredSize,Promise.try(a.onPull||en).then(function(){n.postMessage({sourceName:s,targetName:i,stream:yt.PULL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:yt.PULL_COMPLETE,streamId:e,reason:Dt(l)})});break;case yt.ENQUEUE:if(mt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case yt.CLOSE:if(mt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#n(r,e);break;case yt.ERROR:mt(r,"error should have stream controller"),r.controller.error(Dt(t.reason)),this.#n(r,e);break;case yt.CANCEL_COMPLETE:if(t.success)r.cancelCall.resolve();else r.cancelCall.reject(Dt(t.reason));this.#n(r,e);break;case yt.CANCEL:if(!a)break;let o=Dt(t.reason);Promise.try(a.onCancel||en,o).then(function(){n.postMessage({sourceName:s,targetName:i,stream:yt.CANCEL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:yt.CANCEL_COMPLETE,streamId:e,reason:Dt(l)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw Error("Unexpected stream case")}}async#n(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}}class pi{#t=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=s}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:st(`Not implemented: ${t}`)}let s=this[t];if(!s)throw Error(`Ensure that the \`${t}\` API parameter is provided.`);let i=`${s}${e}`;return this._fetch(i,t).catch((n)=>{throw Error(`Unable to load ${this.#t[t]} data at: ${i}`)})}async _fetch(t,e){st("Abstract method `_fetch` called.")}}class ii extends pi{async _fetch(t,e){let s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await li(t,s);return i instanceof Uint8Array?i:Cs(i)}}class gi{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");let s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset({canvas:t},e,s){if(!t)throw Error("Canvas is not specified");if(e<=0||s<=0)throw Error("Invalid canvas size");t.width=e,t.height=s}destroy(t){let{canvas:e}=t;if(!e)throw Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){st("Abstract method `_createCanvas` called.")}}class $n extends gi{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e});this._document=t}_createCanvas(t,e){let s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class mi{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}class Gn extends mi{#t;#e;#s;#i;#n;#a;#r=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super();this.#i=t,this.#n=e}get#o(){return this.#e||=new Map}get#l(){return this.#a||=new Map}get#h(){if(!this.#s){let t=this.#n.createElement("div"),{style:e}=t;e.colorScheme="only light",e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;let s=this.#n.createElementNS(Mt,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#s=this.#n.createElementNS(Mt,"defs"),t.append(s),s.append(this.#s),this.#n.body.append(t)}return this.#s}#u(t){if(t.length===1){let o=t[0],l=Array(256);for(let c=0;c<256;c++)l[c]=o[c]/255;let h=l.join(",");return[h,h,h]}let[e,s,i]=t,n=Array(256),r=Array(256),a=Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,r[o]=s[o]/255,a[o]=i[o]/255;return[n.join(","),r.join(","),a.join(",")]}#d(t){if(this.#t===void 0){this.#t="";let e=this.#n.URL;if(e!==this.#n.baseURI)if(Ps(e))z('#createUrl: ignore "data:"-URL for performance reasons.');else this.#t=vn(e,"")}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#o.get(t);if(e)return e;let[s,i,n]=this.#u(t),r=t.length===1?s:`${s}${i}${n}`;if(e=this.#o.get(r),e)return this.#o.set(t,e),e;let a=`g_${this.#i}_transfer_map_${this.#r++}`,o=this.#d(a);this.#o.set(t,o),this.#o.set(r,o);let l=this.#m(a);return this.#p(s,i,n,l),o}addHCMFilter(t,e){let s=`${t}-${e}`,i="base",n=this.#l.get("base");if(n?.key===s)return n.url;if(n)n.filter?.remove(),n.key=s,n.url="none",n.filter=null;else n={key:s,url:"none",filter:null},this.#l.set("base",n);if(!t||!e)return n.url;let r=this.#y(t);t=L.makeHexColor(...r);let a=this.#y(e);if(e=L.makeHexColor(...a),this.#A(),t==="#000000"&&e==="#ffffff"||t===e)return n.url;let l=Array.from({length:256},(u,f)=>ti(f/255)).join(","),h=`g_${this.#i}_hcm_filter`,c=n.filter=this.#m(h);this.#p(l,l,l,c),this.#g(c);let d=(u,f)=>{let p=r[u]/255,g=a[u]/255,m=Array(f+1);for(let v=0;v<=f;v++)m[v]=p+v/f*(g-p);return m.join(",")};return this.#p(d(0,5),d(1,5),d(2,5),c),n.url=this.#d(h),n.url}addSelectionHCMFilter(t,e){return this.addHighlightHCMFilter("selection",t,e,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(t=null){let e=t?this.addSelectionHCMFilter(t.foreground,t.background):this.addSelectionFilter();if(e==="none"||!ot.platform.isFirefox)return null;return{"backdrop-filter":e,"background-color":"transparent"}}addAlphaFilter(t){let e=this.#o.get(t);if(e)return e;let[s]=this.#u([t]),i=`alpha_${s}`;if(e=this.#o.get(i),e)return this.#o.set(t,e),e;let n=`g_${this.#i}_alpha_map_${this.#r++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);let a=this.#m(n);return this.#v(s,a),r}addLuminosityFilter(t){let e=this.#o.get(t||"luminosity");if(e)return e;let s,i;if(t)[s]=this.#u([t]),i=`luminosity_${s}`;else i="luminosity";if(e=this.#o.get(i),e)return this.#o.set(t,e),e;let n=`g_${this.#i}_luminosity_map_${this.#r++}`,r=this.#d(n);this.#o.set(t,r),this.#o.set(i,r);let a=this.#m(n);if(this.#f(a),t)this.#v(s,a);return r}addKnockoutFilter(t=0){let e=t>0?Math.min(1/t,1e6):1e6,s=`knockout_${e}`,i=this.#o.get(s);if(i)return i;let n=`g_${this.#i}_knockout_filter_${this.#r++}`,r=this.#d(n);this.#o.set(s,r);let a=this.#m(n),o=this.#n.createElementNS(Mt,"feComponentTransfer");a.append(o);let l=this.#n.createElementNS(Mt,"feFuncA");return l.setAttribute("type","linear"),l.setAttribute("slope",`${e}`),l.setAttribute("intercept","0"),o.append(l),r}addHighlightHCMFilter(t,e,s,i,n){let r=`${e}-${s}-${i}-${n}`,a=this.#l.get(t);if(a?.key===r)return a.url;if(a)a.filter?.remove(),a.key=r,a.url="none",a.filter=null;else a={key:r,url:"none",filter:null},this.#l.set(t,a);if(!e||!s)return a.url;let[o,l]=[e,s].map(this.#y.bind(this)),h=Math.round(0.2126*o[0]+0.7152*o[1]+0.0722*o[2]),c=Math.round(0.2126*l[0]+0.7152*l[1]+0.0722*l[2]),[d,u]=[i,n].map(this.#x.bind(this));if(c<h)[h,c,d,u]=[c,h,u,d];this.#A();let f=(m,v,y)=>{let S=Array(256),A=(c-h)/y,b=m/255,w=(v-m)/(255*y),x=0;for(let T=0;T<=y;T++){let E=Math.round(h+T*A),I=b+T*w;for(let C=x;C<=E;C++)S[C]=I;x=E+1}for(let T=x;T<256;T++)S[T]=S[x-1];return S.join(",")},p=`g_${this.#i}_hcm_${t}_filter`,g=a.filter=this.#m(p);return this.#g(g),this.#p(f(d[0],u[0],5),f(d[1],u[1],5),f(d[2],u[2],5),g),a.url=this.#d(p),a.url}destroy(t=!1){if(t&&this.#a?.size)return;this.#s?.parentNode.parentNode.remove(),this.#s=null,this.#e?.clear(),this.#e=null,this.#a?.clear(),this.#a=null,this.#r=0}#f(t){let e=this.#n.createElementNS(Mt,"feColorMatrix");e.setAttribute("type","matrix"),e.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"),t.append(e)}#g(t){let e=this.#n.createElementNS(Mt,"feColorMatrix");e.setAttribute("type","matrix"),e.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"),t.append(e)}#m(t){let e=this.#n.createElementNS(Mt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#h.append(e),e}#c(t,e,s){let i=this.#n.createElementNS(Mt,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#p(t,e,s,i){let n=this.#n.createElementNS(Mt,"feComponentTransfer");i.append(n),this.#c(n,"feFuncR",t),this.#c(n,"feFuncG",e),this.#c(n,"feFuncB",s)}#v(t,e){let s=this.#n.createElementNS(Mt,"feComponentTransfer");e.append(s),this.#c(s,"feFuncA",t)}#y(t){return this.#h.style.color="CanvasText",this.#h.style.backgroundColor=t,Ke(getComputedStyle(this.#h).getPropertyValue("background-color"))}#b(t){return this.#h.style.color="CanvasText",this.#h.style.backgroundColor=t,Ye(getComputedStyle(this.#h).getPropertyValue("background-color"))}#A(){this.#h.style.color="",this.#h.style.backgroundColor=""}#x(t){let[e,s,i,n]=this.#b(t);if(n===1)return[e,s,i];let[r,a,o]=this.#y("Canvas");return[Ws(e,r,n),Ws(s,a,n),Ws(i,o,n)]}}function Ws(t,e,s){return Math.round(s*t+(1-s)*e)}if(Nt){let t;try{let e=process.getBuiltinModule("module").createRequire(import.meta.url);try{t=e("@napi-rs/canvas")}catch(s){z(`Cannot load "@napi-rs/canvas" package: "${s}".`)}}catch(e){z(`Cannot access the \`require\` function: "${e}".`)}if(!globalThis.DOMMatrix)if(t?.DOMMatrix)globalThis.DOMMatrix=t.DOMMatrix;else z("Cannot polyfill `DOMMatrix`, rendering may be broken.");if(!globalThis.Path2D)if(t?.Path2D)globalThis.Path2D=t.Path2D;else z("Cannot polyfill `Path2D`, rendering may be broken.");if(!globalThis.navigator?.language)globalThis.navigator={language:"en-US",platform:"",userAgent:""}}async function xa(t){let s=await process.getBuiltinModule("fs/promises").readFile(t);return new Uint8Array(s)}class Vn extends mi{}class zn extends gi{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class Wn extends pi{async _fetch(t,e){return xa(t)}}function Xn({src:t,srcPos:e=0,dest:s,width:i,height:n,nonBlackColor:r=4294967295,inverseDecode:a=!1}){let o=ot.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=i>>3,d=i&7,u=l^h,f=t.length;s=new Uint32Array(s.buffer);let p=0;for(let g=0;g<n;++g){for(let v=e+c;e<v;++e,p+=8){let y=t[e];s[p]=l^-(y>>7&1)&u,s[p+1]=l^-(y>>6&1)&u,s[p+2]=l^-(y>>5&1)&u,s[p+3]=l^-(y>>4&1)&u,s[p+4]=l^-(y>>3&1)&u,s[p+5]=l^-(y>>2&1)&u,s[p+6]=l^-(y>>1&1)&u,s[p+7]=l^-(y&1)&u}if(d===0)continue;let m=e<f?t[e++]:255;for(let v=0;v<d;++v,++p)s[p]=l^-(m>>7-v&1)&u}return{srcPos:e,destPos:p}}function Ea({src:t,srcPos:e=0,dest:s,destPos:i=0,width:n,height:r}){let a=0,o=n*r*3,l=o>>2,h=new Uint32Array(t.buffer,e,l),c=ot.isLittleEndian?4278190080:255;if(ot.isLittleEndian){for(;a<l-2;a+=3,i+=4){let d=h[a],u=h[a+1],f=h[a+2];s[i]=d|c,s[i+1]=d>>>24|u<<8|c,s[i+2]=u>>>16|f<<16|c,s[i+3]=f>>>8|c}for(let d=a*4,u=e+o;d<u;d+=3)s[i++]=t[d]|t[d+1]<<8|t[d+2]<<16|c}else{for(;a<l-2;a+=3,i+=4){let d=h[a],u=h[a+1],f=h[a+2];s[i]=d|c,s[i+1]=d<<24|u>>>8|c,s[i+2]=u<<16|f>>>16|c,s[i+3]=f<<8|c}for(let d=a*4,u=e+o;d<u;d+=3)s[i++]=t[d]<<24|t[d+1]<<16|t[d+2]<<8|c}return{srcPos:e+o,destPos:i}}var Ta=`
5
+ struct Uniforms {
6
+ offsetX : f32,
7
+ offsetY : f32,
8
+ scaleX : f32,
9
+ scaleY : f32,
10
+ paddedWidth : f32,
11
+ paddedHeight : f32,
12
+ borderSize : f32,
13
+ _pad : f32,
14
+ };
15
+
16
+ @group(0) @binding(0) var<uniform> u : Uniforms;
17
+
18
+ struct VertexInput {
19
+ @location(0) position : vec2<f32>,
20
+ @location(1) color : vec4<f32>,
21
+ };
22
+
23
+ struct VertexOutput {
24
+ @builtin(position) position : vec4<f32>,
25
+ @location(0) color : vec3<f32>,
26
+ };
27
+
28
+ @vertex
29
+ fn vs_main(in : VertexInput) -> VertexOutput {
30
+ var out : VertexOutput;
31
+ let cx = (in.position.x + u.offsetX) * u.scaleX;
32
+ let cy = (in.position.y + u.offsetY) * u.scaleY;
33
+ out.position = vec4<f32>(
34
+ ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
35
+ 1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
36
+ 0.0,
37
+ 1.0
38
+ );
39
+ out.color = in.color.rgb;
40
+ return out;
41
+ }
42
+
43
+ @fragment
44
+ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
45
+ return vec4<f32>(in.color, 1.0);
46
+ }
47
+ `;class Yn{#t=null;#e=null;#s=null;#i=null;async#n(){if(!globalThis.navigator?.gpu)return!1;try{let t=await navigator.gpu.requestAdapter();if(!t)return!1;return this.#i=navigator.gpu.getPreferredCanvasFormat(),this.#e=await t.requestDevice(),!0}catch{return!1}}init(){return this.#t||=this.#n()}get isReady(){return this.#e!==null}loadMeshShader(){if(!this.#e||this.#s)return;let t=this.#e.createShaderModule({code:Ta});this.#s=this.#e.createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:this.#i}]},primitive:{topology:"triangle-list"}})}draw(t,e,s,i,n,r,a,o){this.loadMeshShader();let l=this.#e,{offsetX:h,offsetY:c,scaleX:d,scaleY:u}=i,f=l.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});if(t.byteLength>0)l.queue.writeBuffer(f,0,t);let p=l.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});if(e.byteLength>0)l.queue.writeBuffer(p,0,e);let g=l.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l.queue.writeBuffer(g,0,new Float32Array([h,c,d,u,r,a,o,0]));let m=l.createBindGroup({layout:this.#s.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:g}}]}),v=new OffscreenCanvas(r,a),y=v.getContext("webgpu");y.configure({device:l,format:this.#i,alphaMode:n?"opaque":"premultiplied"});let S=n?{r:n[0]/255,g:n[1]/255,b:n[2]/255,a:1}:{r:0,g:0,b:0,a:0},A=l.createCommandEncoder(),b=A.beginRenderPass({colorAttachments:[{view:y.getCurrentTexture().createView(),clearValue:S,loadOp:"clear",storeOp:"store"}]});if(s>0)b.setPipeline(this.#s),b.setBindGroup(0,m),b.setVertexBuffer(0,f),b.setVertexBuffer(1,p),b.draw(s);return b.end(),l.queue.submit([A.finish()]),f.destroy(),p.destroy(),g.destroy(),v.transferToImageBitmap()}}var Os=new Yn;function Ca(){return Os.init()}function Ia(){return Os.isReady}function Pa(){Os.loadMeshShader()}function Ma(t,e,s,i,n,r,a,o){return Os.draw(t,e,s,i,n,r,a,o)}var Ct={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function ds(t,e){if(!e)return;let s=e[2]-e[0],i=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],s,i),t.clip(n)}class Rs{matrix=null;isModifyingCurrentTransform(){return!1}getPattern(){st("Abstract method `getPattern` called.")}}class Kn extends Rs{constructor(t){super();this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7]}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}areConic(){if(!this.isRadial())return!1;let t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let s,i=this._p0,n=this._p1;if(e)i=i.slice(),n=n.slice(),L.applyTransform(i,e),L.applyTransform(n,e);if(this._type==="axial")s=t.createLinearGradient(i[0],i[1],n[0],n[1]);else if(this._type==="radial"){let r=this._r0,a=this._r1;if(e){let o=new Float32Array(2);L.singularValueDecompose2dScale(e,o),r*=o[0],a*=o[0]}s=t.createRadialGradient(i[0],i[1],r,n[0],n[1],a)}for(let r of this._colorStops)s.addColorStop(r[0],r[1]);return s}_createReversedGradient(t,e=null){let s=this._p1,i=this._p0;if(e)s=s.slice(),i=i.slice(),L.applyTransform(s,e),L.applyTransform(i,e);let n=this._r1,r=this._r0;if(e){let l=new Float32Array(2);L.singularValueDecompose2dScale(e,l),n*=l[0],r*=l[0]}let a=t.createRadialGradient(s[0],s[1],n,i[0],i[1],r),o=this._colorStops.map(([l,h])=>[1-l,h]).reverse();for(let[l,h]of o)a.addColorStop(l,h);return a}getPattern(t,e,s,i){let n;if(i===Ct.STROKE||i===Ct.FILL){if(this.isOriginBased()){let d=L.transform(s,e.baseTransform);if(this.matrix)d=L.transform(d,this.matrix);let u=0.001,f=Math.hypot(d[0],d[1]),p=Math.hypot(d[2],d[3]),g=(d[0]*d[2]+d[1]*d[3])/(f*p);if(Math.abs(g)<u)if(this.isRadial()){if(Math.abs(f-p)<u)return this._createGradient(t,d)}else return this._createGradient(t,d)}let r=e.current.getClippedPathBoundingBox(i,dt(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.canvasFactory.create(a,o),h=l.context;if(h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),s=L.transform(s,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix)h.transform(...this.matrix);if(ds(h,this._bbox),this.areConic())h.fillStyle=this._createReversedGradient(h),h.fill();h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat"),e.canvasFactory.destroy(l);let c=new DOMMatrix(s);n.setTransform(c)}else{if(this.areConic())t.save(),ds(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-10000000000,-10000000000,20000000000,20000000000),t.restore();ds(t,this._bbox),n=this._createGradient(t)}return n}}function Oa(t,e,s,i,n,r,a,o){let{coords:l,colors:h}=e,c=t.data,d=t.width*4,u;if(l[s*2+1]>l[i*2+1])u=s,s=i,i=u,u=r,r=a,a=u;if(l[i*2+1]>l[n*2+1])u=i,i=n,n=u,u=a,a=o,o=u;if(l[s*2+1]>l[i*2+1])u=s,s=i,i=u,u=r,r=a,a=u;let f=(l[s*2]+e.offsetX)*e.scaleX,p=(l[s*2+1]+e.offsetY)*e.scaleY,g=(l[i*2]+e.offsetX)*e.scaleX,m=(l[i*2+1]+e.offsetY)*e.scaleY,v=(l[n*2]+e.offsetX)*e.scaleX,y=(l[n*2+1]+e.offsetY)*e.scaleY;if(p>=y)return;let S=h[r*4],A=h[r*4+1],b=h[r*4+2],w=h[a*4],x=h[a*4+1],T=h[a*4+2],E=h[o*4],I=h[o*4+1],C=h[o*4+2],O=Math.round(p),D=Math.round(y),k,R,M,_,U,G,it,rt;for(let J=O;J<=D;J++){if(J<m){let P=J<p?0:(p-J)/(p-m);k=f-(f-g)*P,R=S-(S-w)*P,M=A-(A-x)*P,_=b-(b-T)*P}else{let P;if(J>y)P=1;else if(m===y)P=0;else P=(m-J)/(m-y);k=g-(g-v)*P,R=w-(w-E)*P,M=x-(x-I)*P,_=T-(T-C)*P}let et;if(J<p)et=0;else if(J>y)et=1;else et=(p-J)/(p-y);U=f-(f-v)*et,G=S-(S-E)*et,it=A-(A-I)*et,rt=b-(b-C)*et;let ht=Math.round(Math.min(k,U)),Rt=Math.round(Math.max(k,U)),N=d*J+ht*4;for(let P=ht;P<=Rt;P++){if(et=(k-P)/(k-U),et<0)et=0;else if(et>1)et=1;c[N++]=R-(R-G)*et|0,c[N++]=M-(M-it)*et|0,c[N++]=_-(_-rt)*et|0,c[N++]=255}}}class Jn extends Rs{constructor(t){super();this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],Pa()}_createMeshCanvas(t,e,s){let a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),l=Math.ceil(this._bounds[2])-a,h=Math.ceil(this._bounds[3])-o,c=Math.min(Math.ceil(Math.abs(l*t[0]*1.1)),3000)||1,d=Math.min(Math.ceil(Math.abs(h*t[1]*1.1)),3000)||1,u=l?l/c:1,f=h?h/d:1,p={coords:this._posData,colors:this._colData,offsetX:-a,offsetY:-o,scaleX:1/u,scaleY:1/f},g=c+4,m=d+4,v=s.create(g,m);if(Ia()&&this._vertexCount>48)v.context.drawImage(Ma(this._posData,this._colData,this._vertexCount,p,e,g,m,2),0,0);else{let y=v.context.createImageData(c,d);if(e){let S=y.data;for(let A=0,b=S.length;A<b;A+=4)S[A]=e[0],S[A+1]=e[1],S[A+2]=e[2],S[A+3]=255}for(let S=0,A=this._vertexCount;S<A;S+=3)Oa(y,p,S,S+1,S+2,S,S+1,S+2);v.context.putImageData(y,2,2)}return{canvas:v.canvas,offsetX:a-2*u,offsetY:o-2*f,scaleX:u,scaleY:f}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){ds(t,this._bbox);let n=new Float32Array(2);if(i===Ct.SHADING)L.singularValueDecompose2dScale(dt(t),n);else if(this.matrix){L.singularValueDecompose2dScale(this.matrix,n);let[o,l]=n;L.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=o,n[1]*=l}else L.singularValueDecompose2dScale(e.baseTransform,n);let r=this._createMeshCanvas(n,i===Ct.SHADING?null:this._background,e.canvasFactory);if(i!==Ct.SHADING){if(t.setTransform(...e.baseTransform),this.matrix)t.transform(...this.matrix)}t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY);let a=t.createPattern(r.canvas,"no-repeat");return e.canvasFactory.destroy(r),a}}class Qn extends Rs{getPattern(){return"hotpink"}}function Ra(t){switch(t[0]){case"RadialAxial":return new Kn(t);case"Mesh":return new Jn(t);case"Dummy":return new Qn}throw Error(`Unknown IR type: ${t[0]}`)}var sn={COLORED:1,UNCOLORED:2};class He{static MAX_PATTERN_SIZE=3000;constructor(t,e,s,i){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i,this.patternBaseMatrix=this.matrix?L.transform(i,this.matrix):i}canSkipPatternCanvas([t,e,s,i]){let[n,r,a,o]=this.bbox,l=Math.abs(this.xstep),h=Math.abs(this.ystep);if(t>l+0.000001||e>h+0.000001)return null;let c=Math.floor((s-a)/l)+1,d=Math.ceil((s+t-n)/l)-1,u=Math.floor((i-o)/h)+1,f=Math.ceil((i+e-r)/h)-1;return d<=c&&f<=u?[c,u]:null}updatePatternDims(t,e){let s=L.inverseTransform(this.patternBaseMatrix),i=[t[0],t[1]],n=[t[2],t[3]];L.applyTransform(i,s),L.applyTransform(n,s),e[0]=Math.abs(n[0]-i[0]),e[1]=Math.abs(n[1]-i[1]),e[2]=Math.min(i[0],n[0]),e[3]=Math.min(i[1],n[1])}_renderTileCanvas(t,e,s,i){let[n,r,a,o]=this.bbox,l=t.canvasFactory.create(s.size,i.size),h=l.context,c=this.canvasGraphicsFactory.createCanvasGraphics(h,e);return c.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(c,this.paintType,this.color),h.translate(-s.scale*n,-i.scale*r),c.transform(0,s.scale,0,0,i.scale,0,0),h.save(),c.dependencyTracker?.save(),this.clipBbox(c,n,r,a,o),c.baseTransform=dt(c.ctx),c.executeOperatorList(this.operatorList),c.endDrawing(),c.dependencyTracker?.restore(),h.restore(),l}_getCombinedScales(){let t=new Float32Array(2);L.singularValueDecompose2dScale(this.matrix,t);let[e,s]=t;return L.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],s*t[1]]}drawPattern(t,e,s=!1,[i,n],r){let[a,o,l,h]=this.bbox,c=t.dependencyTracker;if(c)t.dependencyTracker=new Ge(c,r);if(t.save(),s)t.ctx.clip(e,"evenodd");else t.ctx.clip(e);if(t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(i*this.xstep,n*this.ystep),this.needsIsolation||t.ctx.globalAlpha!==1||t.ctx.globalCompositeOperation!=="source-over"||t.inSMaskMode){let d=l-a,u=h-o,[f,p]=this._getCombinedScales(),g=this.getSizeAndScale(d,this.ctx.canvas.width,f),m=this.getSizeAndScale(u,this.ctx.canvas.height,p),v=this._renderTileCanvas(t,r,g,m);t.ctx.drawImage(v.canvas,a,o,d,u),t.canvasFactory.destroy(v)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,a,o,l,h),t.baseTransformStack.push(t.baseTransform),t.baseTransform=dt(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();if(t.restore(),c)t.dependencyTracker=c}createPatternCanvas(t,e){let[s,i,n,r]=this.bbox,a=n-s,o=r-i,{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),Ts("TilingType: "+this.tilingType);let[c,d]=this._getCombinedScales(),u=a,f=o,p=!1,g=!1;if(Math.ceil(l*c)>=Math.ceil(a*c))u=l;else p=!0;if(Math.ceil(h*d)>=Math.ceil(o*d))f=h;else g=!0;let m=this.getSizeAndScale(u,this.ctx.canvas.width,c),v=this.getSizeAndScale(f,this.ctx.canvas.height,d),y=this._renderTileCanvas(t,e,m,v);if(p||g){let S=y.canvas;if(p)u=l;if(g)f=h;let A=this.getSizeAndScale(u,this.ctx.canvas.width,c),b=this.getSizeAndScale(f,this.ctx.canvas.height,d),w=A.size,x=b.size,T=t.canvasFactory.create(w,x),E=T.context,I=p?Math.floor(a/l):0,C=g?Math.floor(o/h):0;for(let O=0;O<=I;O++)for(let D=0;D<=C;D++)E.drawImage(S,w*O,x*D,w,x,0,0,w,x);return t.canvasFactory.destroy(y),{canvas:T.canvas,canvasEntry:T,scaleX:A.scale,scaleY:b.scale,offsetX:s,offsetY:i}}return{canvas:y.canvas,canvasEntry:y,scaleX:m.scale,scaleY:v.scale,offsetX:s,offsetY:i}}getSizeAndScale(t,e,s){let i=Math.max(He.MAX_PATTERN_SIZE,e),n=Math.ceil(t*s);if(n>=i)n=i;else s=n/t;return{scale:s,size:n}}clipBbox(t,e,s,i,n){let r=i-e,a=n-s,o=new Path2D;o.rect(e,s,r,a),L.axialAlignedBoundingBox([e,s,i,n],dt(t.ctx),t.current.minMax),t.ctx.clip(o),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,s){let{ctx:i,current:n}=t;switch(n.patternFill=n.patternStroke=!1,e){case sn.COLORED:let{fillStyle:r,strokeStyle:a}=this.ctx;i.fillStyle=n.fillColor=r,i.strokeStyle=n.strokeColor=a;break;case sn.UNCOLORED:i.fillStyle=i.strokeStyle=s,n.fillColor=n.strokeColor=s;break;default:throw new yn(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,n){let r=i!==Ct.SHADING?L.transform(s,this.patternBaseMatrix):s,a=this.createPatternCanvas(e,n),o=new DOMMatrix(r);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);let l=t.createPattern(a.canvas,"repeat");return e.canvasFactory.destroy(a.canvasEntry),l.setTransform(o),l}}var Da=16,ka=100,La=15,nn=10,kt=16,Bt=new Float32Array(2);function rn(t,e){if(t._removeMirroring)throw Error("Context is already forwarding operations.");let s=new Map;for(let i of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){let n=t[i];if(typeof n!=="function"||typeof e[i]!=="function")continue;s.set(i,n),t[i]=function(...r){return e[i](...r),n.apply(this,r)}}t._removeMirroring=()=>{for(let[i,n]of s)t[i]=n;delete t._removeMirroring}}function is(t,e,s,i,n,r,a,o,l,h){let[c,d,u,f,p,g]=dt(t);if(d===0&&u===0){let y=a*c+p,S=Math.round(y),A=o*f+g,b=Math.round(A),w=(a+l)*c+p,x=Math.abs(Math.round(w)-S)||1,T=(o+h)*f+g,E=Math.abs(Math.round(T)-b)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(f),S,b),t.drawImage(e,s,i,n,r,0,0,x,E),t.setTransform(c,d,u,f,p,g),[x,E]}if(c===0&&f===0){let y=o*u+p,S=Math.round(y),A=a*d+g,b=Math.round(A),w=(o+h)*u+p,x=Math.abs(Math.round(w)-S)||1,T=(a+l)*d+g,E=Math.abs(Math.round(T)-b)||1;return t.setTransform(0,Math.sign(d),Math.sign(u),0,S,b),t.drawImage(e,s,i,n,r,0,0,E,x),t.setTransform(c,d,u,f,p,g),[E,x]}t.drawImage(e,s,i,n,r,a,o,l,h);let m=Math.hypot(c,d),v=Math.hypot(u,f);return[m*l,v*h]}class ni{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=Ys;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=bt.FILL;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";minMax=de.slice();constructor(t,e){this.clipBox=new Float32Array([0,0,t,e])}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=this.tilingPatternDims?.slice(),t}getPathBoundingBox(t=Ct.FILL,e=null){let s=this.minMax.slice();if(t===Ct.STROKE){if(!e)st("Stroke bounding box must include transform.");L.singularValueDecompose2dScale(e,Bt);let i=Bt[0]*this.lineWidth/2,n=Bt[1]*this.lineWidth/2;s[0]-=i,s[1]-=n,s[2]+=i,s[3]+=n}return s}updateClipFromPath(){let t=L.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(de,0)}getClippedPathBoundingBox(t=Ct.FILL,e=null){return L.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function an(t,e){let{width:s,height:i,kind:n}=e,r=i%kt,a=(i-r)/kt,o=r===0?a:a+1,l=t.createImageData(s,kt),h=0,c=e.data,d=l.data,u;if(n===hs.GRAYSCALE_1BPP)for(u=0;u<o;u++)({srcPos:h}=Xn({src:c,srcPos:h,dest:d,width:s,height:u<a?kt:r})),t.putImageData(l,0,u*kt);else if(n===hs.RGBA_32BPP){let f=0,p=s*kt*4;for(u=0;u<a;u++)d.set(c.subarray(h,h+p)),h+=p,t.putImageData(l,0,f),f+=kt;if(u<o)p=s*r*4,d.set(c.subarray(h,h+p)),t.putImageData(l,0,f)}else if(n===hs.RGB_24BPP)for(u=0;u<o;u++)({srcPos:h}=Ea({src:c,srcPos:h,dest:new Uint32Array(d.buffer),width:s,height:u<a?kt:r})),t.putImageData(l,0,u*kt);else throw Error(`bad image kind: ${n}`)}function on(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}let{width:s,height:i}=e,n=i%kt,r=(i-n)/kt,a=n===0?r:r+1,o=t.createImageData(s,kt),l=0,h=e.data,c=o.data;for(let d=0;d<a;d++)({srcPos:l}=Xn({src:h,srcPos:l,dest:c,width:s,height:d<r?kt:n,nonBlackColor:0})),t.putImageData(o,0,d*kt)}function le(t,e){let s=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let i of s)if(t[i]!==void 0)e[i]=t[i];if(t.setLineDash!==void 0)e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset}function ns(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",t.setLineDash!==void 0)t.setLineDash([]),t.lineDashOffset=0;let{filter:e}=t;if(e!=="none"&&e!=="")t.filter="none"}function ln(t,e){if(e)return!0;L.singularValueDecompose2dScale(t,Bt);let s=Math.fround(Wt.pixelRatio*pe.PDF_TO_CSS_UNITS);return Bt[0]<=s&&Bt[1]<=s}var Na=["butt","round","square"],Fa=["miter","round","bevel"],Ba={},hn={};class fe{static#t=null;#e=0;#s=0;#i=null;#n=null;#a=null;#r=null;#o=1;#l;#h=null;#u=[];constructor(t,e,s,i,n,{optionalContentConfig:r,markedContentStack:a=null},o,l,h,c){this.ctx=t,this.current=new ni(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=n,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=r,this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null,this.imagesTracker=c??null}getObject(t,e,s=null){if(typeof e==="string")return this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e);return s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){let n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,s){let o=this.transparentCanvasEntry=this.canvasFactory.create(n,r);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=o,this.ctx.save(),this.ctx.transform(...dt(this.compositeCtx))}if(this.ctx.save(),ns(this.ctx),t)this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3];this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=dt(this.ctx)}executeOperatorList(t,e,s,i,n){let{argsArray:r,fnArray:a}=t,o=e||0,l=r.length;if(l===o)return o;let h=l-o>nn&&typeof s==="function",c=h?Date.now()+La:0,d=0,u=this.commonObjs,f=this.objs,p,g;while(!0){if(i!==void 0){if(o===i.nextBreakPoint)return i.breakIt(o,s),o;if(i.shouldSkip(o)){if(++o===l)return o;continue}}if(!n||n(o))if(p=a[o],g=r[o]??null,p!==Qt.dependency)if(g===null)this[p](o);else this[p](o,...g);else for(let m of g){this.dependencyTracker?.recordNamedData(m,o);let v=m.startsWith("g_")?u:f;if(!v.has(m))return v.get(m,s),o}if(o++,o===l)return o;if(h&&++d>nn){if(Date.now()>c)return s(),o;d=0}}}#d(){while(this.stateStack.length||this.inSMaskMode)this.restore();if(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(),this.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null}endDrawing(){this.#d();for(let t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(let t of this.#u)this.#A(t);this.#u.length=0,this.#i=null,this.#n=null,this.#a=null,this.#r=null,this.#o=1,this.#h=null,this.#s=0,this.#e=0,this.cachedPatterns.clear();for(let t of this._cachedBitmapsMap.values()){for(let e of t.values())if(typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement)e.width=e.height=0;t.clear()}this._cachedBitmapsMap.clear(),this.#f()}#f(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let s=t.width??t.displayWidth,i=t.height??t.displayHeight,n=Math.max(Math.hypot(e[0],e[1]),1),r=Math.max(Math.hypot(e[2],e[3]),1),a=[],o=n,l=r,h=s,c=i;while(o>2&&h>1||l>2&&c>1){let m=h,v=c;if(o>2&&h>1)m=Math.ceil(h/2),o/=h/m;if(l>2&&c>1)v=Math.ceil(c/2),l/=c/v;a.push({newWidth:m,newHeight:v}),h=m,c=v}if(a.length===0)return{img:t,paintWidth:s,paintHeight:i,tmpCanvas:null};if(a.length===1){let{newWidth:m,newHeight:v}=a[0],y=this.canvasFactory.create(m,v);return y.context.drawImage(t,0,0,s,i,0,0,m,v),{img:y.canvas,paintWidth:m,paintHeight:v,tmpCanvas:y}}let d=this.canvasFactory.create(1,1),u=this.canvasFactory.create(1,1),f=s,p=i,g=t;for(let{newWidth:m,newHeight:v}of a)this.canvasFactory.reset(u,m,v),u.context.drawImage(g,0,0,f,p,0,0,m,v),[d,u]=[u,d],g=d.canvas,f=m,p=v;return this.canvasFactory.destroy(u),{img:d.canvas,paintWidth:f,paintHeight:p,tmpCanvas:d}}_createMaskCanvas(t,e){let s=this.ctx,{width:i,height:n}=e,r=this.current.fillColor,a=this.current.patternFill,o=dt(s),l,h,c,d;if((e.bitmap||e.data)&&e.count>1){let I=e.bitmap||e.data.buffer;h=JSON.stringify(a?o:[o.slice(0,4),r]),l=this._cachedBitmapsMap.getOrInsertComputed(I,ai);let C=l.get(h);if(C&&!a){let O=Math.round(Math.min(o[0],o[2])+o[4]),D=Math.round(Math.min(o[1],o[3])+o[5]);return this.dependencyTracker?.recordDependencies(t,Ht.transformAndFill),{canvas:C,offsetX:O,offsetY:D}}c=C}if(!c)d=this.canvasFactory.create(i,n),on(d.context,e);let u=L.transform(o,[1/i,0,0,-1/n,0,0]);u=L.transform(u,[1,0,0,1,0,-n]);let f=de.slice();L.axialAlignedBoundingBox([0,0,i,n],u,f);let[p,g,m,v]=f,y=Math.round(m-p)||1,S=Math.round(v-g)||1,A=this.canvasFactory.create(y,S),b=A.context,w=p,x=g;b.translate(-w,-x),b.transform(...u);let T=null;if(!c){let I=this._scaleImage(d.canvas,Yt(b));if(c=I.img,T=I.tmpCanvas,c!==d.canvas)this.canvasFactory.destroy(d),d=null;if(l&&a)l.set(h,c),T=null,d=null}if(b.imageSmoothingEnabled=ln(dt(b),e.interpolate),is(b,c,0,0,c.width,c.height,0,0,i,n),T)this.canvasFactory.destroy(T);if(d)this.canvasFactory.destroy(d);b.globalCompositeOperation="source-in";let E=L.transform(Yt(b),[1,0,0,1,-w,-x]);if(b.fillStyle=a?r.getPattern(s,this,E,Ct.FILL,t):r,b.fillRect(0,0,i,n),l&&!a)l.set(h,A.canvas);return this.dependencyTracker?.recordDependencies(t,Ht.transformAndFill),{canvas:A.canvas,canvasEntry:l&&!a?null:A,offsetX:Math.round(w),offsetY:Math.round(x)}}setLineWidth(t,e){if(this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth)this._cachedScaleForStroking[0]=-1;this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=Na[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=Fa[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){this.dependencyTracker?.recordSimpleData("dash",t);let i=this.ctx;if(i.setLineDash!==void 0)i.setLineDash(e),i.lineDashOffset=s}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(let[s,i]of e)switch(s){case"LW":this.setLineWidth(t,i);break;case"LC":this.setLineCap(t,i);break;case"LJ":this.setLineJoin(t,i);break;case"ML":this.setMiterLimit(t,i);break;case"D":this.setDash(t,i[0],i[1]);break;case"RI":this.setRenderingIntent(t,i);break;case"FL":this.setFlatness(t,i);break;case"Font":this.setFont(t,i[0],i[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=i;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=i;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=i;break;case"SMask":if(this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=i?this.tempSMask:null,this.current.activeSMask)this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation;this.tempSMask=null,this.checkSMaskState(t);break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i);break}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){if(this.smaskPreparedEntry)this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null;this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(t){if(t===this.smaskPreparedFor)return;this._clearPreparedSMask(),this._prepareSMaskCanvas(t)}checkSMaskState(t){let e=this.inSMaskMode;if(this.current.activeSMask&&!e)this.beginSMaskMode(t);else if(!this.current.activeSMask&&e)this.endSMaskMode();else if(this.current.activeSMask&&e)this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(t){let{canvas:e,subtype:s,backdrop:i,transferMap:n}=t,r=s==="Luminosity"||s==="Alpha"&&n;if(!r&&!(s==="Luminosity"&&i)){this.smaskPreparedFor=t;return}let a;if(s==="Luminosity"&&i){let[v,y,S]=Ye(i),A=Math.round(0.3*v+0.59*y+0.11*S);a=n?.[A]??A}else a=n?.[0]??0;let o=4,{width:l,height:h}=this.ctx.canvas,c=e.width*e.height,d=l*h<o*c,u=r?{url:s==="Alpha"?this.filterFactory.addAlphaFilter(n):this.filterFactory.addLuminosityFilter(n),subtype:s,transferMap:n}:null,f=s==="Luminosity"?i:null,p,g,m;if(d)p=this._bakeSMaskCanvas(e,t.offsetX,t.offsetY,l,h,f,u),g=0,m=0;else p=this._bakeSMaskCanvas(e,0,0,e.width,e.height,f,u),g=t.offsetX,m=t.offsetY;this.smaskPreparedEntry=p,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=g,this.smaskPreparedOffsetY=m,this.smaskPreparedOOBAlpha=!d&&a!==0?a:null}_bakeSMaskCanvas(t,e,s,i,n,r,a){if(!r&&!a)st("_bakeSMaskCanvas with neither backdrop nor filter");let o=this.canvasFactory.create(i,n),l=o.context;if(l.drawImage(t,e,s),r)l.globalCompositeOperation="destination-atop",l.fillStyle=r,l.fillRect(0,0,i,n);if(!a)return o;let h=this.canvasFactory.create(i,n),c=h.context;c.filter=a.url;let d=ot.isCanvasFilterSupported&&c.filter!=="none"&&c.filter!=="";if(c.drawImage(o.canvas,0,0),ot.isCanvasFilterSupported)c.filter="none";if(!d){let u=c.getImageData(0,0,i,n),{data:f}=u,{transferMap:p}=a;if(a.subtype==="Luminosity")for(let g=0,m=f.length;g<m;g+=4){let v=0.3*f[g]+0.59*f[g+1]+0.11*f[g+2]+0.5|0;f[g]=f[g+1]=f[g+2]=0,f[g+3]=p?.[v]??v}else for(let g=3,m=f.length;g<m;g+=4)f[g]=p[f[g]];c.putImageData(u,0,0)}return this.canvasFactory.destroy(o),h}beginSMaskMode(t){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let{width:e,height:s}=this.ctx.canvas,i=this.canvasFactory.create(e,s);this.smaskScratchCanvas=i,this.suspendedCtx=this.ctx;let n=this.ctx=i.context;n.setTransform(this.suspendedCtx.getTransform()),le(this.suspendedCtx,n),rn(n,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),le(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}#g(t,e=null,s=1){let{width:i,height:n}=t,r=e??this.canvasFactory.create(i,n),a=r.context;s=Math.round(s*255)/255;let o=s<1;if(o&&this.#l===void 0)this.#l=ot.isCanvasFilterSupported?new Map:"none";let l="none";if(o&&this.#l instanceof Map)l=this.#l.getOrInsertComputed(s,()=>this.filterFactory.addKnockoutFilter(s));if(!o||l!=="none"){if(e)a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,i,n),a.restore();return a.filter=l,a.drawImage(t,0,0),a.filter="none",r}let h=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,i,n),c=a.createImageData(i,n),d=h.data,u=c.data,f=s>0?1/s:1e6;for(let p=3,g=d.length;p<g;p+=4)u[p]=Math.min(Math.round(d[p]*f),255);return a.putImageData(c,0,0),r}#m(t,e,s,i){let n=t?.[e]??null;if(n&&(n.canvas.width!==s||n.canvas.height!==i))this.canvasFactory.destroy(n),n=null;if(!n){if(n=this.canvasFactory.create(s,i),t)t[e]=n;return n}let r=n.context;return r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,s,i),r.restore(),n}#c(t,e,s={}){let{backdropCanvas:i=null,destTransform:n=[1,0,0,1,0,0],backdropOffset:r=[0,0],reuseMaskEntry:a=null,poolMeta:o=null,sourceAlpha:l=1,sourceFilter:h="none",knockoutAlpha:c=1}=s,{width:d,height:u}=e,f=this.#g(e,a,c),p=t.globalCompositeOperation;if(t.save(),t.setTransform(...n),t.globalAlpha=1,ot.isCanvasFilterSupported)t.filter="none";if(t.globalCompositeOperation="destination-out",t.drawImage(f.canvas,0,0),i){let[g,m]=r,v=this.#m(o,"knockoutBackdropEntry",d,u),y=v.context;if(y.drawImage(i,g,m,d,u,0,0,d,u),y.globalCompositeOperation="destination-in",y.drawImage(f.canvas,0,0),y.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(v.canvas,0,0),!o)this.canvasFactory.destroy(v)}if(t.globalCompositeOperation=p,t.globalAlpha=l,ot.isCanvasFilterSupported)t.filter=h??"none";if(t.drawImage(e,0,0),t.restore(),!a)this.canvasFactory.destroy(f)}#p(t=1){if(this.#e===0||this.#s>0||!this.contentVisible)return!1;this.#s++,this.#o=t;let e=this.#u.at(-1),{canvas:s}=this.ctx,i=this.#m(e,"knockoutTempEntry",s.width,s.height);this.#i=i;let n=i.context;if(n.save(),n.setTransform(this.ctx.getTransform()),le(this.ctx,n),this.#r=n.globalCompositeOperation,n.globalCompositeOperation="source-over",rn(n,this.ctx),this.#h=e,this.#n=this.ctx,this.#a=this.suspendedCtx,this.ctx=n,this.inSMaskMode)this.suspendedCtx=n;return!0}#v(t){if(!t)return;let e=this.#i,s=this.#n,i=this.#a,n=e.context;if(this.#i=null,this.#n=null,this.#a=null,this.inSMaskMode&&this.suspendedCtx===n&&this.ctx!==n)this.endSMaskMode();if(this.inSMaskMode)this.suspendedCtx=i;this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=this.#r,this.#r=null,le(this.ctx,s),this.ctx=s;let r=this.#h;this.#h=null;let a=this.#o;this.#o=1;try{this.#c(i??s,e.canvas,{backdropCanvas:r?.backdropCtx?.canvas??null,backdropOffset:r?.backdropCtx?[r.offsetX,r.offsetY]:[0,0],reuseMaskEntry:r?.knockoutMaskEntry??null,poolMeta:r,knockoutAlpha:a})}finally{if(n.restore(),this.#s--,!r)this.canvasFactory.destroy(e)}}compose(t){if(!this.current.activeSMask)return;t=t?[Math.floor(t[0]),Math.floor(t[1]),Math.ceil(t[2]),Math.ceil(t[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let e=this.current.activeSMask,s=this.suspendedCtx,i=this.#s>0&&s===this.ctx;if(this.composeSMask(i?null:s,e,this.ctx,t),i)return;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(t,e,s,i){let n=i[0],r=i[1],a=i[2]-n,o=i[3]-r;if(a===0||o===0)return;let l=this.smaskPreparedEntry;if(l){let h=n,c=r,d=a,u=o,f=this.smaskPreparedOOBAlpha,p=f!==null;if(p){h=Math.max(n,e.offsetX),c=Math.max(r,e.offsetY);let g=Math.min(n+a,e.offsetX+e.canvas.width),m=Math.min(r+o,e.offsetY+e.canvas.height);d=g-h,u=m-c}if(d>0&&u>0){let g=h-this.smaskPreparedOffsetX,m=c-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);let v=new Path2D;v.rect(h,c,d,u),s.clip(v),s.globalCompositeOperation="destination-in",s.drawImage(l.canvas,g,m,d,u,h,c,d,u),s.restore()}if(p&&f<255)this._applySMaskOOBAlpha(s,n,r,a,o,h,c,h+d,c+u,f)}else this.genericComposeSMask(e,s,a,o,n,r);if(!t)return;t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,n,r,a,o,n,r,a,o),t.restore()}_applySMaskOOBAlpha(t,e,s,i,n,r,a,o,l,h){let c=r<o&&a<l;if(c&&r===e&&a===s&&o===e+i&&l===s+n)return;let d=new Path2D;if(d.rect(e,s,i,n),c)d.rect(r,a,o-r,l-a);t.save(),t.globalAlpha=h/255,t.setTransform(1,0,0,1,0,0),t.clip(d,"evenodd"),t.globalCompositeOperation="destination-in",t.fillStyle="#000000",t.fillRect(e,s,i,n),t.restore()}genericComposeSMask(t,e,s,i,n,r){let{context:a,offsetX:o,offsetY:l}=t;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);let h=new Path2D;h.rect(n,r,s,i),e.clip(h),e.globalCompositeOperation="destination-in",e.drawImage(a.canvas,n-o,r-l,s,i,n,r,s,i),e.restore()}save(t){if(this.inSMaskMode)le(this.ctx,this.suspendedCtx);this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),this.stateStack.length===0){if(this.inSMaskMode)this.endSMaskMode();return}if(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode)le(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform());this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,i,n,r,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,s,i,n,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,i){let[n]=s;if(!i){if(n||=s[0]=new Path2D,e!==Qt.stroke&&e!==Qt.closeStroke)this.current.tilingPatternDims=null;this[e](t,n);return}if(this.dependencyTracker!==null){let a=e===Qt.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-a,i[2]+a,i[1]-a,i[3]+a).recordDependencies(t,["transform"])}if(!(n instanceof Path2D))n=s[0]=xn(n);L.axialAlignedBoundingBox(i,dt(this.ctx),this.current.minMax);let r=this.current.tilingPatternDims;if(r&&e!==Qt.stroke&&e!==Qt.closeStroke&&this.current.fillColor instanceof He){let a=L.intersect(this.current.clipBox,this.current.minMax);if(!a)this.current.tilingPatternDims=null;else this.current.fillColor.updatePatternDims(a,r)}this[e](t,n),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){let i=s&&this.#p(this.current.strokeAlpha),n=this.ctx,r=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r==="object"&&r?.getPattern){let a=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=r.getPattern(n,this,Yt(n),Ct.STROKE,t),a){let o=new Path2D;o.addPath(e,n.getTransform().invertSelf().multiplySelf(a)),e=o}this.rescaleAndStroke(e,!1),n.restore()}else this.rescaleAndStroke(e,!0);if(this.dependencyTracker?.recordDependencies(t,Ht.stroke),s)this.consumePath(t,e,this.current.getClippedPathBoundingBox(Ct.STROKE,dt(this.ctx)));n.globalAlpha=this.current.fillAlpha,this.#v(i)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){let i=s&&this.#p(this.current.fillAlpha),n=this.ctx,r=this.current.fillColor,a=this.current.patternFill,o=!1,l=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(t,Ht.fill),a){let h=this.current.tilingPatternDims,c=h&&r.canSkipPatternCanvas(h);if(c){if(r.drawPattern(this,e,this.pendingEOFill,c,t),this.pendingEOFill=!1,s)this.consumePath(t,e,l);this.current.tilingPatternDims=null,this.#v(i);return}let d=r.isModifyingCurrentTransform()?n.getTransform():null;if(this.dependencyTracker?.save(t),n.save(),n.fillStyle=r.getPattern(n,this,Yt(n),Ct.FILL,t),d){let u=new Path2D;u.addPath(e,n.getTransform().invertSelf().multiplySelf(d)),e=u}o=!0}if(this.contentVisible&&l!==null)if(this.pendingEOFill)n.fill(e,"evenodd"),this.pendingEOFill=!1;else n.fill(e);if(o)n.restore(),this.dependencyTracker?.restore(t);if(s)this.consumePath(t,e,l);this.#v(i)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){let s=this.#p(Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e),this.#v(s)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){let s=this.#p(this.current.fillAlpha);this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,Ht.rawFillPath).recordOperation(t),this.#v(s)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Ba}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=hn}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){let e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){let{dependencyTracker:i}=this;if(e!==void 0)i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t);i.recordCloseMarker(t)}if(e!==void 0){let i=new Path2D,n=s.getTransform().invertSelf();for(let{transform:r,x:a,y:o,fontSize:l,path:h}of e){if(!h)continue;i.addPath(h,new DOMMatrix(r).preMultiplySelf(n).translate(a,o).scale(l,-l))}s.clip(i)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);let i=this.commonObjs.get(e),n=this.current;if(!i)throw Error(`Can't find font for ${e}`);if(n.fontMatrix=i.fontMatrix||Ys,n.fontMatrix[0]===0||n.fontMatrix[3]===0)z("Invalid font matrix for font "+e);if(s<0)s=-s,n.fontDirection=-1;else n.fontDirection=1;if(this.current.font=i,this.current.fontSize=s,i.isType3Font)return;let r=i.loadedName||"sans-serif",a=i.systemFontInfo?.css||`"${r}", ${i.fallbackName}`,o="normal";if(i.black)o="900";else if(i.bold)o="bold";let l=i.italic?"italic":"normal",h=ut(s,Da,ka);this.current.fontSizeScale=s/h,this.ctx.font=`${l} ${o} ${h}px ${a}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);let{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#y(t,e,s){let i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i}paintChar(t,e,s,i,n,r){let a=this.ctx,o=this.current,{font:l,textRenderingMode:h}=o,c=o.fontSize/o.fontSizeScale,d=h&bt.FILL_STROKE_MASK,u=!!(h&bt.ADD_TO_PATH_FLAG),f=o.patternFill&&!l.missingFile,p=o.patternStroke&&!l.missingFile,g;if((l.disableFontFace||u||f||p)&&!l.missingFile)g=l.getPathGenerator(this.commonObjs,e);if(g&&(l.disableFontFace||f||p)){a.save(),a.translate(s,i),a.scale(c,-c),this.dependencyTracker?.recordCharacterBBox(t,a,l);let m;if(d===bt.FILL||d===bt.FILL_STROKE)if(n){m=a.getTransform(),a.setTransform(...n);let v=this.#y(g,m,n);a.fill(v)}else a.fill(g);if(d===bt.STROKE||d===bt.FILL_STROKE)if(r){m||=a.getTransform(),a.setTransform(...r);let{a:v,b:y,c:S,d:A}=m,b=L.inverseTransform(r),w=L.transform([v,y,S,A,0,0],b);L.singularValueDecompose2dScale(w,Bt),a.lineWidth*=Math.max(Bt[0],Bt[1])/c,a.stroke(this.#y(g,m,r))}else a.lineWidth/=c,a.stroke(g);a.restore()}else{if(d===bt.FILL||d===bt.FILL_STROKE)a.fillText(e,s,i),this.dependencyTracker?.recordCharacterBBox(t,a,l,c,s,i,()=>a.measureText(e));if(d===bt.STROKE||d===bt.FILL_STROKE){if(this.dependencyTracker)this.dependencyTracker?.recordCharacterBBox(t,a,l,c,s,i,()=>a.measureText(e)).recordDependencies(t,Ht.stroke);a.strokeText(e,s,i)}}if(u)(this.pendingTextPaths||=[]).push({transform:dt(a),x:s,y:i,fontSize:c,path:g}),this.dependencyTracker?.recordCharacterBBox(t,a,l,c,s,i)}get isFontSubpixelAAEnabled(){let t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);let s=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let i=!1;for(let n=3;n<s.length;n+=4)if(s[n]>0&&s[n]<255){i=!0;break}return j(this,"isFontSubpixelAAEnabled",i)}showText(t,e){if(this.dependencyTracker){if(this.dependencyTracker.recordDependencies(t,Ht.showText).resetBBox(t),this.current.textRenderingMode&bt.ADD_TO_PATH_FLAG)this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies()}let s=this.current,i=s.font;if(i.isType3Font){let C=this.#p(s.fillAlpha);this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t),this.#v(C);return}let n=s.fontSize;if(n===0){this.dependencyTracker?.recordOperation(t);return}let r=this.#p(s.fillAlpha),a=this.ctx,{fontSizeScale:o,charSpacing:l,wordSpacing:h,fontDirection:c}=s,d=s.textHScale*c,u=e.length,f=i.vertical,p=f?1:-1,g=i.defaultVMetrics,m=n*s.fontMatrix[0],v=s.textRenderingMode===bt.FILL&&!i.disableFontFace&&!s.patternFill;if(a.save(),s.textMatrix)a.transform(...s.textMatrix);if(a.translate(s.x,s.y+s.textRise),c>0)a.scale(d,-1);else a.scale(d,1);let y,S,A=s.textRenderingMode&bt.FILL_STROKE_MASK,b=A===bt.FILL||A===bt.FILL_STROKE,w=A===bt.STROKE||A===bt.FILL_STROKE,{lineWidth:x,textMatrixScale:T}=s;if(T===0||x===0){if(w)x=this.getSinglePixelWidth()}else x/=T;if(o!==1)a.scale(o,o),x/=o;if(a.lineWidth=x,b&&s.patternFill){a.save();let C=s.fillColor.getPattern(a,this,Yt(a),Ct.FILL,t);y=dt(a),a.restore(),a.fillStyle=C}if(w&&s.patternStroke){a.save();let C=s.strokeColor.getPattern(a,this,Yt(a),Ct.STROKE,t);S=dt(a),a.restore(),a.strokeStyle=C}if(i.isInvalidPDFjsFont){let C=[],O=0;for(let k of e)C.push(k.unicode),O+=k.width;let D=C.join("");if(a.fillText(D,0,0),this.dependencyTracker!==null){let k=a.measureText(D);this.dependencyTracker.recordBBox(t,this.ctx,-k.actualBoundingBoxLeft,k.actualBoundingBoxRight,-k.actualBoundingBoxAscent,k.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=O*m*d,a.restore(),this.compose(),this.#v(r);return}let E=0,I;for(I=0;I<u;++I){let C=e[I];if(typeof C==="number"){E+=p*C*n/1000;continue}let O=!1,D=(C.isSpace?h:0)+l,{fontChar:k,accent:R}=C,M,_,U=C.width;if(f){let rt=C.vmetric||g,J=-(C.vmetric?rt[1]:U*0.5)*m,et=rt[2]*m;U=rt?-rt[0]:U,M=J/o,_=(E+et)/o}else M=E/o,_=0;let G;if(i.remeasure&&U>0){G=a.measureText(k);let rt=G.width*1000/n*o;if(U<rt&&this.isFontSubpixelAAEnabled){let J=U/rt;O=!0,a.save(),a.scale(J,1),M/=J}else if(U!==rt)M+=(U-rt)/2000*n/o}if(this.contentVisible&&(C.isInFont||i.missingFile)){if(v&&!R)a.fillText(k,M,_),this.dependencyTracker?.recordCharacterBBox(t,a,G?{bbox:null}:i,n/o,M,_,()=>G??a.measureText(k));else if(this.paintChar(t,k,M,_,y,S),R){let rt=M+n*R.offset.x/o,J=_-n*R.offset.y/o;this.paintChar(t,R.fontChar,rt,J,y,S)}}let it=f?U*m-D*c:U*m+D*c;if(E+=it,O)a.restore()}if(f)s.y-=E;else s.x+=E*d;a.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t),this.#v(r)}showType3Text(t,e){let s=this.ctx,i=this.current,{font:n,fontSize:r,fontDirection:a}=i,o=n.vertical?1:-1,{charSpacing:l,wordSpacing:h}=i,c=i.textHScale*a,d=i.fontMatrix||Ys,u=e.length,f=i.textRenderingMode===bt.INVISIBLE,p,g,m,v;if(f||r===0)return;if(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),i.textMatrix)s.transform(...i.textMatrix);s.translate(i.x,i.y+i.textRise),s.scale(c,a);let y=this.dependencyTracker;this.dependencyTracker=y?new Ge(y,t):null;for(p=0;p<u;++p){if(g=e[p],typeof g==="number"){v=o*g*r/1000,this.ctx.translate(v,0),i.x+=v*c;continue}let S=(g.isSpace?h:0)+l,A=n.charProcOperatorList.get(g.operatorListId);if(!A)z(`Type3 character "${g.operatorListId}" is not available.`);else if(this.contentVisible){if(this.save(),A.fnArray[0]===Qt.setCharWidth)i.fillAlpha=i.strokeAlpha=1,s.globalAlpha=1;s.scale(r,r),s.transform(...d),this.executeOperatorList(A),this.restore()}let b=[g.width,0];L.applyTransform(b,d),m=b[0]*r+S,s.translate(m,0),i.x+=m*c}if(s.restore(),y)this.dependencyTracker=y}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,n,r,a){let o=new Path2D;o.rect(i,n,r-i,a-n),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,i,r,n,a).recordClipBox(t,this.ctx,i,r,n,a),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){let i=this.baseTransform||dt(this.ctx),n={createCanvasGraphics:(r,a)=>new fe(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Ge(this.dependencyTracker,a,!0):null)};s=new He(e,this.ctx,n,i)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t);let s=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=s instanceof He?[0,0,0,0]:null}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,s=null){let i=this.cachedPatterns.getOrInsertComputed(e,()=>Ra(this.getObject(t,e)));if(s)i.matrix=s;return i}shadingFill(t,e){if(!this.contentVisible)return;let s=this.#p(this.current.fillAlpha),i=this.ctx;this.save(t);let n=this._getPattern(t,e);i.fillStyle=n.getPattern(i,this,Yt(i),Ct.SHADING,t);let r=Yt(i);if(r){let{width:a,height:o}=i.canvas,l=de.slice();L.axialAlignedBoundingBox([0,0,a,o],r,l);let[h,c,d,u]=l;this.ctx.fillRect(h,c,d-h,u-c)}else this.ctx.fillRect(-10000000000,-10000000000,20000000000,20000000000);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Ht.transform).recordDependencies(t,Ht.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),this.#v(s)}beginInlineImage(){st("Should not call beginInlineImage")}beginImageData(){st("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){if(!this.contentVisible)return;if(this.save(t),this.baseTransformStack.push(this.baseTransform),e)this.transform(t,...e);if(this.baseTransform=dt(this.ctx),s){L.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);let[i,n,r,a]=s,o=new Path2D;o.rect(i,n,r-i,a-n),this.ctx.clip(o),this.dependencyTracker?.recordClipBox(t,this.ctx,i,r,n,a),this.endPath(t)}}paintFormXObjectEnd(t){if(!this.contentVisible)return;this.restore(t),this.baseTransform=this.baseTransformStack.pop()}beginGroup(t,e){if(!this.contentVisible)return;this.save(t);let{inSMaskMode:s}=this;if(s)this.endSMaskMode(),this.current.activeSMask=null;let i=this.ctx;if((!e.needsIsolation||!e.isolated&&!e.hasSoftMask)&&!e.knockout&&!e.isGray&&this.#e===0&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&!s){if(e.bbox){let S=new Path2D,[A,b,w,x]=e.bbox;if(S.rect(A,b,w-A,x-b),e.matrix){let T=new Path2D;T.addPath(S,new DOMMatrix(e.matrix)),S=T}i.clip(S)}this.groupStack.push(null),this.#u.push(null),this.groupLevel++;return}if(!e.isolated&&!e.knockout&&this.#e===0)Ts("TODO: Fully support non-isolated non-knockout groups.");let n=dt(i);if(e.matrix)i.transform(...e.matrix);let r=[0,0,i.canvas.width,i.canvas.height],a;if(e.bbox)a=de.slice(),L.axialAlignedBoundingBox(e.bbox,dt(i),a),a=L.intersect(a,r)||[0,0,0,0];else a=r;let o=Math.floor(a[0]),l=Math.floor(a[1]),h=Math.max(Math.ceil(a[2])-o,1),c=Math.max(Math.ceil(a[3])-l,1);this.current.startNewPathAndClipBox([0,0,h,c]);let d=this.canvasFactory.create(h,c);if(e.smask)this.smaskGroupCanvases.push(d);let u=d.context,f=e.knockout&&!e.isolated?i:null,p=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&this.#e>0,g=e.knockout?this.canvasFactory.create(h,c):null,m=this.#e;if(e.knockout)this.#e++;else this.#e=0;u.translate(-o,-l),u.transform(...n);let v=!e.isolated&&!e.smask&&e.needsIsolation,y=v&&!s&&m===0&&!e.knockout&&!e.isGray&&e.hasSoftMask&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&this.current.transferMaps==="none";if(v&&(s||y))u.save(),u.setTransform(1,0,0,1,0,0),u.drawImage(i.canvas,-o,-l),u.restore();if(e.bbox){let S=new Path2D,[A,b,w,x]=e.bbox;if(S.rect(A,b,w-A,x-b),e.matrix){let T=new Path2D;T.addPath(S,new DOMMatrix(e.matrix)),S=T}u.clip(S)}if(e.smask)this.smaskStack.push({canvas:d.canvas,context:u,offsetX:o,offsetY:l,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null});if(!e.smask||this.dependencyTracker)i.setTransform(1,0,0,1,0,0),i.translate(o,l),i.save();le(i,u),this.ctx=u,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(i),this.#u.push({backdropCtx:f,savedKnockoutLevel:m,offsetX:o,offsetY:l,hasInnerBackdrop:p,replaceBackdrop:y,knockoutMaskEntry:g,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;let s=this.ctx,i=this.groupStack.pop(),n=this.#u.pop();if(n)this.#e=n.savedKnockoutLevel;if(i===null){this.restore(t);return}if(e.isGray)this.#b(s);if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask){if(this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker){if(this.ctx.restore(),this.inSMaskMode)this.ctx.setTransform(this.suspendedCtx.getTransform())}this.#A(n)}else{this.ctx.restore();let r=dt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...r);let a=de.slice();L.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],r,a);let o=this.#u.at(-1);if(this.#e>0)if(n.hasInnerBackdrop){let{width:l,height:h}=s.canvas,c=this.canvasFactory.create(l,h),d=c.context;d.drawImage(i.canvas,n.offsetX,n.offsetY,l,h,0,0,l,h),d.globalCompositeOperation="source-over",d.drawImage(s.canvas,0,0);let u=this.#g(s.canvas);d.globalCompositeOperation="destination-in",d.drawImage(u.canvas,0,0);let f=this.ctx.globalCompositeOperation,p=this.ctx.globalAlpha,g=this.ctx.filter;if(this.ctx.save(),this.ctx.setTransform(...r),this.ctx.globalAlpha=1,ot.isCanvasFilterSupported)this.ctx.filter="none";if(this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(u.canvas,0,0),this.ctx.globalCompositeOperation=f,this.ctx.globalAlpha=p,ot.isCanvasFilterSupported)this.ctx.filter=g??"none";this.ctx.drawImage(c.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(u),this.canvasFactory.destroy(c)}else{let l=o?.backdropCtx??null;this.#c(this.ctx,s.canvas,{backdropCanvas:l?.canvas??null,destTransform:r,backdropOffset:l?[o.offsetX+n.offsetX,o.offsetY+n.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else{if(n.replaceBackdrop){let l=new Path2D;l.rect(0,0,s.canvas.width,s.canvas.height),this.ctx.clip(l),this.ctx.globalCompositeOperation="copy"}this.ctx.drawImage(s.canvas,0,0)}this.ctx.restore(),this.canvasFactory.destroy({canvas:s.canvas,context:s}),this.#A(n),this.compose(a)}}#b(t){let{canvas:e}=t,{width:s,height:i}=e;if(ot.isCanvasFilterSupported){t.save(),t.setTransform(1,0,0,1,0,0),t.filter="grayscale(1)",t.globalAlpha=1,t.globalCompositeOperation="copy",t.drawImage(e,0,0),t.restore();return}let n=t.getImageData(0,0,s,i),{data:r}=n;for(let a=0,o=r.length;a<o;a+=4){let l=r[a]*0.2126+r[a+1]*0.7152+r[a+2]*0.0722+0.5|0;r[a]=r[a+1]=r[a+2]=l}t.putImageData(n,0,0)}#A(t){if(!t)return;if(t.knockoutMaskEntry)this.canvasFactory.destroy(t.knockoutMaskEntry),t.knockoutMaskEntry=null;if(t.knockoutTempEntry)this.canvasFactory.destroy(t.knockoutTempEntry),t.knockoutTempEntry=null;if(t.knockoutBackdropEntry)this.canvasFactory.destroy(t.knockoutBackdropEntry),t.knockoutBackdropEntry=null}beginAnnotation(t,e,s,i,n,r,a){if(this.#d(),ns(this.ctx),this.ctx.save(),this.save(t),this.baseTransform)this.ctx.setTransform(...this.baseTransform);if(s){let o=s[2]-s[0],l=s[3]-s[1];if(r&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],L.singularValueDecompose2dScale(dt(this.ctx),Bt);let{viewportScale:h}=this,c=Math.ceil(o*this.outputScaleX*h),d=Math.ceil(l*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,d);let{canvas:u,context:f}=this.annotationCanvas;if(a){let p=this.annotationCanvasMap.getOrInsertComputed(e,Ie);u.setAttribute("data-canvas-name",a);let g=p.findIndex((m)=>m.getAttribute("data-canvas-name")===a);if(g===-1)p.push(u);else p[g]=u}else this.annotationCanvasMap.set(e,u);this.annotationCanvas.savedCtx=this.ctx,this.ctx=f,this.ctx.save(),this.ctx.setTransform(Bt[0],0,0,-Bt[1],0,l*Bt[1]),ns(this.ctx)}else{ns(this.ctx),this.endPath(t);let h=new Path2D;h.rect(s[0],s[1],o,l),this.ctx.clip(h)}}this.current=new ni(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...i),this.transform(t,...n),this.baseTransform=dt(this.ctx)}endAnnotation(t){if(this.annotationCanvas)this.ctx.restore(),this.#f(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas;this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){if(!this.contentVisible)return;let s=e.count;e=this.getObject(t,e.data,e),e.count=s;let i=this.#p(this.current.fillAlpha),n=this.ctx,r=this._createMaskCanvas(t,e),a=r.canvas;if(n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(a,r.offsetX,r.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+a.width,r.offsetY,r.offsetY+a.height).recordOperation(t),n.restore(),r.canvasEntry)this.canvasFactory.destroy(r.canvasEntry);this.compose(),this.#v(i)}paintImageMaskXObjectRepeat(t,e,s,i=0,n=0,r,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);let o=this.#p(this.current.fillAlpha),l=this.ctx;l.save();let h=dt(l);l.transform(s,i,n,r,0,0);let c=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]),this.dependencyTracker?.resetBBox(t);for(let d=0,u=a.length;d<u;d+=2){let f=L.transform(h,[s,i,n,r,a[d],a[d+1]]);l.drawImage(c.canvas,f[4],f[5]),this.dependencyTracker?.recordBBox(t,this.ctx,f[4],f[4]+c.canvas.width,f[5],f[5]+c.canvas.height)}if(l.restore(),c.canvasEntry)this.canvasFactory.destroy(c.canvasEntry);this.compose(),this.dependencyTracker?.recordOperation(t),this.#v(o)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;let s=this.#p(this.current.fillAlpha),i=this.ctx,n=this.current.fillColor,r=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,Ht.transformAndFill);for(let a of e){let{data:o,width:l,height:h,transform:c}=a,d=this.canvasFactory.create(l,h),u=d.context;u.save();let f=this.getObject(t,o,a);on(u,f),u.globalCompositeOperation="source-in",u.fillStyle=r?n.getPattern(u,this,Yt(i),Ct.FILL,t):n,u.fillRect(0,0,l,h),u.restore(),i.save(),i.transform(...c),i.scale(1,-1),is(i,d.canvas,0,0,l,h,0,-1,1,1),this.canvasFactory.destroy(d),this.dependencyTracker?.recordBBox(t,i,0,l,0,h),i.restore()}this.compose(),this.dependencyTracker?.recordOperation(t),this.#v(s)}paintImageXObject(t,e){if(!this.contentVisible)return;let s=this.getObject(t,e);if(!s){z("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,n){if(!this.contentVisible)return;let r=this.getObject(t,e);if(!r){z("Dependent image isn't ready yet");return}let{width:a,height:o}=r,l=[];for(let h=0,c=n.length;h<c;h+=2)l.push({transform:[s,0,0,i,n[h],n[h+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,r,l)}applyTransferMapsToCanvas(t){if(this.current.transferMaps!=="none")t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none";return t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return{img:t.bitmap,canvasEntry:null};let{bitmap:e,width:s,height:i}=t,n=this.canvasFactory.create(s,i),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",{img:n.canvas,canvasEntry:n}}paintInlineImageXObject(t,e){if(!this.contentVisible)return;let{width:s,height:i}=e,n=this.#p(this.current.fillAlpha),r=this.ctx;this.save(t);let{filter:a}=r;if(a!=="none"&&a!=="")r.filter="none";r.scale(1/s,-1/i);let o,l=null;if(e.bitmap){let c=this.applyTransferMapsToBitmap(e);o=c.img,l=c.canvasEntry}else{let c=this.canvasFactory.create(s,i);an(c.context,e),o=this.applyTransferMapsToCanvas(c.context),l=c}let h=this._scaleImage(o,Yt(r));if(r.imageSmoothingEnabled=ln(dt(r),e.interpolate),this.dependencyTracker)this.dependencyTracker.resetBBox(t).recordBBox(t,r,0,s,-i,0).recordDependencies(t,Ht.imageXObject).recordOperation(t),this.imagesTracker?.record(r,s,i,this.dependencyTracker.clipBox);if(is(r,h.img,0,0,h.paintWidth,h.paintHeight,0,-i,s,i),h.tmpCanvas)this.canvasFactory.destroy(h.tmpCanvas);if(l)this.canvasFactory.destroy(l);this.compose(),this.restore(t),this.#v(n)}paintInlineImageXObjectGroup(t,e,s){if(!this.contentVisible)return;let i=this.#p(this.current.fillAlpha),n=this.ctx,r,a=null;if(e.bitmap)r=e.bitmap;else{let{width:o,height:l}=e,h=this.canvasFactory.create(o,l);an(h.context,e),r=this.applyTransferMapsToCanvas(h.context),a=h}this.dependencyTracker?.resetBBox(t);for(let o of s)n.save(),n.transform(...o.transform),n.scale(1,-1),is(n,r,o.x,o.y,o.w,o.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,n,0,1,-1,0),n.restore();if(a)this.canvasFactory.destroy(a);this.dependencyTracker?.recordOperation(t),this.compose(),this.#v(i)}paintSolidColorImageMask(t){if(!this.contentVisible)return;let e=this.#p(this.current.fillAlpha);this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Ht.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),this.#v(e)}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){if(this.dependencyTracker?.beginMarkedContent(t),e==="OC")this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)});else this.markedContentStack.push({visible:!0});this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){let i=this.current.isEmptyClip();if(this.pendingClip)this.current.updateClipFromPath();if(!this.pendingClip)this.compose(s);let n=this.ctx;if(this.pendingClip){if(!i)if(this.pendingClip===hn)n.clip(e,"evenodd");else n.clip(e);this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)}else this.dependencyTracker?.recordOperation(t);this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=dt(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform(),r,a;if(s===0&&i===0){let o=Math.abs(e),l=Math.abs(n);if(o===l)if(t===0)r=a=1/o;else{let h=o*t;r=a=h<1?1/h:1}else if(t===0)r=1/o,a=1/l;else{let h=o*t,c=l*t;r=h<1?1/h:1,a=c<1?1/c:1}}else{let o=Math.abs(e*n-s*i),l=Math.hypot(e,s),h=Math.hypot(i,n);if(t===0)r=h/o,a=l/o;else{let c=t*o;r=h>c?h/c:1,a=l>c?l/c:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t,e){let{ctx:s,current:{lineWidth:i}}=this,[n,r]=this.getScaleForStroking();if(n===r){s.lineWidth=(i||1)*n,s.stroke(t);return}let a=fe.#t??=new DOMMatrix,o=s.getLineDash();if(e)s.save();s.scale(n,r),a.a=1/n,a.d=1/r;let l=new Path2D;if(l.addPath(t,a),o.length>0){let h=Math.max(n,r);s.setLineDash(o.map((c)=>c/h)),s.lineDashOffset/=h}if(s.lineWidth=i||1,s.stroke(l),e)s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(let t in Qt)if(fe.prototype[t]!==void 0)fe.prototype[Qt[t]]=fe.prototype[t];class Je{#t=null;#e=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,s){this._source=t,this.#t=e,this.#e=s}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return mt(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#t(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let s=new this.#e(this,t,e);return this._rangeReaders.add(s),s}cancelAllRequests(t){this._fullReader?.cancel(t);for(let e of new Set(this._rangeReaders))e.cancel(t)}}class Qe{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(t){this._stream=t}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}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(){st("Abstract method `read` called")}cancel(t){st("Abstract method `cancel` called")}}class Ze{_stream=null;constructor(t,e,s){this._stream=t}async read(){st("Abstract method `read` called")}cancel(t){st("Abstract method `cancel` called")}}function _a(t){let e=!0,s=i("filename\\*","i").exec(t);if(s){s=s[1];let c=o(s);return c=unescape(c),c=l(c),c=h(c),r(c)}if(s=a(t),s){let c=h(s);return r(c)}if(s=i("filename","i").exec(t),s){s=s[1];let c=o(s);return c=h(c),r(c)}function i(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function n(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{let u=new TextDecoder(c,{fatal:!0}),f=Cs(d);d=u.decode(f),e=!1}catch{}}return d}function r(c){if(e&&/[\x80-\xff]/.test(c)){if(c=n("utf-8",c),e)c=n("iso-8859-1",c)}return c}function a(c){let d=[],u,f=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");while((u=f.exec(c))!==null){let[,g,m,v]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[m,v]}let p=[];for(let g=0;g<d.length;++g){if(!(g in d))break;let[m,v]=d[g];if(v=o(v),m){if(v=unescape(v),g===0)v=l(v)}p.push(v)}return p.join("")}function o(c){if(c.startsWith('"')){let d=c.slice(1).split("\\\"");for(let u=0;u<d.length;++u){let f=d[u].indexOf('"');if(f!==-1)d[u]=d[u].slice(0,f),d.length=u+1;d[u]=d[u].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function l(c){let d=c.indexOf("'");if(d===-1)return c;let u=c.slice(0,d),p=c.slice(d+1).replace(/^[^']*'/,"");return n(u,p)}function h(c){if(!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c))return c;return c.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(d,u,f,p){if(f==="q"||f==="Q")return p=p.replaceAll("_"," "),p=p.replaceAll(/=([0-9a-f]{2})/gi,function(g,m){return String.fromCharCode(parseInt(m,16))}),n(u,p);try{p=atob(p)}catch{}return n(u,p)})}return""}function Zn(t,e){let s=new Headers;if(!t||!e||typeof e!=="object")return s;for(let i in e){let n=e[i];if(n!==void 0)s.append(i,n)}return s}function Ha(t){let e=t.length;while(e>0&&t[e-1]!==" "&&/\s/.test(t[e-1]))e--;return t.slice(0,e)}function Ds(t){return URL.parse(t)?.origin??null}function qn({responseHeaders:t,isHttp:e,rangeChunkSize:s,disableRange:i}){let n={contentLength:0,isRangeSupported:!1},r=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(r))return n;if(n.contentLength=r,r<=2*s)return n;if(i||!e)return n;if(t.get("Accept-Ranges")!=="bytes")return n;if((t.get("Content-Encoding")||"identity")==="identity")n.isRangeSupported=!0;return n}function tr(t){let e=t.get("Content-Disposition");if(e){let s=_a(e);if(s.includes("%"))try{s=decodeURIComponent(s)}catch{}if(hi(s))return s}return null}function ks(t,e){return new Ue(`Unexpected server response (${t}) while retrieving PDF "${e.href}".`,t,t===404||t===0&&e.protocol==="file:")}function er(t,e){if(t!==e)throw Error(`Expected range response-origin "${t}" to match "${e}".`)}function sr(t,e,s,i){return fetch(t,{method:"GET",headers:e,signal:i.signal,mode:"cors",credentials:s?"include":"same-origin",redirect:"follow"})}function ir(t,e){if(t!==200&&t!==206)throw ks(t,e)}function Ls(t){if(t instanceof Uint8Array)return t.buffer;if(t instanceof ArrayBuffer)return t;throw Error(`getArrayBuffer - unexpected data: ${t}`)}class nr extends Je{_responseOrigin=null;constructor(t){super(t,rr,ar);let{httpHeaders:e,url:s}=t;mt(/https?:/.test(s.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=Zn(!0,e)}}class rr extends Qe{_abortController=new AbortController;_reader=null;constructor(t){super(t);let{disableRange:e,disableStream:s,rangeChunkSize:i,url:n,withCredentials:r}=t._source;this._isStreamingSupported=!s;let a=new Headers(t.headers);sr(n,a,r,this._abortController).then((o)=>{t._responseOrigin=Ds(o.url),ir(o.status,n),this._reader=o.body.getReader();let l=o.headers,{contentLength:h,isRangeSupported:c}=qn({responseHeaders:l,isHttp:!0,rangeChunkSize:i,disableRange:e});if(this._contentLength=h,this._isRangeSupported=c,this._filename=tr(l),!this._isStreamingSupported&&this._isRangeSupported)this.cancel(new se("Streaming is disabled."));this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();if(e)return{value:t,done:e};return this._loaded+=t.byteLength,this._callOnProgress(),{value:Ls(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ar extends Ze{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,s){super(t,e,s);let{url:i,withCredentials:n}=t._source,r=new Headers(t.headers);r.append("Range",`bytes=${e}-${s-1}`),sr(i,r,n,this._abortController).then((a)=>{let o=Ds(a.url);er(o,t._responseOrigin),ir(a.status,i),this._reader=a.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();if(e)return{value:t,done:e};return{value:Ls(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}function cn(t){return t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer}function Ns(){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}class or extends Je{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,lr,hr);let{pdfDataRangeTransport:e}=t,{initialData:s,progressiveDone:i}=e;if(s?.length>0){let r=cn(s);this._queuedChunks.push(r)}this._progressiveDone=i;let n=(r)=>{switch(r.type){case"range":case"progressiveRead":this.#t(r.begin,r.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone(),this._progressiveDone=!0;break}};e.transportReady(n)}#t(t,e){let s=cn(e);if(t===void 0)if(this._fullReader)this._fullReader._enqueue(s);else this._queuedChunks.push(s);else{let i=this._rangeReaders.keys().find((n)=>n._begin===t);mt(i,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),i._enqueue(s)}}getFullReader(){let t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){let s=super.getRangeReader(t,e);if(s)s.onDone=()=>this._rangeReaders.delete(s),this._source.pdfDataRangeTransport.requestDataRange(t,e);return s}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class lr extends Qe{#t=Ns.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);let{pdfDataRangeTransport:e,disableRange:s,disableStream:i}=t._source,{length:n,contentDispositionFilename:r}=e;this._queuedChunks=t._queuedChunks||[];for(let o of this._queuedChunks)this._loaded+=o.byteLength;if(this._done=t._progressiveDone,this._contentLength=n,this._isStreamingSupported=!i,this._isRangeSupported=!s,hi(r))this._filename=r;this._headersCapability.resolve();let a=this._loaded;Promise.resolve().then(()=>{if(a>0&&this._loaded===a)this._callOnProgress()})}_enqueue(t){if(this._done)return;if(this._requests.length>0)this._requests.shift().resolve({value:t,done:!1});else this._queuedChunks.push(t);this._loaded+=t.byteLength,this._callOnProgress()}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t()}progressiveDone(){if(this._done||=!0,this._queuedChunks.length===0)this.#t()}}class hr extends Ze{#t=Ns.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,s){super(t,e,s);this._begin=e}_enqueue(t){if(this._done)return;if(this._requests.length===0)this._queuedChunk=t;else this._requests.shift().resolve({value:t,done:!1}),this.#t();this._done=!0,this.onDone?.()}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 t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this.onDone?.()}}var Xs=200,dn=206;function Ua(t){return typeof t!=="string"?t:Cs(t).buffer}class cr extends Je{#t=new WeakMap;_responseOrigin=null;constructor(t){super(t,dr,ur);let{httpHeaders:e,url:s}=t;this.url=s,this.isHttp=/https?:/.test(s.protocol),this.headers=Zn(this.isHttp,e)}_request(t){let e=new XMLHttpRequest,s={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};this.#t.set(e,s),e.open("GET",this.url),e.withCredentials=this._source.withCredentials;for(let[i,n]of this.headers)e.setRequestHeader(i,n);if(this.isHttp&&"begin"in t&&"end"in t)e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.validateStatus=(i)=>i===dn||i===Xs;else s.validateStatus=(i)=>i===Xs;return e.responseType="arraybuffer",mt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#s.bind(this,e),e.onprogress=this.#e.bind(this,e),e.send(null),e}#e(t,e){this.#t.get(t)?.onProgress?.(e)}#s(t,e){let s=this.#t.get(t);if(!s)return;if(t.readyState>=2&&s.onHeadersReceived)s.onHeadersReceived(),delete s.onHeadersReceived;if(t.readyState!==4)return;if(!this.#t.has(t))return;if(this.#t.delete(t),t.status===0&&this.isHttp){s.onError(t.status);return}let i=t.status||Xs;if(!s.validateStatus(i)){s.onError(t.status);return}let n=Ua(t.response);if(i===dn){let r=t.getResponseHeader("Content-Range");if(/bytes \d+-\d+\/\d+/.test(r))s.onDone(n);else z('Missing or invalid "Content-Range" header.'),s.onError(0)}else if(n)s.onDone(n);else s.onError(t.status)}_abortRequest(t){if(this.#t.has(t))this.#t.delete(t),t.abort()}getRangeReader(t,e){let s=super.getRangeReader(t,e);if(s)s.onClosed=()=>this._rangeReaders.delete(s);return s}}class dr extends Qe{#t=Ns.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t);this._fullRequestXhr=t._request({onHeadersReceived:this.#e.bind(this),onDone:this.#s.bind(this),onError:this.#i.bind(this),onProgress:this.#n.bind(this)})}#e(){let t=this._stream,{disableRange:e,rangeChunkSize:s}=t._source,i=this._fullRequestXhr;t._responseOrigin=Ds(i.responseURL);let n=i.getAllResponseHeaders(),r=new Headers(n?Ha(n.trimStart()).split(/[\r\n]+/).map((l)=>{let[h,...c]=l.split(": ");return[h,c.join(": ")]}):[]),{contentLength:a,isRangeSupported:o}=qn({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:s,disableRange:e});if(this._contentLength=a,this._isRangeSupported=o,this._filename=tr(r),this._isRangeSupported)t._abortRequest(i);this._headersCapability.resolve()}#s(t){if(this._requests.length>0)this._requests.shift().resolve({value:t,done:!1});else this._cachedChunks.push(t);if(this._done=!0,this._cachedChunks.length===0)this.#t()}#i(t){this._storedError=ks(t,this._stream.url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#n(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}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 t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t),this.#t(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class ur extends Ze{#t=Ns.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,s){super(t,e,s);this._requestXhr=t._request({begin:e,end:s,onHeadersReceived:this.#e.bind(this),onDone:this.#s.bind(this),onError:this.#i.bind(this),onProgress:null})}#e(){let t=Ds(this._requestXhr?.responseURL);try{er(t,this._stream._responseOrigin)}catch(e){this._storedError=e,this.#i(0)}}#s(t){if(this._requests.length>0)this._requests.shift().resolve({value:t,done:!1});else this._queuedChunk=t;this._done=!0,this.#t(),this.onClosed?.()}#i(t){this._storedError??=ks(t,this._stream.url);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}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 t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function fr(t,e=null){let s=process.getBuiltinModule("fs"),{Readable:i}=process.getBuiltinModule("stream"),n=s.createReadStream(t,e);return i.toWeb(n)}class pr extends Je{constructor(t){super(t,gr,mr);let{url:e}=t;mt(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class gr extends Qe{_reader=null;constructor(t){super(t);let{disableRange:e,disableStream:s,rangeChunkSize:i,url:n}=t._source;this._isStreamingSupported=!s,process.getBuiltinModule("fs/promises").lstat(n).then((a)=>{let o=fr(n);this._reader=o.getReader();let{size:l}=a;if(this._contentLength=l,this._isRangeSupported=!e&&l>2*i,!this._isStreamingSupported&&this._isRangeSupported)this.cancel(new se("Streaming is disabled."));this._headersCapability.resolve()}).catch((a)=>{if(a.code==="ENOENT")a=ks(0,n);this._headersCapability.reject(a)})}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();if(e)return{value:t,done:e};return this._loaded+=t.byteLength,this._callOnProgress(),{value:Ls(t),done:!1}}cancel(t){this._reader?.cancel(t)}}class mr extends Ze{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,s){super(t,e,s);let{url:i}=t._source;try{let n=fr(i,{start:e,end:s-1});this._reader=n.getReader(),this._readCapability.resolve()}catch(n){this._readCapability.reject(n)}}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();if(e)return{value:t,done:e};return{value:Ls(t),done:!1}}cancel(t){this._reader?.cancel(t)}}function ja(t){return Be(t)?nr:Nt?pr:cr}class re{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!=="string")throw Error("Invalid `workerSrc` type.");this.#e=t}}class vr{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}[Symbol.iterator](){return this.#t.entries()}}var he=Symbol("INTERNAL");class yr{#t=!1;#e=!1;#s=!1;#i=!0;constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){this.#t=!!(t&Lt.DISPLAY),this.#e=!!(t&Lt.PRINT),this.name=e,this.intent=s,this.usage=i,this.rbGroups=n}get visible(){if(this.#s)return this.#i;if(!this.#i)return!1;let{print:t,view:e}=this.usage;if(this.#t)return e?.viewState!=="OFF";else if(this.#e)return t?.printState!=="OFF";return!0}_setVisible(t,e,s=!1){if(t!==he)st("Internal method `_setVisible` called.");this.#s=s,this.#i=e}get serializable(){return{userSet:this.#s,visible:this.#i}}}class vi{#t=null;#e=new Map;#s=null;#i=null;#n;creator=null;name=null;constructor(t,e=Lt.DISPLAY,s=null){if(this.#n=t,this.renderingIntent=e,t===null)return;this.name=t.name,this.creator=t.creator,this.#i=t.order;for(let i of t.groups)this.#e.set(i.id,new yr(e,i));if(s){if(s.size!==this.#e.size)st("Incorrect serialized groupState.");for(let[i,n]of s)this.#e.get(i)._setVisible(he,n.visible,n.userSet)}else{if(t.baseState==="OFF")for(let i of this.#e.values())i._setVisible(he,!1);for(let i of t.on)this.#e.get(i)._setVisible(he,!0);for(let i of t.off)this.#e.get(i)._setVisible(he,!1)}this.#s=this.getHash()}#a(t){let e=t.length;if(e<2)return!0;let s=t[0];for(let i=1;i<e;i++){let n=t[i],r;if(Array.isArray(n))r=this.#a(n);else if(this.#e.has(n))r=this.#e.get(n).visible;else return z(`Optional content group not found: ${n}`),!0;switch(s){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return Ts("Optional content group not defined."),!0;if(t.type==="OCG"){if(!this.#e.has(t.id))return z(`Optional content group not found: ${t.id}`),!0;return this.#e.get(t.id).visible}else if(t.type==="OCMD"){if(t.expression)return this.#a(t.expression);if(!t.policy||t.policy==="AnyOn"){for(let e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(let e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(let e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(let e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return z(`Unknown optional content policy ${t.policy}.`),!0}return z(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){let i=this.#e.get(t);if(!i){z(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length){for(let n of i.rbGroups)for(let r of n)if(r!==t)this.#e.get(r)?._setVisible(he,!1,!0)}i._setVisible(he,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let s;for(let i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}let n=this.#e.get(i);if(!n)continue;switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!n.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#s===null||this.getHash()===this.#s}getOrder(){if(!this.#e.size)return null;if(this.#i)return this.#i.slice();return[...this.#e.keys()]}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;let t=new ms;for(let[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}[Symbol.iterator](){return this.#e.entries()}get serializable(){let t=new Map;for(let[e,s]of this.#e)t.set(e,s.serializable);return{data:this.#n,renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:s}){return new vi(t,e,s)}}class br{#t=null;#e=null;#s=0;#i=null;#n=null;get pagesNumber(){return this.#s}set pagesNumber(t){if(this.#s===t)return;this.#s=t,this.#t=null,this.#e=null}#a(){if(this.#t)return;let t=this.#s,e=this.#t=new Uint32Array(t);for(let s=0;s<t;s++)e[s]=s+1;this.#e=new Int32Array(e)}#r(){let t=new Map,e=this.#t;for(let s=0,i=this.#s;s<i;s++){let n=e[s],r=t.get(n);if(r)r.push(s+1);else t.set(n,[s+1])}return t}movePages(t,e,s){this.#a();let i=this.#t,n=e.length,r=new Uint32Array(n),a=0;for(let d=0;d<n;d++){let u=e[d]-1;if(r[d]=i[u],u<s)a++}let o=this.#s,l=o-n,h=new Int32Array(o),c=ut(s-a,0,l);for(let d=0,u=0;d<o;d++)if(!t.has(d+1))i[u]=i[d],h[u++]=d+1;if(i.copyWithin(c+n,c,l),i.set(r,c),h.copyWithin(c+n,c,l),h.set(e,c),this.#e=h,i.every((d,u)=>d===u+1))this.#t=null}deletePages(t){this.#a();let e=this.#t,s=this.#r();this.#n={pageNumberToId:e.slice(),pagesNumber:this.#s,prevPageNumbers:this.#e.slice()};let i=this.#s-t.length;this.#s=i;let n=this.#t=new Uint32Array(i);this.#e=new Int32Array(i);let r=0,a=0;for(let o of t){let l=o-1;if(l!==r)n.set(e.subarray(r,l),a),a+=l-r;r=l+1}if(r<e.length)n.set(e.subarray(r),a);this.#o(s,new Set(t))}cancelDelete(){if(this.#n)this.#t=this.#n.pageNumberToId,this.#s=this.#n.pagesNumber,this.#e=this.#n.prevPageNumbers,this.#n=null}cleanSavedData(){this.#n=null}copyPages(t){this.#a(),this.#i={pageNumbers:t,pageIds:t.map((e)=>this.#t[e-1])}}cancelCopy(){this.#i=null}pastePages(t){this.#a();let e=this.#t,s=this.#r(),{pageNumbers:i,pageIds:n}=this.#i,r=this.#s+i.length;this.#s=r;let a=this.#t=new Uint32Array(r);this.#e=new Int32Array(r),a.set(e.subarray(0,t),0),a.set(n,t),a.set(e.subarray(t),t+i.length),this.#o(s,null,t,i),this.#i=null}#o(t,e=null,s=-1,i=null){let n=this.#e,r=this.#t,a=s+(i?.length??0),o=new Map;for(let l=0,h=this.#s;l<h;l++){if(l>=s&&l<a){n[l]=-i[l-s];continue}let c=r[l],d=t.get(c),u=o.get(c)||0;if(e&&d)while(u<d.length&&e.has(d[u]))u++;n[l]=d?.[u],o.set(c,u+1)}}hasBeenAltered(){return this.#t!==null}#l(t=null){if(!this.#t)return null;let e=new Int32Array(this.#s).fill(-1),s=new Map;if(t)for(let i of t){let n=this.getPageId(i),r=s.get(n)??0;s.set(n,r+1),e[i-1]=r}else for(let i=0,n=this.#s;i<n;i++){let r=this.#t[i],a=s.get(r)??0;s.set(r,a+1),e[i]=a}return e}getPageMappingForSaving(t=null,e=this.#l()){t??=this.#r();let s=0;for(let n of t.values())s=Math.max(s,n.length);let i=Array(s);for(let n=0;n<s;n++)i[n]={document:null,pageIndices:[],includePages:[]};for(let[n,r]of t)for(let a=0,o=r.length;a<o;a++)i[a].includePages.push([n-1,r[a]-1]);for(let{includePages:n,pageIndices:r}of i){n.sort((a,o)=>a[0]-o[0]);for(let a=0,o=n.length;a<o;a++)r.push(n[a][1]),n[a]=n[a][0]}return{pageInfos:i,copyLevels:e}}extractPages(t){t=Array.from(t).sort((s,i)=>s-i);let e=new Map;for(let s=0,i=t.length;s<i;s++){let n=this.getPageId(t[s]);e.getOrInsertComputed(n,Ie).push(s+1)}return this.getPageMappingForSaving(e,this.#l(t))}getPrevPageNumber(t){return this.#e?.[t-1]??0}getPageNumber(t){if(!this.#t)return t;let e=this.#t;for(let s=0,i=this.#s;s<i;s++)if(e[s]===t)return s+1;return 0}getPageId(t){return this.#t?.[t-1]??t}getMapping(){return this.#t?.subarray(0,this.pagesNumber)}}var we=Symbol("INITIAL_DATA"),un=()=>({...Promise.withResolvers(),data:we});class yi{#t=new Map;get(t,e=null){if(e){let i=this.#t.getOrInsertComputed(t,un);return i.promise.then(()=>e(i.data)),null}let s=this.#t.get(t);if(!s||s.data===we)throw Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){let e=this.#t.get(t);return!!e&&e.data!==we}delete(t){let e=this.#t.get(t);if(!e||e.data===we)return!1;return this.#t.delete(t),!0}resolve(t,e=null){let s=this.#t.getOrInsertComputed(t,un);if(s.data!==we)throw Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}clear(){for(let{data:t}of this.#t.values())t?.bitmap?.close();this.#t.clear()}*[Symbol.iterator](){for(let[t,{data:e}]of this.#t)if(e!==we)yield[t,e]}}var $a=1e5,fn=30;class Ot{#t=Promise.withResolvers();#e=null;#s=!1;#i=!!globalThis.FontInspector?.enabled;#n=null;#a=null;#r=null;#o=0;#l=0;#h=null;#u=null;#d=0;#f=0;#g=Object.create(null);#m=[];#c=null;#p=[];#v=new WeakMap;#y=null;static#b=new Map;static#A=new Map;static#x=new WeakMap;static#w=null;static#E=new Set;constructor({textContentSource:t,images:e,container:s,viewport:i}){if(t instanceof ReadableStream)this.#c=t;else if(typeof t==="object")this.#c=new ReadableStream({start(l){l.enqueue(t),l.close()}});else throw Error('No "textContentSource" parameter specified.');this.#e=this.#u=s,this.#n=e,this.#f=i.scale*Wt.pixelRatio,this.#d=i.rotation,this.#r={div:null,properties:null,ctx:null};let{pageWidth:n,pageHeight:r,pageX:a,pageY:o}=i.rawDims;this.#y=[1,0,0,-1,-a,o+r],this.#l=n,this.#o=r,Ot.#R(),s.style.setProperty("--min-font-size",Ot.#w),ge(s,i),this.#t.promise.finally(()=>{Ot.#E.delete(this),this.#r=null,this.#g=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=ot.platform;return j(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){if(this.#n)this.#e.append(this.#n.render());let t=()=>{this.#h.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#a??=e.lang,Object.assign(this.#g,e.styles),this.#T(e.items),t()},this.#t.reject)};return this.#h=this.#c.getReader(),Ot.#E.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){let s=t.scale*Wt.pixelRatio,i=t.rotation;if(i!==this.#d)e?.(),this.#d=i,ge(this.#u,{rotation:i});if(s!==this.#f){e?.(),this.#f=s;let n={div:null,properties:null,ctx:Ot.#I(this.#a)};for(let r of this.#p)n.properties=this.#v.get(r),n.div=r,this.#P(n)}}cancel(){let t=new se("TextLayer task cancelled.");this.#h?.cancel(t).catch(()=>{}),this.#h=null,this.#t.reject(t)}get textDivs(){return this.#p}get textContentItemsStr(){return this.#m}#T(t){if(this.#s)return;this.#r.ctx??=Ot.#I(this.#a);let e=this.#p,s=this.#m;for(let i of t){if(e.length>$a){z("Ignoring additional textDivs for performance reasons."),this.#s=!0;return}if(i.str===void 0){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){let n=this.#e;if(this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),i.id)this.#e.setAttribute("id",i.id);if(i.tag==="Artifact")this.#e.ariaHidden=!0;n.append(this.#e)}else if(i.type==="endMarkedContent")this.#e=this.#e.parentNode;continue}s.push(i.str),this.#O(i)}}#O(t){let e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#p.push(e);let i=L.transform(this.#y,t.transform),n=Math.atan2(i[1],i[0]),r=this.#g[t.fontName];if(r.vertical)n+=Math.PI/2;let a=this.#i&&r.fontSubstitution||r.fontFamily;a=Ot.fontFamilyMap.get(a)||a;let o=Math.hypot(i[2],i[3]),l=o*Ot.#k(a,r,this.#a),h,c;if(n===0)h=i[4],c=i[5]-l;else h=i[4]+l*Math.sin(n),c=i[5]-l*Math.cos(n);let d=e.style;if(d.left=`${(100*h/this.#l).toFixed(2)}%`,d.top=`${(100*c/this.#o).toFixed(2)}%`,d.setProperty("--font-height",`${o.toFixed(2)}px`),d.fontFamily=a,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#i)e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName;if(n!==0)s.angle=n*(180/Math.PI);let u=!1;if(t.str.length>1)u=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){let f=Math.abs(t.transform[0]),p=Math.abs(t.transform[3]);if(f!==p&&Math.max(f,p)/Math.min(f,p)>1.5)u=!0}if(u)s.canvasWidth=r.vertical?t.height:t.width;if(this.#v.set(e,s),this.#r.div=e,this.#r.properties=s,this.#P(this.#r),s.hasText)this.#e.append(e);if(s.hasEOL){let f=document.createElement("br");f.setAttribute("role","presentation"),this.#e.append(f)}}#P(t){let{div:e,properties:s,ctx:i}=t,{style:n}=e;if(s.canvasWidth!==0&&s.hasText){let{fontFamily:r}=n,{canvasWidth:a,fontSize:o}=s;Ot.#D(i,o*this.#f,r);let{width:l}=i.measureText(e.textContent);if(l>0)n.setProperty("--scale-x",a*this.#f/l)}if(s.angle!==0)n.setProperty("--rotate",`${s.angle}deg`)}static cleanup(){if(this.#E.size>0)return;this.#b.clear();for(let{canvas:t}of this.#A.values())t.remove();this.#A.clear()}static#I(t=null){let e=this.#A.get(t||="");if(!e){let s=document.createElement("canvas");s.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#A.set(t,e),this.#x.set(e,{size:0,family:""})}return e}static#D(t,e,s){let i=this.#x.get(t);if(e===i.size&&s===i.family)return;t.font=`${e}px ${s}`,i.size=e,i.family=s}static#R(){if(this.#w!==null)return;let t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#w=t.getBoundingClientRect().height,t.remove()}static#k(t,e,s){let i=this.#b.get(t);if(i)return i;let n=this.#I(s);n.canvas.width=n.canvas.height=fn,this.#D(n,fn,t);let r=n.measureText(""),a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let l=0.8;if(a)l=a/(a+o);else{if(ot.platform.isFirefox)z("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering.");if(e.ascent)l=e.ascent;else if(e.descent)l=1+e.descent}return this.#b.set(t,l),l}}var Ga=100;function bi(t={}){let e=new Ai,{docId:s}=e,i=t.url?ba(t.url):null,n=t.data?Aa(t.data):null,r=t.httpHeaders||null,a=t.withCredentials===!0,o=t.password??null,l=t.range instanceof Si?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536,c=t.worker instanceof Tt?t.worker:null,d=t.verbosity,u=typeof t.docBaseUrl==="string"&&!Ps(t.docBaseUrl)?t.docBaseUrl:null,f=es(t.cMapUrl),p=t.cMapPacked!==!1,g=es(t.iccUrl),m=es(t.standardFontDataUrl),v=es(t.wasmUrl),y=t.stopAtErrors!==!0,S=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,A=typeof t.isOffscreenCanvasSupported==="boolean"?t.isOffscreenCanvasSupported:!Nt,b=typeof t.isImageDecoderSupported==="boolean"?t.isImageDecoderSupported:!Nt,w=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,x=typeof t.disableFontFace==="boolean"?t.disableFontFace:Nt,T=t.fontExtraProperties===!0,E=t.enableXfa===!0,I=t.ownerDocument||globalThis.document,C=t.disableRange===!0,O=t.disableStream===!0,D=t.disableAutoFetch===!0,k=t.pdfBug===!0,R=t.CanvasFactory||(Nt?zn:$n),M=t.FilterFactory||(Nt?Vn:Gn),_=t.BinaryDataFactory||(Nt?Wn:ii),U=t.enableHWA===!0,it=t.enableWebGPU===!0?Ca():Promise.resolve(!1),rt=t.useWasm!==!1,J=t.pagesMapper||new br,et=typeof t.useSystemFonts==="boolean"?t.useSystemFonts:!Nt&&!x,ht=typeof t.useWorkerFetch==="boolean"?t.useWorkerFetch:!!(_===ii&&f&&p&&m&&v&&Be(f,document.baseURI)&&Be(m,document.baseURI)&&Be(v,document.baseURI)),Rt=null;ea(d);let N={canvasFactory:new R({ownerDocument:I,enableHWA:U}),filterFactory:new M({docId:s,ownerDocument:I}),binaryDataFactory:ht?null:new _({cMapUrl:f,standardFontDataUrl:m,wasmUrl:v})};if(!c)c=Tt.create({verbosity:d,port:re.workerPort}),e._worker=c;let P={docId:s,apiVersion:"6.3.289",data:n,password:o,disableAutoFetch:D,rangeChunkSize:h,docBaseUrl:u,enableXfa:E,evaluatorOptions:{maxImageSize:S,disableFontFace:x,ignoreErrors:y,isOffscreenCanvasSupported:A,isImageDecoderSupported:b,canvasMaxAreaInBytes:w,fontExtraProperties:T,useSystemFonts:et,useWasm:rt,useWorkerFetch:ht,cMapUrl:f,cMapPacked:p,iccUrl:g,standardFontDataUrl:m,wasmUrl:v,hasGPU:!1}},F={ownerDocument:I,pdfBug:k,styleElement:Rt,enableHWA:U,loadingParams:{disableAutoFetch:D,enableXfa:E}};return Promise.all([c.promise,it]).then(function([,X]){if(c.destroyed)throw Error("Worker was destroyed");P.evaluatorOptions.hasGPU=X;let nt=c.messageHandler.sendWithPromise("GetDocRequest",P,n?[n.buffer]:null),V;if(n);else if(l)V=new or({pdfDataRangeTransport:l,disableRange:C,disableStream:O});else if(i)V=new(ja(i))({url:i,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:C,disableStream:O});else throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");return nt.then((Z)=>{if(c.destroyed)throw Error("Worker was destroyed");let lt=new Ee(s,Z,c.port),xt=new Sr(lt,e,V,F,N,J);if(e._transport=xt,e.destroyed)throw Error("Loading aborted");lt.send("Ready",null)})}).catch(e._capability.reject).finally(e._setupCapability.resolve),e}class Ai{static#t=0;_capability=Promise.withResolvers();_setupCapability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${Ai.#t++}`;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0,this._capability.promise.catch(()=>{});try{if(this._worker?.port)this._worker._pendingDestroy=!0;await this._setupCapability.promise,await this._transport?.destroy()}catch(t){if(this._worker?.port)delete this._worker._pendingDestroy;throw t}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class Si{#t=Promise.withResolvers();#e=null;constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}onDataRange(t,e){this.#e({type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){this.#t.promise.then(()=>{this.#e({type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){this.#t.promise.then(()=>{this.#e({type:"progressiveDone"})})}transportReady(t){this.#e=t,this.#t.resolve()}requestDataRange(t,e){st("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Ar{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}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 j(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}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()}getAttachmentContent(t){return this._transport.getAttachmentContent(t)}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}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()}extractPages(t,e=null){return this._transport.extractPages(t,e)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}getSignatures(){return this._transport.getSignatures()}getSignatureData(t){return this._transport.getSignatureData(t)}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class wi{#t=!1;#e=null;constructor(t,e,s,i,n=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=n?new Qs:null,this._pdfBug=n,this.commonObjs=s.commonObjs,this.objs=new yi,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#e=i,this.imageCoordinates=null}clone(t){let e=new wi(t,this._pageInfo,this._transport,this.#e,this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}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:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new Xe({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return j(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:n=ne.ENABLE,transform:r=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:c=null,isEditing:d=!1,recordImages:u=!1,recordOperations:f=!1,operationsFilter:p=null}){this._stats?.time("Overall");let g=this._transport.getRenderingIntent(i,n,c,d),{renderingIntent:m,cacheKey:v}=g;this.#t=!1,o||=this._transport.getOptionalContentConfig(m);let y=this._intentStates.getOrInsertComputed(v,Js);if(y.streamReaderCancelTimeout)clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null;let S=!!(m&Lt.PRINT);if(!y.displayReadyCapability)y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(g);let A=!!(this._pdfBug&&globalThis.StepperManager?.enabled),b=!!e&&!this.recordedBBoxes&&(f||A),w=!!e&&!this.imageCoordinates&&u,x=(O)=>{if(y.renderTasks.delete(I),b){let D=I.gfx?.dependencyTracker.take();if(D){if(I.stepper?.setOperatorBBoxes(D,I.gfx.dependencyTracker.takeDebugMetadata()),f)this.recordedBBoxes=D}}if(w&&!O)this.imageCoordinates=I.gfx?.imagesTracker.take();if(S)this.#t=!0;if(this.#s(),O)I.capability.reject(O),this._abortOperatorList({intentState:y,reason:O instanceof Error?O:Error(O)});else I.capability.resolve();if(this._stats){if(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled)globalThis.Stats.add(this.pageNumber,this._stats)}},T=null,E=null;if(b||w)E=new On(e,y.operatorList.length);if(b)T=new Rn(E,A);let I=new Te({callback:x,params:{canvas:e,canvasContext:t,dependencyTracker:T??E,imagesTracker:w?new vs(e):null,viewport:s,transform:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:y.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!S,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:p});(y.renderTasks||=new Set).add(I);let C=I.task;return Promise.all([y.displayReadyCapability.promise,o]).then(([O,D])=>{if(this.destroyed){x();return}if(this._stats?.time("Rendering"),!(D.renderingIntent&m))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");I.initializeGraphics({transparency:O,optionalContentConfig:D}),I.operatorListChanged()}).catch(x),C}getOperatorList({intent:t="display",annotationMode:e=ne.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){function n(){if(a.operatorList.lastChunk)a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(o)}let r=this._transport.getRenderingIntent(t,e,s,i,!0),a=this._intentStates.getOrInsertComputed(r.cacheKey,Js),o;if(!a.opListReadCapability)o=Object.create(null),o.operatorListChanged=n,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(o),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r);return a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((i)=>je.textContent(i));let e=this.streamTextContent(t),s={items:[],styles:Object.create(null),lang:null};for await(let i of e)s.lang??=i.lang,Object.assign(s.styles,i.styles),s.items.push(...i.items);return s}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values()){if(this._abortOperatorList({intentState:e,reason:Error("Page was destroyed."),force:!0}),e.opListReadCapability)continue;for(let s of e.renderTasks)t.push(s.completed),s.cancel()}return this.objs.clear(),this.#t=!1,Promise.all(t)}cleanup(t=!1){this.#t=!0;let e=this.#s();if(t&&e)this._stats&&=new Qs;return e}#s(){if(!this.#t||this.destroyed)return!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#t=!1,!0}_startRenderPage(t,e){let s=this._intentStates.get(e);if(!s)return;this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t)}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(let s of e.renderTasks)s.operatorListChanged();if(t.lastChunk)this.#s()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){let{map:n,transfer:r}=s,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:i},void 0,r).getReader(),l=this._intentStates.get(e);l.streamReader=o;let h=()=>{o.read().then(({value:c,done:d})=>{if(d){l.streamReader=null;return}if(this._transport.destroyed)return;this._renderPageChunk(c,l),h()},(c)=>{if(l.streamReader=null,this._transport.destroyed)return;if(l.operatorList){l.operatorList.lastChunk=!0;for(let d of l.renderTasks)d.operatorListChanged();this.#s()}if(l.displayReadyCapability)l.displayReadyCapability.reject(c);else if(l.opListReadCapability)l.opListReadCapability.reject(c);else throw c})};h()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(!t.streamReader)return;if(t.streamReaderCancelTimeout)clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null;if(!s){if(t.renderTasks.size>0)return;if(e instanceof Is){let i=Ga;if(e.extraDelay>0&&e.extraDelay<1000)i+=e.extraDelay;t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new se(e.message)).catch(()=>{}),t.streamReader=null,this._transport.destroyed)return;for(let[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}get stats(){return this._stats}}class Tt{#t=Promise.withResolvers();#e=null;#s=null;#i=null;static#n=0;static#a=!1;static#r=new WeakMap;static{if(Nt)this.#a=!0,re.workerSrc||="./pdf.worker.mjs";this._isSameOrigin=(t,e)=>{let s=URL.parse(t);if(!s?.origin||s.origin==="null")return!1;let i=new URL(e,s);return s.origin===i.origin},this._createCDNWrapper=(t)=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:s=sa()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(Tt.#r.has(e))throw Error("Cannot use more than one PDFWorker per port.");Tt.#r.set(e,this),this.#l(e)}else this.#h()}get promise(){return this.#t.promise}#o(){this.#t.resolve(),this.#e.send("configure",{verbosity:this.verbosity})}get port(){return this.#s}get messageHandler(){return this.#e}#l(t){this.#s=t,this.#e=new Ee("main","worker",t),this.#e.on("ready",()=>{}),this.#o()}#h(){if(Tt.#a||Tt.#d){this.#u();return}let{workerSrc:t}=Tt;try{if(!Tt._isSameOrigin(window.location,t))t=Tt._createCDNWrapper(new URL(t,window.location).href);let e=new Worker(t,{type:"module"}),s=new Ee("main","worker",e),i=()=>{if(n.abort(),s.destroy(),e.terminate(),this.destroyed)this.#t.reject(Error("Worker was destroyed"));else this.#u()},n=new AbortController;e.addEventListener("error",()=>{if(!this.#i)i()},{signal:n.signal}),s.on("test",(a)=>{if(n.abort(),this.destroyed||!a){i();return}this.#e=s,this.#s=e,this.#i=e,this.#o()}),s.on("ready",(a)=>{if(n.abort(),this.destroyed){i();return}try{r()}catch{this.#u()}});let r=()=>{let a=new Uint8Array;s.send("test",a,[a.buffer])};r();return}catch{Ts("The worker has been disabled.")}this.#u()}#u(){if(!Tt.#a)z("Setting up fake worker."),Tt.#a=!0;Tt._setupFakeWorkerGlobal.then((t)=>{if(this.destroyed){this.#t.reject(Error("Worker was destroyed"));return}let e=new jn;this.#s=e;let s=`fake${Tt.#n++}`,i=new Ee(s+"_worker",s,e);t.setup(i,e),this.#e=new Ee(s,s+"_worker",e),this.#o()}).catch((t)=>{this.#t.reject(Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#i?.terminate(),this.#i=null,Tt.#r.delete(this.#s),this.#s=null,this.#e?.destroy(),this.#e=null}static create(t){let e=this.#r.get(t?.port);if(e){if(e._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Tt(t)}static get workerSrc(){if(re.workerSrc)return re.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#d(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return j(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#d)return this.#d;return(await import(this.workerSrc)).WorkerMessageHandler})())}}class Sr{downloadInfoCapability=Promise.withResolvers();#t=null;#e=new Map;#s=null;#i=new Map;#n=new Map;#a=new Map;#r=null;constructor(t,e,s,i,n,r){this.messageHandler=t,this.loadingTask=e,this.#s=s,this.commonObjs=new yi,this.fontLoader=new Dn({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.enableHWA=i.enableHWA,this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.binaryDataFactory=n.binaryDataFactory,this.pagesMapper=r,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){let{_pageIndex:e}=t;this.#i.set(e,t),this.#n.set(e,Promise.resolve(t))}#o(t,e=null){return this.#e.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))}#l({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:e?ut(Math.round(t/e*100),0,100):NaN})}get annotationStorage(){return j(this,"annotationStorage",new Ms)}getRenderingIntent(t,e=ne.ENABLE,s=null,i=!1,n=!1){let r=Lt.DISPLAY,a=$e;switch(t){case"any":r=Lt.ANY;break;case"display":break;case"print":r=Lt.PRINT;break;default:z(`getRenderingIntent - invalid intent: ${t}`)}let o=r&Lt.PRINT&&s instanceof fi?s:this.annotationStorage;switch(e){case ne.DISABLE:r+=Lt.ANNOTATIONS_DISABLE;break;case ne.ENABLE:break;case ne.ENABLE_FORMS:r+=Lt.ANNOTATIONS_FORMS;break;case ne.ENABLE_STORAGE:r+=Lt.ANNOTATIONS_STORAGE,a=o.serializable;break;default:z(`getRenderingIntent - invalid annotationMode: ${e}`)}if(i)r+=Lt.IS_EDITING;if(n)r+=Lt.OPLIST;let{ids:l,hash:h}=o.modifiedIds,c=[r,a.hash,h];return{renderingIntent:r,cacheKey:c.join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#r?.reject(Error("Worker was destroyed during onPassword callback"));let t=[];for(let s of this.#i.values())t.push(s._destroy());if(this.#i.clear(),this.#n.clear(),this.#a.clear(),Object.hasOwn(this,"annotationStorage"))this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(),Ot.cleanup(),this.#s?.cancelAllRequests(new se("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{mt(this.#s,"GetReader - no `BasePDFStream` instance available."),this.#t=this.#s.getFullReader(),this.#t.onProgress=(n)=>this.#l(n),i.onPull=()=>{this.#t.read().then(function({value:n,done:r}){if(r){i.close();return}mt(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch((n)=>{i.error(n)})},i.onCancel=(n)=>{this.#t.cancel(n),i.ready.catch((r)=>{if(this.destroyed)return;throw r})}}),t.on("ReaderHeadersReady",async(s)=>{await this.#t.headersReady;let{isStreamingSupported:i,isRangeSupported:n,contentLength:r}=this.#t;if(i&&n)this.#t.onProgress=null;return{isStreamingSupported:i,isRangeSupported:n,contentLength:r}}),t.on("GetRangeReader",(s,i)=>{mt(this.#s,"GetRangeReader - no `BasePDFStream` instance available.");let n=this.#s.getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:r,done:a}){if(a){i.close();return}mt(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch((r)=>{i.error(r)})},i.onCancel=(r)=>{n.cancel(r),i.ready.catch((a)=>{if(this.destroyed)return;throw a})}}),t.on("GetDoc",({pdfInfo:s})=>{this.pagesMapper.pagesNumber=s.numPages,this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new Ar(s,this))}),t.on("DocException",(s)=>{e._capability.reject(Dt(s))}),t.on("PasswordRequest",(s)=>{this.#r=Promise.withResolvers();try{if(!e.onPassword)throw Dt(s);let i=(n)=>{if(n instanceof Error)this.#r.reject(n);else this.#r.resolve({password:n})};e.onPassword(i,s.code)}catch(i){this.#r.reject(i)}return this.#r.promise}),t.on("DataLoaded",(s)=>{this.#l({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",(s)=>{if(this.destroyed)return;this.#i.get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{if(this.destroyed)return null;if(this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in n){let c=n.error;z(`Error during font loading: ${c}`),this.commonObjs.resolve(s,c);break}let r=new _n(n),a=this._params.pdfBug&&globalThis.FontInspector?.enabled?(c,d)=>globalThis.FontInspector.fontAdded(c,d):null,o=new kn(r,a,n.charProcOperatorList,n.extra);this.fontLoader.bind(o).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{if(!o.fontExtraProperties)o.clearData();this.commonObjs.resolve(s,o)});break;case"CopyLocalImage":let{imageRef:l}=n;mt(l,"The imageRef must be defined.");for(let c of this.#i.values())for(let[,d]of c.objs){if(d?.ref!==l)continue;if(!d.dataLen)return null;let u=structuredClone(d);return this.commonObjs.resolve(s,u),d.dataLen}break;case"FontPath":this.commonObjs.resolve(s,new Un(n));break;case"Image":this.commonObjs.resolve(s,n);break;case"Pattern":let h=new Hn(n);this.commonObjs.resolve(s,h.getIR());break;default:throw Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,r])=>{if(this.destroyed)return;let a=this.#i.get(i);if(a.objs.has(s))return;if(a._intentStates.size===0){r?.bitmap?.close();return}switch(n){case"Image":case"Pattern":a.objs.resolve(s,r);break;default:throw Error(`Got unknown object type ${n}`)}}),t.on("DocProgress",(s)=>{if(this.destroyed)return;this.#l(s)}),t.on("FetchBinaryData",async(s)=>{if(this.destroyed)throw Error("Worker was destroyed.");if(!this.binaryDataFactory)throw Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){if(this.annotationStorage.size<=0)z("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this.#t?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t,e=null){let s={pageInfos:t},i,n=globalThis.ImageBitmap;if(typeof n==="function"){let r=Array.isArray(t)?t:[t];for(let a of r)if(a?.image instanceof n)(i||=[]).push(a.image)}if(this.annotationStorage.size>0){let r=this.annotationStorage.serializable,{map:a}=r;if(r.transfer?.length)if(i)i.push(...r.transfer);else i=r.transfer;let o=this.pagesMapper.getMapping();if(o){let l=new Map;for(let[h,c]of a){if(c?.pageIndex!==void 0&&c.pageIndex>=0&&c.pageIndex<o.length){let d=e?.[c.pageIndex]??0,u=o[c.pageIndex]-1;if(u!==c.pageIndex||d!==0){l.set(h,{...c,pageIndex:u,copyLevel:d});continue}}l.set(h,c)}a=l}s.annotationStorage=a}return this.messageHandler.sendWithPromise("ExtractPages",s,i).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(Error("Invalid page request."));let e=t-1,s=this.pagesMapper.getPageId(t)-1,i=this.#n.get(e);if(i)return i;let n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then((r)=>{if(this.destroyed)throw Error("Transport destroyed");if(r.refStr)this.#a.set(r.refStr,s);let a=new wi(e,r,this,this.pagesMapper,this._params.pdfBug);return this.#i.set(e,a),a});return this.#n.set(e,n),n}async getPageIndex(t){if(!si(t))throw Error("Invalid pageIndex request.");let e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),s=this.pagesMapper.getPageNumber(e+1);if(s===0)throw Error("GetPageIndex: page has been removed.");return s-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#o("GetFieldObjects")}getSignatures(){return this.#o("GetSignatures")}getSignatureData(t){return this.messageHandler.sendWithPromise("GetSignatureData",t)}hasJSActions(){return this.#o("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){if(typeof t!=="string")return Promise.reject(Error("Invalid destination request."));return this.messageHandler.sendWithPromise("GetDestination",{id:t})}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)}getAttachmentContent(t){return this.messageHandler.sendWithPromise("GetAttachmentContent",t)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#o("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#o("GetOptionalContentConfig").then((e)=>new vi(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){return this.#e.getOrInsertComputed("GetMetadata",()=>this.messageHandler.sendWithPromise("GetMetadata",null).then((e)=>({info:e[0],metadata:e[1]?new vr(e[1]):null,contentDispositionFilename:this.#t?.filename??null,contentLength:this.#t?.contentLength??null,hasStructTree:e[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(this.destroyed)return;await this.messageHandler.sendWithPromise("Cleanup",null);for(let e of this.#i.values())if(!e.cleanup())throw Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);if(this.commonObjs.clear(),!t)this.fontLoader.clear();this.#e.clear(),this.filterFactory.destroy(!0),Ot.cleanup()}cachedPageNumber(t){if(!si(t))return null;let e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=this.#a.get(e);if(s>=0){let i=this.pagesMapper.getPageNumber(s+1);if(i!==0)return i}return null}}class wr{_internalRenderTask=null;onContinue=null;onError=null;constructor(t){this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&e?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}class Te{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:c=!1,pageColors:d=null,enableHWA:u=!1,operationsFilter:f=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=c,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new wr(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=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,this._operationsFilter=f}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(Te.#e.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.");Te.#e.add(this._canvas)}if(this._pdfBug&&globalThis.StepperManager?.enabled)this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint();let{viewport:s,transform:i,background:n,dependencyTracker:r,imagesTracker:a}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new fe(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,r,a),this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:n}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){if(this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t)window.cancelAnimationFrame(this.#t),this.#t=null;Te.#e.delete(this._canvas),t||=new Is(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}if(this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.updateOperatorList(this.operatorList),this.running)return;this._continue()}_continue(){if(this.running=!0,this.cancelled)return;if(this.task.onContinue)this.task.onContinue(this._scheduleNextBound);else this._scheduleNext()}_scheduleNext(){if(this._useRequestAnimationFrame)this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)});else Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){if(this.cancelled)return;if(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length){if(this.running=!1,this.operatorList.lastChunk)this.gfx.endDrawing(),Te.#e.delete(this._canvas),this.callback()}}}var Va="6.3.289",za="1c8020a7d",Mo=K(3068);class jt{#t=null;#e=null;#s;#i=null;#n=!1;#a=!1;#r=null;#o;#l=null;#h=null;static#u=null;static get _keyboardManager(){return j(this,"_keyboardManager",new Ft([[["Escape"],jt.prototype._hideDropdownFromKeyboard],[["Space"],jt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],jt.prototype._moveToNext],[["ArrowUp","ArrowLeft"],jt.prototype._moveToPrevious],[["Home"],jt.prototype._moveToBeginning],[["End"],jt.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){if(t)this.#a=!1,this.#r=t;else this.#a=!0;this.#h=t?._uiManager||e,this.#o=this.#h._eventBus,this.#s=t?.color?.toUpperCase()||this.#h?.highlightColors.values().next().value||"#FFFF98",jt.#u||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let t=this.#t=document.createElement("button");if(t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#r)t.ariaControls=`${this.#r.id}_colorpicker_dropdown`;let e=this.#h._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#g.bind(this),{signal:e});let s=this.#e=document.createElement("span");return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=this.#s,t.append(s),t}renderMainDropdown(){let t=this.#i=this.#d();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#d(){let t=document.createElement("div"),e=this.#h._signal;if(t.addEventListener("contextmenu",zt,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#r)t.id=`${this.#r.id}_colorpicker_dropdown`;for(let[s,i]of this.#h.highlightColors){let n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",jt.#u[s]);let r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=i,n.ariaSelected=i===this.#s,n.addEventListener("click",this.#f.bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#g.bind(this),{signal:e}),t}#f(t,e){e.stopPropagation(),this.#o.dispatch("switchannotationeditorparams",{source:this,type:q.HIGHLIGHT_COLOR,value:t}),this.update(t)}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#m(t);return}let e=t.target.getAttribute("data-color");if(!e)return;this.#f(e,t)}_moveToNext(t){if(!this.#p){this.#m(t);return}if(t.target===this.#t){this.#i.firstElementChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#i?.firstElementChild||t.target===this.#t){if(this.#p)this._hideDropdownFromKeyboard();return}if(!this.#p)this.#m(t);t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#p){this.#m(t);return}this.#i.firstElementChild?.focus()}_moveToEnd(t){if(!this.#p){this.#m(t);return}this.#i.lastElementChild?.focus()}#g(t){jt._keyboardManager.exec(this,t)}#m(t){if(this.#p){this.hideDropdown();return}if(this.#n=t.detail===0,!this.#l)this.#l=new AbortController,window.addEventListener("pointerdown",this.#c.bind(this),{signal:this.#h.combinedSignal(this.#l)});if(this.#t.ariaExpanded="true",this.#i){this.#i.classList.remove("hidden");return}let e=this.#i=this.#d();this.#t.append(e)}#c(t){if(this.#i?.contains(t.target))return;this.hideDropdown()}hideDropdown(){this.#i?.classList.add("hidden"),this.#t.ariaExpanded="false",this.#l?.abort(),this.#l=null}get#p(){return this.#i&&!this.#i.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(this.#a)return;if(!this.#p){this.#r?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#n})}update(t){if(this.#e)this.#e.style.backgroundColor=t;if(!this.#i)return;let e=this.#h.highlightColors.values();for(let s of this.#i.children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#i?.remove(),this.#i=null}}class ze{#t=null;#e=!1;#s=null;#i=null;static#n=null;constructor(t){this.#s=t,this.#i=t._uiManager,ze.#n||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#t)return this.#t;let{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:i,color:n,opacity:r}=this.#s,a=this.#e=ot.isAlphaColorInputSupported&&i!==void 0,o=this.#t=document.createElement("input");if(o.type="color",a){o.setAttribute("alpha","");let l=L.hexNums[Math.round((r??1)*255)];o.value=(n||"#000000")+l}else o.value=n||"#000000";return o.className="basicColorPicker",o.tabIndex=0,o.setAttribute("data-l10n-id",ze.#n[t]),o.addEventListener("input",()=>{if(a){let l=Ye(o.value);if(!l)return;let[h,c,d,u]=l,f=L.makeHexColor(h,c,d);if(s!==void 0)this.#i.updateParams(s,{color:f,opacity:u});else this.#i.updateParams(e,f),this.#i.updateParams(i,u)}else this.#i.updateParams(e,o.value)},{signal:this.#i._signal}),o}update(t){if(!this.#t)return;if(this.#e){let e=L.hexNums[Math.round(this.#s.opacity*255)];this.#t.value=t+e}else this.#t.value=t}updateOpacity(t){if(!this.#t||!this.#e)return;let e=L.hexNums[Math.round(t*255)];this.#t.value=this.#s.color+e}destroy(){this.#t?.remove(),this.#t=null}hideDropdown(){}}var Oo=K(531);function pn(t){return Math.floor(ut(t,0,1)*255).toString(16).padStart(2,"0")}function Le(t){return ut(t,0,1)*255}class ri{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,0.3*t+0.59*s+0.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=Le(t),[t,t,t]}static G_HTML([t]){let e=pn(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",0.3*t+0.59*e+0.11*s]}static RGB_rgb(t){return t.map(Le)}static RGB_HTML(t){return`#${t.map(pn).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[Le(1-Math.min(1,t+i)),Le(1-Math.min(1,s+i)),Le(1-Math.min(1,e+i))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){let i=1-t,n=1-e,r=1-s,a=Math.min(i,n,r);return["CMYK",i,n,r,a]}}class xr{create(t,e,s=!1){if(t<=0||e<=0)throw Error("Invalid SVG dimensions");let i=this._createSVG("svg:svg");if(i.setAttribute("version","1.1"),!s)i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`);return i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!=="string")throw Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){st("Abstract method `_createSVG` called.")}}class We extends xr{_createSVG(t){return document.createElementNS(Mt,t)}}var Wa=9,me=new WeakSet,Xa=new Date().getTimezoneOffset()*60*1000;class us{static create(t){switch(t.data.annotationType){case gt.LINK:return new Fs(t);case gt.TEXT:return new Tr(t);case gt.WIDGET:switch(t.data.fieldType){case"Tx":return new Cr(t);case"Btn":if(t.data.radioButton)return new Mr(t);else if(t.data.checkBox)return new Pr(t);return new Or(t);case"Ch":return new Rr(t);case"Sig":return new Ir(t)}return new oe(t);case gt.POPUP:return new ys(t);case gt.FREETEXT:return new xi(t);case gt.LINE:return new kr(t);case gt.SQUARE:return new Lr(t);case gt.CIRCLE:return new Nr(t);case gt.POLYLINE:return new Ei(t);case gt.CARET:return new Br(t);case gt.INK:return new Bs(t);case gt.POLYGON:return new Fr(t);case gt.HIGHLIGHT:return new Ti(t);case gt.UNDERLINE:return new _r(t);case gt.SQUIGGLY:return new Hr(t);case gt.STRIKEOUT:return new Ur(t);case gt.STAMP:return new Ci(t);case gt.FILEATTACHMENT:return new jr(t);case gt.RICHMEDIA:case gt.SCREEN:case gt.SOUND:return new Ii(t);default:return new ft(t)}}}class ft{#t=null;#e=!1;#s=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){if(this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e)this.contentElement=this.container=this._createContainer(s);if(i)this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return ft._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:t}=this,e=this.annotationStorage?.getEditor(t.id);if(e)return e.getData();return t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){let t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;let{quadPoints:e,inkLists:s,rect:i}=this.data,n=-1/0,r=-1/0;if(e?.length>=8){for(let a=0;a<e.length;a+=8)if(e[a+1]>r)r=e[a+1],n=e[a+2];else if(e[a+1]===r)n=Math.max(n,e[a+2]);return[n,r]}if(s?.length>=1){for(let a of s)for(let o=0,l=a.length;o<l;o+=2)if(a[o+1]>r)r=a[o+1],n=a[o];else if(a[o+1]===r)n=Math.max(n,a[o]);if(n!==1/0)return[n,r]}if(i)return[i[2],i[3]];return null}_normalizePoint(t){let{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:r}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-n)/s,t[1]=100*(t[1]-r)/i,t}get commentText(){let{data:t}=this;return this.annotationStorage.getRawValue(`${Ce}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){let{data:e}=this,s={deleted:!t,contents:t||""};if(!this.annotationStorage.updateEditor(e.id,{popup:s}))this.annotationStorage.setValue(`${Ce}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:s,popupRef:e.popupRef,modificationDate:new Date});if(!t)this.removePopup()}removePopup(){(this.#s?.popup||this.popup)?.remove(),this.#s=this.popup=null}updateEdited(t){if(!this.container)return;if(t.rect)this.#t||={rect:this.data.rect.slice(0)};let{rect:e,popup:s}=t;if(e)this.#i(e);let i=this.#s?.popup||this.popup;if(!i&&s?.text)this._createPopup(s),i=this.#s.popup;if(!i)return;if(i.updateEdited(t),s?.deleted)i.remove(),this.#s=null,this.popup=null}resetEdited(){if(!this.#t)return;this.#i(this.#t.rect),this.#s?.popup.resetEdited(),this.#t=null}#i(t){let{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;if(s?.splice(0,4,...t),e.left=`${100*(t[0]-a)/n}%`,e.top=`${100*(r-t[3]+o)/r}%`,i===0)e.width=`${100*(t[2]-t[0])/n}%`,e.height=`${100*(t[3]-t[1])/r}%`;else this.setRotation(i)}_createContainer(t){let{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");if(n.setAttribute("data-annotation-id",e.id),!(this instanceof oe)&&!(this instanceof Fs)&&!(this instanceof Ii))n.tabIndex=0;let{style:r}=n;if(r.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText)n.title=e.alternativeText;if(e.noRotate)n.classList.add("norotate");if(!e.rect||this instanceof ys){let{rotation:p}=e;if(!e.hasOwnCanvas&&p!==0)this.setRotation(p,n);return n}let{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;let p=e.borderStyle.horizontalCornerRadius,g=e.borderStyle.verticalCornerRadius;if(p>0||g>0){let v=`calc(${p}px * var(--total-scale-factor)) / calc(${g}px * var(--total-scale-factor))`;r.borderRadius=v}switch(e.borderStyle.style){case Se.SOLID:r.borderStyle="solid";break;case Se.DASHED:r.borderStyle="dashed";break;case Se.BEVELED:z("Unimplemented border style: beveled");break;case Se.INSET:z("Unimplemented border style: inset");break;case Se.UNDERLINE:r.borderBottomStyle="solid";break;default:break}let m=e.borderColor||null;if(m)this.#e=!0,r.borderColor=L.makeHexColor(...m);else r.borderWidth=0}let l=L.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:h,pageHeight:c,pageX:d,pageY:u}=i.rawDims;r.left=`${100*(l[0]-d)/h}%`,r.top=`${100*(l[1]-u)/c}%`;let{rotation:f}=e;if(e.hasOwnCanvas||f===0)r.width=`${100*a/h}%`,r.height=`${100*o/c}%`;else this.setRotation(f,n);return n}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:r}=this;if(t%180!==0)[n,r]=[r,n];e.style.width=`${100*n/s}%`,e.style.height=`${100*r/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(e,s,i)=>{let n=i.detail[e],r=n[0],a=n.slice(1);i.target.style[s]=ri[`${r}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:ri[`${r}_rgb`](a)})};return j(this,"_commonActions",{display:(e)=>{let{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:(e)=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:(e)=>{let{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},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:(e)=>{t("bgColor","backgroundColor",e)},fillColor:(e)=>{t("fillColor","backgroundColor",e)},fgColor:(e)=>{t("fgColor","color",e)},textColor:(e)=>{t("textColor","color",e)},borderColor:(e)=>{t("borderColor","borderColor",e)},strokeColor:(e)=>{t("strokeColor","borderColor",e)},rotation:(e)=>{let s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){let s=this._commonActions;for(let i of Object.keys(e.detail))(t[i]||s[i])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let s=this._commonActions;for(let[i,n]of Object.entries(e)){let r=s[i];if(r){let a={detail:{[i]:n},target:t};r(a),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:t}=this.data;if(!t)return;let[e,s,i,n]=this.data.rect.map(Math.fround);if(t.length===8){let[p,g,m,v]=t.subarray(2,6);if(i===p&&n===g&&e===m&&s===v)return}let{style:r}=this.container,a;if(this.#e){let{borderColor:p,borderWidth:g}=r;r.borderWidth=0,a=["url('data:image/svg+xml;utf8,",`<svg xmlns="${Mt}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${p}" stroke-width="${g}">`],this.container.classList.add("hasBorder")}let o=i-e,l=n-s,{svgFactory:h}=this,c=h.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0),c.role="none";let d=h.createElement("defs");c.append(d);let u=h.createElement("clipPath"),f=`clippath_${this.data.id}`;u.setAttribute("id",f),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let p=2,g=t.length;p<g;p+=8){let m=t[p],v=t[p+1],y=t[p+2],S=t[p+3],A=h.createElement("rect"),b=(y-e)/o,w=(n-v)/l,x=(m-y)/o,T=(v-S)/l;A.setAttribute("x",b),A.setAttribute("y",w),A.setAttribute("width",x),A.setAttribute("height",T),u.append(A),a?.push(`<rect vector-effect="non-scaling-stroke" x="${b}" y="${w}" width="${x}" height="${T}"/>`)}if(this.#e)a.push("</g></svg>')"),r.backgroundImage=a.join("");this.container.append(c),this.container.style.clipPath=`url(#${f})`}_createPopup(t=null){let{data:e}=this,s,i;if(t)s={str:t.text},i=t.date;else s=e.contentsObj,i=e.modificationDate;this.#s=new ys({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#s||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#s}render(){st("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let s=[];if(this._fieldObjects){let i=this._fieldObjects.get(t)||[];for(let{page:n,id:r,exportValues:a}of i){if(n===-1)continue;if(r===e)continue;let o=typeof a==="string"?a:null,l=document.querySelector(`[data-element-id="${r}"]`);if(l&&!me.has(l)){z(`_getElementsByName - element not allowed: ${r}`);continue}s.push({id:r,exportValue:o,domElement:l})}return s}for(let i of document.getElementsByName(t)){let{exportValue:n}=i,r=i.getAttribute("data-element-id");if(r===e)continue;if(!me.has(i))continue;s.push({id:r,exportValue:n,domElement:i})}return s}show(){if(this.container)this.container.hidden=!1;this.popup?.maybeShow()}hide(){if(this.container)this.container.hidden=!0;this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}updateOC(t){if(!this.data.oc||!t)return;if(t.isVisible(this.data.oc))this.show();else this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":L.makeHexColor(...e)}}class Er extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){let{editor:t}=this;if(!t.hasComment)return;this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){if(this.editor.comment=t,!t)this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class Fs extends ft{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0});this.isTooltipOnly=t.data.isTooltipOnly}render(){let{data:t,linkService:e}=this,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;if(t.url)e.addLinkAttributes(s,t.url,t.newWindow),i=!0;else if(t.action)this._bindNamedAction(s,t.action,t.overlaidText),i=!0;else if(t.attachment)this.#e(s,t.attachmentId,t.attachment,t.overlaidText,t.attachmentDest),i=!0;else if(t.setOCGState)this.#s(s,t.setOCGState,t.overlaidText),i=!0;else if(t.dest)this._bindLink(s,t.dest,t.overlaidText),i=!0;else{if(t.actions&&(t.actions.has("Action")||t.actions.has("Mouse Up")||t.actions.has("Mouse Down"))&&this.enableScripting&&this.hasJSActions)this._bindJSAction(s,t),i=!0;if(t.resetForm)this._bindResetFormAction(s,t.resetForm),i=!0;else if(this.isTooltipOnly&&!i)this._bindLink(s,""),i=!0}if(this.container.classList.add("linkAnnotation"),i)this.contentElement=s,this.container.append(s);return this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,s=""){if(t.href=this.linkService.getDestinationHash(e),t.onclick=()=>{if(e)this.linkService.goToDestination(e);return!1},e||e==="")this.#t();if(s)t.title=s}_bindNamedAction(t,e,s=""){if(t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),s)t.title=s;this.#t()}#e(t,e,s,i="",n=null){if(t.href=this.linkService.getAnchorUrl(""),s.description)t.title=s.description;else if(i)t.title=i;let r=async()=>{let a=await this.linkService.getAttachmentContent(e);if(a)this.downloadManager?.openOrDownloadData(a,s.filename,n)};t.onclick=()=>(r(),!1),this.#t()}#s(t,e,s=""){if(t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),s)t.title=s;this.#t()}_bindJSAction(t,{actions:e,id:s,overlaidText:i}){t.href=this.linkService.getAnchorUrl("");let n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let r of e.keys()){let a=n.get(r);if(!a)continue;t[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:r}}),!1)}if(i)t.title=i;t.onclick||=()=>!1,this.#t()}_bindResetFormAction(t,e){let s=t.onclick;if(!s)t.href=this.linkService.getAnchorUrl("");if(this.#t(),!this._fieldObjects){if(z('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),!s)t.onclick=()=>!1;return}t.onclick=()=>{s?.();let{fields:i,refs:n,include:r}=e,a=[];if(i.length!==0||n.length!==0){let h=new Set(n);for(let c of i){let d=this._fieldObjects.get(c)||[];for(let{id:u}of d)h.add(u)}for(let c of this._fieldObjects.values())for(let d of c)if(h.has(d.id)===r)a.push(d)}else for(let h of this._fieldObjects.values())a.push(...h);let o=this.annotationStorage,l=[];for(let h of a){let{id:c}=h;switch(l.push(c),h.type){case"text":{let u=h.defaultValue||"";o.setValue(c,{value:u});break}case"checkbox":case"radiobutton":{let u=h.defaultValue===h.exportValues;o.setValue(c,{value:u});break}case"combobox":case"listbox":{let u=h.defaultValue||"";o.setValue(c,{value:u});break}default:continue}let d=document.querySelector(`[data-element-id="${c}"]`);if(!d)continue;else if(!me.has(d)){z(`_bindResetFormAction - element not allowed: ${c}`);continue}d.dispatchEvent(new Event("resetform"))}if(this.enableScripting)this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}});return!1}}}class Tr extends ft{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let t=document.createElement("img");if(t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container.append(t),this.container}}class oe extends ft{render(){return this.container}_getKeyModifier(t){return ot.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){if(s.includes("mouse"))t.addEventListener(s,(r)=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r),shift:r.shiftKey,modifier:this._getKeyModifier(r)}})});else t.addEventListener(s,(r)=>{if(s==="blur"){if(!e.focused||!r.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}if(!n)return;this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(r)}})})}_setEventListeners(t,e,s,i){let{actions:n}=this.data;for(let[r,a]of s)if(a==="Action"||n?.has(a)){if(a==="Focus"||a==="Blur")e||={focused:!1};if(this._setEventListener(t,e,r,a,i),a==="Focus"&&!n?.has("Blur"))this._setEventListener(t,e,"blur","Blur",null);else if(a==="Blur"&&!n?.has("Focus"))this._setEventListener(t,e,"focus","Focus",null)}}_setTextStyle(t){let e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||Wa,n=t.style,r,a=2,o=(l)=>Math.round(10*l)/10;if(this.data.multiLine){let l=Math.abs(this.data.rect[3]-this.data.rect[1]-2),h=Math.round(l/(1.35*i))||1,c=l/h;r=Math.min(i,o(c/1.35))}else{let l=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(i,o(l/1.35))}if(n.fontSize=`calc(${r}px * var(--total-scale-factor))`,n.color=L.makeHexColor(...s),this.data.textAlignment!==null&&!this.data.comb)n.textAlign=e[this.data.textAlignment]}_setRequired(t,e){if(e)t.setAttribute("required",!0);else t.removeAttribute("required");t.setAttribute("aria-required",e)}}class Cr extends oe{constructor(t){let e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){let n=this.annotationStorage;for(let r of this._getElementsByName(t.name,t.id)){if(r.domElement)r.domElement[e]=s;n.setValue(r.id,{[i]:s})}}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){let i=t.getValue(e,{value:this.data.fieldValue}),n=i.value||"",r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;if(r&&n.length>r)n=n.slice(0,r);let a=i.formattedValue||this.data.textContent?.join(`
48
+ `)||null;if(a&&this.data.comb)a=a.replaceAll(/\s+/g,"");let o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};if(this.data.multiLine){if(s=document.createElement("textarea"),s.textContent=a??n,this.data.doNotScroll)s.style.overflowY="hidden"}else if(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",a??n),this.data.doNotScroll)s.style.overflowX="hidden";if(this.data.hasOwnCanvas){if(this.container.classList.add("hasOwnCanvas"),t.has(e))this.container.classList.add("sandboxModified")}me.add(s),this.contentElement=s,s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;let{datetimeFormat:l,datetimeType:h,timeStep:c}=this.data,d=!!h&&this.enableScripting;if(l)s.title=l;if(this._setRequired(s,this.data.required),r)s.maxLength=r;s.addEventListener("input",(f)=>{t.setValue(e,{value:f.target.value}),this.setPropertyOnSiblings(s,"value",f.target.value,"value"),o.formattedValue=null}),s.addEventListener("resetform",(f)=>{let p=this.data.defaultFieldValue??"";s.value=o.userValue=p,o.formattedValue=null});let u=(f)=>{let{formattedValue:p}=o;if(p!==null&&p!==void 0)f.target.value=p;f.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",(p)=>{if(o.focused)return;let{target:g}=p;if(d){if(g.type=h,c)g.step=c}if(o.userValue){let m=o.userValue;if(d)if(h==="time"){let v=new Date(m),y=[v.getHours(),v.getMinutes(),v.getSeconds()];g.value=y.map((S)=>S.toString().padStart(2,"0")).join(":")}else g.value=new Date(m-Xa).toISOString().split(h==="date"?"T":".",1)[0];else g.value=m}if(o.lastCommittedValue=g.value,o.commitKey=1,!this.data.actions?.has("Focus"))o.focused=!0}),s.addEventListener("updatefromsandbox",(p)=>{this.container.classList.add("sandboxModified");let g={value(m){if(o.userValue=m.detail.value??"",!d)t.setValue(e,{value:o.userValue.toString()});m.target.value=o.userValue},formattedValue(m){let{formattedValue:v}=m.detail;if(o.formattedValue=v,v!==null&&v!==void 0&&m.target!==document.activeElement)m.target.value=v;let y={formattedValue:v};if(d)y.value=v;t.setValue(e,y)},selRange(m){m.target.setSelectionRange(...m.detail.selRange)},charLimit:(m)=>{let{charLimit:v}=m.detail,{target:y}=m;if(v===0){y.removeAttribute("maxLength");return}y.setAttribute("maxLength",v);let S=o.userValue;if(!S||S.length<=v)return;S=S.slice(0,v),y.value=o.userValue=S,t.setValue(e,{value:S}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:S,willCommit:!0,commitKey:1,selStart:y.selectionStart,selEnd:y.selectionEnd}})}};this._dispatchEventFromSandbox(g,p)}),s.addEventListener("keydown",(p)=>{o.commitKey=1;let g=-1;if(p.key==="Escape")g=0;else if(p.key==="Enter"&&!this.data.multiLine)g=2;else if(p.key==="Tab")o.commitKey=3;if(g===-1)return;let{value:m}=p.target;if(o.lastCommittedValue===m)return;o.lastCommittedValue=m,o.userValue=m,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:m,willCommit:!0,commitKey:g,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}})});let f=u;if(u=null,s.addEventListener("blur",(p)=>{if(!o.focused||!p.relatedTarget)return;if(!this.data.actions?.has("Blur"))o.focused=!1;let{target:g}=p,{value:m}=g;if(d){if(m&&h==="time"){let v=m.split(":").map((y)=>parseInt(y,10));m=new Date(2000,0,1,v[0],v[1],v[2]||0).valueOf(),g.step=""}else{if(!m.includes("T"))m=`${m}T00:00`;m=new Date(m).valueOf()}g.type="text"}if(o.userValue=m,o.lastCommittedValue!==m)this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:m,willCommit:!0,commitKey:o.commitKey,selStart:p.target.selectionStart,selEnd:p.target.selectionEnd}});f(p)}),this.data.actions?.has("Keystroke"))s.addEventListener("beforeinput",(p)=>{o.lastCommittedValue=null;let{data:g,target:m}=p,{value:v,selectionStart:y,selectionEnd:S}=m,A=y,b=S;switch(p.inputType){case"deleteWordBackward":{let w=/\w/;while(A>0&&!w.test(v[A-1]))A--;while(A>0&&w.test(v[A-1]))A--;break}case"deleteWordForward":{let w=v.substring(y).match(/^\W*\w*/);if(w)b+=w[0].length;break}case"deleteContentBackward":if(y===S)A-=1;break;case"deleteContentForward":if(y===S)b+=1;break}p.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,change:g||"",willCommit:!1,selStart:A,selEnd:b}})});this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(p)=>p.target.value)}if(u)s.addEventListener("blur",u);if(this.data.comb){let p=(this.data.rect[2]-this.data.rect[0])/r;s.classList.add("comb"),s.style.setProperty("--comb-width",`calc(${p}px * var(--total-scale-factor))`);let g=this.data.textAlignment;if(g===1||g===2){let m=()=>{let v=r-s.value.length;s.style.setProperty("--comb-offset",`${g===1?v>>1:v}`)};m();for(let v of["input","blur","resetform","updatefromsandbox"])s.addEventListener(v,m)}}}else if(s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas)s.hidden=!0;return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Ir extends oe{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Pr extends oe{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,s=e.id,i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;if(typeof i==="string")i=i!=="Off",t.setValue(s,{value:i});this.container.classList.add("buttonWidgetAnnotation","checkBox");let n=document.createElement("input");if(me.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,i)n.setAttribute("checked",!0);if(n.setAttribute("exportValue",e.exportValue),n.tabIndex=0,n.addEventListener("change",(r)=>{let{name:a,checked:o}=r.target;for(let l of this._getElementsByName(a,s)){let h=o&&l.exportValue===e.exportValue;if(l.domElement)l.domElement.checked=h;t.setValue(l.id,{value:h})}t.setValue(s,{value:o})}),n.addEventListener("resetform",(r)=>{let a=e.defaultFieldValue||"Off";r.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions)n.addEventListener("updatefromsandbox",(r)=>{let a={value(o){o.target.checked=o.detail.value!=="Off",t.setValue(s,{value:o.target.checked})}};this._dispatchEventFromSandbox(a,r)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(r)=>r.target.checked);return this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Mr extends oe{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,s=e.id,i=t.getValue(s,{value:e.buttonValue!==null&&e.fieldValue===e.buttonValue}).value;if(typeof i==="string")i=i!==e.buttonValue,t.setValue(s,{value:i});if(i)for(let r of this._getElementsByName(e.fieldName,s))t.setValue(r.id,{value:!1});let n=document.createElement("input");if(me.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,i)n.setAttribute("checked",!0);if(n.tabIndex=0,n.addEventListener("change",(r)=>{let{name:a,checked:o}=r.target;for(let l of this._getElementsByName(a,s))t.setValue(l.id,{value:!1});t.setValue(s,{value:o})}),n.addEventListener("resetform",(r)=>{let a=e.defaultFieldValue;r.target.checked=a!==null&&a!==void 0&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){let r=e.buttonValue;n.addEventListener("updatefromsandbox",(a)=>{let o={value:(l)=>{let h=r===l.detail.value;for(let c of this._getElementsByName(l.target.name)){let d=h&&c.id===s;if(c.domElement)c.domElement.checked=d;t.setValue(c.id,{value:d})}}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(a)=>a.target.checked)}return this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Or extends Fs{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;if(this.enableScripting&&this.hasJSActions&&e)this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(s)=>{this._dispatchEventFromSandbox({},s)});return t}}class Rr extends oe{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");me.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let n=this.data.combo&&this.data.options.length>0;if(!this.data.combo){if(i.size=this.data.options.length,this.data.multiSelect)i.multiple=!0}i.addEventListener("resetform",(c)=>{let d=this.data.defaultFieldValue;for(let u of i.options)u.selected=u.value===d});let r=(c,d)=>{let u=d.replaceAll(" "," ");if(c.textContent=u,u!==d)c.setAttribute("display-value",d)};for(let c of this.data.options){let d=document.createElement("option");if(r(d,c.displayValue),d.value=c.exportValue,s.value.includes(c.exportValue))d.setAttribute("selected",!0),n=!1;i.append(d)}let a=null;if(n){let c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),i.prepend(c),a=()=>{c.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}let o=(c)=>{let d=c?"value":"textContent",{options:u,multiple:f}=i;if(!f)return u.selectedIndex===-1?null:u[u.selectedIndex][d];return Array.prototype.filter.call(u,(p)=>p.selected).map((p)=>p[d])},l=o(!1),h=(c)=>{let d=c.target.options;return Array.prototype.map.call(d,(u)=>({displayValue:u.getAttribute("display-value")||u.textContent,exportValue:u.value}))};if(this.enableScripting&&this.hasJSActions)i.addEventListener("updatefromsandbox",(c)=>{let d={value(u){a?.();let f=u.detail.value,p=new Set(Array.isArray(f)?f:[f]);for(let g of i.options)g.selected=p.has(g.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(u){i.multiple=!0},remove(u){let f=i.options,p=u.detail.remove;if(f[p].selected=!1,i.remove(p),f.length>0){if(Array.prototype.findIndex.call(f,(m)=>m.selected)===-1)f[0].selected=!0}t.setValue(e,{value:o(!0),items:h(u)}),l=o(!1)},clear(u){while(i.length!==0)i.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(u){let{index:f,displayValue:p,exportValue:g}=u.detail.insert,m=i.children[f],v=document.createElement("option");if(r(v,p),v.value=g,m)m.before(v);else i.append(v);t.setValue(e,{value:o(!0),items:h(u)}),l=o(!1)},items(u){let{items:f}=u.detail;while(i.length!==0)i.remove(0);for(let p of f){let{displayValue:g,exportValue:m}=p,v=document.createElement("option");r(v,g),v.value=m,i.append(v)}if(i.options.length>0)i.options[0].selected=!0;t.setValue(e,{value:o(!0),items:h(u)}),l=o(!1)},indices(u){let f=new Set(u.detail.indices);for(let p of u.target.options)p.selected=f.has(p.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(u){u.target.disabled=!u.detail.editable}};this._dispatchEventFromSandbox(d,c)}),i.addEventListener("input",(c)=>{let d=o(!0),u=o(!1);t.setValue(e,{value:d}),c.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:u,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(c)=>c.target.value);else i.addEventListener("input",function(c){t.setValue(e,{value:o(!0)})});if(this.data.combo)this._setTextStyle(i);return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class ys extends ft{constructor(t){let{data:e,elements:s,parent:i}=t,n=!!i._commentManager;super(t,{isRenderable:!n&&ft._hasPopupData(e)});if(this.elements=s,n&&ft._hasPopupData(e)){let r=this.popup=this.#t();for(let a of s)a.popup=r}else this.popup=null}#t(){return new Dr({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,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,commentManager:this.parent._commentManager})}render(){let{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";let e=this.popup=this.#t(),s=[];for(let i of this.elements)i.popup=e,i.container.ariaHasPopup="dialog",s.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",s.map((i)=>`${xe}${i}`).join(",")),this.container}}class Dr{#t=null;#e=this.#V.bind(this);#s=this.#S.bind(this);#i=this.#C.bind(this);#n=this.#j.bind(this);#a=null;#r=null;#o=null;#l=null;#h=null;#u=null;#d=null;#f=!1;#g=null;#m=null;#c=null;#p=null;#v=null;#y=null;#b=null;#A=null;#x=null;#w=null;#E=!1;#T=null;#O=null;constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:c,commentManager:d=null}){if(this.#r=t,this.#x=i,this.#o=r,this.#A=a,this.#u=o,this.#a=e,this.#b=l,this.#d=h,this.#h=s,this.#t=d,this.#T=s[0],this.#l=gs.toDateObject(n),this.trigger=s.flatMap((u)=>u.getElementsToTriggerPopup()),!d){if(this.#P(),this.#r.hidden=!0,c)this.#j()}}#P(){if(this.#m)return;this.#m=new AbortController;let{signal:t}=this.#m;for(let e of this.trigger)e.addEventListener("click",this.#n,{signal:t}),e.addEventListener("pointerenter",this.#i,{signal:t}),e.addEventListener("pointerleave",this.#s,{signal:t}),e.classList.add("popupTriggerArea");for(let e of this.#h)e.container?.addEventListener("keydown",this.#e,{signal:t})}#I(){let t=this.#h.find((e)=>e.hasCommentButton);if(!t)return;this.#v=t._normalizePoint(t.commentButtonPosition)}renderCommentButton(){if(this.#p){if(!this.#p.parentNode)this.#T.container.after(this.#p);return}if(!this.#v)this.#I();if(!this.#v)return;let{signal:t}=this.#m=new AbortController,e=this.#T.hasOwnCommentButton,s=()=>{this.#t.toggleCommentPopup(this,!0,void 0,!e)},i=()=>{this.#t.toggleCommentPopup(this,!1,!0,!e)},n=()=>{this.#t.toggleCommentPopup(this,!1,!1)};if(!e){let r=this.#p=document.createElement("button");r.className="annotationCommentButton";let a=this.#T.container;r.style.zIndex=parseInt(a.style.zIndex,10)+1,r.tabIndex=0,r.ariaHasPopup="dialog",r.ariaControls="commentPopup",r.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#R(),this.#D(),r.addEventListener("keydown",this.#e,{signal:t}),r.addEventListener("click",s,{signal:t}),r.addEventListener("pointerenter",i,{signal:t}),r.addEventListener("pointerleave",n,{signal:t}),a.after(r)}else{this.#p=this.#T.container;for(let r of this.trigger)r.ariaHasPopup="dialog",r.ariaControls="commentPopup",r.addEventListener("keydown",this.#e,{signal:t}),r.addEventListener("click",s,{signal:t}),r.addEventListener("pointerenter",i,{signal:t}),r.addEventListener("pointerleave",n,{signal:t}),r.classList.add("popupTriggerArea")}}#D(){if(this.#T.extraPopupElement&&!this.#T.editor)return;if(!this.#p)this.renderCommentButton();let[t,e]=this.#v,{style:s}=this.#p;s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`}#R(){if(this.#T.extraPopupElement)return;if(!this.#p)this.renderCommentButton();this.#p.style.backgroundColor=this.commentButtonColor||""}get commentButtonColor(){let{color:t,opacity:e}=this.#T.commentData;if(!t)return null;return this.#u._commentManager.makeCommentColor(t,e)}focusCommentButton(){setTimeout(()=>{this.#p?.focus()},0)}getData(){let{richText:t,color:e,opacity:s,creationDate:i,modificationDate:n}=this.#T.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:n}}get elementBeforePopup(){return this.#p}get comment(){return this.#O||=this.#T.commentText,this.#O}set comment(t){if(t===this.comment)return;this.#T.commentText=this.#O=t}focus(){this.#T.container?.focus()}get parentBoundingClientRect(){return this.#T.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){if(!this.#p)return;this.#p.classList.toggle("selected",t),this.#p.ariaExpanded=e}setSelectedCommentButton(t){this.#p.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#y)return this.#y;let{x:t,y:e,height:s}=this.#p.getBoundingClientRect(),{x:i,y:n,width:r,height:a}=this.#T.layer.getBoundingClientRect();return[(t-i)/r,(e+s-n)/a]}set commentPopupPosition(t){this.#y=t}hasDefaultPopupPosition(){return this.#y===null}get commentButtonPosition(){return this.#v}get commentButtonWidth(){return this.#p.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){let[e,s]=this.#y||this.commentButtonPosition.map((l)=>l/100),i=this.parentBoundingClientRect,{x:n,y:r,width:a,height:o}=i;this.#t.showDialog(null,this,n+e*a,r+s*o,{...t,parentDimensions:i})}render(){if(this.#g)return;let t=this.#g=document.createElement("div");if(t.className="popup",this.#a){let s=t.style.outlineColor=L.makeHexColor(...this.#a);t.style.backgroundColor=`color-mix(in srgb, ${s} 30%, white)`}let e=document.createElement("span");if(e.className="header",this.#x?.str){let s=document.createElement("span");s.className="title",e.append(s),{dir:s.dir,str:s.textContent}=this.#x}if(t.append(e),this.#l){let s=document.createElement("time");s.className="popupDate",s.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),s.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#l.valueOf()})),s.dateTime=this.#l.toISOString(),e.append(s)}wn({html:this.#k||this.#o.str,dir:this.#o?.dir,className:"popupContent"},t),this.#r.append(t)}get#k(){let t=this.#A,e=this.#o;if(t?.str&&(!e?.str||e.str===t.str))return this.#A.html||null;return null}get#U(){return this.#k?.attributes?.style?.fontSize||0}get#L(){return this.#k?.attributes?.style?.color||null}#F(t){let e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#L,fontSize:this.#U?`calc(${this.#U}px * var(--total-scale-factor))`:""}};for(let n of t.split(`
49
+ `))e.push({name:"span",value:n,attributes:i});return s}#V(t){if(t.altKey||t.shiftKey||t.ctrlKey||t.metaKey)return;if(t.key==="Enter"||t.key==="Escape"&&this.#f)this.#j()}updateEdited({rect:t,popup:e,deleted:s}){if(this.#t){if(s)this.remove(),this.#O=null;else if(e)if(e.deleted)this.remove();else this.#R(),this.#O=e.text;if(t)this.#v=null,this.#I(),this.#D();return}if(s||e?.deleted){this.remove();return}if(this.#P(),this.#w||={contentsObj:this.#o,richText:this.#A},t)this.#c=null;if(e&&e.text)this.#A=this.#F(e.text),this.#l=gs.toDateObject(e.date),this.#o=null;this.#g?.remove(),this.#g=null}resetEdited(){if(!this.#w)return;({contentsObj:this.#o,richText:this.#A}=this.#w),this.#w=null,this.#g?.remove(),this.#g=null,this.#c=null}remove(){if(this.#m?.abort(),this.#m=null,this.#g?.remove(),this.#g=null,this.#E=!1,this.#f=!1,this.#p?.remove(),this.#p=null,this.trigger)for(let t of this.trigger)t.classList.remove("popupTriggerArea")}#B(){if(this.#c!==null)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=this.#u,r=!!this.#d,a=r?this.#d:this.#b;for(let f of this.#h)if(!a||L.intersect(f.data.rect,a)!==null){a=f.data.rect,r=!0;break}let o=L.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=5,h=r?a[2]-a[0]+l:0,c=o[0]+h,d=o[1];this.#c=[100*(c-i)/e,100*(d-n)/s];let{style:u}=this.#r;u.left=`${this.#c[0]}%`,u.top=`${this.#c[1]}%`}#j(){if(this.#t){this.#t.toggleCommentPopup(this,!1);return}if(this.#f=!this.#f,this.#f)this.#C(),this.#r.addEventListener("click",this.#n),this.#r.addEventListener("keydown",this.#e);else this.#S(),this.#r.removeEventListener("click",this.#n),this.#r.removeEventListener("keydown",this.#e)}#C(){if(!this.#g)this.render();if(!this.isVisible)this.#B(),this.#r.hidden=!1,this.#r.style.zIndex=parseInt(this.#r.style.zIndex,10)+1000;else if(this.#f)this.#r.classList.add("focused")}#S(){if(this.#r.classList.remove("focused"),this.#f||!this.isVisible)return;this.#r.hidden=!0,this.#r.style.zIndex=parseInt(this.#r.style.zIndex,10)-1000}forceHide(){if(this.#E=this.isVisible,!this.#E)return;this.#r.hidden=!0}maybeShow(){if(this.#t)return;if(this.#P(),!this.#E)return;if(!this.#g)this.#C();this.#E=!1,this.#r.hidden=!1}get isVisible(){return!this.#t&&this.#r.hidden===!1}}class xi extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Y.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(let e of this.textContent){let s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}if(!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this._editOnDoubleClick(),this.container}}class kr extends ft{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),n=this.#t=this.svgFactory.createElement("svg:line");if(n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),i.append(n),this.container.append(i),!t.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Lr extends ft{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:rect");if(r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",s-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Nr extends ft{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,r=this.#t=this.svgFactory.createElement("svg:ellipse");if(r.setAttribute("cx",e/2),r.setAttribute("cy",s/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",s/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ei extends ft{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:s,popupRef:i},width:n,height:r}=this;if(!e)return this.container;let a=this.svgFactory.create(n,r,!0),o=[];for(let h=0,c=e.length;h<c;h+=2){let d=e[h]-t[0],u=t[3]-e[h+1];o.push(`${d},${u}`)}o=o.join(" ");let l=this.#t=this.svgFactory.createElement(this.svgElementName);if(l.setAttribute("points",o),l.setAttribute("stroke-width",s.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!i&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Fr extends Ei{constructor(t){super(t);this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Br extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){if(this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container}}class Bs extends ft{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?Y.HIGHLIGHT:Y.INK}#s(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,rotation:e,inkLists:s,borderStyle:i,popupRef:n}}=this,{transform:r,width:a,height:o}=this.#s(e,t),l=this.svgFactory.create(a,o,!0),h=this.#t=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",i.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",r);for(let c of s){let d=this.svgFactory.createElement(this.svgElementName);this.#e.push(d),d.setAttribute("points",c.join(",")),h.append(d)}if(!n&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:s,rect:i}=t,n=this.#t;if(e>=0)n.setAttribute("stroke-width",e||1);if(s)for(let r=0,a=this.#e.length;r<a;r++)this.#e[r].setAttribute("points",s[r].join(","));if(i){let{transform:r,width:a,height:o}=this.#s(this.data.rotation,i);n.parentElement.setAttribute("viewBox",`0 0 ${a} ${o}`),n.setAttribute("transform",r)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ti extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0});this.annotationEditorType=Y.HIGHLIGHT}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){let s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class _r extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("underlineAnnotation"),t){let s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Hr extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("squigglyAnnotation"),t){let s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Ur extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();if(this.container.classList.add("strikeoutAnnotation"),t){let s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Ci extends ft{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});this.annotationEditorType=Y.STAMP}render(){if(this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();return this._editOnDoubleClick(),this.container}}class jr extends ft{#t=null;constructor(t){super(t,{isRenderable:!0});let{fileId:e,file:s}=this.data;this.filename=s.filename,this.content=s.content,this.fileId=e,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:t,data:e}=this,s;if(e.hasAppearance||e.fillAlpha===0)s=document.createElement("div");else if(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1)s.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`;s.addEventListener("dblclick",this.#e.bind(this)),this.#t=s;let{isMac:i}=ot.platform;if(t.addEventListener("keydown",(n)=>{if(n.key==="Enter"&&(i?n.metaKey:n.ctrlKey))this.#e()}),!e.popupRef&&this.hasPopupData)this.hasOwnCommentButton=!0,this._createPopup();else s.classList.add("popupTriggerArea");return t.append(s),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}async#e(){let{fileId:t,filename:e,content:s}=this,i=await this.linkService.getAttachmentContent(t)||s;if(i)this.downloadManager?.openOrDownloadData(i,e)}}class Ii extends ft{#t=new AbortController;#e=null;#s=null;constructor(t){super(t,{isRenderable:!!t.data.richMedia})}render(){this.container.classList.add("mediaAnnotation");let{filename:t}=this.data.richMedia,e=document.createElement("button");return e.className="mediaPlayButton",e.type="button",e.title=e.ariaLabel=t,e.addEventListener("click",()=>this.#i(e),{signal:this.#t.signal}),this.container.append(e),this.container}async#i(t){let{fileId:e,filename:s,contentType:i}=this.data.richMedia;t.disabled=!0;let n;try{n=await this.linkService.getAttachmentContent(e)}catch{return}finally{t.disabled=!1}if(!n||!t.isConnected)return;let{signal:r}=this.#t,a=URL.createObjectURL(new Blob([n],{type:i}));this.#e=a;let o=i.startsWith("audio/"),l=document.createElement(o?"audio":"video");if(this.#s=l,l.className="mediaContent",this._setBackgroundColor(l),l.src=a,l.title=s,l.controls=!0,l.autoplay=!0,l.tabIndex=0,o){let h=!1,c=!1,d=()=>{l.controls=h||c};this.container.addEventListener("pointerenter",()=>{h=!0,d()},{signal:r}),this.container.addEventListener("pointerleave",()=>{h=!1,d()},{signal:r}),this.container.addEventListener("focusin",()=>{c=!0,d()},{signal:r}),this.container.addEventListener("focusout",()=>{c=!1,d()},{signal:r})}l.addEventListener("emptied",()=>this.#n(a),{once:!0,signal:r}),t.replaceWith(l),l.play().catch(()=>{})}#n(t=this.#e){if(t&&t===this.#e)URL.revokeObjectURL(t),this.#e=null}destroy(){if(this.#t.abort(),this.#s)this.#s.pause(),this.#s.removeAttribute("src"),this.#s.load(),this.#s=null;this.#n()}}class Pi{#t=null;#e=null;#s=null;#i=new Map;#n=null;#a=null;#r=[];#o=!1;zIndex=0;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:r,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:h}){this.div=t,this.#t=e,this.#e=s,this.#n=a||null,this.#a=l||null,this.#s=h||new Ms,this.page=n,this.viewport=r,this._annotationEditorUIManager=i,this._commentManager=o||null}hasEditableAnnotations(){return this.#i.size>0}async render(t){let{annotations:e,optionalContentConfig:s}=t,i=this.div;ge(i,this.viewport);let n=new Map,r=[],a={data:null,layer:i,linkService:this.#a,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new We,annotationStorage:this.#s,enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let o of e){if(o.noHTML)continue;let l=o.annotationType===gt.POPUP;if(!l){if(o.rect[2]===o.rect[0]||o.rect[3]===o.rect[1])continue}else{let d=n.get(o.id);if(!d)continue;if(!this._commentManager){r.push(o);continue}a.elements=d}a.data=o;let h=us.create(a);if(!h.isRenderable)continue;if(!l){if(this.#r.push(h),o.popupRef)n.getOrInsertComputed(o.popupRef,Ie).push(h)}let c=h.render();if(o.hidden)c.style.visibility="hidden";if(h.updateOC(s),h._isEditable)this.#i.set(h.data.id,h),this._annotationEditorUIManager?.renderAnnotationElement(h)}await this.#l();for(let o of r){let l=a.elements=n.get(o.id);a.data=o;let h=us.create(a);if(!h.isRenderable)continue;let c=h.render();if(h.contentElement.id=`${xe}${o.id}`,o.hidden)c.style.visibility="hidden";l.at(-1).container.after(c)}this.#h()}async#l(){if(this.#r.length===0)return;this.div.replaceChildren();let t=[];if(!this.#o){this.#o=!0;for(let{contentElement:s,data:{hidden:i,id:n,oc:r}}of this.#r){let a=s.id=`${xe}${n}`,o=s.localName==="a"&&!i&&!r;t.push(this.#n?.getAriaAttributes(a,{enableLinkOwnership:o}).then((l)=>{if(l)for(let[h,c]of l)s.setAttribute(h,c)}))}}this.#r.sort(({data:{rect:[s,i,n,r]}},{data:{rect:[a,o,l,h]}})=>{if(s===n&&i===r)return 1;if(a===l&&o===h)return-1;let c=r,d=i,u=(i+r)/2,f=h,p=o,g=(o+h)/2;if(u>=f&&g<=d)return-1;if(g>=c&&u<=p)return 1;let m=(s+n)/2,v=(a+l)/2;return m-v});let e=document.createDocumentFragment();for(let s of this.#r)if(e.append(s.container),this._commentManager)(s.extraPopupElement?.popup||s.popup)?.renderCommentButton();else if(s.extraPopupElement)e.append(s.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#t){let s=await this.#n?.getAnnotationIds();for(let{contentElement:i}of this.#r){if(s?.has(i.id))continue;this.#t.addPointerInTextLayer(i,!1)}}}async addLinkAnnotations(t){let e={data:null,layer:this.div,linkService:this.#a,svgFactory:new We,parent:this};for(let s of t){s.borderStyle||=Pi._defaultBorderStyle,e.data=s;let i=us.create(e);if(!i.isRenderable)continue;i.render(),i.contentElement.id=`${xe}${s.id}`,this.#r.push(i)}await this.#l()}update({viewport:t,optionalContentConfig:e}){let s=this.div;this.viewport=t,ge(s,{rotation:t.rotation});for(let i of this.#r)i.updateOC(e);this.#h(),s.hidden=!1}destroy(){for(let t of this.#r)t.destroy?.(),this.#t?.removePointerInTextLayer(t.contentElement);this.#r.length=0,this.#i.clear(),this.div.replaceChildren()}#h(){if(!this.#e)return;let t=this.div;for(let[e,s]of this.#e){let i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;if(Array.isArray(s))for(let l of s)l.className="annotationContent",l.ariaHidden=!0;else s.className="annotationContent",s.ariaHidden=!0;let n=[];for(let l of i.children)if(l.nodeName==="CANVAS")n.push(l);for(let l of n)l.remove();let r=Array.isArray(s)?s[0]:s,{firstChild:a}=i;if(!a)i.append(r);else if(!a.classList.contains("annotationContent"))a.before(r);else a.after(r);if(Array.isArray(s)){let l=r;for(let h=1,c=s.length;h<c;h++)l.after(s[h]),l=s[h]}this.#e.delete(e);let o=this.#i.get(e);if(!o)continue;if(o._hasNoCanvas)this._annotationEditorUIManager?.setMissingCanvas(e,i.id,s),o._hasNoCanvas=!1;else o.canvas=s}}refreshCanvases(){this.#h()}getEditableAnnotations(){return this.#i.values()}getEditableAnnotation(t){return this.#i.get(t)}addFakeAnnotation(t){let{div:e}=this,{id:s,rotation:i}=t,n=new Er({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#a,annotationStorage:this.#s});return n.render(),n.contentElement.id=`${xe}${s}`,n.createOrUpdatePopup(),this.#r.push(n),n}removeAnnotation(t){let e=this.#r.findIndex((i)=>i.data.id===t);if(e<0)return;let[s]=this.#r.splice(e,1);this.#t?.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length===0)return;for(let e of t)e.updateFakeAnnotationElement(this);this.#l()}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return j(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Se.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}var rs=/\r\n?|\n/g;class wt extends H{#t="";#e=`${this.id}-editor`;#s=null;#i;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=wt.prototype,e=(n)=>n.isEmpty(),{TRANSLATE_SMALL:s,TRANSLATE_BIG:i}=ae;return j(this,"_keyboardManager",new Ft([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],t.commitOrRemove],[["Escape"],t.commitOrRemove],[["ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=Y.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"});if(this.color=t.color||wt._defaultColor||H._defaultLineColor,this.#i=t.fontSize||wt._defaultFontSize,!this.annotationElementId)this._uiManager.a11yAlert(H._l10nAlert.freetext);this.canAddComment=!1}static initialize(t,e){H.initialize(t,e);let s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case q.FREETEXT_SIZE:wt._defaultFontSize=e;break;case q.FREETEXT_COLOR:wt._defaultColor=e;break}}updateParams(t,e){switch(t){case q.FREETEXT_SIZE:this.#n(e);break;case q.FREETEXT_COLOR:this.#a(e);break}}static get defaultPropertiesToUpdate(){return[[q.FREETEXT_SIZE,wt._defaultFontSize],[q.FREETEXT_COLOR,wt._defaultColor||H._defaultLineColor]]}get propertiesToUpdate(){return[[q.FREETEXT_SIZE,this.#i],[q.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new ze(this),[["colorPicker",this._colorPicker]]}get colorType(){return q.FREETEXT_COLOR}#n(t){let e=(i)=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--total-scale-factor))`,this.translate(0,-(i-this.#i)*this.parentScale),this.#i=i,this.#o()},s=this.#i;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:q.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#a(t){let e=(i)=>{this.color=i,this.onUpdatedColor()},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:q.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-wt._internalPadding*t,-(wt._internalPadding+this.#i)*t]}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(!this.isAttachedToDOM)this.parent.add(this)}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#s=new AbortController;let t=this._uiManager.combinedSignal(this.#s);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){if(!super.disableEditMode())return!1;return this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#e),this._isDraggable=!0,this.#s?.abort(),this.#s=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0}focusin(t){if(!this._focusEventsAllowed)return;if(super.focusin(t),t.target!==this.editorDiv)this.editorDiv.focus()}onceAdded(t){if(this.width)return;if(this.enableEditMode(),t)this.editorDiv.focus();if(this._initialOptions?.isCentered)this.center();this._initialOptions=null}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){if(this.isEditing=!1,this.parent)this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing");super.remove()}#r(){let t=[];this.editorDiv.normalize();let e=null;for(let s of this.editorDiv.childNodes){if(e?.nodeType===Node.TEXT_NODE&&s.nodeName==="BR")continue;t.push(wt.#l(s)),e=s}return t.join(`
50
+ `)}#o(){let[t,e]=this.parentDimensions,s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{let{currentLayer:i,div:n}=this,r=n.style.display,a=n.classList.contains("hidden");n.classList.remove("hidden"),n.style.display="hidden",i.div.append(this.div),s=n.getBoundingClientRect(),n.remove(),n.style.display=r,n.classList.toggle("hidden",a)}if(this.rotation%180===this.parentRotation%180)this.width=s.width/t,this.height=s.height/e;else this.width=s.height/t,this.height=s.width/e;this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#t,e=this.#t=this.#r().trimEnd();if(t===e)return;let s=(i)=>{if(this.#t=i,!i){this.remove();return}this.#h(),this._uiManager.rebuild(this),this.#o()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#o()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){if(t.target===this.div&&t.key==="Enter")this.enterInEditMode(),t.preventDefault()}editorDivKeydown(t){wt._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){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)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;if(this._isCopy||this.annotationElementId)t=this.x,e=this.y;super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#e),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:s}=this.editorDiv;if(s.fontSize=`calc(${this.#i}px * var(--total-scale-factor))`,s.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){let[i,n]=this.parentDimensions;if(this.annotationElementId){let{position:r}=this._initialData,[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);let[l,h]=this.pageDimensions,[c,d]=this.pageTranslation,u,f;switch(this.rotation){case 0:u=t+(r[0]-c)/l,f=e+this.height-(r[1]-d)/h;break;case 90:u=t+(r[0]-c)/l,f=e-(r[1]-d)/h,[a,o]=[o,-a];break;case 180:u=t-this.width+(r[0]-c)/l,f=e-(r[1]-d)/h,[a,o]=[-a,-o];break;case 270:u=t+(r[0]-c-this.height*h)/l,f=e+(r[1]-d-this.width*l)/h,[a,o]=[-o,a];break}this.setAt(u*i,f*n,a,o)}else this._moveAfterPaste(t,e);this.#h(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#l(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(rs,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:s}=e;if(s.length===1&&s[0]==="text/plain")return;t.preventDefault();let i=wt.#d(e.getData("text")||"").replaceAll(rs,`
51
+ `);if(!i)return;let n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();let r=n.getRangeAt(0);if(!i.includes(`
52
+ `)){r.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),n.collapseToStart();return}let{startContainer:a,startOffset:o}=r,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){let u=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(rs,"")),u!==this.editorDiv){let f=l;for(let p of this.editorDiv.childNodes){if(p===u){f=h;continue}f.push(wt.#l(p))}}l.push(a.nodeValue.slice(0,o).replaceAll(rs,""))}else if(a===this.editorDiv){let u=l,f=0;for(let p of this.editorDiv.childNodes){if(f++===o)u=h;u.push(wt.#l(p))}}this.#t=`${l.join(`
53
+ `)}${i}${h.join(`
54
+ `)}`,this.#h();let c=new Range,d=Math.sumPrecise(l.map((u)=>u.length));for(let{firstChild:u}of this.editorDiv.childNodes)if(u.nodeType===Node.TEXT_NODE){let f=u.nodeValue.length;if(d<=f){c.setStart(u,d),c.setEnd(u,d);break}d-=f}n.removeAllRanges(),n.addRange(c)}#h(){if(this.editorDiv.replaceChildren(),!this.#t)return;for(let t of this.#t.split(`
55
+ `)){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#u(){return this.#t.replaceAll(" "," ")}static#d(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){let t=wt._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,s){let i=null;if(t instanceof xi){let{data:{defaultAppearanceData:{fontSize:r,fontColor:a},rect:o,rotation:l,id:h,popupRef:c,richText:d,contentsObj:u,creationDate:f,modificationDate:p},textContent:g,textPosition:m,parent:{page:{pageNumber:v}}}=t;if(!g?.length)return null;i=t={annotationType:Y.FREETEXT,color:Array.from(a),fontSize:r,value:g.join(`
56
+ `),position:m,pageIndex:v-1,rect:o.slice(0),rotation:l,annotationElementId:h,id:h,deleted:!1,popupRef:c,comment:u?.str||null,richText:d,creationDate:f,modificationDate:p}}let n=await super.deserialize(t,e,s);if(n.#i=t.fontSize,n.color=L.makeHexColor(...t.color),n.#t=wt.#d(t.value),n._initialData=i,t.comment)n.setCommentData(t);return n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=H._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),s=Object.assign(super.serialize(t),{color:e,fontSize:this.#i,value:this.#u()});if(this.addComment(s),t)return s.isCopy=!0,s;if(this.annotationElementId&&!this.#f(s))return null;return s.id=this.annotationElementId,s}#f(t){let{value:e,fontSize:s,color:i,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((r,a)=>r!==i[a])||t.pageIndex!==n}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(!e)return null;let{style:s}=e;s.fontSize=`calc(${this.#i}px * var(--total-scale-factor))`,s.color=this.color,e.replaceChildren();for(let i of this.#t.split(`
57
+ `)){let n=document.createElement("div");n.append(i?document.createTextNode(i):document.createElement("br")),e.append(n)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#t}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class _s{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(!t)return;for(let[e,s]of Object.entries(t))if(!e.startsWith("_"))this.updateProperty(e,s)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){let t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){st("Not implemented")}}class Q extends H{#t=null;#e;_clipPathId=null;_colorPicker=null;_drawId=null;_drawOutlines=null;_focusDrawId=null;static _currentDrawId=-1;static _currentParent=null;static#s=null;static#i=null;static#n=null;static#a=null;static _INNER_MARGIN=3;constructor(t){super(t);this.#e=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(t){if(t.drawOutlines)this.#r(t),this.#m()}#r({drawOutlines:t,drawId:e,drawingOptions:s,clipPathId:i}){if(this._drawOutlines=t,this._drawingOptions||=s,!this.annotationElementId)this._uiManager.a11yAlert(H._l10nAlert[this.editorType]);if(e>=0)this._drawId=e,this._clipPathId=i??null,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties),this.#l(this.parent);else this._drawId=this.#o(t,this.parent);this.#v(t.box)}#o(t,e){let{id:s,clipPathId:i}=e.drawLayer.draw(Q._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,this.constructor._hasClipPath);if(this.constructor._hasClipPath)this._clipPathId=i;return this.#l(e),s}#l(t){let e=this._drawOutlines.getFocusSVGProperties(this.#f);if(e)this._focusDrawId=t.drawLayer.drawOutline(e,this._drawOutlines.focusMustRemoveSelfIntersections)}#h(t=this.#f){if(this._focusDrawId===null)return;this.parent?.drawLayer.updateProperties(this._focusDrawId,this._drawOutlines.getFocusSVGProperties(t))}#u(t){if(this._focusDrawId!==null)this.parent?.drawLayer.updateProperties(this._focusDrawId,{rootClass:t})}#d(){let{parent:t,_drawId:e,_focusDrawId:s,_isVisible:i}=this;if(!t||e===null)return;let n={hidden:!i};if(t.drawLayer.updateProperties(e,{rootClass:n}),s!==null)t.drawLayer.updateProperties(s,{rootClass:n})}static _mergeSVGProperties(t,e){let s=new Set(Object.keys(t));for(let[i,n]of Object.entries(e))if(s.has(i))Object.assign(t[i],n);else t[i]=n;return t}static getDefaultDrawingOptions(t){st("Not implemented")}static get typesMap(){st("Not implemented")}static get isDrawer(){return!0}static get _hasClipPath(){return!1}static get _hasDrawClass(){return!0}static get supportMultipleDrawings(){return!1}get _drawRotation(){return this.rotation}get _opacityName(){return this.constructor.typesMap.get(this.opacityType)}get#f(){return(this.parentRotation-this._drawRotation+360)%360}static updateDefaultParams(t,e){let s=this.typesMap.get(t);if(s)this._defaultDrawingOptions.updateProperty(s,e);if(this._currentParent)Q.#s.updateProperty(s,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}updateParams(t,e){let s=this.constructor.typesMap.get(t);if(s)this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[s,i]of this.typesMap)t.push([s,e[i]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[s,i]of this.constructor.typesMap)t.push([s,e[i]]);return t}_updateProperty(t,e,s){let i=this._drawingOptions,n=i[e],r=(a)=>{i.updateProperty(e,a);let o=this._drawOutlines.updateProperty(e,a);if(o)this.#v(o);if(this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),t===this.colorType)this.onUpdatedColor();else if(t===this.opacityType)this.onUpdatedOpacity()};this.addCommands({cmd:r.bind(this,s),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e,s=this.colorAndOpacityType){let i=this.constructor.typesMap.get(this.colorType),n=this._opacityName,r=this._drawingOptions,a=r[i],o=r[n],l=(h,c)=>{r.updateProperty(i,h),r.updateProperty(n,c),this._drawOutlines.updateProperty(i,h),this._drawOutlines.updateProperty(n,c),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:l.bind(this,t,e),undo:l.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:s,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,Q._mergeSVGProperties(this._drawOutlines.getPathResizingSVGProperties(this.#p()),{bbox:this.#y()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,Q._mergeSVGProperties(this._drawOutlines.getPathResizedSVGProperties(this.#p()),{bbox:this.#y()})),this.#h()}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#y()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,Q._mergeSVGProperties(this._drawOutlines.getPathTranslatedSVGProperties(this.#p(),this.parentDimensions),{bbox:this.#y()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}get _mustBeDisabledOnCommit(){return!0}commit(){if(super.commit(),this._mustBeDisabledOnCommit)this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){if(!this.annotationElementId)this.parent.addUndoableEditor(this);if(this._isDraggable=!0,this.#e){if(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen)this.div.focus()}}remove(){this._uiManager.removeShouldRescale(this),this.#g(),super.remove()}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(this.#m(),this.#v(this._drawOutlines.box),!this.isAttachedToDOM)this.parent.add(this)}setParent(t){let e=!1;if(this.parent&&!t)this._uiManager.removeShouldRescale(this),this.#g();else if(t)this._uiManager.addShouldRescale(this),this.#m(t),e=!this.parent&&this.div?.classList.contains("selectedEditor");if(super.setParent(t),this.#d(),e)this.select()}#g(){if(this._drawId===null||!this.parent)return;let{drawLayer:t}=this.parent;if(t.remove(this._drawId),this._drawId=null,this._focusDrawId!==null)t.remove(this._focusDrawId),this._focusDrawId=null;this._drawingOptions.reset()}#m(t=this.parent){if(this._drawId!==null&&this.parent===t)return;if(this._drawId!==null){let{drawLayer:e}=this.parent;if(e.updateParent(this._drawId,t.drawLayer),this._focusDrawId!==null)e.updateParent(this._focusDrawId,t.drawLayer);return}if(this._drawingOptions.updateAll(),this._drawId=this.#o(this._drawOutlines,t),this._clipPathId&&this.#t)this.#t.style.clipPath=this._clipPathId}#c([t,e,s,i]){let{parentDimensions:[n,r],_drawRotation:a}=this;switch(a){case 90:return[e,1-t,s*(r/n),i*(n/r)];case 180:return[1-t,1-e,s,i];case 270:return[1-e,t,s*(r/n),i*(n/r)];default:return[t,e,s,i]}}#p(){let{x:t,y:e,width:s,height:i,parentDimensions:[n,r],_drawRotation:a}=this;switch(a){case 90:return[1-e,t,s*(n/r),i*(r/n)];case 180:return[1-t,1-e,s,i];case 270:return[e,1-t,s*(n/r),i*(r/n)];default:return[t,e,s,i]}}#v(t){if([this.x,this.y,this.width,this.height]=this.#c(t),this.div)this.fixAndSetPosition(),this.setDims();this._onResized()}#y(t=this.parentRotation){let{x:e,y:s,width:i,height:n,_drawRotation:r,parentDimensions:[a,o]}=this;switch((r*4+t)/90){case 1:return[1-s-n,e,n,i];case 2:return[1-e-i,1-s-n,i,n];case 3:return[s,1-e-i,n,i];case 4:return[e,s-i*(a/o),n*(o/a),i*(a/o)];case 5:return[1-s,e,i*(a/o),n*(o/a)];case 6:return[1-e-n*(o/a),1-s,n*(o/a),i*(a/o)];case 7:return[s-i*(a/o),1-e-n*(o/a),i*(a/o),n*(o/a)];case 8:return[e-i,s-n,i,n];case 9:return[1-s,e-i,n,i];case 10:return[1-e,1-s,i,n];case 11:return[s-n,1-e,n,i];case 12:return[e-n*(o/a),s,n*(o/a),i*(a/o)];case 13:return[1-s-i*(a/o),e-n*(o/a),i*(a/o),n*(o/a)];case 14:return[1-e,1-s-i*(a/o),n*(o/a),i*(a/o)];case 15:return[s,1-e,i*(a/o),n*(o/a)];default:return[e,s,i,n]}}rotate(t=this.parentRotation){if(!this.parent||this._drawId===null)return;let e=(t-this._drawRotation+360)%360;this.parent.drawLayer.updateProperties(this._drawId,Q._mergeSVGProperties({bbox:this.#y(t)},this._drawOutlines.updateRotation(e))),this.#h(e)}show(t=this._isVisible){super.show(t),this.#d()}select(){super.select(),this.#u({hovered:!1,selected:!0})}unselect(){super.unselect(),this.#u({selected:!1})}pointerover(){if(!this.isSelected)this.#u({hovered:!0})}pointerleave(){if(!this.isSelected)this.#u({hovered:!1})}onScaleChanging(){if(!this.parent)return;let t=this._drawOutlines.updateParentDimensions(this.parentDimensions,this.parent.scale);if(t)this.#v(t)}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;if(this._isCopy)t=this.x,e=this.y;let s=super.render();if(this.constructor._hasDrawClass)s.classList.add("draw");let i=this.#t=document.createElement("div");if(s.append(i),i.setAttribute("aria-hidden","true"),i.className="internal",this._clipPathId)i.style.clipPath=this._clipPathId;if(Tn(this,i,["pointerover","pointerleave"]),this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy)this._moveAfterPaste(t,e);return s}static createDrawerInstance(t){st("Not implemented")}static _getDrawingTarget(t,{target:e}){return e}static _getPointerCoords({offsetX:t,offsetY:e,clientX:s,clientY:i},n=null){if(!n)return[t,e];let r=s-n.clientX,a=i-n.clientY;switch(this._currentParent.viewport.rotation){case 90:[r,a]=[a,-r];break;case 180:[r,a]=[-r,-a];break;case 270:[r,a]=[-a,r];break}return[n.offsetX+r,n.offsetY+a]}static _addDrawingListeners(t,e){}static _endDrawingSession(t=!1){return this._currentParent.endDrawingSession(t)}static startDrawing(t,e,s,i){let{pointerId:n,pointerType:r}=i;if(at.isInitializedAndDifferentPointerType(r))return;let a=this._getDrawingTarget(t,i),[o,l]=this._getPointerCoords(i),{viewport:{rotation:h}}=t,{x:c,y:d,width:u,height:f}=a.getBoundingClientRect(),p=Q.#i=new AbortController,g=t.combinedSignal(p);if(at.setPointer(r,n),window.addEventListener("pointerup",(y)=>{if(at.isSamePointerIdOrRemove(y.pointerId))this._endDraw(y)},{signal:g}),window.addEventListener("pointercancel",(y)=>{if(at.isSamePointerIdOrRemove(y.pointerId))this._endDrawingSession()},{signal:g}),window.addEventListener("pointerdown",(y)=>{if(!at.isSamePointerType(y.pointerType))return;if(at.initializeAndAddPointerId(y.pointerId),Q.#s.isCancellable())if(Q.#s.removeLastElement(),Q.#s.isEmpty())this._endDrawingSession(!0);else this._endDraw(null)},{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",zt,{signal:g}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:g}),a.addEventListener("touchmove",(y)=>{if(at.isSameTimeStamp(y.timeStamp))At(y)},{signal:g}),this._addDrawingListeners(a,g),t.toggleDrawing(),e._editorUndoBar?.hide(),Q.#s){t.drawLayer.updateProperties(this._currentDrawId,Q.#s.startNew(o,l,u,f,h));return}e.updateUIForDefaultProperties(this),Q.#s=this.createDrawerInstance({x:o,y:l,box:[c,d,u,f],rotation:h,parent:t,isLTR:s}),Q.#n=this.getDefaultDrawingOptions(),this._currentParent=t;let{id:m,clipPathId:v}=t.drawLayer.draw(this._mergeSVGProperties(Q.#n.toSVGProperties(),Q.#s.defaultSVGProperties),!0,this._hasClipPath);this._currentDrawId=m,Q.#a=this._hasClipPath?v:null}static _drawMove(t){if(at.isSameTimeStamp(t.timeStamp),!Q.#s)return;if(!at.isSamePointerId(t.pointerId))return;if(at.isUsingMultiplePointers()){this._endDraw(t);return}let e,s=t.getCoalescedEvents?.();if(s?.length){let i=[];for(let n of s)i.push(...this._getPointerCoords(n,t));e=Q.#s.addPoints(i)}else e=Q.#s.add(...this._getPointerCoords(t));this._currentParent.drawLayer.updateProperties(this._currentDrawId,e),at.setTimeStamp(t.timeStamp),At(t)}static _cleanup(t){if(t)this._currentDrawId=-1,this._currentParent=null,Q.#s=null,Q.#n=null,Q.#a=null,at.clearTimeStamp();if(Q.#i)Q.#i.abort(),Q.#i=null,at.clearPointerIds()}static _endDraw(t){let e=this._currentParent;if(!e)return;if(e.toggleDrawing(!0),this._cleanup(!1),e.drawLayer.updateProperties(this._currentDrawId,t?.target===e.div?Q.#s.end(...this._getPointerCoords(t)):Q.#s.end()),this.supportMultipleDrawings){let s=Q.#s,i=this._currentDrawId,n=s.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,s.setLastElement(n))},undo:()=>{e.drawLayer.updateProperties(i,s.removeLastElement())},mustExec:!1,type:q.DRAW_STEP});return}this.endDrawing(!1)}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(q.DRAW_STEP),!Q.#s.isEmpty()){let{pageDimensions:[s,i],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,clipPathId:Q.#a,drawOutlines:Q.#s.getOutlines(s*n,i*n,n,this._INNER_MARGIN),drawingOptions:Q.#n,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,i,n,r,a){st("Not implemented")}static async deserialize(t,e,s){let{rawDims:{pageWidth:i,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,i,n,this._INNER_MARGIN,t,s),l=await super.deserialize(t,e,s);return l.createDrawingOptions(t),l.#r({drawOutlines:o}),l.#m(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){let[e,s]=this.pageTranslation,[i,n]=this.pageDimensions;return this._drawOutlines.serialize([e,s,i,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class B{static PRECISION=0.0001;focusOutline=null;toSVGPath(){st("Abstract method `toSVGPath` must be implemented.")}get box(){st("Abstract getter `box` must be implemented.")}serialize(t,e){st("Abstract method `serialize` must be implemented.")}get defaultSVGProperties(){st("Abstract getter `defaultSVGProperties` must be implemented.")}get defaultProperties(){return this.defaultSVGProperties}getFocusSVGProperties(t){return null}get focusMustRemoveSelfIntersections(){return!1}updateProperty(t,e){return null}updateParentDimensions(t,e){return null}serializeQuadPoints(t,e){return null}updateRotation(t){return{}}getPathResizingSVGProperties(t){return{}}getPathResizedSVGProperties(t){return{}}getPathTranslatedSVGProperties(t,e){return{}}static _rotateBox([t,e,s,i],n){switch(n){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}static _rescale(t,e,s,i,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*i,r[a+1]=s+t[a+1]*n;return r}static _rescaleAndSwap(t,e,s,i,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*i,r[a+1]=s+t[a]*n;return r}static _translate(t,e,s,i){i||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)i[n]=e+t[n],i[n+1]=s+t[n+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,n){switch(n){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static createBezierPoints(t,e,s,i,n,r){return[(t+5*s)/6,(e+5*i)/6,(5*s+n)/6,(5*i+r)/6,(s+n)/2,(i+r)/2]}}class ue{#t;#e=[];#s;#i;#n=[];#a=new Float32Array(18);#r;#o;#l;#h;#u;#d;#f=[];static#g=8;static#m=2;static#c=ue.#g+ue.#m;constructor(t,e,s,i,n,r,a=0){this.#t=s,this.#d=n*i,this.#i=r,this.#a.set([NaN,NaN,NaN,NaN,t,e],6),this.#s=a,this.#h=ue.#g*i,this.#l=ue.#c*i,this.#u=i,this.#f.push(t,e)}isEmpty(){return isNaN(this.#a[8])}isCancellable(){return this.#f.length<=10}removeLastElement(){return this.#a.fill(NaN),this.#n.length=this.#e.length=this.#f.length=0,{path:{d:""}}}#p(){let t=this.#a.subarray(4,6),e=this.#a.subarray(16,18),[s,i,n,r]=this.#t;return[(this.#r+(t[0]-e[0])/2-s)/n,(this.#o+(t[1]-e[1])/2-i)/r,(this.#r+(e[0]-t[0])/2-s)/n,(this.#o+(e[1]-t[1])/2-i)/r]}add(t,e){this.#r=t,this.#o=e;let[s,i,n,r]=this.#t,[a,o,l,h]=this.#a.subarray(8,12),c=t-l,d=e-h,u=Math.hypot(c,d);if(u<this.#l)return!1;let f=u-this.#h,p=f/u,g=p*c,m=p*d,v=a,y=o;a=l,o=h,l+=g,h+=m,this.#f?.push(t,e);let S=-m/f,A=g/f,b=S*this.#d,w=A*this.#d;if(this.#a.set(this.#a.subarray(2,8),0),this.#a.set([l+b,h+w],4),this.#a.set(this.#a.subarray(14,18),12),this.#a.set([l-b,h-w],16),isNaN(this.#a[6])){if(this.#n.length===0)this.#a.set([a+b,o+w],2),this.#n.push(NaN,NaN,NaN,NaN,(a+b-s)/n,(o+w-i)/r),this.#a.set([a-b,o-w],14),this.#e.push(NaN,NaN,NaN,NaN,(a-b-s)/n,(o-w-i)/r);return this.#a.set([v,y,a,o,l,h],6),!this.isEmpty()}if(this.#a.set([v,y,a,o,l,h],6),Math.abs(Math.atan2(y-o,v-a)-Math.atan2(m,g))<Math.PI/2)return[a,o,l,h]=this.#a.subarray(2,6),this.#n.push(NaN,NaN,NaN,NaN,((a+l)/2-s)/n,((o+h)/2-i)/r),[a,o,v,y]=this.#a.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((v+a)/2-s)/n,((y+o)/2-i)/r),!0;return[v,y,a,o,l,h]=this.#a.subarray(0,6),this.#n.push(((v+5*a)/6-s)/n,((y+5*o)/6-i)/r,((5*a+l)/6-s)/n,((5*o+h)/6-i)/r,((a+l)/2-s)/n,((o+h)/2-i)/r),[l,h,a,o,v,y]=this.#a.subarray(12,18),this.#e.push(((v+5*a)/6-s)/n,((y+5*o)/6-i)/r,((5*a+l)/6-s)/n,((5*o+h)/6-i)/r,((a+l)/2-s)/n,((o+h)/2-i)/r),!0}toSVGPath(){if(this.isEmpty())return"";let t=this.#n,e=this.#e;if(isNaN(this.#a[6])&&!this.isEmpty())return this.#v();let s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)if(isNaN(t[i]))s.push(`L${t[i+4]} ${t[i+5]}`);else s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);this.#b(s);for(let i=e.length-6;i>=6;i-=6)if(isNaN(e[i]))s.push(`L${e[i+4]} ${e[i+5]}`);else s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return this.#y(s),s.join(" ")}#v(){let[t,e,s,i]=this.#t,[n,r,a,o]=this.#p();return`M${(this.#a[2]-t)/s} ${(this.#a[3]-e)/i} L${(this.#a[4]-t)/s} ${(this.#a[5]-e)/i} L${n} ${r} L${a} ${o} L${(this.#a[16]-t)/s} ${(this.#a[17]-e)/i} L${(this.#a[14]-t)/s} ${(this.#a[15]-e)/i} Z`}#y(t){let e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#b(t){let[e,s,i,n]=this.#t,r=this.#a.subarray(4,6),a=this.#a.subarray(16,18),[o,l,h,c]=this.#p();t.push(`L${(r[0]-e)/i} ${(r[1]-s)/n} L${o} ${l} L${h} ${c} L${(a[0]-e)/i} ${(a[1]-s)/n}`)}newFreeDrawOutline(t,e,s,i,n,r){return new Mi(t,e,s,i,n,r)}getOutlines(){let t=this.#n,e=this.#e,s=this.#a,[i,n,r,a]=this.#t,o=new Float32Array((this.#f?.length??0)+2);for(let c=0,d=o.length-2;c<d;c+=2)o[c]=(this.#f[c]-i)/r,o[c+1]=(this.#f[c+1]-n)/a;if(o[o.length-2]=(this.#r-i)/r,o[o.length-1]=(this.#o-n)/a,isNaN(s[6])&&!this.isEmpty())return this.#A(o);let l=new Float32Array(this.#n.length+24+this.#e.length),h=t.length;for(let c=0;c<h;c+=2){if(isNaN(t[c])){l[c]=l[c+1]=NaN;continue}l[c]=t[c],l[c+1]=t[c+1]}h=this.#w(l,h);for(let c=e.length-6;c>=6;c-=6)for(let d=0;d<6;d+=2){if(isNaN(e[c+d])){l[h]=l[h+1]=NaN,h+=2;continue}l[h]=e[c+d],l[h+1]=e[c+d+1],h+=2}return this.#x(l,h),this.newFreeDrawOutline(l,o,this.#t,this.#u,this.#s,this.#i)}#A(t){let e=this.#a,[s,i,n,r]=this.#t,[a,o,l,h]=this.#p(),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/r,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/r,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/r],0),this.newFreeDrawOutline(c,t,this.#t,this.#u,this.#s,this.#i)}#x(t,e){let s=this.#e;return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6}#w(t,e){let s=this.#a.subarray(4,6),i=this.#a.subarray(16,18),[n,r,a,o]=this.#t,[l,h,c,d]=this.#p();return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o],e),e+=24}}class Mi extends B{#t;#e=new Float32Array(4);#s;#i;#n;#a;#r;constructor(t,e,s,i,n,r){super();this.#r=t,this.#n=e,this.#t=s,this.#a=i,this.#s=n,this.#i=r,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#o(r);let[a,o,l,h]=this.#e;for(let c=0,d=t.length;c<d;c+=2)t[c]=(t[c]-a)/l,t[c+1]=(t[c+1]-o)/h;for(let c=0,d=e.length;c<d;c+=2)e[c]=(e[c]-a)/l,e[c+1]=(e[c+1]-o)/h}toSVGPath(){let t=[`M${this.#r[4]} ${this.#r[5]}`];for(let e=6,s=this.#r.length;e<s;e+=6){if(isNaN(this.#r[e])){t.push(`L${this.#r[e+4]} ${this.#r[e+5]}`);continue}t.push(`C${this.#r[e]} ${this.#r[e+1]} ${this.#r[e+2]} ${this.#r[e+3]} ${this.#r[e+4]} ${this.#r[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,i],n){let r=s-t,a=i-e,o,l;switch(n){case 0:o=B._rescale(this.#r,t,i,r,-a),l=B._rescale(this.#n,t,i,r,-a);break;case 90:o=B._rescaleAndSwap(this.#r,t,e,r,a),l=B._rescaleAndSwap(this.#n,t,e,r,a);break;case 180:o=B._rescale(this.#r,s,e,-r,a),l=B._rescale(this.#n,s,e,-r,a);break;case 270:o=B._rescaleAndSwap(this.#r,s,i,-r,-a),l=B._rescaleAndSwap(this.#n,s,i,-r,-a);break}return{outline:Array.from(o),points:[Array.from(l)]}}#o(t){let e=this.#r,s=e[4],i=e[5],n=[s,i,s,i],r=s,a=i,o=s,l=i,h=t?Math.max:Math.min,c=new Float32Array(4);for(let u=6,f=e.length;u<f;u+=6){let p=e[u+4],g=e[u+5];if(isNaN(e[u])){if(L.pointBoundingBox(p,g,n),a>g)r=p,a=g;else if(a===g)r=h(r,p);if(l<g)o=p,l=g;else if(l===g)o=h(o,p)}else{if(c.set(ee,0),L.bezierBoundingBox(s,i,...e.slice(u,u+6),c),L.rectBoundingBox(...c,n),a>c[1])r=c[0],a=c[1];else if(a===c[1])r=h(r,c[0]);if(l<c[3])o=c[2],l=c[3];else if(l===c[3])o=h(o,c[2])}s=p,i=g}let d=this.#e;d[0]=n[0]-this.#s,d[1]=n[1]-this.#s,d[2]=n[2]-n[0]+2*this.#s,d[3]=n[3]-n[1]+2*this.#s,this.firstPoint=[r,a],this.lastPoint=[o,l]}get box(){return this.#e}newOutliner(t,e,s,i,n,r,a=0){return new ue(t,e,s,i,n,r,a)}updateThickness(t){let e=this.getNewOutline(t);return this.#r=e.#r,this.#n=e.#n,this.#e.set(e.#e),this.firstPoint=e.firstPoint,this.lastPoint=e.lastPoint,this.#e}getNewOutline(t,e){let[s,i,n,r]=this.#e,[a,o,l,h]=this.#t,c=n*l,d=r*h,u=s*l+a,f=i*h+o,p=this.#n,g=this.newOutliner(p[0]*c+u,p[1]*d+f,this.#t,this.#a,t,this.#i,e??this.#s);for(let m=2,v=p.length;m<v;m+=2)g.add(p[m]*c+u,p[m+1]*d+f);return g.getOutlines()}}function $r(t){return{bbox:t.box,root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:t.isFree},path:{d:t.toSVGPath()}}}function Gr(t,e){let{focusOutline:s}=t;return{bbox:B._rotateBox(s.box,e),root:{"data-main-rotation":e},rootClass:{highlightOutline:!0,free:t.isFree},path:{d:s.toSVGPath()}}}class bs{#t;#e;#s;#i=[];#n=[];constructor(t,e=0,s=0,i=!0){let n=ee.slice(),r=4,a=0.0001;for(let{x:g,y:m,width:v,height:y}of t){let S=Math.floor((g-e)/0.0001)*0.0001,A=Math.ceil((g+v+e)/0.0001)*0.0001,b=Math.floor((m-e)/0.0001)*0.0001,w=Math.ceil((m+y+e)/0.0001)*0.0001,x=[S,b,w,!0],T=[A,b,w,!1];this.#i.push(x,T),L.rectBoundingBox(S,b,A,w,n)}let o=n[2]-n[0]+2*s,l=n[3]-n[1]+2*s,h=n[0]-s,c=n[1]-s,d=i?-1/0:1/0,u=1/0,f=this.#i.at(i?-1:-2),p=[f[0],f[2]];for(let g of this.#i){let[m,v,y,S]=g;if(!S&&i){if(v<u)u=v,d=m;else if(v===u)d=Math.max(d,m)}else if(S&&!i){if(v<u)u=v,d=m;else if(v===u)d=Math.min(d,m)}g[0]=(m-h)/o,g[1]=(v-c)/l,g[2]=(y-c)/l}this.#t=new Float32Array([h,c,o,l]),this.#e=[d,u],this.#s=p}getOutlines(){this.#i.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);let t=[];for(let e of this.#i)if(e[3])t.push(...this.#h(e)),this.#o(e);else this.#l(e),t.push(...this.#h(e));return this.#a(t)}#a(t){let e=[],s=new Set;for(let r of t){let[a,o,l]=r;e.push([a,o,r],[a,l,r])}e.sort((r,a)=>r[1]-a[1]||r[0]-a[0]);for(let r=0,a=e.length;r<a;r+=2){let o=e[r][2],l=e[r+1][2];o.push(l),l.push(o),s.add(o),s.add(l)}let i=[],n;while(s.size>0){let r=s.values().next().value,[a,o,l,h,c]=r;s.delete(r);let d=a,u=o;n=[a,l],i.push(n);while(!0){let f;if(s.has(h))f=h;else if(s.has(c))f=c;else break;if(s.delete(f),[a,o,l,h,c]=f,d!==a)n.push(d,u,a,u===o?o:l),d=a;u=u===o?l:o}n.push(d,u)}return new As(i,this.#t,this.#e,this.#s)}#r(t){let e=this.#n,s=0,i=e.length-1;while(s<=i){let n=s+i>>1,r=e[n][0];if(r===t)return n;if(r<t)s=n+1;else i=n-1}return i+1}#o([,t,e]){let s=this.#r(t);this.#n.splice(s,0,[t,e])}#l([,t,e]){let s=this.#r(t);for(let i=s;i<this.#n.length;i++){let[n,r]=this.#n[i];if(n!==t)break;if(n===t&&r===e){this.#n.splice(i,1);return}}for(let i=s-1;i>=0;i--){let[n,r]=this.#n[i];if(n!==t)break;if(n===t&&r===e){this.#n.splice(i,1);return}}}#h(t){let[e,s,i]=t,n=[[e,s,i]],r=this.#r(i);for(let a=0;a<r;a++){let[o,l]=this.#n[a];for(let h=0,c=n.length;h<c;h++){let[,d,u]=n[h];if(l<=d||u<=o)continue;if(d>=o){if(u>l)n[h][1]=l;else{if(c===1)return[];n.splice(h,1),h--,c--}continue}if(n[h][2]=o,u>l)n.push([e,l,u])}}return n}}class As extends B{#t;#e=null;#s;constructor(t,e,s,i){super();this.#s=t,this.#t=e,this.firstPoint=s,this.lastPoint=i}static build(t,e){let s=new bs(t,0.001).getOutlines();return s.#e=t,s.focusOutline=new bs(t,0.0025,0.001,e).getOutlines(),s}get isFree(){return!1}get defaultSVGProperties(){return $r(this)}getFocusSVGProperties(t){return Gr(this,t)}updateRotation(t){return{root:{"data-main-rotation":t}}}serializeQuadPoints([t,e],[s,i]){let n=this.#e,r=new Float32Array(n.length*8),a=0;for(let{x:o,y:l,width:h,height:c}of n){let d=o*s+t,u=(1-l)*i+e;r[a]=r[a+4]=d,r[a+1]=r[a+3]=u,r[a+2]=r[a+6]=d+h*s,r[a+5]=r[a+7]=u-c*i,a+=8}return r}toSVGPath(){let t=[];for(let e of this.#s){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){let r=e[n],a=e[n+1];if(r===s)t.push(`V${a}`),i=a;else if(a===i)t.push(`H${r}`),s=r}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],n){let r=[],a=s-t,o=i-e;for(let l of this.#s){let h=Array(l.length);for(let c=0;c<l.length;c+=2)h[c]=t+l[c]*a,h[c+1]=i-l[c+1]*o;r.push(h)}return r}get box(){return this.#t}}class Hs extends ue{newFreeDrawOutline(t,e,s,i,n,r){return new Oi(t,e,s,i,n,r)}}class Vr{#t;#e;constructor(t,e,s,i,n,r,a){this.#t=new Hs(t,e,s,i,n,r,a),this.#e=n}add(t,e){return this.#t.add(t,e)?{path:{d:this.#t.toSVGPath()}}:null}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)e=this.#t.add(t[s],t[s+1])||e;return e?{path:{d:this.#t.toSVGPath()}}:null}end(t,e){return t===void 0?null:this.add(t,e)}isEmpty(){return this.#t.isEmpty()}isCancellable(){return this.#t.isCancellable()}removeLastElement(){return this.#t.removeLastElement()}updateProperty(t,e){return null}getOutlines(){let t=this.#t.getOutlines();return t.buildFocusOutline(2*this.#e),t}get defaultSVGProperties(){return{bbox:[0,0,1,1],root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:!0},path:{d:this.#t.toSVGPath()}}}}class Oi extends Mi{static#t=1.5;newOutliner(t,e,s,i,n,r,a=0){return new Hs(t,e,s,i,n,r,a)}get isFree(){return!0}buildFocusOutline(t){this.focusOutline=this.getNewOutline(t/2+Oi.#t,0.0025)}get defaultSVGProperties(){return $r(this)}getFocusSVGProperties(t){return Gr(this,t)}get focusMustRemoveSelfIntersections(){return!0}updateRotation(t){return{root:{"data-main-rotation":t}}}updateProperty(t,e){if(t!=="thickness")return null;let s=this.updateThickness(e/2);return this.buildFocusOutline(e),s}getPathResizedSVGProperties(){return{path:{d:this.toSVGPath()}}}}class Ri extends _s{constructor(t=null){super();super.updateProperties(t)}updateSVGProperty(t,e){if(t!=="thickness")super.updateSVGProperty(t,e)}clone(){let t=new Ri;return t.updateAll(this),t}}class Vt extends Q{#t=null;#e=0;#s=null;#i=0;#n="";#a="";static _DEFAULT_OPACITY=1;static _DEFAULT_THICKNESS=12;static _defaultDrawingOptions=null;static _type="highlight";static _editorType=Y.HIGHLIGHT;static get _keyboardManager(){let t=Vt.prototype;return j(this,"_keyboardManager",new Ft([[["ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"});this.#t=t.anchorNode||null,this.#e=t.anchorOffset||0,this.#s=t.focusNode||null,this.#i=t.focusOffset||0,this.#n=t.methodOfCreation||(this._drawOutlines?.isFree?"main_toolbar":""),this.#a=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",this.rotate()}static initialize(t,e){H.initialize(t,e),this._defaultDrawingOptions||=new Ri({fill:e.highlightColors?.values().next().value||"#fff066","fill-opacity":Vt._DEFAULT_OPACITY,thickness:Vt._DEFAULT_THICKNESS})}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get typesMap(){return j(this,"typesMap",new Map([[q.HIGHLIGHT_COLOR,"fill"],[q.HIGHLIGHT_THICKNESS,"thickness"]]))}static get isDrawer(){return!1}static get _hasClipPath(){return!0}static get _hasDrawClass(){return!1}_addOutlines(t){let{boxes:e,drawOutlines:s}=t;if(!e&&!s)return;if(this._drawingOptions||=t.drawingOptions||Vt.getDefaultDrawingOptions(),e)t={...t,drawOutlines:As.build(e,this._uiManager.direction==="ltr")};super._addOutlines(t)}get colorType(){return q.HIGHLIGHT_COLOR}get color(){return this._drawingOptions.fill}get opacity(){return this._drawingOptions["fill-opacity"]}get _opacityName(){return"fill-opacity"}get _drawRotation(){return this._drawOutlines?.isFree?this.rotation:0}get isResizable(){return!1}get _mustBeDisabledOnCommit(){return!1}get _mustFixPosition(){return!this._drawOutlines?.isFree}get telemetryInitialData(){return{action:"added",type:this._drawOutlines.isFree?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this._drawingOptions.thickness,methodOfCreation:this.#n}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}translateInPage(t,e){}get toolbarPosition(){return this.#r(this._drawOutlines.focusOutline.lastPoint)}get commentButtonPosition(){return this.#r(this._drawOutlines.firstPoint)}#r([t,e]){let[s,i,n,r]=this._drawOutlines.box;return[(t-s)/n,(e-i)/r]}updateParams(t,e){switch(t){case q.HIGHLIGHT_COLOR:this._updateColorAndOpacity(e,Vt._DEFAULT_OPACITY,t),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0);break;case q.HIGHLIGHT_THICKNESS:super.updateParams(t,e),this._reportTelemetry({action:"thickness_changed",thickness:e},!0);break}}get propertiesToUpdate(){let t=super.propertiesToUpdate;return t.push([q.HIGHLIGHT_FREE,this._drawOutlines.isFree]),t}get toolbarButtons(){if(this._uiManager.highlightColors)return this._colorPicker=new jt({editor:this}),[["colorPicker",this._colorPicker]];return super.toolbarButtons}fixAndSetPosition(){return super.fixAndSetPosition(this._drawRotation)}getRect(t,e){return super.getRect(t,e,this._drawRotation)}onceAdded(t){if(!this.annotationElementId)this.parent.addUndoableEditor(this);if(t)this.div.focus()}remove(){this._reportTelemetry({action:"deleted"}),super.remove()}render(){if(this.div)return this.div;let t=super.render();if(this.#a)t.setAttribute("aria-label",this.#a),t.setAttribute("role","mark");if(this._drawOutlines.isFree)t.classList.add("free");else t.addEventListener("keydown",this.#o.bind(this),{signal:this._uiManager._signal});return this.enableEditing(),t}#o(t){Vt._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#l(!0);break;case 1:case 3:this.#l(!1);break}}#l(t){if(!this.#t)return;let e=window.getSelection();if(t)e.setPosition(this.#t,this.#e);else e.setPosition(this.#s,this.#i)}unselect(){if(super.unselect(),!this._drawOutlines.isFree)this.#l(!1)}static createDrawerInstance({x:t,y:e,box:s,parent:i,isLTR:n}){return new Vr(t,e,s,i.scale,this._defaultDrawingOptions.thickness/2,n,0.001)}static _getDrawingTarget(t,{target:e}){return e.closest(".textLayer")}static _getPointerCoords({x:t,y:e}){return[t,e]}static _addDrawingListeners(t,e){t.classList.add("free"),e.addEventListener("abort",()=>t.classList.remove("free"),{once:!0}),window.addEventListener("blur",()=>this._endDraw(null),{signal:e}),window.addEventListener("pointerdown",At,{capture:!0,passive:!1,signal:e})}static _endDrawingSession(t=!1){return this.endDrawing(t)}createDrawingOptions({color:t,opacity:e,thickness:s}){let{_defaultDrawingOptions:i,_DEFAULT_OPACITY:n}=Vt;this._drawingOptions=Vt.getDefaultDrawingOptions({fill:L.makeHexColor(...t),"fill-opacity":e||n,thickness:s||i.thickness})}static deserializeDraw(t,e,s,i,n,r,a){let{quadPoints:o}=r;if(o){let u=[];for(let f=0,p=o.length;f<p;f+=8)u.push({x:(o[f]-t)/s,y:1-(o[f+1]-e)/i,width:(o[f+2]-o[f])/s,height:(o[f+1]-o[f+5])/i});return As.build(u,a.direction==="ltr")}let l=r.thickness||this._defaultDrawingOptions.thickness,h=(r.inkLists||r.outlines.points)[0],c=new Hs(h[0]-t,i-(h[1]-e),[0,0,s,i],1,l/2,!0,0.001);for(let u=0,f=h.length;u<f;u+=2)c.add(h[u]-t,i-(h[u+1]-e));let d=c.getOutlines();return d.buildFocusOutline(l),d}static async deserialize(t,e,s){let i=null;if(t instanceof Ti){let{data:{quadPoints:r,rect:a,rotation:o,id:l,color:h,opacity:c,popupRef:d,richText:u,contentsObj:f,creationDate:p,modificationDate:g},parent:{page:{pageNumber:m}}}=t;i=t={annotationType:Y.HIGHLIGHT,color:Array.from(h),opacity:c,quadPoints:r,pageIndex:m-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:d,richText:u,comment:f?.str||null,creationDate:p,modificationDate:g}}else if(t instanceof Bs){let{data:{inkLists:r,rect:a,rotation:o,id:l,color:h,borderStyle:{rawWidth:c},popupRef:d,richText:u,contentsObj:f,creationDate:p,modificationDate:g},parent:{page:{pageNumber:m}}}=t;i=t={annotationType:Y.HIGHLIGHT,color:Array.from(h),thickness:c,inkLists:r,pageIndex:m-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:d,richText:u,comment:f?.str||null,creationDate:p,modificationDate:g}}let n=await super.deserialize(t,e,s);if(n._initialData=i,t.comment)n.setCommentData(t);return n}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=super.serialize(t);if(Object.assign(e,{color:H._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),opacity:this.opacity,thickness:this._drawingOptions.thickness,quadPoints:this._drawOutlines.serializeQuadPoints(this.pageTranslation,this.pageDimensions),outlines:this._drawOutlines.serialize(e.rect,this._drawRotation)}),this.addComment(e),this.annotationElementId&&!this.#h(e))return null;return e.id=this.annotationElementId,e}#h(t){let{color:e}=this._initialData;return this.hasEditedComment||t.color.some((s,i)=>s!==e[i])}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;return t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class zr{#t=new Float64Array(6);#e=new Float64Array(2);#s;#i;#n;#a;#r;#o="";#l=0;#h=new Pe;#u;#d;constructor(t,e,s,i,n,r){this.#u=s,this.#d=i,this.#n=n,this.#a=r,[t,e]=this.#f(t,e);let a=this.#s=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e],this.#i=[{line:a,points:this.#r}],this.#t.set(a,0),this.#e.set([t,e],0)}updateProperty(t,e){if(t==="stroke-width")this.#a=e}#f(t,e){return B._normalizePoint(t,e,this.#u,this.#d,this.#n)}isEmpty(){return!this.#i?.length}isCancellable(){return this.#r.length<=10}add(t,e){if(this.#g(t,e))this.toSVGPath();return{path:{d:this.#m()}}}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2){if(!this.#g(t[s],t[s+1]))continue;if(e=!0,this.#r.length<=6)this.toSVGPath(),e=!1}if(e)this.toSVGPath();return{path:{d:this.#m()}}}#g(t,e){[t,e]=this.#f(t,e),this.#e.set([t,e],0);let[s,i,n,r]=this.#t.subarray(2,6),a=t-n,o=e-r;if(Math.hypot(this.#u*a,this.#d*o)<=2)return!1;if(this.#r.push(t,e),isNaN(s))return this.#t.set([n,r,t,e],2),this.#s.push(NaN,NaN,NaN,NaN,t,e),!0;if(isNaN(this.#t[0]))this.#s.splice(6,6);return this.#t.set([s,i,n,r,t,e],0),this.#s.push(...B.createBezierPoints(s,i,n,r,t,e)),!0}end(t,e){if(t!==void 0&&this.#g(t,e))return{path:{d:this.toSVGPath()}};if(this.#r.length===2)return{path:{d:this.toSVGPath()}};return{path:{d:this.#o}}}startNew(t,e,s,i,n){this.#u=s,this.#d=i,this.#n=n,[t,e]=this.#f(t,e);let r=this.#s=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e],this.#e.set([t,e],0);let a=this.#i.at(-1);if(a)a.line=new Float32Array(a.line),a.points=new Float32Array(a.points);return this.#i.push({line:r,points:this.#r}),this.#t.set(r,0),this.#l=0,this.toSVGPath(),null}getLastElement(){return this.#i.at(-1)}setLastElement(t){if(!this.#i)return this.#h.setLastElement(t);return this.#i.push(t),this.#s=t.line,this.#r=t.points,this.#l=0,{path:{d:this.toSVGPath()}}}removeLastElement(){if(!this.#i)return this.#h.removeLastElement();this.#i.pop(),this.#o="";for(let t=0,e=this.#i.length;t<e;t++){let{line:s,points:i}=this.#i[t];this.#s=s,this.#r=i,this.#l=0,this.toSVGPath()}return{path:{d:this.#o}}}#m(){let t=B.svgRound(this.#e[0]),e=B.svgRound(this.#e[1]);if(this.#r.length===2){let s=B.svgRound(this.#s[4]),i=B.svgRound(this.#s[5]);return`${this.#o} M ${s} ${i} L ${t} ${e}`}return`${this.#o} L ${t} ${e}`}toSVGPath(){let t=B.svgRound(this.#s[4]),e=B.svgRound(this.#s[5]);if(this.#r.length===2)return this.#o=`${this.#o} M ${t} ${e} Z`,this.#o;if(this.#r.length<=6){let i=this.#o.lastIndexOf("M");this.#o=`${this.#o.slice(0,i)} M ${t} ${e}`,this.#l=6}if(this.#r.length===4){let i=B.svgRound(this.#s[10]),n=B.svgRound(this.#s[11]);return this.#o=`${this.#o} L ${i} ${n}`,this.#l=12,this.#o}let s=[];if(this.#l===0)s.push(`M ${t} ${e}`),this.#l=6;for(let i=this.#l,n=this.#s.length;i<n;i+=6){let[r,a,o,l,h,c]=this.#s.slice(i,i+6).map(B.svgRound);s.push(`C${r} ${a} ${o} ${l} ${h} ${c}`)}return this.#o+=s.join(" "),this.#l=this.#s.length,this.#o}getOutlines(t,e,s,i){let n=this.#i.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#h.build(this.#i,t,e,s,this.#n,this.#a,i),this.#t=null,this.#s=null,this.#i=null,this.#o=null,this.#h}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Pe extends B{#t;#e=0;#s;#i;#n;#a;#r;#o;#l;build(t,e,s,i,n,r,a){this.#n=e,this.#a=s,this.#r=i,this.#o=n,this.#l=r,this.#s=a??0,this.#i=t,this.#d()}get thickness(){return this.#l}setLastElement(t){return this.#i.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#i.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#i){if(t.push(`M${B.svgRound(e[4])} ${B.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12&&isNaN(e[6])){t.push(`L${B.svgRound(e[10])} ${B.svgRound(e[11])}`);continue}for(let s=6,i=e.length;s<i;s+=6){let[n,r,a,o,l,h]=e.subarray(s,s+6).map(B.svgRound);t.push(`C${n} ${r} ${a} ${o} ${l} ${h}`)}}return t.join("")}serialize([t,e,s,i],n){let r=[],a=[],[o,l,h,c]=this.#u(),d,u,f,p,g,m,v,y,S;switch(this.#o){case 0:S=B._rescale,d=t,u=e+i,f=s,p=-i,g=t+o*s,m=e+(1-l-c)*i,v=t+(o+h)*s,y=e+(1-l)*i;break;case 90:S=B._rescaleAndSwap,d=t,u=e,f=s,p=i,g=t+l*s,m=e+o*i,v=t+(l+c)*s,y=e+(o+h)*i;break;case 180:S=B._rescale,d=t+s,u=e,f=-s,p=i,g=t+(1-o-h)*s,m=e+l*i,v=t+(1-o)*s,y=e+(l+c)*i;break;case 270:S=B._rescaleAndSwap,d=t+s,u=e+i,f=-s,p=-i,g=t+(1-l-c)*s,m=e+(1-o-h)*i,v=t+(1-l)*s,y=e+(1-o)*i;break}for(let{line:A,points:b}of this.#i)r.push(S(A,d,u,f,p,n?Array(A.length):null)),a.push(S(b,d,u,f,p,n?Array(b.length):null));return{lines:r,points:a,rect:[g,m,v,y]}}static deserialize(t,e,s,i,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){let h=[],c,d,u,f,p;switch(o){case 0:p=B._rescale,c=-t/s,d=e/i+1,u=1/s,f=-1/i;break;case 90:p=B._rescaleAndSwap,c=-e/i,d=-t/s,u=1/i,f=1/s;break;case 180:p=B._rescale,c=t/s+1,d=-e/i,u=-1/s,f=1/i;break;case 270:p=B._rescaleAndSwap,c=e/i+1,d=t/s+1,u=-1/i,f=-1/s;break}if(!r){r=[];for(let m of a){let v=m.length;if(v===2){r.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1]]));continue}if(v===4){r.push(new Float32Array([NaN,NaN,NaN,NaN,m[0],m[1],NaN,NaN,NaN,NaN,m[2],m[3]]));continue}let y=new Float32Array(3*(v-2));r.push(y);let[S,A,b,w]=m.subarray(0,4);y.set([NaN,NaN,NaN,NaN,S,A],0);for(let x=4;x<v;x+=2){let T=m[x],E=m[x+1];y.set(B.createBezierPoints(S,A,b,w,T,E),(x-2)*3),[S,A,b,w]=[b,w,T,E]}}}for(let m=0,v=r.length;m<v;m++)h.push({line:p(r[m].map((y)=>y??NaN),c,d,u,f),points:p(a[m].map((y)=>y??NaN),c,d,u,f)});let g=new this.prototype.constructor;return g.build(h,s,i,1,o,l,n),g}#h(t=this.#l){let e=this.#s+t/2*this.#r;return this.#o%180===0?[e/this.#n,e/this.#a]:[e/this.#a,e/this.#n]}#u(){let[t,e,s,i]=this.#t,[n,r]=this.#h(0);return[t+n,e+r,s-2*n,i-2*r]}#d(){let t=this.#t=de.slice();for(let{line:i}of this.#i){if(i.length<=12){for(let a=4,o=i.length;a<o;a+=6)L.pointBoundingBox(i[a],i[a+1],t);continue}let n=i[4],r=i[5];for(let a=6,o=i.length;a<o;a+=6){let[l,h,c,d,u,f]=i.subarray(a,a+6);L.bezierBoundingBox(n,r,l,h,c,d,u,f,t),n=u,r=f}}let[e,s]=this.#h();t[0]=ut(t[0]-e,0,1),t[1]=ut(t[1]-s,0,1),t[2]=ut(t[2]+e,0,1),t[3]=ut(t[3]+s,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#f(e):null}#f(t){let[e,s]=this.#h();this.#l=t;let[i,n]=this.#h(),[r,a]=[i-e,n-s],o=this.#t;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],s){let[i,n]=this.#h();this.#n=t,this.#a=e,this.#r=s;let[r,a]=this.#h(),o=r-i,l=a-n,h=this.#t;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(B.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${B.svgRound(t)} ${B.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#t,s=0,i=0,n=0,r=0,a=0,o=0;switch(this.#e){case 90:i=e/t,n=-t/e,a=t;break;case 180:s=-1,r=-1,a=t,o=e;break;case 270:i=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${s} ${i} ${n} ${r} ${B.svgRound(a)} ${B.svgRound(o)})`}getPathResizingSVGProperties([t,e,s,i]){let[n,r]=this.#h(),[a,o,l,h]=this.#t;if(Math.abs(l-n)<=B.PRECISION||Math.abs(h-r)<=B.PRECISION){let p=t+s/2-(a+l/2),g=e+i/2-(o+h/2);return{path:{"transform-origin":`${B.svgRound(t)} ${B.svgRound(e)}`,transform:`${this.rotationTransform} translate(${p} ${g})`}}}let c=(s-2*n)/(l-2*n),d=(i-2*r)/(h-2*r),u=l/s,f=h/i;return{path:{"transform-origin":`${B.svgRound(a)} ${B.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${f}) translate(${B.svgRound(n)} ${B.svgRound(r)}) scale(${c} ${d}) translate(${B.svgRound(-n)} ${B.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,s,i]){let[n,r]=this.#h(),a=this.#t,[o,l,h,c]=a;if(a[0]=t,a[1]=e,a[2]=s,a[3]=i,Math.abs(h-n)<=B.PRECISION||Math.abs(c-r)<=B.PRECISION){let g=t+s/2-(o+h/2),m=e+i/2-(l+c/2);for(let{line:v,points:y}of this.#i)B._translate(v,g,m,v),B._translate(y,g,m,y);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${B.svgRound(t)} ${B.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let d=(s-2*n)/(h-2*n),u=(i-2*r)/(c-2*r),f=-d*(o+n)+t+n,p=-u*(l+r)+e+r;if(d!==1||u!==1||f!==0||p!==0)for(let{line:g,points:m}of this.#i)B._rescale(g,f,p,d,u,g),B._rescale(m,f,p,d,u,m);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${B.svgRound(t)} ${B.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){let[i,n]=s,r=this.#t,a=t-r[0],o=e-r[1];if(this.#n===i&&this.#a===n)for(let{line:l,points:h}of this.#i)B._translate(l,a,o,l),B._translate(h,a,o,h);else{let l=this.#n/i,h=this.#a/n;this.#n=i,this.#a=n;for(let{line:c,points:d}of this.#i)B._rescale(c,a,o,l,h,c),B._rescale(d,a,o,l,h,d);r[2]*=l,r[3]*=h}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${B.svgRound(t)} ${B.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${B.svgRound(t[0])} ${B.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Us extends _s{constructor(t){super();this._viewParameters=t,super.updateProperties({fill:"none",stroke:H._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){if(t==="stroke-width")e??=this["stroke-width"],e*=this._viewParameters.realScale;super.updateSVGProperty(t,e)}clone(){let t=new Us(this._viewParameters);return t.updateAll(this),t}}class Di extends Q{static _type="ink";static _editorType=Y.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"});this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){H.initialize(t,e),this._defaultDrawingOptions=new Us(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return j(this,"typesMap",new Map([[q.INK_THICKNESS,"stroke-width"],[q.INK_COLOR,"stroke"],[q.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance({x:t,y:e,box:[,,s,i],rotation:n}){return new zr(t,e,s,i,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,s,i,n,r){return Pe.deserialize(t,e,s,i,n,r)}static async deserialize(t,e,s){let i=null;if(t instanceof Bs){let{data:{inkLists:r,rect:a,rotation:o,id:l,color:h,opacity:c,borderStyle:{rawWidth:d},popupRef:u,richText:f,contentsObj:p,creationDate:g,modificationDate:m},parent:{page:{pageNumber:v}}}=t;i=t={annotationType:Y.INK,color:Array.from(h),thickness:d,opacity:c,paths:{points:r},boxes:null,pageIndex:v-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:u,richText:f,comment:p?.str||null,creationDate:g,modificationDate:m}}let n=await super.deserialize(t,e,s);if(n._initialData=i,t.comment)n.setCommentData(t);return n}get toolbarButtons(){return this._colorPicker||=new ze(this),[["colorPicker",this._colorPicker]]}get colorType(){return q.INK_COLOR}get colorAndOpacityType(){return q.INK_COLOR_AND_OPACITY}get opacityType(){return q.INK_OPACITY}updateParams(t,e){if(t===q.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(e.color,e.opacity);return}super.updateParams(t,e)}static updateDefaultParams(t,e){if(t===q.INK_COLOR_AND_OPACITY){super.updateDefaultParams(q.INK_COLOR,e.color),super.updateDefaultParams(q.INK_OPACITY,e.opacity);return}super.updateDefaultParams(t,e)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:s}=this;e.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let t=this._currentParent;if(!t)return;super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}createDrawingOptions({color:t,thickness:e,opacity:s}){this._drawingOptions=Di.getDefaultDrawingOptions({stroke:L.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":n,"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{color:H._colorManager.convert(i),opacity:n,thickness:r,paths:{lines:e,points:s}});if(this.addComment(a),t)return a.isCopy=!0,a;if(this.annotationElementId&&!this.#t(a))return null;return a.id=this.annotationElementId,a}#t(t){let{color:e,thickness:s,opacity:i,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((r,a)=>r!==e[a])||t.thickness!==s||t.opacity!==i||t.pageIndex!==n}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class Ss extends Pe{toSVGPath(){let t=super.toSVGPath();if(!t.endsWith("Z"))t+="Z";return t}}var Ro=K(5213),as=8,Ne=3;class ce{static#t={maxDim:512,sigmaSFactor:0.02,sigmaR:25,kernelSize:16};static#e(t,e,s,i){if(s-=t,i-=e,s===0)return i>0?0:4;if(s===1)return i+6;return 2-i}static#s=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#i(t,e,s,i,n,r,a){let o=this.#e(s,i,n,r);for(let l=0;l<8;l++){let h=(-l+o-a+16)%8,c=this.#s[2*h],d=this.#s[2*h+1];if(t[(s+c)*e+(i+d)]!==0)return h}return-1}static#n(t,e,s,i,n,r,a){let o=this.#e(s,i,n,r);for(let l=0;l<8;l++){let h=(l+o+a+16)%8,c=this.#s[2*h],d=this.#s[2*h+1];if(t[(s+c)*e+(i+d)]!==0)return h}return-1}static#a(t,e,s,i){let n=t.length,r=new Int32Array(n);for(let h=0;h<n;h++)r[h]=t[h]<=i?1:0;for(let h=1;h<s-1;h++)r[h*e]=r[h*e+e-1]=0;for(let h=0;h<e;h++)r[h]=r[e*s-1-h]=0;let a=1,o,l=[];for(let h=1;h<s-1;h++){o=1;for(let c=1;c<e-1;c++){let d=h*e+c,u=r[d];if(u===0)continue;let f=h,p=c;if(u===1&&r[d-1]===0)a+=1,p-=1;else if(u>=1&&r[d+1]===0){if(a+=1,p+=1,u>1)o=u}else{if(u!==1)o=Math.abs(u);continue}let g=[c,h],m=p===c+1,v={isHole:m,points:g,id:a,parent:0};l.push(v);let y;for(let I of l)if(I.id===o){y=I;break}if(!y)v.parent=m?o:0;else if(y.isHole)v.parent=m?y.parent:o;else v.parent=m?o:y.parent;let S=this.#i(r,e,h,c,f,p,0);if(S===-1){if(r[d]=-a,r[d]!==1)o=Math.abs(r[d]);continue}let A=this.#s[2*S],b=this.#s[2*S+1],w=h+A,x=c+b;f=w,p=x;let T=h,E=c;while(!0){let I=this.#n(r,e,T,E,f,p,1);A=this.#s[2*I],b=this.#s[2*I+1];let C=T+A,O=E+b;g.push(O,C);let D=T*e+E;if(r[D+1]===0)r[D]=-a;else if(r[D]===1)r[D]=a;if(C===h&&O===c&&T===w&&E===x){if(r[d]!==1)o=Math.abs(r[d]);break}else f=T,p=E,T=C,E=O}}}return l}static#r(t,e,s,i){if(s-e<=4){for(let w=e;w<s-2;w+=2)i.push(t[w],t[w+1]);return}let n=t[e],r=t[e+1],a=t[s-4]-n,o=t[s-3]-r,l=Math.hypot(a,o),h=a/l,c=o/l,d=h*r-c*n,u=o/a,f=1/l,p=Math.atan(u),g=Math.cos(p),m=Math.sin(p),v=f*(Math.abs(g)+Math.abs(m)),y=f*(1-v+v**2),S=Math.max(Math.atan(Math.abs(m+g)*y),Math.atan(Math.abs(m-g)*y)),A=0,b=e;for(let w=e+2;w<s-2;w+=2){let x=Math.abs(d-h*t[w+1]+c*t[w]);if(x>A)b=w,A=x}if(A>(l*S)**2)this.#r(t,e,b+2,i),this.#r(t,b,s,i);else i.push(n,r)}static#o(t){let e=[],s=t.length;return this.#r(t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e}static#l(t,e,s,i,n,r){let a=new Float32Array(r**2),o=-2*i**2,l=r>>1;for(let p=0;p<r;p++){let g=(p-l)**2;for(let m=0;m<r;m++)a[p*r+m]=Math.exp((g+(m-l)**2)/o)}let h=new Float32Array(256),c=-2*n**2;for(let p=0;p<256;p++)h[p]=Math.exp(p**2/c);let d=t.length,u=new Uint8Array(d),f=new Uint32Array(256);for(let p=0;p<s;p++)for(let g=0;g<e;g++){let m=p*e+g,v=t[m],y=0,S=0;for(let b=0;b<r;b++){let w=p+b-l;if(w<0||w>=s)continue;for(let x=0;x<r;x++){let T=g+x-l;if(T<0||T>=e)continue;let E=t[w*e+T],I=a[b*r+x]*h[Math.abs(E-v)];y+=E*I,S+=I}}let A=u[m]=Math.round(y/S);f[A]++}return[u,f]}static#h(t){let e=new Uint32Array(256);for(let s of t)e[s]++;return e}static#u(t){let e=t.length,s=new Uint8ClampedArray(e>>2),i=-1/0,n=1/0;for(let a=0,o=s.length;a<o;a++){let l=s[a]=t[a<<2];i=Math.max(i,l),n=Math.min(n,l)}let r=255/(i-n);for(let a=0,o=s.length;a<o;a++)s[a]=(s[a]-n)*r;return s}static#d(t){let e,s=-1/0,i=-1/0,n=t.findIndex((o)=>o!==0),r=n,a=n;for(e=n;e<256;e++){let o=t[e];if(o>s){if(e-r>i)i=e-r,a=e-1;s=o,r=e}}for(e=a-1;e>=0;e--)if(t[e]>t[e+1])break;return e}static#f(t){let e=t,{width:s,height:i}=t,{maxDim:n}=this.#t,r=s,a=i;if(s>n||i>n){let d=s,u=i,f=Math.log2(Math.max(s,i)/n),p=Math.floor(f);f=f===p?p-1:p;for(let m=0;m<f;m++){r=Math.ceil(d/2),a=Math.ceil(u/2);let v=new OffscreenCanvas(r,a);if(v.getContext("2d").drawImage(t,0,0,d,u,0,0,r,a),d=r,u=a,t!==e)t.close();t=v.transferToImageBitmap()}let g=Math.min(n/r,n/a);r=Math.round(r*g),a=Math.round(a*g)}let l=new OffscreenCanvas(r,a).getContext("2d",{willReadFrequently:!0});l.fillStyle="white",l.fillRect(0,0,r,a),l.filter="grayscale(1)",l.drawImage(t,0,0,t.width,t.height,0,0,r,a);let h=l.getImageData(0,0,r,a).data;return[this.#u(h),r,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},n,r,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1}),c=200,d=h.font=`${s} ${i} ${c}px ${e}`,{actualBoundingBoxLeft:u,actualBoundingBoxRight:f,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:m,fontBoundingBoxDescent:v,width:y}=h.measureText(t),S=1.5,A=Math.ceil(Math.max(Math.abs(u)+Math.abs(f)||0,y)*S),b=Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||c,Math.abs(m)+Math.abs(v)||c)*S);l=new OffscreenCanvas(A,b),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,A,b),h.fillStyle="black",h.fillText(t,A*(S-1)/2,b*(3-S)/2);let w=this.#u(h.getImageData(0,0,A,b).data),x=this.#h(w),T=this.#d(x),E=this.#a(w,A,b,T);return this.processDrawnLines({lines:{curves:E,width:A,height:b},pageWidth:n,pageHeight:r,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,n){let[r,a,o]=this.#f(t),[l,h]=this.#l(r,a,o,Math.hypot(a,o)*this.#t.sigmaSFactor,this.#t.sigmaR,this.#t.kernelSize),c=this.#d(h),d=this.#a(l,a,o,c);return this.processDrawnLines({lines:{curves:d,width:a,height:o},pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:r,areContours:a}){if(i%180!==0)[e,s]=[s,e];let{curves:o,width:l,height:h}=t,c=t.thickness??0,d=[],u=Math.min(e/l,s/h),f=u/e,p=u/s,g=[];for(let{points:v}of o){let y=r?this.#o(v):v;if(!y)continue;g.push(y);let S=y.length,A=new Float32Array(S),b=new Float32Array(3*(S===2?2:S-2));if(d.push({line:b,points:A}),S===2){A[0]=y[0]*f,A[1]=y[1]*p,b.set([NaN,NaN,NaN,NaN,A[0],A[1]],0);continue}let[w,x,T,E]=y;w*=f,x*=p,T*=f,E*=p,A.set([w,x,T,E],0),b.set([NaN,NaN,NaN,NaN,w,x],0);for(let I=4;I<S;I+=2){let C=A[I]=y[I]*f,O=A[I+1]=y[I+1]*p;b.set(B.createBezierPoints(w,x,T,E,C,O),(I-2)*3),[w,x,T,E]=[T,E,C,O]}}if(d.length===0)return null;let m=a?new Ss:new Pe;return m.build(d,e,s,1,i,a?0:c,n),{outline:m,newCurves:g,areContours:a,thickness:c,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:n}){let r=1/0,a=-1/0,o=0;for(let v of t){o+=v.length;for(let y=2,S=v.length;y<S;y++){let A=v[y]-v[y-2];r=Math.min(r,A),a=Math.max(a,A)}}let l;if(r>=-128&&a<=127)l=Int8Array;else if(r>=-32768&&a<=32767)l=Int16Array;else l=Int32Array;let h=t.length,c=as+Ne*h,d=new Uint32Array(c),u=0;d[u++]=c*Uint32Array.BYTES_PER_ELEMENT+(o-2*h)*l.BYTES_PER_ELEMENT,d[u++]=0,d[u++]=i,d[u++]=n,d[u++]=e?0:1,d[u++]=Math.max(0,Math.floor(s??0)),d[u++]=h,d[u++]=l.BYTES_PER_ELEMENT;for(let v of t)d[u++]=v.length-2,d[u++]=v[0],d[u++]=v[1];let f=new CompressionStream("deflate-raw"),p=f.writable.getWriter();await p.ready,p.write(d);let g=l.prototype.constructor;for(let v of t){let y=new g(v.length-2);for(let S=2,A=v.length;S<A;S++)y[S-2]=v[S]-v[S-2];p.write(y)}return p.close(),(await new Response(f.readable).bytes()).toBase64()}static async decompressSignature(t){try{let e=Uint8Array.fromBase64(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),n=i.getWriter();await n.ready,n.write(e).then(async()=>{await n.ready,await n.close()}).catch(()=>{});let r=null,a=0;for await(let y of s)r||=new Uint8Array(new Uint32Array(y.buffer,0,4)[0]),r.set(y,a),a+=y.length;let o=new Uint32Array(r.buffer,0,r.length>>2),l=o[1];if(l!==0)throw Error(`Invalid version: ${l}`);let h=o[2],c=o[3],d=o[4]===0,u=o[5],f=o[6],p=o[7],g=[],m=(as+Ne*f)*Uint32Array.BYTES_PER_ELEMENT,v;switch(p){case Int8Array.BYTES_PER_ELEMENT:v=new Int8Array(r.buffer,m);break;case Int16Array.BYTES_PER_ELEMENT:v=new Int16Array(r.buffer,m);break;case Int32Array.BYTES_PER_ELEMENT:v=new Int32Array(r.buffer,m);break}a=0;for(let y=0;y<f;y++){let S=o[Ne*y+as],A=new Float32Array(S+2);g.push(A);for(let b=0;b<Ne-1;b++)A[b]=o[Ne*y+as+b+1];for(let b=0;b<S;b++)A[b+2]=A[b]+v[a++]}return{areContours:d,thickness:u,outlines:g,width:h,height:c}}catch(e){return z(`decompressSignature: ${e}`),null}}}class ki extends _s{constructor(){super();super.updateProperties({fill:H._defaultLineColor,"stroke-width":0})}clone(){let t=new ki;return t.updateAll(this),t}}class Li extends Us{constructor(t){super(t);super.updateProperties({stroke:H._defaultLineColor,"stroke-width":1})}clone(){let t=new Li(this._viewParameters);return t.updateAll(this),t}}class Jt extends Q{#t=!1;#e=null;#s=null;#i=null;static _type="signature";static _editorType=Y.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"});this._willKeepAspectRatio=!0,this.#s=t.signatureData||null,this.#e=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){H.initialize(t,e),this._defaultDrawingOptions=new ki,this._defaultDrawnSignatureOptions=new Li(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return j(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#e}}static computeTelemetryFinalData(t){let e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){if(this._drawId===null)return;super.onScaleChanging()}render(){if(this.div)return this.div;let t,e,{_isCopy:s}=this;if(s)this._isCopy=!1,t=this.x,e=this.y;if(super.render(),this._drawId===null)if(this.#s){let{lines:i,mustSmooth:n,areContours:r,description:a,uuid:o,heightInPage:l}=this.#s,{rawDims:{pageWidth:h,pageHeight:c},rotation:d}=this.parent.viewport,u=ce.processDrawnLines({lines:i,pageWidth:h,pageHeight:c,rotation:d,innerMargin:Jt._INNER_MARGIN,mustSmooth:n,areContours:r});this.addSignature(u,l,a,o)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#e||""}));if(s)this._isCopy=!0,this._moveAfterPaste(t,e);return this.div}setUuid(t){this.#i=t,this.addEditToolbar()}getUuid(){return this.#i}get description(){return this.#e}set description(t){if(this.#e=t,!this.div)return;this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then((e)=>{e?.updateEditSignatureButton(t)})}getSignaturePreview(){let{newCurves:t,areContours:e,thickness:s,width:i,height:n}=this.#s,r=Math.max(i,n),a=ce.processDrawnLines({lines:{curves:t.map((o)=>({points:o})),thickness:s,width:i,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,s,i){let{x:n,y:r}=this,{outline:a}=this.#s=t;this.#t=a instanceof Ss,this.description=s;let o;if(this.#t)o=Jt.getDefaultDrawingOptions();else o=Jt._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness});this._addOutlines({drawOutlines:a,drawingOptions:o});let[,l]=this.pageDimensions,h=e/l;if(h=h>=1?0.5:h,this.width*=h/this.height,this.width>=1)h*=0.9/this.width,this.width=0.9;this.height=h,this.setDims(),this.x=n,this.y=r,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!s}}),this.div.hidden=!1}getFromImage(t){let{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return ce.process(t,e,s,i,Jt._INNER_MARGIN)}getFromText(t,e){let{rawDims:{pageWidth:s,pageHeight:i},rotation:n}=this.parent.viewport;return ce.extractContoursFromText(t,e,s,i,n,Jt._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return ce.processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:Jt._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){if(t)this._drawingOptions=Jt.getDefaultDrawingOptions();else this._drawingOptions=Jt._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e})}serialize(t=!1){if(this.isEmpty())return null;let{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":i}}=this,n=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#t,color:[0,0,0],thickness:this.#t?0:i});if(this.addComment(n),t)n.paths={lines:e,points:s},n.uuid=this.#i,n.isCopy=!0;else n.lines=e;if(this.#e)n.accessibilityData={type:"Figure",alt:this.#e};return n}static deserializeDraw(t,e,s,i,n,r){if(r.areContours)return Ss.deserialize(t,e,s,i,n,r);return Pe.deserialize(t,e,s,i,n,r)}static async deserialize(t,e,s){let i=await super.deserialize(t,e,s);return i.#t=t.areContours,i.description=t.accessibilityData?.alt||"",i.#i=t.uuid,i}}class Wr extends H{#t=null;#e=null;#s=null;#i=null;#n=null;#a="";#r=null;#o=!1;#l=null;#h=!1;#u=!1;static _type="stamp";static _editorType=Y.STAMP;constructor(t){super({...t,name:"stampEditor"});this.#i=t.bitmapUrl,this.#n=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){H.initialize(t,e)}static isHandlingMimeForPasting(t){return Zs.includes(t)}static paste(t,e){e.pasteEditor({mode:Y.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){if(this._uiManager.useNewAltTextFlow)this.div.hidden=!1;super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#d(t,e=!1){if(!t){this.remove();return}if(this.#t=t.bitmap,!e)this.#e=t.id,this.#h=t.isSvg;if(t.file)this.#a=t.file.name;this.#m()}#f(){if(this.#s=null,this._uiManager.enableWaiting(!1),!this.#r)return;if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;let{mlManager:s}=this._uiManager;if(!s)throw Error("No ML.");if(!await s.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:i,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await s.guess({name:"altText",request:{data:i,width:n,height:r,channels:i.length/(n*r)}});if(!a)throw Error("No response from the AI service.");if(a.error)throw Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw Error("No valid response from the AI service.");let o=a.output;if(await this.setGuessedAltText(o),e&&!this.hasAltTextData())this.altTextData={alt:o,decorative:!1};return o}#g(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then((s)=>this.#d(s,!0)).finally(()=>this.#f());return}if(this.#i){let s=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromUrl(s).then((i)=>this.#d(i)).finally(()=>this.#f());return}if(this.#n){let s=this.#n;this.#n=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromFile(s).then((i)=>this.#d(i)).finally(()=>this.#f());return}let t=document.createElement("input");t.type="file",t.accept=Zs.join(",");let e=this._uiManager._signal;this.#s=new Promise((s)=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let i=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#d(i)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#f()),t.click()}remove(){if(this.#e){if(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#r?.remove(),this.#r=null,this.#l)clearTimeout(this.#l),this.#l=null}super.remove()}rebuild(){if(!this.parent){if(this.#e)this.#g();return}if(super.rebuild(),this.div===null)return;if(this.#e&&this.#r===null)this.#g();if(!this.isAttachedToDOM)this.parent.add(this)}onceAdded(t){if(this._isDraggable=!0,t)this.div.focus()}isEmpty(){return!(this.#s||this.#t||this.#i||this.#n||this.#e||this.#o)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this._isCopy)t=this.x,e=this.y;if(super.render(),this.div.hidden=!0,this.createAltText(),!this.#o)if(this.#t)this.#m();else this.#g();if(this._isCopy)this._moveAfterPaste(t,e);return this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){let{id:s,bitmap:i}=this._uiManager.imageManager.getFromCanvas(t,e);if(e.remove(),s&&this._uiManager.imageManager.isValidId(s)){if(this.#e=s,i)this.#t=i;this.#o=!1,this.#m()}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;if(this.#l!==null)clearTimeout(this.#l);let t=200;this.#l=setTimeout(()=>{this.#l=null,this.#p()},t)}#m(){let{div:t}=this,{width:e,height:s}=this.#t,[i,n]=this.pageDimensions,r=0.75;if(this.width)e=this.width*i,s=this.height*n;else if(e>0.75*i||s>0.75*n){let o=Math.min(0.75*i/e,0.75*n/s);e*=o,s*=o}this._uiManager.enableWaiting(!1);let a=this.#r=document.createElement("canvas");if(a.setAttribute("role","img"),this.addContainer(a),this.width=e/i,this.height=s/n,this.setDims(),this._initialOptions?.isCentered)this.center();else this.fixAndSetPosition();if(this._initialOptions=null,!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)t.hidden=!1;if(this.#p(),!this.#u)this.parent.addUndoableEditor(this),this.#u=!0;if(this._reportTelemetry({action:"inserted_image"}),this.#a)this.div.setAttribute("aria-description",this.#a);if(!this.annotationElementId)this._uiManager.a11yAlert(H._l10nAlert.stamp)}copyCanvas(t,e,s=!1){t||=224;let{width:i,height:n}=this.#t,r=new Wt,a=this.#t,o=i,l=n,h=null;if(e){if(i>e||n>e){let b=Math.min(e/i,e/n);o=Math.floor(i*b),l=Math.floor(n*b)}h=document.createElement("canvas");let d=h.width=Math.ceil(o*r.sx),u=h.height=Math.ceil(l*r.sy);if(!this.#h)a=this.#c(d,u);let f=h.getContext("2d");f.filter=this._uiManager.hcmFilter;let p="white",g="#cfcfd8";if(this._uiManager.hcmFilter!=="none")g="black";else if(An.isDarkMode)p="#8f8f9d",g="#42414d";let m=15,v=m*r.sx,y=m*r.sy,S=new OffscreenCanvas(v*2,y*2),A=S.getContext("2d");A.fillStyle=p,A.fillRect(0,0,v*2,y*2),A.fillStyle=g,A.fillRect(0,0,v,y),A.fillRect(v,y,v,y),f.fillStyle=f.createPattern(S,"repeat"),f.fillRect(0,0,d,u),f.drawImage(a,0,0,a.width,a.height,0,0,d,u)}let c=null;if(s){let d,u;if(r.symmetric&&a.width<t&&a.height<t)d=a.width,u=a.height;else if(a=this.#t,i>t||n>t){let g=Math.min(t/i,t/n);if(d=Math.floor(i*g),u=Math.floor(n*g),!this.#h)a=this.#c(d,u)}let p=new OffscreenCanvas(d,u).getContext("2d",{willReadFrequently:!0});p.drawImage(a,0,0,a.width,a.height,0,0,d,u),c={width:d,height:u,data:p.getImageData(0,0,d,u).data}}return{canvas:h,width:o,height:l,imageData:c}}#c(t,e){let{width:s,height:i}=this.#t,n=s,r=i,a=this.#t;while(n>2*t||r>2*e){let o=n,l=r;if(n>2*t)n=Math.ceil(n/2);if(r>2*e)r=Math.ceil(r/2);let h=new OffscreenCanvas(n,r);h.getContext("2d").drawImage(a,0,0,o,l,0,0,n,r),a=h.transferToImageBitmap()}return a}#p(){let[t,e]=this.parentDimensions,{width:s,height:i}=this,n=new Wt,r=Math.ceil(s*t*n.sx),a=Math.ceil(i*e*n.sy),o=this.#r;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;let l=this.#h?this.#t:this.#c(r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)}#v(t){if(t){if(this.#h){let i=this._uiManager.imageManager.getSvgUrl(this.#e);if(i)return i}let e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#h){let[e,s]=this.pageDimensions,i=Math.round(this.width*e*pe.PDF_TO_CSS_UNITS),n=Math.round(this.height*s*pe.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,n);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,n),r.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,s){let i=null,n=!1;if(t instanceof Ci){let{data:{rect:p,rotation:g,id:m,structParent:v,popupRef:y,richText:S,contentsObj:A,creationDate:b,modificationDate:w},container:x,parent:{page:{pageNumber:T}},canvas:E}=t,I,C;if(E)delete t.canvas,{id:I,bitmap:C}=s.imageManager.getFromCanvas(x.id,E),E.remove();else n=!0,t._hasNoCanvas=!0;let O=(await e._structTree.getAriaAttributes(`${xe}${m}`))?.get("aria-label")||"";i=t={annotationType:Y.STAMP,bitmapId:I,bitmap:C,pageIndex:T-1,rect:p.slice(0),rotation:g,annotationElementId:m,id:m,deleted:!1,accessibilityData:{decorative:!1,altText:O},isSvg:!1,structParent:v,popupRef:y,richText:S,comment:A?.str||null,creationDate:b,modificationDate:w}}let r=await super.deserialize(t,e,s),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:c,accessibilityData:d}=t;if(n)s.addMissingCanvas(t.id,r),r.#o=!0;else if(h&&s.imageManager.isValidId(h)){if(r.#e=h,o)r.#t=o}else r.#i=l;r.#h=c;let[u,f]=r.pageDimensions;if(r.width=(a[2]-a[0])/u,r.height=(a[3]-a[1])/f,d)r.altTextData=d;if(r._initialData=i,t.comment)r.setCommentData(t);return r.#u=!!i,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let s=Object.assign(super.serialize(t),{bitmapId:this.#e,isSvg:this.#h});if(this.addComment(s),t)return s.bitmapUrl=this.#v(!0),s.accessibilityData=this.serializeAltText(!0),s.isCopy=!0,s;let{decorative:i,altText:n}=this.serializeAltText(!1);if(!i&&n)s.accessibilityData={type:"Figure",alt:n};if(this.annotationElementId){let a=this.#y(s);if(a.isSame)return null;if(a.isSameAltText)delete s.accessibilityData;else s.accessibilityData.structParent=this._initialData.structParent??-1;return s.id=this.annotationElementId,delete s.bitmapId,s}if(e===null)return s;e.stamps||=new Map;let r=this.#h?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:r,serialized:s}),s.bitmap=this.#v(!1);else if(this.#h){let a=e.stamps.get(this.#e);if(r>a.area)a.area=r,a.serialized.bitmap.close(),a.serialized.bitmap=this.#v(!1)}return s}#y(t){let{pageIndex:e,accessibilityData:{altText:s}}=this._initialData,i=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&n,isSameAltText:n}}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;return t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class te{#t;#e=!1;#s=null;#i=null;#n=null;#a=new Map;#r=!1;#o=!1;#l=!1;#h=null;#u=null;#d=null;#f=null;#g=null;#m=-1;#c;static _initialized=!1;static#p=new Map([wt,Di,Wr,Vt,Jt].map((t)=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:r,drawLayer:a,textLayer:o,viewport:l,l10n:h}){let c=[...te.#p.values()];if(!te._initialized){te._initialized=!0;for(let d of c)d.initialize(h,t)}t.registerEditorTypes(c),this.#c=t,this.pageIndex=e,this.div=s,this.#t=n,this.#s=r,this.viewport=l,this.#d=o,this.drawLayer=a,this._structTree=i,this.#c.addLayer(this)}get isEmpty(){return this.#a.size===0}get isInvisible(){return this.isEmpty&&this.#c.getMode()===Y.NONE}updateToolbar(t){this.#c.updateToolbar(t)}updateMode(t=this.#c.getMode()){switch(this.#w(),t){case Y.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Y.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Y.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===Y.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(let s of te.#p.values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#d?.div}setEditingState(t){this.#c.setEditingState(t)}addCommands(t){this.#c.addCommands(t)}cleanUndoStack(t){this.#c.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#s?.togglePointerEvents(t)}get#v(){return this.#a.size!==0?this.#a.values():this.#c.getEditors(this.pageIndex)}async enable(){this.#l=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#g?.abort(),this.#g=null;let t=new Set;for(let s of this.#v)if(s.enableEditing(),s.show(!0),s.annotationElementId)this.#c.removeChangedExistingAnnotation(s),t.add(s.annotationElementId);let e=this.#s;if(e)for(let s of e.getEditableAnnotations()){if(s.hide(),this.#c.isDeletedAnnotationElement(s.data.id))continue;if(t.has(s.data.id))continue;let i=await this.deserialize(s);if(!i)continue;this.addOrRebuild(i),i.enableEditing()}this.#l=!1,this.#c._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#o=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#d&&!this.#g){this.#g=new AbortController;let i=this.#c.combinedSignal(this.#g);this.#d.div.addEventListener("pointerdown",(n)=>{let{clientX:a,clientY:o,timeStamp:l}=n,h=this.#m;if(l-h>500){this.#m=l;return}this.#m=-1;let{classList:c}=this.div;c.toggle("getElements",!0);let d=document.elementsFromPoint(a,o);if(c.toggle("getElements",!1),!this.div.contains(d[0]))return;let u,f=new RegExp(`^${Ce}[0-9]+$`);for(let g of d)if(f.test(g.id)){u=g.id;break}if(!u)return;let p=this.#a.get(u);if(p?.annotationElementId===null)At(n),p.dblclick(n)},{signal:i,capture:!0})}let t=this.#s,e=[];if(t){let i=new Map,n=new Map;for(let r of this.#v){if(r.disableEditing(),!r.annotationElementId){e.push(r);continue}if(r.serialize()!==null){i.set(r.annotationElementId,r);continue}else n.set(r.annotationElementId,r);this.getEditableAnnotation(r.annotationElementId)?.show(),r.remove()}for(let r of t.getEditableAnnotations()){let{id:a}=r.data;if(this.#c.isDeletedAnnotationElement(a)){r.updateEdited({deleted:!0});continue}let o=n.get(a);if(o){o.resetAnnotationElement(r),o.show(!1),r.show();continue}if(o=i.get(a),o){if(this.#c.addChangedExistingAnnotation(o),o.renderAnnotationElement(r))o.show(!1)}r.show()}}if(this.#w(),this.isEmpty)this.div.hidden=!0;let{classList:s}=this.div;for(let i of te.#p.values())s.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#o=!1}getEditableAnnotation(t){return this.#s?.getEditableAnnotation(t)||null}setActiveEditor(t){if(this.#c.getActive()===t)return;this.#c.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#f){this.#f=new AbortController;let t=this.#c.combinedSignal(this.#f);this.#d.div.addEventListener("pointerdown",this.#y.bind(this),{signal:t}),this.#d.div.classList.add("highlighting")}}disableTextSelection(){if(this.div.tabIndex=0,this.#d?.div&&this.#f)this.#f.abort(),this.#f=null,this.#d.div.classList.remove("highlighting")}#y(t){this.#c.unselectAll();let{target:e}=t;if(e===this.#d.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&this.#d.div.contains(e)){let{isMac:s}=ot.platform;if(t.button!==0||t.ctrlKey&&s)return;this.#c.showAllEditors("highlight",!0,!0),Vt.startDrawing(this,this.#c,this.#c.direction==="ltr",t),t.preventDefault()}}enableClick(){if(this.#i)return;this.#i=new AbortController;let t=this.#c.combinedSignal(this.#i);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#i?.abort(),this.#i=null}attach(t){this.#a.set(t.id,t);let{annotationElementId:e}=t;if(e&&this.#c.isDeletedAnnotationElement(e))this.#c.removeDeletedAnnotationElement(t)}detach(t){if(this.#a.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#o&&t.annotationElementId)this.#c.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#c.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){if(t.parent===this)return;if(t.parent&&t.annotationElementId)this.#c.addDeletedAnnotationElement(t),H.deleteAnnotationElement(t),t.annotationElementId=null;if(this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM)t.div.remove(),this.div.append(t.div)}add(t){if(t.parent===this&&t.isAttachedToDOM)return;if(this.changeParent(t),this.#c.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#l),this.#c.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;if(t.div.contains(e)&&!this.#n)t._focusEventsAllowed=!1,this.#n=setTimeout(()=>{if(this.#n=null,!t.div.contains(document.activeElement))t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#c._signal}),e.focus();else t._focusEventsAllowed=!0},0);t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){if(t.needsToBeRebuilt())t.parent||=this,t.rebuild(),t.show();else this.add(t)}addUndoableEditor(t){let e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(let e of this.#a.values())if(e.uid===t)return e;return null}get#b(){return te.#p.get(this.#c.getMode())}combinedSignal(t){return this.#c.combinedSignal(t)}#A(t){let e=this.#b;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#b?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#c.updateMode(t.mode);let{offsetX:s,offsetY:i}=this.#x(),n=this.#c.getId(),r=this.#A({parent:this,id:n,x:s,y:i,uiManager:this.#c,isCentered:!0,...e});if(r)this.add(r)}async deserialize(t){return await te.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#c)||null}createAndAddNewEditor(t,e,s={}){let i=this.#c.getId(),n=this.#A({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#c,isCentered:e,...s});if(n)this.add(n);return n}get boundingClientRect(){return this.div.getBoundingClientRect()}#x(){let{x:t,y:e,width:s,height:i}=this.boundingClientRect,n=Math.max(0,t),r=Math.max(0,e),a=Math.min(window.innerWidth,t+s),o=Math.min(window.innerHeight,e+i),l=(n+a)/2-t,h=(r+o)/2-e,[c,d]=this.viewport.rotation%180===0?[l,h]:[h,l];return{offsetX:c,offsetY:d}}addNewEditor(t={}){this.createAndAddNewEditor(this.#x(),!0,t)}setSelected(t){this.#c.setSelected(t)}toggleSelected(t){this.#c.toggleSelected(t)}unselect(t){this.#c.unselect(t)}pointerup(t){let{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!this.#r)return;if(this.#r=!1,this.#b?.isDrawer&&this.#b.supportMultipleDrawings)return;if(!this.#e){this.#e=!0;return}let s=this.#c.getMode();if(s===Y.STAMP||s===Y.POPUP||s===Y.SIGNATURE){this.#c.unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#c.getMode()===Y.HIGHLIGHT)this.enableTextSelection();if(this.#r){this.#r=!1;return}let{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#r=!0,this.#b?.isDrawer){this.startDrawingSession(t);return}let s=this.#c.getActive();this.#e=!s||s.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#h){this.#b.startDrawing(this,this.#c,!1,t);return}this.#c.setCurrentDrawingSession(this),this.#h=new AbortController;let e=this.#c.combinedSignal(this.#h);this.div.addEventListener("blur",({relatedTarget:s})=>{if(s&&!this.div.contains(s))this.#u=null,this.commitOrRemove()},{signal:e}),this.#b.startDrawing(this,this.#c,!1,t)}pause(t){if(t){let{activeElement:e}=document;if(this.div.contains(e))this.#u=e;return}if(this.#u)setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(t=!1){if(!this.#h)return null;return this.#c.setCurrentDrawingSession(null),this.#h.abort(),this.#h=null,this.#u=null,this.#b.endDrawing(t)}findNewParent(t,e,s){let i=this.#c.findParent(e,s);if(i===null||i===this)return!1;return i.changeParent(t),!0}commitOrRemove(){if(this.#h)return this.endDrawingSession(),!0;return!1}onScaleChanging(){if(!this.#h)return;this.#b.onScaleChangingWhenDrawing(this)}destroy(){if(this.commitOrRemove(),this.#c.getActive()?.parent===this)this.#c.commitOrRemove(),this.#c.setActiveEditor(null);if(this.#n)clearTimeout(this.#n),this.#n=null;for(let t of this.#a.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#a.clear(),this.#c.removeLayer(this)}#w(){for(let t of this.#a.values())if(t.isEmpty())t.remove()}async render({viewport:t}){this.viewport=t,ge(this.div,t);for(let e of this.#c.getEditors(this.pageIndex))this.add(e),e.rebuild();await this.#c.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#c.commitOrRemove(),this.#w();let e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,ge(this.div,{rotation:s}),e!==s)for(let i of this.#a.values())i.rotate(s)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#c.viewParameters.realScale}}var Do=K(1806);function Ya(t,e){if(t===e)return 0;return t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function os(t){if(!t)return null;if(t.nodeType===Node.ELEMENT_NODE)return t.closest(".textLayer");return t.parentElement?.closest(".textLayer")||null}function Ka(t,e,s,i){if(t===s)return e<=i;let n=t.compareDocumentPosition(s);if(n&Node.DOCUMENT_POSITION_FOLLOWING)return!0;if(n&Node.DOCUMENT_POSITION_PRECEDING)return!1;return null}function gn(t,e,s){if(t.nodeType!==Node.ELEMENT_NODE||!t.classList.contains("textLayer")||e!==t.childNodes.length)return{container:t,offset:e};let i=t.lastChild;if(i?.nodeType===Node.ELEMENT_NODE&&i.classList.contains("endOfContent"))i=i.previousSibling;if(!i||!s.contains(i))return null;if(i.nodeType===Node.TEXT_NODE)return{container:i,offset:i.textContent.length};return{container:i,offset:i.childNodes.length}}class W{#t=null;#e=new Map;#s=null;#i=null;#n=null;#a=null;#r=new Map;static#o=0;static#l=0;static#h=null;static#u=new Set;static#d=!1;static#f=new Set;static#g=new WeakMap;constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){if(this.pageIndex=s,this.#i=t,this.#n=e,i){let n=W.#g.get(i);if(n?.selectionDiv)n.selectionDiv.remove(),W.#u.delete(n.selectionDiv);if(W.#g.set(i,{drawLayer:this}),W.#f.add(i),this.#s=i,this.#a=new MutationObserver((r)=>{if(!this.#t||!this.#s?.isConnected||!W.#c())return;for(let{addedNodes:a}of r)for(let o of a)if(o.nodeType===Node.ELEMENT_NODE&&o.classList.contains("endOfContent")){W.#v();return}}),this.#a.observe(i,{childList:!0}),W.#h===null){W.#h=new AbortController;let{signal:r}=W.#h;document.addEventListener("selectionchange",W.#v.bind(W),{signal:r}),document.addEventListener("pointerdown",()=>{W.#d=!0},{signal:r}),document.addEventListener("pointerup",()=>{W.#d=!1},{signal:r}),window.addEventListener("blur",()=>{W.#d=!1},{signal:r})}}}setParent(t){if(!this.#t){if(this.#t=t,this.#s?.isConnected&&W.#c())W.#v();return}if(this.#t!==t){if(this.#e.size>0)for(let e of this.#e.values())e.remove(),t.append(e);this.#t=t}}static#m(t){let e=this.#g.get(t);if(!e?.selectionDiv)return;e.selectionDiv.remove(),this.#u.delete(e.selectionDiv),e.selectionDiv=null,e.path=null}static#c(){let t=document.getSelection();return!!t&&!t.isCollapsed}static#p(){return this.#f.keys().filter((t)=>t.isConnected).toArray().sort(Ya)}static#v(){let t=document.getSelection();if(!t||t.isCollapsed){for(let r of this.#u)r.remove();this.#u.clear();return}let e=new WeakMap,s=this.#p(),i=[];for(let r=0,a=t.rangeCount;r<a;r++){let o=t.getRangeAt(r);if(o.collapsed)continue;let{startContainer:l,startOffset:h,endContainer:c,endOffset:d}=o,u=os(l),f=os(c),p=u===null,g=f===null;if(this.#d&&p!==g)return;if(t.rangeCount===1){let{anchorNode:y,anchorOffset:S,focusNode:A,focusOffset:b}=t,w=os(y),x=os(A),T=Ka(y,S,A,b);if(w&&x&&T!==null)if(T)l=y,h=S,u=w,c=A,d=b,f=x;else l=A,h=b,u=x,c=y,d=S,f=w}let m=s.filter((y)=>o.intersectsNode(y));if(m.length===0)continue;let v=!1;if(!u)u=m[0],l=u,h=0,v=!0;if(!f)f=m.at(-1),c=f,d=f.childNodes.length,v=!0;if(c.nodeType===Node.ELEMENT_NODE){if(c.classList.contains("endOfContent")){let y=c.previousSibling;if(!y)continue;c=y,d=y.nodeType===Node.TEXT_NODE?y.textContent.length:y.childNodes.length}else if(c.classList.contains("textLayer")&&c.childNodes.length===d){let y=gn(c,d,f);if(!y)continue;c=y.container,d=y.offset}}if(l.nodeType===Node.ELEMENT_NODE){let y=gn(l,h,u);if(!y)continue;l=y.container,h=y.offset}if(u===f&&!v&&m.includes(u)){i.push([o,u]);continue}for(let y of m){let S=y.firstChild;if(!S)continue;let A=document.createRange();if(y===u)A.setStart(l,h);else A.setStartBefore(S);if(y===f)A.setEnd(c,d);else{let b=y.lastChild;if(!b)continue;if(b.nodeType===Node.ELEMENT_NODE&&b.classList.contains("endOfContent")){let w=b.previousSibling;if(!w)continue;A.setEndAfter(w)}else A.setEndAfter(b)}if(!A.collapsed)i.push([A,y])}}let n=new Set(i.map((r)=>r[1]));for(let r of this.#f)if(!n.has(r))this.#m(r);for(let[r,a]of i){let o=W.#g.get(a);if(!o)continue;let l=e.get(a);if(!l){let f=a.getBoundingClientRect();l=(p,g,m,v)=>({x:(p-f.x)/f.width,y:(g-f.y)/f.height,width:m/f.width,height:v/f.height}),e.set(a,l)}let h=[];for(let{x:f,y:p,width:g,height:m}of r.getClientRects()){if(g===0||m===0)continue;if({x:f,y:p,width:g,height:m}=l(f,p,g,m),g===1&&m===1)continue;h.push(`M${f} ${p} h${g} v${m} h-${g} Z`)}if(h.length===0)continue;let{drawLayer:c,selectionDiv:d,path:u}=o;if(!d){let f=`clip_selection_${W.#l++}`;d=document.createElement("div"),d.className="selection",d.style.clipPath=`url(#${f})`;let p=c.#i?.createSelectionStyle(c.#n);if(p)for(let[v,y]of Object.entries(p))d.style.setProperty(v,y);let g=W._svgFactory.create(1,1,!0);g.setAttribute("aria-hidden","true"),g.setAttribute("width","100%"),g.setAttribute("height","100%");let m=W._svgFactory.createElement("clipPath");m.setAttribute("id",f),m.setAttribute("clipPathUnits","objectBoundingBox"),u=W._svgFactory.createElement("path"),m.append(u),g.append(m),d.append(g),o.path=u,o.selectionDiv=d}if(c.#t&&d.parentNode!==c.#t)c.#t.append(d),this.#u.add(d);u.setAttribute("d",h.join(" "))}}static get _svgFactory(){return j(this,"_svgFactory",new We)}static#y(t,[e,s,i,n]){let{style:r}=t;r.top=`${100*s}%`,r.left=`${100*e}%`,r.width=`${100*i}%`,r.height=`${100*n}%`}#b(){let t=W._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden","true"),t}#A(t,e){let s=W._svgFactory.createElement("clipPath");t.append(s);let i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");let n=W._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i}#x(t,e){for(let[s,i]of Object.entries(e))if(i===null)t.removeAttribute(s);else t.setAttribute(s,i)}draw(t,e=!1,s=!1){let i=W.#o++,n=this.#b(),r=W._svgFactory.createElement("defs");n.append(r);let a=W._svgFactory.createElement("path");r.append(a);let o=`path_${i}`;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e)this.#r.set(i,a);let l=s?this.#A(r,o):null,h=W._svgFactory.createElement("use");return n.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(n,t),this.#e.set(i,n),{id:i,clipPathId:`url(#${l})`}}drawOutline(t,e){let s=W.#o++,i=this.#b(),n=W._svgFactory.createElement("defs");i.append(n);let r=W._svgFactory.createElement("path");n.append(r);let a=`path_${s}`;r.setAttribute("id",a),r.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){let c=W._svgFactory.createElement("mask");n.append(c),o=`mask_${s}`,c.setAttribute("id",o),c.setAttribute("maskUnits","objectBoundingBox");let d=W._svgFactory.createElement("rect");c.append(d),d.setAttribute("width","1"),d.setAttribute("height","1"),d.setAttribute("fill","white");let u=W._svgFactory.createElement("use");c.append(u),u.setAttribute("href",`#${a}`),u.setAttribute("stroke","none"),u.setAttribute("fill","black"),u.setAttribute("fill-rule","nonzero"),u.classList.add("mask")}let l=W._svgFactory.createElement("use");if(i.append(l),l.setAttribute("href",`#${a}`),o)l.setAttribute("mask",`url(#${o})`);let h=l.cloneNode();return i.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(i,t),this.#e.set(s,i),s}finalizeDraw(t,e){this.#r.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:s,bbox:i,rootClass:n,path:r}=e,a=typeof t==="number"?this.#e.get(t):t;if(!a)return;if(s)this.#x(a,s);if(i)W.#y(a,i);if(n){let{classList:o}=a;for(let[l,h]of Object.entries(n))o.toggle(l,h)}if(r){let l=a.firstElementChild.firstElementChild;this.#x(l,r)}}updateParent(t,e){if(e===this)return;let s=this.#e.get(t);if(!s)return;e.#t.append(s),this.#e.delete(t),e.#e.set(t,s)}remove(t){if(this.#r.delete(t),this.#t===null)return;this.#e.get(t).remove(),this.#e.delete(t)}destroy(){this.#t=null;for(let t of this.#e.values())t.remove();if(this.#e.clear(),this.#r.clear(),this.#a?.disconnect(),this.#a=null,this.#s){if(W.#g.get(this.#s)?.drawLayer===this){if(W.#m(this.#s),W.#g.delete(this.#s),W.#f.delete(this.#s),W.#f.size===0)W.#h?.abort(),W.#h=null,W.#d=!1}this.#s=null}}}function ls(t){return`${(t*100).toFixed(2)}%`}class ws{#t=[];#e=new Map;#s=null;#i=0;#n=0;#a=0;static#r=null;constructor(t,e,s,i){this.#i=t,this.#t=e,this.#n=s.rawDims.pageWidth,this.#a=s.rawDims.pageHeight,this.#s=i}render(){let t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<this.#t.length;e+=6){let s=this.#o(this.#t.subarray(e,e+6));if(s)t.append(s)}return t.addEventListener("contextmenu",(e)=>{if(!(e.target instanceof HTMLCanvasElement))return;let s=e.target,i=this.#e.get(s);if(!i)return;let n=ws.#r?.deref();if(n===s)return;if(n)n.width=0,n.height=0;ws.#r=new WeakRef(s);let{inverseTransform:r,x1:a,y1:o,width:l,height:h}=i,c=this.#s(),d=Math.ceil(a*c.width),u=Math.ceil(o*c.height),f=Math.floor((a+l/this.#n)*c.width),p=Math.floor((o+h/this.#a)*c.height);s.width=f-d,s.height=p-u;let g=s.getContext("2d");g.setTransform(...r),g.translate(-d,-u),g.drawImage(c,0,0)}),t}#o([t,e,s,i,n,r]){let a=Math.hypot((n-t)*this.#n,(r-e)*this.#a),o=Math.hypot((s-t)*this.#n,(i-e)*this.#a);if(a<this.#i||o<this.#i)return null;let l=[(n-t)*this.#n/a,(r-e)*this.#a/a,(s-t)*this.#n/o,(i-e)*this.#a/o,0,0],h=L.inverseTransform(l),c=document.createElement("canvas");return c.className="textLayerImagePlaceholder",c.width=0,c.height=0,Object.assign(c.style,{opacity:0,position:"absolute",left:ls(t),top:ls(e),width:ls(a/this.#n),height:ls(o/this.#a),transformOrigin:"0% 0%",transform:`matrix(${l.join(",")})`}),this.#e.set(c,{inverseTransform:h,width:a,height:o,x1:t,y1:e}),c}}globalThis._pdfjsTestingUtils={HighlightOutliner:bs};globalThis.pdfjsLib={AbortException:se,AnnotationEditorLayer:te,AnnotationEditorParamsType:q,AnnotationEditorType:Y,AnnotationEditorUIManager:ae,AnnotationLayer:Pi,AnnotationMode:ne,AnnotationType:gt,applyOpacity:pa,build:za,ColorPicker:jt,createValidAbsoluteUrl:mn,CSSConstants:Sn,DOMSVGFactory:We,DrawLayer:W,FeatureTest:ot,fetchData:li,findContrastColor:ga,getDocument:bi,getFilenameFromUrl:da,getPdfFilenameFromUrl:ua,getRGB:Ke,getRGBA:Ye,getUuid:bn,GlobalWorkerOptions:re,ImageKind:hs,InvalidPDFException:ps,isDataScheme:Ps,isPdfFile:hi,isValidExplicitDest:wa,makeArr:Ie,makeMap:ai,makeObj:Js,makeSet:la,MathClamp:ut,noContextMenu:zt,normalizeUnicode:aa,OPS:Qt,OutputScale:Wt,PasswordException:fs,PasswordResponses:ta,PDFDataRangeTransport:Si,PDFDateString:gs,PDFWorker:Tt,PermissionFlag:qr,PixelsPerInch:pe,RenderingCancelledException:Is,renderRichText:wn,ResponseException:Ue,setLayerDimensions:ge,shadow:j,SignatureExtractor:ce,stopEvent:At,SupportedImageMimeTypes:Zs,TextLayer:Ot,TextLayerImages:ws,TouchManager:ui,updateUrlHash:vn,Util:L,VerbosityLevel:xs,version:Va,XfaLayer:oi};var qe={maxBytes:104857600,maxPages:2000,maxCanvasPixels:16000000,maxImageWidth:4096};var Xr=(t)=>Object.assign(Error(t),{name:"PdfTooLargeError"});async function Bo(t,e,s){if(e.aborted)return null;re.workerSrc=new URL(s,import.meta.url).href;let i=bi({data:new Uint8Array(t),verbosity:0,stopAtErrors:!0,enableXfa:!1,maxImageSize:qe.maxCanvasPixels,canvasMaxAreaInBytes:qe.maxCanvasPixels*4}),n=()=>void i.destroy();e.addEventListener("abort",n,{once:!0});let r=async()=>{e.removeEventListener("abort",n),await i.destroy()};try{let a=await i.promise;if(a.numPages>qe.maxPages)throw Xr(`PDF has more than ${qe.maxPages} pages`);let o=[];for(let c=1;c<=a.numPages;c++){let{width:d,height:u}=(await a.getPage(c)).getViewport({scale:1});if(e.aborted)return await r(),null;o.push({width:d,height:u})}return{pages:o,draw:async(c,d,u)=>{let f=await a.getPage(c+1);if(u.aborted)return null;let p=f.getViewport({scale:d/f.getViewport({scale:1}).width}),g=document.createElement("canvas");try{g.width=Math.round(p.width),g.height=Math.round(p.height);let m=f.render({canvas:g,viewport:p}),v=()=>m.cancel();u.addEventListener("abort",v,{once:!0});try{await m.promise}finally{u.removeEventListener("abort",v)}let y=await new Promise((S,A)=>g.toBlob((b)=>b?S(b):A(Error("The page could not be drawn")),"image/png"));if(u.aborted)return null;return{url:URL.createObjectURL(y),width:g.width,height:g.height}}finally{g.width=0,g.height=0,f.cleanup()}},textLayer:async(c,d,u)=>{let f=await a.getPage(c+1);if(u.aborted)return;let p=f.getViewport({scale:1}),g=new Ot({textContentSource:f.streamTextContent(),container:d,viewport:p}),[m=0,v=0,y=0,S=0]=p.viewBox;d.style.width=`calc(var(--total-scale-factor) * ${y-m}px)`,d.style.height=`calc(var(--total-scale-factor) * ${S-v}px)`;let A=()=>g.cancel();u.addEventListener("abort",A,{once:!0});try{await g.render()}finally{u.removeEventListener("abort",A)}},close:r}}catch(a){if(await r(),e.aborted)return null;throw a}}export{Bo as openPdf};