@imgly/codesign-mcp 0.7.2 → 0.7.3-next.20261125135902.gfdc6ee3

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 (539) hide show
  1. package/README.md +35 -17
  2. package/dist/cli/license.js +1 -1
  3. package/dist/runtime/cli/commands.d.ts +2 -0
  4. package/dist/runtime/cli/commands.d.ts.map +1 -1
  5. package/dist/runtime/cli/commands.js +56 -1
  6. package/dist/runtime/cli/commands.js.map +1 -1
  7. package/dist/runtime/cli/main.d.ts.map +1 -1
  8. package/dist/runtime/cli/main.js +5 -0
  9. package/dist/runtime/cli/main.js.map +1 -1
  10. package/dist/runtime/codesign-shim/codesign-router/protocol/types.mjs +1 -0
  11. package/dist/runtime/codesign-shim/codesign-router/release-build.generated.mjs +1 -1
  12. package/dist/server-client-types/protocol/types.d.ts +25 -3
  13. package/dist/server-client.mjs +1 -0
  14. package/dist/server.d.ts +2 -0
  15. package/dist/server.d.ts.map +1 -1
  16. package/dist/server.js +4 -2
  17. package/dist/server.js.map +1 -1
  18. package/node_modules/@imgly/codesign-billing/README.md +138 -0
  19. package/node_modules/@imgly/{codesign-sdk/dist/executor/billing → codesign-billing/dist}/charge.d.ts +30 -5
  20. package/node_modules/@imgly/codesign-billing/dist/charge.d.ts.map +1 -0
  21. package/node_modules/@imgly/{codesign-sdk/dist/executor/billing → codesign-billing/dist}/charge.js +16 -1
  22. package/node_modules/@imgly/codesign-billing/dist/charge.js.map +1 -0
  23. package/node_modules/@imgly/codesign-billing/dist/charges.d.ts +71 -0
  24. package/node_modules/@imgly/codesign-billing/dist/charges.d.ts.map +1 -0
  25. package/node_modules/@imgly/codesign-billing/dist/charges.js +198 -0
  26. package/node_modules/@imgly/codesign-billing/dist/charges.js.map +1 -0
  27. package/node_modules/@imgly/codesign-billing/dist/index.d.ts +6 -0
  28. package/node_modules/@imgly/codesign-billing/dist/index.d.ts.map +1 -0
  29. package/node_modules/@imgly/codesign-billing/dist/index.js +6 -0
  30. package/node_modules/@imgly/codesign-billing/dist/index.js.map +1 -0
  31. package/node_modules/@imgly/codesign-billing/dist/ledger.d.ts +55 -0
  32. package/node_modules/@imgly/codesign-billing/dist/ledger.d.ts.map +1 -0
  33. package/node_modules/@imgly/codesign-billing/dist/ledger.js +80 -0
  34. package/node_modules/@imgly/codesign-billing/dist/ledger.js.map +1 -0
  35. package/node_modules/@imgly/{codesign-sdk/dist/executor/billing → codesign-billing/dist}/metering.d.ts +9 -1
  36. package/node_modules/@imgly/codesign-billing/dist/metering.d.ts.map +1 -0
  37. package/node_modules/@imgly/{codesign-sdk/dist/executor/billing → codesign-billing/dist}/metering.js +77 -21
  38. package/node_modules/@imgly/codesign-billing/dist/metering.js.map +1 -0
  39. package/node_modules/@imgly/codesign-billing/dist/refusal.d.ts +20 -0
  40. package/node_modules/@imgly/codesign-billing/dist/refusal.d.ts.map +1 -0
  41. package/node_modules/@imgly/codesign-billing/dist/refusal.js +13 -0
  42. package/node_modules/@imgly/codesign-billing/dist/refusal.js.map +1 -0
  43. package/node_modules/@imgly/codesign-billing/package.json +30 -0
  44. package/node_modules/@imgly/codesign-router/dist/config/unit-config.d.ts +13 -5
  45. package/node_modules/@imgly/codesign-router/dist/config/unit-config.d.ts.map +1 -1
  46. package/node_modules/@imgly/codesign-router/dist/config/unit-config.js +18 -12
  47. package/node_modules/@imgly/codesign-router/dist/config/unit-config.js.map +1 -1
  48. package/node_modules/@imgly/codesign-router/dist/consent.d.ts +6 -2
  49. package/node_modules/@imgly/codesign-router/dist/consent.d.ts.map +1 -1
  50. package/node_modules/@imgly/codesign-router/dist/consent.js +65 -9
  51. package/node_modules/@imgly/codesign-router/dist/consent.js.map +1 -1
  52. package/node_modules/@imgly/codesign-router/dist/protocol/types.d.ts +25 -3
  53. package/node_modules/@imgly/codesign-router/dist/protocol/types.d.ts.map +1 -1
  54. package/node_modules/@imgly/codesign-router/dist/protocol/types.js +1 -0
  55. package/node_modules/@imgly/codesign-router/dist/protocol/types.js.map +1 -1
  56. package/node_modules/@imgly/codesign-router/dist/release-build.generated.d.ts +1 -1
  57. package/node_modules/@imgly/codesign-router/dist/release-build.generated.d.ts.map +1 -1
  58. package/node_modules/@imgly/codesign-router/dist/release-build.generated.js +1 -1
  59. package/node_modules/@imgly/codesign-router/dist/release-build.generated.js.map +1 -1
  60. package/node_modules/@imgly/codesign-router/dist/router/channels-v2.d.ts.map +1 -1
  61. package/node_modules/@imgly/codesign-router/dist/router/channels-v2.js +14 -4
  62. package/node_modules/@imgly/codesign-router/dist/router/channels-v2.js.map +1 -1
  63. package/node_modules/@imgly/codesign-router/dist/router/main.d.ts.map +1 -1
  64. package/node_modules/@imgly/codesign-router/dist/router/main.js +9 -1
  65. package/node_modules/@imgly/codesign-router/dist/router/main.js.map +1 -1
  66. package/node_modules/@imgly/codesign-sdk/CHANGELOG.md +24 -0
  67. package/node_modules/@imgly/codesign-sdk/README.md +8 -7
  68. package/node_modules/@imgly/codesign-sdk/dist/abort.d.ts +1 -0
  69. package/node_modules/@imgly/codesign-sdk/dist/abort.js +18 -0
  70. package/node_modules/@imgly/codesign-sdk/dist/assets/inline.generated.js +12 -12
  71. package/node_modules/@imgly/codesign-sdk/dist/browser/index.d.ts +1 -1
  72. package/node_modules/@imgly/codesign-sdk/dist/browser/worker.d.ts +1 -1
  73. package/node_modules/@imgly/codesign-sdk/dist/browser/worker.js +15 -8
  74. package/node_modules/@imgly/codesign-sdk/dist/cesdk-utils/index.js +2 -0
  75. package/node_modules/@imgly/codesign-sdk/dist/codesign-error.d.ts +38 -1
  76. package/node_modules/@imgly/codesign-sdk/dist/codesign-error.js +9 -0
  77. package/node_modules/@imgly/codesign-sdk/dist/codesign.d.ts +19 -12
  78. package/node_modules/@imgly/codesign-sdk/dist/codesign.js +268 -43
  79. package/node_modules/@imgly/codesign-sdk/dist/design/animatable.generated.js +3 -0
  80. package/node_modules/@imgly/codesign-sdk/dist/design/capabilities.generated.js +1 -0
  81. package/node_modules/@imgly/codesign-sdk/dist/design/facade.d.ts +1 -1
  82. package/node_modules/@imgly/codesign-sdk/dist/design/facade.js +128 -36
  83. package/node_modules/@imgly/codesign-sdk/dist/design/keyframes.js +2 -1
  84. package/node_modules/@imgly/codesign-sdk/dist/design/lint.d.ts +1 -1
  85. package/node_modules/@imgly/codesign-sdk/dist/design/lint.js +82 -5
  86. package/node_modules/@imgly/codesign-sdk/dist/design/props.generated.js +3 -0
  87. package/node_modules/@imgly/codesign-sdk/dist/design/run-offsets.d.ts +10 -0
  88. package/node_modules/@imgly/codesign-sdk/dist/design/run-offsets.js +26 -0
  89. package/node_modules/@imgly/codesign-sdk/dist/design/scene-lint.d.ts +23 -1
  90. package/node_modules/@imgly/codesign-sdk/dist/design/scene-lint.js +194 -3
  91. package/node_modules/@imgly/codesign-sdk/dist/design/timeline-poses.d.ts +8 -0
  92. package/node_modules/@imgly/codesign-sdk/dist/design/timeline-poses.js +53 -0
  93. package/node_modules/@imgly/codesign-sdk/dist/design/variables.d.ts +14 -0
  94. package/node_modules/@imgly/codesign-sdk/dist/design/variables.js +250 -37
  95. package/node_modules/@imgly/codesign-sdk/dist/designs/s3-presigner.d.ts +50 -0
  96. package/node_modules/@imgly/codesign-sdk/dist/designs/s3-presigner.js +116 -0
  97. package/node_modules/@imgly/codesign-sdk/dist/designs/types.d.ts +79 -3
  98. package/node_modules/@imgly/codesign-sdk/dist/engine/audio-extract.d.ts +12 -1
  99. package/node_modules/@imgly/codesign-sdk/dist/engine/audio-extract.js +20 -4
  100. package/node_modules/@imgly/codesign-sdk/dist/engine/engine-capacity.d.ts +20 -7
  101. package/node_modules/@imgly/codesign-sdk/dist/engine/engine-capacity.js +31 -14
  102. package/node_modules/@imgly/codesign-sdk/dist/engine/headless.d.ts +4 -0
  103. package/node_modules/@imgly/codesign-sdk/dist/engine/headless.js +20 -0
  104. package/node_modules/@imgly/codesign-sdk/dist/executor/billing/check.d.ts +1 -14
  105. package/node_modules/@imgly/codesign-sdk/dist/executor/billing/check.js +2 -7
  106. package/node_modules/@imgly/codesign-sdk/dist/executor/billing/metered.d.ts +1 -2
  107. package/node_modules/@imgly/codesign-sdk/dist/executor/billing/metered.js +120 -91
  108. package/node_modules/@imgly/codesign-sdk/dist/executor/encode-watchdog.d.ts +2 -2
  109. package/node_modules/@imgly/codesign-sdk/dist/executor/encode-watchdog.js +10 -4
  110. package/node_modules/@imgly/codesign-sdk/dist/executor/engine-protocol.d.ts +1 -1
  111. package/node_modules/@imgly/codesign-sdk/dist/executor/engine-protocol.js +13 -3
  112. package/node_modules/@imgly/codesign-sdk/dist/executor/executor-options.d.ts +6 -7
  113. package/node_modules/@imgly/codesign-sdk/dist/executor/executor-options.js +14 -7
  114. package/node_modules/@imgly/codesign-sdk/dist/executor/handler.d.ts +47 -2
  115. package/node_modules/@imgly/codesign-sdk/dist/executor/handler.js +519 -8
  116. package/node_modules/@imgly/codesign-sdk/dist/executor/node.d.ts +42 -6
  117. package/node_modules/@imgly/codesign-sdk/dist/executor/node.js +231 -9
  118. package/node_modules/@imgly/codesign-sdk/dist/exporters/fig.d.ts +13 -0
  119. package/node_modules/@imgly/codesign-sdk/dist/exporters/fig.js +28 -0
  120. package/node_modules/@imgly/codesign-sdk/dist/exporters/html.d.ts +18 -2
  121. package/node_modules/@imgly/codesign-sdk/dist/exporters/html.js +129 -15
  122. package/node_modules/@imgly/codesign-sdk/dist/exporters/index.d.ts +5 -2
  123. package/node_modules/@imgly/codesign-sdk/dist/exporters/index.js +2 -2
  124. package/node_modules/@imgly/codesign-sdk/dist/exporters/node.d.ts +1 -1
  125. package/node_modules/@imgly/codesign-sdk/dist/exporters/node.js +4 -3
  126. package/node_modules/@imgly/codesign-sdk/dist/exporters/psd.js +1 -1
  127. package/node_modules/@imgly/codesign-sdk/dist/formats/av-limit.d.ts +2 -0
  128. package/node_modules/@imgly/codesign-sdk/dist/formats/av-limit.js +1 -1
  129. package/node_modules/@imgly/codesign-sdk/dist/formats/design-sniff.d.ts +3 -1
  130. package/node_modules/@imgly/codesign-sdk/dist/formats/design-sniff.js +7 -0
  131. package/node_modules/@imgly/codesign-sdk/dist/formats/import-registry.d.ts +1 -1
  132. package/node_modules/@imgly/codesign-sdk/dist/formats/import-registry.js +4 -2
  133. package/node_modules/@imgly/codesign-sdk/dist/formats/import-warnings.d.ts +5 -0
  134. package/node_modules/@imgly/codesign-sdk/dist/formats/import-warnings.js +31 -0
  135. package/node_modules/@imgly/codesign-sdk/dist/formats/media-facts.d.ts +15 -0
  136. package/node_modules/@imgly/codesign-sdk/dist/formats/media-facts.js +26 -0
  137. package/node_modules/@imgly/codesign-sdk/dist/formats/mime.d.ts +6 -0
  138. package/node_modules/@imgly/codesign-sdk/dist/formats/mime.js +37 -0
  139. package/node_modules/@imgly/codesign-sdk/dist/formats/refuse-media.d.ts +7 -0
  140. package/node_modules/@imgly/codesign-sdk/dist/formats/refuse-media.js +46 -0
  141. package/node_modules/@imgly/codesign-sdk/dist/formats/svg-export.d.ts +6 -0
  142. package/node_modules/@imgly/codesign-sdk/dist/formats/svg-export.js +20 -0
  143. package/node_modules/@imgly/codesign-sdk/dist/formats/svg-import.d.ts +3 -0
  144. package/node_modules/@imgly/codesign-sdk/dist/formats/svg-import.js +25 -0
  145. package/node_modules/@imgly/codesign-sdk/dist/formats/zip-entries.d.ts +2 -0
  146. package/node_modules/@imgly/codesign-sdk/dist/formats/zip-entries.js +1 -0
  147. package/node_modules/@imgly/codesign-sdk/dist/gateway/asset-generate.d.ts +10 -4
  148. package/node_modules/@imgly/codesign-sdk/dist/gateway/asset-generate.js +205 -79
  149. package/node_modules/@imgly/codesign-sdk/dist/gateway/client.d.ts +23 -2
  150. package/node_modules/@imgly/codesign-sdk/dist/gateway/client.js +40 -41
  151. package/node_modules/@imgly/codesign-sdk/dist/gateway/index.d.ts +3 -0
  152. package/node_modules/@imgly/codesign-sdk/dist/gateway/index.js +4 -0
  153. package/node_modules/@imgly/codesign-sdk/dist/gateway/types.d.ts +18 -3
  154. package/node_modules/@imgly/codesign-sdk/dist/gateway/upload-origin.d.ts +3 -0
  155. package/node_modules/@imgly/codesign-sdk/dist/gateway/upload-origin.js +5 -0
  156. package/node_modules/@imgly/codesign-sdk/dist/host/edit-code.d.ts +2 -0
  157. package/node_modules/@imgly/codesign-sdk/dist/host/edit-code.js +8 -1
  158. package/node_modules/@imgly/codesign-sdk/dist/host/preview-size.d.ts +4 -2
  159. package/node_modules/@imgly/codesign-sdk/dist/host/preview-size.js +7 -4
  160. package/node_modules/@imgly/codesign-sdk/dist/host.d.ts +34 -5
  161. package/node_modules/@imgly/codesign-sdk/dist/host.js +6 -0
  162. package/node_modules/@imgly/codesign-sdk/dist/importers/fig.d.ts +4 -0
  163. package/node_modules/@imgly/codesign-sdk/dist/importers/fig.js +57 -0
  164. package/node_modules/@imgly/codesign-sdk/dist/importers/index.d.ts +2 -2
  165. package/node_modules/@imgly/codesign-sdk/dist/importers/index.js +38 -25
  166. package/node_modules/@imgly/codesign-sdk/dist/importers/node.d.ts +5 -0
  167. package/node_modules/@imgly/codesign-sdk/dist/importers/node.js +8 -0
  168. package/node_modules/@imgly/codesign-sdk/dist/importers/pdf-fonts.d.ts +20 -0
  169. package/node_modules/@imgly/codesign-sdk/dist/importers/pdf-fonts.js +76 -0
  170. package/node_modules/@imgly/codesign-sdk/dist/importers/shared.d.ts +14 -0
  171. package/node_modules/@imgly/codesign-sdk/dist/importers/shared.js +18 -0
  172. package/node_modules/@imgly/codesign-sdk/dist/index.d.ts +5 -4
  173. package/node_modules/@imgly/codesign-sdk/dist/index.js +2 -1
  174. package/node_modules/@imgly/codesign-sdk/dist/internal/index.d.ts +24 -17
  175. package/node_modules/@imgly/codesign-sdk/dist/internal/index.js +19 -10
  176. package/node_modules/@imgly/codesign-sdk/dist/node/edit-renders.d.ts +5 -0
  177. package/node_modules/@imgly/codesign-sdk/dist/node/edit-renders.js +73 -0
  178. package/node_modules/@imgly/codesign-sdk/dist/node/engine-child.js +18 -2
  179. package/node_modules/@imgly/codesign-sdk/dist/node/engine-http.js +8 -2
  180. package/node_modules/@imgly/codesign-sdk/dist/node/index.d.ts +1 -0
  181. package/node_modules/@imgly/codesign-sdk/dist/node/index.js +1 -0
  182. package/node_modules/@imgly/codesign-sdk/dist/node/media-probe.js +1 -1
  183. package/node_modules/@imgly/codesign-sdk/dist/sdk-version.generated.js +2 -2
  184. package/node_modules/@imgly/codesign-sdk/dist/session/engine-session.d.ts +59 -13
  185. package/node_modules/@imgly/codesign-sdk/dist/session/engine-session.js +19 -0
  186. package/node_modules/@imgly/codesign-sdk/dist/session/export-facts.d.ts +1 -14
  187. package/node_modules/@imgly/codesign-sdk/dist/session/export-facts.js +15 -4
  188. package/node_modules/@imgly/codesign-sdk/dist/session/file-formats.d.ts +5 -0
  189. package/node_modules/@imgly/codesign-sdk/dist/session/guarded-engine-session.d.ts +2 -0
  190. package/node_modules/@imgly/codesign-sdk/dist/session/guarded-engine-session.js +18 -7
  191. package/node_modules/@imgly/codesign-sdk/dist/session/local-engine-session.js +247 -68
  192. package/node_modules/@imgly/codesign-sdk/dist/session/local-engine.js +2 -2
  193. package/node_modules/@imgly/codesign-sdk/dist/session/multipart.js +10 -2
  194. package/node_modules/@imgly/codesign-sdk/dist/session/pending-video.js +2 -3
  195. package/node_modules/@imgly/codesign-sdk/dist/session/read-resolved.js +93 -6
  196. package/node_modules/@imgly/codesign-sdk/dist/session/remote.d.ts +34 -10
  197. package/node_modules/@imgly/codesign-sdk/dist/session/remote.js +377 -87
  198. package/node_modules/@imgly/codesign-sdk/dist/session/render-id.js +11 -2
  199. package/node_modules/@imgly/codesign-sdk/dist/session/session.d.ts +67 -6
  200. package/node_modules/@imgly/codesign-sdk/dist/session/session.js +213 -32
  201. package/node_modules/@imgly/codesign-sdk/dist/session/silent-audio.d.ts +18 -0
  202. package/node_modules/@imgly/codesign-sdk/dist/session/silent-audio.js +47 -0
  203. package/node_modules/@imgly/codesign-sdk/dist/session/transfers.d.ts +85 -0
  204. package/node_modules/@imgly/codesign-sdk/dist/session/transfers.js +80 -0
  205. package/node_modules/@imgly/codesign-sdk/dist/session/url-guard.d.ts +30 -0
  206. package/node_modules/@imgly/codesign-sdk/dist/session/url-guard.js +187 -0
  207. package/node_modules/@imgly/codesign-sdk/dist/session/url-source.d.ts +21 -0
  208. package/node_modules/@imgly/codesign-sdk/dist/session/url-source.js +163 -0
  209. package/node_modules/@imgly/codesign-sdk/dist/session/wire.d.ts +8 -1
  210. package/node_modules/@imgly/codesign-sdk/dist/session/wire.js +2 -1
  211. package/node_modules/@imgly/codesign-sdk/dist/session-instructions.js +2 -2
  212. package/node_modules/@imgly/codesign-sdk/dist/sessions/state.d.ts +3 -1
  213. package/node_modules/@imgly/codesign-sdk/dist/sessions/state.js +5 -1
  214. package/node_modules/@imgly/codesign-sdk/dist/signed-urls.d.ts +3 -0
  215. package/node_modules/@imgly/codesign-sdk/dist/signed-urls.js +30 -0
  216. package/node_modules/@imgly/codesign-sdk/dist/skill-tool.js +12 -12
  217. package/node_modules/@imgly/codesign-sdk/dist/sources/handshake.d.ts +2 -0
  218. package/node_modules/@imgly/codesign-sdk/dist/sources/mime.js +0 -1
  219. package/node_modules/@imgly/codesign-sdk/dist/sources/route.d.ts +8 -1
  220. package/node_modules/@imgly/codesign-sdk/dist/sources/route.js +17 -2
  221. package/node_modules/@imgly/codesign-sdk/dist/sources/search.js +9 -2
  222. package/node_modules/@imgly/codesign-sdk/dist/sources/types.d.ts +8 -1
  223. package/node_modules/@imgly/codesign-sdk/dist/testing/conformance.js +11 -6
  224. package/node_modules/@imgly/codesign-sdk/dist/testing/fake-engine.d.ts +1 -1
  225. package/node_modules/@imgly/codesign-sdk/dist/testing/fake-engine.js +11 -4
  226. package/node_modules/@imgly/codesign-sdk/dist/tools/edit.js +11 -4
  227. package/node_modules/@imgly/codesign-sdk/dist/tools/errors.js +2 -2
  228. package/node_modules/@imgly/codesign-sdk/dist/tools/export-formats/table.d.ts +4 -4
  229. package/node_modules/@imgly/codesign-sdk/dist/tools/export-formats/table.js +8 -0
  230. package/node_modules/@imgly/codesign-sdk/dist/tools/export.d.ts +3 -1
  231. package/node_modules/@imgly/codesign-sdk/dist/tools/export.js +75 -12
  232. package/node_modules/@imgly/codesign-sdk/dist/tools/omit-defaults.d.ts +3 -0
  233. package/node_modules/@imgly/codesign-sdk/dist/tools/omit-defaults.js +7 -0
  234. package/node_modules/@imgly/codesign-sdk/dist/tools/preview.js +42 -19
  235. package/node_modules/@imgly/codesign-sdk/dist/tools/source-tools.js +11 -4
  236. package/node_modules/@imgly/codesign-sdk/package.json +18 -10
  237. package/node_modules/@imgly/codesign-server/assets/ai-plugins/apps.mjs +5 -5
  238. package/node_modules/@imgly/codesign-server/assets/ai-plugins/image-gateway.mjs +5 -5
  239. package/node_modules/@imgly/codesign-server/assets/ai-plugins/version.json +1 -1
  240. package/node_modules/@imgly/codesign-server/dist/catalog/link.d.ts.map +1 -1
  241. package/node_modules/@imgly/codesign-server/dist/catalog/link.js +2 -1
  242. package/node_modules/@imgly/codesign-server/dist/catalog/link.js.map +1 -1
  243. package/node_modules/@imgly/codesign-server/dist/catalog/local-server.d.ts.map +1 -1
  244. package/node_modules/@imgly/codesign-server/dist/catalog/local-server.js +1 -0
  245. package/node_modules/@imgly/codesign-server/dist/catalog/local-server.js.map +1 -1
  246. package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-add.d.ts +59 -1
  247. package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-add.d.ts.map +1 -1
  248. package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-add.js +127 -23
  249. package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-add.js.map +1 -1
  250. package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-search.d.ts +7 -0
  251. package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-search.d.ts.map +1 -1
  252. package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-search.js +65 -15
  253. package/node_modules/@imgly/codesign-server/dist/catalog/tools/asset-search.js.map +1 -1
  254. package/node_modules/@imgly/codesign-server/dist/catalog/tools/checklist.d.ts +2 -0
  255. package/node_modules/@imgly/codesign-server/dist/catalog/tools/checklist.d.ts.map +1 -1
  256. package/node_modules/@imgly/codesign-server/dist/catalog/tools/checklist.js +15 -5
  257. package/node_modules/@imgly/codesign-server/dist/catalog/tools/checklist.js.map +1 -1
  258. package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-description.d.ts +1 -1
  259. package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-description.d.ts.map +1 -1
  260. package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-description.js +7 -6
  261. package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-description.js.map +1 -1
  262. package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-formats/modules.d.ts +2 -2
  263. package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-formats/modules.d.ts.map +1 -1
  264. package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-formats/modules.js +14 -4
  265. package/node_modules/@imgly/codesign-server/dist/catalog/tools/export-formats/modules.js.map +1 -1
  266. package/node_modules/@imgly/codesign-server/dist/catalog/tools/import.d.ts +10 -0
  267. package/node_modules/@imgly/codesign-server/dist/catalog/tools/import.d.ts.map +1 -1
  268. package/node_modules/@imgly/codesign-server/dist/catalog/tools/import.js +106 -22
  269. package/node_modules/@imgly/codesign-server/dist/catalog/tools/import.js.map +1 -1
  270. package/node_modules/@imgly/codesign-server/dist/cli/connectors.js +1 -1
  271. package/node_modules/@imgly/codesign-server/dist/cli/connectors.js.map +1 -1
  272. package/node_modules/@imgly/codesign-server/dist/cli/doctor/checks/mcp-servers.js +1 -1
  273. package/node_modules/@imgly/codesign-server/dist/cli/doctor/checks/mcp-servers.js.map +1 -1
  274. package/node_modules/@imgly/codesign-server/dist/cli/pack.d.ts +1 -1
  275. package/node_modules/@imgly/codesign-server/dist/cli/pack.d.ts.map +1 -1
  276. package/node_modules/@imgly/codesign-server/dist/cli/pack.js +24 -18
  277. package/node_modules/@imgly/codesign-server/dist/cli/pack.js.map +1 -1
  278. package/node_modules/@imgly/codesign-server/dist/conversation/instructions.js +1 -1
  279. package/node_modules/@imgly/codesign-server/dist/conversation/instructions.js.map +1 -1
  280. package/node_modules/@imgly/codesign-server/dist/conversation/main.d.ts.map +1 -1
  281. package/node_modules/@imgly/codesign-server/dist/conversation/main.js +4 -3
  282. package/node_modules/@imgly/codesign-server/dist/conversation/main.js.map +1 -1
  283. package/node_modules/@imgly/codesign-server/dist/conversation/stage.d.ts +4 -0
  284. package/node_modules/@imgly/codesign-server/dist/conversation/stage.d.ts.map +1 -1
  285. package/node_modules/@imgly/codesign-server/dist/conversation/stage.js +13 -0
  286. package/node_modules/@imgly/codesign-server/dist/conversation/stage.js.map +1 -1
  287. package/node_modules/@imgly/codesign-server/dist/credentials/credential-store.d.ts +0 -6
  288. package/node_modules/@imgly/codesign-server/dist/credentials/credential-store.d.ts.map +1 -1
  289. package/node_modules/@imgly/codesign-server/dist/credentials/credential-store.js +0 -58
  290. package/node_modules/@imgly/codesign-server/dist/credentials/credential-store.js.map +1 -1
  291. package/node_modules/@imgly/codesign-server/dist/credentials/keychain.d.ts +10 -0
  292. package/node_modules/@imgly/codesign-server/dist/credentials/keychain.d.ts.map +1 -0
  293. package/node_modules/@imgly/codesign-server/dist/credentials/keychain.js +84 -0
  294. package/node_modules/@imgly/codesign-server/dist/credentials/keychain.js.map +1 -0
  295. package/node_modules/@imgly/codesign-server/dist/credentials/token-store.d.ts +1 -3
  296. package/node_modules/@imgly/codesign-server/dist/credentials/token-store.d.ts.map +1 -1
  297. package/node_modules/@imgly/codesign-server/dist/credentials/token-store.js +3 -23
  298. package/node_modules/@imgly/codesign-server/dist/credentials/token-store.js.map +1 -1
  299. package/node_modules/@imgly/codesign-server/dist/design/design-library-tools.d.ts +59 -8
  300. package/node_modules/@imgly/codesign-server/dist/design/design-library-tools.d.ts.map +1 -1
  301. package/node_modules/@imgly/codesign-server/dist/design/design-library-tools.js +317 -40
  302. package/node_modules/@imgly/codesign-server/dist/design/design-library-tools.js.map +1 -1
  303. package/node_modules/@imgly/codesign-server/dist/design/engine.js +4 -9
  304. package/node_modules/@imgly/codesign-server/dist/design/engine.js.map +1 -1
  305. package/node_modules/@imgly/codesign-server/dist/design/engines.d.ts +5 -0
  306. package/node_modules/@imgly/codesign-server/dist/design/engines.d.ts.map +1 -1
  307. package/node_modules/@imgly/codesign-server/dist/design/engines.js +49 -0
  308. package/node_modules/@imgly/codesign-server/dist/design/engines.js.map +1 -1
  309. package/node_modules/@imgly/codesign-server/dist/design/host.d.ts +2 -0
  310. package/node_modules/@imgly/codesign-server/dist/design/host.d.ts.map +1 -1
  311. package/node_modules/@imgly/codesign-server/dist/design/host.js +10 -6
  312. package/node_modules/@imgly/codesign-server/dist/design/host.js.map +1 -1
  313. package/node_modules/@imgly/codesign-server/dist/design/lazy-executors.d.ts.map +1 -1
  314. package/node_modules/@imgly/codesign-server/dist/design/lazy-executors.js +34 -5
  315. package/node_modules/@imgly/codesign-server/dist/design/lazy-executors.js.map +1 -1
  316. package/node_modules/@imgly/codesign-server/dist/design/local-design.d.ts +42 -5
  317. package/node_modules/@imgly/codesign-server/dist/design/local-design.d.ts.map +1 -1
  318. package/node_modules/@imgly/codesign-server/dist/design/local-design.js +175 -38
  319. package/node_modules/@imgly/codesign-server/dist/design/local-design.js.map +1 -1
  320. package/node_modules/@imgly/codesign-server/dist/design/local-tools.d.ts +27 -1
  321. package/node_modules/@imgly/codesign-server/dist/design/local-tools.d.ts.map +1 -1
  322. package/node_modules/@imgly/codesign-server/dist/design/local-tools.js +65 -7
  323. package/node_modules/@imgly/codesign-server/dist/design/local-tools.js.map +1 -1
  324. package/node_modules/@imgly/codesign-server/dist/design/main.d.ts.map +1 -1
  325. package/node_modules/@imgly/codesign-server/dist/design/main.js +23 -10
  326. package/node_modules/@imgly/codesign-server/dist/design/main.js.map +1 -1
  327. package/node_modules/@imgly/codesign-server/dist/design/node-exporters.d.ts +4 -0
  328. package/node_modules/@imgly/codesign-server/dist/design/node-exporters.d.ts.map +1 -0
  329. package/node_modules/@imgly/codesign-server/dist/design/node-exporters.js +13 -0
  330. package/node_modules/@imgly/codesign-server/dist/design/node-exporters.js.map +1 -0
  331. package/node_modules/@imgly/codesign-server/dist/design/probe-media.d.ts +2 -0
  332. package/node_modules/@imgly/codesign-server/dist/design/probe-media.d.ts.map +1 -0
  333. package/node_modules/@imgly/codesign-server/dist/design/probe-media.js +16 -0
  334. package/node_modules/@imgly/codesign-server/dist/design/probe-media.js.map +1 -0
  335. package/node_modules/@imgly/codesign-server/dist/design/remote-resources.d.ts +22 -3
  336. package/node_modules/@imgly/codesign-server/dist/design/remote-resources.d.ts.map +1 -1
  337. package/node_modules/@imgly/codesign-server/dist/design/remote-resources.js +123 -32
  338. package/node_modules/@imgly/codesign-server/dist/design/remote-resources.js.map +1 -1
  339. package/node_modules/@imgly/codesign-server/dist/design/save.d.ts +5 -0
  340. package/node_modules/@imgly/codesign-server/dist/design/save.d.ts.map +1 -1
  341. package/node_modules/@imgly/codesign-server/dist/design/save.js +9 -0
  342. package/node_modules/@imgly/codesign-server/dist/design/save.js.map +1 -1
  343. package/node_modules/@imgly/codesign-server/dist/design/sessions/store.d.ts +33 -4
  344. package/node_modules/@imgly/codesign-server/dist/design/sessions/store.d.ts.map +1 -1
  345. package/node_modules/@imgly/codesign-server/dist/design/sessions/store.js +121 -43
  346. package/node_modules/@imgly/codesign-server/dist/design/sessions/store.js.map +1 -1
  347. package/node_modules/@imgly/codesign-server/dist/design/workspace-files.d.ts +8 -0
  348. package/node_modules/@imgly/codesign-server/dist/design/workspace-files.d.ts.map +1 -1
  349. package/node_modules/@imgly/codesign-server/dist/design/workspace-files.js +50 -61
  350. package/node_modules/@imgly/codesign-server/dist/design/workspace-files.js.map +1 -1
  351. package/node_modules/@imgly/codesign-server/dist/design/workspace-library.d.ts +24 -2
  352. package/node_modules/@imgly/codesign-server/dist/design/workspace-library.d.ts.map +1 -1
  353. package/node_modules/@imgly/codesign-server/dist/design/workspace-library.js +132 -17
  354. package/node_modules/@imgly/codesign-server/dist/design/workspace-library.js.map +1 -1
  355. package/node_modules/@imgly/codesign-server/dist/services/archives/create.d.ts.map +1 -1
  356. package/node_modules/@imgly/codesign-server/dist/services/archives/create.js +19 -6
  357. package/node_modules/@imgly/codesign-server/dist/services/archives/create.js.map +1 -1
  358. package/node_modules/@imgly/codesign-server/dist/services/archives/handlers.d.ts.map +1 -1
  359. package/node_modules/@imgly/codesign-server/dist/services/archives/handlers.js +10 -7
  360. package/node_modules/@imgly/codesign-server/dist/services/archives/handlers.js.map +1 -1
  361. package/node_modules/@imgly/codesign-server/dist/services/archives/pack.d.ts +3 -1
  362. package/node_modules/@imgly/codesign-server/dist/services/archives/pack.d.ts.map +1 -1
  363. package/node_modules/@imgly/codesign-server/dist/services/archives/pack.js +5 -4
  364. package/node_modules/@imgly/codesign-server/dist/services/archives/pack.js.map +1 -1
  365. package/node_modules/@imgly/codesign-server/dist/services/archives/seed-pack.d.ts +56 -0
  366. package/node_modules/@imgly/codesign-server/dist/services/archives/seed-pack.d.ts.map +1 -0
  367. package/node_modules/@imgly/codesign-server/dist/services/archives/seed-pack.js +218 -0
  368. package/node_modules/@imgly/codesign-server/dist/services/archives/seed-pack.js.map +1 -0
  369. package/node_modules/@imgly/codesign-server/dist/services/archives/seed.d.ts.map +1 -1
  370. package/node_modules/@imgly/codesign-server/dist/services/archives/seed.js +33 -124
  371. package/node_modules/@imgly/codesign-server/dist/services/archives/seed.js.map +1 -1
  372. package/node_modules/@imgly/codesign-server/dist/services/archives/template.d.ts +1 -0
  373. package/node_modules/@imgly/codesign-server/dist/services/archives/template.d.ts.map +1 -1
  374. package/node_modules/@imgly/codesign-server/dist/services/archives/template.js +1 -1
  375. package/node_modules/@imgly/codesign-server/dist/services/archives/template.js.map +1 -1
  376. package/node_modules/@imgly/codesign-server/dist/services/auth/login-manager.d.ts.map +1 -1
  377. package/node_modules/@imgly/codesign-server/dist/services/auth/login-manager.js +2 -1
  378. package/node_modules/@imgly/codesign-server/dist/services/auth/login-manager.js.map +1 -1
  379. package/node_modules/@imgly/codesign-server/dist/services/diagnostics/status.d.ts +9 -5
  380. package/node_modules/@imgly/codesign-server/dist/services/diagnostics/status.d.ts.map +1 -1
  381. package/node_modules/@imgly/codesign-server/dist/services/diagnostics/status.js +14 -19
  382. package/node_modules/@imgly/codesign-server/dist/services/diagnostics/status.js.map +1 -1
  383. package/node_modules/@imgly/codesign-server/dist/services/diagnostics/tool.d.ts +2 -0
  384. package/node_modules/@imgly/codesign-server/dist/services/diagnostics/tool.d.ts.map +1 -1
  385. package/node_modules/@imgly/codesign-server/dist/services/diagnostics/tool.js +1 -0
  386. package/node_modules/@imgly/codesign-server/dist/services/diagnostics/tool.js.map +1 -1
  387. package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-image-source.d.ts.map +1 -1
  388. package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-image-source.js +4 -1
  389. package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-image-source.js.map +1 -1
  390. package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-source-module.d.ts +5 -1
  391. package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-source-module.d.ts.map +1 -1
  392. package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-source-module.js +67 -6
  393. package/node_modules/@imgly/codesign-server/dist/services/engine/workspace-source-module.js.map +1 -1
  394. package/node_modules/@imgly/codesign-server/dist/services/flags/manifest.js +2 -2
  395. package/node_modules/@imgly/codesign-server/dist/services/flags/manifest.js.map +1 -1
  396. package/node_modules/@imgly/codesign-server/dist/services/flags/release-flags.generated.d.ts +3 -3
  397. package/node_modules/@imgly/codesign-server/dist/services/flags/release-flags.generated.d.ts.map +1 -1
  398. package/node_modules/@imgly/codesign-server/dist/services/flags/release-flags.generated.js +3 -3
  399. package/node_modules/@imgly/codesign-server/dist/services/flags/release-flags.generated.js.map +1 -1
  400. package/node_modules/@imgly/codesign-server/dist/services/gateway-bearer.d.ts +15 -0
  401. package/node_modules/@imgly/codesign-server/dist/services/gateway-bearer.d.ts.map +1 -0
  402. package/node_modules/@imgly/codesign-server/dist/services/gateway-bearer.js +14 -0
  403. package/node_modules/@imgly/codesign-server/dist/services/gateway-bearer.js.map +1 -0
  404. package/node_modules/@imgly/codesign-server/dist/services/telemetry/error-policy.d.ts.map +1 -1
  405. package/node_modules/@imgly/codesign-server/dist/services/telemetry/error-policy.js +36 -0
  406. package/node_modules/@imgly/codesign-server/dist/services/telemetry/error-policy.js.map +1 -1
  407. package/node_modules/@imgly/codesign-server/dist/services/telemetry/usage-sink.d.ts +2 -2
  408. package/node_modules/@imgly/codesign-server/dist/services/telemetry/usage-sink.d.ts.map +1 -1
  409. package/node_modules/@imgly/codesign-server/dist/services/telemetry/usage-sink.js +3 -5
  410. package/node_modules/@imgly/codesign-server/dist/services/telemetry/usage-sink.js.map +1 -1
  411. package/node_modules/@imgly/codesign-server/dist/services/viewer/ai-plugin-assets.d.ts.map +1 -1
  412. package/node_modules/@imgly/codesign-server/dist/services/viewer/ai-plugin-assets.js +5 -4
  413. package/node_modules/@imgly/codesign-server/dist/services/viewer/ai-plugin-assets.js.map +1 -1
  414. package/node_modules/@imgly/codesign-server/dist/services/viewer/spa-assets.generated.d.ts.map +1 -1
  415. package/node_modules/@imgly/codesign-server/dist/services/viewer/spa-assets.generated.js +0 -64
  416. package/node_modules/@imgly/codesign-server/dist/services/viewer/spa-assets.generated.js.map +1 -1
  417. package/node_modules/@imgly/codesign-server/dist/services/viewer/url-builder.d.ts +4 -0
  418. package/node_modules/@imgly/codesign-server/dist/services/viewer/url-builder.d.ts.map +1 -1
  419. package/node_modules/@imgly/codesign-server/dist/services/viewer/url-builder.js +4 -0
  420. package/node_modules/@imgly/codesign-server/dist/services/viewer/url-builder.js.map +1 -1
  421. package/node_modules/@imgly/codesign-server/dist/services/viewer/workspace-source-route.d.ts.map +1 -1
  422. package/node_modules/@imgly/codesign-server/dist/services/viewer/workspace-source-route.js +2 -24
  423. package/node_modules/@imgly/codesign-server/dist/services/viewer/workspace-source-route.js.map +1 -1
  424. package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-sidecars.d.ts +4 -2
  425. package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-sidecars.d.ts.map +1 -1
  426. package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-sidecars.js +15 -14
  427. package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-sidecars.js.map +1 -1
  428. package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-store.d.ts +12 -2
  429. package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-store.d.ts.map +1 -1
  430. package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-store.js +42 -12
  431. package/node_modules/@imgly/codesign-server/dist/services/workspace/asset-store.js.map +1 -1
  432. package/node_modules/@imgly/codesign-server/dist/services/workspace/assets-handlers.d.ts.map +1 -1
  433. package/node_modules/@imgly/codesign-server/dist/services/workspace/assets-handlers.js +1 -2
  434. package/node_modules/@imgly/codesign-server/dist/services/workspace/assets-handlers.js.map +1 -1
  435. package/node_modules/@imgly/codesign-server/dist/services/workspace/image-listing.d.ts.map +1 -1
  436. package/node_modules/@imgly/codesign-server/dist/services/workspace/image-listing.js +24 -2
  437. package/node_modules/@imgly/codesign-server/dist/services/workspace/image-listing.js.map +1 -1
  438. package/node_modules/@imgly/codesign-server/dist/services/workspace/layout-keys.d.ts +47 -0
  439. package/node_modules/@imgly/codesign-server/dist/services/workspace/layout-keys.d.ts.map +1 -0
  440. package/node_modules/@imgly/codesign-server/dist/services/workspace/layout-keys.js +167 -0
  441. package/node_modules/@imgly/codesign-server/dist/services/workspace/layout-keys.js.map +1 -0
  442. package/node_modules/@imgly/codesign-server/dist/services/workspace/layout.d.ts +2 -0
  443. package/node_modules/@imgly/codesign-server/dist/services/workspace/layout.d.ts.map +1 -1
  444. package/node_modules/@imgly/codesign-server/dist/services/workspace/layout.js +2 -0
  445. package/node_modules/@imgly/codesign-server/dist/services/workspace/layout.js.map +1 -1
  446. package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-fs.d.ts +32 -0
  447. package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-fs.d.ts.map +1 -0
  448. package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-fs.js +79 -0
  449. package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-fs.js.map +1 -0
  450. package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-workspace.d.ts +35 -0
  451. package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-workspace.d.ts.map +1 -0
  452. package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-workspace.js +185 -0
  453. package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store-workspace.js.map +1 -0
  454. package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store.d.ts +74 -0
  455. package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store.d.ts.map +1 -0
  456. package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store.js +82 -0
  457. package/node_modules/@imgly/codesign-server/dist/services/workspace/object-store.js.map +1 -0
  458. package/node_modules/@imgly/codesign-server/dist/services/workspace/types.d.ts +10 -0
  459. package/node_modules/@imgly/codesign-server/dist/services/workspace/types.d.ts.map +1 -1
  460. package/node_modules/@imgly/codesign-server/dist/services/workspace/types.js +1 -0
  461. package/node_modules/@imgly/codesign-server/dist/services/workspace/types.js.map +1 -1
  462. package/node_modules/@imgly/codesign-server/dist/services/workspace/write-atomic.d.ts.map +1 -1
  463. package/node_modules/@imgly/codesign-server/dist/services/workspace/write-atomic.js +5 -0
  464. package/node_modules/@imgly/codesign-server/dist/services/workspace/write-atomic.js.map +1 -1
  465. package/node_modules/@imgly/codesign-server/package.json +13 -11
  466. package/node_modules/@imgly/design-lint/dist/rules/text-legibility.d.ts +2 -1
  467. package/node_modules/@imgly/design-lint/dist/rules/text-legibility.d.ts.map +1 -1
  468. package/node_modules/@imgly/design-lint/dist/rules/text-legibility.js +5 -1
  469. package/node_modules/@imgly/design-lint/dist/rules/text-legibility.js.map +1 -1
  470. package/node_modules/@imgly/design-lint/package.json +2 -2
  471. package/node_modules/@imgly/figma-exporter/CHANGELOG.md +79 -0
  472. package/node_modules/@imgly/figma-exporter/LICENSE.md +137 -0
  473. package/node_modules/@imgly/figma-exporter/README.md +201 -0
  474. package/node_modules/@imgly/figma-exporter/THIRD_PARTY_NOTICES.md +475 -0
  475. package/node_modules/@imgly/figma-exporter/dist/index.cjs +1 -0
  476. package/node_modules/@imgly/figma-exporter/dist/index.d.cts +8833 -0
  477. package/node_modules/@imgly/figma-exporter/dist/index.d.ts +8833 -0
  478. package/node_modules/@imgly/figma-exporter/dist/index.js +1 -0
  479. package/node_modules/@imgly/figma-exporter/package.json +92 -0
  480. package/node_modules/@imgly/figma-importer/CHANGELOG.md +84 -0
  481. package/node_modules/@imgly/figma-importer/LICENSE.md +137 -0
  482. package/node_modules/@imgly/figma-importer/README.md +256 -0
  483. package/node_modules/@imgly/figma-importer/THIRD_PARTY_NOTICES.md +446 -0
  484. package/node_modules/@imgly/figma-importer/dist/index.cjs +2 -0
  485. package/node_modules/@imgly/figma-importer/dist/index.d.cts +12831 -0
  486. package/node_modules/@imgly/figma-importer/dist/index.d.ts +12831 -0
  487. package/node_modules/@imgly/figma-importer/dist/index.js +2 -0
  488. package/node_modules/@imgly/figma-importer/package.json +85 -0
  489. package/node_modules/@imgly/html-exporter/CHANGELOG.md +35 -0
  490. package/node_modules/@imgly/html-exporter/README.md +45 -4
  491. package/node_modules/@imgly/html-exporter/dist/index.cjs +610 -493
  492. package/node_modules/@imgly/html-exporter/dist/index.d.cts +235 -216
  493. package/node_modules/@imgly/html-exporter/dist/index.d.ts +235 -216
  494. package/node_modules/@imgly/html-exporter/dist/index.js +610 -493
  495. package/node_modules/@imgly/html-exporter/package.json +15 -10
  496. package/node_modules/@imgly/idml-exporter/CHANGELOG.md +10 -0
  497. package/node_modules/@imgly/idml-exporter/README.md +17 -18
  498. package/node_modules/@imgly/idml-exporter/dist/harfbuzz.browser.js +1 -1
  499. package/node_modules/@imgly/idml-exporter/dist/index.cjs +8 -11
  500. package/node_modules/@imgly/idml-exporter/dist/index.d.cts +14480 -10275
  501. package/node_modules/@imgly/idml-exporter/dist/index.d.ts +14480 -10275
  502. package/node_modules/@imgly/idml-exporter/dist/index.js +8 -10
  503. package/node_modules/@imgly/idml-exporter/dist/woff2.browser.js +14 -14
  504. package/node_modules/@imgly/idml-exporter/package.json +17 -12
  505. package/node_modules/@imgly/idml-importer/CHANGELOG.md +37 -0
  506. package/node_modules/@imgly/idml-importer/README.md +148 -17
  507. package/node_modules/@imgly/idml-importer/dist/index.cjs +6 -5
  508. package/node_modules/@imgly/idml-importer/dist/index.d.cts +1003 -632
  509. package/node_modules/@imgly/idml-importer/dist/index.d.ts +1003 -632
  510. package/node_modules/@imgly/idml-importer/dist/index.js +6 -5
  511. package/node_modules/@imgly/idml-importer/package.json +9 -9
  512. package/node_modules/@imgly/pdf-importer/CHANGELOG.md +59 -0
  513. package/node_modules/@imgly/pdf-importer/README.md +71 -7
  514. package/node_modules/@imgly/pdf-importer/dist/browser.d.ts +940 -788
  515. package/node_modules/@imgly/pdf-importer/dist/browser.js +17 -15
  516. package/node_modules/@imgly/pdf-importer/dist/node.cjs +17 -16
  517. package/node_modules/@imgly/pdf-importer/dist/node.d.cts +940 -788
  518. package/node_modules/@imgly/pdf-importer/dist/node.d.ts +940 -788
  519. package/node_modules/@imgly/pdf-importer/dist/node.js +17 -15
  520. package/node_modules/@imgly/pdf-importer/dist/pdf.worker.mjs +80265 -61990
  521. package/node_modules/@imgly/pdf-importer/package.json +13 -13
  522. package/node_modules/@imgly/psd-exporter/CHANGELOG.md +12 -0
  523. package/node_modules/@imgly/psd-exporter/README.md +50 -7
  524. package/node_modules/@imgly/psd-exporter/dist/index.cjs +5 -7
  525. package/node_modules/@imgly/psd-exporter/dist/index.d.cts +14332 -10063
  526. package/node_modules/@imgly/psd-exporter/dist/index.d.ts +14332 -10063
  527. package/node_modules/@imgly/psd-exporter/dist/index.js +5 -6
  528. package/node_modules/@imgly/psd-exporter/dist/wawoff2-LICENSE.txt +19 -0
  529. package/node_modules/@imgly/psd-exporter/dist/woff2.browser.js +19 -0
  530. package/node_modules/@imgly/psd-exporter/package.json +26 -9
  531. package/node_modules/@imgly/psd-importer/CHANGELOG.md +29 -1
  532. package/node_modules/@imgly/psd-importer/README.md +22 -30
  533. package/node_modules/@imgly/psd-importer/dist/index.cjs +11 -11
  534. package/node_modules/@imgly/psd-importer/dist/index.d.cts +10479 -12978
  535. package/node_modules/@imgly/psd-importer/dist/index.d.ts +10479 -12978
  536. package/node_modules/@imgly/psd-importer/dist/index.js +11 -11
  537. package/node_modules/@imgly/psd-importer/package.json +8 -11
  538. package/package.json +28 -17
  539. package/node_modules/@imgly/pdf-importer/dist/browser.d.cts +0 -941
@@ -1,16 +1,17 @@
1
- var __import_meta_url__ = require('url').pathToFileURL(__filename).href;
2
- "use strict";var Ub=Object.create;var Ps=Object.defineProperty;var Bb=Object.getOwnPropertyDescriptor;var Gb=Object.getOwnPropertyNames;var Hb=Object.getPrototypeOf,jb=Object.prototype.hasOwnProperty;var Vb=(i,t)=>()=>(i&&(t=i(i=0)),t);var Wb=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),Pu=(i,t)=>{for(var e in t)Ps(i,e,{get:t[e],enumerable:!0})},Ru=(i,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Gb(t))!jb.call(i,s)&&s!==e&&Ps(i,s,{get:()=>t[s],enumerable:!(n=Bb(t,s))||n.enumerable});return i};var Ou=(i,t,e)=>(e=i!=null?Ub(Hb(i)):{},Ru(t||!i||!i.__esModule?Ps(e,"default",{value:i,enumerable:!0}):e,i)),$b=i=>Ru(Ps({},"__esModule",{value:!0}),i);var ah={};Pu(ah,{AbortException:()=>Qy,AnnotationEditorLayer:()=>Jy,AnnotationEditorParamsType:()=>qy,AnnotationEditorType:()=>tv,AnnotationEditorUIManager:()=>ev,AnnotationLayer:()=>nv,AnnotationMode:()=>ll,ColorPicker:()=>rv,DOMSVGFactory:()=>sv,DrawLayer:()=>iv,FeatureTest:()=>ov,GlobalWorkerOptions:()=>av,ImageKind:()=>lv,InvalidPDFException:()=>cv,MissingPDFException:()=>uv,OPS:()=>hv,OutputScale:()=>dv,PDFDataRangeTransport:()=>fv,PDFDateString:()=>pv,PDFWorker:()=>gv,PasswordResponses:()=>mv,PermissionFlag:()=>bv,PixelsPerInch:()=>yv,RenderingCancelledException:()=>vv,TextLayer:()=>xv,TouchManager:()=>Sv,UnexpectedResponseException:()=>Av,Util:()=>Tv,VerbosityLevel:()=>wv,XfaLayer:()=>Ev,build:()=>Cv,createValidAbsoluteUrl:()=>kv,fetchData:()=>Iv,getDocument:()=>Pv,getFilenameFromUrl:()=>Rv,getPdfFilenameFromUrl:()=>Ov,getXfaPageViewport:()=>Mv,isDataScheme:()=>Lv,isPdfFile:()=>Fv,noContextMenu:()=>Dv,normalizeUnicode:()=>_v,setLayerDimensions:()=>Nv,shadow:()=>Uv,stopEvent:()=>Bv,version:()=>Gv});function Dt(i){var t=Nu[i];if(t!==void 0)return t.exports;var e=Nu[i]={exports:{}};return ny[i].call(e.exports,e,e.exports,Dt),e.exports}function ly(i){Number.isInteger(i)&&(mi=i)}function cy(){return mi}function bi(i){mi>=gi.INFOS&&console.log(`Info: ${i}`)}function Pt(i){mi>=gi.WARNINGS&&console.log(`Warning: ${i}`)}function $t(i){throw new Error(i)}function ee(i,t){i||$t(t)}function uy(i){switch(i?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function hy(i,t=null,e=null){if(!i)return null;try{if(e&&typeof i=="string"&&(e.addDefaultProtocol&&i.startsWith("www.")&&i.match(/\./g)?.length>=2&&(i=`http://${i}`),e.tryConvertEncoding))try{i=gy(i)}catch{}let n=t?new URL(i,t):new URL(i);if(uy(n))return n}catch{}return null}function Lt(i,t,e,n=!1){return Object.defineProperty(i,t,{value:e,enumerable:!n,configurable:!0,writable:!1}),e}function qu(i){(typeof i!="object"||i?.length===void 0)&&$t("Invalid argument for bytesToString");let t=i.length,e=8192;if(t<e)return String.fromCharCode.apply(null,i);let n=[];for(let s=0;s<t;s+=e){let o=Math.min(s+e,t),l=i.subarray(s,o);n.push(String.fromCharCode.apply(null,l))}return n.join("")}function yi(i){typeof i!="string"&&$t("Invalid argument for stringToBytes");let t=i.length,e=new Uint8Array(t);for(let n=0;n<t;++n)e[n]=i.charCodeAt(n)&255;return e}function dy(i){return String.fromCharCode(i>>24&255,i>>16&255,i>>8&255,i&255)}function sl(i){let t=Object.create(null);for(let[e,n]of i)t[e]=n;return t}function fy(){let i=new Uint8Array(4);return i[0]=1,new Uint32Array(i.buffer,0,1)[0]===1}function py(){try{return new Function(""),!0}catch{return!1}}function gy(i){return decodeURIComponent(escape(i))}function my(i){return Mo||(Mo=/([\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,Uu=new Map([["\uFB05","\u017Ft"]])),i.replaceAll(Mo,(t,e,n)=>e?e.normalize("NFKC"):Uu.get(n))}function by(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();let i=new Uint8Array(32);return crypto.getRandomValues(i),qu(i)}function yy(i){return Uint8Array.prototype.toBase64?i.toBase64():btoa(qu(i))}async function vi(i,t="text"){if(Pr(i,document.baseURI)){let e=await fetch(i);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,n)=>{let s=new XMLHttpRequest;s.open("GET",i,!0),s.responseType=t,s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE){if(s.status===200||s.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(s.response);return}e(s.responseText);return}n(new Error(s.statusText))}},s.send(null)})}function xi(i){let t=i.length,e=0;for(;e<t&&i[e].trim()==="";)e++;return i.substring(e,e+5).toLowerCase()==="data:"}function ol(i){return typeof i=="string"&&/\.pdf$/i.test(i)}function vy(i){return[i]=i.split(/[#?]/,1),i.substring(i.lastIndexOf("/")+1)}function xy(i,t="document.pdf"){if(typeof i!="string")return t;if(xi(i))return Pt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let e=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=e.exec(i),o=n.exec(s[1])||n.exec(s[2])||n.exec(s[3]);if(o&&(o=o[0],o.includes("%")))try{o=n.exec(decodeURIComponent(o))[0]}catch{}return o||t}function Pr(i,t){try{let{protocol:e}=t?new URL(i,t):new URL(i);return e==="http:"||e==="https:"}catch{return!1}}function $e(i){i.preventDefault()}function Ie(i){i.preventDefault(),i.stopPropagation()}function Sy(i,{scale:t=1,rotation:e=0}){let{width:n,height:s}=i.attributes.style,o=[0,0,parseInt(n),parseInt(s)];return new Mr({viewBox:o,userUnit:1,scale:t,rotation:e})}function al(i){if(i.startsWith("#")){let t=parseInt(i.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return i.startsWith("rgb(")?i.slice(4,-1).split(",").map(t=>parseInt(t)):i.startsWith("rgba(")?i.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(Pt(`Not a valid color format: "${i}"`),[0,0,0])}function Ay(i){let t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(let e of i.keys()){t.style.color=e;let n=window.getComputedStyle(t).color;i.set(e,al(n))}t.remove()}function Xt(i){let{a:t,b:e,c:n,d:s,e:o,f:l}=i.getTransform();return[t,e,n,s,o,l]}function Ze(i){let{a:t,b:e,c:n,d:s,e:o,f:l}=i.getTransform().invertSelf();return[t,e,n,s,o,l]}function Nn(i,t,e=!1,n=!0){if(t instanceof Mr){let{pageWidth:s,pageHeight:o}=t.rawDims,{style:l}=i,u=se.isCSSRoundSupported,d=`var(--scale-factor) * ${s}px`,p=`var(--scale-factor) * ${o}px`,m=u?`round(down, ${d}, var(--scale-round-x, 1px))`:`calc(${d})`,b=u?`round(down, ${p}, var(--scale-round-y, 1px))`:`calc(${p})`;!e||t.rotation%180===0?(l.width=m,l.height=b):(l.width=b,l.height=m)}n&&i.setAttribute("data-main-rotation",t.rotation)}function Hs(i,t,e){for(let n of e)t.addEventListener(n,i[n].bind(i))}function Gu(){}function Se(i){if(i instanceof Je||i instanceof Or||i instanceof _n||i instanceof Us||i instanceof ar||i instanceof Rr)return i;switch(i instanceof Error||typeof i=="object"&&i!==null||$t('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),i.name){case"AbortException":return new Je(i.message);case"InvalidPDFException":return new Or(i.message);case"MissingPDFException":return new _n(i.message);case"PasswordException":return new Us(i.message,i.code);case"UnexpectedResponseException":return new ar(i.message,i.status);case"UnknownErrorException":return new Rr(i.message,i.details)}return new Rr(i.message,i.toString())}async function th(i){let e=await process.getBuiltinModule("fs").promises.readFile(i);return new Uint8Array(e)}function ta(i,t){if(!t)return;let e=t[2]-t[0],n=t[3]-t[1],s=new Path2D;s.rect(t[0],t[1],e,n),i.clip(s)}function Lo(i,t,e,n,s,o,l,u){let d=t.coords,p=t.colors,m=i.data,b=i.width*4,v;d[e+1]>d[n+1]&&(v=e,e=n,n=v,v=o,o=l,l=v),d[n+1]>d[s+1]&&(v=n,n=s,s=v,v=l,l=u,u=v),d[e+1]>d[n+1]&&(v=e,e=n,n=v,v=o,o=l,l=v);let A=(d[e]+t.offsetX)*t.scaleX,x=(d[e+1]+t.offsetY)*t.scaleY,w=(d[n]+t.offsetX)*t.scaleX,k=(d[n+1]+t.offsetY)*t.scaleY,I=(d[s]+t.offsetX)*t.scaleX,P=(d[s+1]+t.offsetY)*t.scaleY;if(x>=P)return;let M=p[o],N=p[o+1],D=p[o+2],U=p[l],G=p[l+1],H=p[l+2],W=p[u],J=p[u+1],q=p[u+2],dt=Math.round(x),Q=Math.round(P),ot,ct,X,$,ut,st,St,Ct;for(let wt=dt;wt<=Q;wt++){if(wt<k){let _=wt<x?0:(x-wt)/(x-k);ot=A-(A-w)*_,ct=M-(M-U)*_,X=N-(N-G)*_,$=D-(D-H)*_}else{let _;wt>P?_=1:k===P?_=0:_=(k-wt)/(k-P),ot=w-(w-I)*_,ct=U-(U-W)*_,X=G-(G-J)*_,$=H-(H-q)*_}let Et;wt<x?Et=0:wt>P?Et=1:Et=(x-wt)/(x-P),ut=A-(A-I)*Et,st=M-(M-W)*Et,St=N-(N-J)*Et,Ct=D-(D-q)*Et;let Vt=Math.round(Math.min(ot,ut)),Ut=Math.round(Math.max(ot,ut)),at=b*wt+Vt*4;for(let _=Vt;_<=Ut;_++)Et=(ot-_)/(ot-ut),Et<0?Et=0:Et>1&&(Et=1),m[at++]=ct-(ct-st)*Et|0,m[at++]=X-(X-St)*Et|0,m[at++]=$-($-Ct)*Et|0,m[at++]=255}}function Ty(i,t,e){let n=t.coords,s=t.colors,o,l;switch(t.type){case"lattice":let u=t.verticesPerRow,d=Math.floor(n.length/u)-1,p=u-1;for(o=0;o<d;o++){let m=o*u;for(let b=0;b<p;b++,m++)Lo(i,e,n[m],n[m+1],n[m+u],s[m],s[m+1],s[m+u]),Lo(i,e,n[m+u+1],n[m+1],n[m+u],s[m+u+1],s[m+1],s[m+u])}break;case"triangles":for(o=0,l=n.length;o<l;o+=3)Lo(i,e,n[o],n[o+1],n[o+2],s[o],s[o+1],s[o+2]);break;default:throw new Error("illegal figure")}}function wy(i){switch(i[0]){case"RadialAxial":return new ea(i);case"Mesh":return new na(i);case"Dummy":return new ra}throw new Error(`Unknown IR type: ${i[0]}`)}function Ey({src:i,srcPos:t=0,dest:e,width:n,height:s,nonBlackColor:o=4294967295,inverseDecode:l=!1}){let u=se.isLittleEndian?4278190080:255,[d,p]=l?[o,u]:[u,o],m=n>>3,b=n&7,v=i.length;e=new Uint32Array(e.buffer);let A=0;for(let x=0;x<s;x++){for(let k=t+m;t<k;t++){let I=t<v?i[t]:255;e[A++]=I&128?p:d,e[A++]=I&64?p:d,e[A++]=I&32?p:d,e[A++]=I&16?p:d,e[A++]=I&8?p:d,e[A++]=I&4?p:d,e[A++]=I&2?p:d,e[A++]=I&1?p:d}if(b===0)continue;let w=t<v?i[t++]:255;for(let k=0;k<b;k++)e[A++]=w&1<<7-k?p:d}return{srcPos:t,destPos:A}}function ky(i,t){if(i._removeMirroring)throw new Error("Context is already forwarding operations.");i.__originalSave=i.save,i.__originalRestore=i.restore,i.__originalRotate=i.rotate,i.__originalScale=i.scale,i.__originalTranslate=i.translate,i.__originalTransform=i.transform,i.__originalSetTransform=i.setTransform,i.__originalResetTransform=i.resetTransform,i.__originalClip=i.clip,i.__originalMoveTo=i.moveTo,i.__originalLineTo=i.lineTo,i.__originalBezierCurveTo=i.bezierCurveTo,i.__originalRect=i.rect,i.__originalClosePath=i.closePath,i.__originalBeginPath=i.beginPath,i._removeMirroring=()=>{i.save=i.__originalSave,i.restore=i.__originalRestore,i.rotate=i.__originalRotate,i.scale=i.__originalScale,i.translate=i.__originalTranslate,i.transform=i.__originalTransform,i.setTransform=i.__originalSetTransform,i.resetTransform=i.__originalResetTransform,i.clip=i.__originalClip,i.moveTo=i.__originalMoveTo,i.lineTo=i.__originalLineTo,i.bezierCurveTo=i.__originalBezierCurveTo,i.rect=i.__originalRect,i.closePath=i.__originalClosePath,i.beginPath=i.__originalBeginPath,delete i._removeMirroring},i.save=function(){t.save(),this.__originalSave()},i.restore=function(){t.restore(),this.__originalRestore()},i.translate=function(n,s){t.translate(n,s),this.__originalTranslate(n,s)},i.scale=function(n,s){t.scale(n,s),this.__originalScale(n,s)},i.transform=function(n,s,o,l,u,d){t.transform(n,s,o,l,u,d),this.__originalTransform(n,s,o,l,u,d)},i.setTransform=function(n,s,o,l,u,d){t.setTransform(n,s,o,l,u,d),this.__originalSetTransform(n,s,o,l,u,d)},i.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},i.rotate=function(n){t.rotate(n),this.__originalRotate(n)},i.clip=function(n){t.clip(n),this.__originalClip(n)},i.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},i.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},i.bezierCurveTo=function(e,n,s,o,l,u){t.bezierCurveTo(e,n,s,o,l,u),this.__originalBezierCurveTo(e,n,s,o,l,u)},i.rect=function(e,n,s,o){t.rect(e,n,s,o),this.__originalRect(e,n,s,o)},i.closePath=function(){t.closePath(),this.__originalClosePath()},i.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}function Ls(i,t,e,n,s,o,l,u,d,p){let[m,b,v,A,x,w]=Xt(i);if(b===0&&v===0){let P=l*m+x,M=Math.round(P),N=u*A+w,D=Math.round(N),U=(l+d)*m+x,G=Math.abs(Math.round(U)-M)||1,H=(u+p)*A+w,W=Math.abs(Math.round(H)-D)||1;return i.setTransform(Math.sign(m),0,0,Math.sign(A),M,D),i.drawImage(t,e,n,s,o,0,0,G,W),i.setTransform(m,b,v,A,x,w),[G,W]}if(m===0&&A===0){let P=u*v+x,M=Math.round(P),N=l*b+w,D=Math.round(N),U=(u+p)*v+x,G=Math.abs(Math.round(U)-M)||1,H=(l+d)*b+w,W=Math.abs(Math.round(H)-D)||1;return i.setTransform(0,Math.sign(b),Math.sign(v),0,M,D),i.drawImage(t,e,n,s,o,0,0,W,G),i.setTransform(m,b,v,A,x,w),[W,G]}i.drawImage(t,e,n,s,o,l,u,d,p);let k=Math.hypot(m,b),I=Math.hypot(v,A);return[k*d,I*p]}function Iy(i){let{width:t,height:e}=i;if(t>$u||e>$u)return null;let n=1e3,s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),o=t+1,l=new Uint8Array(o*(e+1)),u,d,p,m=t+7&-8,b=new Uint8Array(m*e),v=0;for(let I of i.data){let P=128;for(;P>0;)b[v++]=I&P?0:255,P>>=1}let A=0;for(v=0,b[v]!==0&&(l[0]=1,++A),d=1;d<t;d++)b[v]!==b[v+1]&&(l[d]=b[v]?2:1,++A),v++;for(b[v]!==0&&(l[d]=2,++A),u=1;u<e;u++){v=u*m,p=u*o,b[v-m]!==b[v]&&(l[p]=b[v]?1:8,++A);let I=(b[v]?4:0)+(b[v-m]?8:0);for(d=1;d<t;d++)I=(I>>2)+(b[v+1]?4:0)+(b[v-m+1]?8:0),s[I]&&(l[p+d]=s[I],++A),v++;if(b[v-m]!==b[v]&&(l[p+d]=b[v]?2:4,++A),A>n)return null}for(v=m*(e-1),p=u*o,b[v]!==0&&(l[p]=8,++A),d=1;d<t;d++)b[v]!==b[v+1]&&(l[p+d]=b[v]?4:8,++A),v++;if(b[v]!==0&&(l[p+d]=4,++A),A>n)return null;let x=new Int32Array([0,o,-1,0,-o,0,0,0,1]),w=new Path2D;for(u=0;A&&u<=e;u++){let I=u*o,P=I+t;for(;I<P&&!l[I];)I++;if(I===P)continue;w.moveTo(I%o,u);let M=I,N=l[I];do{let D=x[N];do I+=D;while(!l[I]);let U=l[I];U!==5&&U!==10?(N=U,l[I]=0):(N=U&51*N>>4,l[I]&=N>>2|N<<2),w.lineTo(I%o,I/o|0),l[I]||--A}while(M!==I);--u}return b=null,l=null,function(I){I.save(),I.scale(1/t,-1/e),I.translate(0,-e),I.fill(w),I.beginPath(),I.restore()}}function zu(i,t){if(t instanceof ImageData){i.putImageData(t,0,0);return}let e=t.height,n=t.width,s=e%Ae,o=(e-s)/Ae,l=s===0?o:o+1,u=i.createImageData(n,Ae),d=0,p,m=t.data,b=u.data,v,A,x,w;if(t.kind===Ns.GRAYSCALE_1BPP){let k=m.byteLength,I=new Uint32Array(b.buffer,0,b.byteLength>>2),P=I.length,M=n+7>>3,N=4294967295,D=se.isLittleEndian?4278190080:255;for(v=0;v<l;v++){for(x=v<o?Ae:s,p=0,A=0;A<x;A++){let U=k-d,G=0,H=U>M?n:U*8-7,W=H&-8,J=0,q=0;for(;G<W;G+=8)q=m[d++],I[p++]=q&128?N:D,I[p++]=q&64?N:D,I[p++]=q&32?N:D,I[p++]=q&16?N:D,I[p++]=q&8?N:D,I[p++]=q&4?N:D,I[p++]=q&2?N:D,I[p++]=q&1?N:D;for(;G<H;G++)J===0&&(q=m[d++],J=128),I[p++]=q&J?N:D,J>>=1}for(;p<P;)I[p++]=0;i.putImageData(u,0,v*Ae)}}else if(t.kind===Ns.RGBA_32BPP){for(A=0,w=n*Ae*4,v=0;v<o;v++)b.set(m.subarray(d,d+w)),d+=w,i.putImageData(u,0,A),A+=Ae;v<l&&(w=n*s*4,b.set(m.subarray(d,d+w)),i.putImageData(u,0,A))}else if(t.kind===Ns.RGB_24BPP)for(x=Ae,w=n*x,v=0;v<l;v++){for(v>=o&&(x=s,w=n*x),p=0,A=w;A--;)b[p++]=m[d++],b[p++]=m[d++],b[p++]=m[d++],b[p++]=255;i.putImageData(u,0,v*Ae)}else throw new Error(`bad image kind: ${t.kind}`)}function Xu(i,t){if(t.bitmap){i.drawImage(t.bitmap,0,0);return}let e=t.height,n=t.width,s=e%Ae,o=(e-s)/Ae,l=s===0?o:o+1,u=i.createImageData(n,Ae),d=0,p=t.data,m=u.data;for(let b=0;b<l;b++){let v=b<o?Ae:s;({srcPos:d}=Ey({src:p,srcPos:d,dest:m,width:n,height:v,nonBlackColor:0})),i.putImageData(u,0,b*Ae)}}function Cr(i,t){let e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let n of e)i[n]!==void 0&&(t[n]=i[n]);i.setLineDash!==void 0&&(t.setLineDash(i.getLineDash()),t.lineDashOffset=i.lineDashOffset)}function Fs(i){if(i.strokeStyle=i.fillStyle="#000000",i.fillRule="nonzero",i.globalAlpha=1,i.lineWidth=1,i.lineCap="butt",i.lineJoin="miter",i.miterLimit=10,i.globalCompositeOperation="source-over",i.font="10px sans-serif",i.setLineDash!==void 0&&(i.setLineDash([]),i.lineDashOffset=0),!he){let{filter:t}=i;t!=="none"&&t!==""&&(i.filter="none")}}function Yu(i,t){if(t)return!0;let e=xt.singularValueDecompose2dScale(i);e[0]=Math.fround(e[0]),e[1]=Math.fround(e[1]);let n=Math.fround((globalThis.devicePixelRatio||1)*vn.PDF_TO_CSS_UNITS);return e[0]<=n&&e[1]<=n}function My(i){let t=!0,e=n("filename\\*","i").exec(i);if(e){e=e[1];let m=u(e);return m=unescape(m),m=d(m),m=p(m),o(m)}if(e=l(i),e){let m=p(e);return o(m)}if(e=n("filename","i").exec(i),e){e=e[1];let m=u(e);return m=p(m),o(m)}function n(m,b){return new RegExp("(?:^|;)\\s*"+m+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',b)}function s(m,b){if(m){if(!/^[\x00-\xFF]+$/.test(b))return b;try{let v=new TextDecoder(m,{fatal:!0}),A=yi(b);b=v.decode(A),t=!1}catch{}}return b}function o(m){return t&&/[\x80-\xff]/.test(m)&&(m=s("utf-8",m),t&&(m=s("iso-8859-1",m))),m}function l(m){let b=[],v,A=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(v=A.exec(m))!==null;){let[,w,k,I]=v;if(w=parseInt(w,10),w in b){if(w===0)break;continue}b[w]=[k,I]}let x=[];for(let w=0;w<b.length&&w in b;++w){let[k,I]=b[w];I=u(I),k&&(I=unescape(I),w===0&&(I=d(I))),x.push(I)}return x.join("")}function u(m){if(m.startsWith('"')){let b=m.slice(1).split('\\"');for(let v=0;v<b.length;++v){let A=b[v].indexOf('"');A!==-1&&(b[v]=b[v].slice(0,A),b.length=v+1),b[v]=b[v].replaceAll(/\\(.)/g,"$1")}m=b.join('"')}return m}function d(m){let b=m.indexOf("'");if(b===-1)return m;let v=m.slice(0,b),x=m.slice(b+1).replace(/^[^']*'/,"");return s(v,x)}function p(m){return!m.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(m)?m:m.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(b,v,A,x){if(A==="q"||A==="Q")return x=x.replaceAll("_"," "),x=x.replaceAll(/=([0-9a-fA-F]{2})/g,function(w,k){return String.fromCharCode(parseInt(k,16))}),s(v,x);try{x=atob(x)}catch{}return s(v,x)})}return""}function eh(i,t){let e=new Headers;if(!i||!t||typeof t!="object")return e;for(let n in t){let s=t[n];s!==void 0&&e.append(n,s)}return e}function Si(i){try{return new URL(i).origin}catch{}return null}function nh({responseHeaders:i,isHttp:t,rangeChunkSize:e,disableRange:n}){let s={allowRangeRequests:!1,suggestedLength:void 0},o=parseInt(i.get("Content-Length"),10);return!Number.isInteger(o)||(s.suggestedLength=o,o<=2*e)||n||!t||i.get("Accept-Ranges")!=="bytes"||(i.get("Content-Encoding")||"identity")!=="identity"||(s.allowRangeRequests=!0),s}function rh(i){let t=i.get("Content-Disposition");if(t){let e=My(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(ol(e))return e}return null}function Ai(i,t){return i===404||i===0&&t.startsWith("file:")?new _n('Missing PDF "'+t+'".'):new ar(`Unexpected server response (${i}) while retrieving PDF "${t}".`,i)}function sh(i){return i===200||i===206}function ih(i,t,e){return{method:"GET",headers:i,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function oh(i){return i instanceof Uint8Array?i.buffer:i instanceof ArrayBuffer?i:(Pt(`getArrayBuffer - unexpected data format: ${i}`),new Uint8Array(i).buffer)}function Ly(i){let t=i.response;return typeof t!="string"?t:yi(t).buffer}function Dy(i){if(Fy.test(i))return new URL(i);let t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(i))}function $y(i={}){typeof i=="string"||i instanceof URL?i={url:i}:(i instanceof ArrayBuffer||ArrayBuffer.isView(i))&&(i={data:i});let t=new Sa,{docId:e}=t,n=i.url?zy(i.url):null,s=i.data?Xy(i.data):null,o=i.httpHeaders||null,l=i.withCredentials===!0,u=i.password??null,d=i.range instanceof ti?i.range:null,p=Number.isInteger(i.rangeChunkSize)&&i.rangeChunkSize>0?i.rangeChunkSize:Uy,m=i.worker instanceof or?i.worker:null,b=i.verbosity,v=typeof i.docBaseUrl=="string"&&!xi(i.docBaseUrl)?i.docBaseUrl:null,A=typeof i.cMapUrl=="string"?i.cMapUrl:null,x=i.cMapPacked!==!1,w=i.CMapReaderFactory||jy,k=typeof i.standardFontDataUrl=="string"?i.standardFontDataUrl:null,I=i.StandardFontDataFactory||Wy,P=i.stopAtErrors!==!0,M=Number.isInteger(i.maxImageSize)&&i.maxImageSize>-1?i.maxImageSize:-1,N=i.isEvalSupported!==!1,D=typeof i.isOffscreenCanvasSupported=="boolean"?i.isOffscreenCanvasSupported:!he,U=typeof i.isImageDecoderSupported=="boolean"?i.isImageDecoderSupported:!he&&(se.platform.isFirefox||!globalThis.chrome),G=Number.isInteger(i.canvasMaxAreaInBytes)?i.canvasMaxAreaInBytes:-1,H=typeof i.disableFontFace=="boolean"?i.disableFontFace:he,W=i.fontExtraProperties===!0,J=i.enableXfa===!0,q=i.ownerDocument||globalThis.document,dt=i.disableRange===!0,Q=i.disableStream===!0,ot=i.disableAutoFetch===!0,ct=i.pdfBug===!0,X=i.CanvasFactory||Hy,$=i.FilterFactory||Vy,ut=i.enableHWA===!0,st=d?d.length:i.length??NaN,St=typeof i.useSystemFonts=="boolean"?i.useSystemFonts:!he&&!H,Ct=typeof i.useWorkerFetch=="boolean"?i.useWorkerFetch:w===Ys&&I===Qs&&A&&k&&Pr(A,document.baseURI)&&Pr(k,document.baseURI),wt=null;ly(b);let Et={canvasFactory:new X({ownerDocument:q,enableHWA:ut}),filterFactory:new $({docId:e,ownerDocument:q}),cMapReaderFactory:Ct?null:new w({baseUrl:A,isCompressed:x}),standardFontDataFactory:Ct?null:new I({baseUrl:k})};if(!m){let at={verbosity:b,port:Dn.workerPort};m=at.port?or.fromPort(at):new or(at),t._worker=m}let Vt={docId:e,apiVersion:"4.10.45",data:s,password:u,disableAutoFetch:ot,rangeChunkSize:p,length:st,docBaseUrl:v,enableXfa:J,evaluatorOptions:{maxImageSize:M,disableFontFace:H,ignoreErrors:P,isEvalSupported:N,isOffscreenCanvasSupported:D,isImageDecoderSupported:U,canvasMaxAreaInBytes:G,fontExtraProperties:W,useSystemFonts:St,cMapUrl:Ct?A:null,standardFontDataUrl:Ct?k:null}},Ut={disableFontFace:H,fontExtraProperties:W,ownerDocument:q,pdfBug:ct,styleElement:wt,loadingParams:{disableAutoFetch:ot,enableXfa:J}};return m.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(m.destroyed)throw new Error("Worker was destroyed");let at=m.messageHandler.sendWithPromise("GetDocRequest",Vt,s?[s.buffer]:null),_;if(d)_=new ca(d,{disableRange:dt,disableStream:Q});else if(!s){if(!n)throw new Error("getDocument - no `url` parameter provided.");let V;if(he)if(Pr(n)){if(typeof fetch>"u"||typeof Response>"u"||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");V=qs}else V=ya;else V=Pr(n)?qs:ga;_=new V({url:n,length:st,httpHeaders:o,withCredentials:l,rangeChunkSize:p,disableRange:dt,disableStream:Q})}return at.then(V=>{if(t.destroyed)throw new Error("Loading aborted");if(m.destroyed)throw new Error("Worker was destroyed");let K=new Fn(e,V,m.port),Z=new Ea(K,t,_,Ut,Et);t._transport=Z,K.send("Ready",null)})}).catch(t._capability.reject),t}function zy(i){if(i instanceof URL)return i.href;try{return new URL(i,window.location).href}catch{if(he&&typeof i=="string")return i}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function Xy(i){if(he&&typeof Buffer<"u"&&i instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength)return i;if(typeof i=="string")return yi(i);if(i instanceof ArrayBuffer||ArrayBuffer.isView(i)||typeof i=="object"&&!isNaN(i?.length))return new Uint8Array(i);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Zu(i){return typeof i=="object"&&Number.isInteger(i?.num)&&i.num>=0&&Number.isInteger(i?.gen)&&i.gen>=0}function Qu(i){return Math.floor(Math.max(0,Math.min(1,i))*255).toString(16).padStart(2,"0")}function Ir(i){return Math.max(0,Math.min(255,255*i))}function yn(i){return{width:i[2]-i[0],height:i[3]-i[1]}}var ny,Nu,kt,YS,KS,ZS,QS,JS,qS,tA,eA,nA,rA,sA,iA,he,Ju,_o,ry,_s,sy,oA,ke,bn,iy,Mt,Ft,oy,ce,Ns,ne,Er,gi,We,ay,mi,xn,Us,Rr,Or,_n,ar,No,Je,se,Oo,xt,Mo,Uu,il,aA,lA,cA,uA,hA,dA,fA,pA,gA,mA,bA,yA,vA,xA,sn,vn,Mr,Lr,Bs,Gs,Fr,Uo,Bo,Go,Ho,jo,Un,Vo,Bn,js,Vs,Yt,Wo,Bu,Fe,Qe,Ws,$o,Dr,$s,zo,Xo,Ms,te,Fn,zs,Yo,Xs,Ys,SA,Ks,Ko,Zs,Qs,Zo,Qo,Jo,qo,ue,_r,ea,na,ra,Hu,sa,ju,Vu,Cy,Wu,$u,Ae,ia,Js,Py,Ry,Oy,Ku,ir,Dn,oa,sr,aa,la,ca,ua,ha,qs,da,fa,Fo,Do,pa,ga,ma,ba,Fy,ya,va,xa,_y,xe,Ny,Nr,Ur,Uy,By,Gy,Hy,jy,Vy,Wy,Sa,ti,Aa,Ta,wa,or,Ea,kr,ei,Ca,ka,Yy,Ky,AA,ni,Ia,Br,ri,Wr,Zy,Gn,Pa,Jt,si,Ra,on,Oa,Ma,La,ii,Fa,Da,Gr,_a,oi,Na,Ua,Ba,ai,Ga,Ha,Hr,li,ja,Va,Wa,ci,$a,za,Ds,Xa,pt,ui,hi,jr,Ya,Vr,Ka,di,fi,Za,Qa,Ja,pi,qa,tl,el,nl,rl,Qy,Jy,qy,tv,ev,nv,ll,rv,sv,iv,ov,av,lv,cv,uv,hv,dv,fv,pv,gv,mv,bv,yv,vv,xv,Sv,Av,Tv,wv,Ev,Cv,kv,Iv,Pv,Rv,Ov,Mv,Lv,Fv,Dv,_v,Nv,Uv,Bv,Gv,cl=Vb(()=>{ny={9306:((i,t,e)=>{var n=e(4901),s=e(6823),o=TypeError;i.exports=function(l){if(n(l))return l;throw new o(s(l)+" is not a function")}}),3506:((i,t,e)=>{var n=e(3925),s=String,o=TypeError;i.exports=function(l){if(n(l))return l;throw new o("Can't set "+s(l)+" as a prototype")}}),7080:((i,t,e)=>{var n=e(4402).has;i.exports=function(s){return n(s),s}}),679:((i,t,e)=>{var n=e(1625),s=TypeError;i.exports=function(o,l){if(n(l,o))return o;throw new s("Incorrect invocation")}}),8551:((i,t,e)=>{var n=e(34),s=String,o=TypeError;i.exports=function(l){if(n(l))return l;throw new o(s(l)+" is not an object")}}),7811:(i=>{i.exports=typeof ArrayBuffer<"u"&&typeof DataView<"u"}),7394:((i,t,e)=>{var n=e(4576),s=e(6706),o=e(2195),l=n.ArrayBuffer,u=n.TypeError;i.exports=l&&s(l.prototype,"byteLength","get")||function(d){if(o(d)!=="ArrayBuffer")throw new u("ArrayBuffer expected");return d.byteLength}}),3238:((i,t,e)=>{var n=e(4576),s=e(7476),o=e(7394),l=n.ArrayBuffer,u=l&&l.prototype,d=u&&s(u.slice);i.exports=function(p){if(o(p)!==0||!d)return!1;try{return d(p,0,0),!1}catch{return!0}}}),5169:((i,t,e)=>{var n=e(3238),s=TypeError;i.exports=function(o){if(n(o))throw new s("ArrayBuffer is detached");return o}}),5636:((i,t,e)=>{var n=e(4576),s=e(9504),o=e(6706),l=e(7696),u=e(5169),d=e(7394),p=e(4483),m=e(1548),b=n.structuredClone,v=n.ArrayBuffer,A=n.DataView,x=Math.min,w=v.prototype,k=A.prototype,I=s(w.slice),P=o(w,"resizable","get"),M=o(w,"maxByteLength","get"),N=s(k.getInt8),D=s(k.setInt8);i.exports=(m||p)&&function(U,G,H){var W=d(U),J=G===void 0?W:l(G),q=!P||!P(U),dt;if(u(U),m&&(U=b(U,{transfer:[U]}),W===J&&(H||q)))return U;if(W>=J&&(!H||q))dt=I(U,0,J);else{var Q=H&&!q&&M?{maxByteLength:M(U)}:void 0;dt=new v(J,Q);for(var ot=new A(U),ct=new A(dt),X=x(J,W),$=0;$<X;$++)D(ct,$,N(ot,$))}return m||p(U),dt}}),4644:((i,t,e)=>{var n=e(7811),s=e(3724),o=e(4576),l=e(4901),u=e(34),d=e(9297),p=e(6955),m=e(6823),b=e(6699),v=e(6840),A=e(2106),x=e(1625),w=e(2787),k=e(2967),I=e(8227),P=e(3392),M=e(1181),N=M.enforce,D=M.get,U=o.Int8Array,G=U&&U.prototype,H=o.Uint8ClampedArray,W=H&&H.prototype,J=U&&w(U),q=G&&w(G),dt=Object.prototype,Q=o.TypeError,ot=I("toStringTag"),ct=P("TYPED_ARRAY_TAG"),X="TypedArrayConstructor",$=n&&!!k&&p(o.opera)!=="Opera",ut=!1,st,St,Ct,wt={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Et={BigInt64Array:8,BigUint64Array:8},Vt=function(nt){if(!u(nt))return!1;var lt=p(nt);return lt==="DataView"||d(wt,lt)||d(Et,lt)},Ut=function(tt){var nt=w(tt);if(u(nt)){var lt=D(nt);return lt&&d(lt,X)?lt[X]:Ut(nt)}},at=function(tt){if(!u(tt))return!1;var nt=p(tt);return d(wt,nt)||d(Et,nt)},_=function(tt){if(at(tt))return tt;throw new Q("Target is not a typed array")},V=function(tt){if(l(tt)&&(!k||x(J,tt)))return tt;throw new Q(m(tt)+" is not a typed array constructor")},K=function(tt,nt,lt,z){if(s){if(lt)for(var it in wt){var Tt=o[it];if(Tt&&d(Tt.prototype,tt))try{delete Tt.prototype[tt]}catch{try{Tt.prototype[tt]=nt}catch{}}}(!q[tt]||lt)&&v(q,tt,lt?nt:$&&G[tt]||nt,z)}},Z=function(tt,nt,lt){var z,it;if(s){if(k){if(lt){for(z in wt)if(it=o[z],it&&d(it,tt))try{delete it[tt]}catch{}}if(!J[tt]||lt)try{return v(J,tt,lt?nt:$&&J[tt]||nt)}catch{}else return}for(z in wt)it=o[z],it&&(!it[tt]||lt)&&v(it,tt,nt)}};for(st in wt)St=o[st],Ct=St&&St.prototype,Ct?N(Ct)[X]=St:$=!1;for(st in Et)St=o[st],Ct=St&&St.prototype,Ct&&(N(Ct)[X]=St);if((!$||!l(J)||J===Function.prototype)&&(J=function(){throw new Q("Incorrect invocation")},$))for(st in wt)o[st]&&k(o[st],J);if((!$||!q||q===dt)&&(q=J.prototype,$))for(st in wt)o[st]&&k(o[st].prototype,q);if($&&w(W)!==q&&k(W,q),s&&!d(q,ot)){ut=!0,A(q,ot,{configurable:!0,get:function(){return u(this)?this[ct]:void 0}});for(st in wt)o[st]&&b(o[st],ct,st)}i.exports={NATIVE_ARRAY_BUFFER_VIEWS:$,TYPED_ARRAY_TAG:ut&&ct,aTypedArray:_,aTypedArrayConstructor:V,exportTypedArrayMethod:K,exportTypedArrayStaticMethod:Z,getTypedArrayConstructor:Ut,isView:Vt,isTypedArray:at,TypedArray:J,TypedArrayPrototype:q}}),5370:((i,t,e)=>{var n=e(6198);i.exports=function(s,o,l){for(var u=0,d=arguments.length>2?l:n(o),p=new s(d);d>u;)p[u]=o[u++];return p}}),9617:((i,t,e)=>{var n=e(5397),s=e(5610),o=e(6198),l=function(u){return function(d,p,m){var b=n(d),v=o(b);if(v===0)return!u&&-1;var A=s(m,v),x;if(u&&p!==p){for(;v>A;)if(x=b[A++],x!==x)return!0}else for(;v>A;A++)if((u||A in b)&&b[A]===p)return u||A||0;return!u&&-1}};i.exports={includes:l(!0),indexOf:l(!1)}}),4527:((i,t,e)=>{var n=e(3724),s=e(4376),o=TypeError,l=Object.getOwnPropertyDescriptor,u=n&&!(function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(d){return d instanceof TypeError}})();i.exports=u?function(d,p){if(s(d)&&!l(d,"length").writable)throw new o("Cannot set read only .length");return d.length=p}:function(d,p){return d.length=p}}),7680:((i,t,e)=>{var n=e(9504);i.exports=n([].slice)}),7628:((i,t,e)=>{var n=e(6198);i.exports=function(s,o){for(var l=n(s),u=new o(l),d=0;d<l;d++)u[d]=s[l-d-1];return u}}),9928:((i,t,e)=>{var n=e(6198),s=e(1291),o=RangeError;i.exports=function(l,u,d,p){var m=n(l),b=s(d),v=b<0?m+b:b;if(v>=m||v<0)throw new o("Incorrect index");for(var A=new u(m),x=0;x<m;x++)A[x]=x===v?p:l[x];return A}}),6319:((i,t,e)=>{var n=e(8551),s=e(9539);i.exports=function(o,l,u,d){try{return d?l(n(u)[0],u[1]):l(u)}catch(p){s(o,"throw",p)}}}),2195:((i,t,e)=>{var n=e(9504),s=n({}.toString),o=n("".slice);i.exports=function(l){return o(s(l),8,-1)}}),6955:((i,t,e)=>{var n=e(2140),s=e(4901),o=e(2195),l=e(8227),u=l("toStringTag"),d=Object,p=o((function(){return arguments})())==="Arguments",m=function(b,v){try{return b[v]}catch{}};i.exports=n?o:function(b){var v,A,x;return b===void 0?"Undefined":b===null?"Null":typeof(A=m(v=d(b),u))=="string"?A:p?o(v):(x=o(v))==="Object"&&s(v.callee)?"Arguments":x}}),7740:((i,t,e)=>{var n=e(9297),s=e(5031),o=e(7347),l=e(4913);i.exports=function(u,d,p){for(var m=s(d),b=l.f,v=o.f,A=0;A<m.length;A++){var x=m[A];!n(u,x)&&!(p&&n(p,x))&&b(u,x,v(d,x))}}}),2211:((i,t,e)=>{var n=e(9039);i.exports=!n(function(){function s(){}return s.prototype.constructor=null,Object.getPrototypeOf(new s)!==s.prototype})}),2529:(i=>{i.exports=function(t,e){return{value:t,done:e}}}),6699:((i,t,e)=>{var n=e(3724),s=e(4913),o=e(6980);i.exports=n?function(l,u,d){return s.f(l,u,o(1,d))}:function(l,u,d){return l[u]=d,l}}),6980:(i=>{i.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}}),4659:((i,t,e)=>{var n=e(3724),s=e(4913),o=e(6980);i.exports=function(l,u,d){n?s.f(l,u,o(0,d)):l[u]=d}}),2106:((i,t,e)=>{var n=e(283),s=e(4913);i.exports=function(o,l,u){return u.get&&n(u.get,l,{getter:!0}),u.set&&n(u.set,l,{setter:!0}),s.f(o,l,u)}}),6840:((i,t,e)=>{var n=e(4901),s=e(4913),o=e(283),l=e(9433);i.exports=function(u,d,p,m){m||(m={});var b=m.enumerable,v=m.name!==void 0?m.name:d;if(n(p)&&o(p,v,m),m.global)b?u[d]=p:l(d,p);else{try{m.unsafe?u[d]&&(b=!0):delete u[d]}catch{}b?u[d]=p:s.f(u,d,{value:p,enumerable:!1,configurable:!m.nonConfigurable,writable:!m.nonWritable})}return u}}),6279:((i,t,e)=>{var n=e(6840);i.exports=function(s,o,l){for(var u in o)n(s,u,o[u],l);return s}}),9433:((i,t,e)=>{var n=e(4576),s=Object.defineProperty;i.exports=function(o,l){try{s(n,o,{value:l,configurable:!0,writable:!0})}catch{n[o]=l}return l}}),3724:((i,t,e)=>{var n=e(9039);i.exports=!n(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),4483:((i,t,e)=>{var n=e(4576),s=e(9429),o=e(1548),l=n.structuredClone,u=n.ArrayBuffer,d=n.MessageChannel,p=!1,m,b,v,A;if(o)p=function(x){l(x,{transfer:[x]})};else if(u)try{d||(m=s("worker_threads"),m&&(d=m.MessageChannel)),d&&(b=new d,v=new u(2),A=function(x){b.port1.postMessage(null,[x])},v.byteLength===2&&(A(v),v.byteLength===0&&(p=A)))}catch{}i.exports=p}),4055:((i,t,e)=>{var n=e(4576),s=e(34),o=n.document,l=s(o)&&s(o.createElement);i.exports=function(u){return l?o.createElement(u):{}}}),6837:(i=>{var t=TypeError,e=9007199254740991;i.exports=function(n){if(n>e)throw t("Maximum allowed index exceeded");return n}}),5002:(i=>{i.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:(i=>{i.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]}),6193:((i,t,e)=>{var n=e(4215);i.exports=n==="NODE"}),2839:((i,t,e)=>{var n=e(4576),s=n.navigator,o=s&&s.userAgent;i.exports=o?String(o):""}),9519:((i,t,e)=>{var n=e(4576),s=e(2839),o=n.process,l=n.Deno,u=o&&o.versions||l&&l.version,d=u&&u.v8,p,m;d&&(p=d.split("."),m=p[0]>0&&p[0]<4?1:+(p[0]+p[1])),!m&&s&&(p=s.match(/Edge\/(\d+)/),(!p||p[1]>=74)&&(p=s.match(/Chrome\/(\d+)/),p&&(m=+p[1]))),i.exports=m}),4215:((i,t,e)=>{var n=e(4576),s=e(2839),o=e(2195),l=function(u){return s.slice(0,u.length)===u};i.exports=(function(){return l("Bun/")?"BUN":l("Cloudflare-Workers")?"CLOUDFLARE":l("Deno/")?"DENO":l("Node.js/")?"NODE":n.Bun&&typeof Bun.version=="string"?"BUN":n.Deno&&typeof Deno.version=="object"?"DENO":o(n.process)==="process"?"NODE":n.window&&n.document?"BROWSER":"REST"})()}),8574:((i,t,e)=>{var n=e(9504),s=Error,o=n("".replace),l=(function(p){return String(new s(p).stack)})("zxcasd"),u=/\n\s*at [^:]*:[^\n]*/,d=u.test(l);i.exports=function(p,m){if(d&&typeof p=="string"&&!s.prepareStackTrace)for(;m--;)p=o(p,u,"");return p}}),6518:((i,t,e)=>{var n=e(4576),s=e(7347).f,o=e(6699),l=e(6840),u=e(9433),d=e(7740),p=e(2796);i.exports=function(m,b){var v=m.target,A=m.global,x=m.stat,w,k,I,P,M,N;if(A?k=n:x?k=n[v]||u(v,{}):k=n[v]&&n[v].prototype,k)for(I in b){if(M=b[I],m.dontCallGetSet?(N=s(k,I),P=N&&N.value):P=k[I],w=p(A?I:v+(x?".":"#")+I,m.forced),!w&&P!==void 0){if(typeof M==typeof P)continue;d(M,P)}(m.sham||P&&P.sham)&&o(M,"sham",!0),l(k,I,M,m)}}}),9039:(i=>{i.exports=function(t){try{return!!t()}catch{return!0}}}),8745:((i,t,e)=>{var n=e(616),s=Function.prototype,o=s.apply,l=s.call;i.exports=typeof Reflect=="object"&&Reflect.apply||(n?l.bind(o):function(){return l.apply(o,arguments)})}),6080:((i,t,e)=>{var n=e(7476),s=e(9306),o=e(616),l=n(n.bind);i.exports=function(u,d){return s(u),d===void 0?u:o?l(u,d):function(){return u.apply(d,arguments)}}}),616:((i,t,e)=>{var n=e(9039);i.exports=!n(function(){var s=(function(){}).bind();return typeof s!="function"||s.hasOwnProperty("prototype")})}),9565:((i,t,e)=>{var n=e(616),s=Function.prototype.call;i.exports=n?s.bind(s):function(){return s.apply(s,arguments)}}),350:((i,t,e)=>{var n=e(3724),s=e(9297),o=Function.prototype,l=n&&Object.getOwnPropertyDescriptor,u=s(o,"name"),d=u&&(function(){}).name==="something",p=u&&(!n||n&&l(o,"name").configurable);i.exports={EXISTS:u,PROPER:d,CONFIGURABLE:p}}),6706:((i,t,e)=>{var n=e(9504),s=e(9306);i.exports=function(o,l,u){try{return n(s(Object.getOwnPropertyDescriptor(o,l)[u]))}catch{}}}),7476:((i,t,e)=>{var n=e(2195),s=e(9504);i.exports=function(o){if(n(o)==="Function")return s(o)}}),9504:((i,t,e)=>{var n=e(616),s=Function.prototype,o=s.call,l=n&&s.bind.bind(o,o);i.exports=n?l:function(u){return function(){return o.apply(u,arguments)}}}),9429:((i,t,e)=>{var n=e(4576),s=e(6193);i.exports=function(o){if(s){try{return n.process.getBuiltinModule(o)}catch{}try{return Function('return require("'+o+'")')()}catch{}}}}),7751:((i,t,e)=>{var n=e(4576),s=e(4901),o=function(l){return s(l)?l:void 0};i.exports=function(l,u){return arguments.length<2?o(n[l]):n[l]&&n[l][u]}}),1767:(i=>{i.exports=function(t){return{iterator:t,next:t.next,done:!1}}}),8646:((i,t,e)=>{var n=e(9565),s=e(8551),o=e(1767),l=e(851);i.exports=function(u,d){(!d||typeof u!="string")&&s(u);var p=l(u);return o(s(p!==void 0?n(p,u):u))}}),851:((i,t,e)=>{var n=e(6955),s=e(5966),o=e(4117),l=e(6269),u=e(8227),d=u("iterator");i.exports=function(p){if(!o(p))return s(p,d)||s(p,"@@iterator")||l[n(p)]}}),81:((i,t,e)=>{var n=e(9565),s=e(9306),o=e(8551),l=e(6823),u=e(851),d=TypeError;i.exports=function(p,m){var b=arguments.length<2?u(p):m;if(s(b))return o(n(b,p));throw new d(l(p)+" is not iterable")}}),5966:((i,t,e)=>{var n=e(9306),s=e(4117);i.exports=function(o,l){var u=o[l];return s(u)?void 0:n(u)}}),3789:((i,t,e)=>{var n=e(9306),s=e(8551),o=e(9565),l=e(1291),u=e(1767),d="Invalid size",p=RangeError,m=TypeError,b=Math.max,v=function(A,x){this.set=A,this.size=b(x,0),this.has=n(A.has),this.keys=n(A.keys)};v.prototype={getIterator:function(){return u(s(o(this.keys,this.set)))},includes:function(A){return o(this.has,this.set,A)}},i.exports=function(A){s(A);var x=+A.size;if(x!==x)throw new m(d);var w=l(x);if(w<0)throw new p(d);return new v(A,w)}}),4576:(function(i){var t=function(e){return e&&e.Math===Math&&e};i.exports=t(typeof globalThis=="object"&&globalThis)||t(typeof window=="object"&&window)||t(typeof self=="object"&&self)||t(typeof global=="object"&&global)||t(typeof this=="object"&&this)||(function(){return this})()||Function("return this")()}),9297:((i,t,e)=>{var n=e(9504),s=e(8981),o=n({}.hasOwnProperty);i.exports=Object.hasOwn||function(u,d){return o(s(u),d)}}),421:(i=>{i.exports={}}),397:((i,t,e)=>{var n=e(7751);i.exports=n("document","documentElement")}),5917:((i,t,e)=>{var n=e(3724),s=e(9039),o=e(4055);i.exports=!n&&!s(function(){return Object.defineProperty(o("div"),"a",{get:function(){return 7}}).a!==7})}),7055:((i,t,e)=>{var n=e(9504),s=e(9039),o=e(2195),l=Object,u=n("".split);i.exports=s(function(){return!l("z").propertyIsEnumerable(0)})?function(d){return o(d)==="String"?u(d,""):l(d)}:l}),3167:((i,t,e)=>{var n=e(4901),s=e(34),o=e(2967);i.exports=function(l,u,d){var p,m;return o&&n(p=u.constructor)&&p!==d&&s(m=p.prototype)&&m!==d.prototype&&o(l,m),l}}),3706:((i,t,e)=>{var n=e(9504),s=e(4901),o=e(7629),l=n(Function.toString);s(o.inspectSource)||(o.inspectSource=function(u){return l(u)}),i.exports=o.inspectSource}),1181:((i,t,e)=>{var n=e(8622),s=e(4576),o=e(34),l=e(6699),u=e(9297),d=e(7629),p=e(6119),m=e(421),b="Object already initialized",v=s.TypeError,A=s.WeakMap,x,w,k,I=function(D){return k(D)?w(D):x(D,{})},P=function(D){return function(U){var G;if(!o(U)||(G=w(U)).type!==D)throw new v("Incompatible receiver, "+D+" required");return G}};if(n||d.state){var M=d.state||(d.state=new A);M.get=M.get,M.has=M.has,M.set=M.set,x=function(D,U){if(M.has(D))throw new v(b);return U.facade=D,M.set(D,U),U},w=function(D){return M.get(D)||{}},k=function(D){return M.has(D)}}else{var N=p("state");m[N]=!0,x=function(D,U){if(u(D,N))throw new v(b);return U.facade=D,l(D,N,U),U},w=function(D){return u(D,N)?D[N]:{}},k=function(D){return u(D,N)}}i.exports={set:x,get:w,has:k,enforce:I,getterFor:P}}),4209:((i,t,e)=>{var n=e(8227),s=e(6269),o=n("iterator"),l=Array.prototype;i.exports=function(u){return u!==void 0&&(s.Array===u||l[o]===u)}}),4376:((i,t,e)=>{var n=e(2195);i.exports=Array.isArray||function(o){return n(o)==="Array"}}),1108:((i,t,e)=>{var n=e(6955);i.exports=function(s){var o=n(s);return o==="BigInt64Array"||o==="BigUint64Array"}}),4901:(i=>{var t=typeof document=="object"&&document.all;i.exports=typeof t>"u"&&t!==void 0?function(e){return typeof e=="function"||e===t}:function(e){return typeof e=="function"}}),2796:((i,t,e)=>{var n=e(9039),s=e(4901),o=/#|\.prototype\./,l=function(b,v){var A=d[u(b)];return A===m?!0:A===p?!1:s(v)?n(v):!!v},u=l.normalize=function(b){return String(b).replace(o,".").toLowerCase()},d=l.data={},p=l.NATIVE="N",m=l.POLYFILL="P";i.exports=l}),4117:(i=>{i.exports=function(t){return t==null}}),34:((i,t,e)=>{var n=e(4901);i.exports=function(s){return typeof s=="object"?s!==null:n(s)}}),3925:((i,t,e)=>{var n=e(34);i.exports=function(s){return n(s)||s===null}}),6395:(i=>{i.exports=!1}),757:((i,t,e)=>{var n=e(7751),s=e(4901),o=e(1625),l=e(7040),u=Object;i.exports=l?function(d){return typeof d=="symbol"}:function(d){var p=n("Symbol");return s(p)&&o(p.prototype,u(d))}}),507:((i,t,e)=>{var n=e(9565);i.exports=function(s,o,l){for(var u=l?s:s.iterator,d=s.next,p,m;!(p=n(d,u)).done;)if(m=o(p.value),m!==void 0)return m}}),2652:((i,t,e)=>{var n=e(6080),s=e(9565),o=e(8551),l=e(6823),u=e(4209),d=e(6198),p=e(1625),m=e(81),b=e(851),v=e(9539),A=TypeError,x=function(k,I){this.stopped=k,this.result=I},w=x.prototype;i.exports=function(k,I,P){var M=P&&P.that,N=!!(P&&P.AS_ENTRIES),D=!!(P&&P.IS_RECORD),U=!!(P&&P.IS_ITERATOR),G=!!(P&&P.INTERRUPTED),H=n(I,M),W,J,q,dt,Q,ot,ct,X=function(ut){return W&&v(W,"normal",ut),new x(!0,ut)},$=function(ut){return N?(o(ut),G?H(ut[0],ut[1],X):H(ut[0],ut[1])):G?H(ut,X):H(ut)};if(D)W=k.iterator;else if(U)W=k;else{if(J=b(k),!J)throw new A(l(k)+" is not iterable");if(u(J)){for(q=0,dt=d(k);dt>q;q++)if(Q=$(k[q]),Q&&p(w,Q))return Q;return new x(!1)}W=m(k,J)}for(ot=D?k.next:W.next;!(ct=s(ot,W)).done;){try{Q=$(ct.value)}catch(ut){v(W,"throw",ut)}if(typeof Q=="object"&&Q&&p(w,Q))return Q}return new x(!1)}}),9539:((i,t,e)=>{var n=e(9565),s=e(8551),o=e(5966);i.exports=function(l,u,d){var p,m;s(l);try{if(p=o(l,"return"),!p){if(u==="throw")throw d;return d}p=n(p,l)}catch(b){m=!0,p=b}if(u==="throw")throw d;if(m)throw p;return s(p),d}}),9462:((i,t,e)=>{var n=e(9565),s=e(2360),o=e(6699),l=e(6279),u=e(8227),d=e(1181),p=e(5966),m=e(7657).IteratorPrototype,b=e(2529),v=e(9539),A=u("toStringTag"),x="IteratorHelper",w="WrapForValidIterator",k=d.set,I=function(N){var D=d.getterFor(N?w:x);return l(s(m),{next:function(){var G=D(this);if(N)return G.nextHandler();try{var H=G.done?void 0:G.nextHandler();return b(H,G.done)}catch(W){throw G.done=!0,W}},return:function(){var U=D(this),G=U.iterator;if(U.done=!0,N){var H=p(G,"return");return H?n(H,G):b(void 0,!0)}if(U.inner)try{v(U.inner.iterator,"normal")}catch(W){return v(G,"throw",W)}return G&&v(G,"normal"),b(void 0,!0)}})},P=I(!0),M=I(!1);o(M,A,"Iterator Helper"),i.exports=function(N,D){var U=function(H,W){W?(W.iterator=H.iterator,W.next=H.next):W=H,W.type=D?w:x,W.nextHandler=N,W.counter=0,W.done=!1,k(this,W)};return U.prototype=D?P:M,U}}),713:((i,t,e)=>{var n=e(9565),s=e(9306),o=e(8551),l=e(1767),u=e(9462),d=e(6319),p=u(function(){var m=this.iterator,b=o(n(this.next,m)),v=this.done=!!b.done;if(!v)return d(m,this.mapper,[b.value,this.counter++],!0)});i.exports=function(b){return o(this),s(b),new p(l(this),{mapper:b})}}),7657:((i,t,e)=>{var n=e(9039),s=e(4901),o=e(34),l=e(2360),u=e(2787),d=e(6840),p=e(8227),m=e(6395),b=p("iterator"),v=!1,A,x,w;[].keys&&(w=[].keys(),"next"in w?(x=u(u(w)),x!==Object.prototype&&(A=x)):v=!0);var k=!o(A)||n(function(){var I={};return A[b].call(I)!==I});k?A={}:m&&(A=l(A)),s(A[b])||d(A,b,function(){return this}),i.exports={IteratorPrototype:A,BUGGY_SAFARI_ITERATORS:v}}),6269:(i=>{i.exports={}}),6198:((i,t,e)=>{var n=e(8014);i.exports=function(s){return n(s.length)}}),283:((i,t,e)=>{var n=e(9504),s=e(9039),o=e(4901),l=e(9297),u=e(3724),d=e(350).CONFIGURABLE,p=e(3706),m=e(1181),b=m.enforce,v=m.get,A=String,x=Object.defineProperty,w=n("".slice),k=n("".replace),I=n([].join),P=u&&!s(function(){return x(function(){},"length",{value:8}).length!==8}),M=String(String).split("String"),N=i.exports=function(D,U,G){w(A(U),0,7)==="Symbol("&&(U="["+k(A(U),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),G&&G.getter&&(U="get "+U),G&&G.setter&&(U="set "+U),(!l(D,"name")||d&&D.name!==U)&&(u?x(D,"name",{value:U,configurable:!0}):D.name=U),P&&G&&l(G,"arity")&&D.length!==G.arity&&x(D,"length",{value:G.arity});try{G&&l(G,"constructor")&&G.constructor?u&&x(D,"prototype",{writable:!1}):D.prototype&&(D.prototype=void 0)}catch{}var H=b(D);return l(H,"source")||(H.source=I(M,typeof U=="string"?U:"")),D};Function.prototype.toString=N(function(){return o(this)&&v(this).source||p(this)},"toString")}),741:(i=>{var t=Math.ceil,e=Math.floor;i.exports=Math.trunc||function(s){var o=+s;return(o>0?e:t)(o)}}),6043:((i,t,e)=>{var n=e(9306),s=TypeError,o=function(l){var u,d;this.promise=new l(function(p,m){if(u!==void 0||d!==void 0)throw new s("Bad Promise constructor");u=p,d=m}),this.resolve=n(u),this.reject=n(d)};i.exports.f=function(l){return new o(l)}}),2603:((i,t,e)=>{var n=e(655);i.exports=function(s,o){return s===void 0?arguments.length<2?"":o:n(s)}}),4149:(i=>{var t=RangeError;i.exports=function(e){if(e===e)return e;throw new t("NaN is not allowed")}}),2360:((i,t,e)=>{var n=e(8551),s=e(6801),o=e(8727),l=e(421),u=e(397),d=e(4055),p=e(6119),m=">",b="<",v="prototype",A="script",x=p("IE_PROTO"),w=function(){},k=function(D){return b+A+m+D+b+"/"+A+m},I=function(D){D.write(k("")),D.close();var U=D.parentWindow.Object;return D=null,U},P=function(){var D=d("iframe"),U="java"+A+":",G;return D.style.display="none",u.appendChild(D),D.src=String(U),G=D.contentWindow.document,G.open(),G.write(k("document.F=Object")),G.close(),G.F},M,N=function(){try{M=new ActiveXObject("htmlfile")}catch{}N=typeof document<"u"?document.domain&&M?I(M):P():I(M);for(var D=o.length;D--;)delete N[v][o[D]];return N()};l[x]=!0,i.exports=Object.create||function(U,G){var H;return U!==null?(w[v]=n(U),H=new w,w[v]=null,H[x]=U):H=N(),G===void 0?H:s.f(H,G)}}),6801:((i,t,e)=>{var n=e(3724),s=e(8686),o=e(4913),l=e(8551),u=e(5397),d=e(1072);t.f=n&&!s?Object.defineProperties:function(m,b){l(m);for(var v=u(b),A=d(b),x=A.length,w=0,k;x>w;)o.f(m,k=A[w++],v[k]);return m}}),4913:((i,t,e)=>{var n=e(3724),s=e(5917),o=e(8686),l=e(8551),u=e(6969),d=TypeError,p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,b="enumerable",v="configurable",A="writable";t.f=n?o?function(w,k,I){if(l(w),k=u(k),l(I),typeof w=="function"&&k==="prototype"&&"value"in I&&A in I&&!I[A]){var P=m(w,k);P&&P[A]&&(w[k]=I.value,I={configurable:v in I?I[v]:P[v],enumerable:b in I?I[b]:P[b],writable:!1})}return p(w,k,I)}:p:function(w,k,I){if(l(w),k=u(k),l(I),s)try{return p(w,k,I)}catch{}if("get"in I||"set"in I)throw new d("Accessors not supported");return"value"in I&&(w[k]=I.value),w}}),7347:((i,t,e)=>{var n=e(3724),s=e(9565),o=e(8773),l=e(6980),u=e(5397),d=e(6969),p=e(9297),m=e(5917),b=Object.getOwnPropertyDescriptor;t.f=n?b:function(A,x){if(A=u(A),x=d(x),m)try{return b(A,x)}catch{}if(p(A,x))return l(!s(o.f,A,x),A[x])}}),8480:((i,t,e)=>{var n=e(1828),s=e(8727),o=s.concat("length","prototype");t.f=Object.getOwnPropertyNames||function(u){return n(u,o)}}),3717:((i,t)=>{t.f=Object.getOwnPropertySymbols}),2787:((i,t,e)=>{var n=e(9297),s=e(4901),o=e(8981),l=e(6119),u=e(2211),d=l("IE_PROTO"),p=Object,m=p.prototype;i.exports=u?p.getPrototypeOf:function(b){var v=o(b);if(n(v,d))return v[d];var A=v.constructor;return s(A)&&v instanceof A?A.prototype:v instanceof p?m:null}}),1625:((i,t,e)=>{var n=e(9504);i.exports=n({}.isPrototypeOf)}),1828:((i,t,e)=>{var n=e(9504),s=e(9297),o=e(5397),l=e(9617).indexOf,u=e(421),d=n([].push);i.exports=function(p,m){var b=o(p),v=0,A=[],x;for(x in b)!s(u,x)&&s(b,x)&&d(A,x);for(;m.length>v;)s(b,x=m[v++])&&(~l(A,x)||d(A,x));return A}}),1072:((i,t,e)=>{var n=e(1828),s=e(8727);i.exports=Object.keys||function(l){return n(l,s)}}),8773:((i,t)=>{var e={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,s=n&&!e.call({1:2},1);t.f=s?function(l){var u=n(this,l);return!!u&&u.enumerable}:e}),2967:((i,t,e)=>{var n=e(6706),s=e(34),o=e(7750),l=e(3506);i.exports=Object.setPrototypeOf||("__proto__"in{}?(function(){var u=!1,d={},p;try{p=n(Object.prototype,"__proto__","set"),p(d,[]),u=d instanceof Array}catch{}return function(b,v){return o(b),l(v),s(b)&&(u?p(b,v):b.__proto__=v),b}})():void 0)}),4270:((i,t,e)=>{var n=e(9565),s=e(4901),o=e(34),l=TypeError;i.exports=function(u,d){var p,m;if(d==="string"&&s(p=u.toString)&&!o(m=n(p,u))||s(p=u.valueOf)&&!o(m=n(p,u))||d!=="string"&&s(p=u.toString)&&!o(m=n(p,u)))return m;throw new l("Can't convert object to primitive value")}}),5031:((i,t,e)=>{var n=e(7751),s=e(9504),o=e(8480),l=e(3717),u=e(8551),d=s([].concat);i.exports=n("Reflect","ownKeys")||function(m){var b=o.f(u(m)),v=l.f;return v?d(b,v(m)):b}}),8235:((i,t,e)=>{var n=e(9504),s=e(9297),o=SyntaxError,l=parseInt,u=String.fromCharCode,d=n("".charAt),p=n("".slice),m=n(/./.exec),b={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
3
- `,"\\r":"\r","\\t":" "},v=/^[\da-f]{4}$/i,A=/^[\u0000-\u001F]$/;i.exports=function(x,w){for(var k=!0,I="";w<x.length;){var P=d(x,w);if(P==="\\"){var M=p(x,w,w+2);if(s(b,M))I+=b[M],w+=2;else if(M==="\\u"){w+=2;var N=p(x,w,w+4);if(!m(v,N))throw new o("Bad Unicode escape at: "+w);I+=u(l(N,16)),w+=4}else throw new o('Unknown escape sequence: "'+M+'"')}else if(P==='"'){k=!1,w++;break}else{if(m(A,P))throw new o("Bad control character in string literal at: "+w);I+=P,w++}}if(k)throw new o("Unterminated string at: "+w);return{value:I,end:w}}}),1103:(i=>{i.exports=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}}}),7750:((i,t,e)=>{var n=e(4117),s=TypeError;i.exports=function(o){if(n(o))throw new s("Can't call method on "+o);return o}}),9286:((i,t,e)=>{var n=e(4402),s=e(8469),o=n.Set,l=n.add;i.exports=function(u){var d=new o;return s(u,function(p){l(d,p)}),d}}),3440:((i,t,e)=>{var n=e(7080),s=e(4402),o=e(9286),l=e(5170),u=e(3789),d=e(8469),p=e(507),m=s.has,b=s.remove;i.exports=function(A){var x=n(this),w=u(A),k=o(x);return l(x)<=w.size?d(x,function(I){w.includes(I)&&b(k,I)}):p(w.getIterator(),function(I){m(x,I)&&b(k,I)}),k}}),4402:((i,t,e)=>{var n=e(9504),s=Set.prototype;i.exports={Set,add:n(s.add),has:n(s.has),remove:n(s.delete),proto:s}}),8750:((i,t,e)=>{var n=e(7080),s=e(4402),o=e(5170),l=e(3789),u=e(8469),d=e(507),p=s.Set,m=s.add,b=s.has;i.exports=function(A){var x=n(this),w=l(A),k=new p;return o(x)>w.size?d(w.getIterator(),function(I){b(x,I)&&m(k,I)}):u(x,function(I){w.includes(I)&&m(k,I)}),k}}),4449:((i,t,e)=>{var n=e(7080),s=e(4402).has,o=e(5170),l=e(3789),u=e(8469),d=e(507),p=e(9539);i.exports=function(b){var v=n(this),A=l(b);if(o(v)<=A.size)return u(v,function(w){if(A.includes(w))return!1},!0)!==!1;var x=A.getIterator();return d(x,function(w){if(s(v,w))return p(x,"normal",!1)})!==!1}}),3838:((i,t,e)=>{var n=e(7080),s=e(5170),o=e(8469),l=e(3789);i.exports=function(d){var p=n(this),m=l(d);return s(p)>m.size?!1:o(p,function(b){if(!m.includes(b))return!1},!0)!==!1}}),8527:((i,t,e)=>{var n=e(7080),s=e(4402).has,o=e(5170),l=e(3789),u=e(507),d=e(9539);i.exports=function(m){var b=n(this),v=l(m);if(o(b)<v.size)return!1;var A=v.getIterator();return u(A,function(x){if(!s(b,x))return d(A,"normal",!1)})!==!1}}),8469:((i,t,e)=>{var n=e(9504),s=e(507),o=e(4402),l=o.Set,u=o.proto,d=n(u.forEach),p=n(u.keys),m=p(new l).next;i.exports=function(b,v,A){return A?s({iterator:p(b),next:m},v):d(b,v)}}),4916:((i,t,e)=>{var n=e(7751),s=function(o){return{size:o,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}};i.exports=function(o){var l=n("Set");try{new l()[o](s(0));try{return new l()[o](s(-1)),!1}catch{return!0}}catch{return!1}}}),5170:((i,t,e)=>{var n=e(6706),s=e(4402);i.exports=n(s.proto,"size","get")||function(o){return o.size}}),3650:((i,t,e)=>{var n=e(7080),s=e(4402),o=e(9286),l=e(3789),u=e(507),d=s.add,p=s.has,m=s.remove;i.exports=function(v){var A=n(this),x=l(v).getIterator(),w=o(A);return u(x,function(k){p(A,k)?m(w,k):d(w,k)}),w}}),4204:((i,t,e)=>{var n=e(7080),s=e(4402).add,o=e(9286),l=e(3789),u=e(507);i.exports=function(p){var m=n(this),b=l(p).getIterator(),v=o(m);return u(b,function(A){s(v,A)}),v}}),6119:((i,t,e)=>{var n=e(5745),s=e(3392),o=n("keys");i.exports=function(l){return o[l]||(o[l]=s(l))}}),7629:((i,t,e)=>{var n=e(6395),s=e(4576),o=e(9433),l="__core-js_shared__",u=i.exports=s[l]||o(l,{});(u.versions||(u.versions=[])).push({version:"3.39.0",mode:n?"pure":"global",copyright:"\xA9 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE",source:"https://github.com/zloirock/core-js"})}),5745:((i,t,e)=>{var n=e(7629);i.exports=function(s,o){return n[s]||(n[s]=o||{})}}),1548:((i,t,e)=>{var n=e(4576),s=e(9039),o=e(9519),l=e(4215),u=n.structuredClone;i.exports=!!u&&!s(function(){if(l==="DENO"&&o>92||l==="NODE"&&o>94||l==="BROWSER"&&o>97)return!1;var d=new ArrayBuffer(8),p=u(d,{transfer:[d]});return d.byteLength!==0||p.byteLength!==8})}),4495:((i,t,e)=>{var n=e(9519),s=e(9039),o=e(4576),l=o.String;i.exports=!!Object.getOwnPropertySymbols&&!s(function(){var u=Symbol("symbol detection");return!l(u)||!(Object(u)instanceof Symbol)||!Symbol.sham&&n&&n<41})}),5610:((i,t,e)=>{var n=e(1291),s=Math.max,o=Math.min;i.exports=function(l,u){var d=n(l);return d<0?s(d+u,0):o(d,u)}}),5854:((i,t,e)=>{var n=e(2777),s=TypeError;i.exports=function(o){var l=n(o,"number");if(typeof l=="number")throw new s("Can't convert number to bigint");return BigInt(l)}}),7696:((i,t,e)=>{var n=e(1291),s=e(8014),o=RangeError;i.exports=function(l){if(l===void 0)return 0;var u=n(l),d=s(u);if(u!==d)throw new o("Wrong length or index");return d}}),5397:((i,t,e)=>{var n=e(7055),s=e(7750);i.exports=function(o){return n(s(o))}}),1291:((i,t,e)=>{var n=e(741);i.exports=function(s){var o=+s;return o!==o||o===0?0:n(o)}}),8014:((i,t,e)=>{var n=e(1291),s=Math.min;i.exports=function(o){var l=n(o);return l>0?s(l,9007199254740991):0}}),8981:((i,t,e)=>{var n=e(7750),s=Object;i.exports=function(o){return s(n(o))}}),9590:((i,t,e)=>{var n=e(1291),s=RangeError;i.exports=function(o){var l=n(o);if(l<0)throw new s("The argument can't be less than 0");return l}}),2777:((i,t,e)=>{var n=e(9565),s=e(34),o=e(757),l=e(5966),u=e(4270),d=e(8227),p=TypeError,m=d("toPrimitive");i.exports=function(b,v){if(!s(b)||o(b))return b;var A=l(b,m),x;if(A){if(v===void 0&&(v="default"),x=n(A,b,v),!s(x)||o(x))return x;throw new p("Can't convert object to primitive value")}return v===void 0&&(v="number"),u(b,v)}}),6969:((i,t,e)=>{var n=e(2777),s=e(757);i.exports=function(o){var l=n(o,"string");return s(l)?l:l+""}}),2140:((i,t,e)=>{var n=e(8227),s=n("toStringTag"),o={};o[s]="z",i.exports=String(o)==="[object z]"}),655:((i,t,e)=>{var n=e(6955),s=String;i.exports=function(o){if(n(o)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return s(o)}}),6823:(i=>{var t=String;i.exports=function(e){try{return t(e)}catch{return"Object"}}}),3392:((i,t,e)=>{var n=e(9504),s=0,o=Math.random(),l=n(1 .toString);i.exports=function(u){return"Symbol("+(u===void 0?"":u)+")_"+l(++s+o,36)}}),7040:((i,t,e)=>{var n=e(4495);i.exports=n&&!Symbol.sham&&typeof Symbol.iterator=="symbol"}),8686:((i,t,e)=>{var n=e(3724),s=e(9039);i.exports=n&&s(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})}),2812:(i=>{var t=TypeError;i.exports=function(e,n){if(e<n)throw new t("Not enough arguments");return e}}),8622:((i,t,e)=>{var n=e(4576),s=e(4901),o=n.WeakMap;i.exports=s(o)&&/native code/.test(String(o))}),8227:((i,t,e)=>{var n=e(4576),s=e(5745),o=e(9297),l=e(3392),u=e(4495),d=e(7040),p=n.Symbol,m=s("wks"),b=d?p.for||p:p&&p.withoutSetter||l;i.exports=function(v){return o(m,v)||(m[v]=u&&o(p,v)?p[v]:b("Symbol."+v)),m[v]}}),6573:((i,t,e)=>{var n=e(3724),s=e(2106),o=e(3238),l=ArrayBuffer.prototype;n&&!("detached"in l)&&s(l,"detached",{configurable:!0,get:function(){return o(this)}})}),7936:((i,t,e)=>{var n=e(6518),s=e(5636);s&&n({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return s(this,arguments.length?arguments[0]:void 0,!1)}})}),8100:((i,t,e)=>{var n=e(6518),s=e(5636);s&&n({target:"ArrayBuffer",proto:!0},{transfer:function(){return s(this,arguments.length?arguments[0]:void 0,!0)}})}),4114:((i,t,e)=>{var n=e(6518),s=e(8981),o=e(6198),l=e(4527),u=e(6837),d=e(9039),p=d(function(){return[].push.call({length:4294967296},1)!==4294967297}),m=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(v){return v instanceof TypeError}},b=p||!m();n({target:"Array",proto:!0,arity:1,forced:b},{push:function(A){var x=s(this),w=o(x),k=arguments.length;u(w+k);for(var I=0;I<k;I++)x[w]=arguments[I],w++;return l(x,w),w}})}),8111:((i,t,e)=>{var n=e(6518),s=e(4576),o=e(679),l=e(8551),u=e(4901),d=e(2787),p=e(2106),m=e(4659),b=e(9039),v=e(9297),A=e(8227),x=e(7657).IteratorPrototype,w=e(3724),k=e(6395),I="constructor",P="Iterator",M=A("toStringTag"),N=TypeError,D=s[P],U=k||!u(D)||D.prototype!==x||!b(function(){D({})}),G=function(){if(o(this,x),d(this)===x)throw new N("Abstract class Iterator not directly constructable")},H=function(W,J){w?p(x,W,{configurable:!0,get:function(){return J},set:function(q){if(l(this),this===x)throw new N("You can't redefine this property");v(this,W)?this[W]=q:m(this,W,q)}}):x[W]=J};v(x,M)||H(M,P),(U||!v(x,I)||x[I]===Object)&&H(I,G),G.prototype=x,n({global:!0,constructor:!0,forced:U},{Iterator:G})}),9314:((i,t,e)=>{var n=e(6518),s=e(9565),o=e(8551),l=e(1767),u=e(4149),d=e(9590),p=e(9462),m=e(6395),b=p(function(){for(var v=this.iterator,A=this.next,x,w;this.remaining;)if(this.remaining--,x=o(s(A,v)),w=this.done=!!x.done,w)return;if(x=o(s(A,v)),w=this.done=!!x.done,!w)return x.value});n({target:"Iterator",proto:!0,real:!0,forced:m},{drop:function(A){o(this);var x=d(u(+A));return new b(l(this),{remaining:x})}})}),1148:((i,t,e)=>{var n=e(6518),s=e(2652),o=e(9306),l=e(8551),u=e(1767);n({target:"Iterator",proto:!0,real:!0},{every:function(p){l(this),o(p);var m=u(this),b=0;return!s(m,function(v,A){if(!p(v,b++))return A()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),2489:((i,t,e)=>{var n=e(6518),s=e(9565),o=e(9306),l=e(8551),u=e(1767),d=e(9462),p=e(6319),m=e(6395),b=d(function(){for(var v=this.iterator,A=this.predicate,x=this.next,w,k,I;;){if(w=l(s(x,v)),k=this.done=!!w.done,k)return;if(I=w.value,p(v,A,[I,this.counter++],!0))return I}});n({target:"Iterator",proto:!0,real:!0,forced:m},{filter:function(A){return l(this),o(A),new b(u(this),{predicate:A})}})}),531:((i,t,e)=>{var n=e(6518),s=e(9565),o=e(9306),l=e(8551),u=e(1767),d=e(8646),p=e(9462),m=e(9539),b=e(6395),v=p(function(){for(var A=this.iterator,x=this.mapper,w,k;;){if(k=this.inner)try{if(w=l(s(k.next,k.iterator)),!w.done)return w.value;this.inner=null}catch(I){m(A,"throw",I)}if(w=l(s(this.next,A)),this.done=!!w.done)return;try{this.inner=d(x(w.value,this.counter++),!1)}catch(I){m(A,"throw",I)}}});n({target:"Iterator",proto:!0,real:!0,forced:b},{flatMap:function(x){return l(this),o(x),new v(u(this),{mapper:x,inner:null})}})}),1701:((i,t,e)=>{var n=e(6518),s=e(713),o=e(6395);n({target:"Iterator",proto:!0,real:!0,forced:o},{map:s})}),3579:((i,t,e)=>{var n=e(6518),s=e(2652),o=e(9306),l=e(8551),u=e(1767);n({target:"Iterator",proto:!0,real:!0},{some:function(p){l(this),o(p);var m=u(this),b=0;return s(m,function(v,A){if(p(v,b++))return A()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),1689:((i,t,e)=>{var n=e(6518),s=e(4576),o=e(8745),l=e(7680),u=e(6043),d=e(9306),p=e(1103),m=s.Promise,b=!1,v=!m||!m.try||p(function(){m.try(function(A){b=A===8},8)}).error||!b;n({target:"Promise",stat:!0,forced:v},{try:function(A){var x=arguments.length>1?l(arguments,1):[],w=u.f(this),k=p(function(){return o(d(A),void 0,x)});return(k.error?w.reject:w.resolve)(k.value),w.promise}})}),4628:((i,t,e)=>{var n=e(6518),s=e(6043);n({target:"Promise",stat:!0},{withResolvers:function(){var l=s.f(this);return{promise:l.promise,resolve:l.resolve,reject:l.reject}}})}),7642:((i,t,e)=>{var n=e(6518),s=e(3440),o=e(4916);n({target:"Set",proto:!0,real:!0,forced:!o("difference")},{difference:s})}),8004:((i,t,e)=>{var n=e(6518),s=e(9039),o=e(8750),l=e(4916),u=!l("intersection")||s(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});n({target:"Set",proto:!0,real:!0,forced:u},{intersection:o})}),3853:((i,t,e)=>{var n=e(6518),s=e(4449),o=e(4916);n({target:"Set",proto:!0,real:!0,forced:!o("isDisjointFrom")},{isDisjointFrom:s})}),5876:((i,t,e)=>{var n=e(6518),s=e(3838),o=e(4916);n({target:"Set",proto:!0,real:!0,forced:!o("isSubsetOf")},{isSubsetOf:s})}),2475:((i,t,e)=>{var n=e(6518),s=e(8527),o=e(4916);n({target:"Set",proto:!0,real:!0,forced:!o("isSupersetOf")},{isSupersetOf:s})}),5024:((i,t,e)=>{var n=e(6518),s=e(3650),o=e(4916);n({target:"Set",proto:!0,real:!0,forced:!o("symmetricDifference")},{symmetricDifference:s})}),1698:((i,t,e)=>{var n=e(6518),s=e(4204),o=e(4916);n({target:"Set",proto:!0,real:!0,forced:!o("union")},{union:s})}),7467:((i,t,e)=>{var n=e(7628),s=e(4644),o=s.aTypedArray,l=s.exportTypedArrayMethod,u=s.getTypedArrayConstructor;l("toReversed",function(){return n(o(this),u(this))})}),4732:((i,t,e)=>{var n=e(4644),s=e(9504),o=e(9306),l=e(5370),u=n.aTypedArray,d=n.getTypedArrayConstructor,p=n.exportTypedArrayMethod,m=s(n.TypedArrayPrototype.sort);p("toSorted",function(v){v!==void 0&&o(v);var A=u(this),x=l(d(A),A);return m(x,v)})}),9577:((i,t,e)=>{var n=e(9928),s=e(4644),o=e(1108),l=e(1291),u=e(5854),d=s.aTypedArray,p=s.getTypedArrayConstructor,m=s.exportTypedArrayMethod,b=!!(function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(v){return v===8}})();m("with",function(v,A){var x=d(this),w=l(v),k=o(x)?u(A):+A;return n(x,p(x),w,k)},!b)}),8992:((i,t,e)=>{e(8111)}),4743:((i,t,e)=>{e(9314)}),3215:((i,t,e)=>{e(1148)}),4520:((i,t,e)=>{e(2489)}),670:((i,t,e)=>{e(531)}),1454:((i,t,e)=>{e(1701)}),7550:((i,t,e)=>{e(3579)}),8335:((i,t,e)=>{var n=e(6518),s=e(3724),o=e(4576),l=e(7751),u=e(9504),d=e(9565),p=e(4901),m=e(34),b=e(4376),v=e(9297),A=e(655),x=e(6198),w=e(4659),k=e(9039),I=e(8235),P=e(4495),M=o.JSON,N=o.Number,D=o.SyntaxError,U=M&&M.parse,G=l("Object","keys"),H=Object.getOwnPropertyDescriptor,W=u("".charAt),J=u("".slice),q=u(/./.exec),dt=u([].push),Q=/^\d$/,ot=/^[1-9]$/,ct=/^[\d-]$/,X=/^[\t\n\r ]$/,$=0,ut=1,st=function(at,_){at=A(at);var V=new Et(at,0,""),K=V.parse(),Z=K.value,tt=V.skip(X,K.end);if(tt<at.length)throw new D('Unexpected extra character: "'+W(at,tt)+'" after the parsed data at: '+tt);return p(_)?St({"":Z},"",_,K):Z},St=function(at,_,V,K){var Z=at[_],tt=K&&Z===K.value,nt=tt&&typeof K.source=="string"?{source:K.source}:{},lt,z,it,Tt,zt;if(m(Z)){var _e=b(Z),Ne=tt?K.nodes:_e?[]:{};if(_e)for(lt=Ne.length,it=x(Z),Tt=0;Tt<it;Tt++)Ct(Z,Tt,St(Z,""+Tt,V,Tt<lt?Ne[Tt]:void 0));else for(z=G(Z),it=x(z),Tt=0;Tt<it;Tt++)zt=z[Tt],Ct(Z,zt,St(Z,zt,V,v(Ne,zt)?Ne[zt]:void 0))}return d(V,at,_,Z,nt)},Ct=function(at,_,V){if(s){var K=H(at,_);if(K&&!K.configurable)return}V===void 0?delete at[_]:w(at,_,V)},wt=function(at,_,V,K){this.value=at,this.end=_,this.source=V,this.nodes=K},Et=function(at,_){this.source=at,this.index=_};Et.prototype={fork:function(at){return new Et(this.source,at)},parse:function(){var at=this.source,_=this.skip(X,this.index),V=this.fork(_),K=W(at,_);if(q(ct,K))return V.number();switch(K){case"{":return V.object();case"[":return V.array();case'"':return V.string();case"t":return V.keyword(!0);case"f":return V.keyword(!1);case"n":return V.keyword(null)}throw new D('Unexpected character: "'+K+'" at: '+_)},node:function(at,_,V,K,Z){return new wt(_,K,at?null:J(this.source,V,K),Z)},object:function(){for(var at=this.source,_=this.index+1,V=!1,K={},Z={};_<at.length;){if(_=this.until(['"',"}"],_),W(at,_)==="}"&&!V){_++;break}var tt=this.fork(_).string(),nt=tt.value;_=tt.end,_=this.until([":"],_)+1,_=this.skip(X,_),tt=this.fork(_).parse(),w(Z,nt,tt),w(K,nt,tt.value),_=this.until([",","}"],tt.end);var lt=W(at,_);if(lt===",")V=!0,_++;else if(lt==="}"){_++;break}}return this.node(ut,K,this.index,_,Z)},array:function(){for(var at=this.source,_=this.index+1,V=!1,K=[],Z=[];_<at.length;){if(_=this.skip(X,_),W(at,_)==="]"&&!V){_++;break}var tt=this.fork(_).parse();if(dt(Z,tt),dt(K,tt.value),_=this.until([",","]"],tt.end),W(at,_)===",")V=!0,_++;else if(W(at,_)==="]"){_++;break}}return this.node(ut,K,this.index,_,Z)},string:function(){var at=this.index,_=I(this.source,this.index+1);return this.node($,_.value,at,_.end)},number:function(){var at=this.source,_=this.index,V=_;if(W(at,V)==="-"&&V++,W(at,V)==="0")V++;else if(q(ot,W(at,V)))V=this.skip(Q,V+1);else throw new D("Failed to parse number at: "+V);if(W(at,V)==="."&&(V=this.skip(Q,V+1)),W(at,V)==="e"||W(at,V)==="E"){V++,(W(at,V)==="+"||W(at,V)==="-")&&V++;var K=V;if(V=this.skip(Q,V),K===V)throw new D("Failed to parse number's exponent value at: "+V)}return this.node($,N(J(at,_,V)),_,V)},keyword:function(at){var _=""+at,V=this.index,K=V+_.length;if(J(this.source,V,K)!==_)throw new D("Failed to parse value at: "+V);return this.node($,at,V,K)},skip:function(at,_){for(var V=this.source;_<V.length&&q(at,W(V,_));_++);return _},until:function(at,_){_=this.skip(X,_);for(var V=W(this.source,_),K=0;K<at.length;K++)if(at[K]===V)return _;throw new D('Unexpected character: "'+V+'" at: '+_)}};var Vt=k(function(){var at="9007199254740993",_;return U(at,function(V,K,Z){_=Z.source}),_!==at}),Ut=P&&!k(function(){return 1/U("-0 ")!==-1/0});n({target:"JSON",stat:!0,forced:Vt},{parse:function(_,V){return Ut&&!p(V)?U(_):st(_,V)}})}),5247:((i,t,e)=>{e(1689)}),4979:((i,t,e)=>{var n=e(6518),s=e(4576),o=e(7751),l=e(6980),u=e(4913).f,d=e(9297),p=e(679),m=e(3167),b=e(2603),v=e(5002),A=e(8574),x=e(3724),w=e(6395),k="DOMException",I=o("Error"),P=o(k),M=function(){p(this,N);var X=arguments.length,$=b(X<1?void 0:arguments[0]),ut=b(X<2?void 0:arguments[1],"Error"),st=new P($,ut),St=new I($);return St.name=k,u(st,"stack",l(1,A(St.stack,1))),m(st,this,M),st},N=M.prototype=P.prototype,D="stack"in new I(k),U="stack"in new P(1,2),G=P&&x&&Object.getOwnPropertyDescriptor(s,k),H=!!G&&!(G.writable&&G.configurable),W=D&&!H&&!U;n({global:!0,constructor:!0,forced:w||W},{DOMException:W?M:P});var J=o(k),q=J.prototype;if(q.constructor!==J){w||u(q,"constructor",l(1,J));for(var dt in v)if(d(v,dt)){var Q=v[dt],ot=Q.s;d(J,ot)||u(J,ot,l(6,Q.c))}}}),4603:((i,t,e)=>{var n=e(6840),s=e(9504),o=e(655),l=e(2812),u=URLSearchParams,d=u.prototype,p=s(d.append),m=s(d.delete),b=s(d.forEach),v=s([].push),A=new u("a=1&a=2&b=3");A.delete("a",1),A.delete("b",void 0),A+""!="a=2"&&n(d,"delete",function(x){var w=arguments.length,k=w<2?void 0:arguments[1];if(w&&k===void 0)return m(this,x);var I=[];b(this,function(W,J){v(I,{key:J,value:W})}),l(w,1);for(var P=o(x),M=o(k),N=0,D=0,U=!1,G=I.length,H;N<G;)H=I[N++],U||H.key===P?(U=!0,m(this,H.key)):D++;for(;D<G;)H=I[D++],H.key===P&&H.value===M||p(this,H.key,H.value)},{enumerable:!0,unsafe:!0})}),7566:((i,t,e)=>{var n=e(6840),s=e(9504),o=e(655),l=e(2812),u=URLSearchParams,d=u.prototype,p=s(d.getAll),m=s(d.has),b=new u("a=1");(b.has("a",2)||!b.has("a",void 0))&&n(d,"has",function(A){var x=arguments.length,w=x<2?void 0:arguments[1];if(x&&w===void 0)return m(this,A);var k=p(this,A);l(x,1);for(var I=o(w),P=0;P<k.length;)if(k[P++]===I)return!0;return!1},{enumerable:!0,unsafe:!0})}),8721:((i,t,e)=>{var n=e(3724),s=e(9504),o=e(2106),l=URLSearchParams.prototype,u=s(l.forEach);n&&!("size"in l)&&o(l,"size",{get:function(){var p=0;return u(this,function(){p++}),p},configurable:!0,enumerable:!0})})},Nu={};Dt.d=(i,t)=>{for(var e in t)Dt.o(t,e)&&!Dt.o(i,e)&&Object.defineProperty(i,e,{enumerable:!0,get:t[e]})};Dt.o=(i,t)=>Object.prototype.hasOwnProperty.call(i,t);kt=globalThis.pdfjsLib={};Dt.d(kt,{AbortException:()=>Je,AnnotationEditorLayer:()=>nl,AnnotationEditorParamsType:()=>Ft,AnnotationEditorType:()=>Mt,AnnotationEditorUIManager:()=>Bn,AnnotationLayer:()=>za,AnnotationMode:()=>bn,ColorPicker:()=>di,DOMSVGFactory:()=>Br,DrawLayer:()=>rl,FeatureTest:()=>se,GlobalWorkerOptions:()=>Dn,ImageKind:()=>Ns,InvalidPDFException:()=>Or,MissingPDFException:()=>_n,OPS:()=>We,OutputScale:()=>Fr,PDFDataRangeTransport:()=>ti,PDFDateString:()=>Gs,PDFWorker:()=>or,PasswordResponses:()=>ay,PermissionFlag:()=>oy,PixelsPerInch:()=>vn,RenderingCancelledException:()=>Lr,TextLayer:()=>Nr,TouchManager:()=>Vs,UnexpectedResponseException:()=>ar,Util:()=>xt,VerbosityLevel:()=>gi,XfaLayer:()=>ri,build:()=>Ky,createValidAbsoluteUrl:()=>hy,fetchData:()=>vi,getDocument:()=>$y,getFilenameFromUrl:()=>vy,getPdfFilenameFromUrl:()=>xy,getXfaPageViewport:()=>Sy,isDataScheme:()=>xi,isPdfFile:()=>ol,noContextMenu:()=>$e,normalizeUnicode:()=>my,setLayerDimensions:()=>Nn,shadow:()=>Lt,stopEvent:()=>Ie,version:()=>Yy});YS=Dt(4114),KS=Dt(6573),ZS=Dt(8100),QS=Dt(7936),JS=Dt(7467),qS=Dt(4732),tA=Dt(9577),eA=Dt(5247),nA=Dt(4979),rA=Dt(4603),sA=Dt(7566),iA=Dt(8721),he=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Ju=[1,0,0,1,0,0],_o=[.001,0,0,.001,0,0],ry=1e7,_s=1.35,sy=.35,oA=sy/_s,ke={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},bn={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},iy="pdfjs_internal_editor_",Mt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Ft={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},oy={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},ce={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},Ns={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},ne={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},Er={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},gi={ERRORS:0,WARNINGS:1,INFOS:5},We={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},ay={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},mi=gi.WARNINGS;xn=(function(){function t(e,n){this.message=e,this.name=n}return t.prototype=new Error,t.constructor=t,t})(),Us=class extends xn{constructor(t,e){super(t,"PasswordException"),this.code=e}},Rr=class extends xn{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}},Or=class extends xn{constructor(t){super(t,"InvalidPDFException")}},_n=class extends xn{constructor(t){super(t,"MissingPDFException")}},ar=class extends xn{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}},No=class extends xn{constructor(t){super(t,"FormatError")}},Je=class extends xn{constructor(t){super(t,"AbortException")}};se=class{static get isLittleEndian(){return Lt(this,"isLittleEndian",fy())}static get isEvalSupported(){return Lt(this,"isEvalSupported",py())}static get isOffscreenCanvasSupported(){return Lt(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return Lt(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){return typeof navigator<"u"&&typeof navigator?.platform=="string"?Lt(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof navigator?.userAgent=="string"&&navigator.userAgent.includes("Firefox")}):Lt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return Lt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}},Oo=Array.from(Array(256).keys(),i=>i.toString(16).padStart(2,"0")),xt=class{static makeHexColor(t,e,n){return`#${Oo[t]}${Oo[e]}${Oo[n]}`}static scaleMinMax(t,e){let n;t[0]?(t[0]<0&&(n=e[0],e[0]=e[2],e[2]=n),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(n=e[1],e[1]=e[3],e[3]=n),e[1]*=t[3],e[3]*=t[3]):(n=e[0],e[0]=e[1],e[1]=n,n=e[2],e[2]=e[3],e[3]=n,t[1]<0&&(n=e[1],e[1]=e[3],e[3]=n),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(n=e[0],e[0]=e[2],e[2]=n),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}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 applyTransform(t,e){let n=t[0]*e[0]+t[1]*e[2]+e[4],s=t[0]*e[1]+t[1]*e[3]+e[5];return[n,s]}static applyInverseTransform(t,e){let n=e[0]*e[3]-e[1]*e[2],s=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/n,o=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/n;return[s,o]}static getAxialAlignedBoundingBox(t,e){let n=this.applyTransform(t,e),s=this.applyTransform(t.slice(2,4),e),o=this.applyTransform([t[0],t[3]],e),l=this.applyTransform([t[2],t[1]],e);return[Math.min(n[0],s[0],o[0],l[0]),Math.min(n[1],s[1],o[1],l[1]),Math.max(n[0],s[0],o[0],l[0]),Math.max(n[1],s[1],o[1],l[1])]}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){let e=[t[0],t[2],t[1],t[3]],n=t[0]*e[0]+t[1]*e[2],s=t[0]*e[1]+t[1]*e[3],o=t[2]*e[0]+t[3]*e[2],l=t[2]*e[1]+t[3]*e[3],u=(n+l)/2,d=Math.sqrt((n+l)**2-4*(n*l-o*s))/2,p=u+d||1,m=u-d||1;return[Math.sqrt(p),Math.sqrt(m)]}static normalizeRect(t){let e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){let n=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(n>s)return null;let o=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),l=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return o>l?null:[n,o,s,l]}static#t(t,e,n,s,o,l,u,d,p,m){if(p<=0||p>=1)return;let b=1-p,v=p*p,A=v*p,x=b*(b*(b*t+3*p*e)+3*v*n)+A*s,w=b*(b*(b*o+3*p*l)+3*v*u)+A*d;m[0]=Math.min(m[0],x),m[1]=Math.min(m[1],w),m[2]=Math.max(m[2],x),m[3]=Math.max(m[3],w)}static#e(t,e,n,s,o,l,u,d,p,m,b,v){if(Math.abs(p)<1e-12){Math.abs(m)>=1e-12&&this.#t(t,e,n,s,o,l,u,d,-b/m,v);return}let A=m**2-4*b*p;if(A<0)return;let x=Math.sqrt(A),w=2*p;this.#t(t,e,n,s,o,l,u,d,(-m+x)/w,v),this.#t(t,e,n,s,o,l,u,d,(-m-x)/w,v)}static bezierBoundingBox(t,e,n,s,o,l,u,d,p){return p?(p[0]=Math.min(p[0],t,u),p[1]=Math.min(p[1],e,d),p[2]=Math.max(p[2],t,u),p[3]=Math.max(p[3],e,d)):p=[Math.min(t,u),Math.min(e,d),Math.max(t,u),Math.max(e,d)],this.#e(t,n,o,u,e,s,l,d,3*(-t+3*(n-o)+u),6*(t-2*n+o),3*(n-t),p),this.#e(t,n,o,u,e,s,l,d,3*(-e+3*(s-l)+d),6*(e-2*s+l),3*(s-e),p),p}};Mo=null,Uu=null;il="pdfjs_internal_id_";aA=Dt(4628),lA=Dt(7642),cA=Dt(8004),uA=Dt(3853),hA=Dt(5876),dA=Dt(2475),fA=Dt(5024),pA=Dt(1698),gA=Dt(1454),mA=Dt(8992),bA=Dt(4743),yA=Dt(3215),vA=Dt(7550),xA=Dt(8335),sn="http://www.w3.org/2000/svg",vn=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};Mr=class i{constructor({viewBox:t,userUnit:e,scale:n,rotation:s,offsetX:o=0,offsetY:l=0,dontFlip:u=!1}){this.viewBox=t,this.userUnit=e,this.scale=n,this.rotation=s,this.offsetX=o,this.offsetY=l,n*=e;let d=(t[2]+t[0])/2,p=(t[3]+t[1])/2,m,b,v,A;switch(s%=360,s<0&&(s+=360),s){case 180:m=-1,b=0,v=0,A=1;break;case 90:m=0,b=1,v=1,A=0;break;case 270:m=0,b=-1,v=-1,A=0;break;case 0:m=1,b=0,v=0,A=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}u&&(v=-v,A=-A);let x,w,k,I;m===0?(x=Math.abs(p-t[1])*n+o,w=Math.abs(d-t[0])*n+l,k=(t[3]-t[1])*n,I=(t[2]-t[0])*n):(x=Math.abs(d-t[0])*n+o,w=Math.abs(p-t[1])*n+l,k=(t[2]-t[0])*n,I=(t[3]-t[1])*n),this.transform=[m*n,b*n,v*n,A*n,x-m*n*d-v*n*p,w-b*n*d-A*n*p],this.width=k,this.height=I}get rawDims(){let{userUnit:t,viewBox:e}=this,n=e.map(s=>s*t);return Lt(this,"rawDims",{pageWidth:n[2]-n[0],pageHeight:n[3]-n[1],pageX:n[0],pageY:n[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:n=this.offsetX,offsetY:s=this.offsetY,dontFlip:o=!1}={}){return new i({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:n,offsetY:s,dontFlip:o})}convertToViewportPoint(t,e){return xt.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){let e=xt.applyTransform([t[0],t[1]],this.transform),n=xt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],n[0],n[1]]}convertToPdfPoint(t,e){return xt.applyInverseTransform([t,e],this.transform)}},Lr=class extends xn{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};Bs=class{started=Object.create(null);times=[];time(t){t in this.started&&Pt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||Pt(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){let t=[],e=0;for(let{name:n}of this.times)e=Math.max(n.length,e);for(let{name:n,start:s,end:o}of this.times)t.push(`${n.padEnd(e)} ${o-s}ms
4
- `);return t.join("")}};Gs=class{static#t;static toDateObject(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 n=parseInt(e[1],10),s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let o=parseInt(e[3],10);o=o>=1&&o<=31?o:1;let l=parseInt(e[4],10);l=l>=0&&l<=23?l:0;let u=parseInt(e[5],10);u=u>=0&&u<=59?u:0;let d=parseInt(e[6],10);d=d>=0&&d<=59?d:0;let p=e[7]||"Z",m=parseInt(e[8],10);m=m>=0&&m<=23?m:0;let b=parseInt(e[9],10)||0;return b=b>=0&&b<=59?b:0,p==="-"?(l+=m,u+=b):p==="+"&&(l-=m,u-=b),new Date(Date.UTC(n,s,o,l,u,d))}};Fr=class{constructor(){let t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}},Uo=class i{#t=null;#e=null;#n;#r=null;#i=null;static#s=null;constructor(t){this.#n=t,i.#s||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){let t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#n._uiManager._signal;t.addEventListener("contextmenu",$e,{signal:e}),t.addEventListener("pointerdown",i.#l,{signal:e});let n=this.#r=document.createElement("div");n.className="buttons",t.append(n);let s=this.#n.toolbarPosition;if(s){let{style:o}=t,l=this.#n._uiManager.direction==="ltr"?1-s[0]:s[0];o.insetInlineEnd=`${100*l}%`,o.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#d(),t}get div(){return this.#t}static#l(t){t.stopPropagation()}#a(t){this.#n._focusEventsAllowed=!1,Ie(t)}#u(t){this.#n._focusEventsAllowed=!0,Ie(t)}#c(t){let e=this.#n._uiManager._signal;t.addEventListener("focusin",this.#a.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",$e,{signal:e})}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#i?.shown()}#d(){let{editorType:t,_uiManager:e}=this.#n,n=document.createElement("button");n.className="delete",n.tabIndex=0,n.setAttribute("data-l10n-id",i.#s[t]),this.#c(n),n.addEventListener("click",s=>{e.delete()},{signal:e._signal}),this.#r.append(n)}get#h(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#c(e),this.#r.prepend(e,this.#h),this.#i=t}addColorPicker(t){this.#e=t;let e=t.renderButton();this.#c(e),this.#r.prepend(e,this.#h)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}},Bo=class{#t=null;#e=null;#n;constructor(t){this.#n=t}#r(){let t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",$e,{signal:this.#n._signal});let e=this.#t=document.createElement("div");return e.className="buttons",t.append(e),this.#s(),t}#i(t,e){let n=0,s=0;for(let o of t){let l=o.y+o.height;if(l<n)continue;let u=o.x+(e?o.width:0);if(l>n){s=u,n=l;continue}e?u>s&&(s=u):u<s&&(s=u)}return[e?1-s:s,n]}show(t,e,n){let[s,o]=this.#i(e,n),{style:l}=this.#e||=this.#r();t.append(this.#e),l.insetInlineEnd=`${100*s}%`,l.top=`calc(${100*o}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#s(){let t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");let e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");let n=this.#n._signal;t.addEventListener("contextmenu",$e,{signal:n}),t.addEventListener("click",()=>{this.#n.highlightSelection("floating_button")},{signal:n}),this.#t.append(t)}};Go=class{#t=0;get id(){return`${iy}${this.#t++}`}},Ho=class i{#t=by();#e=0;#n=null;static get _isSVGFittingCanvas(){let t='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',n=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),s=new Image;s.src=t;let o=s.decode().then(()=>(n.drawImage(s,0,0,1,1,0,0,1,3),new Uint32Array(n.getImageData(0,0,1,1).data.buffer)[0]===0));return Lt(this,"_isSVGFittingCanvas",o)}async#r(t,e){this.#n||=new Map;let n=this.#n.get(t);if(n===null)return null;if(n?.bitmap)return n.refCounter+=1,n;try{n||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let s;if(typeof e=="string"?(n.url=e,s=await vi(e,"blob")):e instanceof File?s=n.file=e:e instanceof Blob&&(s=e),s.type==="image/svg+xml"){let o=i._isSVGFittingCanvas,l=new FileReader,u=new Image,d=new Promise((p,m)=>{u.onload=()=>{n.bitmap=u,n.isSvg=!0,p()},l.onload=async()=>{let b=n.svgUrl=l.result;u.src=await o?`${b}#svgView(preserveAspectRatio(none))`:b},u.onerror=l.onerror=m});l.readAsDataURL(s),await d}else n.bitmap=await createImageBitmap(s);n.refCounter=1}catch(s){Pt(s),n=null}return this.#n.set(t,n),n&&this.#n.set(n.id,n),n}async getFromFile(t){let{lastModified:e,name:n,size:s,type:o}=t;return this.#r(`${e}_${n}_${s}_${o}`,t)}async getFromUrl(t){return this.#r(t,t)}async getFromBlob(t,e){let n=await e;return this.#r(t,n)}async getFromId(t){this.#n||=new Map;let e=this.#n.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:n}=e;return delete e.blobPromise,this.getFromBlob(e.id,n)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#n||=new Map;let n=this.#n.get(t);if(n?.bitmap)return n.refCounter+=1,n;let s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),n={bitmap:s.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#n.set(t,n),this.#n.set(n.id,n),n}getSvgUrl(t){let e=this.#n.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#n||=new Map;let e=this.#n.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;let{bitmap:n}=e;if(!e.url&&!e.file){let s=new OffscreenCanvas(n.width,n.height);s.getContext("bitmaprenderer").transferFromImageBitmap(n),e.blobPromise=s.convertToBlob()}n.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}},jo=class{#t=[];#e=!1;#n;#r=-1;constructor(t=128){this.#n=t}add({cmd:t,undo:e,post:n,mustExec:s,type:o=NaN,overwriteIfSameType:l=!1,keepUndo:u=!1}){if(s&&t(),this.#e)return;let d={cmd:t,undo:e,post:n,type:o};if(this.#r===-1){this.#t.length>0&&(this.#t.length=0),this.#r=0,this.#t.push(d);return}if(l&&this.#t[this.#r].type===o){u&&(d.undo=this.#t[this.#r].undo),this.#t[this.#r]=d;return}let p=this.#r+1;p===this.#n?this.#t.splice(0,1):(this.#r=p,p<this.#t.length&&this.#t.splice(p)),this.#t.push(d)}undo(){if(this.#r===-1)return;this.#e=!0;let{undo:t,post:e}=this.#t[this.#r];t(),e?.(),this.#e=!1,this.#r-=1}redo(){if(this.#r<this.#t.length-1){this.#r+=1,this.#e=!0;let{cmd:t,post:e}=this.#t[this.#r];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#r!==-1}hasSomethingToRedo(){return this.#r<this.#t.length-1}cleanType(t){if(this.#r!==-1){for(let e=this.#r;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#r-e),this.#r=e;return}this.#t.length=0,this.#r=-1}}destroy(){this.#t=null}},Un=class{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:e}=se.platform;for(let[n,s,o={}]of t)for(let l of n){let u=l.startsWith("mac+");e&&u?(this.callbacks.set(l.slice(4),{callback:s,options:o}),this.allKeys.add(l.split("+").at(-1))):!e&&!u&&(this.callbacks.set(l,{callback:s,options:o}),this.allKeys.add(l.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);let e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;let n=this.callbacks.get(this.#t(e));if(!n)return;let{callback:s,options:{bubbles:o=!1,args:l=[],checker:u=null}}=n;u&&!u(t,e)||(s.bind(t,...l,e)(),o||Ie(e))}},Vo=class i{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]);return Ay(t),Lt(this,"_colors",t)}convert(t){let e=al(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[n,s]of this._colors)if(s.every((o,l)=>o===e[l]))return i._colorsMapping.get(n);return e}getHexCode(t){let e=this._colors.get(t);return e?xt.makeHexColor(...e):t}},Bn=class i{#t=new AbortController;#e=null;#n=new Map;#r=new Map;#i=null;#s=null;#l=null;#a=new jo;#u=null;#c=null;#d=0;#h=new Set;#f=null;#o=null;#p=new Set;_editorUndoBar=null;#m=!1;#g=!1;#b=!1;#x=null;#y=null;#S=null;#T=null;#E=!1;#k=null;#P=new Go;#A=!1;#I=!1;#C=null;#O=null;#F=null;#_=null;#w=Mt.NONE;#v=new Set;#L=null;#H=null;#j=null;#V={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#N=[0,0];#D=null;#U=null;#W=null;#M=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=i.prototype,e=l=>l.#U.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&l.hasSomethingToControl(),n=(l,{target:u})=>{if(u instanceof HTMLInputElement){let{type:d}=u;return d!=="text"&&d!=="number"}return!0},s=this.TRANSLATE_SMALL,o=this.TRANSLATE_BIG;return Lt(this,"_keyboardManager",new Un([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],t.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:n}],[["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:n}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(l,{target:u})=>!(u instanceof HTMLButtonElement)&&l.#U.contains(u)&&!l.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(l,{target:u})=>!(u instanceof HTMLButtonElement)&&l.#U.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-o,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[o,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-o],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,o],checker:e}]]))}constructor(t,e,n,s,o,l,u,d,p,m,b,v,A){let x=this._signal=this.#t.signal;this.#U=t,this.#W=e,this.#i=n,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:x}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:x}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:x}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:x}),s._on("setpreference",this.onSetPreference.bind(this),{signal:x}),s._on("switchannotationeditorparams",w=>this.updateParams(w.type,w.value),{signal:x}),this.#et(),this.#it(),this.#Y(),this.#s=o.annotationStorage,this.#x=o.filterFactory,this.#H=l,this.#T=u||null,this.#m=d,this.#g=p,this.#b=m,this.#_=b||null,this.viewParameters={realScale:vn.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=v||null,this._supportsPinchToZoom=A!==!1}destroy(){this.#M?.resolve(),this.#M=null,this.#t?.abort(),this.#t=null,this._signal=null;for(let t of this.#r.values())t.destroy();this.#r.clear(),this.#n.clear(),this.#p.clear(),this.#e=null,this.#v.clear(),this.#a.destroy(),this.#i?.destroy(),this.#k?.hide(),this.#k=null,this.#y&&(clearTimeout(this.#y),this.#y=null),this.#D&&(clearTimeout(this.#D),this.#D=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#_}get useNewAltTextFlow(){return this.#g}get useNewAltTextWhenAddingImage(){return this.#b}get hcmFilter(){return Lt(this,"hcmFilter",this.#H?this.#x.addHCMFilter(this.#H.foreground,this.#H.background):"none")}get direction(){return Lt(this,"direction",getComputedStyle(this.#U).direction)}get highlightColors(){return Lt(this,"highlightColors",this.#T?new Map(this.#T.split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return Lt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#c=t}setMainHighlightColorPicker(t){this.#F=t}editAltText(t,e=!1){this.#i?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),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.#b=e;break}}onPageChanging({pageNumber:t}){this.#d=t-1}focusMainContainer(){this.#U.focus()}findParent(t,e){for(let n of this.#r.values()){let{x:s,y:o,width:l,height:u}=n.div.getBoundingClientRect();if(t>=s&&t<=s+l&&e>=o&&e<=o+u)return n}return null}disableUserSelect(t=!1){this.#W.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#p.add(t)}removeShouldRescale(t){this.#p.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*vn.PDF_TO_CSS_UNITS;for(let e of this.#p)e.onScaleChanging();this.#c?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#B({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#X(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let n of this.#r.values())if(n.hasTextLayer(t))return n;return null}highlightSelection(t=""){let e=document.getSelection();if(!e||e.isCollapsed)return;let{anchorNode:n,anchorOffset:s,focusNode:o,focusOffset:l}=e,u=e.toString(),p=this.#B(e).closest(".textLayer"),m=this.getSelectionBoxes(p);if(!m)return;e.empty();let b=this.#X(p),v=this.#w===Mt.NONE,A=()=>{b?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:m,anchorNode:n,anchorOffset:s,focusNode:o,focusOffset:l,text:u}),v&&this.showAllEditors("highlight",!0,!0)};if(v){this.switchToMode(Mt.HIGHLIGHT,A);return}A()}#q(){let t=document.getSelection();if(!t||t.isCollapsed)return;let n=this.#B(t).closest(".textLayer"),s=this.getSelectionBoxes(n);s&&(this.#k||=new Bo(this),this.#k.show(n,s,this.direction==="ltr"))}addToAnnotationStorage(t){!t.isEmpty()&&this.#s&&!this.#s.has(t.id)&&this.#s.setValue(t.id,t)}#tt(){let t=document.getSelection();if(!t||t.isCollapsed){this.#L&&(this.#k?.hide(),this.#L=null,this.#R({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#L)return;let s=this.#B(t).closest(".textLayer");if(!s){this.#L&&(this.#k?.hide(),this.#L=null,this.#R({hasSelectedText:!1}));return}if(this.#k?.hide(),this.#L=e,this.#R({hasSelectedText:!0}),!(this.#w!==Mt.HIGHLIGHT&&this.#w!==Mt.NONE)&&(this.#w===Mt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#E=this.isShiftKeyDown,!this.isShiftKeyDown)){let o=this.#w===Mt.HIGHLIGHT?this.#X(s):null;o?.toggleDrawing();let l=new AbortController,u=this.combinedSignal(l),d=p=>{p.type==="pointerup"&&p.button!==0||(l.abort(),o?.toggleDrawing(!0),p.type==="pointerup"&&this.#z("main_toolbar"))};window.addEventListener("pointerup",d,{signal:u}),window.addEventListener("blur",d,{signal:u})}}#z(t=""){this.#w===Mt.HIGHLIGHT?this.highlightSelection(t):this.#m&&this.#q()}#et(){document.addEventListener("selectionchange",this.#tt.bind(this),{signal:this._signal})}#nt(){if(this.#S)return;this.#S=new AbortController;let t=this.combinedSignal(this.#S);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#rt(){this.#S?.abort(),this.#S=null}blur(){if(this.isShiftKeyDown=!1,this.#E&&(this.#E=!1,this.#z("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#v)if(e.div.contains(t)){this.#O=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#O)return;let[t,e]=this.#O;this.#O=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#Y(){if(this.#C)return;this.#C=new AbortController;let t=this.combinedSignal(this.#C);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#st(){this.#C?.abort(),this.#C=null}#K(){if(this.#u)return;this.#u=new AbortController;let t=this.combinedSignal(this.#u);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})}#Z(){this.#u?.abort(),this.#u=null}#it(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Y(),this.#K()}removeEditListeners(){this.#st(),this.#Z()}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let n of this.#o)if(n.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let n of this.#o)if(n.isHandlingMimeForPasting(e.type)){n.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let n of this.#v){let s=n.serialize(!0);s&&e.push(s)}e.length!==0&&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 o of e.items)for(let l of this.#o)if(l.isHandlingMimeForPasting(o.type)){l.paste(o,this.currentLayer);return}let n=e.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(o){Pt(`paste: "${o.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();let s=this.currentLayer;try{let o=[];for(let d of n){let p=await s.deserialize(d);if(!p)return;o.push(p)}let l=()=>{for(let d of o)this.#Q(d);this.#J(o)},u=()=>{for(let d of o)d.remove()};this.addCommands({cmd:l,undo:u,mustExec:!0})}catch(o){Pt(`paste: "${o.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#w!==Mt.NONE&&!this.isEditorHandlingKeyboard&&i._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#E&&(this.#E=!1,this.#z("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}}#R(t){Object.entries(t).some(([n,s])=>this.#V[n]!==s)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#V,t)}),this.#w===Mt.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#G([[Ft.HIGHLIGHT_FREE,!0]]))}#G(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#nt(),this.#K(),this.#R({isEditing:this.#w!==Mt.NONE,isEmpty:this.#$(),hasSomethingToUndo:this.#a.hasSomethingToUndo(),hasSomethingToRedo:this.#a.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#rt(),this.#Z(),this.#R({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#o){this.#o=t;for(let e of this.#o)this.#G(e.defaultPropertiesToUpdate)}}getId(){return this.#P.id}get currentLayer(){return this.#r.get(this.#d)}getLayer(t){return this.#r.get(t)}get currentPageIndex(){return this.#d}addLayer(t){this.#r.set(t.pageIndex,t),this.#A?t.enable():t.disable()}removeLayer(t){this.#r.delete(t.pageIndex)}async updateMode(t,e=null,n=!1){if(this.#w!==t&&!(this.#M&&(await this.#M.promise,!this.#M))){if(this.#M=Promise.withResolvers(),this.#w=t,t===Mt.NONE){this.setEditingState(!1),this.#at(),this._editorUndoBar?.hide(),this.#M.resolve();return}this.setEditingState(!0),await this.#ot(),this.unselectAll();for(let s of this.#r.values())s.updateMode(t);if(!e){n&&this.addNewEditorFromKeyboard(),this.#M.resolve();return}for(let s of this.#n.values())s.annotationElementId===e?(this.setSelected(s),s.enterInEditMode()):s.unselect();this.#M.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#w&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#o){switch(t){case Ft.CREATE:this.currentLayer.addNewEditor();return;case Ft.HIGHLIGHT_DEFAULT_COLOR:this.#F?.updateColor(e);break;case Ft.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}for(let n of this.#v)n.updateParams(t,e);for(let n of this.#o)n.updateDefaultParams(t,e)}}showAllEditors(t,e,n=!1){for(let o of this.#n.values())o.editorType===t&&o.show(e);(this.#j?.get(Ft.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#G([[Ft.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#I!==t){this.#I=t;for(let e of this.#r.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#ot(){if(!this.#A){this.#A=!0;let t=[];for(let e of this.#r.values())t.push(e.enable());await Promise.all(t);for(let e of this.#n.values())e.enable()}}#at(){if(this.unselectAll(),this.#A){this.#A=!1;for(let t of this.#r.values())t.disable();for(let t of this.#n.values())t.disable()}}getEditors(t){let e=[];for(let n of this.#n.values())n.pageIndex===t&&e.push(n);return e}getEditor(t){return this.#n.get(t)}addEditor(t){this.#n.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.focusMainContainer(),this.#y=null},0)),this.#n.delete(t.id),this.unselect(t),(!t.annotationElementId||!this.#h.has(t.annotationElementId))&&this.#s?.remove(t.id)}addDeletedAnnotationElement(t){this.#h.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#h.has(t)}removeDeletedAnnotationElement(t){this.#h.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Q(t){let e=this.#r.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#G(t.propertiesToUpdate))}get#lt(){let t=null;for(t of this.#v);return t}updateUI(t){this.#lt===t&&this.#G(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#G(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#v.has(t)){this.#v.delete(t),t.unselect(),this.#R({hasSelectedEditor:this.hasSelection});return}this.#v.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}setSelected(t){this.#c?.commitOrRemove();for(let e of this.#v)e!==t&&e.unselect();this.#v.clear(),this.#v.add(t),t.select(),this.#G(t.propertiesToUpdate),this.#R({hasSelectedEditor:!0})}isSelected(t){return this.#v.has(t)}get firstSelectedEditor(){return this.#v.values().next().value}unselect(t){t.unselect(),this.#v.delete(t),this.#R({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#v.size!==0}get isEnterHandled(){return this.#v.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#a.undo(),this.#R({hasSomethingToUndo:this.#a.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#$()}),this._editorUndoBar?.hide()}redo(){this.#a.redo(),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:this.#a.hasSomethingToRedo(),isEmpty:this.#$()})}addCommands(t){this.#a.add(t),this.#R({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#$()})}cleanUndoStack(t){this.#a.cleanType(t)}#$(){if(this.#n.size===0)return!0;if(this.#n.size===1)for(let t of this.#n.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.#v],n=()=>{this._editorUndoBar?.show(s,e.length===1?e[0].editorType:e.length);for(let o of e)o.remove()},s=()=>{for(let o of e)this.#Q(o)};this.addCommands({cmd:n,undo:s,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#J(t){for(let e of this.#v)e.unselect();this.#v.clear();for(let e of t)e.isEmpty()||(this.#v.add(e),e.select());this.#R({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#v)t.commit();this.#J(this.#n.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#w!==Mt.NONE))&&!this.#c?.commitOrRemove()&&this.hasSelection){for(let t of this.#v)t.unselect();this.#v.clear(),this.#R({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#N[0]+=t,this.#N[1]+=e;let[s,o]=this.#N,l=[...this.#v],u=1e3;this.#D&&clearTimeout(this.#D),this.#D=setTimeout(()=>{this.#D=null,this.#N[0]=this.#N[1]=0,this.addCommands({cmd:()=>{for(let d of l)this.#n.has(d.id)&&d.translateInPage(s,o)},undo:()=>{for(let d of l)this.#n.has(d.id)&&d.translateInPage(-s,-o)},mustExec:!1})},u);for(let d of l)d.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(let t of this.#v)this.#f.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);let t=this.#f;this.#f=null;let e=!1;for(let[{x:s,y:o,pageIndex:l},u]of t)u.newX=s,u.newY=o,u.newPageIndex=l,e||=s!==u.savedX||o!==u.savedY||l!==u.savedPageIndex;if(!e)return!1;let n=(s,o,l,u)=>{if(this.#n.has(s.id)){let d=this.#r.get(u);d?s._setParentAndPosition(d,o,l):(s.pageIndex=u,s.x=o,s.y=l)}};return this.addCommands({cmd:()=>{for(let[s,{newX:o,newY:l,newPageIndex:u}]of t)n(s,o,l,u)},undo:()=>{for(let[s,{savedX:o,savedY:l,savedPageIndex:u}]of t)n(s,o,l,u)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#f)for(let n of this.#f.keys())n.drag(t,e)}rebuild(t){if(t.parent===null){let e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#v.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#w}get imageManager(){return Lt(this,"imageManager",new Ho)}getSelectionBoxes(t){if(!t)return null;let e=document.getSelection();for(let p=0,m=e.rangeCount;p<m;p++)if(!t.contains(e.getRangeAt(p).commonAncestorContainer))return null;let{x:n,y:s,width:o,height:l}=t.getBoundingClientRect(),u;switch(t.getAttribute("data-main-rotation")){case"90":u=(p,m,b,v)=>({x:(m-s)/l,y:1-(p+b-n)/o,width:v/l,height:b/o});break;case"180":u=(p,m,b,v)=>({x:1-(p+b-n)/o,y:1-(m+v-s)/l,width:b/o,height:v/l});break;case"270":u=(p,m,b,v)=>({x:1-(m+v-s)/l,y:(p-n)/o,width:v/l,height:b/o});break;default:u=(p,m,b,v)=>({x:(p-n)/o,y:(m-s)/l,width:b/o,height:v/l});break}let d=[];for(let p=0,m=e.rangeCount;p<m;p++){let b=e.getRangeAt(p);if(!b.collapsed)for(let{x:v,y:A,width:x,height:w}of b.getClientRects())x===0||w===0||d.push(u(v,A,x,w))}return d.length===0?null:d}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#l||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#l?.delete(t)}renderAnnotationElement(t){let e=this.#l?.get(t.data.id);if(!e)return;let n=this.#s.getRawValue(e);n&&(this.#w===Mt.NONE&&!n.hasBeenModified||n.renderAnnotationElement(t))}},js=class i{#t=null;#e=!1;#n=null;#r=null;#i=null;#s=null;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=!1;static#f=null;static _l10n=null;constructor(t){this.#u=t,this.#h=t._uiManager.useNewAltTextFlow,i.#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){i._l10n??=t}async render(){let t=this.#n=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#r=document.createElement("span");t.append(e),this.#h?(t.classList.add("new"),t.setAttribute("data-l10n-id",i.#f.missing),e.setAttribute("data-l10n-id",i.#f["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let n=this.#u._uiManager._signal;t.addEventListener("contextmenu",$e,{signal:n}),t.addEventListener("pointerdown",o=>o.stopPropagation(),{signal:n});let s=o=>{o.preventDefault(),this.#u._uiManager.editAltText(this.#u),this.#h&&this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#o}})};return t.addEventListener("click",s,{capture:!0,signal:n}),t.addEventListener("keydown",o=>{o.target===t&&o.key==="Enter"&&(this.#l=!0,s(o))},{signal:n}),await this.#p(),t}get#o(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#n&&(this.#n.focus({focusVisible:this.#l}),this.#l=!1)}isEmpty(){return this.#h?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#h?this.#t!==null||!!this.#c:this.isEmpty()}get guessedText(){return this.#c}async setGuessedText(t){this.#t===null&&(this.#c=t,this.#d=await i._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#p())}toggleAltTextBadge(t=!1){if(!this.#h||this.#t){this.#a?.remove(),this.#a=null;return}if(!this.#a){let e=this.#a=document.createElement("div");e.className="noAltTextBadge",this.#u.div.append(e)}this.#a.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#c===e&&(e=this.#d),{altText:e,decorative:this.#e,guessedText:this.#c,textWithDisclaimer:this.#d}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:n,textWithDisclaimer:s,cancel:o=!1}){n&&(this.#c=n,this.#d=s),!(this.#t===t&&this.#e===e)&&(o||(this.#t=t,this.#e=e),this.#p())}toggle(t=!1){this.#n&&(!t&&this.#s&&(clearTimeout(this.#s),this.#s=null),this.#n.disabled=!t)}shown(){this.#u._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#o}})}destroy(){this.#n?.remove(),this.#n=null,this.#r=null,this.#i=null,this.#a?.remove(),this.#a=null}async#p(){let t=this.#n;if(!t)return;if(this.#h){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",i.#f[this.#o]),this.#r?.setAttribute("data-l10n-id",i.#f[`${this.#o}-label`]),!this.#t){this.#i?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#i?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#i;if(!e){this.#i=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#u.id}`;let s=100,o=this.#u._uiManager._signal;o.addEventListener("abort",()=>{clearTimeout(this.#s),this.#s=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#s=setTimeout(()=>{this.#s=null,this.#i.classList.add("show"),this.#u._reportTelemetry({action:"alt_text_tooltip"})},s)},{signal:o}),t.addEventListener("mouseleave",()=>{this.#s&&(clearTimeout(this.#s),this.#s=null),this.#i?.classList.remove("show")},{signal:o})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#u.getImageForAltText()?.setAttribute("aria-describedby",e.id)}},Vs=class i{#t;#e=!1;#n=null;#r;#i;#s;#l;#a;#u=null;#c;#d=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:n=null,onPinchStart:s=null,onPinching:o=null,onPinchEnd:l=null,signal:u}){this.#t=t,this.#n=n,this.#r=e,this.#i=s,this.#s=o,this.#l=l,this.#c=new AbortController,this.#a=AbortSignal.any([u,this.#c.signal]),t.addEventListener("touchstart",this.#h.bind(this),{passive:!1,signal:this.#a})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Lt(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#h(t){if(this.#r?.()||t.touches.length<2)return;if(!this.#d){this.#d=new AbortController;let s=AbortSignal.any([this.#a,this.#d.signal]),o=this.#t,l={signal:s,passive:!1};o.addEventListener("touchmove",this.#f.bind(this),l),o.addEventListener("touchend",this.#o.bind(this),l),o.addEventListener("touchcancel",this.#o.bind(this),l),this.#i?.()}if(Ie(t),t.touches.length!==2||this.#n?.()){this.#u=null;return}let[e,n]=t.touches;e.identifier>n.identifier&&([e,n]=[n,e]),this.#u={touch0X:e.screenX,touch0Y:e.screenY,touch1X:n.screenX,touch1Y:n.screenY}}#f(t){if(!this.#u||t.touches.length!==2)return;let[e,n]=t.touches;e.identifier>n.identifier&&([e,n]=[n,e]);let{screenX:s,screenY:o}=e,{screenX:l,screenY:u}=n,d=this.#u,{touch0X:p,touch0Y:m,touch1X:b,touch1Y:v}=d,A=b-p,x=v-m,w=l-s,k=u-o,I=Math.hypot(w,k)||1,P=Math.hypot(A,x)||1;if(!this.#e&&Math.abs(P-I)<=i.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(d.touch0X=s,d.touch0Y=o,d.touch1X=l,d.touch1Y=u,t.preventDefault(),!this.#e){this.#e=!0;return}let M=[(s+l)/2,(o+u)/2];this.#s?.(M,P,I)}#o(t){this.#d.abort(),this.#d=null,this.#l?.(),this.#u&&(t.preventDefault(),this.#u=null,this.#e=!1)}destroy(){this.#c?.abort(),this.#c=null}},Yt=class i{#t=null;#e=null;#n=null;#r=!1;#i=null;#s="";#l=!1;#a=null;#u=null;#c=null;#d=null;#h="";#f=!1;#o=null;#p=!1;#m=!1;#g=!1;#b=null;#x=0;#y=0;#S=null;#T=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#E=!1;#k=i._zIndex++;static _borderLineWidth=-1;static _colorManager=new Vo;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=i.prototype._resizeWithKeyboard,e=Bn.TRANSLATE_SMALL,n=Bn.TRANSLATE_BIG;return Lt(this,"_resizerKeyboardManager",new Un([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-n,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[n,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-n]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,n]}],[["Escape","mac+Escape"],i.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;let{rotation:e,rawDims:{pageWidth:n,pageHeight:s,pageX:o,pageY:l}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,s],this.pageTranslation=[o,l];let[u,d]=this.parentDimensions;this.x=t.x/u,this.y=t.y/d,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Lt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new Wo({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(i._l10n??=t,i._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"}),i._borderLineWidth!==-1)return;let n=getComputedStyle(document.documentElement);i._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){$t("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#E}set _isDraggable(t){this.#E=t,this.div?.classList.toggle("draggable",t)}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.#k}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#B(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#f?this.#f=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,n,s){let[o,l]=this.parentDimensions;[n,s]=this.screenToPageTranslation(n,s),this.x=(t+n)/o,this.y=(e+s)/l,this.fixAndSetPosition()}#P([t,e],n,s){[n,s]=this.screenToPageTranslation(n,s),this.x+=n/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#P(this.parentDimensions,t,e)}translateInPage(t,e){this.#o||=[this.x,this.y,this.width,this.height],this.#P(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#o||=[this.x,this.y,this.width,this.height];let{div:n,parentDimensions:[s,o]}=this;if(this.x+=t/s,this.y+=e/o,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:b,y:v}=this.div.getBoundingClientRect();this.parent.findNewParent(this,b,v)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:l,y:u}=this,[d,p]=this.getBaseTranslation();l+=d,u+=p;let{style:m}=n;m.left=`${(100*l).toFixed(2)}%`,m.top=`${(100*u).toFixed(2)}%`,this._onTranslating(l,u),n.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#o&&(this.#o[0]!==this.x||this.#o[1]!==this.y)}get _hasBeenResized(){return!!this.#o&&(this.#o[2]!==this.width||this.#o[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:n}=i,s=n/t,o=n/e;switch(this.rotation){case 90:return[-s,o];case 180:return[s,o];case 270:return[s,-o];default:return[-s,-o]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[n,s]}=this,{x:o,y:l,width:u,height:d}=this;if(u*=n,d*=s,o*=n,l*=s,this._mustFixPosition)switch(t){case 0:o=Math.max(0,Math.min(n-u,o)),l=Math.max(0,Math.min(s-d,l));break;case 90:o=Math.max(0,Math.min(n-d,o)),l=Math.min(s,Math.max(u,l));break;case 180:o=Math.min(n,Math.max(u,o)),l=Math.min(s,Math.max(d,l));break;case 270:o=Math.min(n,Math.max(d,o)),l=Math.max(0,Math.min(s-u,l));break}this.x=o/=n,this.y=l/=s;let[p,m]=this.getBaseTranslation();o+=p,l+=m,e.left=`${(100*o).toFixed(2)}%`,e.top=`${(100*l).toFixed(2)}%`,this.moveInDOM()}static#A(t,e,n){switch(n){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return i.#A(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return i.#A(t,e,360-this.parentRotation)}#I(t){switch(t){case 90:{let[e,n]=this.pageDimensions;return[0,-e/n,n/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,n]=this.pageDimensions;return[0,e/n,-n/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,n]}=this;return[e*t,n*t]}setDims(t,e){let[n,s]=this.parentDimensions,{style:o}=this.div;o.width=`${(100*t/n).toFixed(2)}%`,this.#l||(o.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){let{style:t}=this.div,{height:e,width:n}=t,s=n.endsWith("%"),o=!this.#l&&e.endsWith("%");if(s&&o)return;let[l,u]=this.parentDimensions;s||(t.width=`${(100*parseFloat(n)/l).toFixed(2)}%`),!this.#l&&!o&&(t.height=`${(100*parseFloat(e)/u).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#C(){if(this.#a)return;this.#a=document.createElement("div"),this.#a.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 n of t){let s=document.createElement("div");this.#a.append(s),s.classList.add("resizer",n),s.setAttribute("data-resizer-name",n),s.addEventListener("pointerdown",this.#O.bind(this,n),{signal:e}),s.addEventListener("contextmenu",$e,{signal:e}),s.tabIndex=-1}this.div.prepend(this.#a)}#O(t,e){e.preventDefault();let{isMac:n}=se.platform;if(e.button!==0||e.ctrlKey&&n)return;this.#n?.toggle(!1);let s=this._isDraggable;this._isDraggable=!1,this.#u=[e.screenX,e.screenY];let o=new AbortController,l=this._uiManager.combinedSignal(o);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#w.bind(this,t),{passive:!0,capture:!0,signal:l}),window.addEventListener("touchmove",Ie,{passive:!1,signal:l}),window.addEventListener("contextmenu",$e,{signal:l}),this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let u=this.parent.div.style.cursor,d=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let p=()=>{o.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=u,this.div.style.cursor=d,this.#_()};window.addEventListener("pointerup",p,{signal:l}),window.addEventListener("blur",p,{signal:l})}#F(t,e,n,s){this.width=n,this.height=s,this.x=t,this.y=e;let[o,l]=this.parentDimensions;this.setDims(o*n,l*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#_(){if(!this.#c)return;let{savedX:t,savedY:e,savedWidth:n,savedHeight:s}=this.#c;this.#c=null;let o=this.x,l=this.y,u=this.width,d=this.height;o===t&&l===e&&u===n&&d===s||this.addCommands({cmd:this.#F.bind(this,o,l,u,d),undo:this.#F.bind(this,t,e,n,s),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#w(t,e){let[n,s]=this.parentDimensions,o=this.x,l=this.y,u=this.width,d=this.height,p=i.MIN_SIZE/n,m=i.MIN_SIZE/s,b=this.#I(this.rotation),v=(X,$)=>[b[0]*X+b[2]*$,b[1]*X+b[3]*$],A=this.#I(360-this.rotation),x=(X,$)=>[A[0]*X+A[2]*$,A[1]*X+A[3]*$],w,k,I=!1,P=!1;switch(t){case"topLeft":I=!0,w=(X,$)=>[0,0],k=(X,$)=>[X,$];break;case"topMiddle":w=(X,$)=>[X/2,0],k=(X,$)=>[X/2,$];break;case"topRight":I=!0,w=(X,$)=>[X,0],k=(X,$)=>[0,$];break;case"middleRight":P=!0,w=(X,$)=>[X,$/2],k=(X,$)=>[0,$/2];break;case"bottomRight":I=!0,w=(X,$)=>[X,$],k=(X,$)=>[0,0];break;case"bottomMiddle":w=(X,$)=>[X/2,$],k=(X,$)=>[X/2,0];break;case"bottomLeft":I=!0,w=(X,$)=>[0,$],k=(X,$)=>[X,0];break;case"middleLeft":P=!0,w=(X,$)=>[0,$/2],k=(X,$)=>[X,$/2];break}let M=w(u,d),N=k(u,d),D=v(...N),U=i._round(o+D[0]),G=i._round(l+D[1]),H=1,W=1,J,q;if(e.fromKeyboard)({deltaX:J,deltaY:q}=e);else{let{screenX:X,screenY:$}=e,[ut,st]=this.#u;[J,q]=this.screenToPageTranslation(X-ut,$-st),this.#u[0]=X,this.#u[1]=$}if([J,q]=x(J/n,q/s),I){let X=Math.hypot(u,d);H=W=Math.max(Math.min(Math.hypot(N[0]-M[0]-J,N[1]-M[1]-q)/X,1/u,1/d),p/u,m/d)}else P?H=Math.max(p,Math.min(1,Math.abs(N[0]-M[0]-J)))/u:W=Math.max(m,Math.min(1,Math.abs(N[1]-M[1]-q)))/d;let dt=i._round(u*H),Q=i._round(d*W);D=v(...k(dt,Q));let ot=U-D[0],ct=G-D[1];this.#o||=[this.x,this.y,this.width,this.height],this.width=dt,this.height=Q,this.x=ot,this.y=ct,this.setDims(n*dt,s*Q),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}async addEditToolbar(){return this._editToolbar||this.#m?this._editToolbar:(this._editToolbar=new Uo(this),this.div.append(this._editToolbar.render()),this.#n&&await this._editToolbar.addAltText(this.#n),this._editToolbar)}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#n?.destroy())}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#n||(js.initialize(i._l10n),this.#n=new js(this),this.#t&&(this.#n.data=this.#t,this.#t=null),await this.addEditToolbar())}get altTextData(){return this.#n?.data}set altTextData(t){this.#n&&(this.#n.data=t)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(t){await this.#n?.setGuessedText(t)}serializeAltText(t){return this.#n?.serialize(t)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#r?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#N();let[t,e]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);let[n,s]=this.getInitialTranslation();return this.translate(n,s),Hs(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#T||=new Vs({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#v.bind(this),onPinching:this.#L.bind(this),onPinchEnd:this.#H.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#v(){this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#L(t,e,n){let o=.7*(n/e)+1-.7;if(o===1)return;let l=this.#I(this.rotation),u=(U,G)=>[l[0]*U+l[2]*G,l[1]*U+l[3]*G],[d,p]=this.parentDimensions,m=this.x,b=this.y,v=this.width,A=this.height,x=i.MIN_SIZE/d,w=i.MIN_SIZE/p;o=Math.max(Math.min(o,1/v,1/A),x/v,w/A);let k=i._round(v*o),I=i._round(A*o);if(k===v&&I===A)return;this.#o||=[m,b,v,A];let P=u(v/2,A/2),M=i._round(m+P[0]),N=i._round(b+P[1]),D=u(k/2,I/2);this.x=M-D[0],this.y=N-D[1],this.width=k,this.height=I,this.setDims(d*k,p*I),this.fixAndSetPosition(),this._onResizing()}#H(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#_()}pointerdown(t){let{isMac:e}=se.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#f=!0,this._isDraggable){this.#V(t);return}this.#j(t)}get isSelected(){return this._uiManager.isSelected(this)}#j(t){let{isMac:e}=se.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#V(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let n=!1,s=new AbortController,o=this._uiManager.combinedSignal(s),l={capture:!0,passive:!1,signal:o},u=p=>{s.abort(),this.#i=null,this.#f=!1,this._uiManager.endDragSession()||this.#j(p),n&&this._onStopDragging()};e&&(this.#x=t.clientX,this.#y=t.clientY,this.#i=t.pointerId,this.#s=t.pointerType,window.addEventListener("pointermove",p=>{n||(n=!0,this._onStartDragging());let{clientX:m,clientY:b,pointerId:v}=p;if(v!==this.#i){Ie(p);return}let[A,x]=this.screenToPageTranslation(m-this.#x,b-this.#y);this.#x=m,this.#y=b,this._uiManager.dragSelectedEditors(A,x)},l),window.addEventListener("touchmove",Ie,l),window.addEventListener("pointerdown",p=>{p.pointerType===this.#s&&(this.#T||p.isPrimary)&&u(p),Ie(p)},l));let d=p=>{if(!this.#i||this.#i===p.pointerId){u(p);return}Ie(p)};window.addEventListener("pointerup",d,{signal:o}),window.addEventListener("blur",d,{signal:o})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,n){t.changeParent(this),this.x=e,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,n=this.rotation){let s=this.parentScale,[o,l]=this.pageDimensions,[u,d]=this.pageTranslation,p=t/s,m=e/s,b=this.x*o,v=this.y*l,A=this.width*o,x=this.height*l;switch(n){case 0:return[b+p+u,l-v-m-x+d,b+p+A+u,l-v-m+d];case 90:return[b+m+u,l-v+p+d,b+m+x+u,l-v+p+A+d];case 180:return[b-p-A+u,l-v+m+d,b-p+u,l-v+m+x+d];case 270:return[b-m-x+u,l-v-p-A+d,b-m+u,l-v-p+d];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[n,s,o,l]=t,u=o-n,d=l-s;switch(this.rotation){case 0:return[n,e-l,u,d];case 90:return[n,e-s,d,u];case 180:return[o,e-s,u,d];case 270:return[o,e-l,d,u];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){this.#m=!0}disableEditMode(){this.#m=!1}isInEditMode(){return this.#m}shouldGetKeyboardEvents(){return this.#g}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:n,right:s}=this.getClientDimensions(),{innerHeight:o,innerWidth:l}=window;return e<l&&s>0&&t<o&&n>0}#N(){if(this.#d||!this.div)return;this.#d=new AbortController;let t=this._uiManager.combinedSignal(this.#d);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#N()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){$t("An editor must be serializable")}static async deserialize(t,e,n){let s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:n});s.rotation=t.rotation,s.#t=t.accessibilityData;let[o,l]=s.pageDimensions,[u,d,p,m]=s.getRectInCurrentCoords(t.rect,l);return s.x=u/o,s.y=d/l,s.width=p/o,s.height=m/l,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#d?.abort(),this.#d=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#b&&(clearTimeout(this.#b),this.#b=null),this.#B(),this.removeEditToolbar(),this.#S){for(let t of this.#S.values())clearTimeout(t);this.#S=null}this.parent=null,this.#T?.destroy(),this.#T=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#C(),this.#a.classList.remove("hidden"),Hs(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#c={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#a.children;if(!this.#e){this.#e=Array.from(e);let l=this.#D.bind(this),u=this.#U.bind(this),d=this._uiManager._signal;for(let p of this.#e){let m=p.getAttribute("data-resizer-name");p.setAttribute("role","spinbutton"),p.addEventListener("keydown",l,{signal:d}),p.addEventListener("blur",u,{signal:d}),p.addEventListener("focus",this.#W.bind(this,m),{signal:d}),p.setAttribute("data-l10n-id",i._l10nResizer[m])}}let n=this.#e[0],s=0;for(let l of e){if(l===n)break;s++}let o=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(o!==s){if(o<s)for(let u=0;u<s-o;u++)this.#a.append(this.#a.firstChild);else if(o>s)for(let u=0;u<o-s;u++)this.#a.firstChild.before(this.#a.lastChild);let l=0;for(let u of e){let p=this.#e[l++].getAttribute("data-resizer-name");u.setAttribute("data-l10n-id",i._l10nResizer[p])}}this.#M(0),this.#g=!0,this.#a.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#D(t){i._resizerKeyboardManager.exec(this,t)}#U(t){this.#g&&t.relatedTarget?.parentNode!==this.#a&&this.#B()}#W(t){this.#h=this.#g?t:""}#M(t){if(this.#e)for(let e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#g&&this.#w(this.#h,{deltaX:t,deltaY:e,fromKeyboard:!0})}#B(){this.#g=!1,this.#M(-1),this.#_()}_stopResizingWithKeyboard(){this.#B(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)}unselect(){this.#a?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#p}set isEditing(t){this.#p=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#l=!0;let n=t/e,{style:s}=this.div;s.aspectRatio=n,s.height="auto"}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.#S||=new Map;let{action:n}=t,s=this.#S.get(n);s&&clearTimeout(s),s=setTimeout(()=>{this._reportTelemetry(t),this.#S.delete(n),this.#S.size===0&&(this.#S=null)},i._telemetryTimeout),this.#S.set(n,s);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(){this.div&&(this.div.tabIndex=0),this.#r=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#r=!0}renderAnnotationElement(t){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 n=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),n.before(e)}return e}resetAnnotationElement(t){let{firstChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}},Wo=class extends Yt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},Bu=3285377520,Fe=4294901760,Qe=65535,Ws=class{constructor(t){this.h1=t?t&4294967295:Bu,this.h2=t?t&4294967295:Bu}update(t){let e,n;if(typeof t=="string"){e=new Uint8Array(t.length*2),n=0;for(let w=0,k=t.length;w<k;w++){let I=t.charCodeAt(w);I<=255?e[n++]=I:(e[n++]=I>>>8,e[n++]=I&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),n=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");let s=n>>2,o=n-s*4,l=new Uint32Array(e.buffer,0,s),u=0,d=0,p=this.h1,m=this.h2,b=3432918353,v=461845907,A=b&Qe,x=v&Qe;for(let w=0;w<s;w++)w&1?(u=l[w],u=u*b&Fe|u*A&Qe,u=u<<15|u>>>17,u=u*v&Fe|u*x&Qe,p^=u,p=p<<13|p>>>19,p=p*5+3864292196):(d=l[w],d=d*b&Fe|d*A&Qe,d=d<<15|d>>>17,d=d*v&Fe|d*x&Qe,m^=d,m=m<<13|m>>>19,m=m*5+3864292196);switch(u=0,o){case 3:u^=e[s*4+2]<<16;case 2:u^=e[s*4+1]<<8;case 1:u^=e[s*4],u=u*b&Fe|u*A&Qe,u=u<<15|u>>>17,u=u*v&Fe|u*x&Qe,s&1?p^=u:m^=u}this.h1=p,this.h2=m}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Fe|t*36045&Qe,e=e*4283543511&Fe|((e<<16|t>>>16)*2950163797&Fe)>>>16,t^=e>>>1,t=t*444984403&Fe|t*60499&Qe,e=e*3301882366&Fe|((e<<16|t>>>16)*3120437893&Fe)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}},$o=Object.freeze({map:null,hash:"",transfer:void 0}),Dr=class{#t=!1;#e=null;#n=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){let n=this.#n.get(t);return n===void 0?e:Object.assign(e,n)}getRawValue(t){return this.#n.get(t)}remove(t){if(this.#n.delete(t),this.#n.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(let e of this.#n.values())if(e instanceof Yt)return;this.onAnnotationEditor(null)}}setValue(t,e){let n=this.#n.get(t),s=!1;if(n!==void 0)for(let[o,l]of Object.entries(e))n[o]!==l&&(s=!0,n[o]=l);else s=!0,this.#n.set(t,e);s&&this.#r(),e instanceof Yt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#n.has(t)}getAll(){return this.#n.size>0?sl(this.#n):null}setAll(t){for(let[e,n]of Object.entries(t))this.setValue(e,n)}get size(){return this.#n.size}#r(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new $s(this)}get serializable(){if(this.#n.size===0)return $o;let t=new Map,e=new Ws,n=[],s=Object.create(null),o=!1;for(let[l,u]of this.#n){let d=u instanceof Yt?u.serialize(!1,s):u;d&&(t.set(l,d),e.update(`${l}:${JSON.stringify(d)}`),o||=!!d.bitmap)}if(o)for(let l of t.values())l.bitmap&&n.push(l.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:n}:$o}get editorStats(){let t=null,e=new Map;for(let n of this.#n.values()){if(!(n instanceof Yt))continue;let s=n.telemetryFinalData;if(!s)continue;let{type:o}=s;e.has(o)||e.set(o,Object.getPrototypeOf(n).constructor),t||=Object.create(null);let l=t[o]||=new Map;for(let[u,d]of Object.entries(s)){if(u==="type")continue;let p=l.get(u);p||(p=new Map,l.set(u,p));let m=p.get(d)??0;p.set(d,m+1)}}for(let[n,s]of e)t[n]=s.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){this.#e=null}get modifiedIds(){if(this.#e)return this.#e;let t=[];for(let e of this.#n.values())!(e instanceof Yt)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return this.#e={ids:new Set(t),hash:t.join(",")}}},$s=class extends Dr{#t;constructor(t){super();let{map:e,hash:n,transfer:s}=t.serializable,o=structuredClone(e,s?{transfer:s}:null);this.#t={map:o,hash:n,transfer:s}}get print(){$t("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return Lt(this,"modifiedIds",{ids:new Set,hash:""})}},zo=class{#t=new Set;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){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||this.#t.has(t.loadedName))){if(ee(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:n,src:s,style:o}=t,l=new FontFace(n,s,o);this.addNativeFontFace(l);try{await l.load(),this.#t.add(n),e?.(t)}catch{Pt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(l)}return}$t("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 n=t.createNativeFontFace();if(n){this.addNativeFontFace(n);try{await n.loaded}catch(s){throw Pt(`Failed to load font '${n.family}': '${s}'.`),t.disableFontFace=!0,s}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(n=>{let s=this._queueLoadingCallback(n);this._prepareFontLoadEvent(t,s)})}}get isFontLoadingAPISupported(){let t=!!this._document?.fonts;return Lt(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(he||typeof navigator<"u"&&typeof navigator?.userAgent=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),Lt(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(ee(!s.done,"completeRequest() cannot be called twice."),s.done=!0;n.length>0&&n[0].done;){let o=n.shift();setTimeout(o.callback,0)}}let{loadingRequests:n}=this,s={done:!1,complete:e,callback:t};return n.push(s),s}get _loadTestFont(){let t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return Lt(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function n(N,D){return N.charCodeAt(D)<<24|N.charCodeAt(D+1)<<16|N.charCodeAt(D+2)<<8|N.charCodeAt(D+3)&255}function s(N,D,U,G){let H=N.substring(0,D),W=N.substring(D+U);return H+G+W}let o,l,u=this._document.createElement("canvas");u.width=1,u.height=1;let d=u.getContext("2d"),p=0;function m(N,D){if(++p>30){Pt("Load test font never loaded."),D();return}if(d.font="30px "+N,d.fillText(".",0,20),d.getImageData(0,0,1,1).data[3]>0){D();return}setTimeout(m.bind(null,N,D))}let b=`lt${Date.now()}${this.loadTestFontId++}`,v=this._loadTestFont;v=s(v,976,b.length,b);let x=16,w=1482184792,k=n(v,x);for(o=0,l=b.length-3;o<l;o+=4)k=k-w+n(b,o)|0;o<b.length&&(k=k-w+n(b+"XXX",o)|0),v=s(v,x,4,dy(k));let I=`url(data:font/opentype;base64,${btoa(v)});`,P=`@font-face {font-family:"${b}";src:${I}}`;this.insertRule(P);let M=this._document.createElement("div");M.style.visibility="hidden",M.style.width=M.style.height="10px",M.style.position="absolute",M.style.top=M.style.left="0px";for(let N of[t.loadedName,b]){let D=this._document.createElement("span");D.textContent="Hi",D.style.fontFamily=N,M.append(D)}this._document.body.append(M),m(b,()=>{M.remove(),e.complete()})}},Xo=class{constructor(t,{disableFontFace:e=!1,fontExtraProperties:n=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(let o in t)this[o]=t[o];this.disableFontFace=e===!0,this.fontExtraProperties=n===!0,this._inspectFont=s}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};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(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,${yy(this.data)});`,e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];let n=this.loadedName+"_path_"+e,s;try{s=t.get(n)}catch(l){Pt(`getPathGenerator - ignoring character: "${l}".`)}let o=new Path2D(s||"");return this.fontExtraProperties||t.delete(n),this.compiledGlyphs[e]=o}},Ms={DATA:1,ERROR:2},te={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};Fn=class{#t=new AbortController;constructor(t,e,n){this.sourceName=t,this.targetName=e,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),n.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#r(t);return}if(t.callback){let n=t.callbackId,s=this.callbackCapabilities[n];if(!s)throw new Error(`Cannot resolve callback ${n}`);if(delete this.callbackCapabilities[n],t.callback===Ms.DATA)s.resolve(t.data);else if(t.callback===Ms.ERROR)s.reject(Se(t.reason));else throw new Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let n=this.sourceName,s=t.sourceName,o=this.comObj;Promise.try(e,t.data).then(function(l){o.postMessage({sourceName:n,targetName:s,callback:Ms.DATA,callbackId:t.callbackId,data:l})},function(l){o.postMessage({sourceName:n,targetName:s,callback:Ms.ERROR,callbackId:t.callbackId,reason:Se(l)})});return}if(t.streamId){this.#n(t);return}e(t.data)}on(t,e){let n=this.actionHandler;if(n[t])throw new Error(`There is already an actionName called "${t}"`);n[t]=e}send(t,e,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},n)}sendWithPromise(t,e,n){let s=this.callbackId++,o=Promise.withResolvers();this.callbackCapabilities[s]=o;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},n)}catch(l){o.reject(l)}return o.promise}sendWithStream(t,e,n,s){let o=this.streamId++,l=this.sourceName,u=this.targetName,d=this.comObj;return new ReadableStream({start:p=>{let m=Promise.withResolvers();return this.streamControllers[o]={controller:p,startCall:m,pullCall:null,cancelCall:null,isClosed:!1},d.postMessage({sourceName:l,targetName:u,action:t,streamId:o,data:e,desiredSize:p.desiredSize},s),m.promise},pull:p=>{let m=Promise.withResolvers();return this.streamControllers[o].pullCall=m,d.postMessage({sourceName:l,targetName:u,stream:te.PULL,streamId:o,desiredSize:p.desiredSize}),m.promise},cancel:p=>{ee(p instanceof Error,"cancel must have a valid reason");let m=Promise.withResolvers();return this.streamControllers[o].cancelCall=m,this.streamControllers[o].isClosed=!0,d.postMessage({sourceName:l,targetName:u,stream:te.CANCEL,streamId:o,reason:Se(p)}),m.promise}},n)}#n(t){let e=t.streamId,n=this.sourceName,s=t.sourceName,o=this.comObj,l=this,u=this.actionHandler[t.action],d={enqueue(p,m=1,b){if(this.isCancelled)return;let v=this.desiredSize;this.desiredSize-=m,v>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),o.postMessage({sourceName:n,targetName:s,stream:te.ENQUEUE,streamId:e,chunk:p},b)},close(){this.isCancelled||(this.isCancelled=!0,o.postMessage({sourceName:n,targetName:s,stream:te.CLOSE,streamId:e}),delete l.streamSinks[e])},error(p){ee(p instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,o.postMessage({sourceName:n,targetName:s,stream:te.ERROR,streamId:e,reason:Se(p)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};d.sinkCapability.resolve(),d.ready=d.sinkCapability.promise,this.streamSinks[e]=d,Promise.try(u,t.data,d).then(function(){o.postMessage({sourceName:n,targetName:s,stream:te.START_COMPLETE,streamId:e,success:!0})},function(p){o.postMessage({sourceName:n,targetName:s,stream:te.START_COMPLETE,streamId:e,reason:Se(p)})})}#r(t){let e=t.streamId,n=this.sourceName,s=t.sourceName,o=this.comObj,l=this.streamControllers[e],u=this.streamSinks[e];switch(t.stream){case te.START_COMPLETE:t.success?l.startCall.resolve():l.startCall.reject(Se(t.reason));break;case te.PULL_COMPLETE:t.success?l.pullCall.resolve():l.pullCall.reject(Se(t.reason));break;case te.PULL:if(!u){o.postMessage({sourceName:n,targetName:s,stream:te.PULL_COMPLETE,streamId:e,success:!0});break}u.desiredSize<=0&&t.desiredSize>0&&u.sinkCapability.resolve(),u.desiredSize=t.desiredSize,Promise.try(u.onPull||Gu).then(function(){o.postMessage({sourceName:n,targetName:s,stream:te.PULL_COMPLETE,streamId:e,success:!0})},function(p){o.postMessage({sourceName:n,targetName:s,stream:te.PULL_COMPLETE,streamId:e,reason:Se(p)})});break;case te.ENQUEUE:if(ee(l,"enqueue should have stream controller"),l.isClosed)break;l.controller.enqueue(t.chunk);break;case te.CLOSE:if(ee(l,"close should have stream controller"),l.isClosed)break;l.isClosed=!0,l.controller.close(),this.#i(l,e);break;case te.ERROR:ee(l,"error should have stream controller"),l.controller.error(Se(t.reason)),this.#i(l,e);break;case te.CANCEL_COMPLETE:t.success?l.cancelCall.resolve():l.cancelCall.reject(Se(t.reason)),this.#i(l,e);break;case te.CANCEL:if(!u)break;let d=Se(t.reason);Promise.try(u.onCancel||Gu,d).then(function(){o.postMessage({sourceName:n,targetName:s,stream:te.CANCEL_COMPLETE,streamId:e,success:!0})},function(p){o.postMessage({sourceName:n,targetName:s,stream:te.CANCEL_COMPLETE,streamId:e,reason:Se(p)})}),u.sinkCapability.reject(d),u.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#i(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}},zs=class{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");let n=this._createCanvas(t,e);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,n){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||n<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=n}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){$t("Abstract method `_createCanvas` called.")}},Yo=class extends zs{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let n=this._document.createElement("canvas");return n.width=t,n.height=e,n}},Xs=class{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");let e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(n=>({cMapData:n,isCompressed:this.isCompressed})).catch(n=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){$t("Abstract method `_fetch` called.")}},Ys=class extends Xs{async _fetch(t){let e=await vi(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):yi(e)}},SA=Dt(4520),Ks=class{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,n,s,o){return"none"}destroy(t=!1){}},Ko=class extends Ks{#t;#e;#n;#r;#i;#s;#l=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#r=t,this.#i=e}get#a(){return this.#e||=new Map}get#u(){return this.#s||=new Map}get#c(){if(!this.#n){let t=this.#i.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;let n=this.#i.createElementNS(sn,"svg");n.setAttribute("width",0),n.setAttribute("height",0),this.#n=this.#i.createElementNS(sn,"defs"),t.append(n),n.append(this.#n),this.#i.body.append(t)}return this.#n}#d(t){if(t.length===1){let d=t[0],p=new Array(256);for(let b=0;b<256;b++)p[b]=d[b]/255;let m=p.join(",");return[m,m,m]}let[e,n,s]=t,o=new Array(256),l=new Array(256),u=new Array(256);for(let d=0;d<256;d++)o[d]=e[d]/255,l[d]=n[d]/255,u[d]=s[d]/255;return[o.join(","),l.join(","),u.join(",")]}#h(t){if(this.#t===void 0){this.#t="";let e=this.#i.URL;e!==this.#i.baseURI&&(xi(e)?Pt('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=e.split("#",1)[0])}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#a.get(t);if(e)return e;let[n,s,o]=this.#d(t),l=t.length===1?n:`${n}${s}${o}`;if(e=this.#a.get(l),e)return this.#a.set(t,e),e;let u=`g_${this.#r}_transfer_map_${this.#l++}`,d=this.#h(u);this.#a.set(t,d),this.#a.set(l,d);let p=this.#p(u);return this.#g(n,s,o,p),d}addHCMFilter(t,e){let n=`${t}-${e}`,s="base",o=this.#u.get(s);if(o?.key===n||(o?(o.filter?.remove(),o.key=n,o.url="none",o.filter=null):(o={key:n,url:"none",filter:null},this.#u.set(s,o)),!t||!e))return o.url;let l=this.#x(t);t=xt.makeHexColor(...l);let u=this.#x(e);if(e=xt.makeHexColor(...u),this.#c.style.color="",t==="#000000"&&e==="#ffffff"||t===e)return o.url;let d=new Array(256);for(let A=0;A<=255;A++){let x=A/255;d[A]=x<=.03928?x/12.92:((x+.055)/1.055)**2.4}let p=d.join(","),m=`g_${this.#r}_hcm_filter`,b=o.filter=this.#p(m);this.#g(p,p,p,b),this.#o(b);let v=(A,x)=>{let w=l[A]/255,k=u[A]/255,I=new Array(x+1);for(let P=0;P<=x;P++)I[P]=w+P/x*(k-w);return I.join(",")};return this.#g(v(0,5),v(1,5),v(2,5),b),o.url=this.#h(m),o.url}addAlphaFilter(t){let e=this.#a.get(t);if(e)return e;let[n]=this.#d([t]),s=`alpha_${n}`;if(e=this.#a.get(s),e)return this.#a.set(t,e),e;let o=`g_${this.#r}_alpha_map_${this.#l++}`,l=this.#h(o);this.#a.set(t,l),this.#a.set(s,l);let u=this.#p(o);return this.#b(n,u),l}addLuminosityFilter(t){let e=this.#a.get(t||"luminosity");if(e)return e;let n,s;if(t?([n]=this.#d([t]),s=`luminosity_${n}`):s="luminosity",e=this.#a.get(s),e)return this.#a.set(t,e),e;let o=`g_${this.#r}_luminosity_map_${this.#l++}`,l=this.#h(o);this.#a.set(t,l),this.#a.set(s,l);let u=this.#p(o);return this.#f(u),t&&this.#b(n,u),l}addHighlightHCMFilter(t,e,n,s,o){let l=`${e}-${n}-${s}-${o}`,u=this.#u.get(t);if(u?.key===l||(u?(u.filter?.remove(),u.key=l,u.url="none",u.filter=null):(u={key:l,url:"none",filter:null},this.#u.set(t,u)),!e||!n))return u.url;let[d,p]=[e,n].map(this.#x.bind(this)),m=Math.round(.2126*d[0]+.7152*d[1]+.0722*d[2]),b=Math.round(.2126*p[0]+.7152*p[1]+.0722*p[2]),[v,A]=[s,o].map(this.#x.bind(this));b<m&&([m,b,v,A]=[b,m,A,v]),this.#c.style.color="";let x=(I,P,M)=>{let N=new Array(256),D=(b-m)/M,U=I/255,G=(P-I)/(255*M),H=0;for(let W=0;W<=M;W++){let J=Math.round(m+W*D),q=U+W*G;for(let dt=H;dt<=J;dt++)N[dt]=q;H=J+1}for(let W=H;W<256;W++)N[W]=N[H-1];return N.join(",")},w=`g_${this.#r}_hcm_${t}_filter`,k=u.filter=this.#p(w);return this.#o(k),this.#g(x(v[0],A[0],5),x(v[1],A[1],5),x(v[2],A[2],5),k),u.url=this.#h(w),u.url}destroy(t=!1){t&&this.#s?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#e?.clear(),this.#e=null,this.#s?.clear(),this.#s=null,this.#l=0)}#f(t){let e=this.#i.createElementNS(sn,"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)}#o(t){let e=this.#i.createElementNS(sn,"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)}#p(t){let e=this.#i.createElementNS(sn,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#c.append(e),e}#m(t,e,n){let s=this.#i.createElementNS(sn,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",n),t.append(s)}#g(t,e,n,s){let o=this.#i.createElementNS(sn,"feComponentTransfer");s.append(o),this.#m(o,"feFuncR",t),this.#m(o,"feFuncG",e),this.#m(o,"feFuncB",n)}#b(t,e){let n=this.#i.createElementNS(sn,"feComponentTransfer");e.append(n),this.#m(n,"feFuncA",t)}#x(t){return this.#c.style.color=t,al(getComputedStyle(this.#c).getPropertyValue("color"))}},Zs=class{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(n=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){$t("Abstract method `_fetch` called.")}},Qs=class extends Zs{async _fetch(t){let e=await vi(t,"arraybuffer");return new Uint8Array(e)}};if(he){let i;try{let t=process.getBuiltinModule("module").createRequire(__import_meta_url__);try{i=t("@napi-rs/canvas")}catch(e){Pt(`Cannot load "@napi-rs/canvas" package: "${e}".`)}}catch(t){Pt(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(i?.DOMMatrix?globalThis.DOMMatrix=i.DOMMatrix:Pt("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.ImageData||(i?.ImageData?globalThis.ImageData=i.ImageData:Pt("Cannot polyfill `ImageData`, rendering may be broken.")),globalThis.Path2D||(i?.Path2D?globalThis.Path2D=i.Path2D:Pt("Cannot polyfill `Path2D`, rendering may be broken."))}Zo=class extends Ks{},Qo=class extends zs{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(__import_meta_url__)("@napi-rs/canvas").createCanvas(t,e)}},Jo=class extends Xs{async _fetch(t){return th(t)}},qo=class extends Zs{async _fetch(t){return th(t)}},ue={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};_r=class{getPattern(){$t("Abstract method `getPattern` called.")}},ea=class extends _r{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],this.matrix=null}_createGradient(t){let e;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let n of this._colorStops)e.addColorStop(n[0],n[1]);return e}getPattern(t,e,n,s){let o;if(s===ue.STROKE||s===ue.FILL){let l=e.current.getClippedPathBoundingBox(s,Xt(t))||[0,0,0,0],u=Math.ceil(l[2]-l[0])||1,d=Math.ceil(l[3]-l[1])||1,p=e.cachedCanvases.getCanvas("pattern",u,d),m=p.context;m.clearRect(0,0,m.canvas.width,m.canvas.height),m.beginPath(),m.rect(0,0,m.canvas.width,m.canvas.height),m.translate(-l[0],-l[1]),n=xt.transform(n,[1,0,0,1,l[0],l[1]]),m.transform(...e.baseTransform),this.matrix&&m.transform(...this.matrix),ta(m,this._bbox),m.fillStyle=this._createGradient(m),m.fill(),o=t.createPattern(p.canvas,"no-repeat");let b=new DOMMatrix(n);o.setTransform(b)}else ta(t,this._bbox),o=this._createGradient(t);return o}};na=class extends _r{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,n){let u=Math.floor(this._bounds[0]),d=Math.floor(this._bounds[1]),p=Math.ceil(this._bounds[2])-u,m=Math.ceil(this._bounds[3])-d,b=Math.min(Math.ceil(Math.abs(p*t[0]*1.1)),3e3),v=Math.min(Math.ceil(Math.abs(m*t[1]*1.1)),3e3),A=p/b,x=m/v,w={coords:this._coords,colors:this._colors,offsetX:-u,offsetY:-d,scaleX:1/A,scaleY:1/x},k=b+4,I=v+4,P=n.getCanvas("mesh",k,I),M=P.context,N=M.createImageData(b,v);if(e){let U=N.data;for(let G=0,H=U.length;G<H;G+=4)U[G]=e[0],U[G+1]=e[1],U[G+2]=e[2],U[G+3]=255}for(let U of this._figures)Ty(N,U,w);return M.putImageData(N,2,2),{canvas:P.canvas,offsetX:u-2*A,offsetY:d-2*x,scaleX:A,scaleY:x}}getPattern(t,e,n,s){ta(t,this._bbox);let o;if(s===ue.SHADING)o=xt.singularValueDecompose2dScale(Xt(t));else if(o=xt.singularValueDecompose2dScale(e.baseTransform),this.matrix){let u=xt.singularValueDecompose2dScale(this.matrix);o=[o[0]*u[0],o[1]*u[1]]}let l=this._createMeshCanvas(o,s===ue.SHADING?null:this._background,e.cachedCanvases);return s!==ue.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(l.offsetX,l.offsetY),t.scale(l.scaleX,l.scaleY),t.createPattern(l.canvas,"no-repeat")}},ra=class extends _r{getPattern(){return"hotpink"}};Hu={COLORED:1,UNCOLORED:2},sa=class i{static MAX_PATTERN_SIZE=3e3;constructor(t,e,n,s,o){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.color=e,this.ctx=n,this.canvasGraphicsFactory=s,this.baseTransform=o}createPatternCanvas(t){let{bbox:e,operatorList:n,paintType:s,tilingType:o,color:l,canvasGraphicsFactory:u}=this,{xstep:d,ystep:p}=this;d=Math.abs(d),p=Math.abs(p),bi("TilingType: "+o);let m=e[0],b=e[1],v=e[2],A=e[3],x=v-m,w=A-b,k=xt.singularValueDecompose2dScale(this.matrix),I=xt.singularValueDecompose2dScale(this.baseTransform),P=k[0]*I[0],M=k[1]*I[1],N=x,D=w,U=!1,G=!1,H=Math.ceil(d*P),W=Math.ceil(p*M),J=Math.ceil(x*P),q=Math.ceil(w*M);H>=J?N=d:U=!0,W>=q?D=p:G=!0;let dt=this.getSizeAndScale(N,this.ctx.canvas.width,P),Q=this.getSizeAndScale(D,this.ctx.canvas.height,M),ot=t.cachedCanvases.getCanvas("pattern",dt.size,Q.size),ct=ot.context,X=u.createCanvasGraphics(ct);if(X.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(X,s,l),ct.translate(-dt.scale*m,-Q.scale*b),X.transform(dt.scale,0,0,Q.scale,0,0),ct.save(),this.clipBbox(X,m,b,v,A),X.baseTransform=Xt(X.ctx),X.executeOperatorList(n),X.endDrawing(),ct.restore(),U||G){let $=ot.canvas;U&&(N=d),G&&(D=p);let ut=this.getSizeAndScale(N,this.ctx.canvas.width,P),st=this.getSizeAndScale(D,this.ctx.canvas.height,M),St=ut.size,Ct=st.size,wt=t.cachedCanvases.getCanvas("pattern-workaround",St,Ct),Et=wt.context,Vt=U?Math.floor(x/d):0,Ut=G?Math.floor(w/p):0;for(let at=0;at<=Vt;at++)for(let _=0;_<=Ut;_++)Et.drawImage($,St*at,Ct*_,St,Ct,0,0,St,Ct);return{canvas:wt.canvas,scaleX:ut.scale,scaleY:st.scale,offsetX:m,offsetY:b}}return{canvas:ot.canvas,scaleX:dt.scale,scaleY:Q.scale,offsetX:m,offsetY:b}}getSizeAndScale(t,e,n){let s=Math.max(i.MAX_PATTERN_SIZE,e),o=Math.ceil(t*n);return o>=s?o=s:n=o/t,{scale:n,size:o}}clipBbox(t,e,n,s,o){let l=s-e,u=o-n;t.ctx.rect(e,n,l,u),t.current.updateRectMinMax(Xt(t.ctx),[e,n,s,o]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,n){let s=t.ctx,o=t.current;switch(e){case Hu.COLORED:let l=this.ctx;s.fillStyle=l.fillStyle,s.strokeStyle=l.strokeStyle,o.fillColor=l.fillStyle,o.strokeColor=l.strokeStyle;break;case Hu.UNCOLORED:let u=xt.makeHexColor(n[0],n[1],n[2]);s.fillStyle=u,s.strokeStyle=u,o.fillColor=u,o.strokeColor=u;break;default:throw new No(`Unsupported paint type: ${e}`)}}getPattern(t,e,n,s){let o=n;s!==ue.SHADING&&(o=xt.transform(o,e.baseTransform),this.matrix&&(o=xt.transform(o,this.matrix)));let l=this.createPatternCanvas(e),u=new DOMMatrix(o);u=u.translate(l.offsetX,l.offsetY),u=u.scale(1/l.scaleX,1/l.scaleY);let d=t.createPattern(l.canvas,"repeat");return d.setTransform(u),d}};ju=16,Vu=100,Cy=15,Wu=10,$u=1e3,Ae=16;ia=class{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,n){let s;return this.cache[t]!==void 0?(s=this.cache[t],this.canvasFactory.reset(s,e,n)):(s=this.canvasFactory.create(e,n),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(let t in this.cache){let e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}};Js=class{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Ju,this.textMatrixScale=1,this.fontMatrix=_o,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=ce.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,n){[e,n]=xt.applyTransform([e,n],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(t,e){let n=xt.applyTransform(e,t),s=xt.applyTransform(e.slice(2),t),o=xt.applyTransform([e[0],e[3]],t),l=xt.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,n[0],s[0],o[0],l[0]),this.minY=Math.min(this.minY,n[1],s[1],o[1],l[1]),this.maxX=Math.max(this.maxX,n[0],s[0],o[0],l[0]),this.maxY=Math.max(this.maxY,n[1],s[1],o[1],l[1])}updateScalingPathMinMax(t,e){xt.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,n,s,o,l,u,d,p,m){let b=xt.bezierBoundingBox(e,n,s,o,l,u,d,p,m);m||this.updateRectMinMax(t,b)}getPathBoundingBox(t=ue.FILL,e=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(t===ue.STROKE){e||$t("Stroke bounding box must include transform.");let s=xt.singularValueDecompose2dScale(e),o=s[0]*this.lineWidth/2,l=s[1]*this.lineWidth/2;n[0]-=o,n[1]-=l,n[2]+=o,n[3]+=l}return n}updateClipFromPath(){let t=xt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=ue.FILL,e=null){return xt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}};Py=["butt","round","square"],Ry=["miter","round","bevel"],Oy={},Ku={},ir=class i{constructor(t,e,n,s,o,{optionalContentConfig:l,markedContentStack:u=null},d,p){this.ctx=t,this.current=new Js(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=n,this.canvasFactory=s,this.filterFactory=o,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=u||[],this.optionalContentConfig=l,this.cachedCanvases=new ia(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=d,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=p,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return typeof t=="string"?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:n=!1,background:s=null}){let o=this.ctx.canvas.width,l=this.ctx.canvas.height,u=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,o,l),this.ctx.fillStyle=u,n){let d=this.cachedCanvases.getCanvas("transparent",o,l);this.compositeCtx=this.ctx,this.transparentCanvas=d.canvas,this.ctx=d.context,this.ctx.save(),this.ctx.transform(...Xt(this.compositeCtx))}this.ctx.save(),Fs(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=Xt(this.ctx)}executeOperatorList(t,e,n,s){let o=t.argsArray,l=t.fnArray,u=e||0,d=o.length;if(d===u)return u;let p=d-u>Wu&&typeof n=="function",m=p?Date.now()+Cy:0,b=0,v=this.commonObjs,A=this.objs,x;for(;;){if(s!==void 0&&u===s.nextBreakPoint)return s.breakIt(u,n),u;if(x=l[u],x!==We.dependency)this[x].apply(this,o[u]);else for(let w of o[u]){let k=w.startsWith("g_")?v:A;if(!k.has(w))return k.get(w,n),u}if(u++,u===d)return u;if(p&&++b>Wu){if(Date.now()>m)return n(),u;b=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let t of this._cachedBitmapsMap.values()){for(let e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){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 n=t.width??t.displayWidth,s=t.height??t.displayHeight,o=Math.max(Math.hypot(e[0],e[1]),1),l=Math.max(Math.hypot(e[2],e[3]),1),u=n,d=s,p="prescale1",m,b;for(;o>2&&u>1||l>2&&d>1;){let v=u,A=d;o>2&&u>1&&(v=u>=16384?Math.floor(u/2)-1||1:Math.ceil(u/2),o/=u/v),l>2&&d>1&&(A=d>=16384?Math.floor(d/2)-1||1:Math.ceil(d)/2,l/=d/A),m=this.cachedCanvases.getCanvas(p,v,A),b=m.context,b.clearRect(0,0,v,A),b.drawImage(t,0,0,u,d,0,0,v,A),t=m.canvas,u=v,d=A,p=p==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:u,paintHeight:d}}_createMaskCanvas(t){let e=this.ctx,{width:n,height:s}=t,o=this.current.fillColor,l=this.current.patternFill,u=Xt(e),d,p,m,b;if((t.bitmap||t.data)&&t.count>1){let H=t.bitmap||t.data.buffer;p=JSON.stringify(l?u:[u.slice(0,4),o]),d=this._cachedBitmapsMap.get(H),d||(d=new Map,this._cachedBitmapsMap.set(H,d));let W=d.get(p);if(W&&!l){let J=Math.round(Math.min(u[0],u[2])+u[4]),q=Math.round(Math.min(u[1],u[3])+u[5]);return{canvas:W,offsetX:J,offsetY:q}}m=W}m||(b=this.cachedCanvases.getCanvas("maskCanvas",n,s),Xu(b.context,t));let v=xt.transform(u,[1/n,0,0,-1/s,0,0]);v=xt.transform(v,[1,0,0,1,0,-s]);let[A,x,w,k]=xt.getAxialAlignedBoundingBox([0,0,n,s],v),I=Math.round(w-A)||1,P=Math.round(k-x)||1,M=this.cachedCanvases.getCanvas("fillCanvas",I,P),N=M.context,D=A,U=x;N.translate(-D,-U),N.transform(...v),m||(m=this._scaleImage(b.canvas,Ze(N)),m=m.img,d&&l&&d.set(p,m)),N.imageSmoothingEnabled=Yu(Xt(N),t.interpolate),Ls(N,m,0,0,m.width,m.height,0,0,n,s),N.globalCompositeOperation="source-in";let G=xt.transform(Ze(N),[1,0,0,1,-D,-U]);return N.fillStyle=l?o.getPattern(e,this,G,ue.FILL):o,N.fillRect(0,0,n,s),d&&!l&&(this.cachedCanvases.delete("fillCanvas"),d.set(p,M.canvas)),{canvas:M.canvas,offsetX:Math.round(D),offsetY:Math.round(U)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Py[t]}setLineJoin(t){this.ctx.lineJoin=Ry[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){let n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(t),n.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(let[e,n]of t)switch(e){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");let t=this.ctx.canvas.width,e=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(n,t,e);this.suspendedCtx=this.ctx,this.ctx=s.context;let o=this.ctx;o.setTransform(...Xt(this.suspendedCtx)),Cr(this.suspendedCtx,o),ky(o,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Cr(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let e=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,e,this.ctx,t),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,n,s){let o=s[0],l=s[1],u=s[2]-o,d=s[3]-l;u===0||d===0||(this.genericComposeSMask(e.context,n,u,d,e.subtype,e.backdrop,e.transferMap,o,l,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(n.canvas,0,0),t.restore())}genericComposeSMask(t,e,n,s,o,l,u,d,p,m,b){let v=t.canvas,A=d-m,x=p-b;if(l){let k=xt.makeHexColor(...l);if(A<0||x<0||A+n>v.width||x+s>v.height){let I=this.cachedCanvases.getCanvas("maskExtension",n,s),P=I.context;P.drawImage(v,-A,-x),P.globalCompositeOperation="destination-atop",P.fillStyle=k,P.fillRect(0,0,n,s),P.globalCompositeOperation="source-over",v=I.canvas,A=x=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let I=new Path2D;I.rect(A,x,n,s),t.clip(I),t.globalCompositeOperation="destination-atop",t.fillStyle=k,t.fillRect(A,x,n,s),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),o==="Alpha"&&u?e.filter=this.filterFactory.addAlphaFilter(u):o==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(u));let w=new Path2D;w.rect(d,p,n,s),e.clip(w),e.globalCompositeOperation="destination-in",e.drawImage(v,A,x,n,s,d,p,n,s),e.restore()}save(){this.inSMaskMode?(Cr(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Cr(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,n,s,o,l){this.ctx.transform(t,e,n,s,o,l),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,n){let s=this.ctx,o=this.current,l=o.x,u=o.y,d,p,m=Xt(s),b=m[0]===0&&m[3]===0||m[1]===0&&m[2]===0,v=b?n.slice(0):null;for(let A=0,x=0,w=t.length;A<w;A++)switch(t[A]|0){case We.rectangle:l=e[x++],u=e[x++];let k=e[x++],I=e[x++],P=l+k,M=u+I;s.moveTo(l,u),k===0||I===0?s.lineTo(P,M):(s.lineTo(P,u),s.lineTo(P,M),s.lineTo(l,M)),b||o.updateRectMinMax(m,[l,u,P,M]),s.closePath();break;case We.moveTo:l=e[x++],u=e[x++],s.moveTo(l,u),b||o.updatePathMinMax(m,l,u);break;case We.lineTo:l=e[x++],u=e[x++],s.lineTo(l,u),b||o.updatePathMinMax(m,l,u);break;case We.curveTo:d=l,p=u,l=e[x+4],u=e[x+5],s.bezierCurveTo(e[x],e[x+1],e[x+2],e[x+3],l,u),o.updateCurvePathMinMax(m,d,p,e[x],e[x+1],e[x+2],e[x+3],l,u,v),x+=6;break;case We.curveTo2:d=l,p=u,s.bezierCurveTo(l,u,e[x],e[x+1],e[x+2],e[x+3]),o.updateCurvePathMinMax(m,d,p,l,u,e[x],e[x+1],e[x+2],e[x+3],v),l=e[x+2],u=e[x+3],x+=4;break;case We.curveTo3:d=l,p=u,l=e[x+2],u=e[x+3],s.bezierCurveTo(e[x],e[x+1],l,u,l,u),o.updateCurvePathMinMax(m,d,p,e[x],e[x+1],l,u,l,u,v),x+=4;break;case We.closePath:s.closePath();break}b&&o.updateScalingPathMinMax(m,v),o.setCurrentPoint(l,u)}closePath(){this.ctx.closePath()}stroke(t=!0){let e=this.ctx,n=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof n=="object"&&n?.getPattern?(e.save(),e.strokeStyle=n.getPattern(e,this,Ze(e),ue.STROKE),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){let e=this.ctx,n=this.current.fillColor,s=this.current.patternFill,o=!1;s&&(e.save(),e.fillStyle=n.getPattern(e,this,Ze(e),ue.FILL),o=!0);let l=this.current.getClippedPathBoundingBox();this.contentVisible&&l!==null&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),o&&e.restore(),t&&this.consumePath(l)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Oy}eoClip(){this.pendingClip=Ku}beginText(){this.current.textMatrix=Ju,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let t=this.pendingTextPaths,e=this.ctx;if(t===void 0){e.beginPath();return}let n=new Path2D,s=e.getTransform().invertSelf();for(let{transform:o,x:l,y:u,fontSize:d,path:p}of t)n.addPath(p,new DOMMatrix(o).preMultiplySelf(s).translate(l,u).scale(d,-d));e.clip(n),e.beginPath(),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){let n=this.commonObjs.get(t),s=this.current;if(!n)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=n.fontMatrix||_o,(s.fontMatrix[0]===0||s.fontMatrix[3]===0)&&Pt("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=n,this.current.fontSize=e,n.isType3Font)return;let o=n.loadedName||"sans-serif",l=n.systemFontInfo?.css||`"${o}", ${n.fallbackName}`,u="normal";n.black?u="900":n.bold&&(u="bold");let d=n.italic?"italic":"normal",p=e;e<ju?p=ju:e>Vu&&(p=Vu),this.current.fontSizeScale=e/p,this.ctx.font=`${d} ${u} ${p}px ${l}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,n,s,o,l){this.current.textMatrix=[t,e,n,s,o,l],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#n(t,e,n){let s=new Path2D;return s.addPath(t,new DOMMatrix(n).invertSelf().multiplySelf(e)),s}paintChar(t,e,n,s,o){let l=this.ctx,u=this.current,d=u.font,p=u.textRenderingMode,m=u.fontSize/u.fontSizeScale,b=p&ce.FILL_STROKE_MASK,v=!!(p&ce.ADD_TO_PATH_FLAG),A=u.patternFill&&!d.missingFile,x=u.patternStroke&&!d.missingFile,w;if((d.disableFontFace||v||A||x)&&(w=d.getPathGenerator(this.commonObjs,t)),d.disableFontFace||A||x){if(l.save(),l.translate(e,n),l.scale(m,-m),b===ce.FILL||b===ce.FILL_STROKE)if(s){let k=l.getTransform();l.setTransform(...s),l.fill(this.#n(w,k,s))}else l.fill(w);if(b===ce.STROKE||b===ce.FILL_STROKE)if(o){let k=l.getTransform();l.setTransform(...o),l.stroke(this.#n(w,k,o))}else l.lineWidth/=m,l.stroke(w);l.restore()}else(b===ce.FILL||b===ce.FILL_STROKE)&&l.fillText(t,e,n),(b===ce.STROKE||b===ce.FILL_STROKE)&&l.strokeText(t,e,n);v&&(this.pendingTextPaths||=[]).push({transform:Xt(l),x:e,y:n,fontSize:m,path:w})}get isFontSubpixelAAEnabled(){let{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);let e=t.getImageData(0,0,10,10).data,n=!1;for(let s=3;s<e.length;s+=4)if(e[s]>0&&e[s]<255){n=!0;break}return Lt(this,"isFontSubpixelAAEnabled",n)}showText(t){let e=this.current,n=e.font;if(n.isType3Font)return this.showType3Text(t);let s=e.fontSize;if(s===0)return;let o=this.ctx,l=e.fontSizeScale,u=e.charSpacing,d=e.wordSpacing,p=e.fontDirection,m=e.textHScale*p,b=t.length,v=n.vertical,A=v?1:-1,x=n.defaultVMetrics,w=s*e.fontMatrix[0],k=e.textRenderingMode===ce.FILL&&!n.disableFontFace&&!e.patternFill;o.save(),o.transform(...e.textMatrix),o.translate(e.x,e.y+e.textRise),p>0?o.scale(m,-1):o.scale(m,1);let I,P;if(e.patternFill){o.save();let G=e.fillColor.getPattern(o,this,Ze(o),ue.FILL);I=Xt(o),o.restore(),o.fillStyle=G}if(e.patternStroke){o.save();let G=e.strokeColor.getPattern(o,this,Ze(o),ue.STROKE);P=Xt(o),o.restore(),o.strokeStyle=G}let M=e.lineWidth,N=e.textMatrixScale;if(N===0||M===0){let G=e.textRenderingMode&ce.FILL_STROKE_MASK;(G===ce.STROKE||G===ce.FILL_STROKE)&&(M=this.getSinglePixelWidth())}else M/=N;if(l!==1&&(o.scale(l,l),M/=l),o.lineWidth=M,n.isInvalidPDFjsFont){let G=[],H=0;for(let W of t)G.push(W.unicode),H+=W.width;o.fillText(G.join(""),0,0),e.x+=H*w*m,o.restore(),this.compose();return}let D=0,U;for(U=0;U<b;++U){let G=t[U];if(typeof G=="number"){D+=A*G*s/1e3;continue}let H=!1,W=(G.isSpace?d:0)+u,J=G.fontChar,q=G.accent,dt,Q,ot=G.width;if(v){let X=G.vmetric||x,$=-(G.vmetric?X[1]:ot*.5)*w,ut=X[2]*w;ot=X?-X[0]:ot,dt=$/l,Q=(D+ut)/l}else dt=D/l,Q=0;if(n.remeasure&&ot>0){let X=o.measureText(J).width*1e3/s*l;if(ot<X&&this.isFontSubpixelAAEnabled){let $=ot/X;H=!0,o.save(),o.scale($,1),dt/=$}else ot!==X&&(dt+=(ot-X)/2e3*s/l)}if(this.contentVisible&&(G.isInFont||n.missingFile)){if(k&&!q)o.fillText(J,dt,Q);else if(this.paintChar(J,dt,Q,I,P),q){let X=dt+s*q.offset.x/l,$=Q-s*q.offset.y/l;this.paintChar(q.fontChar,X,$,I,P)}}let ct=v?ot*w-W*p:ot*w+W*p;D+=ct,H&&o.restore()}v?e.y-=D:e.x+=D*m,o.restore(),this.compose()}showType3Text(t){let e=this.ctx,n=this.current,s=n.font,o=n.fontSize,l=n.fontDirection,u=s.vertical?1:-1,d=n.charSpacing,p=n.wordSpacing,m=n.textHScale*l,b=n.fontMatrix||_o,v=t.length,A=n.textRenderingMode===ce.INVISIBLE,x,w,k,I;if(!(A||o===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...n.textMatrix),e.translate(n.x,n.y),e.scale(m,l),x=0;x<v;++x){if(w=t[x],typeof w=="number"){I=u*w*o/1e3,this.ctx.translate(I,0),n.x+=I*m;continue}let P=(w.isSpace?p:0)+d,M=s.charProcOperatorList[w.operatorListId];if(!M){Pt(`Type3 character "${w.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=w,this.save(),e.scale(o,o),e.transform(...b),this.executeOperatorList(M),this.restore()),k=xt.applyTransform([w.width,0],b)[0]*o+P,e.translate(k,0),n.x+=k*m}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,n,s,o,l){this.ctx.rect(n,s,o-n,l-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if(t[0]==="TilingPattern"){let n=t[1],s=this.baseTransform||Xt(this.ctx),o={createCanvasGraphics:l=>new i(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new sa(t,n,this.ctx,o,s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,n){this.ctx.strokeStyle=this.current.strokeColor=xt.makeHexColor(t,e,n),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,n){this.ctx.fillStyle=this.current.fillColor=xt.makeHexColor(t,e,n),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let n;return this.cachedPatterns.has(t)?n=this.cachedPatterns.get(t):(n=wy(this.getObject(t)),this.cachedPatterns.set(t,n)),e&&(n.matrix=e),n}shadingFill(t){if(!this.contentVisible)return;let e=this.ctx;this.save();let n=this._getPattern(t);e.fillStyle=n.getPattern(e,this,Ze(e),ue.SHADING);let s=Ze(e);if(s){let{width:o,height:l}=e.canvas,[u,d,p,m]=xt.getAxialAlignedBoundingBox([0,0,o,l],s);this.ctx.fillRect(u,d,p-u,m-d)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){$t("Should not call beginInlineImage")}beginImageData(){$t("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Xt(this.ctx),e)){let n=e[2]-e[0],s=e[3]-e[1];this.ctx.rect(e[0],e[1],n,s),this.current.updateRectMinMax(Xt(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let e=this.ctx;t.isolated||bi("TODO: Support non-isolated groups."),t.knockout&&Pt("Knockout groups not supported.");let n=Xt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=xt.getAxialAlignedBoundingBox(t.bbox,Xt(e)),o=[0,0,e.canvas.width,e.canvas.height];s=xt.intersect(s,o)||[0,0,0,0];let l=Math.floor(s[0]),u=Math.floor(s[1]),d=Math.max(Math.ceil(s[2])-l,1),p=Math.max(Math.ceil(s[3])-u,1);this.current.startNewPathAndClipBox([0,0,d,p]);let m="groupAt"+this.groupLevel;t.smask&&(m+="_smask_"+this.smaskCounter++%2);let b=this.cachedCanvases.getCanvas(m,d,p),v=b.context;v.translate(-l,-u),v.transform(...n),t.smask?this.smaskStack.push({canvas:b.canvas,context:v,offsetX:l,offsetY:u,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(l,u),e.save()),Cr(e,v),this.ctx=v,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;let e=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let s=Xt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...s);let o=xt.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],s);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(o)}}beginAnnotation(t,e,n,s,o){if(this.#t(),Fs(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){let l=e[2]-e[0],u=e[3]-e[1];if(o&&this.annotationCanvasMap){n=n.slice(),n[4]-=e[0],n[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=l,e[3]=u;let[d,p]=xt.singularValueDecompose2dScale(Xt(this.ctx)),{viewportScale:m}=this,b=Math.ceil(l*this.outputScaleX*m),v=Math.ceil(u*this.outputScaleY*m);this.annotationCanvas=this.canvasFactory.create(b,v);let{canvas:A,context:x}=this.annotationCanvas;this.annotationCanvasMap.set(t,A),this.annotationCanvas.savedCtx=this.ctx,this.ctx=x,this.ctx.save(),this.ctx.setTransform(d,0,0,-p,0,u*p),Fs(this.ctx)}else Fs(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],l,u),this.ctx.clip(),this.ctx.beginPath()}this.current=new Js(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;let e=t.count;t=this.getObject(t.data,t),t.count=e;let n=this.ctx,s=this.processingType3;if(s&&(s.compiled===void 0&&(s.compiled=Iy(t)),s.compiled)){s.compiled(n);return}let o=this._createMaskCanvas(t),l=o.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(l,o.offsetX,o.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,n=0,s=0,o,l){if(!this.contentVisible)return;t=this.getObject(t.data,t);let u=this.ctx;u.save();let d=Xt(u);u.transform(e,n,s,o,0,0);let p=this._createMaskCanvas(t);u.setTransform(1,0,0,1,p.offsetX-d[4],p.offsetY-d[5]);for(let m=0,b=l.length;m<b;m+=2){let v=xt.transform(d,[e,n,s,o,l[m],l[m+1]]),[A,x]=xt.applyTransform([0,0],v);u.drawImage(p.canvas,A,x)}u.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;let e=this.ctx,n=this.current.fillColor,s=this.current.patternFill;for(let o of t){let{data:l,width:u,height:d,transform:p}=o,m=this.cachedCanvases.getCanvas("maskCanvas",u,d),b=m.context;b.save();let v=this.getObject(l,o);Xu(b,v),b.globalCompositeOperation="source-in",b.fillStyle=s?n.getPattern(b,this,Ze(e),ue.FILL):n,b.fillRect(0,0,u,d),b.restore(),e.save(),e.transform(...p),e.scale(1,-1),Ls(e,m.canvas,0,0,u,d,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;let e=this.getObject(t);if(!e){Pt("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,n,s){if(!this.contentVisible)return;let o=this.getObject(t);if(!o){Pt("Dependent image isn't ready yet");return}let l=o.width,u=o.height,d=[];for(let p=0,m=s.length;p<m;p+=2)d.push({transform:[e,0,0,n,s[p],s[p+1]],x:0,y:0,w:l,h:u});this.paintInlineImageXObjectGroup(o,d)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;let{bitmap:e,width:n,height:s}=t,o=this.cachedCanvases.getCanvas("inlineImage",n,s),l=o.context;return l.filter=this.current.transferMaps,l.drawImage(e,0,0),l.filter="none",o.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;let e=t.width,n=t.height,s=this.ctx;if(this.save(),!he){let{filter:u}=s;u!=="none"&&u!==""&&(s.filter="none")}s.scale(1/e,-1/n);let o;if(t.bitmap)o=this.applyTransferMapsToBitmap(t);else if(typeof HTMLElement=="function"&&t instanceof HTMLElement||!t.data)o=t;else{let d=this.cachedCanvases.getCanvas("inlineImage",e,n).context;zu(d,t),o=this.applyTransferMapsToCanvas(d)}let l=this._scaleImage(o,Ze(s));s.imageSmoothingEnabled=Yu(Xt(s),t.interpolate),Ls(s,l.img,0,0,l.paintWidth,l.paintHeight,0,-n,e,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;let n=this.ctx,s;if(t.bitmap)s=t.bitmap;else{let o=t.width,l=t.height,d=this.cachedCanvases.getCanvas("inlineImage",o,l).context;zu(d,t),s=this.applyTransferMapsToCanvas(d)}for(let o of e)n.save(),n.transform(...o.transform),n.scale(1,-1),Ls(n,s,o.x,o.y,o.w,o.h,0,-1,1,1),n.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){let e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);let n=this.ctx;this.pendingClip&&(e||(this.pendingClip===Ku?n.clip("evenodd"):n.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=Xt(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]),n=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(n,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:t}=this.current,{a:e,b:n,c:s,d:o}=this.ctx.getTransform(),l,u;if(n===0&&s===0){let d=Math.abs(e),p=Math.abs(o);if(d===p)if(t===0)l=u=1/d;else{let m=d*t;l=u=m<1?1/m:1}else if(t===0)l=1/d,u=1/p;else{let m=d*t,b=p*t;l=m<1?1/m:1,u=b<1?1/b:1}}else{let d=Math.abs(e*o-n*s),p=Math.hypot(e,n),m=Math.hypot(s,o);if(t===0)l=m/d,u=p/d;else{let b=t*d;l=m>b?m/b:1,u=p>b?p/b:1}}this._cachedScaleForStroking[0]=l,this._cachedScaleForStroking[1]=u}return this._cachedScaleForStroking}rescaleAndStroke(t){let{ctx:e}=this,{lineWidth:n}=this.current,[s,o]=this.getScaleForStroking();if(e.lineWidth=n||1,s===1&&o===1){e.stroke();return}let l=e.getLineDash();if(t&&e.save(),e.scale(s,o),l.length>0){let u=Math.max(s,o);e.setLineDash(l.map(d=>d/u)),e.lineDashOffset/=u}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};for(let i in We)ir.prototype[i]!==void 0&&(ir.prototype[We[i]]=ir.prototype[i]);Dn=class{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 new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}},oa=class{#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}getAll(){return sl(this.#t)}has(t){return this.#t.has(t)}},sr=Symbol("INTERNAL"),aa=class{#t=!1;#e=!1;#n=!1;#r=!0;constructor(t,{name:e,intent:n,usage:s,rbGroups:o}){this.#t=!!(t&ke.DISPLAY),this.#e=!!(t&ke.PRINT),this.name=e,this.intent=n,this.usage=s,this.rbGroups=o}get visible(){if(this.#n)return this.#r;if(!this.#r)return!1;let{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,n=!1){t!==sr&&$t("Internal method `_setVisible` called."),this.#n=n,this.#r=e}},la=class{#t=null;#e=new Map;#n=null;#r=null;constructor(t,e=ke.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#r=t.order;for(let n of t.groups)this.#e.set(n.id,new aa(e,n));if(t.baseState==="OFF")for(let n of this.#e.values())n._setVisible(sr,!1);for(let n of t.on)this.#e.get(n)._setVisible(sr,!0);for(let n of t.off)this.#e.get(n)._setVisible(sr,!1);this.#n=this.getHash()}}#i(t){let e=t.length;if(e<2)return!0;let n=t[0];for(let s=1;s<e;s++){let o=t[s],l;if(Array.isArray(o))l=this.#i(o);else if(this.#e.has(o))l=this.#e.get(o).visible;else return Pt(`Optional content group not found: ${o}`),!0;switch(n){case"And":if(!l)return!1;break;case"Or":if(l)return!0;break;case"Not":return!l;default:return!0}}return n==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return bi("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(Pt(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#i(t.expression);if(!t.policy||t.policy==="AnyOn"){for(let e of t.ids){if(!this.#e.has(e))return Pt(`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 Pt(`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 Pt(`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 Pt(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return Pt(`Unknown optional content policy ${t.policy}.`),!0}return Pt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,n=!0){let s=this.#e.get(t);if(!s){Pt(`Optional content group not found: ${t}`);return}if(n&&e&&s.rbGroups.length)for(let o of s.rbGroups)for(let l of o)l!==t&&this.#e.get(l)?._setVisible(sr,!1,!0);s._setVisible(sr,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let n;for(let s of t){switch(s){case"ON":case"OFF":case"Toggle":n=s;continue}let o=this.#e.get(s);if(o)switch(n){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!o.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#n===null||this.getHash()===this.#n}getOrder(){return this.#e.size?this.#r?this.#r.slice():[...this.#e.keys()]:null}getGroups(){return this.#e.size>0?sl(this.#e):null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;let t=new Ws;for(let[e,n]of this.#e)t.update(`${e}:${n.visible}`);return this.#t=t.hexdigest()}},ca=class{constructor(t,{disableRange:e=!1,disableStream:n=!1}){ee(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');let{length:s,initialData:o,progressiveDone:l,contentDispositionFilename:u}=t;if(this._queuedChunks=[],this._progressiveDone=l,this._contentDispositionFilename=u,o?.length>0){let d=o instanceof Uint8Array&&o.byteLength===o.buffer.byteLength?o.buffer:new Uint8Array(o).buffer;this._queuedChunks.push(d)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!n,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((d,p)=>{this._onReceiveData({begin:d,chunk:p})}),t.addProgressListener((d,p)=>{this._onProgress({loaded:d,total:p})}),t.addProgressiveReadListener(d=>{this._onReceiveData({chunk:d})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){let n=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n);else{let s=this._rangeReaders.some(function(o){return o._begin!==t?!1:(o._enqueue(n),!0)});ee(s,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){let e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){ee(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let t=this._queuedChunks;return this._queuedChunks=null,new ua(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let n=new ha(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}},ua=class{constructor(t,e,n=!1,s=null){this._stream=t,this._done=n||!1,this._filename=ol(s)?s:null,this._queuedChunks=e||[],this._loaded=0;for(let o of this._queuedChunks)this._loaded+=o.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}},ha=class{constructor(t,e,n){this._stream=t,this._begin=e,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(let n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}};qs=class{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=eh(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return ee(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new da(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let n=new fa(this,t,e);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},da=class{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;let e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;let n=new Headers(t.headers),s=e.url;fetch(s,ih(n,this._withCredentials,this._abortController)).then(o=>{if(t._responseOrigin=Si(o.url),!sh(o.status))throw Ai(o.status,s);this._reader=o.body.getReader(),this._headersCapability.resolve();let l=o.headers,{allowRangeRequests:u,suggestedLength:d}=nh({responseHeaders:l,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=u,this._contentLength=d||this._contentLength,this._filename=rh(l),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Je("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:oh(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},fa=class{constructor(t,e,n){this._stream=t,this._reader=null,this._loaded=0;let s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;let o=new Headers(t.headers);o.append("Range",`bytes=${e}-${n-1}`);let l=s.url;fetch(l,ih(o,this._withCredentials,this._abortController)).then(u=>{let d=Si(u.url);if(d!==t._responseOrigin)throw new Error(`Expected range response-origin "${d}" to match "${t._responseOrigin}".`);if(!sh(u.status))throw Ai(u.status,l);this._readCapability.resolve(),this._reader=u.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:oh(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}},Fo=200,Do=206;pa=class{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:n}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=eh(this.isHttp,e),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){let e=new XMLHttpRequest,n=this.currXhrId++,s=this.pendingRequests[n]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(let[o,l]of this.headers)e.setRequestHeader(o,l);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=Do):s.expectedStatus=Fo,e.responseType="arraybuffer",ee(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,n),e.onprogress=this.onProgress.bind(this,n),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),n}onProgress(t,e){let n=this.pendingRequests[t];n&&n.onProgress?.(e)}onStateChange(t,e){let n=this.pendingRequests[t];if(!n)return;let s=n.xhr;if(s.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),s.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],s.status===0&&this.isHttp){n.onError(s.status);return}let o=s.status||Fo;if(!(o===Fo&&n.expectedStatus===Do)&&o!==n.expectedStatus){n.onError(s.status);return}let u=Ly(s);if(o===Do){let d=s.getResponseHeader("Content-Range"),p=/bytes (\d+)-(\d+)\/(\d+)/.exec(d);p?n.onDone({begin:parseInt(p[1],10),chunk:u}):(Pt('Missing or invalid "Content-Range" header.'),n.onError(0))}else u?n.onDone({begin:0,chunk:u}):n.onError(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){let e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}},ga=class{constructor(t){this._source=t,this._manager=new pa(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){let e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return ee(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new ma(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){let n=new ba(this._manager,t,e);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},ma=class{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=Si(e.responseURL);let n=e.getAllResponseHeaders(),s=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(u=>{let[d,...p]=u.split(": ");return[d,p.join(": ")]}):[]),{allowRangeRequests:o,suggestedLength:l}=nh({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});o&&(this._isRangeSupported=!0),this._contentLength=l||this._contentLength,this._filename=rh(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Ai(t,this._url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}},ba=class{constructor(t,e,n){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:n,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let t=Si(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){let e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(let n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=Ai(t,this._url);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}},Fy=/^[a-z][a-z0-9\-+.]+:/i;ya=class{constructor(t){this.source=t,this.url=Dy(t.url),ee(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return ee(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new va(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let n=new xa(this,t,e);return this._rangeRequestReaders.push(n),n}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(let e of this._rangeRequestReaders.slice(0))e.cancel(t)}},va=class{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;let e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();let n=process.getBuiltinModule("fs");n.promises.lstat(this._url).then(s=>{this._contentLength=s.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()},s=>{s.code==="ENOENT"&&(s=new _n(`Missing PDF "${this._url}".`)),this._storedError=s,this._headersCapability.reject(s)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Je("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}},xa=class{constructor(t,e,n){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let s=t.source;this._isStreamingSupported=!s.disableStream;let o=process.getBuiltinModule("fs");this._setReadableStream(o.createReadStream(this._url,{start:e,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}},_y=1e5,xe=30,Ny=.8,Nr=class i{#t=Promise.withResolvers();#e=null;#n=!1;#r=!!globalThis.FontInspector?.enabled;#i=null;#s=null;#l=0;#a=0;#u=null;#c=null;#d=0;#h=0;#f=Object.create(null);#o=[];#p=null;#m=[];#g=new WeakMap;#b=null;static#x=new Map;static#y=new Map;static#S=new WeakMap;static#T=null;static#E=new Set;constructor({textContentSource:t,container:e,viewport:n}){if(t instanceof ReadableStream)this.#p=t;else if(typeof t=="object")this.#p=new ReadableStream({start(d){d.enqueue(t),d.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#c=e,this.#h=n.scale*(globalThis.devicePixelRatio||1),this.#d=n.rotation,this.#s={div:null,properties:null,ctx:null};let{pageWidth:s,pageHeight:o,pageX:l,pageY:u}=n.rawDims;this.#b=[1,0,0,-1,-l,u+o],this.#a=s,this.#l=o,i.#O(),Nn(e,n),this.#t.promise.finally(()=>{i.#E.delete(this),this.#s=null,this.#f=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=se.platform;return Lt(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){let t=()=>{this.#u.read().then(({value:e,done:n})=>{if(n){this.#t.resolve();return}this.#i??=e.lang,Object.assign(this.#f,e.styles),this.#k(e.items),t()},this.#t.reject)};return this.#u=this.#p.getReader(),i.#E.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){let n=t.scale*(globalThis.devicePixelRatio||1),s=t.rotation;if(s!==this.#d&&(e?.(),this.#d=s,Nn(this.#c,{rotation:s})),n!==this.#h){e?.(),this.#h=n;let o={div:null,properties:null,ctx:i.#I(this.#i)};for(let l of this.#m)o.properties=this.#g.get(l),o.div=l,this.#A(o)}}cancel(){let t=new Je("TextLayer task cancelled.");this.#u?.cancel(t).catch(()=>{}),this.#u=null,this.#t.reject(t)}get textDivs(){return this.#m}get textContentItemsStr(){return this.#o}#k(t){if(this.#n)return;this.#s.ctx??=i.#I(this.#i);let e=this.#m,n=this.#o;for(let s of t){if(e.length>_y){Pt("Ignoring additional textDivs for performance reasons."),this.#n=!0;return}if(s.str===void 0){if(s.type==="beginMarkedContentProps"||s.type==="beginMarkedContent"){let o=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),s.id!==null&&this.#e.setAttribute("id",`${s.id}`),o.append(this.#e)}else s.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}n.push(s.str),this.#P(s)}}#P(t){let e=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#m.push(e);let s=xt.transform(this.#b,t.transform),o=Math.atan2(s[1],s[0]),l=this.#f[t.fontName];l.vertical&&(o+=Math.PI/2);let u=this.#r&&l.fontSubstitution||l.fontFamily;u=i.fontFamilyMap.get(u)||u;let d=Math.hypot(s[2],s[3]),p=d*i.#F(u,this.#i),m,b;o===0?(m=s[4],b=s[5]-p):(m=s[4]+p*Math.sin(o),b=s[5]-p*Math.cos(o));let v="calc(var(--scale-factor)*",A=e.style;this.#e===this.#c?(A.left=`${(100*m/this.#a).toFixed(2)}%`,A.top=`${(100*b/this.#l).toFixed(2)}%`):(A.left=`${v}${m.toFixed(2)}px)`,A.top=`${v}${b.toFixed(2)}px)`),A.fontSize=`${v}${(i.#T*d).toFixed(2)}px)`,A.fontFamily=u,n.fontSize=d,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#r&&(e.dataset.fontName=l.fontSubstitutionLoadedName||t.fontName),o!==0&&(n.angle=o*(180/Math.PI));let x=!1;if(t.str.length>1)x=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){let w=Math.abs(t.transform[0]),k=Math.abs(t.transform[3]);w!==k&&Math.max(w,k)/Math.min(w,k)>1.5&&(x=!0)}if(x&&(n.canvasWidth=l.vertical?t.height:t.width),this.#g.set(e,n),this.#s.div=e,this.#s.properties=n,this.#A(this.#s),n.hasText&&this.#e.append(e),n.hasEOL){let w=document.createElement("br");w.setAttribute("role","presentation"),this.#e.append(w)}}#A(t){let{div:e,properties:n,ctx:s}=t,{style:o}=e,l="";if(i.#T>1&&(l=`scale(${1/i.#T})`),n.canvasWidth!==0&&n.hasText){let{fontFamily:u}=o,{canvasWidth:d,fontSize:p}=n;i.#C(s,p*this.#h,u);let{width:m}=s.measureText(e.textContent);m>0&&(l=`scaleX(${d*this.#h/m}) ${l}`)}n.angle!==0&&(l=`rotate(${n.angle}deg) ${l}`),l.length>0&&(o.transform=l)}static cleanup(){if(!(this.#E.size>0)){this.#x.clear();for(let{canvas:t}of this.#y.values())t.remove();this.#y.clear()}}static#I(t=null){let e=this.#y.get(t||="");if(!e){let n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=t,document.body.append(n),e=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#y.set(t,e),this.#S.set(e,{size:0,family:""})}return e}static#C(t,e,n){let s=this.#S.get(t);e===s.size&&n===s.family||(t.font=`${e}px ${n}`,s.size=e,s.family=n)}static#O(){if(this.#T!==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.#T=t.getBoundingClientRect().height,t.remove()}static#F(t,e){let n=this.#x.get(t);if(n)return n;let s=this.#I(e);s.canvas.width=s.canvas.height=xe,this.#C(s,xe,t);let o=s.measureText(""),l=o.fontBoundingBoxAscent,u=Math.abs(o.fontBoundingBoxDescent);if(l){let m=l/(l+u);return this.#x.set(t,m),s.canvas.width=s.canvas.height=0,m}s.strokeStyle="red",s.clearRect(0,0,xe,xe),s.strokeText("g",0,0);let d=s.getImageData(0,0,xe,xe).data;u=0;for(let m=d.length-1-3;m>=0;m-=4)if(d[m]>0){u=Math.ceil(m/4/xe);break}s.clearRect(0,0,xe,xe),s.strokeText("A",0,xe),d=s.getImageData(0,0,xe,xe).data,l=0;for(let m=0,b=d.length;m<b;m+=4)if(d[m]>0){l=xe-Math.floor(m/4/xe);break}s.canvas.width=s.canvas.height=0;let p=l?l/(l+u):Ny;return this.#x.set(t,p),p}},Ur=class i{static textContent(t){let e=[],n={items:e,styles:Object.create(null)};function s(o){if(!o)return;let l=null,u=o.name;if(u==="#text")l=o.value;else if(i.shouldBuildText(u))o?.attributes?.textContent?l=o.attributes.textContent:o.value&&(l=o.value);else return;if(l!==null&&e.push({str:l}),!!o.children)for(let d of o.children)s(d)}return s(t),n}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}},Uy=65536,By=100,Gy=5e3,Hy=he?Qo:Yo,jy=he?Jo:Ys,Vy=he?Zo:Ko,Wy=he?qo:Qs;Sa=class i{static#t=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${i.#t++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}},ti=class{constructor(t,e,n=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=n,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(let n of this._rangeListeners)n(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(let n of this._progressListeners)n(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(let e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){$t("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},Aa=class{constructor(t,e){this._pdfInfo=t,this._transport=e}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 Lt(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()}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()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}},Ta=class{#t=null;#e=!1;constructor(t,e,n,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=n,this._stats=s?new Bs:null,this._pdfBug=s,this.commonObjs=n.commonObjs,this.objs=new ei,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}get trimBox(){return this._pageInfo.trimBox??null}get bleedBox(){return this._pageInfo.bleedBox??null}get colorSpaceResources(){return this._pageInfo.colorSpaceResources??{}}get imglyPatchVersion(){return this._pageInfo.imglyPatchVersion??null}getViewport({scale:t,rotation:e=this.rotate,offsetX:n=0,offsetY:s=0,dontFlip:o=!1}={}){return new Mr({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:n,offsetY:s,dontFlip:o})}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 Lt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:n="display",annotationMode:s=bn.ENABLE,transform:o=null,background:l=null,optionalContentConfigPromise:u=null,annotationCanvasMap:d=null,pageColors:p=null,printAnnotationStorage:m=null,isEditing:b=!1}){this._stats?.time("Overall");let v=this._transport.getRenderingIntent(n,s,m,b),{renderingIntent:A,cacheKey:x}=v;this.#e=!1,this.#r(),u||=this._transport.getOptionalContentConfig(A);let w=this._intentStates.get(x);w||(w=Object.create(null),this._intentStates.set(x,w)),w.streamReaderCancelTimeout&&(clearTimeout(w.streamReaderCancelTimeout),w.streamReaderCancelTimeout=null);let k=!!(A&ke.PRINT);w.displayReadyCapability||(w.displayReadyCapability=Promise.withResolvers(),w.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(v));let I=N=>{w.renderTasks.delete(P),(this._maybeCleanupAfterRender||k)&&(this.#e=!0),this.#n(!k),N?(P.capability.reject(N),this._abortOperatorList({intentState:w,reason:N instanceof Error?N:new Error(N)})):P.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},P=new ka({callback:I,params:{canvasContext:t,viewport:e,transform:o,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:d,operatorList:w.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!k,pdfBug:this._pdfBug,pageColors:p});(w.renderTasks||=new Set).add(P);let M=P.task;return Promise.all([w.displayReadyCapability.promise,u]).then(([N,D])=>{if(this.destroyed){I();return}if(this._stats?.time("Rendering"),!(D.renderingIntent&A))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");P.initializeGraphics({transparency:N,optionalContentConfig:D}),P.operatorListChanged()}).catch(I),M}getOperatorList({intent:t="display",annotationMode:e=bn.ENABLE,printAnnotationStorage:n=null,isEditing:s=!1}={}){function o(){u.operatorList.lastChunk&&(u.opListReadCapability.resolve(u.operatorList),u.renderTasks.delete(d))}let l=this._transport.getRenderingIntent(t,e,n,s,!0),u=this._intentStates.get(l.cacheKey);u||(u=Object.create(null),this._intentStates.set(l.cacheKey,u));let d;return u.opListReadCapability||(d=Object.create(null),d.operatorListChanged=o,u.opListReadCapability=Promise.withResolvers(),(u.renderTasks||=new Set).add(d),u.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(l)),u.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(s){return s.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(n=>Ur.textContent(n));let e=this.streamTextContent(t);return new Promise(function(n,s){function o(){l.read().then(function({value:d,done:p}){if(p){n(u);return}u.lang??=d.lang,Object.assign(u.styles,d.styles),u.items.push(...d.items),o()},s)}let l=e.getReader(),u={items:[],styles:Object.create(null),lang:null};o()})}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:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let n of e.renderTasks)t.push(n.completed),n.cancel();return this.objs.clear(),this.#e=!1,this.#r(),Promise.all(t)}cleanup(t=!1){this.#e=!0;let e=this.#n(!1);return t&&e&&(this._stats&&=new Bs),e}#n(t=!1){if(this.#r(),!this.#e||this.destroyed)return!1;if(t)return this.#t=setTimeout(()=>{this.#t=null,this.#n(!1)},Gy),!1;for(let{renderTasks:e,operatorList:n}of this._intentStates.values())if(e.size>0||!n.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#e=!1,!0}#r(){this.#t&&(clearTimeout(this.#t),this.#t=null)}_startRenderPage(t,e){let n=this._intentStates.get(e);n&&(this._stats?.timeEnd("Page Request"),n.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let n=0,s=t.length;n<s;n++)e.operatorList.fnArray.push(t.fnArray[n]),e.operatorList.argsArray.push(t.argsArray[n]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(let n of e.renderTasks)n.operatorListChanged();t.lastChunk&&this.#n(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:n,modifiedIds:s}){let{map:o,transfer:l}=n,d=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:o,modifiedIds:s},l).getReader(),p=this._intentStates.get(e);p.streamReader=d;let m=()=>{d.read().then(({value:b,done:v})=>{if(v){p.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(b,p),m())},b=>{if(p.streamReader=null,!this._transport.destroyed){if(p.operatorList){p.operatorList.lastChunk=!0;for(let v of p.renderTasks)v.operatorListChanged();this.#n(!0)}if(p.displayReadyCapability)p.displayReadyCapability.reject(b);else if(p.opListReadCapability)p.opListReadCapability.reject(b);else throw b}})};m()}_abortOperatorList({intentState:t,reason:e,force:n=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!n){if(t.renderTasks.size>0)return;if(e instanceof Lr){let s=By;e.extraDelay>0&&e.extraDelay<1e3&&(s+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},s);return}}if(t.streamReader.cancel(new Je(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[s,o]of this._intentStates)if(o===t){this._intentStates.delete(s);break}this.cleanup()}}}get stats(){return this._stats}},wa=class{#t=new Map;#e=Promise.resolve();postMessage(t,e){let n={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(let[s]of this.#t)s.call(this,n)})}addEventListener(t,e,n=null){let s=null;if(n?.signal instanceof AbortSignal){let{signal:o}=n;if(o.aborted){Pt("LoopbackPort - cannot use an `aborted` signal.");return}let l=()=>this.removeEventListener(t,e);s=()=>o.removeEventListener("abort",l),o.addEventListener("abort",l)}this.#t.set(e,s)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(let[,t]of this.#t)t?.();this.#t.clear()}},or=class i{static#t=0;static#e=!1;static#n;static{he&&(this.#e=!0,Dn.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let n;try{if(n=new URL(t),!n.origin||n.origin==="null")return!1}catch{return!1}let s=new URL(e,n);return n.origin===s.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:n=cy()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=n,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(i.#n?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(i.#n||=new WeakMap).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return this._readyCapability.promise}#r(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Fn("main","worker",t),this._messageHandler.on("ready",function(){}),this.#r()}_initialize(){if(i.#e||i.#i){this._setupFakeWorker();return}let{workerSrc:t}=i;try{i._isSameOrigin(window.location.href,t)||(t=i._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),n=new Fn("main","worker",e),s=()=>{o.abort(),n.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},o=new AbortController;e.addEventListener("error",()=>{this._webWorker||s()},{signal:o.signal}),n.on("test",u=>{if(o.abort(),this.destroyed||!u){s();return}this._messageHandler=n,this._port=e,this._webWorker=e,this.#r()}),n.on("ready",u=>{if(o.abort(),this.destroyed){s();return}try{l()}catch{this._setupFakeWorker()}});let l=()=>{let u=new Uint8Array;n.send("test",u,[u.buffer])};l();return}catch{bi("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){i.#e||(Pt("Setting up fake worker."),i.#e=!0),i._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}let e=new wa;this._port=e;let n=`fake${i.#t++}`,s=new Fn(n+"_worker",n,e);t.setup(s,e),this._messageHandler=new Fn(n,n+"_worker",e),this.#r()}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,i.#n?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");let e=this.#n?.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new i(t)}static get workerSrc(){if(Dn.workerSrc)return Dn.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#i(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Lt(this,"_setupFakeWorkerGlobal",(async()=>this.#i?this.#i:(await import(this.workerSrc)).WorkerMessageHandler)())}},Ea=class{#t=new Map;#e=new Map;#n=new Map;#r=new Map;#i=null;constructor(t,e,n,s,o){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new ei,this.fontLoader=new zo({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=o.canvasFactory,this.filterFactory=o.filterFactory,this.cMapReaderFactory=o.cMapReaderFactory,this.standardFontDataFactory=o.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#s(t,e=null){let n=this.#t.get(t);if(n)return n;let s=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,s),s}get annotationStorage(){return Lt(this,"annotationStorage",new Dr)}getRenderingIntent(t,e=bn.ENABLE,n=null,s=!1,o=!1){let l=ke.DISPLAY,u=$o;switch(t){case"any":l=ke.ANY;break;case"display":break;case"print":l=ke.PRINT;break;default:Pt(`getRenderingIntent - invalid intent: ${t}`)}let d=l&ke.PRINT&&n instanceof $s?n:this.annotationStorage;switch(e){case bn.DISABLE:l+=ke.ANNOTATIONS_DISABLE;break;case bn.ENABLE:break;case bn.ENABLE_FORMS:l+=ke.ANNOTATIONS_FORMS;break;case bn.ENABLE_STORAGE:l+=ke.ANNOTATIONS_STORAGE,u=d.serializable;break;default:Pt(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(l+=ke.IS_EDITING),o&&(l+=ke.OPLIST);let{ids:p,hash:m}=d.modifiedIds,b=[l,u.hash,m];return{renderingIntent:l,cacheKey:b.join("_"),annotationStorageSerializable:u,modifiedIds:p}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#i?.reject(new Error("Worker was destroyed during onPassword callback"));let t=[];for(let n of this.#e.values())t.push(n._destroy());this.#e.clear(),this.#n.clear(),this.#r.clear(),this.hasOwnProperty("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.#t.clear(),this.filterFactory.destroy(),Nr.cleanup(),this._networkStream?.cancelAllRequests(new Je("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",(n,s)=>{ee(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=o=>{this._lastProgress={loaded:o.loaded,total:o.total}},s.onPull=()=>{this._fullReader.read().then(function({value:o,done:l}){if(l){s.close();return}ee(o instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(o),1,[o])}).catch(o=>{s.error(o)})},s.onCancel=o=>{this._fullReader.cancel(o),s.ready.catch(l=>{if(!this.destroyed)throw l})}}),t.on("ReaderHeadersReady",async n=>{await this._fullReader.headersReady;let{isStreamingSupported:s,isRangeSupported:o,contentLength:l}=this._fullReader;return(!s||!o)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=u=>{e.onProgress?.({loaded:u.loaded,total:u.total})}),{isStreamingSupported:s,isRangeSupported:o,contentLength:l}}),t.on("GetRangeReader",(n,s)=>{ee(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let o=this._networkStream.getRangeReader(n.begin,n.end);if(!o){s.close();return}s.onPull=()=>{o.read().then(function({value:l,done:u}){if(u){s.close();return}ee(l instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(l),1,[l])}).catch(l=>{s.error(l)})},s.onCancel=l=>{o.cancel(l),s.ready.catch(u=>{if(!this.destroyed)throw u})}}),t.on("GetDoc",({pdfInfo:n})=>{this._numPages=n.numPages,this._htmlForXfa=n.htmlForXfa,delete n.htmlForXfa,e._capability.resolve(new Aa(n,this))}),t.on("DocException",n=>{e._capability.reject(Se(n))}),t.on("PasswordRequest",n=>{this.#i=Promise.withResolvers();try{if(!e.onPassword)throw Se(n);let s=o=>{o instanceof Error?this.#i.reject(o):this.#i.resolve({password:o})};e.onPassword(s,n.code)}catch(s){this.#i.reject(s)}return this.#i.promise}),t.on("DataLoaded",n=>{e.onProgress?.({loaded:n.length,total:n.length}),this.downloadInfoCapability.resolve(n)}),t.on("StartRenderPage",n=>{if(this.destroyed)return;this.#e.get(n.pageIndex)._startRenderPage(n.transparency,n.cacheKey)}),t.on("commonobj",([n,s,o])=>{if(this.destroyed||this.commonObjs.has(n))return null;switch(s){case"Font":let{disableFontFace:l,fontExtraProperties:u,pdfBug:d}=this._params;if("error"in o){let v=o.error;Pt(`Error during font loading: ${v}`),this.commonObjs.resolve(n,v);break}let p=d&&globalThis.FontInspector?.enabled?(v,A)=>globalThis.FontInspector.fontAdded(v,A):null,m=new Xo(o,{disableFontFace:l,fontExtraProperties:u,inspectFont:p});this.fontLoader.bind(m).catch(()=>t.sendWithPromise("FontFallback",{id:n})).finally(()=>{!u&&m.data&&(m.data=null),this.commonObjs.resolve(n,m)});break;case"CopyLocalImage":let{imageRef:b}=o;ee(b,"The imageRef must be defined.");for(let v of this.#e.values())for(let[,A]of v.objs)if(A?.ref===b)return A.dataLen?(this.commonObjs.resolve(n,structuredClone(A)),A.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(n,o);break;default:throw new Error(`Got unknown common object type ${s}`)}return null}),t.on("obj",([n,s,o,l])=>{if(this.destroyed)return;let u=this.#e.get(s);if(!u.objs.has(n)){if(u._intentStates.size===0){l?.bitmap?.close();return}switch(o){case"Image":u.objs.resolve(n,l),l?.dataLen>ry&&(u._maybeCleanupAfterRender=!0);break;case"Pattern":u.objs.resolve(n,l);break;default:throw new Error(`Got unknown object type ${o}`)}}}),t.on("DocProgress",n=>{this.destroyed||e.onProgress?.({loaded:n.loaded,total:n.total})}),t.on("FetchBuiltInCMap",async n=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(n)}),t.on("FetchStandardFontData",async n=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(n)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&Pt("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._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));let e=t-1,n=this.#n.get(e);if(n)return n;let s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(o=>{if(this.destroyed)throw new Error("Transport destroyed");o.refStr&&this.#r.set(o.refStr,t);let l=new Ta(e,o,this,this._params.pdfBug);return this.#e.set(e,l),l});return this.#n.set(e,s),s}getPageIndex(t){return Zu(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#s("GetFieldObjects")}hasJSActions(){return this.#s("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):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)}getDocJSActions(){return this.#s("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#s("GetOptionalContentConfig").then(e=>new la(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata",e=this.#t.get(t);if(e)return e;let n=this.messageHandler.sendWithPromise(t,null).then(s=>({info:s[0],metadata:s[1]?new oa(s[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(let e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),Nr.cleanup()}}cachedPageNumber(t){if(!Zu(t))return null;let e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#r.get(e)??null}},kr=Symbol("INITIAL_DATA"),ei=class{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:kr}}get(t,e=null){if(e){let s=this.#e(t);return s.promise.then(()=>e(s.data)),null}let n=this.#t[t];if(!n||n.data===kr)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return n.data}has(t){let e=this.#t[t];return!!e&&e.data!==kr}delete(t){let e=this.#t[t];return!e||e.data===kr?!1:(delete this.#t[t],!0)}resolve(t,e=null){let n=this.#e(t);n.data=e,n.resolve()}clear(){for(let t in this.#t){let{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(let t in this.#t){let{data:e}=this.#t[t];e!==kr&&(yield[t,e])}}},Ca=class{#t=null;constructor(t){this.#t=t,this.onContinue=null}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}},ka=class i{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:n,commonObjs:s,annotationCanvasMap:o,operatorList:l,pageIndex:u,canvasFactory:d,filterFactory:p,useRequestAnimationFrame:m=!1,pdfBug:b=!1,pageColors:v=null}){this.callback=t,this.params=e,this.objs=n,this.commonObjs=s,this.annotationCanvasMap=o,this.operatorListIdx=null,this.operatorList=l,this._pageIndex=u,this.canvasFactory=d,this.filterFactory=p,this._pdfBug=b,this.pageColors=v,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=m===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Ca(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.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(i.#e.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");i.#e.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:n,viewport:s,transform:o,background:l}=this.params;this.gfx=new ir(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:o,viewport:s,transparency:t,background:l}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),i.#e.delete(this._canvas),this.callback(t||new Lr(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),i.#e.delete(this._canvas),this.callback())))}},Yy="4.10.45",Ky="18f8e0416",AA=Dt(670);ni=class{static CMYK_G([t,e,n,s]){return["G",1-Math.min(1,.3*t+.59*n+.11*e+s)]}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=Ir(t),[t,t,t]}static G_HTML([t]){let e=Qu(t);return`#${e}${e}${e}`}static RGB_G([t,e,n]){return["G",.3*t+.59*e+.11*n]}static RGB_rgb(t){return t.map(Ir)}static RGB_HTML(t){return`#${t.map(Qu).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,n,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,n+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,n,s]){return[Ir(1-Math.min(1,t+s)),Ir(1-Math.min(1,n+s)),Ir(1-Math.min(1,e+s))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,n]){let s=1-t,o=1-e,l=1-n,u=Math.min(s,o,l);return["CMYK",s,o,l,u]}},Ia=class{create(t,e,n=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");let s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),n||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){$t("Abstract method `_createSVG` called.")}},Br=class extends Ia{_createSVG(t){return document.createElementNS(sn,t)}},ri=class{static setupStorage(t,e,n,s,o){let l=s.getValue(e,{value:null});switch(n.name){case"textarea":if(l.value!==null&&(t.textContent=l.value),o==="print")break;t.addEventListener("input",u=>{s.setValue(e,{value:u.target.value})});break;case"input":if(n.attributes.type==="radio"||n.attributes.type==="checkbox"){if(l.value===n.attributes.xfaOn?t.setAttribute("checked",!0):l.value===n.attributes.xfaOff&&t.removeAttribute("checked"),o==="print")break;t.addEventListener("change",u=>{s.setValue(e,{value:u.target.checked?u.target.getAttribute("xfaOn"):u.target.getAttribute("xfaOff")})})}else{if(l.value!==null&&t.setAttribute("value",l.value),o==="print")break;t.addEventListener("input",u=>{s.setValue(e,{value:u.target.value})})}break;case"select":if(l.value!==null){t.setAttribute("value",l.value);for(let u of n.children)u.attributes.value===l.value?u.attributes.selected=!0:u.attributes.hasOwnProperty("selected")&&delete u.attributes.selected}t.addEventListener("input",u=>{let d=u.target.options,p=d.selectedIndex===-1?"":d[d.selectedIndex].value;s.setValue(e,{value:p})});break}}static setAttributes({html:t,element:e,storage:n=null,intent:s,linkService:o}){let{attributes:l}=e,u=t instanceof HTMLAnchorElement;l.type==="radio"&&(l.name=`${l.name}-${s}`);for(let[d,p]of Object.entries(l))if(p!=null)switch(d){case"class":p.length&&t.setAttribute(d,p.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",p);break;case"style":Object.assign(t.style,p);break;case"textContent":t.textContent=p;break;default:(!u||d!=="href"&&d!=="newWindow")&&t.setAttribute(d,p)}u&&o.addLinkAttributes(t,l.href,l.newWindow),n&&l.dataId&&this.setupStorage(t,l.dataId,e,n)}static render(t){let e=t.annotationStorage,n=t.linkService,s=t.xfaHtml,o=t.intent||"display",l=document.createElement(s.name);s.attributes&&this.setAttributes({html:l,element:s,intent:o,linkService:n});let u=o!=="richText",d=t.div;if(d.append(l),t.viewport){let b=`matrix(${t.viewport.transform.join(",")})`;d.style.transform=b}u&&d.setAttribute("class","xfaLayer xfaFont");let p=[];if(s.children.length===0){if(s.value){let b=document.createTextNode(s.value);l.append(b),u&&Ur.shouldBuildText(s.name)&&p.push(b)}return{textDivs:p}}let m=[[s,-1,l]];for(;m.length>0;){let[b,v,A]=m.at(-1);if(v+1===b.children.length){m.pop();continue}let x=b.children[++m.at(-1)[1]];if(x===null)continue;let{name:w}=x;if(w==="#text"){let I=document.createTextNode(x.value);p.push(I),A.append(I);continue}let k=x?.attributes?.xmlns?document.createElementNS(x.attributes.xmlns,w):document.createElement(w);if(A.append(k),x.attributes&&this.setAttributes({html:k,element:x,storage:e,intent:o,linkService:n}),x.children?.length>0)m.push([x,-1,k]);else if(x.value){let I=document.createTextNode(x.value);u&&Ur.shouldBuildText(w)&&p.push(I),k.append(I)}}for(let b of d.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))b.setAttribute("readOnly",!0);return{textDivs:p}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}},Wr=1e3,Zy=9,Gn=new WeakSet;Pa=class{static create(t){switch(t.data.annotationType){case ne.LINK:return new si(t);case ne.TEXT:return new Ra(t);case ne.WIDGET:switch(t.data.fieldType){case"Tx":return new Oa(t);case"Btn":return t.data.radioButton?new ii(t):t.data.checkBox?new La(t):new Fa(t);case"Ch":return new Da(t);case"Sig":return new Ma(t)}return new on(t);case ne.POPUP:return new Gr(t);case ne.FREETEXT:return new oi(t);case ne.LINE:return new Na(t);case ne.SQUARE:return new Ua(t);case ne.CIRCLE:return new Ba(t);case ne.POLYLINE:return new ai(t);case ne.CARET:return new Ha(t);case ne.INK:return new Hr(t);case ne.POLYGON:return new Ga(t);case ne.HIGHLIGHT:return new li(t);case ne.UNDERLINE:return new ja(t);case ne.SQUIGGLY:return new Va(t);case ne.STRIKEOUT:return new Wa(t);case ne.STAMP:return new ci(t);case ne.FILEATTACHMENT:return new $a(t);default:return new Jt(t)}}},Jt=class i{#t=null;#e=!1;#n=null;constructor(t,{isRenderable:e=!1,ignoreBorder:n=!1,createQuadrilaterals:s=!1}={}){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.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(n)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:n}){return!!(t?.str||e?.str||n?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return i._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};let{rect:e}=t;e&&this.#r(e),this.#n?.popup.updateEdited(t)}resetEdited(){this.#t&&(this.#r(this.#t.rect),this.#n?.popup.resetEdited(),this.#t=null)}#r(t){let{container:{style:e},data:{rect:n,rotation:s},parent:{viewport:{rawDims:{pageWidth:o,pageHeight:l,pageX:u,pageY:d}}}}=this;n?.splice(0,4,...t);let{width:p,height:m}=yn(t);e.left=`${100*(t[0]-u)/o}%`,e.top=`${100*(l-t[3]+d)/l}%`,s===0?(e.width=`${100*p/o}%`,e.height=`${100*m/l}%`):this.setRotation(s)}_createContainer(t){let{data:e,parent:{page:n,viewport:s}}=this,o=document.createElement("section");o.setAttribute("data-annotation-id",e.id),this instanceof on||(o.tabIndex=Wr);let{style:l}=o;if(l.zIndex=this.parent.zIndex++,e.alternativeText&&(o.title=e.alternativeText),e.noRotate&&o.classList.add("norotate"),!e.rect||this instanceof Gr){let{rotation:w}=e;return!e.hasOwnCanvas&&w!==0&&this.setRotation(w,o),o}let{width:u,height:d}=yn(e.rect);if(!t&&e.borderStyle.width>0){l.borderWidth=`${e.borderStyle.width}px`;let w=e.borderStyle.horizontalCornerRadius,k=e.borderStyle.verticalCornerRadius;if(w>0||k>0){let P=`calc(${w}px * var(--scale-factor)) / calc(${k}px * var(--scale-factor))`;l.borderRadius=P}else if(this instanceof ii){let P=`calc(${u}px * var(--scale-factor)) / calc(${d}px * var(--scale-factor))`;l.borderRadius=P}switch(e.borderStyle.style){case Er.SOLID:l.borderStyle="solid";break;case Er.DASHED:l.borderStyle="dashed";break;case Er.BEVELED:Pt("Unimplemented border style: beveled");break;case Er.INSET:Pt("Unimplemented border style: inset");break;case Er.UNDERLINE:l.borderBottomStyle="solid";break;default:break}let I=e.borderColor||null;I?(this.#e=!0,l.borderColor=xt.makeHexColor(I[0]|0,I[1]|0,I[2]|0)):l.borderWidth=0}let p=xt.normalizeRect([e.rect[0],n.view[3]-e.rect[1]+n.view[1],e.rect[2],n.view[3]-e.rect[3]+n.view[1]]),{pageWidth:m,pageHeight:b,pageX:v,pageY:A}=s.rawDims;l.left=`${100*(p[0]-v)/m}%`,l.top=`${100*(p[1]-A)/b}%`;let{rotation:x}=e;return e.hasOwnCanvas||x===0?(l.width=`${100*u/m}%`,l.height=`${100*d/b}%`):this.setRotation(x,o),o}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:n,pageHeight:s}=this.parent.viewport.rawDims,{width:o,height:l}=yn(this.data.rect),u,d;t%180===0?(u=100*o/n,d=100*l/s):(u=100*l/n,d=100*o/s),e.style.width=`${u}%`,e.style.height=`${d}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(e,n,s)=>{let o=s.detail[e],l=o[0],u=o.slice(1);s.target.style[n]=ni[`${l}_HTML`](u),this.annotationStorage.setValue(this.data.id,{[n]:ni[`${l}_rgb`](u)})};return Lt(this,"_commonActions",{display:e=>{let{display:n}=e.detail,s=n%2===1;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:s,noPrint:n===1||n===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{let{hidden:n}=e.detail;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:n,noView:n})},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 n=e.detail.rotation;this.setRotation(n),this.annotationStorage.setValue(this.data.id,{rotation:n})}})}_dispatchEventFromSandbox(t,e){let n=this._commonActions;for(let s of Object.keys(e.detail))(t[s]||n[s])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let n=this._commonActions;for(let[s,o]of Object.entries(e)){let l=n[s];if(l){let u={detail:{[s]:o},target:t};l(u),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:t}=this.data;if(!t)return;let[e,n,s,o]=this.data.rect.map(w=>Math.fround(w));if(t.length===8){let[w,k,I,P]=t.subarray(2,6);if(s===w&&o===k&&e===I&&n===P)return}let{style:l}=this.container,u;if(this.#e){let{borderColor:w,borderWidth:k}=l;l.borderWidth=0,u=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${w}" stroke-width="${k}">`],this.container.classList.add("hasBorder")}let d=s-e,p=o-n,{svgFactory:m}=this,b=m.createElement("svg");b.classList.add("quadrilateralsContainer"),b.setAttribute("width",0),b.setAttribute("height",0);let v=m.createElement("defs");b.append(v);let A=m.createElement("clipPath"),x=`clippath_${this.data.id}`;A.setAttribute("id",x),A.setAttribute("clipPathUnits","objectBoundingBox"),v.append(A);for(let w=2,k=t.length;w<k;w+=8){let I=t[w],P=t[w+1],M=t[w+2],N=t[w+3],D=m.createElement("rect"),U=(M-e)/d,G=(o-P)/p,H=(I-M)/d,W=(P-N)/p;D.setAttribute("x",U),D.setAttribute("y",G),D.setAttribute("width",H),D.setAttribute("height",W),A.append(D),u?.push(`<rect vector-effect="non-scaling-stroke" x="${U}" y="${G}" width="${H}" height="${W}"/>`)}this.#e&&(u.push("</g></svg>')"),l.backgroundImage=u.join("")),this.container.append(b),this.container.style.clipPath=`url(#${x})`}_createPopup(){let{data:t}=this,e=this.#n=new Gr({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){$t("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let n=[];if(this._fieldObjects){let s=this._fieldObjects[t];if(s)for(let{page:o,id:l,exportValues:u}of s){if(o===-1||l===e)continue;let d=typeof u=="string"?u:null,p=document.querySelector(`[data-element-id="${l}"]`);if(p&&!Gn.has(p)){Pt(`_getElementsByName - element not allowed: ${l}`);continue}n.push({id:l,exportValue:d,domElement:p})}return n}for(let s of document.getElementsByName(t)){let{exportValue:o}=s,l=s.getAttribute("data-element-id");l!==e&&Gn.has(s)&&n.push({id:l,exportValue:o,domElement:s})}return n}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let 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})})}},si=class extends Jt{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,n=document.createElement("a");n.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(n,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(n,t.action),s=!0):t.attachment?(this.#e(n,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#n(n,t.setOCGState),s=!0):t.dest?(this._bindLink(n,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,t),s=!0),t.resetForm?(this._bindResetFormAction(n,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(n,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(n),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||e==="")&&this.#t()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#t()}#e(t,e,n=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,n),!1),this.#t()}#n(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let s of Object.keys(e.actions)){let o=n.get(s);o&&(t[o]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){let n=t.onclick;if(n||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){Pt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(t.onclick=()=>!1);return}t.onclick=()=>{n?.();let{fields:s,refs:o,include:l}=e,u=[];if(s.length!==0||o.length!==0){let m=new Set(o);for(let b of s){let v=this._fieldObjects[b]||[];for(let{id:A}of v)m.add(A)}for(let b of Object.values(this._fieldObjects))for(let v of b)m.has(v.id)===l&&u.push(v)}else for(let m of Object.values(this._fieldObjects))u.push(...m);let d=this.annotationStorage,p=[];for(let m of u){let{id:b}=m;switch(p.push(b),m.type){case"text":{let A=m.defaultValue||"";d.setValue(b,{value:A});break}case"checkbox":case"radiobutton":{let A=m.defaultValue===m.exportValues;d.setValue(b,{value:A});break}case"combobox":case"listbox":{let A=m.defaultValue||"";d.setValue(b,{value:A});break}default:continue}let v=document.querySelector(`[data-element-id="${b}"]`);if(v){if(!Gn.has(v)){Pt(`_bindResetFormAction - element not allowed: ${b}`);continue}}else continue;v.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:p,name:"ResetForm"}}),!1}}},Ra=class extends Jt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let t=document.createElement("img");return 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._createPopup(),this.container.append(t),this.container}},on=class extends Jt{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return se.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,n,s,o){n.includes("mouse")?t.addEventListener(n,l=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:o(l),shift:l.shiftKey,modifier:this._getKeyModifier(l)}})}):t.addEventListener(n,l=>{if(n==="blur"){if(!e.focused||!l.relatedTarget)return;e.focused=!1}else if(n==="focus"){if(e.focused)return;e.focused=!0}o&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:o(l)}})})}_setEventListeners(t,e,n,s){for(let[o,l]of n)(l==="Action"||this.data.actions?.[l])&&((l==="Focus"||l==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,o,l,s),l==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):l==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":xt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){let e=["left","center","right"],{fontColor:n}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||Zy,o=t.style,l,u=2,d=p=>Math.round(10*p)/10;if(this.data.multiLine){let p=Math.abs(this.data.rect[3]-this.data.rect[1]-u),m=Math.round(p/(_s*s))||1,b=p/m;l=Math.min(s,d(b/_s))}else{let p=Math.abs(this.data.rect[3]-this.data.rect[1]-u);l=Math.min(s,d(p/_s))}o.fontSize=`calc(${l}px * var(--scale-factor))`,o.color=xt.makeHexColor(n[0],n[1],n[2]),this.data.textAlignment!==null&&(o.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}},Oa=class extends on{constructor(t){let e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,n,s){let o=this.annotationStorage;for(let l of this._getElementsByName(t.name,t.id))l.domElement&&(l.domElement[e]=n),o.setValue(l.id,{[s]:n})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){let s=t.getValue(e,{value:this.data.fieldValue}),o=s.value||"",l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let u=s.formattedValue||this.data.textContent?.join(`
5
- `)||null;u&&this.data.comb&&(u=u.replaceAll(/\s+/g,""));let d={userValue:o,formattedValue:u,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=u??o,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type="text",n.setAttribute("value",u??o),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),Gn.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=Wr,this._setRequired(n,this.data.required),l&&(n.maxLength=l),n.addEventListener("input",m=>{t.setValue(e,{value:m.target.value}),this.setPropertyOnSiblings(n,"value",m.target.value,"value"),d.formattedValue=null}),n.addEventListener("resetform",m=>{let b=this.data.defaultFieldValue??"";n.value=d.userValue=b,d.formattedValue=null});let p=m=>{let{formattedValue:b}=d;b!=null&&(m.target.value=b),m.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",b=>{if(d.focused)return;let{target:v}=b;d.userValue&&(v.value=d.userValue),d.lastCommittedValue=v.value,d.commitKey=1,this.data.actions?.Focus||(d.focused=!0)}),n.addEventListener("updatefromsandbox",b=>{this.showElementAndHideCanvas(b.target);let v={value(A){d.userValue=A.detail.value??"",t.setValue(e,{value:d.userValue.toString()}),A.target.value=d.userValue},formattedValue(A){let{formattedValue:x}=A.detail;d.formattedValue=x,x!=null&&A.target!==document.activeElement&&(A.target.value=x),t.setValue(e,{formattedValue:x})},selRange(A){A.target.setSelectionRange(...A.detail.selRange)},charLimit:A=>{let{charLimit:x}=A.detail,{target:w}=A;if(x===0){w.removeAttribute("maxLength");return}w.setAttribute("maxLength",x);let k=d.userValue;!k||k.length<=x||(k=k.slice(0,x),w.value=d.userValue=k,t.setValue(e,{value:k}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:k,willCommit:!0,commitKey:1,selStart:w.selectionStart,selEnd:w.selectionEnd}}))}};this._dispatchEventFromSandbox(v,b)}),n.addEventListener("keydown",b=>{d.commitKey=1;let v=-1;if(b.key==="Escape"?v=0:b.key==="Enter"&&!this.data.multiLine?v=2:b.key==="Tab"&&(d.commitKey=3),v===-1)return;let{value:A}=b.target;d.lastCommittedValue!==A&&(d.lastCommittedValue=A,d.userValue=A,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:v,selStart:b.target.selectionStart,selEnd:b.target.selectionEnd}}))});let m=p;p=null,n.addEventListener("blur",b=>{if(!d.focused||!b.relatedTarget)return;this.data.actions?.Blur||(d.focused=!1);let{value:v}=b.target;d.userValue=v,d.lastCommittedValue!==v&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:d.commitKey,selStart:b.target.selectionStart,selEnd:b.target.selectionEnd}}),m(b)}),this.data.actions?.Keystroke&&n.addEventListener("beforeinput",b=>{d.lastCommittedValue=null;let{data:v,target:A}=b,{value:x,selectionStart:w,selectionEnd:k}=A,I=w,P=k;switch(b.inputType){case"deleteWordBackward":{let M=x.substring(0,w).match(/\w*[^\w]*$/);M&&(I-=M[0].length);break}case"deleteWordForward":{let M=x.substring(w).match(/^[^\w]*\w*/);M&&(P+=M[0].length);break}case"deleteContentBackward":w===k&&(I-=1);break;case"deleteContentForward":w===k&&(P+=1);break}b.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:x,change:v||"",willCommit:!1,selStart:I,selEnd:P}})}),this._setEventListeners(n,d,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],b=>b.target.value)}if(p&&n.addEventListener("blur",p),this.data.comb){let b=(this.data.rect[2]-this.data.rect[0])/l;n.classList.add("comb"),n.style.letterSpacing=`calc(${b}px * var(--scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}},Ma=class extends on{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}},La=class extends on{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,n=e.id,s=t.getValue(n,{value:e.exportValue===e.fieldValue}).value;typeof s=="string"&&(s=s!=="Off",t.setValue(n,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let o=document.createElement("input");return Gn.add(o),o.setAttribute("data-element-id",n),o.disabled=e.readOnly,this._setRequired(o,this.data.required),o.type="checkbox",o.name=e.fieldName,s&&o.setAttribute("checked",!0),o.setAttribute("exportValue",e.exportValue),o.tabIndex=Wr,o.addEventListener("change",l=>{let{name:u,checked:d}=l.target;for(let p of this._getElementsByName(u,n)){let m=d&&p.exportValue===e.exportValue;p.domElement&&(p.domElement.checked=m),t.setValue(p.id,{value:m})}t.setValue(n,{value:d})}),o.addEventListener("resetform",l=>{let u=e.defaultFieldValue||"Off";l.target.checked=u===e.exportValue}),this.enableScripting&&this.hasJSActions&&(o.addEventListener("updatefromsandbox",l=>{let u={value(d){d.target.checked=d.detail.value!=="Off",t.setValue(n,{value:d.target.checked})}};this._dispatchEventFromSandbox(u,l)}),this._setEventListeners(o,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],l=>l.target.checked)),this._setBackgroundColor(o),this._setDefaultPropertiesFromJS(o),this.container.append(o),this.container}},ii=class extends on{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,n=e.id,s=t.getValue(n,{value:e.fieldValue===e.buttonValue}).value;if(typeof s=="string"&&(s=s!==e.buttonValue,t.setValue(n,{value:s})),s)for(let l of this._getElementsByName(e.fieldName,n))t.setValue(l.id,{value:!1});let o=document.createElement("input");if(Gn.add(o),o.setAttribute("data-element-id",n),o.disabled=e.readOnly,this._setRequired(o,this.data.required),o.type="radio",o.name=e.fieldName,s&&o.setAttribute("checked",!0),o.tabIndex=Wr,o.addEventListener("change",l=>{let{name:u,checked:d}=l.target;for(let p of this._getElementsByName(u,n))t.setValue(p.id,{value:!1});t.setValue(n,{value:d})}),o.addEventListener("resetform",l=>{let u=e.defaultFieldValue;l.target.checked=u!=null&&u===e.buttonValue}),this.enableScripting&&this.hasJSActions){let l=e.buttonValue;o.addEventListener("updatefromsandbox",u=>{let d={value:p=>{let m=l===p.detail.value;for(let b of this._getElementsByName(p.target.name)){let v=m&&b.id===n;b.domElement&&(b.domElement.checked=v),t.setValue(b.id,{value:v})}}};this._dispatchEventFromSandbox(d,u)}),this._setEventListeners(o,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],u=>u.target.checked)}return this._setBackgroundColor(o),this._setDefaultPropertiesFromJS(o),this.container.append(o),this.container}},Fa=class extends si{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",n=>{this._dispatchEventFromSandbox({},n)})),t}},Da=class extends on{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,n=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");Gn.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=Wr;let o=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",m=>{let b=this.data.defaultFieldValue;for(let v of s.options)v.selected=v.value===b});for(let m of this.data.options){let b=document.createElement("option");b.textContent=m.displayValue,b.value=m.exportValue,n.value.includes(m.exportValue)&&(b.setAttribute("selected",!0),o=!1),s.append(b)}let l=null;if(o){let m=document.createElement("option");m.value=" ",m.setAttribute("hidden",!0),m.setAttribute("selected",!0),s.prepend(m),l=()=>{m.remove(),s.removeEventListener("input",l),l=null},s.addEventListener("input",l)}let u=m=>{let b=m?"value":"textContent",{options:v,multiple:A}=s;return A?Array.prototype.filter.call(v,x=>x.selected).map(x=>x[b]):v.selectedIndex===-1?null:v[v.selectedIndex][b]},d=u(!1),p=m=>{let b=m.target.options;return Array.prototype.map.call(b,v=>({displayValue:v.textContent,exportValue:v.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",m=>{let b={value(v){l?.();let A=v.detail.value,x=new Set(Array.isArray(A)?A:[A]);for(let w of s.options)w.selected=x.has(w.value);t.setValue(e,{value:u(!0)}),d=u(!1)},multipleSelection(v){s.multiple=!0},remove(v){let A=s.options,x=v.detail.remove;A[x].selected=!1,s.remove(x),A.length>0&&Array.prototype.findIndex.call(A,k=>k.selected)===-1&&(A[0].selected=!0),t.setValue(e,{value:u(!0),items:p(v)}),d=u(!1)},clear(v){for(;s.length!==0;)s.remove(0);t.setValue(e,{value:null,items:[]}),d=u(!1)},insert(v){let{index:A,displayValue:x,exportValue:w}=v.detail.insert,k=s.children[A],I=document.createElement("option");I.textContent=x,I.value=w,k?k.before(I):s.append(I),t.setValue(e,{value:u(!0),items:p(v)}),d=u(!1)},items(v){let{items:A}=v.detail;for(;s.length!==0;)s.remove(0);for(let x of A){let{displayValue:w,exportValue:k}=x,I=document.createElement("option");I.textContent=w,I.value=k,s.append(I)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:u(!0),items:p(v)}),d=u(!1)},indices(v){let A=new Set(v.detail.indices);for(let x of v.target.options)x.selected=A.has(x.index);t.setValue(e,{value:u(!0)}),d=u(!1)},editable(v){v.target.disabled=!v.detail.editable}};this._dispatchEventFromSandbox(b,m)}),s.addEventListener("input",m=>{let b=u(!0),v=u(!1);t.setValue(e,{value:b}),m.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:d,change:v,changeEx:b,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],m=>m.target.value)):s.addEventListener("input",function(m){t.setValue(e,{value:u(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}},Gr=class extends Jt{constructor(t){let{data:e,elements:n}=t;super(t,{isRenderable:Jt._hasPopupData(e)}),this.elements=n,this.popup=null}render(){this.container.classList.add("popupAnnotation");let t=this.popup=new _a({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(let n of this.elements)n.popup=t,n.container.ariaHasPopup="dialog",e.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(n=>`${il}${n}`).join(",")),this.container}},_a=class{#t=this.#k.bind(this);#e=this.#C.bind(this);#n=this.#I.bind(this);#r=this.#A.bind(this);#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=!1;#f=null;#o=null;#p=null;#m=null;#g=null;#b=null;#x=!1;constructor({container:t,color:e,elements:n,titleObj:s,modificationDate:o,contentsObj:l,richText:u,parent:d,rect:p,parentRect:m,open:b}){this.#s=t,this.#g=s,this.#l=l,this.#m=u,this.#c=d,this.#i=e,this.#p=p,this.#d=m,this.#u=n,this.#a=Gs.toDateObject(o),this.trigger=n.flatMap(v=>v.getElementsToTriggerPopup());for(let v of this.trigger)v.addEventListener("click",this.#r),v.addEventListener("mouseenter",this.#n),v.addEventListener("mouseleave",this.#e),v.classList.add("popupTriggerArea");for(let v of n)v.container?.addEventListener("keydown",this.#t);this.#s.hidden=!0,b&&this.#A()}render(){if(this.#f)return;let t=this.#f=document.createElement("div");if(t.className="popup",this.#i){let o=t.style.outlineColor=xt.makeHexColor(...this.#i);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${o} 30%, white)`:t.style.backgroundColor=xt.makeHexColor(...this.#i.map(u=>Math.floor(.7*(255-u)+u)))}let e=document.createElement("span");e.className="header";let n=document.createElement("h1");if(e.append(n),{dir:n.dir,str:n.textContent}=this.#g,t.append(e),this.#a){let o=document.createElement("span");o.classList.add("popupDate"),o.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),o.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#a.valueOf()})),e.append(o)}let s=this.#y;if(s)ri.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{let o=this._formatContents(this.#l);t.append(o)}this.#s.append(t)}get#y(){let t=this.#m,e=this.#l;return t?.str&&(!e?.str||e.str===t.str)&&this.#m.html||null}get#S(){return this.#y?.attributes?.style?.fontSize||0}get#T(){return this.#y?.attributes?.style?.color||null}#E(t){let e=[],n={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#T,fontSize:this.#S?`calc(${this.#S}px * var(--scale-factor))`:""}};for(let o of t.split(`
6
- `))e.push({name:"span",value:o,attributes:s});return n}_formatContents({str:t,dir:e}){let n=document.createElement("p");n.classList.add("popupContent"),n.dir=e;let s=t.split(/(?:\r\n?|\n)/);for(let o=0,l=s.length;o<l;++o){let u=s[o];n.append(document.createTextNode(u)),o<l-1&&n.append(document.createElement("br"))}return n}#k(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#h)&&this.#A()}updateEdited({rect:t,popupContent:e}){this.#b||={contentsObj:this.#l,richText:this.#m},t&&(this.#o=null),e&&(this.#m=this.#E(e),this.#l=null),this.#f?.remove(),this.#f=null}resetEdited(){this.#b&&({contentsObj:this.#l,richText:this.#m}=this.#b,this.#b=null,this.#f?.remove(),this.#f=null,this.#o=null)}#P(){if(this.#o!==null)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:n,pageX:s,pageY:o}}}=this.#c,l=!!this.#d,u=l?this.#d:this.#p;for(let x of this.#u)if(!u||xt.intersect(x.data.rect,u)!==null){u=x.data.rect,l=!0;break}let d=xt.normalizeRect([u[0],t[3]-u[1]+t[1],u[2],t[3]-u[3]+t[1]]),m=l?u[2]-u[0]+5:0,b=d[0]+m,v=d[1];this.#o=[100*(b-s)/e,100*(v-o)/n];let{style:A}=this.#s;A.left=`${this.#o[0]}%`,A.top=`${this.#o[1]}%`}#A(){this.#h=!this.#h,this.#h?(this.#I(),this.#s.addEventListener("click",this.#r),this.#s.addEventListener("keydown",this.#t)):(this.#C(),this.#s.removeEventListener("click",this.#r),this.#s.removeEventListener("keydown",this.#t))}#I(){this.#f||this.render(),this.isVisible?this.#h&&this.#s.classList.add("focused"):(this.#P(),this.#s.hidden=!1,this.#s.style.zIndex=parseInt(this.#s.style.zIndex)+1e3)}#C(){this.#s.classList.remove("focused"),!(this.#h||!this.isVisible)&&(this.#s.hidden=!0,this.#s.style.zIndex=parseInt(this.#s.style.zIndex)-1e3)}forceHide(){this.#x=this.isVisible,this.#x&&(this.#s.hidden=!0)}maybeShow(){this.#x&&(this.#f||this.#I(),this.#x=!1,this.#s.hidden=!1)}get isVisible(){return this.#s.hidden===!1}},oi=class extends Jt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Mt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(let e of this.textContent){let n=document.createElement("span");n.textContent=e,t.append(n)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},Na=class extends Jt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let t=this.data,{width:e,height:n}=yn(t.rect),s=this.svgFactory.create(e,n,!0),o=this.#t=this.svgFactory.createElement("svg:line");return o.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),o.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),o.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),o.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),o.setAttribute("stroke-width",t.borderStyle.width||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),s.append(o),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},Ua=class extends Jt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let t=this.data,{width:e,height:n}=yn(t.rect),s=this.svgFactory.create(e,n,!0),o=t.borderStyle.width,l=this.#t=this.svgFactory.createElement("svg:rect");return l.setAttribute("x",o/2),l.setAttribute("y",o/2),l.setAttribute("width",e-o),l.setAttribute("height",n-o),l.setAttribute("stroke-width",o||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),s.append(l),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},Ba=class extends Jt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let t=this.data,{width:e,height:n}=yn(t.rect),s=this.svgFactory.create(e,n,!0),o=t.borderStyle.width,l=this.#t=this.svgFactory.createElement("svg:ellipse");return l.setAttribute("cx",e/2),l.setAttribute("cy",n/2),l.setAttribute("rx",e/2-o/2),l.setAttribute("ry",n/2-o/2),l.setAttribute("stroke-width",o||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),s.append(l),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},ai=class extends Jt{#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:n,popupRef:s}}=this;if(!e)return this.container;let{width:o,height:l}=yn(t),u=this.svgFactory.create(o,l,!0),d=[];for(let m=0,b=e.length;m<b;m+=2){let v=e[m]-t[0],A=t[3]-e[m+1];d.push(`${v},${A}`)}d=d.join(" ");let p=this.#t=this.svgFactory.createElement(this.svgElementName);return p.setAttribute("points",d),p.setAttribute("stroke-width",n.width||1),p.setAttribute("stroke","transparent"),p.setAttribute("fill","transparent"),u.append(p),this.container.append(u),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}},Ga=class extends ai{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}},Ha=class extends Jt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}},Hr=class extends Jt{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?Mt.HIGHLIGHT:Mt.INK}#n(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:n,borderStyle:s,popupRef:o}}=this,{transform:l,width:u,height:d}=this.#n(e,t),p=this.svgFactory.create(u,d,!0),m=this.#t=this.svgFactory.createElement("svg:g");p.append(m),m.setAttribute("stroke-width",s.width||1),m.setAttribute("stroke-linecap","round"),m.setAttribute("stroke-linejoin","round"),m.setAttribute("stroke-miterlimit",10),m.setAttribute("stroke","transparent"),m.setAttribute("fill","transparent"),m.setAttribute("transform",l);for(let b=0,v=n.length;b<v;b++){let A=this.svgFactory.createElement(this.svgElementName);this.#e.push(A),A.setAttribute("points",n[b].join(",")),m.append(A)}return!o&&this.hasPopupData&&this._createPopup(),this.container.append(p),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:n,rect:s}=t,o=this.#t;if(e>=0&&o.setAttribute("stroke-width",e||1),n)for(let l=0,u=this.#e.length;l<u;l++)this.#e[l].setAttribute("points",n[l].join(","));if(s){let{transform:l,width:u,height:d}=this.#n(this.data.rotation,s);o.parentElement.setAttribute("viewBox",`0 0 ${u} ${d}`),o.setAttribute("transform",l)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}},li=class extends Jt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Mt.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}},ja=class extends Jt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}},Va=class extends Jt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}},Wa=class extends Jt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}},ci=class extends Jt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Mt.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},$a=class extends Jt{#t=null;constructor(t){super(t,{isRenderable:!0});let{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:t,data:e}=this,n;e.hasAppearance||e.fillAlpha===0?n=document.createElement("div"):(n=document.createElement("img"),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),n.addEventListener("dblclick",this.#e.bind(this)),this.#t=n;let{isMac:s}=se.platform;return t.addEventListener("keydown",o=>{o.key==="Enter"&&(s?o.metaKey:o.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?this._createPopup():n.classList.add("popupTriggerArea"),t.append(n),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}},za=class{#t=null;#e=null;#n=new Map;#r=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:n,annotationEditorUIManager:s,page:o,viewport:l,structTreeLayer:u}){this.div=t,this.#t=e,this.#e=n,this.#r=u||null,this.page=o,this.viewport=l,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#n.size>0}async#i(t,e){let n=t.firstChild||t,s=n.id=`${il}${e}`,o=await this.#r?.getAriaAttributes(s);if(o)for(let[l,u]of o)n.setAttribute(l,u);this.div.append(t),this.#t?.moveElementInDOM(this.div,t,n,!1)}async render(t){let{annotations:e}=t,n=this.div;Nn(n,this.viewport);let s=new Map,o={data:null,layer:n,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Br,annotationStorage:t.annotationStorage||new Dr,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let l of e){if(l.noHTML)continue;let u=l.annotationType===ne.POPUP;if(u){let m=s.get(l.id);if(!m)continue;o.elements=m}else{let{width:m,height:b}=yn(l.rect);if(m<=0||b<=0)continue}o.data=l;let d=Pa.create(o);if(!d.isRenderable)continue;if(!u&&l.popupRef){let m=s.get(l.popupRef);m?m.push(d):s.set(l.popupRef,[d])}let p=d.render();l.hidden&&(p.style.visibility="hidden"),await this.#i(p,l.id),d._isEditable&&(this.#n.set(d.data.id,d),this._annotationEditorUIManager?.renderAnnotationElement(d))}this.#s()}update({viewport:t}){let e=this.div;this.viewport=t,Nn(e,{rotation:t.rotation}),this.#s(),e.hidden=!1}#s(){if(!this.#e)return;let t=this.div;for(let[e,n]of this.#e){let s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;n.className="annotationContent";let{firstChild:o}=s;o?o.nodeName==="CANVAS"?o.replaceWith(n):o.classList.contains("annotationContent")?o.after(n):o.before(n):s.append(n)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#n.values())}getEditableAnnotation(t){return this.#n.get(t)}},Ds=/\r\n?|\n/g,Xa=class i extends Yt{#t;#e="";#n=`${this.id}-editor`;#r=null;#i;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=i.prototype,e=o=>o.isEmpty(),n=Bn.TRANSLATE_SMALL,s=Bn.TRANSLATE_BIG;return Lt(this,"_keyboardManager",new Un([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=Mt.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#t=t.color||i._defaultColor||Yt._defaultLineColor,this.#i=t.fontSize||i._defaultFontSize}static initialize(t,e){Yt.initialize(t,e);let n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case Ft.FREETEXT_SIZE:i._defaultFontSize=e;break;case Ft.FREETEXT_COLOR:i._defaultColor=e;break}}updateParams(t,e){switch(t){case Ft.FREETEXT_SIZE:this.#s(e);break;case Ft.FREETEXT_COLOR:this.#l(e);break}}static get defaultPropertiesToUpdate(){return[[Ft.FREETEXT_SIZE,i._defaultFontSize],[Ft.FREETEXT_COLOR,i._defaultColor||Yt._defaultLineColor]]}get propertiesToUpdate(){return[[Ft.FREETEXT_SIZE,this.#i],[Ft.FREETEXT_COLOR,this.#t]]}#s(t){let e=s=>{this.editorDiv.style.fontSize=`calc(${s}px * var(--scale-factor))`,this.translate(0,-(s-this.#i)*this.parentScale),this.#i=s,this.#u()},n=this.#i;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ft.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#l(t){let e=s=>{this.#t=this.editorDiv.style.color=s},n=this.#t;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ft.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-i._internalPadding*t,-(i._internalPadding+this.#i)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(Mt.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#r=new AbortController;let t=this._uiManager.combinedSignal(this.#r);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})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#n),this._isDraggable=!0,this.#r?.abort(),this.#r=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#a(){let t=[];this.editorDiv.normalize();let e=null;for(let n of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&n.nodeName==="BR"||(t.push(i.#c(n)),e=n);return t.join(`
7
- `)}#u(){let[t,e]=this.parentDimensions,n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{let{currentLayer:s,div:o}=this,l=o.style.display,u=o.classList.contains("hidden");o.classList.remove("hidden"),o.style.display="hidden",s.div.append(this.div),n=o.getBoundingClientRect(),o.remove(),o.style.display=l,o.classList.toggle("hidden",u)}this.rotation%180===this.parentRotation%180?(this.width=n.width/t,this.height=n.height/e):(this.width=n.height/t,this.height=n.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#e,e=this.#e=this.#a().trimEnd();if(t===e)return;let n=s=>{if(this.#e=s,!s){this.remove();return}this.#d(),this._uiManager.rebuild(this),this.#u()};this.addCommands({cmd:()=>{n(e)},undo:()=>{n(t)},mustExec:!1}),this.#u()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){i._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)}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#n),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:n}=this.editorDiv;if(n.fontSize=`calc(${this.#i}px * var(--scale-factor))`,n.color=this.#t,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Hs(this,this.div,["dblclick","keydown"]),this.width){let[s,o]=this.parentDimensions;if(this.annotationElementId){let{position:l}=this._initialData,[u,d]=this.getInitialTranslation();[u,d]=this.pageTranslationToScreen(u,d);let[p,m]=this.pageDimensions,[b,v]=this.pageTranslation,A,x;switch(this.rotation){case 0:A=t+(l[0]-b)/p,x=e+this.height-(l[1]-v)/m;break;case 90:A=t+(l[0]-b)/p,x=e-(l[1]-v)/m,[u,d]=[d,-u];break;case 180:A=t-this.width+(l[0]-b)/p,x=e-(l[1]-v)/m,[u,d]=[-u,-d];break;case 270:A=t+(l[0]-b-this.height*m)/p,x=e+(l[1]-v-this.width*p)/m,[u,d]=[-d,u];break}this.setAt(A*s,x*o,u,d)}else this.setAt(t*s,e*o,this.width*s,this.height*o);this.#d(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#c(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Ds,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:n}=e;if(n.length===1&&n[0]==="text/plain")return;t.preventDefault();let s=i.#f(e.getData("text")||"").replaceAll(Ds,`
8
- `);if(!s)return;let o=window.getSelection();if(!o.rangeCount)return;this.editorDiv.normalize(),o.deleteFromDocument();let l=o.getRangeAt(0);if(!s.includes(`
9
- `)){l.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),o.collapseToStart();return}let{startContainer:u,startOffset:d}=l,p=[],m=[];if(u.nodeType===Node.TEXT_NODE){let A=u.parentElement;if(m.push(u.nodeValue.slice(d).replaceAll(Ds,"")),A!==this.editorDiv){let x=p;for(let w of this.editorDiv.childNodes){if(w===A){x=m;continue}x.push(i.#c(w))}}p.push(u.nodeValue.slice(0,d).replaceAll(Ds,""))}else if(u===this.editorDiv){let A=p,x=0;for(let w of this.editorDiv.childNodes)x++===d&&(A=m),A.push(i.#c(w))}this.#e=`${p.join(`
10
- `)}${s}${m.join(`
11
- `)}`,this.#d();let b=new Range,v=p.reduce((A,x)=>A+x.length,0);for(let{firstChild:A}of this.editorDiv.childNodes)if(A.nodeType===Node.TEXT_NODE){let x=A.nodeValue.length;if(v<=x){b.setStart(A,v),b.setEnd(A,v);break}v-=x}o.removeAllRanges(),o.addRange(b)}#d(){if(this.editorDiv.replaceChildren(),!!this.#e)for(let t of this.#e.split(`
12
- `)){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#h(){return this.#e.replaceAll("\xA0"," ")}static#f(t){return t.replaceAll(" ","\xA0")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,n){let s=null;if(t instanceof oi){let{data:{defaultAppearanceData:{fontSize:l,fontColor:u},rect:d,rotation:p,id:m,popupRef:b},textContent:v,textPosition:A,parent:{page:{pageNumber:x}}}=t;if(!v||v.length===0)return null;s=t={annotationType:Mt.FREETEXT,color:Array.from(u),fontSize:l,value:v.join(`
13
- `),position:A,pageIndex:x-1,rect:d.slice(0),rotation:p,id:m,deleted:!1,popupRef:b}}let o=await super.deserialize(t,e,n);return o.#i=t.fontSize,o.#t=xt.makeHexColor(...t.color),o.#e=i.#f(t.value),o.annotationElementId=t.id||null,o._initialData=s,o}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=i._internalPadding*this.parentScale,n=this.getRect(e,e),s=Yt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#t),o={annotationType:Mt.FREETEXT,color:s,fontSize:this.#i,value:this.#h(),pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!this.#o(o)?null:(o.id=this.annotationElementId,o)}#o(t){let{value:e,fontSize:n,color:s,pageIndex:o}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==n||t.color.some((l,u)=>l!==s[u])||t.pageIndex!==o}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(this.deleted)return e;let{style:n}=e;n.fontSize=`calc(${this.#i}px * var(--scale-factor))`,n.color=this.#t,e.replaceChildren();for(let o of this.#e.split(`
14
- `)){let l=document.createElement("div");l.append(o?document.createTextNode(o):document.createElement("br")),e.append(l)}let s=i._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#e}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}},pt=class{static PRECISION=1e-4;toSVGPath(){$t("Abstract method `toSVGPath` must be implemented.")}get box(){$t("Abstract getter `box` must be implemented.")}serialize(t,e){$t("Abstract method `serialize` must be implemented.")}static _rescale(t,e,n,s,o,l){l||=new Float32Array(t.length);for(let u=0,d=t.length;u<d;u+=2)l[u]=e+t[u]*s,l[u+1]=n+t[u+1]*o;return l}static _rescaleAndSwap(t,e,n,s,o,l){l||=new Float32Array(t.length);for(let u=0,d=t.length;u<d;u+=2)l[u]=e+t[u+1]*s,l[u+1]=n+t[u]*o;return l}static _translate(t,e,n,s){s||=new Float32Array(t.length);for(let o=0,l=t.length;o<l;o+=2)s[o]=e+t[o],s[o+1]=n+t[o+1];return s}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,n,s,o){switch(o){case 90:return[1-e/n,t/s];case 180:return[1-t/n,1-e/s];case 270:return[e/n,1-t/s];default:return[t/n,e/s]}}static _normalizePagePoint(t,e,n){switch(n){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,n,s,o,l){return[(t+5*n)/6,(e+5*s)/6,(5*n+o)/6,(5*s+l)/6,(n+o)/2,(s+l)/2]}},ui=class i{#t;#e=[];#n;#r;#i=[];#s=new Float32Array(18);#l;#a;#u;#c;#d;#h;#f=[];static#o=8;static#p=2;static#m=i.#o+i.#p;constructor({x:t,y:e},n,s,o,l,u=0){this.#t=n,this.#h=o*s,this.#r=l,this.#s.set([NaN,NaN,NaN,NaN,t,e],6),this.#n=u,this.#c=i.#o*s,this.#u=i.#m*s,this.#d=s,this.#f.push(t,e)}isEmpty(){return isNaN(this.#s[8])}#g(){let t=this.#s.subarray(4,6),e=this.#s.subarray(16,18),[n,s,o,l]=this.#t;return[(this.#l+(t[0]-e[0])/2-n)/o,(this.#a+(t[1]-e[1])/2-s)/l,(this.#l+(e[0]-t[0])/2-n)/o,(this.#a+(e[1]-t[1])/2-s)/l]}add({x:t,y:e}){this.#l=t,this.#a=e;let[n,s,o,l]=this.#t,[u,d,p,m]=this.#s.subarray(8,12),b=t-p,v=e-m,A=Math.hypot(b,v);if(A<this.#u)return!1;let x=A-this.#c,w=x/A,k=w*b,I=w*v,P=u,M=d;u=p,d=m,p+=k,m+=I,this.#f?.push(t,e);let N=-I/x,D=k/x,U=N*this.#h,G=D*this.#h;return this.#s.set(this.#s.subarray(2,8),0),this.#s.set([p+U,m+G],4),this.#s.set(this.#s.subarray(14,18),12),this.#s.set([p-U,m-G],16),isNaN(this.#s[6])?(this.#i.length===0&&(this.#s.set([u+U,d+G],2),this.#i.push(NaN,NaN,NaN,NaN,(u+U-n)/o,(d+G-s)/l),this.#s.set([u-U,d-G],14),this.#e.push(NaN,NaN,NaN,NaN,(u-U-n)/o,(d-G-s)/l)),this.#s.set([P,M,u,d,p,m],6),!this.isEmpty()):(this.#s.set([P,M,u,d,p,m],6),Math.abs(Math.atan2(M-d,P-u)-Math.atan2(I,k))<Math.PI/2?([u,d,p,m]=this.#s.subarray(2,6),this.#i.push(NaN,NaN,NaN,NaN,((u+p)/2-n)/o,((d+m)/2-s)/l),[u,d,P,M]=this.#s.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((P+u)/2-n)/o,((M+d)/2-s)/l),!0):([P,M,u,d,p,m]=this.#s.subarray(0,6),this.#i.push(((P+5*u)/6-n)/o,((M+5*d)/6-s)/l,((5*u+p)/6-n)/o,((5*d+m)/6-s)/l,((u+p)/2-n)/o,((d+m)/2-s)/l),[p,m,u,d,P,M]=this.#s.subarray(12,18),this.#e.push(((P+5*u)/6-n)/o,((M+5*d)/6-s)/l,((5*u+p)/6-n)/o,((5*d+m)/6-s)/l,((u+p)/2-n)/o,((d+m)/2-s)/l),!0))}toSVGPath(){if(this.isEmpty())return"";let t=this.#i,e=this.#e;if(isNaN(this.#s[6])&&!this.isEmpty())return this.#b();let n=[];n.push(`M${t[4]} ${t[5]}`);for(let s=6;s<t.length;s+=6)isNaN(t[s])?n.push(`L${t[s+4]} ${t[s+5]}`):n.push(`C${t[s]} ${t[s+1]} ${t[s+2]} ${t[s+3]} ${t[s+4]} ${t[s+5]}`);this.#y(n);for(let s=e.length-6;s>=6;s-=6)isNaN(e[s])?n.push(`L${e[s+4]} ${e[s+5]}`):n.push(`C${e[s]} ${e[s+1]} ${e[s+2]} ${e[s+3]} ${e[s+4]} ${e[s+5]}`);return this.#x(n),n.join(" ")}#b(){let[t,e,n,s]=this.#t,[o,l,u,d]=this.#g();return`M${(this.#s[2]-t)/n} ${(this.#s[3]-e)/s} L${(this.#s[4]-t)/n} ${(this.#s[5]-e)/s} L${o} ${l} L${u} ${d} L${(this.#s[16]-t)/n} ${(this.#s[17]-e)/s} L${(this.#s[14]-t)/n} ${(this.#s[15]-e)/s} Z`}#x(t){let e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#y(t){let[e,n,s,o]=this.#t,l=this.#s.subarray(4,6),u=this.#s.subarray(16,18),[d,p,m,b]=this.#g();t.push(`L${(l[0]-e)/s} ${(l[1]-n)/o} L${d} ${p} L${m} ${b} L${(u[0]-e)/s} ${(u[1]-n)/o}`)}newFreeDrawOutline(t,e,n,s,o,l){return new hi(t,e,n,s,o,l)}getOutlines(){let t=this.#i,e=this.#e,n=this.#s,[s,o,l,u]=this.#t,d=new Float32Array((this.#f?.length??0)+2);for(let b=0,v=d.length-2;b<v;b+=2)d[b]=(this.#f[b]-s)/l,d[b+1]=(this.#f[b+1]-o)/u;if(d[d.length-2]=(this.#l-s)/l,d[d.length-1]=(this.#a-o)/u,isNaN(n[6])&&!this.isEmpty())return this.#S(d);let p=new Float32Array(this.#i.length+24+this.#e.length),m=t.length;for(let b=0;b<m;b+=2){if(isNaN(t[b])){p[b]=p[b+1]=NaN;continue}p[b]=t[b],p[b+1]=t[b+1]}m=this.#E(p,m);for(let b=e.length-6;b>=6;b-=6)for(let v=0;v<6;v+=2){if(isNaN(e[b+v])){p[m]=p[m+1]=NaN,m+=2;continue}p[m]=e[b+v],p[m+1]=e[b+v+1],m+=2}return this.#T(p,m),this.newFreeDrawOutline(p,d,this.#t,this.#d,this.#n,this.#r)}#S(t){let e=this.#s,[n,s,o,l]=this.#t,[u,d,p,m]=this.#g(),b=new Float32Array(36);return b.set([NaN,NaN,NaN,NaN,(e[2]-n)/o,(e[3]-s)/l,NaN,NaN,NaN,NaN,(e[4]-n)/o,(e[5]-s)/l,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,p,m,NaN,NaN,NaN,NaN,(e[16]-n)/o,(e[17]-s)/l,NaN,NaN,NaN,NaN,(e[14]-n)/o,(e[15]-s)/l],0),this.newFreeDrawOutline(b,t,this.#t,this.#d,this.#n,this.#r)}#T(t,e){let n=this.#e;return t.set([NaN,NaN,NaN,NaN,n[4],n[5]],e),e+=6}#E(t,e){let n=this.#s.subarray(4,6),s=this.#s.subarray(16,18),[o,l,u,d]=this.#t,[p,m,b,v]=this.#g();return t.set([NaN,NaN,NaN,NaN,(n[0]-o)/u,(n[1]-l)/d,NaN,NaN,NaN,NaN,p,m,NaN,NaN,NaN,NaN,b,v,NaN,NaN,NaN,NaN,(s[0]-o)/u,(s[1]-l)/d],e),e+=24}},hi=class extends pt{#t;#e=new Float32Array(4);#n;#r;#i;#s;#l;constructor(t,e,n,s,o,l){super(),this.#l=t,this.#i=e,this.#t=n,this.#s=s,this.#n=o,this.#r=l,this.lastPoint=[NaN,NaN],this.#a(l);let[u,d,p,m]=this.#e;for(let b=0,v=t.length;b<v;b+=2)t[b]=(t[b]-u)/p,t[b+1]=(t[b+1]-d)/m;for(let b=0,v=e.length;b<v;b+=2)e[b]=(e[b]-u)/p,e[b+1]=(e[b+1]-d)/m}toSVGPath(){let t=[`M${this.#l[4]} ${this.#l[5]}`];for(let e=6,n=this.#l.length;e<n;e+=6){if(isNaN(this.#l[e])){t.push(`L${this.#l[e+4]} ${this.#l[e+5]}`);continue}t.push(`C${this.#l[e]} ${this.#l[e+1]} ${this.#l[e+2]} ${this.#l[e+3]} ${this.#l[e+4]} ${this.#l[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,n,s],o){let l=n-t,u=s-e,d,p;switch(o){case 0:d=pt._rescale(this.#l,t,s,l,-u),p=pt._rescale(this.#i,t,s,l,-u);break;case 90:d=pt._rescaleAndSwap(this.#l,t,e,l,u),p=pt._rescaleAndSwap(this.#i,t,e,l,u);break;case 180:d=pt._rescale(this.#l,n,e,-l,u),p=pt._rescale(this.#i,n,e,-l,u);break;case 270:d=pt._rescaleAndSwap(this.#l,n,s,-l,-u),p=pt._rescaleAndSwap(this.#i,n,s,-l,-u);break}return{outline:Array.from(d),points:[Array.from(p)]}}#a(t){let e=this.#l,n=e[4],s=e[5],o=n,l=s,u=n,d=s,p=n,m=s,b=t?Math.max:Math.min;for(let A=6,x=e.length;A<x;A+=6){if(isNaN(e[A]))o=Math.min(o,e[A+4]),l=Math.min(l,e[A+5]),u=Math.max(u,e[A+4]),d=Math.max(d,e[A+5]),m<e[A+5]?(p=e[A+4],m=e[A+5]):m===e[A+5]&&(p=b(p,e[A+4]));else{let w=xt.bezierBoundingBox(n,s,...e.slice(A,A+6));o=Math.min(o,w[0]),l=Math.min(l,w[1]),u=Math.max(u,w[2]),d=Math.max(d,w[3]),m<w[3]?(p=w[2],m=w[3]):m===w[3]&&(p=b(p,w[2]))}n=e[A+4],s=e[A+5]}let v=this.#e;v[0]=o-this.#n,v[1]=l-this.#n,v[2]=u-o+2*this.#n,v[3]=d-l+2*this.#n,this.lastPoint=[p,m]}get box(){return this.#e}newOutliner(t,e,n,s,o,l=0){return new ui(t,e,n,s,o,l)}getNewOutline(t,e){let[n,s,o,l]=this.#e,[u,d,p,m]=this.#t,b=o*p,v=l*m,A=n*p+u,x=s*m+d,w=this.newOutliner({x:this.#i[0]*b+A,y:this.#i[1]*v+x},this.#t,this.#s,t,this.#r,e??this.#n);for(let k=2;k<this.#i.length;k+=2)w.add({x:this.#i[k]*b+A,y:this.#i[k+1]*v+x});return w.getOutlines()}},jr=class{#t;#e;#n=[];#r=[];constructor(t,e=0,n=0,s=!0){let o=1/0,l=-1/0,u=1/0,d=-1/0,m=10**-4;for(let{x:I,y:P,width:M,height:N}of t){let D=Math.floor((I-e)/m)*m,U=Math.ceil((I+M+e)/m)*m,G=Math.floor((P-e)/m)*m,H=Math.ceil((P+N+e)/m)*m,W=[D,G,H,!0],J=[U,G,H,!1];this.#n.push(W,J),o=Math.min(o,D),l=Math.max(l,U),u=Math.min(u,G),d=Math.max(d,H)}let b=l-o+2*n,v=d-u+2*n,A=o-n,x=u-n,w=this.#n.at(s?-1:-2),k=[w[0],w[2]];for(let I of this.#n){let[P,M,N]=I;I[0]=(P-A)/b,I[1]=(M-x)/v,I[2]=(N-x)/v}this.#t=new Float32Array([A,x,b,v]),this.#e=k}getOutlines(){this.#n.sort((e,n)=>e[0]-n[0]||e[1]-n[1]||e[2]-n[2]);let t=[];for(let e of this.#n)e[3]?(t.push(...this.#u(e)),this.#l(e)):(this.#a(e),t.push(...this.#u(e)));return this.#i(t)}#i(t){let e=[],n=new Set;for(let l of t){let[u,d,p]=l;e.push([u,d,l],[u,p,l])}e.sort((l,u)=>l[1]-u[1]||l[0]-u[0]);for(let l=0,u=e.length;l<u;l+=2){let d=e[l][2],p=e[l+1][2];d.push(p),p.push(d),n.add(d),n.add(p)}let s=[],o;for(;n.size>0;){let l=n.values().next().value,[u,d,p,m,b]=l;n.delete(l);let v=u,A=d;for(o=[u,p],s.push(o);;){let x;if(n.has(m))x=m;else if(n.has(b))x=b;else break;n.delete(x),[u,d,p,m,b]=x,v!==u&&(o.push(v,A,u,A===d?d:p),v=u),A=A===d?p:d}o.push(v,A)}return new Ya(s,this.#t,this.#e)}#s(t){let e=this.#r,n=0,s=e.length-1;for(;n<=s;){let o=n+s>>1,l=e[o][0];if(l===t)return o;l<t?n=o+1:s=o-1}return s+1}#l([,t,e]){let n=this.#s(t);this.#r.splice(n,0,[t,e])}#a([,t,e]){let n=this.#s(t);for(let s=n;s<this.#r.length;s++){let[o,l]=this.#r[s];if(o!==t)break;if(o===t&&l===e){this.#r.splice(s,1);return}}for(let s=n-1;s>=0;s--){let[o,l]=this.#r[s];if(o!==t)break;if(o===t&&l===e){this.#r.splice(s,1);return}}}#u(t){let[e,n,s]=t,o=[[e,n,s]],l=this.#s(s);for(let u=0;u<l;u++){let[d,p]=this.#r[u];for(let m=0,b=o.length;m<b;m++){let[,v,A]=o[m];if(!(p<=v||A<=d)){if(v>=d){if(A>p)o[m][1]=p;else{if(b===1)return[];o.splice(m,1),m--,b--}continue}o[m][2]=d,A>p&&o.push([e,p,A])}}}return o}},Ya=class extends pt{#t;#e;constructor(t,e,n){super(),this.#e=t,this.#t=e,this.lastPoint=n}toSVGPath(){let t=[];for(let e of this.#e){let[n,s]=e;t.push(`M${n} ${s}`);for(let o=2;o<e.length;o+=2){let l=e[o],u=e[o+1];l===n?(t.push(`V${u}`),s=u):u===s&&(t.push(`H${l}`),n=l)}t.push("Z")}return t.join(" ")}serialize([t,e,n,s],o){let l=[],u=n-t,d=s-e;for(let p of this.#e){let m=new Array(p.length);for(let b=0;b<p.length;b+=2)m[b]=t+p[b]*u,m[b+1]=s-p[b+1]*d;l.push(m)}return l}get box(){return this.#t}get classNamesForOutlining(){return["highlightOutline"]}},Vr=class extends ui{newFreeDrawOutline(t,e,n,s,o,l){return new Ka(t,e,n,s,o,l)}},Ka=class extends hi{newOutliner(t,e,n,s,o,l=0){return new Vr(t,e,n,s,o,l)}},di=class i{#t=null;#e=null;#n;#r=null;#i=!1;#s=!1;#l=null;#a;#u=null;#c=null;#d;static#h=null;static get _keyboardManager(){return Lt(this,"_keyboardManager",new Un([[["Escape","mac+Escape"],i.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],i.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],i.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],i.prototype._moveToPrevious],[["Home","mac+Home"],i.prototype._moveToBeginning],[["End","mac+End"],i.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#s=!1,this.#d=Ft.HIGHLIGHT_COLOR,this.#l=t):(this.#s=!0,this.#d=Ft.HIGHLIGHT_DEFAULT_COLOR),this.#c=t?._uiManager||e,this.#a=this.#c._eventBus,this.#n=t?.color||this.#c?.highlightColors.values().next().value||"#FFFF98",i.#h||=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");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);let e=this.#c._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#p.bind(this),{signal:e});let n=this.#e=document.createElement("span");return n.className="swatch",n.setAttribute("aria-hidden",!0),n.style.backgroundColor=this.#n,t.append(n),t}renderMainDropdown(){let t=this.#r=this.#f();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#f(){let t=document.createElement("div"),e=this.#c._signal;t.addEventListener("contextmenu",$e,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(let[n,s]of this.#c.highlightColors){let o=document.createElement("button");o.tabIndex="0",o.role="option",o.setAttribute("data-color",s),o.title=n,o.setAttribute("data-l10n-id",i.#h[n]);let l=document.createElement("span");o.append(l),l.className="swatch",l.style.backgroundColor=s,o.setAttribute("aria-selected",s===this.#n),o.addEventListener("click",this.#o.bind(this,s),{signal:e}),t.append(o)}return t.addEventListener("keydown",this.#p.bind(this),{signal:e}),t}#o(t,e){e.stopPropagation(),this.#a.dispatch("switchannotationeditorparams",{source:this,type:this.#d,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#m(t);return}let e=t.target.getAttribute("data-color");e&&this.#o(e,t)}_moveToNext(t){if(!this.#b){this.#m(t);return}if(t.target===this.#t){this.#r.firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#r?.firstChild||t.target===this.#t){this.#b&&this._hideDropdownFromKeyboard();return}this.#b||this.#m(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#b){this.#m(t);return}this.#r.firstChild?.focus()}_moveToEnd(t){if(!this.#b){this.#m(t);return}this.#r.lastChild?.focus()}#p(t){i._keyboardManager.exec(this,t)}#m(t){if(this.#b){this.hideDropdown();return}if(this.#i=t.detail===0,this.#u||(this.#u=new AbortController,window.addEventListener("pointerdown",this.#g.bind(this),{signal:this.#c.combinedSignal(this.#u)})),this.#r){this.#r.classList.remove("hidden");return}let e=this.#r=this.#f();this.#t.append(e)}#g(t){this.#r?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#r?.classList.add("hidden"),this.#u?.abort(),this.#u=null}get#b(){return this.#r&&!this.#r.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#s){if(!this.#b){this.#l?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#i})}}updateColor(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#r)return;let e=this.#c.highlightColors.values();for(let n of this.#r.children)n.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#r?.remove(),this.#r=null}},fi=class i extends Yt{#t=null;#e=0;#n;#r=null;#i=null;#s=null;#l=null;#a=0;#u=null;#c=null;#d=null;#h=!1;#f=null;#o;#p=null;#m="";#g;#b="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=Mt.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=i.prototype;return Lt(this,"_keyboardManager",new Un([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||i._defaultColor,this.#g=t.thickness||i._defaultThickness,this.#o=t.opacity||i._defaultOpacity,this.#n=t.boxes||null,this.#b=t.methodOfCreation||"",this.#m=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#h=!0,this.#y(t),this.#P()):this.#n&&(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#l=t.focusNode,this.#a=t.focusOffset,this.#x(),this.#P(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#h?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#g,methodOfCreation:this.#b}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#x(){let t=new jr(this.#n,.001);this.#c=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#c.box;let e=new jr(this.#n,.0025,.001,this._uiManager.direction==="ltr");this.#s=e.getOutlines();let{lastPoint:n}=this.#s;this.#f=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#y({highlightOutlines:t,highlightId:e,clipPathId:n}){this.#c=t;let s=1.5;if(this.#s=t.getNewOutline(this.#g/2+s,.0025),e>=0)this.#d=e,this.#r=n,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#p=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#s.box,path:{d:this.#s.toSVGPath()}},!0);else if(this.parent){let m=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#d,{bbox:i.#A(this.#c.box,(m-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#p,{bbox:i.#A(this.#s.box,m),path:{d:this.#s.toSVGPath()}})}let[o,l,u,d]=t.box;switch(this.rotation){case 0:this.x=o,this.y=l,this.width=u,this.height=d;break;case 90:{let[m,b]=this.parentDimensions;this.x=l,this.y=1-o,this.width=u*b/m,this.height=d*m/b;break}case 180:this.x=1-o,this.y=1-l,this.width=u,this.height=d;break;case 270:{let[m,b]=this.parentDimensions;this.x=1-l,this.y=o,this.width=u*b/m,this.height=d*m/b;break}}let{lastPoint:p}=this.#s;this.#f=[(p[0]-o)/u,(p[1]-l)/d]}static initialize(t,e){Yt.initialize(t,e),i._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case Ft.HIGHLIGHT_DEFAULT_COLOR:i._defaultColor=e;break;case Ft.HIGHLIGHT_THICKNESS:i._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#f}updateParams(t,e){switch(t){case Ft.HIGHLIGHT_COLOR:this.#S(e);break;case Ft.HIGHLIGHT_THICKNESS:this.#T(e);break}}static get defaultPropertiesToUpdate(){return[[Ft.HIGHLIGHT_DEFAULT_COLOR,i._defaultColor],[Ft.HIGHLIGHT_THICKNESS,i._defaultThickness]]}get propertiesToUpdate(){return[[Ft.HIGHLIGHT_COLOR,this.color||i._defaultColor],[Ft.HIGHLIGHT_THICKNESS,this.#g||i._defaultThickness],[Ft.HIGHLIGHT_FREE,this.#h]]}#S(t){let e=(o,l)=>{this.color=o,this.#o=l,this.parent?.drawLayer.updateProperties(this.#d,{root:{fill:o,"fill-opacity":l}}),this.#i?.updateColor(o)},n=this.color,s=this.#o;this.addCommands({cmd:e.bind(this,t,i._defaultOpacity),undo:e.bind(this,n,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ft.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#T(t){let e=this.#g,n=s=>{this.#g=s,this.#E(s)};this.addCommands({cmd:n.bind(this,t),undo:n.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ft.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){let t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#i=new di({editor:this}),t.addColorPicker(this.#i)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#O())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#O())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#k(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#P(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#k():t&&(this.#P(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#E(t){if(!this.#h)return;this.#y({highlightOutlines:this.#c.getNewOutline(t/2)}),this.fixAndSetPosition();let[e,n]=this.parentDimensions;this.setDims(this.width*e,this.height*n)}#k(){this.#d===null||!this.parent||(this.parent.drawLayer.remove(this.#d),this.#d=null,this.parent.drawLayer.remove(this.#p),this.#p=null)}#P(t=this.parent){this.#d===null&&({id:this.#d,clipPathId:this.#r}=t.drawLayer.draw({bbox:this.#c.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#o},rootClass:{highlight:!0,free:this.#h},path:{d:this.#c.toSVGPath()}},!1,!0),this.#p=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#h},bbox:this.#s.box,path:{d:this.#s.toSVGPath()}},this.#h),this.#u&&(this.#u.style.clipPath=this.#r))}static#A([t,e,n,s],o){switch(o){case 90:return[1-e-s,t,s,n];case 180:return[1-t-n,1-e-s,n,s];case 270:return[e,1-t-n,s,n]}return[t,e,n,s]}rotate(t){let{drawLayer:e}=this.parent,n;this.#h?(t=(t-this.rotation+360)%360,n=i.#A(this.#c.box,t)):n=i.#A([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#d,{bbox:n,root:{"data-main-rotation":t}}),e.updateProperties(this.#p,{bbox:i.#A(this.#s.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#m&&(t.setAttribute("aria-label",this.#m),t.setAttribute("role","mark")),this.#h?t.classList.add("free"):this.div.addEventListener("keydown",this.#I.bind(this),{signal:this._uiManager._signal});let e=this.#u=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#r;let[n,s]=this.parentDimensions;return this.setDims(this.width*n,this.height*s),Hs(this,this.#u,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1}})}#I(t){i._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#C(!0);break;case 1:case 3:this.#C(!1);break}}#C(t){if(!this.#t)return;let e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#l,this.#a)}select(){super.select(),this.#p&&this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#p&&(this.parent?.drawLayer.updateProperties(this.#p,{rootClass:{selected:!1}}),this.#h||this.#C(!1))}get _mustFixPosition(){return!this.#h}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#d,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#p,{rootClass:{hidden:!t}}))}#O(){return this.#h?this.rotation:0}#F(){if(this.#h)return null;let[t,e]=this.pageDimensions,[n,s]=this.pageTranslation,o=this.#n,l=new Float32Array(o.length*8),u=0;for(let{x:d,y:p,width:m,height:b}of o){let v=d*t+n,A=(1-p)*e+s;l[u]=l[u+4]=v,l[u+1]=l[u+3]=A,l[u+2]=l[u+6]=v+m*t,l[u+5]=l[u+7]=A-b*e,u+=8}return l}#_(t){return this.#c.serialize(t,this.#O())}static startHighlighting(t,e,{target:n,x:s,y:o}){let{x:l,y:u,width:d,height:p}=n.getBoundingClientRect(),m=new AbortController,b=t.combinedSignal(m),v=A=>{m.abort(),this.#v(t,A)};window.addEventListener("blur",v,{signal:b}),window.addEventListener("pointerup",v,{signal:b}),window.addEventListener("pointerdown",Ie,{capture:!0,passive:!1,signal:b}),window.addEventListener("contextmenu",$e,{signal:b}),n.addEventListener("pointermove",this.#w.bind(this,t),{signal:b}),this._freeHighlight=new Vr({x:s,y:o},[l,u,d,p],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#w(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#v(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,n){let s=null;if(t instanceof li){let{data:{quadPoints:x,rect:w,rotation:k,id:I,color:P,opacity:M,popupRef:N},parent:{page:{pageNumber:D}}}=t;s=t={annotationType:Mt.HIGHLIGHT,color:Array.from(P),opacity:M,quadPoints:x,boxes:null,pageIndex:D-1,rect:w.slice(0),rotation:k,id:I,deleted:!1,popupRef:N}}else if(t instanceof Hr){let{data:{inkLists:x,rect:w,rotation:k,id:I,color:P,borderStyle:{rawWidth:M},popupRef:N},parent:{page:{pageNumber:D}}}=t;s=t={annotationType:Mt.HIGHLIGHT,color:Array.from(P),thickness:M,inkLists:x,boxes:null,pageIndex:D-1,rect:w.slice(0),rotation:k,id:I,deleted:!1,popupRef:N}}let{color:o,quadPoints:l,inkLists:u,opacity:d}=t,p=await super.deserialize(t,e,n);p.color=xt.makeHexColor(...o),p.#o=d||1,u&&(p.#g=t.thickness),p.annotationElementId=t.id||null,p._initialData=s;let[m,b]=p.pageDimensions,[v,A]=p.pageTranslation;if(l){let x=p.#n=[];for(let w=0;w<l.length;w+=8)x.push({x:(l[w]-v)/m,y:1-(l[w+1]-A)/b,width:(l[w+2]-l[w])/m,height:(l[w+1]-l[w+5])/b});p.#x(),p.#P(),p.rotate(p.rotation)}else if(u){p.#h=!0;let x=u[0],w={x:x[0]-v,y:b-(x[1]-A)},k=new Vr(w,[0,0,m,b],1,p.#g/2,!0,.001);for(let M=0,N=x.length;M<N;M+=2)w.x=x[M]-v,w.y=b-(x[M+1]-A),k.add(w);let{id:I,clipPathId:P}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:p.color,"fill-opacity":p._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:k.toSVGPath()}},!0,!0);p.#y({highlightOutlines:k.getOutlines(),highlightId:I,clipPathId:P}),p.#P()}return p}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=this.getRect(0,0),n=Yt._colorManager.convert(this.color),s={annotationType:Mt.HIGHLIGHT,color:n,opacity:this.#o,thickness:this.#g,quadPoints:this.#F(),outlines:this.#_(e),pageIndex:this.pageIndex,rect:e,rotation:this.#O(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#L(s)?null:(s.id=this.annotationElementId,s)}#L(t){let{color:e}=this._initialData;return t.color.some((n,s)=>n!==e[s])}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},Za=class{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,n]of Object.entries(t))this.updateProperty(e,n)}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(){$t("Not implemented")}},Qa=class i extends Yt{#t=null;#e;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#n=null;static#r=null;static#i=null;static#s=NaN;static#l=null;static#a=null;static#u=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,t.drawOutlines&&(this.#c(t),this.#f())}#c({drawOutlines:t,drawId:e,drawingOptions:n}){this.#t=t,this._drawingOptions||=n,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#d(t,this.parent),this.#m(t.box)}#d(t,e){let{id:n}=e.drawLayer.draw(i._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return n}static _mergeSVGProperties(t,e){let n=new Set(Object.keys(t));for(let[s,o]of Object.entries(e))n.has(s)?Object.assign(t[s],o):t[s]=o;return t}static getDefaultDrawingOptions(t){$t("Not implemented")}static get typesMap(){$t("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let n=this.typesMap.get(t);n&&this._defaultDrawingOptions.updateProperty(n,e),this._currentParent&&(i.#n.updateProperty(n,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let n=this.constructor.typesMap.get(t);n&&this._updateProperty(t,n,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[n,s]of this.typesMap)t.push([n,e[s]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[n,s]of this.constructor.typesMap)t.push([n,e[s]]);return t}_updateProperty(t,e,n){let s=this._drawingOptions,o=s[e],l=u=>{s.updateProperty(e,u);let d=this.#t.updateProperty(e,u);d&&this.#m(d),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:l.bind(this,n),undo:l.bind(this,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,i._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#p()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,i._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#p()),{bbox:this.#g()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#g(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,i._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#p(),this.parentDimensions),{bbox:this.#g()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),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){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#h(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#f(),this.#m(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#h()):t&&(this._uiManager.addShouldRescale(this),this.#f(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#h(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#f(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#d(this.#t,t)}}#o([t,e,n,s]){let{parentDimensions:[o,l],rotation:u}=this;switch(u){case 90:return[e,1-t,n*(l/o),s*(o/l)];case 180:return[1-t,1-e,n,s];case 270:return[1-e,t,n*(l/o),s*(o/l)];default:return[t,e,n,s]}}#p(){let{x:t,y:e,width:n,height:s,parentDimensions:[o,l],rotation:u}=this;switch(u){case 90:return[1-e,t,n*(o/l),s*(l/o)];case 180:return[1-t,1-e,n,s];case 270:return[e,1-t,n*(o/l),s*(l/o)];default:return[t,e,n,s]}}#m(t){if([this.x,this.y,this.width,this.height]=this.#o(t),this.div){this.fixAndSetPosition();let[e,n]=this.parentDimensions;this.setDims(this.width*e,this.height*n)}this._onResized()}#g(){let{x:t,y:e,width:n,height:s,rotation:o,parentRotation:l,parentDimensions:[u,d]}=this;switch((o*4+l)/90){case 1:return[1-e-s,t,s,n];case 2:return[1-t-n,1-e-s,n,s];case 3:return[e,1-t-n,s,n];case 4:return[t,e-n*(u/d),s*(d/u),n*(u/d)];case 5:return[1-e,t,n*(u/d),s*(d/u)];case 6:return[1-t-s*(d/u),1-e,s*(d/u),n*(u/d)];case 7:return[e-n*(u/d),1-t-s*(d/u),n*(u/d),s*(d/u)];case 8:return[t-n,e-s,n,s];case 9:return[1-e,t-n,s,n];case 10:return[1-t,1-e,n,s];case 11:return[e-s,1-t,s,n];case 12:return[t-s*(d/u),e,s*(d/u),n*(u/d)];case 13:return[1-e-n*(u/d),t-s*(d/u),n*(u/d),s*(d/u)];case 14:return[1-t,1-e-n*(u/d),s*(d/u),n*(u/d)];case 15:return[e,1-t,n*(u/d),s*(d/u)];default:return[t,e,n,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,i._mergeSVGProperties({bbox:this.#g()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#m(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t=super.render();t.classList.add("draw");let e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";let[n,s]=this.parentDimensions;return this.setDims(this.width*n,this.height*s),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,n,s,o){$t("Not implemented")}static startDrawing(t,e,n,s){let{target:o,offsetX:l,offsetY:u,pointerId:d,pointerType:p}=s;if(i.#l&&i.#l!==p)return;let{viewport:{rotation:m}}=t,{width:b,height:v}=o.getBoundingClientRect(),A=i.#r=new AbortController,x=t.combinedSignal(A);if(i.#s||=d,i.#l??=p,window.addEventListener("pointerup",w=>{i.#s===w.pointerId?this._endDraw(w):i.#a?.delete(w.pointerId)},{signal:x}),window.addEventListener("pointercancel",w=>{i.#s===w.pointerId?this._currentParent.endDrawingSession():i.#a?.delete(w.pointerId)},{signal:x}),window.addEventListener("pointerdown",w=>{i.#l===w.pointerType&&((i.#a||=new Set).add(w.pointerId),i.#n.isCancellable()&&(i.#n.removeLastElement(),i.#n.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:x}),window.addEventListener("contextmenu",$e,{signal:x}),o.addEventListener("pointermove",this._drawMove.bind(this),{signal:x}),o.addEventListener("touchmove",w=>{w.timeStamp===i.#u&&Ie(w)},{signal:x}),t.toggleDrawing(),e._editorUndoBar?.hide(),i.#n){t.drawLayer.updateProperties(this._currentDrawId,i.#n.startNew(l,u,b,v,m));return}e.updateUIForDefaultProperties(this),i.#n=this.createDrawerInstance(l,u,b,v,m),i.#i=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(i.#i.toSVGProperties(),i.#n.defaultSVGProperties),!0,!1)}static _drawMove(t){if(i.#u=-1,!i.#n)return;let{offsetX:e,offsetY:n,pointerId:s}=t;if(i.#s===s){if(i.#a?.size>=1){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,i.#n.add(e,n)),i.#u=t.timeStamp,Ie(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,i.#n=null,i.#i=null,i.#l=null,i.#u=NaN),i.#r&&(i.#r.abort(),i.#r=null,i.#s=NaN,i.#a=null)}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,i.#n.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let n=i.#n,s=this._currentDrawId,o=n.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(s,n.setLastElement(o))},undo:()=>{e.drawLayer.updateProperties(s,n.removeLastElement())},mustExec:!1,type:Ft.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(Ft.DRAW_STEP),!i.#n.isEmpty()){let{pageDimensions:[n,s],scale:o}=e,l=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:i.#n.getOutlines(n*o,s*o,o,this._INNER_MARGIN),drawingOptions:i.#i,mustBeCommitted:!t});return this._cleanup(!0),l}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,n,s,o,l){$t("Not implemented")}static async deserialize(t,e,n){let{rawDims:{pageWidth:s,pageHeight:o,pageX:l,pageY:u}}=e.viewport,d=this.deserializeDraw(l,u,s,o,this._INNER_MARGIN,t),p=await super.deserialize(t,e,n);return p.createDrawingOptions(t),p.#c({drawOutlines:d}),p.#f(),p.onScaleChanging(),p.rotate(),p}serializeDraw(t){let[e,n]=this.pageTranslation,[s,o]=this.pageDimensions;return this.#t.serialize([e,n,s,o],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},Ja=class{#t=new Float64Array(6);#e;#n;#r;#i;#s;#l="";#a=0;#u=new pi;#c;#d;constructor(t,e,n,s,o,l){this.#c=n,this.#d=s,this.#r=o,this.#i=l,[t,e]=this.#h(t,e);let u=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#s=[t,e],this.#n=[{line:u,points:this.#s}],this.#t.set(u,0)}updateProperty(t,e){t==="stroke-width"&&(this.#i=e)}#h(t,e){return pt._normalizePoint(t,e,this.#c,this.#d,this.#r)}isEmpty(){return!this.#n||this.#n.length===0}isCancellable(){return this.#s.length<=10}add(t,e){[t,e]=this.#h(t,e);let[n,s,o,l]=this.#t.subarray(2,6),u=t-o,d=e-l;return Math.hypot(this.#c*u,this.#d*d)<=2?null:(this.#s.push(t,e),isNaN(n)?(this.#t.set([o,l,t,e],2),this.#e.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#t[0])&&this.#e.splice(6,6),this.#t.set([n,s,o,l,t,e],0),this.#e.push(...pt.createBezierPoints(n,s,o,l,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){let n=this.add(t,e);return n||(this.#s.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,n,s,o){this.#c=n,this.#d=s,this.#r=o,[t,e]=this.#h(t,e);let l=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#s=[t,e];let u=this.#n.at(-1);return u&&(u.line=new Float32Array(u.line),u.points=new Float32Array(u.points)),this.#n.push({line:l,points:this.#s}),this.#t.set(l,0),this.#a=0,this.toSVGPath(),null}getLastElement(){return this.#n.at(-1)}setLastElement(t){return this.#n?(this.#n.push(t),this.#e=t.line,this.#s=t.points,this.#a=0,{path:{d:this.toSVGPath()}}):this.#u.setLastElement(t)}removeLastElement(){if(!this.#n)return this.#u.removeLastElement();this.#n.pop(),this.#l="";for(let t=0,e=this.#n.length;t<e;t++){let{line:n,points:s}=this.#n[t];this.#e=n,this.#s=s,this.#a=0,this.toSVGPath()}return{path:{d:this.#l}}}toSVGPath(){let t=pt.svgRound(this.#e[4]),e=pt.svgRound(this.#e[5]);if(this.#s.length===2)return this.#l=`${this.#l} M ${t} ${e} Z`,this.#l;if(this.#s.length<=6){let s=this.#l.lastIndexOf("M");this.#l=`${this.#l.slice(0,s)} M ${t} ${e}`,this.#a=6}if(this.#s.length===4){let s=pt.svgRound(this.#e[10]),o=pt.svgRound(this.#e[11]);return this.#l=`${this.#l} L ${s} ${o}`,this.#a=12,this.#l}let n=[];this.#a===0&&(n.push(`M ${t} ${e}`),this.#a=6);for(let s=this.#a,o=this.#e.length;s<o;s+=6){let[l,u,d,p,m,b]=this.#e.slice(s,s+6).map(pt.svgRound);n.push(`C${l} ${u} ${d} ${p} ${m} ${b}`)}return this.#l+=n.join(" "),this.#a=this.#e.length,this.#l}getOutlines(t,e,n,s){let o=this.#n.at(-1);return o.line=new Float32Array(o.line),o.points=new Float32Array(o.points),this.#u.build(this.#n,t,e,n,this.#r,this.#i,s),this.#t=null,this.#e=null,this.#n=null,this.#l=null,this.#u}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}},pi=class i extends pt{#t;#e=0;#n;#r;#i;#s;#l;#a;#u;build(t,e,n,s,o,l,u){this.#i=e,this.#s=n,this.#l=s,this.#a=o,this.#u=l,this.#n=u??0,this.#r=t,this.#h()}setLastElement(t){return this.#r.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#r.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#r){if(t.push(`M${pt.svgRound(e[4])} ${pt.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12){t.push(`L${pt.svgRound(e[10])} ${pt.svgRound(e[11])}`);continue}for(let n=6,s=e.length;n<s;n+=6){let[o,l,u,d,p,m]=e.subarray(n,n+6).map(pt.svgRound);t.push(`C${o} ${l} ${u} ${d} ${p} ${m}`)}}return t.join("")}serialize([t,e,n,s],o){let l=[],u=[],[d,p,m,b]=this.#d(),v,A,x,w,k,I,P,M,N;switch(this.#a){case 0:N=pt._rescale,v=t,A=e+s,x=n,w=-s,k=t+d*n,I=e+(1-p-b)*s,P=t+(d+m)*n,M=e+(1-p)*s;break;case 90:N=pt._rescaleAndSwap,v=t,A=e,x=n,w=s,k=t+p*n,I=e+d*s,P=t+(p+b)*n,M=e+(d+m)*s;break;case 180:N=pt._rescale,v=t+n,A=e,x=-n,w=s,k=t+(1-d-m)*n,I=e+p*s,P=t+(1-d)*n,M=e+(p+b)*s;break;case 270:N=pt._rescaleAndSwap,v=t+n,A=e+s,x=-n,w=-s,k=t+(1-p-b)*n,I=e+(1-d-m)*s,P=t+(1-p)*n,M=e+(1-d)*s;break}for(let{line:D,points:U}of this.#r)l.push(N(D,v,A,x,w,o?new Array(D.length):null)),u.push(N(U,v,A,x,w,o?new Array(U.length):null));return{lines:l,points:u,rect:[k,I,P,M]}}static deserialize(t,e,n,s,o,{paths:{lines:l,points:u},rotation:d,thickness:p}){let m=[],b,v,A,x,w;switch(d){case 0:w=pt._rescale,b=-t/n,v=e/s+1,A=1/n,x=-1/s;break;case 90:w=pt._rescaleAndSwap,b=-e/s,v=-t/n,A=1/s,x=1/n;break;case 180:w=pt._rescale,b=t/n+1,v=-e/s,A=-1/n,x=1/s;break;case 270:w=pt._rescaleAndSwap,b=e/s+1,v=t/n+1,A=-1/s,x=-1/n;break}if(!l){l=[];for(let I of u){let P=I.length;if(P===2){l.push(new Float32Array([NaN,NaN,NaN,NaN,I[0],I[1]]));continue}if(P===4){l.push(new Float32Array([NaN,NaN,NaN,NaN,I[0],I[1],NaN,NaN,NaN,NaN,I[2],I[3]]));continue}let M=new Float32Array(3*(P-2));l.push(M);let[N,D,U,G]=I.subarray(0,4);M.set([NaN,NaN,NaN,NaN,N,D],0);for(let H=4;H<P;H+=2){let W=I[H],J=I[H+1];M.set(pt.createBezierPoints(N,D,U,G,W,J),(H-2)*3),[N,D,U,G]=[U,G,W,J]}}}for(let I=0,P=l.length;I<P;I++)m.push({line:w(l[I].map(M=>M??NaN),b,v,A,x),points:w(u[I].map(M=>M??NaN),b,v,A,x)});let k=new i;return k.build(m,n,s,1,d,p,o),k}#c(t=this.#u){let e=this.#n+t/2*this.#l;return this.#a%180===0?[e/this.#i,e/this.#s]:[e/this.#s,e/this.#i]}#d(){let[t,e,n,s]=this.#t,[o,l]=this.#c(0);return[t+o,e+l,n-2*o,s-2*l]}#h(){let t=this.#t=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:s}of this.#r){if(s.length<=12){for(let u=4,d=s.length;u<d;u+=6){let[p,m]=s.subarray(u,u+2);t[0]=Math.min(t[0],p),t[1]=Math.min(t[1],m),t[2]=Math.max(t[2],p),t[3]=Math.max(t[3],m)}continue}let o=s[4],l=s[5];for(let u=6,d=s.length;u<d;u+=6){let[p,m,b,v,A,x]=s.subarray(u,u+6);xt.bezierBoundingBox(o,l,p,m,b,v,A,x,t),o=A,l=x}}let[e,n]=this.#c();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-n)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+n)),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,n]=this.#c();this.#u=t;let[s,o]=this.#c(),[l,u]=[s-e,o-n],d=this.#t;return d[0]-=l,d[1]-=u,d[2]+=2*l,d[3]+=2*u,d}updateParentDimensions([t,e],n){let[s,o]=this.#c();this.#i=t,this.#s=e,this.#l=n;let[l,u]=this.#c(),d=l-s,p=u-o,m=this.#t;return m[0]-=d,m[1]-=p,m[2]+=2*d,m[3]+=2*p,m}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(pt.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${pt.svgRound(t)} ${pt.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#t,n=0,s=0,o=0,l=0,u=0,d=0;switch(this.#e){case 90:s=e/t,o=-t/e,u=t;break;case 180:n=-1,l=-1,u=t,d=e;break;case 270:s=-e/t,o=t/e,d=e;break;default:return""}return`matrix(${n} ${s} ${o} ${l} ${pt.svgRound(u)} ${pt.svgRound(d)})`}getPathResizingSVGProperties([t,e,n,s]){let[o,l]=this.#c(),[u,d,p,m]=this.#t;if(Math.abs(p-o)<=pt.PRECISION||Math.abs(m-l)<=pt.PRECISION){let w=t+n/2-(u+p/2),k=e+s/2-(d+m/2);return{path:{"transform-origin":`${pt.svgRound(t)} ${pt.svgRound(e)}`,transform:`${this.rotationTransform} translate(${w} ${k})`}}}let b=(n-2*o)/(p-2*o),v=(s-2*l)/(m-2*l),A=p/n,x=m/s;return{path:{"transform-origin":`${pt.svgRound(u)} ${pt.svgRound(d)}`,transform:`${this.rotationTransform} scale(${A} ${x}) translate(${pt.svgRound(o)} ${pt.svgRound(l)}) scale(${b} ${v}) translate(${pt.svgRound(-o)} ${pt.svgRound(-l)})`}}}getPathResizedSVGProperties([t,e,n,s]){let[o,l]=this.#c(),u=this.#t,[d,p,m,b]=u;if(u[0]=t,u[1]=e,u[2]=n,u[3]=s,Math.abs(m-o)<=pt.PRECISION||Math.abs(b-l)<=pt.PRECISION){let k=t+n/2-(d+m/2),I=e+s/2-(p+b/2);for(let{line:P,points:M}of this.#r)pt._translate(P,k,I,P),pt._translate(M,k,I,M);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${pt.svgRound(t)} ${pt.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let v=(n-2*o)/(m-2*o),A=(s-2*l)/(b-2*l),x=-v*(d+o)+t+o,w=-A*(p+l)+e+l;if(v!==1||A!==1||x!==0||w!==0)for(let{line:k,points:I}of this.#r)pt._rescale(k,x,w,v,A,k),pt._rescale(I,x,w,v,A,I);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${pt.svgRound(t)} ${pt.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],n){let[s,o]=n,l=this.#t,u=t-l[0],d=e-l[1];if(this.#i===s&&this.#s===o)for(let{line:p,points:m}of this.#r)pt._translate(p,u,d,p),pt._translate(m,u,d,m);else{let p=this.#i/s,m=this.#s/o;this.#i=s,this.#s=o;for(let{line:b,points:v}of this.#r)pt._rescale(b,u,d,p,m,b),pt._rescale(v,u,d,p,m,v);l[2]*=p,l[3]*=m}return l[0]=t,l[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${pt.svgRound(t)} ${pt.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${pt.svgRound(t[0])} ${pt.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}},qa=class i extends Za{#t;constructor(t){super(),this.#t=t,super.updateProperties({fill:"none",stroke:Yt._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this.#t.realScale),super.updateSVGProperty(t,e)}clone(){let t=new i(this.#t);return t.updateAll(this),t}},tl=class i extends Qa{static _type="ink";static _editorType=Mt.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){Yt.initialize(t,e),this._defaultDrawingOptions=new qa(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Lt(this,"typesMap",new Map([[Ft.INK_THICKNESS,"stroke-width"],[Ft.INK_COLOR,"stroke"],[Ft.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,n,s,o){return new Ja(t,e,n,s,o,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,n,s,o,l){return pi.deserialize(t,e,n,s,o,l)}static async deserialize(t,e,n){let s=null;if(t instanceof Hr){let{data:{inkLists:l,rect:u,rotation:d,id:p,color:m,opacity:b,borderStyle:{rawWidth:v},popupRef:A},parent:{page:{pageNumber:x}}}=t;s=t={annotationType:Mt.INK,color:Array.from(m),thickness:v,opacity:b,paths:{points:l},boxes:null,pageIndex:x-1,rect:u.slice(0),rotation:d,id:p,deleted:!1,popupRef:A}}let o=await super.deserialize(t,e,n);return o.annotationElementId=t.id||null,o._initialData=s,o}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:n}=this;e.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:n}){this._drawingOptions=i.getDefaultDrawingOptions({stroke:xt.makeHexColor(...t),"stroke-width":e,"stroke-opacity":n})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:n,rect:s}=this.serializeDraw(t),{_drawingOptions:{stroke:o,"stroke-opacity":l,"stroke-width":u}}=this,d={annotationType:Mt.INK,color:Yt._colorManager.convert(o),opacity:l,thickness:u,paths:{lines:e,points:n},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?d:this.annotationElementId&&!this.#t(d)?null:(d.id=this.annotationElementId,d)}#t(t){let{color:e,thickness:n,opacity:s,pageIndex:o}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some((l,u)=>l!==e[u])||t.thickness!==n||t.opacity!==s||t.pageIndex!==o}renderAnnotationElement(t){let{points:e,rect:n}=this.serializeDraw(!1);return t.updateEdited({rect:n,thickness:this._drawingOptions["stroke-width"],points:e}),null}},el=class i extends Yt{#t=null;#e=null;#n=null;#r=null;#i=null;#s="";#l=null;#a=null;#u=!1;#c=!1;static _type="stamp";static _editorType=Mt.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#r=t.bitmapUrl,this.#i=t.bitmapFile}static initialize(t,e){Yt.initialize(t,e)}static get supportedTypes(){return Lt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map(e=>`image/${e}`))}static get supportedTypesStr(){return Lt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(Mt.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){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}this.#t=t.bitmap,e||(this.#e=t.id,this.#u=t.isSvg),t.file&&(this.#s=t.file.name),this.#o()}#h(){if(this.#n=null,this._uiManager.enableWaiting(!1),!!this.#l){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){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:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!await n.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");let{data:s,width:o,height:l}=t||this.copyCanvas(null,null,!0).imageData,u=await n.guess({name:"altText",request:{data:s,width:o,height:l,channels:s.length/(o*l)}});if(!u)throw new Error("No response from the AI service.");if(u.error)throw new Error("Error from the AI service.");if(u.cancel)return null;if(!u.output)throw new Error("No valid response from the AI service.");let d=u.output;return await this.setGuessedAltText(d),e&&!this.hasAltTextData()&&(this.altTextData={alt:d,decorative:!1}),d}#f(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(n=>this.#d(n,!0)).finally(()=>this.#h());return}if(this.#r){let n=this.#r;this.#r=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromUrl(n).then(s=>this.#d(s)).finally(()=>this.#h());return}if(this.#i){let n=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromFile(n).then(s=>this.#d(s)).finally(()=>this.#h());return}let t=document.createElement("input");t.type="file",t.accept=i.supportedTypesStr;let e=this._uiManager._signal;this.#n=new Promise(n=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let s=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#d(s)}n()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),n()},{signal:e})}).finally(()=>this.#h()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#l?.remove(),this.#l=null,this.#a&&(clearTimeout(this.#a),this.#a=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#f();return}super.rebuild(),this.div!==null&&(this.#e&&this.#l===null&&this.#f(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#n||this.#t||this.#r||this.#i||this.#e)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#t?this.#o():this.#f(),this.width&&!this.annotationElementId){let[n,s]=this.parentDimensions;this.setAt(t*n,e*s,this.width*n,this.height*s)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#a!==null&&clearTimeout(this.#a);let t=200;this.#a=setTimeout(()=>{this.#a=null,this.#m()},t)}#o(){let{div:t}=this,{width:e,height:n}=this.#t,[s,o]=this.pageDimensions,l=.75;if(this.width)e=this.width*s,n=this.height*o;else if(e>l*s||n>l*o){let m=Math.min(l*s/e,l*o/n);e*=m,n*=m}let[u,d]=this.parentDimensions;this.setDims(e*u/s,n*d/o),this._uiManager.enableWaiting(!1);let p=this.#l=document.createElement("canvas");p.setAttribute("role","img"),this.addContainer(p),this.width=e/s,this.height=n/o,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#m(),this.#c||(this.parent.addUndoableEditor(this),this.#c=!0),this._reportTelemetry({action:"inserted_image"}),this.#s&&p.setAttribute("aria-label",this.#s)}copyCanvas(t,e,n=!1){t||(t=224);let{width:s,height:o}=this.#t,l=new Fr,u=this.#t,d=s,p=o,m=null;if(e){if(s>e||o>e){let U=Math.min(e/s,e/o);d=Math.floor(s*U),p=Math.floor(o*U)}m=document.createElement("canvas");let v=m.width=Math.ceil(d*l.sx),A=m.height=Math.ceil(p*l.sy);this.#u||(u=this.#p(v,A));let x=m.getContext("2d");x.filter=this._uiManager.hcmFilter;let w="white",k="#cfcfd8";this._uiManager.hcmFilter!=="none"?k="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(w="#8f8f9d",k="#42414d");let I=15,P=I*l.sx,M=I*l.sy,N=new OffscreenCanvas(P*2,M*2),D=N.getContext("2d");D.fillStyle=w,D.fillRect(0,0,P*2,M*2),D.fillStyle=k,D.fillRect(0,0,P,M),D.fillRect(P,M,P,M),x.fillStyle=x.createPattern(N,"repeat"),x.fillRect(0,0,v,A),x.drawImage(u,0,0,u.width,u.height,0,0,v,A)}let b=null;if(n){let v,A;if(l.symmetric&&u.width<t&&u.height<t)v=u.width,A=u.height;else if(u=this.#t,s>t||o>t){let k=Math.min(t/s,t/o);v=Math.floor(s*k),A=Math.floor(o*k),this.#u||(u=this.#p(v,A))}let w=new OffscreenCanvas(v,A).getContext("2d",{willReadFrequently:!0});w.drawImage(u,0,0,u.width,u.height,0,0,v,A),b={width:v,height:A,data:w.getImageData(0,0,v,A).data}}return{canvas:m,width:d,height:p,imageData:b}}#p(t,e){let{width:n,height:s}=this.#t,o=n,l=s,u=this.#t;for(;o>2*t||l>2*e;){let d=o,p=l;o>2*t&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2)),l>2*e&&(l=l>=16384?Math.floor(l/2)-1:Math.ceil(l/2));let m=new OffscreenCanvas(o,l);m.getContext("2d").drawImage(u,0,0,d,p,0,0,o,l),u=m.transferToImageBitmap()}return u}#m(){let[t,e]=this.parentDimensions,{width:n,height:s}=this,o=new Fr,l=Math.ceil(n*t*o.sx),u=Math.ceil(s*e*o.sy),d=this.#l;if(!d||d.width===l&&d.height===u)return;d.width=l,d.height=u;let p=this.#u?this.#t:this.#p(l,u),m=d.getContext("2d");m.filter=this._uiManager.hcmFilter,m.drawImage(p,0,0,p.width,p.height,0,0,l,u)}getImageForAltText(){return this.#l}#g(t){if(t){if(this.#u){let s=this._uiManager.imageManager.getSvgUrl(this.#e);if(s)return s}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.#u){let[e,n]=this.pageDimensions,s=Math.round(this.width*e*vn.PDF_TO_CSS_UNITS),o=Math.round(this.height*n*vn.PDF_TO_CSS_UNITS),l=new OffscreenCanvas(s,o);return l.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,s,o),l.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,n){let s=null;if(t instanceof ci){let{data:{rect:x,rotation:w,id:k,structParent:I,popupRef:P},container:M,parent:{page:{pageNumber:N}}}=t,D=M.querySelector("canvas"),U=n.imageManager.getFromCanvas(M.id,D);D.remove();let G=(await e._structTree.getAriaAttributes(`${il}${k}`))?.get("aria-label")||"";s=t={annotationType:Mt.STAMP,bitmapId:U.id,bitmap:U.bitmap,pageIndex:N-1,rect:x.slice(0),rotation:w,id:k,deleted:!1,accessibilityData:{decorative:!1,altText:G},isSvg:!1,structParent:I,popupRef:P}}let o=await super.deserialize(t,e,n),{rect:l,bitmap:u,bitmapUrl:d,bitmapId:p,isSvg:m,accessibilityData:b}=t;p&&n.imageManager.isValidId(p)?(o.#e=p,u&&(o.#t=u)):o.#r=d,o.#u=m;let[v,A]=o.pageDimensions;return o.width=(l[2]-l[0])/v,o.height=(l[3]-l[1])/A,o.annotationElementId=t.id||null,b&&(o.altTextData=b),o._initialData=s,o.#c=!!s,o}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let n={annotationType:Mt.STAMP,bitmapId:this.#e,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#u,structTreeParentId:this._structTreeParentId};if(t)return n.bitmapUrl=this.#g(!0),n.accessibilityData=this.serializeAltText(!0),n;let{decorative:s,altText:o}=this.serializeAltText(!1);if(!s&&o&&(n.accessibilityData={type:"Figure",alt:o}),this.annotationElementId){let u=this.#b(n);if(u.isSame)return null;u.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1}if(n.id=this.annotationElementId,e===null)return n;e.stamps||=new Map;let l=this.#u?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:l,serialized:n}),n.bitmap=this.#g(!1);else if(this.#u){let u=e.stamps.get(this.#e);l>u.area&&(u.area=l,u.serialized.bitmap.close(),u.serialized.bitmap=this.#g(!1))}return n}#b(t){let{pageIndex:e,accessibilityData:{altText:n}}=this._initialData,s=t.pageIndex===e,o=(t.accessibilityData?.alt||"")===n;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&o,isSameAltText:o}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}},nl=class i{#t;#e=!1;#n=null;#r=null;#i=null;#s=new Map;#l=!1;#a=!1;#u=!1;#c=null;#d=null;#h=null;#f=null;#o;static _initialized=!1;static#p=new Map([Xa,tl,el,fi].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:n,structTreeLayer:s,accessibilityManager:o,annotationLayer:l,drawLayer:u,textLayer:d,viewport:p,l10n:m}){let b=[...i.#p.values()];if(!i._initialized){i._initialized=!0;for(let v of b)v.initialize(m,t)}t.registerEditorTypes(b),this.#o=t,this.pageIndex=e,this.div=n,this.#t=o,this.#n=l,this.viewport=p,this.#h=d,this.drawLayer=u,this._structTree=s,this.#o.addLayer(this)}get isEmpty(){return this.#s.size===0}get isInvisible(){return this.isEmpty&&this.#o.getMode()===Mt.NONE}updateToolbar(t){this.#o.updateToolbar(t)}updateMode(t=this.#o.getMode()){switch(this.#y(),t){case Mt.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Mt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Mt.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;for(let n of i.#p.values())e.toggle(`${n._type}Editing`,t===n._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#h?.div}setEditingState(t){this.#o.setEditingState(t)}addCommands(t){this.#o.addCommands(t)}cleanUndoStack(t){this.#o.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#n?.div.classList.toggle("disabled",!t)}async enable(){this.#u=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);let t=new Set;for(let n of this.#s.values())n.enableEditing(),n.show(!0),n.annotationElementId&&(this.#o.removeChangedExistingAnnotation(n),t.add(n.annotationElementId));if(!this.#n){this.#u=!1;return}let e=this.#n.getEditableAnnotations();for(let n of e){if(n.hide(),this.#o.isDeletedAnnotationElement(n.data.id)||t.has(n.data.id))continue;let s=await this.deserialize(n);s&&(this.addOrRebuild(s),s.enableEditing())}this.#u=!1}disable(){this.#a=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let t=new Map,e=new Map;for(let s of this.#s.values())if(s.disableEditing(),!!s.annotationElementId){if(s.serialize()!==null){t.set(s.annotationElementId,s);continue}else e.set(s.annotationElementId,s);this.getEditableAnnotation(s.annotationElementId)?.show(),s.remove()}if(this.#n){let s=this.#n.getEditableAnnotations();for(let o of s){let{id:l}=o.data;if(this.#o.isDeletedAnnotationElement(l))continue;let u=e.get(l);if(u){u.resetAnnotationElement(o),u.show(!1),o.show();continue}u=t.get(l),u&&(this.#o.addChangedExistingAnnotation(u),u.renderAnnotationElement(o)&&u.show(!1)),o.show()}}this.#y(),this.isEmpty&&(this.div.hidden=!0);let{classList:n}=this.div;for(let s of i.#p.values())n.remove(`${s._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#a=!1}getEditableAnnotation(t){return this.#n?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#o.getActive()!==t&&this.#o.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#h?.div&&!this.#f){this.#f=new AbortController;let t=this.#o.combinedSignal(this.#f);this.#h.div.addEventListener("pointerdown",this.#m.bind(this),{signal:t}),this.#h.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#h?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#h.div.classList.remove("highlighting"))}#m(t){this.#o.unselectAll();let{target:e}=t;if(e===this.#h.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&this.#h.div.contains(e)){let{isMac:n}=se.platform;if(t.button!==0||t.ctrlKey&&n)return;this.#o.showAllEditors("highlight",!0,!0),this.#h.div.classList.add("free"),this.toggleDrawing(),fi.startHighlighting(this,this.#o.direction==="ltr",{target:this.#h.div,x:t.x,y:t.y}),this.#h.div.addEventListener("pointerup",()=>{this.#h.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#o._signal}),t.preventDefault()}}enableClick(){if(this.#r)return;this.#r=new AbortController;let t=this.#o.combinedSignal(this.#r);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.#r?.abort(),this.#r=null}attach(t){this.#s.set(t.id,t);let{annotationElementId:e}=t;e&&this.#o.isDeletedAnnotationElement(e)&&this.#o.removeDeletedAnnotationElement(t)}detach(t){this.#s.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#a&&t.annotationElementId&&this.#o.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#o.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#o.addDeletedAnnotationElement(t.annotationElementId),Yt.deleteAnnotationElement(t),t.annotationElementId=null),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)){if(this.changeParent(t),this.#o.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#u),this.#o.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#i&&(t._focusEventsAllowed=!1,this.#i=setTimeout(()=>{this.#i=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#o._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){let e=()=>t._uiManager.rebuild(t),n=()=>{t.remove()};this.addCommands({cmd:e,undo:n,mustExec:!1})}getNextId(){return this.#o.getId()}get#g(){return i.#p.get(this.#o.getMode())}combinedSignal(t){return this.#o.combinedSignal(t)}#b(t){let e=this.#g;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#g?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#o.updateToolbar(t),this.#o.updateMode(t);let{offsetX:n,offsetY:s}=this.#x(),o=this.getNextId(),l=this.#b({parent:this,id:o,x:n,y:s,uiManager:this.#o,isCentered:!0,...e});l&&this.add(l)}async deserialize(t){return await i.#p.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#o)||null}createAndAddNewEditor(t,e,n={}){let s=this.getNextId(),o=this.#b({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#o,isCentered:e,...n});return o&&this.add(o),o}#x(){let{x:t,y:e,width:n,height:s}=this.div.getBoundingClientRect(),o=Math.max(0,t),l=Math.max(0,e),u=Math.min(window.innerWidth,t+n),d=Math.min(window.innerHeight,e+s),p=(o+u)/2-t,m=(l+d)/2-e,[b,v]=this.viewport.rotation%180===0?[p,m]:[m,p];return{offsetX:b,offsetY:v}}addNewEditor(){this.createAndAddNewEditor(this.#x(),!0)}setSelected(t){this.#o.setSelected(t)}toggleSelected(t){this.#o.toggleSelected(t)}unselect(t){this.#o.unselect(t)}pointerup(t){let{isMac:e}=se.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&this.#l&&(this.#l=!1,!(this.#g?.isDrawer&&this.#g.supportMultipleDrawings))){if(!this.#e){this.#e=!0;return}if(this.#o.getMode()===Mt.STAMP){this.#o.unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(this.#o.getMode()===Mt.HIGHLIGHT&&this.enableTextSelection(),this.#l){this.#l=!1;return}let{isMac:e}=se.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(this.#l=!0,this.#g?.isDrawer){this.startDrawingSession(t);return}let n=this.#o.getActive();this.#e=!n||n.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#c){this.#g.startDrawing(this,this.#o,!1,t);return}this.#o.setCurrentDrawingSession(this),this.#c=new AbortController;let e=this.#o.combinedSignal(this.#c);this.div.addEventListener("blur",({relatedTarget:n})=>{n&&!this.div.contains(n)&&(this.#d=null,this.commitOrRemove())},{signal:e}),this.#g.startDrawing(this,this.#o,!1,t)}pause(t){if(t){let{activeElement:e}=document;this.div.contains(e)&&(this.#d=e);return}this.#d&&setTimeout(()=>{this.#d?.focus(),this.#d=null},0)}endDrawingSession(t=!1){return this.#c?(this.#o.setCurrentDrawingSession(null),this.#c.abort(),this.#c=null,this.#d=null,this.#g.endDrawing(t)):null}findNewParent(t,e,n){let s=this.#o.findParent(e,n);return s===null||s===this?!1:(s.changeParent(t),!0)}commitOrRemove(){return this.#c?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#c&&this.#g.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#o.getActive()?.parent===this&&(this.#o.commitOrRemove(),this.#o.setActiveEditor(null)),this.#i&&(clearTimeout(this.#i),this.#i=null);for(let t of this.#s.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#s.clear(),this.#o.removeLayer(this)}#y(){for(let t of this.#s.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,Nn(this.div,t);for(let e of this.#o.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#o.commitOrRemove(),this.#y();let e=this.viewport.rotation,n=t.rotation;if(this.viewport=t,Nn(this.div,{rotation:n}),e!==n)for(let s of this.#s.values())s.rotate(n)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#o.viewParameters.realScale}},rl=class i{#t=null;#e=0;#n=new Map;#r=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#t){this.#t=t;return}if(this.#t!==t){if(this.#n.size>0)for(let e of this.#n.values())e.remove(),t.append(e);this.#t=t}}static get _svgFactory(){return Lt(this,"_svgFactory",new Br)}static#i(t,[e,n,s,o]){let{style:l}=t;l.top=`${100*n}%`,l.left=`${100*e}%`,l.width=`${100*s}%`,l.height=`${100*o}%`}#s(){let t=i._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden",!0),t}#l(t,e){let n=i._svgFactory.createElement("clipPath");t.append(n);let s=`clip_${e}`;n.setAttribute("id",s),n.setAttribute("clipPathUnits","objectBoundingBox");let o=i._svgFactory.createElement("use");return n.append(o),o.setAttribute("href",`#${e}`),o.classList.add("clip"),s}#a(t,e){for(let[n,s]of Object.entries(e))s===null?t.removeAttribute(n):t.setAttribute(n,s)}draw(t,e=!1,n=!1){let s=this.#e++,o=this.#s(),l=i._svgFactory.createElement("defs");o.append(l);let u=i._svgFactory.createElement("path");l.append(u);let d=`path_p${this.pageIndex}_${s}`;u.setAttribute("id",d),u.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#r.set(s,u);let p=n?this.#l(l,d):null,m=i._svgFactory.createElement("use");return o.append(m),m.setAttribute("href",`#${d}`),this.updateProperties(o,t),this.#n.set(s,o),{id:s,clipPathId:`url(#${p})`}}drawOutline(t,e){let n=this.#e++,s=this.#s(),o=i._svgFactory.createElement("defs");s.append(o);let l=i._svgFactory.createElement("path");o.append(l);let u=`path_p${this.pageIndex}_${n}`;l.setAttribute("id",u),l.setAttribute("vector-effect","non-scaling-stroke");let d;if(e){let b=i._svgFactory.createElement("mask");o.append(b),d=`mask_p${this.pageIndex}_${n}`,b.setAttribute("id",d),b.setAttribute("maskUnits","objectBoundingBox");let v=i._svgFactory.createElement("rect");b.append(v),v.setAttribute("width","1"),v.setAttribute("height","1"),v.setAttribute("fill","white");let A=i._svgFactory.createElement("use");b.append(A),A.setAttribute("href",`#${u}`),A.setAttribute("stroke","none"),A.setAttribute("fill","black"),A.setAttribute("fill-rule","nonzero"),A.classList.add("mask")}let p=i._svgFactory.createElement("use");s.append(p),p.setAttribute("href",`#${u}`),d&&p.setAttribute("mask",`url(#${d})`);let m=p.cloneNode();return s.append(m),p.classList.add("mainOutline"),m.classList.add("secondaryOutline"),this.updateProperties(s,t),this.#n.set(n,s),n}finalizeDraw(t,e){this.#r.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:n,bbox:s,rootClass:o,path:l}=e,u=typeof t=="number"?this.#n.get(t):t;if(u){if(n&&this.#a(u,n),s&&i.#i(u,s),o){let{classList:d}=u;for(let[p,m]of Object.entries(o))d.toggle(p,m)}if(l){let p=u.firstChild.firstChild;this.#a(p,l)}}}updateParent(t,e){if(e===this)return;let n=this.#n.get(t);n&&(e.#t.append(n),this.#n.delete(t),e.#n.set(t,n))}remove(t){this.#r.delete(t),this.#t!==null&&(this.#n.get(t).remove(),this.#n.delete(t))}destroy(){this.#t=null;for(let t of this.#n.values())t.remove();this.#n.clear(),this.#r.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:jr};Qy=kt.AbortException,Jy=kt.AnnotationEditorLayer,qy=kt.AnnotationEditorParamsType,tv=kt.AnnotationEditorType,ev=kt.AnnotationEditorUIManager,nv=kt.AnnotationLayer,ll=kt.AnnotationMode,rv=kt.ColorPicker,sv=kt.DOMSVGFactory,iv=kt.DrawLayer,ov=kt.FeatureTest,av=kt.GlobalWorkerOptions,lv=kt.ImageKind,cv=kt.InvalidPDFException,uv=kt.MissingPDFException,hv=kt.OPS,dv=kt.OutputScale,fv=kt.PDFDataRangeTransport,pv=kt.PDFDateString,gv=kt.PDFWorker,mv=kt.PasswordResponses,bv=kt.PermissionFlag,yv=kt.PixelsPerInch,vv=kt.RenderingCancelledException,xv=kt.TextLayer,Sv=kt.TouchManager,Av=kt.UnexpectedResponseException,Tv=kt.Util,wv=kt.VerbosityLevel,Ev=kt.XfaLayer,Cv=kt.build,kv=kt.createValidAbsoluteUrl,Iv=kt.fetchData,Pv=kt.getDocument,Rv=kt.getFilenameFromUrl,Ov=kt.getPdfFilenameFromUrl,Mv=kt.getXfaPageViewport,Lv=kt.isDataScheme,Fv=kt.isPdfFile,Dv=kt.noContextMenu,_v=kt.normalizeUnicode,Nv=kt.setLayerDimensions,Uv=kt.shadow,Bv=kt.stopEvent,Gv=kt.version});var pl=Wb((vh,Ci)=>{var yh=(()=>{var i=Object.defineProperty,t=Object.getOwnPropertyDescriptor,e=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,s=(r,a)=>{for(var c in a)i(r,c,{get:a[c],enumerable:!0})},o=(r,a,c,h)=>{if(a&&typeof a=="object"||typeof a=="function")for(let f of e(a))!n.call(r,f)&&f!==c&&i(r,f,{get:()=>a[f],enumerable:!(h=t(a,f))||h.enumerable});return r},l=r=>o(i({},"__esModule",{value:!0}),r),u={};s(u,{BoundingBox:()=>ut,Font:()=>wu,Glyph:()=>Kn,Path:()=>Ut,_parse:()=>ht,load:()=>Db,loadSync:()=>_b,parse:()=>Fb});var d=0,p=-3;function m(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function b(r,a){this.source=r,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=a,this.destLen=0,this.ltree=new m,this.dtree=new m}var v=new m,A=new m,x=new Uint8Array(30),w=new Uint16Array(30),k=new Uint8Array(30),I=new Uint16Array(30),P=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),M=new m,N=new Uint8Array(320);function D(r,a,c,h){var f,g;for(f=0;f<c;++f)r[f]=0;for(f=0;f<30-c;++f)r[f+c]=f/c|0;for(g=h,f=0;f<30;++f)a[f]=g,g+=1<<r[f]}function U(r,a){var c;for(c=0;c<7;++c)r.table[c]=0;for(r.table[7]=24,r.table[8]=152,r.table[9]=112,c=0;c<24;++c)r.trans[c]=256+c;for(c=0;c<144;++c)r.trans[24+c]=c;for(c=0;c<8;++c)r.trans[168+c]=280+c;for(c=0;c<112;++c)r.trans[176+c]=144+c;for(c=0;c<5;++c)a.table[c]=0;for(a.table[5]=32,c=0;c<32;++c)a.trans[c]=c}var G=new Uint16Array(16);function H(r,a,c,h){var f,g;for(f=0;f<16;++f)r.table[f]=0;for(f=0;f<h;++f)r.table[a[c+f]]++;for(r.table[0]=0,g=0,f=0;f<16;++f)G[f]=g,g+=r.table[f];for(f=0;f<h;++f)a[c+f]&&(r.trans[G[a[c+f]]++]=f)}function W(r){r.bitcount--||(r.tag=r.source[r.sourceIndex++],r.bitcount=7);var a=r.tag&1;return r.tag>>>=1,a}function J(r,a,c){if(!a)return c;for(;r.bitcount<24;)r.tag|=r.source[r.sourceIndex++]<<r.bitcount,r.bitcount+=8;var h=r.tag&65535>>>16-a;return r.tag>>>=a,r.bitcount-=a,h+c}function q(r,a){for(;r.bitcount<24;)r.tag|=r.source[r.sourceIndex++]<<r.bitcount,r.bitcount+=8;var c=0,h=0,f=0,g=r.tag;do h=2*h+(g&1),g>>>=1,++f,c+=a.table[f],h-=a.table[f];while(h>=0);return r.tag=g,r.bitcount-=f,a.trans[c+h]}function dt(r,a,c){var h,f,g,y,S,T;for(h=J(r,5,257),f=J(r,5,1),g=J(r,4,4),y=0;y<19;++y)N[y]=0;for(y=0;y<g;++y){var C=J(r,3,0);N[P[y]]=C}for(H(M,N,0,19),S=0;S<h+f;){var E=q(r,M);switch(E){case 16:var O=N[S-1];for(T=J(r,2,3);T;--T)N[S++]=O;break;case 17:for(T=J(r,3,3);T;--T)N[S++]=0;break;case 18:for(T=J(r,7,11);T;--T)N[S++]=0;break;default:N[S++]=E;break}}H(a,N,0,h),H(c,N,h,f)}function Q(r,a,c){for(;;){var h=q(r,a);if(h===256)return d;if(h<256)r.dest[r.destLen++]=h;else{var f,g,y,S;for(h-=257,f=J(r,x[h],w[h]),g=q(r,c),y=r.destLen-J(r,k[g],I[g]),S=y;S<y+f;++S)r.dest[r.destLen++]=r.dest[S]}}}function ot(r){for(var a,c,h;r.bitcount>8;)r.sourceIndex--,r.bitcount-=8;if(a=r.source[r.sourceIndex+1],a=256*a+r.source[r.sourceIndex],c=r.source[r.sourceIndex+3],c=256*c+r.source[r.sourceIndex+2],a!==(~c&65535))return p;for(r.sourceIndex+=4,h=a;h;--h)r.dest[r.destLen++]=r.source[r.sourceIndex++];return r.bitcount=0,d}function ct(r,a){var c=new b(r,a),h,f,g;do{switch(h=W(c),f=J(c,2,0),f){case 0:g=ot(c);break;case 1:g=Q(c,v,A);break;case 2:dt(c,c.ltree,c.dtree),g=Q(c,c.ltree,c.dtree);break;default:g=p}if(g!==d)throw new Error("Data error")}while(!h);return c.destLen<c.dest.length?typeof c.dest.slice=="function"?c.dest.slice(0,c.destLen):c.dest.subarray(0,c.destLen):c.dest}U(v,A),D(x,w,4,3),D(k,I,2,1),x[28]=0,w[28]=258;function X(r,a,c,h,f){return Math.pow(1-f,3)*r+3*Math.pow(1-f,2)*f*a+3*(1-f)*Math.pow(f,2)*c+Math.pow(f,3)*h}function $(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}$.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},$.prototype.addPoint=function(r,a){typeof r=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=r,this.x2=r),r<this.x1&&(this.x1=r),r>this.x2&&(this.x2=r)),typeof a=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=a,this.y2=a),a<this.y1&&(this.y1=a),a>this.y2&&(this.y2=a))},$.prototype.addX=function(r){this.addPoint(r,null)},$.prototype.addY=function(r){this.addPoint(null,r)},$.prototype.addBezier=function(r,a,c,h,f,g,y,S){let T=[r,a],C=[c,h],E=[f,g],O=[y,S];this.addPoint(r,a),this.addPoint(y,S);for(let R=0;R<=1;R++){let F=6*T[R]-12*C[R]+6*E[R],L=-3*T[R]+9*C[R]-9*E[R]+3*O[R],B=3*C[R]-3*T[R];if(L===0){if(F===0)continue;let At=-B/F;0<At&&At<1&&(R===0&&this.addX(X(T[R],C[R],E[R],O[R],At)),R===1&&this.addY(X(T[R],C[R],E[R],O[R],At)));continue}let Y=Math.pow(F,2)-4*B*L;if(Y<0)continue;let yt=(-F+Math.sqrt(Y))/(2*L);0<yt&&yt<1&&(R===0&&this.addX(X(T[R],C[R],E[R],O[R],yt)),R===1&&this.addY(X(T[R],C[R],E[R],O[R],yt)));let mt=(-F-Math.sqrt(Y))/(2*L);0<mt&&mt<1&&(R===0&&this.addX(X(T[R],C[R],E[R],O[R],mt)),R===1&&this.addY(X(T[R],C[R],E[R],O[R],mt)))}},$.prototype.addQuad=function(r,a,c,h,f,g){let y=r+.6666666666666666*(c-r),S=a+2/3*(h-a),T=y+1/3*(f-r),C=S+1/3*(g-a);this.addBezier(r,a,y,S,T,C,f,g)};var ut=$;function st(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}var St={};function Ct(r,a){let c=Math.floor(r),h=r-c;if(St[a]||(St[a]={}),St[a][h]!==void 0){let g=St[a][h];return c+g}let f=+(Math.round(h+"e+"+a)+"e-"+a);return St[a][h]=f,c+f}function wt(r){let a=[[]],c=0,h=0;for(let f=0;f<r.length;f+=1){let g=a[a.length-1],y=r[f],S=g[0],T=g[1],C=g[g.length-1],E=r[f+1];g.push(y),y.type==="M"?(c=y.x,h=y.y):y.type==="L"&&(!E||E.type==="Z")?Math.abs(y.x-c)>1||Math.abs(y.y-h)>1||g.pop():y.type==="L"&&C&&C.x===y.x&&C.y===y.y?g.pop():y.type==="Z"&&(S&&T&&C&&S.type==="M"&&T.type==="L"&&C.type==="L"&&C.x===S.x&&C.y===S.y&&(g.shift(),g[0].type="M"),f+1<r.length&&a.push([]))}return r=[].concat.apply([],a),r}function Et(r){return Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0,scale:1,x:0,y:0},r)}function Vt(r){return parseInt(r)===r&&(r={decimalPlaces:r,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},r)}st.prototype.fromSVG=function(r,a={}){typeof SVGPathElement<"u"&&r instanceof SVGPathElement&&(r=r.getAttribute("d")),a=Et(a),this.commands=[];let c="0123456789",h="MmLlQqCcZzHhVv",f="SsTtAa",g="-+",y={},S=[""],T=!1;function C(L){return L.filter(B=>B.length).map(B=>{let Y=parseFloat(B);return(a.decimalPlaces||a.decimalPlaces===0)&&(Y=Ct(Y,a.decimalPlaces)),Y})}function E(L){if(!this.commands.length)return L;let B=this.commands[this.commands.length-1];for(let Y=0;Y<L.length;Y++)L[Y]+=B[Y&1?"y":"x"];return L}function O(){if(y.type===void 0)return;let L=y.type.toUpperCase(),B=L!=="Z"&&y.type.toUpperCase()!==y.type,Y=C(S);if(S=[""],!Y.length&&L!=="Z")return;B&&L!=="H"&&L!=="V"&&(Y=E.apply(this,[Y]));let yt=this.commands.length&&this.commands[this.commands.length-1].x||0,mt=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(L){case"M":this.moveTo(...Y);break;case"L":this.lineTo(...Y);break;case"V":for(let At=0;At<Y.length;At++){let Rt=0;B&&(Rt=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(yt,Y[At]+Rt)}break;case"H":for(let At=0;At<Y.length;At++){let Rt=0;B&&(Rt=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(Y[At]+Rt,mt)}break;case"C":this.bezierCurveTo(...Y);break;case"Q":this.quadraticCurveTo(...Y);break;case"Z":(this.commands.length<1||this.commands[this.commands.length-1].type!=="Z")&&this.close();break}if(this.commands.length)for(let At in this.commands[this.commands.length-1])this.commands[this.commands.length-1][At]===void 0&&(this.commands[this.commands.length-1][At]=0)}for(let L=0;L<r.length;L++){let B=r.charAt(L),Y=S[S.length-1];if(c.indexOf(B)>-1)S[S.length-1]+=B;else if(g.indexOf(B)>-1)if(!y.type&&!this.commands.length&&(y.type="L"),B==="-")!y.type||Y.indexOf("-")>0?T=!0:Y.length?S.push("-"):S[S.length-1]=B;else if(!y.type||Y.length>0)T=!0;else continue;else if(h.indexOf(B)>-1)y.type?(O.apply(this),y={type:B}):y.type=B;else{if(f.indexOf(B)>-1)throw new Error("Unsupported path command: "+B+". Currently supported commands are "+h.split("").join(", ")+".");` ,
15
- \r\f\v`.indexOf(B)>-1?S.push(""):B==="."?!y.type||Y.indexOf(B)>-1?T=!0:S[S.length-1]+=B:T=!0}if(T)throw new Error("Unexpected character: "+B+" at offset "+L)}O.apply(this),a.optimize&&(this.commands=wt(this.commands));let R=a.flipY,F=a.flipYBase;if(R===!0&&a.flipYBase===void 0){let L=this.getBoundingBox();F=L.y1+L.y2}for(let L in this.commands){let B=this.commands[L];for(let Y in B)["x","x1","x2"].includes(Y)?this.commands[L][Y]=a.x+B[Y]*a.scale:["y","y1","y2"].includes(Y)&&(this.commands[L][Y]=a.y+(R?F-B[Y]:B[Y])*a.scale)}return this},st.fromSVG=function(r,a){return new st().fromSVG(r,a)},st.prototype.moveTo=function(r,a){this.commands.push({type:"M",x:r,y:a})},st.prototype.lineTo=function(r,a){this.commands.push({type:"L",x:r,y:a})},st.prototype.curveTo=st.prototype.bezierCurveTo=function(r,a,c,h,f,g){this.commands.push({type:"C",x1:r,y1:a,x2:c,y2:h,x:f,y:g})},st.prototype.quadTo=st.prototype.quadraticCurveTo=function(r,a,c,h){this.commands.push({type:"Q",x1:r,y1:a,x:c,y:h})},st.prototype.close=st.prototype.closePath=function(){this.commands.push({type:"Z"})},st.prototype.extend=function(r){if(r.commands)r=r.commands;else if(r instanceof ut){let a=r;this.moveTo(a.x1,a.y1),this.lineTo(a.x2,a.y1),this.lineTo(a.x2,a.y2),this.lineTo(a.x1,a.y2),this.close();return}Array.prototype.push.apply(this.commands,r)},st.prototype.getBoundingBox=function(){let r=new ut,a=0,c=0,h=0,f=0;for(let g=0;g<this.commands.length;g++){let y=this.commands[g];switch(y.type){case"M":r.addPoint(y.x,y.y),a=h=y.x,c=f=y.y;break;case"L":r.addPoint(y.x,y.y),h=y.x,f=y.y;break;case"Q":r.addQuad(h,f,y.x1,y.y1,y.x,y.y),h=y.x,f=y.y;break;case"C":r.addBezier(h,f,y.x1,y.y1,y.x2,y.y2,y.x,y.y),h=y.x,f=y.y;break;case"Z":h=a,f=c;break;default:throw new Error("Unexpected path command "+y.type)}}return r.isEmpty()&&r.addPoint(0,0),r},st.prototype.draw=function(r){let a=this._layers;if(a&&a.length){for(let h=0;h<a.length;h++)this.draw.call(a[h],r);return}let c=this._image;if(c){r.drawImage(c.image,c.x,c.y,c.width,c.height);return}r.beginPath();for(let h=0;h<this.commands.length;h+=1){let f=this.commands[h];f.type==="M"?r.moveTo(f.x,f.y):f.type==="L"?r.lineTo(f.x,f.y):f.type==="C"?r.bezierCurveTo(f.x1,f.y1,f.x2,f.y2,f.x,f.y):f.type==="Q"?r.quadraticCurveTo(f.x1,f.y1,f.x,f.y):f.type==="Z"&&this.stroke&&this.strokeWidth&&r.closePath()}this.fill&&(r.fillStyle=this.fill,r.fill()),this.stroke&&(r.strokeStyle=this.stroke,r.lineWidth=this.strokeWidth,r.stroke())},st.prototype.toPathData=function(r){r=Vt(r);function a(S){let T=Ct(S,r.decimalPlaces);return Math.round(S)===T?""+T:T.toFixed(r.decimalPlaces)}function c(){let S="";for(let T=0;T<arguments.length;T+=1){let C=arguments[T];C>=0&&T>0&&(S+=" "),S+=a(C)}return S}let h=this.commands;r.optimize&&(h=JSON.parse(JSON.stringify(this.commands)),h=wt(h));let f=r.flipY,g=r.flipYBase;if(f===!0&&g===void 0){let S=new st;S.extend(h);let T=S.getBoundingBox();g=T.y1+T.y2}let y="";for(let S=0;S<h.length;S+=1){let T=h[S];T.type==="M"?y+="M"+c(T.x,f?g-T.y:T.y):T.type==="L"?y+="L"+c(T.x,f?g-T.y:T.y):T.type==="C"?y+="C"+c(T.x1,f?g-T.y1:T.y1,T.x2,f?g-T.y2:T.y2,T.x,f?g-T.y:T.y):T.type==="Q"?y+="Q"+c(T.x1,f?g-T.y1:T.y1,T.x,f?g-T.y:T.y):T.type==="Z"&&(y+="Z")}return y},st.prototype.toSVG=function(r,a){this._layers&&this._layers.length&&console.warn("toSVG() does not support colr font layers yet"),this._image&&console.warn("toSVG() does not support SVG glyphs yet"),a||(a=this.toPathData(r));let c='<path d="';return c+=a,c+='"',this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?c+=' fill="none"':c+=' fill="'+this.fill+'"'),this.stroke&&(c+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),c+="/>",c},st.prototype.toDOMElement=function(r,a){this._layers&&this._layers.length&&console.warn("toDOMElement() does not support colr font layers yet"),a||(a=this.toPathData(r));let c=document.createElementNS("http://www.w3.org/2000/svg","path");return c.setAttribute("d",a),this.fill!==void 0&&this.fill!=="black"&&(this.fill===null?c.setAttribute("fill","none"):c.setAttribute("fill",this.fill)),this.stroke&&(c.setAttribute("stroke",this.stroke),c.setAttribute("stroke-width",this.strokeWidth)),c};var Ut=st;function at(r){throw new Error(r)}function _(r,a){r||at(a)}var V={fail:at,argument:_,assert:_},K=32768,Z=2147483648,tt=-32768,nt=32767+1/65536,lt={},z={},it={};function Tt(r){return function(){return r}}z.BYTE=function(r){return V.argument(r>=0&&r<=255,"Byte value should be between 0 and 255."),[r]},it.BYTE=Tt(1),z.CHAR=function(r){return[r.charCodeAt(0)]},it.CHAR=Tt(1),z.CHARARRAY=function(r){(r===null||typeof r>"u")&&(r="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));let a=[];for(let c=0;c<r.length;c+=1)a[c]=r.charCodeAt(c);return a},it.CHARARRAY=function(r){return typeof r>"u"?0:r.length},z.USHORT=function(r){return[r>>8&255,r&255]},it.USHORT=Tt(2),z.SHORT=function(r){return r>=K&&(r=-(2*K-r)),[r>>8&255,r&255]},it.SHORT=Tt(2),z.UINT24=function(r){return[r>>16&255,r>>8&255,r&255]},it.UINT24=Tt(3),z.ULONG=function(r){return[r>>24&255,r>>16&255,r>>8&255,r&255]},it.ULONG=Tt(4),z.LONG=function(r){return r>=Z&&(r=-(2*Z-r)),[r>>24&255,r>>16&255,r>>8&255,r&255]},it.LONG=Tt(4),z.FLOAT=function(r){if(r>nt||r<tt)throw new Error(`Value ${r} is outside the range of representable values in 16.16 format`);let a=Math.round(r*65536)<<0;return z.ULONG(a)},it.FLOAT=it.ULONG,z.FIXED=z.ULONG,it.FIXED=it.ULONG,z.FWORD=z.SHORT,it.FWORD=it.SHORT,z.UFWORD=z.USHORT,it.UFWORD=it.USHORT,z.F2DOT14=function(r){return z.USHORT(r*16384)},it.F2DOT14=it.USHORT,z.LONGDATETIME=function(r){return[0,0,0,0,r>>24&255,r>>16&255,r>>8&255,r&255]},it.LONGDATETIME=Tt(8),z.TAG=function(r){return V.argument(r.length===4,"Tag should be exactly 4 ASCII characters."),[r.charCodeAt(0),r.charCodeAt(1),r.charCodeAt(2),r.charCodeAt(3)]},it.TAG=Tt(4),z.Card8=z.BYTE,it.Card8=it.BYTE,z.Card16=z.USHORT,it.Card16=it.USHORT,z.OffSize=z.BYTE,it.OffSize=it.BYTE,z.SID=z.USHORT,it.SID=it.USHORT,z.NUMBER=function(r){return r>=-107&&r<=107?[r+139]:r>=108&&r<=1131?(r=r-108,[(r>>8)+247,r&255]):r>=-1131&&r<=-108?(r=-r-108,[(r>>8)+251,r&255]):r>=-32768&&r<=32767?z.NUMBER16(r):z.NUMBER32(r)},it.NUMBER=function(r){return z.NUMBER(r).length},z.NUMBER16=function(r){return[28,r>>8&255,r&255]},it.NUMBER16=Tt(3),z.NUMBER32=function(r){return[29,r>>24&255,r>>16&255,r>>8&255,r&255]},it.NUMBER32=Tt(5),z.REAL=function(r){let a=r.toString(),c=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(a);if(c){let g=parseFloat("1e"+((c[2]?+c[2]:0)+c[1].length));a=(Math.round(r*g)/g).toString()}let h="";for(let g=0,y=a.length;g<y;g+=1){let S=a[g];S==="e"?h+=a[++g]==="-"?"c":"b":S==="."?h+="a":S==="-"?h+="e":h+=S}h+=h.length&1?"f":"ff";let f=[30];for(let g=0,y=h.length;g<y;g+=2)f.push(parseInt(h.substr(g,2),16));return f},it.REAL=function(r){return z.REAL(r).length},z.NAME=z.CHARARRAY,it.NAME=it.CHARARRAY,z.STRING=z.CHARARRAY,it.STRING=it.CHARARRAY,lt.UTF8=function(r,a,c){let h=[],f=c;for(let g=0;g<f;g++,a+=1)h[g]=r.getUint8(a);return String.fromCharCode.apply(null,h)},lt.UTF16=function(r,a,c){let h=[],f=c/2;for(let g=0;g<f;g++,a+=2)h[g]=r.getUint16(a);return String.fromCharCode.apply(null,h)},z.UTF16=function(r){let a=[];for(let c=0;c<r.length;c+=1){let h=r.charCodeAt(c);a[a.length]=h>>8&255,a[a.length]=h&255}return a},it.UTF16=function(r){return r.length*2};var zt={"x-mac-croatian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\u0160\u2122\xB4\xA8\u2260\u017D\xD8\u221E\xB1\u2264\u2265\u2206\xB5\u2202\u2211\u220F\u0161\u222B\xAA\xBA\u03A9\u017E\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u0106\xAB\u010C\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u0110\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\uF8FF\xA9\u2044\u20AC\u2039\u203A\xC6\xBB\u2013\xB7\u201A\u201E\u2030\xC2\u0107\xC1\u010D\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u0111\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u03C0\xCB\u02DA\xB8\xCA\xE6\u02C7","x-mac-cyrillic":"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u2020\xB0\u0490\xA3\xA7\u2022\xB6\u0406\xAE\xA9\u2122\u0402\u0452\u2260\u0403\u0453\u221E\xB1\u2264\u2265\u0456\xB5\u0491\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040A\u045A\u0458\u0405\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\u040B\u045B\u040C\u045C\u0455\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u201E\u040E\u045E\u040F\u045F\u2116\u0401\u0451\u044F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E","x-mac-gaelic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u1E02\xB1\u2264\u2265\u1E03\u010A\u010B\u1E0A\u1E0B\u1E1E\u1E1F\u0120\u0121\u1E40\xE6\xF8\u1E41\u1E56\u1E57\u027C\u0192\u017F\u1E60\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\u1E61\u1E9B\xFF\u0178\u1E6A\u20AC\u2039\u203A\u0176\u0177\u1E6B\xB7\u1EF2\u1EF3\u204A\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\u2663\xD2\xDA\xDB\xD9\u0131\xDD\xFD\u0174\u0175\u1E84\u1E85\u1E80\u1E81\u1E82\u1E83","x-mac-greek":"\xC4\xB9\xB2\xC9\xB3\xD6\xDC\u0385\xE0\xE2\xE4\u0384\xA8\xE7\xE9\xE8\xEA\xEB\xA3\u2122\xEE\xEF\u2022\xBD\u2030\xF4\xF6\xA6\u20AC\xF9\xFB\xFC\u2020\u0393\u0394\u0398\u039B\u039E\u03A0\xDF\xAE\xA9\u03A3\u03AA\xA7\u2260\xB0\xB7\u0391\xB1\u2264\u2265\xA5\u0392\u0395\u0396\u0397\u0399\u039A\u039C\u03A6\u03AB\u03A8\u03A9\u03AC\u039D\xAC\u039F\u03A1\u2248\u03A4\xAB\xBB\u2026\xA0\u03A5\u03A7\u0386\u0388\u0153\u2013\u2015\u201C\u201D\u2018\u2019\xF7\u0389\u038A\u038C\u038E\u03AD\u03AE\u03AF\u03CC\u038F\u03CD\u03B1\u03B2\u03C8\u03B4\u03B5\u03C6\u03B3\u03B7\u03B9\u03BE\u03BA\u03BB\u03BC\u03BD\u03BF\u03C0\u03CE\u03C1\u03C3\u03C4\u03B8\u03C9\u03C2\u03C7\u03C5\u03B6\u03CA\u03CB\u0390\u03B0\xAD","x-mac-icelandic":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\xDD\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\xD0\xF0\xDE\xFE\xFD\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-inuit":"\u1403\u1404\u1405\u1406\u140A\u140B\u1431\u1432\u1433\u1434\u1438\u1439\u1449\u144E\u144F\u1450\u1451\u1455\u1456\u1466\u146D\u146E\u146F\u1470\u1472\u1473\u1483\u148B\u148C\u148D\u148E\u1490\u1491\xB0\u14A1\u14A5\u14A6\u2022\xB6\u14A7\xAE\xA9\u2122\u14A8\u14AA\u14AB\u14BB\u14C2\u14C3\u14C4\u14C5\u14C7\u14C8\u14D0\u14EF\u14F0\u14F1\u14F2\u14F4\u14F5\u1505\u14D5\u14D6\u14D7\u14D8\u14DA\u14DB\u14EA\u1528\u1529\u152A\u152B\u152D\u2026\xA0\u152E\u153E\u1555\u1556\u1557\u2013\u2014\u201C\u201D\u2018\u2019\u1558\u1559\u155A\u155D\u1546\u1547\u1548\u1549\u154B\u154C\u1550\u157F\u1580\u1581\u1582\u1583\u1584\u1585\u158F\u1590\u1591\u1592\u1593\u1594\u1595\u1671\u1672\u1673\u1674\u1675\u1676\u1596\u15A0\u15A1\u15A2\u15A3\u15A4\u15A5\u15A6\u157C\u0141\u0142","x-mac-ce":"\xC4\u0100\u0101\xC9\u0104\xD6\xDC\xE1\u0105\u010C\xE4\u010D\u0106\u0107\xE9\u0179\u017A\u010E\xED\u010F\u0112\u0113\u0116\xF3\u0117\xF4\xF6\xF5\xFA\u011A\u011B\xFC\u2020\xB0\u0118\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\u0119\xA8\u2260\u0123\u012E\u012F\u012A\u2264\u2265\u012B\u0136\u2202\u2211\u0142\u013B\u013C\u013D\u013E\u0139\u013A\u0145\u0146\u0143\xAC\u221A\u0144\u0147\u2206\xAB\xBB\u2026\xA0\u0148\u0150\xD5\u0151\u014C\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\u014D\u0154\u0155\u0158\u2039\u203A\u0159\u0156\u0157\u0160\u201A\u201E\u0161\u015A\u015B\xC1\u0164\u0165\xCD\u017D\u017E\u016A\xD3\xD4\u016B\u016E\xDA\u016F\u0170\u0171\u0172\u0173\xDD\xFD\u0137\u017B\u0141\u017C\u0122\u02C7",macintosh:"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\uFB01\uFB02\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-romanian":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\u0102\u0218\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\u0103\u0219\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u2044\u20AC\u2039\u203A\u021A\u021B\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\u0131\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7","x-mac-turkish":"\xC4\xC5\xC7\xC9\xD1\xD6\xDC\xE1\xE0\xE2\xE4\xE3\xE5\xE7\xE9\xE8\xEA\xEB\xED\xEC\xEE\xEF\xF1\xF3\xF2\xF4\xF6\xF5\xFA\xF9\xFB\xFC\u2020\xB0\xA2\xA3\xA7\u2022\xB6\xDF\xAE\xA9\u2122\xB4\xA8\u2260\xC6\xD8\u221E\xB1\u2264\u2265\xA5\xB5\u2202\u2211\u220F\u03C0\u222B\xAA\xBA\u03A9\xE6\xF8\xBF\xA1\xAC\u221A\u0192\u2248\u2206\xAB\xBB\u2026\xA0\xC0\xC3\xD5\u0152\u0153\u2013\u2014\u201C\u201D\u2018\u2019\xF7\u25CA\xFF\u0178\u011E\u011F\u0130\u0131\u015E\u015F\u2021\xB7\u201A\u201E\u2030\xC2\xCA\xC1\xCB\xC8\xCD\xCE\xCF\xCC\xD3\xD4\uF8FF\xD2\xDA\xDB\xD9\uF8A0\u02C6\u02DC\xAF\u02D8\u02D9\u02DA\xB8\u02DD\u02DB\u02C7"};lt.MACSTRING=function(r,a,c,h){let f=zt[h];if(f===void 0)return;let g="";for(let y=0;y<c;y++){let S=r.getUint8(a+y);S<=127?g+=String.fromCharCode(S):g+=f[S&127]}return g};var _e=typeof WeakMap=="function"&&new WeakMap,Ne,Qd=function(r){if(!Ne){Ne={};for(let f in zt)Ne[f]=new String(f)}let a=Ne[r];if(a===void 0)return;if(_e){let f=_e.get(a);if(f!==void 0)return f}let c=zt[r];if(c===void 0)return;let h={};for(let f=0;f<c.length;f++)h[c.charCodeAt(f)]=f+128;return _e&&_e.set(a,h),h};z.MACSTRING=function(r,a){let c=Qd(a);if(c===void 0)return;let h=[];for(let f=0;f<r.length;f++){let g=r.charCodeAt(f);if(g>=128&&(g=c[g],g===void 0))return;h[f]=g}return h},it.MACSTRING=function(r,a){let c=z.MACSTRING(r,a);return c!==void 0?c.length:0};function Yi(r){return r>=-128&&r<=127}function Jd(r,a,c){let h=0,f=r.length;for(;a<f&&h<64&&r[a]===0;)++a,++h;return c.push(128|h-1),a}function qd(r,a,c){let h=0,f=r.length,g=a;for(;g<f&&h<64;){let y=r[g];if(!Yi(y)||y===0&&g+1<f&&r[g+1]===0)break;++g,++h}c.push(h-1);for(let y=a;y<g;++y)c.push(r[y]+256&255);return g}function tf(r,a,c){let h=0,f=r.length,g=a;for(;g<f&&h<64;){let y=r[g];if(y===0||Yi(y)&&g+1<f&&Yi(r[g+1]))break;++g,++h}c.push(64|h-1);for(let y=a;y<g;++y){let S=r[y];c.push(S+65536>>8&255,S+256&255)}return g}z.VARDELTAS=function(r){let a=0,c=[];for(;a<r.length;){let h=r[a];h===0?a=Jd(r,a,c):h>=-128&&h<=127?a=qd(r,a,c):a=tf(r,a,c)}return c},z.INDEX=function(r){let a=1,c=[a],h=[];for(let S=0;S<r.length;S+=1){let T=z.OBJECT(r[S]);Array.prototype.push.apply(h,T),a+=T.length,c.push(a)}if(h.length===0)return[0,0];let f=[],g=1+Math.floor(Math.log(a)/Math.log(2))/8|0,y=[void 0,z.BYTE,z.USHORT,z.UINT24,z.ULONG][g];for(let S=0;S<c.length;S+=1){let T=y(c[S]);Array.prototype.push.apply(f,T)}return Array.prototype.concat(z.Card16(r.length),z.OffSize(g),f,h)},it.INDEX=function(r){return z.INDEX(r).length},z.DICT=function(r){let a=[],c=Object.keys(r),h=c.length;for(let f=0;f<h;f+=1){let g=parseInt(c[f],0),y=r[g],S=z.OPERAND(y.value,y.type),T=z.OPERATOR(g);for(let C=0;C<S.length;C++)a.push(S[C]);for(let C=0;C<T.length;C++)a.push(T[C])}return a},it.DICT=function(r){return z.DICT(r).length},z.OPERATOR=function(r){return r<1200?[r]:[12,r-1200]},z.OPERAND=function(r,a){let c=[];if(Array.isArray(a))for(let h=0;h<a.length;h+=1){V.argument(r.length===a.length,"Not enough arguments given for type"+a);let f=z.OPERAND(r[h],a[h]);for(let g=0;g<f.length;g++)c.push(f[g])}else if(a==="SID"){let h=z.NUMBER(r);for(let f=0;f<h.length;f++)c.push(h[f])}else if(a==="offset"){let h=z.NUMBER32(r);for(let f=0;f<h.length;f++)c.push(h[f])}else if(a==="number"){let h=z.NUMBER(r);for(let f=0;f<h.length;f++)c.push(h[f])}else if(a==="real"){let h=z.REAL(r);for(let f=0;f<h.length;f++)c.push(h[f])}else throw new Error("Unknown operand type "+a);return c},z.OP=z.BYTE,it.OP=it.BYTE;var rs=typeof WeakMap=="function"&&new WeakMap;z.CHARSTRING=function(r){if(rs){let h=rs.get(r);if(h!==void 0)return h}let a=[],c=r.length;for(let h=0;h<c;h+=1){let f=r[h],g=z[f.type](f.value);for(let y=0;y<g.length;y++)a.push(g[y])}return rs&&rs.set(r,a),a},it.CHARSTRING=function(r){return z.CHARSTRING(r).length},z.OBJECT=function(r){let a=z[r.type];return V.argument(a!==void 0,"No encoding function for type "+r.type),a(r.value)},it.OBJECT=function(r){let a=it[r.type];return V.argument(a!==void 0,"No sizeOf function for type "+r.type),a(r.value)},z.TABLE=function(r){let a=[],c=(r.fields||[]).length,h=[],f=[];for(let g=0;g<c;g+=1){let y=r.fields[g],S=z[y.type];V.argument(S!==void 0,"No encoding function for field type "+y.type+" ("+y.name+")");let T=r[y.name];T===void 0&&(T=y.value);let C=S(T);if(y.type==="TABLE")T.fields!==null&&(f.push(a.length),h.push(C)),a.push(0,0);else for(let E=0;E<C.length;E++)a.push(C[E])}for(let g=0;g<h.length;g+=1){let y=f[g],S=a.length;V.argument(S<65536,"Table "+r.tableName+" too big."),a[y]=S>>8,a[y+1]=S&255;for(let T=0;T<h[g].length;T++)a.push(h[g][T])}return a},it.TABLE=function(r){let a=0,c=(r.fields||[]).length;for(let h=0;h<c;h+=1){let f=r.fields[h],g=it[f.type];V.argument(g!==void 0,"No sizeOf function for field type "+f.type+" ("+f.name+")");let y=r[f.name];y===void 0&&(y=f.value),a+=g(y),f.type==="TABLE"&&(a+=2)}return a},z.RECORD=z.TABLE,it.RECORD=it.TABLE,z.LITERAL=function(r){return r},it.LITERAL=function(r){return r.length};function Zt(r,a,c){if(a&&a.length)for(let h=0;h<a.length;h+=1){let f=a[h];this[f.name]=f.value}if(this.tableName=r,this.fields=a,c){let h=Object.keys(c);for(let f=0;f<h.length;f+=1){let g=h[f],y=c[g];this[g]!==void 0&&(this[g]=y)}}}Zt.prototype.encode=function(){return z.TABLE(this)},Zt.prototype.sizeOf=function(){return it.TABLE(this)};function zn(r,a,c){c===void 0&&(c=a.length);let h=new Array(a.length+1);h[0]={name:r+"Count",type:"USHORT",value:c};for(let f=0;f<a.length;f++)h[f+1]={name:r+f,type:"USHORT",value:a[f]};return h}function Ki(r,a,c){let h=a.length,f=new Array(h+1);f[0]={name:r+"Count",type:"USHORT",value:h};for(let g=0;g<h;g++)f[g+1]={name:r+g,type:"TABLE",value:c(a[g],g)};return f}function Xn(r,a,c){let h=a.length,f=[];f[0]={name:r+"Count",type:"USHORT",value:h};for(let g=0;g<h;g++)f=f.concat(c(a[g],g));return f}function ss(r){r.format===1?Zt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(zn("glyph",r.glyphs))):r.format===2?Zt.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(Xn("rangeRecord",r.ranges,function(a,c){return[{name:"startGlyphID"+c,type:"USHORT",value:a.start},{name:"endGlyphID"+c,type:"USHORT",value:a.end},{name:"startCoverageIndex"+c,type:"USHORT",value:a.index}]}))):V.assert(!1,"Coverage format must be 1 or 2.")}ss.prototype=Object.create(Zt.prototype),ss.prototype.constructor=ss;function is(r){Zt.call(this,"scriptListTable",Xn("scriptRecord",r,function(a,c){let h=a.script,f=h.defaultLangSys;return V.assert(!!f,"Unable to write GSUB: script "+a.tag+" has no default language system."),[{name:"scriptTag"+c,type:"TAG",value:a.tag},{name:"script"+c,type:"TABLE",value:new Zt("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Zt("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:f.reqFeatureIndex}].concat(zn("featureIndex",f.featureIndexes)))}].concat(Xn("langSys",h.langSysRecords,function(g,y){let S=g.langSys;return[{name:"langSysTag"+y,type:"TAG",value:g.tag},{name:"langSys"+y,type:"TABLE",value:new Zt("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:S.reqFeatureIndex}].concat(zn("featureIndex",S.featureIndexes)))}]})))}]}))}is.prototype=Object.create(Zt.prototype),is.prototype.constructor=is;function os(r){Zt.call(this,"featureListTable",Xn("featureRecord",r,function(a,c){let h=a.feature;return[{name:"featureTag"+c,type:"TAG",value:a.tag},{name:"feature"+c,type:"TABLE",value:new Zt("featureTable",[{name:"featureParams",type:"USHORT",value:h.featureParams}].concat(zn("lookupListIndex",h.lookupListIndexes)))}]}))}os.prototype=Object.create(Zt.prototype),os.prototype.constructor=os;function as(r,a){Zt.call(this,"lookupListTable",Ki("lookup",r,function(c){let h=a[c.lookupType];return V.assert(!!h,"Unable to write GSUB lookup type "+c.lookupType+" tables."),new Zt("lookupTable",[{name:"lookupType",type:"USHORT",value:c.lookupType},{name:"lookupFlag",type:"USHORT",value:c.lookupFlag}].concat(Ki("subtable",c.subtables,h)))}))}as.prototype=Object.create(Zt.prototype),as.prototype.constructor=as;function ls(r){r.format===1?Zt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:1},{name:"startGlyphID",type:"USHORT",value:r.startGlyph}].concat(zn("glyph",r.classes))):r.format===2?Zt.call(this,"classDefTable",[{name:"classFormat",type:"USHORT",value:2}].concat(Xn("rangeRecord",r.ranges,function(a,c){return[{name:"startGlyphID"+c,type:"USHORT",value:a.start},{name:"endGlyphID"+c,type:"USHORT",value:a.end},{name:"class"+c,type:"USHORT",value:a.classId}]}))):V.assert(!1,"Class format must be 1 or 2.")}ls.prototype=Object.create(Zt.prototype),ls.prototype.constructor=ls;var rt={Table:Zt,Record:Zt,Coverage:ss,ClassDef:ls,ScriptList:is,FeatureList:os,LookupList:as,ushortList:zn,tableList:Ki,recordList:Xn};function Vl(r,a){return r.getUint8(a)}function cs(r,a){return r.getUint16(a,!1)}function ef(r,a){return r.getInt16(a,!1)}function Wl(r,a){return(r.getUint16(a)<<8)+r.getUint8(a+2)}function Zi(r,a){return r.getUint32(a,!1)}function nf(r,a){return r.getInt32(a,!1)}function $l(r,a){let c=r.getInt16(a,!1),h=r.getUint16(a+2,!1);return c+h/65535}function rf(r,a){let c="";for(let h=a;h<a+4;h+=1)c+=String.fromCharCode(r.getInt8(h));return c}function sf(r,a,c){let h=0;for(let f=0;f<c;f+=1)h<<=8,h+=r.getUint8(a+f);return h}function of(r,a,c){let h=[];for(let f=a;f<c;f+=1)h.push(r.getUint8(f));return h}function af(r){let a="";for(let c=0;c<r.length;c+=1)a+=String.fromCharCode(r[c]);return a}var lf={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},ie={LONG_WORDS:32768,WORD_DELTA_COUNT_MASK:32767,SHARED_POINT_NUMBERS:32768,COUNT_MASK:4095,EMBEDDED_PEAK_TUPLE:32768,INTERMEDIATE_REGION:16384,PRIVATE_POINT_NUMBERS:8192,TUPLE_INDEX_MASK:4095,POINTS_ARE_WORDS:128,POINT_RUN_COUNT_MASK:127,DELTAS_ARE_ZERO:128,DELTAS_ARE_WORDS:64,DELTA_RUN_COUNT_MASK:63,INNER_INDEX_BIT_COUNT_MASK:15,MAP_ENTRY_SIZE_MASK:48};function j(r,a){this.data=r,this.offset=a,this.relativeOffset=0}j.prototype.parseByte=function(){let r=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,r},j.prototype.parseChar=function(){let r=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,r},j.prototype.parseCard8=j.prototype.parseByte,j.prototype.parseUShort=function(){let r=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,r},j.prototype.parseCard16=j.prototype.parseUShort,j.prototype.parseSID=j.prototype.parseUShort,j.prototype.parseOffset16=j.prototype.parseUShort,j.prototype.parseShort=function(){let r=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,r},j.prototype.parseF2Dot14=function(){let r=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,r},j.prototype.parseUInt24=function(){let r=Wl(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,r},j.prototype.parseULong=function(){let r=Zi(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,r},j.prototype.parseLong=function(){let r=nf(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,r},j.prototype.parseOffset32=j.prototype.parseULong,j.prototype.parseFixed=function(){let r=$l(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,r},j.prototype.parseString=function(r){let a=this.data,c=this.offset+this.relativeOffset,h="";this.relativeOffset+=r;for(let f=0;f<r;f++)h+=String.fromCharCode(a.getUint8(c+f));return h},j.prototype.parseTag=function(){return this.parseString(4)},j.prototype.parseLongDateTime=function(){let r=Zi(this.data,this.offset+this.relativeOffset+4);return r-=2082844800,this.relativeOffset+=8,r},j.prototype.parseVersion=function(r){let a=cs(this.data,this.offset+this.relativeOffset),c=cs(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,r===void 0&&(r=4096),a+c/r/10},j.prototype.skip=function(r,a){a===void 0&&(a=1),this.relativeOffset+=lf[r]*a},j.prototype.parseULongList=function(r){r===void 0&&(r=this.parseULong());let a=new Array(r),c=this.data,h=this.offset+this.relativeOffset;for(let f=0;f<r;f++)a[f]=c.getUint32(h),h+=4;return this.relativeOffset+=r*4,a},j.prototype.parseOffset16List=j.prototype.parseUShortList=function(r){r===void 0&&(r=this.parseUShort());let a=new Array(r),c=this.data,h=this.offset+this.relativeOffset;for(let f=0;f<r;f++)a[f]=c.getUint16(h),h+=2;return this.relativeOffset+=r*2,a},j.prototype.parseShortList=function(r){let a=new Array(r),c=this.data,h=this.offset+this.relativeOffset;for(let f=0;f<r;f++)a[f]=c.getInt16(h),h+=2;return this.relativeOffset+=r*2,a},j.prototype.parseByteList=function(r){let a=new Array(r),c=this.data,h=this.offset+this.relativeOffset;for(let f=0;f<r;f++)a[f]=c.getUint8(h++);return this.relativeOffset+=r,a},j.prototype.parseList=function(r,a){a||(a=r,r=this.parseUShort());let c=new Array(r);for(let h=0;h<r;h++)c[h]=a.call(this);return c},j.prototype.parseList32=function(r,a){a||(a=r,r=this.parseULong());let c=new Array(r);for(let h=0;h<r;h++)c[h]=a.call(this);return c},j.prototype.parseRecordList=function(r,a){a||(a=r,r=this.parseUShort());let c=new Array(r),h=Object.keys(a);for(let f=0;f<r;f++){let g={};for(let y=0;y<h.length;y++){let S=h[y],T=a[S];g[S]=T.call(this)}c[f]=g}return c},j.prototype.parseRecordList32=function(r,a){a||(a=r,r=this.parseULong());let c=new Array(r),h=Object.keys(a);for(let f=0;f<r;f++){let g={};for(let y=0;y<h.length;y++){let S=h[y],T=a[S];g[S]=T.call(this)}c[f]=g}return c},j.prototype.parseTupleRecords=function(r,a){let c=[];for(let h=0;h<r;h++){let f=[];for(let g=0;g<a;g++)f.push(this.parseF2Dot14());c.push(f)}return c},j.prototype.parseStruct=function(r){if(typeof r=="function")return r.call(this);{let a=Object.keys(r),c={};for(let h=0;h<a.length;h++){let f=a[h],g=r[f];c[f]=g.call(this)}return c}},j.prototype.parseValueRecord=function(r){if(r===void 0&&(r=this.parseUShort()),r===0)return;let a={};return r&1&&(a.xPlacement=this.parseShort()),r&2&&(a.yPlacement=this.parseShort()),r&4&&(a.xAdvance=this.parseShort()),r&8&&(a.yAdvance=this.parseShort()),r&16&&(a.xPlaDevice=void 0,this.parseShort()),r&32&&(a.yPlaDevice=void 0,this.parseShort()),r&64&&(a.xAdvDevice=void 0,this.parseShort()),r&128&&(a.yAdvDevice=void 0,this.parseShort()),a},j.prototype.parseValueRecordList=function(){let r=this.parseUShort(),a=this.parseUShort(),c=new Array(a);for(let h=0;h<a;h++)c[h]=this.parseValueRecord(r);return c},j.prototype.parsePointer=function(r){let a=this.parseOffset16();if(a>0)return new j(this.data,this.offset+a).parseStruct(r)},j.prototype.parsePointer32=function(r){let a=this.parseOffset32();if(a>0)return new j(this.data,this.offset+a).parseStruct(r)},j.prototype.parseListOfLists=function(r){let a=this.parseOffset16List(),c=a.length,h=this.relativeOffset,f=new Array(c);for(let g=0;g<c;g++){let y=a[g];if(y===0){f[g]=void 0;continue}if(this.relativeOffset=y,r){let S=this.parseOffset16List(),T=new Array(S.length);for(let C=0;C<S.length;C++)this.relativeOffset=y+S[C],T[C]=r.call(this);f[g]=T}else f[g]=this.parseUShortList()}return this.relativeOffset=h,f},j.prototype.parseCoverage=function(){let r=this.offset+this.relativeOffset,a=this.parseUShort(),c=this.parseUShort();if(a===1)return{format:1,glyphs:this.parseUShortList(c)};if(a===2){let h=new Array(c);for(let f=0;f<c;f++)h[f]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:h}}throw new Error("0x"+r.toString(16)+": Coverage format must be 1 or 2.")},j.prototype.parseClassDef=function(){let r=this.offset+this.relativeOffset,a=this.parseUShort();return a===1?{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()}:a===2?{format:2,ranges:this.parseRecordList({start:j.uShort,end:j.uShort,classId:j.uShort})}:(console.warn(`0x${r.toString(16)}: This font file uses an invalid ClassDef format of ${a}. It might be corrupted and should be reacquired if it doesn't display as intended.`),{format:a})},j.list=function(r,a){return function(){return this.parseList(r,a)}},j.list32=function(r,a){return function(){return this.parseList32(r,a)}},j.recordList=function(r,a){return function(){return this.parseRecordList(r,a)}},j.recordList32=function(r,a){return function(){return this.parseRecordList32(r,a)}},j.pointer=function(r){return function(){return this.parsePointer(r)}},j.pointer32=function(r){return function(){return this.parsePointer32(r)}},j.tag=j.prototype.parseTag,j.byte=j.prototype.parseByte,j.uShort=j.offset16=j.prototype.parseUShort,j.uShortList=j.prototype.parseUShortList,j.uInt24=j.prototype.parseUInt24,j.uLong=j.offset32=j.prototype.parseULong,j.uLongList=j.prototype.parseULongList,j.fixed=j.prototype.parseFixed,j.f2Dot14=j.prototype.parseF2Dot14,j.struct=j.prototype.parseStruct,j.coverage=j.prototype.parseCoverage,j.classDef=j.prototype.parseClassDef;var zl={reserved:j.uShort,reqFeatureIndex:j.uShort,featureIndexes:j.uShortList};j.prototype.parseScriptList=function(){return this.parsePointer(j.recordList({tag:j.tag,script:j.pointer({defaultLangSys:j.pointer(zl),langSysRecords:j.recordList({tag:j.tag,langSys:j.pointer(zl)})})}))||[]},j.prototype.parseFeatureList=function(){return this.parsePointer(j.recordList({tag:j.tag,feature:j.pointer({featureParams:j.offset16,lookupListIndexes:j.uShortList})}))||[]},j.prototype.parseLookupList=function(r){return this.parsePointer(j.list(j.pointer(function(){let a=this.parseUShort();V.argument(1<=a&&a<=9,"GPOS/GSUB lookup type "+a+" unknown.");let c=this.parseUShort(),h=c&16;return{lookupType:a,lookupFlag:c,subtables:this.parseList(j.pointer(r[a])),markFilteringSet:h?this.parseUShort():void 0}})))||[]},j.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){let r=this.parseUShort(),a=this.parseUShort();return V.argument(r===1&&a<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:j.offset32,featureTableSubstitutionOffset:j.offset32})})||[]},j.prototype.parseVariationStore=function(){let r=this.relativeOffset,a=this.parseUShort(),c={itemVariationStore:this.parseItemVariationStore()};return this.relativeOffset=r+a+2,c},j.prototype.parseItemVariationStore=function(){let r=this.relativeOffset,a={format:this.parseUShort(),variationRegions:[],itemVariationSubtables:[]},c=this.parseOffset32(),h=this.parseUShort(),f=this.parseULongList(h);this.relativeOffset=r+c,a.variationRegions=this.parseVariationRegionList();for(let g=0;g<h;g++){let y=f[g];this.relativeOffset=r+y,a.itemVariationSubtables.push(this.parseItemVariationSubtable())}return a},j.prototype.parseVariationRegionList=function(){let r=this.parseUShort(),a=this.parseUShort();return this.parseRecordList(a,{regionAxes:j.recordList(r,{startCoord:j.f2Dot14,peakCoord:j.f2Dot14,endCoord:j.f2Dot14})})},j.prototype.parseItemVariationSubtable=function(){let r=this.parseUShort(),a=this.parseUShort(),c=this.parseUShortList(),h=c.length;return{regionIndexes:c,deltaSets:r&&h?this.parseDeltaSets(r,a,h):[]}},j.prototype.parseDeltaSetIndexMap=function(){let r=this.parseByte(),a=this.parseByte(),c=[],h=0;switch(r){case 0:h=this.parseUShort();break;case 1:h=this.parseULong();break;default:console.error(`unsupported DeltaSetIndexMap format ${r}`)}if(!h)return{format:r,entryFormat:a};let f=(a&ie.INNER_INDEX_BIT_COUNT_MASK)+1,g=((a&ie.MAP_ENTRY_SIZE_MASK)>>4)+1;for(let y=0;y<h;y++){let S;if(g===1)S=this.parseByte();else if(g===2)S=this.parseUShort();else if(g===3)S=this.parseUInt24();else if(g===4)S=this.parseULong();else throw new Error(`Invalid entry size of ${g}`);let T=S>>f,C=S&(1<<f)-1;c.push({outerIndex:T,innerIndex:C})}return{format:r,entryFormat:a,map:c}},j.prototype.parseDeltaSets=function(r,a,c){let h=Array.from({length:r},()=>[]),f=a&ie.LONG_WORDS,g=a&ie.WORD_DELTA_COUNT_MASK;if(g>c)throw Error("wordCount must be less than or equal to regionIndexCount");let y=(f?this.parseLong:this.parseShort).bind(this),S=(f?this.parseShort:this.parseChar).bind(this);for(let T=0;T<r;T++)for(let C=0;C<c;C++)C<g?h[T].push(y()):h[T].push(S());return h},j.prototype.parseTupleVariationStoreList=function(r,a,c){let h=this.parseUShort(),g=this.parseUShort()&1,y=this.parseOffset32(),S=(g?this.parseULong:this.parseUShort).bind(this),T={},C=S();g||(C*=2);let E;for(let O=0;O<h;O++){E=S(),g||(E*=2);let R=E-C;T[O]=R?this.parseTupleVariationStore(y+C,r,a,c,O):void 0,C=E}return T},j.prototype.parseTupleVariationStore=function(r,a,c,h,f){let g=this.relativeOffset;this.relativeOffset=r,c==="cvar"&&(this.relativeOffset+=4);let y=this.parseUShort(),S=!!(y&ie.SHARED_POINT_NUMBERS),T=y&ie.COUNT_MASK,C=this.parseOffset16(),E=[],O=[];for(let L=0;L<T;L++){let B=this.parseTupleVariationHeader(a,c);E.push(B)}this.relativeOffset!==r+C&&(console.warn(`Unexpected offset after parsing tuple variation headers! Expected ${r+C}, actually ${this.relativeOffset}`),this.relativeOffset=r+C),S&&(O=this.parsePackedPointNumbers());let R=this.relativeOffset;for(let L=0;L<T;L++){let B=E[L];B.privatePoints=[],this.relativeOffset=R,c==="cvar"&&!B.peakTuple&&console.warn("An embedded peak tuple is required in TupleVariationHeaders for the cvar table."),B.flags.privatePointNumbers&&(B.privatePoints=this.parsePackedPointNumbers()),delete B.flags;let Y=this.offset,yt=this.relativeOffset,mt=At=>{let Rt,Nt,Gt=()=>{let Ht=0;if(c==="gvar"){if(Ht=B.privatePoints.length||O.length,!Ht){let qt=h.get(f);qt.path,Ht=qt.points.length,Ht+=4}}else c==="cvar"&&(Ht=h.length);this.offset=Y,this.relativeOffset=yt,Rt=this.parsePackedDeltas(Ht),c==="gvar"&&(Nt=this.parsePackedDeltas(Ht))};return{configurable:!0,get:function(){return Rt===void 0&&Gt(),At==="deltasY"?Nt:Rt},set:function(Ht){Rt===void 0&&Gt(),At==="deltasY"?Nt=Ht:Rt=Ht}}};Object.defineProperty(B,"deltas",mt.call(this,"deltas")),c==="gvar"&&Object.defineProperty(B,"deltasY",mt.call(this,"deltasY")),R+=B.variationDataSize,delete B.variationDataSize}this.relativeOffset=g;let F={headers:E};return F.sharedPoints=O,F},j.prototype.parseTupleVariationHeader=function(r,a){let c=this.parseUShort(),h=this.parseUShort(),f=!!(h&ie.EMBEDDED_PEAK_TUPLE),g=!!(h&ie.INTERMEDIATE_REGION),y=!!(h&ie.PRIVATE_POINT_NUMBERS),S=f?void 0:h&ie.TUPLE_INDEX_MASK,T=f?this.parseTupleRecords(1,r)[0]:void 0,C=g?this.parseTupleRecords(1,r)[0]:void 0,E=g?this.parseTupleRecords(1,r)[0]:void 0,O={variationDataSize:c,peakTuple:T,intermediateStartTuple:C,intermediateEndTuple:E,flags:{embeddedPeakTuple:f,intermediateRegion:g,privatePointNumbers:y}};return a==="gvar"&&(O.sharedTupleRecordsIndex=S),O},j.prototype.parsePackedPointNumbers=function(){let r=this.parseByte(),a=[],c=r;if(r>=128){let f=this.parseByte();c=(r&ie.POINT_RUN_COUNT_MASK)<<8|f}let h=0;for(;a.length<c;){let f=this.parseByte(),g=!!(f&ie.POINTS_ARE_WORDS),y=(f&ie.POINT_RUN_COUNT_MASK)+1;for(let S=0;S<y&&a.length<c;S++){let T;g?T=this.parseUShort():T=this.parseByte(),h=h+T,a.push(h)}}return a},j.prototype.parsePackedDeltas=function(r){let a=[];for(;a.length<r;){let c=this.parseByte(),h=!!(c&ie.DELTAS_ARE_ZERO),f=!!(c&ie.DELTAS_ARE_WORDS),g=(c&ie.DELTA_RUN_COUNT_MASK)+1;for(let y=0;y<g&&a.length<r;y++)h?a.push(0):f?a.push(this.parseShort()):a.push(this.parseChar())}return a};var ht={getByte:Vl,getCard8:Vl,getUShort:cs,getCard16:cs,getShort:ef,getUInt24:Wl,getULong:Zi,getFixed:$l,getTag:rf,getOffset:sf,getBytes:of,bytesToString:af,Parser:j},us=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Xl={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},cf={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},Yl={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function uf(r,a,c){switch(r){case 0:if(a===65535)return"und";if(c)return c[a];break;case 1:return Xl[a];case 3:return Yl[a]}}var Qi="utf-16",hf={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},df={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function Ji(r,a,c){switch(r){case 0:return Qi;case 1:return df[c]||hf[a];case 3:if(a===1||a===10)return Qi;break}}var Kl={0:"unicode",1:"macintosh",2:"reserved",3:"windows"};function ff(r){return Kl[r]}function pf(r,a,c){let h={},f=new ht.Parser(r,a),g=f.parseUShort(),y=f.parseUShort(),S=f.offset+f.parseUShort();for(let T=0;T<y;T++){let C=f.parseUShort(),E=f.parseUShort(),O=f.parseUShort(),R=f.parseUShort(),F=us[R]||R,L=f.parseUShort(),B=f.parseUShort(),Y=uf(C,O,c),yt=Ji(C,E,O),mt=ff(C);if(yt!==void 0&&Y!==void 0&&mt!==void 0){let At;if(yt===Qi?At=lt.UTF16(r,S+B,L):At=lt.MACSTRING(r,S+B,L,yt),At){let Rt=h[mt];Rt===void 0&&(Rt=h[mt]={});let Nt=Rt[F];Nt===void 0&&(Nt=Rt[F]={}),Nt[Y]=At}}}return g===1&&f.parseUShort(),h}function hs(r){let a={};for(let c in r)a[r[c]]=parseInt(c);return a}function Zl(r,a,c,h,f,g){return new rt.Record("NameRecord",[{name:"platformID",type:"USHORT",value:r},{name:"encodingID",type:"USHORT",value:a},{name:"languageID",type:"USHORT",value:c},{name:"nameID",type:"USHORT",value:h},{name:"length",type:"USHORT",value:f},{name:"offset",type:"USHORT",value:g}])}function gf(r,a){let c=r.length,h=a.length-c+1;t:for(let f=0;f<h;f++)for(;f<h;f++){for(let g=0;g<c;g++)if(a[f+g]!==r[g])continue t;return f}return-1}function Ql(r,a){let c=gf(r,a);if(c<0){c=a.length;let h=0,f=r.length;for(;h<f;++h)a.push(r[h])}return c}function mf(r,a){let c=hs(Kl),h=hs(Xl),f=hs(Yl),g=[],y=[];for(let T in r){let C,E=[],O={},R=hs(us),F=c[T];for(let L in r[T]){let B=R[L];if(B===void 0&&(B=L),C=parseInt(B),isNaN(C))throw new Error('Name table entry "'+L+'" does not exist, see nameTableNames for complete list.');O[C]=r[T][L],E.push(C)}for(let L=0;L<E.length;L++){C=E[L];let B=O[C];for(let Y in B){let yt=B[Y];if(F===1||F===0){let mt=h[Y],At=cf[mt],Rt=Ji(F,At,mt),Nt=z.MACSTRING(yt,Rt);if(F===0&&(mt=a.indexOf(Y),mt<0&&(mt=a.length,a.push(Y)),At=4,Nt=z.UTF16(yt)),Nt!==void 0){let Gt=Ql(Nt,y);g.push(Zl(F,At,mt,C,Nt.length,Gt))}}if(F===3){let mt=f[Y];if(mt!==void 0){let At=z.UTF16(yt),Rt=Ql(At,y);g.push(Zl(3,1,mt,C,At.length,Rt))}}}}}g.sort(function(T,C){return T.platformID-C.platformID||T.encodingID-C.encodingID||T.languageID-C.languageID||T.nameID-C.nameID});let S=new rt.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:g.length},{name:"stringOffset",type:"USHORT",value:6+g.length*12}]);for(let T=0;T<g.length;T++)S.fields.push({name:"record_"+T,type:"RECORD",value:g[T]});return S.fields.push({name:"strings",type:"LITERAL",value:y}),S}function ds(r,a,c=[]){if(a<256&&a in us){if(c.length&&!c.includes(parseInt(a)))return;a=us[a]}for(let h in r)for(let f in r[h])if(f===a||parseInt(f)===a)return r[h][f]}var Jl={parse:pf,make:mf,getNameByID:ds};function bf(r,a,c,h){r.length=a.parseUShort(),r.language=a.parseUShort()-1;let f=a.parseByteList(r.length),g=Object.assign({},f),y=Ji(c,h,r.language),S=zt[y];for(let T=0;T<S.length;T++)g[S.charCodeAt(T)]=f[128+T];r.glyphIndexMap=g}function yf(r,a,c){a.parseUShort(),r.length=a.parseULong(),r.language=a.parseULong();let h;r.groupCount=h=a.parseULong(),r.glyphIndexMap={};for(let f=0;f<h;f+=1){let g=a.parseULong(),y=a.parseULong(),S=a.parseULong();for(let T=g;T<=y;T+=1)r.glyphIndexMap[T]=S,c===12&&S++}}function vf(r,a,c,h,f){r.length=a.parseUShort(),r.language=a.parseUShort();let g;r.segCount=g=a.parseUShort()>>1,a.skip("uShort",3),r.glyphIndexMap={};let y=new ht.Parser(c,h+f+14),S=new ht.Parser(c,h+f+16+g*2),T=new ht.Parser(c,h+f+16+g*4),C=new ht.Parser(c,h+f+16+g*6),E=h+f+16+g*8;for(let O=0;O<g-1;O+=1){let R,F=y.parseUShort(),L=S.parseUShort(),B=T.parseShort(),Y=C.parseUShort();for(let yt=L;yt<=F;yt+=1)Y!==0?(E=C.offset+C.relativeOffset-2,E+=Y,E+=(yt-L)*2,R=ht.getUShort(c,E),R!==0&&(R=R+B&65535)):R=yt+B&65535,r.glyphIndexMap[yt]=R}}function xf(r,a){let c={};a.skip("uLong");let h=a.parseULong();for(let f=0;f<h;f+=1){let g=a.parseUInt24(),y={varSelector:g},S=a.parseOffset32(),T=a.parseOffset32(),C=a.relativeOffset;S&&(a.relativeOffset=S,y.defaultUVS=a.parseStruct({ranges:function(){return a.parseRecordList32({startUnicodeValue:a.parseUInt24,additionalCount:a.parseByte})}})),T&&(a.relativeOffset=T,y.nonDefaultUVS=a.parseStruct({uvsMappings:function(){let E={},O=a.parseRecordList32({unicodeValue:a.parseUInt24,glyphID:a.parseUShort});for(let R=0;R<O.length;R+=1)E[O[R].unicodeValue]=O[R];return E}})),c[g]=y,a.relativeOffset=C}r.varSelectorList=c}function Sf(r,a){let c={};c.version=ht.getUShort(r,a),V.argument(c.version===0,"cmap table version should be 0."),c.numTables=ht.getUShort(r,a+2);let h=null,f=-1,g=-1,y=null,S=null,T=[0,1,2,3,4,6],C=[0,1,10];for(let O=c.numTables-1;O>=0;O-=1)if(y=ht.getUShort(r,a+4+O*8),S=ht.getUShort(r,a+4+O*8+2),y===3&&C.includes(S)||y===0&&T.includes(S)||y===1&&S===0){if(g>0)continue;if(g=ht.getULong(r,a+4+O*8+4),h)break}else if(y===0&&S===5){if(f=ht.getULong(r,a+4+O*8+4),h=new ht.Parser(r,a+f),h.parseUShort()!==14)f=-1,h=null;else if(g>0)break}if(g===-1)throw new Error("No valid cmap sub-tables found.");let E=new ht.Parser(r,a+g);if(c.format=E.parseUShort(),c.format===0)bf(c,E,y,S);else if(c.format===12||c.format===13)yf(c,E,c.format);else if(c.format===4)vf(c,E,r,a,g);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+c.format+", platformId "+y+", encodingId "+S+").");return h&&xf(c,h),c}function Af(r,a,c){r.segments.push({end:a,start:a,delta:-(a-c),offset:0,glyphIndex:c})}function Tf(r){r.segments.push({end:65535,start:65535,delta:1,offset:0})}function wf(r){if(r.length===0)return r;let a=[r[0]];for(let c=1;c<r.length;c++){let h=a[a.length-1],f=r[c];h.end+1===f.start&&h.delta===f.delta&&f.end!==65535?h.end=f.end:a.push(f)}return a}function Ef(r){let a=!0,c;for(c=r.length-1;c>0;c-=1)if(r.get(c).unicode>65535){a=!1;break}let h=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:a?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:a?12:20}];a||h.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),h.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});let f=new rt.Table("cmap",h);for(f.segments=[],c=0;c<r.length;c+=1){let F=r.get(c);for(let L=0;L<F.unicodes.length;L+=1)Af(f,F.unicodes[L],c)}f.segments.sort(function(F,L){return F.start-L.start}),f.segments=wf(f.segments),Tf(f);let g=f.segments.length,y=0,S=[],T=[],C=[],E=[],O=[],R=[];for(c=0;c<g;c+=1){let F=f.segments[c];F.end<=65535&&F.start<=65535?(S.push({name:"end_"+c,type:"USHORT",value:F.end}),T.push({name:"start_"+c,type:"USHORT",value:F.start}),C.push({name:"idDelta_"+c,type:"SHORT",value:F.delta}),E.push({name:"idRangeOffset_"+c,type:"USHORT",value:F.offset}),F.glyphId!==void 0&&O.push({name:"glyph_"+c,type:"USHORT",value:F.glyphId})):y+=1,!a&&F.glyphIndex!==void 0&&(R.push({name:"cmap12Start_"+c,type:"ULONG",value:F.start}),R.push({name:"cmap12End_"+c,type:"ULONG",value:F.end}),R.push({name:"cmap12Glyph_"+c,type:"ULONG",value:F.glyphIndex}))}f.segCountX2=(g-y)*2,f.searchRange=Math.pow(2,Math.floor(Math.log(g-y)/Math.log(2)))*2,f.entrySelector=Math.log(f.searchRange/2)/Math.log(2),f.rangeShift=f.segCountX2-f.searchRange;for(let F=0;F<S.length;F++)f.fields.push(S[F]);f.fields.push({name:"reservedPad",type:"USHORT",value:0});for(let F=0;F<T.length;F++)f.fields.push(T[F]);for(let F=0;F<C.length;F++)f.fields.push(C[F]);for(let F=0;F<E.length;F++)f.fields.push(E[F]);for(let F=0;F<O.length;F++)f.fields.push(O[F]);if(f.cmap4Length=14+S.length*2+2+T.length*2+C.length*2+E.length*2+O.length*2,!a){let F=16+R.length*4;f.cmap12Offset=20+f.cmap4Length,f.fields.push({name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:F},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:R.length/3});for(let L=0;L<R.length;L++)f.fields.push(R[L])}return f}var ql={parse:Sf,make:Ef},fs=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],Cf=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],kf=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],If=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"],qi=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],Pf=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],kn=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function tc(r){this.font=r}tc.prototype.charToGlyphIndex=function(r){let a=r.codePointAt(0),c=this.font.glyphs;if(c)for(let h=0;h<c.length;h+=1){let f=c.get(h);for(let g=0;g<f.unicodes.length;g+=1)if(f.unicodes[g]===a)return h}return null};function ec(r){this.cmap=r}ec.prototype.charToGlyphIndex=function(r){return this.cmap.glyphIndexMap[r.codePointAt(0)]||0};function nc(r,a){this.encoding=r,this.charset=a}nc.prototype.charToGlyphIndex=function(r){let a=r.codePointAt(0),c=this.encoding[a];return this.charset.indexOf(c)};function to(r){switch(r.version){case 1:this.names=kn.slice();break;case 2:this.names=new Array(r.numberOfGlyphs);for(let a=0;a<r.numberOfGlyphs;a++)r.glyphNameIndex[a]<kn.length?this.names[a]=kn[r.glyphNameIndex[a]]:this.names[a]=r.names[r.glyphNameIndex[a]-kn.length];break;case 2.5:this.names=new Array(r.numberOfGlyphs);for(let a=0;a<r.numberOfGlyphs;a++)this.names[a]=kn[a+r.glyphNameIndex[a]];break;case 3:this.names=[];break;default:this.names=[];break}}to.prototype.nameToGlyphIndex=function(r){return this.names.indexOf(r)},to.prototype.glyphIndexToName=function(r){return this.names[r]};function Rf(r){let a,c=r.tables.cmap.glyphIndexMap,h=Object.keys(c);for(let f=0;f<h.length;f+=1){let g=h[f],y=c[g];a=r.glyphs.get(y),a.addUnicode(parseInt(g))}for(let f=0;f<r.glyphs.length;f+=1)a=r.glyphs.get(f),r.cffEncoding?a.name=r.cffEncoding.charset[f]:r.glyphNames.names&&(a.name=r.glyphNames.glyphIndexToName(f))}function Of(r){r._IndexToUnicodeMap={};let a=r.tables.cmap.glyphIndexMap,c=Object.keys(a);for(let h=0;h<c.length;h+=1){let f=c[h],g=a[f];r._IndexToUnicodeMap[g]===void 0?r._IndexToUnicodeMap[g]={unicodes:[parseInt(f)]}:r._IndexToUnicodeMap[g].unicodes.push(parseInt(f))}}function Mf(r,a){a.lowMemory?Of(r):Rf(r)}function Lf(r,a,c,h,f){r.beginPath(),r.moveTo(a,c),r.lineTo(h,f),r.stroke()}var In={line:Lf};function Ff(r,a){let c=new j(r,a),h=c.parseShort();h!==0&&console.warn("Only CPALv0 is currently fully supported.");let f=c.parseShort(),g=c.parseShort(),y=c.parseShort(),S=c.parseOffset32(),T=c.parseUShortList(g);c.relativeOffset=S;let C=c.parseULongList(y);return c.relativeOffset=S,{version:h,numPaletteEntries:f,colorRecords:C,colorRecordIndices:T}}function Df({version:r=0,numPaletteEntries:a=0,colorRecords:c=[],colorRecordIndices:h=[0]}){return V.argument(r===0,"Only CPALv0 are supported."),V.argument(c.length,"No colorRecords given."),V.argument(h.length,"No colorRecordIndices given."),h.length>1&&V.argument(a,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new rt.Table("CPAL",[{name:"version",type:"USHORT",value:r},{name:"numPaletteEntries",type:"USHORT",value:a||c.length},{name:"numPalettes",type:"USHORT",value:h.length},{name:"numColorRecords",type:"USHORT",value:c.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*h.length},...h.map((f,g)=>({name:"colorRecordIndices_"+g,type:"USHORT",value:f})),...c.map((f,g)=>({name:"colorRecords_"+g,type:"ULONG",value:f}))])}function rc(r){var a=(r&4278190080)>>24,c=(r&16711680)>>16,h=(r&65280)>>8,f=r&255;return a=a+256&255,c=c+256&255,h=h+256&255,f=(f+256&255)/255,{b:a,g:c,r:h,a:f}}function eo(r,a,c=0,h="hexa"){if(a==65535)return"currentColor";let f=r&&r.tables&&r.tables.cpal;if(!f)return"currentColor";if(c>f.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${f.colorRecordIndices.length}, index: ${a})`);if(a>f.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${f.numPaletteEntries}, index: ${a})`);let g=f.colorRecordIndices[c]+a;if(g>f.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${f.colorRecords.length}, lookupIndex: ${g})`);let y=rc(f.colorRecords[g]);return h==="bgra"?y:Yn(y,h)}function Ue(r){return("0"+parseInt(r).toString(16)).slice(-2)}function _f(r){let a=r.r/255,c=r.g/255,h=r.b/255,f=Math.max(a,c,h),g=Math.min(a,c,h),y,S,T=(f+g)/2;if(f===g)y=S=0;else{let C=f-g;switch(S=T>.5?C/(2-f-g):C/(f+g),f){case a:y=(c-h)/C+(c<h?6:0);break;case c:y=(h-a)/C+2;break;case h:y=(a-c)/C+4;break}y/=6}return{h:y*360,s:S*100,l:T*100}}function Nf(r){let{h:a,s:c,l:h,a:f}=r;a=a%360,c/=100,h/=100;let g=(1-Math.abs(2*h-1))*c,y=g*(1-Math.abs(a/60%2-1)),S=h-g/2,T=0,C=0,E=0;return 0<=a&&a<60?(T=g,C=y,E=0):60<=a&&a<120?(T=y,C=g,E=0):120<=a&&a<180?(T=0,C=g,E=y):180<=a&&a<240?(T=0,C=y,E=g):240<=a&&a<300?(T=y,C=0,E=g):300<=a&&a<=360&&(T=g,C=0,E=y),{r:Math.round((T+S)*255),g:Math.round((C+S)*255),b:Math.round((E+S)*255),a:f}}function sc(r){return parseInt(`0x${Ue(r.b)}${Ue(r.g)}${Ue(r.r)}${Ue(r.a*255)}`,16)}function ps(r,a="hexa"){let c=a=="raw"||a=="cpal",h=Number.isInteger(r),f=!0;if(h&&c||r==="currentColor")return r;if(typeof r=="object"){if(a=="bgra")return r;if(c)return sc(r)}else if(!h&&/^#([a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i.test(r.trim())){switch(r=r.trim().substring(1),r.length){case 3:r={r:parseInt(r[0].repeat(2),16),g:parseInt(r[1].repeat(2),16),b:parseInt(r[2].repeat(2),16),a:1};break;case 4:r={r:parseInt(r[0].repeat(2),16),g:parseInt(r[1].repeat(2),16),b:parseInt(r[2].repeat(2),16),a:parseInt(r[3].repeat(2),16)/255};break;case 6:r={r:parseInt(r[0]+r[1],16),g:parseInt(r[2]+r[3],16),b:parseInt(r[4]+r[5],16),a:1};break;case 8:r={r:parseInt(r[0]+r[1],16),g:parseInt(r[2]+r[3],16),b:parseInt(r[4]+r[5],16),a:parseInt(r[6]+r[7],16)/255};break}if(a=="bgra")return r}else if(typeof document<"u"&&/^[a-z]+$/i.test(r)){let g=document.createElement("canvas").getContext("2d");g.fillStyle=r;let y=Yn(g.fillStyle,"hexa");y==="#000000ff"&&r.toLowerCase()!=="black"?f=!1:r=y}else{r=r.trim();let g=/rgba?\(\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(g.test(r)){let y=r.match(g).filter(S=>typeof S<"u");r={r:Math.round(parseFloat(y[1])/(y[2]?.39215686274509803:1)),g:Math.round(parseFloat(y[3])/(y[4]?.39215686274509803:1)),b:Math.round(parseFloat(y[5])/(y[6]?.39215686274509803:1)),a:y[7]?parseFloat(y[7])/(y[8]?100:1):1}}else{let y=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(y.test(r)){let S=r.match(y).filter(T=>typeof T<"u");r=Nf({h:parseFloat(S[1])*(S[2]==="turn"?360:1),s:parseFloat(S[3]),l:parseFloat(S[4]),a:S[5]?parseFloat(S[5])/(S[6]?100:1):1})}else f=!1}}if(!f)throw new Error(`Invalid color format: ${r}`);return Yn(r,a)}function Yn(r,a="hexa"){if(r==="currentColor")return r;if(Number.isInteger(r)){if(a=="raw"||a=="cpal")return r;r=rc(r)}else typeof r!="object"&&(r=ps(r,"bgra"));let c=["hsl","hsla"].includes(a)?_f(r):null;switch(a){case"rgba":return`rgba(${r.r}, ${r.g}, ${r.b}, ${parseFloat(r.a.toFixed(3))})`;case"rgb":return`rgb(${r.r}, ${r.g}, ${r.b})`;case"hex":case"hex6":case"hex-6":return`#${Ue(r.r)}${Ue(r.g)}${Ue(r.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Ue(r.r)}${Ue(r.g)}${Ue(r.b)}${Ue(r.a*255)}`;case"hsl":return`hsl(${c.h.toFixed(2)}, ${c.s.toFixed(2)}%, ${c.l.toFixed(2)}%)`;case"hsla":return`hsla(${c.h.toFixed(2)}, ${c.s.toFixed(2)}%, ${c.l.toFixed(2)}%, ${parseFloat(r.a.toFixed(3))})`;case"bgra":return r;case"raw":case"cpal":return sc(r);default:throw new Error("Unknown color format: "+a)}}var ic={parse:Ff,make:Df,getPaletteColor:eo,parseColor:ps,formatColor:Yn};function Uf(r,a){let c=a||new Ut;return{configurable:!0,get:function(){return typeof c=="function"&&(c=c()),c},set:function(h){c=h}}}function oe(r){this.bindConstructorValues(r)}oe.prototype.bindConstructorValues=function(r){if(this.index=r.index||0,r.name===".notdef"?r.unicode=void 0:r.name===".null"&&(r.unicode=0),r.unicode===0&&r.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=r.name||null,this.unicode=r.unicode,this.unicodes=r.unicodes||(r.unicode!==void 0?[r.unicode]:[]),"xMin"in r&&(this.xMin=r.xMin),"yMin"in r&&(this.yMin=r.yMin),"xMax"in r&&(this.xMax=r.xMax),"yMax"in r&&(this.yMax=r.yMax),"advanceWidth"in r&&(this.advanceWidth=r.advanceWidth),"leftSideBearing"in r&&(this.leftSideBearing=r.leftSideBearing),"points"in r&&(this.points=r.points),Object.defineProperty(this,"path",Uf(this,r.path))},oe.prototype.addUnicode=function(r){this.unicodes.length===0&&(this.unicode=r),this.unicodes.push(r)},oe.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},oe.prototype.getPath=function(r,a,c,h,f){r=r!==void 0?r:0,a=a!==void 0?a:0,c=c!==void 0?c:72,h=Object.assign({},f&&f.defaultRenderOptions,h);let g,y,S=h.xScale,T=h.yScale,C=1/(this.path.unitsPerEm||1e3)*c,E=this;f&&f.variation&&(E=f.variation.getTransform(this,h.variation),g=E.path.commands),h.hinting&&f&&f.hinting&&(y=E.path&&f.hinting.exec(E,c,h)),y?(g=f.hinting.getCommands(y),r=Math.round(r),a=Math.round(a),S=T=1):(g=E.path.commands,S===void 0&&(S=C),T===void 0&&(T=C));let O=new Ut;if(h.drawSVG){let R=this.getSvgImage(f);if(R){let F=new Ut;return F._image={image:R.image,x:r+R.leftSideBearing*C,y:a-R.baseline*C,width:R.image.width*C,height:R.image.height*C},O._layers=[F],O}}if(h.drawLayers){let R=this.getLayers(f);if(R&&R.length){O._layers=[];for(let F=0;F<R.length;F+=1){let L=R[F],B=eo(f,L.paletteIndex,h.usePalette);B==="currentColor"?B=h.fill||"black":B=Yn(B,h.colorFormat||"rgba"),h=Object.assign({},h,{fill:B}),O._layers.push(this.getPath.call(L.glyph,r,a,c,h,f))}return O}}O.fill=h.fill||this.path.fill,O.stroke=this.path.stroke,O.strokeWidth=this.path.strokeWidth*C;for(let R=0;R<g.length;R+=1){let F=g[R];F.type==="M"?O.moveTo(r+F.x*S,a+-F.y*T):F.type==="L"?O.lineTo(r+F.x*S,a+-F.y*T):F.type==="Q"?O.quadraticCurveTo(r+F.x1*S,a+-F.y1*T,r+F.x*S,a+-F.y*T):F.type==="C"?O.curveTo(r+F.x1*S,a+-F.y1*T,r+F.x2*S,a+-F.y2*T,r+F.x*S,a+-F.y*T):F.type==="Z"&&O.stroke&&O.strokeWidth&&O.closePath()}return O},oe.prototype.getLayers=function(r){if(!r)throw new Error("The font object is required to read the colr/cpal tables in order to get the layers.");return r.layers.get(this.index)},oe.prototype.getSvgImage=function(r){if(!r)throw new Error("The font object is required to read the svg table in order to get the image.");return r.svgImages.get(this.index)},oe.prototype.getContours=function(r=null){if(this.points===void 0&&!r)return[];let a=[],c=[],h=r||this.points;for(let f=0;f<h.length;f+=1){let g=h[f];c.push(g),g.lastPointOfContour&&(a.push(c),c=[])}return V.argument(c.length===0,"There are still points left in the current contour."),a},oe.prototype.getMetrics=function(){let r=this.path.commands,a=[],c=[];for(let f=0;f<r.length;f+=1){let g=r[f];g.type!=="Z"&&(a.push(g.x),c.push(g.y)),(g.type==="Q"||g.type==="C")&&(a.push(g.x1),c.push(g.y1)),g.type==="C"&&(a.push(g.x2),c.push(g.y2))}let h={xMin:Math.min.apply(null,a),yMin:Math.min.apply(null,c),xMax:Math.max.apply(null,a),yMax:Math.max.apply(null,c),leftSideBearing:this.leftSideBearing};return isFinite(h.xMin)||(h.xMin=0),isFinite(h.xMax)||(h.xMax=this.advanceWidth),isFinite(h.yMin)||(h.yMin=0),isFinite(h.yMax)||(h.yMax=0),h.rightSideBearing=this.advanceWidth-h.leftSideBearing-(h.xMax-h.xMin),h},oe.prototype.draw=function(r,a,c,h,f,g){f=Object.assign({},g&&g.defaultRenderOptions,f),this.getPath(a,c,h,f,g).draw(r)},oe.prototype.drawPoints=function(r,a,c,h,f,g){if(f=Object.assign({},g&&g.defaultRenderOptions,f),f.drawLayers){let R=this.getLayers(g);if(R&&R.length){for(let F=0;F<R.length;F+=1)R[F].glyph.index!==this.index&&this.drawPoints.call(R[F].glyph,r,a,c,h);return}}function y(R,F,L,B){r.beginPath();for(let Y=0;Y<R.length;Y+=1)r.moveTo(F+R[Y].x*B,L+R[Y].y*B),r.arc(F+R[Y].x*B,L+R[Y].y*B,2,0,Math.PI*2,!1);r.fill()}a=a!==void 0?a:0,c=c!==void 0?c:0,h=h!==void 0?h:24;let S=1/this.path.unitsPerEm*h,T=[],C=[],O=this.path.commands;g&&g.variation&&(O=g.variation.getTransform(this,f.variation).path.commands);for(let R=0;R<O.length;R+=1){let F=O[R];F.x!==void 0&&T.push({x:F.x,y:-F.y}),F.x1!==void 0&&C.push({x:F.x1,y:-F.y1}),F.x2!==void 0&&C.push({x:F.x2,y:-F.y2})}r.fillStyle="blue",y(T,a,c,S),r.fillStyle="red",y(C,a,c,S)},oe.prototype.drawMetrics=function(r,a,c,h){let f;a=a!==void 0?a:0,c=c!==void 0?c:0,h=h!==void 0?h:24,f=1/this.path.unitsPerEm*h,r.lineWidth=1,r.strokeStyle="black",In.line(r,a,-1e4,a,1e4),In.line(r,-1e4,c,1e4,c);let g=this.xMin||0,y=this.yMin||0,S=this.xMax||0,T=this.yMax||0,C=this.advanceWidth||0;r.strokeStyle="blue",In.line(r,a+g*f,-1e4,a+g*f,1e4),In.line(r,a+S*f,-1e4,a+S*f,1e4),In.line(r,-1e4,c+-y*f,1e4,c+-y*f),In.line(r,-1e4,c+-T*f,1e4,c+-T*f),r.strokeStyle="green",In.line(r,a+C*f,-1e4,a+C*f,1e4)},oe.prototype.toPathData=function(r,a){r=Object.assign({},{variation:a&&a.defaultRenderOptions.variation},r);let c=this;a&&a.variation&&(c=a.variation.getTransform(this,r.variation));let h=c.points&&r.pointsTransform?r.pointsTransform(c.points):c.path;return r.pathTransform&&(h=r.pathTransform(h)),h.toPathData(r)},oe.prototype.fromSVG=function(r,a={}){return this.path.fromSVG(r,a)},oe.prototype.toSVG=function(r,a){let c=this.toPathData.apply(this,[r,a]);return this.path.toSVG(r,c)},oe.prototype.toDOMElement=function(r,a){r=Object.assign({},{variation:a&&a.defaultRenderOptions.variation},r);let c=this.path;return a&&a.variation&&(c=a.variation.getTransform(this,r.variation).path),c.toDOMElement(r)};var Kn=oe;function Zn(r,a,c){Object.defineProperty(r,a,{get:function(){return typeof r[c]>"u"&&r.path,r[c]},set:function(h){r[c]=h},enumerable:!0,configurable:!0})}function gs(r,a){if(this.font=r,this.glyphs={},Array.isArray(a))for(let c=0;c<a.length;c++){let h=a[c];h.path.unitsPerEm=r.unitsPerEm,this.glyphs[c]=h}this.length=a&&a.length||0}typeof Symbol<"u"&&Symbol.iterator&&(gs.prototype[Symbol.iterator]=function(){let r=-1;return{next:function(){r++;let a=r>=this.length-1;return{value:this.get(r),done:a}}.bind(this)}}),gs.prototype.get=function(r){if(this.font._push&&this.glyphs[r]===void 0){this.font._push(r),typeof this.glyphs[r]=="function"&&(this.glyphs[r]=this.glyphs[r]());let a=this.glyphs[r],c=this.font._IndexToUnicodeMap[r];if(c)for(let h=0;h<c.unicodes.length;h++)a.addUnicode(c.unicodes[h]);this.font.cffEncoding?a.name=this.font.cffEncoding.charset[r]:this.font.glyphNames.names&&(a.name=this.font.glyphNames.glyphIndexToName(r)),this.glyphs[r].advanceWidth=this.font._hmtxTableData[r].advanceWidth,this.glyphs[r].leftSideBearing=this.font._hmtxTableData[r].leftSideBearing}else typeof this.glyphs[r]=="function"&&(this.glyphs[r]=this.glyphs[r]());return this.glyphs[r]},gs.prototype.push=function(r,a){this.glyphs[r]=a,this.length++};function Bf(r,a){return new Kn({index:a,font:r})}function Gf(r,a,c,h,f,g){return function(){let y=new Kn({index:a,font:r});return y.path=function(){c(y,h,f);let S=g(r.glyphs,y);return S.unitsPerEm=r.unitsPerEm,S},Zn(y,"numberOfContours","_numberOfContours"),Zn(y,"xMin","_xMin"),Zn(y,"xMax","_xMax"),Zn(y,"yMin","_yMin"),Zn(y,"yMax","_yMax"),Zn(y,"points","_points"),y}}function Hf(r,a,c,h,f){return function(){let g=new Kn({index:a,font:r});return g.path=function(){let y=c(r,g,h,f);return y.unitsPerEm=r.unitsPerEm,y},g}}var ze={GlyphSet:gs,glyphLoader:Bf,ttfGlyphLoader:Gf,cffGlyphLoader:Hf};function oc(r,a){if(r===a)return!0;if(Array.isArray(r)&&Array.isArray(a)){if(r.length!==a.length)return!1;for(let c=0;c<r.length;c+=1)if(!oc(r[c],a[c]))return!1;return!0}else return!1}var ac=10;function ms(r){let a;return r.length<1240?a=107:r.length<33900?a=1131:a=32768,a}function Xe(r,a,c,h){let f=[],g=[],y=h>1?ht.getULong(r,a):ht.getCard16(r,a),S=h>1?4:2,T,C;if(y!==0){let E=ht.getByte(r,a+S);T=a+(y+1)*E+S;let O=a+S+1;for(let R=0;R<y+1;R+=1)f.push(ht.getOffset(r,O,E)),O+=E;C=T+f[y]}else C=a+S;for(let E=0;E<f.length-1;E+=1){let O=ht.getBytes(r,T+f[E],T+f[E+1]);c&&(O=c(O,r,a,h)),g.push(O)}return{objects:g,startOffset:a,endOffset:C}}function jf(r,a,c){let h=[],f=c>1?ht.getULong(r,a):ht.getCard16(r,a),g=c>1?4:2,y,S;if(f!==0){let T=ht.getByte(r,a+g);y=a+(f+1)*T+g;let C=a+g+1;for(let E=0;E<f+1;E+=1)h.push(ht.getOffset(r,C,T)),C+=T;S=y+h[f]}else S=a+g;return{offsets:h,startOffset:a,endOffset:S}}function Vf(r,a,c,h,f,g){let y=g>1?ht.getULong(c,h):ht.getCard16(c,h),S=g>1?4:2,T=0;if(y!==0){let E=ht.getByte(c,h+S);T=h+(y+1)*E+S}let C=ht.getBytes(c,T+a[r],T+a[r+1]);return f&&(C=f(C)),C}function Wf(r){let a="",h=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){let f=r.parseByte(),g=f>>4,y=f&15;if(g===15||(a+=h[g],y===15))break;a+=h[y]}return parseFloat(a)}function $f(r,a){let c,h,f,g;if(a===28)return c=r.parseByte(),h=r.parseByte(),c<<8|h;if(a===29)return c=r.parseByte(),h=r.parseByte(),f=r.parseByte(),g=r.parseByte(),c<<24|h<<16|f<<8|g;if(a===30)return Wf(r);if(a>=32&&a<=246)return a-139;if(a>=247&&a<=250)return c=r.parseByte(),(a-247)*256+c+108;if(a>=251&&a<=254)return c=r.parseByte(),-(a-251)*256-c-108;throw new Error("Invalid b0 "+a)}function zf(r){let a={};for(let c=0;c<r.length;c+=1){let h=r[c][0],f=r[c][1],g;if(f.length===1?g=f[0]:g=f,Object.prototype.hasOwnProperty.call(a,h)&&!isNaN(a[h]))throw new Error("Object "+a+" already has key "+h);a[h]=g}return a}function no(r,a,c,h){a=a!==void 0?a:0;let f=new ht.Parser(r,a),g=[],y=[];c=c!==void 0?c:r.byteLength;let S=h<2?22:28;for(;f.relativeOffset<c;){let T=f.parseByte();if(T<S){if(T===12&&(T=1200+f.parseByte()),h>1&&T===23){tp(y);continue}g.push([T,y]),y=[]}else y.push($f(f,T,h))}return zf(g)}function br(r,a){return a<=390?a=fs[a]:r?a=r[a-391]:a=void 0,a}function ro(r,a,c){let h={},f;for(let g=0;g<a.length;g+=1){let y=a[g];if(Array.isArray(y.type)){let S=[];S.length=y.type.length;for(let T=0;T<y.type.length;T++)f=r[y.op]!==void 0?r[y.op][T]:void 0,f===void 0&&(f=y.value!==void 0&&y.value[T]!==void 0?y.value[T]:null),y.type[T]==="SID"&&(f=br(c,f)),S[T]=f;h[y.name]=S}else f=r[y.op],f===void 0&&(f=y.value!==void 0?y.value:null),y.type==="SID"&&(f=br(c,f)),h[y.name]=f}return h}function Xf(r,a){let c={};if(c.formatMajor=ht.getCard8(r,a),c.formatMinor=ht.getCard8(r,a+1),c.formatMajor>2)throw new Error(`Unsupported CFF table version ${c.formatMajor}.${c.formatMinor}`);return c.size=ht.getCard8(r,a+2),c.formatMajor<2?(c.offsetSize=ht.getCard8(r,a+3),c.startOffset=a,c.endOffset=a+4):(c.topDictLength=ht.getCard16(r,a+3),c.endOffset=a+8),c}var lc=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],cc=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],uc=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],hc=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],Yf=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function Kf(r,a,c,h){let f=no(r,a,r.byteLength,h);return ro(f,h>1?cc:lc,c)}function so(r,a,c,h,f){let g=no(r,a,c,f);return ro(g,f>1?hc:uc,h)}function Zf(r,a,c){let h=no(r,a,void 0,c);return ro(h,Yf)}function Qf(r,a,c){let h=[];for(let f=0;f<c.length;f++){let g=new DataView(new Uint8Array(c[f]).buffer),y=Zf(g,0,2),S=y.private[0],T=y.private[1];if(S!==0&&T!==0){let C=so(r,T+a,S,[],2);if(C.subrs){let E=T+C.subrs,O=Xe(r,E+a,void 0,2);y._subrs=O.objects,y._subrsBias=ms(y._subrs)}y._privateDict=C}h.push(y)}return h}function io(r,a,c,h,f){let g=[];for(let y=0;y<c.length;y+=1){let S=new DataView(new Uint8Array(c[y]).buffer),T=Kf(S,0,h,f);T._subrs=[],T._subrsBias=0,T._defaultWidthX=0,T._nominalWidthX=0;let C=f<2?T.private[0]:0,E=f<2?T.private[1]:0;if(C!==0&&E!==0){let O=so(r,E+a,C,h,f);if(T._defaultWidthX=O.defaultWidthX,T._nominalWidthX=O.nominalWidthX,O.subrs!==0){let R=E+O.subrs,F=Xe(r,R+a,void 0,f);T._subrs=F.objects,T._subrsBias=ms(T._subrs)}T._privateDict=O}g.push(T)}return g}function Jf(r,a,c,h,f){let g,y,S=new ht.Parser(r,a);c-=1;let T=[".notdef"],C=S.parseCard8();if(C===0)for(let E=0;E<c;E+=1)g=S.parseSID(),f?T.push(g):T.push(br(h,g)||g);else if(C===1)for(;T.length<=c;){g=S.parseSID(),y=S.parseCard8();for(let E=0;E<=y;E+=1)f?T.push("cid"+("00000"+g).slice(-5)):T.push(br(h,g)||g),g+=1}else if(C===2)for(;T.length<=c;){g=S.parseSID(),y=S.parseCard16();for(let E=0;E<=y;E+=1)f?T.push("cid"+("00000"+g).slice(-5)):T.push(br(h,g)||g),g+=1}else throw new Error("Unknown charset format "+C);return T}function qf(r,a){let c,h={},f=new ht.Parser(r,a),g=f.parseCard8();if(g===0){let y=f.parseCard8();for(let S=0;S<y;S+=1)c=f.parseCard8(),h[c]=S}else if(g===1){let y=f.parseCard8();c=1;for(let S=0;S<y;S+=1){let T=f.parseCard8(),C=f.parseCard8();for(let E=T;E<=T+C;E+=1)h[E]=c,c+=1}}else throw new Error("Unknown encoding format "+g);return h}function tp(r){let a=r.pop();for(;r.length>a;)r.pop()}function dc(r,a){let c=r.tables.cff&&r.tables.cff.topDict&&r.tables.cff.topDict.paintType||0;return c===2&&(a.fill=null,a.stroke="black",a.strokeWidth=r.tables.cff.topDict.strokeWidth||0),c}function oo(r,a,c,h,f){let g,y,S,T,C=new Ut,E=[],O=0,R=!1,F=!1,L=0,B=0,Y,yt,mt,At,Rt=0,Nt=[],Gt,Ht=0,qt=r.tables.cff2||r.tables.cff;if(mt=qt.topDict._defaultWidthX,At=qt.topDict._nominalWidthX,f=f||r.variation&&r.variation.get(),a.getBlendPath||(a.getBlendPath=function(ft){return oo(r,a,c,h,ft)}),r.isCIDFont||h>1){let ft=qt.topDict._fdSelect?qt.topDict._fdSelect[a.index]:0,gt=qt.topDict._fdArray[ft];Y=gt._subrs,yt=gt._subrsBias,h>1?(Nt=qt.topDict._vstore.itemVariationStore,Rt=gt._privateDict.vsindex):(mt=gt._defaultWidthX,At=gt._nominalWidthX)}else Y=qt.topDict._subrs,yt=qt.topDict._subrsBias;let He=dc(r,C),Ot=mt;function Ee(ft,gt){F&&He!==2&&C.closePath(),C.moveTo(ft,gt),F=!0}function fe(){let ft;ft=(E.length&1)!==0,ft&&!R&&(Ot=E.shift()+At),O+=E.length>>1,E.length=0,R=!0}function vt(ft){let gt,ae,gn,Cs,Mn,je,pe,Oe,le,Ce,ge,me,Qt=0;for(;Qt<ft.length;){let Le=ft[Qt];switch(Qt+=1,Le){case 1:fe();break;case 3:fe();break;case 4:E.length>1&&!R&&(Ot=E.shift()+At,R=!0),B+=E.pop(),Ee(L,B);break;case 5:for(;E.length>0;)L+=E.shift(),B+=E.shift(),C.lineTo(L,B);break;case 6:for(;E.length>0&&(L+=E.shift(),C.lineTo(L,B),E.length!==0);)B+=E.shift(),C.lineTo(L,B);break;case 7:for(;E.length>0&&(B+=E.shift(),C.lineTo(L,B),E.length!==0);)L+=E.shift(),C.lineTo(L,B);break;case 8:for(;E.length>0;)g=L+E.shift(),y=B+E.shift(),S=g+E.shift(),T=y+E.shift(),L=S+E.shift(),B=T+E.shift(),C.curveTo(g,y,S,T,L,B);break;case 10:if(Mn=E.pop()+yt,je=Y[Mn],je){if(Ht>=ac){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}Ht++,vt(je),Ht--}break;case 11:if(h>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Le=ft[Qt],Qt+=1,Le){case 35:g=L+E.shift(),y=B+E.shift(),S=g+E.shift(),T=y+E.shift(),pe=S+E.shift(),Oe=T+E.shift(),le=pe+E.shift(),Ce=Oe+E.shift(),ge=le+E.shift(),me=Ce+E.shift(),L=ge+E.shift(),B=me+E.shift(),E.shift(),C.curveTo(g,y,S,T,pe,Oe),C.curveTo(le,Ce,ge,me,L,B);break;case 34:g=L+E.shift(),y=B,S=g+E.shift(),T=y+E.shift(),pe=S+E.shift(),Oe=T,le=pe+E.shift(),Ce=T,ge=le+E.shift(),me=B,L=ge+E.shift(),C.curveTo(g,y,S,T,pe,Oe),C.curveTo(le,Ce,ge,me,L,B);break;case 36:g=L+E.shift(),y=B+E.shift(),S=g+E.shift(),T=y+E.shift(),pe=S+E.shift(),Oe=T,le=pe+E.shift(),Ce=T,ge=le+E.shift(),me=Ce+E.shift(),L=ge+E.shift(),C.curveTo(g,y,S,T,pe,Oe),C.curveTo(le,Ce,ge,me,L,B);break;case 37:g=L+E.shift(),y=B+E.shift(),S=g+E.shift(),T=y+E.shift(),pe=S+E.shift(),Oe=T+E.shift(),le=pe+E.shift(),Ce=Oe+E.shift(),ge=le+E.shift(),me=Ce+E.shift(),Math.abs(ge-L)>Math.abs(me-B)?L=ge+E.shift():B=me+E.shift(),C.curveTo(g,y,S,T,pe,Oe),C.curveTo(le,Ce,ge,me,L,B);break;default:console.log("Glyph "+a.index+": unknown operator 1200"+Le),E.length=0}break;case 14:if(h>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(E.length>=4){let Ln=qi[E.pop()],tr=qi[E.pop()],ks=E.pop(),Is=E.pop();if(Ln&&tr){a.isComposite=!0,a.components=[];let ku=r.cffEncoding.charset.indexOf(Ln),Iu=r.cffEncoding.charset.indexOf(tr);a.components.push({glyphIndex:Iu,dx:0,dy:0}),a.components.push({glyphIndex:ku,dx:Is,dy:ks}),C.extend(r.glyphs.get(Iu).path);let Nb=r.glyphs.get(ku),Eo=JSON.parse(JSON.stringify(Nb.path.commands));for(let Co=0;Co<Eo.length;Co+=1){let Ke=Eo[Co];Ke.type!=="Z"&&(Ke.x+=Is,Ke.y+=ks),(Ke.type==="Q"||Ke.type==="C")&&(Ke.x1+=Is,Ke.y1+=ks),Ke.type==="C"&&(Ke.x2+=Is,Ke.y2+=ks)}C.extend(Eo)}}else E.length>0&&!R&&(Ot=E.shift()+At,R=!0);F&&He!==2&&(C.closePath(),F=!1);break;case 15:if(h<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}Rt=E.pop();break;case 16:if(h<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}Gt||(Gt=r.variation&&f&&r.variation.process.getBlendVector(Nt,Rt,f));var Wt=E.pop(),ve=Gt?Gt.length:Nt.itemVariationSubtables[Rt].regionIndexes.length,Me=Wt*ve,Ve=E.length-Me,rn=Ve-Wt;if(Gt)for(let Ln=0;Ln<Wt;Ln++){var Cu=E[rn+Ln];for(let tr=0;tr<ve;tr++)Cu+=Gt[tr]*E[Ve++];E[rn+Ln]=Cu}for(;Me--;)E.pop();break;case 18:fe();break;case 19:case 20:fe(),Qt+=O+7>>3;break;case 21:E.length>2&&!R&&(Ot=E.shift()+At,R=!0),B+=E.pop(),L+=E.pop(),Ee(L,B);break;case 22:E.length>1&&!R&&(Ot=E.shift()+At,R=!0),L+=E.pop(),Ee(L,B);break;case 23:fe();break;case 24:for(;E.length>2;)g=L+E.shift(),y=B+E.shift(),S=g+E.shift(),T=y+E.shift(),L=S+E.shift(),B=T+E.shift(),C.curveTo(g,y,S,T,L,B);L+=E.shift(),B+=E.shift(),C.lineTo(L,B);break;case 25:for(;E.length>6;)L+=E.shift(),B+=E.shift(),C.lineTo(L,B);g=L+E.shift(),y=B+E.shift(),S=g+E.shift(),T=y+E.shift(),L=S+E.shift(),B=T+E.shift(),C.curveTo(g,y,S,T,L,B);break;case 26:for(E.length&1&&(L+=E.shift());E.length>0;)g=L,y=B+E.shift(),S=g+E.shift(),T=y+E.shift(),L=S,B=T+E.shift(),C.curveTo(g,y,S,T,L,B);break;case 27:for(E.length&1&&(B+=E.shift());E.length>0;)g=L+E.shift(),y=B,S=g+E.shift(),T=y+E.shift(),L=S+E.shift(),B=T,C.curveTo(g,y,S,T,L,B);break;case 28:gt=ft[Qt],ae=ft[Qt+1],E.push((gt<<24|ae<<16)>>16),Qt+=2;break;case 29:if(Mn=E.pop()+r.gsubrsBias,je=r.gsubrs[Mn],je){if(Ht>=ac){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}Ht++,vt(je),Ht--}break;case 30:for(;E.length>0&&(g=L,y=B+E.shift(),S=g+E.shift(),T=y+E.shift(),L=S+E.shift(),B=T+(E.length===1?E.shift():0),C.curveTo(g,y,S,T,L,B),E.length!==0);)g=L+E.shift(),y=B,S=g+E.shift(),T=y+E.shift(),B=T+E.shift(),L=S+(E.length===1?E.shift():0),C.curveTo(g,y,S,T,L,B);break;case 31:for(;E.length>0&&(g=L+E.shift(),y=B,S=g+E.shift(),T=y+E.shift(),B=T+E.shift(),L=S+(E.length===1?E.shift():0),C.curveTo(g,y,S,T,L,B),E.length!==0);)g=L,y=B+E.shift(),S=g+E.shift(),T=y+E.shift(),L=S+E.shift(),B=T+(E.length===1?E.shift():0),C.curveTo(g,y,S,T,L,B);break;default:Le<32?console.log("Glyph "+a.index+": unknown operator "+Le):Le<247?E.push(Le-139):Le<251?(gt=ft[Qt],Qt+=1,E.push((Le-247)*256+gt+108)):Le<255?(gt=ft[Qt],Qt+=1,E.push(-(Le-251)*256-gt-108)):(gt=ft[Qt],ae=ft[Qt+1],gn=ft[Qt+2],Cs=ft[Qt+3],Qt+=4,E.push((gt<<24|ae<<16|gn<<8|Cs)/65536))}}}return vt(c),r.variation&&f&&(C.commands=C.commands.map(ft=>{let gt=Object.keys(ft);for(let ae=0;ae<gt.length;ae++){let gn=gt[ae];gn!=="type"&&(ft[gn]=Math.round(ft[gn]))}return ft})),R&&(a.advanceWidth=Ot),C}function fc(r,a,c,h,f){let g=[],y,S=new ht.Parser(r,a),T=S.parseCard8();if(T===0)for(let C=0;C<c;C++){if(y=S.parseCard8(),y>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+y+" (FD count "+h+")");g.push(y)}else if(T===3||f>1&&T===4){let C=T===4?S.parseULong():S.parseCard16(),E=T===4?S.parseULong():S.parseCard16();if(E!==0)throw new Error(`CFF Table CID Font FDSelect format ${T} range has bad initial GID ${E}`);let O;for(let R=0;R<C;R++){if(y=T===4?S.parseUShort():S.parseCard8(),O=T===4?S.parseULong():S.parseCard16(),y>=h)throw new Error("CFF table CID Font FDSelect has bad FD index value "+y+" (FD count "+h+")");if(O>c)throw new Error(`CFF Table CID Font FDSelect format ${f} range has bad GID ${O}`);for(;E<O;E++)g.push(y);E=O}if(O!==c)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID "+O)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+T);return g}function ep(r,a,c,h){let f,g=Xf(r,a);g.formatMajor===2?f=c.tables.cff2={}:f=c.tables.cff={};let y=g.formatMajor>1?null:Xe(r,g.endOffset,ht.bytesToString),S=g.formatMajor>1?null:Xe(r,y.endOffset),T=g.formatMajor>1?null:Xe(r,S.endOffset,ht.bytesToString),C=Xe(r,g.formatMajor>1?a+g.size+g.topDictLength:T.endOffset,void 0,g.formatMajor);c.gsubrs=C.objects,c.gsubrsBias=ms(c.gsubrs);let E;if(g.formatMajor>1){let R=a+g.size,F=ht.getBytes(r,R,R+g.topDictLength);E=io(r,0,[F],void 0,g.formatMajor)[0]}else{let R=io(r,a,S.objects,T.objects,g.formatMajor);if(R.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+R.length);E=R[0]}if(f.topDict=E,E._privateDict&&(c.defaultWidthX=E._privateDict.defaultWidthX,c.nominalWidthX=E._privateDict.nominalWidthX),g.formatMajor<2&&E.ros[0]!==void 0&&E.ros[1]!==void 0&&(c.isCIDFont=!0),g.formatMajor>1){let R=E.fdArray,F=E.fdSelect;if(!R)throw new Error("This is a CFF2 font, but FDArray information is missing");let L=Xe(r,a+R,null,g.formatMajor),B=Qf(r,a,L.objects);E._fdArray=B,F&&(E._fdSelect=fc(r,a+F,c.numGlyphs,B.length,g.formatMajor))}else if(c.isCIDFont){let R=E.fdArray,F=E.fdSelect;if(R===0||F===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");R+=a;let L=Xe(r,R),B=io(r,a,L.objects,T.objects,g.formatMajor);E._fdArray=B,F+=a,E._fdSelect=fc(r,F,c.numGlyphs,B.length,g.formatMajor)}if(g.formatMajor<2){let R=a+E.private[1],F=so(r,R,E.private[0],T.objects,g.formatMajor);if(c.defaultWidthX=F.defaultWidthX,c.nominalWidthX=F.nominalWidthX,F.subrs!==0){let L=R+F.subrs,B=Xe(r,L);c.subrs=B.objects,c.subrsBias=ms(c.subrs)}else c.subrs=[],c.subrsBias=0}let O;if(h.lowMemory?(O=jf(r,a+E.charStrings,g.formatMajor),c.nGlyphs=O.offsets.length-(g.formatMajor>1?1:0)):(O=Xe(r,a+E.charStrings,null,g.formatMajor),c.nGlyphs=O.objects.length),g.formatMajor>1&&c.tables.maxp&&c.nGlyphs!==c.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${c.nGlyphs}) must correspond to the glyph count in the maxp table (${c.tables.maxp.numGlyphs})`),g.formatMajor<2){let R=[],F=[];E.charset===0?R=Cf:E.charset===1?R=kf:E.charset===2?R=If:R=Jf(r,a+E.charset,c.nGlyphs,T.objects,c.isCIDFont),E.encoding===0?F=qi:E.encoding===1?F=Pf:F=qf(r,a+E.encoding),c.cffEncoding=new nc(F,R),c.encoding=c.encoding||c.cffEncoding}if(c.glyphs=new ze.GlyphSet(c),h.lowMemory)c._push=function(R){let F=Vf(R,O.offsets,r,a+E.charStrings,void 0,g.formatMajor);c.glyphs.push(R,ze.cffGlyphLoader(c,R,oo,F,g.formatMajor))};else for(let R=0;R<c.nGlyphs;R+=1){let F=O.objects[R];c.glyphs.push(R,ze.cffGlyphLoader(c,R,oo,F,g.formatMajor))}if(E.vstore){let R=new ht.Parser(r,a+E.vstore);E._vstore=R.parseVariationStore()}}function pc(r,a){let c,h=fs.indexOf(r);return h>=0&&(c=h),h=a.indexOf(r),h>=0?c=h+fs.length:(c=fs.length+a.length,a.push(r)),c}function np(){return new rt.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function rp(r){let a=new rt.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);a.names=[];for(let c=0;c<r.length;c+=1)a.names.push({name:"name_"+c,type:"NAME",value:r[c]});return a}function gc(r,a,c){let h={};for(let f=0;f<r.length;f+=1){let g=r[f],y=a[g.name];y!==void 0&&!oc(y,g.value)&&(g.type==="SID"&&(y=pc(y,c)),h[g.op]={name:g.name,type:g.type,value:y})}return h}function mc(r,a,c){let h=new rt.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=gc(c>1?cc:lc,r,a),h}function bc(r){let a=new rt.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return a.topDicts=[{name:"topDict_0",type:"TABLE",value:r}],a}function sp(r){let a=new rt.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);a.strings=[];for(let c=0;c<r.length;c+=1)a.strings.push({name:"string_"+c,type:"STRING",value:r[c]});return a}function ip(){return new rt.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function op(r,a){let c=new rt.Record("Charsets",[{name:"format",type:"Card8",value:0}]);for(let h=0;h<r.length;h+=1){let f=r[h],g=pc(f,a);c.fields.push({name:"glyph_"+h,type:"SID",value:g})}return c}function ap(r,a){let c=[],h=r.path;a<2&&c.push({name:"width",type:"NUMBER",value:r.advanceWidth});let f=0,g=0;for(let y=0;y<h.commands.length;y+=1){let S,T,C=h.commands[y];if(C.type==="Q"){let E=.3333333333333333,O=2/3;C={type:"C",x:C.x,y:C.y,x1:Math.round(E*f+O*C.x1),y1:Math.round(E*g+O*C.y1),x2:Math.round(E*C.x+O*C.x1),y2:Math.round(E*C.y+O*C.y1)}}if(C.type==="M")S=Math.round(C.x-f),T=Math.round(C.y-g),c.push({name:"dx",type:"NUMBER",value:S}),c.push({name:"dy",type:"NUMBER",value:T}),c.push({name:"rmoveto",type:"OP",value:21}),f=Math.round(C.x),g=Math.round(C.y);else if(C.type==="L")S=Math.round(C.x-f),T=Math.round(C.y-g),c.push({name:"dx",type:"NUMBER",value:S}),c.push({name:"dy",type:"NUMBER",value:T}),c.push({name:"rlineto",type:"OP",value:5}),f=Math.round(C.x),g=Math.round(C.y);else if(C.type==="C"){let E=Math.round(C.x1-f),O=Math.round(C.y1-g),R=Math.round(C.x2-C.x1),F=Math.round(C.y2-C.y1);S=Math.round(C.x-C.x2),T=Math.round(C.y-C.y2),c.push({name:"dx1",type:"NUMBER",value:E}),c.push({name:"dy1",type:"NUMBER",value:O}),c.push({name:"dx2",type:"NUMBER",value:R}),c.push({name:"dy2",type:"NUMBER",value:F}),c.push({name:"dx",type:"NUMBER",value:S}),c.push({name:"dy",type:"NUMBER",value:T}),c.push({name:"rrcurveto",type:"OP",value:8}),f=Math.round(C.x),g=Math.round(C.y)}}return a<2&&c.push({name:"endchar",type:"OP",value:14}),c}function lp(r,a){let c=new rt.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]);for(let h=0;h<r.length;h+=1){let f=r.get(h),g=ap(f,a);c.charStrings.push({name:f.name,type:"CHARSTRING",value:g})}return c}function cp(r,a,c){let h=new rt.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return h.dict=gc(c>1?hc:uc,r,a),h}function up(r,a){let h=new rt.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),f=1/a.unitsPerEm,g={version:a.version,fullName:a.fullName,familyName:a.familyName,weight:a.weightName,fontBBox:a.fontBBox||[0,0,0,0],fontMatrix:[f,0,0,f,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},y=a&&a.topDict||{};y.paintType&&(g.paintType=y.paintType,g.strokeWidth=y.strokeWidth||0);let S={},T=[],C;for(let F=1;F<r.length;F+=1)C=r.get(F),T.push(C.name);let E=[];h.header=np(),h.nameIndex=rp([a.postScriptName]);let O=mc(g,E);h.topDictIndex=bc(O),h.globalSubrIndex=ip(),h.charsets=op(T,E),h.charStringsIndex=lp(r,1),h.privateDict=cp(S,E),h.stringIndex=sp(E);let R=h.header.sizeOf()+h.nameIndex.sizeOf()+h.topDictIndex.sizeOf()+h.stringIndex.sizeOf()+h.globalSubrIndex.sizeOf();return g.charset=R,g.encoding=0,g.charStrings=g.charset+h.charsets.sizeOf(),g.private[1]=g.charStrings+h.charStringsIndex.sizeOf(),O=mc(g,E),h.topDictIndex=bc(O),h}var ao={parse:ep,make:up};function hp(r,a){let c={},h=new ht.Parser(r,a);return c.version=h.parseVersion(),c.fontRevision=Math.round(h.parseFixed()*1e3)/1e3,c.checkSumAdjustment=h.parseULong(),c.magicNumber=h.parseULong(),V.argument(c.magicNumber===1594834165,"Font header has wrong magic number."),c.flags=h.parseUShort(),c.unitsPerEm=h.parseUShort(),c.created=h.parseLongDateTime(),c.modified=h.parseLongDateTime(),c.xMin=h.parseShort(),c.yMin=h.parseShort(),c.xMax=h.parseShort(),c.yMax=h.parseShort(),c.macStyle=h.parseUShort(),c.lowestRecPPEM=h.parseUShort(),c.fontDirectionHint=h.parseShort(),c.indexToLocFormat=h.parseShort(),c.glyphDataFormat=h.parseShort(),c}function dp(r){let a=Math.round(new Date().getTime()/1e3)+2082844800,c=a,h=r.macStyle||0;return r.createdTimestamp&&(c=r.createdTimestamp+2082844800),new rt.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:c},{name:"modified",type:"LONGDATETIME",value:a},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:h},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],r)}var yc={parse:hp,make:dp};function fp(r,a){let c={},h=new ht.Parser(r,a);return c.version=h.parseVersion(),c.ascender=h.parseShort(),c.descender=h.parseShort(),c.lineGap=h.parseShort(),c.advanceWidthMax=h.parseUShort(),c.minLeftSideBearing=h.parseShort(),c.minRightSideBearing=h.parseShort(),c.xMaxExtent=h.parseShort(),c.caretSlopeRise=h.parseShort(),c.caretSlopeRun=h.parseShort(),c.caretOffset=h.parseShort(),h.relativeOffset+=8,c.metricDataFormat=h.parseShort(),c.numberOfHMetrics=h.parseUShort(),c}function pp(r){return new rt.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],r)}var vc={parse:fp,make:pp};function gp(r,a,c,h,f){let g,y,S=new ht.Parser(r,a);for(let T=0;T<h;T+=1){T<c&&(g=S.parseUShort(),y=S.parseShort());let C=f.get(T);C.advanceWidth=g,C.leftSideBearing=y}}function mp(r,a,c,h,f){r._hmtxTableData={};let g,y,S=new ht.Parser(a,c);for(let T=0;T<f;T+=1)T<h&&(g=S.parseUShort(),y=S.parseShort()),r._hmtxTableData[T]={advanceWidth:g,leftSideBearing:y}}function bp(r,a,c,h,f,g,y){y.lowMemory?mp(r,a,c,h,f):gp(a,c,h,f,g)}function yp(r){let a=new rt.Table("hmtx",[]);for(let c=0;c<r.length;c+=1){let h=r.get(c),f=h.advanceWidth||0,g=h.leftSideBearing||0;a.fields.push({name:"advanceWidth_"+c,type:"USHORT",value:f}),a.fields.push({name:"leftSideBearing_"+c,type:"SHORT",value:g})}return a}var xc={parse:bp,make:yp};function vp(r){let a=new rt.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:r.length}]),c="",h=12+r.length*4;for(let f=0;f<r.length;++f){let g=c.indexOf(r[f]);g<0&&(g=c.length,c+=r[f]),a.fields.push({name:"offset "+f,type:"USHORT",value:h+g}),a.fields.push({name:"length "+f,type:"USHORT",value:r[f].length})}return a.fields.push({name:"stringPool",type:"CHARARRAY",value:c}),a}function xp(r,a){let c=new ht.Parser(r,a),h=c.parseULong();V.argument(h===1,"Unsupported ltag table version."),c.skip("uLong",1);let f=c.parseULong(),g=[];for(let y=0;y<f;y++){let S="",T=a+c.parseUShort(),C=c.parseUShort();for(let E=T;E<T+C;++E)S+=String.fromCharCode(r.getInt8(E));g.push(S)}return g}var Sc={make:vp,parse:xp};function Sp(r,a){let c={},h=new ht.Parser(r,a);return c.version=h.parseVersion(),c.numGlyphs=h.parseUShort(),c.version===1&&(c.maxPoints=h.parseUShort(),c.maxContours=h.parseUShort(),c.maxCompositePoints=h.parseUShort(),c.maxCompositeContours=h.parseUShort(),c.maxZones=h.parseUShort(),c.maxTwilightPoints=h.parseUShort(),c.maxStorage=h.parseUShort(),c.maxFunctionDefs=h.parseUShort(),c.maxInstructionDefs=h.parseUShort(),c.maxStackElements=h.parseUShort(),c.maxSizeOfInstructions=h.parseUShort(),c.maxComponentElements=h.parseUShort(),c.maxComponentDepth=h.parseUShort()),c}function Ap(r){return new rt.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:r}])}var Ac={parse:Sp,make:Ap},lo=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function Tp(r){for(let a=0;a<lo.length;a+=1){let c=lo[a];if(r>=c.begin&&r<c.end)return a}return-1}function wp(r,a){let c={},h=new ht.Parser(r,a);c.version=h.parseUShort(),c.xAvgCharWidth=h.parseShort(),c.usWeightClass=h.parseUShort(),c.usWidthClass=h.parseUShort(),c.fsType=h.parseUShort(),c.ySubscriptXSize=h.parseShort(),c.ySubscriptYSize=h.parseShort(),c.ySubscriptXOffset=h.parseShort(),c.ySubscriptYOffset=h.parseShort(),c.ySuperscriptXSize=h.parseShort(),c.ySuperscriptYSize=h.parseShort(),c.ySuperscriptXOffset=h.parseShort(),c.ySuperscriptYOffset=h.parseShort(),c.yStrikeoutSize=h.parseShort(),c.yStrikeoutPosition=h.parseShort(),c.sFamilyClass=h.parseShort(),c.panose=[];for(let f=0;f<10;f++)c.panose[f]=h.parseByte();return c.ulUnicodeRange1=h.parseULong(),c.ulUnicodeRange2=h.parseULong(),c.ulUnicodeRange3=h.parseULong(),c.ulUnicodeRange4=h.parseULong(),c.achVendID=String.fromCharCode(h.parseByte(),h.parseByte(),h.parseByte(),h.parseByte()),c.fsSelection=h.parseUShort(),c.usFirstCharIndex=h.parseUShort(),c.usLastCharIndex=h.parseUShort(),c.sTypoAscender=h.parseShort(),c.sTypoDescender=h.parseShort(),c.sTypoLineGap=h.parseShort(),c.usWinAscent=h.parseUShort(),c.usWinDescent=h.parseUShort(),c.version>=1&&(c.ulCodePageRange1=h.parseULong(),c.ulCodePageRange2=h.parseULong()),c.version>=2&&(c.sxHeight=h.parseShort(),c.sCapHeight=h.parseShort(),c.usDefaultChar=h.parseUShort(),c.usBreakChar=h.parseUShort(),c.usMaxContent=h.parseUShort()),c}function Ep(r){return new rt.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],r)}var co={parse:wp,make:Ep,unicodeRanges:lo,getUnicodeRange:Tp};function Cp(r,a){let c={},h=new ht.Parser(r,a);switch(c.version=h.parseVersion(),c.italicAngle=h.parseFixed(),c.underlinePosition=h.parseShort(),c.underlineThickness=h.parseShort(),c.isFixedPitch=h.parseULong(),c.minMemType42=h.parseULong(),c.maxMemType42=h.parseULong(),c.minMemType1=h.parseULong(),c.maxMemType1=h.parseULong(),c.version){case 1:c.names=kn.slice();break;case 2:c.numberOfGlyphs=h.parseUShort(),c.glyphNameIndex=new Array(c.numberOfGlyphs);for(let f=0;f<c.numberOfGlyphs;f++)c.glyphNameIndex[f]=h.parseUShort();c.names=[];for(let f=0;f<c.numberOfGlyphs;f++)if(c.glyphNameIndex[f]>=kn.length){let g=h.parseChar();c.names.push(h.parseString(g))}break;case 2.5:c.numberOfGlyphs=h.parseUShort(),c.offset=new Array(c.numberOfGlyphs);for(let f=0;f<c.numberOfGlyphs;f++)c.offset[f]=h.parseChar();break}return c}function kp(r){let{italicAngle:a=Math.round((r.italicAngle||0)*65536),underlinePosition:c=0,underlineThickness:h=0,isFixedPitch:f=0,minMemType42:g=0,maxMemType42:y=0,minMemType1:S=0,maxMemType1:T=0}=r.tables.post||{};return new rt.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:a},{name:"underlinePosition",type:"FWORD",value:c},{name:"underlineThickness",type:"FWORD",value:h},{name:"isFixedPitch",type:"ULONG",value:f},{name:"minMemType42",type:"ULONG",value:g},{name:"maxMemType42",type:"ULONG",value:y},{name:"minMemType1",type:"ULONG",value:S},{name:"maxMemType1",type:"ULONG",value:T}])}var Tc={parse:Cp,make:kp},Be=new Array(9);Be[1]=function(){let a=this.offset+this.relativeOffset,c=this.parseUShort();if(c===1)return{substFormat:1,coverage:this.parsePointer(j.coverage),deltaGlyphId:this.parseShort()};if(c===2)return{substFormat:2,coverage:this.parsePointer(j.coverage),substitute:this.parseOffset16List()};V.assert(!1,"0x"+a.toString(16)+": lookup type 1 format must be 1 or 2.")},Be[2]=function(){let a=this.parseUShort();return V.argument(a===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:a,coverage:this.parsePointer(j.coverage),sequences:this.parseListOfLists()}},Be[3]=function(){let a=this.parseUShort();return V.argument(a===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:a,coverage:this.parsePointer(j.coverage),alternateSets:this.parseListOfLists()}},Be[4]=function(){let a=this.parseUShort();return V.argument(a===1,"GSUB ligature table identifier-format must be 1"),{substFormat:a,coverage:this.parsePointer(j.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Qn={sequenceIndex:j.uShort,lookupListIndex:j.uShort};Be[5]=function(){let a=this.offset+this.relativeOffset,c=this.parseUShort();if(c===1)return{substFormat:c,coverage:this.parsePointer(j.coverage),ruleSets:this.parseListOfLists(function(){let h=this.parseUShort(),f=this.parseUShort();return{input:this.parseUShortList(h-1),lookupRecords:this.parseRecordList(f,Qn)}})};if(c===2)return{substFormat:c,coverage:this.parsePointer(j.coverage),classDef:this.parsePointer(j.classDef),classSets:this.parseListOfLists(function(){let h=this.parseUShort(),f=this.parseUShort();return{classes:this.parseUShortList(h-1),lookupRecords:this.parseRecordList(f,Qn)}})};if(c===3){let h=this.parseUShort(),f=this.parseUShort();return{substFormat:c,coverages:this.parseList(h,j.pointer(j.coverage)),lookupRecords:this.parseRecordList(f,Qn)}}V.assert(!1,"0x"+a.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},Be[6]=function(){let a=this.offset+this.relativeOffset,c=this.parseUShort();if(c===1)return{substFormat:1,coverage:this.parsePointer(j.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Qn)}})};if(c===2)return{substFormat:2,coverage:this.parsePointer(j.coverage),backtrackClassDef:this.parsePointer(j.classDef),inputClassDef:this.parsePointer(j.classDef),lookaheadClassDef:this.parsePointer(j.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Qn)}})};if(c===3)return{substFormat:3,backtrackCoverage:this.parseList(j.pointer(j.coverage)),inputCoverage:this.parseList(j.pointer(j.coverage)),lookaheadCoverage:this.parseList(j.pointer(j.coverage)),lookupRecords:this.parseRecordList(Qn)};V.assert(!1,"0x"+a.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},Be[7]=function(){let a=this.parseUShort();V.argument(a===1,"GSUB Extension Substitution subtable identifier-format must be 1");let c=this.parseUShort(),h=new j(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:c,extension:Be[c].call(h)}},Be[8]=function(){let a=this.parseUShort();return V.argument(a===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:a,coverage:this.parsePointer(j.coverage),backtrackCoverage:this.parseList(j.pointer(j.coverage)),lookaheadCoverage:this.parseList(j.pointer(j.coverage)),substitutes:this.parseUShortList()}};function Ip(r,a){a=a||0;let c=new j(r,a),h=c.parseVersion(1);return V.argument(h===1||h===1.1,"Unsupported GSUB table version."),h===1?{version:h,scripts:c.parseScriptList(),features:c.parseFeatureList(),lookups:c.parseLookupList(Be)}:{version:h,scripts:c.parseScriptList(),features:c.parseFeatureList(),lookups:c.parseLookupList(Be),variations:c.parseFeatureVariationsList()}}var Pn=new Array(9);Pn[1]=function(a){if(a.substFormat===1)return new rt.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new rt.Coverage(a.coverage)},{name:"deltaGlyphID",type:"SHORT",value:a.deltaGlyphId}]);if(a.substFormat===2)return new rt.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new rt.Coverage(a.coverage)}].concat(rt.ushortList("substitute",a.substitute)));V.fail("Lookup type 1 substFormat must be 1 or 2.")},Pn[2]=function(a){return V.assert(a.substFormat===1,"Lookup type 2 substFormat must be 1."),new rt.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new rt.Coverage(a.coverage)}].concat(rt.tableList("seqSet",a.sequences,function(c){return new rt.Table("sequenceSetTable",rt.ushortList("sequence",c))})))},Pn[3]=function(a){return V.assert(a.substFormat===1,"Lookup type 3 substFormat must be 1."),new rt.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new rt.Coverage(a.coverage)}].concat(rt.tableList("altSet",a.alternateSets,function(c){return new rt.Table("alternateSetTable",rt.ushortList("alternate",c))})))},Pn[4]=function(a){return V.assert(a.substFormat===1,"Lookup type 4 substFormat must be 1."),new rt.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new rt.Coverage(a.coverage)}].concat(rt.tableList("ligSet",a.ligatureSets,function(c){return new rt.Table("ligatureSetTable",rt.tableList("ligature",c,function(h){return new rt.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:h.ligGlyph}].concat(rt.ushortList("component",h.components,h.components.length+1)))}))})))},Pn[5]=function(a){if(a.substFormat===1)return new rt.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:a.substFormat},{name:"coverage",type:"TABLE",value:new rt.Coverage(a.coverage)}].concat(rt.tableList("sequenceRuleSet",a.ruleSets,function(c){return c?new rt.Table("sequenceRuleSetTable",rt.tableList("sequenceRule",c,function(h){let f=rt.ushortList("seqLookup",[],h.lookupRecords.length).concat(rt.ushortList("inputSequence",h.input,h.input.length+1));[f[0],f[1]]=[f[1],f[0]];for(let g=0;g<h.lookupRecords.length;g++){let y=h.lookupRecords[g];f=f.concat({name:"sequenceIndex"+g,type:"USHORT",value:y.sequenceIndex}).concat({name:"lookupListIndex"+g,type:"USHORT",value:y.lookupListIndex})}return new rt.Table("sequenceRuleTable",f)})):new rt.Table("NULL",null)})));if(a.substFormat===2)return new rt.Table("contextualSubstitutionTable",[{name:"substFormat",type:"USHORT",value:a.substFormat},{name:"coverage",type:"TABLE",value:new rt.Coverage(a.coverage)},{name:"classDef",type:"TABLE",value:new rt.ClassDef(a.classDef)}].concat(rt.tableList("classSeqRuleSet",a.classSets,function(c){return c?new rt.Table("classSeqRuleSetTable",rt.tableList("classSeqRule",c,function(h){let f=rt.ushortList("classes",h.classes,h.classes.length+1).concat(rt.ushortList("seqLookupCount",[],h.lookupRecords.length));for(let g=0;g<h.lookupRecords.length;g++){let y=h.lookupRecords[g];f=f.concat({name:"sequenceIndex"+g,type:"USHORT",value:y.sequenceIndex}).concat({name:"lookupListIndex"+g,type:"USHORT",value:y.lookupListIndex})}return new rt.Table("classSeqRuleTable",f)})):new rt.Table("NULL",null)})));if(a.substFormat===3){let c=[{name:"substFormat",type:"USHORT",value:a.substFormat}];c.push({name:"inputGlyphCount",type:"USHORT",value:a.coverages.length}),c.push({name:"substitutionCount",type:"USHORT",value:a.lookupRecords.length});for(let f=0;f<a.coverages.length;f++){let g=a.coverages[f];c.push({name:"inputCoverage"+f,type:"TABLE",value:new rt.Coverage(g)})}for(let f=0;f<a.lookupRecords.length;f++){let g=a.lookupRecords[f];c=c.concat({name:"sequenceIndex"+f,type:"USHORT",value:g.sequenceIndex}).concat({name:"lookupListIndex"+f,type:"USHORT",value:g.lookupListIndex})}return new rt.Table("contextualSubstitutionTable",c)}V.assert(!1,"lookup type 5 format must be 1, 2 or 3.")},Pn[6]=function(a){if(a.substFormat===1)return new rt.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:a.substFormat},{name:"coverage",type:"TABLE",value:new rt.Coverage(a.coverage)}].concat(rt.tableList("chainRuleSet",a.chainRuleSets,function(h){return new rt.Table("chainRuleSetTable",rt.tableList("chainRule",h,function(f){let g=rt.ushortList("backtrackGlyph",f.backtrack,f.backtrack.length).concat(rt.ushortList("inputGlyph",f.input,f.input.length+1)).concat(rt.ushortList("lookaheadGlyph",f.lookahead,f.lookahead.length)).concat(rt.ushortList("substitution",[],f.lookupRecords.length));for(let y=0;y<f.lookupRecords.length;y++){let S=f.lookupRecords[y];g=g.concat({name:"sequenceIndex"+y,type:"USHORT",value:S.sequenceIndex}).concat({name:"lookupListIndex"+y,type:"USHORT",value:S.lookupListIndex})}return new rt.Table("chainRuleTable",g)}))})));if(a.substFormat===2)V.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(a.substFormat===3){let c=[{name:"substFormat",type:"USHORT",value:a.substFormat}];c.push({name:"backtrackGlyphCount",type:"USHORT",value:a.backtrackCoverage.length});for(let f=0;f<a.backtrackCoverage.length;f++){let g=a.backtrackCoverage[f];c.push({name:"backtrackCoverage"+f,type:"TABLE",value:new rt.Coverage(g)})}c.push({name:"inputGlyphCount",type:"USHORT",value:a.inputCoverage.length});for(let f=0;f<a.inputCoverage.length;f++){let g=a.inputCoverage[f];c.push({name:"inputCoverage"+f,type:"TABLE",value:new rt.Coverage(g)})}c.push({name:"lookaheadGlyphCount",type:"USHORT",value:a.lookaheadCoverage.length});for(let f=0;f<a.lookaheadCoverage.length;f++){let g=a.lookaheadCoverage[f];c.push({name:"lookaheadCoverage"+f,type:"TABLE",value:new rt.Coverage(g)})}c.push({name:"substitutionCount",type:"USHORT",value:a.lookupRecords.length});for(let f=0;f<a.lookupRecords.length;f++){let g=a.lookupRecords[f];c=c.concat({name:"sequenceIndex"+f,type:"USHORT",value:g.sequenceIndex}).concat({name:"lookupListIndex"+f,type:"USHORT",value:g.lookupListIndex})}return new rt.Table("chainContextTable",c)}V.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function Pp(r){return new rt.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new rt.ScriptList(r.scripts)},{name:"features",type:"TABLE",value:new rt.FeatureList(r.features)},{name:"lookups",type:"TABLE",value:new rt.LookupList(r.lookups,Pn)}])}var wc={parse:Ip,make:Pp};function Rp(r,a){let c=new ht.Parser(r,a),h=c.parseULong();V.argument(h===1,"Unsupported META table version."),c.parseULong(),c.parseULong();let f=c.parseULong(),g={};for(let y=0;y<f;y++){let S=c.parseTag(),T=c.parseULong(),C=c.parseULong();if(S==="appl"||S==="bild")continue;let E=lt.UTF8(r,a+T,C);g[S]=E}return g}function Op(r){let a=Object.keys(r).length,c="",h=16+a*12,f=new rt.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:h},{name:"numTags",type:"ULONG",value:a}]);for(let g in r){let y=c.length;c+=r[g],f.fields.push({name:"tag "+g,type:"TAG",value:g}),f.fields.push({name:"offset "+g,type:"ULONG",value:h+y}),f.fields.push({name:"length "+g,type:"ULONG",value:r[g].length})}return f.fields.push({name:"stringPool",type:"CHARARRAY",value:c}),f}var Ec={parse:Rp,make:Op};function Mp(r,a){let c=new j(r,a),h=c.parseUShort();h!==0&&console.warn("Only COLRv0 is currently fully supported. A subset of color glyphs might be available in this font if provided in the v0 format.");let f=c.parseUShort(),g=c.parseOffset32(),y=c.parseOffset32(),S=c.parseUShort();c.relativeOffset=g;let T=c.parseRecordList(f,{glyphID:j.uShort,firstLayerIndex:j.uShort,numLayers:j.uShort});c.relativeOffset=y;let C=c.parseRecordList(S,{glyphID:j.uShort,paletteIndex:j.uShort});return{version:h,baseGlyphRecords:T,layerRecords:C}}function Lp({version:r=0,baseGlyphRecords:a=[],layerRecords:c=[]}){V.argument(r===0,"Only COLRv0 supported.");let h=14,f=h+a.length*6;return new rt.Table("COLR",[{name:"version",type:"USHORT",value:r},{name:"numBaseGlyphRecords",type:"USHORT",value:a.length},{name:"baseGlyphRecordsOffset",type:"ULONG",value:h},{name:"layerRecordsOffset",type:"ULONG",value:f},{name:"numLayerRecords",type:"USHORT",value:c.length},...a.map((g,y)=>[{name:"glyphID_"+y,type:"USHORT",value:g.glyphID},{name:"firstLayerIndex_"+y,type:"USHORT",value:g.firstLayerIndex},{name:"numLayers_"+y,type:"USHORT",value:g.numLayers}]).flat(),...c.map((g,y)=>[{name:"LayerGlyphID_"+y,type:"USHORT",value:g.glyphID},{name:"paletteIndex_"+y,type:"USHORT",value:g.paletteIndex}]).flat()])}var Cc={parse:Mp,make:Lp};function Fp(r,a){return[{name:"tag_"+r,type:"TAG",value:a.tag},{name:"minValue_"+r,type:"FIXED",value:a.minValue<<16},{name:"defaultValue_"+r,type:"FIXED",value:a.defaultValue<<16},{name:"maxValue_"+r,type:"FIXED",value:a.maxValue<<16},{name:"flags_"+r,type:"USHORT",value:0},{name:"nameID_"+r,type:"USHORT",value:a.axisNameID}]}function Dp(r,a,c){let h={},f=new ht.Parser(r,a);h.tag=f.parseTag(),h.minValue=f.parseFixed(),h.defaultValue=f.parseFixed(),h.maxValue=f.parseFixed(),f.skip("uShort",1);let g=f.parseUShort();return h.axisNameID=g,h.name=ds(c,g),h}function _p(r,a,c,h={}){let f=[{name:"nameID_"+r,type:"USHORT",value:a.subfamilyNameID},{name:"flags_"+r,type:"USHORT",value:0}];for(let g=0;g<c.length;++g){let y=c[g].tag;f.push({name:"axis_"+r+" "+y,type:"FIXED",value:a.coordinates[y]<<16})}return h&&h.postScriptNameID&&f.push({name:"postScriptNameID_",type:"USHORT",value:a.postScriptNameID!==void 0?a.postScriptNameID:65535}),f}function Np(r,a,c,h,f){let g={},y=new ht.Parser(r,a),S=y.parseUShort();g.subfamilyNameID=S,g.name=ds(h,S,[2,17]),y.skip("uShort",1),g.coordinates={};for(let C=0;C<c.length;++C)g.coordinates[c[C].tag]=y.parseFixed();if(y.relativeOffset===f)return g.postScriptNameID=void 0,g.postScriptName=void 0,g;let T=y.parseUShort();return g.postScriptNameID=T==65535?void 0:T,g.postScriptName=g.postScriptNameID!==void 0?ds(h,T,[6]):"",g}function Up(r,a){let c=new rt.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:r.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:r.instances.length},{name:"instanceSize",type:"USHORT",value:4+r.axes.length*4}]);c.offsetToData=c.sizeOf();for(let f=0;f<r.axes.length;f++)c.fields=c.fields.concat(Fp(f,r.axes[f],a));let h={};for(let f=0;f<r.instances.length;f++)if(r.instances[f].postScriptNameID!==void 0){c.instanceSize+=2,h.postScriptNameID=!0;break}for(let f=0;f<r.instances.length;f++)c.fields=c.fields.concat(_p(f,r.instances[f],r.axes,h));return c}function Bp(r,a,c){let h=new ht.Parser(r,a),f=h.parseULong();V.argument(f===65536,"Unsupported fvar table version.");let g=h.parseOffset16();h.skip("uShort",1);let y=h.parseUShort(),S=h.parseUShort(),T=h.parseUShort(),C=h.parseUShort(),E=[];for(let F=0;F<y;F++)E.push(Dp(r,a+g+F*S,c));let O=[],R=a+g+y*S;for(let F=0;F<T;F++)O.push(Np(r,R+F*C,E,c,C));return{axes:E,instances:O}}var kc={make:Up,parse:Bp},Gp={tag:j.tag,nameID:j.uShort,ordering:j.uShort},yr=new Array(5);yr[1]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed()}},yr[2]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),nominalValue:this.parseFixed(),rangeMinValue:this.parseFixed(),rangeMaxValue:this.parseFixed()}},yr[3]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed(),linkedValue:this.parseFixed()}},yr[4]=function(){let a=this.parseUShort();return{flags:this.parseUShort(),valueNameID:this.parseUShort(),axisValues:this.parseList(a,function(){return{axisIndex:this.parseUShort(),value:this.parseFixed()}})}};function Hp(){let r=this.parseUShort(),a=yr[r],c={format:r};return a===void 0?(console.warn(`Unknown axis value table format ${r}`),c):Object.assign(c,this.parseStruct(a.bind(this)))}function jp(r,a,c){a||(a=0);let h=new ht.Parser(r,a),f=h.parseUShort(),g=h.parseUShort();f!==1&&console.warn(`Unsupported STAT table version ${f}.${g}`);let y=[f,g],S=h.parseUShort(),T=h.parseUShort(),C=h.parseOffset32(),E=h.parseUShort(),O=h.parseOffset32(),R=f>1||g>0?h.parseUShort():void 0;c!==void 0&&V.argument(T>=c.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),E>0&&V.argument(T>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");let F=[];for(let Y=0;Y<T;Y++)h.offset=a+C,h.relativeOffset=Y*S,F.push(h.parseStruct(Gp));h.offset=a,h.relativeOffset=O;let L=h.parseUShortList(E),B=[];for(let Y=0;Y<E;Y++)h.offset=a+O,h.relativeOffset=L[Y],B.push(Hp.apply(h));return{version:y,axes:F,values:B,elidedFallbackNameID:R}}var vr=new Array(5);vr[1]=function(a,c){return[{name:`format${a}`,type:"USHORT",value:1},{name:`axisIndex${a}`,type:"USHORT",value:c.axisIndex},{name:`flags${a}`,type:"USHORT",value:c.flags},{name:`valueNameID${a}`,type:"USHORT",value:c.valueNameID},{name:`value${a}`,type:"FLOAT",value:c.value}]},vr[2]=function(a,c){return[{name:`format${a}`,type:"USHORT",value:2},{name:`axisIndex${a}`,type:"USHORT",value:c.axisIndex},{name:`flags${a}`,type:"USHORT",value:c.flags},{name:`valueNameID${a}`,type:"USHORT",value:c.valueNameID},{name:`nominalValue${a}`,type:"FLOAT",value:c.nominalValue},{name:`rangeMinValue${a}`,type:"FLOAT",value:c.rangeMinValue},{name:`rangeMaxValue${a}`,type:"FLOAT",value:c.rangeMaxValue}]},vr[3]=function(a,c){return[{name:`format${a}`,type:"USHORT",value:3},{name:`axisIndex${a}`,type:"USHORT",value:c.axisIndex},{name:`flags${a}`,type:"USHORT",value:c.flags},{name:`valueNameID${a}`,type:"USHORT",value:c.valueNameID},{name:`value${a}`,type:"FLOAT",value:c.value},{name:`linkedValue${a}`,type:"FLOAT",value:c.linkedValue}]},vr[4]=function(a,c){let h=[{name:`format${a}`,type:"USHORT",value:4},{name:`axisCount${a}`,type:"USHORT",value:c.axisValues.length},{name:`flags${a}`,type:"USHORT",value:c.flags},{name:`valueNameID${a}`,type:"USHORT",value:c.valueNameID}];for(let f=0;f<c.axisValues.length;f++)h=h.concat([{name:`format${a}axisIndex${f}`,type:"USHORT",value:c.axisValues[f].axisIndex},{name:`format${a}value${f}`,type:"FLOAT",value:c.axisValues[f].value}]);return h};function Vp(r,a){return new rt.Record("axisRecord_"+r,[{name:"axisTag_"+r,type:"TAG",value:a.tag},{name:"axisNameID_"+r,type:"USHORT",value:a.nameID},{name:"axisOrdering_"+r,type:"USHORT",value:a.ordering}])}function Wp(r,a){let c=a.format,h=vr[c];V.argument(h!==void 0,`Unknown axis value table format ${c}`);let f=h(r,a);return new rt.Table("axisValueTable_"+r,f)}function $p(r){let a=new rt.Table("STAT",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:2},{name:"designAxisSize",type:"USHORT",value:8},{name:"designAxisCount",type:"USHORT",value:r.axes.length},{name:"designAxesOffset",type:"ULONG",value:0},{name:"axisValueCount",type:"USHORT",value:r.values.length},{name:"offsetToAxisValueOffsets",type:"ULONG",value:0},{name:"elidedFallbackNameID",type:"USHORT",value:r.elidedFallbackNameID}]);a.designAxesOffset=a.offsetToAxisValueOffsets=a.sizeOf();for(let g=0;g<r.axes.length;g++){let y=Vp(g,r.axes[g]);a.offsetToAxisValueOffsets+=y.sizeOf(),a.fields=a.fields.concat(y.fields)}let c=[],h=[],f=r.values.length*2;for(let g=0;g<r.values.length;g++){let y=Wp(g,r.values[g]);c.push({name:"offset_"+g,type:"USHORT",value:f}),f+=y.sizeOf(),h=h.concat(y.fields)}return a.fields=a.fields.concat(c),a.fields=a.fields.concat(h),a}var Ic={make:$p,parse:jp};function zp(r,a){return new rt.Record("axisValueMap_"+r,[{name:"fromCoordinate_"+r,type:"F2DOT14",value:a.fromCoordinate},{name:"toCoordinate_"+r,type:"F2DOT14",value:a.toCoordinate}])}function Xp(r,a){let c=new rt.Record("segmentMap_"+r,[{name:"positionMapCount_"+r,type:"USHORT",value:a.axisValueMaps.length}]),h=[];for(let f=0;f<a.axisValueMaps.length;f++){let g=zp(`${r}_${f}`,a.axisValueMaps[f]);h=h.concat(g.fields)}return c.fields=c.fields.concat(h),c}function Yp(r,a){V.argument(r.axisSegmentMaps.length===a.axes.length,"avar axis count must correspond to fvar axis count");let c=new rt.Table("avar",[{name:"majorVersion",type:"USHORT",value:1},{name:"minorVersion",type:"USHORT",value:0},{name:"reserved",type:"USHORT",value:0},{name:"axisCount",type:"USHORT",value:r.axisSegmentMaps.length}]);for(let h=0;h<r.axisSegmentMaps.length;h++){let f=Xp(h,r.axisSegmentMaps[h]);c.fields=c.fields.concat(f.fields)}return c}function Kp(r,a,c){a||(a=0);let h=new j(r,a),f=h.parseUShort(),g=h.parseUShort();f!==1&&console.warn(`Unsupported avar table version ${f}.${g}`),h.skip("uShort",1);let y=h.parseUShort();V.argument(y===c.axes.length,"avar axis count must correspond to fvar axis count");let S=[];for(let T=0;T<y;T++){let C=[],E=h.parseUShort();for(let O=0;O<E;O++){let R=h.parseF2Dot14(),F=h.parseF2Dot14();C.push({fromCoordinate:R,toCoordinate:F})}S.push({axisValueMaps:C})}return{version:[f,g],axisSegmentMaps:S}}var Pc={make:Yp,parse:Kp};function Zp(r,a,c,h){let f=new ht.Parser(r,a),g=f.parseTupleVariationStore(f.relativeOffset,c.axes.length,"cvar",h),y=f.parseUShort(),S=f.parseUShort();return y!==1&&console.warn(`Unsupported cvar table version ${y}.${S}`),{version:[y,S],...g}}function Qp(){console.warn("Writing of cvar tables is not yet supported.")}var Rc={make:Qp,parse:Zp};function Jp(r,a,c,h){let f=new ht.Parser(r,a),g=f.parseUShort(),y=f.parseUShort();g!==1&&console.warn(`Unsupported gvar table version ${g}.${y}`);let S=f.parseUShort();S!==c.axes.length&&console.warn(`axisCount ${S} in gvar table does not match the number of axes ${c.axes.length} in the fvar table!`);let T=f.parseUShort(),C=f.parsePointer32(function(){return this.parseTupleRecords(T,S)}),E=f.parseTupleVariationStoreList(S,"gvar",h);return{version:[g,y],sharedTuples:C,glyphVariations:E}}function qp(){console.warn("Writing of gvar tables is not yet supported.")}var Oc={make:qp,parse:Jp};function tg(r,a){let c={},h=new ht.Parser(r,a);c.version=h.parseUShort(),V.argument(c.version<=1,"Unsupported gasp table version."),c.numRanges=h.parseUShort(),c.gaspRanges=[];for(let f=0;f<c.numRanges;f++)c.gaspRanges[f]={rangeMaxPPEM:h.parseUShort(),rangeGaspBehavior:h.parseUShort()};return c}function eg(r){let a=new rt.Table("gasp",[{name:"version",type:"USHORT",value:1},{name:"numRanges",type:"USHORT",value:r.numRanges}]);for(let c in r.gaspRanges)a.fields.push({name:"rangeMaxPPEM",type:"USHORT",value:r.gaspRanges[c].rangeMaxPPEM}),a.fields.push({name:"rangeGaspBehavior",type:"USHORT",value:r.gaspRanges[c].rangeGaspBehavior});return a}var Mc={parse:tg,make:eg};function ng(r,a){let c=new Map,h=r.buffer,f=new j(r,a);if(f.parseUShort()!==0)return c;f.relativeOffset=f.parseOffset32();let y=r.byteOffset+a+f.relativeOffset,S=f.parseUShort(),T=new Map;for(let C=0;C<S;C++){let E=f.parseUShort(),O=f.parseUShort(),R=y+f.parseOffset32(),F=f.parseULong(),L=T.get(R);L===void 0&&(L=new Uint8Array(h,R,F),T.set(R,L));for(let B=E;B<=O;B++)c.set(B,L)}return c}function rg(r){let a=Array.from(r.keys()).sort(),c=[],h=[],f=new Map,g=0,y={endGlyphID:null};for(let R=0,F=a.length;R<F;R++){let L=a[R],B=r.get(L),Y=f.get(B);Y===void 0&&(Y=g,h.push(B),f.set(B,Y),g+=B.byteLength),L-1===y.endGlyphID&&Y===y.svgDocOffset?y.endGlyphID=L:(y={startGlyphID:L,endGlyphID:L,svgDocOffset:Y,svgDocLength:B.byteLength},c.push(y))}let S=c.length,T=h.length,C=2+S*12,E=new Array(4+S*4+T),O=0;E[O++]={name:"version",type:"USHORT",value:0},E[O++]={name:"svgDocumentListOffset",type:"ULONG",value:10},E[O++]={name:"reserved",type:"ULONG",value:0},E[O++]={name:"numEntries",type:"USHORT",value:S};for(let R=0;R<S;R++){let F="documentRecord_"+R,{startGlyphID:L,endGlyphID:B,svgDocOffset:Y,svgDocLength:yt}=c[R];E[O++]={name:F+"_startGlyphID",type:"USHORT",value:L},E[O++]={name:F+"_endGlyphID",type:"USHORT",value:B},E[O++]={name:F+"_svgDocOffset",type:"ULONG",value:C+Y},E[O++]={name:F+"_svgDocLength",type:"ULONG",value:yt}}for(let R=0;R<T;R++)E[O++]={name:"svgDoc_"+R,type:"LITERAL",value:h[R]};return new rt.Table("SVG ",E)}var Lc={make:rg,parse:ng};function Fc(r){return Math.log(r)/Math.log(2)|0}function uo(r){for(;r.length%4!==0;)r.push(0);let a=0;for(let c=0;c<r.length;c+=4)a+=(r[c]<<24)+(r[c+1]<<16)+(r[c+2]<<8)+r[c+3];return a%=Math.pow(2,32),a}function Dc(r,a,c,h){return new rt.Record("Table Record",[{name:"tag",type:"TAG",value:r!==void 0?r:""},{name:"checkSum",type:"ULONG",value:a!==void 0?a:0},{name:"offset",type:"ULONG",value:c!==void 0?c:0},{name:"length",type:"ULONG",value:h!==void 0?h:0}])}function _c(r){let a=new rt.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);a.tables=r,a.numTables=r.length;let c=Math.pow(2,Fc(a.numTables));a.searchRange=16*c,a.entrySelector=Fc(c),a.rangeShift=a.numTables*16-a.searchRange;let h=[],f=[],g=a.sizeOf()+Dc().sizeOf()*a.numTables;for(;g%4!==0;)g+=1,f.push({name:"padding",type:"BYTE",value:0});for(let y=0;y<r.length;y+=1){let S=r[y];V.argument(S.tableName.length===4,"Table name"+S.tableName+" is invalid.");let T=S.sizeOf(),C=Dc(S.tableName,uo(S.encode()),g,T);for(h.push({name:C.tag+" Table Record",type:"RECORD",value:C}),f.push({name:S.tableName+" table",type:"RECORD",value:S}),g+=T,V.argument(!isNaN(g),"Something went wrong calculating the offset.");g%4!==0;)g+=1,f.push({name:"padding",type:"BYTE",value:0})}return h.sort(function(y,S){return y.value.tag>S.value.tag?1:-1}),a.fields=a.fields.concat(h),a.fields=a.fields.concat(f),a}function Nc(r,a,c){for(let h=0;h<a.length;h+=1){let f=r.charToGlyphIndex(a[h]);if(f>0)return r.glyphs.get(f).getMetrics()}return c}function sg(r){let a=0;for(let c=0;c<r.length;c+=1)a+=r[c];return a/r.length}function ig(r){let a=[],c=[],h=[],f=[],g=[],y=[],S=[],T,C=0,E=0,O=0,R=0,F=0;for(let Wt=0;Wt<r.glyphs.length;Wt+=1){let ve=r.glyphs.get(Wt),Me=ve.unicode|0;if(isNaN(ve.advanceWidth))throw new Error("Glyph "+ve.name+" ("+Wt+"): advanceWidth is not a number.");(T>Me||T===void 0)&&Me>0&&(T=Me),C<Me&&(C=Me);let Ve=co.getUnicodeRange(Me);if(Ve<32)E|=1<<Ve;else if(Ve<64)O|=1<<Ve-32;else if(Ve<96)R|=1<<Ve-64;else if(Ve<123)F|=1<<Ve-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(ve.name===".notdef")continue;let rn=ve.getMetrics();a.push(rn.xMin),c.push(rn.yMin),h.push(rn.xMax),f.push(rn.yMax),y.push(rn.leftSideBearing),S.push(rn.rightSideBearing),g.push(ve.advanceWidth)}let L={xMin:Math.min.apply(null,a),yMin:Math.min.apply(null,c),xMax:Math.max.apply(null,h),yMax:Math.max.apply(null,f),advanceWidthMax:Math.max.apply(null,g),advanceWidthAvg:sg(g),minLeftSideBearing:Math.min.apply(null,y),maxLeftSideBearing:Math.max.apply(null,y),minRightSideBearing:Math.min.apply(null,S)};L.ascender=r.ascender,L.descender=r.descender;let B=0;r.weightClass>=600&&(B|=r.macStyleValues.BOLD),r.italicAngle<0&&(B|=r.macStyleValues.ITALIC);let Y=yc.make({flags:3,unitsPerEm:r.unitsPerEm,xMin:L.xMin,yMin:L.yMin,xMax:L.xMax,yMax:L.yMax,lowestRecPPEM:3,macStyle:B,createdTimestamp:r.createdTimestamp}),yt=vc.make({ascender:L.ascender,descender:L.descender,advanceWidthMax:L.advanceWidthMax,minLeftSideBearing:L.minLeftSideBearing,minRightSideBearing:L.minRightSideBearing,xMaxExtent:L.maxLeftSideBearing+(L.xMax-L.xMin),numberOfHMetrics:r.glyphs.length}),mt=Ac.make(r.glyphs.length),At=co.make(Object.assign({xAvgCharWidth:Math.round(L.advanceWidthAvg),usFirstCharIndex:T,usLastCharIndex:C,ulUnicodeRange1:E,ulUnicodeRange2:O,ulUnicodeRange3:R,ulUnicodeRange4:F,sTypoAscender:L.ascender,sTypoDescender:L.descender,sTypoLineGap:0,usWinAscent:L.yMax,usWinDescent:Math.abs(L.yMin),ulCodePageRange1:1,sxHeight:Nc(r,"xyvw",{yMax:Math.round(L.ascender/2)}).yMax,sCapHeight:Nc(r,"HIKLEFJMNTZBDPRAGOQSUVWXY",L).yMax,usDefaultChar:r.hasChar(" ")?32:0,usBreakChar:r.hasChar(" ")?32:0},r.tables.os2)),Rt=xc.make(r.glyphs),Nt=ql.make(r.glyphs),Gt=r.getEnglishName("fontFamily"),Ht=r.getEnglishName("fontSubfamily"),qt=Gt+" "+Ht,He=r.getEnglishName("postScriptName");He||(He=Gt.replace(/\s/g,"")+"-"+Ht);let Ot={};for(let Wt in r.names)Ot[Wt]=r.names[Wt];Ot.unicode=Ot.unicode||{},Ot.macintosh=Ot.macintosh||{},Ot.windows=Ot.windows||{};let Ee=r.names.unicode||{},fe=r.names.macintosh||{},vt=r.names.windows||{};for(let Wt in Ot){if(Ot[Wt]=Ot[Wt]||{},!Ot[Wt].uniqueID){let ve=r.getEnglishName("manufacturer")||"";Ot[Wt].uniqueID={en:`${ve}: ${qt}`}}Ot[Wt].postScriptName||(Ot[Wt].postScriptName={en:He})}Ot.unicode.preferredFamily||(Ot.unicode.preferredFamily=Ee.fontFamily||fe.fontFamily||vt.fontFamily),Ot.macintosh.preferredFamily||(Ot.macintosh.preferredFamily=fe.fontFamily||Ee.fontFamily||vt.fontFamily),Ot.windows.preferredFamily||(Ot.windows.preferredFamily=vt.fontFamily||Ee.fontFamily||fe.fontFamily),Ot.unicode.preferredSubfamily||(Ot.unicode.preferredSubfamily=Ee.fontSubfamily||fe.fontSubfamily||vt.fontSubfamily),Ot.macintosh.preferredSubfamily||(Ot.macintosh.preferredSubfamily=fe.fontSubfamily||Ee.fontSubfamily||vt.fontSubfamily),Ot.windows.preferredSubfamily||(Ot.windows.preferredSubfamily=vt.fontSubfamily||Ee.fontSubfamily||fe.fontSubfamily);let ft=[],gt=Jl.make(Ot,ft),ae=ft.length>0?Sc.make(ft):void 0,gn=Tc.make(r),Cs=ao.make(r.glyphs,{version:r.getEnglishName("version"),fullName:qt,familyName:Gt,weightName:Ht,postScriptName:He,unitsPerEm:r.unitsPerEm,fontBBox:[0,L.yMin,L.ascender,L.advanceWidthMax],topDict:r.tables.cff&&r.tables.cff.topDict||{}}),Mn=r.metas&&Object.keys(r.metas).length>0?Ec.make(r.metas):void 0,je=[Y,yt,mt,At,gt,Nt,gn,Cs,Rt];ae&&je.push(ae);let pe={gsub:wc,cpal:ic,colr:Cc,stat:Ic,avar:Pc,cvar:Rc,fvar:kc,gvar:Oc,gasp:Mc,svg:Lc},Oe={avar:[r.tables.fvar],fvar:[r.names]};for(let Wt in pe){let ve=r.tables[Wt];if(ve){let Me=pe[Wt].make.call(r,ve,...Oe[Wt]||[]);Me&&je.push(Me)}}Mn&&je.push(Mn);let le=_c(je),Ce=le.encode(),ge=uo(Ce),me=le.fields,Qt=!1;for(let Wt=0;Wt<me.length;Wt+=1)if(me[Wt].name==="head table"){me[Wt].value.checkSumAdjustment=2981146554-ge,Qt=!0;break}if(!Qt)throw new Error("Could not find head table with checkSum to adjust.");return le}var og={make:_c,fontToTable:ig,computeCheckSum:uo};function ho(r,a){let c=0,h=r.length-1;for(;c<=h;){let f=c+h>>>1,g=r[f].tag;if(g===a)return f;g<a?c=f+1:h=f-1}return-c-1}function Uc(r,a){let c=0,h=r.length-1;for(;c<=h;){let f=c+h>>>1,g=r[f];if(g===a)return f;g<a?c=f+1:h=f-1}return-c-1}function Bc(r,a){let c,h=0,f=r.length-1;for(;h<=f;){let g=h+f>>>1;c=r[g];let y=c.start;if(y===a)return c;y<a?h=g+1:f=g-1}if(h>0)return c=r[h-1],a>c.end?0:c}function Gc(r,a){this.font=r,this.tableName=a}Gc.prototype={searchTag:ho,binSearch:Uc,getTable:function(r){let a=this.font.tables[this.tableName];return!a&&r&&(a=this.font.tables[this.tableName]=this.createDefaultTable()),a},getScriptNames:function(){let r=this.getTable();return r?r.scripts.map(function(a){return a.tag}):[]},getDefaultScriptName:function(){let r=this.getTable();if(!r)return;let a=!1;for(let c=0;c<r.scripts.length;c++){let h=r.scripts[c].tag;if(h==="DFLT")return h;h==="latn"&&(a=!0)}if(a)return"latn"},getScriptTable:function(r,a){let c=this.getTable(a);if(c){r=r||"DFLT";let h=c.scripts,f=ho(c.scripts,r);if(f>=0)return h[f].script;if(a){let g={tag:r,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return h.splice(-1-f,0,g),g.script}}},getLangSysTable:function(r,a,c){let h=this.getScriptTable(r,c);if(h){if(!a||a==="dflt"||a==="DFLT")return h.defaultLangSys;let f=ho(h.langSysRecords,a);if(f>=0)return h.langSysRecords[f].langSys;if(c){let g={tag:a,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return h.langSysRecords.splice(-1-f,0,g),g.langSys}}},getFeatureTable:function(r,a,c,h){let f=this.getLangSysTable(r,a,h);if(f){let g,y=f.featureIndexes,S=this.font.tables[this.tableName].features;for(let T=0;T<y.length;T++)if(g=S[y[T]],g.tag===c)return g.feature;if(h){let T=S.length;return V.assert(T===0||c>=S[T-1].tag,"Features must be added in alphabetical order."),g={tag:c,feature:{params:0,lookupListIndexes:[]}},S.push(g),y.push(T),g.feature}}},getLookupTables:function(r,a,c,h,f){let g=this.getFeatureTable(r,a,c,f),y=[];if(g){let S,T=g.lookupListIndexes,C=this.font.tables[this.tableName].lookups;for(let E=0;E<T.length;E++)S=C[T[E]],S.lookupType===h&&y.push(S);if(y.length===0&&f){S={lookupType:h,lookupFlag:0,subtables:[],markFilteringSet:void 0};let E=C.length;return C.push(S),T.push(E),[S]}}return y},getGlyphClass:function(r,a){switch(r.format){case 1:return r.startGlyph<=a&&a<r.startGlyph+r.classes.length?r.classes[a-r.startGlyph]:0;case 2:{let c=Bc(r.ranges,a);return c?c.classId:0}}},getCoverageIndex:function(r,a){switch(r.format){case 1:{let c=Uc(r.glyphs,a);return c>=0?c:-1}case 2:{let c=Bc(r.ranges,a);return c?c.index+a-c.start:-1}}},expandCoverage:function(r){if(r.format===1)return r.glyphs;{let a=[],c=r.ranges;for(let h=0;h<c.length;h++){let f=c[h],g=f.start,y=f.end;for(let S=g;S<=y;S++)a.push(S)}return a}}};var bs=Gc;function xr(r){bs.call(this,r,"gpos")}xr.prototype=bs.prototype,xr.prototype.init=function(){let r=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(r)},xr.prototype.getKerningValue=function(r,a,c){for(let h=0;h<r.length;h++){let f=r[h].subtables;for(let g=0;g<f.length;g++){let y=f[g],S=this.getCoverageIndex(y.coverage,a);if(!(S<0))switch(y.posFormat){case 1:{let T=y.pairSets[S];for(let C=0;C<T.length;C++){let E=T[C];if(E.secondGlyph===c)return E.value1&&E.value1.xAdvance||0}break}case 2:{let T=this.getGlyphClass(y.classDef1,a),C=this.getGlyphClass(y.classDef2,c),E=y.classRecords[T][C];return E.value1&&E.value1.xAdvance||0}}}}return 0},xr.prototype.getKerningTables=function(r,a){if(this.font.tables.gpos)return this.getLookupTables(r,a,"kern",2)};var ag=xr;function lg(r,a){let c=r.length;if(c!==a.length)return!1;for(let h=0;h<c;h++)if(r[h]!==a[h])return!1;return!0}function cg(r,a,c){let h=0,f=r.length-1,g=null;for(;h<=f;){let y=Math.floor((h+f)/2),S=r[y],T=S[a];if(T<c)h=y+1;else if(T>c)f=y-1;else{g=S;break}}return g}function ug(r,a,c){let h=0,f=r.length-1;for(;h<=f;){let g=Math.floor((h+f)/2),y=r[g];if(y[a]<c)h=g+1;else if(y[a]>c)f=g-1;else return g}return-1}function hg(r,a,c){let h=0,f=r.length,g=(y,S)=>y[a]-S[a];for(;h<f;){let y=h+f>>>1;g(r[y],c)<0?h=y+1:f=y}return r.splice(h,0,c),h}function Hc(r){return r[0]===31&&r[1]===139&&r[2]===8}function dg(r){let a=new DataView(r.buffer,r.byteOffset,r.byteLength),c=10,h=r.byteLength-8,f=a.getInt8(3);if(f&4&&(c+=2+a.getUint16(c,!0)),f&8)for(;c<h&&r[c++]!==0;);if(f&16)for(;c<h&&r[c++]!==0;);if(f&2&&(c+=2),c>=h)throw new Error("Can't find compressed blocks");let g=a.getUint32(a.byteLength-4,!0);return ct(r.subarray(c,h),new Uint8Array(g))}function jc(r){return{x:r.x,y:r.y,onCurve:r.onCurve,lastPointOfContour:r.lastPointOfContour}}function fg(r){return{glyphIndex:r.glyphIndex,xScale:r.xScale,scale01:r.scale01,scale10:r.scale10,yScale:r.yScale,dx:r.dx,dy:r.dy}}function Te(r){bs.call(this,r,"gsub")}function fo(r,a,c){let h=r.subtables;for(let f=0;f<h.length;f++){let g=h[f];if(g.substFormat===a)return g}if(c)return h.push(c),c}Te.prototype=bs.prototype,Te.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},Te.prototype.getSingle=function(r,a,c){let h=[],f=this.getLookupTables(a,c,r,1);for(let g=0;g<f.length;g++){let y=f[g].subtables;for(let S=0;S<y.length;S++){let T=y[S],C=this.expandCoverage(T.coverage),E;if(T.substFormat===1){let O=T.deltaGlyphId;for(E=0;E<C.length;E++){let R=C[E];h.push({sub:R,by:R+O})}}else{let O=T.substitute;for(E=0;E<C.length;E++)h.push({sub:C[E],by:O[E]})}}}return h},Te.prototype.getMultiple=function(r,a,c){let h=[],f=this.getLookupTables(a,c,r,2);for(let g=0;g<f.length;g++){let y=f[g].subtables;for(let S=0;S<y.length;S++){let T=y[S],C=this.expandCoverage(T.coverage),E;for(E=0;E<C.length;E++){let O=C[E],R=T.sequences[E];h.push({sub:O,by:R})}}}return h},Te.prototype.getAlternates=function(r,a,c){let h=[],f=this.getLookupTables(a,c,r,3);for(let g=0;g<f.length;g++){let y=f[g].subtables;for(let S=0;S<y.length;S++){let T=y[S],C=this.expandCoverage(T.coverage),E=T.alternateSets;for(let O=0;O<C.length;O++)h.push({sub:C[O],by:E[O]})}}return h},Te.prototype.getLigatures=function(r,a,c){let h=[],f=this.getLookupTables(a,c,r,4);for(let g=0;g<f.length;g++){let y=f[g].subtables;for(let S=0;S<y.length;S++){let T=y[S],C=this.expandCoverage(T.coverage),E=T.ligatureSets;for(let O=0;O<C.length;O++){let R=C[O],F=E[O];for(let L=0;L<F.length;L++){let B=F[L];h.push({sub:[R].concat(B.components),by:B.ligGlyph})}}}}return h},Te.prototype.addSingle=function(r,a,c,h){let f=this.getLookupTables(c,h,r,1,!0)[0],g=fo(f,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});V.assert(g.coverage.format===1,"Single: unable to modify coverage table format "+g.coverage.format);let y=a.sub,S=this.binSearch(g.coverage.glyphs,y);S<0&&(S=-1-S,g.coverage.glyphs.splice(S,0,y),g.substitute.splice(S,0,0)),g.substitute[S]=a.by},Te.prototype.addMultiple=function(r,a,c,h){V.assert(a.by instanceof Array&&a.by.length>1,'Multiple: "by" must be an array of two or more ids');let f=this.getLookupTables(c,h,r,2,!0)[0],g=fo(f,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});V.assert(g.coverage.format===1,"Multiple: unable to modify coverage table format "+g.coverage.format);let y=a.sub,S=this.binSearch(g.coverage.glyphs,y);S<0&&(S=-1-S,g.coverage.glyphs.splice(S,0,y),g.sequences.splice(S,0,0)),g.sequences[S]=a.by},Te.prototype.addAlternate=function(r,a,c,h){let f=this.getLookupTables(c,h,r,3,!0)[0],g=fo(f,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});V.assert(g.coverage.format===1,"Alternate: unable to modify coverage table format "+g.coverage.format);let y=a.sub,S=this.binSearch(g.coverage.glyphs,y);S<0&&(S=-1-S,g.coverage.glyphs.splice(S,0,y),g.alternateSets.splice(S,0,0)),g.alternateSets[S]=a.by},Te.prototype.addLigature=function(r,a,c,h){let f=this.getLookupTables(c,h,r,4,!0)[0],g=f.subtables[0];g||(g={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},f.subtables[0]=g),V.assert(g.coverage.format===1,"Ligature: unable to modify coverage table format "+g.coverage.format);let y=a.sub[0],S=a.sub.slice(1),T={ligGlyph:a.by,components:S},C=this.binSearch(g.coverage.glyphs,y);if(C>=0){let E=g.ligatureSets[C];for(let O=0;O<E.length;O++)if(lg(E[O].components,S))return;E.push(T)}else C=-1-C,g.coverage.glyphs.splice(C,0,y),g.ligatureSets.splice(C,0,[T])},Te.prototype.getFeature=function(r,a,c){if(/ss\d\d/.test(r))return this.getSingle(r,a,c);switch(r){case"aalt":case"salt":return this.getSingle(r,a,c).concat(this.getAlternates(r,a,c));case"dlig":case"liga":case"rlig":return this.getLigatures(r,a,c);case"ccmp":return this.getMultiple(r,a,c).concat(this.getLigatures(r,a,c));case"stch":return this.getMultiple(r,a,c)}},Te.prototype.add=function(r,a,c,h){if(/ss\d\d/.test(r))return this.addSingle(r,a,c,h);switch(r){case"aalt":case"salt":return typeof a.by=="number"?this.addSingle(r,a,c,h):this.addAlternate(r,a,c,h);case"dlig":case"liga":case"rlig":return this.addLigature(r,a,c,h);case"ccmp":return a.by instanceof Array?this.addMultiple(r,a,c,h):this.addLigature(r,a,c,h)}};var pg=Te,Vc=class{constructor(r){this.defaultValue=255,this.font=r}cpal(){return this.font.tables&&this.font.tables.cpal?this.font.tables.cpal:!1}getAll(r){let a=[],c=this.cpal();if(!c)return a;for(let h=0;h<c.colorRecordIndices.length;h++){let f=c.colorRecordIndices[h],g=[];for(let y=f;y<f+c.numPaletteEntries;y++)g.push(Yn(c.colorRecords[y],r||"hexa"));a.push(g)}return a}toCPALcolor(r){return Array.isArray(r)?r.map(a=>ps(a,"raw")):ps(r,"raw")}fillPalette(r,a=[],c=this.cpal().numPaletteEntries){return r=Number.isInteger(r)?this.get(r,"raw"):r,Object.assign(Array(c).fill(this.defaultValue),this.toCPALcolor(r).concat(this.toCPALcolor(a)))}extend(r){if(this.ensureCPAL(Array(r).fill(this.defaultValue)))return;let a=this.cpal(),c=a.numPaletteEntries+r,h=this.getAll().map(f=>this.fillPalette(f,[],c));a.numPaletteEntries=c,a.colorRecords=this.toCPALcolor(h.flat()),this.updateIndices()}get(r,a="hexa"){return this.getAll(a)[r]||null}getColor(r,a=0,c="hexa"){return eo(this.font,r,a,c)}setColor(r,a,c=0){r=parseInt(r),c=parseInt(c);let h=this.getAll("raw"),f=h[c];if(!f)throw Error(`paletteIndex ${c} out of range`);let g=this.cpal(),y=g.numPaletteEntries;Array.isArray(a)||(a=[a]),a.length+r>y&&(this.extend(a.length+r-y),h=this.getAll("raw"),f=h[c]);for(let S=0;S<a.length;S++)f[S+r]=this.toCPALcolor(a[S]);g.colorRecords=h.flat(),this.updateIndices()}add(r){if(this.ensureCPAL(r))return;let a=this.cpal(),c=a.numPaletteEntries;r&&r.length?(r=this.toCPALcolor(r),r.length>c?this.extend(r.length-c):r.length<c&&(r=this.fillPalette(r)),a.colorRecordIndices.push(a.colorRecords.length),a.colorRecords.push(...r)):(a.colorRecordIndices.push(a.colorRecords.length),a.colorRecords.push(...Array(c).fill(this.defaultValue)))}delete(r){let a=this.getAll("raw");delete a[r];let c=this.cpal();c.colorRecordIndices.pop(),c.colorRecords=a.flat()}deleteColor(r,a){if(r===a)throw Error("replacementIndex cannot be the same as colorIndex");let c=this.cpal(),h=this.getAll("raw"),f=[];if(a>c.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${c.numPaletteEntries-1}, replacementIndex: ${a})`);for(let S=0;S<h.length;S++){let C=h[S].filter((E,O)=>O!==r);f.push(C)}let g=this.font.tables.colr;if(g){let S=g.layerRecords;for(let T=0;T<S.length;T++){let C=S[T].paletteIndex;if(C>r)S[T].paletteIndex-=1;else if(C===r){let E=0;for(let O=0;O<h.length;O++)if(a>r&&a<=r+h[O].length){E++;break}S[T].paletteIndex=a-E}}this.font.tables.colr={...g,layerRecords:S}}let y=f.flat();for(let S=0;S<h.length;S++)c.colorRecordIndices[S]-=S;c.numPaletteEntries=Math.max(0,c.numPaletteEntries-1),c.colorRecords=this.toCPALcolor(y)}ensureCPAL(r){return this.cpal()?!1:(!r||!r.length?r=[this.defaultValue]:r=this.toCPALcolor(r),this.font.tables.cpal={version:0,numPaletteEntries:r.length,colorRecords:r,colorRecordIndices:[0]},!0)}updateIndices(){let r=this.cpal(),a=Math.ceil(r.colorRecords.length/r.numPaletteEntries);r.colorRecordIndices=[];for(let c=0;c<a;c++)r.colorRecordIndices.push(c*r.numPaletteEntries)}},gg=class{constructor(r){this.font=r}ensureCOLR(){return this.font.tables.colr||(this.font.tables.colr={version:0,baseGlyphRecords:[],layerRecords:[]}),this.font}get(r){let a=this.font,c=[],h=a.tables.colr,f=a.tables.cpal;if(!h||!f)return c;let g=cg(h.baseGlyphRecords,"glyphID",r);if(!g)return c;let y=g.firstLayerIndex,S=g.numLayers;for(let T=0;T<S;T++){let C=h.layerRecords[y+T];c.push({glyph:a.glyphs.get(C.glyphID),paletteIndex:C.paletteIndex})}return c}add(r,a,c){let h=this.get(r);a=Array.isArray(a)?a:[a],c===void 0||c===1/0||c>h.length?c=h.length:c<0&&(c=h.length+1+c%(h.length+1),c>=h.length+1&&(c-=h.length+1));let f=[];for(let g=0;g<c;g++){let y=Number.isInteger(h[g].glyph)?h[g].glyph:h[g].glyph.index;f.push({glyphID:y,paletteIndex:h[g].paletteIndex})}for(let g of a){let y=Number.isInteger(g.glyph)?g.glyph:g.glyph.index;f.push({glyphID:y,paletteIndex:g.paletteIndex})}for(let g=c;g<h.length;g++){let y=Number.isInteger(h[g].glyph)?h[g].glyph:h[g].glyph.index;f.push({glyphID:y,paletteIndex:h[g].paletteIndex})}this.updateColrTable(r,f)}setPaletteIndex(r,a,c){let h=this.get(r);h[a]?(h=h.map((f,g)=>({glyphID:f.glyph.index,paletteIndex:g===a?c:f.paletteIndex})),this.updateColrTable(r,h)):console.error("Invalid layer index")}remove(r,a,c=a){let h=this.get(r);h=h.map(f=>({glyphID:f.glyph.index,paletteIndex:f.paletteIndex})),h.splice(a,c-a+1),this.updateColrTable(r,h)}updateColrTable(r,a){this.ensureCOLR();let h=this.font.tables.colr,f=ug(h.baseGlyphRecords,"glyphID",r);if(f===-1){let E={glyphID:r,firstLayerIndex:h.layerRecords.length,numLayers:0};f=hg(h.baseGlyphRecords,"glyphID",E)}let y=h.baseGlyphRecords[f],S=y.numLayers,T=a.length,C=T-S;if(C>0){let E=a.slice(S).map(O=>({glyphID:O.glyphID,paletteIndex:O.paletteIndex}));h.layerRecords.splice(y.firstLayerIndex+S,0,...E)}else C<0&&h.layerRecords.splice(y.firstLayerIndex+T,-C);for(let E=0;E<Math.min(S,T);E++)h.layerRecords[y.firstLayerIndex+E]={glyphID:a[E].glyphID,paletteIndex:a[E].paletteIndex};if(y.numLayers=T,C!==0)for(let E=0;E<h.baseGlyphRecords.length;E++){let O=h.baseGlyphRecords[E];E===f||O.firstLayerIndex<y.firstLayerIndex||(h.baseGlyphRecords[E].firstLayerIndex+=C)}}},mg=class{constructor(r){this.font=r,this.cache=new WeakMap}get(r){let a=this.getOrCreateSvgImageCacheEntry(r);return a&&a.image}getAsync(r){let a=this.getOrCreateSvgImageCacheEntry(r);return a&&a.promise}getOrCreateSvgImageCacheEntry(r){let a=this.font.tables.svg;if(a===void 0)return;let c=a.get(r);if(c===void 0)return;let h=this.cache.get(c);h===void 0&&(h=bg(c),this.cache.set(c,h));let f=h.images.get(r);return f===void 0&&(f=yg(this.font,h.template,r),f.promise.then(g=>{if(f.image=g,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(r)}catch(y){console.error("font.onGlyphUpdated",r,y)}}),h.images.set(r,f)),f}};function bg(r){return{template:vg(r).then(Ag),images:new Map}}function yg(r,a,c){return{promise:a.then(h=>{let f;typeof h=="string"?f=h:(h[4]=c,f=h.join(""));let g=Tg(f,r.unitsPerEm);return g.image.decode().then(()=>g)}),image:void 0}}var vg=typeof DecompressionStream=="function"?Sg:xg;function xg(r){try{return Promise.resolve(new TextDecoder().decode(Hc(r)?dg(r):r))}catch(a){return Promise.reject(a)}}function Sg(r){if(Hc(r))return new Response(new Response(r).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(r))}catch(a){return Promise.reject(a)}}function Ag(r){let a=r.indexOf("<svg"),c=r.indexOf(">",a+4)+1;if(/ id=['"]glyph\d+['"]/.test(r.substring(a,c)))return r;let h=r.lastIndexOf("</svg>");return[r.substring(0,c),"<defs>",r.substring(c,h),'</defs><use href="#glyph',"",'"/>',r.substring(h)]}function Tg(r,a){let h=new DOMParser().parseFromString(r,"image/svg+xml").documentElement,f=h.viewBox.baseVal,g=h.width.baseVal,y=h.height.baseVal,S=1,T=1;f.width>0&&f.height>0&&(g.unitType===1?(S=g.valueInSpecifiedUnits/f.width,T=y.unitType===1?y.valueInSpecifiedUnits/f.height:S):y.unitType===1?(T=y.valueInSpecifiedUnits/f.height,S=T):a&&(S=a/f.width,T=a/f.height));let C=document.createElement("div");C.style.position="fixed",C.style.visibility="hidden",C.appendChild(h),document.body.appendChild(C);let E=h.getBBox();document.body.removeChild(C);let O=(E.x-f.x)*S,R=(f.y-E.y)*T,F=E.width*S,L=E.height*T;h.setAttribute("viewBox",[E.x,E.y,E.width,E.height].join(" ")),S!==1&&h.setAttribute("width",F),T!==1&&h.setAttribute("height",L);let B=new Image(F,L);return B.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(h.outerHTML),{leftSideBearing:O,baseline:R,image:B}}var po=new WeakMap;function Wc(r,a,c,h,f){let g;return(a&h)>0?(g=r.parseByte(),(a&f)===0&&(g=-g),g=c+g):(a&f)>0?g=c:g=c+r.parseShort(),g}function $c(r,a,c){let h=new ht.Parser(a,c);r._numberOfContours=h.parseShort(),r._xMin=h.parseShort(),r._yMin=h.parseShort(),r._xMax=h.parseShort(),r._yMax=h.parseShort();let f,g;if(r._numberOfContours>0){let y=r.endPointIndices=[];for(let T=0;T<r._numberOfContours;T+=1)y.push(h.parseUShort());r.instructionLength=h.parseUShort(),r.instructions=[];for(let T=0;T<r.instructionLength;T+=1)r.instructions.push(h.parseByte());let S=y[y.length-1]+1;f=[];for(let T=0;T<S;T+=1)if(g=h.parseByte(),f.push(g),(g&8)>0){let C=h.parseByte();for(let E=0;E<C;E+=1)f.push(g),T+=1}if(V.argument(f.length===S,"Bad flags."),y.length>0){let T=[],C;if(S>0){for(let R=0;R<S;R+=1)g=f[R],C={},C.onCurve=!!(g&1),C.lastPointOfContour=y.indexOf(R)>=0,T.push(C);let E=0;for(let R=0;R<S;R+=1)g=f[R],C=T[R],C.x=Wc(h,g,E,2,16),E=C.x;let O=0;for(let R=0;R<S;R+=1)g=f[R],C=T[R],C.y=Wc(h,g,O,4,32),O=C.y}r.points=T}else r.points=[]}else if(r._numberOfContours===0)r.points=[];else{r.isComposite=!0,r.points=[],r.components=[];let y=!0;for(;y;){f=h.parseUShort();let S={glyphIndex:h.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(f&1)>0?(f&2)>0?(S.dx=h.parseShort(),S.dy=h.parseShort()):S.matchedPoints=[h.parseUShort(),h.parseUShort()]:(f&2)>0?(S.dx=h.parseChar(),S.dy=h.parseChar()):S.matchedPoints=[h.parseByte(),h.parseByte()],(f&8)>0?S.xScale=S.yScale=h.parseF2Dot14():(f&64)>0?(S.xScale=h.parseF2Dot14(),S.yScale=h.parseF2Dot14()):(f&128)>0&&(S.xScale=h.parseF2Dot14(),S.scale01=h.parseF2Dot14(),S.scale10=h.parseF2Dot14(),S.yScale=h.parseF2Dot14()),r.components.push(S),y=!!(f&32)}if(f&256){r.instructionLength=h.parseUShort(),r.instructions=[];for(let S=0;S<r.instructionLength;S+=1)r.instructions.push(h.parseByte())}}}function ys(r,a){let c=[];for(let h=0;h<r.length;h+=1){let f=r[h],g={x:a.xScale*f.x+a.scale10*f.y+a.dx,y:a.scale01*f.x+a.yScale*f.y+a.dy,onCurve:f.onCurve,lastPointOfContour:f.lastPointOfContour};c.push(g)}return c}function wg(r){let a=[],c=[];for(let h=0;h<r.length;h+=1){let f=r[h];c.push(f),f.lastPointOfContour&&(a.push(c),c=[])}return V.argument(c.length===0,"There are still points left in the current contour."),a}function go(r){let a=new Ut;if(!r)return a;let c=wg(r);for(let h=0;h<c.length;++h){let f=c[h],g=f[f.length-1],y=f[0];if(g.onCurve)a.moveTo(g.x,g.y);else if(y.onCurve)a.moveTo(y.x,y.y);else{let S={x:(g.x+y.x)*.5,y:(g.y+y.y)*.5};a.moveTo(S.x,S.y)}for(let S=0;S<f.length;++S)if(g=y,y=f[(S+1)%f.length],g.onCurve)a.lineTo(g.x,g.y);else{let T=y;y.onCurve||(T={x:(g.x+y.x)*.5,y:(g.y+y.y)*.5}),a.quadraticCurveTo(g.x,g.y,T.x,T.y)}a.closePath()}return a}function zc(r,a){if(a.isComposite){po.has(r)||po.set(r,new Set);let c=po.get(r);c.add(a.index);try{for(let h=0;h<a.components.length;h+=1){let f=a.components[h];if(c.has(f.glyphIndex))continue;let g=r.get(f.glyphIndex);if(g.getPath(),g.points){let y;if(f.matchedPoints===void 0)y=ys(g.points,f);else{if(f.matchedPoints[0]>a.points.length-1||f.matchedPoints[1]>g.points.length-1)throw Error("Matched points out of range in "+a.name);let S=a.points[f.matchedPoints[0]],T=g.points[f.matchedPoints[1]],C={xScale:f.xScale,scale01:f.scale01,scale10:f.scale10,yScale:f.yScale,dx:0,dy:0};T=ys([T],C)[0],C.dx=S.x-T.x,C.dy=S.y-T.y,y=ys(g.points,C)}a.points=a.points.concat(y)}}}finally{c.delete(a.index)}}return go(a.points)}function Eg(r,a,c,h){let f=new ze.GlyphSet(h);for(let g=0;g<c.length-1;g+=1){let y=c[g],S=c[g+1];y!==S?f.push(g,ze.ttfGlyphLoader(h,g,$c,r,a+y,zc)):f.push(g,ze.glyphLoader(h,g))}return f}function Cg(r,a,c,h){let f=new ze.GlyphSet(h);return h._push=function(g){let y=c[g],S=c[g+1];y!==S?f.push(g,ze.ttfGlyphLoader(h,g,$c,r,a+y,zc)):f.push(g,ze.glyphLoader(h,g))},f}function kg(r,a,c,h,f){return f.lowMemory?Cg(r,a,c,h):Eg(r,a,c,h)}var Xc={getPath:go,parse:kg},Ig=class{constructor(r){this.font=r}normalizeCoordTags(r){for(let a in r)if(a.length<4){let c=a.padEnd(4," ");r[c]===void 0&&(r[c]=r[a]),delete r[a]}}getNormalizedCoords(r){r||(r=this.font.variation.get());let a=[];this.normalizeCoordTags(r);for(let c=0;c<this.fvar().axes.length;c++){let h=this.fvar().axes[c],f=r[h.tag];f===void 0&&(f=h.defaultValue),f<h.defaultValue?a.push((f-h.defaultValue+Number.EPSILON)/(h.defaultValue-h.minValue+Number.EPSILON)):a.push((f-h.defaultValue+Number.EPSILON)/(h.maxValue-h.defaultValue+Number.EPSILON))}if(this.avar())for(let c=0;c<this.avar().axisSegmentMaps.length;c++){let h=this.avar().axisSegmentMaps[c];for(let f=0;f<h.axisValueMaps.length;f++){let g=h.axisValueMaps[f];if(f>=1&&a[c]<g.fromCoordinate){let y=h.axisValueMaps[f-1];a[c]=((a[c]-y.fromCoordinate)*(g.toCoordinate-y.toCoordinate)+Number.EPSILON)/(g.fromCoordinate-y.fromCoordinate+Number.EPSILON)+y.toCoordinate;break}}}return a}interpolatePoints(r,a,c){if(r.length===0)return;let h=0;for(;h<r.length;){let f=h,g=h,y=r[g];for(;!y.lastPointOfContour;)y=r[++g];for(;h<=g&&!c[h];)h++;if(h>g)continue;let S=h,T=h;for(h++;h<=g;)c[h]&&(this.deltaInterpolate(T+1,h-1,T,h,a,r),T=h),h++;T===S?this.deltaShift(f,g,T,a,r):(this.deltaInterpolate(T+1,g,T,S,a,r),S>0&&this.deltaInterpolate(f,S-1,T,S,a,r)),h=g+1}}deltaInterpolate(r,a,c,h,f,g){if(r>a)return;let y=["x","y"];for(let T=0;T<y.length;T++){let C=y[T];if(f[c][C]>f[h][C]){var S=c;c=h,h=S}let E=f[c][C],O=f[h][C],R=g[c][C],F=g[h][C];if(E!==O||R===F){let L=E===O?0:(F-R)/(O-E);for(let B=r;B<=a;B++){let Y=f[B][C];Y<=E?Y+=R-E:Y>=O?Y+=F-O:Y=R+(Y-E)*L,g[B][C]=Y}}}}deltaShift(r,a,c,h,f){let g=f[c].x-h[c].x,y=f[c].y-h[c].y;if(!(g===0&&y===0))for(let S=r;S<=a;S++)S!==c&&(f[S].x+=g,f[S].y+=y)}transformComponents(r,a,c,h,f,g){let y=0;for(let S=0;S<r.components.length;S++){let T=r.components[S],C=this.font.glyphs.get(T.glyphIndex),E=fg(T),O=h.indexOf(S);O>-1&&(E.dx+=Math.round(f.deltas[O]*g),E.dy+=Math.round(f.deltasY[O]*g));let R=ys(this.getTransform(C,c).points,E);a.splice(y,R.length,...R),y+=C.points.length}}applyTupleVariationStore(r,a,c,h="gvar",f={}){c||(c=this.font.variation.get());let g=this.getNormalizedCoords(c),{headers:y,sharedPoints:S}=r,T=this.fvar().axes.length,C;h==="gvar"?C=a.map(jc):h==="cvar"&&(C=[...a]);for(let E=0;E<y.length;E++){let O=y[E],R=1;for(let L=0;L<T;L++){let B=[0];switch(h){case"gvar":B=O.peakTuple?O.peakTuple:this.gvar().sharedTuples[O.sharedTupleRecordsIndex];break;case"cvar":B=O.peakTuple;break}if(B[L]!==0){if(g[L]===0){R=0;break}if(O.intermediateStartTuple)if(g[L]<O.intermediateStartTuple[L]||g[L]>O.intermediateEndTuple[L]){R=0;break}else g[L]<B[L]?R=R*(g[L]-O.intermediateStartTuple[L]+Number.EPSILON)/(B[L]-O.intermediateStartTuple[L]+Number.EPSILON):R=R*(O.intermediateEndTuple[L]-g[L]+Number.EPSILON)/(O.intermediateEndTuple[L]-B[L]+Number.EPSILON);else{if(g[L]<Math.min(0,B[L])||g[L]>Math.max(0,B[L])){R=0;break}R=(R*g[L]+Number.EPSILON)/(B[L]+Number.EPSILON)}}}if(R===0)continue;let F=O.privatePoints.length?O.privatePoints:S;if(h==="gvar"&&f.glyph&&f.glyph.isComposite)this.transformComponents(f.glyph,C,c,F,O,R);else if(F.length===0)for(let L=0;L<C.length;L++){let B=C[L];h==="gvar"?C[L]={x:Math.round(B.x+O.deltas[L]*R),y:Math.round(B.y+O.deltasY[L]*R),onCurve:B.onCurve,lastPointOfContour:B.lastPointOfContour}:h==="cvar"&&(C[L]=Math.round(B+O.deltas[L]*R))}else{let L;h==="gvar"?L=C.map(jc):h==="cvar"&&(L=C);let B=Array(a.length).fill(!1);for(let Y=0;Y<F.length;Y++){let yt=F[Y];if(yt<a.length){let mt=L[yt];h==="gvar"?(B[yt]=!0,mt.x+=O.deltas[Y]*R,mt.y+=O.deltasY[Y]*R):h==="cvar"&&(C[yt]=Math.round(mt+O.deltas[Y]*R))}}if(h==="gvar"){this.interpolatePoints(L,C,B);for(let Y=0;Y<a.length;Y++){let yt=L[Y].x-C[Y].x,mt=L[Y].y-C[Y].y;C[Y].x=Math.round(C[Y].x+yt),C[Y].y=Math.round(C[Y].y+mt)}}}}return C}getTransform(r,a){Number.isInteger(r)&&(r=this.font.glyphs.get(r));let c=r.getBlendPath,h=!!(r.points&&r.points.length),f=r;if(c||h){if(a||(a=this.font.variation.get()),h){let g=this.gvar()&&this.gvar().glyphVariations[r.index];if(g){let y=r.points,S=this.applyTupleVariationStore(g,y,a,"gvar",{glyph:r});f=new Kn(Object.assign({},r,{points:S,path:go(S)}))}}else if(c){let g=r.getBlendPath(a);f=new Kn(Object.assign({},r,{path:g}))}}return this.font.tables.hvar&&(r._advanceWidth=typeof r._advanceWidth<"u"?r._advanceWidth:r.advanceWidth,r.advanceWidth=f.advanceWidth=Math.round(r._advanceWidth+this.getVariableAdjustment(f.index,"hvar","advanceWidth",a)),r._leftSideBearing=typeof r._leftSideBearing<"u"?r._leftSideBearing:r.leftSideBearing,r.leftSideBearing=f.leftSideBearing=Math.round(r._leftSideBearing+this.getVariableAdjustment(f.index,"hvar","lsb",a))),f}getCvarTransform(r){let a=this.font.tables.cvt,c=this.cvar();return!a||!a.length||!c||!c.headers.length?a:this.applyTupleVariationStore(c,a,r,"cvar")}getVariableAdjustment(r,a,c,h){h=h||this.font.variation.get();let f,g,y=this.font.tables[a];if(!y)throw Error(`trying to get variation adjustment from non-existent table "${y}"`);if(!y.itemVariationStore)throw Error(`trying to get variation adjustment from table "${y}" which does not have an itemVariationStore`);let S=y[c]&&y[c].map.length;if(S){let T=r;T>=S&&(T=S-1),{outerIndex:f,innerIndex:g}=y[c].map[T]}else f=0,g=r;return this.getDelta(y.itemVariationStore,f,g,h)}getDelta(r,a,c,h){if(a>=r.itemVariationSubtables.length)return 0;let f=r.itemVariationSubtables[a];if(c>=f.deltaSets.length)return 0;let g=f.deltaSets[c],y=this.getBlendVector(r,a,h),S=0;for(let T=0;T<f.regionIndexes.length;T++)S+=g[T]*y[T];return S}getBlendVector(r,a,c){c||(c=this.font.variation.get());let h=r.itemVariationSubtables[a],f=this.getNormalizedCoords(c),g=[];for(let y=0;y<h.regionIndexes.length;y++){let S=1,T=h.regionIndexes[y],C=r.variationRegions[T].regionAxes;for(let E=0;E<C.length;E++){let O=C[E],R;O.startCoord>O.peakCoord||O.peakCoord>O.endCoord||O.startCoord<0&&O.endCoord>0&&O.peakCoord!==0||O.peakCoord===0?R=1:f[E]<O.startCoord||f[E]>O.endCoord?R=0:f[E]===O.peakCoord?R=1:f[E]<O.peakCoord?R=(f[E]-O.startCoord+Number.EPSILON)/(O.peakCoord-O.startCoord+Number.EPSILON):R=(O.endCoord-f[E]+Number.EPSILON)/(O.endCoord-O.peakCoord+Number.EPSILON),S*=R}g[y]=S}return g}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},Pg=class{constructor(r){this.font=r,this.process=new Ig(this.font),this.activateDefaultVariation(),this.getTransform=this.process.getTransform.bind(this.process)}activateDefaultVariation(){let r=this.getDefaultInstanceIndex();r>-1?this.set(r):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((r,a)=>(r[a.tag]=a.defaultValue,r),{})}getDefaultInstanceIndex(){let r=this.getDefaultCoordinates(),a=this.getInstanceIndex(r);return a<0&&(a=this.fvar().instances.findIndex(c=>c.name&&c.name.en==="Regular")),a}getInstanceIndex(r){return this.fvar().instances.findIndex(a=>Object.keys(r).every(c=>a.coordinates[c]===r[c]))}getInstance(r){return this.fvar().instances&&this.fvar().instances[r]}set(r){let a;if(Number.isInteger(r)){let c=this.getInstance(r);if(!c)throw Error(`Invalid instance index ${r}`);a={...c.coordinates}}else a=r,this.process.normalizeCoordTags(a);a=Object.assign({},this.font.defaultRenderOptions.variation,a),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:a})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},Yc=1e6,vs=64,xs=1e4,Kc,Rn,Zc,mo;function Qc(r){this.font=r,this.getCommands=function(a){return Xc.getPath(a).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Rg(r){return r}function Jc(r){return Math.sign(r)*Math.round(Math.abs(r))}function Og(r){return Math.sign(r)*Math.round(Math.abs(r*2))/2}function Mg(r){return Math.sign(r)*(Math.round(Math.abs(r)+.5)-.5)}function Lg(r){return Math.sign(r)*Math.ceil(Math.abs(r))}function Fg(r){return Math.sign(r)*Math.floor(Math.abs(r))}var qc=function(r){let a=this.srPeriod,c=this.srPhase,h=this.srThreshold,f=1;return r<0&&(r=-r,f=-1),r+=h-c,r=Math.trunc(r/a)*a,r+=c,r<0?c*f:r*f},Ye={x:1,y:0,axis:"x",distance:function(r,a,c,h){return(c?r.xo:r.x)-(h?a.xo:a.x)},interpolate:function(r,a,c,h){let f,g,y,S,T,C,E;if(!h||h===this){if(f=r.xo-a.xo,g=r.xo-c.xo,T=a.x-a.xo,C=c.x-c.xo,y=Math.abs(f),S=Math.abs(g),E=y+S,E===0){r.x=r.xo+(T+C)/2;return}r.x=r.xo+(T*S+C*y)/E;return}if(f=h.distance(r,a,!0,!0),g=h.distance(r,c,!0,!0),T=h.distance(a,a,!1,!0),C=h.distance(c,c,!1,!0),y=Math.abs(f),S=Math.abs(g),E=y+S,E===0){Ye.setRelative(r,r,(T+C)/2,h,!0);return}Ye.setRelative(r,r,(T*S+C*y)/E,h,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(r,a,c,h,f){if(!h||h===this){r.x=(f?a.xo:a.x)+c;return}let g=f?a.xo:a.x,y=f?a.yo:a.y,S=g+c*h.x,T=y+c*h.y;r.x=S+(r.y-T)/h.normalSlope},slope:0,touch:function(r){r.xTouched=!0},touched:function(r){return r.xTouched},untouch:function(r){r.xTouched=!1}},en={x:0,y:1,axis:"y",distance:function(r,a,c,h){return(c?r.yo:r.y)-(h?a.yo:a.y)},interpolate:function(r,a,c,h){let f,g,y,S,T,C,E;if(!h||h===this){if(f=r.yo-a.yo,g=r.yo-c.yo,T=a.y-a.yo,C=c.y-c.yo,y=Math.abs(f),S=Math.abs(g),E=y+S,E===0){r.y=r.yo+(T+C)/2;return}r.y=r.yo+(T*S+C*y)/E;return}if(f=h.distance(r,a,!0,!0),g=h.distance(r,c,!0,!0),T=h.distance(a,a,!1,!0),C=h.distance(c,c,!1,!0),y=Math.abs(f),S=Math.abs(g),E=y+S,E===0){en.setRelative(r,r,(T+C)/2,h,!0);return}en.setRelative(r,r,(T*S+C*y)/E,h,!0)},normalSlope:0,setRelative:function(r,a,c,h,f){if(!h||h===this){r.y=(f?a.yo:a.y)+c;return}let g=f?a.xo:a.x,y=f?a.yo:a.y,S=g+c*h.x,T=y+c*h.y;r.y=T+h.normalSlope*(r.x-S)},slope:Number.POSITIVE_INFINITY,touch:function(r){r.yTouched=!0},touched:function(r){return r.yTouched},untouch:function(r){r.yTouched=!1}};Object.freeze(Ye),Object.freeze(en);function Sr(r,a){this.x=r,this.y=a,this.axis=void 0,this.slope=a/r,this.normalSlope=-r/a,Object.freeze(this)}Sr.prototype.distance=function(r,a,c,h){return this.x*Ye.distance(r,a,c,h)+this.y*en.distance(r,a,c,h)},Sr.prototype.interpolate=function(r,a,c,h){let f,g,y,S,T,C,E;if(y=h.distance(r,a,!0,!0),S=h.distance(r,c,!0,!0),f=h.distance(a,a,!1,!0),g=h.distance(c,c,!1,!0),T=Math.abs(y),C=Math.abs(S),E=T+C,E===0){this.setRelative(r,r,(f+g)/2,h,!0);return}this.setRelative(r,r,(f*C+g*T)/E,h,!0)},Sr.prototype.setRelative=function(r,a,c,h,f){h=h||this;let g=f?a.xo:a.x,y=f?a.yo:a.y,S=g+c*h.x,T=y+c*h.y,C=h.normalSlope,E=this.slope,O=r.x,R=r.y;r.x=(E*O-C*S+T-R)/(E-C),r.y=E*(r.x-O)+R},Sr.prototype.touch=function(r){r.xTouched=!0,r.yTouched=!0};function Ar(r,a){let c=Math.sqrt(r*r+a*a);return r/=c,a/=c,r===1&&a===0?Ye:r===0&&a===1?en:new Sr(r,a)}function nn(r,a,c,h){this.x=this.xo=Math.round(r*64)/64,this.y=this.yo=Math.round(a*64)/64,this.lastPointOfContour=c,this.onCurve=h,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}nn.prototype.nextTouched=function(r){let a=this.nextPointOnContour;for(;!r.touched(a)&&a!==this;)a=a.nextPointOnContour;return a},nn.prototype.prevTouched=function(r){let a=this.prevPointOnContour;for(;!r.touched(a)&&a!==this;)a=a.prevPointOnContour;return a};var Tr=Object.freeze(new nn(0,0)),Dg={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function ln(r,a){switch(this.env=r,this.stack=[],this.prog=a,r){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=Ye,this.round=Jc}}Qc.prototype.exec=function(r,a){if(typeof a!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;let c=this.font,h=this._prepState;if(!h||h.ppem!==a){let f=this._fpgmState;if(!f){ln.prototype=Dg,f=this._fpgmState=new ln("fpgm",c.tables.fpgm),f.funcs=[],f.font=c,f.instructionCount=0,f.callDepth=0;try{Rn(f)}catch(y){console.log("Hinting error in FPGM:"+y),this._errorState=3;return}}ln.prototype=f,h=this._prepState=new ln("prep",c.tables.prep),h.ppem=a,h.instructionCount=0,h.callDepth=0;let g=c.variation&&c.variation.process.getCvarTransform()||c.tables.cvt;if(g){let y=h.cvt=new Array(g.length),S=a/c.unitsPerEm;for(let T=0;T<g.length;T++)y[T]=g[T]*S}else h.cvt=[];try{Rn(h)}catch(y){this._errorState<2&&console.log("Hinting error in PREP:"+y),this._errorState=2}}if(!(this._errorState>1))try{return Zc(r,h)}catch(f){this._errorState<1&&(console.log("Hinting error:"+f),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}},Zc=function(r,a){let c=a.ppem/a.font.unitsPerEm,h=c,f=r.components,g,y,S;if(ln.prototype=a,!f)S=new ln("glyf",r.instructions),S.instructionCount=0,S.callDepth=0,mo(r,S,c,h),y=S.gZone;else{let T=a.font;y=[],g=[];for(let C=0;C<f.length;C++){let E=f[C],O=T.glyphs.get(E.glyphIndex);S=new ln("glyf",O.instructions),S.instructionCount=0,S.callDepth=0,mo(O,S,c,h);let R=Math.round(E.dx*c),F=Math.round(E.dy*h),L=S.gZone,B=S.contours;for(let yt=0;yt<L.length;yt++){let mt=L[yt];mt.xTouched=mt.yTouched=!1,mt.xo=mt.x=mt.x+R,mt.yo=mt.y=mt.y+F}let Y=y.length;y.push.apply(y,L);for(let yt=0;yt<B.length;yt++)g.push(B[yt]+Y)}r.instructions&&!S.inhibitGridFit&&(S=new ln("glyf",r.instructions),S.gZone=S.z0=S.z1=S.z2=y,S.contours=g,y.push(new nn(0,0),new nn(Math.round(r.advanceWidth*c),0)),Rn(S),y.length-=2)}return y},mo=function(r,a,c,h){let f=r.points||[],g=f.length,y=a.gZone=a.z0=a.z1=a.z2=[],S=a.contours=[],T;for(let O=0;O<g;O++)T=f[O],y[O]=new nn(T.x*c,T.y*h,T.lastPointOfContour,T.onCurve);let C,E;for(let O=0;O<g;O++)T=y[O],C||(C=T,S.push(O)),T.lastPointOfContour?(T.nextPointOnContour=C,C.prevPointOnContour=T,C=void 0):(E=y[O+1],T.nextPointOnContour=E,E.prevPointOnContour=T);a.inhibitGridFit||(y.push(new nn(0,0),new nn(Math.round(r.advanceWidth*c),0)),Rn(a),y.length-=2)},Rn=function(r){let a=r.prog;if(!a)return;let c=a.length,h;for(r.ip=0;r.ip<c;r.ip++){if(++r.instructionCount>Yc)throw new Error("Hinting instructions exceeded maximum of "+Yc);if(h=Kc[a[r.ip]],!h)throw new Error("unknown instruction: 0x"+Number(a[r.ip]).toString(16));h(r)}};function Ss(r){let a=r.tZone=new Array(r.gZone.length);for(let c=0;c<a.length;c++)a[c]=new nn(0,0)}function tu(r,a){let c=r.prog,h=r.ip,f=1,g;do if(g=c[++h],g===88)f++;else if(g===89)f--;else if(g===64)h+=c[h+1]+1;else if(g===65)h+=2*c[h+1]+1;else if(g>=176&&g<=183)h+=g-176+1;else if(g>=184&&g<=191)h+=(g-184+1)*2;else if(a&&f===1&&g===27)break;while(f>0);r.ip=h}function eu(r,a){a.fv=a.pv=a.dpv=r}function nu(r,a){a.pv=a.dpv=r}function ru(r,a){a.fv=r}function su(r,a){let c=a.stack,h=c.pop(),f=c.pop(),g=a.z2[h],y=a.z1[f],S,T;r?(S=g.y-y.y,T=y.x-g.x):(S=y.x-g.x,T=y.y-g.y),a.pv=a.dpv=Ar(S,T)}function iu(r,a){let c=a.stack,h=c.pop(),f=c.pop(),g=a.z2[h],y=a.z1[f],S,T;r?(S=g.y-y.y,T=y.x-g.x):(S=y.x-g.x,T=y.y-g.y),a.fv=Ar(S,T)}function _g(r){let a=r.stack,c=a.pop(),h=a.pop();r.pv=r.dpv=Ar(h,c)}function Ng(r){let a=r.stack,c=a.pop(),h=a.pop();r.fv=Ar(h,c)}function Ug(r){let a=r.stack,c=r.pv;a.push(c.x*16384),a.push(c.y*16384)}function Bg(r){let a=r.stack,c=r.fv;a.push(c.x*16384),a.push(c.y*16384)}function Gg(r){r.fv=r.pv}function Hg(r){let a=r.stack,c=a.pop(),h=a.pop(),f=a.pop(),g=a.pop(),y=a.pop(),S=r.z0,T=r.z1,C=S[c],E=S[h],O=T[f],R=T[g],F=r.z2[y],L=C.x,B=C.y,Y=E.x,yt=E.y,mt=O.x,At=O.y,Rt=R.x,Nt=R.y,Gt=(L-Y)*(At-Nt)-(B-yt)*(mt-Rt),Ht=L*yt-B*Y,qt=mt*Nt-At*Rt;F.x=(Ht*(mt-Rt)-qt*(L-Y))/Gt,F.y=(Ht*(At-Nt)-qt*(B-yt))/Gt}function jg(r){r.rp0=r.stack.pop()}function Vg(r){r.rp1=r.stack.pop()}function Wg(r){r.rp2=r.stack.pop()}function $g(r){let a=r.stack.pop();switch(r.zp0=a,a){case 0:r.tZone||Ss(r),r.z0=r.tZone;break;case 1:r.z0=r.gZone;break;default:throw new Error("Invalid zone pointer")}}function zg(r){let a=r.stack.pop();switch(r.zp1=a,a){case 0:r.tZone||Ss(r),r.z1=r.tZone;break;case 1:r.z1=r.gZone;break;default:throw new Error("Invalid zone pointer")}}function Xg(r){let a=r.stack.pop();switch(r.zp2=a,a){case 0:r.tZone||Ss(r),r.z2=r.tZone;break;case 1:r.z2=r.gZone;break;default:throw new Error("Invalid zone pointer")}}function Yg(r){let a=r.stack.pop();switch(r.zp0=r.zp1=r.zp2=a,a){case 0:r.tZone||Ss(r),r.z0=r.z1=r.z2=r.tZone;break;case 1:r.z0=r.z1=r.z2=r.gZone;break;default:throw new Error("Invalid zone pointer")}}function Kg(r){r.loop=r.stack.pop(),r.loop>xs&&(r.loop=xs)}function Zg(r){r.round=Jc}function Qg(r){r.round=Mg}function Jg(r){let a=r.stack.pop();r.minDis=a/64}function qg(r){tu(r,!1)}function tm(r){let a=r.stack.pop();r.ip+=a-1}function em(r){let a=r.stack.pop();r.cvCutIn=a/64}function nm(r){let a=r.stack;a.push(a[a.length-1])}function bo(r){r.stack.pop()}function rm(r){r.stack.length=0}function sm(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(c),a.push(h)}function im(r){let a=r.stack;a.push(a.length)}function om(r){let a=r.stack,c=a.pop(),h=a.pop();if(h>xs&&(h=xs),++r.callDepth>vs)throw new Error("Hinting call depth exceeded maximum of "+vs);let f=r.ip,g=r.prog;r.prog=r.funcs[c];for(let y=0;y<h;y++)Rn(r);r.ip=f,r.prog=g,r.callDepth--}function am(r){let a=r.stack.pop();if(++r.callDepth>vs)throw new Error("Hinting call depth exceeded maximum of "+vs);let c=r.ip,h=r.prog;r.prog=r.funcs[a],Rn(r),r.ip=c,r.prog=h,r.callDepth--}function lm(r){let a=r.stack,c=a.pop();a.push(a[a.length-c])}function cm(r){let a=r.stack,c=a.pop();a.push(a.splice(a.length-c,1)[0])}function um(r){if(r.env!=="fpgm")throw new Error("FDEF not allowed here");let a=r.stack,c=r.prog,h=r.ip,f=a.pop(),g=h;for(;c[++h]!==45;);r.ip=h,r.funcs[f]=c.slice(g+1,h)}function ou(r,a){let c=a.stack.pop(),h=a.z0[c],f=a.fv,g=a.pv,y=g.distance(h,Tr);r&&(y=a.round(y)),f.setRelative(h,Tr,y,g),f.touch(h),a.rp0=a.rp1=c}function au(r,a){let c=a.z2,h=c.length-2,f,g,y;for(let S=0;S<h;S++)f=c[S],!r.touched(f)&&(g=f.prevTouched(r),g!==f&&(y=f.nextTouched(r),g===y&&r.setRelative(f,f,r.distance(g,g,!1,!0),r,!0),r.interpolate(f,g,y,r)))}function lu(r,a){let c=a.stack,h=r?a.rp1:a.rp2,f=(r?a.z0:a.z1)[h],g=a.fv,y=a.pv,S=a.loop,T=a.z2;for(;S--;){let C=c.pop(),E=T[C],O=y.distance(f,f,!1,!0);g.setRelative(E,E,O,y),g.touch(E)}a.loop=1}function cu(r,a){let c=a.stack,h=r?a.rp1:a.rp2,f=(r?a.z0:a.z1)[h],g=a.fv,y=a.pv,S=c.pop(),T=a.z2[a.contours[S]],C=T,E=y.distance(f,f,!1,!0);do C!==f&&g.setRelative(C,C,E,y),C=C.nextPointOnContour;while(C!==T)}function uu(r,a){let c=a.stack,h=r?a.rp1:a.rp2,f=(r?a.z0:a.z1)[h],g=a.fv,y=a.pv,S=c.pop(),T;switch(S){case 0:T=a.tZone;break;case 1:T=a.gZone;break;default:throw new Error("Invalid zone")}let C,E=y.distance(f,f,!1,!0),O=T.length-2;for(let R=0;R<O;R++)C=T[R],g.setRelative(C,C,E,y)}function hm(r){let a=r.stack,c=r.loop,h=r.fv,f=a.pop()/64,g=r.z2;for(;c--;){let y=a.pop(),S=g[y];h.setRelative(S,S,f),h.touch(S)}r.loop=1}function dm(r){let a=r.stack,c=r.rp1,h=r.rp2,f=r.loop,g=r.z0[c],y=r.z1[h],S=r.fv,T=r.dpv,C=r.z2;for(;f--;){let E=a.pop(),O=C[E];S.interpolate(O,g,y,T),S.touch(O)}r.loop=1}function hu(r,a){let c=a.stack,h=c.pop()/64,f=c.pop(),g=a.z1[f],y=a.z0[a.rp0],S=a.fv,T=a.pv;S.setRelative(g,y,h,T),S.touch(g),a.rp1=a.rp0,a.rp2=f,r&&(a.rp0=f)}function fm(r){let a=r.stack,c=r.rp0,h=r.z0[c],f=r.loop,g=r.fv,y=r.pv,S=r.z1;for(;f--;){let T=a.pop(),C=S[T];g.setRelative(C,h,0,y),g.touch(C)}r.loop=1}function pm(r){r.round=Og}function du(r,a){let c=a.stack,h=c.pop(),f=c.pop(),g=a.z0[f],y=a.fv,S=a.pv,T=a.cvt[h],C=S.distance(g,Tr);r&&(Math.abs(C-T)<a.cvCutIn&&(C=T),C=a.round(C)),y.setRelative(g,Tr,C,S),a.zp0===0&&(g.xo=g.x,g.yo=g.y),y.touch(g),a.rp0=a.rp1=f}function gm(r){let a=r.prog,c=r.ip,h=r.stack,f=a[++c];for(let g=0;g<f;g++)h.push(a[++c]);r.ip=c}function mm(r){let a=r.ip,c=r.prog,h=r.stack,f=c[++a];for(let g=0;g<f;g++){let y=c[++a]<<8|c[++a];y&32768&&(y=-((y^65535)+1)),h.push(y)}r.ip=a}function bm(r){let a=r.stack,c=r.store;c||(c=r.store=[]);let h=a.pop(),f=a.pop();c[f]=h}function ym(r){let a=r.stack,c=r.store,h=a.pop(),f=c&&c[h]||0;a.push(f)}function vm(r){let a=r.stack,c=a.pop(),h=a.pop();r.cvt[h]=c/64}function xm(r){let a=r.stack,c=a.pop();a.push(r.cvt[c]*64)}function fu(r,a){let c=a.stack,h=c.pop(),f=a.z2[h];c.push(a.dpv.distance(f,Tr,r,!1)*64)}function pu(r,a){let c=a.stack,h=c.pop(),f=c.pop(),g=a.z1[h],y=a.z0[f],S=a.dpv.distance(y,g,r,r);a.stack.push(Math.round(S*64))}function Sm(r){r.stack.push(r.ppem)}function Am(r){r.autoFlip=!0}function Tm(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(h<c?1:0)}function wm(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(h<=c?1:0)}function Em(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(h>c?1:0)}function Cm(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(h>=c?1:0)}function km(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(c===h?1:0)}function Im(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(c!==h?1:0)}function Pm(r){let a=r.stack,c=a.pop();a.push(Math.trunc(c)&1?1:0)}function Rm(r){let a=r.stack,c=a.pop();a.push(Math.trunc(c)&1?0:1)}function Om(r){let a=r.stack.pop(),c;a||tu(r,!0)}function Mm(r){}function Lm(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(c&&h?1:0)}function Fm(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(c||h?1:0)}function Dm(r){let a=r.stack,c=a.pop();a.push(c?0:1)}function yo(r,a){let c=a.stack,h=c.pop(),f=a.fv,g=a.pv,y=a.ppem,S=a.deltaBase+(r-1)*16,T=a.deltaShift,C=a.z0;for(let E=0;E<h;E++){let O=c.pop(),R=c.pop();if(S+((R&240)>>4)!==y)continue;let L=(R&15)-8;L>=0&&L++;let B=C[O];f.setRelative(B,B,L*T,g)}}function _m(r){let c=r.stack.pop();r.deltaBase=c}function Nm(r){let c=r.stack.pop();r.deltaShift=Math.pow(.5,c)}function Um(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(h+c)}function Bm(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(h-c)}function Gm(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(h*64/c)}function Hm(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(h*c/64)}function jm(r){let a=r.stack,c=a.pop();a.push(Math.abs(c))}function Vm(r){let a=r.stack,c=a.pop();a.push(-c)}function Wm(r){let a=r.stack,c=a.pop();a.push(Math.floor(c/64)*64)}function $m(r){let a=r.stack,c=a.pop();a.push(Math.ceil(c/64)*64)}function As(r,a){let c=a.stack,h=c.pop();c.push(a.round(h/64)*64)}function zm(r){let a=r.stack,c=a.pop(),h=a.pop();r.cvt[h]=c*r.ppem/r.font.unitsPerEm}function vo(r,a){let c=a.stack,h=c.pop(),f=a.ppem,g=a.deltaBase+(r-1)*16,y=a.deltaShift;for(let S=0;S<h;S++){let T=c.pop(),C=c.pop();if(g+((C&240)>>4)!==f)continue;let O=(C&15)-8;O>=0&&O++;let R=O*y;a.cvt[T]+=R}}function Xm(r){let a=r.stack.pop();r.round=qc;let c;switch(a&192){case 0:c=.5;break;case 64:c=1;break;case 128:c=2;break;default:throw new Error("invalid SROUND value")}switch(r.srPeriod=c,a&48){case 0:r.srPhase=0;break;case 16:r.srPhase=.25*c;break;case 32:r.srPhase=.5*c;break;case 48:r.srPhase=.75*c;break;default:throw new Error("invalid SROUND value")}a&=15,a===0?r.srThreshold=0:r.srThreshold=(a/8-.5)*c}function Ym(r){let a=r.stack.pop();r.round=qc;let c;switch(a&192){case 0:c=Math.sqrt(2)/2;break;case 64:c=Math.sqrt(2);break;case 128:c=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(r.srPeriod=c,a&48){case 0:r.srPhase=0;break;case 16:r.srPhase=.25*c;break;case 32:r.srPhase=.5*c;break;case 48:r.srPhase=.75*c;break;default:throw new Error("invalid S45ROUND value")}a&=15,a===0?r.srThreshold=0:r.srThreshold=(a/8-.5)*c}function Km(r){r.round=Rg}function Zm(r){r.round=Lg}function Qm(r){r.round=Fg}function Jm(r){let a=r.stack.pop()}function gu(r,a){let c=a.stack,h=c.pop(),f=c.pop(),g=a.z2[h],y=a.z1[f],S,T;r?(S=g.y-y.y,T=y.x-g.x):(S=y.x-g.x,T=y.y-g.y),a.dpv=Ar(S,T)}function qm(r){let a=r.stack,c=a.pop(),h=0;c&1&&(h=35),c&32&&(h|=4096),a.push(h)}function t0(r){let a=r.stack,c=a.pop(),h=a.pop(),f=a.pop();a.push(h),a.push(c),a.push(f)}function e0(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(Math.max(h,c))}function n0(r){let a=r.stack,c=a.pop(),h=a.pop();a.push(Math.min(h,c))}function r0(r){let a=r.stack.pop()}function s0(r){let a=r.stack.pop(),c=r.stack.pop();switch(a){case 1:r.inhibitGridFit=!!c;return;case 2:r.ignoreCvt=!!c;return;default:throw new Error("invalid INSTCTRL[] selector")}}function cn(r,a){let c=a.stack,h=a.prog,f=a.ip;for(let g=0;g<r;g++)c.push(h[++f]);a.ip=f}function un(r,a){let c=a.ip,h=a.prog,f=a.stack;for(let g=0;g<r;g++){let y=h[++c]<<8|h[++c];y&32768&&(y=-((y^65535)+1)),f.push(y)}a.ip=c}function bt(r,a,c,h,f,g){let y=g.stack,S=r&&y.pop(),T=y.pop(),C=g.rp0,E=g.z0[C],O=g.z1[T],R=g.minDis,F=g.fv,L=g.dpv,B,Y,yt,mt;Y=B=L.distance(O,E,!0,!0),yt=Y>=0?1:-1,Y=Math.abs(Y),r&&(mt=g.cvt[S],h&&Math.abs(Y-mt)<g.cvCutIn&&(Y=mt)),c&&Y<R&&(Y=R),h&&(Y=g.round(Y)),F.setRelative(O,E,yt*Y,L),F.touch(O),g.rp1=g.rp0,g.rp2=T,a&&(g.rp0=T)}Kc=[eu.bind(void 0,en),eu.bind(void 0,Ye),nu.bind(void 0,en),nu.bind(void 0,Ye),ru.bind(void 0,en),ru.bind(void 0,Ye),su.bind(void 0,0),su.bind(void 0,1),iu.bind(void 0,0),iu.bind(void 0,1),_g,Ng,Ug,Bg,Gg,Hg,jg,Vg,Wg,$g,zg,Xg,Yg,Kg,Zg,Qg,Jg,qg,tm,em,void 0,void 0,nm,bo,rm,sm,im,lm,cm,void 0,void 0,void 0,om,am,um,void 0,ou.bind(void 0,0),ou.bind(void 0,1),au.bind(void 0,en),au.bind(void 0,Ye),lu.bind(void 0,0),lu.bind(void 0,1),cu.bind(void 0,0),cu.bind(void 0,1),uu.bind(void 0,0),uu.bind(void 0,1),hm,dm,hu.bind(void 0,0),hu.bind(void 0,1),fm,pm,du.bind(void 0,0),du.bind(void 0,1),gm,mm,bm,ym,vm,xm,fu.bind(void 0,0),fu.bind(void 0,1),void 0,pu.bind(void 0,0),pu.bind(void 0,1),Sm,void 0,Am,void 0,void 0,Tm,wm,Em,Cm,km,Im,Pm,Rm,Om,Mm,Lm,Fm,Dm,yo.bind(void 0,1),_m,Nm,Um,Bm,Gm,Hm,jm,Vm,Wm,$m,As.bind(void 0,0),As.bind(void 0,1),As.bind(void 0,2),As.bind(void 0,3),void 0,void 0,void 0,void 0,zm,yo.bind(void 0,2),yo.bind(void 0,3),vo.bind(void 0,1),vo.bind(void 0,2),vo.bind(void 0,3),Xm,Ym,void 0,void 0,Km,void 0,Zm,Qm,bo,bo,void 0,void 0,void 0,void 0,void 0,Jm,gu.bind(void 0,0),gu.bind(void 0,1),qm,void 0,t0,e0,n0,r0,s0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,cn.bind(void 0,1),cn.bind(void 0,2),cn.bind(void 0,3),cn.bind(void 0,4),cn.bind(void 0,5),cn.bind(void 0,6),cn.bind(void 0,7),cn.bind(void 0,8),un.bind(void 0,1),un.bind(void 0,2),un.bind(void 0,3),un.bind(void 0,4),un.bind(void 0,5),un.bind(void 0,6),un.bind(void 0,7),un.bind(void 0,8),bt.bind(void 0,0,0,0,0,0),bt.bind(void 0,0,0,0,0,1),bt.bind(void 0,0,0,0,0,2),bt.bind(void 0,0,0,0,0,3),bt.bind(void 0,0,0,0,1,0),bt.bind(void 0,0,0,0,1,1),bt.bind(void 0,0,0,0,1,2),bt.bind(void 0,0,0,0,1,3),bt.bind(void 0,0,0,1,0,0),bt.bind(void 0,0,0,1,0,1),bt.bind(void 0,0,0,1,0,2),bt.bind(void 0,0,0,1,0,3),bt.bind(void 0,0,0,1,1,0),bt.bind(void 0,0,0,1,1,1),bt.bind(void 0,0,0,1,1,2),bt.bind(void 0,0,0,1,1,3),bt.bind(void 0,0,1,0,0,0),bt.bind(void 0,0,1,0,0,1),bt.bind(void 0,0,1,0,0,2),bt.bind(void 0,0,1,0,0,3),bt.bind(void 0,0,1,0,1,0),bt.bind(void 0,0,1,0,1,1),bt.bind(void 0,0,1,0,1,2),bt.bind(void 0,0,1,0,1,3),bt.bind(void 0,0,1,1,0,0),bt.bind(void 0,0,1,1,0,1),bt.bind(void 0,0,1,1,0,2),bt.bind(void 0,0,1,1,0,3),bt.bind(void 0,0,1,1,1,0),bt.bind(void 0,0,1,1,1,1),bt.bind(void 0,0,1,1,1,2),bt.bind(void 0,0,1,1,1,3),bt.bind(void 0,1,0,0,0,0),bt.bind(void 0,1,0,0,0,1),bt.bind(void 0,1,0,0,0,2),bt.bind(void 0,1,0,0,0,3),bt.bind(void 0,1,0,0,1,0),bt.bind(void 0,1,0,0,1,1),bt.bind(void 0,1,0,0,1,2),bt.bind(void 0,1,0,0,1,3),bt.bind(void 0,1,0,1,0,0),bt.bind(void 0,1,0,1,0,1),bt.bind(void 0,1,0,1,0,2),bt.bind(void 0,1,0,1,0,3),bt.bind(void 0,1,0,1,1,0),bt.bind(void 0,1,0,1,1,1),bt.bind(void 0,1,0,1,1,2),bt.bind(void 0,1,0,1,1,3),bt.bind(void 0,1,1,0,0,0),bt.bind(void 0,1,1,0,0,1),bt.bind(void 0,1,1,0,0,2),bt.bind(void 0,1,1,0,0,3),bt.bind(void 0,1,1,0,1,0),bt.bind(void 0,1,1,0,1,1),bt.bind(void 0,1,1,0,1,2),bt.bind(void 0,1,1,0,1,3),bt.bind(void 0,1,1,1,0,0),bt.bind(void 0,1,1,1,0,1),bt.bind(void 0,1,1,1,0,2),bt.bind(void 0,1,1,1,0,3),bt.bind(void 0,1,1,1,1,0),bt.bind(void 0,1,1,1,1,1),bt.bind(void 0,1,1,1,1,2),bt.bind(void 0,1,1,1,1,3)];var i0=Qc;function Jn(r){this.char=r,this.state={},this.activeState=null}function xo(r,a,c){this.contextName=c,this.startIndex=r,this.endOffset=a}function o0(r,a,c){this.contextName=r,this.openRange=null,this.ranges=[],this.checkStart=a,this.checkEnd=c}function de(r,a){this.context=r,this.index=a,this.length=r.length,this.current=r[a],this.backtrack=r.slice(0,a),this.lookahead=r.slice(a+1)}function Ts(r){this.eventId=r,this.subscribers=[]}function a0(r){let a=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];for(let h=0;h<a.length;h++){let f=a[h];Object.defineProperty(this.events,f,{value:new Ts(f)})}if(r)for(let h=0;h<a.length;h++){let f=a[h],g=r[f];typeof g=="function"&&this.events[f].subscribe(g)}let c=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];for(let h=0;h<c.length;h++){let f=c[h];this.events[f].subscribe(this.updateContextsRanges)}}function Kt(r){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],a0.call(this,r)}Jn.prototype.setState=function(r,a){return this.state[r]=a,this.activeState={key:r,value:this.state[r]},this.activeState},Jn.prototype.getState=function(r){return this.state[r]||null},Kt.prototype.inboundIndex=function(r){return r>=0&&r<this.tokens.length},Kt.prototype.composeRUD=function(r){let c=r.map(f=>this[f[0]].apply(this,f.slice(1).concat(!0))),h=f=>typeof f=="object"&&Object.prototype.hasOwnProperty.call(f,"FAIL");if(c.every(h))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:c.filter(h)};this.dispatch("composeRUD",[c.filter(f=>!h(f))])},Kt.prototype.replaceRange=function(r,a,c,h){a=a!==null?a:this.tokens.length;let f=c.every(g=>g instanceof Jn);if(!isNaN(r)&&this.inboundIndex(r)&&f){let g=this.tokens.splice.apply(this.tokens,[r,a].concat(c));return h||this.dispatch("replaceToken",[r,a,c]),[g,c]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},Kt.prototype.replaceToken=function(r,a,c){if(!isNaN(r)&&this.inboundIndex(r)&&a instanceof Jn){let h=this.tokens.splice(r,1,a);return c||this.dispatch("replaceToken",[r,a]),[h[0],a]}else return{FAIL:"replaceToken: invalid token or index."}},Kt.prototype.removeRange=function(r,a,c){a=isNaN(a)?this.tokens.length:a;let h=this.tokens.splice(r,a);return c||this.dispatch("removeRange",[h,r,a]),h},Kt.prototype.removeToken=function(r,a){if(!isNaN(r)&&this.inboundIndex(r)){let c=this.tokens.splice(r,1);return a||this.dispatch("removeToken",[c,r]),c}else return{FAIL:"removeToken: invalid token index."}},Kt.prototype.insertToken=function(r,a,c){return r.every(f=>f instanceof Jn)?(this.tokens.splice.apply(this.tokens,[a,0].concat(r)),c||this.dispatch("insertToken",[r,a]),r):{FAIL:"insertToken: invalid token(s)."}},Kt.prototype.registerModifier=function(r,a,c){this.events.newToken.subscribe(function(h,f){let g=[h,f],y=a===null||a.apply(this,g)===!0,S=[h,f];if(y){let T=c.apply(this,S);h.setState(r,T)}}),this.registeredModifiers.push(r)},Ts.prototype.subscribe=function(r){return typeof r=="function"?this.subscribers.push(r)-1:{FAIL:`invalid '${this.eventId}' event handler`}},Ts.prototype.unsubscribe=function(r){this.subscribers.splice(r,1)},de.prototype.setCurrentIndex=function(r){this.index=r,this.current=this.context[r],this.backtrack=this.context.slice(0,r),this.lookahead=this.context.slice(r+1)},de.prototype.get=function(r){switch(!0){case r===0:return this.current;case(r<0&&Math.abs(r)<=this.backtrack.length):return this.backtrack.slice(r)[0];case(r>0&&r<=this.lookahead.length):return this.lookahead[r-1];default:return null}},Kt.prototype.rangeToText=function(r){if(r instanceof xo)return this.getRangeTokens(r).map(a=>a.char).join("")},Kt.prototype.getText=function(){return this.tokens.map(r=>r.char).join("")},Kt.prototype.getContext=function(r){let a=this.registeredContexts[r];return a||null},Kt.prototype.on=function(r,a){let c=this.events[r];return c?c.subscribe(a):null},Kt.prototype.dispatch=function(r,a){let c=this.events[r];if(c instanceof Ts)for(let h=0;h<c.subscribers.length;h++)c.subscribers[h].apply(this,a||[])},Kt.prototype.registerContextChecker=function(r,a,c){if(this.getContext(r))return{FAIL:`context name '${r}' is already registered.`};if(typeof a!="function")return{FAIL:"missing context start check."};if(typeof c!="function")return{FAIL:"missing context end check."};let h=new o0(r,a,c);return this.registeredContexts[r]=h,this.contextCheckers.push(h),h},Kt.prototype.getRangeTokens=function(r){let a=r.startIndex+r.endOffset;return[].concat(this.tokens.slice(r.startIndex,a))},Kt.prototype.getContextRanges=function(r){let a=this.getContext(r);return a?a.ranges:{FAIL:`context checker '${r}' is not registered.`}},Kt.prototype.resetContextsRanges=function(){let r=this.registeredContexts;for(let a in r)if(Object.prototype.hasOwnProperty.call(r,a)){let c=r[a];c.ranges=[]}},Kt.prototype.updateContextsRanges=function(){this.resetContextsRanges();let r=this.tokens.map(a=>a.char);for(let a=0;a<r.length;a++){let c=new de(r,a);this.runContextCheck(c)}this.dispatch("updateContextsRanges",[this.registeredContexts])},Kt.prototype.setEndOffset=function(r,a){let c=this.getContext(a).openRange.startIndex,h=new xo(c,r,a),f=this.getContext(a).ranges;return h.rangeId=`${a}.${f.length}`,f.push(h),this.getContext(a).openRange=null,h},Kt.prototype.runContextCheck=function(r){let a=r.index;for(let c=0;c<this.contextCheckers.length;c++){let h=this.contextCheckers[c],f=h.contextName,g=this.getContext(f).openRange;if(!g&&h.checkStart(r)&&(g=new xo(a,null,f),this.getContext(f).openRange=g,this.dispatch("contextStart",[f,a])),g&&h.checkEnd(r)){let y=a-g.startIndex+1,S=this.setEndOffset(y,f);this.dispatch("contextEnd",[f,S])}}},Kt.prototype.tokenize=function(r){this.tokens=[],this.resetContextsRanges();let a=Array.from(r);this.dispatch("start");for(let c=0;c<a.length;c++){let h=a[c],f=new de(a,c);this.dispatch("next",[f]),this.runContextCheck(f);let g=new Jn(h);this.tokens.push(g),this.dispatch("newToken",[g,f])}return this.dispatch("end",[this.tokens]),this.tokens};var l0=Kt;function hn(r){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(r)}function mu(r){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(r)}function dn(r){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(r)}function ws(r){return/[\u0E00-\u0E7F]/.test(r)}function Es(r){return/[A-z]/.test(r)}function c0(r){return/\s/.test(r)}function we(r){this.font=r,this.features={}}function fn(r){this.id=r.id,this.tag=r.tag,this.substitution=r.substitution}function pn(r,a){if(!r)return-1;switch(a.format){case 1:return a.glyphs.indexOf(r);case 2:{let c=a.ranges;for(let h=0;h<c.length;h++){let f=c[h];if(r>=f.start&&r<=f.end){let g=r-f.start;return f.index+g}}break}default:return-1}return-1}function u0(r,a){return pn(r,a.coverage)===-1?null:r+a.deltaGlyphId}function h0(r,a){let c=pn(r,a.coverage);return c===-1?null:a.substitute[c]}function So(r,a){let c=[];for(let h=0;h<r.length;h++){let f=r[h],g=a.current;g=Array.isArray(g)?g[0]:g;let y=pn(g,f);y!==-1&&c.push(y)}return c.length!==r.length?-1:c}function d0(r,a){let c=a.inputCoverage.length+a.lookaheadCoverage.length+a.backtrackCoverage.length;if(r.context.length<c)return[];let h=So(a.inputCoverage,r);if(h===-1)return[];let f=a.inputCoverage.length-1;if(r.lookahead.length<a.lookaheadCoverage.length)return[];let g=r.lookahead.slice(f);for(;g.length&&dn(g[0].char);)g.shift();let y=new de(g,0),S=So(a.lookaheadCoverage,y),T=[].concat(r.backtrack);for(T.reverse();T.length&&dn(T[0].char);)T.shift();if(T.length<a.backtrackCoverage.length)return[];let C=new de(T,0),E=So(a.backtrackCoverage,C),O=h.length===a.inputCoverage.length&&S.length===a.lookaheadCoverage.length&&E.length===a.backtrackCoverage.length,R=[];if(O)for(let F=0;F<a.lookupRecords.length;F++){let L=a.lookupRecords[F],B=L.lookupListIndex,Y=this.getLookupByIndex(B);for(let yt=0;yt<Y.subtables.length;yt++){let mt=Y.subtables[yt],At,Rt=this.getSubstitutionType(Y,mt);if(Rt==="71"?(Rt=this.getSubstitutionType(mt,mt.extension),At=this.getLookupMethod(mt,mt.extension),mt=mt.extension):At=this.getLookupMethod(Y,mt),Rt==="12"){let Nt=r.get(L.sequenceIndex),Gt=At(Nt);Gt&&R.push(Gt)}else if(Rt==="21"){let Nt=r.get(L.sequenceIndex),Gt=At(Nt);Gt&&R.push(Gt)}else throw new Error(`Substitution type ${Rt} is not supported in chaining substitution`)}}return R}function f0(r,a){let c=r.current,h=pn(c,a.coverage);if(h===-1)return null;let f,g=a.ligatureSets[h];for(let y=0;y<g.length;y++){f=g[y];for(let S=0;S<f.components.length;S++){let T=r.lookahead[S],C=f.components[S];if(T!==C)break;if(S===f.components.length-1)return f}}return null}function p0(r,a){let c=r.current;if(pn(c,a.coverage)===-1)return null;for(let f of a.ruleSets)for(let g of f){let y=!0;for(let S=0;S<g.input.length;S++)if(r.lookahead[S]!==g.input[S]){y=!1;break}if(y){let S=[];S.push(c);for(let C=0;C<g.input.length;C++)S.push(g.input[C]);let T=(C,E)=>{let{lookupListIndex:O,sequenceIndex:R}=E,{subtables:F}=this.getLookupByIndex(O);for(let L of F)pn(C[R],L.coverage)!==-1&&(C[R]=L.deltaGlyphId)};for(let C=0;C<g.lookupRecords.length;C++){let E=g.lookupRecords[C];T(S,E)}return S}}return null}function g0(r,a){if(r.context.length<a.coverages.length)return[];for(let h=0;h<a.coverages.length;h++){let f=r.get(h);if(f=Array.isArray(f)?f[0]:f,pn(f,a.coverages[h])===-1)return[]}let c=[];for(let h=0;h<a.lookupRecords.length;h++){let f=a.lookupRecords[h],g=f.lookupListIndex,y=this.getLookupByIndex(g);for(let S=0;S<y.subtables.length;S++){let T=y.subtables[S],C,E=this.getSubstitutionType(y,T);if(E==="71"?(E=this.getSubstitutionType(T,T.extension),C=this.getLookupMethod(T,T.extension),T=T.extension):C=this.getLookupMethod(y,T),E==="12"){let O=r.get(f.sequenceIndex),R=C(O);R&&c.push(R)}else if(E==="21"){let O=r.get(f.sequenceIndex),R=C(O);R&&c.push(R)}}}return c}function m0(r,a){let c=pn(r,a.coverage);return c===-1?null:a.sequences[c]}we.prototype.getDefaultScriptFeaturesIndexes=function(){let r=this.font.tables.gsub.scripts;for(let a=0;a<r.length;a++){let c=r[a];if(c.tag==="DFLT")return c.script.defaultLangSys.featureIndexes}return[]},we.prototype.getScriptFeaturesIndexes=function(r){if(!this.font.tables.gsub)return[];if(!r)return this.getDefaultScriptFeaturesIndexes();let c=this.font.tables.gsub.scripts;for(let h=0;h<c.length;h++){let f=c[h];if(f.tag===r&&f.script.defaultLangSys)return f.script.defaultLangSys.featureIndexes;{let g=f.langSysRecords;if(g)for(let y=0;y<g.length;y++){let S=g[y];if(S.tag===r)return S.langSys.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},we.prototype.mapTagsToFeatures=function(r,a){let c={};for(let h=0;h<r.length;h++){let f=r[h].tag,g=r[h].feature;c[f]=g}this.features[a].tags=c},we.prototype.getScriptFeatures=function(r){let a=this.features[r];if(Object.prototype.hasOwnProperty.call(this.features,r))return a;let c=this.getScriptFeaturesIndexes(r);if(!c)return null;let h=this.font.tables.gsub;return a=c.map(f=>h.features[f]),this.features[r]=a,this.mapTagsToFeatures(a,r),a},we.prototype.getSubstitutionType=function(r,a){let c=r.lookupType.toString(),h=a.substFormat.toString();return c+h},we.prototype.getLookupMethod=function(r,a){let c=this.getSubstitutionType(r,a);switch(c){case"11":return h=>u0.apply(this,[h,a]);case"12":return h=>h0.apply(this,[h,a]);case"63":return h=>d0.apply(this,[h,a]);case"41":return h=>f0.apply(this,[h,a]);case"21":return h=>m0.apply(this,[h,a]);case"51":return h=>p0.apply(this,[h,a]);case"53":return h=>g0.apply(this,[h,a]);default:throw new Error(`substitutionType : ${c} lookupType: ${r.lookupType} - substFormat: ${a.substFormat} is not yet supported`)}},we.prototype.lookupFeature=function(r){let a=r.contextParams,c=a.index,h=this.getFeature({tag:r.tag,script:r.script});if(!h)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${r.tag}' for script '${r.script}'.`);let f=this.getFeatureLookups(h),g=[].concat(a.context);for(let y=0;y<f.length;y++){let S=f[y],T=this.getLookupSubtables(S);for(let C=0;C<T.length;C++){let E=T[C],O=this.getSubstitutionType(S,E),R;O==="71"?(O=this.getSubstitutionType(E,E.extension),R=this.getLookupMethod(E,E.extension),E=E.extension):R=this.getLookupMethod(S,E);let F;switch(O){case"11":F=R(a.current),F&&g.splice(c,1,new fn({id:11,tag:r.tag,substitution:F}));break;case"12":F=R(a.current),F&&g.splice(c,1,new fn({id:12,tag:r.tag,substitution:F}));break;case"63":F=R(a),Array.isArray(F)&&F.length&&g.splice(c,1,new fn({id:63,tag:r.tag,substitution:F}));break;case"41":F=R(a),F&&g.splice(c,1,new fn({id:41,tag:r.tag,substitution:F}));break;case"21":F=R(a.current),F&&g.splice(c,1,new fn({id:21,tag:r.tag,substitution:F}));break;case"51":case"53":F=R(a),Array.isArray(F)&&F.length&&g.splice(c,1,new fn({id:parseInt(O),tag:r.tag,substitution:F}));break}a=new de(g,c),!(Array.isArray(F)&&!F.length)&&(F=null)}}return g.length?g:null},we.prototype.supports=function(r){if(!r.script)return!1;this.getScriptFeatures(r.script);let a=Object.prototype.hasOwnProperty.call(this.features,r.script);if(!r.tag)return a;let c=this.features[r.script].some(h=>h.tag===r.tag);return a&&c},we.prototype.getLookupSubtables=function(r){return r.subtables||null},we.prototype.getLookupByIndex=function(r){return this.font.tables.gsub.lookups[r]||null},we.prototype.getFeatureLookups=function(r){return r.lookupListIndexes.map(this.getLookupByIndex.bind(this))},we.prototype.getFeature=function(a){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,a.script)||this.getScriptFeatures(a.script);let c=this.features[a.script];return c?c.tags[a.tag]?this.features[a.script].tags[a.tag]:null:{FAIL:`No feature for script ${a.script}`}};var b0=we;function y0(r){let a=r.current,c=r.get(-1);return c===null&&hn(a)||!hn(c)&&hn(a)}function v0(r){let a=r.get(1);return a===null||!hn(a)}var x0={startCheck:y0,endCheck:v0};function S0(r){let a=r.current,c=r.get(-1);return(hn(a)||dn(a))&&!hn(c)}function A0(r){let a=r.get(1);switch(!0){case a===null:return!0;case(!hn(a)&&!dn(a)):{let c=c0(a);if(!c)return!0;if(c){let h=!1;if(h=r.lookahead.some(f=>hn(f)||dn(f)),!h)return!0}break}default:return!1}}var T0={startCheck:S0,endCheck:A0};function w0(r,a,c){a[c].setState(r.tag,r.substitution)}function E0(r,a,c){a[c].setState(r.tag,r.substitution)}function Ao(r,a,c){for(let h=0;h<r.substitution.length;h++){let f=r.substitution[h],g=a[c+h];if(Array.isArray(f)){f.length?g.setState(r.tag,f[0]):g.setState("deleted",!0);continue}g.setState(r.tag,f)}}function C0(r,a,c){let h=a[c];h.setState(r.tag,r.substitution.ligGlyph);let f=r.substitution.components.length;for(let g=0;g<f;g++)h=a[c+g+1],h.setState("deleted",!0)}var bu={11:w0,12:E0,63:Ao,41:C0,51:Ao,53:Ao};function k0(r,a,c){r instanceof fn&&bu[r.id]&&bu[r.id](r,a,c)}var On=k0;function I0(r){let a=[].concat(r.backtrack);for(let c=a.length-1;c>=0;c--){let h=a[c],f=mu(h),g=dn(h);if(!f&&!g)return!0;if(f)return!1}return!1}function P0(r){if(mu(r.current))return!1;for(let a=0;a<r.lookahead.length;a++){let c=r.lookahead[a];if(!dn(c))return!0}return!1}function R0(r){let a="arab",c=this.featuresTags[a],h=this.tokenizer.getRangeTokens(r);if(h.length===1)return;let f=new de(h.map(y=>y.getState("glyphIndex")),0),g=new de(h.map(y=>y.char),0);for(let y=0;y<h.length;y++){let S=h[y];if(dn(S.char))continue;f.setCurrentIndex(y),g.setCurrentIndex(y);let T=0;I0(g)&&(T|=1),P0(g)&&(T|=2);let C;switch(T){case 1:C="fina";break;case 2:C="init";break;case 3:C="medi";break}if(c.indexOf(C)===-1)continue;let E=this.query.lookupFeature({tag:C,script:a,contextParams:f});if(E instanceof Error){console.info(E.message);continue}for(let O=0;O<E.length;O++){let R=E[O];R instanceof fn&&(On(R,h,O),f.context[O]=R.substitution)}}}var O0=R0;function yu(r,a){let c=r.map(h=>h.activeState.value);return new de(c,a||0)}function M0(r){let a="arab",c=this.tokenizer.getRangeTokens(r),h=yu(c);for(let f=0;f<h.context.length;f++){h.setCurrentIndex(f);let g=this.query.lookupFeature({tag:"rlig",script:a,contextParams:h});if(g.length){for(let y=0;y<g.length;y++){let S=g[y];On(S,c,f)}h=yu(c)}}}var L0=M0;function F0(r){return r.index===0&&r.context.length>1}function D0(r){return r.index===r.context.length-1}var _0={startCheck:F0,endCheck:D0};function vu(r,a){let c=r.map(h=>h.activeState.value);return new de(c,a||0)}function N0(r){let a="delf",c="ccmp",h=this.tokenizer.getRangeTokens(r),f=vu(h);for(let g=0;g<f.context.length;g++){if(!this.query.getFeature({tag:c,script:a,contextParams:f}))continue;f.setCurrentIndex(g);let y=this.query.lookupFeature({tag:c,script:a,contextParams:f});if(y.length){for(let S=0;S<y.length;S++){let T=y[S];On(T,h,g)}f=vu(h)}}}var U0=N0;function B0(r){let a=r.current,c=r.get(-1);return c===null&&Es(a)||!Es(c)&&Es(a)}function G0(r){let a=r.get(1);return a===null||!Es(a)}var H0={startCheck:B0,endCheck:G0};function xu(r,a){let c=r.map(h=>h.activeState.value);return new de(c,a||0)}function j0(r){let a="latn",c=this.tokenizer.getRangeTokens(r),h=xu(c);for(let f=0;f<h.context.length;f++){h.setCurrentIndex(f);let g=this.query.lookupFeature({tag:"liga",script:a,contextParams:h});if(g.length){for(let y=0;y<g.length;y++){let S=g[y];On(S,c,f)}h=xu(c)}}}var V0=j0;function W0(r){let a=r.current,c=r.get(-1);return c===null&&ws(a)||!ws(c)&&ws(a)}function $0(r){let a=r.get(1);return a===null||!ws(a)}var z0={startCheck:W0,endCheck:$0};function Su(r,a){let c=r.map(h=>h.activeState.value);return new de(c,a||0)}function X0(r){let a="thai",c=this.tokenizer.getRangeTokens(r),h=Su(c,0);for(let f=0;f<h.context.length;f++){h.setCurrentIndex(f);let g=this.query.lookupFeature({tag:"ccmp",script:a,contextParams:h});if(g.length){for(let y=0;y<g.length;y++){let S=g[y];On(S,c,f)}h=Su(c,f)}}}var Y0=X0;function Au(r,a){let c=r.map(h=>h.activeState.value);return new de(c,a||0)}function K0(r){let a="thai",c=this.tokenizer.getRangeTokens(r),h=Au(c,0);for(let f=0;f<h.context.length;f++){h.setCurrentIndex(f);let g=this.query.lookupFeature({tag:"liga",script:a,contextParams:h});if(g.length){for(let y=0;y<g.length;y++){let S=g[y];On(S,c,f)}h=Au(c,f)}}}var Z0=K0;function Tu(r,a){let c=r.map(h=>h.activeState.value);return new de(c,a||0)}function Q0(r){let a="thai",c=this.tokenizer.getRangeTokens(r),h=Tu(c,0);for(let f=0;f<h.context.length;f++){h.setCurrentIndex(f);let g=this.query.lookupFeature({tag:"rlig",script:a,contextParams:h});if(g.length){for(let y=0;y<g.length;y++){let S=g[y];On(S,c,f)}h=Tu(c,f)}}}var J0=Q0;function To(r){if(r===null)return!1;let a=r.codePointAt(0);return a>=6155&&a<=6157||a>=65024&&a<=65039||a>=917760&&a<=917999}function q0(r){let a=r.current,c=r.get(1);return c===null&&To(a)||To(c)}function tb(r){let a=r.get(1);return a===null||!To(a)}var eb={startCheck:q0,endCheck:tb};function nb(r){let a=this.query.font,c=this.tokenizer.getRangeTokens(r);if(c[1].setState("deleted",!0),a.tables.cmap&&a.tables.cmap.varSelectorList){let h=c[0].char.codePointAt(0),f=c[1].char.codePointAt(0),g=a.tables.cmap.varSelectorList[f];if(g!==void 0&&g.nonDefaultUVS){let y=g.nonDefaultUVS.uvsMappings;if(y[h]){let S=y[h].glyphID;a.glyphs.glyphs[S]!==void 0&&c[0].setState("glyphIndex",S)}}}}var rb=nb;function Re(r){this.baseDir=r||"ltr",this.tokenizer=new l0,this.featuresTags={}}Re.prototype.setText=function(r){this.text=r},Re.prototype.contextChecks={ccmpReplacementCheck:_0,latinWordCheck:H0,arabicWordCheck:x0,arabicSentenceCheck:T0,thaiWordCheck:z0,unicodeVariationSequenceCheck:eb};function qn(r){let a=this.contextChecks[`${r}Check`];return this.tokenizer.registerContextChecker(r,a.startCheck,a.endCheck)}function sb(){return qn.call(this,"ccmpReplacement"),qn.call(this,"latinWord"),qn.call(this,"arabicWord"),qn.call(this,"arabicSentence"),qn.call(this,"thaiWord"),qn.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function ib(){let r=this.tokenizer.getContextRanges("arabicSentence");for(let a=0;a<r.length;a++){let c=r[a],h=this.tokenizer.getRangeTokens(c);this.tokenizer.replaceRange(c.startIndex,c.endOffset,h.reverse())}}Re.prototype.registerFeatures=function(r,a){let c=a.filter(h=>this.query.supports({script:r,tag:h}));Object.prototype.hasOwnProperty.call(this.featuresTags,r)?this.featuresTags[r]=this.featuresTags[r].concat(c):this.featuresTags[r]=c},Re.prototype.applyFeatures=function(r,a){if(!r)throw new Error("No valid font was provided to apply features");this.query||(this.query=new b0(r));for(let c=0;c<a.length;c++){let h=a[c];this.query.supports({script:h.script})&&this.registerFeatures(h.script,h.tags)}},Re.prototype.registerModifier=function(r,a,c){this.tokenizer.registerModifier(r,a,c)};function wr(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function ob(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,"arab"))return;wr.call(this);let a=this.tokenizer.getContextRanges("arabicWord");for(let c=0;c<a.length;c++){let h=a[c];O0.call(this,h)}}function ab(){wr.call(this);let r=this.tokenizer.getContextRanges("ccmpReplacement");for(let a=0;a<r.length;a++){let c=r[a];U0.call(this,c)}}function lb(){if(!this.hasFeatureEnabled("arab","rlig"))return;wr.call(this);let r=this.tokenizer.getContextRanges("arabicWord");for(let a=0;a<r.length;a++){let c=r[a];L0.call(this,c)}}function cb(){if(!this.hasFeatureEnabled("latn","liga"))return;wr.call(this);let r=this.tokenizer.getContextRanges("latinWord");for(let a=0;a<r.length;a++){let c=r[a];V0.call(this,c)}}function ub(){let r=this.tokenizer.getContextRanges("unicodeVariationSequence");for(let a=0;a<r.length;a++){let c=r[a];rb.call(this,c)}}function hb(){wr.call(this);let r=this.tokenizer.getContextRanges("thaiWord");for(let a=0;a<r.length;a++){let c=r[a];this.hasFeatureEnabled("thai","liga")&&Z0.call(this,c),this.hasFeatureEnabled("thai","rlig")&&J0.call(this,c),this.hasFeatureEnabled("thai","ccmp")&&Y0.call(this,c)}}Re.prototype.checkContextReady=function(r){return!!this.tokenizer.getContext(r)},Re.prototype.applyFeaturesToContexts=function(){this.checkContextReady("ccmpReplacement")&&ab.call(this),this.checkContextReady("arabicWord")&&(ob.call(this),lb.call(this)),this.checkContextReady("latinWord")&&cb.call(this),this.checkContextReady("arabicSentence")&&ib.call(this),this.checkContextReady("thaiWord")&&hb.call(this),this.checkContextReady("unicodeVariationSequence")&&ub.call(this)},Re.prototype.hasFeatureEnabled=function(r,a){return(this.featuresTags[r]||[]).indexOf(a)!==-1},Re.prototype.processText=function(r){(!this.text||this.text!==r)&&(this.setText(r),sb.call(this),this.applyFeaturesToContexts())},Re.prototype.getBidiText=function(r){return this.processText(r),this.tokenizer.getText()},Re.prototype.getTextGlyphs=function(r){this.processText(r);let a=[];for(let c=0;c<this.tokenizer.tokens.length;c++){let h=this.tokenizer.tokens[c];if(h.state.deleted)continue;let f=h.activeState.value;a.push(Array.isArray(f)?f[0]:f)}return a};var db=Re;function wo(r){return{fontFamily:{en:r.familyName||" "},fontSubfamily:{en:r.styleName||" "},fullName:{en:r.fullName||r.familyName+" "+r.styleName},postScriptName:{en:r.postScriptName||(r.familyName+r.styleName).replace(/\s/g,"")},designer:{en:r.designer||" "},designerURL:{en:r.designerURL||" "},manufacturer:{en:r.manufacturer||" "},manufacturerURL:{en:r.manufacturerURL||" "},license:{en:r.license||" "},licenseURL:{en:r.licenseURL||" "},version:{en:r.version||"Version 0.1"},description:{en:r.description||" "},copyright:{en:r.copyright||" "},trademark:{en:r.trademark||" "}}}function Bt(r){if(r=r||{},r.tables=r.tables||{},!r.empty){if(!r.familyName)throw new Error("When creating a new Font object, familyName is required.");if(!r.styleName)throw new Error("When creating a new Font object, styleName is required.");if(!r.unitsPerEm)throw new Error("When creating a new Font object, unitsPerEm is required.");if(!r.ascender)throw new Error("When creating a new Font object, ascender is required.");if(r.descender>0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=wo(r),this.names.macintosh=wo(r),this.names.windows=wo(r),this.unitsPerEm=r.unitsPerEm||1e3,this.ascender=r.ascender,this.descender=r.descender,this.createdTimestamp=r.createdTimestamp,this.italicAngle=r.italicAngle||0,this.weightClass=r.weightClass||0;let a=0;r.fsSelection?a=r.fsSelection:(this.italicAngle<0?a|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(a|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(a|=this.fsSelectionValues.BOLD),a===0&&(a=this.fsSelectionValues.REGULAR)),(!r.panose||!Array.isArray(r.panose))&&(r.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(r.tables,{os2:Object.assign({usWeightClass:r.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:r.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:r.panose[0]||0,bSerifStyle:r.panose[1]||0,bWeight:r.panose[2]||0,bProportion:r.panose[3]||0,bContrast:r.panose[4]||0,bStrokeVariation:r.panose[5]||0,bArmStyle:r.panose[6]||0,bLetterform:r.panose[7]||0,bMidline:r.panose[8]||0,bXHeight:r.panose[9]||0,fsSelection:a},r.tables.os2)})}this.supported=!0,this.glyphs=new ze.GlyphSet(this,r.glyphs||[]),this.encoding=new tc(this),this.position=new ag(this),this.substitution=new pg(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(a,c,h)=>(a[c]=h,a.fvar&&(a.gvar||a.cff2)&&!this.variation&&(this.variation=new Pg(this)),!0)}),this.palettes=new Vc(this),this.layers=new gg(this),this.svgImages=new mg(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new i0(this):null}})}Bt.prototype.hasChar=function(r){return this.encoding.charToGlyphIndex(r)>0},Bt.prototype.charToGlyphIndex=function(r){return this.encoding.charToGlyphIndex(r)},Bt.prototype.charToGlyph=function(r){let a=this.charToGlyphIndex(r),c=this.glyphs.get(a);return c||(c=this.glyphs.get(0)),c},Bt.prototype.updateFeatures=function(r){return this.defaultRenderOptions.features.map(a=>a.script==="latn"?{script:"latn",tags:a.tags.filter(c=>r[c])}:a)},Bt.prototype.stringToGlyphIndexes=function(r,a){let c=new db,h=g=>this.charToGlyphIndex(g.char);c.registerModifier("glyphIndex",null,h);let f=a?this.updateFeatures(a.features):this.defaultRenderOptions.features;return c.applyFeatures(this,f),c.getTextGlyphs(r)},Bt.prototype.stringToGlyphs=function(r,a){let c=this.stringToGlyphIndexes(r,a),h=c.length,f=new Array(h),g=this.glyphs.get(0);for(let y=0;y<h;y+=1)f[y]=this.glyphs.get(c[y])||g;return f},Bt.prototype.nameToGlyphIndex=function(r){return this.glyphNames.nameToGlyphIndex(r)},Bt.prototype.nameToGlyph=function(r){let a=this.nameToGlyphIndex(r),c=this.glyphs.get(a);return c||(c=this.glyphs.get(0)),c},Bt.prototype.glyphIndexToName=function(r){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(r):""},Bt.prototype.getKerningValue=function(r,a){r=r.index||r,a=a.index||a;let c=this.position.defaultKerningTables;return c?this.position.getKerningValue(c,r,a):this.kerningPairs[r+","+a]||0},Bt.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]},{script:"thai",tags:["liga","rlig","ccmp"]}],hinting:!1,usePalette:0,drawLayers:!0,drawSVG:!0},Bt.prototype.forEachGlyph=function(r,a,c,h,f,g){a=a!==void 0?a:0,c=c!==void 0?c:0,h=h!==void 0?h:72,f=Object.assign({},this.defaultRenderOptions,f);let y=1/this.unitsPerEm*h,S=this.stringToGlyphs(r,f),T;if(f.kerning){let C=f.script||this.position.getDefaultScriptName();T=this.position.getKerningTables(C,f.language)}for(let C=0;C<S.length;C+=1){let E=S[C];if(g.call(this,E,a,c,h,f),E.advanceWidth&&(a+=E.advanceWidth*y),f.kerning&&C<S.length-1){let O=T?this.position.getKerningValue(T,E.index,S[C+1].index):this.getKerningValue(E,S[C+1]);a+=O*y}f.letterSpacing?a+=f.letterSpacing*h:f.tracking&&(a+=f.tracking/1e3*h)}return a},Bt.prototype.getPath=function(r,a,c,h,f){f=Object.assign({},this.defaultRenderOptions,f);let g=new Ut;if(g._layers=[],dc(this,g,h),g.stroke){let y=1/(g.unitsPerEm||1e3)*h;g.strokeWidth*=y}return this.forEachGlyph(r,a,c,h,f,(y,S,T,C)=>{let E=y.getPath(S,T,C,f,this);if(f.drawSVG||f.drawLayers){let O=E._layers;if(O&&O.length){for(let R=0;R<O.length;R++){let F=O[R];g._layers.push(F)}return}}g.extend(E)}),g},Bt.prototype.getPaths=function(r,a,c,h,f){f=Object.assign({},this.defaultRenderOptions,f);let g=[];return this.forEachGlyph(r,a,c,h,f,function(y,S,T,C){let E=y.getPath(S,T,C,f,this);g.push(E)}),g},Bt.prototype.getAdvanceWidth=function(r,a,c){return c=Object.assign({},this.defaultRenderOptions,c),this.forEachGlyph(r,0,0,a,c,function(){})},Bt.prototype.draw=function(r,a,c,h,f,g){this.getPath(a,c,h,f,g).draw(r)},Bt.prototype.drawPoints=function(r,a,c,h,f,g){g=Object.assign({},this.defaultRenderOptions,g),this.forEachGlyph(a,c,h,f,g,function(y,S,T,C){y.drawPoints(r,S,T,C,g,this)})},Bt.prototype.drawMetrics=function(r,a,c,h,f,g){g=Object.assign({},this.defaultRenderOptions,g),this.forEachGlyph(a,c,h,f,g,function(y,S,T,C){y.drawMetrics(r,S,T,C)})},Bt.prototype.getEnglishName=function(r){let a=(this.names.unicode||this.names.macintosh||this.names.windows)[r];if(a)return a.en},Bt.prototype.validate=function(){let r=[],a=this;function c(f,g){f||(console.warn(`[opentype.js] ${g}`),r.push(g))}function h(f){let g=a.getEnglishName(f);c(g&&g.trim().length>0,"No English "+f+" specified.")}if(h("fontFamily"),h("weightName"),h("manufacturer"),h("copyright"),h("version"),c(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){let f=this.tables.colr.baseGlyphRecords,g=-1;for(let y=0;y<f.length;y++){let S=f[y].glyphID;if(c(g<f[y].glyphID,`baseGlyphs must be sorted by GlyphID in ascending order, but glyphID ${S} comes after ${g}`),g>f[y].glyphID)break;g=S}}return r},Bt.prototype.toTables=function(){return og.fontToTable(this)},Bt.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},Bt.prototype.toArrayBuffer=function(){let a=this.toTables().encode(),c=new ArrayBuffer(a.length),h=new Uint8Array(c);for(let f=0;f<a.length;f++)h[f]=a[f];return c},Bt.prototype.download=function(){console.error("DEPRECATED: platform-specific actions are to be implemented on user-side")},Bt.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},Bt.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64},Bt.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},Bt.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var wu=Bt;function fb(r,a){let c=new ht.Parser(r,a),h=c.parseUShort(),f=c.parseUShort();h!==1&&console.warn(`Unsupported hvar table version ${h}.${f}`);let g=[h,f],y=c.parsePointer32(function(){return this.parseItemVariationStore()}),S=c.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),T=c.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),C=c.parsePointer32(function(){return this.parseDeltaSetIndexMap()});return{version:g,itemVariationStore:y,advanceWidth:S,lsb:T,rsb:C}}function pb(){console.warn("Writing of hvar tables is not yet supported.")}var gb={make:pb,parse:fb},mb=function(){return{coverage:this.parsePointer(j.coverage),attachPoints:this.parseList(j.pointer(j.uShortList))}},bb=function(){var r=this.parseUShort();if(V.argument(r===1||r===2||r===3,"Unsupported CaretValue table version."),r===1)return{coordinate:this.parseShort()};if(r===2)return{pointindex:this.parseShort()};if(r===3)return{coordinate:this.parseShort()}},yb=function(){return this.parseList(j.pointer(bb))},vb=function(){return{coverage:this.parsePointer(j.coverage),ligGlyphs:this.parseList(j.pointer(yb))}},xb=function(){return this.parseUShort(),this.parseList(j.pointer(j.coverage))};function Sb(r,a){a=a||0;let c=new j(r,a),h=c.parseVersion(1);V.argument(h===1||h===1.2||h===1.3,"Unsupported GDEF table version.");var f={version:h,classDef:c.parsePointer(j.classDef),attachList:c.parsePointer(mb),ligCaretList:c.parsePointer(vb),markAttachClassDef:c.parsePointer(j.classDef)};return h>=1.2&&(f.markGlyphSets=c.parsePointer(xb)),f}var Ab={parse:Sb},Ge=new Array(10);Ge[1]=function(){let a=this.offset+this.relativeOffset,c=this.parseUShort();if(c===1)return{posFormat:1,coverage:this.parsePointer(j.coverage),value:this.parseValueRecord()};if(c===2)return{posFormat:2,coverage:this.parsePointer(j.coverage),values:this.parseValueRecordList()};V.assert(!1,"0x"+a.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},Ge[2]=function(){let a=this.offset+this.relativeOffset,c=this.parseUShort();V.assert(c===1||c===2,"0x"+a.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");let h=this.parsePointer(j.coverage),f=this.parseUShort(),g=this.parseUShort();if(c===1)return{posFormat:c,coverage:h,valueFormat1:f,valueFormat2:g,pairSets:this.parseList(j.pointer(j.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(f),value2:this.parseValueRecord(g)}})))};if(c===2){let y=this.parsePointer(j.classDef),S=this.parsePointer(j.classDef),T=this.parseUShort(),C=this.parseUShort();return{posFormat:c,coverage:h,valueFormat1:f,valueFormat2:g,classDef1:y,classDef2:S,class1Count:T,class2Count:C,classRecords:this.parseList(T,j.list(C,function(){return{value1:this.parseValueRecord(f),value2:this.parseValueRecord(g)}}))}}},Ge[3]=function(){return{error:"GPOS Lookup 3 not supported"}},Ge[4]=function(){return{error:"GPOS Lookup 4 not supported"}},Ge[5]=function(){return{error:"GPOS Lookup 5 not supported"}},Ge[6]=function(){return{error:"GPOS Lookup 6 not supported"}},Ge[7]=function(){return{error:"GPOS Lookup 7 not supported"}},Ge[8]=function(){return{error:"GPOS Lookup 8 not supported"}},Ge[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Tb(r,a){a=a||0;let c=new j(r,a),h=c.parseVersion(1);return V.argument(h===1||h===1.1,"Unsupported GPOS table version "+h),h===1?{version:h,scripts:c.parseScriptList(),features:c.parseFeatureList(),lookups:c.parseLookupList(Ge)}:{version:h,scripts:c.parseScriptList(),features:c.parseFeatureList(),lookups:c.parseLookupList(Ge),variations:c.parseFeatureVariationsList()}}var wb=new Array(10);function Eb(r){return new rt.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new rt.ScriptList(r.scripts)},{name:"features",type:"TABLE",value:new rt.FeatureList(r.features)},{name:"lookups",type:"TABLE",value:new rt.LookupList(r.lookups,wb)}])}var Cb={parse:Tb,make:Eb};function kb(r){let a={};r.skip("uShort");let c=r.parseUShort();V.argument(c===0,"Unsupported kern sub-table version."),r.skip("uShort",2);let h=r.parseUShort();r.skip("uShort",3);for(let f=0;f<h;f+=1){let g=r.parseUShort(),y=r.parseUShort(),S=r.parseShort();a[g+","+y]=S}return a}function Ib(r){let a={};r.skip("uShort"),r.parseULong()>1&&console.warn("Only the first kern subtable is supported."),r.skip("uLong");let f=r.parseUShort()&255;if(r.skip("uShort"),f===0){let g=r.parseUShort();r.skip("uShort",3);for(let y=0;y<g;y+=1){let S=r.parseUShort(),T=r.parseUShort(),C=r.parseShort();a[S+","+T]=C}}return a}function Pb(r,a){let c=new ht.Parser(r,a),h=c.parseUShort();if(h===0)return kb(c);if(h===1)return Ib(c);throw new Error("Unsupported kern table version ("+h+").")}var Rb={parse:Pb};function Ob(r,a,c,h){let f=new ht.Parser(r,a),g=h?f.parseUShort:f.parseULong,y=[];for(let S=0;S<c+1;S+=1){let T=g.call(f);h&&(T*=2),y.push(T)}return y}var Mb={parse:Ob};function Eu(r,a){let c=[],h=12;for(let f=0;f<a;f+=1){let g=ht.getTag(r,h),y=ht.getULong(r,h+4),S=ht.getULong(r,h+8),T=ht.getULong(r,h+12);c.push({tag:g,checksum:y,offset:S,length:T,compression:!1}),h+=16}return c}function Lb(r,a){let c=[],h=44;for(let f=0;f<a;f+=1){let g=ht.getTag(r,h),y=ht.getULong(r,h+4),S=ht.getULong(r,h+8),T=ht.getULong(r,h+12),C;S<T?C="WOFF":C=!1,c.push({tag:g,offset:y,compression:C,compressedLength:S,length:T}),h+=20}return c}function _t(r,a){if(a.compression==="WOFF"){let c=new Uint8Array(r.buffer,a.offset+2,a.compressedLength-2),h=new Uint8Array(a.length);if(ct(c,h),h.byteLength!==a.length)throw new Error("Decompression error: "+a.tag+" decompressed length doesn't match recorded length");return{data:new DataView(h.buffer,0),offset:0}}else return{data:r,offset:a.offset}}function Fb(r,a={}){let c,h,f=new wu({empty:!0});r.constructor!==ArrayBuffer&&(r=new Uint8Array(r).buffer);let g=new DataView(r,0),y,S=[],T=ht.getTag(g,0);if(T==="\0\0\0"||T==="true"||T==="typ1")f.outlinesFormat="truetype",y=ht.getUShort(g,4),S=Eu(g,y);else if(T==="OTTO")f.outlinesFormat="cff",y=ht.getUShort(g,4),S=Eu(g,y);else if(T==="wOFF"){let vt=ht.getTag(g,4);if(vt==="\0\0\0")f.outlinesFormat="truetype";else if(vt==="OTTO")f.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+T);y=ht.getUShort(g,12),S=Lb(g,y)}else if(T==="wOF2"){let vt="https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025";throw new Error("WOFF2 require an external decompressor library, see examples at: "+vt)}else throw new Error("Unsupported OpenType signature "+T);let C,E,O,R,F,L,B,Y,yt,mt,At,Rt,Nt,Gt,Ht,qt,He,Ot;for(let vt=0;vt<y;vt+=1){let ft=S[vt],gt;switch(ft.tag){case"avar":B=ft;break;case"cmap":gt=_t(g,ft),f.tables.cmap=ql.parse(gt.data,gt.offset),f.encoding=new ec(f.tables.cmap);break;case"cvt ":gt=_t(g,ft),Ot=new ht.Parser(gt.data,gt.offset),f.tables.cvt=Ot.parseShortList(ft.length/2);break;case"fvar":O=ft;break;case"STAT":R=ft;break;case"gvar":F=ft;break;case"cvar":L=ft;break;case"fpgm":gt=_t(g,ft),Ot=new ht.Parser(gt.data,gt.offset),f.tables.fpgm=Ot.parseByteList(ft.length);break;case"head":gt=_t(g,ft),f.tables.head=yc.parse(gt.data,gt.offset),f.unitsPerEm=f.tables.head.unitsPerEm,c=f.tables.head.indexToLocFormat;break;case"hhea":gt=_t(g,ft),f.tables.hhea=vc.parse(gt.data,gt.offset),f.ascender=f.tables.hhea.ascender,f.descender=f.tables.hhea.descender,f.numberOfHMetrics=f.tables.hhea.numberOfHMetrics;break;case"HVAR":Nt=ft;break;case"hmtx":Rt=ft;break;case"ltag":gt=_t(g,ft),h=Sc.parse(gt.data,gt.offset);break;case"COLR":gt=_t(g,ft),f.tables.colr=Cc.parse(gt.data,gt.offset);break;case"CPAL":gt=_t(g,ft),f.tables.cpal=ic.parse(gt.data,gt.offset);break;case"maxp":gt=_t(g,ft),f.tables.maxp=Ac.parse(gt.data,gt.offset),f.numGlyphs=f.tables.maxp.numGlyphs;break;case"name":qt=ft;break;case"OS/2":gt=_t(g,ft),f.tables.os2=co.parse(gt.data,gt.offset);break;case"post":gt=_t(g,ft),f.tables.post=Tc.parse(gt.data,gt.offset),f.glyphNames=new to(f.tables.post);break;case"prep":gt=_t(g,ft),Ot=new ht.Parser(gt.data,gt.offset),f.tables.prep=Ot.parseByteList(ft.length);break;case"glyf":Y=ft;break;case"loca":Ht=ft;break;case"CFF ":C=ft;break;case"CFF2":E=ft;break;case"kern":Gt=ft;break;case"GDEF":yt=ft;break;case"GPOS":mt=ft;break;case"GSUB":At=ft;break;case"meta":He=ft;break;case"gasp":try{gt=_t(g,ft),f.tables.gasp=Mc.parse(gt.data,gt.offset)}catch(ae){console.warn("Failed to parse gasp table, skipping."),console.warn(ae)}break;case"SVG ":gt=_t(g,ft),f.tables.svg=Lc.parse(gt.data,gt.offset);break;default:break}}let Ee=_t(g,qt);if(f.tables.name=Jl.parse(Ee.data,Ee.offset,h),f.names=f.tables.name,Y&&Ht){let vt=c===0,ft=_t(g,Ht),gt=Mb.parse(ft.data,ft.offset,f.numGlyphs,vt),ae=_t(g,Y);f.glyphs=Xc.parse(ae.data,ae.offset,gt,f,a)}else if(C){let vt=_t(g,C);ao.parse(vt.data,vt.offset,f,a)}else if(E){let vt=_t(g,E);ao.parse(vt.data,vt.offset,f,a)}else throw new Error("Font doesn't contain TrueType, CFF or CFF2 outlines.");let fe=_t(g,Rt);if(xc.parse(f,fe.data,fe.offset,f.numberOfHMetrics,f.numGlyphs,f.glyphs,a),Mf(f,a),Gt){let vt=_t(g,Gt);f.kerningPairs=Rb.parse(vt.data,vt.offset)}else f.kerningPairs={};if(yt){let vt=_t(g,yt);f.tables.gdef=Ab.parse(vt.data,vt.offset)}if(mt){let vt=_t(g,mt);f.tables.gpos=Cb.parse(vt.data,vt.offset),f.position.init()}if(At){let vt=_t(g,At);f.tables.gsub=wc.parse(vt.data,vt.offset)}if(O){let vt=_t(g,O);f.tables.fvar=kc.parse(vt.data,vt.offset,f.names)}if(R){let vt=_t(g,R);f.tables.stat=Ic.parse(vt.data,vt.offset,f.tables.fvar)}if(F){O||console.warn("This font provides a gvar table, but no fvar table, which is required for variable fonts."),Y||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let vt=_t(g,F);f.tables.gvar=Oc.parse(vt.data,vt.offset,f.tables.fvar,f.glyphs)}if(L){O||console.warn("This font provides a cvar table, but no fvar table, which is required for variable fonts."),f.tables.cvt||console.warn("This font provides a cvar table, but no cvt table which could be made variable."),Y||console.warn("This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.");let vt=_t(g,L);f.tables.cvar=Rc.parse(vt.data,vt.offset,f.tables.fvar,f.tables.cvt||[])}if(B){O||console.warn("This font provides an avar table, but no fvar table, which is required for variable fonts.");let vt=_t(g,B);f.tables.avar=Pc.parse(vt.data,vt.offset,f.tables.fvar)}if(Nt){O||console.warn("This font provides an HVAR table, but no fvar table, which is required for variable fonts."),Rt||console.warn("This font provides an HVAR table, but no hmtx table to vary.");let vt=_t(g,Nt);f.tables.hvar=gb.parse(vt.data,vt.offset,f.tables.fvar)}if(He){let vt=_t(g,He);f.tables.meta=Ec.parse(vt.data,vt.offset),f.metas=f.tables.meta}return f.palettes=new Vc(f),f}function Db(){console.error("DEPRECATED! migrate to: opentype.parse(buffer, opt) See: https://github.com/opentypejs/opentype.js/issues/675")}function _b(){console.error('DEPRECATED! migrate to: opentype.parse(require("fs").readFileSync(url), opt)')}return l(u)})();(function(i,t){typeof define=="function"&&define.amd?define(t):typeof Ci=="object"&&Ci.exports?Ci.exports=t():i.opentype=t()})(typeof self<"u"?self:vh,()=>({...yh,default:yh}))});var NS={};Pu(NS,{Logger:()=>Os,PDFParser:()=>Xi,addGfontsAssetLibrary:()=>ko,anyMatchResolverStage:()=>Jr,assetLibraryStrategy:()=>Pd,createFontCascade:()=>qr,createFontStrategy:()=>ts,defaultEmission:()=>gr,defaultStrategy:()=>$n,editableFirstStrategy:()=>_l,embeddedSubsetStage:()=>Qr,exactFidelityStrategy:()=>Id,perfectMatchResolverStage:()=>pr});module.exports=$b(NS);function zb(i,t){return i.replace(/\{(\w+)\}/g,(e,n)=>{if(!(n in t))throw new Error(`Missing param "${n}" for warning template: ${i}`);return String(t[n])})}var Os=class{constructor(i){this.registry=i}messages=[];emit(i,t={}){let e=this.registry[i];this.messages.push({code:i,type:e.severity,message:zb(e.template,t),params:t})}getMessages(){return this.messages}},Xb="0.1.0",Mu=`https://cdn.img.ly/packages/imgly/gfonts/${Xb}/dist/ttf`,nr="ly.img.gfonts",rr="ly.img.gfonts-fallbacks",Yb=5,Kb=20;async function ko(i){let t=i.asset.findAllSources();t.includes(nr)||await i.asset.addLocalAssetSourceFromJSONURI(`${Mu}/${nr}/content.json`),t.includes(rr)||await i.asset.addLocalAssetSourceFromJSONURI(`${Mu}/${rr}/content.json`)}async function Io(i,t,e){let n=t.asset.findAllSources();if(!n.includes(nr)||!n.includes(rr))throw new Error(`The gfonts asset sources (${nr}, ${rr}) are not available. Call addGfontsAssetLibrary() first.`);let s=await qb(t,i.family);if(!s)return null;let{typeface:o,substitutedFrom:l}=s,u=o.fonts.find(d=>Zb(d,i));if(!u&&i.weight&&e?.closestWeightMatch){let d=i.style!==void 0?o.fonts.filter(p=>p.style?.toLowerCase()===i.style.toLowerCase()):o.fonts;d.length>0&&(u=Jb(d,i.weight))}return u?{typeface:o,font:u,substitutedFrom:l}:null}var Po={100:"thin",200:"extraLight",300:"light",regular:"normal",400:"normal",500:"medium",600:"semiBold",700:"bold",800:"extraBold",900:"heavy"},mn=["thin","extraLight","light","normal","medium","semiBold","bold","extraBold","heavy"];function Zb(i,t){return!(t.style!==void 0&&i.style?.toLowerCase()!==t.style.toLowerCase()||t.weight!==void 0&&!Qb(t.weight,i.weight))}function Qb(i,t){if(!t)return!1;if(i===t)return!0;let e=i.toLowerCase();if(e===t)return!0;let n=Po[e];return n!==void 0&&n===t}function Lu(i){let t=i.toLowerCase();for(let e of mn)if(e.toLowerCase()===t)return e;return Po[t]??null}function Jb(i,t){let e=Lu(t);if(e===null)return;let n=mn.indexOf(e);if(n===-1)return;let s=new Map;for(let d of i){if(!d.weight)continue;let p=Lu(d.weight);if(p===null)continue;let m=mn.indexOf(p);m>=0&&!s.has(m)&&s.set(m,d)}if(s.size===0)return;let o=mn.indexOf("normal"),l=mn.indexOf("medium"),u=[];if(n===o||n===l){for(let d=n;d<=l;d++)u.push(d);for(let d=o-1;d>=0;d--)u.push(d);for(let d=l+1;d<mn.length;d++)u.push(d)}else if(n<o){for(let d=n;d>=0;d--)u.push(d);for(let d=n+1;d<mn.length;d++)u.push(d)}else{for(let d=n;d<mn.length;d++)u.push(d);for(let d=n-1;d>=0;d--)u.push(d)}for(let d of u){let p=s.get(d);if(p)return p}}function er(i){return i.toLowerCase().replace(/[\s\-_]+/g,"")}function Rs(i,t){return i.find(n=>{let s=n.payload?.typeface?.name;return s!=null&&er(s)===t||n.id!=null&&er(n.id)===t||typeof n.label=="string"&&er(n.label)===t})?.payload?.typeface??null}async function qb(i,t){let e=await Fu(i,rr,t);if(e)return{typeface:e,substitutedFrom:t};let n=await Fu(i,nr,t);if(n)return{typeface:n};let s=await Du(i,rr,t),o=await Du(i,nr,t);return s&&s.kind!=="fuzzy"&&!(o?.kind==="prefix"&&o.matched>s.matched)?{typeface:s.typeface,substitutedFrom:t}:o?{typeface:o.typeface}:null}async function Fu(i,t,e){let n=er(e);if(i.asset.fetchAsset){let o=await i.asset.fetchAsset(t,n),l=Rs(o?[o]:[],n);if(l)return l}let s=[[{property:"id",equals:n}],[{property:"label",equals:e.trim()}]];for(let o of s){let l=await i.asset.findAssets(t,{page:0,perPage:Yb,filter:o}),u=Rs(l?.assets??[],n);if(u)return u}return null}async function Du(i,t,e){let n=er(e),s=null,o=null;for(let l of ey(e)){let d=(await i.asset.findAssets(t,{page:0,query:l,perPage:Kb}))?.assets??[];if(d.length===0)continue;let p=Rs(d,n);if(p)return{typeface:p,kind:"exact",matched:n.length};if(!s){let m=er(l),b=Rs(d,m);b&&(s={typeface:b,matched:m.length})}o??=d[0].payload?.typeface??null}return s?{...s,kind:"prefix"}:o?{typeface:o,kind:"fuzzy",matched:0}:null}function ty(i){return i.replace(/[_\-+.,]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").trim().split(/\s+/).filter(Boolean)}function ey(i){let t=ty(i),e=[i.trim()];for(let n=t.length;n>0;n--)e.push(t.slice(0,n).join(" "));return[...new Set(e)]}var Ro="x-adobe-psd",BS=64*1024;var GS=`${Ro}/spot-colors`;var HS=`${Ro}/editable-text-alternate`,jS=`${Ro}/editable-text-alternates`;var _u={DOC_PAGE_COUNT:{severity:"info",template:"PDF has {count} page(s)"},DOC_PAGE_BLOCK_COUNT:{severity:"info",template:"Page {page}: {imageCount} image, {vectorCount} vector, {textCount} text, {outlineCount} outline"},DOC_PAGE_ROTATION_DROPPED:{severity:"warning",template:"{prefix}PDF declares /Rotate {pageRotation}; the importer does not apply page rotation, so the imported page is in its un-rotated (native) orientation. Viewer-rendered output may differ from the source's display orientation."},BLOCK_KIND_UNKNOWN:{severity:"error",template:'An unknown block kind "{kind}" was encountered and was skipped.'},PAGE_INDEX_OUT_OF_RANGE:{severity:"warning",template:"Requested page index {requested} is out of range; PDF has {available} page(s). No blocks were emitted."},FONT_OPENTYPE_PARSE_FAILED:{severity:"warning",template:'{prefix}font "{fontName}" could not be parsed as OpenType{reason}. Glyph outlines will fall back to pdf.js raster paths \u2014 some shapes may render without stroke/anti-aliasing detail.'},FONT_CMAP_AUGMENTED:{severity:"info",template:'Font "{fontName}" character map was augmented (cmap patches={cmapPatches}, injected glyphs={injectedGlyphs}).'},FONT_CMAP_AUGMENT_FAILED:{severity:"warning",template:'Font "{fontName}" character map could not be augmented. Using the original font data \u2014 some glyphs may render incorrectly.'},FONT_RESOLVER_MISS:{severity:"warning",template:'Font "{fontFamily}" could not be resolved. The text was rendered as a vector outline.'},FONT_NOT_FOUND_IN_ASSETS:{severity:"warning",template:'Font "{fontFamily}" was not found in the asset library. The text was rendered as a vector outline.'},FONT_SUBSTITUTED:{severity:"info",template:'Font "{fontFamily}" was substituted with "{substitutedName}" from the asset library.'},FONT_REF_NOT_EXTRACTED:{severity:"error",template:'Text run references font "{fontRef}" which was not extracted. The text was skipped.'},FONT_SUBSTITUTIONS:{severity:"warning",template:"Substituted {count} font famil{plural} during import: {pairs}."},FONT_SUBSET_FALLBACK:{severity:"warning",template:`Used PDF-embedded subset bytes for {count} font famil{plural} not in the asset library: {families}. Subset fonts render the PDF's exact glyphs but their CMap / OpenType-feature tables can produce ligature or kerning artifacts (e.g. "f\xFCr" \u2192 "fi\xFCr"). Add the families to the asset library to use clean asset-library fonts instead.`},TEXT_OUTLINE_NO_FONT_FAMILY:{severity:"warning",template:"Text outline has no declared font family. The run was skipped."},TEXT_RUN_SKIPPED_NO_RESOLUTION:{severity:"warning",template:'No typeface or glyph outlines for "{fontFamily}"; run skipped.'},TEXT_RENDER_MODE_SKIPPED:{severity:"warning",template:'Text item{pageTag}: skipped "{text}" \u2014 PDF text rendering mode {modeLabel}. This text paints no ink; for mode 7 it acts as a clipping mask for following images, an effect the importer does not currently reproduce.'},TEXT_OVERFLOW_AFTER_AUTOSIZE:{severity:"warning",template:'Text "{text}" did not fit after auto-sizing; it still overflows by {overflowLines} line(s). The text was kept; some content may be clipped.'},TEXT_FONTS_READY_TIMEOUT:{severity:"warning",template:"{count} text block(s) were still loading fonts after {timeoutMs} ms. Letter-spacing was fitted against fallback font metrics and may be visibly wrong for those blocks."},TEXT_CLIP_MODE_7_DROPPED:{severity:"warning",template:"{prefix}{label} at ({bbox}) {bboxSize} pt: dropped because the surrounding region was clipped by text in PDF render mode 7 (text-as-clipping-mask). The masked artwork cannot be reproduced as text-clipped content."},IMAGE_ENCODER_MISS:{severity:"warning",template:"{prefix}an image{idLabel} ({width}\xD7{height} raw pixels{kind}) could not be encoded ({reason}). The image was dropped from the imported design."},IMAGE_PDFJS_UNRESOLVED:{severity:"error",template:"{prefix}image placement {idLabel} at ({bboxX}, {bboxY}) {bboxW}\xD7{bboxH} pt could not be resolved by pdf.js (reason={reason}) and was dropped."},IMAGE_NO_PIXELS:{severity:"warning",template:"An image element has no pixel data and was skipped."},IMAGE_FLIP_UNSUPPORTED:{severity:"warning",template:"Image flip could not be applied (engine version too old). The image will display without flip."},IMAGE_PLACEMENT_UNSUPPORTED:{severity:"warning",template:"Image placement could not be applied (engine version too old). The image will be scaled evenly to cover its box and can be cut off."},IMAGE_SKEW_DROPPED:{severity:"warning",template:"{prefix}an image{idLabel} at ({bboxX}, {bboxY}) {bboxW}\xD7{bboxH} pt has a skewed transform ctm={ctm}{residualStr} that cannot be represented. Placed axis-aligned \u2014 image content will appear un-skewed."},IMAGE_CLIPPED_NO_BYTES:{severity:"warning",template:"{prefix}a clipped image at {bbox} had no decoded bytes; the placement was dropped before combining clip shapes."},IMAGE_CLIP_UNUSABLE:{severity:"warning",template:"{prefix}a clipped image at {bbox} with {clipCount} clip path(s) has no usable clip \u2014 {degenerateCount} degenerate, {disjointCount} disjoint from the image. The image was dropped."},IMAGE_CLIPPED_TO_EMPTY:{severity:"info",template:"{prefix}a clipped image at {bbox} with {clipCount} clip path(s) lies entirely outside its clip region ({disjointCount} clip path(s) disjoint from the image); the source draws nothing there, so the placement was skipped."},IMAGE_CLIP_EMPTY_INTERSECTION:{severity:"warning",template:"{prefix}a clipped image at {bbox} with {clipCount} clip path(s) had an empty intersection. The image was dropped."},IMAGE_CLIP_COMBINE_FAILED:{severity:"error",template:"{prefix}a clipped image at {bbox} with {clipCount} clip path(s) could not be combined. The image was dropped from the imported design."},IMAGE_MASK_NO_FILL_COLOR:{severity:"warning",template:"{prefix}a stencil ImageMask paint (objId={objId}) had no current fill colour to composite with. The mask was dropped from the imported design."},IMAGE_MASK_COMPOSITE_FAIL:{severity:"warning",template:"{prefix}a stencil ImageMask (objId={objId}) at ({bboxX}, {bboxY}) {bboxW}\xD7{bboxH} pt could not be composited with the current fill colour (space={colourSpace}). The mask was dropped from the imported design."},IMAGE_MASK_GROUP_UNSUPPORTED:{severity:"warning",template:"{prefix}a paintImageMaskXObjectGroup batch of {count} stencil paints is not supported by the importer. The masks were dropped."},IMAGE_MASK_REPEAT_UNSUPPORTED:{severity:"warning",template:"{prefix}a paintImageMaskXObjectRepeat tiling {count} stencil paints is not supported by the importer. The masks were dropped."},CLIP_DEGENERATE_FALLBACK:{severity:"warning",template:"{prefix}a clipped vector path at {bbox} with {clipCount} clip path(s) has no usable clip \u2014 {degenerateCount} degenerate (zero width or height). Falling back to the unclipped path."},CLIP_COMBINE_STROKE_ONLY:{severity:"warning",template:"{prefix}a clipped vector path at {bbox} with {clipCount} clip path(s) has no fill color (stroke-only) which cannot survive combine. Falling back to the unclipped path."},CLIP_COMBINE_FAILED:{severity:"warning",template:"{prefix}a vector path at {bbox} with {clipCount} clip path(s) could not be combined. Rendered without its clip \u2014 some content may extend beyond the intended mask."},CLIP_COMBINE_TOO_FEW_INPUTS:{severity:"warning",template:"{prefix}clip combine was called with {inputCount} input block(s) (need at least 2). The owner block was emitted without its clips."},CLIP_COMBINE_NOT_COMBINABLE:{severity:"warning",template:"{prefix}clip combine rejected {inputCount} input block(s) as not combinable (nested or incompatible shapes). The owner block was emitted without its clips."},CLIP_COMBINE_THREW:{severity:"warning",template:"{prefix}clip combine of {inputCount} input block(s) failed ({reason}). The owner block was emitted without its clips."},COLOR_TYPE_UNSUPPORTED:{severity:"warning",template:'{prefix}{subject}color of type "{colorType}" is not supported. Rendered as black.'},COLOR_SPACE_UNSUPPORTED:{severity:"warning",template:'{prefix}{elementLabel}color space "{space}" ({color}) at {bbox} is not supported. Rendered as black.'},COLOR_DEVICEN_INKS_NOT_PRESERVED:{severity:"warning",template:"{prefix}the page declares DeviceN color resources. Imported DeviceN colors use their alternate color space; independent ink channels are not preserved."},COLOR_DEVICEN_TINT_UNRESOLVED:{severity:"warning",template:"{prefix}the PDF decoder did not resolve DeviceN tint values. The all-inks-solid alternate color was used; colors can differ from the source. Use the bundled PDF decoder."},SPOT_COLOR_NO_ALTERNATE:{severity:"warning",template:'Spot color "{name}" has no resolvable alternate; leaving at engine default.'},SPOT_COLOR_REGISTER_FAILED:{severity:"warning",template:'Failed to register spot color "{name}": {error}'},SPOT_COLOR_DEFINITION_PRESERVED:{severity:"warning",template:'Spot color "{name}" is already defined differently in the destination. Imported content uses the existing definition.'},VECTOR_PATH_FILL_RULE_UNSUPPORTED:{severity:"warning",template:"CE.SDK does not expose `{property}` on `vector_path` shapes (added in CE.SDK {sinceVersion}); the source PDF used non-zero winding fill, but imported paths render with the engine default (even-odd) winding. Self-overlapping or compound paths may render with holes inverted. Upgrade `@cesdk/engine` to {sinceVersion} or newer to preserve the source winding rule."},BLEND_MODE_UNSUPPORTED:{severity:"warning",template:'Blend mode "{mode}" is not supported. Using "Normal" as the default.'},SHADING_COLORSPACE_CONVERTED:{severity:"warning",template:"{prefix}gradient pattern colors were converted to sampled RGB stops by the PDF decoder. Original CMYK or spot-color definitions are not preserved."},SHADING_PATTERN_TRANSFORM_UNSUPPORTED:{severity:"warning",template:"{prefix}a gradient fill inside a transformed PDF form was dropped because its placement cannot be preserved."},SHADING_UNRESOLVED:{severity:"error",template:"{prefix}gradient shading could not be resolved by pdf.js and was removed. The painted region will be missing in the imported scene."},SHADING_MESH_UNSUPPORTED:{severity:"warning",template:"{prefix}gradient shading uses an unsupported mesh variant (PDF ShadingType 4\u20137). The region was dropped because mesh gradients can't be represented as a CE.SDK gradient fill."},SHADING_MESH_FLATTENED:{severity:"warning",template:"{prefix}mesh at {at} retains {triangles} triangle(s) as editable vector geometry. Its corner-color gradient was replaced by the solid average color {fill}.{background}"},SHADING_MESH_GEOMETRY_DROPPED:{severity:"warning",template:"{prefix}mesh shading was omitted because {reason}. Its vector geometry could not be retained."},SHADING_UNKNOWN_IR_TAG:{severity:"error",template:'{prefix}gradient shading reported unknown IR tag "{tag}" and was dropped.'},SHADING_INSUFFICIENT_STOPS:{severity:"warning",template:"{prefix}gradient shading produced fewer than two color stops and was dropped."},SHADING_NO_CLIP_FALLBACK_BBOX:{severity:"info",template:"{prefix}gradient shading was painted without an active clip path. Falling back to the shading /BBox; if this scene shows gradient bands outside the intended shape, file a bug."},SHADING_CLIP_DEGENERATE:{severity:"warning",template:"{prefix}gradient shading clip path was degenerate and the region was dropped."},SHADING_RADIAL_FOCAL_DROPPED:{severity:"info",template:"{prefix}radial gradient declared a non-zero inner radius (PDF Shading Type 3 focal point). It was approximated as a centered radial; the focal offset was dropped."},SHADING_UNKNOWN_RADIAL_SUBTYPE:{severity:"error",template:'{prefix}gradient shading reported unknown RadialAxial subtype "{kind}" and was dropped.'},SHADING_NO_PATTERN_REF:{severity:"error",template:"{prefix}gradient shading was emitted without a pattern reference and was dropped."},TILING_PATTERN_AS_IMAGE:{severity:"info",template:'{prefix}tiling pattern "{patternId}" was imported as an image (single-image tiling pattern, e.g. Skia/Chrome PDF export of an embedded bitmap).'},TILING_PATTERN_UNSUPPORTED:{severity:"warning",template:'{prefix}tiling pattern "{patternId}" could not be imported as a bounded, opaque vector tile or a single-image pattern. The pattern fill was dropped.'},TILING_PATTERN_UNRESOLVED:{severity:"error",template:'{prefix}tiling pattern "{patternId}" could not be resolved by pdf.js and was dropped.'},TILING_PATTERN_IMAGE_DECODE_FAILED:{severity:"warning",template:'{prefix}tiling pattern "{patternId}" referenced image "{imageObjId}" but the image bytes could not be decoded. The pattern fill was dropped.'}};cl();var Ti=require("@napi-rs/canvas");async function qe(i,t){return{canvas:(0,Ti.createCanvas)(i,t),ImageData:Ti.ImageData}}async function Hn(i){return new Uint8Array(i.toBuffer("image/png"))}async function lh(i){return{opList:await i.getOperatorList({annotationMode:ll.DISABLE})}}function jn(i,t){return ch(i.objs,t)}function lr(i,t){return ch(i.commonObjs,t)}function ch(i,t){return t==null?Promise.resolve({data:null,reason:"cb-null"}):new Promise(e=>{let n=!1,s=(l,u)=>{n||(n=!0,e({data:l,reason:u}))};try{i.get(t,l=>s(l,l==null?"cb-null":"ok"))}catch{s(null,"throw");return}setTimeout(()=>s(null,"timeout"),1e4).unref?.()})}async function Ei(i,t,e={}){if(i==null)return null;let n=i.width,s=i.height;if(!n||!s)return wi("missing width/height",i,t,e),null;let{canvas:o,ImageData:l}=await qe(n,s),u=o.getContext("2d");if(i.bitmap)try{u.drawImage(i.bitmap,0,0)}catch(d){let p=d&&typeof d=="object"&&"message"in d?String(d.message):String(d);return wi(`bitmap drawImage failed: ${p}`,i,t,e),null}else if(i.data){let d=dl(i);if(!d)return wi(`unknown data kind=${i.kind}`,i,t,e),null;let p=new l(d,n,s);u.putImageData(p,0,0)}else return wi("no bitmap and no data",i,t,e),null;return Hn(o)}async function uh(i,t,e,n={}){if(i==null)return null;let s=i.width,o=i.height;if(!s||!o)return null;let l=hl(t);if(l==null)return null;let[u,d,p]=l,m=await ul(i);if(m==null)return null;let{canvas:b,ImageData:v}=await qe(s,o),A=b.getContext("2d"),x=new Uint8ClampedArray(s*o*4);for(let k=0;k<s*o;k++)x[k*4]=u,x[k*4+1]=d,x[k*4+2]=p,x[k*4+3]=m[k];let w=new v(x,s,o);return A.putImageData(w,0,0),Hn(b)}async function ul(i){let t=i.width,e=i.height,n=t*e;if(i.data){let{kind:s,data:o}=i;if(s===1){if(o.length>=n)return new Uint8ClampedArray(o.buffer,o.byteOffset,n);let l=new Uint8ClampedArray(n),u=Math.ceil(t/8);for(let d=0;d<e;d++)for(let p=0;p<t;p++){let b=o[d*u+(p>>3)]>>7-(p&7)&1;l[d*t+p]=b?255:0}return l}if(s===2){let l=new Uint8ClampedArray(n);for(let u=0;u<n;u++)l[u]=Math.round(o[u*3]*.299+o[u*3+1]*.587+o[u*3+2]*.114);return l}if(s===3){let l=new Uint8ClampedArray(n);for(let u=0;u<n;u++)l[u]=Math.round(o[u*4]*.299+o[u*4+1]*.587+o[u*4+2]*.114);return l}return null}if(i.bitmap){let{canvas:s}=await qe(t,e),o=s.getContext("2d");try{o.drawImage(i.bitmap,0,0)}catch{return null}let u=o.getImageData(0,0,t,e).data,d=new Uint8ClampedArray(n);for(let p=0;p<n;p++)d[p]=Math.round(u[p*4]*.299+u[p*4+1]*.587+u[p*4+2]*.114);return d}return null}function hl(i){if(!i||typeof i!="object")return null;let{space:t,values:e}=i;if(t==="rgb"&&Array.isArray(e)&&e.length>=3)return[Math.round(Sn(e[0])*255),Math.round(Sn(e[1])*255),Math.round(Sn(e[2])*255)];if(t==="gray"&&Array.isArray(e)&&e.length>=1){let n=Math.round(Sn(e[0])*255);return[n,n,n]}if(t==="cmyk"&&Array.isArray(e)&&e.length>=4){let n=Sn(e[0]),s=Sn(e[1]),o=Sn(e[2]),l=Sn(e[3]);return[Math.round(255*(1-n)*(1-l)),Math.round(255*(1-s)*(1-l)),Math.round(255*(1-o)*(1-l))]}return null}function Sn(i){return typeof i!="number"||Number.isNaN(i)||i<0?0:i>1?1:i}function wi(i,t,e,n={}){if(!e?.emit)return;let s=n.pageIndex!=null?`Page ${n.pageIndex}: `:"",o=n.objId?` objId="${n.objId}"`:"",l=t?.width??"?",u=t?.height??"?",d=t?.kind!=null?`, kind=${t.kind}`:"";e.emit("IMAGE_ENCODER_MISS",{prefix:s,idLabel:o,width:l,height:u,kind:d,reason:i,page:n.pageIndex,objId:n.objId??null})}function dl(i){let t=i.width,e=i.height,n=i.kind,s=i.data,o=t*e,l=new Uint8ClampedArray(o*4);if(n===1){if(s.length>=o){for(let d=0;d<o;d++){let p=s[d];l[d*4]=p,l[d*4+1]=p,l[d*4+2]=p,l[d*4+3]=255}return l}let u=Math.ceil(t/8);for(let d=0;d<e;d++)for(let p=0;p<t;p++){let v=s[d*u+(p>>3)]>>7-(p&7)&1?255:0,A=(d*t+p)*4;l[A]=v,l[A+1]=v,l[A+2]=v,l[A+3]=255}return l}if(n===2){for(let u=0;u<o;u++)l[u*4]=s[u*3],l[u*4+1]=s[u*3+1],l[u*4+2]=s[u*3+2],l[u*4+3]=255;return l}return n===3?new Uint8ClampedArray(s.buffer,s.byteOffset,s.byteLength):null}async function Hv(i){if(i==null)return null;let{width:t,height:e}=i;if(!t||!e)return null;let n=t*e;if(i.data){let s=new Uint8ClampedArray(n),o=Math.ceil(t/8);for(let l=0;l<e;l++)for(let u=0;u<t;u++){let p=i.data[l*o+(u>>3)]>>7-(u&7)&1;s[l*t+u]=p?0:255}return s}if(i.bitmap){let{canvas:s}=await qe(t,e),o=s.getContext("2d");try{o.drawImage(i.bitmap,0,0)}catch{return null}let l=o.getImageData(0,0,t,e),u=new Uint8ClampedArray(n);for(let d=0;d<n;d++)u[d]=l.data[d*4+3];return u}return null}async function hh(i,t,e,n={}){if(i==null)return null;let s=i.width,o=i.height;if(!s||!o)return null;let l=hl(t);if(l==null)return null;let[u,d,p]=l,m=await Hv(i);if(m==null)return null;let{canvas:b,ImageData:v}=await qe(s,o),A=b.getContext("2d"),x=new Uint8ClampedArray(s*o*4);for(let k=0;k<s*o;k++)x[k*4]=u,x[k*4+1]=d,x[k*4+2]=p,x[k*4+3]=m[k];let w=new v(x,s,o);return A.putImageData(w,0,0),Hn(b)}async function fh(i){let{imageObj:t,imageCtm:e,maskSource:n,modulatedAlpha:s}=i;if(t==null)return null;let o=t.width,l=t.height;if(!o||!l)return null;let u=gh(s??1);if(n.kind==="shading"){let d=jv(n.ir,n.ctm);return d==null?null:dh(o,l,e,d,u)}if(n.kind==="image"){if(n.obj==null)return null;let d=n.obj.width,p=n.obj.height;if(!d||!p)return null;let m=await ul(n.obj);if(m==null)return null;let b=Vv(n.ctm,m,d,p);return b==null?null:dh(o,l,e,b,u)}return null}async function ph(i,t){if(i==null)return null;let e=i.width,n=i.height;if(!e||!n||t.length!==e*n)return null;let s=null;if(i.bitmap){let{canvas:m}=await qe(e,n),b=m.getContext("2d");try{b.drawImage(i.bitmap,0,0)}catch{return null}let v=b.getImageData(0,0,e,n);s=new Uint8ClampedArray(v.data.buffer.slice(0))}else i.data&&(s=dl(i));if(!s)return null;let o=new Uint8ClampedArray(e*n*4);for(let m=0;m<e*n;m++){o[m*4]=s[m*4],o[m*4+1]=s[m*4+1],o[m*4+2]=s[m*4+2];let b=s[m*4+3];o[m*4+3]=Math.round(b*t[m]/255)}let{canvas:l,ImageData:u}=await qe(e,n),d=l.getContext("2d"),p=new u(o,e,n);return d.putImageData(p,0,0),Hn(l)}function dh(i,t,e,n,s){let o=new Uint8ClampedArray(i*t),[l,u,d,p,m,b]=e;for(let v=0;v<t;v++)for(let A=0;A<i;A++){let x=(A+.5)/i,w=1-(v+.5)/t,k=l*x+d*w+m,I=u*x+p*w+b,P=n(k,I);o[v*i+A]=Math.round(P*255*s)}return o}function jv(i,t){if(!Array.isArray(i)||i[0]!=="RadialAxial")return null;let e=i[1],n=i[3],s=i[4],o=i[5],l=i[6],u=i[7],d=Wv(n);if(d==null)return null;let p=mh(t);if(p==null)return null;if(e==="axial"){if(!Array.isArray(s)||!Array.isArray(o))return null;let[m,b]=s,[v,A]=o,x=v-m,w=A-b,k=x*x+w*w;return k<=0?null:(I,P)=>{let[M,N]=fl(p,I,P),D=((M-m)*x+(N-b)*w)/k,U=Math.max(0,Math.min(1,D));return d[Math.round(U*255)]/255}}if(e==="radial"){if(!Array.isArray(o)||typeof u!="number"||u<=0||Math.abs(typeof l=="number"?l:0)>.001)return null;let[b,v]=o;return(A,x)=>{let[w,k]=fl(p,A,x),I=w-b,P=k-v,N=Math.sqrt(I*I+P*P)/u,D=Math.max(0,Math.min(1,N));return d[Math.round(D*255)]/255}}return null}function Vv(i,t,e,n){let s=mh(i);return s==null?null:(o,l)=>{let[u,d]=fl(s,o,l);if(u<0||u>1||d<0||d>1)return 0;let p=Math.min(e-1,Math.floor(u*e)),m=Math.min(n-1,Math.floor((1-d)*n));return t[m*e+p]/255}}function Wv(i){if(!Array.isArray(i)||i.length<2)return null;let t=[];for(let n of i){if(!Array.isArray(n)||n.length<2)continue;let s=gh(n[0]),o=$v(n[1]);o&&t.push({offset:s,r:o[0],g:o[1],b:o[2]})}if(t.length<2)return null;t.sort((n,s)=>n.offset-s.offset);let e=new Uint8Array(256);for(let n=0;n<256;n++){let s=n/255,o=t[0],l=t[t.length-1];for(let v=0;v<t.length-1;v++)if(s>=t[v].offset&&s<=t[v+1].offset){o=t[v],l=t[v+1];break}let u=l.offset-o.offset,d=u>0?(s-o.offset)/u:0,p=o.r+(l.r-o.r)*d,m=o.g+(l.g-o.g)*d,b=o.b+(l.b-o.b)*d;e[n]=Math.round(.299*p+.587*m+.114*b)}return e}function $v(i){if(typeof i!="string")return null;if(i==="transparent")return[255,255,255];let t=/^#([0-9a-fA-F]{6})$/.exec(i.trim());if(!t)return null;let e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function gh(i){return typeof i!="number"||!Number.isFinite(i)||i<0?0:i>1?1:i}function fl(i,t,e){return[i[0]*t+i[2]*e+i[4],i[1]*t+i[3]*e+i[5]]}function mh(i){let[t,e,n,s,o,l]=i,u=t*s-e*n;if(!Number.isFinite(u)||Math.abs(u)<1e-12)return null;let d=1/u;return[s*d,-e*d,-n*d,t*d,(n*l-s*o)*d,(e*o-t*l)*d]}var zv=/^[A-Z]{6}\+/,Xv=[["ultracondensed","ultraCondensed"],["extracondensed","extraCondensed"],["semicondensed","semiCondensed"],["condensed","condensed"],["compressed","condensed"],["narrow","condensed"],["cond","condensed"],["comp","condensed"],["ultraexpanded","ultraExpanded"],["extraexpanded","extraExpanded"],["semiexpanded","semiExpanded"],["expanded","expanded"],["extended","expanded"],["wide","expanded"]],Yv=["italic","oblique"],bh={bd:700,lt:300,md:500,rg:400,bk:900,blk:900,hv:900,th:100,hl:100};function $r(i){let t=i.replace(zv,""),e=t.lastIndexOf("-"),n=t.lastIndexOf(","),s=Math.max(e,n);if(s<0)return{fullName:t,family:t,weight:null,style:"normal",width:null,styleSuffix:null};let o=t.slice(0,s),l=t.slice(s+1),u=Kv(l);return u?{fullName:t,family:o,weight:u.weight,style:u.style,width:u.width,styleSuffix:l}:{fullName:t,family:t,weight:null,style:"normal",width:null,styleSuffix:null}}function Kv(i){let t=i.toLowerCase(),e=!1,n="normal";for(let l of Yv)if(t.includes(l)){n="italic",e=!0;break}let s=null;for(let[l,u]of Xv)if(t.includes(l)){s=u,e=!0;break}let o=Zv(t);return o!==null&&(e=!0),e?{weight:o,style:n,width:s}:null}function Zv(i){return i.includes("extrabold")||i.includes("ultrabold")?800:i.includes("semibold")||i.includes("demibold")?600:i.includes("extralight")||i.includes("ultralight")?200:i.includes("thin")||i.includes("hairline")?100:i.includes("light")?300:i.includes("medium")?500:i.includes("bold")?700:i.includes("black")||i.includes("heavy")?900:i.includes("regular")||i==="normal"||i.includes("book")||i.includes("roman")?400:Object.prototype.hasOwnProperty.call(bh,i)?bh[i]:null}var Qv=/^[A-Z]{6}\+/;async function gl(i,t){if(!i||!i.data||i.data.length===0)return null;let e=$r(i.name??"");if(!e.fullName)return null;let n=i.loadedName?`${e.fullName}#${i.loadedName}`:e.fullName,s=i._parsed??null,o=s?.names,l=(o?.fontFamily?.en?.trim()||o?.fontFamily?.und?.trim()||e.family).replace(Qv,""),u=s?.tables?.os2,d=e.weight??u?.usWeightClass??(i.black?900:i.bold?700:400),p=i.italic?"italic":e.style,m=e.width??Jv(u?.usWidthClass),b=i.data instanceof Uint8Array?i.data:new Uint8Array(i.data),v=await n1(s,b,i.toFontChar??null,t),A=qv(v);return{postScriptName:n,family:l,weight:d,style:p,...m?{width:m}:{},data:v,mimeType:A}}function Jv(i){if(typeof i=="number")switch(i){case 1:return"ultraCondensed";case 2:return"extraCondensed";case 3:return"condensed";case 4:return"semiCondensed";case 5:return"normal";case 6:return"semiExpanded";case 7:return"expanded";case 8:return"extraExpanded";case 9:return"ultraExpanded";default:return}}function xh(i,t){if(!Ii(i)||!t||t.length===0)return!1;for(let e of t){let n=e.unicode;if(!n||t1(n))return!1}return!0}function Ii(i){return!(!i||i.isType3Font||!i.data||i.data.length===0||!i._parsed)}function An(i){let t=Number(i)||400;return t<=150?"thin":t<=250?"extraLight":t<=350?"light":t<=450?"normal":t<=550?"medium":t<=650?"semiBold":t<=750?"bold":t<=850?"extraBold":"heavy"}function Sh(i){let t=$r(i?.name??""),e=i?._parsed?.tables?.os2,n=t.weight??e?.usWeightClass??(i?.black?900:i?.bold?700:400);return{style:i?.italic?"italic":t.style,weight:An(n)}}function qv(i){return i.length>=4&&i[0]===79&&i[1]===84&&i[2]===84&&i[3]===79?"font/otf":"font/ttf"}function t1(i){for(let t of i){let e=t.codePointAt(0);if(e!=null&&(e>=57344&&e<=63743||e>=983040&&e<=1048573||e>=1048576&&e<=1114109))return!0}return!1}var e1=[32,160];async function n1(i,t,e,n){if(!i)return t;let s=ki.get(i);if(s)return s;try{let{default:o}=await Promise.resolve().then(()=>Ou(pl(),1)),l=r1(i,e);for(let{glyphIndex:w,unicode:k}of l){let I=i.glyphs.get(w);if(!I)continue;let P=I;P.unicodes||(P.unicodes=P.unicode!=null?[P.unicode]:[]),P.unicodes.includes(k)||P.unicodes.push(k)}let u=[],d=i.unitsPerEm||1e3,p=Math.round(d*.25),m=i.glyphs;for(let w of e1){if(i1(i,w))continue;let k=m.length,I=new o.Glyph({name:w===32?"space":`uni${w.toString(16).toUpperCase()}`,unicode:w,advanceWidth:p,path:new o.Path});I.index=k,m.glyphs[k]=I,m.length=k+1,u.push(w)}if(l.length===0&&u.length===0)return ki.set(i,t),t;for(let w=0;w<m.length;w+=1){let k=i.glyphs.get(w);k&&(typeof k.name!="string"||k.name==="")&&(k.name=w===0?".notdef":`gid${w}`)}i.numGlyphs=m.length;let b=i.toArrayBuffer(),A=o.parse(b).toArrayBuffer(),x=new Uint8Array(A);if(ki.set(i,x),s1()){let w=i.names?.postScriptName?.en??"<unknown>",k=u.map(I=>"U+"+I.toString(16).toUpperCase()).join(",")||"none";n?.emit?.("FONT_CMAP_AUGMENTED",{fontName:w,cmapPatches:l.length,injectedGlyphs:k})}return x}catch(o){let l=i.names?.postScriptName?.en??"<unknown>",u=o&&typeof o=="object"&&"message"in o?String(o.message):String(o);return n?.emit?.("FONT_CMAP_AUGMENT_FAILED",{fontName:l,error:u}),ki.set(i,t),t}}function r1(i,t){let e=[];if(!t)return e;let s=i.tables?.cmap?.glyphIndexMap;if(!s)return e;for(let[o,l]of Object.entries(t)){let u=Number(o);if(!Number.isFinite(u)||u===l||s[u])continue;let d=s[l];d&&e.push({unicode:u,glyphIndex:d})}return e}var ki=new WeakMap;function s1(){return!!(typeof process<"u"&&process.env?.PDF2CESDK_DEBUG_FONTS||typeof globalThis<"u"&&globalThis.PDF2CESDK_DEBUG_FONTS)}function i1(i,t){try{let e=i.charToGlyphIndex(String.fromCodePoint(t));if(!e)return!1;let n=i.glyphs.get(e);return!!n&&(n.advanceWidth??0)>0}catch{return!1}}function Eh(i,t,e,n){if(!i||i.length===0)return[];let s=i.map(u=>a1(u,t,e,n)),o=[],l=null;for(let u of s)if(u){if(l&&o1(l,u)){l.items.push(u);continue}l&&o.push(Ah(l,t)),l={items:[u]}}return l&&o.push(Ah(l,t)),o}function o1(i,t){let e=i.items[i.items.length-1];return!(t.fontObjId!==e.fontObjId||Math.abs(t.fontSizePt-e.fontSizePt)>1||Math.abs(t.baselineYPt-e.baselineYPt)>2||t.originXPt-(e.originXPt+e.advancePt)>.5*t.fontSizePt)}function a1(i,t,e,n){let s=t[i.fontObjId];if(!s)return null;let o=wh(e,i.textMatrix),l=[i.fontSize,0,0,i.fontSize,0,0],u=wh(o,l),d=Math.hypot(u[2],u[3]),p=o[4],m=n-o[5],b=l1(i,s,d);return{glyph:i,fontObjId:i.fontObjId,fontSizePt:d,originXPt:p,baselineYPt:m,advancePt:b}}function l1(i,t,e){let n=t._parsed;if(n&&i.unicode)try{let s=n.charToGlyph?.(i.unicode);if(s&&s.advanceWidth&&n.unitsPerEm)return s.advanceWidth/n.unitsPerEm*e}catch{}return .5*e}function Ah(i,t){let e=i.items,n=e[0],s=e[e.length-1],l=t[n.fontObjId]?._parsed,u=Th(e.map(I=>I.fontSizePt)),d=l?.unitsPerEm??1e3,p=l?.ascender?l.ascender/d*u:.8*u,m=l?.descender?Math.abs(l.descender/d)*u:.2*u,b=n.originXPt,v=Th(e.map(I=>I.baselineYPt)),x=s.originXPt+s.advancePt-b+.05*u*e.length,w="",k=null;for(let I of e){let P=I.glyph.unicode??"";if(k){let M=k.originXPt+k.advancePt;I.originXPt-M>.2*I.fontSizePt&&!P.startsWith(" ")&&!w.endsWith(" ")&&(w+=" ")}w+=P,k=I}return{glyphs:e.map(I=>I.glyph),fontObjId:n.fontObjId,fontSizePt:u,originXPt:b,baselineYPt:v,widthPt:x,ascenderPt:p,descenderPt:m,text:w}}function Th(i){return i.length===0?0:i.reduce((t,e)=>t+e,0)/i.length}function wh(i,t){let[e,n,s,o,l,u]=i,[d,p,m,b,v,A]=t;return[e*d+s*p,n*d+o*p,e*m+s*b,n*m+o*b,e*v+s*A+l,n*v+o*A+u]}function jt(i){return Number.isFinite(i)?i.toFixed(1):String(i)}function ye(i){if(!i)return"(unknown position)";let t=typeof i.x=="number"?jt(i.x):"?",e=typeof i.y=="number"?jt(i.y):"?",n=typeof i.width=="number"?jt(i.width):"?",s=typeof i.height=="number"?jt(i.height):"?";return`(${t}, ${e}) ${n}\xD7${s} pt`}function Ch(i){if(!i||i.length<6)return"[invalid]";let[t,e,n,s,o,l]=i;return`[a=${jt(t)}, b=${jt(e)}, c=${jt(n)}, d=${jt(s)}, e=${jt(o)}, f=${jt(l)}]`}function Pi(i){if(i==null)return"none";if(typeof i!="object")return String(i);let t=i;if("type"in t)switch(t.type){case"rgb":return`rgb(${be(t.r)}, ${be(t.g)}, ${be(t.b)})`;case"cmyk":return`cmyk(${be(t.c)}, ${be(t.m)}, ${be(t.y)}, ${be(t.k)})`;case"spot":{let e=typeof t.name=="string"?`"${t.name}"`:"(unnamed)",n=typeof t.tint=="number"?`, tint=${be(t.tint)}`:"",s=t.fallback_rgb,o=Array.isArray(s)?`, fallback=rgb(${be(s[0])}, ${be(s[1])}, ${be(s[2])})`:", no fallback";return`spot ${e}${n}${o}`}default:return`type="${String(t.type)}"`}if("space"in t&&Array.isArray(t.values)){let e=t.values.map(n=>be(n)).join(", ");return`${String(t.space)}(${e})`}return"r"in t&&"g"in t&&"b"in t?`rgb(${be(t.r)}, ${be(t.g)}, ${be(t.b)})`:"(opaque)"}function be(i){return Number.isFinite(i)?i.toFixed(2):String(i)}function ml(){return[]}function kh(i,t,e,n){return[...i,{path:t,fillRule:e,ctm:n.slice()}]}function bl(i){return i.slice()}function Ih(i){return i.pop()??ml()}function cr(i){return i.length===0}var Vn=Object.freeze({moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19}),WA=Object.freeze([1,0,0,1,0,0]);function c1(i,t,e){let n=i.ops??[],s=i.coords??[],o=[],l=[],u=0,d=null,[p,m,b,v,A,x]=t,w=(k,I)=>[p*k+b*I+A,e-(m*k+v*I+x)];for(let k=0;k<n.length;k++)switch(n[k]){case Vn.rectangle:{let I=s[u++],P=s[u++],M=s[u++],N=s[u++],D=w(I,P),U=w(I+M,P),G=w(I+M,P+N),H=w(I,P+N);o.push({cmd:"M",pts:[D]}),o.push({cmd:"L",pts:[U]}),o.push({cmd:"L",pts:[G]}),o.push({cmd:"L",pts:[H]}),o.push({cmd:"Z"}),l.push(D,U,G,H);break}case Vn.moveTo:{let I=w(s[u++],s[u++]);o.push({cmd:"M",pts:[I]}),l.push(I),d=I;break}case Vn.lineTo:{let I=w(s[u++],s[u++]);o.push({cmd:"L",pts:[I]}),l.push(I),d=I;break}case Vn.curveTo:{let I=w(s[u++],s[u++]),P=w(s[u++],s[u++]),M=w(s[u++],s[u++]);o.push({cmd:"C",pts:[I,P,M]}),l.push(I,P,M),d=M;break}case Vn.curveTo2:{let I=w(s[u++],s[u++]),P=w(s[u++],s[u++]),M=d??I;o.push({cmd:"C",pts:[M,I,P]}),l.push(I,P),d=P;break}case Vn.curveTo3:{let I=w(s[u++],s[u++]),P=w(s[u++],s[u++]);o.push({cmd:"C",pts:[I,P,P]}),l.push(I,P),d=P;break}case Vn.closePath:o.push({cmd:"Z"});break;default:break}return{cmds:o,devPoints:l}}function u1(i){if(i.length===0)return{x:0,y:0,width:0,height:0};let t=1/0,e=1/0,n=-1/0,s=-1/0;for(let[o,l]of i)o<t&&(t=o),l<e&&(e=l),o>n&&(n=o),l>s&&(s=l);return{x:t,y:e,width:n-t,height:s-e}}function h1(i,t,e){let n=o=>`${Math.round(o*100)/100}`,s=[];for(let o of i){if(o.cmd==="Z"){s.push("Z");continue}let l=o.pts.map(([u,d])=>`${n(u-t)} ${n(d-e)}`).join(" ");s.push(`${o.cmd} ${l}`)}return s.join(" ")}function Ri(i,t,e){let{cmds:n,devPoints:s}=c1(i,t,e);if(s.length===0)return null;let o=u1(s);return{...o,d:h1(n,o.x,o.y),cmds:n,devPoints:s}}function tn(i,t){let e=[];for(let n of i){let s=d1(n,t);s&&e.push(s)}return e}function d1(i,t){let e=Ri(i.path,i.ctm,t.heightPt);return!e||e.width<=0&&e.height<=0?null:{d:e.d,x:e.x,y:e.y,width:e.width,height:e.height,fillRule:i.fillRule}}function Oi(i){if(!Array.isArray(i)&&!ArrayBuffer.isView(i))return null;let t=i;return Number.isSafeInteger(t.length)&&t.length>=0?t:null}function Ph({shadingIR:i,ctm:t,pageBox:e}){if(!Array.isArray(i)||i[0]!=="Mesh"||![4,5,6,7].includes(i[1])||t.length!==6||t.some(Q=>!Number.isFinite(Q))||!Number.isFinite(e.widthPt)||!Number.isFinite(e.heightPt)||e.widthPt<=0||e.heightPt<=0)return{status:"invalid"};let n=Oi(i[2]),s=Oi(i[3]),o=i[4];if(!n||!s||!Array.isArray(o)||n.length%2!==0||s.length%3!==0)return{status:"invalid"};let l=n.length+s.length+o.length;if(l>131072)return{status:"limit"};let u=0,d=[];for(let Q of o){if(Q==null||typeof Q!="object")return{status:"invalid"};let ot=Q,ct=Oi(ot.coords),X=Oi(ot.colors);if(!ct||!X||ct.length!==X.length)return{status:"invalid"};if(l+=ct.length+X.length,l>131072)return{status:"limit"};let $=0;if(ot.type==="triangles"){if(ct.length%3!==0)return{status:"invalid"};u+=ct.length/3}else if(ot.type==="lattice"){let ut=ot.verticesPerRow;if(typeof ut!="number"||!Number.isSafeInteger(ut)||ut<2||ct.length%ut!==0)return{status:"invalid"};$=ut,u+=Math.max(0,ct.length/ut-1)*(ut-1)*2}else return{status:"invalid"};if(u>8192)return{status:"limit"};d.push({type:ot.type,coords:ct,colors:X,verticesPerRow:$})}let p=new Map,m=new Map,b=[],v=[0,0,0],A=0,x=1/0,w=1/0,k=-1/0,I=-1/0,[P,M,N,D,U,G]=t;function H(Q,ot){let ct=Q.coords[ot],X=Q.colors[ot];if(!Number.isSafeInteger(ct)||ct<0||ct%2!==0||ct+1>=n.length||!Number.isSafeInteger(X)||X<0||X%3!==0||X+2>=s.length)return null;for(let ut=0;ut<3;ut++){let st=s[X+ut];if(!Number.isFinite(st)||st<0||st>255)return null}let $=p.get(ct);if(!$){let ut=n[ct],st=n[ct+1];if(!Number.isFinite(ut)||!Number.isFinite(st))return null;let St=P*ut+N*st+U,Ct=e.heightPt-(M*ut+D*st+G);if(!Number.isFinite(St)||!Number.isFinite(Ct))return null;$=[St,Ct],p.set(ct,$)}return{point:$,coord:ct,color:X}}function W(Q,ot,ct,X){let $=H(Q,ot),ut=H(Q,ct),st=H(Q,X);if(!$||!ut||!st)return!1;let[St,Ct,wt]=[$.point,ut.point,st.point],Et=(Ct[0]-St[0])*(wt[1]-St[1])-(Ct[1]-St[1])*(wt[0]-St[0]);if(!Number.isFinite(Et))return!1;if(Et===0)return!0;b.push(Et>0?[St,Ct,wt]:[St,wt,Ct]);for(let Vt of[$,ut,st]){x=Math.min(x,Vt.point[0]),w=Math.min(w,Vt.point[1]),k=Math.max(k,Vt.point[0]),I=Math.max(I,Vt.point[1]);let Ut=m.get(Vt.coord);if(Ut||m.set(Vt.coord,Ut=new Set),!Ut.has(Vt.color)){Ut.add(Vt.color);for(let at=0;at<3;at++)v[at]+=s[Vt.color+at];A++}}return!0}for(let Q of d)if(Q.type==="triangles"){for(let ot=0;ot<Q.coords.length;ot+=3)if(!W(Q,ot,ot+1,ot+2))return{status:"invalid"}}else{let ot=Q.verticesPerRow,ct=Q.coords.length/ot;for(let X=0;X<ct-1;X++)for(let $=0;$<ot-1;$++){let ut=X*ot+$;if(!W(Q,ut,ut+1,ut+ot)||!W(Q,ut+ot+1,ut+1,ut+ot))return{status:"invalid"}}}if(b.length===0)return{status:"empty"};let J=k-x,q=I-w;if(!Number.isFinite(J)||!Number.isFinite(q))return{status:"invalid"};let dt=Q=>`${Q[0]-x} ${Q[1]-w}`;return{status:"ok",triangleCount:b.length,block:{kind:"vector-path",x,y:w,width:J,height:q,d:b.map(([Q,ot,ct])=>`M ${dt(Q)} L ${dt(ot)} L ${dt(ct)} Z`).join(" "),fill:{space:"rgb",values:v.map(Q=>Q/(255*A))},stroke:null,strokeWidth:0,fillRule:"nonzero",opacity:1}}}function Rh({shadingIR:i,ctm:t,clipEntry:e,remainingClips:n,pageBox:s,opacity:o,blendMode:l,logger:u,pageIndex:d,isPattern:p=!1}){let m=Array.isArray(i)?i[0]:null,b=d!=null?`Page ${d}: `:"";if(m==="Dummy"||m==null)return u?.emit?.("SHADING_UNRESOLVED",{prefix:b,page:d}),null;if(m==="Mesh"){let U=Ph({shadingIR:i,ctm:t,pageBox:s}),G=Q=>(u?.emit?.("SHADING_MESH_GEOMETRY_DROPPED",{prefix:b,page:d,reason:Q}),null);if(U.status!=="ok")return G(U.status==="limit"?"its decoded geometry exceeds the import safety limit":U.status==="empty"?"it contains no non-degenerate triangles":"its decoded vertex or index data is invalid");let H=U.block;H.opacity=o??1,H.blendMode=l??void 0;let W=[...n,...e?[e]:[]],J=i,q=J[6];if(q!=null){if(!Array.isArray(q)||q.length!==4||!q.every(Q=>typeof Q=="number"&&Number.isFinite(Q))||q[2]<=q[0]||q[3]<=q[1])return G("its shading BBox is invalid or empty");W.push({path:{ops:[19],coords:[q[0],q[1],q[2]-q[0],q[3]-q[1]]},ctm:t,fillRule:"nonzero"})}let dt=tn(W,s);return dt.length!==W.length||dt.some(Q=>Q.width<=0||Q.height<=0)?null:(dt.length&&(H.clips=dt),u?.emit?.("SHADING_MESH_FLATTENED",{prefix:b,page:d,at:ye(H),triangles:U.triangleCount,fill:Pi(H.fill),background:p&&J[7]!=null?" The pattern background was omitted.":""}),H)}if(m!=="RadialAxial")return u?.emit?.("SHADING_UNKNOWN_IR_TAG",{prefix:b,tag:String(m),page:d}),null;let v=i,A=v[1],x=v[3],w=v[4],k=v[5],I=v[6],P=v[7],M=f1(x);if(M.length<2)return u?.emit?.("SHADING_INSUFFICIENT_STOPS",{prefix:b,page:d}),null;e==null&&u?.emit?.("SHADING_NO_CLIP_FALLBACK_BBOX",{prefix:b,page:d});let N=e?Ri(e.path,e.ctm,s.heightPt):null;if(!N||N.width<=0&&N.height<=0)return u?.emit?.("SHADING_CLIP_DEGENERATE",{prefix:b,page:d}),null;let D={kind:"vector-path",x:N.x,y:N.y,width:N.width,height:N.height,d:N.d,fill:null,stroke:null,strokeWidth:0,fillRule:e?.fillRule??"nonzero",opacity:1,blendMode:l??void 0};if(A==="axial"){let U=yl(w,t,s.heightPt),G=yl(k,t,s.heightPt);D.fill={kind:"linearGradient",start:U,end:G,stops:M}}else if(A==="radial"){typeof I=="number"&&I>.001&&u?.emit?.("SHADING_RADIAL_FOCAL_DROPPED",{prefix:b,page:d,innerRadius:I});let U=yl(k,t,s.heightPt),G=m1(t);D.fill={kind:"radialGradient",center:U,radius:Math.max(.001,Math.abs((P??0)*G)),stops:M}}else return u?.emit?.("SHADING_UNKNOWN_RADIAL_SUBTYPE",{prefix:b,kind:String(A),page:d}),null;if(o!=null&&o<1&&(D.opacity=o),n&&n.length>0){let U=tn(n,s);U.length>0&&(D.clips=U)}return D}function f1(i){if(!Array.isArray(i))return[];let t=[];for(let e of i){if(!Array.isArray(e)||e.length<2)continue;let n=g1(e[0]),s=p1(e[1]);if(!s)continue;let o={space:"rgb",values:s};t.push({offset:n,color:o})}return t}function p1(i){if(typeof i!="string")return null;if(i==="transparent")return[1,1,1];let t=/^#([0-9a-fA-F]{6})$/.exec(i.trim());if(!t)return null;let e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}function g1(i){return typeof i!="number"||!Number.isFinite(i)||i<0?0:i>1?1:i}function yl(i,t,e){let n=Array.isArray(i)?i[0]:0,s=Array.isArray(i)?i[1]:0,[o,l,u,d,p,m]=t;return{x:o*n+u*s+p,y:e-(l*n+d*s+m)}}function m1([i,t,e,n]){return Math.sqrt(Math.abs(i*n-t*e))}var b1=12,y1=85,v1=10,x1=11,S1=91,A1=22,T1=23,w1=24,E1=25,C1=28,k1=29,I1=30,P1=new Set([1,9,31,32,37,2,50,51,53,55,56,57,58,59,60,61]);async function Oh({page:i,pattern:t,logger:e,pageIndex:n}){let s=n!=null?`Page ${n}: `:"",{fnArray:o,argsArray:l}=t.operatorList,u=0,d=0,p=0,m=[],b=null,v=[1,0,0,1,0,0],A=[];for(let G=0;G<o.length;G++){let H=o[G],W=l[G]??[];switch(H){case v1:A.push(v.slice());break;case x1:v=A.pop()??[1,0,0,1,0,0];break;case b1:v=R1(v,W);break;case y1:{u++;let J=W[0],q=Number(W[1]??0)||0,dt=Number(W[2]??0)||0;typeof J=="string"&&m.push({objId:J,ctm:v.slice(),w:q,h:dt});break}case S1:{let J=W,q=J[2];if(q&&q.length>=4)b={w:q[2]-q[0],h:q[3]-q[1]};else{let dt=J[1];b=M1(dt)}break}case A1:case T1:case w1:case E1:b!=null?(p+=O1(b,v),b=null):d++;break;case C1:case k1:case I1:b=null;break;default:P1.has(H)||d++}}if(m.length===0)return e?.emit?.("TILING_PATTERN_UNSUPPORTED",{prefix:s,patternId:t.patternId,imageCount:u,otherOpCount:d,page:n,reason:"no-images"}),null;m.sort((G,H)=>H.w*H.h-G.w*G.h);let x=m[0],w=10,k=x.w*x.h,I=m.slice(1).reduce((G,H)=>G+H.w*H.h,0),P=Math.abs(x.ctm[0]*x.ctm[3]-x.ctm[1]*x.ctm[2]);if(!(d===0&&k>0&&k>=w*I&&P>=p))return e?.emit?.("TILING_PATTERN_UNSUPPORTED",{prefix:s,patternId:t.patternId,imageCount:u,otherOpCount:d,page:n,reason:"not-image-dominant",primarySrcArea:k,otherSrcArea:I,primaryPaintedArea:P,rectFillArea:p}),null;let D=(await(x.objId.startsWith("g_")?lr(i,x.objId):jn(i,x.objId))).data;if(!D)return e?.emit?.("TILING_PATTERN_IMAGE_DECODE_FAILED",{prefix:s,patternId:t.patternId,imageObjId:x.objId,page:n}),null;let U=await Ei(D,e,{objId:x.objId,pageIndex:n??void 0});return U?{bytes:U,width:D.width??0,height:D.height??0}:(e?.emit?.("TILING_PATTERN_IMAGE_DECODE_FAILED",{prefix:s,patternId:t.patternId,imageObjId:x.objId,page:n}),null)}function R1(i,t){let[e,n,s,o,l,u]=i,[d,p,m,b,v,A]=t;return[e*d+s*p,n*d+o*p,e*m+s*b,n*m+o*b,e*v+s*A+l,n*v+o*A+u]}function O1(i,t){return Math.abs(t[0]*t[3]-t[1]*t[2])*i.w*i.h}function M1(i){if(!i||i.length<2)return null;let t=1/0,e=1/0,n=-1/0,s=-1/0;for(let o=0;o+1<i.length;o+=2){let l=i[o],u=i[o+1];l<t&&(t=l),u<e&&(e=u),l>n&&(n=l),u>s&&(s=u)}return!Number.isFinite(t)||!Number.isFinite(e)?null:{w:n-t,h:s-e}}var L1=new Set([2,3,4,5,6,10,11,12,22,23,28,29,30,57,59,61,91]);function Mh(i,t,e,n){let{fnArray:s,argsArray:o}=i.operatorList;if(i.paintType!==1||s.length>512||s.length!==o.length||s.some(Q=>!L1.has(Q)))return null;let l=0,u=0,d=0;for(let Q=0;Q<s.length;Q++){if(s[Q]===10&&++l>32||s[Q]===11&&--l<0)return null;if(s[Q]===91){let ot=o[Q]?.[1],ct=o[Q]?.[0];if(ot==null||ct==null||(u+=ot.length,d+=ct.length,u>16384||d>4096||Array.from(ot).some(X=>!Number.isFinite(X))))return null}if(s[Q]===12&&(o[Q].length!==6||o[Q].some(ot=>typeof ot!="number"||!Number.isFinite(ot))))return null}if(l!==0)return null;let p=i.matrix,m=i.bbox,b=Math.abs(i.xStep),v=Math.abs(i.yStep);if(p.length!==6||m.length!==4||[...p,...m,b,v,t.x,t.y,t.width,t.height].some(Q=>!Number.isFinite(Q))||!(b>0&&v>0&&m[2]>m[0]&&m[3]>m[1])||m[2]-m[0]>b+1e-8||m[3]-m[1]>v+1e-8)return null;let[A,x,w,k,I,P]=p,M=A*k-x*w;if(Math.abs(M)<1e-8)return null;let N=[],D=[];for(let Q of[t.x,t.x+t.width])for(let ot of[t.y,t.y+t.height]){let ct=Q+n.x-I,X=e-ot+n.y-P;N.push((k*ct-w*X)/M),D.push((-x*ct+A*X)/M)}let U=Math.floor((Math.min(...N)-m[2])/b+1e-9)+1,G=Math.ceil((Math.max(...N)-m[0])/b-1e-9)-1,H=Math.floor((Math.min(...D)-m[3])/v+1e-9)+1,W=Math.ceil((Math.max(...D)-m[1])/v-1e-9)-1,J=Math.max(0,G-U+1)*Math.max(0,W-H+1),q=J*(s.length+10+u+d);if(![U,G,H,W,J].every(Number.isSafeInteger)||J>1024||q>32768)return null;let dt=[];for(let Q=H;Q<=W;Q++)for(let ot=U;ot<=G;ot++)dt.push({fnArray:[12,12,91,29,28,...s],argsArray:[p,[1,0,0,1,ot*b,Q*v],[[19],[m[0],m[1],m[2]-m[0],m[3]-m[1]]],[],[],...o]});return{tiles:dt,work:q}}var D1={0:"Butt",1:"Round",2:"Square"},et={setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,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,beginText:31,endText:32,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,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColorN:53,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,paintImageXObject:85,paintInlineImageXObject:86,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,shadingFill:62},wn=[1,0,0,1,0,0];async function Hh(i,t,e={}){let n=e.textMode??"outline",s=e.docFonts??new Map,o=e.logger,l=e.pageIndex,{opList:u}=await lh(i),d=await _1(i,u,{logger:o,pageIndex:l}),p=i.colorSpaceResources??{};Object.values(p).some(v=>v.kind==="deviceN")&&o?.emit?.("COLOR_DEVICEN_INKS_NOT_PRESERVED",{prefix:l!=null?`Page ${l}: `:""});let{out:m,colorSnapshots:b}=await jh(u,t,i,d,{textMode:n,docFonts:s,logger:o,pageIndex:l,colorSpaceResources:p});return{out:m,colorSnapshots:b,finalize:()=>Z1(Vh(m),t,e.preserveWhitePageBackground)}}async function _1(i,t,e={}){let n=new Set,s=t.fnArray,o=t.argsArray;for(let u=0;u<s.length;u++)s[u]===et.setFont&&n.add(o[u][0]);let l={};for(let u of n){let d=(await lr(i,u)).data;if(d&&!d.isType3Font&&d.data){let p=d.name||d.loadedName||d.fallbackName||`(font object ${u})`;d._parsed=await N1(d.data,p,e)}l[u]=d}return l}async function N1(i,t,e={}){try{let{default:n}=await Promise.resolve().then(()=>Ou(pl(),1)),s=i instanceof Uint8Array?i:new Uint8Array(i),o=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength);return n.parse(o)}catch(n){let s=e.pageIndex!=null?`Page ${e.pageIndex}: `:"",o=n&&typeof n=="object"&&"message"in n?String(n.message):null,l=o?` (${o})`:"";return e.logger?.emit?.("FONT_OPENTYPE_PARSE_FAILED",{prefix:s,fontName:t,reason:l,page:e.pageIndex,error:o}),null}}async function jh(i,t,e,n,s){let o=i.fnArray,l=i.argsArray,u=[],d=s?.colorSpaceResources??{},p=[],m=s.pageIndex!=null?`Page ${s.pageIndex}: `:"",b=!1,v=()=>{b||(b=!0,s.logger?.emit?.("COLOR_DEVICEN_TINT_UNRESOLVED",{prefix:m}))},A=t.originShiftPt??{x:0,y:0},x=Uh(A),w=[],k=null,I=ml(),P=[],M=null,N=[],D=[],U=[],G=null,H=[],W=[],J=[],q=[],dt=[],Q=0,ot=!1,ct=[],X=()=>ct.some(_=>_.suppressing),$=null,ut=null,st=null,St=_=>{let V=s.pageIndex!=null?`Page ${s.pageIndex}: `:"";s.logger?.log?.(`${V}${_}`,"warning")},Ct=_=>{if(!Array.isArray(_)||_.length<4)return"(unknown bbox)";let[V,K,Z,tt]=_,nt=V/72,lt=(t.heightPt-tt)/72,z=Math.abs(Z-V)/72,it=Math.abs(tt-K)/72;return`(${nt.toFixed(2)} in, ${lt.toFixed(2)} in) ${z.toFixed(2)}\xD7${it.toFixed(2)} in`},wt=()=>{if(x.blendMode!=null&&x.blendMode!=="source-over")return x.blendMode;for(let _=H.length-1;_>=0;_--){let V=H[_];if(V!=null&&V!=="source-over")return V}return x.blendMode},Et=()=>{if(x.fillAlpha!=null&&x.fillAlpha<1)return x.fillAlpha;for(let _=W.length-1;_>=0;_--){let V=W[_];if(V!=null&&V<1)return V}return x.fillAlpha},Vt=()=>{G&&G.glyphs.length>0?U1(G,n,t,s):G&&De(G.placeholder),G=null};for(let _=0;_<o.length;_++){let V=o[_],K=l[_];switch(V){case et.save:w.push(x),x=Bh(x),P.push(bl(I));break;case et.restore:x=w.pop()??Uh(A),I=Ih(P);break;case et.paintFormXObjectBegin:J.push(Array.isArray(K?.[0])&&K[0].some((Z,tt)=>Z!==wn[tt])||x.ctm.some((Z,tt)=>Z!==[1,0,0,1,-A.x,-A.y][tt])),H.push(x.blendMode),W.push(x.fillAlpha),q.push(Bh(x));break;case et.paintFormXObjectEnd:{J.pop(),H.pop(),W.pop();let Z=q.pop();Z&&(x.blendMode=Z.blendMode,Z.fillAlpha!=null&&(x.fillAlpha=Z.fillAlpha),x.fillColor=Z.fillColor,x.fillColorSpaceName=Z.fillColorSpaceName,x.fillPattern=Z.fillPattern,x.strokeColor=Z.strokeColor,x.strokeColorSpaceName=Z.strokeColorSpaceName,x.strokeAlpha=Z.strokeAlpha,x.lineWidth=Z.lineWidth,x.lineDash=Z.lineDash,x.lineDashPhase=Z.lineDashPhase,x.lineCap=Z.lineCap,x.lineJoin=Z.lineJoin,x.miterLimit=Z.miterLimit);break}case et.beginGroup:{let Z=K?.[0]??{},tt=Z.smask!=null;dt.push(tt),tt&&Q++,ct.push({candidate:ot&&!tt,suppressing:!1}),tt&&Z.smask?.subtype==="Luminosity"&&($={groupBbox:Array.isArray(Z.bbox)?Z.bbox.slice():null,captured:null,abort:!1,abortReason:null}),ot&&!tt&&ut!=null&&st==null&&(st={mask:ut,target:x.fillColor!=null?{kind:"solid",color:x.fillColor}:null,formBbox:Array.isArray(Z.bbox)?Z.bbox.slice():null,alpha:null,aborted:!1},ut=null),ot=!1;break}case et.endGroup:{let Z=dt.pop();Z&&Q--;let tt=ct.pop();if(Z&&$!=null&&($.abort?St(`a luminosity SMask group at ${Ct($.groupBbox)} ${$.abortReason}. The shadow was dropped from the imported design.`):$.captured==null?St(`a luminosity SMask group at ${Ct($.groupBbox)} has no grayscale image content. The shadow was dropped from the imported design.`):ut={groupBbox:$.groupBbox,captured:$.captured},$=null),tt&&tt.candidate&&st!=null){let{mask:nt,target:lt,formBbox:z,alpha:it,aborted:Tt}=st;if(st=null,Tt)St(`a luminosity SMask at ${Ct(z)} modulates multiple images in one paint group (only single-paint targets are supported). The shadow was dropped from the imported design.`);else if(lt==null)St(`a luminosity SMask at ${Ct(z)} modulates an unsupported paint shape (no solid fill colour or image was captured). The shadow was dropped from the imported design.`);else if(lt.kind==="solid"){let zt=lt.color;if(zt.space!=="rgb"&&zt.space!=="cmyk"&&zt.space!=="gray")St(`a luminosity SMask at ${Ct(z)} modulates a non-solid fill (${zt.space}); compositing isn't supported. The shadow was dropped from the imported design.`);else if(nt.captured.kind!=="image")St(`a luminosity SMask at ${Ct(z)} uses a shading mask against a solid fill (only image masks are supported for solid targets). The shadow was dropped from the imported design.`);else{let _e={kind:"image",_placeholderIndex:u.length};u.push(_e);let Ne=it??1;N.push({placeholder:_e,objId:nt.captured.objId,inline:null,ctm:nt.captured.ctm,opacity:Ne,blendMode:null,clips:null,compositeWith:zt})}}else{let zt={kind:"image",_placeholderIndex:u.length};u.push(zt),N.push({placeholder:zt,objId:lt.objId,inline:null,ctm:lt.ctm,opacity:1,blendMode:null,clips:null,compositeWithMask:{mask:nt.captured,maskGroupBbox:nt.groupBbox,modulatedAlpha:it??1}})}}break}case et.transform:x.ctm=Pe(x.ctm,K);break;case et.setLineWidth:x.lineWidth=K[0];break;case et.setLineCap:typeof K[0]=="number"&&(x.lineCap=K[0]);break;case et.setLineJoin:typeof K[0]=="number"&&(x.lineJoin=K[0]);break;case et.setMiterLimit:typeof K[0]=="number"&&(x.miterLimit=K[0]);break;case et.setDash:x.lineDash=Array.isArray(K[0])?K[0].slice():[],x.lineDashPhase=typeof K[1]=="number"?K[1]:0;break;case et.setFillRGBColor:x.fillColor=Fh(K),x.fillPattern=null;break;case et.setStrokeRGBColor:x.strokeColor=Fh(K);break;case et.setFillCMYKColor:x.fillColor={space:"cmyk",values:[K[0],K[1],K[2],K[3]]},x.fillPattern=null;break;case et.setStrokeCMYKColor:x.strokeColor={space:"cmyk",values:[K[0],K[1],K[2],K[3]]};break;case et.setFillGray:x.fillColor={space:"gray",values:[K[0]]},x.fillPattern=null;break;case et.setStrokeGray:x.strokeColor={space:"gray",values:[K[0]]};break;case et.setFillColorSpace:x.fillColorSpaceName=K?.[0]??null,x.fillColorSpaceName!=="Pattern"&&(x.fillPattern=null);break;case et.setStrokeColorSpace:x.strokeColorSpaceName=K?.[0]??null;break;case et.setFillColorN:{if(K?.[0]==="Shading"){x.fillPattern={shadingId:K[1],matrix:Array.isArray(K[2])?K[2]:wn.slice()};break}let Z=X1(K);if(Z){x.fillPattern=Z;break}let{key:tt,components:nt}=Dh(K);x.fillColor=_h(tt??x.fillColorSpaceName,nt,d,x.fillColor,v),x.fillPattern=null;break}case et.setStrokeColorN:{let{key:Z,components:tt}=Dh(K);x.strokeColor=_h(Z??x.strokeColorSpaceName,tt,d,x.strokeColor,v);break}case et.setGState:{let Z=!1,tt=!1,nt=null;for(let[lt,z]of K[0]??[])lt==="BM"&&z==="multiply"&&(Z=!0),lt==="ca"&&typeof z=="number"&&(z<1&&(tt=!0),nt=z);if(Z&&tt&&ct.length>0){let lt=ct[ct.length-1];lt.candidate&&!lt.suppressing&&(lt.suppressing=!0)}st!=null&&nt!=null&&nt<(st.alpha??1)&&(st.alpha=nt);for(let[lt,z]of K[0]??[])if(lt==="SMask"&&(z===!0?ot=!0:(z===!1||z==null)&&(ot=!1)),lt==="ca"&&typeof z=="number")x.fillAlpha=z;else if(lt==="CA"&&typeof z=="number")x.strokeAlpha=z;else if(lt==="LW"&&typeof z=="number")x.lineWidth=z;else if(lt==="LC"&&typeof z=="number")x.lineCap=z;else if(lt==="LJ"&&typeof z=="number")x.lineJoin=z;else if(lt==="ML"&&typeof z=="number")x.miterLimit=z;else if(lt==="D"&&Array.isArray(z))x.lineDash=Array.isArray(z[0])?z[0].slice():[],x.lineDashPhase=typeof z[1]=="number"?z[1]:0;else if(lt==="BM"){if(typeof z=="string"&&z!=="")x.blendMode=z;else if(Array.isArray(z)){for(let it of z)if(typeof it=="string"&&it!==""){x.blendMode=it;break}}}break}case et.constructPath:k={ops:K[0],coords:K[1],minMax:K[2]};break;case et.clip:M="nonzero";break;case et.eoClip:M="evenodd";break;case et.fill:case et.eoFill:case et.stroke:case et.closeStroke:case et.fillStroke:case et.eoFillStroke:case et.closeFillStroke:case et.closeEOFillStroke:case et.endPath:{if(M&&k!=null&&(I=kh(I,k,M,x.ctm),M=null),k==null)break;let Z=j1(V);if(Z){if(x.textClipActive){ur(s,x.ctm,t,`vector ${Z}`),k=null;break}if(Q>0&&$!=null&&($.abort=!0,$.abortReason="contains vector paint operations (only single-paint image or shading masks are supported)"),Q>0||X()){k=null;break}if(Z.fill&&x.fillPattern&&"shadingId"in x.fillPattern){if(J.some(Boolean)&&(s.logger?.emit?.("SHADING_PATTERN_TRANSFORM_UNSUPPORTED",{prefix:s.pageIndex!=null?`Page ${s.pageIndex}: `:"",page:s.pageIndex}),Z.fill=!1,!Z.stroke)){k=null;break}if(Z.fill){let nt={kind:"vector-path",_placeholderIndex:u.length};if(u.push(nt),D.push({placeholder:nt,patternId:x.fillPattern.shadingId,isPattern:!0,ctm:Pe([1,0,0,1,-A.x,-A.y],x.fillPattern.matrix),clipEntry:{path:k,ctm:x.ctm.slice(),fillRule:Z.fillRule},remainingClips:bl(I),opacity:Et(),blendMode:wt()}),s.logger?.emit?.("SHADING_COLORSPACE_CONVERTED",{prefix:s.pageIndex!=null?`Page ${s.pageIndex}: `:"",page:s.pageIndex}),!Z.stroke){k=null;break}Z.fill=!1}}if(Z.fill&&x.fillPattern&&!("shadingId"in x.fillPattern)){let nt=Y1(k);if(nt){let lt=K1(x.ctm,nt),z={kind:"image",_placeholderIndex:u.length};u.push(z),U.push({placeholder:z,pattern:x.fillPattern,placementCtm:lt,fillClip:tn([{path:k,ctm:x.ctm.slice(),fillRule:Z.fillRule}],t)[0]??null,insideForm:J.length>0,opacity:Et(),blendMode:wt(),clips:cr(I)?null:tn(I,t)})}if(Z.fill=!1,!Z.stroke){k=null;break}}let tt=Nh(k,Z,x,t);if(tt){tt.blendMode=wt();let nt=Et();nt!=null&&nt<1&&(tt.opacity=nt),Lh(tt,I,t),u.push(tt)}}k=null;break}case et.paintImageXObject:{if(Q>0&&$!=null&&($.captured!=null?($.abort=!0,$.abortReason="contains multiple paint operations; only single-paint masks are supported"):$.captured={kind:"image",objId:K[0],ctm:x.ctm.slice()}),Q>0||X())break;if(st!=null){st.target?.kind==="image"?(st.target=null,st.aborted=!0):!st.aborted&&(st.target==null||st.target.kind==="solid")&&(st.target={kind:"image",objId:K[0],ctm:x.ctm.slice()});break}if(x.textClipActive){ur(s,x.ctm,t,`image objId="${K[0]}"`);break}let Z={kind:"image",_placeholderIndex:u.length};u.push(Z),N.push({placeholder:Z,objId:K[0],inline:null,ctm:x.ctm.slice(),opacity:Et(),blendMode:wt(),clips:cr(I)?null:tn(I,t)});break}case et.paintInlineImageXObject:{if(Q>0&&$!=null&&($.abort=!0,$.abortReason="contains an inline image (only image-xobject masks are supported)"),Q>0||X())break;if(x.textClipActive){ur(s,x.ctm,t,"inline image");break}let Z={kind:"image",_placeholderIndex:u.length};u.push(Z),N.push({placeholder:Z,objId:null,inline:K[0],ctm:x.ctm.slice(),opacity:Et(),blendMode:wt(),clips:cr(I)?null:tn(I,t)});break}case et.paintImageMaskXObject:{if(Q>0&&$!=null&&($.abort=!0,$.abortReason="contains a paintImageMaskXObject (only single-paint image or shading masks are supported)"),Q>0||X())break;let tt=(K[0]??{}).data;if(x.textClipActive){ur(s,x.ctm,t,`image mask objId="${tt}"`);break}if(x.fillColor==null){let lt=s.pageIndex!=null?`Page ${s.pageIndex}: `:"";s.logger?.emit?.("IMAGE_MASK_NO_FILL_COLOR",{prefix:lt,objId:tt??null,page:s.pageIndex});break}let nt={kind:"image",_placeholderIndex:u.length};u.push(nt),N.push({placeholder:nt,objId:tt,inline:null,stencilFill:x.fillColor,ctm:x.ctm.slice(),opacity:Et(),blendMode:wt(),clips:cr(I)?null:tn(I,t)});break}case et.paintSolidColorImageMask:{if(Q>0&&$!=null&&($.abort=!0,$.abortReason="contains a paintSolidColorImageMask (only single-paint image or shading masks are supported)"),Q>0||X())break;if(x.textClipActive){ur(s,x.ctm,t,"solid-colour image mask");break}if(x.fillColor==null){let nt=s.pageIndex!=null?`Page ${s.pageIndex}: `:"";s.logger?.emit?.("IMAGE_MASK_NO_FILL_COLOR",{prefix:nt,objId:null,page:s.pageIndex});break}let Z={ops:[et.rectangle],coords:[0,0,1,1]},tt=Nh(Z,{fill:!0,stroke:!1,fillRule:"nonzero"},x,t);if(tt){tt.blendMode=wt();let nt=Et();nt!=null&&nt<1&&(tt.opacity=nt),Lh(tt,I,t),u.push(tt)}break}case et.paintImageMaskXObjectGroup:{if(Q>0&&$!=null&&($.abort=!0,$.abortReason="contains a paintImageMaskXObjectGroup (only single-paint image or shading masks are supported)"),Q>0||X())break;let Z=s.pageIndex!=null?`Page ${s.pageIndex}: `:"",tt=Array.isArray(K[0])?K[0].length:0;s.logger?.emit?.("IMAGE_MASK_GROUP_UNSUPPORTED",{prefix:Z,count:tt,page:s.pageIndex});break}case et.paintImageMaskXObjectRepeat:{if(Q>0&&$!=null&&($.abort=!0,$.abortReason="contains a paintImageMaskXObjectRepeat (only single-paint image or shading masks are supported)"),Q>0||X())break;let Z=s.pageIndex!=null?`Page ${s.pageIndex}: `:"",tt=K[5],nt=Array.isArray(tt)?Math.floor(tt.length/2):0;s.logger?.emit?.("IMAGE_MASK_REPEAT_UNSUPPORTED",{prefix:Z,count:nt,page:s.pageIndex});break}case et.shadingFill:{if(Q>0&&$!=null&&($.captured!=null?($.abort=!0,$.abortReason="contains a shading fill plus another paint (only single-paint masks are supported)"):$.captured={kind:"shading",patternId:K?.[0],ctm:x.ctm.slice()}),Q>0||X())break;if(x.textClipActive){ur(s,x.ctm,t,"shading fill");break}let Z={kind:"vector-path",_placeholderIndex:u.length};u.push(Z);let tt=I.length>0?I[I.length-1]:null,nt=I.length>1?I.slice(0,-1):[];D.push({placeholder:Z,patternId:K?.[0],ctm:x.ctm.slice(),clipEntry:tt??null,remainingClips:nt,opacity:Et(),blendMode:wt()});break}case et.beginText:x.textMatrix=wn.slice(),x.textLineMatrix=wn.slice();break;case et.endText:Vt();break;case et.setFont:x.fontObjId=K[0],x.fontSize=K[1];break;case et.setTextMatrix:x.textMatrix=[K[0],K[1],K[2],K[3],K[4],K[5]],x.textLineMatrix=x.textMatrix.slice();break;case et.moveText:{x.textLineMatrix=Pe(x.textLineMatrix,[1,0,0,1,K[0],K[1]]),x.textMatrix=x.textLineMatrix.slice();break}case et.setLeadingMoveText:{x.textLeading=-K[1],x.textLineMatrix=Pe(x.textLineMatrix,[1,0,0,1,K[0],K[1]]),x.textMatrix=x.textLineMatrix.slice();break}case et.nextLine:{x.textLineMatrix=Pe(x.textLineMatrix,[1,0,0,1,0,-x.textLeading]),x.textMatrix=x.textLineMatrix.slice();break}case et.setLeading:x.textLeading=K[0];break;case et.setCharSpacing:x.charSpacing=K[0];break;case et.setWordSpacing:x.wordSpacing=K[0];break;case et.setHScale:x.textHScale=K[0]/100;break;case et.setTextRise:x.textRise=K[0];break;case et.setTextRenderingMode:x.textRenderingMode=K[0]??0;break;case et.showText:case et.nextLineShowText:case et.nextLineSetSpacingShowText:case et.showSpacedText:{let Z=(V===et.showText||V===et.nextLineShowText,K[0]);if(x.textRenderingMode===7&&(x.textClipActive=!0),!G){let nt={_placeholder:!0};u.push(nt),G={placeholder:nt,ctm:x.ctm.slice(),fillColor:x.fillColor,fillAlpha:x.fillAlpha,fontObjIdFirst:x.fontObjId,textString:"",glyphs:[]}}let tt=(()=>{let nt=Pe(x.ctm,x.textMatrix),lt={fontObjId:x.fontObjId??"",baselineX:nt[4],baselineY:nt[5],fill:Mi(x.fillColor,Et()),text:"",placeholder:G.placeholder,renderMode:x.textRenderingMode};return p.push(lt),lt})();for(let nt of Z){if(typeof nt=="number"){let zt=-nt*.001*x.fontSize*x.textHScale;x.textMatrix[4]+=zt*x.textMatrix[0],x.textMatrix[5]+=zt*x.textMatrix[1];continue}G.textString+=nt.unicode??"",tt.text+=nt.unicode??"",nt.isInFont!==!1&&G.glyphs.push({operatorListId:nt.operatorListId,fontChar:nt.fontChar,unicode:nt.unicode,fontObjId:x.fontObjId??"",fontSize:x.fontSize,textMatrix:x.textMatrix.slice()});let z=(x.fontObjId!=null?n[x.fontObjId]:null)?.fontMatrix?.[0]??.001,Tt=((nt.width??0)*z*x.fontSize+x.charSpacing+(nt.isSpace?x.wordSpacing:0))*x.textHScale;x.textMatrix[4]+=Tt*x.textMatrix[0],x.textMatrix[5]+=Tt*x.textMatrix[1]}break}default:break}}Vt();for(let _ of N){let V=_.inline,K="ok";if(!V){let nt=typeof _.objId=="string"&&_.objId.startsWith("g_"),lt=typeof _.objId=="string"?_.objId:null,z=await(nt?lr(e,lt):jn(e,lt));V=z.data,K=z.reason}if(!V){let nt=s.pageIndex!=null?`Page ${s.pageIndex}: `:"",lt=Tn(_.ctm,t.heightPt),z=_.objId?`objId="${_.objId}"`:"inline image";s.logger?.emit?.("IMAGE_PDFJS_UNRESOLVED",{prefix:nt,idLabel:z,bboxX:jt(lt.x),bboxY:jt(lt.y),bboxW:jt(lt.w),bboxH:jt(lt.h),page:s.pageIndex,objId:_.objId??null,reason:K}),De(_.placeholder);continue}let Z=null;if(_.stencilFill){if(Z=await hh(V,_.stencilFill,s.logger,{objId:typeof _.objId=="string"?_.objId:null,pageIndex:s.pageIndex}),!Z){let nt=s.pageIndex!=null?`Page ${s.pageIndex}: `:"",lt=Tn(_.ctm,t.heightPt),z=_.stencilFill?.space??"unknown";s.logger?.emit?.("IMAGE_MASK_COMPOSITE_FAIL",{prefix:nt,objId:_.objId??null,bboxX:jt(lt.x),bboxY:jt(lt.y),bboxW:jt(lt.w),bboxH:jt(lt.h),colourSpace:z,page:s.pageIndex}),De(_.placeholder);continue}}else if(_.compositeWith){if(Z=await uh(V,_.compositeWith,s.logger,{objId:typeof _.objId=="string"?_.objId:null,pageIndex:s.pageIndex}),!Z){let nt=s.pageIndex!=null?`Page ${s.pageIndex}: `:"",lt=Tn(_.ctm,t.heightPt),z=_.compositeWith?.space??"unknown",it=V?.kind,Tt=it!=null?`kind=${it}`:"bitmap";s.logger?.log?.(`${nt}a luminosity SMask at (${lt.x.toFixed(2)} in, ${lt.y.toFixed(2)} in) ${lt.w.toFixed(2)}\xD7${lt.h.toFixed(2)} in could not be composited (mask ${Tt}, fill colour space "${z}"). The shadow was dropped from the imported design.`,"warning"),De(_.placeholder);continue}}else if(_.compositeWithMask){let nt=_.compositeWithMask.mask,lt=null;if(nt.kind==="image"){let it=typeof nt.objId=="string"?nt.objId:null,zt=await(typeof it=="string"&&it.startsWith("g_")?lr(e,it):jn(e,it));zt.data!=null&&(lt={kind:"image",obj:zt.data,ctm:nt.ctm})}else{let it=typeof nt.patternId=="string"?nt.patternId:null;if(it!=null){let Tt=await jn(e,it);Tt.data!=null&&(lt={kind:"shading",ir:Tt.data,ctm:nt.ctm})}}if(lt==null){let it=s.pageIndex!=null?`Page ${s.pageIndex}: `:"",Tt=Tn(_.ctm,t.heightPt);s.logger?.log?.(`${it}a luminosity SMask at (${Tt.x.toFixed(2)} in, ${Tt.y.toFixed(2)} in) could not resolve its mask source (${nt.kind}). The shadow was dropped from the imported design.`,"warning"),De(_.placeholder);continue}let z=await fh({maskSource:lt,imageObj:V,imageCtm:_.ctm,modulatedAlpha:_.compositeWithMask.modulatedAlpha,pageBox:t,logger:s.logger,pageIndex:s.pageIndex});if(!z){let it=s.pageIndex!=null?`Page ${s.pageIndex}: `:"",Tt=Tn(_.ctm,t.heightPt);s.logger?.log?.(`${it}a luminosity SMask at (${Tt.x.toFixed(2)} in, ${Tt.y.toFixed(2)} in) failed to rasterize (${nt.kind} mask shape unsupported). The shadow was dropped from the imported design.`,"warning"),De(_.placeholder);continue}if(Z=await ph(V,z),!Z){De(_.placeholder);continue}}else if(Z=await Ei(V,s.logger,{objId:typeof _.objId=="string"?_.objId:null,ctm:_.ctm,pageIndex:s.pageIndex}),!Z){De(_.placeholder);continue}let tt=Tn(_.ctm,t.heightPt,{logger:s.logger,pageIndex:s.pageIndex,objId:_.objId});Object.assign(_.placeholder,{kind:"image",x:tt.x,y:tt.y,width:tt.w,height:tt.h,mimeType:"image/png",bytes:Z,opacity:_.opacity??1,...Math.abs(tt.rotation)>1e-6?{rotation:tt.rotation}:{},...tt.flipHorizontal?{flipHorizontal:!0}:{},...tt.flipVertical?{flipVertical:!0}:{},..._.blendMode?{blendMode:_.blendMode}:{},..._.clips&&_.clips.length>0?{clips:_.clips}:{}})}let Ut=new Map,at=32768;for(let _ of U){if(!_.pattern.operatorList.fnArray.includes(et.paintImageXObject)){let tt=(_.opacity==null||_.opacity===1)&&(_.blendMode==null||_.blendMode==="source-over"),nt=_.fillClip&&!_.insideForm&&tt?Mh(_.pattern,_.fillClip,t.heightPt,A):null;if(nt==null||nt.work>at){s.logger?.emit?.("TILING_PATTERN_UNSUPPORTED",{prefix:s.pageIndex!=null?`Page ${s.pageIndex}: `:"",patternId:_.pattern.patternId,imageCount:0,otherOpCount:_.pattern.operatorList.fnArray.length,page:s.pageIndex}),De(_.placeholder);continue}at-=nt.work;let lt=[];for(let z of nt.tiles){let it=await jh(z,t,e,n,s);for(let Tt of Vh(it.out)){if(Tt.kind!=="vector-path")throw new Error("Vector tiling produced non-vector artwork");Tt.clips=[..._.clips??[],_.fillClip,...Tt.clips??[]],lt.push(Tt)}}Object.assign(_.placeholder,{_placeholder:!0,_replacements:lt});continue}let V=Ut.get(_.pattern.patternId)??null;if(V==null){let tt=await Oh({page:e,pattern:_.pattern,logger:s.logger,pageIndex:s.pageIndex});if(!tt){De(_.placeholder);continue}V=tt.bytes,Ut.set(_.pattern.patternId,V)}let K=s.pageIndex!=null?`Page ${s.pageIndex}: `:"";s.logger?.emit?.("TILING_PATTERN_AS_IMAGE",{prefix:K,patternId:_.pattern.patternId,page:s.pageIndex});let Z=Tn(_.placementCtm,t.heightPt,{logger:s.logger,pageIndex:s.pageIndex,objId:_.pattern.patternId});Object.assign(_.placeholder,{kind:"image",x:Z.x,y:Z.y,width:Z.w,height:Z.h,mimeType:"image/png",bytes:V,patternTile:!0,opacity:_.opacity??1,...Math.abs(Z.rotation)>1e-6?{rotation:Z.rotation}:{},...Z.flipHorizontal?{flipHorizontal:!0}:{},...Z.flipVertical?{flipVertical:!0}:{},..._.blendMode?{blendMode:_.blendMode}:{},..._.clips&&_.clips.length>0?{clips:_.clips}:{}})}for(let _ of D){let V=s.pageIndex!=null?`Page ${s.pageIndex}: `:"";if(typeof _.patternId!="string"){s.logger?.emit?.("SHADING_NO_PATTERN_REF",{prefix:V,page:s.pageIndex}),De(_.placeholder);continue}let K=(await jn(e,_.patternId)).data,Z=Rh({shadingIR:K,ctm:_.ctm,clipEntry:_.clipEntry,remainingClips:_.remainingClips,pageBox:t,opacity:_.opacity,blendMode:_.blendMode,logger:s.logger,pageIndex:s.pageIndex,isPattern:_.isPattern});if(!Z){De(_.placeholder);continue}Object.assign(_.placeholder,Z)}return{out:u,colorSnapshots:p}}function Vh(i){let t=[];for(let e of i)if(!e._removed){if(e._placeholder){Array.isArray(e._replacements)&&t.push(...e._replacements);continue}t.push(e)}return t}function U1(i,t,e,n){let s=n?.textMode??"outline",o=[];if(i.placeholder._replacements=o,s==="outline"){let d=vl(i,i.glyphs,t,e);d&&o.push(d);return}let l=Eh(i.glyphs,t,i.ctm,e.heightPt),u=[];i.placeholder._lazyGlyphOutlines=u;for(let d of l){let p=t[d.fontObjId];if(xh(p,d.glyphs)){let b=d;u.push(()=>{let v=vl(i,b.glyphs,t,e);return!v||v.kind!=="text-outline"?null:{d:v.d,x:v.x,y:v.y,width:v.width,height:v.height}});continue}if(s==="editable"){let b=p?.name??d.fontObjId;throw new Error(`textMode 'editable': embeddability gate failed for font ${b} (text: ${JSON.stringify(d.text)})`)}let m=vl(i,d.glyphs,t,e);m&&o.push(m)}}function vl(i,t,e,n){if(!t||t.length===0)return null;let s=[],o=[],l=0,u=0,d="";for(let ct of t){let X=e[ct.fontObjId];if(!X)continue;let $=X.fontMatrix??[.001,0,0,.001,0,0],ut=[ct.fontSize,0,0,ct.fontSize,0,0],st=Pe(ut,$);st=Pe(ct.textMatrix,st),st=Pe(i.ctm,st);let St=null;if(X.isType3Font?St=B1(X,ct.operatorListId):X._parsed&&(St=H1(X,ct)),St){let wt=Wh(St,st,n.heightPt);s.push(...wt.cmds),o.push(...wt.devPoints)}let Ct=Pe(i.ctm,Pe(ct.textMatrix,ut));l+=Math.hypot(Ct[2],Ct[3]),u+=1,d+=ct.unicode??""}let p=u>0?l/u:0,m=1/0,b=1/0,v=-1/0,A=-1/0;for(let[ct,X]of o)ct<m&&(m=ct),X<b&&(b=X),ct>v&&(v=ct),X>A&&(A=X);Number.isFinite(m)||(m=b=v=A=0);let x=e[t[0].fontObjId],{style:w,weight:k}=Sh(x),I=$r(x?.name??""),P=I.family||I.fullName,M=Pe(i.ctm,t[0].textMatrix),N=M[4],D=n.heightPt-M[5],U=-Math.atan2(M[1],M[0]),G=Math.cos(-U),H=Math.sin(-U),W=1/0,J=1/0,q=-1/0,dt=-1/0;for(let[ct,X]of o){let $=ct*G-X*H,ut=ct*H+X*G;$<W&&(W=$),ut<J&&(J=ut),$>q&&(q=$),ut>dt&&(dt=ut)}let Q=Number.isFinite(W)?Math.max(0,q-W):0,ot=Number.isFinite(J)?Math.max(0,dt-J):0;return{kind:"text-outline",x:m,y:b,width:Math.max(0,v-m),height:Math.max(0,A-b),d:$h(s,m,b),text:d,fontFamily:P,fontSize:p,fontStyle:w,fontWeight:k,fill:Mi(i.fillColor,i.fillAlpha),opacity:i.fillAlpha!=null&&i.fillAlpha<1?i.fillAlpha:1,textOriginX:N,textOriginY:D,rotation:U,unrotWidth:Q,unrotHeight:ot}}function B1(i,t){let e=i?.charProcOperatorList?.[t];if(!e)return null;let n=e.fnArray,s=e.argsArray,o={ops:[],coords:[]},l=wn,u=[];for(let d=0;d<n.length;d++)switch(n[d]){case et.save:u.push(l);break;case et.restore:l=u.pop()??wn;break;case et.transform:l=Pe(l,s[d]);break;case et.constructPath:G1(o,s[d][0],s[d][1],l);break;default:break}return o.ops.length===0?null:o}function G1(i,t,e,n){let[s,o,l,u,d,p]=n;if(s===1&&o===0&&l===0&&u===1&&d===0&&p===0){i.ops.push(...t),i.coords.push(...e);return}let m=o===0&&l===0,b=(A,x)=>{i.coords.push(s*A+l*x+d,o*A+u*x+p)},v=0;for(let A of t)switch(A){case et.rectangle:{let x=e[v++],w=e[v++],k=e[v++],I=e[v++];if(m){i.ops.push(et.rectangle),b(x,w),i.coords.push(s*k,u*I);break}i.ops.push(et.moveTo,et.lineTo,et.lineTo,et.lineTo,et.closePath),b(x,w),b(x+k,w),b(x+k,w+I),b(x,w+I);break}case et.moveTo:case et.lineTo:case et.curveTo2:case et.curveTo3:case et.curveTo:{let x=A===et.moveTo||A===et.lineTo?1:A===et.curveTo?3:2;i.ops.push(A);for(let w=0;w<x;w++)b(e[v++],e[v++]);break}default:i.ops.push(A);break}}function H1(i,t){let e=i._parsed;if(!e)return null;let n=null,s=e.encoding,o=m=>{if(m==null)return-1;let b=s?.cmap?.glyphIndexMap?.[m];if(typeof b=="number")return b;try{let v=s?.charToGlyphIndex?.(m);return typeof v=="number"?v:-1}catch{return-1}},l=t.fontChar?t.fontChar.codePointAt(0):null,u=o(l);if(u>0&&(n=e.glyphs.get(u)),!n)try{t.fontChar&&(n=e.charToGlyph(t.fontChar))}catch{}if((!n||n.index===0)&&t.unicode)try{let m=e.charToGlyph(t.unicode);m&&m.index>0&&(n=m)}catch{}if(!n||!n.path||n.index===0)return null;let d=[],p=[];for(let m of n.path.commands)switch(m.type){case"M":d.push(et.moveTo),p.push(m.x,m.y);break;case"L":d.push(et.lineTo),p.push(m.x,m.y);break;case"C":d.push(et.curveTo),p.push(m.x1,m.y1,m.x2,m.y2,m.x,m.y);break;case"Q":{d.push(et.curveTo),p.push(m.x1,m.y1,m.x1,m.y1,m.x,m.y);break}case"Z":d.push(et.closePath);break;default:break}return d.length===0?null:{ops:d,coords:p}}function De(i){i._removed=!0}function Lh(i,t,e){if(cr(t))return;let n=tn(t,e);n.length>0&&(i.clips=n)}function Fh(i){return{space:"rgb",values:[i[0]/255,i[1]/255,i[2]/255]}}function Dh(i){if(!Array.isArray(i)||i.length===0)return{key:null,components:[]};let t=i[i.length-1];return typeof t=="string"||t===null?{key:typeof t=="string"?t:null,components:i.slice(0,-1)}:{key:null,components:i}}function _h(i,t,e,n,s){if(i==null)return n;switch(i){case"DeviceGray":return{space:"gray",values:[t?.[0]??0]};case"DeviceRGB":return{space:"rgb",values:[t?.[0]??0,t?.[1]??0,t?.[2]??0]};case"DeviceCMYK":return{space:"cmyk",values:[t?.[0]??0,t?.[1]??0,t?.[2]??0,t?.[3]??0]}}let o=e[i];if(!o)return n;if(o.kind==="separation"){let l=t?.[0]??1,u=Array.isArray(o.solid)?o.solid:[],d=u.map(p=>p*l);return{space:"spot",name:o.name,tint:l,alternateSpace:o.alternateSpace,solid:u,values:d}}if(o.kind==="deviceN"){s();let l=Array.isArray(o.solid)?o.solid:[];return o.alternateSpace==="DeviceCMYK"?{space:"cmyk",values:l.slice(0,4)}:o.alternateSpace==="DeviceGray"?{space:"gray",values:l.slice(0,1)}:{space:"rgb",values:l.slice(0,3)}}return n}function j1(i){switch(i){case et.fill:return{fill:!0,stroke:!1,fillRule:"nonzero"};case et.eoFill:return{fill:!0,stroke:!1,fillRule:"evenodd"};case et.stroke:case et.closeStroke:return{fill:!1,stroke:!0,fillRule:"nonzero"};case et.fillStroke:case et.closeFillStroke:return{fill:!0,stroke:!0,fillRule:"nonzero"};case et.eoFillStroke:case et.closeEOFillStroke:return{fill:!0,stroke:!0,fillRule:"evenodd"};default:return null}}function Nh(i,t,e,n){let s=V1(i,e.ctm,n.heightPt);if(!s)return null;let{devPoints:o,cmds:l}=s;if(o.length===0)return null;let u=1/0,d=1/0,p=-1/0,m=-1/0;for(let[G,H]of o)G<u&&(u=G),H<d&&(d=H),G>p&&(p=G),H>m&&(m=H);let b=p-u,v=m-d;if(b<=0&&v<=0)return null;let A=t.stroke?Math.abs(Gh(e.ctm)*e.lineWidth):0,x=Math.abs(Gh(e.ctm)),w=t.stroke&&e.lineDash.length>0?e.lineDash.map(G=>G*x):void 0,k=t.stroke?D1[e.lineCap]:void 0,I=t.stroke&&b<=0?A:0,P=t.stroke&&v<=0?A:0,M=u-I/2,N=d-P/2,D=b+I,U=v+P;return{kind:"vector-path",x:M,y:N,width:D,height:U,d:$h(l,M,N),fill:t.fill?Mi(e.fillColor,e.fillAlpha):null,stroke:t.stroke?Mi(e.strokeColor,e.strokeAlpha):null,strokeWidth:A,strokeDashArray:w,strokeDashOffset:w!=null?e.lineDashPhase*x:void 0,strokeCap:k,strokeJoin:t.stroke?["Miter","Round","Bevel"][e.lineJoin]:void 0,strokeMiterLimit:t.stroke?e.miterLimit:void 0,fillRule:t.fillRule,opacity:1,blendMode:e.blendMode}}function V1(i,t,e){return Wh(i,t,e)}function Wh(i,t,e){let n=i.ops??[],s=i.coords??[],o=[],l=[],u=0,d=null,p=(m,b)=>{let[v,A,x,w,k,I]=t;return[v*m+x*b+k,e-(A*m+w*b+I)]};for(let m=0;m<n.length;m++)switch(n[m]){case et.rectangle:{let v=s[u++],A=s[u++],x=s[u++],w=s[u++],k=p(v,A),I=p(v+x,A),P=p(v+x,A+w),M=p(v,A+w);l.push({cmd:"M",pts:[k]}),l.push({cmd:"L",pts:[I]}),l.push({cmd:"L",pts:[P]}),l.push({cmd:"L",pts:[M]}),l.push({cmd:"Z"}),o.push(k,I,P,M);break}case et.moveTo:{let v=p(s[u++],s[u++]);l.push({cmd:"M",pts:[v]}),o.push(v),d=v;break}case et.lineTo:{let v=p(s[u++],s[u++]);l.push({cmd:"L",pts:[v]}),o.push(v),d=v;break}case et.curveTo:{let v=p(s[u++],s[u++]),A=p(s[u++],s[u++]),x=p(s[u++],s[u++]);l.push({cmd:"C",pts:[v,A,x]}),o.push(v,A,x),d=x;break}case et.curveTo2:{let v=p(s[u++],s[u++]),A=p(s[u++],s[u++]),x=d??v;l.push({cmd:"C",pts:[x,v,A]}),o.push(v,A),d=A;break}case et.curveTo3:{let v=p(s[u++],s[u++]),A=p(s[u++],s[u++]);l.push({cmd:"C",pts:[v,A,A]}),o.push(v,A),d=A;break}case et.closePath:l.push({cmd:"Z"});break;default:break}return{devPoints:o,cmds:l}}function $h(i,t,e){let n=o=>`${Math.round(o*100)/100}`,s=[];for(let o of i){if(o.cmd==="Z"){s.push("Z");continue}let l=(o.pts??[]).map(([u,d])=>`${n(u-t)} ${n(d-e)}`).join(" ");s.push(`${o.cmd} ${l}`)}return s.join(" ")}var W1=.01;function ur(i,t,e,n){let s=i?.pageIndex!=null?`Page ${i.pageIndex}: `:"",o=Tn(t,e.heightPt);i?.logger?.emit?.("TEXT_CLIP_MODE_7_DROPPED",{prefix:s,label:n,bbox:`${jt(o.x)}, ${jt(o.y)}`,bboxSize:`${jt(o.w)}\xD7${jt(o.h)}`,page:i?.pageIndex})}function Tn(i,t,e=null){let[n,s,o,l,u,d]=i,p=Math.hypot(n,s),m=Math.hypot(o,l);if(Math.abs(s)<1e-6&&Math.abs(o)<1e-6)return $1(i,t);let v=p>0&&m>0?(n*o+s*l)/(p*m):0;if(!(Math.abs(v)<W1)||!(p>0&&m>0))return z1(i,t,e,v);let A=u+(n+o)*.5,x=d+(s+l)*.5,w=Math.atan2(-s,n),k=n*l-s*o<0;return{x:A-p*.5,y:t-x-m*.5,w:p,h:m,rotation:w,flipHorizontal:!1,flipVertical:k}}function $1(i,t){let[e,n,s,o,l,u]=i,d=Math.hypot(e,n),p=Math.hypot(s,o),m=l+(e+s)*.5,b=u+(n+o)*.5;return{x:m-d*.5,y:t-b-p*.5,w:d,h:p,rotation:0,flipHorizontal:e<0,flipVertical:o<0}}function z1(i,t,e=null,n=null){let[s,o,l,u,d,p]=i,m=[d,d+s,d+l,d+s+l],b=[p,p+o,p+u,p+o+u],v=Math.min(...m),A=Math.max(...m),x=Math.min(...b),w=Math.max(...b),k={x:v,y:t-w,w:A-v,h:w-x,rotation:0,flipHorizontal:!1,flipVertical:!1};if(e?.logger?.emit){let I=e.pageIndex!=null?`Page ${e.pageIndex}: `:"",P=n!=null?`, residual=${jt(n)}`:"",M=e.objId?` objId="${e.objId}"`:"";e.logger.emit("IMAGE_SKEW_DROPPED",{prefix:I,idLabel:M,bboxX:jt(k.x),bboxY:jt(k.y),bboxW:jt(k.w),bboxH:jt(k.h),ctm:Ch(i),residualStr:P,page:e.pageIndex,objId:e.objId??null})}return k}function Mi(i,t){return i==null?null:t==null||t===1?i:{...i,alpha:t}}function Uh(i={x:0,y:0}){return{ctm:[1,0,0,1,-i.x,-i.y],fillColor:{space:"gray",values:[0]},strokeColor:{space:"gray",values:[0]},fillColorSpaceName:null,strokeColorSpaceName:null,fillPattern:null,fillAlpha:1,strokeAlpha:1,lineWidth:1,lineDash:[],lineDashPhase:0,lineCap:0,lineJoin:0,miterLimit:10,blendMode:null,textMatrix:wn.slice(),textLineMatrix:wn.slice(),fontObjId:null,fontSize:0,charSpacing:0,wordSpacing:0,textHScale:1,textRise:0,textLeading:0,textRenderingMode:0,textClipActive:!1}}function Bh(i){return{ctm:i.ctm.slice(),fillColor:i.fillColor,strokeColor:i.strokeColor,fillColorSpaceName:i.fillColorSpaceName,strokeColorSpaceName:i.strokeColorSpaceName,fillPattern:i.fillPattern,fillAlpha:i.fillAlpha,strokeAlpha:i.strokeAlpha,lineWidth:i.lineWidth,lineDash:i.lineDash,lineDashPhase:i.lineDashPhase,lineCap:i.lineCap,lineJoin:i.lineJoin,miterLimit:i.miterLimit,blendMode:i.blendMode,textMatrix:i.textMatrix.slice(),textLineMatrix:i.textLineMatrix.slice(),fontObjId:i.fontObjId,fontSize:i.fontSize,charSpacing:i.charSpacing,wordSpacing:i.wordSpacing,textHScale:i.textHScale,textRise:i.textRise,textLeading:i.textLeading,textRenderingMode:i.textRenderingMode,textClipActive:i.textClipActive}}function Gh([i,t,e,n]){return(Math.hypot(i,t)+Math.hypot(e,n))/2}function X1(i){if(!Array.isArray(i)||i.length<5||i[0]!=="TilingPattern")return null;let t=i[2];if(!t||!Array.isArray(t.fnArray)||!Array.isArray(t.argsArray))return null;let e=i[3]??[1,0,0,1,0,0],n=i[4]??[0,0,0,0],s="pattern";for(let o=0;o<t.fnArray.length;o++)if(t.fnArray[o]===et.paintImageXObject){let u=t.argsArray[o]?.[0];if(typeof u=="string"){s=`pattern[${u}]`;break}}return{patternId:s,operatorList:{fnArray:t.fnArray,argsArray:t.argsArray},matrix:e,bbox:n,xStep:Number(i[5]),yStep:Number(i[6]),paintType:Number(i[7])}}function Y1(i){let t=i.coords??[];if(t.length<2)return null;let e=1/0,n=1/0,s=-1/0,o=-1/0;for(let l=0;l+1<t.length;l+=2){let u=t[l],d=t[l+1];u<e&&(e=u),d<n&&(n=d),u>s&&(s=u),d>o&&(o=d)}return!Number.isFinite(e)||!Number.isFinite(n)?null:{x:e,y:n,w:s-e,h:o-n}}function K1(i,t){let[e,n,s,o,l,u]=i,d=t.y+t.h;return[e*t.w,n*t.w,-s*t.h,-o*t.h,e*t.x+s*d+l,n*t.x+o*d+u]}function Pe(i,t){let[e,n,s,o,l,u]=i,[d,p,m,b,v,A]=t;return[e*d+s*p,n*d+o*p,e*m+s*b,n*m+o*b,e*v+s*A+l,n*v+o*A+u]}function Z1(i,t,e=!1){return i.filter(n=>{if(n.kind!=="vector-path")return!0;let s=n.fill;return!(s&&"alpha"in s&&s.alpha===0&&!n.stroke||!e&&Q1(n,t))})}function Q1(i,t){if(i.kind!=="vector-path"||i.stroke||!i.fill||i.fill.space!=="rgb")return!1;let[e,n,s]=i.fill.values;if(!(e>=.98&&n>=.98&&s>=.98))return!1;let o=1;return Math.abs(i.x)<=o&&Math.abs(i.y)<=o&&Math.abs(i.width-t.widthPt)<=o&&Math.abs(i.height-t.heightPt)<=o?J1(i.d,i.x,i.y,i.width,i.height):!1}function J1(i,t,e,n,s){if(/[cqstaCQSTA]/.test(i))return!1;let o=q1(i);if(o.length===0)return!1;let l=.5,u=[[t,e],[t+n,e],[t+n,e+s],[t,e+s]];for(let[p,m]of o)if(!u.some(([v,A])=>Math.abs(p-v)<=l&&Math.abs(m-A)<=l))return!1;return u.filter(([p,m])=>o.some(([b,v])=>Math.abs(b-p)<=l&&Math.abs(v-m)<=l)).length>=3}function q1(i){let t=[],e=i.match(/[a-zA-Z]|-?\d*\.?\d+(?:[eE][+-]?\d+)?/g)??[],n="",s=0,o=0,l=0;for(;l<e.length;){let u=e[l];if(/[a-zA-Z]/.test(u)){if(n=u,l++,n==="Z"||n==="z")continue;continue}n==="M"||n==="L"?(s=parseFloat(e[l]),o=parseFloat(e[l+1]),t.push([s,o]),l+=2,n==="M"&&(n="L")):n==="m"||n==="l"?(s+=parseFloat(e[l]),o+=parseFloat(e[l+1]),t.push([s,o]),l+=2,n==="m"&&(n="l")):n==="H"?(s=parseFloat(e[l]),t.push([s,o]),l+=1):n==="h"?(s+=parseFloat(e[l]),t.push([s,o]),l+=1):n==="V"?(o=parseFloat(e[l]),t.push([s,o]),l+=1):(n==="v"&&(o+=parseFloat(e[l]),t.push([s,o])),l+=1)}return t}var tx=.05,Xh=1.5,Li=1,ex=new Set([0,2,4,6]),nx=36,rx=4;async function Yh(i,t){let e=await i.getTextContent({includeMarkedContent:!1,disableNormalization:!0}),n=[],s={cursor:0,consumed:new Set};for(let o of e.items){if(o.type||fx(o.str))continue;if(o.str&&o.str.length>0&&o.str.trim()===""){let m=t.pageBox.originShiftPt??{x:0,y:0};lx({fontObjId:o.fontName,baselineX:o.transform[4]-m.x,baselineY:o.transform[5]-m.y,widthPt:o.width,str:o.str,dirSignX:o.transform[0]<0?-1:1},t.colorSnapshots,s);continue}if(!o.str)continue;let l=Kh(i,o.fontName);if(!Ii(l))continue;let u=e.styles?.[o.fontName],d=await sx(o,l,u,t,s);if(!d||!d.run)continue;let p=d.placeholder;if(p&&Array.isArray(p._replacements)){let m=p._lazyGlyphOutlines;Array.isArray(m)&&m.length>0&&(d.run._buildGlyphOutline=m.shift()),p._replacements.push(d.run)}else n.push(d.run)}return n}async function sx(i,t,e,n,s){let[o,l,u,d,p,m]=i.transform,b=Math.hypot(u,d);if(!(b>0))return null;let v=Math.atan2(l,o),A=n.pageBox.originShiftPt??{x:0,y:0},x=p-A.x,w=m-A.y,{ascentRatio:k,descentRatio:I}=dx(e,t),P=b*k,M=b*I,N=i.width+b*tx,D=P+M,U=Math.cos(v),G=Math.sin(v),H=N/2,W=(P-M)/2,J=x+H*U-W*G,q=w+H*G+W*U,dt=J-H,Q=n.pageBox.heightPt-q-D/2,ot=D/2,ct=dt-ot*G,X=Q+ot*(1-U),$=await gl(t,n.logger);if(!$)return null;n.docFonts.has($.postScriptName)||n.docFonts.set($.postScriptName,$);let ut=ox({fontObjId:i.fontName,baselineX:x,baselineY:w,widthPt:i.width,str:i.str,dirSignX:o<0?-1:1},n.colorSnapshots,s);if(ut==null)return null;let st=$,St=ut.walkerFontObjId;if(St&&St!==i.fontName&&n.page){let at=Kh(n.page,St);if(at&&Ii(at)){let _=await gl(at,n.logger);_&&(st=_,n.docFonts.has(_.postScriptName)||n.docFonts.set(_.postScriptName,_))}}if(ut.renderMode===3||ut.renderMode===7){let at=n.pageIndex!=null?` on page ${n.pageIndex}`:"",_=ut.renderMode===7?"7 (add to clipping path)":"3 (invisible)";return n.logger?.emit?.("TEXT_RENDER_MODE_SKIPPED",{pageTag:at,text:ix(i.str,60),modeLabel:_,page:n.pageIndex,renderMode:ut.renderMode}),null}let{fill:Ct,colorSpans:wt}=ut,Et=Ct?.alpha,Vt=Et!=null&&Et<1?Et:1,Ut={kind:"text-run",x:ct,y:X,width:N,height:D,text:i.str,fontRef:st.postScriptName,family:st.family,...st.weight!=null?{fontWeight:st.weight}:{},...st.style?{fontStyle:st.style}:{},...st.width?{fontWidth:st.width}:{},fontSize:b,rotation:-v,fill:Ct,...wt?{colorSpans:wt}:{},baselineXPt:x,baselineYPt:w,advanceWidthPt:i.width};return Ut.opacity=Vt,{run:Ut,placeholder:ut.placeholder??null}}function ix(i,t){return typeof i!="string"?"":i.length>t?`${i.slice(0,t)}\u2026`:i}function ox(i,t,e){let n=[],s=[],o=e.cursor,l=i.str.length,u=0;for(let x=e.cursor;x<t.length;x++){if(e.consumed.has(x)||!zr(t[x])||!Fi(t[x],i))continue;let w=t[x].text?.length??0;if(u>=l)break;n.push(t[x]),s.push(x),u+=w,o=x+1}if(n.length===0)for(let x=0;x<t.length;x++){if(e.consumed.has(x)||!zr(t[x])||!Fi(t[x],i))continue;let w=t[x].text?.length??0;if(u>=l)break;n.push(t[x]),s.push(x),u+=w}else e.cursor=o;if(n.length===0){for(let P=0;P<t.length;P++)if(e.consumed.has(P)&&zr(t[P])&&Fi(t[P],i)&&ux(t[P].text,i.str))return null;let x=Math.max(i.widthPt,nx)*rx,w=null,k=!1,I=!1;for(let P=0;P<t.length;P++){let M=t[P];if(!e.consumed.has(P)||!zr(M)||!ex.has(M.renderMode??0)||Math.abs(M.baselineY-i.baselineY)>Xh||Math.abs(M.baselineX-i.baselineX)>x)continue;let N=M.fill??null;if(!k)w=N,k=!0;else if(!xl(w,N)){I=!0;break}}return k&&!I&&w!=null?{fill:w,colorSpans:void 0,renderMode:0,placeholder:null,walkerFontObjId:null}:{fill:null,colorSpans:void 0,renderMode:0,placeholder:null,walkerFontObjId:null}}for(let x of s)e.consumed.add(x);let d=n[0].renderMode??0,p=n[0].placeholder??null,m=cx(n,i.str),b=n[0].fill??null;if(n.every(x=>xl(x.fill??null,b)))return{fill:b,colorSpans:void 0,renderMode:d,placeholder:p,walkerFontObjId:m};let A=ax(i.str,n);return A.length===0?{fill:b,colorSpans:void 0,renderMode:d,placeholder:p,walkerFontObjId:m}:{fill:A[0].fill,colorSpans:A,renderMode:d,placeholder:p,walkerFontObjId:m}}function ax(i,t){if(i.length===0||t.length===0)return[];let e="",n=[];for(let p=0;p<t.length;p++){let m=t[p].text??"";for(let b=0;b<m.length;b++)e+=m[b],n.push(p)}if(e.length===0)return[];let s=new Array(i.length),o=0,l=0,u=n[0];for(;o<i.length&&l<e.length;){let p=i[o],m=e[l];p===m?(s[o]=n[l],u=n[l],o++,l++):zh(m)?l++:zh(p)?(s[o]=u,o++):(s[o]=n[l],u=n[l],o++,l++)}for(;o<i.length;)s[o]=u,o++;let d=[];for(let p=0;p<i.length;p++){let m=t[s[p]]?.fill??null,b=d[d.length-1];b&&xl(b.fill,m)?b.to=p+1:d.push({from:p,to:p+1,fill:m})}return d}function zh(i){return i===" "||i===" "||i===`
16
- `||i==="\r"||i==="\xA0"}function lx(i,t,e){let n=[],s=e.cursor,o=i.str.length,l=0;for(let u=e.cursor;u<t.length;u++){if(e.consumed.has(u)||!zr(t[u])||!Fi(t[u],i))continue;let d=t[u].text??"";if(d.length>o-l||d.length>0&&d.trim()!==""||(n.push(u),l+=d.length,s=u+1,l>=o))break}if(n.length!==0){e.cursor=s;for(let u of n)e.consumed.add(u)}}function cx(i,t){if(i.length===0)return null;let e=t.trim();if(i.length===1&&e.length>0&&i[0].text!=null&&i[0].text.trim().length===0)return null;if(i.length===1&&i[0].fontObjId)return i[0].fontObjId;if(e.length===0)return i[0].fontObjId||null;for(let n of i){if(!n.fontObjId||!n.text)continue;let s=n.text.replace(/^\s+/,"");if(s===e||s.startsWith(e)||e.startsWith(s)&&s.length>=2)return n.fontObjId}return null}function ux(i,t){if(!i)return!1;let e=i.trim(),n=t.trim();return e.length===0||n.length===0?!1:e.includes(n)||n.includes(e)}function zr(i){if(!i)return!1;let t=i.fill;return t?(t.alpha??1)>0:!1}function xl(i,t){if(i==null&&t==null)return!0;if(i==null||t==null||i.space!==t.space||(i.alpha??1)!==(t.alpha??1)||!i.values||!t.values||i.values.length!==t.values.length)return!1;for(let e=0;e<i.values.length;e++)if(Math.abs(i.values[e]-t.values[e])>1e-6)return!1;return!0}function Fi(i,t){if(Math.abs(i.baselineY-t.baselineY)>Xh)return!1;let e=hx(i.text),n,s;return t.dirSignX<0?(n=t.baselineX-t.widthPt-Li,s=t.baselineX+Li+e):(n=t.baselineX-Li-e,s=t.baselineX+t.widthPt+Li),!(i.baselineX<n||i.baselineX>s)}function hx(i){if(!i)return 0;let t=0;for(let e of i)if(e===" "||e===" "||e==="\xA0")t++;else break;return t*5}function dx(i,t){if(Number.isFinite(i?.ascent)&&Number.isFinite(i?.descent))return{ascentRatio:i.ascent,descentRatio:Math.abs(i.descent)};let e=t?._parsed,n=e?.unitsPerEm,s=e?.tables?.hhea,o=s?.ascender,l=s?.descender;return typeof n=="number"&&Number.isFinite(n)&&n>0&&Number.isFinite(o)&&Number.isFinite(l)?{ascentRatio:o/n,descentRatio:Math.abs(l)/n}:{ascentRatio:.8,descentRatio:.2}}function Kh(i,t){if(!t)return null;try{if(i.commonObjs.has(t))return i.commonObjs.get(t)}catch{}return null}function fx(i){for(let t of i){let e=t.codePointAt(0);if(e!=null&&(e>=57344&&e<=63743||e>=983040&&e<=1048573||e>=1048576&&e<=1114109))return!0}return!1}function px(i,t){let e=Math.round(i.width*100)/100,n=Math.round(i.height*100)/100;return(i.d===`M 0 ${n} L ${e} ${n} L ${e} 0 L 0 0 Z`||i.d===`M 0 0 L ${e} 0 L ${e} ${n} L 0 ${n} Z`)&&t.x>i.x+.02&&t.y>i.y+.02&&t.x+t.width<i.x+i.width-.02&&t.y+t.height<i.y+i.height-.02}function Zh(i,t){return i.x+i.width+.02<t.x||t.x+t.width+.02<i.x||i.y+i.height+.02<t.y||t.y+t.height+.02<i.y}function Qh(i){if(i.filter(o=>o.kind==="vector-path").length<1e3)return i;let t=[],e=[],n,s=()=>{if(e.length===1&&t.push({...e[0],clips:void 0}),e.length>1){let o=Math.min(...e.map(u=>u.x)),l=Math.min(...e.map(u=>u.y));t.push({...e[0],clips:void 0,x:o,y:l,width:Math.max(...e.map(u=>u.x+u.width))-o,height:Math.max(...e.map(u=>u.y+u.height))-l,d:e.map(u=>{let d=0;return u.d.replace(/-?\d+(?:\.\d+)?(?:e[+-]?\d+)?/gi,p=>{let m=d++%2===0?u.x-o:u.y-l;return String(Math.round((Number(p)+m)*100)/100)})}).join(" ")})}e=[]};for(let o of i){if(o.kind!=="vector-path"||!o.fill||!("space"in o.fill)||o.stroke||(o.opacity??1)!==1||(o.fill.alpha??1)!==1||o.blendMode!=null&&o.blendMode!=="source-over"){s(),t.push(o);continue}if(o.clips?.some(u=>Zh(o,u)))continue;if(o.clips?.some(u=>!px(u,o))){s(),t.push(o);continue}let l=JSON.stringify([o.fill.space,o.fill.values,o.fillRule,o.clips??[]]);(n!==l||e.length===256||!e.every(u=>Zh(o,u)))&&s(),n=l,e.push(o)}return s(),t}var Sl=require("node:fs"),Di=require("node:path"),_i=require("node:url"),Al=require("node:module");async function Jh(){let i=new URL("./pdf.worker.mjs",__import_meta_url__);return(0,Sl.existsSync)(i)?i.href:(0,_i.pathToFileURL)((0,Al.createRequire)(__import_meta_url__).resolve("@imgly/pdfjs-dist/legacy/build/pdf.worker.mjs")).href}async function qh(){let i=new URL("./standard_fonts/FoxitFixed.pfb",__import_meta_url__),t=new URL("./standard_fonts/",__import_meta_url__);if((0,Sl.existsSync)(i))return(0,_i.fileURLToPath)(t);let e=(0,Al.createRequire)(__import_meta_url__).resolve("@imgly/pdfjs-dist/standard_fonts/FoxitFixed.pfb");return(0,Di.dirname)(e)+Di.sep}var Tl=2;function gx(i){let t=i?.imglyPatchVersion??null;if(t!==Tl)throw new Error(`[@imgly/pdf-importer] @imgly/pdfjs-dist patch missing or outdated (got ${t??"none"}, expected ${Tl}). The patched APIs (trimBox, bleedBox, colorSpaceResources, native CMYK args) are required for correct color and geometry import. Pin @imgly/pdfjs-dist to 4.10.38-imgly.${Tl} or newer and reinstall.`)}async function td(i,t={}){let e=t.pdfjsModule??await Promise.resolve().then(()=>(cl(),ah));e.GlobalWorkerOptions.workerSrc=t.workerSrc??await Jh();let n=t.standardFontDataUrl??await qh(),s=t.textMode??"outline",o=i instanceof Uint8Array?i:(()=>{let m=i;return new Uint8Array(m.buffer??i,m.byteOffset??0,m.byteLength??m.length)})(),u=await e.getDocument({data:o,password:t.password,disableFontFace:!0,useSystemFonts:!1,isEvalSupported:!1,fontExtraProperties:!0,standardFontDataUrl:n}).promise,d=new Map,p=[];for(let m=1;m<=u.numPages;m++){let b=await u.getPage(m);m===1&&gx(b),p.push(await mx(b,{textMode:s,preserveWhitePageBackground:t.preserveWhitePageBackground,docFonts:d,logger:t.logger,pageIndex:m})),b.cleanup()}return await u.destroy(),{source:t.source??"unknown",pages:p,fonts:d}}async function mx(i,t){let e=i.trimBox,n=i.bleedBox,s=i.view??[0,0,0,0],o=s[2]-s[0],l=s[3]-s[1],u={x:s[0],y:s[1]},d={widthPt:o,heightPt:l,originShiftPt:u},p=null,m={left:0,top:0,right:0,bottom:0},b=!1;e&&(p={xPt:e[0]-s[0],yPt:s[3]-e[3],widthPt:e[2]-e[0],heightPt:e[3]-e[1]},n&&(m={left:Math.max(0,e[0]-n[0]),bottom:Math.max(0,e[1]-n[1]),right:Math.max(0,n[2]-e[2]),top:Math.max(0,n[3]-e[3])},b=!0));let{colorSnapshots:v,finalize:A}=await Hh(i,d,t),x=t.textMode==="outline"?[]:await Yh(i,{pageBox:d,docFonts:t.docFonts,colorSnapshots:v,logger:t.logger,pageIndex:t.pageIndex,page:i}),w=A();x.length>0&&w.push(...x);let k=i.rotate??0;if(k!==0){let I=t.pageIndex!=null?`Page ${t.pageIndex}: `:"";t.logger?.emit?.("DOC_PAGE_ROTATION_DROPPED",{prefix:I,pageRotation:k,page:t.pageIndex})}return{widthPt:o,heightPt:l,rotation:k,trimPt:p,bleedPt:m,hasBleed:b,blocks:Qh(w)}}var ed=new WeakMap;function nd(i,t){ed.set(i,Wn(t))}function Wn(i){return ed.get(i)??i}var rd=new WeakMap;function sd(i,t,e,n){let s=i.block;if(typeof s.setTypeface=="function"&&s.setTypeface(t,e),typeof s.setTextFontStyle=="function"&&n?.style)try{s.setTextFontStyle(t,n.style)}catch{}if(typeof s.setTextFontWeight=="function"&&n?.weight)try{s.setTextFontWeight(t,n.weight)}catch{}let o=n?.uri,l=i.editor;o&&typeof l?.getFontMetrics=="function"&&l.getFontMetrics(o).catch(()=>{})}function Ni(i,t){let e=Wn(i),n=rd.get(e);n||(n=new Map,rd.set(e,n));let s=n.get(t.postScriptName);if(s)try{return e.editor.getBufferLength(s.uri),s}catch{}let o=i.editor.createBuffer(),l=t.data instanceof Uint8Array?t.data:new Uint8Array(t.data);i.editor.setBufferData(o,0,l);let u={name:s?`${t.postScriptName}#${o}`:t.postScriptName,fonts:[{uri:o,subFamily:t.family,weight:An(t.weight),style:t.style??"normal"}]},d={uri:o,typeface:u};return n.set(t.postScriptName,d),d}function id(i,t,e){let{uri:n,typeface:s}=Ni(i,e);typeof i.block.setFont=="function"&&i.block.setFont(t,n,s)}var re=Object.freeze({IMAGE:"image",VECTOR_PATH:"vector-path",TEXT_OUTLINE:"text-outline",TEXT_RUN:"text-run"});var wl=new WeakSet;function od(i){wl.add(i)}function It(i,t){if(wl.has(i))return t/72;let e=i.scene.get();if(e===null)return t/72;switch(i.scene.getDesignUnit()){case"Inch":return t/72;case"Millimeter":return t*25.4/72;case"Pixel":return t*i.block.getFloat(e,"scene/dpi")/72}}function El(i,t){if(wl.has(i))return t;let e=i.scene.get(),n=i.scene;return e!==null&&n.getFontSizeUnit?.()==="Pixel"?t*i.block.getFloat(e,"scene/dpi")/72:t}var ad=Object.freeze({"source-over":null,normal:null,multiply:"Multiply",screen:"Screen",overlay:"Overlay",darken:"Darken",lighten:"Lighten","color-dodge":"ColorDodge","color-burn":"ColorBurn","hard-light":"HardLight","soft-light":"SoftLight",difference:"Difference",exclusion:"Exclusion",hue:"Hue",saturation:"Saturation",color:"Color",luminosity:"Luminosity"});function Ui(i,t){return i==null||i===""?null:Object.prototype.hasOwnProperty.call(ad,i)?ad[i]:(t?.emit?.("BLEND_MODE_UNSUPPORTED",{mode:i}),null)}var bx=6;function yx(i,t){return i.replace(/-?\d*\.?\d+(?:[eE][-+]?\d+)?/g,e=>{let s=(parseFloat(e)*t).toFixed(bx).replace(/\.?0+$/,"");return s==="-0"||s===""?"0":s})}function hr(i,t,e,n){let s=i.block.createShape("vector_path");i.block.setString(s,"vector_path/path",yx(t,It(i,1)));try{i.block.setFloat(s,"vector_path/width",It(i,e)),i.block.setFloat(s,"vector_path/height",It(i,n))}catch{}return s}var Xr=()=>({state:"unknown",warned:!1}),Cl="shape/vector_path/fillRule",vx="1.75.0",xx=i=>i==="nonzero"?"NonZero":"EvenOdd";function Sx(i,t,e){if(e.state==="unknown"){let n=!1;try{n=i.block.findAllProperties(t).includes(Cl)}catch{n=!1}e.state=n?"supported":"unsupported"}return e.state==="supported"}function Bi(i,t,e,n){if(!(e==null||e==="evenodd")){if(!Sx(i,t,n.support)){n.support.warned||(n.support.warned=!0,n.logger?.emit?.("VECTOR_PATH_FILL_RULE_UNSUPPORTED",{property:Cl,sinceVersion:vx}));return}try{i.block.setEnum(t,Cl,xx(e))}catch{}}}var Yr=Symbol("COMBINE_EMPTY_INTERSECTION");function Gi(i,t,e){if(!Array.isArray(t)||t.length<2)return e?.logger?.emit?.("CLIP_COMBINE_TOO_FEW_INPUTS",{prefix:kl(e),inputCount:t?.length??0,label:e?.label??null}),null;if(e?.flush?.(),!i.block.isCombinable(t))return e?.logger?.emit?.("CLIP_COMBINE_NOT_COMBINABLE",{prefix:kl(e),inputCount:t.length,label:e?.label??null}),null;try{return i.block.combine(t,"Intersection")}catch(n){let s=n&&typeof n=="object"&&"message"in n?String(n.message):String(n);return Ax(s)?Yr:(e?.logger?.emit?.("CLIP_COMBINE_THREW",{prefix:kl(e),inputCount:t.length,reason:s,label:e?.label??null}),null)}}function Ax(i){return typeof i=="string"&&i.includes("empty shape")}function kl(i){return i?.label?`${i.label}: `:""}function En(i,t){for(let e of t)try{i.block.isValid?.(e)!==!1&&i.block.destroy(e)}catch{}}var Tx=Object.freeze({scaleX:1,scaleY:1,translationX:0,translationY:0});function ld(i,t){return!(t.width>0)||!(t.height>0)?Tx:{scaleX:i.width/t.width,scaleY:i.height/t.height,translationX:(i.x-t.x)/t.width,translationY:(i.y-t.y)/t.height}}function cd(i,t){let e=Math.max(i.x,t.x),n=Math.max(i.y,t.y),s=Math.min(i.x+i.width,t.x+t.width),o=Math.min(i.y+i.height,t.y+t.height);return{x:e,y:n,width:s-e,height:o-n}}var ud=new WeakMap;function dr(i,t,e,n){if(!e?.bytes||e.bytes.length===0)return n?.logger?.emit?.("IMAGE_NO_PIXELS",{}),!1;let s=i.block.createFill("image"),o=e.bytes instanceof Uint8Array?e.bytes:null,l=Wn(i),u=ud.get(l);u||(u=new WeakMap,ud.set(l,u));let d=o!=null?u.get(o):void 0;if(d!=null)try{l.editor.getBufferLength(d)}catch{d=void 0}if(d==null){d=i.editor.createBuffer();let p=e.bytes instanceof Uint8Array?e.bytes:new Uint8Array(e.bytes);i.editor.setBufferData(d,0,p),o!=null&&u.set(o,d)}return i.block.setString(s,"fill/image/imageFileURI",d),i.block.setFill(t,s),!0}function Il(i,t,e,n){wx(i,t,e,n),Ex(i,t,e,n)}function Pl(i,t){i.block.getGlobalBoundingBoxX(t)}function wx(i,t,e,n){try{if(e.patternTile){i.block.setContentFillMode(t,"Cover");return}let s={x:It(i,e.x),y:It(i,e.y),width:It(i,e.width),height:It(i,e.height)},o=ld(s,Cx(i,t));i.block.setContentFillMode(t,"Crop"),i.block.setCropScaleX(t,o.scaleX),i.block.setCropScaleY(t,o.scaleY),i.block.setCropTranslationX(t,o.translationX),i.block.setCropTranslationY(t,o.translationY)}catch{n?.logger?.emit?.("IMAGE_PLACEMENT_UNSUPPORTED",{})}}function Ex(i,t,e,n){if(!(!e?.flipHorizontal&&!e?.flipVertical))try{e.flipHorizontal&&i.block.flipCropHorizontal(t),e.flipVertical&&i.block.flipCropVertical(t)}catch{n?.logger?.emit?.("IMAGE_FLIP_UNSUPPORTED",{})}}function Cx(i,t){let e=i.block.getWidth(t),n=i.block.getHeight(t),s=i.block.getRotation(t),o=Math.cos(s),l=Math.sin(s),u=i.block.getPositionX(t)+(e*o-n*l)/2,d=i.block.getPositionY(t)+(e*l+n*o)/2;return{x:u-e/2,y:d-n/2,width:e,height:n}}var Cn=Symbol("EMITTED_DROPPED");function gd(i,t,e,n,s){if(!t?.bytes||t.bytes.length===0)return s?.logger?.emit?.("IMAGE_CLIPPED_NO_BYTES",{prefix:an(s),bbox:ye(t),page:s?.pageIndex}),null;let o=e.filter(p=>Kr(p)),l=e.filter(p=>!Kr(p)&&!pd(p,t)),u=e.filter(p=>!Kr(p)&&pd(p,t));if(u.length===0||l.length>0)return l.length>0?s?.logger?.emit?.("IMAGE_CLIPPED_TO_EMPTY",{prefix:an(s),bbox:ye(t),clipCount:e.length,degenerateCount:o.length,disjointCount:l.length,page:s?.pageIndex}):s?.logger?.emit?.("IMAGE_CLIP_UNUSABLE",{prefix:an(s),bbox:ye(t),clipCount:e.length,degenerateCount:o.length,disjointCount:l.length,page:s?.pageIndex}),Cn;let d=kx(u,t);return d.length===1?Ol(i,t,d[0],s):Ox(i,t,d,n,s)}function kx(i,t){let e=[],n=new Set;for(let s of i)Ix(s,t)||n.has(s.d)||(n.add(s.d),e.push(s));return e.length>0?e:[i[0]]}function Ix(i,t){if(!md(i.d))return!1;let e=.001;return i.x<=t.x+e&&i.y<=t.y+e&&i.x+i.width+e>=t.x+t.width&&i.y+i.height+e>=t.y+t.height}function md(i){if(typeof i!="string")return!1;let t=i.trim().split(/\s+/),e=t.pop();if(e!=="Z"&&e!=="z"||t.length!==12&&t.length!==15)return!1;let n=[],s=[];for(let u=0;u<t.length;u+=3){if(t[u]!==(u===0?"M":"L"))return!1;let d=Number(t[u+1]),p=Number(t[u+2]);if(!Number.isFinite(d)||!Number.isFinite(p))return!1;n.push(d),s.push(p)}let o=.001;if(n.length===5&&(Math.abs(n[4]-n[0])>o||Math.abs(s[4]-s[0])>o))return!1;for(let u=0;u<4;u++){let d=(u+1)%4,p=Math.abs(n[u]-n[d])<=o,m=Math.abs(s[u]-s[d])<=o;if(p===m)return!1;let b=(u+2)%4;if(Math.abs(n[u]-n[b])<=o&&Math.abs(s[u]-s[b])<=o)return!1}let l=u=>{let d=[];for(let p of u)d.some(m=>Math.abs(m-p)<=o)||d.push(p);return d};return l(n).length===2&&l(s).length===2}function bd(i,t,e,n,s){let o=e.filter(b=>Kr(b)),l=e.filter(b=>!Kr(b));if(l.length===0)return s?.logger?.emit?.("CLIP_DEGENERATE_FALLBACK",{prefix:an(s),bbox:ye(t),clipCount:e.length,degenerateCount:o.length,page:s?.pageIndex}),null;if(!t.fill)return s?.logger?.emit?.("CLIP_COMBINE_STROKE_ONLY",{prefix:an(s),bbox:ye(t),clipCount:e.length,page:s?.pageIndex}),null;let u=[];for(let b of l){let v=Ml(i,b);i.block.appendChild(n,v),u.push(v)}let d={x:t.x,y:t.y,width:t.width,height:t.height},p=Bx(i,t.d,d,t.fill,t.opacity);i.block.appendChild(n,p);let m=Gi(i,[p,...u],{logger:s?.logger,label:`${an(s)}vector path at ${ye(t)}`,flush:s?.flush});return m===Yr?(En(i,[p,...u]),Cn):m==null?(En(i,[p,...u]),null):(Px(i,m,t),t.opacity!=null&&t.opacity!==1&&i.block.setOpacity(m,t.opacity),Rl(i,m,t.blendMode,s?.logger),m)}function Px(i,t,e){let n=e.fill,s=n?.kind;if(s==="linearGradient"||s==="radialGradient"){Rx(i,t,e);return}let o=i.block.createFill("color");i.block.setColor(o,"fill/color/value",Ll(n)),i.block.setFill(t,o)}function Rx(i,t,e){let n=e.fill,s=n.kind==="linearGradient"?"gradient/linear":"gradient/radial",o=i.block.createFill(s),l=(n.stops??[]).map(p=>({color:Ll(p.color),stop:p.offset}));i.block.setGradientColorStops(o,"fill/gradient/colors",l);let u=e.width>0?e.width:1,d=e.height>0?e.height:1;if(n.kind==="linearGradient")i.block.setFloat(o,"fill/gradient/linear/startPointX",(n.start.x-e.x)/u),i.block.setFloat(o,"fill/gradient/linear/startPointY",(n.start.y-e.y)/d),i.block.setFloat(o,"fill/gradient/linear/endPointX",(n.end.x-e.x)/u),i.block.setFloat(o,"fill/gradient/linear/endPointY",(n.end.y-e.y)/d);else{let p=Math.max(.001,Math.min(u,d));i.block.setFloat(o,"fill/gradient/radial/centerPointX",(n.center.x-e.x)/u),i.block.setFloat(o,"fill/gradient/radial/centerPointY",(n.center.y-e.y)/d),i.block.setFloat(o,"fill/gradient/radial/radius",n.radius/p)}i.block.setFill(t,o)}function Rl(i,t,e,n){let s=Ui(e,n);s!=null&&(typeof i.block.supportsBlendMode=="function"&&!i.block.supportsBlendMode(t)||i.block.setBlendMode(t,s))}function Ol(i,t,e,n){let s=i.block.create("graphic"),o=!t.rotation&&!t.patternTile&&md(e.d)?{...t,x:Math.max(t.x,e.x),y:Math.max(t.y,e.y),width:Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x),height:Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y)}:t,l=o!==t?`M 0 0 L ${o.width} 0 L ${o.width} ${o.height} L 0 ${o.height} Z`:Gx(e,t),u=hr(i,l,o.width,o.height);return i.block.setShape(s,u),dr(i,s,t),Hi(i,s,o),t.rotation&&Math.abs(t.rotation)>1e-6&&yd(i,s,t.rotation,n),t.opacity!=null&&t.opacity!==1&&i.block.setOpacity(s,t.opacity),Rl(i,s,t.blendMode,n?.logger),s}function yd(i,t,e,n){let s=()=>i.block.setRotation(t,e);n?.unbatched?n.unbatched(s):s()}function Ox(i,t,e,n,s){if(t.rotation&&Math.abs(t.rotation)>1e-6){let p=Mx(i,t,e,n,s);if(p!==fr)return p}let l=Ux(i,t,s);i.block.appendChild(n,l);let u=[];for(let p of e){let m=Ml(i,p);i.block.appendChild(n,m),u.push(m)}let d=Gi(i,[l,...u],{logger:s?.logger,label:`${an(s)}clipped image at ${ye(t)}`,flush:s?.flush});return d===Yr?(En(i,[l,...u]),Cn):d==null?(En(i,[l,...u]),null):(dr(i,d,t),t.opacity!=null&&t.opacity!==1&&i.block.setOpacity(d,t.opacity),Rl(i,d,t.blendMode,s?.logger),d)}var fr=Symbol("UNHANDLED");function Mx(i,t,e,n,s){let o=Fx(e);if(o==null)return Lx(i,t,e,n,s);if(o.points.length<3)return s?.logger?.emit?.("IMAGE_CLIP_EMPTY_INTERSECTION",{prefix:an(s),bbox:ye(t),clipCount:e.length,page:s?.pageIndex}),Cn;let l=Nx(o.points);return Ol(i,t,l,s)}function Lx(i,t,e,n,s){let o=s?.vectorPathFillRuleSupport??Xr(),l=e.map(d=>{let p=Ml(i,d);return Bi(i,i.block.getShape(p),d.fillRule,{support:o,logger:s?.logger}),i.block.appendChild(n,p),p}),u=Gi(i,l,{logger:s?.logger,label:`${an(s)}rotated image clips`,flush:s?.flush});if(u===Yr)return En(i,l),Cn;if(u==null)return En(i,l),fr;try{let d=i.block.getShape(u);if(i.block.getType(d)!=="//ly.img.ubq/shape/vector_path")return fr;let p=It(i,1),m=i.block.getWidth(u)/p,b=i.block.getHeight(u)/p,v=i.block.getFloat(d,"vector_path/width"),A=i.block.getFloat(d,"vector_path/height");if(!(v>0&&A>0))return fr;let w=i.block.getString(d,"vector_path/path").match(/[A-Za-z]|[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g);if(!w||w.some(I=>/^[A-Za-z]$/.test(I)&&!/^[MLCZ]$/.test(I)))return fr;let k={x:i.block.getPositionX(u)/p,y:i.block.getPositionY(u)/p,width:m,height:b,d:xd(w.join(" "),(I,P)=>[I*m/v,P*b/A]),fillRule:"evenodd"};return Ol(i,t,k,s)}catch{return fr}finally{En(i,[u])}}function Fx(i){if(i.length===0)return null;let t=hd(i[0]);if(t==null)return null;for(let e=1;e<i.length;e++){let n=hd(i[e]);if(n==null)return null;if(t=Dx(t,n),t.length===0)return{points:[]}}return{points:t}}function hd(i){let t=i.d.split(/\s+/),e=[],n=0;for(;n<t.length;){let s=t[n++];if(!(s==="Z"||s==="z")){if(s==="M"||s==="L"){let o=parseFloat(t[n++]),l=parseFloat(t[n++]);if(Number.isNaN(o)||Number.isNaN(l))return null;let u=i.x+o,d=i.y+l,p=e[e.length-1];if(p&&Math.abs(p[0]-u)<1e-6&&Math.abs(p[1]-d)<1e-6)continue;e.push([u,d]);continue}return null}}return e}function Dx(i,t){if(t.length<3)return[];let e=Math.sign(_x(t))||1,n=i.slice();for(let s=0;s<t.length&&n.length!==0;s++){let o=t[s],l=t[(s+1)%t.length],u=n;n=[];let d=u[u.length-1];for(let p of u){let m=dd(p,o,l)*e>=-1e-9,b=dd(d,o,l)*e>=-1e-9;m?(b||n.push(fd(d,p,o,l)),n.push(p)):b&&n.push(fd(d,p,o,l)),d=p}}return n}function _x(i){let t=0;for(let e=0;e<i.length;e++){let[n,s]=i[e],[o,l]=i[(e+1)%i.length];t+=n*l-o*s}return t*.5}function dd(i,t,e){return(e[0]-t[0])*(i[1]-t[1])-(e[1]-t[1])*(i[0]-t[0])}function fd(i,t,e,n){let s=n[0]-e[0],o=n[1]-e[1],l=t[0]-i[0],u=t[1]-i[1],d=s*u-l*o;if(Math.abs(d)<1e-12)return t.slice();let p=(s*(e[1]-i[1])-o*(e[0]-i[0]))/d;return[i[0]+p*l,i[1]+p*u]}function Nx(i){let t=1/0,e=1/0,n=-1/0,s=-1/0;for(let[u,d]of i)u<t&&(t=u),d<e&&(e=d),u>n&&(n=u),d>s&&(s=d);let o=u=>`${Math.round(u*100)/100}`,l=[];for(let u=0;u<i.length;u++){let[d,p]=i[u];l.push(`${u===0?"M":"L"} ${o(d-t)} ${o(p-e)}`)}return l.push("Z"),{d:l.join(" "),x:t,y:e,width:n-t,height:s-e,fillRule:"nonzero"}}function Ux(i,t,e){let n=i.block.create("graphic");return i.block.setShape(n,i.block.createShape("rect")),dr(i,n,t),Hi(i,n,t),t.rotation&&Math.abs(t.rotation)>1e-6&&yd(i,n,t.rotation,e),n}function Ml(i,t){let e=i.block.create("graphic"),n=hr(i,t.d,t.width,t.height);return i.block.setShape(e,n),i.block.setFill(e,vd(i)),Hi(i,e,t),e}function Bx(i,t,e,n,s){let o=i.block.create("graphic"),l=hr(i,t,e.width,e.height);i.block.setShape(o,l);let u=n?.kind;if(n&&!(u==="linearGradient"||u==="radialGradient")){let p=i.block.createFill("color");i.block.setColor(p,"fill/color/value",Ll(n)),i.block.setFill(o,p)}else i.block.setFill(o,vd(i));return Hi(i,o,e),s!=null&&s!==1&&i.block.setOpacity(o,s),o}function vd(i){let t=i.block.createFill("color");return i.block.setColor(t,"fill/color/value",{r:0,g:0,b:0,a:0}),t}function Hi(i,t,e){i.block.setPositionX(t,It(i,e.x)),i.block.setPositionY(t,It(i,e.y)),i.block.setWidth(t,It(i,e.width)),i.block.setHeight(t,It(i,e.height))}function Gx(i,t){let e=t.rotation??0;if(Math.abs(e)<1e-6)return Hx(i.d,i.x-t.x,i.y-t.y);let n=t.x+t.width*.5,s=t.y+t.height*.5,o=Math.cos(e),l=Math.sin(e),u=(d,p)=>{let m=d+i.x-n,b=p+i.y-s,v=o*m+l*b,A=-l*m+o*b;return[v+t.width*.5,A+t.height*.5]};return xd(i.d,u)}function xd(i,t){let e=l=>`${Math.round(l*100)/100}`,n=i.split(/\s+/),s=[],o=0;for(;o<n.length;){let l=n[o++];if(l==="Z"||l==="z"){s.push("Z");continue}if(l==="M"||l==="L"){let[u,d]=t(parseFloat(n[o++]),parseFloat(n[o++]));s.push(`${l} ${e(u)} ${e(d)}`);continue}if(l==="C"){let[u,d]=t(parseFloat(n[o++]),parseFloat(n[o++])),[p,m]=t(parseFloat(n[o++]),parseFloat(n[o++])),[b,v]=t(parseFloat(n[o++]),parseFloat(n[o++]));s.push(`C ${e(u)} ${e(d)} ${e(p)} ${e(m)} ${e(b)} ${e(v)}`);continue}s.push(l)}return s.join(" ")}function Hx(i,t,e){let n=u=>`${Math.round(u*100)/100}`,s=i.split(/\s+/),o=[],l=0;for(;l<s.length;){let u=s[l++];if(u==="Z"||u==="z"){o.push("Z");continue}if(u==="M"||u==="L"){let d=parseFloat(s[l++]),p=parseFloat(s[l++]);o.push(`${u} ${n(d+t)} ${n(p+e)}`);continue}if(u==="C"){let d=parseFloat(s[l++]),p=parseFloat(s[l++]),m=parseFloat(s[l++]),b=parseFloat(s[l++]),v=parseFloat(s[l++]),A=parseFloat(s[l++]);o.push(`C ${n(d+t)} ${n(p+e)} ${n(m+t)} ${n(b+e)} ${n(v+t)} ${n(A+e)}`);continue}o.push(u)}return o.join(" ")}function Kr(i){return!(i.width>0&&i.height>0)}function pd(i,t){let e=cd({x:i.x,y:i.y,width:i.width,height:i.height},{x:t.x,y:t.y,width:t.width,height:t.height});return e.width>0&&e.height>0}function an(i){return i?.pageIndex!=null?`Page ${i.pageIndex}: `:""}function Ll(i){if(!i)return{r:0,g:0,b:0,a:1};if(i.space==="rgb"){let[e,n,s]=i.values;return{r:e,g:n,b:s,a:1}}if(i.space==="gray"){let[e]=i.values;return{r:e,g:e,b:e,a:1}}if(i.space==="cmyk"){let[e,n,s,o]=i.values;return{c:e,m:n,y:s,k:o,tint:1}}let t=i;return t.space==="spot"?{name:t.name,tint:t.tint??1,externalReference:""}:{r:0,g:0,b:0,a:1}}function Sd(i){let t=i.strokeWidth??0;if(i.fill||!i.stroke||!(t>0)||i.strokeDashArray?.length)return null;let e=i.d.trim().split(/\s+/),n=[],s=!1;for(let k=0;k<e.length;){let I=e[k++];if(I==="Z"&&k===e.length){s=!0;break}if(I!==(n.length===0?"M":"L"))return null;let P=Number(e[k++]),M=Number(e[k++]);if(!Number.isFinite(P)||!Number.isFinite(M))return null;n.push([P,M])}let o=(k,I)=>k[0]===I[0]&&k[1]===I[1];if(n.length>2&&o(n[0],n[n.length-1])){if(!s&&i.strokeCap!=="Square")return null;s=!0,n.pop()}let l=n.map(([k])=>k),u=n.map(([,k])=>k),d=Math.min(...l),p=Math.min(...u),m=Math.max(...l),b=Math.max(...u),v=t/2,A="";if(n.length===2&&!s){if(i.strokeCap==="Round")return null;let k=p===b,I=d===m;if(k===I)return null;let P=i.strokeCap==="Square"?v:0;d-=k?P:v,m+=k?P:v,p-=I?P:v,b+=I?P:v}else if(n.length===4&&s){if(i.strokeJoin!=="Miter"||(i.strokeMiterLimit??0)<Math.SQRT2||new Set(n.map(P=>P.join(","))).size!==4)return null;for(let P=0;P<n.length;P++){let M=n[P],N=n[(P+1)%n.length];if(M[0]===N[0]==(M[1]===N[1]))return null}let k=m-d-t,I=b-p-t;if(d-=v,p-=v,m+=v,b+=v,k>0&&I>0){let P=t,M=t;A=` M ${P} ${M} L ${P} ${M+I} L ${P+k} ${M+I} L ${P+k} ${M} Z`}}else return null;let x=m-d,w=b-p;return{...i,x:i.x+d,y:i.y+p,width:x,height:w,d:`M 0 0 L ${x} 0 L ${x} ${w} L 0 ${w} Z${A}`,fill:i.stroke,stroke:null,fillRule:"evenodd"}}var Zr="features/implicitUpdatesEnabled";async function wd(i,t){let e=jx(i),n=i.editor;if(e===void 0||typeof n.getSettingBool!="function"||typeof n.setSettingBool!="function")return t(Ad,Td);let s;try{s=n.getSettingBool(Zr),n.setSettingBool(Zr,!1)}catch{return t(Ad,Td)}let o=l=>{n.setSettingBool?.(Zr,!0);try{return l()}finally{n.setSettingBool?.(Zr,!1)}};try{return await t(e,o)}finally{n.setSettingBool(Zr,s)}}var Ad=()=>{},Td=i=>i();function jx(i){let t=i;if(typeof t.update=="function")return()=>t.update?.();if(typeof t.editor?._update=="function")return()=>t.editor?._update?.()}async function ji(i,t,e,n){let s=`${t.family}|${t.style??"normal"}|${t.weight??"normal"}`,o=e.get(s);if(o!==void 0)return o;let l=null;try{l=await i(t,n)}catch{l=null}return e.set(s,l),l}function Ed(i,t){if(i.substitutedFrom!=null)return!1;let n=(i.typeface?.name??"").toLowerCase().trim(),s=t.toLowerCase().trim();if(n===s)return!0;let o=l=>l.replace(/\s+/g,"");return o(n)===o(s)}var Vx={name:"perfect-match-resolver",async resolve(i,t){if(!t.resolver)return{kind:"pass",reason:"no-resolver-configured"};if(!i.family)return{kind:"pass",reason:"no-font-family"};let e=await ji(t.resolver,{family:i.family,style:i.style,weight:i.weight},t.resolverCache,t.engine);return e?Ed(e,i.family)?{kind:"typeface",typeface:e.typeface,font:e.font,provenance:"perfect-match",substitutedFrom:e.substitutedFrom}:{kind:"pass",reason:"not-perfect-match"}:{kind:"pass",reason:"resolver-miss"}}},pr=Vx;var Wx={name:"embedded-subset",async resolve(i){return i.embeddedFont?{kind:"subset",embeddedFont:i.embeddedFont,provenance:"embedded-subset"}:{kind:"pass",reason:"no-embedded-font"}}},Qr=Wx;var $x={name:"any-match-resolver",async resolve(i,t){if(!t.resolver)return{kind:"pass",reason:"no-resolver-configured"};if(!i.family)return{kind:"pass",reason:"no-font-family"};let e=await ji(t.resolver,{family:i.family,style:i.style,weight:i.weight},t.resolverCache,t.engine);return e?{kind:"typeface",typeface:e.typeface,font:e.font,provenance:"any-match",substitutedFrom:e.substitutedFrom}:{kind:"pass",reason:"resolver-miss"}}},Jr=$x;var Cd="ly.img.pdf-importer.text";function Fl(i,t,e,n){if(typeof i.block?.setMetadata!="function")return;let s=(l,u)=>{if(!(u==null||u===""))try{i.block.setMetadata(t,`${Cd}.${l}`,String(u))}catch{}};s("content",e.text),s("fontFamily",e.family);let o=e.source;"fontSize"in o&&typeof o.fontSize=="number"&&Number.isFinite(o.fontSize)&&s("fontSize",o.fontSize),s("fontStyle",e.style),s("fontWeight",e.weight),s("fallbackReason",n)}function kd(i,t){return t?i.family?"resolver-miss":"no-font-family":"resolver-disabled"}var gr={name:"default",async emit(i,t,e){if(t?.kind==="typeface"){let n=await e.helpers.resolveLayoutForSubstitution(i,t),s=e.helpers.createEditableText(i,n,(l,u)=>{sd(l,u,t.typeface,t.font)}),o=t.substitutedFrom!=null;return{blocks:[s],substituted:o,resolvedFamily:t.typeface.name}}if(t?.kind==="subset")return{blocks:[e.helpers.createEditableText(i,i.source,(s,o)=>{id(s,o,t.embeddedFont)})],substituted:!1,resolvedFamily:i.family};if(i.glyphPaths!=null||i.buildGlyphOutline!=null){let n=e.helpers.emitGlyphsAsVectorPath(i);if(n!=null){let s=kd(i,!0);return Fl(e.engine,n,i,s),{blocks:[n],substituted:!1}}}return i.text.trim()===""?{blocks:[],substituted:!1}:(e.logger?.emit?.("TEXT_RUN_SKIPPED_NO_RESOLUTION",{fontFamily:i.family}),{blocks:[],substituted:!1})}};function Dl(i,t){if(i.kind===re.TEXT_RUN){let e=t.fonts?.get?.(i.fontRef);return e?{family:e.family,style:e.style??"normal",weight:e.weight!=null?zx(e.weight):"normal",text:i.text,embeddedFont:e,buildGlyphOutline:i._buildGlyphOutline,source:i}:null}return i.fontFamily?{family:i.fontFamily,style:i.fontStyle??"normal",weight:i.fontWeight??"normal",text:i.text,glyphPaths:i.d,source:i}:null}function zx(i){let t=Number(i)||400;return t<=150?"thin":t<=250?"extraLight":t<=350?"light":t<=450?"normal":t<=550?"medium":t<=650?"semiBold":t<=750?"bold":t<=850?"extraBold":"heavy"}function qr(i){return{stages:i,async resolve(t,e){for(let n of i){let s=await n.resolve(t,e);if(s.kind!=="pass")return s}return null}}}function ts(i){return{cascade:i.cascade,emission:i.emission}}var _l=ts({cascade:qr([pr,Qr,Jr]),emission:gr}),Id=ts({cascade:qr([pr,Qr]),emission:gr}),Pd=ts({cascade:qr([pr,Jr]),emission:gr}),$n=_l;function Nl(i){if(i?.aborted)throw new DOMException("PDF import was aborted.","AbortError")}function Vi(i,t=0){if(Nl(i.signal),i.maxBlocks!==void 0){if(!Number.isSafeInteger(i.maxBlocks)||i.maxBlocks<=0)throw new RangeError("maxBlocks must be a positive safe integer.");if(t>i.maxBlocks)throw new Error(`PDF import exceeds the block limit of ${i.maxBlocks}.`)}}function Wi(i,t){return t?new Promise((e,n)=>{let s=()=>{t.removeEventListener("abort",s),n(new DOMException("PDF import was aborted.","AbortError"))};t.addEventListener("abort",s,{once:!0}),i.then(o=>{t.removeEventListener("abort",s),e(o)},o=>{t.removeEventListener("abort",s),n(o)}),t.aborted&&s()}):i}var Xx=16,Yx=new Set(["create","createShape","createFill","createEffect","createBlur","group","combine","duplicate"]),es=new WeakMap,mr=new WeakMap,$i=class{constructor(t,e){this.original=t;this.options=e;this.identity=Wn(t),this.scene=t.scene.get(),this.units=this.readUnits(),this.originalSpots=new Set(t.editor.findAllSpotColors());let n=this.facade(t.block,(o,l,u)=>{if(this.check(),!Yx.has(o))return u();if(this.checkBudget(1),o==="duplicate"||o==="combine"){let p=new Set([...t.block.findAll(),...this.blocks]);try{return o==="combine"?this.withLayoutFor(l[0],u):u()}finally{let m=t.block.findAll().filter(v=>!p.has(v)),b=this.withResources(m).filter(v=>!p.has(v));this.blocks.push(...b),this.allocations+=b.length,this.checkBudget(0)}}let d=o==="group"?this.withLayoutFor(l[0],u):u();if(this.blocks.push(d),this.allocations++,o==="create"){let p=this.withResources([d]).filter(m=>m!==d);this.blocks.push(...p),this.allocations+=p.length,this.checkBudget(0)}return d}),s=this.facade(t.editor,(o,l,u)=>{this.check();let d=u();if(o==="createBuffer"&&this.buffers.push(d),(o==="setSpotColorRGB"||o==="setSpotColorCMYK")&&!this.originalSpots.has(l[0])){let p=l[0];this.spots.set(p,this.readSpotDefinition(p))}return d});this.engine=new Proxy(t,{get(o,l){if(l==="block")return n;if(l==="editor")return s;let u=Reflect.get(o,l,o);return typeof u=="function"?u.bind(o):u}}),nd(this.engine,t),mr.set(this.identity,(mr.get(this.identity)??0)+1)}engine;blocks=[];buffers=[];spots=new Map;originalSpots;identity;scene;units;active=!0;disposed=!1;allocations=0;failure;pages=new Set;parking;lastYield=performance.now();parkPage(t){this.parking??=this.engine.block.create("page"),this.pages.add(t),this.engine.block.appendChild(this.parking,t)}withLayout(t,e){if(this.check(),this.scene===null||this.parking===void 0)return e();this.original.block.getGlobalBoundingBoxX(this.scene),this.original.block.appendChild(this.scene,t);try{return this.original.block.getGlobalBoundingBoxX(t),e()}finally{this.original.block.appendChild(this.parking,t)}}withLayoutFor(t,e){let n=t[0]??null;for(;n!==null&&!this.pages.has(n);)n=this.original.block.getParent(n);return n===null?e():this.withLayout(n,e)}check(){if(this.failure)throw this.failure;if(Nl(this.options.signal),!this.active)throw new Error("This PDF block import is no longer active.");if(this.original.scene.get()!==this.scene||this.readUnits()!==this.units)throw new Error("The scene or its units changed during PDF import.")}async wait(t){let e=await Wi(t,this.options.signal);return this.check(),performance.now()-this.lastYield>=Xx&&(await new Promise(n=>setTimeout(n,0)),this.check(),this.lastYield=performance.now()),e}finish(){this.check(),this.parking!==void 0&&this.original.block.destroy(this.parking),this.active=!1,this.releaseActiveSession();let t=es.get(this.identity);t&&(this.cleanupPendingSpots(t),t.buffers.size===0&&t.spots.size===0&&es.delete(this.identity))}rollback(t){try{this.dispose()}catch(e){throw new AggregateError([t,e],"PDF import failed and cleanup was incomplete.")}throw t}dispose(){if(this.disposed)return;this.disposed=!0;let t=this.active;this.active=!1,t&&this.releaseActiveSession();let e=es.get(this.identity)??{buffers:new Set,spots:new Map};es.set(this.identity,e);for(let o of this.buffers)e.buffers.add(o);for(let[o,l]of this.spots)e.spots.set(o,l);let n=[],s=o=>{try{o()}catch(l){n.push(l)}};for(let o of[...this.blocks].reverse())s(()=>{this.original.block.isValid(o)&&this.original.block.destroy(o)});if(e.buffers.size>0&&s(()=>{let o=new Set(this.original.editor.findAllTransientResources().map(({URL:l})=>l));for(let l of e.buffers)o.has(l)||s(()=>{this.original.editor.destroyBuffer(l),e.buffers.delete(l)})}),e.spots.size>0&&s(()=>this.cleanupPendingSpots(e)),e.buffers.size===0&&e.spots.size===0&&es.delete(this.identity),n.length>0)throw new AggregateError(n,"PDF import cleanup was incomplete.")}releaseActiveSession(){let t=mr.get(this.identity);t===1?mr.delete(this.identity):t!==void 0&&mr.set(this.identity,t-1)}cleanupPendingSpots(t){if(mr.has(this.identity)||t.spots.size===0)return;let e=this.referencedSpots(),n=new Set(this.original.editor.findAllSpotColors()),s=[];for(let[o,l]of t.spots){if(!n.has(o)){t.spots.delete(o);continue}try{this.readSpotDefinition(o).every((p,m)=>Math.abs(p-l[m])<1e-6)?e.has(o)||(this.original.editor.removeSpotColor(o),t.spots.delete(o)):t.spots.delete(o)}catch(u){s.push(u)}}if(s.length>0)throw new AggregateError(s,"PDF spot color cleanup was incomplete.")}readSpotDefinition(t){return[...this.original.editor.getSpotColorRGBA(t),...this.original.editor.getSpotColorCMYK(t)]}withResources(t){let e=this.original.block,n=new Set(t),s=o=>{e.isValid(o)&&n.add(o)};for(let o of t){if(e.supportsFill(o)&&s(e.getFill(o)),e.supportsShape(o)&&s(e.getShape(o)),e.supportsEffects(o))for(let l of e.getEffects(o))s(l);e.supportsBlur(o)&&s(e.getBlur(o))}return[...n]}referencedSpots(){let t=new Set,e=n=>{"name"in n&&t.add(n.name)};for(let n of this.withResources(this.original.block.findAll())){for(let s of this.original.block.findAllProperties(n))if(!(s==="fill/solid/color"||s==="camera/clearColor")){if(this.original.block.getPropertyType(s)==="Color")e(this.original.block.getColor(n,s));else if(s==="fill/gradient/colors")for(let o of this.original.block.getGradientColorStops(n,s))e(o.color)}if(this.original.block.getType(n)==="//ly.img.ubq/text")for(let s of this.original.block.getTextColors(n))e(s)}return t}checkBudget(t){if(this.options.maxBlocks!==void 0&&this.allocations+t>this.options.maxBlocks)throw this.failure=new Error(`PDF import exceeds the block limit of ${this.options.maxBlocks}.`),this.failure}readUnits(){if(this.scene===null)return"";let t=this.original.scene;return`${this.original.scene.getDesignUnit()}:${t.getFontSizeUnit?.()??"Point"}:${this.original.block.getFloat(this.scene,"scene/dpi")}`}facade(t,e){let n=new Map;return new Proxy(t,{get(s,o){let l=Reflect.get(s,o,s);return typeof l!="function"?l:(n.has(o)||n.set(o,(...u)=>e(o,u,()=>Reflect.apply(l,s,u))),n.get(o))}})}};function*Rd(i={}){let t=yield 0;return t>1?yield*Kx(t):i.allowWiden===!1?{ls:0,lines:t,direction:"unchanged"}:yield*Zx()}function*Kx(i){let t=0,e=i;for(let n=0;n<15;n++){let s=Math.max(-.15,t-.01);if(s===t)break;if(t=s,e=yield t,e<=1)return{ls:t,lines:e,direction:"tightened"}}return{ls:t,lines:e,direction:"tightened"}}function*Zx(){let i=0,t=1;for(let n=0;n<15;n++){let s=Math.min(.03,i+.01);if(s===i)break;let o=yield s;if(o>1)break;i=s,t=o}let e=Math.max(0,i-2*.01);return e!==i&&(t=yield e),{ls:e,lines:t,direction:e>0?"widened":"unchanged"}}var Md="ly.img.pdf-importer.pageBounds";async function Ld(i,t,e={}){let n=i.scene.create("VerticalStack");i.scene.setDesignUnit("Inch");let s=i.block.findByType("stack")[0];i.block.setFloat(s,"stack/spacing",bS),i.block.setBool(s,"stack/spacingInScreenspace",yS);let o=[],l={fontResolver:e.fontResolver??null,fontStrategy:e.fontStrategy??$n,logger:e.logger??null,resolverCache:new Map,textRuns:o,substitutions:new Map,subsetFallbacks:new Set,vectorPathFillRuleSupport:Xr(),irFonts:t.fonts},u=e.pageBounds??"trim";return jd(i,t,l.logger),wd(i,async(d,p)=>{l.flush=d,l.unbatched=p,l.pendingRotations=[];let m=[];for(let b=0;b<t.pages.length;b++){let v=t.pages[b];l.pageIndex=b+1;let A=i.block.create("page");i.block.setWidth(A,It(i,v.widthPt)),i.block.setHeight(A,It(i,v.heightPt));let x=[],w=[];for(let k of v.blocks){let I=await Ud(i,k,t,A,l);I!=null&&(w.push(I),k.kind===re.IMAGE&&x.push({block:I,ir:k}))}for(let k of w)i.block.appendChild(A,k);m.push({pageBlock:A,page:v,placements:x})}for(let{pageBlock:b}of m)i.block.appendChild(s,b);d();for(let{id:b,rotation:v}of l.pendingRotations??[])i.block.setRotation(b,v);for(let{pageBlock:b,page:v,placements:A}of m){A.length>0&&Pl(i,A[0].block);for(let x of A)Il(i,x.block,x.ir,{logger:l.logger??void 0});qx(i,b,v,u)}return await Dd(i,o.map(({id:b})=>b),{flush:d,logger:l.logger}),d(),o.length>0&&Pl(i,o[0].id),Bl(i,o,l,d),_d(l),Nd(l),n})}async function Fd(i,t,e={}){Vi(e,t.pages.reduce((o,l,u)=>e.pageIndex===void 0||e.pageIndex===u?o+l.blocks.length:o,0));let n=new $i(i,e),s=n.engine;e.legacyUnits&&od(s);try{let o=[],l={fontResolver:e.fontResolver??null,fontStrategy:e.fontStrategy??$n,logger:e.logger??null,resolverCache:new Map,textRuns:o,substitutions:new Map,subsetFallbacks:new Set,vectorPathFillRuleSupport:Xr(),irFonts:t.fonts},u=e.pageIndex!=null?[e.pageIndex]:t.pages.map((v,A)=>A);jd(s,{...t,pages:u.map(v=>t.pages[v]).filter(Boolean)},l.logger,!0);let d=[],p=[],m=new Map;for(let v of u){let A=t.pages[v];if(A==null||A.blocks.length===0)continue;l.pageIndex=v+1;let x=e.pageBounds==="trim"?A.trimPt:null,w=Qx(s,x?{...A,widthPt:x.widthPt,heightPt:x.heightPt}:A),k=s.block.create("page");n.parkPage(k),p.push(k),s.block.setWidth(k,It(s,A.widthPt)),s.block.setHeight(k,It(s,A.heightPt)),s.block.appendChild(k,w);let I=[],P=o.length,M=[];for(let U of A.blocks){let G=await n.wait(Ud(s,U,t,k,l));G!=null&&(M.push(G),U.kind===re.IMAGE&&I.push({block:G,ir:U}))}for(let U of M)s.block.appendChild(k,U);I.length>0&&n.withLayout(k,()=>{for(let U of I)Il(s,U.block,U.ir,{logger:l.logger??void 0})});let N=s.block.getChildren(k);if(N.length===1){s.block.destroy(k);continue}if(x)for(let U of N)U!==w&&(s.block.setPositionX(U,s.block.getPositionX(U)-It(s,x.xPt)),s.block.setPositionY(U,s.block.getPositionY(U)-It(s,x.yPt)));let D=s.block.group(N);e.preservePageBounds||s.block.destroy(w),d.push(D),m.set(k,{runs:o.slice(P),widthPt:x?.widthPt??A.widthPt})}await n.wait(Dd(s,o.map(({id:v})=>v),{signal:e.signal,logger:l.logger}));for(let[v,{runs:A,widthPt:x}]of m)A.length>0&&(e.legacyUnits?Bl(s,A,l,void 0,!1):n.withLayout(v,()=>{Bl(s,A,l),vS(s,A,x)}));_d(l),Nd(l);let b=d.map(v=>{let A=s.block.duplicate(v,!1);for(let x of s.block.getChildren(A))s.block.findAllMetadata(x).includes(Md)&&s.block.setScopeEnabled(x,"editor/select",!1);return A});for(let v of p)s.block.isValid(v)&&s.block.destroy(v);return n.finish(),{blocks:b,dispose:()=>n.dispose()}}catch(o){return n.rollback(o)}}function Qx(i,t){let e=i.block.create("graphic");i.block.setShape(e,i.block.createShape("rect")),i.block.setWidth(e,It(i,t.widthPt)),i.block.setHeight(e,It(i,t.heightPt)),i.block.setPositionX(e,0),i.block.setPositionY(e,0);let n=i.block.createFill("color");return i.block.setColor(n,"fill/color/value",{r:0,g:0,b:0,a:0}),i.block.setFill(e,n),i.block.setBool(e,"fill/enabled",!1),i.block.setName(e,"PDF page bounds"),i.block.setMetadata(e,Md,"true"),i.block.setScopeEnabled(e,"editor/select",!1),e}async function Dd(i,t,e={}){let{timeoutMs:n=1e4,flush:s,logger:o,signal:l}=e;if(typeof i.block.getState!="function"||typeof i.block.onStateChanged!="function")return;let u=p=>{try{let m=i.block.getState(p);return m.type==="Ready"||m.type==="Error"}catch{return!0}},d=t.filter(p=>!u(p));d.length!==0&&await new Promise((p,m)=>{let b=new Set(d),v=null,A=s!==void 0?setInterval(s,Jx):null,x=(I=!1,P)=>{v?.(),clearTimeout(k),A!==null&&clearInterval(A),l?.removeEventListener("abort",w),I&&b.size>0&&o?.emit?.("TEXT_FONTS_READY_TIMEOUT",{count:b.size,timeoutMs:n}),P?m(P):p()},w=()=>x(!1,new DOMException("PDF import was aborted.","AbortError")),k=setTimeout(()=>x(!0),n);l?.addEventListener("abort",w,{once:!0}),v=i.block.onStateChanged(d,I=>{for(let P of I)u(P)&&b.delete(P);b.size===0&&x()});for(let I of d)u(I)&&b.delete(I);b.size===0&&x(),l?.aborted&&w()})}var Jx=100;function _d(i){if(i.substitutions.size===0)return;let t=Array.from(i.substitutions.entries()).map(([n,s])=>`${n} \u2192 ${s}`).join(", "),e=i.substitutions.size;i.logger?.emit?.("FONT_SUBSTITUTIONS",{count:e,plural:e===1?"y":"ies",pairs:t})}function Nd(i){if(i.subsetFallbacks.size===0)return;let t=Array.from(i.subsetFallbacks).sort().join(", "),e=i.subsetFallbacks.size;i.logger?.emit?.("FONT_SUBSET_FALLBACK",{count:e,plural:e===1?"y":"ies",families:t})}function qx(i,t,e,n){if(n==="media"||!e.trimPt)return;let{xPt:s,yPt:o,widthPt:l,heightPt:u}=e.trimPt,d=It(i,s),p=It(i,o);if(d!==0||p!==0)for(let m of i.block.getChildren(t))i.block.setPositionX(m,i.block.getPositionX(m)-d),i.block.setPositionY(m,i.block.getPositionY(m)-p);i.block.setWidth(t,It(i,l)),i.block.setHeight(t,It(i,u)),e.hasBleed&&(i.block.setBool(t,"page/marginEnabled",!0),i.block.setFloat(t,"page/margin/top",It(i,e.bleedPt.top)),i.block.setFloat(t,"page/margin/bottom",It(i,e.bleedPt.bottom)),i.block.setFloat(t,"page/margin/left",It(i,e.bleedPt.left)),i.block.setFloat(t,"page/margin/right",It(i,e.bleedPt.right)))}async function Ud(i,t,e,n,s){switch(t.kind){case re.IMAGE:return tS(i,t,n,s);case re.VECTOR_PATH:return Bd(i,t,n,s);case re.TEXT_OUTLINE:case re.TEXT_RUN:return await sS(i,t,e,s);default:return s?.logger?.emit?.("BLOCK_KIND_UNKNOWN",{kind:t.kind}),null}}function tS(i,t,e,n){if(t.clips?.length){let l=gd(i,t,t.clips,e,{logger:n?.logger??void 0,pageIndex:n?.pageIndex,flush:n?.flush,unbatched:n?.unbatched});return l===Cn?null:l??(n?.logger?.emit?.("IMAGE_CLIP_COMBINE_FAILED",{prefix:Hl(n),bbox:ye(t),clipCount:t.clips.length,page:n?.pageIndex}),null)}let s=i.block.create("graphic"),o=i.block.createShape("rect");if(i.block.setShape(s,o),!dr(i,s,t,{logger:n?.logger??void 0})){try{i.block.destroy(s)}catch{}return null}return Hd(i,s,t),t.rotation&&Math.abs(t.rotation)>1e-6&&(n?.pendingRotations?n.pendingRotations.push({id:s,rotation:t.rotation}):i.block.setRotation(s,t.rotation)),t.opacity!=null&&t.opacity!==1&&i.block.setOpacity(s,t.opacity),Gd(i,s,t.blendMode,n),s}function eS(i){let t=i.block;return typeof t.setStrokeDashArray=="function"&&typeof t.setStrokeCap=="function"&&typeof t.setStrokeDashStartCap=="function"&&typeof t.setStrokeDashEndCap=="function"?t:null}function nS(i,t,e=.5){let n=e;if(!(i.x<=t.x+n&&i.y<=t.y+n&&i.x+i.width>=t.x+t.width-n&&i.y+i.height>=t.y+t.height-n)||/[CcQqSsTtAaHhVv]/.test(i.d))return!1;let o=i.x,l=i.y,u=i.x+i.width,d=i.y+i.height,p=.01,m=(v,A)=>(Math.abs(v-o)<p||Math.abs(v-u)<p)&&(Math.abs(A-l)<p||Math.abs(A-d)<p),b=i.d.match(/-?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!b||b.length<8)return!1;for(let v=0;v+1<b.length;v+=2)if(!m(parseFloat(b[v]),parseFloat(b[v+1])))return!1;return!0}function Bd(i,t,e,n){let s=Sd(t),o=t.stroke!=null&&t.fill==null,l=o?(t.strokeWidth??0)/2:0,u=s??{x:t.x-l,y:t.y-l,width:t.width+2*l,height:t.height+2*l},d=t.clips?.filter(b=>!nS(b,u,o?1e-6:.5));if(d?.length){let b=bd(i,s??t,d,e,{logger:n?.logger??void 0,pageIndex:n?.pageIndex,vectorPathFillRuleSupport:n.vectorPathFillRuleSupport,flush:n?.flush,unbatched:n?.unbatched});if(b===Cn)return null;if(b!=null)return b;n?.logger?.emit?.("CLIP_COMBINE_FAILED",{prefix:Hl(n),bbox:ye(t),clipCount:d.length,page:n?.pageIndex})}let p=i.block.create("graphic"),m=hr(i,t.d,t.width,t.height);if(Bi(i,m,t.fillRule,{logger:n?.logger??null,support:n.vectorPathFillRuleSupport}),i.block.setShape(p,m),t.fill){let b=t.fill.kind;if(b==="linearGradient"||b==="radialGradient")rS(i,p,t,n);else{let v=i.block.createFill("color");i.block.setColor(v,"fill/color/value",ns(t.fill,n,t,"vector path fill")),i.block.setFill(p,v)}}else i.block.setFillEnabled(p,!1);if(t.stroke){i.block.setStrokeEnabled(p,!0),i.block.setStrokeColor(p,ns(t.stroke,n,t,"vector path stroke")),t.strokeWidth!=null&&i.block.setStrokeWidth(p,It(i,t.strokeWidth));let b=eS(i);b!=null&&(t.strokeDashArray!=null&&t.strokeDashArray.length>0&&(b.setStrokeDashArray(p,t.strokeDashArray.map(A=>It(i,A))),t.strokeDashOffset!=null&&b.setStrokeDashOffset?.(p,It(i,t.strokeDashOffset)),t.strokeCap!=null&&(b.setStrokeDashStartCap(p,t.strokeCap),b.setStrokeDashEndCap(p,t.strokeCap))),t.strokeCap!=null&&b.setStrokeCap(p,t.strokeCap));let v=i.block;t.strokeJoin!=null&&v.setStrokeCornerGeometry?.(p,t.strokeJoin)}return Hd(i,p,t),t.opacity!=null&&t.opacity!==1&&i.block.setOpacity(p,t.opacity),Gd(i,p,t.blendMode,n),p}function Gd(i,t,e,n){let s=Ui(e,n?.logger??void 0);s!=null&&(typeof i.block.supportsBlendMode=="function"&&!i.block.supportsBlendMode(t)||i.block.setBlendMode(t,s))}function rS(i,t,e,n){let s=e.fill,o=s.kind==="linearGradient"?"gradient/linear":"gradient/radial",l=i.block.createFill(o),u=(s.stops??[]).map(m=>({color:ns(m.color,n,e,"vector path gradient stop"),stop:m.offset}));i.block.setGradientColorStops(l,"fill/gradient/colors",u);let d=e.width>0?e.width:1,p=e.height>0?e.height:1;if(s.kind==="linearGradient")i.block.setFloat(l,"fill/gradient/linear/startPointX",(s.start.x-e.x)/d),i.block.setFloat(l,"fill/gradient/linear/startPointY",(s.start.y-e.y)/p),i.block.setFloat(l,"fill/gradient/linear/endPointX",(s.end.x-e.x)/d),i.block.setFloat(l,"fill/gradient/linear/endPointY",(s.end.y-e.y)/p);else{let m=Math.max(.001,Math.min(d,p));i.block.setFloat(l,"fill/gradient/radial/centerPointX",(s.center.x-e.x)/d),i.block.setFloat(l,"fill/gradient/radial/centerPointY",(s.center.y-e.y)/p),i.block.setFloat(l,"fill/gradient/radial/radius",s.radius/m)}i.block.setFill(t,l)}async function sS(i,t,e,n){let s=Dl(t,e);if(!s)return n.logger?.emit?.(t.kind===re.TEXT_RUN?"FONT_REF_NOT_EXTRACTED":"TEXT_OUTLINE_NO_FONT_FAMILY",{fontRef:t.kind===re.TEXT_RUN?t.fontRef:""}),null;let o=await n.fontStrategy.cascade.resolve(s,{engine:i,resolver:n.fontResolver,resolverCache:n.resolverCache,logger:n.logger}),l=iS(i,n),u=await n.fontStrategy.emission.emit(s,o,{engine:i,logger:n.logger,pageIndex:n.pageIndex,helpers:l});if(u.substituted&&o?.kind==="typeface"){let p=o.typeface.name??"?";n.substitutions.has(s.family)||n.substitutions.set(s.family,p)}if(o?.kind==="subset"&&n.subsetFallbacks.add(s.family),u.blocks.length===0)return null;let d=u.blocks[0];return n.textRuns&&(o?.kind==="typeface"||o?.kind==="subset")&&(t.kind===re.TEXT_RUN?n.textRuns.push({id:d,ir:t}):n.textRuns.push({id:d,ir:{kind:re.TEXT_RUN,x:t.x,y:t.y,width:t.width,height:t.height,text:t.text,fontRef:t.fontFamily,fontSize:t.fontSize,rotation:0,fill:t.fill}})),d}function iS(i,t){return{createEditableText(e,n,s){return aS(i,e.source,s,n,t)},emitGlyphsAsVectorPath(e){let n=null;if(e.glyphPaths){let l=e.source;n={d:e.glyphPaths,x:l.x,y:l.y,width:l.width,height:l.height}}else e.buildGlyphOutline&&(n=e.buildGlyphOutline());if(!n)return null;let s=e.source,o="opacity"in s&&typeof s.opacity=="number"?s.opacity:1;return Bd(i,{kind:re.VECTOR_PATH,x:n.x,y:n.y,width:n.width,height:n.height,d:n.d,fill:s.fill,stroke:null,strokeWidth:0,opacity:o},0,t)},async resolveLayoutForSubstitution(e,n){return e.source.kind!==re.TEXT_OUTLINE||n.kind!=="typeface"?e.source:lS(i,e.source,{typeface:n.typeface,font:n.font},t)}}}async function oS(i,t,e,n){let s=t?.font?.uri,o=i.editor;if(!s||typeof o?.getFontMetrics!="function"||!n)return null;n.fontMetricsCache||(n.fontMetricsCache=new Map);let l=n.fontMetricsCache.get(s);if(l===void 0){try{l=await o.getFontMetrics(s)}catch{l=null}n.fontMetricsCache.set(s,l)}return!l||!l.unitsPerEm||l.ascender==null?null:l.ascender/l.unitsPerEm*e}function aS(i,t,e,n,s){let o=i.block.create("text");return cS(i,o,n),e(i,o),uS(i,o,t,s),t.rotation&&i.block.setRotation(o,t.rotation),o}async function lS(i,t,e,n){if(!(Math.abs(t.rotation??0)>1e-6)){if(!Number.isFinite(t.textOriginX)&&!Number.isFinite(t.textOriginY))return t;let x={};if(Number.isFinite(t.textOriginX)&&(x.x=t.textOriginX),Number.isFinite(t.textOriginY)){let w=await oS(i,e,t.fontSize,n);w!=null&&(x.y=(t.textOriginY??0)-w)}return{...t,...x}}let o=t.unrotWidth!=null&&Number.isFinite(t.unrotWidth)&&t.unrotWidth>0?t.unrotWidth:t.width,l=t.unrotHeight!=null&&Number.isFinite(t.unrotHeight)&&t.unrotHeight>0?t.unrotHeight:t.height,u=t.rotation??0,d=Math.sin(u),p=Math.cos(u),m=t.x+t.width/2,b=t.y+t.height/2,v=m-o/2+l/2*d,A=b-l/2*p;return{...t,x:v,y:A,width:o,height:l}}function cS(i,t,e){i.block.setPositionX(t,It(i,e.x)),i.block.setPositionY(t,It(i,e.y)),i.block.setWidth(t,It(i,e.width)),typeof i.block.setWidthMode=="function"&&i.block.setWidthMode(t,"Absolute"),typeof i.block.setHeightMode=="function"&&i.block.setHeightMode(t,"Auto")}function uS(i,t,e,n){typeof i.block.setTextFontSize=="function"?i.block.setTextFontSize(t,El(i,e.fontSize)):i.block.setFloat(t,"text/fontSize",El(i,e.fontSize)),typeof i.block.replaceText=="function"?i.block.replaceText(t,e.text):i.block.setString(t,"text/text",e.text),fS(i,t,e,n),dS(i,t,e,n);let s=e.opacity;s!=null&&s!==1&&i.block.setOpacity(t,s)}function hS(i){if(!i||i==="normal")return null;switch(i){case"ultraCondensed":return"Ultra Condensed";case"extraCondensed":return"Extra Condensed";case"condensed":return"Condensed";case"semiCondensed":return"Semi Condensed";case"semiExpanded":return"Semi Expanded";case"expanded":return"Expanded";case"extraExpanded":return"Extra Expanded";case"ultraExpanded":return"Ultra Expanded";default:return null}}function dS(i,t,e,n){let s=e.styleSpans;if(!Array.isArray(s)||s.length===0||!n.irFonts)return;let o=i.block;if(typeof o.setTypeface!="function"||typeof o.setTextFontWeight!="function"||typeof o.setTextFontStyle!="function")return;let l="";try{l=i.block.getString(t,"text/fontFileUri")}catch{}if(l.startsWith("https://")){for(let H of s){if(H.fontWeight!=null)try{o.setTextFontWeight(t,An(H.fontWeight),H.from,H.to)}catch{}if(H.fontStyle)try{o.setTextFontStyle(t,H.fontStyle,H.from,H.to)}catch{}}return}let u=new Map;for(let H of s){if(!H.fontRef||u.has(H.fontRef))continue;let W=n.irFonts.get(H.fontRef);if(!W){n.logger?.emit?.("TEXT_STYLE_SPAN_FONT_MISSING",{fontRef:H.fontRef,text:(e.text??"").slice(0,40)});return}let J=Ni(i,W);u.set(H.fontRef,{fontRef:H.fontRef,ef:W,uri:J.uri,typefaceName:J.typeface.name})}if(u.size===0)return;let d=[...u.values()][0],p=d.ef.family??"PDF Imported Font",m=d.ef.width,b=new Map(u),v=new Set,A=H=>`${An(H.weight)}|${H.style??"normal"}`;for(let H of u.values())v.add(A(H.ef));for(let[H,W]of n.irFonts){if(b.has(H)||W.family!==p||W.width!==m)continue;let J=A(W);if(v.has(J))continue;v.add(J);let q=Ni(i,W);b.set(H,{fontRef:H,ef:W,uri:q.uri,typefaceName:q.typeface.name})}let x=hS(m),w=x?`${p} ${x}`:p,k=[...b.values()],M={name:k.some(H=>H.typefaceName!==H.ef.postScriptName)?`${w}#${k.map(H=>H.uri).sort().join("|")}`:w,fonts:k.map(H=>({uri:H.uri,subFamily:H.ef.family,weight:An(H.ef.weight),style:H.ef.style??"normal"}))},N=u,D=s[0],G=(D?.fontRef?N.get(D.fontRef):void 0)?.uri??[...N.values()][0].uri;try{typeof o.setFont=="function"?o.setFont(t,G,M):o.setTypeface(t,M)}catch{return}for(let H of s){if(H.fontWeight!=null)try{o.setTextFontWeight(t,An(H.fontWeight),H.from,H.to)}catch{}if(H.fontStyle)try{o.setTextFontStyle(t,H.fontStyle,H.from,H.to)}catch{}}}function fS(i,t,e,n){let s=e.colorSpans;if(Array.isArray(s)&&s.length>0){if(typeof i.block.setTextColor=="function")for(let o of s){if(!o.fill)continue;let l=ns(o.fill,n,e,"text");i.block.setTextColor(t,l,o.from,o.to)}}else if(e.fill){let o=ns(e.fill,n,e,"text");if(typeof i.block.setTextColor=="function")i.block.setTextColor(t,o);else try{i.block.setColor(t,"fill/color/value",o)}catch{}}}var pS=!0,Od=1.05,Ul=1.5,gS=9,mS=.7,bS=32,yS=!0;function Bl(i,t,e,n,s=!0){if(!pS||typeof i.block.getTextVisibleLineCount!="function")return;let o=[];for(let{id:l,ir:u}of t){let d=u.width;if(d<u.fontSize){let v=Math.max(1,u.text.length)*u.fontSize*mS;v>d&&(d=v,i.block.setWidth(l,It(i,d)))}if(!s){i.block.setFloat(l,"text/letterSpacing",0);continue}let p=Rd({allowWiden:!1}),m=p.next();if(m.done)continue;let b=m.value;o.push({id:l,ir:u,gen:p,phase:"ls",workingWidthScene:It(i,d),widen:1,widenIter:0,lines:1,write:()=>i.block.setFloat(l,"text/letterSpacing",b)})}for(;o.length>0;){for(let u of o)u.write();let l=o[0].id;i.block.setRotation(l,i.block.getRotation(l)),n?.();for(let u=o.length-1;u>=0;u--){let d=o[u],p=Gl(i,d.id);xS(i,d,p)&&(o.splice(u,1),d.lines>1&&e?.logger?.emit?.("TEXT_OVERFLOW_AFTER_AUTOSIZE",{text:SS(d.ir.text,30),overflowLines:d.lines-1}))}}}function vS(i,t,e){let n=It(i,e);for(let{id:s,ir:o}of t){if(Math.abs(o.rotation??0)>1e-6||o.advanceWidthPt==null||o.width-o.advanceWidthPt>o.fontSize*.05+1e-6)continue;let l=i.block.getWidth(s),u=n-i.block.getPositionX(s);u<=0||l<=u||It(i,o.advanceWidthPt)>u||i.block.getTextVisibleLineCount(s)!==1||(i.block.setWidth(s,u),i.block.setRotation(s,i.block.getRotation(s)),Gl(i,s)!==1&&(i.block.setWidth(s,l),i.block.setRotation(s,i.block.getRotation(s)),Gl(i,s)))}}function xS(i,t,e){if(t.phase==="ls"){let s=t.gen.next(e);if(!s.done){let l=s.value;return t.write=()=>i.block.setFloat(t.id,"text/letterSpacing",l),!1}if(t.lines=s.value.lines,t.lines<=1)return!0;t.phase="widen",t.widenIter=1,t.widen=Math.min(Ul,t.widen*Od);let o=t.workingWidthScene*t.widen;return t.write=()=>i.block.setWidth(t.id,o),!1}if(t.lines=e,e<=1||t.widen>=Ul||t.widenIter>=gS)return!0;t.widenIter+=1,t.widen=Math.min(Ul,t.widen*Od);let n=t.workingWidthScene*t.widen;return t.write=()=>i.block.setWidth(t.id,n),!1}function Gl(i,t){try{return i.block.getTextVisibleLineCount(t)}catch{return 1}}function SS(i,t){return i.length>t?i.slice(0,t-1)+"\u2026":i}function Hd(i,t,e){i.block.setPositionX(t,It(i,e.x)),i.block.setPositionY(t,It(i,e.y)),i.block.setWidth(t,It(i,e.width)),i.block.setHeight(t,It(i,e.height))}function jd(i,t,e,n=!1){if(!i?.editor?.setSpotColorCMYK)return;let s=new Map,o=u=>{let d=u;!d||d.space!=="spot"||!d.name||s.has(d.name)||s.set(d.name,{alt:d.alternateSpace??"DeviceCMYK",solid:Array.isArray(d.solid)?d.solid:[]})};for(let u of t.pages??[])for(let d of u.blocks??[])o(d.fill),o(d.stroke);let l=n?new Set(i.editor.findAllSpotColors()):new Set;for(let[u,d]of s)try{if(l.has(u)){let p=d.alt==="DeviceCMYK"?i.editor.getSpotColorCMYK(u):i.editor.getSpotColorRGBA(u).slice(0,3),m=d.alt==="DeviceGray"?Array(3).fill(d.solid[0]):d.solid;(m.length!==p.length||m.some((b,v)=>Math.abs(b-p[v])>1e-6))&&e?.emit?.("SPOT_COLOR_DEFINITION_PRESERVED",{name:u});continue}if(d.alt==="DeviceCMYK"&&d.solid.length>=4){let[p,m,b,v]=d.solid;i.editor.setSpotColorCMYK(u,p,m,b,v)}else if(d.alt==="DeviceGray"&&d.solid.length>=1){let p=d.solid[0];i.editor.setSpotColorRGB(u,p,p,p)}else if(d.alt==="DeviceRGB"&&d.solid.length>=3){let[p,m,b]=d.solid;i.editor.setSpotColorRGB(u,p,m,b)}else e?.emit?.("SPOT_COLOR_NO_ALTERNATE",{name:u})}catch(p){let m=p&&typeof p=="object"&&"message"in p?String(p.message):String(p);e?.emit?.("SPOT_COLOR_REGISTER_FAILED",{name:u,error:m})}}function ns(i,t,e,n){if(!i)return{r:0,g:0,b:0,a:1};if(i.space==="rgb"){let[o,l,u]=i.values;return{r:o,g:l,b:u,a:1}}if(i.space==="gray"){let[o]=i.values;return{r:o,g:o,b:o,a:1}}if(i.space==="cmyk"){let[o,l,u,d]=i.values;return{c:o,m:l,y:u,k:d,tint:1}}let s=i;return s.space==="spot"?{name:s.name,tint:s.tint??1,externalReference:""}:(t?.logger?.emit?.("COLOR_SPACE_UNSUPPORTED",{prefix:Hl(t),elementLabel:AS(n),space:s.space,color:Pi(i),bbox:ye(e),page:t?.pageIndex,element:n??null}),{r:0,g:0,b:0,a:1})}function Hl(i){return i?.pageIndex!=null?`Page ${i.pageIndex}: `:""}function AS(i){return i?`${i} `:""}function zd(i){let t=[],e=null,n=()=>{if(e){if(e.runs.length===1)t.push(e.runs[0]);else if(ES(e.runs))for(let s of e.runs)t.push(s);else t.push(RS(e.runs));e=null}};for(let s of i){if(s.kind!==re.TEXT_RUN){n(),t.push(s);continue}let o=s;if(!e){e={runs:[o]};continue}let l=e.runs[e.runs.length-1];CS(l,o)?e.runs.push(o):(n(),e={runs:[o]})}return n(),t}var Xd=.15,Yd=.35,TS=.5,wS=.5;function ES(i){let t=new Map;for(let e of i){if(!e.family)continue;let n=`${e.family}|${e.fontWeight??""}|${e.fontStyle??""}|${e.fontWidth??""}`,s=t.get(n);if(s!==void 0&&s!==e.fontRef)return!0;s===void 0&&t.set(n,e.fontRef)}return!1}function CS(i,t){let e=!1;if(i.fontRef!==t.fontRef){if(!i.family||!t.family||i.family!==t.family||!i.fontWidth||!t.fontWidth||i.fontWidth!==t.fontWidth)return!1;e=!0}return Math.abs(i.fontSize-t.fontSize)>.5||Math.abs((i.rotation??0)-(t.rotation??0))>.001?!1:i.baselineXPt!=null&&i.baselineYPt!=null&&i.advanceWidthPt!=null&&t.baselineXPt!=null&&t.baselineYPt!=null?kS(i,t,e):IS(i,t,e)}function kS(i,t,e){let n=i.fontSize||10,s=i.rotation??0,o=Math.cos(s),l=Math.sin(s),u=i.baselineXPt,d=i.baselineYPt,p=i.advanceWidthPt,m=t.baselineXPt,b=t.baselineYPt,v=u+p*o,A=d+p*l,x=m-v,w=b-A,k=x*o+w*l,I=-x*l+w*o,P=(e?Yd:Xd)*n;return!(Math.abs(I)>TS*n||k<-wS*n||k>P)}function IS(i,t,e){let n=i.fontSize||10,s=i.rotation??0,o=Math.cos(s),l=Math.sin(s),u=t.x+t.width/2-(i.x+i.width/2),d=t.y+t.height/2-(i.y+i.height/2);if(Math.abs(u*-l+d*o)>.5*n)return!1;let m=Math.abs(u*o+d*l),b=(i.width+t.width)/2,v=e?Yd*n:0;return!(m>b+v)}function PS(i,t){if(i.fontRef===t.fontRef||!i.family||!t.family||i.family!==t.family)return!1;let e=i.fontSize||10,n=Xd*e;if(i.baselineXPt!=null&&i.advanceWidthPt!=null&&t.baselineXPt!=null){let l=i.rotation??0,u=Math.cos(l),d=Math.sin(l),p=i.baselineXPt+i.advanceWidthPt*u,m=(i.baselineYPt??0)+i.advanceWidthPt*d,b=t.baselineXPt-p,v=(t.baselineYPt??0)-m;return b*u+v*d>n}let s=Math.abs(t.x+t.width/2-(i.x+i.width/2)),o=(i.width+t.width)/2;return s-o>n}function Vd(i){for(let t=1;t<i.length;t++){let e=i[t-1],n=i[t];n.from>e.to&&(e.to=n.from)}}function RS(i){let t=i[0],e=Math.min(...i.map(w=>w.x)),n=Math.min(...i.map(w=>w.y)),s=Math.max(...i.map(w=>w.x+w.width)),o=Math.max(...i.map(w=>w.y+w.height)),l="",u=[],d=[];for(let w=0;w<i.length;w++){let k=i[w];if(w>0){let P=i[w-1];PS(P,k)&&(l+=" ")}let I=l.length;if(Array.isArray(k.colorSpans)&&k.colorSpans.length>0)for(let P of k.colorSpans)u.push({from:I+P.from,to:I+P.to,fill:P.fill??null});else u.push({from:I,to:I+k.text.length,fill:k.fill??null});d.push({from:I,to:I+k.text.length,fontWeight:k.fontWeight,fontStyle:k.fontStyle,fontRef:k.fontRef}),l+=k.text}Vd(u),Vd(d);let p=[];for(let w of u){let k=p[p.length-1];k&&jl(k.fill,w.fill)&&k.to===w.from?k.to=w.to:p.push({...w})}let m=p.every(w=>jl(w.fill,p[0].fill)),b=[];for(let w of d){let k=b[b.length-1];k&&k.fontWeight===w.fontWeight&&k.fontStyle===w.fontStyle&&k.fontRef===w.fontRef&&k.to===w.from?k.to=w.to:b.push({...w})}let v=b.every(w=>w.fontWeight===b[0].fontWeight&&w.fontStyle===b[0].fontStyle&&w.fontRef===b[0].fontRef),A=b.map(w=>({from:w.from,to:w.to,...w.fontWeight!=null?{fontWeight:w.fontWeight}:{},...w.fontStyle!=null?{fontStyle:w.fontStyle}:{},fontRef:w.fontRef})),x=OS(i);return{...t,x:e,y:n,width:s-e,height:o-n,text:l,...m?{}:{colorSpans:p},...v?{}:{styleSpans:A},...x?{_buildGlyphOutline:x}:{}}}function OS(i){let t=i.map(e=>e._buildGlyphOutline).filter(e=>e!=null);if(t.length!==0)return()=>{let e=t.map(d=>d()).filter(d=>d!=null);if(e.length===0)return null;let n=1/0,s=1/0,o=-1/0,l=-1/0;for(let d of e)d.x<n&&(n=d.x),d.y<s&&(s=d.y),d.x+d.width>o&&(o=d.x+d.width),d.y+d.height>l&&(l=d.y+d.height);return{d:e.map(d=>Zd(d.d,d.x-n,d.y-s)).filter(d=>d.length>0).join(" "),x:n,y:s,width:o-n,height:l-s}}}var MS=.5,Wd=.3;function Kd(i){let t=[],e=null,n=()=>{e&&(e.length===1?t.push(e[0]):t.push(FS(e)),e=null)};for(let s of i){if(s.kind!==re.TEXT_OUTLINE){n(),t.push(s);continue}let o=s;if(!e){e=[o];continue}let l=e[e.length-1];LS(l,o)?e.push(o):(n(),e=[o])}return n(),t}function LS(i,t){if(!i.fontFamily||!t.fontFamily||i.fontFamily!==t.fontFamily||Math.abs((i.fontSize??0)-(t.fontSize??0))>.5||(i.fontStyle??"normal")!==(t.fontStyle??"normal")||(i.fontWeight??"normal")!==(t.fontWeight??"normal")||!jl(i.fill,t.fill))return!1;let e=i.fontSize||10;if(Math.abs(i.y-t.y)>e*Wd||Math.abs(i.y+i.height-(t.y+t.height))>e*Wd)return!1;let n=i.x+i.width,s=t.x-n,o=e*MS;return!(s>o||s<-o)}function jl(i,t){if(i==null&&t==null)return!0;if(i==null||t==null||i.space!==t.space||(i.alpha??1)!==(t.alpha??1)||!i.values||!t.values||i.values.length!==t.values.length)return!1;for(let e=0;e<i.values.length;e++)if(Math.abs(i.values[e]-t.values[e])>1e-6)return!1;return!0}function FS(i){let t=i[0],e=Math.min(...i.map(m=>m.x)),n=Math.min(...i.map(m=>m.y)),s=Math.max(...i.map(m=>m.x+m.width)),o=Math.max(...i.map(m=>m.y+m.height)),l=i.map(m=>m.text??"").join(""),u=i.map(m=>Zd(m.d??"",m.x-e,m.y-n)).filter(m=>m.length>0).join(" "),d=i.map(m=>m.textOriginX).filter(m=>Number.isFinite(m)),p=d.length>0?Math.min(...d):void 0;return{...t,x:e,y:n,width:s-e,height:o-n,text:l,d:u,textOriginX:p}}function Zd(i,t,e){if(!i)return"";if(Math.abs(t)<1e-9&&Math.abs(e)<1e-9)return i;let n=i.trim().split(/\s+/),s=[],o=0;for(;o<n.length;){let l=n[o];if(l==="Z"||l==="z"){s.push(l),o++;continue}if(/^[A-Za-z]$/.test(l)){let u=l,d=DS(u);s.push(u);for(let p=0;p<d;p++){let m=Number(n[o+1+p*2]),b=Number(n[o+2+p*2]);if(!Number.isFinite(m)||!Number.isFinite(b)){s.push(n[o+1+p*2],n[o+2+p*2]);continue}s.push($d(m+t),$d(b+e))}o+=1+d*2;continue}s.push(l),o++}return s.join(" ")}function DS(i){switch(i){case"M":case"m":case"L":case"l":case"T":case"t":return 1;case"Q":case"q":case"S":case"s":return 2;case"C":case"c":return 3;default:return 0}}function $d(i){return`${Math.round(i*100)/100}`}var zi=40,Xi=class i{engine;pdfBytes;fontResolver;fontStrategy;pageBounds;preserveWhitePageBackground;logger=new Os(_u);ir;constructor(t,e,n,s="trim",o=$n,l=!1){this.engine=t,this.pdfBytes=e,this.fontResolver=n??Io,this.fontStrategy=o,this.pageBounds=s,this.preserveWhitePageBackground=l}static async fromFile(t,e,n){let s;e instanceof ArrayBuffer?s=e:s=await e.arrayBuffer();let o=new Uint8Array(s);return typeof n=="function"?new i(t,o,n):new i(t,o,n?.fontResolver,n?.pageBounds,n?.fontStrategy,n?.preserveWhitePageBackground)}async parse(){let t=await this.ensureIR(),e=await Ld(this.engine,t,{fontResolver:this.fontResolver,fontStrategy:this.fontStrategy,logger:this.logger,pageBounds:this.pageBounds});return await this.zoomToFirstPage(),{scene:e,logger:this.logger}}async zoomToFirstPage(){try{let t=this.engine.scene.getPages()[0];if(t===void 0||typeof this.engine.scene.zoomToBlock!="function")return;await this.engine.scene.zoomToBlock(t,zi,zi,zi,zi)}catch{}}async loadAsBlocks(t){Vi(t??{});let e=this.engine.scene.get(),n=await Wi(this.ensureIR(),t?.signal);if(this.engine.scene.get()!==e)throw new Error("The scene changed during PDF import.");return t?.pageIndex!=null&&(t.pageIndex<0||t.pageIndex>=n.pages.length)?(this.logger.emit("PAGE_INDEX_OUT_OF_RANGE",{requested:t.pageIndex,available:n.pages.length}),{blocks:[],logger:this.logger,dispose:()=>{}}):{...await Fd(this.engine,n,{fontResolver:this.fontResolver,fontStrategy:this.fontStrategy,logger:this.logger,pageBounds:"media",pageIndex:t?.pageIndex,legacyUnits:t?.units!=="scene",preservePageBounds:t?.preservePageBounds,signal:t?.signal,maxBlocks:t?.maxBlocks}),logger:this.logger}}async getPageCount(){return(await this.ensureIR()).pages.length}getLogger(){return this.logger}async ensureIR(){if(this.ir)return this.ir;let t=await td(this.pdfBytes,{textMode:"auto",preserveWhitePageBackground:this.preserveWhitePageBackground,logger:this.logger});this.logger.emit("DOC_PAGE_COUNT",{count:t.pages.length});for(let e=0;e<t.pages.length;e++){let n=_S(t.pages[e].blocks);this.logger.emit("DOC_PAGE_BLOCK_COUNT",{page:e,imageCount:n.image,vectorCount:n.vector,textCount:n.text,outlineCount:n.outline})}for(let e of t.pages)e.blocks=Kd(e.blocks),e.blocks=zd(e.blocks);return this.ir=t,t}};function _S(i){let t={image:0,vector:0,text:0,outline:0};for(let e of i)e.kind==="image"?t.image++:e.kind==="vector-path"?t.vector++:e.kind==="text-run"?t.text++:e.kind==="text-outline"&&t.outline++;return t}0&&(module.exports={Logger,PDFParser,addGfontsAssetLibrary,anyMatchResolverStage,assetLibraryStrategy,createFontCascade,createFontStrategy,defaultEmission,defaultStrategy,editableFirstStrategy,embeddedSubsetStage,exactFidelityStrategy,perfectMatchResolverStage});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,o)=>(o=n==null?{}:e(i(n)),l(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));let d=require("@napi-rs/canvas"),f=require("node:fs"),p=require("node:path"),m=require("node:url"),h=require("node:module");function g(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>{if(!(r in t))throw Error(`Missing param "${r}" for warning template: ${e}`);return String(t[r])})}var _=class{registry;messages=[];constructor(e){this.registry=e}emit(e,t={}){let n=this.registry[e];this.messages.push({code:e,type:n.severity,message:g(n.template,t),params:t})}getMessages(){return this.messages}};const v=`https://cdn.img.ly/packages/imgly/gfonts/0.1.0/dist/ttf`,y=`ly.img.gfonts`,b=`ly.img.gfonts-fallbacks`;async function x(e){let t=e.asset.findAllSources();t.includes(y)||await e.asset.addLocalAssetSourceFromJSONURI(`${v}/${y}/content.json`),t.includes(b)||await e.asset.addLocalAssetSourceFromJSONURI(`${v}/${b}/content.json`)}async function S(e,t,n){let r=t.asset.findAllSources();if(!r.includes(y)||!r.includes(b))throw Error(`The gfonts asset sources (${y}, ${b}) are not available. Call addGfontsAssetLibrary() first.`);let i=await j(t,e.family);if(!i)return null;let{typeface:a,substitutedFrom:o}=i,s=a.fonts.find(t=>T(t,e));if(!s&&e.weight&&n?.closestWeightMatch){let t=e.style===void 0?a.fonts:a.fonts.filter(t=>t.style?.toLowerCase()===e.style.toLowerCase());t.length>0&&(s=O(t,e.weight))}return s?{typeface:a,font:s,substitutedFrom:o}:null}const C={100:`thin`,200:`extraLight`,300:`light`,regular:`normal`,400:`normal`,500:`medium`,600:`semiBold`,700:`bold`,800:`extraBold`,900:`heavy`},w=[`thin`,`extraLight`,`light`,`normal`,`medium`,`semiBold`,`bold`,`extraBold`,`heavy`];function T(e,t){return!(t.style!==void 0&&e.style?.toLowerCase()!==t.style.toLowerCase()||t.weight!==void 0&&!E(t.weight,e.weight))}function E(e,t){if(!t)return!1;if(e===t)return!0;let n=e.toLowerCase();if(n===t)return!0;let r=C[n];return r!==void 0&&r===t}function D(e){let t=e.toLowerCase();for(let e of w)if(e.toLowerCase()===t)return e;return C[t]??null}function O(e,t){let n=D(t);if(n===null)return;let r=w.indexOf(n);if(r===-1)return;let i=/* @__PURE__ */ new Map;for(let t of e){if(!t.weight)continue;let e=D(t.weight);if(e===null)continue;let n=w.indexOf(e);n>=0&&!i.has(n)&&i.set(n,t)}if(i.size===0)return;let a=w.indexOf(`normal`),o=w.indexOf(`medium`),s=[];if(r===a||r===o){for(let e=r;e<=o;e++)s.push(e);for(let e=a-1;e>=0;e--)s.push(e);for(let e=o+1;e<w.length;e++)s.push(e)}else if(r<a){for(let e=r;e>=0;e--)s.push(e);for(let e=r+1;e<w.length;e++)s.push(e)}else{for(let e=r;e<w.length;e++)s.push(e);for(let e=r-1;e>=0;e--)s.push(e)}for(let e of s){let t=i.get(e);if(t)return t}}function k(e){return e.toLowerCase().replace(/[\s\-_]+/g,``)}function A(e,t){return e.find(e=>{let n=e.payload?.typeface?.name;return n!=null&&k(n)===t||e.id!=null&&k(e.id)===t||typeof e.label==`string`&&k(e.label)===t})?.payload?.typeface??null}async function j(e,t){let n=await M(e,b,t);if(n)return{typeface:n,substitutedFrom:t};let r=await M(e,y,t);if(r)return{typeface:r};let i=await ee(e,b,t),a=await ee(e,y,t);return i&&i.kind!==`fuzzy`&&!(a?.kind===`prefix`&&a.matched>i.matched)?{typeface:i.typeface,substitutedFrom:t}:a?{typeface:a.typeface}:null}async function M(e,t,n){let r=k(n);if(e.asset.fetchAsset){let n=await e.asset.fetchAsset(t,r),i=A(n?[n]:[],r);if(i)return i}let i=[[{property:`id`,equals:r}],[{property:`label`,equals:n.trim()}]];for(let n of i){let i=A((await e.asset.findAssets(t,{page:0,perPage:5,filter:n}))?.assets??[],r);if(i)return i}return null}async function ee(e,t,n){let r=k(n),i=null,a=null;for(let o of P(n)){let n=(await e.asset.findAssets(t,{page:0,query:o,perPage:20}))?.assets??[];if(n.length===0)continue;let s=A(n,r);if(s)return{typeface:s,kind:`exact`,matched:r.length};if(!i){let e=k(o),t=A(n,e);t&&(i={typeface:t,matched:e.length})}a??=n[0].payload?.typeface??null}return i?{...i,kind:`prefix`}:a?{typeface:a,kind:`fuzzy`,matched:0}:null}function N(e){return e.replace(/[_\-+.,]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1 $2`).trim().split(/\s+/).filter(Boolean)}function P(e){let t=N(e),n=[e.trim()];for(let e=t.length;e>0;e--)n.push(t.slice(0,e).join(` `));return[...new Set(n)]}function F(e){return typeof e.block.setTextFontWeightAndStyle==`function`}function I(e,t,n,r,i){let{weight:a,style:o}=n;if(a!=null&&o!=null&&F(e))try{e.block.setTextFontWeightAndStyle(t,a,o,r,i);return}catch{}let s=()=>{a!=null&&e.block.setTextFontWeight(t,a,r,i)},c=()=>{o!=null&&e.block.setTextFontStyle(t,o,r,i)};try{s(),c()}catch{c(),s()}}function te(e,t,n=1,r=0){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t.unitsPerEm)||t.unitsPerEm<=0||!Number.isFinite(t.underlineSize)||!Number.isFinite(t.underlineOffset)||!Number.isFinite(n)||n<0||!Number.isFinite(r))return null;let i=Math.abs(e*Math.max(t.underlineSize,10)/t.unitsPerEm)*n;return{weight:i,offset:-e*t.underlineOffset/t.unitsPerEm*(1+r)+i/2}}function ne(e,t,n,r){let i=te(e,t);if(!i||n!==void 0&&(!Number.isFinite(n)||n<0)||r!==void 0&&!Number.isFinite(r))return null;let a=n??i.weight,o=i.offset-i.weight/2,s=r===void 0?o:r-a/2;return o===0&&s!==0?null:{thickness:a/i.weight,relativeOffset:o===0?0:s/o-1}}const re={DOC_PAGE_COUNT:{severity:`info`,template:`PDF has {count} page(s)`},DOC_PAGE_BLOCK_COUNT:{severity:`info`,template:`Page {page}: {imageCount} image, {vectorCount} vector, {textCount} text, {outlineCount} outline`},DOC_PAGE_ROTATION_DROPPED:{severity:`warning`,template:`{prefix}PDF declares /Rotate {pageRotation}; the importer does not apply page rotation, so the imported page is in its un-rotated (native) orientation. Viewer-rendered output may differ from the source's display orientation.`},BLOCK_KIND_UNKNOWN:{severity:`error`,template:`An unknown block kind "{kind}" was encountered and was skipped.`},PAGE_INDEX_OUT_OF_RANGE:{severity:`warning`,template:`Requested page index {requested} is out of range; PDF has {available} page(s). No blocks were emitted.`},FONT_OPENTYPE_PARSE_FAILED:{severity:`warning`,template:`{prefix}font "{fontName}" could not be parsed as OpenType{reason}. Glyph outlines will fall back to pdf.js raster paths — some shapes may render without stroke/anti-aliasing detail.`},FONT_CMAP_AUGMENTED:{severity:`info`,template:`Font "{fontName}" character map was augmented (cmap patches={cmapPatches}, injected glyphs={injectedGlyphs}).`},FONT_CMAP_AUGMENT_FAILED:{severity:`warning`,template:`Font "{fontName}" character map could not be augmented. Using the original font data — some glyphs may render incorrectly.`},FONT_RESOLVER_MISS:{severity:`warning`,template:`Font "{fontFamily}" could not be resolved. The text was rendered as a vector outline.`},FONT_NOT_FOUND_IN_ASSETS:{severity:`warning`,template:`Font "{fontFamily}" was not found in the asset library. The text was rendered as a vector outline.`},FONT_SUBSTITUTED:{severity:`info`,template:`Font "{fontFamily}" was substituted with "{substitutedName}" from the asset library.`},FONT_REF_NOT_EXTRACTED:{severity:`error`,template:`Text run references font "{fontRef}" which was not extracted. The text was skipped.`},FONT_SUBSTITUTIONS:{severity:`warning`,template:`Substituted {count} font famil{plural} during import: {pairs}.`},FONT_SUBSET_FALLBACK:{severity:`warning`,template:`Used PDF-embedded subset bytes for {count} font famil{plural} not in the asset library: {families}. Subset fonts use the glyphs of the PDF. They have no kerning and hold only the glyphs the PDF uses, so text typed later can look different. Add the families to the asset library to use clean asset-library fonts instead.`},TEXT_OUTLINE_NO_FONT_FAMILY:{severity:`warning`,template:`Text outline has no declared font family. The run was skipped.`},TEXT_RUN_SKIPPED_NO_RESOLUTION:{severity:`warning`,template:`No typeface or glyph outlines for "{fontFamily}"; run skipped.`},TEXT_RENDER_MODE_SKIPPED:{severity:`warning`,template:`Text item{pageTag}: skipped "{text}" — PDF text rendering mode {modeLabel}. This text paints no ink; for mode 7 it acts as a clipping mask for following images, an effect the importer does not currently reproduce.`},TEXT_OVERFLOW_AFTER_AUTOSIZE:{severity:`warning`,template:`Text "{text}" did not fit after auto-sizing; it still overflows by {overflowLines} line(s). The text was kept; some content may be clipped.`},TEXT_FONTS_READY_TIMEOUT:{severity:`warning`,template:`{count} text block(s) were still loading fonts after {timeoutMs} ms. Their letter spacing and width were fitted to fallback fonts. When the real fonts arrive, these blocks can wrap differently, so their lines and baselines can move.`},TEXT_CLIP_MODE_7_DROPPED:{severity:`warning`,template:`{prefix}{label} at ({bbox}) {bboxSize} pt: dropped because text in PDF render mode 7 clips it, and the shape of some letters is unknown. The artwork would otherwise show outside the letters.`},IMAGE_ENCODER_MISS:{severity:`warning`,template:`{prefix}an image{idLabel} ({width}×{height} raw pixels{kind}) could not be encoded ({reason}). The image was dropped from the imported design.`},IMAGE_PDFJS_UNRESOLVED:{severity:`error`,template:`{prefix}image placement {idLabel} at ({bboxX}, {bboxY}) {bboxW}×{bboxH} pt could not be resolved by pdf.js (reason={reason}) and was dropped.`},IMAGE_NO_PIXELS:{severity:`warning`,template:`An image element has no pixel data and was skipped.`},IMAGE_PROFILE_BUDGET_EXCEEDED:{severity:`warning`,template:`{prefix}the images of this import pass 512 MiB of ICC profile data. Later images with an ICC profile keep their decoded pixels instead of their original JPEG colors.`},IMAGE_DEFINITION_FALLBACK:{severity:`warning`,template:`{prefix}an image at {bbox} could not keep its original JPEG colors ({error}). It was imported from its decoded pixels.`},IMAGE_PROFILE_REFUSED:{severity:`warning`,template:`{prefix}the ICC profile of an image at {bbox} cannot be used ({reason}). The image keeps its decoded pixels instead of its original JPEG colors.`},IMAGE_FLIP_UNSUPPORTED:{severity:`warning`,template:`Image flip could not be applied (engine version too old). The image will display without flip.`},IMAGE_PLACEMENT_UNSUPPORTED:{severity:`warning`,template:`Image placement could not be applied (engine version too old). The image will be scaled evenly to cover its box and can be cut off.`},IMAGE_SKEW_DROPPED:{severity:`warning`,template:`{prefix}an image{idLabel} at ({bboxX}, {bboxY}) {bboxW}×{bboxH} pt has a skewed transform ctm={ctm}{residualStr} that cannot be represented. The image keeps its rotation, width and area, but appears without the skew.`},IMAGE_CLIPPED_NO_BYTES:{severity:`warning`,template:`{prefix}a clipped image at {bbox} had no decoded bytes; the placement was dropped before combining clip shapes.`},IMAGE_CLIP_UNUSABLE:{severity:`warning`,template:`{prefix}a clipped image at {bbox} with {clipCount} clip path(s) has no usable clip — {degenerateCount} degenerate, {disjointCount} disjoint from the image. The image was dropped.`},IMAGE_CLIPPED_TO_EMPTY:{severity:`info`,template:`{prefix}a clipped image at {bbox} with {clipCount} clip path(s) lies entirely outside its clip region ({disjointCount} clip path(s) disjoint from the image); the source draws nothing there, so the placement was skipped.`},IMAGE_CLIP_EMPTY_INTERSECTION:{severity:`warning`,template:`{prefix}a clipped image at {bbox} with {clipCount} clip path(s) had an empty intersection. The image was dropped.`},IMAGE_CLIP_COMBINE_FAILED:{severity:`error`,template:`{prefix}a clipped image at {bbox} with {clipCount} clip path(s) could not be combined. The image was dropped from the imported design.`},IMAGE_MASK_NO_FILL_COLOR:{severity:`warning`,template:`{prefix}a stencil ImageMask paint (objId={objId}) had no current fill colour to composite with. The mask was dropped from the imported design.`},IMAGE_MASK_COMPOSITE_FAIL:{severity:`warning`,template:`{prefix}a stencil ImageMask (objId={objId}) at ({bboxX}, {bboxY}) {bboxW}×{bboxH} pt could not be composited with the current fill colour (space={colourSpace}). The mask was dropped from the imported design.`},IMAGE_SOFT_MASK_DROPPED:{severity:`warning`,template:`{prefix}{detail} The masked content was dropped from the imported design.`},IMAGE_SOFT_MASK_IGNORED:{severity:`warning`,template:`{prefix}a luminosity soft mask at {bbox} modulates content other than images. That content was kept without the mask, so it can look harder or more opaque than in the PDF.`},IMAGE_MASK_GROUP_UNSUPPORTED:{severity:`warning`,template:`{prefix}a paintImageMaskXObjectGroup batch of {count} stencil paints is not supported by the importer. The masks were dropped.`},IMAGE_MASK_REPEAT_UNSUPPORTED:{severity:`warning`,template:`{prefix}a paintImageMaskXObjectRepeat tiling {count} stencil paints is not supported by the importer. The masks were dropped.`},CLIP_DEGENERATE_FALLBACK:{severity:`warning`,template:`{prefix}a clipped vector path at {bbox} with {clipCount} clip path(s) has no usable clip — {degenerateCount} degenerate (zero width or height). Falling back to the unclipped path.`},CLIP_COMBINE_STROKE_ONLY:{severity:`warning`,template:`{prefix}a clipped stroke-only vector path at {bbox} with {clipCount} clip path(s) could not be outlined for clipping, because its path data is unreadable or the CE.SDK version has no non-zero fill rule. Falling back to the unclipped path.`},CLIP_STROKE_DROPPED:{severity:`warning`,template:`{prefix}a clipped vector path at {bbox} that fills and strokes keeps its clipped fill but loses its stroke, because the stroke could not be outlined for clipping (path data too large or unreadable, or a CE.SDK version without the non-zero fill rule).`},CLIP_COMBINE_FAILED:{severity:`warning`,template:`{prefix}a vector path at {bbox} with {clipCount} clip path(s) could not be combined. Rendered without its clip — some content may extend beyond the intended mask.`},CLIP_COMBINE_TOO_FEW_INPUTS:{severity:`warning`,template:`{prefix}clip combine was called with {inputCount} input block(s) (need at least 2). The owner block was emitted without its clips.`},CLIP_COMBINE_NOT_COMBINABLE:{severity:`warning`,template:`{prefix}clip combine rejected {inputCount} input block(s) as not combinable (nested or incompatible shapes). The owner block was emitted without its clips.`},CLIP_COMBINE_THREW:{severity:`warning`,template:`{prefix}clip combine of {inputCount} input block(s) failed ({reason}). The owner block was emitted without its clips.`},COLOR_TYPE_UNSUPPORTED:{severity:`warning`,template:`{prefix}{subject}color of type "{colorType}" is not supported. Rendered as black.`},COLOR_SPACE_UNSUPPORTED:{severity:`warning`,template:`{prefix}{elementLabel}color space "{space}" ({color}) at {bbox} is not supported. Rendered as black.`},COLOR_DEVICEN_INKS_NOT_PRESERVED:{severity:`warning`,template:`{prefix}the page declares DeviceN color resources. Imported DeviceN colors use their alternate color space; independent ink channels are not preserved.`},COLOR_DEVICEN_TINT_UNRESOLVED:{severity:`warning`,template:`{prefix}the PDF decoder did not resolve DeviceN tint values. The all-inks-solid alternate color was used; colors can differ from the source. Use the bundled PDF decoder.`},SPOT_COLOR_NO_ALTERNATE:{severity:`warning`,template:`Spot color "{name}" has no resolvable alternate; leaving at engine default.`},SPOT_COLOR_REGISTER_FAILED:{severity:`warning`,template:`Failed to register spot color "{name}": {error}`},SPOT_COLOR_DEFINITION_PRESERVED:{severity:`warning`,template:`Spot color "{name}" is already defined differently in the destination. Imported content uses the existing definition.`},OUTPUT_INTENT_APPLIED:{severity:`info`,template:`PDF output intent "{identifier}" was applied. Its {space} profile is the output profile of the document.`},OUTPUT_INTENT_UNREADABLE:{severity:`warning`,template:`The PDF output intents could not be read ({error}). The pages were imported without an output profile, so colors use the default profile.`},OUTPUT_INTENT_PROFILE_MISSING:{severity:`info`,template:`PDF output intent "{identifier}" embeds no usable ICC profile. Colors use the default profile.`},OUTPUT_INTENT_SPACE_UNSUPPORTED:{severity:`warning`,template:`PDF output intent "{identifier}" has a {space} profile, which a document cannot hold. Colors use the default profile.`},OUTPUT_INTENT_REJECTED:{severity:`warning`,template:`The profile of PDF output intent "{identifier}" could not be used: {error}. Colors use the default profile.`},OUTPUT_INTENT_ENGINE_UNSUPPORTED:{severity:`warning`,template:`PDF output intent "{identifier}" was not applied, because this engine version cannot store an output profile in the document. Colors use the default profile. Use engine version 1.86 or later to keep the profile.`},OUTPUT_INTENT_DROPPED_DETACHED:{severity:`warning`,template:`PDF output intent "{identifier}" was not applied, because placed pages keep the color profiles of the destination design. To keep the profile, import the PDF with parse() instead of loadAsBlocks().`},RENDERING_INTENT_PER_OBJECT:{severity:`warning`,template:`{prefix}the page sets the rendering intent {intents} on single objects. The imported objects use the rendering intent of the document instead.`},VECTOR_PATH_FILL_RULE_UNSUPPORTED:{severity:`warning`,template:"CE.SDK does not expose `{property}` on `vector_path` shapes (added in CE.SDK {sinceVersion}); the source PDF used non-zero winding fill, but imported paths render with the engine default (even-odd) winding. Self-overlapping or compound paths may render with holes inverted. Upgrade `@cesdk/engine` to {sinceVersion} or newer to preserve the source winding rule."},BLEND_MODE_UNSUPPORTED:{severity:`warning`,template:`Blend mode "{mode}" is not supported. Using "Normal" as the default.`},SHADING_COLORSPACE_CONVERTED:{severity:`warning`,template:`{prefix}gradient pattern colors were converted to sampled RGB stops by the PDF decoder. Original CMYK or spot-color definitions are not preserved.`},SHADING_PATTERN_TRANSFORM_UNSUPPORTED:{severity:`warning`,template:`{prefix}a gradient fill inside a transformed PDF form was dropped because its placement cannot be preserved.`},SHADING_UNRESOLVED:{severity:`error`,template:`{prefix}gradient shading could not be resolved by pdf.js and was removed. The painted region will be missing in the imported scene.`},SHADING_MESH_UNSUPPORTED:{severity:`warning`,template:`{prefix}gradient shading uses an unsupported mesh variant (PDF ShadingType 4–7). The region was dropped because mesh gradients can't be represented as a CE.SDK gradient fill.`},SHADING_MESH_FLATTENED:{severity:`warning`,template:`{prefix}mesh at {at} retains {triangles} triangle(s) as editable vector geometry. Its corner-color gradient was replaced by the solid average color {fill}.{background}`},SHADING_MESH_GEOMETRY_DROPPED:{severity:`warning`,template:`{prefix}mesh shading was omitted because {reason}. Its vector geometry could not be retained.`},SHADING_UNKNOWN_IR_TAG:{severity:`error`,template:`{prefix}gradient shading reported unknown IR tag "{tag}" and was dropped.`},SHADING_INSUFFICIENT_STOPS:{severity:`warning`,template:`{prefix}gradient shading produced fewer than two color stops and was dropped.`},SHADING_NO_CLIP_FALLBACK_BBOX:{severity:`info`,template:`{prefix}gradient shading was painted without an active clip path. Falling back to the shading /BBox; if this scene shows gradient bands outside the intended shape, file a bug.`},SHADING_CLIP_DEGENERATE:{severity:`warning`,template:`{prefix}gradient shading clip path was degenerate and the region was dropped.`},SHADING_RADIAL_FOCAL_DROPPED:{severity:`info`,template:`{prefix}radial gradient declared a non-zero inner radius (PDF Shading Type 3 focal point). It was approximated as a centered radial; the focal offset was dropped.`},SHADING_UNKNOWN_RADIAL_SUBTYPE:{severity:`error`,template:`{prefix}gradient shading reported unknown RadialAxial subtype "{kind}" and was dropped.`},SHADING_NO_PATTERN_REF:{severity:`error`,template:`{prefix}gradient shading was emitted without a pattern reference and was dropped.`},IMAGE_TILES_MERGED:{severity:`info`,template:`{prefix}{count} image pieces at ({bbox}) {bboxSize} pt were joined into one image. The PDF stores the picture in pieces, as the transparency flattener of a PDF/X-1a export does.`},IMAGE_TILES_MERGE_FAILED:{severity:`warning`,template:`{prefix}the image pieces on this page could not be joined ({reason}). They were imported as separate images.`},PATTERN_PAINT_UNSUPPORTED:{severity:`warning`,template:`{prefix}the {paint} of a vector path at {at} uses a {pattern} that cannot be imported. It was painted with the solid color {fallback} instead.`},TILING_PATTERN_AS_IMAGE:{severity:`info`,template:`{prefix}tiling pattern "{patternId}" was imported as an image (single-image tiling pattern, e.g. Skia/Chrome PDF export of an embedded bitmap).`},TILING_PATTERN_UNSUPPORTED:{severity:`warning`,template:`{prefix}tiling pattern "{patternId}" could not be imported as a bounded, opaque vector tile or a single-image pattern. The pattern fill was dropped.`},TILING_PATTERN_UNRESOLVED:{severity:`error`,template:`{prefix}tiling pattern "{patternId}" could not be resolved by pdf.js and was dropped.`},TILING_PATTERN_IMAGE_DECODE_FAILED:{severity:`warning`,template:`{prefix}tiling pattern "{patternId}" referenced image "{imageObjId}" but the image bytes could not be decoded. The pattern fill was dropped.`}},L=[`Perceptual`,`RelativeColorimetric`,`Saturation`,`AbsoluteColorimetric`],ie=e=>L.includes(e)?e:`RelativeColorimetric`,ae=Object.freeze({IMAGE:`image`,VECTOR_PATH:`vector-path`,TEXT_OUTLINE:`text-outline`,TEXT_RUN:`text-run`});function R(e){return e.space===`spot`}function oe(e,t){if(e==null)return e;if(t&&R(e))return e.overprint?e:{...e,overprint:!0};if(!e.overprint)return e;let n={...e};return delete n.overprint,n}function se(e,t,n=!0){if(e==null&&t==null)return!0;if(e==null||t==null||e.space!==t.space||(e.alpha??1)!==(t.alpha??1)||n&&(e.overprint??!1)!==(t.overprint??!1)||!e.values||!t.values||e.values.length!==t.values.length)return!1;for(let n=0;n<e.values.length;n++)if(Math.abs(e.values[n]-t.values[n])>1e-6)return!1;return!0}var ce=/* @__PURE__ */ c({AbortException:()=>Ia,AnnotationEditorLayer:()=>Vc,AnnotationEditorParamsType:()=>ya,AnnotationEditorType:()=>J,AnnotationEditorUIManager:()=>no,AnnotationLayer:()=>Cc,AnnotationMode:()=>_a,ColorPicker:()=>Mc,DOMSVGFactory:()=>Gs,DrawLayer:()=>Hc,FeatureTest:()=>La,GlobalWorkerOptions:()=>Qo,ImageKind:()=>Sa,InvalidPDFException:()=>Ma,MissingPDFException:()=>Na,OPS:()=>Ea,OutputScale:()=>Ja,PDFDataRangeTransport:()=>js,PDFDateString:()=>qa,PDFWorker:()=>Fs,PasswordResponses:()=>Da,PermissionFlag:()=>ba,PixelsPerInch:()=>Ua,RenderingCancelledException:()=>Ga,TextLayer:()=>xs,TouchManager:()=>io,UnexpectedResponseException:()=>Pa,Util:()=>Y,VerbosityLevel:()=>Ta,XfaLayer:()=>Ks,build:()=>Hs,createValidAbsoluteUrl:()=>fe,fetchData:()=>Ce,getDocument:()=>ct,getFilenameFromUrl:()=>G,getPdfFilenameFromUrl:()=>Ee,getXfaPageViewport:()=>Ae,isDataScheme:()=>we,isPdfFile:()=>Te,noContextMenu:()=>Oe,normalizeUnicode:()=>be,setLayerDimensions:()=>Fe,shadow:()=>W,stopEvent:()=>ke,version:()=>Vs});function z(e){let t=gt[e];if(t!==void 0)return t.exports;let n=gt[e]={exports:{}};return ht[e](n,n.exports,z),n.exports}function le(e){Number.isInteger(e)&&(Oa=e)}function B(){return Oa}function V(e){Oa>=Ta.INFOS&&console.log(`Info: ${e}`)}function H(e){Oa>=Ta.WARNINGS&&console.log(`Warning: ${e}`)}function U(e){throw Error(e)}function ue(e,t){e||U(t)}function de(e){switch(e?.protocol){case`http:`:case`https:`:case`ftp:`:case`mailto:`:case`tel:`:return!0;default:return!1}}function fe(e,t=null,n=null){if(!e)return null;try{if(n&&typeof e==`string`&&(n.addDefaultProtocol&&e.startsWith(`www.`)&&e.match(/\./g)?.length>=2&&(e=`http://${e}`),n.tryConvertEncoding))try{e=ye(e)}catch{}let r=t?new URL(e,t):new URL(e);if(de(r))return r}catch{}return null}function W(e,t,n,r=!1){return Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}function pe(e){(typeof e!=`object`||e?.length===void 0)&&U(`Invalid argument for bytesToString`);let t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);let r=[];for(let i=0;i<t;i+=n){let a=Math.min(i+n,t),o=e.subarray(i,a);r.push(String.fromCharCode.apply(null,o))}return r.join(``)}function me(e){typeof e!=`string`&&U(`Invalid argument for stringToBytes`);let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r)&255;return n}function he(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255)}function ge(e){let t=Object.create(null);for(let[n,r]of e)t[n]=r;return t}function _e(){let e=/* @__PURE__ */ new Uint8Array(4);return e[0]=1,new Uint32Array(e.buffer,0,1)[0]===1}function ve(){try{return Function(``),!0}catch{return!1}}function ye(e){return decodeURIComponent(escape(e))}function be(e){return za||(za=/([\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,Ba=/* @__PURE__ */ new Map([[`ſt`,`ſt`]])),e.replaceAll(za,(e,t,n)=>t?t.normalize(`NFKC`):Ba.get(n))}function xe(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=/* @__PURE__ */ new Uint8Array(32);return crypto.getRandomValues(e),pe(e)}function Se(e){return Uint8Array.prototype.toBase64?e.toBase64():btoa(pe(e))}async function Ce(e,t=`text`){if(De(e,document.baseURI)){let n=await fetch(e);if(!n.ok)throw Error(n.statusText);switch(t){case`arraybuffer`:return n.arrayBuffer();case`blob`:return n.blob();case`json`:return n.json()}return n.text()}return new Promise((n,r)=>{let i=new XMLHttpRequest;i.open(`GET`,e,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case`arraybuffer`:case`blob`:case`json`:n(i.response);return}n(i.responseText)}else r(Error(i.statusText))}},i.send(null)})}function we(e){let t=e.length,n=0;for(;n<t&&e[n].trim()===``;)n++;return e.substring(n,n+5).toLowerCase()===`data:`}function Te(e){return typeof e==`string`&&/\.pdf$/i.test(e)}function G(e){return[e]=e.split(/[#?]/,1),e.substring(e.lastIndexOf(`/`)+1)}function Ee(e,t=`document.pdf`){if(typeof e!=`string`)return t;if(we(e))return H(`getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.`),t;let n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,r=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=n.exec(e),a=r.exec(i[1])||r.exec(i[2])||r.exec(i[3]);if(a&&(a=a[0],a.includes(`%`)))try{a=r.exec(decodeURIComponent(a))[0]}catch{}return a||t}function De(e,t){try{let{protocol:n}=t?new URL(e,t):new URL(e);return n===`http:`||n===`https:`}catch{return!1}}function Oe(e){e.preventDefault()}function ke(e){e.preventDefault(),e.stopPropagation()}function Ae(e,{scale:t=1,rotation:n=0}){let{width:r,height:i}=e.attributes.style;return new Wa({viewBox:[0,0,parseInt(r),parseInt(i)],userUnit:1,scale:t,rotation:n})}function je(e){if(e.startsWith(`#`)){let t=parseInt(e.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return e.startsWith(`rgb(`)?e.slice(4,-1).split(`,`).map(e=>parseInt(e)):e.startsWith(`rgba(`)?e.slice(5,-1).split(`,`).map(e=>parseInt(e)).slice(0,3):(H(`Not a valid color format: "${e}"`),[0,0,0])}function Me(e){let t=document.createElement(`span`);t.style.visibility=`hidden`,document.body.append(t);for(let n of e.keys()){t.style.color=n;let r=window.getComputedStyle(t).color;e.set(n,je(r))}t.remove()}function Ne(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform();return[t,n,r,i,a,o]}function Pe(e){let{a:t,b:n,c:r,d:i,e:a,f:o}=e.getTransform().invertSelf();return[t,n,r,i,a,o]}function Fe(e,t,n=!1,r=!0){if(t instanceof Wa){let{pageWidth:r,pageHeight:i}=t.rawDims,{style:a}=e,o=La.isCSSRoundSupported,s=`var(--scale-factor) * ${r}px`,c=`var(--scale-factor) * ${i}px`,l=o?`round(down, ${s}, var(--scale-round-x, 1px))`:`calc(${s})`,u=o?`round(down, ${c}, var(--scale-round-y, 1px))`:`calc(${c})`;!n||t.rotation%180==0?(a.width=l,a.height=u):(a.width=u,a.height=l)}r&&e.setAttribute(`data-main-rotation`,t.rotation)}function Ie(e,t,n){for(let r of n)t.addEventListener(r,e[r].bind(e))}function Le(){}function Re(e){if(e instanceof Ia||e instanceof Ma||e instanceof Na||e instanceof Aa||e instanceof Pa||e instanceof ja)return e;switch(e instanceof Error||typeof e==`object`&&e||U(`wrapReason: Expected "reason" to be a (possibly cloned) Error.`),e.name){case`AbortException`:return new Ia(e.message);case`InvalidPDFException`:return new Ma(e.message);case`MissingPDFException`:return new Na(e.message);case`PasswordException`:return new Aa(e.message,e.code);case`UnexpectedResponseException`:return new Pa(e.message,e.status);case`UnknownErrorException`:return new ja(e.message,e.details)}return new ja(e.message,e.toString())}async function K(e){let t=await process.getBuiltinModule(`fs`).promises.readFile(e);return new Uint8Array(t)}function ze(e,t){if(!t)return;let n=t[2]-t[0],r=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],n,r),e.clip(i)}function q(e,t,n,r,i,a,o,s){let c=t.coords,l=t.colors,u=e.data,d=e.width*4,f;c[n+1]>c[r+1]&&(f=n,n=r,r=f,f=a,a=o,o=f),c[r+1]>c[i+1]&&(f=r,r=i,i=f,f=o,o=s,s=f),c[n+1]>c[r+1]&&(f=n,n=r,r=f,f=a,a=o,o=f);let p=(c[n]+t.offsetX)*t.scaleX,m=(c[n+1]+t.offsetY)*t.scaleY,h=(c[r]+t.offsetX)*t.scaleX,g=(c[r+1]+t.offsetY)*t.scaleY,_=(c[i]+t.offsetX)*t.scaleX,v=(c[i+1]+t.offsetY)*t.scaleY;if(m>=v)return;let y=l[a],b=l[a+1],x=l[a+2],S=l[o],C=l[o+1],w=l[o+2],T=l[s],E=l[s+1],D=l[s+2],O=Math.round(m),k=Math.round(v),A,j,M,ee,N,P,F,I;for(let e=O;e<=k;e++){if(e<g){let t=e<m?0:(m-e)/(m-g);A=p-(p-h)*t,j=y-(y-S)*t,M=b-(b-C)*t,ee=x-(x-w)*t}else{let t;t=e>v?1:g===v?0:(g-e)/(g-v),A=h-(h-_)*t,j=S-(S-T)*t,M=C-(C-E)*t,ee=w-(w-D)*t}let t;t=e<m?0:e>v?1:(m-e)/(m-v),N=p-(p-_)*t,P=y-(y-T)*t,F=b-(b-E)*t,I=x-(x-D)*t;let n=Math.round(Math.min(A,N)),r=Math.round(Math.max(A,N)),i=d*e+n*4;for(let e=n;e<=r;e++)t=(A-e)/(A-N),t<0?t=0:t>1&&(t=1),u[i++]=j-(j-P)*t|0,u[i++]=M-(M-F)*t|0,u[i++]=ee-(ee-I)*t|0,u[i++]=255}}function Be(e,t,n){let r=t.coords,i=t.colors,a,o;switch(t.type){case`lattice`:let s=t.verticesPerRow,c=Math.floor(r.length/s)-1,l=s-1;for(a=0;a<c;a++){let t=a*s;for(let a=0;a<l;a++,t++)q(e,n,r[t],r[t+1],r[t+s],i[t],i[t+1],i[t+s]),q(e,n,r[t+s+1],r[t+1],r[t+s],i[t+s+1],i[t+1],i[t+s])}break;case`triangles`:for(a=0,o=r.length;a<o;a+=3)q(e,n,r[a],r[a+1],r[a+2],i[a],i[a+1],i[a+2]);break;default:throw Error(`illegal figure`)}}function Ve(e){switch(e[0]){case`RadialAxial`:return new Po(e);case`Mesh`:return new Fo(e);case`Dummy`:return new Io}throw Error(`Unknown IR type: ${e[0]}`)}function He({src:e,srcPos:t=0,dest:n,width:r,height:i,nonBlackColor:a=4294967295,inverseDecode:o=!1}){let s=La.isLittleEndian?4278190080:255,[c,l]=o?[a,s]:[s,a],u=r>>3,d=r&7,f=e.length;n=new Uint32Array(n.buffer);let p=0;for(let r=0;r<i;r++){for(let r=t+u;t<r;t++){let r=t<f?e[t]:255;n[p++]=r&128?l:c,n[p++]=r&64?l:c,n[p++]=r&32?l:c,n[p++]=r&16?l:c,n[p++]=r&8?l:c,n[p++]=r&4?l:c,n[p++]=r&2?l:c,n[p++]=r&1?l:c}if(d===0)continue;let r=t<f?e[t++]:255;for(let e=0;e<d;e++)n[p++]=r&1<<7-e?l:c}return{srcPos:t,destPos:p}}function Ue(e,t){if(e._removeMirroring)throw Error(`Context is already forwarding operations.`);e.__originalSave=e.save,e.__originalRestore=e.restore,e.__originalRotate=e.rotate,e.__originalScale=e.scale,e.__originalTranslate=e.translate,e.__originalTransform=e.transform,e.__originalSetTransform=e.setTransform,e.__originalResetTransform=e.resetTransform,e.__originalClip=e.clip,e.__originalMoveTo=e.moveTo,e.__originalLineTo=e.lineTo,e.__originalBezierCurveTo=e.bezierCurveTo,e.__originalRect=e.rect,e.__originalClosePath=e.closePath,e.__originalBeginPath=e.beginPath,e._removeMirroring=()=>{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(e,n){t.translate(e,n),this.__originalTranslate(e,n)},e.scale=function(e,n){t.scale(e,n),this.__originalScale(e,n)},e.transform=function(e,n,r,i,a,o){t.transform(e,n,r,i,a,o),this.__originalTransform(e,n,r,i,a,o)},e.setTransform=function(e,n,r,i,a,o){t.setTransform(e,n,r,i,a,o),this.__originalSetTransform(e,n,r,i,a,o)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(e){t.rotate(e),this.__originalRotate(e)},e.clip=function(e){t.clip(e),this.__originalClip(e)},e.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},e.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},e.bezierCurveTo=function(e,n,r,i,a,o){t.bezierCurveTo(e,n,r,i,a,o),this.__originalBezierCurveTo(e,n,r,i,a,o)},e.rect=function(e,n,r,i){t.rect(e,n,r,i),this.__originalRect(e,n,r,i)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}function We(e,t,n,r,i,a,o,s,c,l){let[u,d,f,p,m,h]=Ne(e);if(d===0&&f===0){let g=o*u+m,_=Math.round(g),v=s*p+h,y=Math.round(v),b=(o+c)*u+m,x=Math.abs(Math.round(b)-_)||1,S=(s+l)*p+h,C=Math.abs(Math.round(S)-y)||1;return e.setTransform(Math.sign(u),0,0,Math.sign(p),_,y),e.drawImage(t,n,r,i,a,0,0,x,C),e.setTransform(u,d,f,p,m,h),[x,C]}if(u===0&&p===0){let g=s*f+m,_=Math.round(g),v=o*d+h,y=Math.round(v),b=(s+l)*f+m,x=Math.abs(Math.round(b)-_)||1,S=(o+c)*d+h,C=Math.abs(Math.round(S)-y)||1;return e.setTransform(0,Math.sign(d),Math.sign(f),0,_,y),e.drawImage(t,n,r,i,a,0,0,C,x),e.setTransform(u,d,f,p,m,h),[C,x]}e.drawImage(t,n,r,i,a,o,s,c,l);let g=Math.hypot(u,d),_=Math.hypot(f,p);return[g*c,_*l]}function Ge(e){let{width:t,height:n}=e;if(t>Uo||n>Uo)return null;let r=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),a=t+1,o=new Uint8Array(a*(n+1)),s,c,l,u=t+7&-8,d=new Uint8Array(u*n),f=0;for(let t of e.data){let e=128;for(;e>0;)d[f++]=t&e?0:255,e>>=1}let p=0;for(f=0,d[f]!==0&&(o[0]=1,++p),c=1;c<t;c++)d[f]!==d[f+1]&&(o[c]=d[f]?2:1,++p),f++;for(d[f]!==0&&(o[c]=2,++p),s=1;s<n;s++){f=s*u,l=s*a,d[f-u]!==d[f]&&(o[l]=d[f]?1:8,++p);let e=(d[f]?4:0)+(d[f-u]?8:0);for(c=1;c<t;c++)e=(e>>2)+(d[f+1]?4:0)+(d[f-u+1]?8:0),i[e]&&(o[l+c]=i[e],++p),f++;if(d[f-u]!==d[f]&&(o[l+c]=d[f]?2:4,++p),p>r)return null}for(f=u*(n-1),l=s*a,d[f]!==0&&(o[l]=8,++p),c=1;c<t;c++)d[f]!==d[f+1]&&(o[l+c]=d[f]?4:8,++p),f++;if(d[f]!==0&&(o[l+c]=4,++p),p>r)return null;let m=new Int32Array([0,a,-1,0,-a,0,0,0,1]),h=new Path2D;for(s=0;p&&s<=n;s++){let e=s*a,n=e+t;for(;e<n&&!o[e];)e++;if(e===n)continue;h.moveTo(e%a,s);let r=e,i=o[e];do{let t=m[i];do e+=t;while(!o[e]);let n=o[e];n!==5&&n!==10?(i=n,o[e]=0):(i=n&51*i>>4,o[e]&=i>>2|i<<2),h.lineTo(e%a,e/a|0),o[e]||--p}while(r!==e);--s}return d=null,o=null,function(e){e.save(),e.scale(1/t,-1/n),e.translate(0,-n),e.fill(h),e.beginPath(),e.restore()}}function Ke(e,t){if(t instanceof ImageData){e.putImageData(t,0,0);return}let n=t.height,r=t.width,i=n%Wo,a=(n-i)/Wo,o=i===0?a:a+1,s=e.createImageData(r,Wo),c=0,l,u=t.data,d=s.data,f,p,m,h;if(t.kind===Sa.GRAYSCALE_1BPP){let t=u.byteLength,n=new Uint32Array(d.buffer,0,d.byteLength>>2),h=n.length,g=r+7>>3,_=4294967295,v=La.isLittleEndian?4278190080:255;for(f=0;f<o;f++){for(m=f<a?Wo:i,l=0,p=0;p<m;p++){let e=t-c,i=0,a=e>g?r:e*8-7,o=a&-8,s=0,d=0;for(;i<o;i+=8)d=u[c++],n[l++]=d&128?_:v,n[l++]=d&64?_:v,n[l++]=d&32?_:v,n[l++]=d&16?_:v,n[l++]=d&8?_:v,n[l++]=d&4?_:v,n[l++]=d&2?_:v,n[l++]=d&1?_:v;for(;i<a;i++)s===0&&(d=u[c++],s=128),n[l++]=d&s?_:v,s>>=1}for(;l<h;)n[l++]=0;e.putImageData(s,0,f*Wo)}}else if(t.kind===Sa.RGBA_32BPP){for(p=0,h=r*Wo*4,f=0;f<a;f++)d.set(u.subarray(c,c+h)),c+=h,e.putImageData(s,0,p),p+=Wo;f<o&&(h=r*i*4,d.set(u.subarray(c,c+h)),e.putImageData(s,0,p))}else if(t.kind===Sa.RGB_24BPP)for(m=Wo,h=r*m,f=0;f<o;f++){for(f>=a&&(m=i,h=r*m),l=0,p=h;p--;)d[l++]=u[c++],d[l++]=u[c++],d[l++]=u[c++],d[l++]=255;e.putImageData(s,0,f*Wo)}else throw Error(`bad image kind: ${t.kind}`)}function qe(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}let n=t.height,r=t.width,i=n%Wo,a=(n-i)/Wo,o=i===0?a:a+1,s=e.createImageData(r,Wo),c=0,l=t.data,u=s.data;for(let t=0;t<o;t++){let n=t<a?Wo:i;({srcPos:c}=He({src:l,srcPos:c,dest:u,width:r,height:n,nonBlackColor:0})),e.putImageData(s,0,t*Wo)}}function Je(e,t){for(let n of[`strokeStyle`,`fillStyle`,`fillRule`,`globalAlpha`,`lineWidth`,`lineCap`,`lineJoin`,`miterLimit`,`globalCompositeOperation`,`font`,`filter`])e[n]!==void 0&&(t[n]=e[n]);e.setLineDash!==void 0&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function Ye(e){if(e.strokeStyle=e.fillStyle=`#000000`,e.fillRule=`nonzero`,e.globalAlpha=1,e.lineWidth=1,e.lineCap=`butt`,e.lineJoin=`miter`,e.miterLimit=10,e.globalCompositeOperation=`source-over`,e.font=`10px sans-serif`,e.setLineDash!==void 0&&(e.setLineDash([]),e.lineDashOffset=0),!fa){let{filter:t}=e;t!==`none`&&t!==``&&(e.filter=`none`)}}function Xe(e,t){if(t)return!0;let n=Y.singularValueDecompose2dScale(e);n[0]=Math.fround(n[0]),n[1]=Math.fround(n[1]);let r=Math.fround((globalThis.devicePixelRatio||1)*Ua.PDF_TO_CSS_UNITS);return n[0]<=r&&n[1]<=r}function Ze(e){let t=!0,n=r(`filename\\*`,`i`).exec(e);if(n){n=n[1];let e=s(n);return e=unescape(e),e=c(e),e=l(e),a(e)}if(n=o(e),n)return a(l(n));if(n=r(`filename`,`i`).exec(e),n){n=n[1];let e=s(n);return e=l(e),a(e)}function r(e,t){return RegExp(`(?:^|;)\\s*`+e+`\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)`,t)}function i(e,n){if(e){if(!/^[\x00-\xFF]+$/.test(n))return n;try{let r=new TextDecoder(e,{fatal:!0}),i=me(n);n=r.decode(i),t=!1}catch{}}return n}function a(e){return t&&/[\x80-\xff]/.test(e)&&(e=i(`utf-8`,e),t&&(e=i(`iso-8859-1`,e))),e}function o(e){let t=[],n,i=r(`filename\\*((?!0\\d)\\d+)(\\*?)`,`ig`);for(;(n=i.exec(e))!==null;){let[,e,r,i]=n;if(e=parseInt(e,10),e in t){if(e===0)break}else t[e]=[r,i]}let a=[];for(let e=0;e<t.length&&e in t;++e){let[n,r]=t[e];r=s(r),n&&(r=unescape(r),e===0&&(r=c(r))),a.push(r)}return a.join(``)}function s(e){if(e.startsWith(`"`)){let t=e.slice(1).split(`\\"`);for(let e=0;e<t.length;++e){let n=t[e].indexOf(`"`);n!==-1&&(t[e]=t[e].slice(0,n),t.length=e+1),t[e]=t[e].replaceAll(/\\(.)/g,`$1`)}e=t.join(`"`)}return e}function c(e){let t=e.indexOf(`'`);return t===-1?e:i(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,``))}function l(e){return!e.startsWith(`=?`)||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(e,t,n,r){if(n===`q`||n===`Q`)return r=r.replaceAll(`_`,` `),r=r.replaceAll(/=([0-9a-fA-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}),i(t,r);try{r=atob(r)}catch{}return i(t,r)})}return``}function Qe(e,t){let n=new Headers;if(!e||!t||typeof t!=`object`)return n;for(let e in t){let r=t[e];r!==void 0&&n.append(e,r)}return n}function $e(e){try{return new URL(e).origin}catch{}return null}function et({responseHeaders:e,isHttp:t,rangeChunkSize:n,disableRange:r}){let i={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(e.get(`Content-Length`),10);return!Number.isInteger(a)||(i.suggestedLength=a,a<=2*n)||r||!t||e.get(`Accept-Ranges`)!==`bytes`||(e.get(`Content-Encoding`)||`identity`)!==`identity`||(i.allowRangeRequests=!0),i}function tt(e){let t=e.get(`Content-Disposition`);if(t){let e=Ze(t);if(e.includes(`%`))try{e=decodeURIComponent(e)}catch{}if(Te(e))return e}return null}function nt(e,t){return e===404||e===0&&t.startsWith(`file:`)?new Na(`Missing PDF "`+t+`".`):new Pa(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)}function rt(e){return e===200||e===206}function it(e,t,n){return{method:`GET`,headers:e,signal:n.signal,mode:`cors`,credentials:t?`include`:`same-origin`,redirect:`follow`}}function at(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:(H(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}function ot(e){let t=e.response;return typeof t==`string`?me(t).buffer:t}function st(e){if(ms.test(e))return new URL(e);let t=process.getBuiltinModule(`url`);return new URL(t.pathToFileURL(e))}function ct(e={}){typeof e==`string`||e instanceof URL?e={url:e}:(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t=new As,{docId:n}=t,r=e.url?lt(e.url):null,i=e.data?ut(e.data):null,a=e.httpHeaders||null,o=e.withCredentials===!0,s=e.password??null,c=e.range instanceof js?e.range:null,l=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:Cs,u=e.worker instanceof Fs?e.worker:null,d=e.verbosity,f=typeof e.docBaseUrl==`string`&&!we(e.docBaseUrl)?e.docBaseUrl:null,p=typeof e.cMapUrl==`string`?e.cMapUrl:null,m=e.cMapPacked!==!1,h=e.CMapReaderFactory||Ds,g=typeof e.standardFontDataUrl==`string`?e.standardFontDataUrl:null,_=e.StandardFontDataFactory||ks,v=e.stopAtErrors!==!0,y=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,b=e.isEvalSupported!==!1,x=typeof e.isOffscreenCanvasSupported==`boolean`?e.isOffscreenCanvasSupported:!fa,S=typeof e.isImageDecoderSupported==`boolean`?e.isImageDecoderSupported:!fa&&(La.platform.isFirefox||!globalThis.chrome),C=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,w=typeof e.disableFontFace==`boolean`?e.disableFontFace:fa,T=e.fontExtraProperties===!0,E=e.exposeRawImageData===!0,D=e.enableXfa===!0,O=e.ownerDocument||globalThis.document,k=e.disableRange===!0,A=e.disableStream===!0,j=e.disableAutoFetch===!0,M=e.pdfBug===!0,ee=e.CanvasFactory||Es,N=e.FilterFactory||Os,P=e.enableHWA===!0,F=c?c.length:e.length??NaN,I=typeof e.useSystemFonts==`boolean`?e.useSystemFonts:!fa&&!w,te=typeof e.useWorkerFetch==`boolean`?e.useWorkerFetch:h===Co&&_===Do&&p&&g&&De(p,document.baseURI)&&De(g,document.baseURI);le(d);let ne={canvasFactory:new ee({ownerDocument:O,enableHWA:P}),filterFactory:new N({docId:n,ownerDocument:O}),cMapReaderFactory:te?null:new h({baseUrl:p,isCompressed:m}),standardFontDataFactory:te?null:new _({baseUrl:g})};if(!u){let e={verbosity:d,port:Qo.workerPort};u=e.port?Fs.fromPort(e):new Fs(e),t._worker=u}let re={docId:n,apiVersion:`4.10.47`,data:i,password:s,disableAutoFetch:j,rangeChunkSize:l,length:F,docBaseUrl:f,enableXfa:D,evaluatorOptions:{maxImageSize:y,disableFontFace:w,ignoreErrors:v,isEvalSupported:b,isOffscreenCanvasSupported:x,isImageDecoderSupported:S,canvasMaxAreaInBytes:C,fontExtraProperties:T,exposeRawImageData:E,useSystemFonts:I,cMapUrl:te?p:null,standardFontDataUrl:te?g:null}},L={disableFontFace:w,fontExtraProperties:T,ownerDocument:O,pdfBug:M,styleElement:null,loadingParams:{disableAutoFetch:j,enableXfa:D}};return u.promise.then(function(){if(t.destroyed)throw Error(`Loading aborted`);if(u.destroyed)throw Error(`Worker was destroyed`);let e=u.messageHandler.sendWithPromise(`GetDocRequest`,re,i?[i.buffer]:null),s;if(c)s=new rs(c,{disableRange:k,disableStream:A});else if(!i){if(!r)throw Error("getDocument - no `url` parameter provided.");let e;if(fa){if(De(r)){if(typeof fetch>`u`||typeof Response>`u`||!(`body`in Response.prototype))throw Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");e=os}else e=hs}else e=De(r)?os:fs;s=new e({url:r,length:F,httpHeaders:a,withCredentials:o,rangeChunkSize:l,disableRange:k,disableStream:A})}return e.then(e=>{if(t.destroyed)throw Error(`Loading aborted`);if(u.destroyed)throw Error(`Worker was destroyed`);let r=new yo(n,e,u.port),i=new Is(r,t,s,L,ne);t._transport=i,r.send(`Ready`,null)})}).catch(t._capability.reject),t}function lt(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch{if(fa&&typeof e==`string`)return e}throw Error(`Invalid PDF url data: either string or URL-object is expected in the url property.`)}function ut(e){if(fa&&typeof Buffer<`u`&&e instanceof Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if(typeof e==`string`)return me(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof e==`object`&&!isNaN(e?.length))return new Uint8Array(e);throw Error(`Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.`)}function dt(e){return typeof e==`object`&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0}function ft(e){return Math.floor(Math.max(0,Math.min(1,e))*255).toString(16).padStart(2,`0`)}function pt(e){return Math.max(0,Math.min(255,255*e))}function mt(e){return{width:e[2]-e[0],height:e[3]-e[1]}}var ht,gt,_t,vt,yt,bt,xt,St,Ct,wt,Tt,Et,Dt,Ot,kt,At,jt,Mt,Nt,Pt,Ft,It,Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt,Zt,Qt,$t,en,tn,nn,rn,an,on,sn,cn,ln,un,dn,fn,pn,mn,hn,gn,_n,vn,yn,bn,xn,Sn,Cn,wn,Tn,En,Dn,On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr,rr,ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni,ri,ii,ai,oi,si,ci,li,ui,di,fi,pi,mi,hi,gi,_i,vi,yi,bi,xi,Si,Ci,wi,Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta,na,ra,ia,aa,oa,sa,ca,la,ua,da,fa,pa,ma,ha,ga,_a,va,J,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La,Ra,Y,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,eo,to,no,ro,io,ao,oo,so,co,lo,uo,fo,po,mo,ho,go,_o,vo,yo,bo,xo,So,Co,wo,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io,Lo,Ro,zo,Bo,Vo,Ho,Uo,Wo,Go,Ko,qo,Jo,Yo,Xo,Zo,Qo,$o,es,ts,ns,rs,is,as,os,ss,cs,ls,us,ds,fs,X,ps,ms,hs,gs,_s,vs,ys,bs,xs,Ss,Cs,ws,Ts,Es,Ds,Os,ks,As,js,Ms,Ns,Ps,Fs,Is,Ls,Rs,zs,Bs,Vs,Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs,Qs,$s,ec,tc,nc,rc,ic,ac,oc,sc,cc,lc,uc,dc,fc,pc,mc,hc,gc,_c,vc,yc,bc,xc,Sc,Cc,wc,Tc,Z,Ec,Dc,Oc,kc,Ac,jc,Mc,Nc,Pc,Fc,Ic,Lc,Rc,zc,Bc,Vc,Hc,Uc=o((()=>{if(ht={498(e){var t=TypeError;e.exports=function(e){if(typeof e==`string`)return e;throw new t(`Argument is not a string`)}},469(e){var t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`,n=t+`+/`,r=t+`-_`,i=function(e){for(var t={},n=0;n<64;n++)t[e.charAt(n)]=n;return t};e.exports={i2c:n,c2i:i(n),i2cUrl:r,c2iUrl:i(r)}},566(e){e.exports=function(e,t){return{value:e,done:t}}},504(e){var t=TypeError,n=9007199254740991;e.exports=function(e){if(e>n)throw new t(`Maximum allowed index exceeded`);return e}},849(e){e.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}}},35(e){var t=TypeError;e.exports=function(e){var n=e&&e.alphabet;if(n===void 0||n===`base64`||n===`base64url`)return n||`base64`;throw new t("Incorrect `alphabet` option")}},60(e){e.exports=function(e){return{iterator:e,next:e.next,done:!1}}},600(e){e.exports=function(e){return e==null}},430(e){e.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}},909(e){e.exports=function(e,t){var n=typeof Iterator==`function`&&Iterator.prototype[e];if(n)try{n.call({next:null},t).next()}catch{return!0}}},510(e){e.exports=Object.create?Object.create(null):{}},352(e){var t=Math.ceil,n=Math.floor;e.exports=Math.trunc||function(e){var r=+e;return(r>0?n:t)(r)}},18(e){var t=RangeError;e.exports=function(e){if(e===e)return e;throw new t(`NaN is not allowed`)}},706(e,t){t.f=Object.getOwnPropertySymbols},636(e){e.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}},263(e,t,n){var r=n(600),i=TypeError;e.exports=function(e){if(r(e))throw new i(`Can't call method on `+e);return e}},758(e){e.exports=function(e){try{var t=/* @__PURE__ */ new Set,n=t[e]({size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){return t.clear(),t.add(4),function(){return{done:!0}}}})}});return n.size===1&&n.values().next().value===4}catch{return!1}}},473(e,t,n){var r=n(402),i=n(737),a=RangeError;e.exports=function(e){if(e===void 0)return 0;var t=r(e),n=i(t);if(t!==n)throw new a(`Wrong length or index`);return n}},402(e,t,n){var r=n(352);e.exports=function(e){var t=+e;return t!==t||t===0?0:r(t)}},737(e,t,n){var r=n(402),i=Math.min;e.exports=function(e){var t=r(e);return t>0?i(t,9007199254740991):0}},674(e,t,n){var r=n(263),i=Object;e.exports=function(e){return i(r(e))}},137(e,t,n){var r=n(402),i=RangeError;e.exports=function(e){var t=r(e);if(t<0)throw new i(`The argument can't be less than 0`);return t}},395(e){var t=TypeError;e.exports=function(e,n){if(e<n)throw new t(`Not enough arguments`);return e}}},gt={},z.cw=e=>{var t;return()=>{if(e){var n=e;e=0,t={exports:{}},n.call(t.exports,t,t.exports)}return t.exports}},z.d=(e,t)=>{for(var n in t)z.o(t,n)&&!z.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},z.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),_t=/*#__PURE__*/ z.cw(function(e,t){var n=Vn(),r=si(),i=TypeError;e.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not a function`)}}),vt=/*#__PURE__*/ z.cw(function(e,t){var n=Gn(),r=String,i=TypeError;e.exports=function(e){if(n(e))return e;throw new i(`Can't set `+r(e)+` as a prototype`)}}),yt=/*#__PURE__*/ z.cw(function(e,t){var n=Mr().has;e.exports=function(e){return n(e),e}}),bt=()=>z(498),xt=/*#__PURE__*/ z.cw(function(e,t){var n=hi(),r=new n.WeakMap,i=n.set,a=n.remove;e.exports=function(e){return i(r,e,1),a(r,e),e}}),St=/*#__PURE__*/ z.cw(function(e,t){var n=hi().has;e.exports=function(e){return n(e),e}}),Ct=/*#__PURE__*/ z.cw(function(e,t){var n=gi(),r=fr(),i=mr().f,a=n(`unscopables`),o=Array.prototype;o[a]===void 0&&i(o,a,{configurable:!0,value:r(null)}),e.exports=function(e){o[a][e]=!0}}),wt=/*#__PURE__*/ z.cw(function(e,t){var n=yr(),r=TypeError;e.exports=function(e,t){if(n(t,e))return e;throw new r(`Incorrect invocation`)}}),Tt=/*#__PURE__*/ z.cw(function(e,t){var n=Wn(),r=String,i=TypeError;e.exports=function(e){if(e===void 0||n(e))return e;throw new i(r(e)+` is not an object or undefined`)}}),Et=/*#__PURE__*/ z.cw(function(e,t){var n=Wn(),r=String,i=TypeError;e.exports=function(e){if(n(e))return e;throw new i(r(e)+` is not an object`)}}),Dt=/*#__PURE__*/ z.cw(function(e,t){var n=Vt(),r=TypeError;e.exports=function(e){if(n(e)===`Uint8Array`)return e;throw new r(`Argument is not an Uint8Array`)}}),Ot=/*#__PURE__*/ z.cw(function(e,t){e.exports=typeof ArrayBuffer<`u`&&typeof DataView<`u`}),kt=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=_n(),i=Bt(),a=n.ArrayBuffer,o=n.TypeError;e.exports=a&&r(a.prototype,`byteLength`,`get`)||function(e){if(i(e)!==`ArrayBuffer`)throw new o(`ArrayBuffer expected`);return e.byteLength}}),At=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=Ot(),i=kt(),a=n.DataView;e.exports=function(e){if(!r||i(e)!==0)return!1;try{return new a(e),!1}catch{return!0}}}),jt=/*#__PURE__*/ z.cw(function(e,t){var n=At(),r=TypeError;e.exports=function(e){if(n(e))throw new r(`ArrayBuffer is detached`);return e}}),Mt=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=yn(),i=_n(),a=Zr(),o=jt(),s=kt(),c=$t(),l=Kr(),u=n.structuredClone,d=n.ArrayBuffer,f=n.DataView,p=Math.max,m=Math.min,h=d.prototype,g=f.prototype,_=r(h.slice),v=i(h,`resizable`,`get`),y=i(h,`maxByteLength`,`get`),b=r(g.getInt8),x=r(g.setInt8);e.exports=(l||c)&&function(e,t,n){var r=s(e),i=t===void 0?r:a(t),h=!v||!v(e),g;if(o(e),l&&(e=u(e,{transfer:[e]}),r===i&&(n||h)))return e;if(r>=i&&(!n||h))g=_(e,0,i);else{g=new d(i,n&&!h&&y?{maxByteLength:p(i,y(e))}:void 0);for(var S=new f(e),C=new f(g),w=m(i,r),T=0;T<w;T++)x(C,T,b(S,T))}return l||c(e),g}}),Nt=/*#__PURE__*/ z.cw(function(e,t){var n=Ot(),r=Qt(),i=kn(),a=Vn(),o=Wn(),s=An(),c=Vt(),l=si(),u=Gt(),d=Yt(),f=Jt(),p=yr(),m=vr(),h=Cr(),g=gi(),_=ci(),v=Ln(),y=v.enforce,b=v.get,x=i.Int8Array,S=x&&x.prototype,C=i.Uint8ClampedArray,w=C&&C.prototype,T=x&&m(x),E=S&&m(S),D=Object.prototype,O=i.TypeError,k=g(`toStringTag`),A=_(`TYPED_ARRAY_TAG`),j=`TypedArrayConstructor`,M=n&&!!h&&c(i.opera)!==`Opera`,ee=!1,N,P,F,I={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},te={BigInt64Array:8,BigUint64Array:8},ne=function(e){if(!o(e))return!1;var t=c(e);return t===`DataView`||s(I,t)||s(te,t)},re=function(e){var t=m(e);if(o(t)){var n=b(t);return n&&s(n,j)?n[j]:re(t)}},L=function(e){if(!o(e))return!1;var t=c(e);return s(I,t)||s(te,t)},ie=function(e){if(L(e))return e;throw new O(`Target is not a typed array`)},ae=function(e){if(a(e)&&(!h||p(T,e)))return e;throw new O(l(e)+` is not a typed array constructor`)},R=function(e,t,n,a){if(r){if(n)for(var o in I){var c=i[o];if(c&&s(c.prototype,e))try{delete c.prototype[e]}catch{try{c.prototype[e]=t}catch{}}}(!E[e]||n)&&d(E,e,n?t:M&&S[e]||t,a)}},oe=function(e,t,n){var a,o;if(r){if(h){if(n){for(a in I)if(o=i[a],o&&s(o,e))try{delete o[e]}catch{}}if(!T[e]||n)try{return d(T,e,n?t:M&&T[e]||t)}catch{}else return}for(a in I)o=i[a],o&&(!o[e]||n)&&d(o,e,t)}};for(N in I)P=i[N],F=P&&P.prototype,F?y(F)[j]=P:M=!1;for(N in te)P=i[N],F=P&&P.prototype,F&&(y(F)[j]=P);if((!M||!a(T)||T===Function.prototype)&&(T=function(){throw new O(`Incorrect invocation`)},M))for(N in I)i[N]&&h(i[N],T);if((!M||!E||E===D)&&(E=T.prototype,M))for(N in I)i[N]&&h(i[N].prototype,E);if(M&&m(w)!==E&&h(w,E),r&&!s(E,k))for(N in ee=!0,f(E,k,{configurable:!0,get:function(){return o(this)?this[A]:void 0}}),I)i[N]&&u(i[N].prototype,A,N);e.exports={NATIVE_ARRAY_BUFFER_VIEWS:M,TYPED_ARRAY_TAG:ee&&A,aTypedArray:ie,aTypedArrayConstructor:ae,exportTypedArrayMethod:R,exportTypedArrayStaticMethod:oe,getTypedArrayConstructor:re,isView:ne,isTypedArray:L,TypedArray:T,TypedArrayPrototype:E}}),Pt=/*#__PURE__*/ z.cw(function(e,t){var n=ar();e.exports=function(e,t,r){for(var i=0,a=arguments.length>2?r:n(t),o=new e(a);a>i;)o[i]=t[i++];return o}}),Ft=/*#__PURE__*/ z.cw(function(e,t){var n=Qr(),r=Yr(),i=ar(),a=function(e){return function(t,a,o){var s=n(t),c=i(s);if(c===0)return!e&&-1;var l=r(o,c),u;if(e&&a!==a){for(;c>l;)if(u=s[l++],u!==u)return!0}else for(;c>l;l++)if((e||l in s)&&s[l]===a)return e||l||0;return!e&&-1}};e.exports={includes:a(!0),indexOf:a(!1)}}),It=/*#__PURE__*/ z.cw(function(e,t){var n=Qt(),r=zn(),i=TypeError,a=Object.getOwnPropertyDescriptor;e.exports=n&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}()?function(e,t){if(r(e)&&!a(e,`length`).writable)throw new i(`Cannot set read only .length`);return e.length=t}:function(e,t){return e.length=t}}),Lt=/*#__PURE__*/ z.cw(function(e,t){e.exports=yn()([].slice)}),Rt=()=>z(469),zt=/*#__PURE__*/ z.cw(function(e,t){var n=Et(),r=$n();e.exports=function(e,t,i,a){try{return a?t(n(i)[0],i[1]):t(i)}catch(t){r(e,`throw`,t)}}}),Bt=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=n({}.toString),i=n(``.slice);e.exports=function(e){return i(r(e),8,-1)}}),Vt=/*#__PURE__*/ z.cw(function(e,t){var n=ai(),r=Vn(),i=Bt(),a=gi()(`toStringTag`),o=Object,s=i(function(){return arguments}())===`Arguments`,c=function(e,t){try{return e[t]}catch{}};e.exports=n?i:function(e){var t,n,l;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=c(t=o(e),a))==`string`?n:s?i(t):(l=i(t))===`Object`&&r(t.callee)?`Arguments`:l}}),Ht=/*#__PURE__*/ z.cw(function(e,t){var n=An(),r=Tr(),i=hr(),a=mr();e.exports=function(e,t,o){for(var s=r(t),c=a.f,l=i.f,u=0;u<s.length;u++){var d=s[u];!n(e,d)&&!(o&&n(o,d))&&c(e,d,l(t,d))}}}),Ut=/*#__PURE__*/ z.cw(function(e,t){e.exports=!dn()(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})}),Wt=()=>z(566),Gt=/*#__PURE__*/ z.cw(function(e,t){var n=Qt(),r=mr(),i=Kt();e.exports=n?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}}),Kt=/*#__PURE__*/ z.cw(function(e,t){e.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}}),qt=/*#__PURE__*/ z.cw(function(e,t){var n=Qt(),r=mr(),i=Kt();e.exports=function(e,t,a){n?r.f(e,t,i(0,a)):e[t]=a}}),Jt=/*#__PURE__*/ z.cw(function(e,t){var n=or(),r=mr();e.exports=function(e,t,i){return i.get&&n(i.get,t,{getter:!0}),i.set&&n(i.set,t,{setter:!0}),r.f(e,t,i)}}),Yt=/*#__PURE__*/ z.cw(function(e,t){var n=Vn(),r=mr(),i=or(),a=Zt();e.exports=function(e,t,o,s){s||={};var c=s.enumerable,l=s.name===void 0?t:s.name;if(n(o)&&i(o,l,s),s.global)c?e[t]=o:a(t,o);else{try{s.unsafe?e[t]&&(c=!0):delete e[t]}catch{}c?e[t]=o:r.f(e,t,{value:o,enumerable:!1,configurable:!s.nonConfigurable,writable:!s.nonWritable})}return e}}),Xt=/*#__PURE__*/ z.cw(function(e,t){var n=Yt();e.exports=function(e,t,r){for(var i in t)n(e,i,t[i],r);return e}}),Zt=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=Object.defineProperty;e.exports=function(e,t){try{r(n,e,{value:t,configurable:!0,writable:!0})}catch{n[e]=t}return t}}),Qt=/*#__PURE__*/ z.cw(function(e,t){e.exports=!dn()(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),$t=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=xn(),i=Kr(),a=n.structuredClone,o=n.ArrayBuffer,s=n.MessageChannel,c=!1,l,u,d,f;if(i)c=function(e){a(e,{transfer:[e]})};else if(o)try{s||(l=r(`worker_threads`),l&&(s=l.MessageChannel)),s&&(u=new s,d=new o(2),f=function(e){u.port1.postMessage(null,[e])},d.byteLength===2&&(f(d),d.byteLength===0&&(c=f)))}catch{}e.exports=c}),en=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=Wn(),i=n.document,a=r(i)&&r(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}}),tn=()=>z(504),nn=()=>z(849),rn=/*#__PURE__*/ z.cw(function(e,t){e.exports=[`constructor`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`toLocaleString`,`toString`,`valueOf`]}),an=/*#__PURE__*/ z.cw(function(e,t){e.exports=cn()===`NODE`}),on=/*#__PURE__*/ z.cw(function(e,t){var n=kn().navigator,r=n&&n.userAgent;e.exports=r?String(r):``}),sn=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=on(),i=n.process,a=n.Deno,o=i&&i.versions||a&&a.version,s=o&&o.v8,c,l;s&&(c=s.split(`.`),l=c[0]>0&&c[0]<4?1:+(c[0]+c[1])),!l&&r&&(c=r.match(/Edge\/(\d+)/),(!c||c[1]>=74)&&(c=r.match(/Chrome\/(\d+)/),c&&(l=+c[1]))),e.exports=l}),cn=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=on(),i=Bt(),a=function(e){return r.slice(0,e.length)===e};e.exports=(function(){return a(`Bun/`)?`BUN`:a(`Cloudflare-Workers`)?`CLOUDFLARE`:a(`Deno/`)?`DENO`:a(`Node.js/`)?`NODE`:n.Bun&&typeof Bun.version==`string`?`BUN`:n.Deno&&typeof Deno.version==`object`?`DENO`:i(n.process)===`process`?`NODE`:n.window&&n.document?`BROWSER`:`REST`})()}),ln=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=Error,i=n(``.replace),a=(function(e){return String(new r(e).stack)})(`zxcasd`),o=/\n\s*at [^:]*:[^\n]*/,s=o.test(a);e.exports=function(e,t){if(s&&typeof e==`string`&&!r.prepareStackTrace)for(;t--;)e=i(e,o,``);return e}}),un=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=hr().f,i=Gt(),a=Yt(),o=Zt(),s=Ht(),c=Hn();e.exports=function(e,t){var l=e.target,u=e.global,d=e.stat,f,p=u?n:d?n[l]||o(l,{}):n[l]&&n[l].prototype,m,h,g,_;if(p)for(m in t){if(g=t[m],e.dontCallGetSet?(_=r(p,m),h=_&&_.value):h=p[m],f=c(u?m:l+(d?`.`:`#`)+m,e.forced),!f&&h!==void 0){if(typeof g==typeof h)continue;s(g,h)}(e.sham||h&&h.sham)&&i(g,`sham`,!0),a(p,m,g,e)}}}),dn=/*#__PURE__*/ z.cw(function(e,t){e.exports=function(e){try{return!!e()}catch{return!0}}}),fn=/*#__PURE__*/ z.cw(function(e,t){var n=mn(),r=Function.prototype,i=r.apply,a=r.call;e.exports=typeof Reflect==`object`&&Reflect.apply||(n?a.bind(i):function(){return a.apply(i,arguments)})}),pn=/*#__PURE__*/ z.cw(function(e,t){var n=vn(),r=_t(),i=mn(),a=n(n.bind);e.exports=function(e,t){return r(e),t===void 0?e:i?a(e,t):function(){return e.apply(t,arguments)}}}),mn=/*#__PURE__*/ z.cw(function(e,t){e.exports=!dn()(function(){var e=function(){}.bind();return typeof e!=`function`||e.hasOwnProperty(`prototype`)})}),hn=/*#__PURE__*/ z.cw(function(e,t){var n=mn(),r=Function.prototype.call;e.exports=n?r.bind(r):function(){return r.apply(r,arguments)}}),gn=/*#__PURE__*/ z.cw(function(e,t){var n=Qt(),r=An(),i=Function.prototype,a=n&&Object.getOwnPropertyDescriptor,o=r(i,`name`);o&&function(){}.name,e.exports={CONFIGURABLE:o&&(!n||n&&a(i,`name`).configurable)}}),_n=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=_t();e.exports=function(e,t,i){try{return n(r(Object.getOwnPropertyDescriptor(e,t)[i]))}catch{}}}),vn=/*#__PURE__*/ z.cw(function(e,t){var n=Bt(),r=yn();e.exports=function(e){if(n(e)===`Function`)return r(e)}}),yn=/*#__PURE__*/ z.cw(function(e,t){var n=mn(),r=Function.prototype,i=r.call,a=n&&r.bind.bind(i,i);e.exports=n?a:function(e){return function(){return i.apply(e,arguments)}}}),bn=()=>z(35),xn=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=an();e.exports=function(e){if(r){try{return n.process.getBuiltinModule(e)}catch{}try{return Function(`return require("`+e+`")`)()}catch{}}}}),Sn=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=Vn(),i=function(e){return r(e)?e:void 0};e.exports=function(e,t){return arguments.length<2?i(n[e]):n[e]&&n[e][t]}}),Cn=()=>z(60),wn=/*#__PURE__*/ z.cw(function(e,t){var n=hn(),r=Et(),i=Cn(),a=En();e.exports=function(e,t){t&&typeof e==`string`||r(e);var o=a(e);return i(r(o===void 0?e:n(o,e)))}}),Tn=/*#__PURE__*/ z.cw(function(e,t){var n=hn(),r=Vn(),i=Et(),a=si(),o=En(),s=TypeError;e.exports=function(e,t){var c=arguments.length<2?o(e):t;if(r(c))return i(n(c,e));throw new s(a(e)+` is not iterable`)}}),En=/*#__PURE__*/ z.cw(function(e,t){var n=Bt(),r=Un(),i=Dn(),a=gi()(`iterator`),o=Array.prototype;e.exports=function(e){if(!r(e))return i(e,a)||i(e,`@@iterator`)||(n(e)===`Arguments`?o[a]:void 0)}}),Dn=/*#__PURE__*/ z.cw(function(e,t){var n=_t(),r=Un();e.exports=function(e,t){var i=e[t];return r(i)?void 0:n(i)}}),On=/*#__PURE__*/ z.cw(function(e,t){var n=_t(),r=Et(),i=hn(),a=$r(),o=Cn(),s=`Invalid size`,c=RangeError,l=TypeError,u=Math.max,d=function(e,t){this.set=e,this.size=u(t,0),this.has=n(e.has),this.keys=n(e.keys)};d.prototype={getIterator:function(){return o(r(i(this.keys,this.set)))},includes:function(e){return i(this.has,this.set,e)}},e.exports=function(e){r(e);var t=+e.size;if(t!==t)throw new l(s);var n=a(t);if(n<0)throw new c(s);return new d(e,n)}}),kn=/*#__PURE__*/ z.cw(function(e,t){var n=function(e){return e&&e.Math===Math&&e};e.exports=n(typeof globalThis==`object`&&globalThis)||n(typeof window==`object`&&window)||n(typeof self==`object`&&self)||n(typeof global==`object`&&global)||n(typeof this==`object`&&this)||(function(){return this})()||Function(`return this`)()}),An=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=ti(),i=n({}.hasOwnProperty);e.exports=Object.hasOwn||function(e,t){return i(r(e),t)}}),jn=/*#__PURE__*/ z.cw(function(e,t){e.exports={}}),Mn=/*#__PURE__*/ z.cw(function(e,t){e.exports=Sn()(`document`,`documentElement`)}),Nn=/*#__PURE__*/ z.cw(function(e,t){var n=Qt(),r=dn(),i=en();e.exports=!n&&!r(function(){return Object.defineProperty(i(`div`),"a",{get:function(){return 7}}).a!==7})}),Pn=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=dn(),i=Bt(),a=Object,o=n(``.split);e.exports=r(function(){return!a(`z`).propertyIsEnumerable(0)})?function(e){return i(e)===`String`?o(e,``):a(e)}:a}),Fn=/*#__PURE__*/ z.cw(function(e,t){var n=Vn(),r=Wn(),i=Cr();e.exports=function(e,t,a){var o,s;return i&&n(o=t.constructor)&&o!==a&&r(s=o.prototype)&&s!==a.prototype&&i(e,s),e}}),In=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=Vn(),i=Wr(),a=n(Function.toString);r(i.inspectSource)||(i.inspectSource=function(e){return a(e)}),e.exports=i.inspectSource}),Ln=/*#__PURE__*/ z.cw(function(e,t){var n=mi(),r=kn(),i=Wn(),a=Gt(),o=An(),s=Wr(),c=Ur(),l=jn(),u=`Object already initialized`,d=r.TypeError,f=r.WeakMap,p,m,h,g=function(e){return h(e)?m(e):p(e,{})},_=function(e){return function(t){var n;if(!i(t)||(n=m(t)).type!==e)throw new d(`Incompatible receiver, `+e+` required`);return n}};if(n||s.state){var v=s.state||=new f;v.get=v.get,v.has=v.has,v.set=v.set,p=function(e,t){if(v.has(e))throw new d(u);return t.facade=e,v.set(e,t),t},m=function(e){return v.get(e)||{}},h=function(e){return v.has(e)}}else{var y=c(`state`);l[y]=!0,p=function(e,t){if(o(e,y))throw new d(u);return t.facade=e,a(e,y,t),t},m=function(e){return o(e,y)?e[y]:{}},h=function(e){return o(e,y)}}e.exports={set:p,get:m,has:h,enforce:g,getterFor:_}}),Rn=/*#__PURE__*/ z.cw(function(e,t){var n=gi(),r=ir(),i=n(`iterator`),a=Array.prototype;e.exports=function(e){return e!==void 0&&(r.Array===e||a[i]===e)}}),zn=/*#__PURE__*/ z.cw(function(e,t){var n=Bt();e.exports=Array.isArray||function(e){return n(e)===`Array`}}),Bn=/*#__PURE__*/ z.cw(function(e,t){var n=Vt();e.exports=function(e){var t=n(e);return t===`BigInt64Array`||t===`BigUint64Array`}}),Vn=/*#__PURE__*/ z.cw(function(e,t){var n=typeof document==`object`&&document.all;e.exports=n===void 0&&n!==void 0?function(e){return typeof e==`function`||e===n}:function(e){return typeof e==`function`}}),Hn=/*#__PURE__*/ z.cw(function(e,t){var n=dn(),r=Vn(),i=/#|\.prototype\./,a=function(e,t){var i=s[o(e)];return i===l?!0:i===c?!1:r(t)?n(t):!!t},o=a.normalize=function(e){return String(e).replace(i,`.`).toLowerCase()},s=a.data={},c=a.NATIVE=`N`,l=a.POLYFILL=`P`;e.exports=a}),Un=()=>z(600),Wn=/*#__PURE__*/ z.cw(function(e,t){var n=Vn();e.exports=function(e){return typeof e==`object`?e!==null:n(e)}}),Gn=/*#__PURE__*/ z.cw(function(e,t){var n=Wn();e.exports=function(e){return n(e)||e===null}}),Kn=/*#__PURE__*/ z.cw(function(e,t){e.exports=!1}),qn=/*#__PURE__*/ z.cw(function(e,t){var n=Wn(),r=Ln().get;e.exports=function(e){if(!n(e))return!1;var t=r(e);return!!t&&t.type===`RawJSON`}}),Jn=/*#__PURE__*/ z.cw(function(e,t){var n=Sn(),r=Vn(),i=yr(),a=di(),o=Object;e.exports=a?function(e){return typeof e==`symbol`}:function(e){var t=n(`Symbol`);return r(t)&&i(t.prototype,o(e))}}),Yn=/*#__PURE__*/ z.cw(function(e,t){var n=hn();e.exports=function(e,t,r){for(var i=r?e:e.iterator,a=e.next,o,s;!(o=n(a,i)).done;)if(s=t(o.value),s!==void 0)return s}}),Xn=/*#__PURE__*/ z.cw(function(e,t){var n=pn(),r=hn(),i=Et(),a=si(),o=Rn(),s=ar(),c=yr(),l=Tn(),u=En(),d=$n(),f=TypeError,p=function(e,t){this.stopped=e,this.result=t},m=p.prototype;e.exports=function(e,t,h){var g=h&&h.that,_=!!(h&&h.AS_ENTRIES),v=!!(h&&h.IS_RECORD),y=!!(h&&h.IS_ITERATOR),b=!!(h&&h.INTERRUPTED),x=n(t,g),S,C,w,T,E,D,O,k=function(e){var t=S;return S=void 0,t&&d(t,`normal`),new p(!0,e)},A=function(e){return _?(i(e),b?x(e[0],e[1],k):x(e[0],e[1])):b?x(e,k):x(e)};if(v)S=e.iterator;else if(y)S=e;else{if(C=u(e),!C)throw new f(a(e)+` is not iterable`);if(o(C)){for(w=0,T=s(e);T>w;w++)if(E=A(e[w]),E&&c(m,E))return E;return new p(!1)}S=l(e,C)}for(D=v?e.next:S.next;!(O=r(D,S)).done;){var j=O.value;try{E=A(j)}catch(e){if(S)d(S,`throw`,e);else throw e}if(typeof E==`object`&&E&&c(m,E))return E}return new p(!1)}}),Zn=()=>z(430),Qn=/*#__PURE__*/ z.cw(function(e,t){var n=$n();e.exports=function(e,t,r){for(var i=e.length-1;i>=0;i--)if(e[i]!==void 0)try{r=n(e[i].iterator,t,r)}catch(e){t=`throw`,r=e}if(t===`throw`)throw r;return r}}),$n=/*#__PURE__*/ z.cw(function(e,t){var n=hn(),r=Et(),i=Dn();e.exports=function(e,t,a){var o,s;r(e);try{if(o=i(e,`return`),!o){if(t===`throw`)throw a;return a}o=n(o,e)}catch(e){s=!0,o=e}if(t===`throw`)throw a;if(s)throw o;return r(o),a}}),er=/*#__PURE__*/ z.cw(function(e,t){var n=hn(),r=fr(),i=Gt(),a=Xt(),o=gi(),s=Ln(),c=Dn(),l=rr().IteratorPrototype,u=Wt(),d=$n(),f=Qn(),p=Zn(),m=o(`toStringTag`),h=`IteratorHelper`,g=`WrapForValidIterator`,_=`normal`,v=`throw`,y=s.set,b=function(e){var t=s.getterFor(e?g:h);return a(r(l),{next:function(){var n=t(this);if(e)return n.nextHandler();if(n.done)return u(void 0,!0);try{var r=n.nextHandler();return n.done&&p(n),n.returnHandlerResult?r:u(r,n.done)}catch(e){throw n.done=!0,p(n),e}},return:function(){var r=t(this),i=r.iterator,a=r.inner,o=r.openIters,s=r.done;if(r.done=!0,e){var l=c(i,`return`);return l?n(l,i):u(void 0,!0)}if(p(r),s)return u(void 0,!0);if(a)try{d(a.iterator,_)}catch(e){return d(i,v,e)}if(o)try{f(o,_)}catch(e){if(i)return d(i,v,e);throw e}return i&&d(i,_),u(void 0,!0)}})},x=b(!0),S=b(!1);i(S,m,`Iterator Helper`),e.exports=function(e,t,n){var r=function(r,i){i?(i.iterator=r.iterator,i.next=r.next):i=r,i.type=t?g:h,i.returnHandlerResult=!!n,i.nextHandler=e,i.counter=0,i.done=!1,y(this,i)};return r.prototype=t?x:S,r}}),tr=()=>z(909),nr=/*#__PURE__*/ z.cw(function(e,t){var n=kn();e.exports=function(e,t){var r=n.Iterator,i=r&&r.prototype,a=i&&i[e],o=!1;if(a)try{a.call({next:function(){return{done:!0}},return:function(){o=!0}},-1)}catch(e){e instanceof t||(o=!1)}if(!o)return a}}),rr=/*#__PURE__*/ z.cw(function(e,t){var n=dn(),r=Vn(),i=Wn(),a=fr(),o=vr(),s=Yt(),c=gi(),l=Kn(),u=c(`iterator`),d,f,p;[].keys&&(p=[].keys(),`next`in p&&(f=o(o(p)),f!==Object.prototype&&(d=f))),!i(d)||n(function(){var e={};return d[u].call(e)!==e})?d={}:l&&(d=a(d)),r(d[u])||s(d,u,function(){return this}),e.exports={IteratorPrototype:d}}),ir=()=>z(510),ar=/*#__PURE__*/ z.cw(function(e,t){var n=ei();e.exports=function(e){return n(e.length)}}),or=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=dn(),i=Vn(),a=An(),o=Qt(),s=gn().CONFIGURABLE,c=In(),l=Ln(),u=l.enforce,d=l.get,f=String,p=Object.defineProperty,m=n(``.slice),h=n(``.replace),g=n([].join),_=o&&!r(function(){return p(function(){},`length`,{value:8}).length!==8}),v=String(String).split(`String`),y=e.exports=function(e,t,n){m(f(t),0,7)===`Symbol(`&&(t=`[`+h(f(t),/^Symbol\(([^)]*)\).*$/,`$1`)+`]`),n&&n.getter&&(t=`get `+t),n&&n.setter&&(t=`set `+t),(!a(e,`name`)||s&&e.name!==t)&&(o?p(e,`name`,{value:t,configurable:!0}):e.name=t),_&&n&&a(n,`arity`)&&e.length!==n.arity&&p(e,`length`,{value:n.arity});try{n&&a(n,`constructor`)&&n.constructor?o&&p(e,`prototype`,{writable:!1}):e.prototype&&=void 0}catch{}var r=u(e);return a(r,`source`)||(r.source=g(v,typeof t==`string`?t:``)),e};Function.prototype.toString=y(function(){return i(this)&&d(this).source||c(this)},`toString`)}),sr=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=Map.prototype;e.exports={Map,set:n(r.set),get:n(r.get),has:n(r.has),remove:n(r.delete),proto:r}}),cr=/*#__PURE__*/ z.cw(function(e,t){e.exports=!dn()(function(){var e=`9007199254740993`,t=JSON.rawJSON(e);return!JSON.isRawJSON(t)||JSON.stringify(t)!==e})}),lr=/*#__PURE__*/ z.cw(function(e,t){var n=_t(),r=TypeError,i=function(e){var t,i;this.promise=new e(function(e,n){if(t!==void 0||i!==void 0)throw new r(`Bad Promise constructor`);t=e,i=n}),this.resolve=n(t),this.reject=n(i)};e.exports.f=function(e){return new i(e)}}),ur=/*#__PURE__*/ z.cw(function(e,t){var n=oi();e.exports=function(e,t){return e===void 0?arguments.length<2?``:t:n(e)}}),dr=()=>z(18),fr=/*#__PURE__*/ z.cw(function(e,t){var n=Et(),r=pr(),i=rn(),a=jn(),o=Mn(),s=en(),c=Ur(),l=`>`,u=`<`,d=`prototype`,f=`script`,p=c(`IE_PROTO`),m=function(){},h=function(e){return u+f+l+e+u+`/`+f+l},g=function(e){e.write(h(``)),e.close();var t=e.parentWindow.Object;return e=null,t},_=function(){var e=s(`iframe`),t=`java`+f+`:`,n;return e.style.display=`none`,o.appendChild(e),e.src=String(t),n=e.contentWindow.document,n.open(),n.write(h(`document.F=Object`)),n.close(),n.F},v,y=function(){try{v=new ActiveXObject(`htmlfile`)}catch{}y=typeof document<`u`?document.domain&&v?g(v):_():g(v);for(var e=i.length;e--;)delete y[d][i[e]];return y()};a[p]=!0,e.exports=Object.create||function(e,t){var i;return e===null?i=y():(m[d]=n(e),i=new m,m[d]=null,i[p]=e),t===void 0?i:r.f(i,t)}}),pr=/*#__PURE__*/ z.cw(function(e,t){var n=Qt(),r=fi(),i=mr(),a=Et(),o=Qr(),s=xr();t.f=n&&!r?Object.defineProperties:function(e,t){a(e);for(var n=o(t),r=s(t),c=r.length,l=0,u;c>l;)i.f(e,u=r[l++],n[u]);return e}}),mr=/*#__PURE__*/ z.cw(function(e,t){var n=Qt(),r=Nn(),i=fi(),a=Et(),o=ii(),s=TypeError,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=`enumerable`,d=`configurable`,f=`writable`;t.f=n?i?function(e,t,n){if(a(e),t=o(t),a(n),typeof e==`function`&&t===`prototype`&&`value`in n&&f in n&&!n[f]){var r=l(e,t);r&&r[f]&&(e[t]=n.value,n={configurable:d in n?n[d]:r[d],enumerable:u in n?n[u]:r[u],writable:!1})}return c(e,t,n)}:c:function(e,t,n){if(a(e),t=o(t),a(n),r)try{return c(e,t,n)}catch{}if(`get`in n||`set`in n)throw new s(`Accessors not supported`);return`value`in n&&(e[t]=n.value),e}}),hr=/*#__PURE__*/ z.cw(function(e,t){var n=Qt(),r=hn(),i=Sr(),a=Kt(),o=Qr(),s=ii(),c=An(),l=Nn(),u=Object.getOwnPropertyDescriptor;t.f=n?u:function(e,t){if(e=o(e),t=s(t),l)try{return u(e,t)}catch{}if(c(e,t))return a(!r(i.f,e,t),e[t])}}),gr=/*#__PURE__*/ z.cw(function(e,t){var n=br(),r=rn().concat(`length`,`prototype`);t.f=Object.getOwnPropertyNames||function(e){return n(e,r)}}),_r=()=>z(706),vr=/*#__PURE__*/ z.cw(function(e,t){var n=An(),r=Vn(),i=ti(),a=Ur(),o=Ut(),s=a(`IE_PROTO`),c=Object,l=c.prototype;e.exports=o?c.getPrototypeOf:function(e){var t=i(e);if(n(t,s))return t[s];var a=t.constructor;return r(a)&&t instanceof a?a.prototype:t instanceof c?l:null}}),yr=/*#__PURE__*/ z.cw(function(e,t){e.exports=yn()({}.isPrototypeOf)}),br=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=An(),i=Qr(),a=Ft().indexOf,o=jn(),s=n([].push);e.exports=function(e,t){var n=i(e),c=0,l=[],u;for(u in n)!r(o,u)&&r(n,u)&&s(l,u);for(;t.length>c;)r(n,u=t[c++])&&(~a(l,u)||s(l,u));return l}}),xr=/*#__PURE__*/ z.cw(function(e,t){var n=br(),r=rn();e.exports=Object.keys||function(e){return n(e,r)}}),Sr=/*#__PURE__*/ z.cw(function(e,t){var n={}.propertyIsEnumerable,r=Object.getOwnPropertyDescriptor;t.f=r&&!n.call({1:2},1)?function(e){var t=r(this,e);return!!t&&t.enumerable}:n}),Cr=/*#__PURE__*/ z.cw(function(e,t){var n=_n(),r=Wn(),i=kr(),a=vt();e.exports=Object.setPrototypeOf||(`__proto__`in{}?function(){var e=!1,t={},o;try{o=n(Object.prototype,`__proto__`,`set`),o(t,[]),e=t instanceof Array}catch{}return function(t,n){return i(t),a(n),r(t)&&(e?o(t,n):t.__proto__=n),t}}():void 0)}),wr=/*#__PURE__*/ z.cw(function(e,t){var n=hn(),r=Vn(),i=Wn(),a=TypeError;e.exports=function(e,t){var o,s;if(t===`string`&&r(o=e.toString)&&!i(s=n(o,e))||r(o=e.valueOf)&&!i(s=n(o,e))||t!==`string`&&r(o=e.toString)&&!i(s=n(o,e)))return s;throw new a(`Can't convert object to primitive value`)}}),Tr=/*#__PURE__*/ z.cw(function(e,t){var n=Sn(),r=yn(),i=gr(),a=_r(),o=Et(),s=r([].concat);e.exports=n(`Reflect`,`ownKeys`)||function(e){var t=i.f(o(e)),n=a.f;return n?s(t,n(e)):t}}),Er=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=An(),i=SyntaxError,a=parseInt,o=String.fromCharCode,s=n(``.charAt),c=n(``.slice),l=n(/./.exec),u={'\\"':`"`,"\\\\":`\\`,"\\/":`/`,"\\b":`\b`,"\\f":`\f`,"\\n":`
2
+ `,"\\r":`\r`,"\\t":` `},d=/^[\da-f]{4}$/i,f=/^[\u0000-\u001F]$/;e.exports=function(e,t){for(var n=!0,p=``;t<e.length;){var m=s(e,t);if(m===`\\`){var h=c(e,t,t+2);if(r(u,h))p+=u[h],t+=2;else if(h===`\\u`){t+=2;var g=c(e,t,t+4);if(!l(d,g))throw new i(`Bad Unicode escape at: `+t);p+=o(a(g,16)),t+=4}else throw new i(`Unknown escape sequence: "`+h+`"`)}else if(m===`"`){n=!1,t++;break}else{if(l(f,m))throw new i(`Bad control character in string literal at: `+t);p+=m,t++}}if(n)throw new i(`Unterminated string at: `+t);return{value:p,end:t}}}),Dr=()=>z(636),Or=/*#__PURE__*/ z.cw(function(e,t){var n=Et(),r=Wn(),i=lr();e.exports=function(e,t){if(n(e),r(t)&&t.constructor===e)return t;var a=i.f(e),o=a.resolve;return o(t),a.promise}}),kr=()=>z(263),Ar=/*#__PURE__*/ z.cw(function(e,t){var n=Mr(),r=Lr(),i=n.Set,a=n.add;e.exports=function(e){var t=new i;return r(e,function(e){a(t,e)}),t}}),jr=/*#__PURE__*/ z.cw(function(e,t){var n=yt(),r=Mr(),i=Ar(),a=Br(),o=On(),s=Lr(),c=Yn(),l=r.has,u=r.remove;e.exports=function(e){var t=n(this),r=o(e),d=i(t);return a(d)<=r.size?s(d,function(e){r.includes(e)&&u(d,e)}):c(r.getIterator(),function(e){l(d,e)&&u(d,e)}),d}}),Mr=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=Set.prototype;e.exports={Set,add:n(r.add),has:n(r.has),remove:n(r.delete),proto:r}}),Nr=/*#__PURE__*/ z.cw(function(e,t){var n=yt(),r=Mr(),i=Br(),a=On(),o=Lr(),s=Yn(),c=r.Set,l=r.add,u=r.has;e.exports=function(e){var t=n(this),r=a(e),d=new c;return i(t)>r.size?s(r.getIterator(),function(e){u(t,e)&&l(d,e)}):o(t,function(e){r.includes(e)&&l(d,e)}),d}}),Pr=/*#__PURE__*/ z.cw(function(e,t){var n=yt(),r=Mr().has,i=Br(),a=On(),o=Lr(),s=Yn(),c=$n();e.exports=function(e){var t=n(this),l=a(e);if(i(t)<=l.size)return o(t,function(e){if(l.includes(e))return!1},!0)!==!1;var u=l.getIterator();return s(u,function(e){if(r(t,e))return c(u.iterator,`normal`,!1)})!==!1}}),Fr=/*#__PURE__*/ z.cw(function(e,t){var n=yt(),r=Br(),i=Lr(),a=On();e.exports=function(e){var t=n(this),o=a(e);return r(t)>o.size?!1:i(t,function(e){if(!o.includes(e))return!1},!0)!==!1}}),Ir=/*#__PURE__*/ z.cw(function(e,t){var n=yt(),r=Mr().has,i=Br(),a=On(),o=Yn(),s=$n();e.exports=function(e){var t=n(this),c=a(e);if(i(t)<c.size)return!1;var l=c.getIterator();return o(l,function(e){if(!r(t,e))return s(l.iterator,`normal`,!1)})!==!1}}),Lr=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=Yn(),i=Mr(),a=i.Set,o=i.proto,s=n(o.forEach),c=n(o.keys),l=c(new a).next;e.exports=function(e,t,n){return n?r({iterator:c(e),next:l},t):s(e,t)}}),Rr=/*#__PURE__*/ z.cw(function(e,t){var n=Sn(),r=function(e){return{size:e,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},i=function(e){return{size:e,has:function(){return!0},keys:function(){throw Error(`e`)}}};e.exports=function(e,t){var a=n(`Set`);try{new a()[e](r(0));try{return new a()[e](r(-1)),!1}catch{if(!t)return!0;try{return new a()[e](i(-1/0)),!1}catch{return t(new a([1,2])[e](i(1/0)))}}}catch{return!1}}}),zr=()=>z(758),Br=/*#__PURE__*/ z.cw(function(e,t){e.exports=_n()(Mr().proto,`size`,`get`)||function(e){return e.size}}),Vr=/*#__PURE__*/ z.cw(function(e,t){var n=yt(),r=Mr(),i=Ar(),a=On(),o=Yn(),s=r.add,c=r.has,l=r.remove;e.exports=function(e){var t=n(this),r=a(e).getIterator(),u=i(t);return o(r,function(e){c(t,e)?l(u,e):s(u,e)}),u}}),Hr=/*#__PURE__*/ z.cw(function(e,t){var n=yt(),r=Mr().add,i=Ar(),a=On(),o=Yn();e.exports=function(e){var t=n(this),s=a(e).getIterator(),c=i(t);return o(s,function(e){r(c,e)}),c}}),Ur=/*#__PURE__*/ z.cw(function(e,t){var n=Gr(),r=ci(),i=n(`keys`);e.exports=function(e){return i[e]||(i[e]=r(e))}}),Wr=/*#__PURE__*/ z.cw(function(e,t){var n=Kn(),r=kn(),i=Zt(),a=`__core-js_shared__`,o=e.exports=r[a]||i(a,{});(o.versions||=[]).push({version:`3.50.0`,mode:n?`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`})}),Gr=/*#__PURE__*/ z.cw(function(e,t){var n=Wr(),r=Object.create||Object;e.exports=function(e,t){return n[e]||(n[e]=t||r(null))}}),Kr=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=dn(),i=sn(),a=cn(),o=n.structuredClone;e.exports=!!o&&!r(function(){if(a===`DENO`&&i>92||a===`NODE`&&i>94||a===`BROWSER`&&i>97)return!1;var e=/* @__PURE__ */ new ArrayBuffer(8),t=o(e,{transfer:[e]});return e.byteLength!==0||t.byteLength!==8})}),qr=/*#__PURE__*/ z.cw(function(e,t){var n=sn(),r=dn(),i=kn().String;e.exports=!!Object.getOwnPropertySymbols&&!r(function(){var e=Symbol(`symbol detection`);return!i(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&n&&n<41})}),Jr=/*#__PURE__*/ z.cw(function(e,t){e.exports=yn()(1.1.valueOf)}),Yr=/*#__PURE__*/ z.cw(function(e,t){var n=$r(),r=Math.max,i=Math.min;e.exports=function(e,t){var a=n(e);return a<0?r(a+t,0):i(a,t)}}),Xr=/*#__PURE__*/ z.cw(function(e,t){var n=ri(),r=TypeError;e.exports=function(e){var t=n(e,`number`);if(typeof t==`number`)throw new r(`Can't convert number to bigint`);return BigInt(t)}}),Zr=()=>z(473),Qr=/*#__PURE__*/ z.cw(function(e,t){var n=Pn(),r=kr();e.exports=function(e){return n(r(e))}}),$r=()=>z(402),ei=()=>z(737),ti=()=>z(674),ni=()=>z(137),ri=/*#__PURE__*/ z.cw(function(e,t){var n=hn(),r=Wn(),i=Jn(),a=Dn(),o=wr(),s=gi(),c=TypeError,l=s(`toPrimitive`);e.exports=function(e,t){if(!r(e)||i(e))return e;var s=a(e,l),u;if(s){if(t===void 0&&(t=`default`),u=n(s,e,t),!r(u)||i(u))return u;throw new c(`Can't convert object to primitive value`)}return t===void 0&&(t=`number`),o(e,t)}}),ii=/*#__PURE__*/ z.cw(function(e,t){var n=ri(),r=Jn();e.exports=function(e){var t=n(e,`string`);return r(t)?t:t+``}}),ai=/*#__PURE__*/ z.cw(function(e,t){var n=gi()(`toStringTag`),r={};r[n]=`z`,e.exports=String(r)===`[object z]`}),oi=/*#__PURE__*/ z.cw(function(e,t){var n=Vt(),r=String;e.exports=function(e){if(n(e)===`Symbol`)throw TypeError(`Cannot convert a Symbol value to a string`);return r(e)}}),si=/*#__PURE__*/ z.cw(function(e,t){var n=String;e.exports=function(e){try{return n(e)}catch{return`Object`}}}),ci=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=0,i=Math.random(),a=n(1.1.toString);e.exports=function(e){return`Symbol(`+(e===void 0?``:e)+`)_`+a(++r+i,36)}}),li=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=yn(),i=Tt(),a=bt(),o=An(),s=Rt(),c=bn(),l=jt(),u=s.c2i,d=s.c2iUrl,f=n.SyntaxError,p=n.TypeError,m=n.Array,h=r(``.charAt),g=Math.floor,_=function(e,t){for(var n=e.length;t<n;t++){var r=h(e,t);if(r!==` `&&r!==` `&&r!==`
3
+ `&&r!==`\f`&&r!==`\r`)break}return t},v=function(e,t,n){var r=e.length;r<4&&(e+=r===2?`AA`:`A`);var i=(t[h(e,0)]<<18)+(t[h(e,1)]<<12)+(t[h(e,2)]<<6)+t[h(e,3)],a=[i>>16&255,i>>8&255,i&255];if(r===2){if(n&&a[1]!==0)throw new f(`Extra bits`);return[a[0]]}if(r===3){if(n&&a[2]!==0)throw new f(`Extra bits`);return[a[0],a[1]]}return a},y=function(e,t,n){for(var r=t.length,i=0;i<r;i++)e[n+i]=t[i];return n+r};e.exports=function(e,t,n,r){a(e),i(t);var s=c(t)===`base64`?u:d,b=t?t.lastChunkHandling:void 0;if(b===void 0&&(b=`loose`),b!==`loose`&&b!==`strict`&&b!==`stop-before-partial`)throw new p("Incorrect `lastChunkHandling` option");n&&l(n.buffer);var x=e.length,S=n||m(g(x*3/4)),C=0,w=0,T=``,E=0;if(r)for(;;){if(E=_(e,E),E===x){if(T.length>0){if(b===`stop-before-partial`)break;if(b===`loose`){if(T.length===1)throw new f(`Malformed padding: exactly one additional character`);C=y(S,v(T,s,!1),C)}else throw new f(`Missing padding`)}w=x;break}var D=h(e,E);if(++E,D===`=`){if(T.length<2)throw new f(`Padding is too early`);if(E=_(e,E),T.length===2){if(E===x){if(b===`stop-before-partial`)break;throw new f(`Malformed padding: only one =`)}h(e,E)===`=`&&(++E,E=_(e,E))}if(E<x)throw new f(`Unexpected character after padding`);C=y(S,v(T,s,b===`strict`),C),w=x;break}if(!o(s,D))throw new f(`Unexpected character`);var O=r-C;if(O===1&&T.length===2||O===2&&T.length===3||(T+=D,T.length===4&&(C=y(S,v(T,s,!1),C),T=``,w=E,C===r)))break}return n||(S.length=C),{bytes:S,read:w,written:C}}}),ui=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=yn(),i=n.Uint8Array,a=n.SyntaxError,o=Math.min,s=r(``.match);e.exports=function(e,t){var n=e.length;if(n%2!=0)throw new a(`String should be an even number of characters`);for(var r=t?o(t.length,n/2):n/2,c=t||new i(r),l=s(e,/[\S\s]{2}/g),u=0;u<r;u++){var d=+(`0x`+l[u]+`0`);if(d!==d)throw new a(`String should only contain hex characters`);c[u]=d>>4}return{bytes:c,read:u<<1}}}),di=/*#__PURE__*/ z.cw(function(e,t){e.exports=qr()&&!Symbol.sham&&typeof Symbol.iterator==`symbol`}),fi=/*#__PURE__*/ z.cw(function(e,t){var n=Qt(),r=dn();e.exports=n&&r(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})}),pi=()=>z(395),mi=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=Vn(),i=n.WeakMap;e.exports=r(i)&&/native code/.test(String(i))}),hi=/*#__PURE__*/ z.cw(function(e,t){var n=yn(),r=WeakMap.prototype;e.exports={WeakMap,set:n(r.set),get:n(r.get),has:n(r.has),remove:n(r.delete)}}),gi=/*#__PURE__*/ z.cw(function(e,t){var n=kn(),r=Gr(),i=An(),a=ci(),o=qr(),s=di(),c=n.Symbol,l=r(`wks`),u=s?c.for||c:c&&c.withoutSetter||a;e.exports=function(e){return i(l,e)||(l[e]=o&&i(c,e)?c[e]:u(`Symbol.`+e)),l[e]}}),_i=/*#__PURE__*/ z.cw(function(e,t){var n=Qt(),r=Jt(),i=At(),a=ArrayBuffer.prototype;n&&!(`detached`in a)&&r(a,`detached`,{configurable:!0,get:function(){return i(this)}})}),vi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=Mt();r&&n({target:`ArrayBuffer`,proto:!0},{transferToFixedLength:function(){return r(this,arguments.length?arguments[0]:void 0,!1)}})}),yi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=Mt();r&&n({target:`ArrayBuffer`,proto:!0},{transfer:function(){return r(this,arguments.length?arguments[0]:void 0,!0)}})}),bi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=Ft().includes,i=dn(),a=Ct(),o=i(function(){return![,].includes()}),s=i(function(){return[,1].includes(void 0,1)});n({target:`Array`,proto:!0,forced:o||s},{includes:function(e){return r(this,e,arguments.length>1?arguments[1]:void 0)}}),a(`includes`)}),xi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=ti(),i=ar(),a=It(),o=tn();n({target:`Array`,proto:!0,arity:1,forced:dn()(function(){return[].push.call({length:4294967296},1)!==4294967297})||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}}()},{push:function(e){var t=r(this),n=i(t),s=arguments.length;o(n+s);for(var c=0;c<s;c++)t[n]=arguments[c],n++;return a(t,n),n}})}),Si=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=kn(),i=wt(),a=Et(),o=Vn(),s=vr(),c=Jt(),l=qt(),u=dn(),d=An(),f=gi(),p=rr().IteratorPrototype,m=Qt(),h=Kn(),g=`constructor`,_=`Iterator`,v=f(`toStringTag`),y=TypeError,b=r[_],x=h||!o(b)||b.prototype!==p||!u(function(){b({})}),S=function(){if(i(this,p),s(this)===p)throw new y(`Abstract class Iterator not directly constructable`)},C=function(e,t){m?c(p,e,{configurable:!0,get:function(){return t},set:function(t){if(a(this),this===p)throw new y(`You can't redefine this property`);d(this,e)?this[e]=t:l(this,e,t)}}):p[e]=t};d(p,v)||C(v,_),(x||!d(p,g)||p[g]===Object)&&C(g,S),S.prototype=p,n({global:!0,constructor:!0,forced:x},{Iterator:S})}),Ci=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=hn(),i=Et(),a=Cn(),o=dr(),s=ni(),c=$n(),l=er(),u=tr(),d=nr(),f=Kn(),p=RangeError,m=1/0,h=!f&&!u(`drop`,0),g=!f&&!h&&d(`drop`,RangeError),_=f||h||g||!function(){try{Iterator.prototype.drop.call({next:function(){return{done:!0}}},9007199254740992)}catch(e){return e instanceof p}}(),v=l(function(){for(var e=this.iterator,t=this.next,n,a;this.remaining;)if(this.remaining--,n=i(r(t,e)),a=this.done=!!n.done,a)return;if(n=i(r(t,e)),a=this.done=!!n.done,!a)return n.value});n({target:`Iterator`,proto:!0,real:!0,forced:_},{drop:function(e){i(this);var t;try{if(t=s(o(+e)),t>9007199254740991&&t!==m)throw new p(`The argument should be a safe integer`)}catch(e){c(this,`throw`,e)}return g?r(g,this,t):new v(a(this),{remaining:t})}})}),wi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=hn(),i=Xn(),a=_t(),o=Et(),s=Cn(),c=$n(),l=nr()(`every`,TypeError);n({target:`Iterator`,proto:!0,real:!0,forced:l},{every:function(e){o(this);try{a(e)}catch(e){c(this,`throw`,e)}if(l)return r(l,this,e);var t=s(this),n=0;return!i(t,function(t,r){if(!e(t,n++))return r()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),Ti=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=hn(),i=_t(),a=Et(),o=Cn(),s=er(),c=zt(),l=Kn(),u=$n(),d=tr(),f=nr(),p=!l&&!d(`filter`,function(){}),m=!l&&!p&&f(`filter`,TypeError),h=l||p||m,g=s(function(){for(var e=this.iterator,t=this.predicate,n=this.next,i,o,s;;){if(i=a(r(n,e)),o=this.done=!!i.done,o)return;if(s=i.value,c(e,t,[s,this.counter++],!0))return s}});n({target:`Iterator`,proto:!0,real:!0,forced:h},{filter:function(e){a(this);try{i(e)}catch(e){u(this,`throw`,e)}return m?r(m,this,e):new g(o(this),{predicate:e})}})}),Ei=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=hn(),i=_t(),a=Et(),o=Cn(),s=wn(),c=er(),l=$n(),u=dn(),d=Kn(),f=tr(),p=nr(),m=!d&&u(function(){return[1].values().flatMap(function(){return[1]}).find(function(){return!0})!==1}),h=!d&&!m&&!f(`flatMap`,function(){}),g=!d&&!m&&!h&&p(`flatMap`,TypeError),_=d||m||h||g,v=c(function(){for(var e=this.iterator,t=this.mapper,n,i;;){if(i=this.inner)try{if(n=a(r(i.next,i.iterator)),!n.done)return n.value;this.inner=null}catch(t){l(e,`throw`,t)}if(n=a(r(this.next,e)),this.done=!!n.done)return;try{this.inner=s(t(n.value,this.counter++),!1)}catch(t){l(e,`throw`,t)}}});n({target:`Iterator`,proto:!0,real:!0,forced:_},{flatMap:function(e){a(this);try{i(e)}catch(e){l(this,`throw`,e)}return g?r(g,this,e):new v(o(this),{mapper:e,inner:null})}})}),Di=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=hn(),i=_t(),a=Et(),o=Cn(),s=er(),c=zt(),l=$n(),u=tr(),d=nr(),f=Kn(),p=!f&&!u(`map`,function(){}),m=!f&&!p&&d(`map`,TypeError),h=f||p||m,g=s(function(){var e=this.iterator,t=a(r(this.next,e));if(!(this.done=!!t.done))return c(e,this.mapper,[t.value,this.counter++],!0)});n({target:`Iterator`,proto:!0,real:!0,forced:h},{map:function(e){a(this);try{i(e)}catch(e){l(this,`throw`,e)}return m?r(m,this,e):new g(o(this),{mapper:e})}})}),Oi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=hn(),i=Xn(),a=_t(),o=Et(),s=Cn(),c=$n(),l=nr()(`some`,TypeError);n({target:`Iterator`,proto:!0,real:!0,forced:l},{some:function(e){o(this);try{a(e)}catch(e){c(this,`throw`,e)}if(l)return r(l,this,e);var t=s(this),n=0;return i(t,function(t,r){if(e(t,n++))return r()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),ki=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=Qt(),i=kn(),a=Sn(),o=yn(),s=hn(),c=Vn(),l=Wn(),u=zn(),d=An(),f=oi(),p=ar(),m=qt(),h=dn(),g=Er(),_=qr(),v=i.JSON,y=i.Number,b=i.SyntaxError,x=v&&v.parse,S=a(`Object`,`keys`),C=Object.getOwnPropertyDescriptor,w=o(``.charAt),T=o(``.slice),E=o(/./.exec),D=o([].push),O=/^\d$/,k=/^[1-9]$/,A=/^[\d-]$/,j=/^[\t\n\r ]$/,M=0,ee=1,N=function(e,t){e=f(e);var n=new te(e,0),r=n.parse(),i=r.value,a=n.skip(j,r.end);if(a<e.length)throw new b(`Unexpected extra character: "`+w(e,a)+`" after the parsed data at: `+a);return c(t)?P({"":i},``,t,r):i},P=function(e,t,n,r){var i=e[t],a=r&&i===r.value,o=a&&typeof r.source==`string`?{source:r.source}:{},c,f,m,h,g;if(l(i)){var _=u(i),v=a?r.nodes:_?[]:{};if(_)for(c=v.length,m=p(i),h=0;h<m;h++)F(i,h,P(i,``+h,n,h<c?v[h]:void 0));else for(f=S(i),m=p(f),h=0;h<m;h++)g=f[h],F(i,g,P(i,g,n,d(v,g)?v[g]:void 0))}return s(n,e,t,i,o)},F=function(e,t,n){if(r){var i=C(e,t);if(i&&!i.configurable)return}n===void 0?delete e[t]:m(e,t,n)},I=function(e,t,n,r){this.value=e,this.end=t,this.source=n,this.nodes=r},te=function(e,t){this.source=e,this.index=t};te.prototype={fork:function(e){return new te(this.source,e)},parse:function(){var e=this.source,t=this.skip(j,this.index),n=this.fork(t),r=w(e,t);if(E(A,r))return n.number();switch(r){case`{`:return n.object();case`[`:return n.array();case`"`:return n.string();case`t`:return n.keyword(!0);case`f`:return n.keyword(!1);case`n`:return n.keyword(null)}throw new b(`Unexpected character: "`+r+`" at: `+t)},node:function(e,t,n,r,i){return new I(t,r,e?null:T(this.source,n,r),i)},object:function(){for(var e=this.source,t=this.index+1,n=!1,r={},i={},a=!1;t<e.length;){if(t=this.until([`"`,`}`],t),w(e,t)===`}`&&!n){t++,a=!0;break}var o=this.fork(t).string(),s=o.value;t=o.end,t=this.until([`:`],t)+1,t=this.skip(j,t),o=this.fork(t).parse(),m(i,s,o),m(r,s,o.value),t=this.until([`,`,`}`],o.end);var c=w(e,t);if(c===`,`)n=!0,t++;else if(c===`}`){t++,a=!0;break}}if(!a)throw new b(`Unterminated object at: `+t);return this.node(ee,r,this.index,t,i)},array:function(){for(var e=this.source,t=this.index+1,n=!1,r=[],i=[],a=!1;t<e.length;){if(t=this.skip(j,t),w(e,t)===`]`&&!n){t++,a=!0;break}var o=this.fork(t).parse();if(D(i,o),D(r,o.value),t=this.until([`,`,`]`],o.end),w(e,t)===`,`)n=!0,t++;else if(w(e,t)===`]`){t++,a=!0;break}}if(!a)throw new b(`Unterminated array at: `+t);return this.node(ee,r,this.index,t,i)},string:function(){var e=this.index,t=g(this.source,this.index+1);return this.node(M,t.value,e,t.end)},number:function(){var e=this.source,t=this.index,n=t;if(w(e,n)===`-`&&n++,w(e,n)===`0`)n++;else if(E(k,w(e,n)))n=this.skip(O,n+1);else throw new b(`Failed to parse number at: `+n);if(w(e,n)===`.`){var r=n+1;if(n=this.skip(O,r),r===n)throw new b(`Failed to parse number's fraction at: `+n)}if(w(e,n)===`e`||w(e,n)===`E`){n++,(w(e,n)===`+`||w(e,n)===`-`)&&n++;var i=n;if(n=this.skip(O,n),i===n)throw new b(`Failed to parse number's exponent value at: `+n)}return this.node(M,y(T(e,t,n)),t,n)},keyword:function(e){var t=``+e,n=this.index,r=n+t.length;if(T(this.source,n,r)!==t)throw new b(`Failed to parse value at: `+n);return this.node(M,e,n,r)},skip:function(e,t){for(var n=this.source;t<n.length&&E(e,w(n,t));t++);return t},until:function(e,t){t=this.skip(j,t);for(var n=w(this.source,t),r=0;r<e.length;r++)if(e[r]===n)return t;throw new b(`Unexpected character: "`+n+`" at: `+t)}};var ne=h(function(){var e=`9007199254740993`,t;return x(e,function(e,n,r){t=r.source}),t!==e}),re=_&&!h(function(){return 1/x(`-0 `)!=-1/0});n({target:`JSON`,stat:!0,forced:ne},{parse:function(e,t){return re&&!c(t)?x(e):N(e,t)}})}),Ai=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=Sn(),i=hn(),a=yn(),o=dn(),s=zn(),c=Vn(),l=Wn(),u=fr(),d=qn(),f=Jn(),p=Bt(),m=Jr(),h=Ft().includes,g=An(),_=oi(),v=Er(),y=ci(),b=qr(),x=cr(),S=String,C=TypeError,w=r(`JSON`,`stringify`),T=r(`BigInt`),E=a(``.valueOf),D=a((!0).valueOf),O=T&&a(T.prototype.valueOf),k=a(/./.exec),A=a(``.charAt),j=a(``.charCodeAt),M=a(``.replace),ee=a(``.slice),N=a([].push),P=a([].pop),F=a(1.1.toString),I=/[\uD800-\uDFFF]/g,te=/^[\uD800-\uDBFF]$/,ne=/^[\uDC00-\uDFFF]$/,re=/^\d+$/,L=y(),ie=y(),ae=y(),R=L.length,oe=ie.length,se=!b||o(function(){var e=r(`Symbol`)(`stringify detection`);return w([e])!==`[null]`||w({a:e})!==`{}`||w(Object(e))!==`{}`}),ce=o(function(){return w(`\udf06\ud834`)!==`"\\udf06\\ud834"`||w(`\udead`)!==`"\\udead"`}),z=x?r(`JSON`,`isRawJSON`):d,le=se?function(e,t,n){return w(e,function(e,n){var r=i(t,this,e,n);if(!f(r))return r},n)}:w,B=function(e,t,n){var r=A(n,t-1),i=A(n,t+1);return k(te,e)&&!k(ne,i)||k(ne,e)&&!k(te,r)?`\\u`+F(j(e,0),16):e},V=function(e){if(s(e)){for(var t=e.length,n=[],r=u(null),i=0;i<t;i++){var a=e[i],o;if(typeof a==`string`)o=a;else if(typeof a==`number`||p(a)===`Number`||p(a)===`String`)o=_(a);else continue;g(r,o)||(r[o]=!0,N(n,o))}return n}},H=function(e,t){try{return e(t),!0}catch{return!1}},U=function(e){var t=p(e);return t===`Number`&&H(m,e)||t===`String`&&H(E,e)||t===`Boolean`&&H(D,e)||!!O&&t===`BigInt`&&H(O,e)},ue=function(e){if(!l(e)||c(e)||s(e))return!1;try{return!U(e)}catch{return!0}},de=function(e,t){return{toJSON:function(){var n=e[t];if(l(n)||typeof n==`bigint`){var r=n.toJSON;c(r)&&(n=i(r,n,t))}return n}}},fe=function(e){for(var t=0,n=e.length;t<n;t++)if(k(re,e[t]))return ie;return``},W=function(e,t,n){for(var r=u(null),i=0,a=t.length;i<a;i++){var o=t[i];r[n+o]=de(e,o)}return r[ae]=null,r};w&&n({target:`JSON`,stat:!0,arity:3,forced:se||ce||!x},{stringify:function(e,t,n){var r=c(t)?t:void 0,a=r?void 0:V(t),o=a&&fe(a),l=[],u=[],d=[],f,p=!1,m=!0,g=le(e,function(e,t){if(e=S(e),a){if(e===ae){P(u),f=P(d);return}if(m)m=!1;else if(this!==f&&!s(this)&&!h(a,e))return}else r&&(t=i(r,this,e,t));if(z(t))return x?t:(p=!0,L+(N(l,t.rawJSON)-1));if(a&&ue(t)){if(h(u,t))throw new C(`Converting circular structure to JSON`);var n=W(t,a,o);return N(u,t),N(d,f),f=n,o&&(p=!0),n}return t},n);if(typeof g!=`string`||(ce&&(g=M(g,I,B)),!p))return g;for(var _=``,y=g.length,b=0;b<y;b++){var w=A(g,b);if(w===`"`){var T=v(g,++b).end-1,E=ee(g,b,T);ee(E,0,R)===L?_+=l[ee(E,R)]:ee(E,0,oe)===ie?_+=`"`+ee(E,oe)+`"`:_+=`"`+E+`"`,b=T}else _+=w}return _}})}),ji=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=_t(),i=sr(),a=Kn(),o=i.get,s=i.has,c=i.set;n({target:`Map`,proto:!0,real:!0,forced:a},{getOrInsertComputed:function(e,t){var n=s(this,e);if(r(t),n)return o(this,e);e===0&&1/e==-1/0&&(e=0);var i=t(e);return c(this,e,i),i}})}),Mi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=sr(),i=Kn(),a=r.get,o=r.has,s=r.set;n({target:`Map`,proto:!0,real:!0,forced:i},{getOrInsert:function(e,t){return o(this,e)?a(this,e):(s(this,e,t),t)}})}),Ni=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=kn(),i=fn(),a=Lt(),o=Or(),s=lr(),c=_t(),l=Dr(),u=dn(),d=r.Promise,f=!1;n({target:`Promise`,stat:!0,forced:!d||!d.try||u(function(){var e=d.resolve();return d.try(function(t){return f=t===8,e},8)!==e})||!f},{try:function(e){var t=arguments.length>1?a(arguments,1):[],n=l(function(){return i(c(e),void 0,t)});if(!n.error)return o(this,n.value);var r=s.f(this),u=r.reject;return u(n.value),r.promise}})}),Pi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=lr();n({target:`Promise`,stat:!0},{withResolvers:function(){var e=r.f(this);return{promise:e.promise,resolve:e.resolve,reject:e.reject}}})}),Fi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=jr(),i=dn();n({target:`Set`,proto:!0,real:!0,forced:!Rr()(`difference`,function(e){return e.size===0})||i(function(){var e={size:1,has:function(){return!0},keys:function(){var e=0;return{next:function(){var n=e++>1;return t.has(1)&&t.clear(),{done:n,value:2}}}}},t=/* @__PURE__ */ new Set([1,2,3,4]);return t.difference(e).size!==3})},{difference:r})}),Ii=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=dn(),i=Nr();n({target:`Set`,proto:!0,real:!0,forced:!Rr()(`intersection`,function(e){return e.size===2&&e.has(1)&&e.has(2)})||r(function(){return String(Array.from((/* @__PURE__ */ new Set([1,2,3])).intersection(/* @__PURE__ */ new Set([3,2]))))!==`3,2`})},{intersection:i})}),Li=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=Pr();n({target:`Set`,proto:!0,real:!0,forced:!Rr()(`isDisjointFrom`,function(e){return!e})},{isDisjointFrom:r})}),Ri=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=Fr();n({target:`Set`,proto:!0,real:!0,forced:!Rr()(`isSubsetOf`,function(e){return e})},{isSubsetOf:r})}),zi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=Ir();n({target:`Set`,proto:!0,real:!0,forced:!Rr()(`isSupersetOf`,function(e){return!e})},{isSupersetOf:r})}),Bi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=Vr(),i=zr();n({target:`Set`,proto:!0,real:!0,forced:!Rr()(`symmetricDifference`)||!i(`symmetricDifference`)},{symmetricDifference:r})}),Vi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=Hr(),i=zr();n({target:`Set`,proto:!0,real:!0,forced:!Rr()(`union`)||!i(`union`)},{union:r})}),Hi=/*#__PURE__*/ z.cw(function(e,t){var n=ar(),r=Nt(),i=r.aTypedArray,a=r.exportTypedArrayMethod,o=r.getTypedArrayConstructor;a(`toReversed`,function(){for(var e=i(this),t=n(e),r=new(o(e))(t),a=0;a<t;a++)r[a]=e[t-a-1];return r})}),Ui=/*#__PURE__*/ z.cw(function(e,t){var n=Nt(),r=yn(),i=_t(),a=Pt(),o=n.aTypedArray,s=n.getTypedArrayConstructor,c=n.exportTypedArrayMethod,l=r(n.TypedArrayPrototype.sort);c(`toSorted`,function(e){e!==void 0&&i(e);var t=o(this);return l(a(s(t),t),e)})}),Wi=/*#__PURE__*/ z.cw(function(e,t){var n=Nt(),r=Bn(),i=ar(),a=$r(),o=Xr(),s=n.aTypedArray,c=n.getTypedArrayConstructor,l=n.exportTypedArrayMethod,u=RangeError,d=function(){try{(/* @__PURE__ */ new Int8Array(1)).with(2,{valueOf:function(){throw 8}})}catch(e){return e===8}}(),f=d&&function(){try{(/* @__PURE__ */ new Int8Array(1)).with(-.5,1)}catch{return!0}}();l(`with`,{with:function(e,t){var n=s(this),l=i(n),d=a(e),f=d<0?l+d:d,p=r(n)?o(t):+t;if(f>=l||f<0)throw new u(`Incorrect index`);for(var m=new(c(n))(l),h=0;h<l;h++)m[h]=h===f?p:n[h];return m}}.with,!d||f)}),Gi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=kn(),i=Pt(),a=li(),o=r.Uint8Array,s=!o||!o.fromBase64||!function(){try{o.fromBase64(`a`);return}catch{}try{o.fromBase64(``,null)}catch{return!0}}();o&&n({target:`Uint8Array`,stat:!0,forced:s},{fromBase64:function(e){return i(o,a(e,arguments.length>1?arguments[1]:void 0,null,9007199254740991).bytes)}})}),Ki=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=kn(),i=li(),a=Dt(),o=r.Uint8Array,s=!o||!o.prototype.setFromBase64||!function(){var e=new o([255,255,255,255,255]);try{e.setFromBase64(``,null);return}catch{}try{e.setFromBase64(`a`);return}catch{}try{e.setFromBase64(`MjYyZg===`)}catch{return e[0]===50&&e[1]===54&&e[2]===50&&e[3]===255&&e[4]===255}}();o&&n({target:`Uint8Array`,proto:!0,forced:s},{setFromBase64:function(e){a(this);var t=i(e,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:t.read,written:t.written}}})}),qi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=kn(),i=bt(),a=Dt(),o=jt(),s=ui();function c(){try{new Uint8Array(new ArrayBuffer(16,{maxByteLength:1024})).setFromHex(`cafed00d`)}catch{return!0}}r.Uint8Array&&n({target:`Uint8Array`,proto:!0,forced:c()},{setFromHex:function(e){a(this),i(e),o(this.buffer);var t=s(e,this).read;return{read:t,written:t/2}}})}),Ji=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=kn(),i=yn(),a=Tt(),o=Dt(),s=jt(),c=Rt(),l=bn(),u=c.i2c,d=c.i2cUrl,f=Math.floor,p=Math.ceil,m=i(``.charAt),h=r.Uint8Array,g=r.Array,_=i([].join),v=!h||!h.prototype.toBase64||!function(){try{new h().toBase64(null)}catch{return!0}}();h&&n({target:`Uint8Array`,proto:!0,forced:v},{toBase64:function(){var e=o(this),t=arguments.length?a(arguments[0]):void 0,n=l(t)===`base64`?u:d,r=!!t&&!!t.omitPadding;s(this.buffer);for(var i=0,c=e.length,h=g(r?f(c/3)*4+(c%3?c%3+1:0):p(c/3)*4),v=0,y,b=function(e){return m(n,y>>6*e&63)};i+2<c;i+=3)y=(e[i]<<16)+(e[i+1]<<8)+e[i+2],h[v++]=b(3),h[v++]=b(2),h[v++]=b(1),h[v++]=b(0);return i+2===c?(y=(e[i]<<16)+(e[i+1]<<8),h[v++]=b(3),h[v++]=b(2),h[v++]=b(1),r||(h[v++]=`=`)):i+1===c&&(y=e[i]<<16,h[v++]=b(3),h[v++]=b(2),r||(h[v++]=`=`,h[v++]=`=`)),_(h,``)}})}),Yi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=kn(),i=yn(),a=Dt(),o=jt(),s=i(1.1.toString),c=i([].join),l=Array,u=r.Uint8Array,d=!u||!u.prototype.toHex||!(function(){try{return new u([255,255,255,255,255,255,255,255]).toHex()===`ffffffffffffffff`}catch{return!1}})();u&&n({target:`Uint8Array`,proto:!0,forced:d},{toHex:function(){a(this),o(this.buffer);for(var e=l(this.length),t=0,n=this.length;t<n;t++){var r=s(this[t],16);e[t]=r.length===1?`0`+r:r}return c(e,``)}})}),Xi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=_t(),i=St(),a=xt(),o=hi(),s=Kn(),c=o.get,l=o.has,u=o.set;n({target:`WeakMap`,proto:!0,real:!0,forced:s||!function(){try{WeakMap.prototype.getOrInsertComputed&&(/* @__PURE__ */ new WeakMap()).getOrInsertComputed(1,function(){throw 1})}catch(e){return e instanceof TypeError}}()},{getOrInsertComputed:function(e,t){if(s||i(this),a(e),r(t),l(this,e))return c(this,e);var n=t(e);return u(this,e,n),n}})}),Zi=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=hi(),i=Kn(),a=r.get,o=r.has,s=r.set;n({target:`WeakMap`,proto:!0,real:!0,forced:i},{getOrInsert:function(e,t){return o(this,e)?a(this,e):(s(this,e,t),t)}})}),Qi=/*#__PURE__*/ z.cw(function(e,t){ki()}),$i=/*#__PURE__*/ z.cw(function(e,t){ji()}),ea=/*#__PURE__*/ z.cw(function(e,t){Mi()}),ta=/*#__PURE__*/ z.cw(function(e,t){Gi()}),na=/*#__PURE__*/ z.cw(function(e,t){Ki()}),ra=/*#__PURE__*/ z.cw(function(e,t){qi()}),ia=/*#__PURE__*/ z.cw(function(e,t){Ji()}),aa=/*#__PURE__*/ z.cw(function(e,t){Yi()}),oa=/*#__PURE__*/ z.cw(function(e,t){Xi()}),sa=/*#__PURE__*/ z.cw(function(e,t){Zi()}),ca=/*#__PURE__*/ z.cw(function(e,t){var n=un(),r=kn(),i=Sn(),a=Kt(),o=mr().f,s=An(),c=wt(),l=Fn(),u=ur(),d=nn(),f=ln(),p=Qt(),m=Kn(),h=`DOMException`,g=i(`Error`),_=i(h),v=function(){c(this,y);var e=arguments.length,t=u(e<1?void 0:arguments[0]),n=new _(t,u(e<2?void 0:arguments[1],`Error`)),r=new g(t);return r.name=h,o(n,`stack`,a(1,f(r.stack,1))),l(n,this,v),n},y=v.prototype=_.prototype,b=`stack`in new g(h),x=`stack`in new _(1,2),S=_&&p&&Object.getOwnPropertyDescriptor(r,h),C=!!S&&!(S.writable&&S.configurable),w=b&&!C&&!x;n({global:!0,constructor:!0,forced:m||w},{DOMException:w?v:_});var T=i(h),E=T.prototype;if(E.constructor!==T){for(var D in m||o(E,`constructor`,a(1,T)),d)if(s(d,D)){var O=d[D],k=O.s;s(T,k)||o(T,k,a(6,O.c))}}}),la=/*#__PURE__*/ z.cw(function(e,t){var n=Yt(),r=yn(),i=oi(),a=pi(),o=URLSearchParams,s=o.prototype,c=r(s.append),l=r(s.delete),u=r(s.forEach),d=r([].push),f=new o(`a=1&a=2&b=3`);f.delete(`a`,1),f.delete(`b`,void 0),f+``!=`a=2`&&n(s,`delete`,function(e){var t=arguments.length,n=t<2?void 0:arguments[1];if(t&&n===void 0)return l(this,e);var r=[];u(this,function(e,t){d(r,{key:t,value:e})}),a(t,1);for(var o=i(e),s=i(n),f=0,p=r.length,m;f<p;)m=r[f],l(this,m.key),f++;for(f=0;f<p;)m=r[f++],(m.key!==o||m.value!==s)&&c(this,m.key,m.value)},{enumerable:!0,unsafe:!0})}),ua=/*#__PURE__*/ z.cw(function(e,t){var n=Yt(),r=yn(),i=oi(),a=pi(),o=URLSearchParams,s=o.prototype,c=r(s.getAll),l=r(s.has),u=new o(`a=1`);(u.has(`a`,2)||!u.has(`a`,void 0))&&n(s,`has`,function(e){var t=arguments.length,n=t<2?void 0:arguments[1];if(t&&n===void 0)return l(this,e);var r=c(this,e);a(t,1);for(var o=i(n),s=0;s<r.length;)if(r[s++]===o)return!0;return!1},{enumerable:!0,unsafe:!0})}),da=/*#__PURE__*/ z.cw(function(e,t){var n=Qt(),r=yn(),i=Jt(),a=URLSearchParams.prototype,o=r(a.forEach);n&&!(`size`in a)&&i(a,`size`,{get:function(){var e=0;return o(this,function(){e++}),e},configurable:!0,enumerable:!0})}),bi(),xi(),_i(),yi(),vi(),Ni(),Hi(),Ui(),Wi(),ea(),$i(),ta(),na(),ra(),ia(),aa(),ca(),la(),ua(),da(),fa=typeof process==`object`&&process+``==`[object process]`&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!==`browser`),pa=[1,0,0,1,0,0],ma=[.001,0,0,.001,0,0],ha=1e7,ga={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},_a={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},va=`pdfjs_internal_editor_`,J={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},ya={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},ba={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},xa={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},Sa={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Ca={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},wa={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Ta={ERRORS:0,WARNINGS:1,INFOS:5},Ea={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},Da={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Oa=Ta.WARNINGS,ka=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=/* @__PURE__ */ Error(),e.constructor=e,e}(),Aa=class extends ka{constructor(e,t){super(e,`PasswordException`),this.code=t}},ja=class extends ka{constructor(e,t){super(e,`UnknownErrorException`),this.details=t}},Ma=class extends ka{constructor(e){super(e,`InvalidPDFException`)}},Na=class extends ka{constructor(e){super(e,`MissingPDFException`)}},Pa=class extends ka{constructor(e,t){super(e,`UnexpectedResponseException`),this.status=t}},Fa=class extends ka{constructor(e){super(e,`FormatError`)}},Ia=class extends ka{constructor(e){super(e,`AbortException`)}},La=class{static get isLittleEndian(){return W(this,`isLittleEndian`,_e())}static get isEvalSupported(){return W(this,`isEvalSupported`,ve())}static get isOffscreenCanvasSupported(){return W(this,`isOffscreenCanvasSupported`,typeof OffscreenCanvas<`u`)}static get isImageDecoderSupported(){return W(this,`isImageDecoderSupported`,typeof ImageDecoder<`u`)}static get platform(){return typeof navigator<`u`&&typeof navigator?.platform==`string`?W(this,`platform`,{isMac:navigator.platform.includes(`Mac`),isWindows:navigator.platform.includes(`Win`),isFirefox:typeof navigator?.userAgent==`string`&&navigator.userAgent.includes(`Firefox`)}):W(this,`platform`,{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return W(this,`isCSSRoundSupported`,globalThis.CSS?.supports?.(`width: round(1.5px, 1px)`))}},Ra=Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,`0`)),Y=class{static makeHexColor(e,t,n){return`#${Ra[e]}${Ra[t]}${Ra[n]}`}static scaleMinMax(e,t){let n;e[0]?(e[0]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[3],t[3]*=e[3]):(n=t[0],t[0]=t[1],t[1]=n,n=t[2],t[2]=t[3],t[3]=n,e[1]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[2],t[2]*=e[2]),t[0]+=e[4],t[1]+=e[5],t[2]+=e[4],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){let n=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){let n=this.applyTransform(e,t),r=this.applyTransform(e.slice(2,4),t),i=this.applyTransform([e[0],e[3]],t),a=this.applyTransform([e[2],e[1]],t);return[Math.min(n[0],r[0],i[0],a[0]),Math.min(n[1],r[1],i[1],a[1]),Math.max(n[0],r[0],i[0],a[0]),Math.max(n[1],r[1],i[1],a[1])]}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){let t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],r=e[0]*t[1]+e[1]*t[3],i=e[2]*t[0]+e[3]*t[2],a=e[2]*t[1]+e[3]*t[3],o=(n+a)/2,s=Math.sqrt((n+a)**2-4*(n*a-i*r))/2,c=o+s||1,l=o-s||1;return[Math.sqrt(c),Math.sqrt(l)]}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>r)return null;let i=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return i>a?null:[n,i,r,a]}static#e(e,t,n,r,i,a,o,s,c,l){if(c<=0||c>=1)return;let u=1-c,d=c*c,f=d*c,p=u*(u*(u*e+3*c*t)+3*d*n)+f*r,m=u*(u*(u*i+3*c*a)+3*d*o)+f*s;l[0]=Math.min(l[0],p),l[1]=Math.min(l[1],m),l[2]=Math.max(l[2],p),l[3]=Math.max(l[3],m)}static#t(e,t,n,r,i,a,o,s,c,l,u,d){if(Math.abs(c)<1e-12){Math.abs(l)>=1e-12&&this.#e(e,t,n,r,i,a,o,s,-u/l,d);return}let f=l**2-4*u*c;if(f<0)return;let p=Math.sqrt(f),m=2*c;this.#e(e,t,n,r,i,a,o,s,(-l+p)/m,d),this.#e(e,t,n,r,i,a,o,s,(-l-p)/m,d)}static bezierBoundingBox(e,t,n,r,i,a,o,s,c){return c?(c[0]=Math.min(c[0],e,o),c[1]=Math.min(c[1],t,s),c[2]=Math.max(c[2],e,o),c[3]=Math.max(c[3],t,s)):c=[Math.min(e,o),Math.min(t,s),Math.max(e,o),Math.max(t,s)],this.#t(e,n,i,o,t,r,a,s,3*(-e+3*(n-i)+o),6*(e-2*n+i),3*(n-e),c),this.#t(e,n,i,o,t,r,a,s,3*(-t+3*(r-a)+s),6*(t-2*r+a),3*(r-t),c),c}},za=null,Ba=null,Va=`pdfjs_internal_id_`,Si(),Di(),Pi(),Fi(),Ii(),Li(),Ri(),zi(),Bi(),Vi(),sa(),oa(),Ai(),Ci(),wi(),Oi(),Qi(),Ha=`http://www.w3.org/2000/svg`,Ua=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF},Wa=class e{constructor({viewBox:e,userUnit:t,scale:n,rotation:r,offsetX:i=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=t,this.scale=n,this.rotation=r,this.offsetX=i,this.offsetY=a,n*=t;let s=(e[2]+e[0])/2,c=(e[3]+e[1])/2,l,u,d,f;switch(r%=360,r<0&&(r+=360),r){case 180:l=-1,u=0,d=0,f=1;break;case 90:l=0,u=1,d=1,f=0;break;case 270:l=0,u=-1,d=-1,f=0;break;case 0:l=1,u=0,d=0,f=-1;break;default:throw Error(`PageViewport: Invalid rotation, must be a multiple of 90 degrees.`)}o&&(d=-d,f=-f);let p,m,h,g;l===0?(p=Math.abs(c-e[1])*n+i,m=Math.abs(s-e[0])*n+a,h=(e[3]-e[1])*n,g=(e[2]-e[0])*n):(p=Math.abs(s-e[0])*n+i,m=Math.abs(c-e[1])*n+a,h=(e[2]-e[0])*n,g=(e[3]-e[1])*n),this.transform=[l*n,u*n,d*n,f*n,p-l*n*s-d*n*c,m-u*n*s-f*n*c],this.width=h,this.height=g}get rawDims(){let{userUnit:e,viewBox:t}=this,n=t.map(t=>t*e);return W(this,`rawDims`,{pageWidth:n[2]-n[0],pageHeight:n[3]-n[1],pageX:n[0],pageY:n[1]})}clone({scale:t=this.scale,rotation:n=this.rotation,offsetX:r=this.offsetX,offsetY:i=this.offsetY,dontFlip:a=!1}={}){return new e({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:n,offsetX:r,offsetY:i,dontFlip:a})}convertToViewportPoint(e,t){return Y.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){let t=Y.applyTransform([e[0],e[1]],this.transform),n=Y.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],n[0],n[1]]}convertToPdfPoint(e,t){return Y.applyInverseTransform([e,t],this.transform)}},Ga=class extends ka{constructor(e,t=0){super(e,`RenderingCancelledException`),this.extraDelay=t}},Ka=class{started=Object.create(null);times=[];time(e){e in this.started&&H(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||H(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){let e=[],t=0;for(let{name:e}of this.times)t=Math.max(e.length,t);for(let{name:n,start:r,end:i}of this.times)e.push(`${n.padEnd(t)} ${i-r}ms\n`);return e.join(``)}},qa=class{static#e;static toDateObject(e){if(!e||typeof e!=`string`)return null;this.#e||=/* @__PURE__ */ RegExp(`^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?`);let t=this.#e.exec(e);if(!t)return null;let n=parseInt(t[1],10),r=parseInt(t[2],10);r=r>=1&&r<=12?r-1:0;let i=parseInt(t[3],10);i=i>=1&&i<=31?i:1;let a=parseInt(t[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(t[5],10);o=o>=0&&o<=59?o:0;let s=parseInt(t[6],10);s=s>=0&&s<=59?s:0;let c=t[7]||`Z`,l=parseInt(t[8],10);l=l>=0&&l<=23?l:0;let u=parseInt(t[9],10)||0;return u=u>=0&&u<=59?u:0,c===`-`?(a+=l,o+=u):c===`+`&&(a-=l,o-=u),new Date(Date.UTC(n,r,i,a,o,s))}},Ja=class{constructor(){let e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}},Ya=class e{#e=null;#t=null;#n;#r=null;#i=null;static#a=null;constructor(t){this.#n=t,e.#a||=Object.freeze({freetext:`pdfjs-editor-remove-freetext-button`,highlight:`pdfjs-editor-remove-highlight-button`,ink:`pdfjs-editor-remove-ink-button`,stamp:`pdfjs-editor-remove-stamp-button`})}render(){let t=this.#e=document.createElement(`div`);t.classList.add(`editToolbar`,`hidden`),t.setAttribute(`role`,`toolbar`);let n=this.#n._uiManager._signal;t.addEventListener(`contextmenu`,Oe,{signal:n}),t.addEventListener(`pointerdown`,e.#o,{signal:n});let r=this.#r=document.createElement(`div`);r.className=`buttons`,t.append(r);let i=this.#n.toolbarPosition;if(i){let{style:e}=t;e.insetInlineEnd=`${100*(this.#n._uiManager.direction===`ltr`?1-i[0]:i[0])}%`,e.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#u(),t}get div(){return this.#e}static#o(e){e.stopPropagation()}#s(e){this.#n._focusEventsAllowed=!1,ke(e)}#c(e){this.#n._focusEventsAllowed=!0,ke(e)}#l(e){let t=this.#n._uiManager._signal;e.addEventListener(`focusin`,this.#s.bind(this),{capture:!0,signal:t}),e.addEventListener(`focusout`,this.#c.bind(this),{capture:!0,signal:t}),e.addEventListener(`contextmenu`,Oe,{signal:t})}hide(){this.#e.classList.add(`hidden`),this.#t?.hideDropdown()}show(){this.#e.classList.remove(`hidden`),this.#i?.shown()}#u(){let{editorType:t,_uiManager:n}=this.#n,r=document.createElement(`button`);r.className=`delete`,r.tabIndex=0,r.setAttribute(`data-l10n-id`,e.#a[t]),this.#l(r),r.addEventListener(`click`,e=>{n.delete()},{signal:n._signal}),this.#r.append(r)}get#d(){let e=document.createElement(`div`);return e.className=`divider`,e}async addAltText(e){let t=await e.render();this.#l(t),this.#r.prepend(t,this.#d),this.#i=e}addColorPicker(e){this.#t=e;let t=e.renderButton();this.#l(t),this.#r.prepend(t,this.#d)}remove(){this.#e.remove(),this.#t?.destroy(),this.#t=null}},Xa=class{#e=null;#t=null;#n;constructor(e){this.#n=e}#r(){let e=this.#t=document.createElement(`div`);e.className=`editToolbar`,e.setAttribute(`role`,`toolbar`),e.addEventListener(`contextmenu`,Oe,{signal:this.#n._signal});let t=this.#e=document.createElement(`div`);return t.className=`buttons`,e.append(t),this.#a(),e}#i(e,t){let n=0,r=0;for(let i of e){let e=i.y+i.height;if(e<n)continue;let a=i.x+(t?i.width:0);e>n?(r=a,n=e):t?a>r&&(r=a):a<r&&(r=a)}return[t?1-r:r,n]}show(e,t,n){let[r,i]=this.#i(t,n),{style:a}=this.#t||=this.#r();e.append(this.#t),a.insetInlineEnd=`${100*r}%`,a.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){this.#t.remove()}#a(){let e=document.createElement(`button`);e.className=`highlightButton`,e.tabIndex=0,e.setAttribute(`data-l10n-id`,`pdfjs-highlight-floating-button1`);let t=document.createElement(`span`);e.append(t),t.className=`visuallyHidden`,t.setAttribute(`data-l10n-id`,`pdfjs-highlight-floating-button-label`);let n=this.#n._signal;e.addEventListener(`contextmenu`,Oe,{signal:n}),e.addEventListener(`click`,()=>{this.#n.highlightSelection(`floating_button`)},{signal:n}),this.#e.append(e)}},Za=class{#e=0;get id(){return`${va}${this.#e++}`}},Qa=class e{#e=xe();#t=0;#n=null;static get _isSVGFittingCanvas(){let e=new OffscreenCanvas(1,3).getContext(`2d`,{willReadFrequently:!0}),t=new Image;t.src=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>`;let n=t.decode().then(()=>(e.drawImage(t,0,0,1,1,0,0,1,3),new Uint32Array(e.getImageData(0,0,1,1).data.buffer)[0]===0));return W(this,`_isSVGFittingCanvas`,n)}async#r(t,n){this.#n||=/* @__PURE__ */ new Map;let r=this.#n.get(t);if(r===null)return null;if(r?.bitmap)return r.refCounter+=1,r;try{r||={bitmap:null,id:`image_${this.#e}_${this.#t++}`,refCounter:0,isSvg:!1};let t;if(typeof n==`string`?(r.url=n,t=await Ce(n,`blob`)):n instanceof File?t=r.file=n:n instanceof Blob&&(t=n),t.type===`image/svg+xml`){let n=e._isSVGFittingCanvas,i=new FileReader,a=new Image,o=new Promise((e,t)=>{a.onload=()=>{r.bitmap=a,r.isSvg=!0,e()},i.onload=async()=>{let e=r.svgUrl=i.result;a.src=await n?`${e}#svgView(preserveAspectRatio(none))`:e},a.onerror=i.onerror=t});i.readAsDataURL(t),await o}else r.bitmap=await createImageBitmap(t);r.refCounter=1}catch(e){H(e),r=null}return this.#n.set(t,r),r&&this.#n.set(r.id,r),r}async getFromFile(e){let{lastModified:t,name:n,size:r,type:i}=e;return this.#r(`${t}_${n}_${r}_${i}`,e)}async getFromUrl(e){return this.#r(e,e)}async getFromBlob(e,t){let n=await t;return this.#r(e,n)}async getFromId(e){this.#n||=/* @__PURE__ */ new Map;let t=this.#n.get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){let{blobPromise:e}=t;return delete t.blobPromise,this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){this.#n||=/* @__PURE__ */ new Map;let n=this.#n.get(e);if(n?.bitmap)return n.refCounter+=1,n;let r=new OffscreenCanvas(t.width,t.height);return r.getContext(`2d`).drawImage(t,0,0),n={bitmap:r.transferToImageBitmap(),id:`image_${this.#e}_${this.#t++}`,refCounter:1,isSvg:!1},this.#n.set(e,n),this.#n.set(n.id,n),n}getSvgUrl(e){let t=this.#n.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#n||=/* @__PURE__ */ new Map;let t=this.#n.get(e);if(!t||(--t.refCounter,t.refCounter!==0))return;let{bitmap:n}=t;if(!t.url&&!t.file){let e=new OffscreenCanvas(n.width,n.height);e.getContext(`bitmaprenderer`).transferFromImageBitmap(n),t.blobPromise=e.convertToBlob()}n.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#e}_`)}},$a=class{#e=[];#t=!1;#n;#r=-1;constructor(e=128){this.#n=e}add({cmd:e,undo:t,post:n,mustExec:r,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(r&&e(),this.#t)return;let s={cmd:e,undo:t,post:n,type:i};if(this.#r===-1){this.#e.length>0&&(this.#e.length=0),this.#r=0,this.#e.push(s);return}if(a&&this.#e[this.#r].type===i){o&&(s.undo=this.#e[this.#r].undo),this.#e[this.#r]=s;return}let c=this.#r+1;c===this.#n?this.#e.splice(0,1):(this.#r=c,c<this.#e.length&&this.#e.splice(c)),this.#e.push(s)}undo(){if(this.#r===-1)return;this.#t=!0;let{undo:e,post:t}=this.#e[this.#r];e(),t?.(),this.#t=!1,--this.#r}redo(){if(this.#r<this.#e.length-1){this.#r+=1,this.#t=!0;let{cmd:e,post:t}=this.#e[this.#r];e(),t?.(),this.#t=!1}}hasSomethingToUndo(){return this.#r!==-1}hasSomethingToRedo(){return this.#r<this.#e.length-1}cleanType(e){if(this.#r!==-1){for(let t=this.#r;t>=0;t--)if(this.#e[t].type!==e){this.#e.splice(t+1,this.#r-t),this.#r=t;return}this.#e.length=0,this.#r=-1}}destroy(){this.#e=null}},eo=class{constructor(e){this.buffer=[],this.callbacks=/* @__PURE__ */ new Map,this.allKeys=/* @__PURE__ */ new Set;let{isMac:t}=La.platform;for(let[n,r,i={}]of e)for(let e of n){let n=e.startsWith(`mac+`);t&&n?(this.callbacks.set(e.slice(4),{callback:r,options:i}),this.allKeys.add(e.split(`+`).at(-1))):!t&&!n&&(this.callbacks.set(e,{callback:r,options:i}),this.allKeys.add(e.split(`+`).at(-1)))}}#e(e){e.altKey&&this.buffer.push(`alt`),e.ctrlKey&&this.buffer.push(`ctrl`),e.metaKey&&this.buffer.push(`meta`),e.shiftKey&&this.buffer.push(`shift`),this.buffer.push(e.key);let t=this.buffer.join(`+`);return this.buffer.length=0,t}exec(e,t){if(!this.allKeys.has(t.key))return;let n=this.callbacks.get(this.#e(t));if(!n)return;let{callback:r,options:{bubbles:i=!1,args:a=[],checker:o=null}}=n;(!o||o(e,t))&&(r.bind(e,...a,t)(),i||ke(t))}},to=class e{static _colorsMapping=/* @__PURE__ */ new Map([[`CanvasText`,[0,0,0]],[`Canvas`,[255,255,255]]]);get _colors(){let e=/* @__PURE__ */ new Map([[`CanvasText`,null],[`Canvas`,null]]);return Me(e),W(this,`_colors`,e)}convert(t){let n=je(t);if(!window.matchMedia(`(forced-colors: active)`).matches)return n;for(let[t,r]of this._colors)if(r.every((e,t)=>e===n[t]))return e._colorsMapping.get(t);return n}getHexCode(e){let t=this._colors.get(e);return t?Y.makeHexColor(...t):e}},no=class e{#e=new AbortController;#t=null;#n=/* @__PURE__ */ new Map;#r=/* @__PURE__ */ new Map;#i=null;#a=null;#o=null;#s=new $a;#c=null;#l=null;#u=0;#d=/* @__PURE__ */ new Set;#f=null;#p=null;#m=/* @__PURE__ */ new Set;_editorUndoBar=null;#h=!1;#g=!1;#_=!1;#v=null;#y=null;#b=null;#x=null;#S=!1;#C=null;#w=new Za;#T=!1;#E=!1;#D=null;#O=null;#k=null;#A=null;#j=J.NONE;#M=/* @__PURE__ */ new Set;#N=null;#P=null;#F=null;#I={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#L=[0,0];#R=null;#z=null;#B=null;#V=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=e.prototype,n=e=>e.#z.contains(document.activeElement)&&document.activeElement.tagName!==`BUTTON`&&e.hasSomethingToControl(),r=(e,{target:t})=>{if(t instanceof HTMLInputElement){let{type:e}=t;return e!==`text`&&e!==`number`}return!0},i=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return W(this,`_keyboardManager`,new eo([[[`ctrl+a`,`mac+meta+a`],t.selectAll,{checker:r}],[[`ctrl+z`,`mac+meta+z`],t.undo,{checker:r}],[[`ctrl+y`,`ctrl+shift+z`,`mac+meta+shift+z`,`ctrl+shift+Z`,`mac+meta+shift+Z`],t.redo,{checker:r}],[[`Backspace`,`alt+Backspace`,`ctrl+Backspace`,`shift+Backspace`,`mac+Backspace`,`mac+alt+Backspace`,`mac+ctrl+Backspace`,`Delete`,`ctrl+Delete`,`shift+Delete`,`mac+Delete`],t.delete,{checker:r}],[[`Enter`,`mac+Enter`],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#z.contains(t)&&!e.isEnterHandled}],[[` `,`mac+ `],t.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#z.contains(document.activeElement)}],[[`Escape`,`mac+Escape`],t.unselectAll],[[`ArrowLeft`,`mac+ArrowLeft`],t.translateSelectedEditors,{args:[-i,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t.translateSelectedEditors,{args:[-a,0],checker:n}],[[`ArrowRight`,`mac+ArrowRight`],t.translateSelectedEditors,{args:[i,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t.translateSelectedEditors,{args:[a,0],checker:n}],[[`ArrowUp`,`mac+ArrowUp`],t.translateSelectedEditors,{args:[0,-i],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t.translateSelectedEditors,{args:[0,-a],checker:n}],[[`ArrowDown`,`mac+ArrowDown`],t.translateSelectedEditors,{args:[0,i],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t.translateSelectedEditors,{args:[0,a],checker:n}]]))}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f){let p=this._signal=this.#e.signal;this.#z=e,this.#B=t,this.#i=n,this._eventBus=r,r._on(`editingaction`,this.onEditingAction.bind(this),{signal:p}),r._on(`pagechanging`,this.onPageChanging.bind(this),{signal:p}),r._on(`scalechanging`,this.onScaleChanging.bind(this),{signal:p}),r._on(`rotationchanging`,this.onRotationChanging.bind(this),{signal:p}),r._on(`setpreference`,this.onSetPreference.bind(this),{signal:p}),r._on(`switchannotationeditorparams`,e=>this.updateParams(e.type,e.value),{signal:p}),this.#q(),this.#ee(),this.#X(),this.#a=i.annotationStorage,this.#v=i.filterFactory,this.#P=a,this.#x=o||null,this.#h=s,this.#g=c,this.#_=l,this.#A=u||null,this.viewParameters={realScale:Ua.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=d||null,this._supportsPinchToZoom=f!==!1}destroy(){this.#V?.resolve(),this.#V=null,this.#e?.abort(),this.#e=null,this._signal=null;for(let e of this.#r.values())e.destroy();this.#r.clear(),this.#n.clear(),this.#m.clear(),this.#t=null,this.#M.clear(),this.#s.destroy(),this.#i?.destroy(),this.#C?.hide(),this.#C=null,this.#y&&=(clearTimeout(this.#y),null),this.#R&&=(clearTimeout(this.#R),null),this._editorUndoBar?.destroy()}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#A}get useNewAltTextFlow(){return this.#g}get useNewAltTextWhenAddingImage(){return this.#_}get hcmFilter(){return W(this,`hcmFilter`,this.#P?this.#v.addHCMFilter(this.#P.foreground,this.#P.background):`none`)}get direction(){return W(this,`direction`,getComputedStyle(this.#z).direction)}get highlightColors(){return W(this,`highlightColors`,this.#x?new Map(this.#x.split(`,`).map(e=>e.split(`=`).map(e=>e.trim()))):null)}get highlightColorNames(){return W(this,`highlightColorNames`,this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#l=e}setMainHighlightColorPicker(e){this.#k=e}editAltText(e,t=!1){this.#i?.editAltText(this,e,t)}switchToMode(e,t){this._eventBus.on(`annotationeditormodechanged`,t,{once:!0,signal:this._signal}),this._eventBus.dispatch(`showannotationeditorui`,{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch(`setpreference`,{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){e===`enableNewAltTextWhenAddingImage`&&(this.#_=t)}onPageChanging({pageNumber:e}){this.#u=e-1}focusMainContainer(){this.#z.focus()}findParent(e,t){for(let n of this.#r.values()){let{x:r,y:i,width:a,height:o}=n.div.getBoundingClientRect();if(e>=r&&e<=r+a&&t>=i&&t<=i+o)return n}return null}disableUserSelect(e=!1){this.#B.classList.toggle(`noUserSelect`,e)}addShouldRescale(e){this.#m.add(e)}removeShouldRescale(e){this.#m.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*Ua.PDF_TO_CSS_UNITS;for(let e of this.#m)e.onScaleChanging();this.#l?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#H({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#U(e){let{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(let t of this.#r.values())if(t.hasTextLayer(e))return t;return null}highlightSelection(e=``){let t=document.getSelection();if(!t||t.isCollapsed)return;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=t,o=t.toString(),s=this.#H(t).closest(`.textLayer`),c=this.getSelectionBoxes(s);if(!c)return;t.empty();let l=this.#U(s),u=this.#j===J.NONE,d=()=>{l?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:c,anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a,text:o}),u&&this.showAllEditors(`highlight`,!0,!0)};u?this.switchToMode(J.HIGHLIGHT,d):d()}#W(){let e=document.getSelection();if(!e||e.isCollapsed)return;let t=this.#H(e).closest(`.textLayer`),n=this.getSelectionBoxes(t);n&&(this.#C||=new Xa(this),this.#C.show(t,n,this.direction===`ltr`))}addToAnnotationStorage(e){!e.isEmpty()&&this.#a&&!this.#a.has(e.id)&&this.#a.setValue(e.id,e)}#G(){let e=document.getSelection();if(!e||e.isCollapsed){this.#N&&(this.#C?.hide(),this.#N=null,this.#te({hasSelectedText:!1}));return}let{anchorNode:t}=e;if(t===this.#N)return;let n=this.#H(e).closest(`.textLayer`);if(!n)this.#N&&(this.#C?.hide(),this.#N=null,this.#te({hasSelectedText:!1}));else if(this.#C?.hide(),this.#N=t,this.#te({hasSelectedText:!0}),(this.#j===J.HIGHLIGHT||this.#j===J.NONE)&&(this.#j===J.HIGHLIGHT&&this.showAllEditors(`highlight`,!0,!0),this.#S=this.isShiftKeyDown,!this.isShiftKeyDown)){let e=this.#j===J.HIGHLIGHT?this.#U(n):null;e?.toggleDrawing();let t=new AbortController,r=this.combinedSignal(t),i=n=>{(n.type!==`pointerup`||n.button===0)&&(t.abort(),e?.toggleDrawing(!0),n.type===`pointerup`&&this.#K(`main_toolbar`))};window.addEventListener(`pointerup`,i,{signal:r}),window.addEventListener(`blur`,i,{signal:r})}}#K(e=``){this.#j===J.HIGHLIGHT?this.highlightSelection(e):this.#h&&this.#W()}#q(){document.addEventListener(`selectionchange`,this.#G.bind(this),{signal:this._signal})}#J(){if(this.#b)return;this.#b=new AbortController;let e=this.combinedSignal(this.#b);window.addEventListener(`focus`,this.focus.bind(this),{signal:e}),window.addEventListener(`blur`,this.blur.bind(this),{signal:e})}#Y(){this.#b?.abort(),this.#b=null}blur(){if(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#K(`main_toolbar`)),!this.hasSelection)return;let{activeElement:e}=document;for(let t of this.#M)if(t.div.contains(e)){this.#O=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#O)return;let[e,t]=this.#O;this.#O=null,t.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}#X(){if(this.#D)return;this.#D=new AbortController;let e=this.combinedSignal(this.#D);window.addEventListener(`keydown`,this.keydown.bind(this),{signal:e}),window.addEventListener(`keyup`,this.keyup.bind(this),{signal:e})}#Z(){this.#D?.abort(),this.#D=null}#Q(){if(this.#c)return;this.#c=new AbortController;let e=this.combinedSignal(this.#c);document.addEventListener(`copy`,this.copy.bind(this),{signal:e}),document.addEventListener(`cut`,this.cut.bind(this),{signal:e}),document.addEventListener(`paste`,this.paste.bind(this),{signal:e})}#$(){this.#c?.abort(),this.#c=null}#ee(){let e=this._signal;document.addEventListener(`dragover`,this.dragOver.bind(this),{signal:e}),document.addEventListener(`drop`,this.drop.bind(this),{signal:e})}addEditListeners(){this.#X(),this.#Q()}removeEditListeners(){this.#Z(),this.#$()}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let n of this.#p)if(n.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect=`copy`,e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let n of this.#p)if(n.isHandlingMimeForPasting(t.type)){n.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),this.#t?.commitOrRemove(),!this.hasSelection)return;let t=[];for(let e of this.#M){let n=e.serialize(!0);n&&t.push(n)}t.length!==0&&e.clipboardData.setData(`application/pdfjs`,JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();let{clipboardData:t}=e;for(let e of t.items)for(let t of this.#p)if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}let n=t.getData(`application/pdfjs`);if(!n)return;try{n=JSON.parse(n)}catch(e){H(`paste: "${e.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();let r=this.currentLayer;try{let e=[];for(let t of n){let n=await r.deserialize(t);if(!n)return;e.push(n)}this.addCommands({cmd:()=>{for(let t of e)this.#ae(t);this.#ce(e)},undo:()=>{for(let t of e)t.remove()},mustExec:!0})}catch(e){H(`paste: "${e.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key===`Shift`&&(this.isShiftKeyDown=!0),this.#j!==J.NONE&&!this.isEditorHandlingKeyboard&&e._keyboardManager.exec(this,t)}keyup(e){this.isShiftKeyDown&&e.key===`Shift`&&(this.isShiftKeyDown=!1,this.#S&&(this.#S=!1,this.#K(`main_toolbar`)))}onEditingAction({name:e}){switch(e){case`undo`:case`redo`:case`delete`:case`selectAll`:this[e]();break;case`highlightSelection`:this.highlightSelection(`context_menu`)}}#te(e){Object.entries(e).some(([e,t])=>this.#I[e]!==t)&&(this._eventBus.dispatch(`annotationeditorstateschanged`,{source:this,details:Object.assign(this.#I,e)}),this.#j===J.HIGHLIGHT&&e.hasSelectedEditor===!1&&this.#ne([[ya.HIGHLIGHT_FREE,!0]]))}#ne(e){this._eventBus.dispatch(`annotationeditorparamschanged`,{source:this,details:e})}setEditingState(e){e?(this.#J(),this.#Q(),this.#te({isEditing:this.#j!==J.NONE,isEmpty:this.#se(),hasSomethingToUndo:this.#s.hasSomethingToUndo(),hasSomethingToRedo:this.#s.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Y(),this.#$(),this.#te({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#p){this.#p=e;for(let e of this.#p)this.#ne(e.defaultPropertiesToUpdate)}}getId(){return this.#w.id}get currentLayer(){return this.#r.get(this.#u)}getLayer(e){return this.#r.get(e)}get currentPageIndex(){return this.#u}addLayer(e){this.#r.set(e.pageIndex,e),this.#T?e.enable():e.disable()}removeLayer(e){this.#r.delete(e.pageIndex)}async updateMode(e,t=null,n=!1){if(this.#j!==e&&!(this.#V&&(await this.#V.promise,!this.#V))){if(this.#V=Promise.withResolvers(),this.#j=e,e===J.NONE)this.setEditingState(!1),this.#ie(),this._editorUndoBar?.hide(),this.#V.resolve();else{this.setEditingState(!0),await this.#re(),this.unselectAll();for(let t of this.#r.values())t.updateMode(e);if(!t)n&&this.addNewEditorFromKeyboard(),this.#V.resolve();else{for(let e of this.#n.values())e.annotationElementId===t?(this.setSelected(e),e.enterInEditMode()):e.unselect();this.#V.resolve()}}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==this.#j&&this._eventBus.dispatch(`switchannotationeditormode`,{source:this,mode:e})}updateParams(e,t){if(this.#p){switch(e){case ya.CREATE:this.currentLayer.addNewEditor();return;case ya.HIGHLIGHT_DEFAULT_COLOR:this.#k?.updateColor(t);break;case ya.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:{type:`highlight`,action:`toggle_visibility`}}}),(this.#F||=/* @__PURE__ */ new Map).set(e,t),this.showAllEditors(`highlight`,t)}for(let n of this.#M)n.updateParams(e,t);for(let n of this.#p)n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){for(let n of this.#n.values())n.editorType===e&&n.show(t);(this.#F?.get(ya.HIGHLIGHT_SHOW_ALL)??!0)!==t&&this.#ne([[ya.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#E!==e){this.#E=e;for(let t of this.#r.values())e?t.disableClick():t.enableClick(),t.div.classList.toggle(`waiting`,e)}}async#re(){if(!this.#T){this.#T=!0;let e=[];for(let t of this.#r.values())e.push(t.enable());await Promise.all(e);for(let e of this.#n.values())e.enable()}}#ie(){if(this.unselectAll(),this.#T){this.#T=!1;for(let e of this.#r.values())e.disable();for(let e of this.#n.values())e.disable()}}getEditors(e){let t=[];for(let n of this.#n.values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return this.#n.get(e)}addEditor(e){this.#n.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#y&&clearTimeout(this.#y),this.#y=setTimeout(()=>{this.focusMainContainer(),this.#y=null},0)),this.#n.delete(e.id),this.unselect(e),e.annotationElementId&&this.#d.has(e.annotationElementId)||this.#a?.remove(e.id)}addDeletedAnnotationElement(e){this.#d.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#d.has(e)}removeDeletedAnnotationElement(e){this.#d.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#ae(e){let t=this.#r.get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#t!==e&&(this.#t=e,e&&this.#ne(e.propertiesToUpdate))}get#oe(){let e=null;for(e of this.#M);return e}updateUI(e){this.#oe===e&&this.#ne(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#ne(e.defaultPropertiesToUpdate)}toggleSelected(e){this.#M.has(e)?(this.#M.delete(e),e.unselect(),this.#te({hasSelectedEditor:this.hasSelection})):(this.#M.add(e),e.select(),this.#ne(e.propertiesToUpdate),this.#te({hasSelectedEditor:!0}))}setSelected(e){this.#l?.commitOrRemove();for(let t of this.#M)t!==e&&t.unselect();this.#M.clear(),this.#M.add(e),e.select(),this.#ne(e.propertiesToUpdate),this.#te({hasSelectedEditor:!0})}isSelected(e){return this.#M.has(e)}get firstSelectedEditor(){return this.#M.values().next().value}unselect(e){e.unselect(),this.#M.delete(e),this.#te({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#M.size!==0}get isEnterHandled(){return this.#M.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#s.undo(),this.#te({hasSomethingToUndo:this.#s.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#se()}),this._editorUndoBar?.hide()}redo(){this.#s.redo(),this.#te({hasSomethingToUndo:!0,hasSomethingToRedo:this.#s.hasSomethingToRedo(),isEmpty:this.#se()})}addCommands(e){this.#s.add(e),this.#te({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#se()})}cleanUndoStack(e){this.#s.cleanType(e)}#se(){if(this.#n.size===0)return!0;if(this.#n.size===1)for(let e of this.#n.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();let e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;let t=e?[e]:[...this.#M],n=()=>{this._editorUndoBar?.show(r,t.length===1?t[0].editorType:t.length);for(let e of t)e.remove()},r=()=>{for(let e of t)this.#ae(e)};this.addCommands({cmd:n,undo:r,mustExec:!0})}commitOrRemove(){this.#t?.commitOrRemove()}hasSomethingToControl(){return this.#t||this.hasSelection}#ce(e){for(let e of this.#M)e.unselect();this.#M.clear();for(let t of e)t.isEmpty()||(this.#M.add(t),t.select());this.#te({hasSelectedEditor:this.hasSelection})}selectAll(){for(let e of this.#M)e.commit();this.#ce(this.#n.values())}unselectAll(){if(!(this.#t&&(this.#t.commitOrRemove(),this.#j!==J.NONE))&&!this.#l?.commitOrRemove()&&this.hasSelection){for(let e of this.#M)e.unselect();this.#M.clear(),this.#te({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#L[0]+=e,this.#L[1]+=t;let[r,i]=this.#L,a=[...this.#M];this.#R&&clearTimeout(this.#R),this.#R=setTimeout(()=>{this.#R=null,this.#L[0]=this.#L[1]=0,this.addCommands({cmd:()=>{for(let e of a)this.#n.has(e.id)&&e.translateInPage(r,i)},undo:()=>{for(let e of a)this.#n.has(e.id)&&e.translateInPage(-r,-i)},mustExec:!1})},1e3);for(let n of a)n.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=/* @__PURE__ */ new Map;for(let e of this.#M)this.#f.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);let e=this.#f;this.#f=null;let t=!1;for(let[{x:n,y:r,pageIndex:i},a]of e)a.newX=n,a.newY=r,a.newPageIndex=i,t||=n!==a.savedX||r!==a.savedY||i!==a.savedPageIndex;if(!t)return!1;let n=(e,t,n,r)=>{if(this.#n.has(e.id)){let i=this.#r.get(r);i?e._setParentAndPosition(i,t,n):(e.pageIndex=r,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(let[t,{newX:r,newY:i,newPageIndex:a}]of e)n(t,r,i,a)},undo:()=>{for(let[t,{savedX:r,savedY:i,savedPageIndex:a}]of e)n(t,r,i,a)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(this.#f)for(let n of this.#f.keys())n.drag(e,t)}rebuild(e){if(e.parent===null){let t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#M.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#t===e}getActive(){return this.#t}getMode(){return this.#j}get imageManager(){return W(this,`imageManager`,new Qa)}getSelectionBoxes(e){if(!e)return null;let t=document.getSelection();for(let n=0,r=t.rangeCount;n<r;n++)if(!e.contains(t.getRangeAt(n).commonAncestorContainer))return null;let{x:n,y:r,width:i,height:a}=e.getBoundingClientRect(),o;switch(e.getAttribute(`data-main-rotation`)){case`90`:o=(e,t,o,s)=>({x:(t-r)/a,y:1-(e+o-n)/i,width:s/a,height:o/i});break;case`180`:o=(e,t,o,s)=>({x:1-(e+o-n)/i,y:1-(t+s-r)/a,width:o/i,height:s/a});break;case`270`:o=(e,t,o,s)=>({x:1-(t+s-r)/a,y:(e-n)/i,width:s/a,height:o/i});break;default:o=(e,t,o,s)=>({x:(e-n)/i,y:(t-r)/a,width:o/i,height:s/a})}let s=[];for(let e=0,n=t.rangeCount;e<n;e++){let n=t.getRangeAt(e);if(!n.collapsed)for(let{x:e,y:t,width:r,height:i}of n.getClientRects())r!==0&&i!==0&&s.push(o(e,t,r,i))}return s.length===0?null:s}addChangedExistingAnnotation({annotationElementId:e,id:t}){(this.#o||=/* @__PURE__ */ new Map).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){this.#o?.delete(e)}renderAnnotationElement(e){let t=this.#o?.get(e.data.id);if(!t)return;let n=this.#a.getRawValue(t);n&&(this.#j!==J.NONE||n.hasBeenModified)&&n.renderAnnotationElement(e)}},ro=class e{#e=null;#t=!1;#n=null;#r=null;#i=null;#a=null;#o=!1;#s=null;#c=null;#l=null;#u=null;#d=!1;static#f=null;static _l10n=null;constructor(t){this.#c=t,this.#d=t._uiManager.useNewAltTextFlow,e.#f||=Object.freeze({added:`pdfjs-editor-new-alt-text-added-button`,"added-label":`pdfjs-editor-new-alt-text-added-button-label`,missing:`pdfjs-editor-new-alt-text-missing-button`,"missing-label":`pdfjs-editor-new-alt-text-missing-button-label`,review:`pdfjs-editor-new-alt-text-to-review-button`,"review-label":`pdfjs-editor-new-alt-text-to-review-button-label`})}static initialize(t){e._l10n??=t}async render(){let t=this.#n=document.createElement(`button`);t.className=`altText`,t.tabIndex=`0`;let n=this.#r=document.createElement(`span`);t.append(n),this.#d?(t.classList.add(`new`),t.setAttribute(`data-l10n-id`,e.#f.missing),n.setAttribute(`data-l10n-id`,e.#f[`missing-label`])):(t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button`),n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-button-label`));let r=this.#c._uiManager._signal;t.addEventListener(`contextmenu`,Oe,{signal:r}),t.addEventListener(`pointerdown`,e=>e.stopPropagation(),{signal:r});let i=e=>{e.preventDefault(),this.#c._uiManager.editAltText(this.#c),this.#d&&this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_clicked`,data:{label:this.#p}})};return t.addEventListener(`click`,i,{capture:!0,signal:r}),t.addEventListener(`keydown`,e=>{e.target===t&&e.key===`Enter`&&(this.#o=!0,i(e))},{signal:r}),await this.#m(),t}get#p(){return this.#e&&`added`||this.#e===null&&this.guessedText&&`review`||`missing`}finish(){this.#n&&(this.#n.focus({focusVisible:this.#o}),this.#o=!1)}isEmpty(){return this.#d?this.#e===null:!this.#e&&!this.#t}hasData(){return this.#d?this.#e!==null||!!this.#l:this.isEmpty()}get guessedText(){return this.#l}async setGuessedText(t){this.#e===null&&(this.#l=t,this.#u=await e._l10n.get(`pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer`,{generatedAltText:t}),this.#m())}toggleAltTextBadge(e=!1){if(!this.#d||this.#e)this.#s?.remove(),this.#s=null;else{if(!this.#s){let e=this.#s=document.createElement(`div`);e.className=`noAltTextBadge`,this.#c.div.append(e)}this.#s.classList.toggle(`hidden`,!e)}}serialize(e){let t=this.#e;return!e&&this.#l===t&&(t=this.#u),{altText:t,decorative:this.#t,guessedText:this.#l,textWithDisclaimer:this.#u}}get data(){return{altText:this.#e,decorative:this.#t}}set data({altText:e,decorative:t,guessedText:n,textWithDisclaimer:r,cancel:i=!1}){n&&(this.#l=n,this.#u=r),(this.#e!==e||this.#t!==t)&&(i||(this.#e=e,this.#t=t),this.#m())}toggle(e=!1){this.#n&&(!e&&this.#a&&(clearTimeout(this.#a),this.#a=null),this.#n.disabled=!e)}shown(){this.#c._reportTelemetry({action:`pdfjs.image.alt_text.image_status_label_displayed`,data:{label:this.#p}})}destroy(){this.#n?.remove(),this.#n=null,this.#r=null,this.#i=null,this.#s?.remove(),this.#s=null}async#m(){let t=this.#n;if(!t)return;if(this.#d){if(t.classList.toggle(`done`,!!this.#e),t.setAttribute(`data-l10n-id`,e.#f[this.#p]),this.#r?.setAttribute(`data-l10n-id`,e.#f[`${this.#p}-label`]),!this.#e){this.#i?.remove();return}}else{if(!this.#e&&!this.#t){t.classList.remove(`done`),this.#i?.remove();return}t.classList.add(`done`),t.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-edit-button`)}let n=this.#i;if(!n){this.#i=n=document.createElement(`span`),n.className=`tooltip`,n.setAttribute(`role`,`tooltip`),n.id=`alt-text-tooltip-${this.#c.id}`;let e=this.#c._uiManager._signal;e.addEventListener(`abort`,()=>{clearTimeout(this.#a),this.#a=null},{once:!0}),t.addEventListener(`mouseenter`,()=>{this.#a=setTimeout(()=>{this.#a=null,this.#i.classList.add(`show`),this.#c._reportTelemetry({action:`alt_text_tooltip`})},100)},{signal:e}),t.addEventListener(`mouseleave`,()=>{this.#a&&=(clearTimeout(this.#a),null),this.#i?.classList.remove(`show`)},{signal:e})}this.#t?n.setAttribute(`data-l10n-id`,`pdfjs-editor-alt-text-decorative-tooltip`):(n.removeAttribute(`data-l10n-id`),n.textContent=this.#e),n.parentNode||t.append(n),this.#c.getImageForAltText()?.setAttribute(`aria-describedby`,n.id)}},io=class e{#e;#t=!1;#n=null;#r;#i;#a;#o;#s;#c=null;#l;#u=null;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:i=null,onPinchEnd:a=null,signal:o}){this.#e=e,this.#n=n,this.#r=t,this.#i=r,this.#a=i,this.#o=a,this.#l=new AbortController,this.#s=AbortSignal.any([o,this.#l.signal]),e.addEventListener(`touchstart`,this.#d.bind(this),{passive:!1,signal:this.#s})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return W(this,`MIN_TOUCH_DISTANCE_TO_PINCH`,35/(window.devicePixelRatio||1))}#d(e){if(this.#r?.()||e.touches.length<2)return;if(!this.#u){this.#u=new AbortController;let e=AbortSignal.any([this.#s,this.#u.signal]),t=this.#e,n={signal:e,passive:!1};t.addEventListener(`touchmove`,this.#f.bind(this),n),t.addEventListener(`touchend`,this.#p.bind(this),n),t.addEventListener(`touchcancel`,this.#p.bind(this),n),this.#i?.()}if(ke(e),e.touches.length!==2||this.#n?.()){this.#c=null;return}let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]),this.#c={touch0X:t.screenX,touch0Y:t.screenY,touch1X:n.screenX,touch1Y:n.screenY}}#f(t){if(!this.#c||t.touches.length!==2)return;let[n,r]=t.touches;n.identifier>r.identifier&&([n,r]=[r,n]);let{screenX:i,screenY:a}=n,{screenX:o,screenY:s}=r,c=this.#c,{touch0X:l,touch0Y:u,touch1X:d,touch1Y:f}=c,p=d-l,m=f-u,h=o-i,g=s-a,_=Math.hypot(h,g)||1,v=Math.hypot(p,m)||1;if(!this.#t&&Math.abs(v-_)<=e.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(c.touch0X=i,c.touch0Y=a,c.touch1X=o,c.touch1Y=s,t.preventDefault(),!this.#t){this.#t=!0;return}let y=[(i+o)/2,(a+s)/2];this.#a?.(y,v,_)}#p(e){this.#u.abort(),this.#u=null,this.#o?.(),this.#c&&(e.preventDefault(),this.#c=null,this.#t=!1)}destroy(){this.#l?.abort(),this.#l=null}},ao=class e{#e=null;#t=null;#n=null;#r=!1;#i=null;#a=``;#o=!1;#s=null;#c=null;#l=null;#u=null;#d=``;#f=!1;#p=null;#m=!1;#h=!1;#g=!1;#_=null;#v=0;#y=0;#b=null;#x=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#S=!1;#C=e._zIndex++;static _borderLineWidth=-1;static _colorManager=new to;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=e.prototype._resizeWithKeyboard,n=no.TRANSLATE_SMALL,r=no.TRANSLATE_BIG;return W(this,`_resizerKeyboardManager`,new eo([[[`ArrowLeft`,`mac+ArrowLeft`],t,{args:[-n,0]}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t,{args:[-r,0]}],[[`ArrowRight`,`mac+ArrowRight`],t,{args:[n,0]}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t,{args:[r,0]}],[[`ArrowUp`,`mac+ArrowUp`],t,{args:[0,-n]}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t,{args:[0,-r]}],[[`ArrowDown`,`mac+ArrowDown`],t,{args:[0,n]}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t,{args:[0,r]}],[[`Escape`,`mac+Escape`],e.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null;let{rotation:t,rawDims:{pageWidth:n,pageHeight:r,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,r],this.pageTranslation=[i,a];let[o,s]=this.parentDimensions;this.x=e.x/o,this.y=e.y/s,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return W(this,`_defaultLineColor`,this._colorManager.getHexCode(`CanvasText`))}static deleteAnnotationElement(e){let t=new oo({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(t,n){if(e._l10n??=t,e._l10nResizer||=Object.freeze({topLeft:`pdfjs-editor-resizer-top-left`,topMiddle:`pdfjs-editor-resizer-top-middle`,topRight:`pdfjs-editor-resizer-top-right`,middleRight:`pdfjs-editor-resizer-middle-right`,bottomRight:`pdfjs-editor-resizer-bottom-right`,bottomMiddle:`pdfjs-editor-resizer-bottom-middle`,bottomLeft:`pdfjs-editor-resizer-bottom-left`,middleLeft:`pdfjs-editor-resizer-middle-left`}),e._borderLineWidth!==-1)return;let r=getComputedStyle(document.documentElement);e._borderLineWidth=parseFloat(r.getPropertyValue(`--outline-width`))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){U(`Not implemented`)}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#S}set _isDraggable(e){this.#S=e,this.div?.classList.toggle(`draggable`,e)}get isEnterHandled(){return!0}center(){let[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#C}setParent(e){e===null?this.#H():(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#f?this.#f=!1:this.parent.setSelected(this))}focusout(e){this._focusEventsAllowed&&this.isAttachedToDOM&&(e.relatedTarget?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove()))}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,r){let[i,a]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(e+n)/i,this.y=(t+r)/a,this.fixAndSetPosition()}#w([e,t],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/e,this.y+=r/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#w(this.parentDimensions,e,t)}translateInPage(e,t){this.#p||=[this.x,this.y,this.width,this.height],this.#w(this.pageDimensions,e,t),this.div.scrollIntoView({block:`nearest`})}drag(e,t){this.#p||=[this.x,this.y,this.width,this.height];let{div:n,parentDimensions:[r,i]}=this;if(this.x+=e/r,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this,[s,c]=this.getBaseTranslation();a+=s,o+=c;let{style:l}=n;l.left=`${(100*a).toFixed(2)}%`,l.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),n.scrollIntoView({block:`nearest`})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#p&&(this.#p[0]!==this.x||this.#p[1]!==this.y)}get _hasBeenResized(){return!!this.#p&&(this.#p[2]!==this.width||this.#p[3]!==this.height)}getBaseTranslation(){let[t,n]=this.parentDimensions,{_borderLineWidth:r}=e,i=r/t,a=r/n;switch(this.rotation){case 90:return[-i,a];case 180:return[i,a];case 270:return[i,-a];default:return[-i,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let{div:{style:t},pageDimensions:[n,r]}=this,{x:i,y:a,width:o,height:s}=this;if(o*=n,s*=r,i*=n,a*=r,this._mustFixPosition)switch(e){case 0:i=Math.max(0,Math.min(n-o,i)),a=Math.max(0,Math.min(r-s,a));break;case 90:i=Math.max(0,Math.min(n-s,i)),a=Math.min(r,Math.max(o,a));break;case 180:i=Math.min(n,Math.max(o,i)),a=Math.min(r,Math.max(s,a));break;case 270:i=Math.min(n,Math.max(s,i)),a=Math.max(0,Math.min(r-o,a))}this.x=i/=n,this.y=a/=r;let[c,l]=this.getBaseTranslation();i+=c,a+=l,t.left=`${(100*i).toFixed(2)}%`,t.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}static#T(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(t,n){return e.#T(t,n,this.parentRotation)}pageTranslationToScreen(t,n){return e.#T(t,n,360-this.parentRotation)}#E(e){switch(e){case 90:{let[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{let[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:e,pageDimensions:[t,n]}=this;return[t*e,n*e]}setDims(e,t){let[n,r]=this.parentDimensions,{style:i}=this.div;i.width=`${(100*e/n).toFixed(2)}%`,this.#o||(i.height=`${(100*t/r).toFixed(2)}%`)}fixDims(){let{style:e}=this.div,{height:t,width:n}=e,r=n.endsWith(`%`),i=!this.#o&&t.endsWith(`%`);if(r&&i)return;let[a,o]=this.parentDimensions;r||(e.width=`${(100*parseFloat(n)/a).toFixed(2)}%`),!this.#o&&!i&&(e.height=`${(100*parseFloat(t)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#D(){if(this.#s)return;this.#s=document.createElement(`div`),this.#s.classList.add(`resizers`);let e=this._willKeepAspectRatio?[`topLeft`,`topRight`,`bottomRight`,`bottomLeft`]:[`topLeft`,`topMiddle`,`topRight`,`middleRight`,`bottomRight`,`bottomMiddle`,`bottomLeft`,`middleLeft`],t=this._uiManager._signal;for(let n of e){let e=document.createElement(`div`);this.#s.append(e),e.classList.add(`resizer`,n),e.setAttribute(`data-resizer-name`,n),e.addEventListener(`pointerdown`,this.#O.bind(this,n),{signal:t}),e.addEventListener(`contextmenu`,Oe,{signal:t}),e.tabIndex=-1}this.div.prepend(this.#s)}#O(e,t){t.preventDefault();let{isMac:n}=La.platform;if(t.button!==0||t.ctrlKey&&n)return;this.#n?.toggle(!1);let r=this._isDraggable;this._isDraggable=!1,this.#c=[t.screenX,t.screenY];let i=new AbortController,a=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener(`pointermove`,this.#j.bind(this,e),{passive:!0,capture:!0,signal:a}),window.addEventListener(`touchmove`,ke,{passive:!1,signal:a}),window.addEventListener(`contextmenu`,Oe,{signal:a}),this.#l={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let o=this.parent.div.style.cursor,s=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;let c=()=>{i.abort(),this.parent.togglePointerEvents(!0),this.#n?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=o,this.div.style.cursor=s,this.#A()};window.addEventListener(`pointerup`,c,{signal:a}),window.addEventListener(`blur`,c,{signal:a})}#k(e,t,n,r){this.width=n,this.height=r,this.x=e,this.y=t;let[i,a]=this.parentDimensions;this.setDims(i*n,a*r),this.fixAndSetPosition(),this._onResized()}_onResized(){}#A(){if(!this.#l)return;let{savedX:e,savedY:t,savedWidth:n,savedHeight:r}=this.#l;this.#l=null;let i=this.x,a=this.y,o=this.width,s=this.height;(i!==e||a!==t||o!==n||s!==r)&&this.addCommands({cmd:this.#k.bind(this,i,a,o,s),undo:this.#k.bind(this,e,t,n,r),mustExec:!0})}static _round(e){return Math.round(e*1e4)/1e4}#j(t,n){let[r,i]=this.parentDimensions,a=this.x,o=this.y,s=this.width,c=this.height,l=e.MIN_SIZE/r,u=e.MIN_SIZE/i,d=this.#E(this.rotation),f=(e,t)=>[d[0]*e+d[2]*t,d[1]*e+d[3]*t],p=this.#E(360-this.rotation),m=(e,t)=>[p[0]*e+p[2]*t,p[1]*e+p[3]*t],h,g,_=!1,v=!1;switch(t){case`topLeft`:_=!0,h=(e,t)=>[0,0],g=(e,t)=>[e,t];break;case`topMiddle`:h=(e,t)=>[e/2,0],g=(e,t)=>[e/2,t];break;case`topRight`:_=!0,h=(e,t)=>[e,0],g=(e,t)=>[0,t];break;case`middleRight`:v=!0,h=(e,t)=>[e,t/2],g=(e,t)=>[0,t/2];break;case`bottomRight`:_=!0,h=(e,t)=>[e,t],g=(e,t)=>[0,0];break;case`bottomMiddle`:h=(e,t)=>[e/2,t],g=(e,t)=>[e/2,0];break;case`bottomLeft`:_=!0,h=(e,t)=>[0,t],g=(e,t)=>[e,0];break;case`middleLeft`:v=!0,h=(e,t)=>[0,t/2],g=(e,t)=>[e,t/2]}let y=h(s,c),b=g(s,c),x=f(...b),S=e._round(a+x[0]),C=e._round(o+x[1]),w=1,T=1,E,D;if(n.fromKeyboard)({deltaX:E,deltaY:D}=n);else{let{screenX:e,screenY:t}=n,[r,i]=this.#c;[E,D]=this.screenToPageTranslation(e-r,t-i),this.#c[0]=e,this.#c[1]=t}if([E,D]=m(E/r,D/i),_){let e=Math.hypot(s,c);w=T=Math.max(Math.min(Math.hypot(b[0]-y[0]-E,b[1]-y[1]-D)/e,1/s,1/c),l/s,u/c)}else v?w=Math.max(l,Math.min(1,Math.abs(b[0]-y[0]-E)))/s:T=Math.max(u,Math.min(1,Math.abs(b[1]-y[1]-D)))/c;let O=e._round(s*w),k=e._round(c*T);x=f(...g(O,k));let A=S-x[0],j=C-x[1];this.#p||=[this.x,this.y,this.width,this.height],this.width=O,this.height=k,this.x=A,this.y=j,this.setDims(r*O,i*k),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#n?.finish()}async addEditToolbar(){return this._editToolbar||this.#h||(this._editToolbar=new Ya(this),this.div.append(this._editToolbar.render()),this.#n&&await this._editToolbar.addAltText(this.#n)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#n?.destroy())}addContainer(e){let t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#n||(ro.initialize(e._l10n),this.#n=new ro(this),this.#e&&=(this.#n.data=this.#e,null),await this.addEditToolbar())}get altTextData(){return this.#n?.data}set altTextData(e){this.#n&&(this.#n.data=e)}get guessedAltText(){return this.#n?.guessedText}async setGuessedAltText(e){await this.#n?.setGuessedText(e)}serializeAltText(e){return this.#n?.serialize(e)}hasAltText(){return!!this.#n&&!this.#n.isEmpty()}hasAltTextData(){return this.#n?.hasData()??!1}render(){this.div=document.createElement(`div`),this.div.setAttribute(`data-editor-rotation`,(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute(`id`,this.id),this.div.tabIndex=this.#r?-1:0,this._isVisible||this.div.classList.add(`hidden`),this.setInForeground(),this.#L();let[e,t]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*t/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/t).toFixed(2)}%`);let[n,r]=this.getInitialTranslation();return this.translate(n,r),Ie(this,this.div,[`pointerdown`]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#x||=new io({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#M.bind(this),onPinching:this.#N.bind(this),onPinchEnd:this.#P.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#M(){this.#l={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#n?.toggle(!1),this.parent.togglePointerEvents(!1)}#N(t,n,r){let i=.7,a=r/n*i+1-i;if(a===1)return;let o=this.#E(this.rotation),s=(e,t)=>[o[0]*e+o[2]*t,o[1]*e+o[3]*t],[c,l]=this.parentDimensions,u=this.x,d=this.y,f=this.width,p=this.height,m=e.MIN_SIZE/c,h=e.MIN_SIZE/l;a=Math.max(Math.min(a,1/f,1/p),m/f,h/p);let g=e._round(f*a),_=e._round(p*a);if(g===f&&_===p)return;this.#p||=[u,d,f,p];let v=s(f/2,p/2),y=e._round(u+v[0]),b=e._round(d+v[1]),x=s(g/2,_/2);this.x=y-x[0],this.y=b-x[1],this.width=g,this.height=_,this.setDims(c*g,l*_),this.fixAndSetPosition(),this._onResizing()}#P(){this.#n?.toggle(!0),this.parent.togglePointerEvents(!0),this.#A()}pointerdown(e){let{isMac:t}=La.platform;e.button!==0||e.ctrlKey&&t?e.preventDefault():(this.#f=!0,this._isDraggable?this.#I(e):this.#F(e))}get isSelected(){return this._uiManager.isSelected(this)}#F(e){let{isMac:t}=La.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#I(e){let{isSelected:t}=this;this._uiManager.setUpDragSession();let n=!1,r=new AbortController,i=this._uiManager.combinedSignal(r),a={capture:!0,passive:!1,signal:i},o=e=>{r.abort(),this.#i=null,this.#f=!1,this._uiManager.endDragSession()||this.#F(e),n&&this._onStopDragging()};t&&(this.#v=e.clientX,this.#y=e.clientY,this.#i=e.pointerId,this.#a=e.pointerType,window.addEventListener(`pointermove`,e=>{n||(n=!0,this._onStartDragging());let{clientX:t,clientY:r,pointerId:i}=e;if(i!==this.#i){ke(e);return}let[a,o]=this.screenToPageTranslation(t-this.#v,r-this.#y);this.#v=t,this.#y=r,this._uiManager.dragSelectedEditors(a,o)},a),window.addEventListener(`touchmove`,ke,a),window.addEventListener(`pointerdown`,e=>{e.pointerType===this.#a&&(this.#x||e.isPrimary)&&o(e),ke(e)},a));let s=e=>{!this.#i||this.#i===e.pointerId?o(e):ke(e)};window.addEventListener(`pointerup`,s,{signal:i}),window.addEventListener(`blur`,s,{signal:i})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#_&&clearTimeout(this.#_),this.#_=setTimeout(()=>{this.#_=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,n=this.rotation){let r=this.parentScale,[i,a]=this.pageDimensions,[o,s]=this.pageTranslation,c=e/r,l=t/r,u=this.x*i,d=this.y*a,f=this.width*i,p=this.height*a;switch(n){case 0:return[u+c+o,a-d-l-p+s,u+c+f+o,a-d-l+s];case 90:return[u+l+o,a-d+c+s,u+l+p+o,a-d+c+f+s];case 180:return[u-c-f+o,a-d+l+s,u-c+o,a-d+l+p+s];case 270:return[u-l-p+o,a-d-c-f+s,u-l+o,a-d-c+s];default:throw Error(`Invalid rotation`)}}getRectInCurrentCoords(e,t){let[n,r,i,a]=e,o=i-n,s=a-r;switch(this.rotation){case 0:return[n,t-a,o,s];case 90:return[n,t-r,s,o];case 180:return[i,t-r,o,s];case 270:return[i,t-a,s,o];default:throw Error(`Invalid rotation`)}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){this.#h=!0}disableEditMode(){this.#h=!1}isInEditMode(){return this.#h}shouldGetKeyboardEvents(){return this.#g}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:e,left:t,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return t<a&&r>0&&e<i&&n>0}#L(){if(this.#u||!this.div)return;this.#u=new AbortController;let e=this._uiManager.combinedSignal(this.#u);this.div.addEventListener(`focusin`,this.focusin.bind(this),{signal:e}),this.div.addEventListener(`focusout`,this.focusout.bind(this),{signal:e})}rebuild(){this.#L()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||``}}serialize(e=!1,t=null){U(`An editor must be serializable`)}static async deserialize(e,t,n){let r=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:n});r.rotation=e.rotation,r.#e=e.accessibilityData;let[i,a]=r.pageDimensions,[o,s,c,l]=r.getRectInCurrentCoords(e.rect,a);return r.x=o/i,r.y=s/a,r.width=c/i,r.height=l/a,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#u?.abort(),this.#u=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#_&&=(clearTimeout(this.#_),null),this.#H(),this.removeEditToolbar(),this.#b){for(let e of this.#b.values())clearTimeout(e);this.#b=null}this.parent=null,this.#x?.destroy(),this.#x=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#D(),this.#s.classList.remove(`hidden`),Ie(this,this.div,[`keydown`]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!==`Enter`)return;this._uiManager.setSelected(this),this.#l={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let n=this.#s.children;if(!this.#t){this.#t=Array.from(n);let t=this.#R.bind(this),r=this.#z.bind(this),i=this._uiManager._signal;for(let n of this.#t){let a=n.getAttribute(`data-resizer-name`);n.setAttribute(`role`,`spinbutton`),n.addEventListener(`keydown`,t,{signal:i}),n.addEventListener(`blur`,r,{signal:i}),n.addEventListener(`focus`,this.#B.bind(this,a),{signal:i}),n.setAttribute(`data-l10n-id`,e._l10nResizer[a])}}let r=this.#t[0],i=0;for(let e of n){if(e===r)break;i++}let a=(360-this.rotation+this.parentRotation)%360/90*(this.#t.length/4);if(a!==i){if(a<i)for(let e=0;e<i-a;e++)this.#s.append(this.#s.firstChild);else if(a>i)for(let e=0;e<a-i;e++)this.#s.firstChild.before(this.#s.lastChild);let t=0;for(let r of n){let n=this.#t[t++].getAttribute(`data-resizer-name`);r.setAttribute(`data-l10n-id`,e._l10nResizer[n])}}this.#V(0),this.#g=!0,this.#s.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#R(t){e._resizerKeyboardManager.exec(this,t)}#z(e){this.#g&&e.relatedTarget?.parentNode!==this.#s&&this.#H()}#B(e){this.#d=this.#g?e:``}#V(e){if(this.#t)for(let t of this.#t)t.tabIndex=e}_resizeWithKeyboard(e,t){this.#g&&this.#j(this.#d,{deltaX:e,deltaY:t,fromKeyboard:!0})}#H(){this.#g=!1,this.#V(-1),this.#A()}_stopResizingWithKeyboard(){this.#H(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add(`selectedEditor`),this._editToolbar?(this._editToolbar?.show(),this.#n?.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{this.div?.classList.contains(`selectedEditor`)&&this._editToolbar?.show()})}unselect(){this.#s?.classList.add(`hidden`),this.div?.classList.remove(`selectedEditor`),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#n?.toggleAltTextBadge(!0)}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#m}set isEditing(e){this.#m=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){this.#o=!0;let n=e/t,{style:r}=this.div;r.aspectRatio=n,r.height=`auto`}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:`added`}}get telemetryFinalData(){return null}_reportTelemetry(t,n=!1){if(n){this.#b||=/* @__PURE__ */ new Map;let{action:n}=t,r=this.#b.get(n);r&&clearTimeout(r),r=setTimeout(()=>{this._reportTelemetry(t),this.#b.delete(n),this.#b.size===0&&(this.#b=null)},e._telemetryTimeout),this.#b.set(n,r)}else t.type||=this.editorType,this._uiManager._eventBus.dispatch(`reporttelemetry`,{source:this,details:{type:`editing`,data:t}})}show(e=this._isVisible){this.div.classList.toggle(`hidden`,!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#r=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#r=!0}renderAnnotationElement(e){let t=e.container.querySelector(`.annotationContent`);if(!t)t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.container.prepend(t);else if(t.nodeName===`CANVAS`){let e=t;t=document.createElement(`div`),t.classList.add(`annotationContent`,this.editorType),e.before(t)}return t}resetAnnotationElement(e){let{firstChild:t}=e.container;t?.nodeName===`DIV`&&t.classList.contains(`annotationContent`)&&t.remove()}},oo=class extends ao{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}},so=3285377520,co=4294901760,lo=65535,uo=class{constructor(e){this.h1=e?e|0:so,this.h2=e?e|0:so}update(e){let t,n;if(typeof e==`string`){t=new Uint8Array(e.length*2),n=0;for(let r=0,i=e.length;r<i;r++){let i=e.charCodeAt(r);i<=255?t[n++]=i:(t[n++]=i>>>8,t[n++]=i&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),n=t.byteLength;else throw Error(`Invalid data format, must be a string or TypedArray.`);let r=n>>2,i=n-r*4,a=new Uint32Array(t.buffer,0,r),o=0,s=0,c=this.h1,l=this.h2,u=3432918353,d=461845907,f=11601,p=13715;for(let e=0;e<r;e++)e&1?(o=a[e],o=o*u&co|o*f&lo,o=o<<15|o>>>17,o=o*d&co|o*p&lo,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(s=a[e],s=s*u&co|s*f&lo,s=s<<15|s>>>17,s=s*d&co|s*p&lo,l^=s,l=l<<13|l>>>19,l=l*5+3864292196);switch(o=0,i){case 3:o^=t[r*4+2]<<16;case 2:o^=t[r*4+1]<<8;case 1:o^=t[r*4],o=o*u&co|o*f&lo,o=o<<15|o>>>17,o=o*d&co|o*p&lo,r&1?c^=o:l^=o}this.h1=c,this.h2=l}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&co|e*36045&lo,t=t*4283543511&co|((t<<16|e>>>16)*2950163797&co)>>>16,e^=t>>>1,e=e*444984403&co|e*60499&lo,t=t*3301882366&co|((t<<16|e>>>16)*3120437893&co)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}},fo=Object.freeze({map:null,hash:``,transfer:void 0}),po=class{#e=!1;#t=null;#n=/* @__PURE__ */ new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){let n=this.#n.get(e);return n===void 0?t:Object.assign(t,n)}getRawValue(e){return this.#n.get(e)}remove(e){if(this.#n.delete(e),this.#n.size===0&&this.resetModified(),typeof this.onAnnotationEditor==`function`){for(let e of this.#n.values())if(e instanceof ao)return;this.onAnnotationEditor(null)}}setValue(e,t){let n=this.#n.get(e),r=!1;if(n!==void 0)for(let[e,i]of Object.entries(t))n[e]!==i&&(r=!0,n[e]=i);else r=!0,this.#n.set(e,t);r&&this.#r(),t instanceof ao&&typeof this.onAnnotationEditor==`function`&&this.onAnnotationEditor(t.constructor._type)}has(e){return this.#n.has(e)}getAll(){return this.#n.size>0?ge(this.#n):null}setAll(e){for(let[t,n]of Object.entries(e))this.setValue(t,n)}get size(){return this.#n.size}#r(){this.#e||(this.#e=!0,typeof this.onSetModified==`function`&&this.onSetModified())}resetModified(){this.#e&&(this.#e=!1,typeof this.onResetModified==`function`&&this.onResetModified())}get print(){return new mo(this)}get serializable(){if(this.#n.size===0)return fo;let e=/* @__PURE__ */ new Map,t=new uo,n=[],r=Object.create(null),i=!1;for(let[n,a]of this.#n){let o=a instanceof ao?a.serialize(!1,r):a;o&&(e.set(n,o),t.update(`${n}:${JSON.stringify(o)}`),i||=!!o.bitmap)}if(i)for(let t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:fo}get editorStats(){let e=null,t=/* @__PURE__ */ new Map;for(let n of this.#n.values()){if(!(n instanceof ao))continue;let r=n.telemetryFinalData;if(!r)continue;let{type:i}=r;t.has(i)||t.set(i,Object.getPrototypeOf(n).constructor),e||=Object.create(null);let a=e[i]||=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(r)){if(e===`type`)continue;let n=a.get(e);n||(n=/* @__PURE__ */ new Map,a.set(e,n));let r=n.get(t)??0;n.set(t,r+1)}}for(let[n,r]of t)e[n]=r.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){this.#t=null}get modifiedIds(){if(this.#t)return this.#t;let e=[];for(let t of this.#n.values())t instanceof ao&&t.annotationElementId&&t.serialize()&&e.push(t.annotationElementId);return this.#t={ids:new Set(e),hash:e.join(`,`)}}},mo=class extends po{#e;constructor(e){super();let{map:t,hash:n,transfer:r}=e.serializable,i=structuredClone(t,r?{transfer:r}:null);this.#e={map:i,hash:n,transfer:r}}get print(){U(`Should not call PrintAnnotationStorage.print`)}get serializable(){return this.#e}get modifiedIds(){return W(this,`modifiedIds`,{ids:/* @__PURE__ */ new Set,hash:``})}},ho=class{#e=/* @__PURE__ */ new Set;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=/* @__PURE__ */ new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement(`style`),this._document.documentElement.getElementsByTagName(`head`)[0].append(this.styleElement));let t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),this.#e.clear(),this.styleElement&&=(this.styleElement.remove(),null)}async loadSystemFont({systemFontInfo:e,_inspectFont:t}){if(e&&!this.#e.has(e.loadedName)){if(ue(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:n,src:r,style:i}=e,a=new FontFace(n,r,i);this.addNativeFontFace(a);try{await a.load(),this.#e.add(n),t?.(e)}catch{H(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}}else U(`Not implemented: loadSystemFont without the Font Loading API.`)}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){let t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(n){throw H(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(t=>{let n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)})}}get isFontLoadingAPISupported(){let e=!!this._document?.fonts;return W(this,`isFontLoadingAPISupported`,e)}get isSyncFontLoadingSupported(){let e=!1;return(fa||typeof navigator<`u`&&typeof navigator?.userAgent==`string`&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),W(this,`isSyncFontLoadingSupported`,e)}_queueLoadingCallback(e){function t(){for(ue(!r.done,`completeRequest() cannot be called twice.`),r.done=!0;n.length>0&&n[0].done;){let e=n.shift();setTimeout(e.callback,0)}}let{loadingRequests:n}=this,r={done:!1,complete:t,callback:e};return n.push(r),r}get _loadTestFont(){let e=atob(`T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==`);return W(this,`_loadTestFont`,e)}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3)&255}function r(e,t,n,r){let i=e.substring(0,t),a=e.substring(t+n);return i+r+a}let i,a,o=this._document.createElement(`canvas`);o.width=1,o.height=1;let s=o.getContext(`2d`),c=0;function l(e,t){++c>30?(H(`Load test font never loaded.`),t()):(s.font=`30px `+e,s.fillText(`.`,0,20),s.getImageData(0,0,1,1).data[3]>0?t():setTimeout(l.bind(null,e,t)))}let u=`lt${Date.now()}${this.loadTestFontId++}`,d=this._loadTestFont;d=r(d,976,u.length,u);let f=1482184792,p=n(d,16);for(i=0,a=u.length-3;i<a;i+=4)p=p-f+n(u,i)|0;i<u.length&&(p=p-f+n(u+`XXX`,i)|0),d=r(d,16,4,he(p));let m=`@font-face {font-family:"${u}";src:${`url(data:font/opentype;base64,${btoa(d)});`}}`;this.insertRule(m);let h=this._document.createElement(`div`);h.style.visibility=`hidden`,h.style.width=h.style.height=`10px`,h.style.position=`absolute`,h.style.top=h.style.left=`0px`;for(let t of[e.loadedName,u]){let e=this._document.createElement(`span`);e.textContent=`Hi`,e.style.fontFamily=t,h.append(e)}this._document.body.append(h),l(u,()=>{h.remove(),t.complete()})}},go=class{constructor(e,{disableFontFace:t=!1,fontExtraProperties:n=!1,inspectFont:r=null}){this.compiledGlyphs=Object.create(null);for(let t in e)this[t]=e[t];this.disableFontFace=t===!0,this.fontExtraProperties=n===!0,this._inspectFont=r}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{let t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${Se(this.data)});`,t;if(!this.cssFontInfo)t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${e}}`}return this._inspectFont?.(this,e),t}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];let n=this.loadedName+`_path_`+t,r;try{r=e.get(n)}catch(e){H(`getPathGenerator - ignoring character: "${e}".`)}let i=new Path2D(r||``);return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[t]=i}},_o={DATA:1,ERROR:2},vo={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8},yo=class{#e=new AbortController;constructor(e,t,n){this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),n.addEventListener(`message`,this.#t.bind(this),{signal:this.#e.signal})}#t({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){this.#r(e);return}if(e.callback){let t=e.callbackId,n=this.callbackCapabilities[t];if(!n)throw Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],e.callback===_o.DATA)n.resolve(e.data);else if(e.callback===_o.ERROR)n.reject(Re(e.reason));else throw Error(`Unexpected callback case`);return}let t=this.actionHandler[e.action];if(!t)throw Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){let n=this.sourceName,r=e.sourceName,i=this.comObj;Promise.try(t,e.data).then(function(t){i.postMessage({sourceName:n,targetName:r,callback:_o.DATA,callbackId:e.callbackId,data:t})},function(t){i.postMessage({sourceName:n,targetName:r,callback:_o.ERROR,callbackId:e.callbackId,reason:Re(t)})})}else e.streamId?this.#n(e):t(e.data)}on(e,t){let n=this.actionHandler;if(n[e])throw Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){let r=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[r]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:r,data:t},n)}catch(e){i.reject(e)}return i.promise}sendWithStream(e,t,n,r){let i=this.streamId++,a=this.sourceName,o=this.targetName,s=this.comObj;return new ReadableStream({start:n=>{let c=Promise.withResolvers();return this.streamControllers[i]={controller:n,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},s.postMessage({sourceName:a,targetName:o,action:e,streamId:i,data:t,desiredSize:n.desiredSize},r),c.promise},pull:e=>{let t=Promise.withResolvers();return this.streamControllers[i].pullCall=t,s.postMessage({sourceName:a,targetName:o,stream:vo.PULL,streamId:i,desiredSize:e.desiredSize}),t.promise},cancel:e=>{ue(e instanceof Error,`cancel must have a valid reason`);let t=Promise.withResolvers();return this.streamControllers[i].cancelCall=t,this.streamControllers[i].isClosed=!0,s.postMessage({sourceName:a,targetName:o,stream:vo.CANCEL,streamId:i,reason:Re(e)}),t.promise}},n)}#n(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this,o=this.actionHandler[e.action],s={enqueue(e,a=1,o){if(this.isCancelled)return;let s=this.desiredSize;this.desiredSize-=a,s>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:n,targetName:r,stream:vo.ENQUEUE,streamId:t,chunk:e},o)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:vo.CLOSE,streamId:t}),delete a.streamSinks[t])},error(e){ue(e instanceof Error,`error must have a valid reason`),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:r,stream:vo.ERROR,streamId:t,reason:Re(e)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};s.sinkCapability.resolve(),s.ready=s.sinkCapability.promise,this.streamSinks[t]=s,Promise.try(o,e.data,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:vo.START_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:vo.START_COMPLETE,streamId:t,reason:Re(e)})})}#r(e){let t=e.streamId,n=this.sourceName,r=e.sourceName,i=this.comObj,a=this.streamControllers[t],o=this.streamSinks[t];switch(e.stream){case vo.START_COMPLETE:e.success?a.startCall.resolve():a.startCall.reject(Re(e.reason));break;case vo.PULL_COMPLETE:e.success?a.pullCall.resolve():a.pullCall.reject(Re(e.reason));break;case vo.PULL:if(!o){i.postMessage({sourceName:n,targetName:r,stream:vo.PULL_COMPLETE,streamId:t,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||Le).then(function(){i.postMessage({sourceName:n,targetName:r,stream:vo.PULL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:vo.PULL_COMPLETE,streamId:t,reason:Re(e)})});break;case vo.ENQUEUE:if(ue(a,`enqueue should have stream controller`),a.isClosed)break;a.controller.enqueue(e.chunk);break;case vo.CLOSE:if(ue(a,`close should have stream controller`),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#i(a,t);break;case vo.ERROR:ue(a,`error should have stream controller`),a.controller.error(Re(e.reason)),this.#i(a,t);break;case vo.CANCEL_COMPLETE:e.success?a.cancelCall.resolve():a.cancelCall.reject(Re(e.reason)),this.#i(a,t);break;case vo.CANCEL:if(!o)break;let s=Re(e.reason);Promise.try(o.onCancel||Le,s).then(function(){i.postMessage({sourceName:n,targetName:r,stream:vo.CANCEL_COMPLETE,streamId:t,success:!0})},function(e){i.postMessage({sourceName:n,targetName:r,stream:vo.CANCEL_COMPLETE,streamId:t,reason:Re(e)})}),o.sinkCapability.reject(s),o.isCancelled=!0,delete this.streamSinks[t];break;default:throw Error(`Unexpected stream case`)}}async#i(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]}destroy(){this.#e?.abort(),this.#e=null}},bo=class{#e=!1;constructor({enableHWA:e=!1}){this.#e=e}create(e,t){if(e<=0||t<=0)throw Error(`Invalid canvas size`);let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext(`2d`,{willReadFrequently:!this.#e})}}reset(e,t,n){if(!e.canvas)throw Error(`Canvas is not specified`);if(t<=0||n<=0)throw Error(`Invalid canvas size`);e.canvas.width=t,e.canvas.height=n}destroy(e){if(!e.canvas)throw Error(`Canvas is not specified`);e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){U("Abstract method `_createCanvas` called.")}},xo=class extends bo{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){let n=this._document.createElement(`canvas`);return n.width=e,n.height=t,n}},So=class{constructor({baseUrl:e=null,isCompressed:t=!0}){this.baseUrl=e,this.isCompressed=t}async fetch({name:e}){if(!this.baseUrl)throw Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw Error(`CMap name must be specified.`);let t=this.baseUrl+e+(this.isCompressed?`.bcmap`:``);return this._fetch(t).then(e=>({cMapData:e,isCompressed:this.isCompressed})).catch(e=>{throw Error(`Unable to load ${this.isCompressed?`binary `:``}CMap at: ${t}`)})}async _fetch(e){U("Abstract method `_fetch` called.")}},Co=class extends So{async _fetch(e){let t=await Ce(e,this.isCompressed?`arraybuffer`:`text`);return t instanceof ArrayBuffer?new Uint8Array(t):me(t)}},Ti(),wo=class{addFilter(e){return`none`}addHCMFilter(e,t){return`none`}addAlphaFilter(e){return`none`}addLuminosityFilter(e){return`none`}addHighlightHCMFilter(e,t,n,r,i){return`none`}destroy(e=!1){}},To=class extends wo{#e;#t;#n;#r;#i;#a;#o=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super(),this.#r=e,this.#i=t}get#s(){return this.#t||=/* @__PURE__ */ new Map}get#c(){return this.#a||=/* @__PURE__ */ new Map}get#l(){if(!this.#n){let e=this.#i.createElement(`div`),{style:t}=e;t.visibility=`hidden`,t.contain=`strict`,t.width=t.height=0,t.position=`absolute`,t.top=t.left=0,t.zIndex=-1;let n=this.#i.createElementNS(Ha,`svg`);n.setAttribute(`width`,0),n.setAttribute(`height`,0),this.#n=this.#i.createElementNS(Ha,`defs`),e.append(n),n.append(this.#n),this.#i.body.append(e)}return this.#n}#u(e){if(e.length===1){let t=e[0],n=Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;let r=n.join(`,`);return[r,r,r]}let[t,n,r]=e,i=Array(256),a=Array(256),o=Array(256);for(let e=0;e<256;e++)i[e]=t[e]/255,a[e]=n[e]/255,o[e]=r[e]/255;return[i.join(`,`),a.join(`,`),o.join(`,`)]}#d(e){if(this.#e===void 0){this.#e=``;let e=this.#i.URL;e!==this.#i.baseURI&&(we(e)?H(`#createUrl: ignore "data:"-URL for performance reasons.`):this.#e=e.split(`#`,1)[0])}return`url(${this.#e}#${e})`}addFilter(e){if(!e)return`none`;let t=this.#s.get(e);if(t)return t;let[n,r,i]=this.#u(e),a=e.length===1?n:`${n}${r}${i}`;if(t=this.#s.get(a),t)return this.#s.set(e,t),t;let o=`g_${this.#r}_transfer_map_${this.#o++}`,s=this.#d(o);this.#s.set(e,s),this.#s.set(a,s);let c=this.#m(o);return this.#g(n,r,i,c),s}addHCMFilter(e,t){let n=`${e}-${t}`,r=`base`,i=this.#c.get(r);if(i?.key===n||(i?(i.filter?.remove(),i.key=n,i.url=`none`,i.filter=null):(i={key:n,url:`none`,filter:null},this.#c.set(r,i)),!e||!t))return i.url;let a=this.#v(e);e=Y.makeHexColor(...a);let o=this.#v(t);if(t=Y.makeHexColor(...o),this.#l.style.color=``,e===`#000000`&&t===`#ffffff`||e===t)return i.url;let s=Array(256);for(let e=0;e<=255;e++){let t=e/255;s[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}let c=s.join(`,`),l=`g_${this.#r}_hcm_filter`,u=i.filter=this.#m(l);this.#g(c,c,c,u),this.#p(u);let d=(e,t)=>{let n=a[e]/255,r=o[e]/255,i=Array(t+1);for(let e=0;e<=t;e++)i[e]=n+e/t*(r-n);return i.join(`,`)};return this.#g(d(0,5),d(1,5),d(2,5),u),i.url=this.#d(l),i.url}addAlphaFilter(e){let t=this.#s.get(e);if(t)return t;let[n]=this.#u([e]),r=`alpha_${n}`;if(t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_alpha_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#_(n,o),a}addLuminosityFilter(e){let t=this.#s.get(e||`luminosity`);if(t)return t;let n,r;if(e?([n]=this.#u([e]),r=`luminosity_${n}`):r=`luminosity`,t=this.#s.get(r),t)return this.#s.set(e,t),t;let i=`g_${this.#r}_luminosity_map_${this.#o++}`,a=this.#d(i);this.#s.set(e,a),this.#s.set(r,a);let o=this.#m(i);return this.#f(o),e&&this.#_(n,o),a}addHighlightHCMFilter(e,t,n,r,i){let a=`${t}-${n}-${r}-${i}`,o=this.#c.get(e);if(o?.key===a||(o?(o.filter?.remove(),o.key=a,o.url=`none`,o.filter=null):(o={key:a,url:`none`,filter:null},this.#c.set(e,o)),!t||!n))return o.url;let[s,c]=[t,n].map(this.#v.bind(this)),l=Math.round(.2126*s[0]+.7152*s[1]+.0722*s[2]),u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[d,f]=[r,i].map(this.#v.bind(this));u<l&&([l,u,d,f]=[u,l,f,d]),this.#l.style.color=``;let p=(e,t,n)=>{let r=Array(256),i=(u-l)/n,a=e/255,o=(t-e)/(255*n),s=0;for(let e=0;e<=n;e++){let t=Math.round(l+e*i),n=a+e*o;for(let e=s;e<=t;e++)r[e]=n;s=t+1}for(let e=s;e<256;e++)r[e]=r[s-1];return r.join(`,`)},m=`g_${this.#r}_hcm_${e}_filter`,h=o.filter=this.#m(m);return this.#p(h),this.#g(p(d[0],f[0],5),p(d[1],f[1],5),p(d[2],f[2],5),h),o.url=this.#d(m),o.url}destroy(e=!1){e&&this.#a?.size||(this.#n?.parentNode.parentNode.remove(),this.#n=null,this.#t?.clear(),this.#t=null,this.#a?.clear(),this.#a=null,this.#o=0)}#f(e){let t=this.#i.createElementNS(Ha,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.setAttribute(`values`,`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0`),e.append(t)}#p(e){let t=this.#i.createElementNS(Ha,`feColorMatrix`);t.setAttribute(`type`,`matrix`),t.setAttribute(`values`,`0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0`),e.append(t)}#m(e){let t=this.#i.createElementNS(Ha,`filter`);return t.setAttribute(`color-interpolation-filters`,`sRGB`),t.setAttribute(`id`,e),this.#l.append(t),t}#h(e,t,n){let r=this.#i.createElementNS(Ha,t);r.setAttribute(`type`,`discrete`),r.setAttribute(`tableValues`,n),e.append(r)}#g(e,t,n,r){let i=this.#i.createElementNS(Ha,`feComponentTransfer`);r.append(i),this.#h(i,`feFuncR`,e),this.#h(i,`feFuncG`,t),this.#h(i,`feFuncB`,n)}#_(e,t){let n=this.#i.createElementNS(Ha,`feComponentTransfer`);t.append(n),this.#h(n,`feFuncA`,e)}#v(e){return this.#l.style.color=e,je(getComputedStyle(this.#l).getPropertyValue(`color`))}},Eo=class{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw Error(`Font filename must be specified.`);let t=`${this.baseUrl}${e}`;return this._fetch(t).catch(e=>{throw Error(`Unable to load font data at: ${t}`)})}async _fetch(e){U("Abstract method `_fetch` called.")}},Do=class extends Eo{async _fetch(e){let t=await Ce(e,`arraybuffer`);return new Uint8Array(t)}},fa){let e;try{let t=process.getBuiltinModule(`module`).createRequire(require("url").pathToFileURL(__filename).href);try{e=t(`@napi-rs/canvas`)}catch(e){H(`Cannot load "@napi-rs/canvas" package: "${e}".`)}}catch(e){H(`Cannot access the \`require\` function: "${e}".`)}globalThis.DOMMatrix||(e?.DOMMatrix?globalThis.DOMMatrix=e.DOMMatrix:H("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.ImageData||(e?.ImageData?globalThis.ImageData=e.ImageData:H("Cannot polyfill `ImageData`, rendering may be broken.")),globalThis.Path2D||(e?.Path2D?globalThis.Path2D=e.Path2D:H("Cannot polyfill `Path2D`, rendering may be broken."))}Oo=class extends wo{},ko=class extends bo{_createCanvas(e,t){return process.getBuiltinModule(`module`).createRequire(require("url").pathToFileURL(__filename).href)(`@napi-rs/canvas`).createCanvas(e,t)}},Ao=class extends So{async _fetch(e){return K(e)}},jo=class extends Eo{async _fetch(e){return K(e)}},Mo={FILL:`Fill`,STROKE:`Stroke`,SHADING:`Shading`},No=class{getPattern(){U("Abstract method `getPattern` called.")}},Po=class extends No{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;this._type===`axial`?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type===`radial`&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let e of this._colorStops)t.addColorStop(e[0],e[1]);return t}getPattern(e,t,n,r){let i;if(r===Mo.STROKE||r===Mo.FILL){let a=t.current.getClippedPathBoundingBox(r,Ne(e))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,s=Math.ceil(a[3]-a[1])||1,c=t.cachedCanvases.getCanvas(`pattern`,o,s),l=c.context;l.clearRect(0,0,l.canvas.width,l.canvas.height),l.beginPath(),l.rect(0,0,l.canvas.width,l.canvas.height),l.translate(-a[0],-a[1]),n=Y.transform(n,[1,0,0,1,a[0],a[1]]),l.transform(...t.baseTransform),this.matrix&&l.transform(...this.matrix),ze(l,this._bbox),l.fillStyle=this._createGradient(l),l.fill(),i=e.createPattern(c.canvas,`no-repeat`);let u=new DOMMatrix(n);i.setTransform(u)}else ze(e,this._bbox),i=this._createGradient(e);return i}},Fo=class extends No{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[7],this._background=e[8],this.matrix=null}_createMeshCanvas(e,t,n){let r=1.1,i=3e3,a=Math.floor(this._bounds[0]),o=Math.floor(this._bounds[1]),s=Math.ceil(this._bounds[2])-a,c=Math.ceil(this._bounds[3])-o,l=Math.min(Math.ceil(Math.abs(s*e[0]*r)),i),u=Math.min(Math.ceil(Math.abs(c*e[1]*r)),i),d=s/l,f=c/u,p={coords:this._coords,colors:this._colors,offsetX:-a,offsetY:-o,scaleX:1/d,scaleY:1/f},m=l+4,h=u+4,g=n.getCanvas(`mesh`,m,h),_=g.context,v=_.createImageData(l,u);if(t){let e=v.data;for(let n=0,r=e.length;n<r;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=255}for(let e of this._figures)Be(v,e,p);return _.putImageData(v,2,2),{canvas:g.canvas,offsetX:a-2*d,offsetY:o-2*f,scaleX:d,scaleY:f}}getPattern(e,t,n,r){ze(e,this._bbox);let i;if(r===Mo.SHADING)i=Y.singularValueDecompose2dScale(Ne(e));else if(i=Y.singularValueDecompose2dScale(t.baseTransform),this.matrix){let e=Y.singularValueDecompose2dScale(this.matrix);i=[i[0]*e[0],i[1]*e[1]]}let a=this._createMeshCanvas(i,r===Mo.SHADING?null:this._background,t.cachedCanvases);return r!==Mo.SHADING&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(a.offsetX,a.offsetY),e.scale(a.scaleX,a.scaleY),e.createPattern(a.canvas,`no-repeat`)}},Io=class extends No{getPattern(){return`hotpink`}},Lo={COLORED:1,UNCOLORED:2},Ro=class e{static MAX_PATTERN_SIZE=3e3;constructor(e,t,n,r,i){this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.color=t,this.ctx=n,this.canvasGraphicsFactory=r,this.baseTransform=i}createPatternCanvas(e){let{bbox:t,operatorList:n,paintType:r,tilingType:i,color:a,canvasGraphicsFactory:o}=this,{xstep:s,ystep:c}=this;s=Math.abs(s),c=Math.abs(c),V(`TilingType: `+i);let l=t[0],u=t[1],d=t[2],f=t[3],p=d-l,m=f-u,h=Y.singularValueDecompose2dScale(this.matrix),g=Y.singularValueDecompose2dScale(this.baseTransform),_=h[0]*g[0],v=h[1]*g[1],y=p,b=m,x=!1,S=!1,C=Math.ceil(s*_),w=Math.ceil(c*v),T=Math.ceil(p*_),E=Math.ceil(m*v);C>=T?y=s:x=!0,w>=E?b=c:S=!0;let D=this.getSizeAndScale(y,this.ctx.canvas.width,_),O=this.getSizeAndScale(b,this.ctx.canvas.height,v),k=e.cachedCanvases.getCanvas(`pattern`,D.size,O.size),A=k.context,j=o.createCanvasGraphics(A);if(j.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(j,r,a),A.translate(-D.scale*l,-O.scale*u),j.transform(D.scale,0,0,O.scale,0,0),A.save(),this.clipBbox(j,l,u,d,f),j.baseTransform=Ne(j.ctx),j.executeOperatorList(n),j.endDrawing(),A.restore(),x||S){let t=k.canvas;x&&(y=s),S&&(b=c);let n=this.getSizeAndScale(y,this.ctx.canvas.width,_),r=this.getSizeAndScale(b,this.ctx.canvas.height,v),i=n.size,a=r.size,o=e.cachedCanvases.getCanvas(`pattern-workaround`,i,a),d=o.context,f=x?Math.floor(p/s):0,h=S?Math.floor(m/c):0;for(let e=0;e<=f;e++)for(let n=0;n<=h;n++)d.drawImage(t,i*e,a*n,i,a,0,0,i,a);return{canvas:o.canvas,scaleX:n.scale,scaleY:r.scale,offsetX:l,offsetY:u}}return{canvas:k.canvas,scaleX:D.scale,scaleY:O.scale,offsetX:l,offsetY:u}}getSizeAndScale(t,n,r){let i=Math.max(e.MAX_PATTERN_SIZE,n),a=Math.ceil(t*r);return a>=i?a=i:r=a/t,{scale:r,size:a}}clipBbox(e,t,n,r,i){let a=r-t,o=i-n;e.ctx.rect(t,n,a,o),e.current.updateRectMinMax(Ne(e.ctx),[t,n,r,i]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,n){let r=e.ctx,i=e.current;switch(t){case Lo.COLORED:let e=this.ctx;r.fillStyle=e.fillStyle,r.strokeStyle=e.strokeStyle,i.fillColor=e.fillStyle,i.strokeColor=e.strokeStyle;break;case Lo.UNCOLORED:let a=Y.makeHexColor(n[0],n[1],n[2]);r.fillStyle=a,r.strokeStyle=a,i.fillColor=a,i.strokeColor=a;break;default:throw new Fa(`Unsupported paint type: ${t}`)}}getPattern(e,t,n,r){let i=n;r!==Mo.SHADING&&(i=Y.transform(i,t.baseTransform),this.matrix&&(i=Y.transform(i,this.matrix)));let a=this.createPatternCanvas(t),o=new DOMMatrix(i);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);let s=e.createPattern(a.canvas,`repeat`);return s.setTransform(o),s}},zo=16,Bo=100,Vo=15,Ho=10,Uo=1e3,Wo=16,Go=class{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,n){let r;return this.cache[e]===void 0?(r=this.canvasFactory.create(t,n),this.cache[e]=r):(r=this.cache[e],this.canvasFactory.reset(r,t,n)),r}delete(e){delete this.cache[e]}clear(){for(let e in this.cache){let t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}},Ko=class{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=pa,this.textMatrixScale=1,this.fontMatrix=ma,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=xa.FILL,this.textRise=0,this.fillColor=`#000000`,this.strokeColor=`#000000`,this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps=`none`,this.startNewPathAndClipBox([0,0,e,t])}clone(){let e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,n){[t,n]=Y.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(e,t){let n=Y.applyTransform(t,e),r=Y.applyTransform(t.slice(2),e),i=Y.applyTransform([t[0],t[3]],e),a=Y.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,n[0],r[0],i[0],a[0]),this.minY=Math.min(this.minY,n[1],r[1],i[1],a[1]),this.maxX=Math.max(this.maxX,n[0],r[0],i[0],a[0]),this.maxY=Math.max(this.maxY,n[1],r[1],i[1],a[1])}updateScalingPathMinMax(e,t){Y.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.minY=Math.min(this.minY,t[1]),this.maxX=Math.max(this.maxX,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,r,i,a,o,s,c,l){let u=Y.bezierBoundingBox(t,n,r,i,a,o,s,c,l);l||this.updateRectMinMax(e,u)}getPathBoundingBox(e=Mo.FILL,t=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(e===Mo.STROKE){t||U(`Stroke bounding box must include transform.`);let e=Y.singularValueDecompose2dScale(t),r=e[0]*this.lineWidth/2,i=e[1]*this.lineWidth/2;n[0]-=r,n[1]-=i,n[2]+=r,n[3]+=i}return n}updateClipFromPath(){let e=Y.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=Mo.FILL,t=null){return Y.intersect(this.clipBox,this.getPathBoundingBox(e,t))}},qo=[`butt`,`round`,`square`],Jo=[`miter`,`round`,`bevel`],Yo={},Xo={},Zo=class e{constructor(e,t,n,r,i,{optionalContentConfig:a,markedContentStack:o=null},s,c){this.ctx=e,this.current=new Ko(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=t,this.objs=n,this.canvasFactory=r,this.filterFactory=i,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedCanvases=new Go(this.canvasFactory),this.cachedPatterns=/* @__PURE__ */ new Map,this.annotationCanvasMap=s,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=/* @__PURE__ */ new Map}getObject(e,t=null){return typeof e==`string`?e.startsWith(`g_`)?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:r=null}){let i=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=r||`#ffffff`,this.ctx.fillRect(0,0,i,a),this.ctx.fillStyle=o,n){let e=this.cachedCanvases.getCanvas(`transparent`,i,a);this.compositeCtx=this.ctx,this.transparentCanvas=e.canvas,this.ctx=e.context,this.ctx.save(),this.ctx.transform(...Ne(this.compositeCtx))}this.ctx.save(),Ye(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=Ne(this.ctx)}executeOperatorList(e,t,n,r){let i=e.argsArray,a=e.fnArray,o=t||0,s=i.length;if(s===o)return o;let c=s-o>Ho&&typeof n==`function`,l=c?Date.now()+Vo:0,u=0,d=this.commonObjs,f=this.objs,p;for(;;){if(r!==void 0&&o===r.nextBreakPoint)return r.breakIt(o,n),o;if(p=a[o],p!==Ea.dependency)this[p].apply(this,i[o]);else for(let e of i[o]){let t=e.startsWith(`g_`)?d:f;if(!t.has(e))return t.get(e,n),o}if(o++,o===s)return o;if(c&&++u>Ho){if(Date.now()>l)return n(),o;u=0}}}#e(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&=(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),null)}endDrawing(){this.#e(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let e of this._cachedBitmapsMap.values()){for(let t of e.values())typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),this.#t()}#t(){if(this.pageColors){let e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!==`none`){let t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}_scaleImage(e,t){let n=e.width??e.displayWidth,r=e.height??e.displayHeight,i=Math.max(Math.hypot(t[0],t[1]),1),a=Math.max(Math.hypot(t[2],t[3]),1),o=n,s=r,c=`prescale1`,l,u;for(;i>2&&o>1||a>2&&s>1;){let t=o,n=s;i>2&&o>1&&(t=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),i/=o/t),a>2&&s>1&&(n=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s)/2,a/=s/n),l=this.cachedCanvases.getCanvas(c,t,n),u=l.context,u.clearRect(0,0,t,n),u.drawImage(e,0,0,o,s,0,0,t,n),e=l.canvas,o=t,s=n,c=c===`prescale1`?`prescale2`:`prescale1`}return{img:e,paintWidth:o,paintHeight:s}}_createMaskCanvas(e){let t=this.ctx,{width:n,height:r}=e,i=this.current.fillColor,a=this.current.patternFill,o=Ne(t),s,c,l,u;if((e.bitmap||e.data)&&e.count>1){let t=e.bitmap||e.data.buffer;c=JSON.stringify(a?o:[o.slice(0,4),i]),s=this._cachedBitmapsMap.get(t),s||(s=/* @__PURE__ */ new Map,this._cachedBitmapsMap.set(t,s));let n=s.get(c);if(n&&!a)return{canvas:n,offsetX:Math.round(Math.min(o[0],o[2])+o[4]),offsetY:Math.round(Math.min(o[1],o[3])+o[5])};l=n}l||(u=this.cachedCanvases.getCanvas(`maskCanvas`,n,r),qe(u.context,e));let d=Y.transform(o,[1/n,0,0,-1/r,0,0]);d=Y.transform(d,[1,0,0,1,0,-r]);let[f,p,m,h]=Y.getAxialAlignedBoundingBox([0,0,n,r],d),g=Math.round(m-f)||1,_=Math.round(h-p)||1,v=this.cachedCanvases.getCanvas(`fillCanvas`,g,_),y=v.context,b=f,x=p;y.translate(-b,-x),y.transform(...d),l||(l=this._scaleImage(u.canvas,Pe(y)),l=l.img,s&&a&&s.set(c,l)),y.imageSmoothingEnabled=Xe(Ne(y),e.interpolate),We(y,l,0,0,l.width,l.height,0,0,n,r),y.globalCompositeOperation=`source-in`;let S=Y.transform(Pe(y),[1,0,0,1,-b,-x]);return y.fillStyle=a?i.getPattern(t,this,S,Mo.FILL):i,y.fillRect(0,0,n,r),s&&!a&&(this.cachedCanvases.delete(`fillCanvas`),s.set(c,v.canvas)),{canvas:v.canvas,offsetX:Math.round(b),offsetY:Math.round(x)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=qo[e]}setLineJoin(e){this.ctx.lineJoin=Jo[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){let n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(e),n.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,n]of e)switch(t){case`LW`:this.setLineWidth(n);break;case`LC`:this.setLineCap(n);break;case`LJ`:this.setLineJoin(n);break;case`ML`:this.setMiterLimit(n);break;case`D`:this.setDash(n[0],n[1]);break;case`RI`:this.setRenderingIntent(n);break;case`FL`:this.setFlatness(n);break;case`Font`:this.setFont(n[0],n[1]);break;case`CA`:this.current.strokeAlpha=n;break;case`ca`:this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case`BM`:this.ctx.globalCompositeOperation=n;break;case`SMask`:this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case`TR`:this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw Error(`beginSMaskMode called while already in smask mode`);let e=this.ctx.canvas.width,t=this.ctx.canvas.height,n=`smaskGroupAt`+this.groupLevel,r=this.cachedCanvases.getCanvas(n,e,t);this.suspendedCtx=this.ctx,this.ctx=r.context;let i=this.ctx;i.setTransform(...Ne(this.suspendedCtx)),Je(this.suspendedCtx,i),Ue(i,this.suspendedCtx),this.setGState([[`BM`,`source-over`],[`ca`,1],[`CA`,1]])}endSMaskMode(){if(!this.inSMaskMode)throw Error(`endSMaskMode called while not in smask mode`);this.ctx._removeMirroring(),Je(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let t=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,t,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,t,n,r){let i=r[0],a=r[1],o=r[2]-i,s=r[3]-a;o!==0&&s!==0&&(this.genericComposeSMask(t.context,n,o,s,t.subtype,t.backdrop,t.transferMap,i,a,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation=`source-over`,e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,0,0),e.restore())}genericComposeSMask(e,t,n,r,i,a,o,s,c,l,u){let d=e.canvas,f=s-l,p=c-u;if(a){let t=Y.makeHexColor(...a);if(f<0||p<0||f+n>d.width||p+r>d.height){let e=this.cachedCanvases.getCanvas(`maskExtension`,n,r),i=e.context;i.drawImage(d,-f,-p),i.globalCompositeOperation=`destination-atop`,i.fillStyle=t,i.fillRect(0,0,n,r),i.globalCompositeOperation=`source-over`,d=e.canvas,f=p=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);let i=new Path2D;i.rect(f,p,n,r),e.clip(i),e.globalCompositeOperation=`destination-atop`,e.fillStyle=t,e.fillRect(f,p,n,r),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),i===`Alpha`&&o?t.filter=this.filterFactory.addAlphaFilter(o):i===`Luminosity`&&(t.filter=this.filterFactory.addLuminosityFilter(o));let m=new Path2D;m.rect(s,c,n,r),t.clip(m),t.globalCompositeOperation=`destination-in`,t.drawImage(d,f,p,n,r,s,c,n,r),t.restore()}save(){this.inSMaskMode?(Je(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Je(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,n,r,i,a){this.ctx.transform(e,t,n,r,i,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,n){let r=this.ctx,i=this.current,a=i.x,o=i.y,s,c,l=Ne(r),u=l[0]===0&&l[3]===0||l[1]===0&&l[2]===0,d=u?n.slice(0):null;for(let n=0,f=0,p=e.length;n<p;n++)switch(e[n]|0){case Ea.rectangle:a=t[f++],o=t[f++];let e=t[f++],n=t[f++],p=a+e,m=o+n;r.moveTo(a,o),e===0||n===0?r.lineTo(p,m):(r.lineTo(p,o),r.lineTo(p,m),r.lineTo(a,m)),u||i.updateRectMinMax(l,[a,o,p,m]),r.closePath();break;case Ea.moveTo:a=t[f++],o=t[f++],r.moveTo(a,o),u||i.updatePathMinMax(l,a,o);break;case Ea.lineTo:a=t[f++],o=t[f++],r.lineTo(a,o),u||i.updatePathMinMax(l,a,o);break;case Ea.curveTo:s=a,c=o,a=t[f+4],o=t[f+5],r.bezierCurveTo(t[f],t[f+1],t[f+2],t[f+3],a,o),i.updateCurvePathMinMax(l,s,c,t[f],t[f+1],t[f+2],t[f+3],a,o,d),f+=6;break;case Ea.curveTo2:s=a,c=o,r.bezierCurveTo(a,o,t[f],t[f+1],t[f+2],t[f+3]),i.updateCurvePathMinMax(l,s,c,a,o,t[f],t[f+1],t[f+2],t[f+3],d),a=t[f+2],o=t[f+3],f+=4;break;case Ea.curveTo3:s=a,c=o,a=t[f+2],o=t[f+3],r.bezierCurveTo(t[f],t[f+1],a,o,a,o),i.updateCurvePathMinMax(l,s,c,t[f],t[f+1],a,o,a,o,d),f+=4;break;case Ea.closePath:r.closePath()}u&&i.updateScalingPathMinMax(l,d),i.setCurrentPoint(a,o)}closePath(){this.ctx.closePath()}stroke(e=!0){let t=this.ctx,n=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof n==`object`&&n?.getPattern?(t.save(),t.strokeStyle=n.getPattern(t,this,Pe(t),Mo.STROKE),this.rescaleAndStroke(!1),t.restore()):this.rescaleAndStroke(!0)),e&&this.consumePath(this.current.getClippedPathBoundingBox()),t.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){let t=this.ctx,n=this.current.fillColor,r=this.current.patternFill,i=!1;r&&(t.save(),t.fillStyle=n.getPattern(t,this,Pe(t),Mo.FILL),i=!0);let a=this.current.getClippedPathBoundingBox();this.contentVisible&&a!==null&&(this.pendingEOFill?(t.fill(`evenodd`),this.pendingEOFill=!1):t.fill()),i&&t.restore(),e&&this.consumePath(a)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Yo}eoClip(){this.pendingClip=Xo}beginText(){this.current.textMatrix=pa,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let e=this.pendingTextPaths,t=this.ctx;if(e===void 0){t.beginPath();return}let n=new Path2D,r=t.getTransform().invertSelf();for(let{transform:t,x:i,y:a,fontSize:o,path:s}of e)n.addPath(s,new DOMMatrix(t).preMultiplySelf(r).translate(i,a).scale(o,-o));t.clip(n),t.beginPath(),delete this.pendingTextPaths}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){let n=this.commonObjs.get(e),r=this.current;if(!n)throw Error(`Can't find font for ${e}`);if(r.fontMatrix=n.fontMatrix||ma,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&H(`Invalid font matrix for font `+e),t<0?(t=-t,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=t,n.isType3Font)return;let i=n.loadedName||`sans-serif`,a=n.systemFontInfo?.css||`"${i}", ${n.fallbackName}`,o=`normal`;n.black?o=`900`:n.bold&&(o=`bold`);let s=n.italic?`italic`:`normal`,c=t;t<zo?c=zo:t>Bo&&(c=Bo),this.current.fontSizeScale=t/c,this.ctx.font=`${s} ${o} ${c}px ${a}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,n,r,i,a){this.current.textMatrix=[e,t,n,r,i,a],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#n(e,t,n){let r=new Path2D;return r.addPath(e,new DOMMatrix(n).invertSelf().multiplySelf(t)),r}paintChar(e,t,n,r,i){let a=this.ctx,o=this.current,s=o.font,c=o.textRenderingMode,l=o.fontSize/o.fontSizeScale,u=c&xa.FILL_STROKE_MASK,d=!!(c&xa.ADD_TO_PATH_FLAG),f=o.patternFill&&!s.missingFile,p=o.patternStroke&&!s.missingFile,m;if((s.disableFontFace||d||f||p)&&(m=s.getPathGenerator(this.commonObjs,e)),s.disableFontFace||f||p){if(a.save(),a.translate(t,n),a.scale(l,-l),u===xa.FILL||u===xa.FILL_STROKE){if(r){let e=a.getTransform();a.setTransform(...r),a.fill(this.#n(m,e,r))}else a.fill(m)}if(u===xa.STROKE||u===xa.FILL_STROKE){if(i){let e=a.getTransform();a.setTransform(...i),a.stroke(this.#n(m,e,i))}else a.lineWidth/=l,a.stroke(m)}a.restore()}else(u===xa.FILL||u===xa.FILL_STROKE)&&a.fillText(e,t,n),(u===xa.STROKE||u===xa.FILL_STROKE)&&a.strokeText(e,t,n);d&&(this.pendingTextPaths||=[]).push({transform:Ne(a),x:t,y:n,fontSize:l,path:m})}get isFontSubpixelAAEnabled(){let{context:e}=this.cachedCanvases.getCanvas(`isFontSubpixelAAEnabled`,10,10);e.scale(1.5,1),e.fillText(`I`,0,10);let t=e.getImageData(0,0,10,10).data,n=!1;for(let e=3;e<t.length;e+=4)if(t[e]>0&&t[e]<255){n=!0;break}return W(this,`isFontSubpixelAAEnabled`,n)}showText(e){let t=this.current,n=t.font;if(n.isType3Font)return this.showType3Text(e);let r=t.fontSize;if(r===0)return;let i=this.ctx,a=t.fontSizeScale,o=t.charSpacing,s=t.wordSpacing,c=t.fontDirection,l=t.textHScale*c,u=e.length,d=n.vertical,f=d?1:-1,p=n.defaultVMetrics,m=r*t.fontMatrix[0],h=t.textRenderingMode===xa.FILL&&!n.disableFontFace&&!t.patternFill;i.save(),i.transform(...t.textMatrix),i.translate(t.x,t.y+t.textRise),c>0?i.scale(l,-1):i.scale(l,1);let g,_;if(t.patternFill){i.save();let e=t.fillColor.getPattern(i,this,Pe(i),Mo.FILL);g=Ne(i),i.restore(),i.fillStyle=e}if(t.patternStroke){i.save();let e=t.strokeColor.getPattern(i,this,Pe(i),Mo.STROKE);_=Ne(i),i.restore(),i.strokeStyle=e}let v=t.lineWidth,y=t.textMatrixScale;if(y===0||v===0){let e=t.textRenderingMode&xa.FILL_STROKE_MASK;(e===xa.STROKE||e===xa.FILL_STROKE)&&(v=this.getSinglePixelWidth())}else v/=y;if(a!==1&&(i.scale(a,a),v/=a),i.lineWidth=v,n.isInvalidPDFjsFont){let n=[],r=0;for(let t of e)n.push(t.unicode),r+=t.width;i.fillText(n.join(``),0,0),t.x+=r*m*l,i.restore(),this.compose();return}let b=0,x=0;for(;x<u;++x){let t=e[x];if(typeof t==`number`){b+=f*t*r/1e3;continue}let l=!1,u=(t.isSpace?s:0)+o,v=t.fontChar,y=t.accent,S,C,w=t.width;if(d){let e=t.vmetric||p,n=-(t.vmetric?e[1]:w*.5)*m,r=e[2]*m;w=e?-e[0]:w,S=n/a,C=(b+r)/a}else S=b/a,C=0;if(n.remeasure&&w>0){let e=i.measureText(v).width*1e3/r*a;if(w<e&&this.isFontSubpixelAAEnabled){let t=w/e;l=!0,i.save(),i.scale(t,1),S/=t}else w!==e&&(S+=(w-e)/2e3*r/a)}if(this.contentVisible&&(t.isInFont||n.missingFile)){if(h&&!y)i.fillText(v,S,C);else if(this.paintChar(v,S,C,g,_),y){let e=S+r*y.offset.x/a,t=C-r*y.offset.y/a;this.paintChar(y.fontChar,e,t,g,_)}}let T=d?w*m-u*c:w*m+u*c;b+=T,l&&i.restore()}d?t.y-=b:t.x+=b*l,i.restore(),this.compose()}showType3Text(e){let t=this.ctx,n=this.current,r=n.font,i=n.fontSize,a=n.fontDirection,o=r.vertical?1:-1,s=n.charSpacing,c=n.wordSpacing,l=n.textHScale*a,u=n.fontMatrix||ma,d=e.length,f=n.textRenderingMode===xa.INVISIBLE,p,m,h,g;if(!(f||i===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,t.save(),t.transform(...n.textMatrix),t.translate(n.x,n.y),t.scale(l,a),p=0;p<d;++p){if(m=e[p],typeof m==`number`){g=o*m*i/1e3,this.ctx.translate(g,0),n.x+=g*l;continue}let a=(m.isSpace?c:0)+s,d=r.charProcOperatorList[m.operatorListId];d?(this.contentVisible&&(this.processingType3=m,this.save(),t.scale(i,i),t.transform(...u),this.executeOperatorList(d),this.restore()),h=Y.applyTransform([m.width,0],u)[0]*i+a,t.translate(h,0),n.x+=h*l):H(`Type3 character "${m.operatorListId}" is not available.`)}t.restore(),this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,n,r,i,a){this.ctx.rect(n,r,i-n,a-r),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let n;if(t[0]===`TilingPattern`){let r=t[1],i=this.baseTransform||Ne(this.ctx);n=new Ro(t,r,this.ctx,{createCanvasGraphics:t=>new e(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})},i)}else n=this._getPattern(t[1],t[2]);return n}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,n){this.ctx.strokeStyle=this.current.strokeColor=Y.makeHexColor(e,t,n),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor=`transparent`,this.current.patternStroke=!1}setFillRGBColor(e,t,n){this.ctx.fillStyle=this.current.fillColor=Y.makeHexColor(e,t,n),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor=`transparent`,this.current.patternFill=!1}_getPattern(e,t=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=Ve(this.getObject(e)),this.cachedPatterns.set(e,n)),t&&(n.matrix=t),n}shadingFill(e){if(!this.contentVisible)return;let t=this.ctx;this.save(),t.fillStyle=this._getPattern(e).getPattern(t,this,Pe(t),Mo.SHADING);let n=Pe(t);if(n){let{width:e,height:r}=t.canvas,[i,a,o,s]=Y.getAxialAlignedBoundingBox([0,0,e,r],n);this.ctx.fillRect(i,a,o-i,s-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){U(`Should not call beginInlineImage`)}beginImageData(){U(`Should not call beginImageData`)}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=Ne(this.ctx),t)){let e=t[2]-t[0],n=t[3]-t[1];this.ctx.rect(t[0],t[1],e,n),this.current.updateRectMinMax(Ne(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let t=this.ctx;e.isolated||V(`TODO: Support non-isolated groups.`),e.knockout&&H(`Knockout groups not supported.`);let n=Ne(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw Error(`Bounding box is required.`);let r=Y.getAxialAlignedBoundingBox(e.bbox,Ne(t)),i=[0,0,t.canvas.width,t.canvas.height];r=Y.intersect(r,i)||[0,0,0,0];let a=Math.floor(r[0]),o=Math.floor(r[1]),s=Math.max(Math.ceil(r[2])-a,1),c=Math.max(Math.ceil(r[3])-o,1);this.current.startNewPathAndClipBox([0,0,s,c]);let l=`groupAt`+this.groupLevel;e.smask&&(l+=`_smask_`+this.smaskCounter++%2);let u=this.cachedCanvases.getCanvas(l,s,c),d=u.context;d.translate(-a,-o),d.transform(...n),e.smask?this.smaskStack.push({canvas:u.canvas,context:d,offsetX:a,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(a,o),t.save()),Je(t,d),this.ctx=d,this.setGState([[`BM`,`source-over`],[`ca`,1],[`CA`,1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;let t=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let e=Ne(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...e);let n=Y.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],e);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(e,t,n,r,i){if(this.#e(),Ye(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){let r=t[2]-t[0],a=t[3]-t[1];if(i&&this.annotationCanvasMap){n=n.slice(),n[4]-=t[0],n[5]-=t[1],t=t.slice(),t[0]=t[1]=0,t[2]=r,t[3]=a;let[i,o]=Y.singularValueDecompose2dScale(Ne(this.ctx)),{viewportScale:s}=this,c=Math.ceil(r*this.outputScaleX*s),l=Math.ceil(a*this.outputScaleY*s);this.annotationCanvas=this.canvasFactory.create(c,l);let{canvas:u,context:d}=this.annotationCanvas;this.annotationCanvasMap.set(e,u),this.annotationCanvas.savedCtx=this.ctx,this.ctx=d,this.ctx.save(),this.ctx.setTransform(i,0,0,-o,0,a*o),Ye(this.ctx)}else Ye(this.ctx),this.endPath(),this.ctx.rect(t[0],t[1],r,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new Ko(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#t(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;let t=e.count;e=this.getObject(e.data,e),e.count=t;let n=this.ctx,r=this.processingType3;if(r&&(r.compiled===void 0&&(r.compiled=Ge(e)),r.compiled)){r.compiled(n);return}let i=this._createMaskCanvas(e),a=i.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(a,i.offsetX,i.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,n=0,r=0,i,a){if(!this.contentVisible)return;e=this.getObject(e.data,e);let o=this.ctx;o.save();let s=Ne(o);o.transform(t,n,r,i,0,0);let c=this._createMaskCanvas(e);o.setTransform(1,0,0,1,c.offsetX-s[4],c.offsetY-s[5]);for(let e=0,l=a.length;e<l;e+=2){let l=Y.transform(s,[t,n,r,i,a[e],a[e+1]]),[u,d]=Y.applyTransform([0,0],l);o.drawImage(c.canvas,u,d)}o.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;let t=this.ctx,n=this.current.fillColor,r=this.current.patternFill;for(let i of e){let{data:e,width:a,height:o,transform:s}=i,c=this.cachedCanvases.getCanvas(`maskCanvas`,a,o),l=c.context;l.save(),qe(l,this.getObject(e,i)),l.globalCompositeOperation=`source-in`,l.fillStyle=r?n.getPattern(l,this,Pe(t),Mo.FILL):n,l.fillRect(0,0,a,o),l.restore(),t.save(),t.transform(...s),t.scale(1,-1),We(t,c.canvas,0,0,a,o,0,-1,1,1),t.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;let t=this.getObject(e);t?this.paintInlineImageXObject(t):H(`Dependent image isn't ready yet`)}paintImageXObjectRepeat(e,t,n,r){if(!this.contentVisible)return;let i=this.getObject(e);if(!i){H(`Dependent image isn't ready yet`);return}let a=i.width,o=i.height,s=[];for(let e=0,i=r.length;e<i;e+=2)s.push({transform:[t,0,0,n,r[e],r[e+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(i,s)}applyTransferMapsToCanvas(e){return this.current.transferMaps!==`none`&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter=`none`),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps===`none`)return e.bitmap;let{bitmap:t,width:n,height:r}=e,i=this.cachedCanvases.getCanvas(`inlineImage`,n,r),a=i.context;return a.filter=this.current.transferMaps,a.drawImage(t,0,0),a.filter=`none`,i.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;let t=e.width,n=e.height,r=this.ctx;if(this.save(),!fa){let{filter:e}=r;e!==`none`&&e!==``&&(r.filter=`none`)}r.scale(1/t,-1/n);let i;if(e.bitmap)i=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement==`function`&&e instanceof HTMLElement||!e.data)i=e;else{let r=this.cachedCanvases.getCanvas(`inlineImage`,t,n).context;Ke(r,e),i=this.applyTransferMapsToCanvas(r)}let a=this._scaleImage(i,Pe(r));r.imageSmoothingEnabled=Xe(Ne(r),e.interpolate),We(r,a.img,0,0,a.paintWidth,a.paintHeight,0,-n,t,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(e,t){if(!this.contentVisible)return;let n=this.ctx,r;if(e.bitmap)r=e.bitmap;else{let t=e.width,n=e.height,i=this.cachedCanvases.getCanvas(`inlineImage`,t,n).context;Ke(i,e),r=this.applyTransferMapsToCanvas(i)}for(let e of t)n.save(),n.transform(...e.transform),n.scale(1,-1),We(n,r,e.x,e.y,e.w,e.h,0,-1,1,1),n.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){e===`OC`?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){let t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);let n=this.ctx;this.pendingClip&&=(t||(this.pendingClip===Xo?n.clip(`evenodd`):n.clip()),null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let e=Ne(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{let t=Math.abs(e[0]*e[3]-e[2]*e[1]),n=Math.hypot(e[0],e[2]),r=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(n,r)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:e}=this.current,{a:t,b:n,c:r,d:i}=this.ctx.getTransform(),a,o;if(n===0&&r===0){let n=Math.abs(t),r=Math.abs(i);if(n===r){if(e===0)a=o=1/n;else{let t=n*e;a=o=t<1?1/t:1}}else if(e===0)a=1/n,o=1/r;else{let t=n*e,i=r*e;a=t<1?1/t:1,o=i<1?1/i:1}}else{let s=Math.abs(t*i-n*r),c=Math.hypot(t,n),l=Math.hypot(r,i);if(e===0)a=l/s,o=c/s;else{let t=e*s;a=l>t?l/t:1,o=c>t?c/t:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(e){let{ctx:t}=this,{lineWidth:n}=this.current,[r,i]=this.getScaleForStroking();if(t.lineWidth=n||1,r===1&&i===1){t.stroke();return}let a=t.getLineDash();if(e&&t.save(),t.scale(r,i),a.length>0){let e=Math.max(r,i);t.setLineDash(a.map(t=>t/e)),t.lineDashOffset/=e}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};for(let e in Ea)Zo.prototype[e]!==void 0&&(Zo.prototype[Ea[e]]=Zo.prototype[e]);Qo=class{static#e=null;static#t=``;static get workerPort(){return this.#e}static set workerPort(e){if(!(typeof Worker<`u`&&e instanceof Worker)&&e!==null)throw Error("Invalid `workerPort` type.");this.#e=e}static get workerSrc(){return this.#t}static set workerSrc(e){if(typeof e!=`string`)throw Error("Invalid `workerSrc` type.");this.#t=e}},$o=class{#e;#t;constructor({parsedData:e,rawData:t}){this.#e=e,this.#t=t}getRaw(){return this.#t}get(e){return this.#e.get(e)??null}getAll(){return ge(this.#e)}has(e){return this.#e.has(e)}},es=Symbol(`INTERNAL`),ts=class{#e=!1;#t=!1;#n=!1;#r=!0;constructor(e,{name:t,intent:n,usage:r,rbGroups:i}){this.#e=!!(e&ga.DISPLAY),this.#t=!!(e&ga.PRINT),this.name=t,this.intent=n,this.usage=r,this.rbGroups=i}get visible(){if(this.#n)return this.#r;if(!this.#r)return!1;let{print:e,view:t}=this.usage;return this.#e?t?.viewState!==`OFF`:!this.#t||e?.printState!==`OFF`}_setVisible(e,t,n=!1){e!==es&&U("Internal method `_setVisible` called."),this.#n=n,this.#r=t}},ns=class{#e=null;#t=/* @__PURE__ */ new Map;#n=null;#r=null;constructor(e,t=ga.DISPLAY){if(this.renderingIntent=t,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,this.#r=e.order;for(let n of e.groups)this.#t.set(n.id,new ts(t,n));if(e.baseState===`OFF`)for(let e of this.#t.values())e._setVisible(es,!1);for(let t of e.on)this.#t.get(t)._setVisible(es,!0);for(let t of e.off)this.#t.get(t)._setVisible(es,!1);this.#n=this.getHash()}}#i(e){let t=e.length;if(t<2)return!0;let n=e[0];for(let r=1;r<t;r++){let t=e[r],i;if(Array.isArray(t))i=this.#i(t);else if(this.#t.has(t))i=this.#t.get(t).visible;else return H(`Optional content group not found: ${t}`),!0;switch(n){case`And`:if(!i)return!1;break;case`Or`:if(i)return!0;break;case`Not`:return!i;default:return!0}}return n===`And`}isVisible(e){if(this.#t.size===0)return!0;if(!e)return V(`Optional content group not defined.`),!0;if(e.type===`OCG`)return this.#t.has(e.id)?this.#t.get(e.id).visible:(H(`Optional content group not found: ${e.id}`),!0);if(e.type===`OCMD`){if(e.expression)return this.#i(e.expression);if(!e.policy||e.policy===`AnyOn`){for(let t of e.ids){if(!this.#t.has(t))return H(`Optional content group not found: ${t}`),!0;if(this.#t.get(t).visible)return!0}return!1}if(e.policy===`AllOn`){for(let t of e.ids){if(!this.#t.has(t))return H(`Optional content group not found: ${t}`),!0;if(!this.#t.get(t).visible)return!1}return!0}if(e.policy===`AnyOff`){for(let t of e.ids){if(!this.#t.has(t))return H(`Optional content group not found: ${t}`),!0;if(!this.#t.get(t).visible)return!0}return!1}if(e.policy===`AllOff`){for(let t of e.ids){if(!this.#t.has(t))return H(`Optional content group not found: ${t}`),!0;if(this.#t.get(t).visible)return!1}return!0}return H(`Unknown optional content policy ${e.policy}.`),!0}return H(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,n=!0){let r=this.#t.get(e);if(!r)H(`Optional content group not found: ${e}`);else{if(n&&t&&r.rbGroups.length)for(let t of r.rbGroups)for(let n of t)n!==e&&this.#t.get(n)?._setVisible(es,!1,!0);r._setVisible(es,!!t,!0),this.#e=null}}setOCGState({state:e,preserveRB:t}){let n;for(let r of e){switch(r){case`ON`:case`OFF`:case`Toggle`:n=r;continue}let e=this.#t.get(r);if(e)switch(n){case`ON`:this.setVisibility(r,!0,t);break;case`OFF`:this.setVisibility(r,!1,t);break;case`Toggle`:this.setVisibility(r,!e.visible,t)}}this.#e=null}get hasInitialVisibility(){return this.#n===null||this.getHash()===this.#n}getOrder(){return this.#t.size?this.#r?this.#r.slice():[...this.#t.keys()]:null}getGroups(){return this.#t.size>0?ge(this.#t):null}getGroup(e){return this.#t.get(e)||null}getHash(){if(this.#e!==null)return this.#e;let e=new uo;for(let[t,n]of this.#t)e.update(`${t}:${n.visible}`);return this.#e=e.hexdigest()}},rs=class{constructor(e,{disableRange:t=!1,disableStream:n=!1}){ue(e,`PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.`);let{length:r,initialData:i,progressiveDone:a,contentDispositionFilename:o}=e;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=o,i?.length>0){let e=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!n,this._isRangeSupported=!t,this._contentLength=r,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener((e,t)=>{this._onReceiveData({begin:e,chunk:t})}),e.addProgressListener((e,t)=>{this._onProgress({loaded:e,total:t})}),e.addProgressiveReadListener(e=>{this._onReceiveData({chunk:e})}),e.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),e.transportReady()}_onReceiveData({begin:e,chunk:t}){let n=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;e===void 0?this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n):ue(this._rangeReaders.some(function(t){return t._begin===e&&(t._enqueue(n),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(e){e.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:e.loaded}):this._fullRequestReader?.onProgress?.({loaded:e.loaded,total:e.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){let t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){ue(!this._fullRequestReader,`PDFDataTransportStream.getFullReader can only be called once.`);let e=this._queuedChunks;return this._queuedChunks=null,new is(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new as(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeReaders.slice(0))t.cancel(e);this._pdfDataRangeTransport.abort()}},is=class{constructor(e,t,n=!1,r=null){this._stream=e,this._done=n||!1,this._filename=Te(r)?r:null,this._queuedChunks=t||[],this._loaded=0;for(let e of this._queuedChunks)this._loaded+=e.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||=!0}},as=class{constructor(e,t,n){this._stream=e,this._begin=t,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length===0)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}},os=class{_responseOrigin=null;constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=Qe(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return ue(!this._fullRequestReader,`PDFFetchStream.getFullReader can only be called once.`),this._fullRequestReader=new ss(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new cs(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},ss=class{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;let t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange;let n=new Headers(e.headers),r=t.url;fetch(r,it(n,this._withCredentials,this._abortController)).then(t=>{if(e._responseOrigin=$e(t.url),!rt(t.status))throw nt(t.status,r);this._reader=t.body.getReader(),this._headersCapability.resolve();let n=t.headers,{allowRangeRequests:i,suggestedLength:a}=et({responseHeaders:n,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=a||this._contentLength,this._filename=tt(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Ia(`Streaming is disabled.`))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;let{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:at(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}},cs=class{constructor(e,t,n){this._stream=e,this._reader=null,this._loaded=0;let r=e.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;let i=new Headers(e.headers);i.append(`Range`,`bytes=${t}-${n-1}`);let a=r.url;fetch(a,it(i,this._withCredentials,this._abortController)).then(t=>{let n=$e(t.url);if(n!==e._responseOrigin)throw Error(`Expected range response-origin "${n}" to match "${e._responseOrigin}".`);if(!rt(t.status))throw nt(t.status,a);this._readCapability.resolve(),this._reader=t.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded}),{value:at(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}},ls=200,us=206,ds=class{_responseOrigin=null;constructor({url:e,httpHeaders:t,withCredentials:n}){this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=Qe(this.isHttp,t),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){let t=new XMLHttpRequest,n=this.currXhrId++,r=this.pendingRequests[n]={xhr:t};t.open(`GET`,this.url),t.withCredentials=this.withCredentials;for(let[e,n]of this.headers)t.setRequestHeader(e,n);return this.isHttp&&`begin`in e&&`end`in e?(t.setRequestHeader(`Range`,`bytes=${e.begin}-${e.end-1}`),r.expectedStatus=us):r.expectedStatus=ls,t.responseType=`arraybuffer`,ue(e.onError,"Expected `onError` callback to be provided."),t.onerror=()=>{e.onError(t.status)},t.onreadystatechange=this.onStateChange.bind(this,n),t.onprogress=this.onProgress.bind(this,n),r.onHeadersReceived=e.onHeadersReceived,r.onDone=e.onDone,r.onError=e.onError,r.onProgress=e.onProgress,t.send(null),n}onProgress(e,t){let n=this.pendingRequests[e];n&&n.onProgress?.(t)}onStateChange(e,t){let n=this.pendingRequests[e];if(!n)return;let r=n.xhr;if(r.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),r.readyState!==4||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],r.status===0&&this.isHttp){n.onError(r.status);return}let i=r.status||ls;if((i!==ls||n.expectedStatus!==us)&&i!==n.expectedStatus){n.onError(r.status);return}let a=ot(r);if(i===us){let e=r.getResponseHeader(`Content-Range`),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);t?n.onDone({begin:parseInt(t[1],10),chunk:a}):(H(`Missing or invalid "Content-Range" header.`),n.onError(0))}else a?n.onDone({begin:0,chunk:a}):n.onError(r.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){let t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}},fs=class{constructor(e){this._source=e,this._manager=new ds(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){let t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return ue(!this._fullRequestReader,`PDFNetworkStream.getFullReader can only be called once.`),this._fullRequestReader=new X(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){let n=new ps(this._manager,e,t);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},X=class{constructor(e,t){this._manager=e,this._url=t.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let e=this._fullRequestId,t=this._manager.getRequestXhr(e);this._manager._responseOrigin=$e(t.responseURL);let n=t.getAllResponseHeaders(),r=new Headers(n?n.trimStart().replace(/[^\S ]+$/,``).split(/[\r\n]+/).map(e=>{let[t,...n]=e.split(`: `);return[t,n.join(`: `)]}):[]),{allowRangeRequests:i,suggestedLength:a}=et({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=tt(r),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=nt(e,this._url),this._headersCapability.reject(this._storedError);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e);for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}},ps=class{constructor(e,t,n){this._manager=e,this._url=e.url,this._requestId=e.request({begin:t,end:n,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let e=$e(this._manager.getRequestXhr(this._requestId)?.responseURL);e!==this._manager._responseOrigin&&(this._storedError=/* @__PURE__ */ Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(e){let t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError??=nt(e,this._url);for(let e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){this.isStreamingSupported||this.onProgress?.({loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}},ms=/^[a-z][a-z0-9\-+.]+:/i,hs=class{constructor(e){this.source=e,this.url=st(e.url),ue(this.url.protocol===`file:`,`PDFNodeStream only supports file:// URLs.`),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return ue(!this._fullRequestReader,`PDFNodeStream.getFullReader can only be called once.`),this._fullRequestReader=new gs(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new _s(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(let t of this._rangeRequestReaders.slice(0))t.cancel(e)}},gs=class{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;let t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();let n=process.getBuiltinModule(`fs`);n.promises.lstat(this._url).then(e=>{this._contentLength=e.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()},e=>{e.code===`ENOENT`&&(e=new Na(`Missing PDF "${this._url}".`)),this._storedError=e,this._headersCapability.reject(e)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on(`readable`,()=>{this._readCapability.resolve()}),e.on(`end`,()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on(`error`,e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Ia(`streaming is disabled`)),this._storedError&&this._readableStream.destroy(this._storedError)}},_s=class{constructor(e,t,n){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let r=e.source;this._isStreamingSupported=!r.disableStream;let i=process.getBuiltinModule(`fs`);this._setReadableStream(i.createReadStream(this._url,{start:t,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on(`readable`,()=>{this._readCapability.resolve()}),e.on(`end`,()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on(`error`,e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}},vs=1e5,ys=30,bs=.8,xs=class e{#e=Promise.withResolvers();#t=null;#n=!1;#r=!!globalThis.FontInspector?.enabled;#i=null;#a=null;#o=0;#s=0;#c=null;#l=null;#u=0;#d=0;#f=Object.create(null);#p=[];#m=null;#h=[];#g=/* @__PURE__ */ new WeakMap;#_=null;static#v=/* @__PURE__ */ new Map;static#y=/* @__PURE__ */ new Map;static#b=/* @__PURE__ */ new WeakMap;static#x=null;static#S=/* @__PURE__ */ new Set;constructor({textContentSource:t,container:n,viewport:r}){if(t instanceof ReadableStream)this.#m=t;else if(typeof t==`object`)this.#m=new ReadableStream({start(e){e.enqueue(t),e.close()}});else throw Error(`No "textContentSource" parameter specified.`);this.#t=this.#l=n,this.#d=r.scale*(globalThis.devicePixelRatio||1),this.#u=r.rotation,this.#a={div:null,properties:null,ctx:null};let{pageWidth:i,pageHeight:a,pageX:o,pageY:s}=r.rawDims;this.#_=[1,0,0,-1,-o,s+a],this.#s=i,this.#o=a,e.#O(),Fe(n,r),this.#e.promise.finally(()=>{e.#S.delete(this),this.#a=null,this.#f=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:e,isFirefox:t}=La.platform;return W(this,`fontFamilyMap`,/* @__PURE__ */ new Map([[`sans-serif`,`${e&&t?`Calibri, `:``}sans-serif`],[`monospace`,`${e&&t?`Lucida Console, `:``}monospace`]]))}render(){let t=()=>{this.#c.read().then(({value:e,done:n})=>{n?this.#e.resolve():(this.#i??=e.lang,Object.assign(this.#f,e.styles),this.#C(e.items),t())},this.#e.reject)};return this.#c=this.#m.getReader(),e.#S.add(this),t(),this.#e.promise}update({viewport:t,onBefore:n=null}){let r=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==this.#u&&(n?.(),this.#u=i,Fe(this.#l,{rotation:i})),r!==this.#d){n?.(),this.#d=r;let t={div:null,properties:null,ctx:e.#E(this.#i)};for(let e of this.#h)t.properties=this.#g.get(e),t.div=e,this.#T(t)}}cancel(){let e=new Ia(`TextLayer task cancelled.`);this.#c?.cancel(e).catch(()=>{}),this.#c=null,this.#e.reject(e)}get textDivs(){return this.#h}get textContentItemsStr(){return this.#p}#C(t){if(this.#n)return;this.#a.ctx??=e.#E(this.#i);let n=this.#h,r=this.#p;for(let e of t){if(n.length>vs){H(`Ignoring additional textDivs for performance reasons.`),this.#n=!0;return}if(e.str===void 0){if(e.type===`beginMarkedContentProps`||e.type===`beginMarkedContent`){let t=this.#t;this.#t=document.createElement(`span`),this.#t.classList.add(`markedContent`),e.id!==null&&this.#t.setAttribute(`id`,`${e.id}`),t.append(this.#t)}else e.type===`endMarkedContent`&&(this.#t=this.#t.parentNode)}else r.push(e.str),this.#w(e)}}#w(t){let n=document.createElement(`span`),r={angle:0,canvasWidth:0,hasText:t.str!==``,hasEOL:t.hasEOL,fontSize:0};this.#h.push(n);let i=Y.transform(this.#_,t.transform),a=Math.atan2(i[1],i[0]),o=this.#f[t.fontName];o.vertical&&(a+=Math.PI/2);let s=this.#r&&o.fontSubstitution||o.fontFamily;s=e.fontFamilyMap.get(s)||s;let c=Math.hypot(i[2],i[3]),l=c*e.#k(s,this.#i),u,d;a===0?(u=i[4],d=i[5]-l):(u=i[4]+l*Math.sin(a),d=i[5]-l*Math.cos(a));let f=`calc(var(--scale-factor)*`,p=n.style;this.#t===this.#l?(p.left=`${(100*u/this.#s).toFixed(2)}%`,p.top=`${(100*d/this.#o).toFixed(2)}%`):(p.left=`${f}${u.toFixed(2)}px)`,p.top=`${f}${d.toFixed(2)}px)`),p.fontSize=`${f}${(e.#x*c).toFixed(2)}px)`,p.fontFamily=s,r.fontSize=c,n.setAttribute(`role`,`presentation`),n.textContent=t.str,n.dir=t.dir,this.#r&&(n.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),a!==0&&(r.angle=180/Math.PI*a);let m=!1;if(t.str.length>1)m=!0;else if(t.str!==` `&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),n=Math.abs(t.transform[3]);e!==n&&Math.max(e,n)/Math.min(e,n)>1.5&&(m=!0)}if(m&&(r.canvasWidth=o.vertical?t.height:t.width),this.#g.set(n,r),this.#a.div=n,this.#a.properties=r,this.#T(this.#a),r.hasText&&this.#t.append(n),r.hasEOL){let e=document.createElement(`br`);e.setAttribute(`role`,`presentation`),this.#t.append(e)}}#T(t){let{div:n,properties:r,ctx:i}=t,{style:a}=n,o=``;if(e.#x>1&&(o=`scale(${1/e.#x})`),r.canvasWidth!==0&&r.hasText){let{fontFamily:t}=a,{canvasWidth:s,fontSize:c}=r;e.#D(i,c*this.#d,t);let{width:l}=i.measureText(n.textContent);l>0&&(o=`scaleX(${s*this.#d/l}) ${o}`)}r.angle!==0&&(o=`rotate(${r.angle}deg) ${o}`),o.length>0&&(a.transform=o)}static cleanup(){if(!(this.#S.size>0)){this.#v.clear();for(let{canvas:e}of this.#y.values())e.remove();this.#y.clear()}}static#E(e=null){let t=this.#y.get(e||=``);if(!t){let n=document.createElement(`canvas`);n.className=`hiddenCanvasElement`,n.lang=e,document.body.append(n),t=n.getContext(`2d`,{alpha:!1,willReadFrequently:!0}),this.#y.set(e,t),this.#b.set(t,{size:0,family:``})}return t}static#D(e,t,n){let r=this.#b.get(e);(t!==r.size||n!==r.family)&&(e.font=`${t}px ${n}`,r.size=t,r.family=n)}static#O(){if(this.#x!==null)return;let e=document.createElement(`div`);e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize=`1px`,e.style.position=`absolute`,e.textContent=`X`,document.body.append(e),this.#x=e.getBoundingClientRect().height,e.remove()}static#k(e,t){let n=this.#v.get(e);if(n)return n;let r=this.#E(t);r.canvas.width=r.canvas.height=ys,this.#D(r,ys,e);let i=r.measureText(``),a=i.fontBoundingBoxAscent,o=Math.abs(i.fontBoundingBoxDescent);if(a){let t=a/(a+o);return this.#v.set(e,t),r.canvas.width=r.canvas.height=0,t}r.strokeStyle=`red`,r.clearRect(0,0,ys,ys),r.strokeText(`g`,0,0);let s=r.getImageData(0,0,ys,ys).data;o=0;for(let e=s.length-1-3;e>=0;e-=4)if(s[e]>0){o=Math.ceil(e/4/ys);break}r.clearRect(0,0,ys,ys),r.strokeText(`A`,0,ys),s=r.getImageData(0,0,ys,ys).data,a=0;for(let e=0,t=s.length;e<t;e+=4)if(s[e]>0){a=ys-Math.floor(e/4/ys);break}r.canvas.width=r.canvas.height=0;let c=a?a/(a+o):bs;return this.#v.set(e,c),c}},Ss=class e{static textContent(t){let n=[],r={items:n,styles:Object.create(null)};function i(t){if(!t)return;let r=null,a=t.name;if(a===`#text`)r=t.value;else if(e.shouldBuildText(a))t?.attributes?.textContent?r=t.attributes.textContent:t.value&&(r=t.value);else return;if(r!==null&&n.push({str:r}),t.children)for(let e of t.children)i(e)}return i(t),r}static shouldBuildText(e){return e!==`textarea`&&e!==`input`&&e!==`option`&&e!==`select`}},Cs=65536,ws=100,Ts=5e3,Es=fa?ko:xo,Ds=fa?Ao:Co,Os=fa?Oo:To,ks=fa?jo:Do,As=class e{static#e=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${e.#e++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(e){throw this._worker?.port&&delete this._worker._pendingDestroy,e}this._transport=null,this._worker?.destroy(),this._worker=null}},js=class{constructor(e,t,n=!1,r=null){this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=r,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(let n of this._rangeListeners)n(e,t)}onDataProgress(e,t){this._readyCapability.promise.then(()=>{for(let n of this._progressListeners)n(e,t)})}onDataProgressiveRead(e){this._readyCapability.promise.then(()=>{for(let t of this._progressiveReadListeners)t(e)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let e of this._progressiveDoneListeners)e()})}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){U(`Abstract method PDFDataRangeTransport.requestDataRange`)}abort(){}},Ms=class{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return W(this,`isPureXfa`,!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e=`display`}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getOutputIntents(){return this._transport.getOutputIntents()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}},Ns=class{#e=null;#t=!1;constructor(e,t,n,r=!1){this._pageIndex=e,this._pageInfo=t,this._transport=n,this._stats=r?new Ka:null,this._pdfBug=r,this.commonObjs=n.commonObjs,this.objs=new Rs,this._maybeCleanupAfterRender=!1,this._intentStates=/* @__PURE__ */ new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}get trimBox(){return this._pageInfo.trimBox??null}get bleedBox(){return this._pageInfo.bleedBox??null}get colorSpaceResources(){return this._pageInfo.colorSpaceResources??{}}get imglyPatchVersion(){return this._pageInfo.imglyPatchVersion??null}getViewport({scale:e,rotation:t=this.rotate,offsetX:n=0,offsetY:r=0,dontFlip:i=!1}={}){return new Wa({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:r,dontFlip:i})}getAnnotations({intent:e=`display`}={}){let{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return W(this,`isPureXfa`,!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,viewport:t,intent:n=`display`,annotationMode:r=_a.ENABLE,transform:i=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:s=null,pageColors:c=null,printAnnotationStorage:l=null,isEditing:u=!1}){this._stats?.time(`Overall`);let d=this._transport.getRenderingIntent(n,r,l,u),{renderingIntent:f,cacheKey:p}=d;this.#t=!1,this.#r(),o||=this._transport.getOptionalContentConfig(f);let m=this._intentStates.get(p);m||(m=Object.create(null),this._intentStates.set(p,m)),m.streamReaderCancelTimeout&&(clearTimeout(m.streamReaderCancelTimeout),m.streamReaderCancelTimeout=null);let h=!!(f&ga.PRINT);m.displayReadyCapability||(m.displayReadyCapability=Promise.withResolvers(),m.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time(`Page Request`),this._pumpOperatorList(d));let g=e=>{m.renderTasks.delete(_),(this._maybeCleanupAfterRender||h)&&(this.#t=!0),this.#n(!h),e?(_.capability.reject(e),this._abortOperatorList({intentState:m,reason:e instanceof Error?e:Error(e)})):_.capability.resolve(),this._stats&&(this._stats.timeEnd(`Rendering`),this._stats.timeEnd(`Overall`),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},_=new Bs({callback:g,params:{canvasContext:e,viewport:t,transform:i,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:s,operatorList:m.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!h,pdfBug:this._pdfBug,pageColors:c});(m.renderTasks||=/* @__PURE__ */ new Set).add(_);let v=_.task;return Promise.all([m.displayReadyCapability.promise,o]).then(([e,t])=>{if(this.destroyed)g();else{if(this._stats?.time(`Rendering`),!(t.renderingIntent&f))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:e,optionalContentConfig:t}),_.operatorListChanged()}}).catch(g),v}getOperatorList({intent:e=`display`,annotationMode:t=_a.ENABLE,printAnnotationStorage:n=null,isEditing:r=!1}={}){function i(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(s))}let a=this._transport.getRenderingIntent(e,t,n,r,!0),o=this._intentStates.get(a.cacheKey);o||(o=Object.create(null),this._intentStates.set(a.cacheKey,o));let s;return o.opListReadCapability||(s=Object.create(null),s.operatorListChanged=i,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||=/* @__PURE__ */ new Set).add(s),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time(`Page Request`),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream(`GetTextContent`,{pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:t===!0},{highWaterMark:100,size(e){return e.items.length}})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(e=>Ss.textContent(e));let t=this.streamTextContent(e);return new Promise(function(e,n){function r(){i.read().then(function({value:t,done:n}){n?e(a):(a.lang??=t.lang,Object.assign(a.styles,t.styles),a.items.push(...t.items),r())},n)}let i=t.getReader(),a={items:[],styles:Object.create(null),lang:null};r()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let e=[];for(let t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:/* @__PURE__ */ Error(`Page was destroyed.`),force:!0}),!t.opListReadCapability)for(let n of t.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),this.#t=!1,this.#r(),Promise.all(e)}cleanup(e=!1){this.#t=!0;let t=this.#n(!1);return e&&t&&(this._stats&&=new Ka),t}#n(e=!1){if(this.#r(),!this.#t||this.destroyed)return!1;if(e)return this.#e=setTimeout(()=>{this.#e=null,this.#n(!1)},Ts),!1;for(let{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#t=!1,!0}#r(){this.#e&&=(clearTimeout(this.#e),null)}_startRenderPage(e,t){let n=this._intentStates.get(t);n&&(this._stats?.timeEnd(`Page Request`),n.displayReadyCapability?.resolve(e))}_renderPageChunk(e,t){for(let n=0,r=e.length;n<r;n++)t.operatorList.fnArray.push(e.fnArray[n]),t.operatorList.argsArray.push(e.argsArray[n]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(let e of t.renderTasks)e.operatorListChanged();e.lastChunk&&this.#n(!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:n,modifiedIds:r}){let{map:i,transfer:a}=n,o=this._transport.messageHandler.sendWithStream(`GetOperatorList`,{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:i,modifiedIds:r},a).getReader(),s=this._intentStates.get(t);s.streamReader=o;let c=()=>{o.read().then(({value:e,done:t})=>{t?s.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,s),c())},e=>{if(s.streamReader=null,!this._transport.destroyed){if(s.operatorList){s.operatorList.lastChunk=!0;for(let e of s.renderTasks)e.operatorListChanged();this.#n(!0)}if(s.displayReadyCapability)s.displayReadyCapability.reject(e);else if(s.opListReadCapability)s.opListReadCapability.reject(e);else throw e}})};c()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&=(clearTimeout(e.streamReaderCancelTimeout),null),!n){if(e.renderTasks.size>0)return;if(t instanceof Ga){let n=ws;t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},n);return}}if(e.streamReader.cancel(new Ia(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(let[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}},Ps=class{#e=/* @__PURE__ */ new Map;#t=Promise.resolve();postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};this.#t.then(()=>{for(let[e]of this.#e)e.call(this,n)})}addEventListener(e,t,n=null){let r=null;if(n?.signal instanceof AbortSignal){let{signal:i}=n;if(i.aborted){H("LoopbackPort - cannot use an `aborted` signal.");return}let a=()=>this.removeEventListener(e,t);r=()=>i.removeEventListener(`abort`,a),i.addEventListener(`abort`,a)}this.#e.set(t,r)}removeEventListener(e,t){this.#e.get(t)?.(),this.#e.delete(t)}terminate(){for(let[,e]of this.#e)e?.();this.#e.clear()}},Fs=class e{static#e=0;static#t=!1;static#n;static{fa&&(this.#t=!0,Qo.workerSrc||=`./pdf.worker.mjs`),this._isSameOrigin=(e,t)=>{let n;try{if(n=new URL(e),!n.origin||n.origin===`null`)return!1}catch{return!1}let r=new URL(t,n);return n.origin===r.origin},this._createCDNWrapper=e=>{let t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:`text/javascript`}))}}constructor({name:t=null,port:n=null,verbosity:r=B()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=r,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,n){if(e.#n?.has(n))throw Error(`Cannot use more than one PDFWorker per port.`);(e.#n||=/* @__PURE__ */ new WeakMap).set(n,this),this._initializeFromPort(n)}else this._initialize()}get promise(){return this._readyCapability.promise}#r(){this._readyCapability.resolve(),this._messageHandler.send(`configure`,{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new yo(`main`,`worker`,e),this._messageHandler.on(`ready`,function(){}),this.#r()}_initialize(){if(e.#t||e.#i){this._setupFakeWorker();return}let{workerSrc:t}=e;try{e._isSameOrigin(window.location.href,t)||(t=e._createCDNWrapper(new URL(t,window.location).href));let n=new Worker(t,{type:`module`}),r=new yo(`main`,`worker`,n),i=()=>{a.abort(),r.destroy(),n.terminate(),this.destroyed?this._readyCapability.reject(/* @__PURE__ */ Error(`Worker was destroyed`)):this._setupFakeWorker()},a=new AbortController;n.addEventListener(`error`,()=>{this._webWorker||i()},{signal:a.signal}),r.on(`test`,e=>{a.abort(),this.destroyed||!e?i():(this._messageHandler=r,this._port=n,this._webWorker=n,this.#r())}),r.on(`ready`,e=>{if(a.abort(),this.destroyed)i();else try{o()}catch{this._setupFakeWorker()}});let o=()=>{let e=/* @__PURE__ */ new Uint8Array;r.send(`test`,e,[e.buffer])};o();return}catch{V(`The worker has been disabled.`)}this._setupFakeWorker()}_setupFakeWorker(){e.#t||=(H(`Setting up fake worker.`),!0),e._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(/* @__PURE__ */ Error(`Worker was destroyed`));return}let n=new Ps;this._port=n;let r=`fake${e.#e++}`,i=new yo(r+`_worker`,r,n);t.setup(i,n),this._messageHandler=new yo(r,r+`_worker`,n),this.#r()}).catch(e=>{this._readyCapability.reject(/* @__PURE__ */ Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,e.#n?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(t){if(!t?.port)throw Error(`PDFWorker.fromPort - invalid method signature.`);let n=this.#n?.get(t.port);if(n){if(n._pendingDestroy)throw Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return n}return new e(t)}static get workerSrc(){if(Qo.workerSrc)return Qo.workerSrc;throw Error(`No "GlobalWorkerOptions.workerSrc" specified.`)}static get#i(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return W(this,`_setupFakeWorkerGlobal`,(async()=>this.#i?this.#i:(await import(
4
+ /*webpackIgnore: true*/
5
+ this.workerSrc)).WorkerMessageHandler)())}},Is=class{#e=/* @__PURE__ */ new Map;#t=/* @__PURE__ */ new Map;#n=/* @__PURE__ */ new Map;#r=/* @__PURE__ */ new Map;#i=null;constructor(e,t,n,r,i){this.messageHandler=e,this.loadingTask=t,this.commonObjs=new Rs,this.fontLoader=new ho({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#a(e,t=null){let n=this.#e.get(e);if(n)return n;let r=this.messageHandler.sendWithPromise(e,t);return this.#e.set(e,r),r}get annotationStorage(){return W(this,`annotationStorage`,new po)}getRenderingIntent(e,t=_a.ENABLE,n=null,r=!1,i=!1){let a=ga.DISPLAY,o=fo;switch(e){case`any`:a=ga.ANY;break;case`display`:break;case`print`:a=ga.PRINT;break;default:H(`getRenderingIntent - invalid intent: ${e}`)}let s=a&ga.PRINT&&n instanceof mo?n:this.annotationStorage;switch(t){case _a.DISABLE:a+=ga.ANNOTATIONS_DISABLE;break;case _a.ENABLE:break;case _a.ENABLE_FORMS:a+=ga.ANNOTATIONS_FORMS;break;case _a.ENABLE_STORAGE:a+=ga.ANNOTATIONS_STORAGE,o=s.serializable;break;default:H(`getRenderingIntent - invalid annotationMode: ${t}`)}r&&(a+=ga.IS_EDITING),i&&(a+=ga.OPLIST);let{ids:c,hash:l}=s.modifiedIds,u=[a,o.hash,l];return{renderingIntent:a,cacheKey:u.join(`_`),annotationStorageSerializable:o,modifiedIds:c}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#i?.reject(/* @__PURE__ */ Error(`Worker was destroyed during onPassword callback`));let e=[];for(let t of this.#t.values())e.push(t._destroy());this.#t.clear(),this.#n.clear(),this.#r.clear(),this.hasOwnProperty(`annotationStorage`)&&this.annotationStorage.resetModified();let t=this.messageHandler.sendWithPromise(`Terminate`,null);return e.push(t),Promise.all(e).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(),xs.cleanup(),this._networkStream?.cancelAllRequests(new Ia(`Worker was terminated.`)),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:e,loadingTask:t}=this;e.on(`GetReader`,(e,t)=>{ue(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}},t.onPull=()=>{this._fullReader.read().then(function({value:e,done:n}){n?t.close():(ue(e instanceof ArrayBuffer,`GetReader - expected an ArrayBuffer.`),t.enqueue(new Uint8Array(e),1,[e]))}).catch(e=>{t.error(e)})},t.onCancel=e=>{this._fullReader.cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}}),e.on(`ReaderHeadersReady`,async e=>{await this._fullReader.headersReady;let{isStreamingSupported:n,isRangeSupported:r,contentLength:i}=this._fullReader;return n&&r||(this._lastProgress&&t.onProgress?.(this._lastProgress),this._fullReader.onProgress=e=>{t.onProgress?.({loaded:e.loaded,total:e.total})}),{isStreamingSupported:n,isRangeSupported:r,contentLength:i}}),e.on(`GetRangeReader`,(e,t)=>{ue(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let n=this._networkStream.getRangeReader(e.begin,e.end);n?(t.onPull=()=>{n.read().then(function({value:e,done:n}){n?t.close():(ue(e instanceof ArrayBuffer,`GetRangeReader - expected an ArrayBuffer.`),t.enqueue(new Uint8Array(e),1,[e]))}).catch(e=>{t.error(e)})},t.onCancel=e=>{n.cancel(e),t.ready.catch(e=>{if(!this.destroyed)throw e})}):t.close()}),e.on(`GetDoc`,({pdfInfo:e})=>{this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,t._capability.resolve(new Ms(e,this))}),e.on(`DocException`,e=>{t._capability.reject(Re(e))}),e.on(`PasswordRequest`,e=>{this.#i=Promise.withResolvers();try{if(!t.onPassword)throw Re(e);t.onPassword(e=>{e instanceof Error?this.#i.reject(e):this.#i.resolve({password:e})},e.code)}catch(e){this.#i.reject(e)}return this.#i.promise}),e.on(`DataLoaded`,e=>{t.onProgress?.({loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)}),e.on(`StartRenderPage`,e=>{this.destroyed||this.#t.get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)}),e.on(`commonobj`,([t,n,r])=>{if(this.destroyed||this.commonObjs.has(t))return null;switch(n){case`Font`:let{disableFontFace:i,fontExtraProperties:a,pdfBug:o}=this._params;if(`error`in r){let e=r.error;H(`Error during font loading: ${e}`),this.commonObjs.resolve(t,e);break}let s=o&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,c=new go(r,{disableFontFace:i,fontExtraProperties:a,inspectFont:s});this.fontLoader.bind(c).catch(()=>e.sendWithPromise(`FontFallback`,{id:t})).finally(()=>{!a&&c.data&&(c.data=null),this.commonObjs.resolve(t,c)});break;case`CopyLocalImage`:let{imageRef:l}=r;ue(l,`The imageRef must be defined.`);for(let e of this.#t.values())for(let[,n]of e.objs)if(n?.ref===l)return n.dataLen?(this.commonObjs.resolve(t,structuredClone(n)),n.dataLen):null;break;case`FontPath`:case`Image`:case`IccProfile`:case`Pattern`:this.commonObjs.resolve(t,r);break;default:throw Error(`Got unknown common object type ${n}`)}return null}),e.on(`obj`,([e,t,n,r])=>{if(this.destroyed)return;let i=this.#t.get(t);if(!i.objs.has(e)){if(i._intentStates.size===0)r?.bitmap?.close();else switch(n){case`Image`:i.objs.resolve(e,r),r?.dataLen>ha&&(i._maybeCleanupAfterRender=!0);break;case`Pattern`:i.objs.resolve(e,r);break;default:throw Error(`Got unknown object type ${n}`)}}}),e.on(`DocProgress`,e=>{this.destroyed||t.onProgress?.({loaded:e.loaded,total:e.total})}),e.on(`FetchBuiltInCMap`,async e=>{if(this.destroyed)throw Error(`Worker was destroyed.`);if(!this.cMapReaderFactory)throw Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(e)}),e.on(`FetchStandardFontData`,async e=>{if(this.destroyed)throw Error(`Worker was destroyed.`);if(!this.standardFontDataFactory)throw Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(e)})}getData(){return this.messageHandler.sendWithPromise(`GetData`,null)}saveDocument(){this.annotationStorage.size<=0&&H("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise(`SaveDocument`,{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:this._fullReader?.filename??null},t).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(/* @__PURE__ */ Error(`Invalid page request.`));let t=e-1,n=this.#n.get(t);if(n)return n;let r=this.messageHandler.sendWithPromise(`GetPage`,{pageIndex:t}).then(n=>{if(this.destroyed)throw Error(`Transport destroyed`);n.refStr&&this.#r.set(n.refStr,e);let r=new Ns(t,n,this,this._params.pdfBug);return this.#t.set(t,r),r});return this.#n.set(t,r),r}getPageIndex(e){return dt(e)?this.messageHandler.sendWithPromise(`GetPageIndex`,{num:e.num,gen:e.gen}):Promise.reject(/* @__PURE__ */ Error(`Invalid pageIndex request.`))}getAnnotations(e,t){return this.messageHandler.sendWithPromise(`GetAnnotations`,{pageIndex:e,intent:t})}getFieldObjects(){return this.#a(`GetFieldObjects`)}hasJSActions(){return this.#a(`HasJSActions`)}getCalculationOrderIds(){return this.messageHandler.sendWithPromise(`GetCalculationOrderIds`,null)}getDestinations(){return this.messageHandler.sendWithPromise(`GetDestinations`,null)}getDestination(e){return typeof e==`string`?this.messageHandler.sendWithPromise(`GetDestination`,{id:e}):Promise.reject(/* @__PURE__ */ Error(`Invalid destination request.`))}getPageLabels(){return this.messageHandler.sendWithPromise(`GetPageLabels`,null)}getPageLayout(){return this.messageHandler.sendWithPromise(`GetPageLayout`,null)}getPageMode(){return this.messageHandler.sendWithPromise(`GetPageMode`,null)}getViewerPreferences(){return this.messageHandler.sendWithPromise(`GetViewerPreferences`,null)}getOpenAction(){return this.messageHandler.sendWithPromise(`GetOpenAction`,null)}getAttachments(){return this.messageHandler.sendWithPromise(`GetAttachments`,null)}getDocJSActions(){return this.#a(`GetDocJSActions`)}getPageJSActions(e){return this.messageHandler.sendWithPromise(`GetPageJSActions`,{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise(`GetStructTree`,{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise(`GetOutline`,null)}getOptionalContentConfig(e){return this.#a(`GetOptionalContentConfig`).then(t=>new ns(t,e))}getPermissions(){return this.messageHandler.sendWithPromise(`GetPermissions`,null)}getMetadata(){let e=`GetMetadata`,t=this.#e.get(e);if(t)return t;let n=this.messageHandler.sendWithPromise(e,null).then(e=>({info:e[0],metadata:e[1]?new $o(e[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#e.set(e,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise(`GetMarkInfo`,null)}getOutputIntents(){return this.#a(`GetOutputIntents`)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise(`Cleanup`,null);for(let e of this.#t.values())if(!e.cleanup())throw Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(!0),xs.cleanup()}}cachedPageNumber(e){if(!dt(e))return null;let t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return this.#r.get(t)??null}},Ls=Symbol(`INITIAL_DATA`),Rs=class{#e=Object.create(null);#t(e){return this.#e[e]||={...Promise.withResolvers(),data:Ls}}get(e,t=null){if(t){let n=this.#t(e);return n.promise.then(()=>t(n.data)),null}let n=this.#e[e];if(!n||n.data===Ls)throw Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){let t=this.#e[e];return!!t&&t.data!==Ls}delete(e){let t=this.#e[e];return!t||t.data===Ls?!1:(delete this.#e[e],!0)}resolve(e,t=null){let n=this.#t(e);n.data=t,n.resolve()}clear(){for(let e in this.#e){let{data:t}=this.#e[e];t?.bitmap?.close()}this.#e=Object.create(null)}*[Symbol.iterator](){for(let e in this.#e){let{data:t}=this.#e[e];t!==Ls&&(yield[e,t])}}},zs=class{#e=null;constructor(e){this.#e=e,this.onContinue=null}get promise(){return this.#e.capability.promise}cancel(e=0){this.#e.cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=this.#e.operatorList;if(!e)return!1;let{annotationCanvasMap:t}=this.#e;return e.form||e.canvas&&t?.size>0}},Bs=class e{#e=null;static#t=/* @__PURE__ */ new WeakSet;constructor({callback:e,params:t,objs:n,commonObjs:r,annotationCanvasMap:i,operatorList:a,pageIndex:o,canvasFactory:s,filterFactory:c,useRequestAnimationFrame:l=!1,pdfBug:u=!1,pageColors:d=null}){this.callback=e,this.params=t,this.objs=n,this.commonObjs=r,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=s,this.filterFactory=c,this._pdfBug=u,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=l===!0&&typeof window<`u`,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new zs(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:n}){if(this.cancelled)return;if(this._canvas){if(e.#t.has(this._canvas))throw Error(`Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.`);e.#t.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:r,viewport:i,transform:a,background:o}=this.params;this.gfx=new Zo(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:n},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:i,transparency:t,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,n=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#e&&=(window.cancelAnimationFrame(this.#e),null),e.#t.delete(this._canvas),this.callback(t||new Ga(`Rendering cancelled, page ${this._pageIndex+1}`,n))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#e=window.requestAnimationFrame(()=>{this.#e=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),e.#t.delete(this._canvas),this.callback())))}},Vs=`4.10.47`,Hs=`035c490bb`,Ei(),Us=class{static CMYK_G([e,t,n,r]){return[`G`,1-Math.min(1,.3*e+.59*n+.11*t+r)]}static G_CMYK([e]){return[`CMYK`,0,0,0,1-e]}static G_RGB([e]){return[`RGB`,e,e,e]}static G_rgb([e]){return e=pt(e),[e,e,e]}static G_HTML([e]){let t=ft(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return[`G`,.3*e+.59*t+.11*n]}static RGB_rgb(e){return e.map(pt)}static RGB_HTML(e){return`#${e.map(ft).join(``)}`}static T_HTML(){return`#00000000`}static T_rgb(){return[null]}static CMYK_RGB([e,t,n,r]){return[`RGB`,1-Math.min(1,e+r),1-Math.min(1,n+r),1-Math.min(1,t+r)]}static CMYK_rgb([e,t,n,r]){return[pt(1-Math.min(1,e+r)),pt(1-Math.min(1,n+r)),pt(1-Math.min(1,t+r))]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){let r=1-e,i=1-t,a=1-n;return[`CMYK`,r,i,a,Math.min(r,i,a)]}},Ws=class{create(e,t,n=!1){if(e<=0||t<=0)throw Error(`Invalid SVG dimensions`);let r=this._createSVG(`svg:svg`);return r.setAttribute(`version`,`1.1`),n||(r.setAttribute(`width`,`${e}px`),r.setAttribute(`height`,`${t}px`)),r.setAttribute(`preserveAspectRatio`,`none`),r.setAttribute(`viewBox`,`0 0 ${e} ${t}`),r}createElement(e){if(typeof e!=`string`)throw Error(`Invalid SVG element type`);return this._createSVG(e)}_createSVG(e){U("Abstract method `_createSVG` called.")}},Gs=class extends Ws{_createSVG(e){return document.createElementNS(Ha,e)}},Ks=class{static setupStorage(e,t,n,r,i){let a=r.getValue(t,{value:null});switch(n.name){case`textarea`:if(a.value!==null&&(e.textContent=a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})});break;case`input`:if(n.attributes.type===`radio`||n.attributes.type===`checkbox`){if(a.value===n.attributes.xfaOn?e.setAttribute(`checked`,!0):a.value===n.attributes.xfaOff&&e.removeAttribute(`checked`),i===`print`)break;e.addEventListener(`change`,e=>{r.setValue(t,{value:e.target.checked?e.target.getAttribute(`xfaOn`):e.target.getAttribute(`xfaOff`)})})}else{if(a.value!==null&&e.setAttribute(`value`,a.value),i===`print`)break;e.addEventListener(`input`,e=>{r.setValue(t,{value:e.target.value})})}break;case`select`:if(a.value!==null){e.setAttribute(`value`,a.value);for(let e of n.children)e.attributes.value===a.value?e.attributes.selected=!0:e.attributes.hasOwnProperty(`selected`)&&delete e.attributes.selected}e.addEventListener(`input`,e=>{let n=e.target.options,i=n.selectedIndex===-1?``:n[n.selectedIndex].value;r.setValue(t,{value:i})})}}static setAttributes({html:e,element:t,storage:n=null,intent:r,linkService:i}){let{attributes:a}=t,o=e instanceof HTMLAnchorElement;a.type===`radio`&&(a.name=`${a.name}-${r}`);for(let[t,n]of Object.entries(a))if(n!=null)switch(t){case`class`:n.length&&e.setAttribute(t,n.join(` `));break;case`dataId`:break;case`id`:e.setAttribute(`data-element-id`,n);break;case`style`:Object.assign(e.style,n);break;case`textContent`:e.textContent=n;break;default:(!o||t!==`href`&&t!==`newWindow`)&&e.setAttribute(t,n)}o&&i.addLinkAttributes(e,a.href,a.newWindow),n&&a.dataId&&this.setupStorage(e,a.dataId,t,n)}static render(e){let t=e.annotationStorage,n=e.linkService,r=e.xfaHtml,i=e.intent||`display`,a=document.createElement(r.name);r.attributes&&this.setAttributes({html:a,element:r,intent:i,linkService:n});let o=i!==`richText`,s=e.div;if(s.append(a),e.viewport){let t=`matrix(${e.viewport.transform.join(`,`)})`;s.style.transform=t}o&&s.setAttribute(`class`,`xfaLayer xfaFont`);let c=[];if(r.children.length===0){if(r.value){let e=document.createTextNode(r.value);a.append(e),o&&Ss.shouldBuildText(r.name)&&c.push(e)}return{textDivs:c}}let l=[[r,-1,a]];for(;l.length>0;){let[e,r,a]=l.at(-1);if(r+1===e.children.length){l.pop();continue}let s=e.children[++l.at(-1)[1]];if(s===null)continue;let{name:u}=s;if(u===`#text`){let e=document.createTextNode(s.value);c.push(e),a.append(e);continue}let d=s?.attributes?.xmlns?document.createElementNS(s.attributes.xmlns,u):document.createElement(u);if(a.append(d),s.attributes&&this.setAttributes({html:d,element:s,storage:t,intent:i,linkService:n}),s.children?.length>0)l.push([s,-1,d]);else if(s.value){let e=document.createTextNode(s.value);o&&Ss.shouldBuildText(u)&&c.push(e),d.append(e)}}for(let e of s.querySelectorAll(`.xfaNonInteractive input, .xfaNonInteractive textarea`))e.setAttribute(`readOnly`,!0);return{textDivs:c}}static update(e){let t=`matrix(${e.viewport.transform.join(`,`)})`;e.div.style.transform=t,e.div.hidden=!1}},qs=1e3,Js=9,Ys=/* @__PURE__ */ new WeakSet,Xs=class{static create(e){switch(e.data.annotationType){case Ca.LINK:return new Qs(e);case Ca.TEXT:return new $s(e);case Ca.WIDGET:switch(e.data.fieldType){case`Tx`:return new tc(e);case`Btn`:return e.data.radioButton?new ic(e):e.data.checkBox?new rc(e):new ac(e);case`Ch`:return new oc(e);case`Sig`:return new nc(e)}return new ec(e);case Ca.POPUP:return new sc(e);case Ca.FREETEXT:return new lc(e);case Ca.LINE:return new uc(e);case Ca.SQUARE:return new dc(e);case Ca.CIRCLE:return new fc(e);case Ca.POLYLINE:return new pc(e);case Ca.CARET:return new hc(e);case Ca.INK:return new gc(e);case Ca.POLYGON:return new mc(e);case Ca.HIGHLIGHT:return new _c(e);case Ca.UNDERLINE:return new vc(e);case Ca.SQUIGGLY:return new yc(e);case Ca.STRIKEOUT:return new bc(e);case Ca.STAMP:return new xc(e);case Ca.FILEATTACHMENT:return new Sc(e);default:return new Zs(e)}}},Zs=class e{#e=null;#t=!1;#n=null;constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:r=!1}={}){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(n)),r&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:n}){return!!(e?.str||t?.str||n?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return e._hasPopupData(this.data)}updateEdited(e){if(!this.container)return;this.#e||={rect:this.data.rect.slice(0)};let{rect:t}=e;t&&this.#r(t),this.#n?.popup.updateEdited(e)}resetEdited(){this.#e&&=(this.#r(this.#e.rect),this.#n?.popup.resetEdited(),null)}#r(e){let{container:{style:t},data:{rect:n,rotation:r},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:o,pageY:s}}}}=this;n?.splice(0,4,...e);let{width:c,height:l}=mt(e);t.left=`${100*(e[0]-o)/i}%`,t.top=`${100*(a-e[3]+s)/a}%`,r===0?(t.width=`${100*c/i}%`,t.height=`${100*l/a}%`):this.setRotation(r)}_createContainer(e){let{data:t,parent:{page:n,viewport:r}}=this,i=document.createElement(`section`);i.setAttribute(`data-annotation-id`,t.id),this instanceof ec||(i.tabIndex=qs);let{style:a}=i;if(a.zIndex=this.parent.zIndex++,t.alternativeText&&(i.title=t.alternativeText),t.noRotate&&i.classList.add(`norotate`),!t.rect||this instanceof sc){let{rotation:e}=t;return!t.hasOwnCanvas&&e!==0&&this.setRotation(e,i),i}let{width:o,height:s}=mt(t.rect);if(!e&&t.borderStyle.width>0){a.borderWidth=`${t.borderStyle.width}px`;let e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;switch(e>0||n>0?a.borderRadius=`calc(${e}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`:this instanceof ic&&(a.borderRadius=`calc(${o}px * var(--scale-factor)) / calc(${s}px * var(--scale-factor))`),t.borderStyle.style){case wa.SOLID:a.borderStyle=`solid`;break;case wa.DASHED:a.borderStyle=`dashed`;break;case wa.BEVELED:H(`Unimplemented border style: beveled`);break;case wa.INSET:H(`Unimplemented border style: inset`);break;case wa.UNDERLINE:a.borderBottomStyle=`solid`}let r=t.borderColor||null;r?(this.#t=!0,a.borderColor=Y.makeHexColor(r[0]|0,r[1]|0,r[2]|0)):a.borderWidth=0}let c=Y.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]),{pageWidth:l,pageHeight:u,pageX:d,pageY:f}=r.rawDims;a.left=`${100*(c[0]-d)/l}%`,a.top=`${100*(c[1]-f)/u}%`;let{rotation:p}=t;return t.hasOwnCanvas||p===0?(a.width=`${100*o/l}%`,a.height=`${100*s/u}%`):this.setRotation(p,i),i}setRotation(e,t=this.container){if(!this.data.rect)return;let{pageWidth:n,pageHeight:r}=this.parent.viewport.rawDims,{width:i,height:a}=mt(this.data.rect),o,s;e%180==0?(o=100*i/n,s=100*a/r):(o=100*a/n,s=100*i/r),t.style.width=`${o}%`,t.style.height=`${s}%`,t.setAttribute(`data-main-rotation`,(360-e)%360)}get _commonActions(){let e=(e,t,n)=>{let r=n.detail[e],i=r[0],a=r.slice(1);n.target.style[t]=Us[`${i}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[t]:Us[`${i}_rgb`](a)})};return W(this,`_commonActions`,{display:e=>{let{display:t}=e.detail,n=t%2==1;this.container.style.visibility=n?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:t===1||t===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{let{hidden:t}=e.detail;this.container.style.visibility=t?`hidden`:`visible`,this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e(`bgColor`,`backgroundColor`,t)},fillColor:t=>{e(`fillColor`,`backgroundColor`,t)},fgColor:t=>{e(`fgColor`,`color`,t)},textColor:t=>{e(`textColor`,`color`,t)},borderColor:t=>{e(`borderColor`,`borderColor`,t)},strokeColor:t=>{e(`strokeColor`,`borderColor`,t)},rotation:e=>{let t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){let n=this._commonActions;for(let r of Object.keys(t.detail))(e[r]||n[r])?.(t)}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let n=this._commonActions;for(let[r,i]of Object.entries(t)){let a=n[r];a&&(a({detail:{[r]:i},target:e}),delete t[r])}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[t,n,r,i]=this.data.rect.map(e=>Math.fround(e));if(e.length===8){let[a,o,s,c]=e.subarray(2,6);if(r===a&&i===o&&t===s&&n===c)return}let{style:a}=this.container,o;if(this.#t){let{borderColor:e,borderWidth:t}=a;a.borderWidth=0,o=[`url('data:image/svg+xml;utf8,`,`<svg xmlns="http://www.w3.org/2000/svg"`,` preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${e}" stroke-width="${t}">`],this.container.classList.add(`hasBorder`)}let s=r-t,c=i-n,{svgFactory:l}=this,u=l.createElement(`svg`);u.classList.add(`quadrilateralsContainer`),u.setAttribute(`width`,0),u.setAttribute(`height`,0);let d=l.createElement(`defs`);u.append(d);let f=l.createElement(`clipPath`),p=`clippath_${this.data.id}`;f.setAttribute(`id`,p),f.setAttribute(`clipPathUnits`,`objectBoundingBox`),d.append(f);for(let n=2,r=e.length;n<r;n+=8){let r=e[n],a=e[n+1],u=e[n+2],d=e[n+3],p=l.createElement(`rect`),m=(u-t)/s,h=(i-a)/c,g=(r-u)/s,_=(a-d)/c;p.setAttribute(`x`,m),p.setAttribute(`y`,h),p.setAttribute(`width`,g),p.setAttribute(`height`,_),f.append(p),o?.push(`<rect vector-effect="non-scaling-stroke" x="${m}" y="${h}" width="${g}" height="${_}"/>`)}this.#t&&(o.push(`</g></svg>')`),a.backgroundImage=o.join(``)),this.container.append(u),this.container.style.clipPath=`url(#${p})`}_createPopup(){let{data:e}=this,t=this.#n=new sc({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(t.render())}render(){U("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let n=[];if(this._fieldObjects){let r=this._fieldObjects[e];if(r)for(let{page:e,id:i,exportValues:a}of r){if(e===-1||i===t)continue;let r=typeof a==`string`?a:null,o=document.querySelector(`[data-element-id="${i}"]`);o&&!Ys.has(o)?H(`_getElementsByName - element not allowed: ${i}`):n.push({id:i,exportValue:r,domElement:o})}return n}for(let r of document.getElementsByName(e)){let{exportValue:e}=r,i=r.getAttribute(`data-element-id`);i!==t&&Ys.has(r)&&n.push({id:i,exportValue:e,domElement:r})}return n}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(let t of e)t.classList.add(`highlightArea`);else e.classList.add(`highlightArea`)}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener(`dblclick`,()=>{this.linkService.eventBus?.dispatch(`switchannotationeditormode`,{source:this,mode:e,editId:t})})}},Qs=class extends Zs{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,n=document.createElement(`a`);n.setAttribute(`data-element-id`,e.id);let r=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(n,e.action),r=!0):e.attachment?(this.#t(n,e.attachment,e.attachmentDest),r=!0):e.setOCGState?(this.#n(n,e.setOCGState),r=!0):e.dest?(this._bindLink(n,e.dest),r=!0):(e.actions&&(e.actions.Action||e.actions[`Mouse Up`]||e.actions[`Mouse Down`])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),r=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,``),r=!0)),this.container.classList.add(`linkAnnotation`),r&&this.container.append(n),this.container}#e(){this.container.setAttribute(`data-internal-link`,``)}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||t===``)&&this.#e()}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),this.#e()}#t(e,t,n=null){e.href=this.linkService.getAnchorUrl(``),t.description&&(e.title=t.description),e.onclick=()=>(this.downloadManager?.openOrDownloadData(t.content,t.filename,n),!1),this.#e()}#n(e,t){e.href=this.linkService.getAnchorUrl(``),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),this.#e()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl(``);let n=/* @__PURE__ */ new Map([[`Action`,`onclick`],[`Mouse Up`,`onmouseup`],[`Mouse Down`,`onmousedown`]]);for(let r of Object.keys(t.actions)){let i=n.get(r);i&&(e[i]=()=>(this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t.id,name:r}}),!1))}e.onclick||=()=>!1,this.#e()}_bindResetFormAction(e,t){let n=e.onclick;n||(e.href=this.linkService.getAnchorUrl(``)),this.#e(),this._fieldObjects?e.onclick=()=>{n?.();let{fields:e,refs:r,include:i}=t,a=[];if(e.length!==0||r.length!==0){let t=new Set(r);for(let n of e){let e=this._fieldObjects[n]||[];for(let{id:n}of e)t.add(n)}for(let e of Object.values(this._fieldObjects))for(let n of e)t.has(n.id)===i&&a.push(n)}else for(let e of Object.values(this._fieldObjects))a.push(...e);let o=this.annotationStorage,s=[];for(let e of a){let{id:t}=e;switch(s.push(t),e.type){case`text`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}case`checkbox`:case`radiobutton`:{let n=e.defaultValue===e.exportValues;o.setValue(t,{value:n});break}case`combobox`:case`listbox`:{let n=e.defaultValue||``;o.setValue(t,{value:n});break}default:continue}let n=document.querySelector(`[data-element-id="${t}"]`);n&&(Ys.has(n)?n.dispatchEvent(new Event(`resetform`)):H(`_bindResetFormAction - element not allowed: ${t}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:`app`,ids:s,name:`ResetForm`}}),!1}:(H('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(e.onclick=()=>!1))}},$s=class extends Zs{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add(`textAnnotation`);let e=document.createElement(`img`);return e.src=this.imageResourcesPath+`annotation-`+this.data.name.toLowerCase()+`.svg`,e.setAttribute(`data-l10n-id`,`pdfjs-text-annotation-type`),e.setAttribute(`data-l10n-args`,JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}},ec=class extends Zs{render(){return this.container}showElementAndHideCanvas(e){this.data.hasOwnCanvas&&(e.previousSibling?.nodeName===`CANVAS`&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return La.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,n,r,i){n.includes(`mouse`)?e.addEventListener(n,e=>{this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})}):e.addEventListener(n,e=>{if(n===`blur`){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if(n===`focus`){if(t.focused)return;t.focused=!0}i&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:this.data.id,name:r,value:i(e)}})})}_setEventListeners(e,t,n,r){for(let[i,a]of n)(a===`Action`||this.data.actions?.[a])&&((a===`Focus`||a===`Blur`)&&(t||={focused:!1}),this._setEventListener(e,t,i,a,r),a===`Focus`&&!this.data.actions?.Blur?this._setEventListener(e,t,`blur`,`Blur`,null):a===`Blur`&&!this.data.actions?.Focus&&this._setEventListener(e,t,`focus`,`Focus`,null))}_setBackgroundColor(e){let t=this.data.backgroundColor||null;e.style.backgroundColor=t===null?`transparent`:Y.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){let t=[`left`,`center`,`right`],{fontColor:n}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||Js,i=e.style,a,o=e=>Math.round(10*e)/10;if(this.data.multiLine){let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(1.35*r))||1);a=Math.min(r,o(t/1.35))}else{let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(r,o(e/1.35))}i.fontSize=`calc(${a}px * var(--scale-factor))`,i.color=Y.makeHexColor(n[0],n[1],n[2]),this.data.textAlignment!==null&&(i.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute(`required`,!0):e.removeAttribute(`required`),e.setAttribute(`aria-required`,t)}},tc=class extends ec{constructor(e){let t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,n,r){let i=this.annotationStorage;for(let a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[t]=n),i.setValue(a.id,{[r]:n})}render(){let e=this.annotationStorage,t=this.data.id;this.container.classList.add(`textWidgetAnnotation`);let n=null;if(this.renderForms){let r=e.getValue(t,{value:this.data.fieldValue}),i=r.value||``,a=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;a&&i.length>a&&(i=i.slice(0,a));let o=r.formattedValue||this.data.textContent?.join(`
6
+ `)||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,``));let s={userValue:i,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement(`textarea`),n.textContent=o??i,this.data.doNotScroll&&(n.style.overflowY=`hidden`)):(n=document.createElement(`input`),n.type=`text`,n.setAttribute(`value`,o??i),this.data.doNotScroll&&(n.style.overflowX=`hidden`)),this.data.hasOwnCanvas&&(n.hidden=!0),Ys.add(n),n.setAttribute(`data-element-id`,t),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=qs,this._setRequired(n,this.data.required),a&&(n.maxLength=a),n.addEventListener(`input`,r=>{e.setValue(t,{value:r.target.value}),this.setPropertyOnSiblings(n,`value`,r.target.value,`value`),s.formattedValue=null}),n.addEventListener(`resetform`,e=>{let t=this.data.defaultFieldValue??``;n.value=s.userValue=t,s.formattedValue=null});let c=e=>{let{formattedValue:t}=s;t!=null&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener(`focus`,e=>{if(s.focused)return;let{target:t}=e;s.userValue&&(t.value=s.userValue),s.lastCommittedValue=t.value,s.commitKey=1,this.data.actions?.Focus||(s.focused=!0)}),n.addEventListener(`updatefromsandbox`,n=>{this.showElementAndHideCanvas(n.target),this._dispatchEventFromSandbox({value(n){s.userValue=n.detail.value??``,e.setValue(t,{value:s.userValue.toString()}),n.target.value=s.userValue},formattedValue(n){let{formattedValue:r}=n.detail;s.formattedValue=r,r!=null&&n.target!==document.activeElement&&(n.target.value=r),e.setValue(t,{formattedValue:r})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:n=>{let{charLimit:r}=n.detail,{target:i}=n;if(r===0){i.removeAttribute(`maxLength`);return}i.setAttribute(`maxLength`,r);let a=s.userValue;!a||a.length<=r||(a=a.slice(0,r),i.value=s.userValue=a,e.setValue(t,{value:a}),this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:a,willCommit:!0,commitKey:1,selStart:i.selectionStart,selEnd:i.selectionEnd}}))}},n)}),n.addEventListener(`keydown`,e=>{s.commitKey=1;let n=-1;if(e.key===`Escape`?n=0:e.key===`Enter`&&!this.data.multiLine?n=2:e.key===`Tab`&&(s.commitKey=3),n===-1)return;let{value:r}=e.target;s.lastCommittedValue!==r&&(s.lastCommittedValue=r,s.userValue=r,this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:r,willCommit:!0,commitKey:n,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))});let r=c;c=null,n.addEventListener(`blur`,e=>{if(!s.focused||!e.relatedTarget)return;this.data.actions?.Blur||(s.focused=!1);let{value:n}=e.target;s.userValue=n,s.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:n,willCommit:!0,commitKey:s.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}),r(e)}),this.data.actions?.Keystroke&&n.addEventListener(`beforeinput`,e=>{s.lastCommittedValue=null;let{data:n,target:r}=e,{value:i,selectionStart:a,selectionEnd:o}=r,c=a,l=o;switch(e.inputType){case`deleteWordBackward`:{let e=i.substring(0,a).match(/\w*[^\w]*$/);e&&(c-=e[0].length);break}case`deleteWordForward`:{let e=i.substring(a).match(/^[^\w]*\w*/);e&&(l+=e[0].length);break}case`deleteContentBackward`:a===o&&--c;break;case`deleteContentForward`:a===o&&(l+=1)}e.preventDefault(),this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:i,change:n||``,willCommit:!1,selStart:c,selEnd:l}})}),this._setEventListeners(n,s,[[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.value)}if(c&&n.addEventListener(`blur`,c),this.data.comb){let e=(this.data.rect[2]-this.data.rect[0])/a;n.classList.add(`comb`),n.style.letterSpacing=`calc(${e}px * var(--scale-factor) - 1ch)`}}else n=document.createElement(`div`),n.textContent=this.data.fieldValue,n.style.verticalAlign=`middle`,n.style.display=`table-cell`,this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}},nc=class extends ec{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}},rc=class extends ec{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,n=t.id,r=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;typeof r==`string`&&(r=r!==`Off`,e.setValue(n,{value:r})),this.container.classList.add(`buttonWidgetAnnotation`,`checkBox`);let i=document.createElement(`input`);return Ys.add(i),i.setAttribute(`data-element-id`,n),i.disabled=t.readOnly,this._setRequired(i,this.data.required),i.type=`checkbox`,i.name=t.fieldName,r&&i.setAttribute(`checked`,!0),i.setAttribute(`exportValue`,t.exportValue),i.tabIndex=qs,i.addEventListener(`change`,r=>{let{name:i,checked:a}=r.target;for(let r of this._getElementsByName(i,n)){let n=a&&r.exportValue===t.exportValue;r.domElement&&(r.domElement.checked=n),e.setValue(r.id,{value:n})}e.setValue(n,{value:a})}),i.addEventListener(`resetform`,e=>{let n=t.defaultFieldValue||`Off`;e.target.checked=n===t.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener(`updatefromsandbox`,t=>{this._dispatchEventFromSandbox({value(t){t.target.checked=t.detail.value!==`Off`,e.setValue(n,{value:t.target.checked})}},t)}),this._setEventListeners(i,null,[[`change`,`Validate`],[`change`,`Action`],[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.checked)),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},ic=class extends ec{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add(`buttonWidgetAnnotation`,`radioButton`);let e=this.annotationStorage,t=this.data,n=t.id,r=e.getValue(n,{value:t.fieldValue===t.buttonValue}).value;if(typeof r==`string`&&(r=r!==t.buttonValue,e.setValue(n,{value:r})),r)for(let r of this._getElementsByName(t.fieldName,n))e.setValue(r.id,{value:!1});let i=document.createElement(`input`);if(Ys.add(i),i.setAttribute(`data-element-id`,n),i.disabled=t.readOnly,this._setRequired(i,this.data.required),i.type=`radio`,i.name=t.fieldName,r&&i.setAttribute(`checked`,!0),i.tabIndex=qs,i.addEventListener(`change`,t=>{let{name:r,checked:i}=t.target;for(let t of this._getElementsByName(r,n))e.setValue(t.id,{value:!1});e.setValue(n,{value:i})}),i.addEventListener(`resetform`,e=>{let n=t.defaultFieldValue;e.target.checked=n!=null&&n===t.buttonValue}),this.enableScripting&&this.hasJSActions){let r=t.buttonValue;i.addEventListener(`updatefromsandbox`,t=>{this._dispatchEventFromSandbox({value:t=>{let i=r===t.detail.value;for(let r of this._getElementsByName(t.target.name)){let t=i&&r.id===n;r.domElement&&(r.domElement.checked=t),e.setValue(r.id,{value:t})}}},t)}),this._setEventListeners(i,null,[[`change`,`Validate`],[`change`,`Action`],[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`]],e=>e.target.checked)}return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}},ac=class extends Qs{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add(`buttonWidgetAnnotation`,`pushButton`);let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener(`updatefromsandbox`,e=>{this._dispatchEventFromSandbox({},e)})),e}},oc=class extends ec{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add(`choiceWidgetAnnotation`);let e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),r=document.createElement(`select`);Ys.add(r),r.setAttribute(`data-element-id`,t),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=qs;let i=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener(`resetform`,e=>{let t=this.data.defaultFieldValue;for(let e of r.options)e.selected=e.value===t});for(let e of this.data.options){let t=document.createElement(`option`);t.textContent=e.displayValue,t.value=e.exportValue,n.value.includes(e.exportValue)&&(t.setAttribute(`selected`,!0),i=!1),r.append(t)}let a=null;if(i){let e=document.createElement(`option`);e.value=` `,e.setAttribute(`hidden`,!0),e.setAttribute(`selected`,!0),r.prepend(e),a=()=>{e.remove(),r.removeEventListener(`input`,a),a=null},r.addEventListener(`input`,a)}let o=e=>{let t=e?`value`:`textContent`,{options:n,multiple:i}=r;return i?Array.prototype.filter.call(n,e=>e.selected).map(e=>e[t]):n.selectedIndex===-1?null:n[n.selectedIndex][t]},s=o(!1),c=e=>{let t=e.target.options;return Array.prototype.map.call(t,e=>({displayValue:e.textContent,exportValue:e.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener(`updatefromsandbox`,n=>{this._dispatchEventFromSandbox({value(n){a?.();let i=n.detail.value,c=new Set(Array.isArray(i)?i:[i]);for(let e of r.options)e.selected=c.has(e.value);e.setValue(t,{value:o(!0)}),s=o(!1)},multipleSelection(e){r.multiple=!0},remove(n){let i=r.options,a=n.detail.remove;i[a].selected=!1,r.remove(a),i.length>0&&Array.prototype.findIndex.call(i,e=>e.selected)===-1&&(i[0].selected=!0),e.setValue(t,{value:o(!0),items:c(n)}),s=o(!1)},clear(n){for(;r.length!==0;)r.remove(0);e.setValue(t,{value:null,items:[]}),s=o(!1)},insert(n){let{index:i,displayValue:a,exportValue:l}=n.detail.insert,u=r.children[i],d=document.createElement(`option`);d.textContent=a,d.value=l,u?u.before(d):r.append(d),e.setValue(t,{value:o(!0),items:c(n)}),s=o(!1)},items(n){let{items:i}=n.detail;for(;r.length!==0;)r.remove(0);for(let e of i){let{displayValue:t,exportValue:n}=e,i=document.createElement(`option`);i.textContent=t,i.value=n,r.append(i)}r.options.length>0&&(r.options[0].selected=!0),e.setValue(t,{value:o(!0),items:c(n)}),s=o(!1)},indices(n){let r=new Set(n.detail.indices);for(let e of n.target.options)e.selected=r.has(e.index);e.setValue(t,{value:o(!0)}),s=o(!1)},editable(e){e.target.disabled=!e.detail.editable}},n)}),r.addEventListener(`input`,n=>{let r=o(!0),i=o(!1);e.setValue(t,{value:r}),n.preventDefault(),this.linkService.eventBus?.dispatch(`dispatcheventinsandbox`,{source:this,detail:{id:t,name:`Keystroke`,value:s,change:i,changeEx:r,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(r,null,[[`focus`,`Focus`],[`blur`,`Blur`],[`mousedown`,`Mouse Down`],[`mouseenter`,`Mouse Enter`],[`mouseleave`,`Mouse Exit`],[`mouseup`,`Mouse Up`],[`input`,`Action`],[`input`,`Validate`]],e=>e.target.value)):r.addEventListener(`input`,function(n){e.setValue(t,{value:o(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}},sc=class extends Zs{constructor(e){let{data:t,elements:n}=e;super(e,{isRenderable:Zs._hasPopupData(t)}),this.elements=n,this.popup=null}render(){this.container.classList.add(`popupAnnotation`);let e=this.popup=new cc({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(let n of this.elements)n.popup=e,n.container.ariaHasPopup=`dialog`,t.push(n.data.id),n.addHighlightArea();return this.container.setAttribute(`aria-controls`,t.map(e=>`${Va}${e}`).join(`,`)),this.container}},cc=class{#e=this.#C.bind(this);#t=this.#D.bind(this);#n=this.#E.bind(this);#r=this.#T.bind(this);#i=null;#a=null;#o=null;#s=null;#c=null;#l=null;#u=null;#d=!1;#f=null;#p=null;#m=null;#h=null;#g=null;#_=null;#v=!1;constructor({container:e,color:t,elements:n,titleObj:r,modificationDate:i,contentsObj:a,richText:o,parent:s,rect:c,parentRect:l,open:u}){this.#a=e,this.#g=r,this.#o=a,this.#h=o,this.#l=s,this.#i=t,this.#m=c,this.#u=l,this.#c=n,this.#s=qa.toDateObject(i),this.trigger=n.flatMap(e=>e.getElementsToTriggerPopup());for(let e of this.trigger)e.addEventListener(`click`,this.#r),e.addEventListener(`mouseenter`,this.#n),e.addEventListener(`mouseleave`,this.#t),e.classList.add(`popupTriggerArea`);for(let e of n)e.container?.addEventListener(`keydown`,this.#e);this.#a.hidden=!0,u&&this.#T()}render(){if(this.#f)return;let e=this.#f=document.createElement(`div`);if(e.className=`popup`,this.#i){let t=e.style.outlineColor=Y.makeHexColor(...this.#i);CSS.supports(`background-color`,`color-mix(in srgb, red 30%, white)`)?e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`:e.style.backgroundColor=Y.makeHexColor(...this.#i.map(e=>Math.floor(.7*(255-e)+e)))}let t=document.createElement(`span`);t.className=`header`;let n=document.createElement(`h1`);if(t.append(n),{dir:n.dir,str:n.textContent}=this.#g,e.append(t),this.#s){let e=document.createElement(`span`);e.classList.add(`popupDate`),e.setAttribute(`data-l10n-id`,`pdfjs-annotation-date-time-string`),e.setAttribute(`data-l10n-args`,JSON.stringify({dateObj:this.#s.valueOf()})),t.append(e)}let r=this.#y;if(r)Ks.render({xfaHtml:r,intent:`richText`,div:e}),e.lastChild.classList.add(`richText`,`popupContent`);else{let t=this._formatContents(this.#o);e.append(t)}this.#a.append(e)}get#y(){let e=this.#h,t=this.#o;return e?.str&&(!t?.str||t.str===e.str)&&this.#h.html||null}get#b(){return this.#y?.attributes?.style?.fontSize||0}get#x(){return this.#y?.attributes?.style?.color||null}#S(e){let t=[],n={str:e,html:{name:`div`,attributes:{dir:`auto`},children:[{name:`p`,children:t}]}},r={style:{color:this.#x,fontSize:this.#b?`calc(${this.#b}px * var(--scale-factor))`:``}};for(let n of e.split(`
7
+ `))t.push({name:`span`,value:n,attributes:r});return n}_formatContents({str:e,dir:t}){let n=document.createElement(`p`);n.classList.add(`popupContent`),n.dir=t;let r=e.split(/(?:\r\n?|\n)/);for(let e=0,t=r.length;e<t;++e){let i=r[e];n.append(document.createTextNode(i)),e<t-1&&n.append(document.createElement(`br`))}return n}#C(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key===`Enter`||e.key===`Escape`&&this.#d)&&this.#T()}updateEdited({rect:e,popupContent:t}){this.#_||={contentsObj:this.#o,richText:this.#h},e&&(this.#p=null),t&&(this.#h=this.#S(t),this.#o=null),this.#f?.remove(),this.#f=null}resetEdited(){this.#_&&({contentsObj:this.#o,richText:this.#h}=this.#_,this.#_=null,this.#f?.remove(),this.#f=null,this.#p=null)}#w(){if(this.#p!==null)return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:r,pageY:i}}}=this.#l,a=!!this.#u,o=a?this.#u:this.#m;for(let e of this.#c)if(!o||Y.intersect(e.data.rect,o)!==null){o=e.data.rect,a=!0;break}let s=Y.normalizeRect([o[0],e[3]-o[1]+e[1],o[2],e[3]-o[3]+e[1]]),c=a?o[2]-o[0]+5:0,l=s[0]+c,u=s[1];this.#p=[100*(l-r)/t,100*(u-i)/n];let{style:d}=this.#a;d.left=`${this.#p[0]}%`,d.top=`${this.#p[1]}%`}#T(){this.#d=!this.#d,this.#d?(this.#E(),this.#a.addEventListener(`click`,this.#r),this.#a.addEventListener(`keydown`,this.#e)):(this.#D(),this.#a.removeEventListener(`click`,this.#r),this.#a.removeEventListener(`keydown`,this.#e))}#E(){this.#f||this.render(),this.isVisible?this.#d&&this.#a.classList.add(`focused`):(this.#w(),this.#a.hidden=!1,this.#a.style.zIndex=parseInt(this.#a.style.zIndex)+1e3)}#D(){this.#a.classList.remove(`focused`),!(this.#d||!this.isVisible)&&(this.#a.hidden=!0,this.#a.style.zIndex=parseInt(this.#a.style.zIndex)-1e3)}forceHide(){this.#v=this.isVisible,this.#v&&(this.#a.hidden=!0)}maybeShow(){this.#v&&(this.#f||this.#E(),this.#v=!1,this.#a.hidden=!1)}get isVisible(){return this.#a.hidden===!1}},lc=class extends Zs{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=J.FREETEXT}render(){if(this.container.classList.add(`freeTextAnnotation`),this.textContent){let e=document.createElement(`div`);e.classList.add(`annotationTextContent`),e.setAttribute(`role`,`comment`);for(let t of this.textContent){let n=document.createElement(`span`);n.textContent=t,e.append(n)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},uc=class extends Zs{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add(`lineAnnotation`);let e=this.data,{width:t,height:n}=mt(e.rect),r=this.svgFactory.create(t,n,!0),i=this.#e=this.svgFactory.createElement(`svg:line`);return i.setAttribute(`x1`,e.rect[2]-e.lineCoordinates[0]),i.setAttribute(`y1`,e.rect[3]-e.lineCoordinates[1]),i.setAttribute(`x2`,e.rect[2]-e.lineCoordinates[2]),i.setAttribute(`y2`,e.rect[3]-e.lineCoordinates[3]),i.setAttribute(`stroke-width`,e.borderStyle.width||1),i.setAttribute(`stroke`,`transparent`),i.setAttribute(`fill`,`transparent`),r.append(i),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}},dc=class extends Zs{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add(`squareAnnotation`);let e=this.data,{width:t,height:n}=mt(e.rect),r=this.svgFactory.create(t,n,!0),i=e.borderStyle.width,a=this.#e=this.svgFactory.createElement(`svg:rect`);return a.setAttribute(`x`,i/2),a.setAttribute(`y`,i/2),a.setAttribute(`width`,t-i),a.setAttribute(`height`,n-i),a.setAttribute(`stroke-width`,i||1),a.setAttribute(`stroke`,`transparent`),a.setAttribute(`fill`,`transparent`),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}},fc=class extends Zs{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add(`circleAnnotation`);let e=this.data,{width:t,height:n}=mt(e.rect),r=this.svgFactory.create(t,n,!0),i=e.borderStyle.width,a=this.#e=this.svgFactory.createElement(`svg:ellipse`);return a.setAttribute(`cx`,t/2),a.setAttribute(`cy`,n/2),a.setAttribute(`rx`,t/2-i/2),a.setAttribute(`ry`,n/2-i/2),a.setAttribute(`stroke-width`,i||1),a.setAttribute(`stroke`,`transparent`),a.setAttribute(`fill`,`transparent`),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}},pc=class extends Zs{#e=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName=`polylineAnnotation`,this.svgElementName=`svg:polyline`}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,vertices:t,borderStyle:n,popupRef:r}}=this;if(!t)return this.container;let{width:i,height:a}=mt(e),o=this.svgFactory.create(i,a,!0),s=[];for(let n=0,r=t.length;n<r;n+=2){let r=t[n]-e[0],i=e[3]-t[n+1];s.push(`${r},${i}`)}s=s.join(` `);let c=this.#e=this.svgFactory.createElement(this.svgElementName);return c.setAttribute(`points`,s),c.setAttribute(`stroke-width`,n.width||1),c.setAttribute(`stroke`,`transparent`),c.setAttribute(`fill`,`transparent`),o.append(c),this.container.append(o),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}},mc=class extends pc{constructor(e){super(e),this.containerClassName=`polygonAnnotation`,this.svgElementName=`svg:polygon`}},hc=class extends Zs{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add(`caretAnnotation`),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}},gc=class extends Zs{#e=null;#t=[];constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName=`inkAnnotation`,this.svgElementName=`svg:polyline`,this.annotationEditorType=this.data.it===`InkHighlight`?J.HIGHLIGHT:J.INK}#n(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:e,rotation:t,inkLists:n,borderStyle:r,popupRef:i}}=this,{transform:a,width:o,height:s}=this.#n(t,e),c=this.svgFactory.create(o,s,!0),l=this.#e=this.svgFactory.createElement(`svg:g`);c.append(l),l.setAttribute(`stroke-width`,r.width||1),l.setAttribute(`stroke-linecap`,`round`),l.setAttribute(`stroke-linejoin`,`round`),l.setAttribute(`stroke-miterlimit`,10),l.setAttribute(`stroke`,`transparent`),l.setAttribute(`fill`,`transparent`),l.setAttribute(`transform`,a);for(let e=0,t=n.length;e<t;e++){let t=this.svgFactory.createElement(this.svgElementName);this.#t.push(t),t.setAttribute(`points`,n[e].join(`,`)),l.append(t)}return!i&&this.hasPopupData&&this._createPopup(),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);let{thickness:t,points:n,rect:r}=e,i=this.#e;if(t>=0&&i.setAttribute(`stroke-width`,t||1),n)for(let e=0,t=this.#t.length;e<t;e++)this.#t[e].setAttribute(`points`,n[e].join(`,`));if(r){let{transform:e,width:t,height:n}=this.#n(this.data.rotation,r);i.parentElement.setAttribute(`viewBox`,`0 0 ${t} ${n}`),i.setAttribute(`transform`,e)}}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add(`highlightArea`)}},_c=class extends Zs{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=J.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add(`highlightAnnotation`),this._editOnDoubleClick(),this.container}},vc=class extends Zs{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add(`underlineAnnotation`),this.container}},yc=class extends Zs{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add(`squigglyAnnotation`),this.container}},bc=class extends Zs{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add(`strikeoutAnnotation`),this.container}},xc=class extends Zs{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=J.STAMP}render(){return this.container.classList.add(`stampAnnotation`),this.container.setAttribute(`role`,`img`),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}},Sc=class extends Zs{#e=null;constructor(e){super(e,{isRenderable:!0});let{file:t}=this.data;this.filename=t.filename,this.content=t.content,this.linkService.eventBus?.dispatch(`fileattachmentannotation`,{source:this,...t})}render(){this.container.classList.add(`fileAttachmentAnnotation`);let{container:e,data:t}=this,n;t.hasAppearance||t.fillAlpha===0?n=document.createElement(`div`):(n=document.createElement(`img`),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?`paperclip`:`pushpin`}.svg`,t.fillAlpha&&t.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(t.fillAlpha*100)}%);`)),n.addEventListener(`dblclick`,this.#t.bind(this)),this.#e=n;let{isMac:r}=La.platform;return e.addEventListener(`keydown`,e=>{e.key===`Enter`&&(r?e.metaKey:e.ctrlKey)&&this.#t()}),!t.popupRef&&this.hasPopupData?this._createPopup():n.classList.add(`popupTriggerArea`),e.append(n),e}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add(`highlightArea`)}#t(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}},Cc=class{#e=null;#t=null;#n=/* @__PURE__ */ new Map;#r=null;constructor({div:e,accessibilityManager:t,annotationCanvasMap:n,annotationEditorUIManager:r,page:i,viewport:a,structTreeLayer:o}){this.div=e,this.#e=t,this.#t=n,this.#r=o||null,this.page=i,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=r}hasEditableAnnotations(){return this.#n.size>0}async#i(e,t){let n=e.firstChild||e,r=n.id=`${Va}${t}`,i=await this.#r?.getAriaAttributes(r);if(i)for(let[e,t]of i)n.setAttribute(e,t);this.div.append(e),this.#e?.moveElementInDOM(this.div,e,n,!1)}async render(e){let{annotations:t}=e,n=this.div;Fe(n,this.viewport);let r=/* @__PURE__ */ new Map,i={data:null,layer:n,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||``,renderForms:e.renderForms!==!1,svgFactory:new Gs,annotationStorage:e.annotationStorage||new po,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(let e of t){if(e.noHTML)continue;let t=e.annotationType===Ca.POPUP;if(t){let t=r.get(e.id);if(!t)continue;i.elements=t}else{let{width:t,height:n}=mt(e.rect);if(t<=0||n<=0)continue}i.data=e;let n=Xs.create(i);if(!n.isRenderable)continue;if(!t&&e.popupRef){let t=r.get(e.popupRef);t?t.push(n):r.set(e.popupRef,[n])}let a=n.render();e.hidden&&(a.style.visibility=`hidden`),await this.#i(a,e.id),n._isEditable&&(this.#n.set(n.data.id,n),this._annotationEditorUIManager?.renderAnnotationElement(n))}this.#a()}update({viewport:e}){let t=this.div;this.viewport=e,Fe(t,{rotation:e.rotation}),this.#a(),t.hidden=!1}#a(){if(!this.#t)return;let e=this.div;for(let[t,n]of this.#t){let r=e.querySelector(`[data-annotation-id="${t}"]`);if(!r)continue;n.className=`annotationContent`;let{firstChild:i}=r;i?i.nodeName===`CANVAS`?i.replaceWith(n):i.classList.contains(`annotationContent`)?i.after(n):i.before(n):r.append(n)}this.#t.clear()}getEditableAnnotations(){return Array.from(this.#n.values())}getEditableAnnotation(e){return this.#n.get(e)}},wc=/\r\n?|\n/g,Tc=class e extends ao{#e;#t=``;#n=`${this.id}-editor`;#r=null;#i;static _freeTextDefaultContent=``;static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=e.prototype,n=e=>e.isEmpty(),r=no.TRANSLATE_SMALL,i=no.TRANSLATE_BIG;return W(this,`_keyboardManager`,new eo([[[`ctrl+s`,`mac+meta+s`,`ctrl+p`,`mac+meta+p`],t.commitOrRemove,{bubbles:!0}],[[`ctrl+Enter`,`mac+meta+Enter`,`Escape`,`mac+Escape`],t.commitOrRemove],[[`ArrowLeft`,`mac+ArrowLeft`],t._translateEmpty,{args:[-r,0],checker:n}],[[`ctrl+ArrowLeft`,`mac+shift+ArrowLeft`],t._translateEmpty,{args:[-i,0],checker:n}],[[`ArrowRight`,`mac+ArrowRight`],t._translateEmpty,{args:[r,0],checker:n}],[[`ctrl+ArrowRight`,`mac+shift+ArrowRight`],t._translateEmpty,{args:[i,0],checker:n}],[[`ArrowUp`,`mac+ArrowUp`],t._translateEmpty,{args:[0,-r],checker:n}],[[`ctrl+ArrowUp`,`mac+shift+ArrowUp`],t._translateEmpty,{args:[0,-i],checker:n}],[[`ArrowDown`,`mac+ArrowDown`],t._translateEmpty,{args:[0,r],checker:n}],[[`ctrl+ArrowDown`,`mac+shift+ArrowDown`],t._translateEmpty,{args:[0,i],checker:n}]]))}static _type=`freetext`;static _editorType=J.FREETEXT;constructor(t){super({...t,name:`freeTextEditor`}),this.#e=t.color||e._defaultColor||ao._defaultLineColor,this.#i=t.fontSize||e._defaultFontSize}static initialize(e,t){ao.initialize(e,t);let n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue(`--freetext-padding`))}static updateDefaultParams(t,n){switch(t){case ya.FREETEXT_SIZE:e._defaultFontSize=n;break;case ya.FREETEXT_COLOR:e._defaultColor=n}}updateParams(e,t){switch(e){case ya.FREETEXT_SIZE:this.#a(t);break;case ya.FREETEXT_COLOR:this.#o(t)}}static get defaultPropertiesToUpdate(){return[[ya.FREETEXT_SIZE,e._defaultFontSize],[ya.FREETEXT_COLOR,e._defaultColor||ao._defaultLineColor]]}get propertiesToUpdate(){return[[ya.FREETEXT_SIZE,this.#i],[ya.FREETEXT_COLOR,this.#e]]}#a(e){let t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`,this.translate(0,-(e-this.#i)*this.parentScale),this.#i=e,this.#c()},n=this.#i;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ya.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#o(e){let t=e=>{this.#e=this.editorDiv.style.color=e},n=this.#e;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ya.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){let t=this.parentScale;return[-e._internalPadding*t,-(e._internalPadding+this.#i)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(J.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove(`enabled`),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute(`aria-activedescendant`),this.#r=new AbortController;let e=this._uiManager.combinedSignal(this.#r);this.editorDiv.addEventListener(`keydown`,this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener(`focus`,this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener(`blur`,this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener(`input`,this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener(`paste`,this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add(`enabled`),this.editorDiv.contentEditable=!1,this.div.setAttribute(`aria-activedescendant`,this.#n),this._isDraggable=!0,this.#r?.abort(),this.#r=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add(`freetextEditing`))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===``}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add(`freetextEditing`)),super.remove()}#s(){let t=[];this.editorDiv.normalize();let n=null;for(let r of this.editorDiv.childNodes)(n?.nodeType!==Node.TEXT_NODE||r.nodeName!==`BR`)&&(t.push(e.#l(r)),n=r);return t.join(`
8
+ `)}#c(){let[e,t]=this.parentDimensions,n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{let{currentLayer:e,div:t}=this,r=t.style.display,i=t.classList.contains(`hidden`);t.classList.remove(`hidden`),t.style.display=`hidden`,e.div.append(this.div),n=t.getBoundingClientRect(),t.remove(),t.style.display=r,t.classList.toggle(`hidden`,i)}this.rotation%180==this.parentRotation%180?(this.width=n.width/e,this.height=n.height/t):(this.width=n.height/e,this.height=n.width/t),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=this.#t,t=this.#t=this.#s().trimEnd();if(e===t)return;let n=e=>{this.#t=e,e?(this.#u(),this._uiManager.rebuild(this),this.#c()):this.remove()};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),this.#c()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&e.key===`Enter`&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(t){e._keyboardManager.exec(this,t)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle(`freetextEditing`,this.isEmpty())}disableEditing(){this.editorDiv.setAttribute(`role`,`comment`),this.editorDiv.removeAttribute(`aria-multiline`)}enableEditing(){this.editorDiv.setAttribute(`role`,`textbox`),this.editorDiv.setAttribute(`aria-multiline`,!0)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement(`div`),this.editorDiv.className=`internal`,this.editorDiv.setAttribute(`id`,this.#n),this.editorDiv.setAttribute(`data-l10n-id`,`pdfjs-free-text2`),this.editorDiv.setAttribute(`data-l10n-attrs`,`default-content`),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:n}=this.editorDiv;if(n.fontSize=`calc(${this.#i}px * var(--scale-factor))`,n.color=this.#e,this.div.append(this.editorDiv),this.overlayDiv=document.createElement(`div`),this.overlayDiv.classList.add(`overlay`,`enabled`),this.div.append(this.overlayDiv),Ie(this,this.div,[`dblclick`,`keydown`]),this.width){let[n,r]=this.parentDimensions;if(this.annotationElementId){let{position:i}=this._initialData,[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);let[s,c]=this.pageDimensions,[l,u]=this.pageTranslation,d,f;switch(this.rotation){case 0:d=e+(i[0]-l)/s,f=t+this.height-(i[1]-u)/c;break;case 90:d=e+(i[0]-l)/s,f=t-(i[1]-u)/c,[a,o]=[o,-a];break;case 180:d=e-this.width+(i[0]-l)/s,f=t-(i[1]-u)/c,[a,o]=[-a,-o];break;case 270:d=e+(i[0]-l-this.height*c)/s,f=t+(i[1]-u-this.width*s)/c,[a,o]=[-o,a]}this.setAt(d*n,f*r,a,o)}else this.setAt(e*n,t*r,this.width*n,this.height*r);this.#u(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#l(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(wc,``)}editorDivPaste(t){let n=t.clipboardData||window.clipboardData,{types:r}=n;if(r.length===1&&r[0]===`text/plain`)return;t.preventDefault();let i=e.#f(n.getData(`text`)||``).replaceAll(wc,`
9
+ `);if(!i)return;let a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();let o=a.getRangeAt(0);if(!i.includes(`
10
+ `)){o.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),a.collapseToStart();return}let{startContainer:s,startOffset:c}=o,l=[],u=[];if(s.nodeType===Node.TEXT_NODE){let t=s.parentElement;if(u.push(s.nodeValue.slice(c).replaceAll(wc,``)),t!==this.editorDiv){let n=l;for(let r of this.editorDiv.childNodes)r===t?n=u:n.push(e.#l(r))}l.push(s.nodeValue.slice(0,c).replaceAll(wc,``))}else if(s===this.editorDiv){let t=l,n=0;for(let r of this.editorDiv.childNodes)n++===c&&(t=u),t.push(e.#l(r))}this.#t=`${l.join(`
11
+ `)}${i}${u.join(`
12
+ `)}`,this.#u();let d=new Range,f=l.reduce((e,t)=>e+t.length,0);for(let{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){let t=e.nodeValue.length;if(f<=t){d.setStart(e,f),d.setEnd(e,f);break}f-=t}a.removeAllRanges(),a.addRange(d)}#u(){if(this.editorDiv.replaceChildren(),this.#t)for(let e of this.#t.split(`
13
+ `)){let t=document.createElement(`div`);t.append(e?document.createTextNode(e):document.createElement(`br`)),this.editorDiv.append(t)}}#d(){return this.#t.replaceAll(`\xA0`,` `)}static#f(e){return e.replaceAll(` `,`\xA0`)}get contentDiv(){return this.editorDiv}static async deserialize(t,n,r){let i=null;if(t instanceof lc){let{data:{defaultAppearanceData:{fontSize:e,fontColor:n},rect:r,rotation:a,id:o,popupRef:s},textContent:c,textPosition:l,parent:{page:{pageNumber:u}}}=t;if(!c||c.length===0)return null;i=t={annotationType:J.FREETEXT,color:Array.from(n),fontSize:e,value:c.join(`
14
+ `),position:l,pageIndex:u-1,rect:r.slice(0),rotation:a,id:o,deleted:!1,popupRef:s}}let a=await super.deserialize(t,n,r);return a.#i=t.fontSize,a.#e=Y.makeHexColor(...t.color),a.#t=e.#f(t.value),a.annotationElementId=t.id||null,a._initialData=i,a}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let n=e._internalPadding*this.parentScale,r=this.getRect(n,n),i=ao._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#e),a={annotationType:J.FREETEXT,color:i,fontSize:this.#i,value:this.#d(),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?a:this.annotationElementId&&!this.#p(a)?null:(a.id=this.annotationElementId,a)}#p(e){let{value:t,fontSize:n,color:r,pageIndex:i}=this._initialData;return this._hasBeenMoved||e.value!==t||e.fontSize!==n||e.color.some((e,t)=>e!==r[t])||e.pageIndex!==i}renderAnnotationElement(t){let n=super.renderAnnotationElement(t);if(this.deleted)return n;let{style:r}=n;r.fontSize=`calc(${this.#i}px * var(--scale-factor))`,r.color=this.#e,n.replaceChildren();for(let e of this.#t.split(`
15
+ `)){let t=document.createElement(`div`);t.append(e?document.createTextNode(e):document.createElement(`br`)),n.append(t)}let i=e._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(i,i),popupContent:this.#t}),n}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}},Z=class{static PRECISION=1e-4;toSVGPath(){U("Abstract method `toSVGPath` must be implemented.")}get box(){U("Abstract getter `box` must be implemented.")}serialize(e,t){U("Abstract method `serialize` must be implemented.")}static _rescale(e,t,n,r,i,a){a||=new Float32Array(e.length);for(let o=0,s=e.length;o<s;o+=2)a[o]=t+e[o]*r,a[o+1]=n+e[o+1]*i;return a}static _rescaleAndSwap(e,t,n,r,i,a){a||=new Float32Array(e.length);for(let o=0,s=e.length;o<s;o+=2)a[o]=t+e[o+1]*r,a[o+1]=n+e[o]*i;return a}static _translate(e,t,n,r){r||=new Float32Array(e.length);for(let i=0,a=e.length;i<a;i+=2)r[i]=t+e[i],r[i+1]=n+e[i+1];return r}static svgRound(e){return Math.round(e*1e4)}static _normalizePoint(e,t,n,r,i){switch(i){case 90:return[1-t/n,e/r];case 180:return[1-e/n,1-t/r];case 270:return[t/n,1-e/r];default:return[e/n,t/r]}}static _normalizePagePoint(e,t,n){switch(n){case 90:return[1-t,e];case 180:return[1-e,1-t];case 270:return[t,1-e];default:return[e,t]}}static createBezierPoints(e,t,n,r,i,a){return[(e+5*n)/6,(t+5*r)/6,(5*n+i)/6,(5*r+a)/6,(n+i)/2,(r+a)/2]}},Ec=class e{#e;#t=[];#n;#r;#i=[];#a=/* @__PURE__ */ new Float32Array(18);#o;#s;#c;#l;#u;#d;#f=[];static#p=8;static#m=2;static#h=e.#p+e.#m;constructor({x:t,y:n},r,i,a,o,s=0){this.#e=r,this.#d=a*i,this.#r=o,this.#a.set([NaN,NaN,NaN,NaN,t,n],6),this.#n=s,this.#l=e.#p*i,this.#c=e.#h*i,this.#u=i,this.#f.push(t,n)}isEmpty(){return isNaN(this.#a[8])}#g(){let e=this.#a.subarray(4,6),t=this.#a.subarray(16,18),[n,r,i,a]=this.#e;return[(this.#o+(e[0]-t[0])/2-n)/i,(this.#s+(e[1]-t[1])/2-r)/a,(this.#o+(t[0]-e[0])/2-n)/i,(this.#s+(t[1]-e[1])/2-r)/a]}add({x:e,y:t}){this.#o=e,this.#s=t;let[n,r,i,a]=this.#e,[o,s,c,l]=this.#a.subarray(8,12),u=e-c,d=t-l,f=Math.hypot(u,d);if(f<this.#c)return!1;let p=f-this.#l,m=p/f,h=m*u,g=m*d,_=o,v=s;o=c,s=l,c+=h,l+=g,this.#f?.push(e,t);let y=-g/p,b=h/p,x=y*this.#d,S=b*this.#d;return this.#a.set(this.#a.subarray(2,8),0),this.#a.set([c+x,l+S],4),this.#a.set(this.#a.subarray(14,18),12),this.#a.set([c-x,l-S],16),isNaN(this.#a[6])?(this.#i.length===0&&(this.#a.set([o+x,s+S],2),this.#i.push(NaN,NaN,NaN,NaN,(o+x-n)/i,(s+S-r)/a),this.#a.set([o-x,s-S],14),this.#t.push(NaN,NaN,NaN,NaN,(o-x-n)/i,(s-S-r)/a)),this.#a.set([_,v,o,s,c,l],6),!this.isEmpty()):(this.#a.set([_,v,o,s,c,l],6),Math.abs(Math.atan2(v-s,_-o)-Math.atan2(g,h))<Math.PI/2?([o,s,c,l]=this.#a.subarray(2,6),this.#i.push(NaN,NaN,NaN,NaN,((o+c)/2-n)/i,((s+l)/2-r)/a),[o,s,_,v]=this.#a.subarray(14,18),this.#t.push(NaN,NaN,NaN,NaN,((_+o)/2-n)/i,((v+s)/2-r)/a),!0):([_,v,o,s,c,l]=this.#a.subarray(0,6),this.#i.push(((_+5*o)/6-n)/i,((v+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a),[c,l,o,s,_,v]=this.#a.subarray(12,18),this.#t.push(((_+5*o)/6-n)/i,((v+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a),!0))}toSVGPath(){if(this.isEmpty())return``;let e=this.#i,t=this.#t;if(isNaN(this.#a[6])&&!this.isEmpty())return this.#_();let n=[];n.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?n.push(`L${e[t+4]} ${e[t+5]}`):n.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);this.#y(n);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?n.push(`L${t[e+4]} ${t[e+5]}`):n.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);return this.#v(n),n.join(` `)}#_(){let[e,t,n,r]=this.#e,[i,a,o,s]=this.#g();return`M${(this.#a[2]-e)/n} ${(this.#a[3]-t)/r} L${(this.#a[4]-e)/n} ${(this.#a[5]-t)/r} L${i} ${a} L${o} ${s} L${(this.#a[16]-e)/n} ${(this.#a[17]-t)/r} L${(this.#a[14]-e)/n} ${(this.#a[15]-t)/r} Z`}#v(e){let t=this.#t;e.push(`L${t[4]} ${t[5]} Z`)}#y(e){let[t,n,r,i]=this.#e,a=this.#a.subarray(4,6),o=this.#a.subarray(16,18),[s,c,l,u]=this.#g();e.push(`L${(a[0]-t)/r} ${(a[1]-n)/i} L${s} ${c} L${l} ${u} L${(o[0]-t)/r} ${(o[1]-n)/i}`)}newFreeDrawOutline(e,t,n,r,i,a){return new Dc(e,t,n,r,i,a)}getOutlines(){let e=this.#i,t=this.#t,n=this.#a,[r,i,a,o]=this.#e,s=new Float32Array((this.#f?.length??0)+2);for(let e=0,t=s.length-2;e<t;e+=2)s[e]=(this.#f[e]-r)/a,s[e+1]=(this.#f[e+1]-i)/o;if(s[s.length-2]=(this.#o-r)/a,s[s.length-1]=(this.#s-i)/o,isNaN(n[6])&&!this.isEmpty())return this.#b(s);let c=new Float32Array(this.#i.length+24+this.#t.length),l=e.length;for(let t=0;t<l;t+=2)isNaN(e[t])?c[t]=c[t+1]=NaN:(c[t]=e[t],c[t+1]=e[t+1]);l=this.#S(c,l);for(let e=t.length-6;e>=6;e-=6)for(let n=0;n<6;n+=2)isNaN(t[e+n])?(c[l]=c[l+1]=NaN,l+=2):(c[l]=t[e+n],c[l+1]=t[e+n+1],l+=2);return this.#x(c,l),this.newFreeDrawOutline(c,s,this.#e,this.#u,this.#n,this.#r)}#b(e){let t=this.#a,[n,r,i,a]=this.#e,[o,s,c,l]=this.#g(),u=/* @__PURE__ */ new Float32Array(36);return u.set([NaN,NaN,NaN,NaN,(t[2]-n)/i,(t[3]-r)/a,NaN,NaN,NaN,NaN,(t[4]-n)/i,(t[5]-r)/a,NaN,NaN,NaN,NaN,o,s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,(t[16]-n)/i,(t[17]-r)/a,NaN,NaN,NaN,NaN,(t[14]-n)/i,(t[15]-r)/a],0),this.newFreeDrawOutline(u,e,this.#e,this.#u,this.#n,this.#r)}#x(e,t){let n=this.#t;return e.set([NaN,NaN,NaN,NaN,n[4],n[5]],t),t+=6}#S(e,t){let n=this.#a.subarray(4,6),r=this.#a.subarray(16,18),[i,a,o,s]=this.#e,[c,l,u,d]=this.#g();return e.set([NaN,NaN,NaN,NaN,(n[0]-i)/o,(n[1]-a)/s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,(r[0]-i)/o,(r[1]-a)/s],t),t+=24}},Dc=class extends Z{#e;#t=/* @__PURE__ */ new Float32Array(4);#n;#r;#i;#a;#o;constructor(e,t,n,r,i,a){super(),this.#o=e,this.#i=t,this.#e=n,this.#a=r,this.#n=i,this.#r=a,this.lastPoint=[NaN,NaN],this.#s(a);let[o,s,c,l]=this.#t;for(let t=0,n=e.length;t<n;t+=2)e[t]=(e[t]-o)/c,e[t+1]=(e[t+1]-s)/l;for(let e=0,n=t.length;e<n;e+=2)t[e]=(t[e]-o)/c,t[e+1]=(t[e+1]-s)/l}toSVGPath(){let e=[`M${this.#o[4]} ${this.#o[5]}`];for(let t=6,n=this.#o.length;t<n;t+=6)isNaN(this.#o[t])?e.push(`L${this.#o[t+4]} ${this.#o[t+5]}`):e.push(`C${this.#o[t]} ${this.#o[t+1]} ${this.#o[t+2]} ${this.#o[t+3]} ${this.#o[t+4]} ${this.#o[t+5]}`);return e.push(`Z`),e.join(` `)}serialize([e,t,n,r],i){let a=n-e,o=r-t,s,c;switch(i){case 0:s=Z._rescale(this.#o,e,r,a,-o),c=Z._rescale(this.#i,e,r,a,-o);break;case 90:s=Z._rescaleAndSwap(this.#o,e,t,a,o),c=Z._rescaleAndSwap(this.#i,e,t,a,o);break;case 180:s=Z._rescale(this.#o,n,t,-a,o),c=Z._rescale(this.#i,n,t,-a,o);break;case 270:s=Z._rescaleAndSwap(this.#o,n,r,-a,-o),c=Z._rescaleAndSwap(this.#i,n,r,-a,-o)}return{outline:Array.from(s),points:[Array.from(c)]}}#s(e){let t=this.#o,n=t[4],r=t[5],i=n,a=r,o=n,s=r,c=n,l=r,u=e?Math.max:Math.min;for(let e=6,d=t.length;e<d;e+=6){if(isNaN(t[e]))i=Math.min(i,t[e+4]),a=Math.min(a,t[e+5]),o=Math.max(o,t[e+4]),s=Math.max(s,t[e+5]),l<t[e+5]?(c=t[e+4],l=t[e+5]):l===t[e+5]&&(c=u(c,t[e+4]));else{let d=Y.bezierBoundingBox(n,r,...t.slice(e,e+6));i=Math.min(i,d[0]),a=Math.min(a,d[1]),o=Math.max(o,d[2]),s=Math.max(s,d[3]),l<d[3]?(c=d[2],l=d[3]):l===d[3]&&(c=u(c,d[2]))}n=t[e+4],r=t[e+5]}let d=this.#t;d[0]=i-this.#n,d[1]=a-this.#n,d[2]=o-i+2*this.#n,d[3]=s-a+2*this.#n,this.lastPoint=[c,l]}get box(){return this.#t}newOutliner(e,t,n,r,i,a=0){return new Ec(e,t,n,r,i,a)}getNewOutline(e,t){let[n,r,i,a]=this.#t,[o,s,c,l]=this.#e,u=i*c,d=a*l,f=n*c+o,p=r*l+s,m=this.newOutliner({x:this.#i[0]*u+f,y:this.#i[1]*d+p},this.#e,this.#a,e,this.#r,t??this.#n);for(let e=2;e<this.#i.length;e+=2)m.add({x:this.#i[e]*u+f,y:this.#i[e+1]*d+p});return m.getOutlines()}},Oc=class{#e;#t;#n=[];#r=[];constructor(e,t=0,n=0,r=!0){let i=1/0,a=-1/0,o=1/0,s=-1/0,c=10**-4;for(let{x:n,y:r,width:l,height:u}of e){let e=Math.floor((n-t)/c)*c,d=Math.ceil((n+l+t)/c)*c,f=Math.floor((r-t)/c)*c,p=Math.ceil((r+u+t)/c)*c,m=[e,f,p,!0],h=[d,f,p,!1];this.#n.push(m,h),i=Math.min(i,e),a=Math.max(a,d),o=Math.min(o,f),s=Math.max(s,p)}let l=a-i+2*n,u=s-o+2*n,d=i-n,f=o-n,p=this.#n.at(r?-1:-2),m=[p[0],p[2]];for(let e of this.#n){let[t,n,r]=e;e[0]=(t-d)/l,e[1]=(n-f)/u,e[2]=(r-f)/u}this.#e=new Float32Array([d,f,l,u]),this.#t=m}getOutlines(){this.#n.sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);let e=[];for(let t of this.#n)t[3]?(e.push(...this.#c(t)),this.#o(t)):(this.#s(t),e.push(...this.#c(t)));return this.#i(e)}#i(e){let t=[],n=/* @__PURE__ */ new Set;for(let n of e){let[e,r,i]=n;t.push([e,r,n],[e,i,n])}t.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,r=t.length;e<r;e+=2){let r=t[e][2],i=t[e+1][2];r.push(i),i.push(r),n.add(r),n.add(i)}let r=[],i;for(;n.size>0;){let e=n.values().next().value,[t,a,o,s,c]=e;n.delete(e);let l=t,u=a;for(i=[t,o],r.push(i);;){let e;if(n.has(s))e=s;else if(n.has(c))e=c;else break;n.delete(e),[t,a,o,s,c]=e,l!==t&&(i.push(l,u,t,u===a?a:o),l=t),u=u===a?o:a}i.push(l,u)}return new kc(r,this.#e,this.#t)}#a(e){let t=this.#r,n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i][0];if(a===e)return i;a<e?n=i+1:r=i-1}return r+1}#o([,e,t]){let n=this.#a(e);this.#r.splice(n,0,[e,t])}#s([,e,t]){let n=this.#a(e);for(let r=n;r<this.#r.length;r++){let[n,i]=this.#r[r];if(n!==e)break;if(n===e&&i===t){this.#r.splice(r,1);return}}for(let r=n-1;r>=0;r--){let[n,i]=this.#r[r];if(n!==e)break;if(n===e&&i===t){this.#r.splice(r,1);return}}}#c(e){let[t,n,r]=e,i=[[t,n,r]],a=this.#a(r);for(let e=0;e<a;e++){let[n,r]=this.#r[e];for(let e=0,a=i.length;e<a;e++){let[,o,s]=i[e];if(!(r<=o||s<=n)){if(o>=n){if(s>r)i[e][1]=r;else{if(a===1)return[];i.splice(e,1),e--,a--}}else i[e][2]=n,s>r&&i.push([t,r,s])}}}return i}},kc=class extends Z{#e;#t;constructor(e,t,n){super(),this.#t=e,this.#e=t,this.lastPoint=n}toSVGPath(){let e=[];for(let t of this.#t){let[n,r]=t;e.push(`M${n} ${r}`);for(let i=2;i<t.length;i+=2){let a=t[i],o=t[i+1];a===n?(e.push(`V${o}`),r=o):o===r&&(e.push(`H${a}`),n=a)}e.push(`Z`)}return e.join(` `)}serialize([e,t,n,r],i){let a=[],o=n-e,s=r-t;for(let t of this.#t){let n=Array(t.length);for(let i=0;i<t.length;i+=2)n[i]=e+t[i]*o,n[i+1]=r-t[i+1]*s;a.push(n)}return a}get box(){return this.#e}get classNamesForOutlining(){return[`highlightOutline`]}},Ac=class extends Ec{newFreeDrawOutline(e,t,n,r,i,a){return new jc(e,t,n,r,i,a)}},jc=class extends Dc{newOutliner(e,t,n,r,i,a=0){return new Ac(e,t,n,r,i,a)}},Mc=class e{#e=null;#t=null;#n;#r=null;#i=!1;#a=!1;#o=null;#s;#c=null;#l=null;#u;static#d=null;static get _keyboardManager(){return W(this,`_keyboardManager`,new eo([[[`Escape`,`mac+Escape`],e.prototype._hideDropdownFromKeyboard],[[` `,`mac+ `],e.prototype._colorSelectFromKeyboard],[[`ArrowDown`,`ArrowRight`,`mac+ArrowDown`,`mac+ArrowRight`],e.prototype._moveToNext],[[`ArrowUp`,`ArrowLeft`,`mac+ArrowUp`,`mac+ArrowLeft`],e.prototype._moveToPrevious],[[`Home`,`mac+Home`],e.prototype._moveToBeginning],[[`End`,`mac+End`],e.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:n=null}){t?(this.#a=!1,this.#u=ya.HIGHLIGHT_COLOR,this.#o=t):(this.#a=!0,this.#u=ya.HIGHLIGHT_DEFAULT_COLOR),this.#l=t?._uiManager||n,this.#s=this.#l._eventBus,this.#n=t?.color||this.#l?.highlightColors.values().next().value||`#FFFF98`,e.#d||=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 e=this.#e=document.createElement(`button`);e.className=`colorPicker`,e.tabIndex=`0`,e.setAttribute(`data-l10n-id`,`pdfjs-editor-colorpicker-button`),e.setAttribute(`aria-haspopup`,!0);let t=this.#l._signal;e.addEventListener(`click`,this.#h.bind(this),{signal:t}),e.addEventListener(`keydown`,this.#m.bind(this),{signal:t});let n=this.#t=document.createElement(`span`);return n.className=`swatch`,n.setAttribute(`aria-hidden`,!0),n.style.backgroundColor=this.#n,e.append(n),e}renderMainDropdown(){let e=this.#r=this.#f();return e.setAttribute(`aria-orientation`,`horizontal`),e.setAttribute(`aria-labelledby`,`highlightColorPickerLabel`),e}#f(){let t=document.createElement(`div`),n=this.#l._signal;t.addEventListener(`contextmenu`,Oe,{signal:n}),t.className=`dropdown`,t.role=`listbox`,t.setAttribute(`aria-multiselectable`,!1),t.setAttribute(`aria-orientation`,`vertical`),t.setAttribute(`data-l10n-id`,`pdfjs-editor-colorpicker-dropdown`);for(let[r,i]of this.#l.highlightColors){let a=document.createElement(`button`);a.tabIndex=`0`,a.role=`option`,a.setAttribute(`data-color`,i),a.title=r,a.setAttribute(`data-l10n-id`,e.#d[r]);let o=document.createElement(`span`);a.append(o),o.className=`swatch`,o.style.backgroundColor=i,a.setAttribute(`aria-selected`,i===this.#n),a.addEventListener(`click`,this.#p.bind(this,i),{signal:n}),t.append(a)}return t.addEventListener(`keydown`,this.#m.bind(this),{signal:n}),t}#p(e,t){t.stopPropagation(),this.#s.dispatch(`switchannotationeditorparams`,{source:this,type:this.#u,value:e})}_colorSelectFromKeyboard(e){if(e.target===this.#e){this.#h(e);return}let t=e.target.getAttribute(`data-color`);t&&this.#p(t,e)}_moveToNext(e){this.#_?e.target===this.#e?this.#r.firstChild?.focus():e.target.nextSibling?.focus():this.#h(e)}_moveToPrevious(e){e.target===this.#r?.firstChild||e.target===this.#e?this.#_&&this._hideDropdownFromKeyboard():(this.#_||this.#h(e),e.target.previousSibling?.focus())}_moveToBeginning(e){this.#_?this.#r.firstChild?.focus():this.#h(e)}_moveToEnd(e){this.#_?this.#r.lastChild?.focus():this.#h(e)}#m(t){e._keyboardManager.exec(this,t)}#h(e){if(this.#_){this.hideDropdown();return}if(this.#i=e.detail===0,this.#c||(this.#c=new AbortController,window.addEventListener(`pointerdown`,this.#g.bind(this),{signal:this.#l.combinedSignal(this.#c)})),this.#r){this.#r.classList.remove(`hidden`);return}let t=this.#r=this.#f();this.#e.append(t)}#g(e){this.#r?.contains(e.target)||this.hideDropdown()}hideDropdown(){this.#r?.classList.add(`hidden`),this.#c?.abort(),this.#c=null}get#_(){return this.#r&&!this.#r.classList.contains(`hidden`)}_hideDropdownFromKeyboard(){this.#a||(this.#_?(this.hideDropdown(),this.#e.focus({preventScroll:!0,focusVisible:this.#i})):this.#o?.unselect())}updateColor(e){if(this.#t&&(this.#t.style.backgroundColor=e),!this.#r)return;let t=this.#l.highlightColors.values();for(let n of this.#r.children)n.setAttribute(`aria-selected`,t.next().value===e)}destroy(){this.#e?.remove(),this.#e=null,this.#t=null,this.#r?.remove(),this.#r=null}},Nc=class e extends ao{#e=null;#t=0;#n;#r=null;#i=null;#a=null;#o=null;#s=0;#c=null;#l=null;#u=null;#d=!1;#f=null;#p;#m=null;#h=``;#g;#_=``;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type=`highlight`;static _editorType=J.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId=``;static get _keyboardManager(){let t=e.prototype;return W(this,`_keyboardManager`,new eo([[[`ArrowLeft`,`mac+ArrowLeft`],t._moveCaret,{args:[0]}],[[`ArrowRight`,`mac+ArrowRight`],t._moveCaret,{args:[1]}],[[`ArrowUp`,`mac+ArrowUp`],t._moveCaret,{args:[2]}],[[`ArrowDown`,`mac+ArrowDown`],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:`highlightEditor`}),this.color=t.color||e._defaultColor,this.#g=t.thickness||e._defaultThickness,this.#p=t.opacity||e._defaultOpacity,this.#n=t.boxes||null,this.#_=t.methodOfCreation||``,this.#h=t.text||``,this._isDraggable=!1,t.highlightId>-1?(this.#d=!0,this.#y(t),this.#w()):this.#n&&(this.#e=t.anchorNode,this.#t=t.anchorOffset,this.#o=t.focusNode,this.#s=t.focusOffset,this.#v(),this.#w(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:`added`,type:this.#d?`free_highlight`:`highlight`,color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#g,methodOfCreation:this.#_}}get telemetryFinalData(){return{type:`highlight`,color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get(`color`).size}}#v(){let e=new Oc(this.#n,.001);this.#l=e.getOutlines(),[this.x,this.y,this.width,this.height]=this.#l.box;let t=new Oc(this.#n,.0025,.001,this._uiManager.direction===`ltr`);this.#a=t.getOutlines();let{lastPoint:n}=this.#a;this.#f=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#y({highlightOutlines:t,highlightId:n,clipPathId:r}){if(this.#l=t,this.#a=t.getNewOutline(this.#g/2+1.5,.0025),n>=0)this.#u=n,this.#r=r,this.parent.drawLayer.finalizeDraw(n,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#m=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},!0);else if(this.parent){let n=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:e.#T(this.#l.box,(n-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#m,{bbox:e.#T(this.#a.box,n),path:{d:this.#a.toSVGPath()}})}let[i,a,o,s]=t.box;switch(this.rotation){case 0:this.x=i,this.y=a,this.width=o,this.height=s;break;case 90:{let[e,t]=this.parentDimensions;this.x=a,this.y=1-i,this.width=o*t/e,this.height=s*e/t;break}case 180:this.x=1-i,this.y=1-a,this.width=o,this.height=s;break;case 270:{let[e,t]=this.parentDimensions;this.x=1-a,this.y=i,this.width=o*t/e,this.height=s*e/t;break}}let{lastPoint:c}=this.#a;this.#f=[(c[0]-i)/o,(c[1]-a)/s]}static initialize(t,n){ao.initialize(t,n),e._defaultColor||=n.highlightColors?.values().next().value||`#fff066`}static updateDefaultParams(t,n){switch(t){case ya.HIGHLIGHT_DEFAULT_COLOR:e._defaultColor=n;break;case ya.HIGHLIGHT_THICKNESS:e._defaultThickness=n}}translateInPage(e,t){}get toolbarPosition(){return this.#f}updateParams(e,t){switch(e){case ya.HIGHLIGHT_COLOR:this.#b(t);break;case ya.HIGHLIGHT_THICKNESS:this.#x(t)}}static get defaultPropertiesToUpdate(){return[[ya.HIGHLIGHT_DEFAULT_COLOR,e._defaultColor],[ya.HIGHLIGHT_THICKNESS,e._defaultThickness]]}get propertiesToUpdate(){return[[ya.HIGHLIGHT_COLOR,this.color||e._defaultColor],[ya.HIGHLIGHT_THICKNESS,this.#g||e._defaultThickness],[ya.HIGHLIGHT_FREE,this.#d]]}#b(t){let n=(e,t)=>{this.color=e,this.#p=t,this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:e,"fill-opacity":t}}),this.#i?.updateColor(e)},r=this.color,i=this.#p;this.addCommands({cmd:n.bind(this,t,e._defaultOpacity),undo:n.bind(this,r,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ya.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:`color_changed`,color:this._uiManager.highlightColorNames.get(t)},!0)}#x(e){let t=this.#g,n=e=>{this.#g=e,this.#S(e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:ya.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:`thickness_changed`,thickness:e},!0)}async addEditToolbar(){let e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(this.#i=new Mc({editor:this}),e.addColorPicker(this.#i)),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle(`disabled`,!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle(`disabled`,!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#O())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#O())}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){this.#C(),this._reportTelemetry({action:`deleted`}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#w(),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?this.#C():e&&(this.#w(e),t=!this.parent&&this.div?.classList.contains(`selectedEditor`)),super.setParent(e),this.show(this._isVisible),t&&this.select()}#S(e){if(!this.#d)return;this.#y({highlightOutlines:this.#l.getNewOutline(e/2)}),this.fixAndSetPosition();let[t,n]=this.parentDimensions;this.setDims(this.width*t,this.height*n)}#C(){this.#u!==null&&this.parent&&(this.parent.drawLayer.remove(this.#u),this.#u=null,this.parent.drawLayer.remove(this.#m),this.#m=null)}#w(e=this.parent){this.#u===null&&({id:this.#u,clipPathId:this.#r}=e.drawLayer.draw({bbox:this.#l.box,root:{viewBox:`0 0 1 1`,fill:this.color,"fill-opacity":this.#p},rootClass:{highlight:!0,free:this.#d},path:{d:this.#l.toSVGPath()}},!1,!0),this.#m=e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},this.#d),this.#c&&(this.#c.style.clipPath=this.#r))}static#T([e,t,n,r],i){switch(i){case 90:return[1-t-r,e,r,n];case 180:return[1-e-n,1-t-r,n,r];case 270:return[t,1-e-n,r,n]}return[e,t,n,r]}rotate(t){let{drawLayer:n}=this.parent,r;this.#d?(t=(t-this.rotation+360)%360,r=e.#T(this.#l.box,t)):r=e.#T([this.x,this.y,this.width,this.height],t),n.updateProperties(this.#u,{bbox:r,root:{"data-main-rotation":t}}),n.updateProperties(this.#m,{bbox:e.#T(this.#a.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let e=super.render();this.#h&&(e.setAttribute(`aria-label`,this.#h),e.setAttribute(`role`,`mark`)),this.#d?e.classList.add(`free`):this.div.addEventListener(`keydown`,this.#E.bind(this),{signal:this._uiManager._signal});let t=this.#c=document.createElement(`div`);e.append(t),t.setAttribute(`aria-hidden`,`true`),t.className=`internal`,t.style.clipPath=this.#r;let[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),Ie(this,this.#c,[`pointerover`,`pointerleave`]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!1}})}#E(t){e._keyboardManager.exec(this,t)}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:this.#D(!0);break;case 1:case 3:this.#D(!1)}}#D(e){if(!this.#e)return;let t=window.getSelection();e?t.setPosition(this.#e,this.#t):t.setPosition(this.#o,this.#s)}select(){super.select(),this.#m&&this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#m&&(this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{selected:!1}}),this.#d||this.#D(!1))}get _mustFixPosition(){return!this.#d}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(this.#m,{rootClass:{hidden:!e}}))}#O(){return this.#d?this.rotation:0}#k(){if(this.#d)return null;let[e,t]=this.pageDimensions,[n,r]=this.pageTranslation,i=this.#n,a=new Float32Array(i.length*8),o=0;for(let{x:s,y:c,width:l,height:u}of i){let i=s*e+n,d=(1-c)*t+r;a[o]=a[o+4]=i,a[o+1]=a[o+3]=d,a[o+2]=a[o+6]=i+l*e,a[o+5]=a[o+7]=d-u*t,o+=8}return a}#A(e){return this.#l.serialize(e,this.#O())}static startHighlighting(e,t,{target:n,x:r,y:i}){let{x:a,y:o,width:s,height:c}=n.getBoundingClientRect(),l=new AbortController,u=e.combinedSignal(l),d=t=>{l.abort(),this.#M(e,t)};window.addEventListener(`blur`,d,{signal:u}),window.addEventListener(`pointerup`,d,{signal:u}),window.addEventListener(`pointerdown`,ke,{capture:!0,passive:!1,signal:u}),window.addEventListener(`contextmenu`,Oe,{signal:u}),n.addEventListener(`pointermove`,this.#j.bind(this,e),{signal:u}),this._freeHighlight=new Ac({x:r,y:i},[a,o,s,c],e.scale,this._defaultThickness/2,t,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#j(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#M(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:`main_toolbar`}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=``}static async deserialize(e,t,n){let r=null;if(e instanceof _c){let{data:{quadPoints:t,rect:n,rotation:i,id:a,color:o,opacity:s,popupRef:c},parent:{page:{pageNumber:l}}}=e;r=e={annotationType:J.HIGHLIGHT,color:Array.from(o),opacity:s,quadPoints:t,boxes:null,pageIndex:l-1,rect:n.slice(0),rotation:i,id:a,deleted:!1,popupRef:c}}else if(e instanceof gc){let{data:{inkLists:t,rect:n,rotation:i,id:a,color:o,borderStyle:{rawWidth:s},popupRef:c},parent:{page:{pageNumber:l}}}=e;r=e={annotationType:J.HIGHLIGHT,color:Array.from(o),thickness:s,inkLists:t,boxes:null,pageIndex:l-1,rect:n.slice(0),rotation:i,id:a,deleted:!1,popupRef:c}}let{color:i,quadPoints:a,inkLists:o,opacity:s}=e,c=await super.deserialize(e,t,n);c.color=Y.makeHexColor(...i),c.#p=s||1,o&&(c.#g=e.thickness),c.annotationElementId=e.id||null,c._initialData=r;let[l,u]=c.pageDimensions,[d,f]=c.pageTranslation;if(a){let e=c.#n=[];for(let t=0;t<a.length;t+=8)e.push({x:(a[t]-d)/l,y:1-(a[t+1]-f)/u,width:(a[t+2]-a[t])/l,height:(a[t+1]-a[t+5])/u});c.#v(),c.#w(),c.rotate(c.rotation)}else if(o){c.#d=!0;let e=o[0],n={x:e[0]-d,y:u-(e[1]-f)},r=new Ac(n,[0,0,l,u],1,c.#g/2,!0,.001);for(let t=0,i=e.length;t<i;t+=2)n.x=e[t]-d,n.y=u-(e[t+1]-f),r.add(n);let{id:i,clipPathId:a}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:c.color,"fill-opacity":c._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:r.toSVGPath()}},!0,!0);c.#y({highlightOutlines:r.getOutlines(),highlightId:i,clipPathId:a}),c.#w()}return c}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();let t=this.getRect(0,0),n=ao._colorManager.convert(this.color),r={annotationType:J.HIGHLIGHT,color:n,opacity:this.#p,thickness:this.#g,quadPoints:this.#k(),outlines:this.#A(t),pageIndex:this.pageIndex,rect:t,rotation:this.#O(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#N(r)?null:(r.id=this.annotationElementId,r)}#N(e){let{color:t}=this._initialData;return e.color.some((e,n)=>e!==t[n])}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},Pc=class{#e=Object.create(null);updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(let[t,n]of Object.entries(e))this.updateProperty(t,n)}updateSVGProperty(e,t){this.#e[e]=t}toSVGProperties(){let e=this.#e;return this.#e=Object.create(null),{root:e}}reset(){this.#e=Object.create(null)}updateAll(e=this){this.updateProperties(e)}clone(){U(`Not implemented`)}},Fc=class e extends ao{#e=null;#t;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#n=null;static#r=null;static#i=null;static#a=NaN;static#o=null;static#s=null;static#c=NaN;static _INNER_MARGIN=3;constructor(e){super(e),this.#t=e.mustBeCommitted||!1,e.drawOutlines&&(this.#l(e),this.#f())}#l({drawOutlines:e,drawId:t,drawingOptions:n}){this.#e=e,this._drawingOptions||=n,t>=0?(this._drawId=t,this.parent.drawLayer.finalizeDraw(t,e.defaultProperties)):this._drawId=this.#u(e,this.parent),this.#h(e.box)}#u(t,n){let{id:r}=n.drawLayer.draw(e._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return r}static _mergeSVGProperties(e,t){let n=new Set(Object.keys(e));for(let[r,i]of Object.entries(t))n.has(r)?Object.assign(e[r],i):e[r]=i;return e}static getDefaultDrawingOptions(e){U(`Not implemented`)}static get typesMap(){U(`Not implemented`)}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,n){let r=this.typesMap.get(t);r&&this._defaultDrawingOptions.updateProperty(r,n),this._currentParent&&(e.#n.updateProperty(r,n),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,t){let n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,t)}static get defaultPropertiesToUpdate(){let e=[],t=this._defaultDrawingOptions;for(let[n,r]of this.typesMap)e.push([n,t[r]]);return e}get propertiesToUpdate(){let e=[],{_drawingOptions:t}=this;for(let[n,r]of this.constructor.typesMap)e.push([n,t[r]]);return e}_updateProperty(e,t,n){let r=this._drawingOptions,i=r[t],a=e=>{r.updateProperty(t,e);let n=this.#e.updateProperty(t,e);n&&this.#h(n),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties())};this.addCommands({cmd:a.bind(this,n),undo:a.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties(this.#e.getPathResizingSVGProperties(this.#m()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties(this.#e.getPathResizedSVGProperties(this.#m()),{bbox:this.#g()}))}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#g(e,t)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties(this.#e.getPathTranslatedSVGProperties(this.#m(),this.parentDimensions),{bbox:this.#g()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),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(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#t&&(this.#t=!1,this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){this.#d(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#f(),this.#h(this.#e.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),this.#d()):e&&(this._uiManager.addShouldRescale(this),this.#f(e),t=!this.parent&&this.div?.classList.contains(`selectedEditor`)),super.setParent(e),t&&this.select()}#d(){this._drawId!==null&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#f(e=this.parent){(this._drawId===null||this.parent!==e)&&(this._drawId===null?(this._drawingOptions.updateAll(),this._drawId=this.#u(this.#e,e)):this.parent.drawLayer.updateParent(this._drawId,e.drawLayer))}#p([e,t,n,r]){let{parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[t,1-e,a/i*n,i/a*r];case 180:return[1-e,1-t,n,r];case 270:return[1-t,e,a/i*n,i/a*r];default:return[e,t,n,r]}}#m(){let{x:e,y:t,width:n,height:r,parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[1-t,e,i/a*n,a/i*r];case 180:return[1-e,1-t,n,r];case 270:return[t,1-e,i/a*n,a/i*r];default:return[e,t,n,r]}}#h(e){if([this.x,this.y,this.width,this.height]=this.#p(e),this.div){this.fixAndSetPosition();let[e,t]=this.parentDimensions;this.setDims(this.width*e,this.height*t)}this._onResized()}#g(){let{x:e,y:t,width:n,height:r,rotation:i,parentRotation:a,parentDimensions:[o,s]}=this;switch((i*4+a)/90){case 1:return[1-t-r,e,r,n];case 2:return[1-e-n,1-t-r,n,r];case 3:return[t,1-e-n,r,n];case 4:return[e,t-o/s*n,s/o*r,o/s*n];case 5:return[1-t,e,o/s*n,s/o*r];case 6:return[1-e-s/o*r,1-t,s/o*r,o/s*n];case 7:return[t-o/s*n,1-e-s/o*r,o/s*n,s/o*r];case 8:return[e-n,t-r,n,r];case 9:return[1-t,e-n,r,n];case 10:return[1-e,1-t,n,r];case 11:return[t-r,1-e,r,n];case 12:return[e-s/o*r,t,s/o*r,o/s*n];case 13:return[1-t-o/s*n,e-s/o*r,o/s*n,s/o*r];case 14:return[1-e,1-t-o/s*n,s/o*r,o/s*n];case 15:return[t,1-e,o/s*n,s/o*r];default:return[e,t,n,r]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,e._mergeSVGProperties({bbox:this.#g()},this.#e.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#h(this.#e.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e=super.render();e.classList.add(`draw`);let t=document.createElement(`div`);e.append(t),t.setAttribute(`aria-hidden`,`true`),t.className=`internal`;let[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),this._uiManager.addShouldRescale(this),this.disableEditing(),e}static createDrawerInstance(e,t,n,r,i){U(`Not implemented`)}static startDrawing(t,n,r,i){let{target:a,offsetX:o,offsetY:s,pointerId:c,pointerType:l}=i;if(e.#o&&e.#o!==l)return;let{viewport:{rotation:u}}=t,{width:d,height:f}=a.getBoundingClientRect(),p=e.#r=new AbortController,m=t.combinedSignal(p);e.#a||=c,e.#o??=l,window.addEventListener(`pointerup`,t=>{e.#a===t.pointerId?this._endDraw(t):e.#s?.delete(t.pointerId)},{signal:m}),window.addEventListener(`pointercancel`,t=>{e.#a===t.pointerId?this._currentParent.endDrawingSession():e.#s?.delete(t.pointerId)},{signal:m}),window.addEventListener(`pointerdown`,t=>{e.#o===t.pointerType&&((e.#s||=/* @__PURE__ */ new Set).add(t.pointerId),e.#n.isCancellable()&&(e.#n.removeLastElement(),e.#n.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:m}),window.addEventListener(`contextmenu`,Oe,{signal:m}),a.addEventListener(`pointermove`,this._drawMove.bind(this),{signal:m}),a.addEventListener(`touchmove`,t=>{t.timeStamp===e.#c&&ke(t)},{signal:m}),t.toggleDrawing(),n._editorUndoBar?.hide(),e.#n?t.drawLayer.updateProperties(this._currentDrawId,e.#n.startNew(o,s,d,f,u)):(n.updateUIForDefaultProperties(this),e.#n=this.createDrawerInstance(o,s,d,f,u),e.#i=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(e.#i.toSVGProperties(),e.#n.defaultSVGProperties),!0,!1))}static _drawMove(t){if(e.#c=-1,!e.#n)return;let{offsetX:n,offsetY:r,pointerId:i}=t;e.#a===i&&(e.#s?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,e.#n.add(n,r)),e.#c=t.timeStamp,ke(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,e.#n=null,e.#i=null,e.#o=null,e.#c=NaN),e.#r&&(e.#r.abort(),e.#r=null,e.#a=NaN,e.#s=null)}static _endDraw(t){let n=this._currentParent;if(n){if(n.toggleDrawing(!0),this._cleanup(!1),t&&n.drawLayer.updateProperties(this._currentDrawId,e.#n.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let t=e.#n,r=this._currentDrawId,i=t.getLastElement();n.addCommands({cmd:()=>{n.drawLayer.updateProperties(r,t.setLastElement(i))},undo:()=>{n.drawLayer.updateProperties(r,t.removeLastElement())},mustExec:!1,type:ya.DRAW_STEP})}else this.endDrawing(!1)}}static endDrawing(t){let n=this._currentParent;if(!n)return null;if(n.toggleDrawing(!0),n.cleanUndoStack(ya.DRAW_STEP),!e.#n.isEmpty()){let{pageDimensions:[r,i],scale:a}=n,o=n.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:e.#n.getOutlines(r*a,i*a,a,this._INNER_MARGIN),drawingOptions:e.#i,mustBeCommitted:!t});return this._cleanup(!0),o}return n.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,t,n,r,i,a){U(`Not implemented`)}static async deserialize(e,t,n){let{rawDims:{pageWidth:r,pageHeight:i,pageX:a,pageY:o}}=t.viewport,s=this.deserializeDraw(a,o,r,i,this._INNER_MARGIN,e),c=await super.deserialize(e,t,n);return c.createDrawingOptions(e),c.#l({drawOutlines:s}),c.#f(),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){let[t,n]=this.pageTranslation,[r,i]=this.pageDimensions;return this.#e.serialize([t,n,r,i],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}},Ic=class{#e=/* @__PURE__ */ new Float64Array(6);#t;#n;#r;#i;#a;#o=``;#s=0;#c=new Lc;#l;#u;constructor(e,t,n,r,i,a){this.#l=n,this.#u=r,this.#r=i,this.#i=a,[e,t]=this.#d(e,t);let o=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#a=[e,t],this.#n=[{line:o,points:this.#a}],this.#e.set(o,0)}updateProperty(e,t){e===`stroke-width`&&(this.#i=t)}#d(e,t){return Z._normalizePoint(e,t,this.#l,this.#u,this.#r)}isEmpty(){return!this.#n||this.#n.length===0}isCancellable(){return this.#a.length<=10}add(e,t){[e,t]=this.#d(e,t);let[n,r,i,a]=this.#e.subarray(2,6),o=e-i,s=t-a;return Math.hypot(this.#l*o,this.#u*s)<=2?null:(this.#a.push(e,t),isNaN(n)?(this.#e.set([i,a,e,t],2),this.#t.push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}}):(isNaN(this.#e[0])&&this.#t.splice(6,6),this.#e.set([n,r,i,a,e,t],0),this.#t.push(...Z.createBezierPoints(n,r,i,a,e,t)),{path:{d:this.toSVGPath()}}))}end(e,t){return this.add(e,t)||(this.#a.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,n,r,i){this.#l=n,this.#u=r,this.#r=i,[e,t]=this.#d(e,t);let a=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#a=[e,t];let o=this.#n.at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),this.#n.push({line:a,points:this.#a}),this.#e.set(a,0),this.#s=0,this.toSVGPath(),null}getLastElement(){return this.#n.at(-1)}setLastElement(e){return this.#n?(this.#n.push(e),this.#t=e.line,this.#a=e.points,this.#s=0,{path:{d:this.toSVGPath()}}):this.#c.setLastElement(e)}removeLastElement(){if(!this.#n)return this.#c.removeLastElement();this.#n.pop(),this.#o=``;for(let e=0,t=this.#n.length;e<t;e++){let{line:t,points:n}=this.#n[e];this.#t=t,this.#a=n,this.#s=0,this.toSVGPath()}return{path:{d:this.#o}}}toSVGPath(){let e=Z.svgRound(this.#t[4]),t=Z.svgRound(this.#t[5]);if(this.#a.length===2)return this.#o=`${this.#o} M ${e} ${t} Z`,this.#o;if(this.#a.length<=6){let n=this.#o.lastIndexOf(`M`);this.#o=`${this.#o.slice(0,n)} M ${e} ${t}`,this.#s=6}if(this.#a.length===4){let e=Z.svgRound(this.#t[10]),t=Z.svgRound(this.#t[11]);return this.#o=`${this.#o} L ${e} ${t}`,this.#s=12,this.#o}let n=[];this.#s===0&&(n.push(`M ${e} ${t}`),this.#s=6);for(let e=this.#s,t=this.#t.length;e<t;e+=6){let[t,r,i,a,o,s]=this.#t.slice(e,e+6).map(Z.svgRound);n.push(`C${t} ${r} ${i} ${a} ${o} ${s}`)}return this.#o+=n.join(` `),this.#s=this.#t.length,this.#o}getOutlines(e,t,n,r){let i=this.#n.at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),this.#c.build(this.#n,e,t,n,this.#r,this.#i,r),this.#e=null,this.#t=null,this.#n=null,this.#o=null,this.#c}get defaultSVGProperties(){return{root:{viewBox:`0 0 10000 10000`},rootClass:{draw:!0},bbox:[0,0,1,1]}}},Lc=class e extends Z{#e;#t=0;#n;#r;#i;#a;#o;#s;#c;build(e,t,n,r,i,a,o){this.#i=t,this.#a=n,this.#o=r,this.#s=i,this.#c=a,this.#n=o??0,this.#r=e,this.#d()}setLastElement(e){return this.#r.push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#r.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let e=[];for(let{line:t}of this.#r)if(e.push(`M${Z.svgRound(t[4])} ${Z.svgRound(t[5])}`),t.length===6)e.push(`Z`);else if(t.length===12)e.push(`L${Z.svgRound(t[10])} ${Z.svgRound(t[11])}`);else for(let n=6,r=t.length;n<r;n+=6){let[r,i,a,o,s,c]=t.subarray(n,n+6).map(Z.svgRound);e.push(`C${r} ${i} ${a} ${o} ${s} ${c}`)}return e.join(``)}serialize([e,t,n,r],i){let a=[],o=[],[s,c,l,u]=this.#u(),d,f,p,m,h,g,_,v,y;switch(this.#s){case 0:y=Z._rescale,d=e,f=t+r,p=n,m=-r,h=e+s*n,g=t+(1-c-u)*r,_=e+(s+l)*n,v=t+(1-c)*r;break;case 90:y=Z._rescaleAndSwap,d=e,f=t,p=n,m=r,h=e+c*n,g=t+s*r,_=e+(c+u)*n,v=t+(s+l)*r;break;case 180:y=Z._rescale,d=e+n,f=t,p=-n,m=r,h=e+(1-s-l)*n,g=t+c*r,_=e+(1-s)*n,v=t+(c+u)*r;break;case 270:y=Z._rescaleAndSwap,d=e+n,f=t+r,p=-n,m=-r,h=e+(1-c-u)*n,g=t+(1-s-l)*r,_=e+(1-c)*n,v=t+(1-s)*r}for(let{line:e,points:t}of this.#r)a.push(y(e,d,f,p,m,i?Array(e.length):null)),o.push(y(t,d,f,p,m,i?Array(t.length):null));return{lines:a,points:o,rect:[h,g,_,v]}}static deserialize(t,n,r,i,a,{paths:{lines:o,points:s},rotation:c,thickness:l}){let u=[],d,f,p,m,h;switch(c){case 0:h=Z._rescale,d=-t/r,f=n/i+1,p=1/r,m=-1/i;break;case 90:h=Z._rescaleAndSwap,d=-n/i,f=-t/r,p=1/i,m=1/r;break;case 180:h=Z._rescale,d=t/r+1,f=-n/i,p=-1/r,m=1/i;break;case 270:h=Z._rescaleAndSwap,d=n/i+1,f=t/r+1,p=-1/i,m=-1/r}if(!o){o=[];for(let e of s){let t=e.length;if(t===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(t===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}let n=new Float32Array(3*(t-2));o.push(n);let[r,i,a,s]=e.subarray(0,4);n.set([NaN,NaN,NaN,NaN,r,i],0);for(let o=4;o<t;o+=2){let t=e[o],c=e[o+1];n.set(Z.createBezierPoints(r,i,a,s,t,c),(o-2)*3),[r,i,a,s]=[a,s,t,c]}}}for(let e=0,t=o.length;e<t;e++)u.push({line:h(o[e].map(e=>e??NaN),d,f,p,m),points:h(s[e].map(e=>e??NaN),d,f,p,m)});let g=new e;return g.build(u,r,i,1,c,l,a),g}#l(e=this.#c){let t=this.#n+e/2*this.#o;return this.#s%180==0?[t/this.#i,t/this.#a]:[t/this.#a,t/this.#i]}#u(){let[e,t,n,r]=this.#e,[i,a]=this.#l(0);return[e+i,t+a,n-2*i,r-2*a]}#d(){let e=this.#e=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:t}of this.#r){if(t.length<=12){for(let n=4,r=t.length;n<r;n+=6){let[r,i]=t.subarray(n,n+2);e[0]=Math.min(e[0],r),e[1]=Math.min(e[1],i),e[2]=Math.max(e[2],r),e[3]=Math.max(e[3],i)}continue}let n=t[4],r=t[5];for(let i=6,a=t.length;i<a;i+=6){let[a,o,s,c,l,u]=t.subarray(i,i+6);Y.bezierBoundingBox(n,r,a,o,s,c,l,u,e),n=l,r=u}}let[t,n]=this.#l();e[0]=Math.min(1,Math.max(0,e[0]-t)),e[1]=Math.min(1,Math.max(0,e[1]-n)),e[2]=Math.min(1,Math.max(0,e[2]+t)),e[3]=Math.min(1,Math.max(0,e[3]+n)),e[2]-=e[0],e[3]-=e[1]}get box(){return this.#e}updateProperty(e,t){return e===`stroke-width`?this.#f(t):null}#f(e){let[t,n]=this.#l();this.#c=e;let[r,i]=this.#l(),[a,o]=[r-t,i-n],s=this.#e;return s[0]-=a,s[1]-=o,s[2]+=2*a,s[3]+=2*o,s}updateParentDimensions([e,t],n){let[r,i]=this.#l();this.#i=e,this.#a=t,this.#o=n;let[a,o]=this.#l(),s=a-r,c=o-i,l=this.#e;return l[0]-=s,l[1]-=c,l[2]+=2*s,l[3]+=2*c,l}updateRotation(e){return this.#t=e,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#e.map(Z.svgRound).join(` `)}get defaultProperties(){let[e,t]=this.#e;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`}}}get rotationTransform(){let[,,e,t]=this.#e,n=0,r=0,i=0,a=0,o=0,s=0;switch(this.#t){case 90:r=t/e,i=-e/t,o=e;break;case 180:n=-1,a=-1,o=e,s=t;break;case 270:r=-t/e,i=e/t,s=t;break;default:return``}return`matrix(${n} ${r} ${i} ${a} ${Z.svgRound(o)} ${Z.svgRound(s)})`}getPathResizingSVGProperties([e,t,n,r]){let[i,a]=this.#l(),[o,s,c,l]=this.#e;if(Math.abs(c-i)<=Z.PRECISION||Math.abs(l-a)<=Z.PRECISION){let i=e+n/2-(o+c/2),a=t+r/2-(s+l/2);return{path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:`${this.rotationTransform} translate(${i} ${a})`}}}let u=(n-2*i)/(c-2*i),d=(r-2*a)/(l-2*a),f=c/n,p=l/r;return{path:{"transform-origin":`${Z.svgRound(o)} ${Z.svgRound(s)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${Z.svgRound(i)} ${Z.svgRound(a)}) scale(${u} ${d}) translate(${Z.svgRound(-i)} ${Z.svgRound(-a)})`}}}getPathResizedSVGProperties([e,t,n,r]){let[i,a]=this.#l(),o=this.#e,[s,c,l,u]=o;if(o[0]=e,o[1]=t,o[2]=n,o[3]=r,Math.abs(l-i)<=Z.PRECISION||Math.abs(u-a)<=Z.PRECISION){let i=e+n/2-(s+l/2),a=t+r/2-(c+u/2);for(let{line:e,points:t}of this.#r)Z._translate(e,i,a,e),Z._translate(t,i,a,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let d=(n-2*i)/(l-2*i),f=(r-2*a)/(u-2*a),p=-d*(s+i)+e+i,m=-f*(c+a)+t+a;if(d!==1||f!==1||p!==0||m!==0)for(let{line:e,points:t}of this.#r)Z._rescale(e,p,m,d,f,e),Z._rescale(t,p,m,d,f,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],n){let[r,i]=n,a=this.#e,o=e-a[0],s=t-a[1];if(this.#i===r&&this.#a===i)for(let{line:e,points:t}of this.#r)Z._translate(e,o,s,e),Z._translate(t,o,s,t);else{let e=this.#i/r,t=this.#a/i;this.#i=r,this.#a=i;for(let{line:n,points:r}of this.#r)Z._rescale(n,o,s,e,t,n),Z._rescale(r,o,s,e,t,r);a[2]*=e,a[3]*=t}return a[0]=e,a[1]=t,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`}}}get defaultSVGProperties(){let e=this.#e;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Z.svgRound(e[0])} ${Z.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}},Rc=class e extends Pc{#e;constructor(e){super(),this.#e=e,super.updateProperties({fill:`none`,stroke:ao._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-miterlimit":10})}updateSVGProperty(e,t){e===`stroke-width`&&(t??=this[`stroke-width`],t*=this.#e.realScale),super.updateSVGProperty(e,t)}clone(){let t=new e(this.#e);return t.updateAll(this),t}},zc=class e extends Fc{static _type=`ink`;static _editorType=J.INK;static _defaultDrawingOptions=null;constructor(e){super({...e,name:`inkEditor`}),this._willKeepAspectRatio=!0}static initialize(e,t){ao.initialize(e,t),this._defaultDrawingOptions=new Rc(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!0}static get typesMap(){return W(this,`typesMap`,/* @__PURE__ */ new Map([[ya.INK_THICKNESS,`stroke-width`],[ya.INK_COLOR,`stroke`],[ya.INK_OPACITY,`stroke-opacity`]]))}static createDrawerInstance(e,t,n,r,i){return new Ic(e,t,n,r,i,this._defaultDrawingOptions[`stroke-width`])}static deserializeDraw(e,t,n,r,i,a){return Lc.deserialize(e,t,n,r,i,a)}static async deserialize(e,t,n){let r=null;if(e instanceof gc){let{data:{inkLists:t,rect:n,rotation:i,id:a,color:o,opacity:s,borderStyle:{rawWidth:c},popupRef:l},parent:{page:{pageNumber:u}}}=e;r=e={annotationType:J.INK,color:Array.from(o),thickness:c,opacity:s,paths:{points:t},boxes:null,pageIndex:u-1,rect:n.slice(0),rotation:i,id:a,deleted:!1,popupRef:l}}let i=await super.deserialize(e,t,n);return i.annotationElementId=e.id||null,i._initialData=r,i}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:e,_drawingOptions:t,parent:n}=this;t.updateSVGProperty(`stroke-width`),n.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){let e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty(`stroke-width`),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:n,opacity:r}){this._drawingOptions=e.getDefaultDrawingOptions({stroke:Y.makeHexColor(...t),"stroke-width":n,"stroke-opacity":r})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:t,points:n,rect:r}=this.serializeDraw(e),{_drawingOptions:{stroke:i,"stroke-opacity":a,"stroke-width":o}}=this,s={annotationType:J.INK,color:ao._colorManager.convert(i),opacity:a,thickness:o,paths:{lines:t,points:n},pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?s:this.annotationElementId&&!this.#e(s)?null:(s.id=this.annotationElementId,s)}#e(e){let{color:t,thickness:n,opacity:r,pageIndex:i}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||e.color.some((e,n)=>e!==t[n])||e.thickness!==n||e.opacity!==r||e.pageIndex!==i}renderAnnotationElement(e){let{points:t,rect:n}=this.serializeDraw(!1);return e.updateEdited({rect:n,thickness:this._drawingOptions[`stroke-width`],points:t}),null}},Bc=class e extends ao{#e=null;#t=null;#n=null;#r=null;#i=null;#a=``;#o=null;#s=null;#c=!1;#l=!1;static _type=`stamp`;static _editorType=J.STAMP;constructor(e){super({...e,name:`stampEditor`}),this.#r=e.bitmapUrl,this.#i=e.bitmapFile}static initialize(e,t){ao.initialize(e,t)}static get supportedTypes(){return W(this,`supportedTypes`,[`apng`,`avif`,`bmp`,`gif`,`jpeg`,`png`,`svg+xml`,`webp`,`x-icon`].map(e=>`image/${e}`))}static get supportedTypesStr(){return W(this,`supportedTypesStr`,this.supportedTypes.join(`,`))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,t){t.pasteEditor(J.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:`stamp`,hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){let t=e.get(`hasAltText`);return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}#u(e,t=!1){e?(this.#e=e.bitmap,t||(this.#t=e.id,this.#c=e.isSvg),e.file&&(this.#a=e.file.name),this.#p()):this.remove()}#d(){if(this.#n=null,this._uiManager.enableWaiting(!1),this.#o){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e)this._editToolbar.hide(),this._uiManager.editAltText(this,!0);else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e){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(e=null,t=!0){if(this.hasAltTextData())return null;let{mlManager:n}=this._uiManager;if(!n)throw Error(`No ML.`);if(!await n.isEnabledFor(`altText`))throw Error(`ML isn't enabled for alt text.`);let{data:r,width:i,height:a}=e||this.copyCanvas(null,null,!0).imageData,o=await n.guess({name:`altText`,request:{data:r,width:i,height:a,channels:r.length/(i*a)}});if(!o)throw Error(`No response from the AI service.`);if(o.error)throw Error(`Error from the AI service.`);if(o.cancel)return null;if(!o.output)throw Error(`No valid response from the AI service.`);let s=o.output;return await this.setGuessedAltText(s),t&&!this.hasAltTextData()&&(this.altTextData={alt:s,decorative:!1}),s}#f(){if(this.#t){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#t).then(e=>this.#u(e,!0)).finally(()=>this.#d());return}if(this.#r){let e=this.#r;this.#r=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromUrl(e).then(e=>this.#u(e)).finally(()=>this.#d());return}if(this.#i){let e=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#n=this._uiManager.imageManager.getFromFile(e).then(e=>this.#u(e)).finally(()=>this.#d());return}let t=document.createElement(`input`);t.type=`file`,t.accept=e.supportedTypesStr;let n=this._uiManager._signal;this.#n=new Promise(e=>{t.addEventListener(`change`,async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:`pdfjs.image.image_selected`,data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#u(e)}e()},{signal:n}),t.addEventListener(`cancel`,()=>{this.remove(),e()},{signal:n})}).finally(()=>this.#d()),t.click()}remove(){this.#t&&(this.#e=null,this._uiManager.imageManager.deleteId(this.#t),this.#o?.remove(),this.#o=null,this.#s&&=(clearTimeout(this.#s),null)),super.remove()}rebuild(){this.parent?(super.rebuild(),this.div!==null&&(this.#t&&this.#o===null&&this.#f(),this.isAttachedToDOM||this.parent.add(this))):this.#t&&this.#f()}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(this.#n||this.#e||this.#r||this.#i||this.#t)}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this.width&&(e=this.x,t=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute(`role`,`figure`),this.addAltTextButton(),this.#e?this.#p():this.#f(),this.width&&!this.annotationElementId){let[n,r]=this.parentDimensions;this.setAt(e*n,t*r,this.width*n,this.height*r)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(this.#s!==null&&clearTimeout(this.#s),this.#s=setTimeout(()=>{this.#s=null,this.#h()},200))}#p(){let{div:e}=this,{width:t,height:n}=this.#e,[r,i]=this.pageDimensions,a=.75;if(this.width)t=this.width*r,n=this.height*i;else if(t>a*r||n>a*i){let e=Math.min(a*r/t,a*i/n);t*=e,n*=e}let[o,s]=this.parentDimensions;this.setDims(t*o/r,n*s/i),this._uiManager.enableWaiting(!1);let c=this.#o=document.createElement(`canvas`);c.setAttribute(`role`,`img`),this.addContainer(c),this.width=t/r,this.height=n/i,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),this.#h(),this.#l||=(this.parent.addUndoableEditor(this),!0),this._reportTelemetry({action:`inserted_image`}),this.#a&&c.setAttribute(`aria-label`,this.#a)}copyCanvas(e,t,n=!1){e||=224;let{width:r,height:i}=this.#e,a=new Ja,o=this.#e,s=r,c=i,l=null;if(t){if(r>t||i>t){let e=Math.min(t/r,t/i);s=Math.floor(r*e),c=Math.floor(i*e)}l=document.createElement(`canvas`);let e=l.width=Math.ceil(s*a.sx),n=l.height=Math.ceil(c*a.sy);this.#c||(o=this.#m(e,n));let u=l.getContext(`2d`);u.filter=this._uiManager.hcmFilter;let d=`white`,f=`#cfcfd8`;this._uiManager.hcmFilter===`none`?window.matchMedia?.(`(prefers-color-scheme: dark)`).matches&&(d=`#8f8f9d`,f=`#42414d`):f=`black`;let p=15*a.sx,m=15*a.sy,h=new OffscreenCanvas(p*2,m*2),g=h.getContext(`2d`);g.fillStyle=d,g.fillRect(0,0,p*2,m*2),g.fillStyle=f,g.fillRect(0,0,p,m),g.fillRect(p,m,p,m),u.fillStyle=u.createPattern(h,`repeat`),u.fillRect(0,0,e,n),u.drawImage(o,0,0,o.width,o.height,0,0,e,n)}let u=null;if(n){let t,n;if(a.symmetric&&o.width<e&&o.height<e)t=o.width,n=o.height;else if(o=this.#e,r>e||i>e){let a=Math.min(e/r,e/i);t=Math.floor(r*a),n=Math.floor(i*a),this.#c||(o=this.#m(t,n))}let s=new OffscreenCanvas(t,n).getContext(`2d`,{willReadFrequently:!0});s.drawImage(o,0,0,o.width,o.height,0,0,t,n),u={width:t,height:n,data:s.getImageData(0,0,t,n).data}}return{canvas:l,width:s,height:c,imageData:u}}#m(e,t){let{width:n,height:r}=this.#e,i=n,a=r,o=this.#e;for(;i>2*e||a>2*t;){let n=i,r=a;i>2*e&&(i=i>=16384?Math.floor(i/2)-1:Math.ceil(i/2)),a>2*t&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));let s=new OffscreenCanvas(i,a);s.getContext(`2d`).drawImage(o,0,0,n,r,0,0,i,a),o=s.transferToImageBitmap()}return o}#h(){let[e,t]=this.parentDimensions,{width:n,height:r}=this,i=new Ja,a=Math.ceil(n*e*i.sx),o=Math.ceil(r*t*i.sy),s=this.#o;if(!s||s.width===a&&s.height===o)return;s.width=a,s.height=o;let c=this.#c?this.#e:this.#m(a,o),l=s.getContext(`2d`);l.filter=this._uiManager.hcmFilter,l.drawImage(c,0,0,c.width,c.height,0,0,a,o)}getImageForAltText(){return this.#o}#g(e){if(e){if(this.#c){let e=this._uiManager.imageManager.getSvgUrl(this.#t);if(e)return e}let e=document.createElement(`canvas`);return{width:e.width,height:e.height}=this.#e,e.getContext(`2d`).drawImage(this.#e,0,0),e.toDataURL()}if(this.#c){let[e,t]=this.pageDimensions,n=Math.round(this.width*e*Ua.PDF_TO_CSS_UNITS),r=Math.round(this.height*t*Ua.PDF_TO_CSS_UNITS),i=new OffscreenCanvas(n,r);return i.getContext(`2d`).drawImage(this.#e,0,0,this.#e.width,this.#e.height,0,0,n,r),i.transferToImageBitmap()}return structuredClone(this.#e)}static async deserialize(e,t,n){let r=null;if(e instanceof xc){let{data:{rect:i,rotation:a,id:o,structParent:s,popupRef:c},container:l,parent:{page:{pageNumber:u}}}=e,d=l.querySelector(`canvas`),f=n.imageManager.getFromCanvas(l.id,d);d.remove();let p=(await t._structTree.getAriaAttributes(`${Va}${o}`))?.get(`aria-label`)||``;r=e={annotationType:J.STAMP,bitmapId:f.id,bitmap:f.bitmap,pageIndex:u-1,rect:i.slice(0),rotation:a,id:o,deleted:!1,accessibilityData:{decorative:!1,altText:p},isSvg:!1,structParent:s,popupRef:c}}let i=await super.deserialize(e,t,n),{rect:a,bitmap:o,bitmapUrl:s,bitmapId:c,isSvg:l,accessibilityData:u}=e;c&&n.imageManager.isValidId(c)?(i.#t=c,o&&(i.#e=o)):i.#r=s,i.#c=l;let[d,f]=i.pageDimensions;return i.width=(a[2]-a[0])/d,i.height=(a[3]-a[1])/f,i.annotationElementId=e.id||null,u&&(i.altTextData=u),i._initialData=r,i.#l=!!r,i}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let n={annotationType:J.STAMP,bitmapId:this.#t,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#c,structTreeParentId:this._structTreeParentId};if(e)return n.bitmapUrl=this.#g(!0),n.accessibilityData=this.serializeAltText(!0),n;let{decorative:r,altText:i}=this.serializeAltText(!1);if(!r&&i&&(n.accessibilityData={type:`Figure`,alt:i}),this.annotationElementId){let e=this.#_(n);if(e.isSame)return null;e.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1}if(n.id=this.annotationElementId,t===null)return n;t.stamps||=/* @__PURE__ */ new Map;let a=this.#c?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(!t.stamps.has(this.#t))t.stamps.set(this.#t,{area:a,serialized:n}),n.bitmap=this.#g(!1);else if(this.#c){let e=t.stamps.get(this.#t);a>e.area&&(e.area=a,e.serialized.bitmap.close(),e.serialized.bitmap=this.#g(!1))}return n}#_(e){let{pageIndex:t,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===t,i=(e.accessibilityData?.alt||``)===n;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&r&&i,isSameAltText:i}}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}},Vc=class e{#e;#t=!1;#n=null;#r=null;#i=null;#a=/* @__PURE__ */ new Map;#o=!1;#s=!1;#c=!1;#l=null;#u=null;#d=null;#f=null;#p;static _initialized=!1;static#m=new Map([Tc,zc,Bc,Nc].map(e=>[e._editorType,e]));constructor({uiManager:t,pageIndex:n,div:r,structTreeLayer:i,accessibilityManager:a,annotationLayer:o,drawLayer:s,textLayer:c,viewport:l,l10n:u}){let d=[...e.#m.values()];if(!e._initialized){e._initialized=!0;for(let e of d)e.initialize(u,t)}t.registerEditorTypes(d),this.#p=t,this.pageIndex=n,this.div=r,this.#e=a,this.#n=o,this.viewport=l,this.#d=c,this.drawLayer=s,this._structTree=i,this.#p.addLayer(this)}get isEmpty(){return this.#a.size===0}get isInvisible(){return this.isEmpty&&this.#p.getMode()===J.NONE}updateToolbar(e){this.#p.updateToolbar(e)}updateMode(t=this.#p.getMode()){switch(this.#y(),t){case J.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case J.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case J.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:n}=this.div;for(let r of e.#m.values())n.toggle(`${r._type}Editing`,t===r._editorType);this.div.hidden=!1}hasTextLayer(e){return e===this.#d?.div}setEditingState(e){this.#p.setEditingState(e)}addCommands(e){this.#p.addCommands(e)}cleanUndoStack(e){this.#p.cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle(`drawing`,!e)}togglePointerEvents(e=!1){this.div.classList.toggle(`disabled`,!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#n?.div.classList.toggle(`disabled`,!e)}async enable(){this.#c=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);let e=/* @__PURE__ */ new Set;for(let t of this.#a.values())t.enableEditing(),t.show(!0),t.annotationElementId&&(this.#p.removeChangedExistingAnnotation(t),e.add(t.annotationElementId));if(!this.#n){this.#c=!1;return}let t=this.#n.getEditableAnnotations();for(let n of t){if(n.hide(),this.#p.isDeletedAnnotationElement(n.data.id)||e.has(n.data.id))continue;let t=await this.deserialize(n);t&&(this.addOrRebuild(t),t.enableEditing())}this.#c=!1}disable(){this.#s=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let e of this.#a.values())e.disableEditing(),e.annotationElementId&&(e.serialize()===null?(n.set(e.annotationElementId,e),this.getEditableAnnotation(e.annotationElementId)?.show(),e.remove()):t.set(e.annotationElementId,e));if(this.#n){let e=this.#n.getEditableAnnotations();for(let r of e){let{id:e}=r.data;if(this.#p.isDeletedAnnotationElement(e))continue;let i=n.get(e);i?(i.resetAnnotationElement(r),i.show(!1),r.show()):(i=t.get(e),i&&(this.#p.addChangedExistingAnnotation(i),i.renderAnnotationElement(r)&&i.show(!1)),r.show())}}this.#y(),this.isEmpty&&(this.div.hidden=!0);let{classList:r}=this.div;for(let t of e.#m.values())r.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#s=!1}getEditableAnnotation(e){return this.#n?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#p.getActive()!==e&&this.#p.setActiveEditor(e)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#f){this.#f=new AbortController;let e=this.#p.combinedSignal(this.#f);this.#d.div.addEventListener(`pointerdown`,this.#h.bind(this),{signal:e}),this.#d.div.classList.add(`highlighting`)}}disableTextSelection(){this.div.tabIndex=0,this.#d?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#d.div.classList.remove(`highlighting`))}#h(e){this.#p.unselectAll();let{target:t}=e;if(t===this.#d.div||(t.getAttribute(`role`)===`img`||t.classList.contains(`endOfContent`))&&this.#d.div.contains(t)){let{isMac:t}=La.platform;if(e.button!==0||e.ctrlKey&&t)return;this.#p.showAllEditors(`highlight`,!0,!0),this.#d.div.classList.add(`free`),this.toggleDrawing(),Nc.startHighlighting(this,this.#p.direction===`ltr`,{target:this.#d.div,x:e.x,y:e.y}),this.#d.div.addEventListener(`pointerup`,()=>{this.#d.div.classList.remove(`free`),this.toggleDrawing(!0)},{once:!0,signal:this.#p._signal}),e.preventDefault()}}enableClick(){if(this.#r)return;this.#r=new AbortController;let e=this.#p.combinedSignal(this.#r);this.div.addEventListener(`pointerdown`,this.pointerdown.bind(this),{signal:e});let t=this.pointerup.bind(this);this.div.addEventListener(`pointerup`,t,{signal:e}),this.div.addEventListener(`pointercancel`,t,{signal:e})}disableClick(){this.#r?.abort(),this.#r=null}attach(e){this.#a.set(e.id,e);let{annotationElementId:t}=e;t&&this.#p.isDeletedAnnotationElement(t)&&this.#p.removeDeletedAnnotationElement(e)}detach(e){this.#a.delete(e.id),this.#e?.removePointerInTextLayer(e.contentDiv),!this.#s&&e.annotationElementId&&this.#p.addDeletedAnnotationElement(e)}remove(e){this.detach(e),this.#p.removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){e.parent!==this&&(e.parent&&e.annotationElementId&&(this.#p.addDeletedAnnotationElement(e.annotationElementId),ao.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),e.parent?.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(!(e.parent===this&&e.isAttachedToDOM)){if(this.changeParent(e),this.#p.addEditor(e),this.attach(e),!e.isAttachedToDOM){let t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!this.#c),this.#p.addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;let{activeElement:t}=document;e.div.contains(t)&&!this.#i&&(e._focusEventsAllowed=!1,this.#i=setTimeout(()=>{this.#i=null,e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this.#p._signal}),t.focus())},0)),e._structTreeParentId=this.#e?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||=this,e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getNextId(){return this.#p.getId()}get#g(){return e.#m.get(this.#p.getMode())}combinedSignal(e){return this.#p.combinedSignal(e)}#_(e){let t=this.#g;return t?new t.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#g?.canCreateNewEmptyEditor()}pasteEditor(e,t){this.#p.updateToolbar(e),this.#p.updateMode(e);let{offsetX:n,offsetY:r}=this.#v(),i=this.getNextId(),a=this.#_({parent:this,id:i,x:n,y:r,uiManager:this.#p,isCentered:!0,...t});a&&this.add(a)}async deserialize(t){return await e.#m.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#p)||null}createAndAddNewEditor(e,t,n={}){let r=this.getNextId(),i=this.#_({parent:this,id:r,x:e.offsetX,y:e.offsetY,uiManager:this.#p,isCentered:t,...n});return i&&this.add(i),i}#v(){let{x:e,y:t,width:n,height:r}=this.div.getBoundingClientRect(),i=Math.max(0,e),a=Math.max(0,t),o=Math.min(window.innerWidth,e+n),s=Math.min(window.innerHeight,t+r),c=(i+o)/2-e,l=(a+s)/2-t,[u,d]=this.viewport.rotation%180==0?[c,l]:[l,c];return{offsetX:u,offsetY:d}}addNewEditor(){this.createAndAddNewEditor(this.#v(),!0)}setSelected(e){this.#p.setSelected(e)}toggleSelected(e){this.#p.toggleSelected(e)}unselect(e){this.#p.unselect(e)}pointerup(e){let{isMac:t}=La.platform;e.button!==0||e.ctrlKey&&t||e.target===this.div&&this.#o&&(this.#o=!1,!(this.#g?.isDrawer&&this.#g.supportMultipleDrawings)&&(this.#t?this.#p.getMode()===J.STAMP?this.#p.unselectAll():this.createAndAddNewEditor(e,!1):this.#t=!0))}pointerdown(e){if(this.#p.getMode()===J.HIGHLIGHT&&this.enableTextSelection(),this.#o){this.#o=!1;return}let{isMac:t}=La.platform;if(e.button!==0||e.ctrlKey&&t||e.target!==this.div)return;if(this.#o=!0,this.#g?.isDrawer){this.startDrawingSession(e);return}let n=this.#p.getActive();this.#t=!n||n.isEmpty()}startDrawingSession(e){if(this.div.focus(),this.#l){this.#g.startDrawing(this,this.#p,!1,e);return}this.#p.setCurrentDrawingSession(this),this.#l=new AbortController;let t=this.#p.combinedSignal(this.#l);this.div.addEventListener(`blur`,({relatedTarget:e})=>{e&&!this.div.contains(e)&&(this.#u=null,this.commitOrRemove())},{signal:t}),this.#g.startDrawing(this,this.#p,!1,e)}pause(e){if(e){let{activeElement:e}=document;this.div.contains(e)&&(this.#u=e)}else this.#u&&setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(e=!1){return this.#l?(this.#p.setCurrentDrawingSession(null),this.#l.abort(),this.#l=null,this.#u=null,this.#g.endDrawing(e)):null}findNewParent(e,t,n){let r=this.#p.findParent(t,n);return r===null||r===this?!1:(r.changeParent(e),!0)}commitOrRemove(){return this.#l?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#l&&this.#g.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#p.getActive()?.parent===this&&(this.#p.commitOrRemove(),this.#p.setActiveEditor(null)),this.#i&&=(clearTimeout(this.#i),null);for(let e of this.#a.values())this.#e?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,this.#a.clear(),this.#p.removeLayer(this)}#y(){for(let e of this.#a.values())e.isEmpty()&&e.remove()}render({viewport:e}){this.viewport=e,Fe(this.div,e);for(let e of this.#p.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:e}){this.#p.commitOrRemove(),this.#y();let t=this.viewport.rotation,n=e.rotation;if(this.viewport=e,Fe(this.div,{rotation:n}),t!==n)for(let e of this.#a.values())e.rotate(n)}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return this.#p.viewParameters.realScale}},Hc=class e{#e=null;#t=0;#n=/* @__PURE__ */ new Map;#r=/* @__PURE__ */ new Map;constructor({pageIndex:e}){this.pageIndex=e}setParent(e){if(!this.#e)this.#e=e;else if(this.#e!==e){if(this.#n.size>0)for(let t of this.#n.values())t.remove(),e.append(t);this.#e=e}}static get _svgFactory(){return W(this,`_svgFactory`,new Gs)}static#i(e,[t,n,r,i]){let{style:a}=e;a.top=`${100*n}%`,a.left=`${100*t}%`,a.width=`${100*r}%`,a.height=`${100*i}%`}#a(){let t=e._svgFactory.create(1,1,!0);return this.#e.append(t),t.setAttribute(`aria-hidden`,!0),t}#o(t,n){let r=e._svgFactory.createElement(`clipPath`);t.append(r);let i=`clip_${n}`;r.setAttribute(`id`,i),r.setAttribute(`clipPathUnits`,`objectBoundingBox`);let a=e._svgFactory.createElement(`use`);return r.append(a),a.setAttribute(`href`,`#${n}`),a.classList.add(`clip`),i}#s(e,t){for(let[n,r]of Object.entries(t))r===null?e.removeAttribute(n):e.setAttribute(n,r)}draw(t,n=!1,r=!1){let i=this.#t++,a=this.#a(),o=e._svgFactory.createElement(`defs`);a.append(o);let s=e._svgFactory.createElement(`path`);o.append(s);let c=`path_p${this.pageIndex}_${i}`;s.setAttribute(`id`,c),s.setAttribute(`vector-effect`,`non-scaling-stroke`),n&&this.#r.set(i,s);let l=r?this.#o(o,c):null,u=e._svgFactory.createElement(`use`);return a.append(u),u.setAttribute(`href`,`#${c}`),this.updateProperties(a,t),this.#n.set(i,a),{id:i,clipPathId:`url(#${l})`}}drawOutline(t,n){let r=this.#t++,i=this.#a(),a=e._svgFactory.createElement(`defs`);i.append(a);let o=e._svgFactory.createElement(`path`);a.append(o);let s=`path_p${this.pageIndex}_${r}`;o.setAttribute(`id`,s),o.setAttribute(`vector-effect`,`non-scaling-stroke`);let c;if(n){let t=e._svgFactory.createElement(`mask`);a.append(t),c=`mask_p${this.pageIndex}_${r}`,t.setAttribute(`id`,c),t.setAttribute(`maskUnits`,`objectBoundingBox`);let n=e._svgFactory.createElement(`rect`);t.append(n),n.setAttribute(`width`,`1`),n.setAttribute(`height`,`1`),n.setAttribute(`fill`,`white`);let i=e._svgFactory.createElement(`use`);t.append(i),i.setAttribute(`href`,`#${s}`),i.setAttribute(`stroke`,`none`),i.setAttribute(`fill`,`black`),i.setAttribute(`fill-rule`,`nonzero`),i.classList.add(`mask`)}let l=e._svgFactory.createElement(`use`);i.append(l),l.setAttribute(`href`,`#${s}`),c&&l.setAttribute(`mask`,`url(#${c})`);let u=l.cloneNode();return i.append(u),l.classList.add(`mainOutline`),u.classList.add(`secondaryOutline`),this.updateProperties(i,t),this.#n.set(r,i),r}finalizeDraw(e,t){this.#r.delete(e),this.updateProperties(e,t)}updateProperties(t,n){if(!n)return;let{root:r,bbox:i,rootClass:a,path:o}=n,s=typeof t==`number`?this.#n.get(t):t;if(s){if(r&&this.#s(s,r),i&&e.#i(s,i),a){let{classList:e}=s;for(let[t,n]of Object.entries(a))e.toggle(t,n)}if(o){let e=s.firstChild.firstChild;this.#s(e,o)}}}updateParent(e,t){if(t===this)return;let n=this.#n.get(e);n&&(t.#e.append(n),this.#n.delete(e),t.#n.set(e,n))}remove(e){this.#r.delete(e),this.#e!==null&&(this.#n.get(e).remove(),this.#n.delete(e))}destroy(){this.#e=null;for(let e of this.#n.values())e.remove();this.#n.clear(),this.#r.clear()}},globalThis.pdfjsTestingUtils={HighlightOutliner:Oc}}));Uc();async function Wc(e,t){return{canvas:(0,d.createCanvas)(e,t),ImageData:d.ImageData}}async function Gc(e){return new Uint8Array(e.toBuffer(`image/png`))}async function Kc(e){return await(0,d.loadImage)(Buffer.from(e))}function qc(e){return new d.Path2D(e)}async function Jc(e){return{opList:await e.getOperatorList({annotationMode:_a.DISABLE})}}function Yc(e,t){return Zc(e.objs,t)}function Xc(e,t){return Zc(e.commonObjs,t)}function Zc(e,t){return t==null?Promise.resolve({data:null,reason:`cb-null`}):new Promise(n=>{let r=!1,i=(e,t)=>{r||(r=!0,n({data:e,reason:t}))};try{e.get(t,e=>i(e,e==null?`cb-null`:`ok`))}catch{i(null,`throw`);return}setTimeout(()=>i(null,`timeout`),1e4).unref?.()})}async function Qc(e,t,n={}){if(e==null)return null;let r=e.width,i=e.height;if(!r||!i)return rl(`missing width/height`,e,t,n),null;let{canvas:a,ImageData:o}=await Wc(r,i),s=a.getContext(`2d`);if(e.bitmap)try{s.drawImage(e.bitmap,0,0)}catch(r){return rl(`bitmap drawImage failed: ${r&&typeof r==`object`&&`message`in r?String(r.message):String(r)}`,e,t,n),null}else if(e.data){let a=il(e);if(!a)return rl(`unknown data kind=${e.kind}`,e,t,n),null;let c=new o(a,r,i);s.putImageData(c,0,0)}else return rl(`no bitmap and no data`,e,t,n),null;return Gc(a)}async function $c(e,t,n,r={}){if(e==null)return null;let i=e.width,a=e.height;if(!i||!a)return null;let o=tl(t);if(o==null)return null;let[s,c,l]=o,u=await el(e);if(u==null)return null;let{canvas:d,ImageData:f}=await Wc(i,a),p=d.getContext(`2d`),m=new Uint8ClampedArray(i*a*4);for(let e=0;e<i*a;e++)m[e*4]=s,m[e*4+1]=c,m[e*4+2]=l,m[e*4+3]=u[e];let h=new f(m,i,a);return p.putImageData(h,0,0),Gc(d)}async function el(e){let t=e.width,n=e.height,r=t*n;if(e.data){let{kind:i,data:a}=e;if(i===1){if(a.length>=r)return new Uint8ClampedArray(a.buffer,a.byteOffset,r);let e=new Uint8ClampedArray(r),i=Math.ceil(t/8);for(let r=0;r<n;r++)for(let n=0;n<t;n++){let o=a[r*i+(n>>3)]>>7-(n&7)&1;e[r*t+n]=o?255:0}return e}if(i===2){let e=new Uint8ClampedArray(r);for(let t=0;t<r;t++)e[t]=Math.round(a[t*3]*.299+a[t*3+1]*.587+a[t*3+2]*.114);return e}if(i===3){let e=new Uint8ClampedArray(r);for(let t=0;t<r;t++)e[t]=Math.round(a[t*4]*.299+a[t*4+1]*.587+a[t*4+2]*.114);return e}return null}if(e.bitmap){let{canvas:i}=await Wc(t,n),a=i.getContext(`2d`);try{a.drawImage(e.bitmap,0,0)}catch{return null}let o=a.getImageData(0,0,t,n).data,s=new Uint8ClampedArray(r);for(let e=0;e<r;e++)s[e]=Math.round(o[e*4]*.299+o[e*4+1]*.587+o[e*4+2]*.114);return s}return null}function tl(e){if(!e||typeof e!=`object`)return null;let{space:t,values:n}=e;if(t===`rgb`&&Array.isArray(n)&&n.length>=3)return[Math.round(nl(n[0])*255),Math.round(nl(n[1])*255),Math.round(nl(n[2])*255)];if(t===`gray`&&Array.isArray(n)&&n.length>=1){let e=Math.round(nl(n[0])*255);return[e,e,e]}if(t===`cmyk`&&Array.isArray(n)&&n.length>=4){let e=nl(n[0]),t=nl(n[1]),r=nl(n[2]),i=nl(n[3]);return[Math.round(255*(1-e)*(1-i)),Math.round(255*(1-t)*(1-i)),Math.round(255*(1-r)*(1-i))]}return null}function nl(e){return typeof e!=`number`||Number.isNaN(e)||e<0?0:e>1?1:e}function rl(e,t,n,r={}){if(!n?.emit)return;let i=r.pageIndex==null?``:`Page ${r.pageIndex}: `,a=r.objId?` objId="${r.objId}"`:``,o=t?.width??`?`,s=t?.height??`?`,c=t?.kind==null?``:`, kind=${t.kind}`;n.emit(`IMAGE_ENCODER_MISS`,{prefix:i,idLabel:a,width:o,height:s,kind:c,reason:e,page:r.pageIndex,objId:r.objId??null})}function il(e){let t=e.width,n=e.height,r=e.kind,i=e.data,a=t*n,o=new Uint8ClampedArray(a*4);if(r===1){if(i.length>=a){for(let e=0;e<a;e++){let t=i[e];o[e*4]=t,o[e*4+1]=t,o[e*4+2]=t,o[e*4+3]=255}return o}let e=Math.ceil(t/8);for(let r=0;r<n;r++)for(let n=0;n<t;n++){let a=i[r*e+(n>>3)]>>7-(n&7)&1?255:0,s=(r*t+n)*4;o[s]=a,o[s+1]=a,o[s+2]=a,o[s+3]=255}return o}if(r===2){for(let e=0;e<a;e++)o[e*4]=i[e*3],o[e*4+1]=i[e*3+1],o[e*4+2]=i[e*3+2],o[e*4+3]=255;return o}return r===3?new Uint8ClampedArray(i.buffer,i.byteOffset,i.byteLength):null}async function al(e){if(e==null)return null;let{width:t,height:n}=e;if(!t||!n)return null;let r=t*n;if(e.data){let i=new Uint8ClampedArray(r),a=Math.ceil(t/8);for(let r=0;r<n;r++)for(let n=0;n<t;n++){let o=e.data[r*a+(n>>3)]>>7-(n&7)&1;i[r*t+n]=o?0:255}return i}if(e.bitmap){let{canvas:i}=await Wc(t,n),a=i.getContext(`2d`);try{a.drawImage(e.bitmap,0,0)}catch{return null}let o=a.getImageData(0,0,t,n),s=new Uint8ClampedArray(r);for(let e=0;e<r;e++)s[e]=o.data[e*4+3];return s}return null}async function ol(e,t,n,r={}){if(e==null)return null;let i=e.width,a=e.height;if(!i||!a)return null;let o=tl(t);if(o==null)return null;let[s,c,l]=o,u=await al(e);if(u==null)return null;let{canvas:d,ImageData:f}=await Wc(i,a),p=d.getContext(`2d`),m=new Uint8ClampedArray(i*a*4);for(let e=0;e<i*a;e++)m[e*4]=s,m[e*4+1]=c,m[e*4+2]=l,m[e*4+3]=u[e];let h=new f(m,i,a);return p.putImageData(h,0,0),Gc(d)}async function sl(e){let{imageObj:t,imageCtm:n,maskSource:r,modulatedAlpha:i}=e;if(t==null)return null;let a=t.width,o=t.height;if(!a||!o)return null;let s=ml(i??1);if(r.kind===`shading`){let e=ul(r.ir,r.ctm);return e==null?null:ll(a,o,n,e,s)}if(r.kind===`image`){if(r.obj==null)return null;let e=r.obj.width,t=r.obj.height;if(!e||!t)return null;let i=await el(r.obj);if(i==null)return null;let c=dl(r.ctm,i,e,t);return c==null?null:ll(a,o,n,c,s)}return null}async function cl(e,t){if(e==null)return null;let n=e.width,r=e.height;if(!n||!r||t.length!==n*r)return null;let i=null;if(e.bitmap){let{canvas:t}=await Wc(n,r),a=t.getContext(`2d`);try{a.drawImage(e.bitmap,0,0)}catch{return null}let o=a.getImageData(0,0,n,r);i=new Uint8ClampedArray(o.data.buffer.slice(0))}else e.data&&(i=il(e));if(!i)return null;let a=new Uint8ClampedArray(n*r*4);for(let e=0;e<n*r;e++){a[e*4]=i[e*4],a[e*4+1]=i[e*4+1],a[e*4+2]=i[e*4+2];let n=i[e*4+3];a[e*4+3]=Math.round(n*t[e]/255)}let{canvas:o,ImageData:s}=await Wc(n,r),c=o.getContext(`2d`),l=new s(a,n,r);return c.putImageData(l,0,0),Gc(o)}function ll(e,t,n,r,i){let a=new Uint8ClampedArray(e*t),[o,s,c,l,u,d]=n;for(let n=0;n<t;n++)for(let f=0;f<e;f++){let p=(f+.5)/e,m=1-(n+.5)/t,h=r(o*p+c*m+u,s*p+l*m+d);a[n*e+f]=Math.round(h*255*i)}return a}function ul(e,t){if(!Array.isArray(e)||e[0]!==`RadialAxial`)return null;let n=e[1],r=e[3],i=e[4],a=e[5],o=e[6],s=e[7],c=fl(r);if(c==null)return null;let l=gl(t);if(l==null)return null;if(n===`axial`){if(!Array.isArray(i)||!Array.isArray(a))return null;let[e,t]=i,[n,r]=a,o=n-e,s=r-t,u=o*o+s*s;return u<=0?null:(n,r)=>{let[i,a]=hl(l,n,r),d=((i-e)*o+(a-t)*s)/u;return c[Math.round(Math.max(0,Math.min(1,d))*255)]/255}}if(n===`radial`){if(!Array.isArray(a)||typeof s!=`number`||s<=0||Math.abs(typeof o==`number`?o:0)>.001)return null;let[e,t]=a;return(n,r)=>{let[i,a]=hl(l,n,r),o=i-e,u=a-t,d=Math.sqrt(o*o+u*u)/s;return c[Math.round(Math.max(0,Math.min(1,d))*255)]/255}}return null}function dl(e,t,n,r){let i=gl(e);return i==null?null:(e,a)=>{let[o,s]=hl(i,e,a);if(o<0||o>1||s<0||s>1)return 0;let c=Math.min(n-1,Math.floor(o*n));return t[Math.min(r-1,Math.floor((1-s)*r))*n+c]/255}}function fl(e){if(!Array.isArray(e)||e.length<2)return null;let t=[];for(let n of e){if(!Array.isArray(n)||n.length<2)continue;let e=ml(n[0]),r=pl(n[1]);r&&t.push({offset:e,r:r[0],g:r[1],b:r[2]})}if(t.length<2)return null;t.sort((e,t)=>e.offset-t.offset);let n=/* @__PURE__ */ new Uint8Array(256);for(let e=0;e<256;e++){let r=e/255,i=t[0],a=t[t.length-1];for(let e=0;e<t.length-1;e++)if(r>=t[e].offset&&r<=t[e+1].offset){i=t[e],a=t[e+1];break}let o=a.offset-i.offset,s=o>0?(r-i.offset)/o:0,c=i.r+(a.r-i.r)*s,l=i.g+(a.g-i.g)*s,u=i.b+(a.b-i.b)*s;n[e]=Math.round(.299*c+.587*l+.114*u)}return n}function pl(e){if(typeof e!=`string`)return null;if(e===`transparent`)return[255,255,255];let t=/^#([0-9a-fA-F]{6})$/.exec(e.trim());if(!t)return null;let n=parseInt(t[1],16);return[n>>16&255,n>>8&255,n&255]}function ml(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?0:e>1?1:e}function hl(e,t,n){return[e[0]*t+e[2]*n+e[4],e[1]*t+e[3]*n+e[5]]}function gl(e){let[t,n,r,i,a,o]=e,s=t*i-n*r;if(!Number.isFinite(s)||Math.abs(s)<1e-12)return null;let c=1/s;return[i*c,-n*c,-r*c,t*c,(r*o-i*a)*c,(n*a-t*o)*c]}const _l=/^[A-Z]{6}\+/,vl=[[`ultracondensed`,`ultraCondensed`],[`extracondensed`,`extraCondensed`],[`semicondensed`,`semiCondensed`],[`condensed`,`condensed`],[`compressed`,`condensed`],[`narrow`,`condensed`],[`cond`,`condensed`],[`comp`,`condensed`],[`ultraexpanded`,`ultraExpanded`],[`extraexpanded`,`extraExpanded`],[`semiexpanded`,`semiExpanded`],[`expanded`,`expanded`],[`extended`,`expanded`],[`wide`,`expanded`]],yl=[`italic`,`oblique`],bl={bd:700,lt:300,md:500,rg:400,bk:900,blk:900,hv:900,th:100,hl:100};function xl(e){let t=e.replace(_l,``),n=t.lastIndexOf(`-`),r=t.lastIndexOf(`,`),i=Math.max(n,r);if(i<0)return{fullName:t,family:t,weight:null,style:`normal`,width:null,styleSuffix:null};let a=t.slice(0,i),o=t.slice(i+1),s=Sl(o);return s?{fullName:t,family:a,weight:s.weight,style:s.style,width:s.width,styleSuffix:o}:{fullName:t,family:t,weight:null,style:`normal`,width:null,styleSuffix:null}}function Sl(e){let t=e.toLowerCase(),n=!1,r=`normal`;for(let e of yl)if(t.includes(e)){r=`italic`,n=!0;break}let i=null;for(let[e,r]of vl)if(t.includes(e)){i=r,n=!0;break}let a=Cl(t);return a!==null&&(n=!0),n?{weight:a,style:r,width:i}:null}function Cl(e){return e.includes(`extrabold`)||e.includes(`ultrabold`)?800:e.includes(`semibold`)||e.includes(`demibold`)?600:e.includes(`extralight`)||e.includes(`ultralight`)?200:e.includes(`thin`)||e.includes(`hairline`)?100:e.includes(`light`)?300:e.includes(`medium`)?500:e.includes(`bold`)?700:e.includes(`black`)||e.includes(`heavy`)?900:e.includes(`regular`)||e===`normal`||e.includes(`book`)||e.includes(`roman`)?400:Object.prototype.hasOwnProperty.call(bl,e)?bl[e]:null}var wl=/* @__PURE__ */ s(((e,t,n)=>{var r=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(t,n)=>{for(var r in n)e(t,r,{get:n[r],enumerable:!0})},a=(i,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(let c of n(a))!r.call(i,c)&&c!==o&&e(i,c,{get:()=>a[c],enumerable:!(s=t(a,c))||s.enumerable});return i},o=t=>a(e({},`__esModule`,{value:!0}),t),s={};i(s,{BoundingBox:()=>N,Font:()=>Yc,Glyph:()=>Wt,Path:()=>L,_parse:()=>q,load:()=>xl,loadSync:()=>Sl,parse:()=>bl});var c=0,l=-3;function u(){this.table=/* @__PURE__ */ new Uint16Array(16),this.trans=/* @__PURE__ */ new Uint16Array(288)}function d(e,t){this.source=e,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new u,this.dtree=new u}var f=new u,p=new u,m=/* @__PURE__ */ new Uint8Array(30),h=/* @__PURE__ */ new Uint16Array(30),g=/* @__PURE__ */ new Uint8Array(30),_=/* @__PURE__ */ new Uint16Array(30),v=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),y=new u,b=/* @__PURE__ */ new Uint8Array(320);function x(e,t,n,r){for(var i=0,a;i<n;++i)e[i]=0;for(i=0;i<30-n;++i)e[i+n]=i/n|0;for(a=r,i=0;i<30;++i)t[i]=a,a+=1<<e[i]}function S(e,t){for(var n=0;n<7;++n)e.table[n]=0;for(e.table[7]=24,e.table[8]=152,e.table[9]=112,n=0;n<24;++n)e.trans[n]=256+n;for(n=0;n<144;++n)e.trans[24+n]=n;for(n=0;n<8;++n)e.trans[168+n]=280+n;for(n=0;n<112;++n)e.trans[176+n]=144+n;for(n=0;n<5;++n)t.table[n]=0;for(t.table[5]=32,n=0;n<32;++n)t.trans[n]=n}var C=/* @__PURE__ */ new Uint16Array(16);function w(e,t,n,r){for(var i=0,a;i<16;++i)e.table[i]=0;for(i=0;i<r;++i)e.table[t[n+i]]++;for(e.table[0]=0,a=0,i=0;i<16;++i)C[i]=a,a+=e.table[i];for(i=0;i<r;++i)t[n+i]&&(e.trans[C[t[n+i]]++]=i)}function T(e){e.bitcount--||(e.tag=e.source[e.sourceIndex++],e.bitcount=7);var t=e.tag&1;return e.tag>>>=1,t}function E(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<<e.bitcount,e.bitcount+=8;var r=e.tag&65535>>>16-t;return e.tag>>>=t,e.bitcount-=t,r+n}function D(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<<e.bitcount,e.bitcount+=8;var n=0,r=0,i=0,a=e.tag;do r=2*r+(a&1),a>>>=1,++i,n+=t.table[i],r-=t.table[i];while(r>=0);return e.tag=a,e.bitcount-=i,t.trans[n+r]}function O(e,t,n){for(var r=E(e,5,257),i=E(e,5,1),a=E(e,4,4),o=0,s,c;o<19;++o)b[o]=0;for(o=0;o<a;++o){var l=E(e,3,0);b[v[o]]=l}for(w(y,b,0,19),s=0;s<r+i;){var u=D(e,y);switch(u){case 16:var d=b[s-1];for(c=E(e,2,3);c;--c)b[s++]=d;break;case 17:for(c=E(e,3,3);c;--c)b[s++]=0;break;case 18:for(c=E(e,7,11);c;--c)b[s++]=0;break;default:b[s++]=u}}w(t,b,0,r),w(n,b,r,i)}function k(e,t,n){for(;;){var r=D(e,t);if(r===256)return c;if(r<256)e.dest[e.destLen++]=r;else{var i,a,o,s;for(r-=257,i=E(e,m[r],h[r]),a=D(e,n),o=e.destLen-E(e,g[a],_[a]),s=o;s<o+i;++s)e.dest[e.destLen++]=e.dest[s]}}}function A(e){for(var t,n,r;e.bitcount>8;)e.sourceIndex--,e.bitcount-=8;if(t=e.source[e.sourceIndex+1],t=256*t+e.source[e.sourceIndex],n=e.source[e.sourceIndex+3],n=256*n+e.source[e.sourceIndex+2],t!==(~n&65535))return l;for(e.sourceIndex+=4,r=t;r;--r)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,c}function j(e,t){var n=new d(e,t),r,i,a;do{switch(r=T(n),i=E(n,2,0),i){case 0:a=A(n);break;case 1:a=k(n,f,p);break;case 2:O(n,n.ltree,n.dtree),a=k(n,n.ltree,n.dtree);break;default:a=l}if(a!==c)throw Error(`Data error`)}while(!r);return n.destLen<n.dest.length?typeof n.dest.slice==`function`?n.dest.slice(0,n.destLen):n.dest.subarray(0,n.destLen):n.dest}S(f,p),x(m,h,4,3),x(g,_,2,1),m[28]=0,h[28]=258;function M(e,t,n,r,i){return(1-i)**3*e+3*(1-i)**2*i*t+3*(1-i)*i**2*n+i**3*r}function ee(){this.x1=NaN,this.y1=NaN,this.x2=NaN,this.y2=NaN}ee.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},ee.prototype.addPoint=function(e,t){typeof e==`number`&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=e,this.x2=e),e<this.x1&&(this.x1=e),e>this.x2&&(this.x2=e)),typeof t==`number`&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),t<this.y1&&(this.y1=t),t>this.y2&&(this.y2=t))},ee.prototype.addX=function(e){this.addPoint(e,null)},ee.prototype.addY=function(e){this.addPoint(null,e)},ee.prototype.addBezier=function(e,t,n,r,i,a,o,s){let c=[e,t],l=[n,r],u=[i,a],d=[o,s];this.addPoint(e,t),this.addPoint(o,s);for(let e=0;e<=1;e++){let t=6*c[e]-12*l[e]+6*u[e],n=-3*c[e]+9*l[e]-9*u[e]+3*d[e],r=3*l[e]-3*c[e];if(n===0){if(t===0)continue;let n=-r/t;0<n&&n<1&&(e===0&&this.addX(M(c[e],l[e],u[e],d[e],n)),e===1&&this.addY(M(c[e],l[e],u[e],d[e],n)));continue}let i=t**2-4*r*n;if(i<0)continue;let a=(-t+Math.sqrt(i))/(2*n);0<a&&a<1&&(e===0&&this.addX(M(c[e],l[e],u[e],d[e],a)),e===1&&this.addY(M(c[e],l[e],u[e],d[e],a)));let o=(-t-Math.sqrt(i))/(2*n);0<o&&o<1&&(e===0&&this.addX(M(c[e],l[e],u[e],d[e],o)),e===1&&this.addY(M(c[e],l[e],u[e],d[e],o)))}},ee.prototype.addQuad=function(e,t,n,r,i,a){let o=e+2/3*(n-e),s=t+2/3*(r-t),c=o+1/3*(i-e),l=s+1/3*(a-t);this.addBezier(e,t,o,s,c,l,i,a)};var N=ee;function P(){this.commands=[],this.fill=`black`,this.stroke=null,this.strokeWidth=1}var F={};function I(e,t){let n=Math.floor(e),r=e-n;if(F[t]||(F[t]={}),F[t][r]!==void 0)return n+F[t][r];let i=+(Math.round(r+`e+`+t)+`e-`+t);return F[t][r]=i,n+i}function te(e){let t=[[]],n=0,r=0;for(let i=0;i<e.length;i+=1){let a=t[t.length-1],o=e[i],s=a[0],c=a[1],l=a[a.length-1],u=e[i+1];a.push(o),o.type===`M`?(n=o.x,r=o.y):o.type===`L`&&(!u||u.type===`Z`)?Math.abs(o.x-n)>1||Math.abs(o.y-r)>1||a.pop():o.type===`L`&&l&&l.x===o.x&&l.y===o.y?a.pop():o.type===`Z`&&(s&&c&&l&&s.type===`M`&&c.type===`L`&&l.type===`L`&&l.x===s.x&&l.y===s.y&&(a.shift(),a[0].type=`M`),i+1<e.length&&t.push([]))}return e=[].concat.apply([],t),e}function ne(e){return Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0,scale:1,x:0,y:0},e)}function re(e){return parseInt(e)===e&&(e={decimalPlaces:e,flipY:!1}),Object.assign({},{decimalPlaces:2,optimize:!0,flipY:!0,flipYBase:void 0},e)}P.prototype.fromSVG=function(e,t={}){typeof SVGPathElement<`u`&&e instanceof SVGPathElement&&(e=e.getAttribute(`d`)),t=ne(t),this.commands=[];let n=`MmLlQqCcZzHhVv`,r={},i=[``],a=!1;function o(e){return e.filter(e=>e.length).map(e=>{let n=parseFloat(e);return(t.decimalPlaces||t.decimalPlaces===0)&&(n=I(n,t.decimalPlaces)),n})}function s(e){if(!this.commands.length)return e;let t=this.commands[this.commands.length-1];for(let n=0;n<e.length;n++)e[n]+=t[n&1?`y`:`x`];return e}function c(){if(r.type===void 0)return;let e=r.type.toUpperCase(),t=e!==`Z`&&r.type.toUpperCase()!==r.type,n=o(i);if(i=[``],!n.length&&e!==`Z`)return;t&&e!==`H`&&e!==`V`&&(n=s.apply(this,[n]));let a=this.commands.length&&this.commands[this.commands.length-1].x||0,c=this.commands.length&&this.commands[this.commands.length-1].y||0;switch(e){case`M`:this.moveTo(...n);break;case`L`:this.lineTo(...n);break;case`V`:for(let e=0;e<n.length;e++){let r=0;t&&(r=this.commands.length&&this.commands[this.commands.length-1].y||0),this.lineTo(a,n[e]+r)}break;case`H`:for(let e=0;e<n.length;e++){let r=0;t&&(r=this.commands.length&&this.commands[this.commands.length-1].x||0),this.lineTo(n[e]+r,c)}break;case`C`:this.bezierCurveTo(...n);break;case`Q`:this.quadraticCurveTo(...n);break;case`Z`:(this.commands.length<1||this.commands[this.commands.length-1].type!==`Z`)&&this.close()}if(this.commands.length)for(let e in this.commands[this.commands.length-1])this.commands[this.commands.length-1][e]===void 0&&(this.commands[this.commands.length-1][e]=0)}for(let t=0;t<e.length;t++){let o=e.charAt(t),s=i[i.length-1];if(`0123456789`.indexOf(o)>-1)i[i.length-1]+=o;else if(`-+`.indexOf(o)>-1){if(!r.type&&!this.commands.length&&(r.type=`L`),o===`-`)!r.type||s.indexOf(`-`)>0?a=!0:s.length?i.push(`-`):i[i.length-1]=o;else if(!r.type||s.length>0)a=!0;else continue}else if(n.indexOf(o)>-1)r.type?(c.apply(this),r={type:o}):r.type=o;else if(`SsTtAa`.indexOf(o)>-1)throw Error(`Unsupported path command: `+o+`. Currently supported commands are `+n.split(``).join(`, `)+`.`);else` ,
16
+ \r\f\v`.indexOf(o)>-1?i.push(``):o===`.`?!r.type||s.indexOf(o)>-1?a=!0:i[i.length-1]+=o:a=!0;if(a)throw Error(`Unexpected character: `+o+` at offset `+t)}c.apply(this),t.optimize&&(this.commands=te(this.commands));let l=t.flipY,u=t.flipYBase;if(l===!0&&t.flipYBase===void 0){let e=this.getBoundingBox();u=e.y1+e.y2}for(let e in this.commands){let n=this.commands[e];for(let r in n)[`x`,`x1`,`x2`].includes(r)?this.commands[e][r]=t.x+n[r]*t.scale:[`y`,`y1`,`y2`].includes(r)&&(this.commands[e][r]=t.y+(l?u-n[r]:n[r])*t.scale)}return this},P.fromSVG=function(e,t){return new P().fromSVG(e,t)},P.prototype.moveTo=function(e,t){this.commands.push({type:`M`,x:e,y:t})},P.prototype.lineTo=function(e,t){this.commands.push({type:`L`,x:e,y:t})},P.prototype.curveTo=P.prototype.bezierCurveTo=function(e,t,n,r,i,a){this.commands.push({type:`C`,x1:e,y1:t,x2:n,y2:r,x:i,y:a})},P.prototype.quadTo=P.prototype.quadraticCurveTo=function(e,t,n,r){this.commands.push({type:`Q`,x1:e,y1:t,x:n,y:r})},P.prototype.close=P.prototype.closePath=function(){this.commands.push({type:`Z`})},P.prototype.extend=function(e){if(e.commands)e=e.commands;else if(e instanceof N){let t=e;this.moveTo(t.x1,t.y1),this.lineTo(t.x2,t.y1),this.lineTo(t.x2,t.y2),this.lineTo(t.x1,t.y2),this.close();return}Array.prototype.push.apply(this.commands,e)},P.prototype.getBoundingBox=function(){let e=new N,t=0,n=0,r=0,i=0;for(let a=0;a<this.commands.length;a++){let o=this.commands[a];switch(o.type){case`M`:e.addPoint(o.x,o.y),t=r=o.x,n=i=o.y;break;case`L`:e.addPoint(o.x,o.y),r=o.x,i=o.y;break;case`Q`:e.addQuad(r,i,o.x1,o.y1,o.x,o.y),r=o.x,i=o.y;break;case`C`:e.addBezier(r,i,o.x1,o.y1,o.x2,o.y2,o.x,o.y),r=o.x,i=o.y;break;case`Z`:r=t,i=n;break;default:throw Error(`Unexpected path command `+o.type)}}return e.isEmpty()&&e.addPoint(0,0),e},P.prototype.draw=function(e){let t=this._layers;if(t&&t.length){for(let n=0;n<t.length;n++)this.draw.call(t[n],e);return}let n=this._image;if(n)e.drawImage(n.image,n.x,n.y,n.width,n.height);else{e.beginPath();for(let t=0;t<this.commands.length;t+=1){let n=this.commands[t];n.type===`M`?e.moveTo(n.x,n.y):n.type===`L`?e.lineTo(n.x,n.y):n.type===`C`?e.bezierCurveTo(n.x1,n.y1,n.x2,n.y2,n.x,n.y):n.type===`Q`?e.quadraticCurveTo(n.x1,n.y1,n.x,n.y):n.type===`Z`&&this.stroke&&this.strokeWidth&&e.closePath()}this.fill&&(e.fillStyle=this.fill,e.fill()),this.stroke&&(e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,e.stroke())}},P.prototype.toPathData=function(e){e=re(e);function t(t){let n=I(t,e.decimalPlaces);return Math.round(t)===n?``+n:n.toFixed(e.decimalPlaces)}function n(){let e=``;for(let n=0;n<arguments.length;n+=1){let r=arguments[n];r>=0&&n>0&&(e+=` `),e+=t(r)}return e}let r=this.commands;e.optimize&&(r=JSON.parse(JSON.stringify(this.commands)),r=te(r));let i=e.flipY,a=e.flipYBase;if(i===!0&&a===void 0){let e=new P;e.extend(r);let t=e.getBoundingBox();a=t.y1+t.y2}let o=``;for(let e=0;e<r.length;e+=1){let t=r[e];t.type===`M`?o+=`M`+n(t.x,i?a-t.y:t.y):t.type===`L`?o+=`L`+n(t.x,i?a-t.y:t.y):t.type===`C`?o+=`C`+n(t.x1,i?a-t.y1:t.y1,t.x2,i?a-t.y2:t.y2,t.x,i?a-t.y:t.y):t.type===`Q`?o+=`Q`+n(t.x1,i?a-t.y1:t.y1,t.x,i?a-t.y:t.y):t.type===`Z`&&(o+=`Z`)}return o},P.prototype.toSVG=function(e,t){this._layers&&this._layers.length&&console.warn(`toSVG() does not support colr font layers yet`),this._image&&console.warn(`toSVG() does not support SVG glyphs yet`),t||=this.toPathData(e);let n=`<path d="`;return n+=t,n+=`"`,this.fill!==void 0&&this.fill!==`black`&&(this.fill===null?n+=` fill="none"`:n+=` fill="`+this.fill+`"`),this.stroke&&(n+=` stroke="`+this.stroke+`" stroke-width="`+this.strokeWidth+`"`),n+=`/>`,n},P.prototype.toDOMElement=function(e,t){this._layers&&this._layers.length&&console.warn(`toDOMElement() does not support colr font layers yet`),t||=this.toPathData(e);let n=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return n.setAttribute(`d`,t),this.fill!==void 0&&this.fill!==`black`&&(this.fill===null?n.setAttribute(`fill`,`none`):n.setAttribute(`fill`,this.fill)),this.stroke&&(n.setAttribute(`stroke`,this.stroke),n.setAttribute(`stroke-width`,this.strokeWidth)),n};var L=P;function ie(e){throw Error(e)}function ae(e,t){e||ie(t)}var R={fail:ie,argument:ae,assert:ae},oe=32768,se=2147483648,ce=-32768,z=32767+1/65536,le={},B={},V={};function H(e){return function(){return e}}B.BYTE=function(e){return R.argument(e>=0&&e<=255,`Byte value should be between 0 and 255.`),[e]},V.BYTE=H(1),B.CHAR=function(e){return[e.charCodeAt(0)]},V.CHAR=H(1),B.CHARARRAY=function(e){e??(e=``,console.warn(`CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name.`));let t=[];for(let n=0;n<e.length;n+=1)t[n]=e.charCodeAt(n);return t},V.CHARARRAY=function(e){return e===void 0?0:e.length},B.USHORT=function(e){return[e>>8&255,e&255]},V.USHORT=H(2),B.SHORT=function(e){return e>=oe&&(e=-(2*oe-e)),[e>>8&255,e&255]},V.SHORT=H(2),B.UINT24=function(e){return[e>>16&255,e>>8&255,e&255]},V.UINT24=H(3),B.ULONG=function(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]},V.ULONG=H(4),B.LONG=function(e){return e>=se&&(e=-(2*se-e)),[e>>24&255,e>>16&255,e>>8&255,e&255]},V.LONG=H(4),B.FLOAT=function(e){if(e>z||e<ce)throw Error(`Value ${e} is outside the range of representable values in 16.16 format`);let t=Math.round(e*65536)|0;return B.ULONG(t)},V.FLOAT=V.ULONG,B.FIXED=B.ULONG,V.FIXED=V.ULONG,B.FWORD=B.SHORT,V.FWORD=V.SHORT,B.UFWORD=B.USHORT,V.UFWORD=V.USHORT,B.F2DOT14=function(e){return B.USHORT(e*16384)},V.F2DOT14=V.USHORT,B.LONGDATETIME=function(e){return[0,0,0,0,e>>24&255,e>>16&255,e>>8&255,e&255]},V.LONGDATETIME=H(8),B.TAG=function(e){return R.argument(e.length===4,`Tag should be exactly 4 ASCII characters.`),[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]},V.TAG=H(4),B.Card8=B.BYTE,V.Card8=V.BYTE,B.Card16=B.USHORT,V.Card16=V.USHORT,B.OffSize=B.BYTE,V.OffSize=V.BYTE,B.SID=B.USHORT,V.SID=V.USHORT,B.NUMBER=function(e){return e>=-107&&e<=107?[e+139]:e>=108&&e<=1131?(e-=108,[(e>>8)+247,e&255]):e>=-1131&&e<=-108?(e=-e-108,[(e>>8)+251,e&255]):e>=-32768&&e<=32767?B.NUMBER16(e):B.NUMBER32(e)},V.NUMBER=function(e){return B.NUMBER(e).length},B.NUMBER16=function(e){return[28,e>>8&255,e&255]},V.NUMBER16=H(3),B.NUMBER32=function(e){return[29,e>>24&255,e>>16&255,e>>8&255,e&255]},V.NUMBER32=H(5),B.REAL=function(e){let t=e.toString(),n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(t);if(n){let r=parseFloat(`1e`+((n[2]?+n[2]:0)+n[1].length));t=(Math.round(e*r)/r).toString()}let r=``;for(let e=0,n=t.length;e<n;e+=1){let n=t[e];r+=n===`e`?t[++e]===`-`?`c`:`b`:n===`.`?`a`:n===`-`?`e`:n}r+=r.length&1?`f`:`ff`;let i=[30];for(let e=0,t=r.length;e<t;e+=2)i.push(parseInt(r.substr(e,2),16));return i},V.REAL=function(e){return B.REAL(e).length},B.NAME=B.CHARARRAY,V.NAME=V.CHARARRAY,B.STRING=B.CHARARRAY,V.STRING=V.CHARARRAY,le.UTF8=function(e,t,n){let r=[],i=n;for(let n=0;n<i;n++,t+=1)r[n]=e.getUint8(t);return String.fromCharCode.apply(null,r)},le.UTF16=function(e,t,n){let r=[],i=n/2;for(let n=0;n<i;n++,t+=2)r[n]=e.getUint16(t);return String.fromCharCode.apply(null,r)},B.UTF16=function(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);t[t.length]=r>>8&255,t[t.length]=r&255}return t},V.UTF16=function(e){return e.length*2};var U={"x-mac-croatian":`ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ\xA0ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ`,"x-mac-cyrillic":`АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»…\xA0ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю`,"x-mac-gaelic":`ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»…\xA0ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ`,"x-mac-greek":`Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»…\xA0ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­`,"x-mac-icelandic":`ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»…\xA0ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ`,"x-mac-inuit":`ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ…\xA0ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł`,"x-mac-ce":`ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»…\xA0ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ`,macintosh:`ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»…\xA0ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ`,"x-mac-romanian":`ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»…\xA0ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ`,"x-mac-turkish":`ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»…\xA0ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ`};le.MACSTRING=function(e,t,n,r){let i=U[r];if(i===void 0)return;let a=``;for(let r=0;r<n;r++){let n=e.getUint8(t+r);a+=n<=127?String.fromCharCode(n):i[n&127]}return a};var ue=typeof WeakMap==`function`&&/* @__PURE__ */ new WeakMap,de,fe=function(e){if(!de){de={};for(let e in U)de[e]=new String(e)}let t=de[e];if(t===void 0)return;if(ue){let e=ue.get(t);if(e!==void 0)return e}let n=U[e];if(n===void 0)return;let r={};for(let e=0;e<n.length;e++)r[n.charCodeAt(e)]=e+128;return ue&&ue.set(t,r),r};B.MACSTRING=function(e,t){let n=fe(t);if(n===void 0)return;let r=[];for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);if(i>=128&&(i=n[i],i===void 0))return;r[t]=i}return r},V.MACSTRING=function(e,t){let n=B.MACSTRING(e,t);return n===void 0?0:n.length};function W(e){return e>=-128&&e<=127}function pe(e,t,n){let r=0,i=e.length;for(;t<i&&r<64&&e[t]===0;)++t,++r;return n.push(128|r-1),t}function me(e,t,n){let r=0,i=e.length,a=t;for(;a<i&&r<64;){let t=e[a];if(!W(t)||t===0&&a+1<i&&e[a+1]===0)break;++a,++r}n.push(r-1);for(let r=t;r<a;++r)n.push(e[r]+256&255);return a}function he(e,t,n){let r=0,i=e.length,a=t;for(;a<i&&r<64;){let t=e[a];if(t===0||W(t)&&a+1<i&&W(e[a+1]))break;++a,++r}n.push(64|r-1);for(let r=t;r<a;++r){let t=e[r];n.push(t+65536>>8&255,t+256&255)}return a}B.VARDELTAS=function(e){let t=0,n=[];for(;t<e.length;){let r=e[t];t=r===0?pe(e,t,n):r>=-128&&r<=127?me(e,t,n):he(e,t,n)}return n},B.INDEX=function(e){let t=1,n=[t],r=[];for(let i=0;i<e.length;i+=1){let a=B.OBJECT(e[i]);Array.prototype.push.apply(r,a),t+=a.length,n.push(t)}if(r.length===0)return[0,0];let i=[],a=1+Math.floor(Math.log(t)/Math.log(2))/8|0,o=[void 0,B.BYTE,B.USHORT,B.UINT24,B.ULONG][a];for(let e=0;e<n.length;e+=1){let t=o(n[e]);Array.prototype.push.apply(i,t)}return Array.prototype.concat(B.Card16(e.length),B.OffSize(a),i,r)},V.INDEX=function(e){return B.INDEX(e).length},B.DICT=function(e){let t=[],n=Object.keys(e),r=n.length;for(let i=0;i<r;i+=1){let r=parseInt(n[i],0),a=e[r],o=B.OPERAND(a.value,a.type),s=B.OPERATOR(r);for(let e=0;e<o.length;e++)t.push(o[e]);for(let e=0;e<s.length;e++)t.push(s[e])}return t},V.DICT=function(e){return B.DICT(e).length},B.OPERATOR=function(e){return e<1200?[e]:[12,e-1200]},B.OPERAND=function(e,t){let n=[];if(Array.isArray(t))for(let r=0;r<t.length;r+=1){R.argument(e.length===t.length,`Not enough arguments given for type`+t);let i=B.OPERAND(e[r],t[r]);for(let e=0;e<i.length;e++)n.push(i[e])}else if(t===`SID`){let t=B.NUMBER(e);for(let e=0;e<t.length;e++)n.push(t[e])}else if(t===`offset`){let t=B.NUMBER32(e);for(let e=0;e<t.length;e++)n.push(t[e])}else if(t===`number`){let t=B.NUMBER(e);for(let e=0;e<t.length;e++)n.push(t[e])}else if(t===`real`){let t=B.REAL(e);for(let e=0;e<t.length;e++)n.push(t[e])}else throw Error(`Unknown operand type `+t);return n},B.OP=B.BYTE,V.OP=V.BYTE;var ge=typeof WeakMap==`function`&&/* @__PURE__ */ new WeakMap;B.CHARSTRING=function(e){if(ge){let t=ge.get(e);if(t!==void 0)return t}let t=[],n=e.length;for(let r=0;r<n;r+=1){let n=e[r],i=B[n.type](n.value);for(let e=0;e<i.length;e++)t.push(i[e])}return ge&&ge.set(e,t),t},V.CHARSTRING=function(e){return B.CHARSTRING(e).length},B.OBJECT=function(e){let t=B[e.type];return R.argument(t!==void 0,`No encoding function for type `+e.type),t(e.value)},V.OBJECT=function(e){let t=V[e.type];return R.argument(t!==void 0,`No sizeOf function for type `+e.type),t(e.value)},B.TABLE=function(e){let t=[],n=(e.fields||[]).length,r=[],i=[];for(let a=0;a<n;a+=1){let n=e.fields[a],o=B[n.type];R.argument(o!==void 0,`No encoding function for field type `+n.type+` (`+n.name+`)`);let s=e[n.name];s===void 0&&(s=n.value);let c=o(s);if(n.type===`TABLE`)s.fields!==null&&(i.push(t.length),r.push(c)),t.push(0,0);else for(let e=0;e<c.length;e++)t.push(c[e])}for(let n=0;n<r.length;n+=1){let a=i[n],o=t.length;R.argument(o<65536,`Table `+e.tableName+` too big.`),t[a]=o>>8,t[a+1]=o&255;for(let e=0;e<r[n].length;e++)t.push(r[n][e])}return t},V.TABLE=function(e){let t=0,n=(e.fields||[]).length;for(let r=0;r<n;r+=1){let n=e.fields[r],i=V[n.type];R.argument(i!==void 0,`No sizeOf function for field type `+n.type+` (`+n.name+`)`);let a=e[n.name];a===void 0&&(a=n.value),t+=i(a),n.type===`TABLE`&&(t+=2)}return t},B.RECORD=B.TABLE,V.RECORD=V.TABLE,B.LITERAL=function(e){return e},V.LITERAL=function(e){return e.length};function _e(e,t,n){if(t&&t.length)for(let e=0;e<t.length;e+=1){let n=t[e];this[n.name]=n.value}if(this.tableName=e,this.fields=t,n){let e=Object.keys(n);for(let t=0;t<e.length;t+=1){let r=e[t],i=n[r];this[r]!==void 0&&(this[r]=i)}}}_e.prototype.encode=function(){return B.TABLE(this)},_e.prototype.sizeOf=function(){return V.TABLE(this)};function ve(e,t,n){n===void 0&&(n=t.length);let r=Array(t.length+1);r[0]={name:e+`Count`,type:`USHORT`,value:n};for(let n=0;n<t.length;n++)r[n+1]={name:e+n,type:`USHORT`,value:t[n]};return r}function ye(e,t,n){let r=t.length,i=Array(r+1);i[0]={name:e+`Count`,type:`USHORT`,value:r};for(let a=0;a<r;a++)i[a+1]={name:e+a,type:`TABLE`,value:n(t[a],a)};return i}function be(e,t,n){let r=t.length,i=[];i[0]={name:e+`Count`,type:`USHORT`,value:r};for(let e=0;e<r;e++)i=i.concat(n(t[e],e));return i}function xe(e){e.format===1?_e.call(this,`coverageTable`,[{name:`coverageFormat`,type:`USHORT`,value:1}].concat(ve(`glyph`,e.glyphs))):e.format===2?_e.call(this,`coverageTable`,[{name:`coverageFormat`,type:`USHORT`,value:2}].concat(be(`rangeRecord`,e.ranges,function(e,t){return[{name:`startGlyphID`+t,type:`USHORT`,value:e.start},{name:`endGlyphID`+t,type:`USHORT`,value:e.end},{name:`startCoverageIndex`+t,type:`USHORT`,value:e.index}]}))):R.assert(!1,`Coverage format must be 1 or 2.`)}xe.prototype=Object.create(_e.prototype),xe.prototype.constructor=xe;function Se(e){_e.call(this,`scriptListTable`,be(`scriptRecord`,e,function(e,t){let n=e.script,r=n.defaultLangSys;return R.assert(!!r,`Unable to write GSUB: script `+e.tag+` has no default language system.`),[{name:`scriptTag`+t,type:`TAG`,value:e.tag},{name:`script`+t,type:`TABLE`,value:new _e(`scriptTable`,[{name:`defaultLangSys`,type:`TABLE`,value:new _e(`defaultLangSys`,[{name:`lookupOrder`,type:`USHORT`,value:0},{name:`reqFeatureIndex`,type:`USHORT`,value:r.reqFeatureIndex}].concat(ve(`featureIndex`,r.featureIndexes)))}].concat(be(`langSys`,n.langSysRecords,function(e,t){let n=e.langSys;return[{name:`langSysTag`+t,type:`TAG`,value:e.tag},{name:`langSys`+t,type:`TABLE`,value:new _e(`langSys`,[{name:`lookupOrder`,type:`USHORT`,value:0},{name:`reqFeatureIndex`,type:`USHORT`,value:n.reqFeatureIndex}].concat(ve(`featureIndex`,n.featureIndexes)))}]})))}]}))}Se.prototype=Object.create(_e.prototype),Se.prototype.constructor=Se;function Ce(e){_e.call(this,`featureListTable`,be(`featureRecord`,e,function(e,t){let n=e.feature;return[{name:`featureTag`+t,type:`TAG`,value:e.tag},{name:`feature`+t,type:`TABLE`,value:new _e(`featureTable`,[{name:`featureParams`,type:`USHORT`,value:n.featureParams}].concat(ve(`lookupListIndex`,n.lookupListIndexes)))}]}))}Ce.prototype=Object.create(_e.prototype),Ce.prototype.constructor=Ce;function we(e,t){_e.call(this,`lookupListTable`,ye(`lookup`,e,function(e){let n=t[e.lookupType];return R.assert(!!n,`Unable to write GSUB lookup type `+e.lookupType+` tables.`),new _e(`lookupTable`,[{name:`lookupType`,type:`USHORT`,value:e.lookupType},{name:`lookupFlag`,type:`USHORT`,value:e.lookupFlag}].concat(ye(`subtable`,e.subtables,n)))}))}we.prototype=Object.create(_e.prototype),we.prototype.constructor=we;function Te(e){e.format===1?_e.call(this,`classDefTable`,[{name:`classFormat`,type:`USHORT`,value:1},{name:`startGlyphID`,type:`USHORT`,value:e.startGlyph}].concat(ve(`glyph`,e.classes))):e.format===2?_e.call(this,`classDefTable`,[{name:`classFormat`,type:`USHORT`,value:2}].concat(be(`rangeRecord`,e.ranges,function(e,t){return[{name:`startGlyphID`+t,type:`USHORT`,value:e.start},{name:`endGlyphID`+t,type:`USHORT`,value:e.end},{name:`class`+t,type:`USHORT`,value:e.classId}]}))):R.assert(!1,`Class format must be 1 or 2.`)}Te.prototype=Object.create(_e.prototype),Te.prototype.constructor=Te;var G={Table:_e,Record:_e,Coverage:xe,ClassDef:Te,ScriptList:Se,FeatureList:Ce,LookupList:we,ushortList:ve,tableList:ye,recordList:be};function Ee(e,t){return e.getUint8(t)}function De(e,t){return e.getUint16(t,!1)}function Oe(e,t){return e.getInt16(t,!1)}function ke(e,t){return(e.getUint16(t)<<8)+e.getUint8(t+2)}function Ae(e,t){return e.getUint32(t,!1)}function je(e,t){return e.getInt32(t,!1)}function Me(e,t){return e.getInt16(t,!1)+e.getUint16(t+2,!1)/65535}function Ne(e,t){let n=``;for(let r=t;r<t+4;r+=1)n+=String.fromCharCode(e.getInt8(r));return n}function Pe(e,t,n){let r=0;for(let i=0;i<n;i+=1)r<<=8,r+=e.getUint8(t+i);return r}function Fe(e,t,n){let r=[];for(let i=t;i<n;i+=1)r.push(e.getUint8(i));return r}function Ie(e){let t=``;for(let n=0;n<e.length;n+=1)t+=String.fromCharCode(e[n]);return t}var Le={byte:1,uShort:2,f2dot14:2,short:2,uInt24:3,uLong:4,fixed:4,longDateTime:8,tag:4},Re={LONG_WORDS:32768,WORD_DELTA_COUNT_MASK:32767,SHARED_POINT_NUMBERS:32768,COUNT_MASK:4095,EMBEDDED_PEAK_TUPLE:32768,INTERMEDIATE_REGION:16384,PRIVATE_POINT_NUMBERS:8192,TUPLE_INDEX_MASK:4095,POINTS_ARE_WORDS:128,POINT_RUN_COUNT_MASK:127,DELTAS_ARE_ZERO:128,DELTAS_ARE_WORDS:64,DELTA_RUN_COUNT_MASK:63,INNER_INDEX_BIT_COUNT_MASK:15,MAP_ENTRY_SIZE_MASK:48};function K(e,t){this.data=e,this.offset=t,this.relativeOffset=0}K.prototype.parseByte=function(){let e=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,e},K.prototype.parseChar=function(){let e=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,e},K.prototype.parseCard8=K.prototype.parseByte,K.prototype.parseUShort=function(){let e=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,e},K.prototype.parseCard16=K.prototype.parseUShort,K.prototype.parseSID=K.prototype.parseUShort,K.prototype.parseOffset16=K.prototype.parseUShort,K.prototype.parseShort=function(){let e=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,e},K.prototype.parseF2Dot14=function(){let e=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,e},K.prototype.parseUInt24=function(){let e=ke(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=3,e},K.prototype.parseULong=function(){let e=Ae(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,e},K.prototype.parseLong=function(){let e=je(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,e},K.prototype.parseOffset32=K.prototype.parseULong,K.prototype.parseFixed=function(){let e=Me(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,e},K.prototype.parseString=function(e){let t=this.data,n=this.offset+this.relativeOffset,r=``;this.relativeOffset+=e;for(let i=0;i<e;i++)r+=String.fromCharCode(t.getUint8(n+i));return r},K.prototype.parseTag=function(){return this.parseString(4)},K.prototype.parseLongDateTime=function(){let e=Ae(this.data,this.offset+this.relativeOffset+4);return e-=2082844800,this.relativeOffset+=8,e},K.prototype.parseVersion=function(e){let t=De(this.data,this.offset+this.relativeOffset),n=De(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,e===void 0&&(e=4096),t+n/e/10},K.prototype.skip=function(e,t){t===void 0&&(t=1),this.relativeOffset+=Le[e]*t},K.prototype.parseULongList=function(e){e===void 0&&(e=this.parseULong());let t=Array(e),n=this.data,r=this.offset+this.relativeOffset;for(let i=0;i<e;i++)t[i]=n.getUint32(r),r+=4;return this.relativeOffset+=e*4,t},K.prototype.parseOffset16List=K.prototype.parseUShortList=function(e){e===void 0&&(e=this.parseUShort());let t=Array(e),n=this.data,r=this.offset+this.relativeOffset;for(let i=0;i<e;i++)t[i]=n.getUint16(r),r+=2;return this.relativeOffset+=e*2,t},K.prototype.parseShortList=function(e){let t=Array(e),n=this.data,r=this.offset+this.relativeOffset;for(let i=0;i<e;i++)t[i]=n.getInt16(r),r+=2;return this.relativeOffset+=e*2,t},K.prototype.parseByteList=function(e){let t=Array(e),n=this.data,r=this.offset+this.relativeOffset;for(let i=0;i<e;i++)t[i]=n.getUint8(r++);return this.relativeOffset+=e,t},K.prototype.parseList=function(e,t){t||(t=e,e=this.parseUShort());let n=Array(e);for(let r=0;r<e;r++)n[r]=t.call(this);return n},K.prototype.parseList32=function(e,t){t||(t=e,e=this.parseULong());let n=Array(e);for(let r=0;r<e;r++)n[r]=t.call(this);return n},K.prototype.parseRecordList=function(e,t){t||(t=e,e=this.parseUShort());let n=Array(e),r=Object.keys(t);for(let i=0;i<e;i++){let e={};for(let n=0;n<r.length;n++){let i=r[n];e[i]=t[i].call(this)}n[i]=e}return n},K.prototype.parseRecordList32=function(e,t){t||(t=e,e=this.parseULong());let n=Array(e),r=Object.keys(t);for(let i=0;i<e;i++){let e={};for(let n=0;n<r.length;n++){let i=r[n];e[i]=t[i].call(this)}n[i]=e}return n},K.prototype.parseTupleRecords=function(e,t){let n=[];for(let r=0;r<e;r++){let e=[];for(let n=0;n<t;n++)e.push(this.parseF2Dot14());n.push(e)}return n},K.prototype.parseStruct=function(e){if(typeof e==`function`)return e.call(this);{let t=Object.keys(e),n={};for(let r=0;r<t.length;r++){let i=t[r];n[i]=e[i].call(this)}return n}},K.prototype.parseValueRecord=function(e){if(e===void 0&&(e=this.parseUShort()),e===0)return;let t={};return e&1&&(t.xPlacement=this.parseShort()),e&2&&(t.yPlacement=this.parseShort()),e&4&&(t.xAdvance=this.parseShort()),e&8&&(t.yAdvance=this.parseShort()),e&16&&(t.xPlaDevice=void 0,this.parseShort()),e&32&&(t.yPlaDevice=void 0,this.parseShort()),e&64&&(t.xAdvDevice=void 0,this.parseShort()),e&128&&(t.yAdvDevice=void 0,this.parseShort()),t},K.prototype.parseValueRecordList=function(){let e=this.parseUShort(),t=this.parseUShort(),n=Array(t);for(let r=0;r<t;r++)n[r]=this.parseValueRecord(e);return n},K.prototype.parsePointer=function(e){let t=this.parseOffset16();if(t>0)return new K(this.data,this.offset+t).parseStruct(e)},K.prototype.parsePointer32=function(e){let t=this.parseOffset32();if(t>0)return new K(this.data,this.offset+t).parseStruct(e)},K.prototype.parseListOfLists=function(e){let t=this.parseOffset16List(),n=t.length,r=this.relativeOffset,i=Array(n);for(let r=0;r<n;r++){let n=t[r];if(n===0)i[r]=void 0;else if(this.relativeOffset=n,e){let t=this.parseOffset16List(),a=Array(t.length);for(let r=0;r<t.length;r++)this.relativeOffset=n+t[r],a[r]=e.call(this);i[r]=a}else i[r]=this.parseUShortList()}return this.relativeOffset=r,i},K.prototype.parseCoverage=function(){let e=this.offset+this.relativeOffset,t=this.parseUShort(),n=this.parseUShort();if(t===1)return{format:1,glyphs:this.parseUShortList(n)};if(t===2){let e=Array(n);for(let t=0;t<n;t++)e[t]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:e}}throw Error(`0x`+e.toString(16)+`: Coverage format must be 1 or 2.`)},K.prototype.parseClassDef=function(){let e=this.offset+this.relativeOffset,t=this.parseUShort();return t===1?{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()}:t===2?{format:2,ranges:this.parseRecordList({start:K.uShort,end:K.uShort,classId:K.uShort})}:(console.warn(`0x${e.toString(16)}: This font file uses an invalid ClassDef format of ${t}. It might be corrupted and should be reacquired if it doesn't display as intended.`),{format:t})},K.list=function(e,t){return function(){return this.parseList(e,t)}},K.list32=function(e,t){return function(){return this.parseList32(e,t)}},K.recordList=function(e,t){return function(){return this.parseRecordList(e,t)}},K.recordList32=function(e,t){return function(){return this.parseRecordList32(e,t)}},K.pointer=function(e){return function(){return this.parsePointer(e)}},K.pointer32=function(e){return function(){return this.parsePointer32(e)}},K.tag=K.prototype.parseTag,K.byte=K.prototype.parseByte,K.uShort=K.offset16=K.prototype.parseUShort,K.uShortList=K.prototype.parseUShortList,K.uInt24=K.prototype.parseUInt24,K.uLong=K.offset32=K.prototype.parseULong,K.uLongList=K.prototype.parseULongList,K.fixed=K.prototype.parseFixed,K.f2Dot14=K.prototype.parseF2Dot14,K.struct=K.prototype.parseStruct,K.coverage=K.prototype.parseCoverage,K.classDef=K.prototype.parseClassDef;var ze={reserved:K.uShort,reqFeatureIndex:K.uShort,featureIndexes:K.uShortList};K.prototype.parseScriptList=function(){return this.parsePointer(K.recordList({tag:K.tag,script:K.pointer({defaultLangSys:K.pointer(ze),langSysRecords:K.recordList({tag:K.tag,langSys:K.pointer(ze)})})}))||[]},K.prototype.parseFeatureList=function(){return this.parsePointer(K.recordList({tag:K.tag,feature:K.pointer({featureParams:K.offset16,lookupListIndexes:K.uShortList})}))||[]},K.prototype.parseLookupList=function(e){return this.parsePointer(K.list(K.pointer(function(){let t=this.parseUShort();R.argument(1<=t&&t<=9,`GPOS/GSUB lookup type `+t+` unknown.`);let n=this.parseUShort(),r=n&16;return{lookupType:t,lookupFlag:n,subtables:this.parseList(K.pointer(e[t])),markFilteringSet:r?this.parseUShort():void 0}})))||[]},K.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){let e=this.parseUShort(),t=this.parseUShort();return R.argument(e===1&&t<1,`GPOS/GSUB feature variations table unknown.`),this.parseRecordList32({conditionSetOffset:K.offset32,featureTableSubstitutionOffset:K.offset32})})||[]},K.prototype.parseVariationStore=function(){let e=this.relativeOffset,t=this.parseUShort(),n={itemVariationStore:this.parseItemVariationStore()};return this.relativeOffset=e+t+2,n},K.prototype.parseItemVariationStore=function(){let e=this.relativeOffset,t={format:this.parseUShort(),variationRegions:[],itemVariationSubtables:[]},n=this.parseOffset32(),r=this.parseUShort(),i=this.parseULongList(r);this.relativeOffset=e+n,t.variationRegions=this.parseVariationRegionList();for(let n=0;n<r;n++){let r=i[n];this.relativeOffset=e+r,t.itemVariationSubtables.push(this.parseItemVariationSubtable())}return t},K.prototype.parseVariationRegionList=function(){let e=this.parseUShort(),t=this.parseUShort();return this.parseRecordList(t,{regionAxes:K.recordList(e,{startCoord:K.f2Dot14,peakCoord:K.f2Dot14,endCoord:K.f2Dot14})})},K.prototype.parseItemVariationSubtable=function(){let e=this.parseUShort(),t=this.parseUShort(),n=this.parseUShortList(),r=n.length;return{regionIndexes:n,deltaSets:e&&r?this.parseDeltaSets(e,t,r):[]}},K.prototype.parseDeltaSetIndexMap=function(){let e=this.parseByte(),t=this.parseByte(),n=[],r=0;switch(e){case 0:r=this.parseUShort();break;case 1:r=this.parseULong();break;default:console.error(`unsupported DeltaSetIndexMap format ${e}`)}if(!r)return{format:e,entryFormat:t};let i=(t&Re.INNER_INDEX_BIT_COUNT_MASK)+1,a=((t&Re.MAP_ENTRY_SIZE_MASK)>>4)+1;for(let e=0;e<r;e++){let e;if(a===1)e=this.parseByte();else if(a===2)e=this.parseUShort();else if(a===3)e=this.parseUInt24();else if(a===4)e=this.parseULong();else throw Error(`Invalid entry size of ${a}`);let t=e>>i,r=e&(1<<i)-1;n.push({outerIndex:t,innerIndex:r})}return{format:e,entryFormat:t,map:n}},K.prototype.parseDeltaSets=function(e,t,n){let r=Array.from({length:e},()=>[]),i=t&Re.LONG_WORDS,a=t&Re.WORD_DELTA_COUNT_MASK;if(a>n)throw Error(`wordCount must be less than or equal to regionIndexCount`);let o=(i?this.parseLong:this.parseShort).bind(this),s=(i?this.parseShort:this.parseChar).bind(this);for(let t=0;t<e;t++)for(let e=0;e<n;e++)e<a?r[t].push(o()):r[t].push(s());return r},K.prototype.parseTupleVariationStoreList=function(e,t,n){let r=this.parseUShort(),i=this.parseUShort()&1,a=this.parseOffset32(),o=(i?this.parseULong:this.parseUShort).bind(this),s={},c=o();i||(c*=2);let l;for(let u=0;u<r;u++){l=o(),i||(l*=2);let r=l-c;s[u]=r?this.parseTupleVariationStore(a+c,e,t,n,u):void 0,c=l}return s},K.prototype.parseTupleVariationStore=function(e,t,n,r,i){let a=this.relativeOffset;this.relativeOffset=e,n===`cvar`&&(this.relativeOffset+=4);let o=this.parseUShort(),s=!!(o&Re.SHARED_POINT_NUMBERS),c=o&Re.COUNT_MASK,l=this.parseOffset16(),u=[],d=[];for(let e=0;e<c;e++){let e=this.parseTupleVariationHeader(t,n);u.push(e)}this.relativeOffset!==e+l&&(console.warn(`Unexpected offset after parsing tuple variation headers! Expected ${e+l}, actually ${this.relativeOffset}`),this.relativeOffset=e+l),s&&(d=this.parsePackedPointNumbers());let f=this.relativeOffset;for(let e=0;e<c;e++){let t=u[e];t.privatePoints=[],this.relativeOffset=f,n===`cvar`&&!t.peakTuple&&console.warn(`An embedded peak tuple is required in TupleVariationHeaders for the cvar table.`),t.flags.privatePointNumbers&&(t.privatePoints=this.parsePackedPointNumbers()),delete t.flags;let a=this.offset,o=this.relativeOffset,s=e=>{let s,c,l=()=>{let e=0;if(n===`gvar`){if(e=t.privatePoints.length||d.length,!e){let t=r.get(i);t.path,e=t.points.length,e+=4}}else n===`cvar`&&(e=r.length);this.offset=a,this.relativeOffset=o,s=this.parsePackedDeltas(e),n===`gvar`&&(c=this.parsePackedDeltas(e))};return{configurable:!0,get:function(){return s===void 0&&l(),e===`deltasY`?c:s},set:function(t){s===void 0&&l(),e===`deltasY`?c=t:s=t}}};Object.defineProperty(t,"deltas",s.call(this,`deltas`)),n===`gvar`&&Object.defineProperty(t,"deltasY",s.call(this,`deltasY`)),f+=t.variationDataSize,delete t.variationDataSize}this.relativeOffset=a;let p={headers:u};return p.sharedPoints=d,p},K.prototype.parseTupleVariationHeader=function(e,t){let n=this.parseUShort(),r=this.parseUShort(),i=!!(r&Re.EMBEDDED_PEAK_TUPLE),a=!!(r&Re.INTERMEDIATE_REGION),o=!!(r&Re.PRIVATE_POINT_NUMBERS),s=i?void 0:r&Re.TUPLE_INDEX_MASK,c={variationDataSize:n,peakTuple:i?this.parseTupleRecords(1,e)[0]:void 0,intermediateStartTuple:a?this.parseTupleRecords(1,e)[0]:void 0,intermediateEndTuple:a?this.parseTupleRecords(1,e)[0]:void 0,flags:{embeddedPeakTuple:i,intermediateRegion:a,privatePointNumbers:o}};return t===`gvar`&&(c.sharedTupleRecordsIndex=s),c},K.prototype.parsePackedPointNumbers=function(){let e=this.parseByte(),t=[],n=e;if(e>=128){let t=this.parseByte();n=(e&Re.POINT_RUN_COUNT_MASK)<<8|t}let r=0;for(;t.length<n;){let e=this.parseByte(),i=!!(e&Re.POINTS_ARE_WORDS),a=(e&Re.POINT_RUN_COUNT_MASK)+1;for(let e=0;e<a&&t.length<n;e++){let e;e=i?this.parseUShort():this.parseByte(),r+=e,t.push(r)}}return t},K.prototype.parsePackedDeltas=function(e){let t=[];for(;t.length<e;){let n=this.parseByte(),r=!!(n&Re.DELTAS_ARE_ZERO),i=!!(n&Re.DELTAS_ARE_WORDS),a=(n&Re.DELTA_RUN_COUNT_MASK)+1;for(let n=0;n<a&&t.length<e;n++)r?t.push(0):i?t.push(this.parseShort()):t.push(this.parseChar())}return t};var q={getByte:Ee,getCard8:Ee,getUShort:De,getCard16:De,getShort:Oe,getUInt24:ke,getULong:Ae,getFixed:Me,getTag:Ne,getOffset:Pe,getBytes:Fe,bytesToString:Ie,Parser:K},Be=[`copyright`,`fontFamily`,`fontSubfamily`,`uniqueID`,`fullName`,`version`,`postScriptName`,`trademark`,`manufacturer`,`designer`,`description`,`manufacturerURL`,`designerURL`,`license`,`licenseURL`,`reserved`,`preferredFamily`,`preferredSubfamily`,`compatibleFullName`,`sampleText`,`postScriptFindFontName`,`wwsFamily`,`wwsSubfamily`],Ve={0:`en`,1:`fr`,2:`de`,3:`it`,4:`nl`,5:`sv`,6:`es`,7:`da`,8:`pt`,9:`no`,10:`he`,11:`ja`,12:`ar`,13:`fi`,14:`el`,15:`is`,16:`mt`,17:`tr`,18:`hr`,19:`zh-Hant`,20:`ur`,21:`hi`,22:`th`,23:`ko`,24:`lt`,25:`pl`,26:`hu`,27:`es`,28:`lv`,29:`se`,30:`fo`,31:`fa`,32:`ru`,33:`zh`,34:`nl-BE`,35:`ga`,36:`sq`,37:`ro`,38:`cz`,39:`sk`,40:`si`,41:`yi`,42:`sr`,43:`mk`,44:`bg`,45:`uk`,46:`be`,47:`uz`,48:`kk`,49:`az-Cyrl`,50:`az-Arab`,51:`hy`,52:`ka`,53:`mo`,54:`ky`,55:`tg`,56:`tk`,57:`mn-CN`,58:`mn`,59:`ps`,60:`ks`,61:`ku`,62:`sd`,63:`bo`,64:`ne`,65:`sa`,66:`mr`,67:`bn`,68:`as`,69:`gu`,70:`pa`,71:`or`,72:`ml`,73:`kn`,74:`ta`,75:`te`,76:`si`,77:`my`,78:`km`,79:`lo`,80:`vi`,81:`id`,82:`tl`,83:`ms`,84:`ms-Arab`,85:`am`,86:`ti`,87:`om`,88:`so`,89:`sw`,90:`rw`,91:`rn`,92:`ny`,93:`mg`,94:`eo`,128:`cy`,129:`eu`,130:`ca`,131:`la`,132:`qu`,133:`gn`,134:`ay`,135:`tt`,136:`ug`,137:`dz`,138:`jv`,139:`su`,140:`gl`,141:`af`,142:`br`,143:`iu`,144:`gd`,145:`gv`,146:`ga`,147:`to`,148:`el-polyton`,149:`kl`,150:`az`,151:`nn`},He={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},Ue={1078:`af`,1052:`sq`,1156:`gsw`,1118:`am`,5121:`ar-DZ`,15361:`ar-BH`,3073:`ar`,2049:`ar-IQ`,11265:`ar-JO`,13313:`ar-KW`,12289:`ar-LB`,4097:`ar-LY`,6145:`ary`,8193:`ar-OM`,16385:`ar-QA`,1025:`ar-SA`,10241:`ar-SY`,7169:`aeb`,14337:`ar-AE`,9217:`ar-YE`,1067:`hy`,1101:`as`,2092:`az-Cyrl`,1068:`az`,1133:`ba`,1069:`eu`,1059:`be`,2117:`bn`,1093:`bn-IN`,8218:`bs-Cyrl`,5146:`bs`,1150:`br`,1026:`bg`,1027:`ca`,3076:`zh-HK`,5124:`zh-MO`,2052:`zh`,4100:`zh-SG`,1028:`zh-TW`,1155:`co`,1050:`hr`,4122:`hr-BA`,1029:`cs`,1030:`da`,1164:`prs`,1125:`dv`,2067:`nl-BE`,1043:`nl`,3081:`en-AU`,10249:`en-BZ`,4105:`en-CA`,9225:`en-029`,16393:`en-IN`,6153:`en-IE`,8201:`en-JM`,17417:`en-MY`,5129:`en-NZ`,13321:`en-PH`,18441:`en-SG`,7177:`en-ZA`,11273:`en-TT`,2057:`en-GB`,1033:`en`,12297:`en-ZW`,1061:`et`,1080:`fo`,1124:`fil`,1035:`fi`,2060:`fr-BE`,3084:`fr-CA`,1036:`fr`,5132:`fr-LU`,6156:`fr-MC`,4108:`fr-CH`,1122:`fy`,1110:`gl`,1079:`ka`,3079:`de-AT`,1031:`de`,5127:`de-LI`,4103:`de-LU`,2055:`de-CH`,1032:`el`,1135:`kl`,1095:`gu`,1128:`ha`,1037:`he`,1081:`hi`,1038:`hu`,1039:`is`,1136:`ig`,1057:`id`,1117:`iu`,2141:`iu-Latn`,2108:`ga`,1076:`xh`,1077:`zu`,1040:`it`,2064:`it-CH`,1041:`ja`,1099:`kn`,1087:`kk`,1107:`km`,1158:`quc`,1159:`rw`,1089:`sw`,1111:`kok`,1042:`ko`,1088:`ky`,1108:`lo`,1062:`lv`,1063:`lt`,2094:`dsb`,1134:`lb`,1071:`mk`,2110:`ms-BN`,1086:`ms`,1100:`ml`,1082:`mt`,1153:`mi`,1146:`arn`,1102:`mr`,1148:`moh`,1104:`mn`,2128:`mn-CN`,1121:`ne`,1044:`nb`,2068:`nn`,1154:`oc`,1096:`or`,1123:`ps`,1045:`pl`,1046:`pt`,2070:`pt-PT`,1094:`pa`,1131:`qu-BO`,2155:`qu-EC`,3179:`qu`,1048:`ro`,1047:`rm`,1049:`ru`,9275:`smn`,4155:`smj-NO`,5179:`smj`,3131:`se-FI`,1083:`se`,2107:`se-SE`,8251:`sms`,6203:`sma-NO`,7227:`sms`,1103:`sa`,7194:`sr-Cyrl-BA`,3098:`sr`,6170:`sr-Latn-BA`,2074:`sr-Latn`,1132:`nso`,1074:`tn`,1115:`si`,1051:`sk`,1060:`sl`,11274:`es-AR`,16394:`es-BO`,13322:`es-CL`,9226:`es-CO`,5130:`es-CR`,7178:`es-DO`,12298:`es-EC`,17418:`es-SV`,4106:`es-GT`,18442:`es-HN`,2058:`es-MX`,19466:`es-NI`,6154:`es-PA`,15370:`es-PY`,10250:`es-PE`,20490:`es-PR`,3082:`es`,1034:`es`,21514:`es-US`,14346:`es-UY`,8202:`es-VE`,2077:`sv-FI`,1053:`sv`,1114:`syr`,1064:`tg`,2143:`tzm`,1097:`ta`,1092:`tt`,1098:`te`,1054:`th`,1105:`bo`,1055:`tr`,1090:`tk`,1152:`ug`,1058:`uk`,1070:`hsb`,1056:`ur`,2115:`uz-Cyrl`,1091:`uz`,1066:`vi`,1106:`cy`,1160:`wo`,1157:`sah`,1144:`ii`,1130:`yo`};function We(e,t,n){switch(e){case 0:if(t===65535)return`und`;if(n)return n[t];break;case 1:return Ve[t];case 3:return Ue[t]}}var Ge=`utf-16`,Ke={0:`macintosh`,1:`x-mac-japanese`,2:`x-mac-chinesetrad`,3:`x-mac-korean`,6:`x-mac-greek`,7:`x-mac-cyrillic`,9:`x-mac-devanagai`,10:`x-mac-gurmukhi`,11:`x-mac-gujarati`,12:`x-mac-oriya`,13:`x-mac-bengali`,14:`x-mac-tamil`,15:`x-mac-telugu`,16:`x-mac-kannada`,17:`x-mac-malayalam`,18:`x-mac-sinhalese`,19:`x-mac-burmese`,20:`x-mac-khmer`,21:`x-mac-thai`,22:`x-mac-lao`,23:`x-mac-georgian`,24:`x-mac-armenian`,25:`x-mac-chinesesimp`,26:`x-mac-tibetan`,27:`x-mac-mongolian`,28:`x-mac-ethiopic`,29:`x-mac-ce`,30:`x-mac-vietnamese`,31:`x-mac-extarabic`},qe={15:`x-mac-icelandic`,17:`x-mac-turkish`,18:`x-mac-croatian`,24:`x-mac-ce`,25:`x-mac-ce`,26:`x-mac-ce`,27:`x-mac-ce`,28:`x-mac-ce`,30:`x-mac-icelandic`,37:`x-mac-romanian`,38:`x-mac-ce`,39:`x-mac-ce`,40:`x-mac-ce`,143:`x-mac-inuit`,146:`x-mac-gaelic`};function Je(e,t,n){switch(e){case 0:return Ge;case 1:return qe[n]||Ke[t];case 3:if(t===1||t===10)return Ge}}var Ye={0:`unicode`,1:`macintosh`,2:`reserved`,3:`windows`};function Xe(e){return Ye[e]}function Ze(e,t,n){let r={},i=new q.Parser(e,t),a=i.parseUShort(),o=i.parseUShort(),s=i.offset+i.parseUShort();for(let t=0;t<o;t++){let t=i.parseUShort(),a=i.parseUShort(),o=i.parseUShort(),c=i.parseUShort(),l=Be[c]||c,u=i.parseUShort(),d=i.parseUShort(),f=We(t,o,n),p=Je(t,a,o),m=Xe(t);if(p!==void 0&&f!==void 0&&m!==void 0){let t;if(t=p===Ge?le.UTF16(e,s+d,u):le.MACSTRING(e,s+d,u,p),t){let e=r[m];e===void 0&&(e=r[m]={});let n=e[l];n===void 0&&(n=e[l]={}),n[f]=t}}}return a===1&&i.parseUShort(),r}function Qe(e){let t={};for(let n in e)t[e[n]]=parseInt(n);return t}function $e(e,t,n,r,i,a){return new G.Record(`NameRecord`,[{name:`platformID`,type:`USHORT`,value:e},{name:`encodingID`,type:`USHORT`,value:t},{name:`languageID`,type:`USHORT`,value:n},{name:`nameID`,type:`USHORT`,value:r},{name:`length`,type:`USHORT`,value:i},{name:`offset`,type:`USHORT`,value:a}])}function et(e,t){let n=e.length,r=t.length-n+1;loop:for(let i=0;i<r;i++)for(;i<r;i++){for(let r=0;r<n;r++)if(t[i+r]!==e[r])continue loop;return i}return-1}function tt(e,t){let n=et(e,t);if(n<0){n=t.length;let r=0,i=e.length;for(;r<i;++r)t.push(e[r])}return n}function nt(e,t){let n=Qe(Ye),r=Qe(Ve),i=Qe(Ue),a=[],o=[];for(let s in e){let c,l=[],u={},d=Qe(Be),f=n[s];for(let t in e[s]){let n=d[t];if(n===void 0&&(n=t),c=parseInt(n),isNaN(c))throw Error(`Name table entry "`+t+`" does not exist, see nameTableNames for complete list.`);u[c]=e[s][t],l.push(c)}for(let e=0;e<l.length;e++){c=l[e];let n=u[c];for(let e in n){let s=n[e];if(f===1||f===0){let n=r[e],i=He[n],l=Je(f,i,n),u=B.MACSTRING(s,l);if(f===0&&(n=t.indexOf(e),n<0&&(n=t.length,t.push(e)),i=4,u=B.UTF16(s)),u!==void 0){let e=tt(u,o);a.push($e(f,i,n,c,u.length,e))}}if(f===3){let t=i[e];if(t!==void 0){let e=B.UTF16(s),n=tt(e,o);a.push($e(3,1,t,c,e.length,n))}}}}}a.sort(function(e,t){return e.platformID-t.platformID||e.encodingID-t.encodingID||e.languageID-t.languageID||e.nameID-t.nameID});let s=new G.Table(`name`,[{name:`format`,type:`USHORT`,value:0},{name:`count`,type:`USHORT`,value:a.length},{name:`stringOffset`,type:`USHORT`,value:6+a.length*12}]);for(let e=0;e<a.length;e++)s.fields.push({name:`record_`+e,type:`RECORD`,value:a[e]});return s.fields.push({name:`strings`,type:`LITERAL`,value:o}),s}function rt(e,t,n=[]){if(t<256&&t in Be){if(n.length&&!n.includes(parseInt(t)))return;t=Be[t]}for(let n in e)for(let r in e[n])if(r===t||parseInt(r)===t)return e[n][r]}var it={parse:Ze,make:nt,getNameByID:rt};function at(e,t,n,r){e.length=t.parseUShort(),e.language=t.parseUShort()-1;let i=t.parseByteList(e.length),a=Object.assign({},i),o=U[Je(n,r,e.language)];for(let e=0;e<o.length;e++)a[o.charCodeAt(e)]=i[128+e];e.glyphIndexMap=a}function ot(e,t,n){t.parseUShort(),e.length=t.parseULong(),e.language=t.parseULong();let r;e.groupCount=r=t.parseULong(),e.glyphIndexMap={};for(let i=0;i<r;i+=1){let r=t.parseULong(),i=t.parseULong(),a=t.parseULong();for(let t=r;t<=i;t+=1)e.glyphIndexMap[t]=a,n===12&&a++}}function st(e,t,n,r,i){e.length=t.parseUShort(),e.language=t.parseUShort();let a;e.segCount=a=t.parseUShort()>>1,t.skip(`uShort`,3),e.glyphIndexMap={};let o=new q.Parser(n,r+i+14),s=new q.Parser(n,r+i+16+a*2),c=new q.Parser(n,r+i+16+a*4),l=new q.Parser(n,r+i+16+a*6),u=r+i+16+a*8;for(let t=0;t<a-1;t+=1){let t,r=o.parseUShort(),i=s.parseUShort(),a=c.parseShort(),d=l.parseUShort();for(let o=i;o<=r;o+=1)d===0?t=o+a&65535:(u=l.offset+l.relativeOffset-2,u+=d,u+=(o-i)*2,t=q.getUShort(n,u),t!==0&&(t=t+a&65535)),e.glyphIndexMap[o]=t}}function ct(e,t){let n={};t.skip(`uLong`);let r=t.parseULong();for(let e=0;e<r;e+=1){let e=t.parseUInt24(),r={varSelector:e},i=t.parseOffset32(),a=t.parseOffset32(),o=t.relativeOffset;i&&(t.relativeOffset=i,r.defaultUVS=t.parseStruct({ranges:function(){return t.parseRecordList32({startUnicodeValue:t.parseUInt24,additionalCount:t.parseByte})}})),a&&(t.relativeOffset=a,r.nonDefaultUVS=t.parseStruct({uvsMappings:function(){let e={},n=t.parseRecordList32({unicodeValue:t.parseUInt24,glyphID:t.parseUShort});for(let t=0;t<n.length;t+=1)e[n[t].unicodeValue]=n[t];return e}})),n[e]=r,t.relativeOffset=o}e.varSelectorList=n}function lt(e,t){let n={};n.version=q.getUShort(e,t),R.argument(n.version===0,`cmap table version should be 0.`),n.numTables=q.getUShort(e,t+2);let r=null,i=-1,a=-1,o=null,s=null,c=[0,1,2,3,4,6],l=[0,1,10];for(let u=n.numTables-1;u>=0;--u)if(o=q.getUShort(e,t+4+u*8),s=q.getUShort(e,t+4+u*8+2),o===3&&l.includes(s)||o===0&&c.includes(s)||o===1&&s===0){if(a>0)continue;if(a=q.getULong(e,t+4+u*8+4),r)break}else if(o===0&&s===5){if(i=q.getULong(e,t+4+u*8+4),r=new q.Parser(e,t+i),r.parseUShort()!==14)i=-1,r=null;else if(a>0)break}if(a===-1)throw Error(`No valid cmap sub-tables found.`);let u=new q.Parser(e,t+a);if(n.format=u.parseUShort(),n.format===0)at(n,u,o,s);else if(n.format===12||n.format===13)ot(n,u,n.format);else if(n.format===4)st(n,u,e,t,a);else throw Error(`Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format `+n.format+`, platformId `+o+`, encodingId `+s+`).`);return r&&ct(n,r),n}function ut(e,t,n){e.segments.push({end:t,start:t,delta:-(t-n),offset:0,glyphIndex:n})}function dt(e){e.segments.push({end:65535,start:65535,delta:1,offset:0})}function ft(e){if(e.length===0)return e;let t=[e[0]];for(let n=1;n<e.length;n++){let r=t[t.length-1],i=e[n];r.end+1===i.start&&r.delta===i.delta&&i.end!==65535?r.end=i.end:t.push(i)}return t}function pt(e){let t=!0,n;for(n=e.length-1;n>0;--n)if(e.get(n).unicode>65535){t=!1;break}let r=[{name:`version`,type:`USHORT`,value:0},{name:`numTables`,type:`USHORT`,value:t?1:2},{name:`platformID`,type:`USHORT`,value:3},{name:`encodingID`,type:`USHORT`,value:1},{name:`offset`,type:`ULONG`,value:t?12:20}];t||r.push({name:`cmap12PlatformID`,type:`USHORT`,value:3},{name:`cmap12EncodingID`,type:`USHORT`,value:10},{name:`cmap12Offset`,type:`ULONG`,value:0}),r.push({name:`format`,type:`USHORT`,value:4},{name:`cmap4Length`,type:`USHORT`,value:0},{name:`language`,type:`USHORT`,value:0},{name:`segCountX2`,type:`USHORT`,value:0},{name:`searchRange`,type:`USHORT`,value:0},{name:`entrySelector`,type:`USHORT`,value:0},{name:`rangeShift`,type:`USHORT`,value:0});let i=new G.Table(`cmap`,r);for(i.segments=[],n=0;n<e.length;n+=1){let t=e.get(n);for(let e=0;e<t.unicodes.length;e+=1)ut(i,t.unicodes[e],n)}i.segments.sort(function(e,t){return e.start-t.start}),i.segments=ft(i.segments),dt(i);let a=i.segments.length,o=0,s=[],c=[],l=[],u=[],d=[],f=[];for(n=0;n<a;n+=1){let e=i.segments[n];e.end<=65535&&e.start<=65535?(s.push({name:`end_`+n,type:`USHORT`,value:e.end}),c.push({name:`start_`+n,type:`USHORT`,value:e.start}),l.push({name:`idDelta_`+n,type:`SHORT`,value:e.delta}),u.push({name:`idRangeOffset_`+n,type:`USHORT`,value:e.offset}),e.glyphId!==void 0&&d.push({name:`glyph_`+n,type:`USHORT`,value:e.glyphId})):o+=1,!t&&e.glyphIndex!==void 0&&(f.push({name:`cmap12Start_`+n,type:`ULONG`,value:e.start}),f.push({name:`cmap12End_`+n,type:`ULONG`,value:e.end}),f.push({name:`cmap12Glyph_`+n,type:`ULONG`,value:e.glyphIndex}))}i.segCountX2=(a-o)*2,i.searchRange=2**Math.floor(Math.log(a-o)/Math.log(2))*2,i.entrySelector=Math.log(i.searchRange/2)/Math.log(2),i.rangeShift=i.segCountX2-i.searchRange;for(let e=0;e<s.length;e++)i.fields.push(s[e]);i.fields.push({name:`reservedPad`,type:`USHORT`,value:0});for(let e=0;e<c.length;e++)i.fields.push(c[e]);for(let e=0;e<l.length;e++)i.fields.push(l[e]);for(let e=0;e<u.length;e++)i.fields.push(u[e]);for(let e=0;e<d.length;e++)i.fields.push(d[e]);if(i.cmap4Length=14+s.length*2+2+c.length*2+l.length*2+u.length*2+d.length*2,!t){let e=16+f.length*4;i.cmap12Offset=20+i.cmap4Length,i.fields.push({name:`cmap12Format`,type:`USHORT`,value:12},{name:`cmap12Reserved`,type:`USHORT`,value:0},{name:`cmap12Length`,type:`ULONG`,value:e},{name:`cmap12Language`,type:`ULONG`,value:0},{name:`cmap12nGroups`,type:`ULONG`,value:f.length/3});for(let e=0;e<f.length;e++)i.fields.push(f[e])}return i}var mt={parse:lt,make:pt},ht=/* @__PURE__ */ `.notdef,space,exclam,quotedbl,numbersign,dollar,percent,ampersand,quoteright,parenleft,parenright,asterisk,plus,comma,hyphen,period,slash,zero,one,two,three,four,five,six,seven,eight,nine,colon,semicolon,less,equal,greater,question,at,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,bracketleft,backslash,bracketright,asciicircum,underscore,quoteleft,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,braceleft,bar,braceright,asciitilde,exclamdown,cent,sterling,fraction,yen,florin,section,currency,quotesingle,quotedblleft,guillemotleft,guilsinglleft,guilsinglright,fi,fl,endash,dagger,daggerdbl,periodcentered,paragraph,bullet,quotesinglbase,quotedblbase,quotedblright,guillemotright,ellipsis,perthousand,questiondown,grave,acute,circumflex,tilde,macron,breve,dotaccent,dieresis,ring,cedilla,hungarumlaut,ogonek,caron,emdash,AE,ordfeminine,Lslash,Oslash,OE,ordmasculine,ae,dotlessi,lslash,oslash,oe,germandbls,onesuperior,logicalnot,mu,trademark,Eth,onehalf,plusminus,Thorn,onequarter,divide,brokenbar,degree,thorn,threequarters,twosuperior,registered,minus,eth,multiply,threesuperior,copyright,Aacute,Acircumflex,Adieresis,Agrave,Aring,Atilde,Ccedilla,Eacute,Ecircumflex,Edieresis,Egrave,Iacute,Icircumflex,Idieresis,Igrave,Ntilde,Oacute,Ocircumflex,Odieresis,Ograve,Otilde,Scaron,Uacute,Ucircumflex,Udieresis,Ugrave,Yacute,Ydieresis,Zcaron,aacute,acircumflex,adieresis,agrave,aring,atilde,ccedilla,eacute,ecircumflex,edieresis,egrave,iacute,icircumflex,idieresis,igrave,ntilde,oacute,ocircumflex,odieresis,ograve,otilde,scaron,uacute,ucircumflex,udieresis,ugrave,yacute,ydieresis,zcaron,exclamsmall,Hungarumlautsmall,dollaroldstyle,dollarsuperior,ampersandsmall,Acutesmall,parenleftsuperior,parenrightsuperior,266 ff,onedotenleader,zerooldstyle,oneoldstyle,twooldstyle,threeoldstyle,fouroldstyle,fiveoldstyle,sixoldstyle,sevenoldstyle,eightoldstyle,nineoldstyle,commasuperior,threequartersemdash,periodsuperior,questionsmall,asuperior,bsuperior,centsuperior,dsuperior,esuperior,isuperior,lsuperior,msuperior,nsuperior,osuperior,rsuperior,ssuperior,tsuperior,ff,ffi,ffl,parenleftinferior,parenrightinferior,Circumflexsmall,hyphensuperior,Gravesmall,Asmall,Bsmall,Csmall,Dsmall,Esmall,Fsmall,Gsmall,Hsmall,Ismall,Jsmall,Ksmall,Lsmall,Msmall,Nsmall,Osmall,Psmall,Qsmall,Rsmall,Ssmall,Tsmall,Usmall,Vsmall,Wsmall,Xsmall,Ysmall,Zsmall,colonmonetary,onefitted,rupiah,Tildesmall,exclamdownsmall,centoldstyle,Lslashsmall,Scaronsmall,Zcaronsmall,Dieresissmall,Brevesmall,Caronsmall,Dotaccentsmall,Macronsmall,figuredash,hypheninferior,Ogoneksmall,Ringsmall,Cedillasmall,questiondownsmall,oneeighth,threeeighths,fiveeighths,seveneighths,onethird,twothirds,zerosuperior,foursuperior,fivesuperior,sixsuperior,sevensuperior,eightsuperior,ninesuperior,zeroinferior,oneinferior,twoinferior,threeinferior,fourinferior,fiveinferior,sixinferior,seveninferior,eightinferior,nineinferior,centinferior,dollarinferior,periodinferior,commainferior,Agravesmall,Aacutesmall,Acircumflexsmall,Atildesmall,Adieresissmall,Aringsmall,AEsmall,Ccedillasmall,Egravesmall,Eacutesmall,Ecircumflexsmall,Edieresissmall,Igravesmall,Iacutesmall,Icircumflexsmall,Idieresissmall,Ethsmall,Ntildesmall,Ogravesmall,Oacutesmall,Ocircumflexsmall,Otildesmall,Odieresissmall,OEsmall,Oslashsmall,Ugravesmall,Uacutesmall,Ucircumflexsmall,Udieresissmall,Yacutesmall,Thornsmall,Ydieresissmall,001.000,001.001,001.002,001.003,Black,Bold,Book,Light,Medium,Regular,Roman,Semibold`.split(`,`),gt=/* @__PURE__ */ `.notdef,space,exclam,quotedbl,numbersign,dollar,percent,ampersand,quoteright,parenleft,parenright,asterisk,plus,comma,hyphen,period,slash,zero,one,two,three,four,five,six,seven,eight,nine,colon,semicolon,less,equal,greater,question,at,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,bracketleft,backslash,bracketright,asciicircum,underscore,quoteleft,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,braceleft,bar,braceright,asciitilde,exclamdown,cent,sterling,fraction,yen,florin,section,currency,quotesingle,quotedblleft,guillemotleft,guilsinglleft,guilsinglright,fi,fl,endash,dagger,daggerdbl,periodcentered,paragraph,bullet,quotesinglbase,quotedblbase,quotedblright,guillemotright,ellipsis,perthousand,questiondown,grave,acute,circumflex,tilde,macron,breve,dotaccent,dieresis,ring,cedilla,hungarumlaut,ogonek,caron,emdash,AE,ordfeminine,Lslash,Oslash,OE,ordmasculine,ae,dotlessi,lslash,oslash,oe,germandbls,onesuperior,logicalnot,mu,trademark,Eth,onehalf,plusminus,Thorn,onequarter,divide,brokenbar,degree,thorn,threequarters,twosuperior,registered,minus,eth,multiply,threesuperior,copyright,Aacute,Acircumflex,Adieresis,Agrave,Aring,Atilde,Ccedilla,Eacute,Ecircumflex,Edieresis,Egrave,Iacute,Icircumflex,Idieresis,Igrave,Ntilde,Oacute,Ocircumflex,Odieresis,Ograve,Otilde,Scaron,Uacute,Ucircumflex,Udieresis,Ugrave,Yacute,Ydieresis,Zcaron,aacute,acircumflex,adieresis,agrave,aring,atilde,ccedilla,eacute,ecircumflex,edieresis,egrave,iacute,icircumflex,idieresis,igrave,ntilde,oacute,ocircumflex,odieresis,ograve,otilde,scaron,uacute,ucircumflex,udieresis,ugrave,yacute,ydieresis,zcaron`.split(`,`),_t=/* @__PURE__ */ `.notdef,space,exclamsmall,Hungarumlautsmall,dollaroldstyle,dollarsuperior,ampersandsmall,Acutesmall,parenleftsuperior,parenrightsuperior,twodotenleader,onedotenleader,comma,hyphen,period,fraction,zerooldstyle,oneoldstyle,twooldstyle,threeoldstyle,fouroldstyle,fiveoldstyle,sixoldstyle,sevenoldstyle,eightoldstyle,nineoldstyle,colon,semicolon,commasuperior,threequartersemdash,periodsuperior,questionsmall,asuperior,bsuperior,centsuperior,dsuperior,esuperior,isuperior,lsuperior,msuperior,nsuperior,osuperior,rsuperior,ssuperior,tsuperior,ff,fi,fl,ffi,ffl,parenleftinferior,parenrightinferior,Circumflexsmall,hyphensuperior,Gravesmall,Asmall,Bsmall,Csmall,Dsmall,Esmall,Fsmall,Gsmall,Hsmall,Ismall,Jsmall,Ksmall,Lsmall,Msmall,Nsmall,Osmall,Psmall,Qsmall,Rsmall,Ssmall,Tsmall,Usmall,Vsmall,Wsmall,Xsmall,Ysmall,Zsmall,colonmonetary,onefitted,rupiah,Tildesmall,exclamdownsmall,centoldstyle,Lslashsmall,Scaronsmall,Zcaronsmall,Dieresissmall,Brevesmall,Caronsmall,Dotaccentsmall,Macronsmall,figuredash,hypheninferior,Ogoneksmall,Ringsmall,Cedillasmall,onequarter,onehalf,threequarters,questiondownsmall,oneeighth,threeeighths,fiveeighths,seveneighths,onethird,twothirds,zerosuperior,onesuperior,twosuperior,threesuperior,foursuperior,fivesuperior,sixsuperior,sevensuperior,eightsuperior,ninesuperior,zeroinferior,oneinferior,twoinferior,threeinferior,fourinferior,fiveinferior,sixinferior,seveninferior,eightinferior,nineinferior,centinferior,dollarinferior,periodinferior,commainferior,Agravesmall,Aacutesmall,Acircumflexsmall,Atildesmall,Adieresissmall,Aringsmall,AEsmall,Ccedillasmall,Egravesmall,Eacutesmall,Ecircumflexsmall,Edieresissmall,Igravesmall,Iacutesmall,Icircumflexsmall,Idieresissmall,Ethsmall,Ntildesmall,Ogravesmall,Oacutesmall,Ocircumflexsmall,Otildesmall,Odieresissmall,OEsmall,Oslashsmall,Ugravesmall,Uacutesmall,Ucircumflexsmall,Udieresissmall,Yacutesmall,Thornsmall,Ydieresissmall`.split(`,`),vt=/* @__PURE__ */ `.notdef,space,dollaroldstyle,dollarsuperior,parenleftsuperior,parenrightsuperior,twodotenleader,onedotenleader,comma,hyphen,period,fraction,zerooldstyle,oneoldstyle,twooldstyle,threeoldstyle,fouroldstyle,fiveoldstyle,sixoldstyle,sevenoldstyle,eightoldstyle,nineoldstyle,colon,semicolon,commasuperior,threequartersemdash,periodsuperior,asuperior,bsuperior,centsuperior,dsuperior,esuperior,isuperior,lsuperior,msuperior,nsuperior,osuperior,rsuperior,ssuperior,tsuperior,ff,fi,fl,ffi,ffl,parenleftinferior,parenrightinferior,hyphensuperior,colonmonetary,onefitted,rupiah,centoldstyle,figuredash,hypheninferior,onequarter,onehalf,threequarters,oneeighth,threeeighths,fiveeighths,seveneighths,onethird,twothirds,zerosuperior,onesuperior,twosuperior,threesuperior,foursuperior,fivesuperior,sixsuperior,sevensuperior,eightsuperior,ninesuperior,zeroinferior,oneinferior,twoinferior,threeinferior,fourinferior,fiveinferior,sixinferior,seveninferior,eightinferior,nineinferior,centinferior,dollarinferior,periodinferior,commainferior`.split(`,`),yt=/* @__PURE__ */ `................................space.exclam.quotedbl.numbersign.dollar.percent.ampersand.quoteright.parenleft.parenright.asterisk.plus.comma.hyphen.period.slash.zero.one.two.three.four.five.six.seven.eight.nine.colon.semicolon.less.equal.greater.question.at.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.bracketleft.backslash.bracketright.asciicircum.underscore.quoteleft.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.braceleft.bar.braceright.asciitilde...................................exclamdown.cent.sterling.fraction.yen.florin.section.currency.quotesingle.quotedblleft.guillemotleft.guilsinglleft.guilsinglright.fi.fl..endash.dagger.daggerdbl.periodcentered..paragraph.bullet.quotesinglbase.quotedblbase.quotedblright.guillemotright.ellipsis.perthousand..questiondown..grave.acute.circumflex.tilde.macron.breve.dotaccent.dieresis..ring.cedilla..hungarumlaut.ogonek.caron.emdash.................AE..ordfeminine.....Lslash.Oslash.OE.ordmasculine......ae....dotlessi...lslash.oslash.oe.germandbls`.split(`.`),bt=/* @__PURE__ */ `................................space.exclamsmall.Hungarumlautsmall..dollaroldstyle.dollarsuperior.ampersandsmall.Acutesmall.parenleftsuperior.parenrightsuperior.twodotenleader.onedotenleader.comma.hyphen.period.fraction.zerooldstyle.oneoldstyle.twooldstyle.threeoldstyle.fouroldstyle.fiveoldstyle.sixoldstyle.sevenoldstyle.eightoldstyle.nineoldstyle.colon.semicolon.commasuperior.threequartersemdash.periodsuperior.questionsmall..asuperior.bsuperior.centsuperior.dsuperior.esuperior...isuperior...lsuperior.msuperior.nsuperior.osuperior...rsuperior.ssuperior.tsuperior..ff.fi.fl.ffi.ffl.parenleftinferior..parenrightinferior.Circumflexsmall.hyphensuperior.Gravesmall.Asmall.Bsmall.Csmall.Dsmall.Esmall.Fsmall.Gsmall.Hsmall.Ismall.Jsmall.Ksmall.Lsmall.Msmall.Nsmall.Osmall.Psmall.Qsmall.Rsmall.Ssmall.Tsmall.Usmall.Vsmall.Wsmall.Xsmall.Ysmall.Zsmall.colonmonetary.onefitted.rupiah.Tildesmall...................................exclamdownsmall.centoldstyle.Lslashsmall...Scaronsmall.Zcaronsmall.Dieresissmall.Brevesmall.Caronsmall..Dotaccentsmall...Macronsmall...figuredash.hypheninferior...Ogoneksmall.Ringsmall.Cedillasmall....onequarter.onehalf.threequarters.questiondownsmall.oneeighth.threeeighths.fiveeighths.seveneighths.onethird.twothirds...zerosuperior.onesuperior.twosuperior.threesuperior.foursuperior.fivesuperior.sixsuperior.sevensuperior.eightsuperior.ninesuperior.zeroinferior.oneinferior.twoinferior.threeinferior.fourinferior.fiveinferior.sixinferior.seveninferior.eightinferior.nineinferior.centinferior.dollarinferior.periodinferior.commainferior.Agravesmall.Aacutesmall.Acircumflexsmall.Atildesmall.Adieresissmall.Aringsmall.AEsmall.Ccedillasmall.Egravesmall.Eacutesmall.Ecircumflexsmall.Edieresissmall.Igravesmall.Iacutesmall.Icircumflexsmall.Idieresissmall.Ethsmall.Ntildesmall.Ogravesmall.Oacutesmall.Ocircumflexsmall.Otildesmall.Odieresissmall.OEsmall.Oslashsmall.Ugravesmall.Uacutesmall.Ucircumflexsmall.Udieresissmall.Yacutesmall.Thornsmall.Ydieresissmall`.split(`.`),xt=/* @__PURE__ */ `.notdef,.null,nonmarkingreturn,space,exclam,quotedbl,numbersign,dollar,percent,ampersand,quotesingle,parenleft,parenright,asterisk,plus,comma,hyphen,period,slash,zero,one,two,three,four,five,six,seven,eight,nine,colon,semicolon,less,equal,greater,question,at,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,bracketleft,backslash,bracketright,asciicircum,underscore,grave,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,braceleft,bar,braceright,asciitilde,Adieresis,Aring,Ccedilla,Eacute,Ntilde,Odieresis,Udieresis,aacute,agrave,acircumflex,adieresis,atilde,aring,ccedilla,eacute,egrave,ecircumflex,edieresis,iacute,igrave,icircumflex,idieresis,ntilde,oacute,ograve,ocircumflex,odieresis,otilde,uacute,ugrave,ucircumflex,udieresis,dagger,degree,cent,sterling,section,bullet,paragraph,germandbls,registered,copyright,trademark,acute,dieresis,notequal,AE,Oslash,infinity,plusminus,lessequal,greaterequal,yen,mu,partialdiff,summation,product,pi,integral,ordfeminine,ordmasculine,Omega,ae,oslash,questiondown,exclamdown,logicalnot,radical,florin,approxequal,Delta,guillemotleft,guillemotright,ellipsis,nonbreakingspace,Agrave,Atilde,Otilde,OE,oe,endash,emdash,quotedblleft,quotedblright,quoteleft,quoteright,divide,lozenge,ydieresis,Ydieresis,fraction,currency,guilsinglleft,guilsinglright,fi,fl,daggerdbl,periodcentered,quotesinglbase,quotedblbase,perthousand,Acircumflex,Ecircumflex,Aacute,Edieresis,Egrave,Iacute,Icircumflex,Idieresis,Igrave,Oacute,Ocircumflex,apple,Ograve,Uacute,Ucircumflex,Ugrave,dotlessi,circumflex,tilde,macron,breve,dotaccent,ring,cedilla,hungarumlaut,ogonek,caron,Lslash,lslash,Scaron,scaron,Zcaron,zcaron,brokenbar,Eth,eth,Yacute,yacute,Thorn,thorn,minus,multiply,onesuperior,twosuperior,threesuperior,onehalf,onequarter,threequarters,franc,Gbreve,gbreve,Idotaccent,Scedilla,scedilla,Cacute,cacute,Ccaron,ccaron,dcroat`.split(`,`);function St(e){this.font=e}St.prototype.charToGlyphIndex=function(e){let t=e.codePointAt(0),n=this.font.glyphs;if(n)for(let e=0;e<n.length;e+=1){let r=n.get(e);for(let n=0;n<r.unicodes.length;n+=1)if(r.unicodes[n]===t)return e}return null};function Ct(e){this.cmap=e}Ct.prototype.charToGlyphIndex=function(e){return this.cmap.glyphIndexMap[e.codePointAt(0)]||0};function wt(e,t){this.encoding=e,this.charset=t}wt.prototype.charToGlyphIndex=function(e){let t=e.codePointAt(0),n=this.encoding[t];return this.charset.indexOf(n)};function Tt(e){switch(e.version){case 1:this.names=xt.slice();break;case 2:this.names=Array(e.numberOfGlyphs);for(let t=0;t<e.numberOfGlyphs;t++)e.glyphNameIndex[t]<xt.length?this.names[t]=xt[e.glyphNameIndex[t]]:this.names[t]=e.names[e.glyphNameIndex[t]-xt.length];break;case 2.5:this.names=Array(e.numberOfGlyphs);for(let t=0;t<e.numberOfGlyphs;t++)this.names[t]=xt[t+e.glyphNameIndex[t]];break;case 3:this.names=[];break;default:this.names=[]}}Tt.prototype.nameToGlyphIndex=function(e){return this.names.indexOf(e)},Tt.prototype.glyphIndexToName=function(e){return this.names[e]};function Et(e){let t,n=e.tables.cmap.glyphIndexMap,r=Object.keys(n);for(let i=0;i<r.length;i+=1){let a=r[i],o=n[a];t=e.glyphs.get(o),t.addUnicode(parseInt(a))}for(let n=0;n<e.glyphs.length;n+=1)t=e.glyphs.get(n),e.cffEncoding?t.name=e.cffEncoding.charset[n]:e.glyphNames.names&&(t.name=e.glyphNames.glyphIndexToName(n))}function Dt(e){e._IndexToUnicodeMap={};let t=e.tables.cmap.glyphIndexMap,n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r],a=t[i];e._IndexToUnicodeMap[a]===void 0?e._IndexToUnicodeMap[a]={unicodes:[parseInt(i)]}:e._IndexToUnicodeMap[a].unicodes.push(parseInt(i))}}function Ot(e,t){t.lowMemory?Dt(e):Et(e)}function kt(e,t,n,r,i){e.beginPath(),e.moveTo(t,n),e.lineTo(r,i),e.stroke()}var At={line:kt};function jt(e,t){let n=new K(e,t),r=n.parseShort();r!==0&&console.warn(`Only CPALv0 is currently fully supported.`);let i=n.parseShort(),a=n.parseShort(),o=n.parseShort(),s=n.parseOffset32(),c=n.parseUShortList(a);n.relativeOffset=s;let l=n.parseULongList(o);return n.relativeOffset=s,{version:r,numPaletteEntries:i,colorRecords:l,colorRecordIndices:c}}function Mt({version:e=0,numPaletteEntries:t=0,colorRecords:n=[],colorRecordIndices:r=[0]}){return R.argument(e===0,`Only CPALv0 are supported.`),R.argument(n.length,`No colorRecords given.`),R.argument(r.length,`No colorRecordIndices given.`),r.length>1&&R.argument(t,`Can't infer numPaletteEntries on multiple colorRecordIndices`),new G.Table(`CPAL`,[{name:`version`,type:`USHORT`,value:e},{name:`numPaletteEntries`,type:`USHORT`,value:t||n.length},{name:`numPalettes`,type:`USHORT`,value:r.length},{name:`numColorRecords`,type:`USHORT`,value:n.length},{name:`colorRecordsArrayOffset`,type:`ULONG`,value:12+2*r.length},...r.map((e,t)=>({name:`colorRecordIndices_`+t,type:`USHORT`,value:e})),...n.map((e,t)=>({name:`colorRecords_`+t,type:`ULONG`,value:e}))])}function Nt(e){var t=(e&4278190080)>>24,n=(e&16711680)>>16,r=(e&65280)>>8,i=e&255;return t=t+256&255,n=n+256&255,r=r+256&255,i=(i+256&255)/255,{b:t,g:n,r,a:i}}function Pt(e,t,n=0,r=`hexa`){if(t==65535)return`currentColor`;let i=e&&e.tables&&e.tables.cpal;if(!i)return`currentColor`;if(n>i.colorRecordIndices.length-1)throw Error(`Palette index out of range (colorRecordIndices.length: ${i.colorRecordIndices.length}, index: ${t})`);if(t>i.numPaletteEntries)throw Error(`Color index out of range (numPaletteEntries: ${i.numPaletteEntries}, index: ${t})`);let a=i.colorRecordIndices[n]+t;if(a>i.colorRecords)throw Error(`Color index out of range (colorRecords.length: ${i.colorRecords.length}, lookupIndex: ${a})`);let o=Nt(i.colorRecords[a]);return r===`bgra`?o:Bt(o,r)}function Ft(e){return(`0`+parseInt(e).toString(16)).slice(-2)}function It(e){let t=e.r/255,n=e.g/255,r=e.b/255,i=Math.max(t,n,r),a=Math.min(t,n,r),o,s,c=(i+a)/2;if(i===a)o=s=0;else{let e=i-a;switch(s=c>.5?e/(2-i-a):e/(i+a),i){case t:o=(n-r)/e+(n<r?6:0);break;case n:o=(r-t)/e+2;break;case r:o=(t-n)/e+4}o/=6}return{h:o*360,s:s*100,l:c*100}}function Lt(e){let{h:t,s:n,l:r,a:i}=e;t%=360,n/=100,r/=100;let a=(1-Math.abs(2*r-1))*n,o=a*(1-Math.abs(t/60%2-1)),s=r-a/2,c=0,l=0,u=0;return 0<=t&&t<60?(c=a,l=o,u=0):60<=t&&t<120?(c=o,l=a,u=0):120<=t&&t<180?(c=0,l=a,u=o):180<=t&&t<240?(c=0,l=o,u=a):240<=t&&t<300?(c=o,l=0,u=a):300<=t&&t<=360&&(c=a,l=0,u=o),{r:Math.round((c+s)*255),g:Math.round((l+s)*255),b:Math.round((u+s)*255),a:i}}function Rt(e){return parseInt(`0x${Ft(e.b)}${Ft(e.g)}${Ft(e.r)}${Ft(e.a*255)}`,16)}function zt(e,t=`hexa`){let n=t==`raw`||t==`cpal`,r=Number.isInteger(e),i=!0;if(r&&n||e===`currentColor`)return e;if(typeof e==`object`){if(t==`bgra`)return e;if(n)return Rt(e)}else if(!r&&/^#([a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i.test(e.trim())){switch(e=e.trim().substring(1),e.length){case 3:e={r:parseInt(e[0].repeat(2),16),g:parseInt(e[1].repeat(2),16),b:parseInt(e[2].repeat(2),16),a:1};break;case 4:e={r:parseInt(e[0].repeat(2),16),g:parseInt(e[1].repeat(2),16),b:parseInt(e[2].repeat(2),16),a:parseInt(e[3].repeat(2),16)/255};break;case 6:e={r:parseInt(e[0]+e[1],16),g:parseInt(e[2]+e[3],16),b:parseInt(e[4]+e[5],16),a:1};break;case 8:e={r:parseInt(e[0]+e[1],16),g:parseInt(e[2]+e[3],16),b:parseInt(e[4]+e[5],16),a:parseInt(e[6]+e[7],16)/255}}if(t==`bgra`)return e}else if(typeof document<`u`&&/^[a-z]+$/i.test(e)){let t=document.createElement(`canvas`).getContext(`2d`);t.fillStyle=e;let n=Bt(t.fillStyle,`hexa`);n===`#000000ff`&&e.toLowerCase()!==`black`?i=!1:e=n}else{e=e.trim();let t=/rgba?\(\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:,|\s*)\s*(?:(\d*\.\d+)(%?)|(\d+)(%?))\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(t.test(e)){let n=e.match(t).filter(e=>e!==void 0);e={r:Math.round(parseFloat(n[1])/(n[2]?100/255:1)),g:Math.round(parseFloat(n[3])/(n[4]?100/255:1)),b:Math.round(parseFloat(n[5])/(n[6]?100/255:1)),a:n[7]?parseFloat(n[7])/(n[8]?100:1):1}}else{let t=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(t.test(e)){let n=e.match(t).filter(e=>e!==void 0);e=Lt({h:parseFloat(n[1])*(n[2]===`turn`?360:1),s:parseFloat(n[3]),l:parseFloat(n[4]),a:n[5]?parseFloat(n[5])/(n[6]?100:1):1})}else i=!1}}if(!i)throw Error(`Invalid color format: ${e}`);return Bt(e,t)}function Bt(e,t=`hexa`){if(e===`currentColor`)return e;if(Number.isInteger(e)){if(t==`raw`||t==`cpal`)return e;e=Nt(e)}else typeof e!=`object`&&(e=zt(e,`bgra`));let n=[`hsl`,`hsla`].includes(t)?It(e):null;switch(t){case`rgba`:return`rgba(${e.r}, ${e.g}, ${e.b}, ${parseFloat(e.a.toFixed(3))})`;case`rgb`:return`rgb(${e.r}, ${e.g}, ${e.b})`;case`hex`:case`hex6`:case`hex-6`:return`#${Ft(e.r)}${Ft(e.g)}${Ft(e.b)}`;case`hexa`:case`hex8`:case`hex-8`:return`#${Ft(e.r)}${Ft(e.g)}${Ft(e.b)}${Ft(e.a*255)}`;case`hsl`:return`hsl(${n.h.toFixed(2)}, ${n.s.toFixed(2)}%, ${n.l.toFixed(2)}%)`;case`hsla`:return`hsla(${n.h.toFixed(2)}, ${n.s.toFixed(2)}%, ${n.l.toFixed(2)}%, ${parseFloat(e.a.toFixed(3))})`;case`bgra`:return e;case`raw`:case`cpal`:return Rt(e);default:throw Error(`Unknown color format: `+t)}}var Vt={parse:jt,make:Mt,getPaletteColor:Pt,parseColor:zt,formatColor:Bt};function Ht(e,t){let n=t||new L;return{configurable:!0,get:function(){return typeof n==`function`&&(n=n()),n},set:function(e){n=e}}}function Ut(e){this.bindConstructorValues(e)}Ut.prototype.bindConstructorValues=function(e){if(this.index=e.index||0,e.name===`.notdef`?e.unicode=void 0:e.name===`.null`&&(e.unicode=0),e.unicode===0&&e.name!==`.null`)throw Error(`The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.`);this.name=e.name||null,this.unicode=e.unicode,this.unicodes=e.unicodes||(e.unicode===void 0?[]:[e.unicode]),`xMin`in e&&(this.xMin=e.xMin),`yMin`in e&&(this.yMin=e.yMin),`xMax`in e&&(this.xMax=e.xMax),`yMax`in e&&(this.yMax=e.yMax),`advanceWidth`in e&&(this.advanceWidth=e.advanceWidth),`leftSideBearing`in e&&(this.leftSideBearing=e.leftSideBearing),`points`in e&&(this.points=e.points),Object.defineProperty(this,"path",Ht(this,e.path))},Ut.prototype.addUnicode=function(e){this.unicodes.length===0&&(this.unicode=e),this.unicodes.push(e)},Ut.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},Ut.prototype.getPath=function(e,t,n,r,i){e=e===void 0?0:e,t=t===void 0?0:t,n=n===void 0?72:n,r=Object.assign({},i&&i.defaultRenderOptions,r);let a,o,s=r.xScale,c=r.yScale,l=1/(this.path.unitsPerEm||1e3)*n,u=this;i&&i.variation&&(u=i.variation.getTransform(this,r.variation),a=u.path.commands),r.hinting&&i&&i.hinting&&(o=u.path&&i.hinting.exec(u,n,r)),o?(a=i.hinting.getCommands(o),e=Math.round(e),t=Math.round(t),s=c=1):(a=u.path.commands,s===void 0&&(s=l),c===void 0&&(c=l));let d=new L;if(r.drawSVG){let n=this.getSvgImage(i);if(n){let r=new L;return r._image={image:n.image,x:e+n.leftSideBearing*l,y:t-n.baseline*l,width:n.image.width*l,height:n.image.height*l},d._layers=[r],d}}if(r.drawLayers){let a=this.getLayers(i);if(a&&a.length){d._layers=[];for(let o=0;o<a.length;o+=1){let s=a[o],c=Pt(i,s.paletteIndex,r.usePalette);c=c===`currentColor`?r.fill||`black`:Bt(c,r.colorFormat||`rgba`),r=Object.assign({},r,{fill:c}),d._layers.push(this.getPath.call(s.glyph,e,t,n,r,i))}return d}}d.fill=r.fill||this.path.fill,d.stroke=this.path.stroke,d.strokeWidth=this.path.strokeWidth*l;for(let n=0;n<a.length;n+=1){let r=a[n];r.type===`M`?d.moveTo(e+r.x*s,t+-r.y*c):r.type===`L`?d.lineTo(e+r.x*s,t+-r.y*c):r.type===`Q`?d.quadraticCurveTo(e+r.x1*s,t+-r.y1*c,e+r.x*s,t+-r.y*c):r.type===`C`?d.curveTo(e+r.x1*s,t+-r.y1*c,e+r.x2*s,t+-r.y2*c,e+r.x*s,t+-r.y*c):r.type===`Z`&&d.stroke&&d.strokeWidth&&d.closePath()}return d},Ut.prototype.getLayers=function(e){if(!e)throw Error(`The font object is required to read the colr/cpal tables in order to get the layers.`);return e.layers.get(this.index)},Ut.prototype.getSvgImage=function(e){if(!e)throw Error(`The font object is required to read the svg table in order to get the image.`);return e.svgImages.get(this.index)},Ut.prototype.getContours=function(e=null){if(this.points===void 0&&!e)return[];let t=[],n=[],r=e||this.points;for(let e=0;e<r.length;e+=1){let i=r[e];n.push(i),i.lastPointOfContour&&(t.push(n),n=[])}return R.argument(n.length===0,`There are still points left in the current contour.`),t},Ut.prototype.getMetrics=function(){let e=this.path.commands,t=[],n=[];for(let r=0;r<e.length;r+=1){let i=e[r];i.type!==`Z`&&(t.push(i.x),n.push(i.y)),(i.type===`Q`||i.type===`C`)&&(t.push(i.x1),n.push(i.y1)),i.type===`C`&&(t.push(i.x2),n.push(i.y2))}let r={xMin:Math.min.apply(null,t),yMin:Math.min.apply(null,n),xMax:Math.max.apply(null,t),yMax:Math.max.apply(null,n),leftSideBearing:this.leftSideBearing};return isFinite(r.xMin)||(r.xMin=0),isFinite(r.xMax)||(r.xMax=this.advanceWidth),isFinite(r.yMin)||(r.yMin=0),isFinite(r.yMax)||(r.yMax=0),r.rightSideBearing=this.advanceWidth-r.leftSideBearing-(r.xMax-r.xMin),r},Ut.prototype.draw=function(e,t,n,r,i,a){i=Object.assign({},a&&a.defaultRenderOptions,i),this.getPath(t,n,r,i,a).draw(e)},Ut.prototype.drawPoints=function(e,t,n,r,i,a){if(i=Object.assign({},a&&a.defaultRenderOptions,i),i.drawLayers){let i=this.getLayers(a);if(i&&i.length){for(let a=0;a<i.length;a+=1)i[a].glyph.index!==this.index&&this.drawPoints.call(i[a].glyph,e,t,n,r);return}}function o(t,n,r,i){e.beginPath();for(let a=0;a<t.length;a+=1)e.moveTo(n+t[a].x*i,r+t[a].y*i),e.arc(n+t[a].x*i,r+t[a].y*i,2,0,Math.PI*2,!1);e.fill()}t=t===void 0?0:t,n=n===void 0?0:n,r=r===void 0?24:r;let s=1/this.path.unitsPerEm*r,c=[],l=[],u=this.path.commands;a&&a.variation&&(u=a.variation.getTransform(this,i.variation).path.commands);for(let e=0;e<u.length;e+=1){let t=u[e];t.x!==void 0&&c.push({x:t.x,y:-t.y}),t.x1!==void 0&&l.push({x:t.x1,y:-t.y1}),t.x2!==void 0&&l.push({x:t.x2,y:-t.y2})}e.fillStyle=`blue`,o(c,t,n,s),e.fillStyle=`red`,o(l,t,n,s)},Ut.prototype.drawMetrics=function(e,t,n,r){let i;t=t===void 0?0:t,n=n===void 0?0:n,r=r===void 0?24:r,i=1/this.path.unitsPerEm*r,e.lineWidth=1,e.strokeStyle=`black`,At.line(e,t,-1e4,t,1e4),At.line(e,-1e4,n,1e4,n);let a=this.xMin||0,o=this.yMin||0,s=this.xMax||0,c=this.yMax||0,l=this.advanceWidth||0;e.strokeStyle=`blue`,At.line(e,t+a*i,-1e4,t+a*i,1e4),At.line(e,t+s*i,-1e4,t+s*i,1e4),At.line(e,-1e4,n+-o*i,1e4,n+-o*i),At.line(e,-1e4,n+-c*i,1e4,n+-c*i),e.strokeStyle=`green`,At.line(e,t+l*i,-1e4,t+l*i,1e4)},Ut.prototype.toPathData=function(e,t){e=Object.assign({},{variation:t&&t.defaultRenderOptions.variation},e);let n=this;t&&t.variation&&(n=t.variation.getTransform(this,e.variation));let r=n.points&&e.pointsTransform?e.pointsTransform(n.points):n.path;return e.pathTransform&&(r=e.pathTransform(r)),r.toPathData(e)},Ut.prototype.fromSVG=function(e,t={}){return this.path.fromSVG(e,t)},Ut.prototype.toSVG=function(e,t){let n=this.toPathData.apply(this,[e,t]);return this.path.toSVG(e,n)},Ut.prototype.toDOMElement=function(e,t){e=Object.assign({},{variation:t&&t.defaultRenderOptions.variation},e);let n=this.path;return t&&t.variation&&(n=t.variation.getTransform(this,e.variation).path),n.toDOMElement(e)};var Wt=Ut;function Gt(e,t,n){Object.defineProperty(e,t,{get:function(){return e[n]===void 0&&e.path,e[n]},set:function(t){e[n]=t},enumerable:!0,configurable:!0})}function Kt(e,t){if(this.font=e,this.glyphs={},Array.isArray(t))for(let n=0;n<t.length;n++){let r=t[n];r.path.unitsPerEm=e.unitsPerEm,this.glyphs[n]=r}this.length=t&&t.length||0}typeof Symbol<`u`&&Symbol.iterator&&(Kt.prototype[Symbol.iterator]=function(){let e=-1;return{next:function(){e++;let t=e>=this.length-1;return{value:this.get(e),done:t}}.bind(this)}}),Kt.prototype.get=function(e){if(this.font._push&&this.glyphs[e]===void 0){this.font._push(e),typeof this.glyphs[e]==`function`&&(this.glyphs[e]=this.glyphs[e]());let t=this.glyphs[e],n=this.font._IndexToUnicodeMap[e];if(n)for(let e=0;e<n.unicodes.length;e++)t.addUnicode(n.unicodes[e]);this.font.cffEncoding?t.name=this.font.cffEncoding.charset[e]:this.font.glyphNames.names&&(t.name=this.font.glyphNames.glyphIndexToName(e)),this.glyphs[e].advanceWidth=this.font._hmtxTableData[e].advanceWidth,this.glyphs[e].leftSideBearing=this.font._hmtxTableData[e].leftSideBearing}else typeof this.glyphs[e]==`function`&&(this.glyphs[e]=this.glyphs[e]());return this.glyphs[e]},Kt.prototype.push=function(e,t){this.glyphs[e]=t,this.length++};function qt(e,t){return new Wt({index:t,font:e})}function Jt(e,t,n,r,i,a){return function(){let o=new Wt({index:t,font:e});return o.path=function(){n(o,r,i);let t=a(e.glyphs,o);return t.unitsPerEm=e.unitsPerEm,t},Gt(o,`numberOfContours`,`_numberOfContours`),Gt(o,`xMin`,`_xMin`),Gt(o,`xMax`,`_xMax`),Gt(o,`yMin`,`_yMin`),Gt(o,`yMax`,`_yMax`),Gt(o,`points`,`_points`),o}}function Yt(e,t,n,r,i){return function(){let a=new Wt({index:t,font:e});return a.path=function(){let t=n(e,a,r,i);return t.unitsPerEm=e.unitsPerEm,t},a}}var Xt={GlyphSet:Kt,glyphLoader:qt,ttfGlyphLoader:Jt,cffGlyphLoader:Yt};function Zt(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!Zt(e[n],t[n]))return!1;return!0}return!1}var Qt=10;function $t(e){let t;return t=e.length<1240?107:e.length<33900?1131:32768,t}function en(e,t,n,r){let i=[],a=[],o=r>1?q.getULong(e,t):q.getCard16(e,t),s=r>1?4:2,c,l;if(o!==0){let n=q.getByte(e,t+s);c=t+(o+1)*n+s;let r=t+s+1;for(let t=0;t<o+1;t+=1)i.push(q.getOffset(e,r,n)),r+=n;l=c+i[o]}else l=t+s;for(let o=0;o<i.length-1;o+=1){let s=q.getBytes(e,c+i[o],c+i[o+1]);n&&(s=n(s,e,t,r)),a.push(s)}return{objects:a,startOffset:t,endOffset:l}}function tn(e,t,n){let r=[],i=n>1?q.getULong(e,t):q.getCard16(e,t),a=n>1?4:2,o,s;if(i!==0){let n=q.getByte(e,t+a);o=t+(i+1)*n+a;let c=t+a+1;for(let t=0;t<i+1;t+=1)r.push(q.getOffset(e,c,n)),c+=n;s=o+r[i]}else s=t+a;return{offsets:r,startOffset:t,endOffset:s}}function nn(e,t,n,r,i,a){let o=a>1?q.getULong(n,r):q.getCard16(n,r),s=a>1?4:2,c=0;if(o!==0){let e=q.getByte(n,r+s);c=r+(o+1)*e+s}let l=q.getBytes(n,c+t[e],c+t[e+1]);return i&&(l=i(l)),l}function rn(e){let t=``,n=[`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`.`,`E`,`E-`,null,`-`];for(;;){let r=e.parseByte(),i=r>>4,a=r&15;if(i===15||(t+=n[i],a===15))break;t+=n[a]}return parseFloat(t)}function an(e,t){let n,r,i,a;if(t===28)return n=e.parseByte(),r=e.parseByte(),n<<8|r;if(t===29)return n=e.parseByte(),r=e.parseByte(),i=e.parseByte(),a=e.parseByte(),n<<24|r<<16|i<<8|a;if(t===30)return rn(e);if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return n=e.parseByte(),(t-247)*256+n+108;if(t>=251&&t<=254)return n=e.parseByte(),-(t-251)*256-n-108;throw Error(`Invalid b0 `+t)}function on(e){let t={};for(let n=0;n<e.length;n+=1){let r=e[n][0],i=e[n][1],a;if(a=i.length===1?i[0]:i,Object.prototype.hasOwnProperty.call(t,r)&&!isNaN(t[r]))throw Error(`Object `+t+` already has key `+r);t[r]=a}return t}function sn(e,t,n,r){t=t===void 0?0:t;let i=new q.Parser(e,t),a=[],o=[];n=n===void 0?e.byteLength:n;let s=r<2?22:28;for(;i.relativeOffset<n;){let e=i.parseByte();if(e<s){if(e===12&&(e=1200+i.parseByte()),r>1&&e===23){Cn(o);continue}a.push([e,o]),o=[]}else o.push(an(i,e,r))}return on(a)}function cn(e,t){return t=t<=390?ht[t]:e?e[t-391]:void 0,t}function ln(e,t,n){let r={},i;for(let a=0;a<t.length;a+=1){let o=t[a];if(Array.isArray(o.type)){let t=[];t.length=o.type.length;for(let r=0;r<o.type.length;r++)i=e[o.op]===void 0?void 0:e[o.op][r],i===void 0&&(i=o.value!==void 0&&o.value[r]!==void 0?o.value[r]:null),o.type[r]===`SID`&&(i=cn(n,i)),t[r]=i;r[o.name]=t}else i=e[o.op],i===void 0&&(i=o.value===void 0?null:o.value),o.type===`SID`&&(i=cn(n,i)),r[o.name]=i}return r}function un(e,t){let n={};if(n.formatMajor=q.getCard8(e,t),n.formatMinor=q.getCard8(e,t+1),n.formatMajor>2)throw Error(`Unsupported CFF table version ${n.formatMajor}.${n.formatMinor}`);return n.size=q.getCard8(e,t+2),n.formatMajor<2?(n.offsetSize=q.getCard8(e,t+3),n.startOffset=t,n.endOffset=t+4):(n.topDictLength=q.getCard16(e,t+3),n.endOffset=t+8),n}var dn=[{name:`version`,op:0,type:`SID`},{name:`notice`,op:1,type:`SID`},{name:`copyright`,op:1200,type:`SID`},{name:`fullName`,op:2,type:`SID`},{name:`familyName`,op:3,type:`SID`},{name:`weight`,op:4,type:`SID`},{name:`isFixedPitch`,op:1201,type:`number`,value:0},{name:`italicAngle`,op:1202,type:`number`,value:0},{name:`underlinePosition`,op:1203,type:`number`,value:-100},{name:`underlineThickness`,op:1204,type:`number`,value:50},{name:`paintType`,op:1205,type:`number`,value:0},{name:`charstringType`,op:1206,type:`number`,value:2},{name:`fontMatrix`,op:1207,type:[`real`,`real`,`real`,`real`,`real`,`real`],value:[.001,0,0,.001,0,0]},{name:`uniqueId`,op:13,type:`number`},{name:`fontBBox`,op:5,type:[`number`,`number`,`number`,`number`],value:[0,0,0,0]},{name:`strokeWidth`,op:1208,type:`number`,value:0},{name:`xuid`,op:14,type:[],value:null},{name:`charset`,op:15,type:`offset`,value:0},{name:`encoding`,op:16,type:`offset`,value:0},{name:`charStrings`,op:17,type:`offset`,value:0},{name:`private`,op:18,type:[`number`,`offset`],value:[0,0]},{name:`ros`,op:1230,type:[`SID`,`SID`,`number`]},{name:`cidFontVersion`,op:1231,type:`number`,value:0},{name:`cidFontRevision`,op:1232,type:`number`,value:0},{name:`cidFontType`,op:1233,type:`number`,value:0},{name:`cidCount`,op:1234,type:`number`,value:8720},{name:`uidBase`,op:1235,type:`number`},{name:`fdArray`,op:1236,type:`offset`},{name:`fdSelect`,op:1237,type:`offset`},{name:`fontName`,op:1238,type:`SID`}],fn=[{name:`fontMatrix`,op:1207,type:[`real`,`real`,`real`,`real`,`real`,`real`],value:[.001,0,0,.001,0,0]},{name:`charStrings`,op:17,type:`offset`},{name:`fdArray`,op:1236,type:`offset`},{name:`fdSelect`,op:1237,type:`offset`},{name:`vstore`,op:24,type:`offset`}],pn=[{name:`subrs`,op:19,type:`offset`,value:0},{name:`defaultWidthX`,op:20,type:`number`,value:0},{name:`nominalWidthX`,op:21,type:`number`,value:0}],mn=[{name:`blueValues`,op:6,type:`delta`},{name:`otherBlues`,op:7,type:`delta`},{name:`familyBlues`,op:7,type:`delta`},{name:`familyBlues`,op:8,type:`delta`},{name:`familyOtherBlues`,op:9,type:`delta`},{name:`blueScale`,op:1209,type:`number`,value:.039625},{name:`blueShift`,op:1210,type:`number`,value:7},{name:`blueFuzz`,op:1211,type:`number`,value:1},{name:`stdHW`,op:10,type:`number`},{name:`stdVW`,op:11,type:`number`},{name:`stemSnapH`,op:1212,type:`number`},{name:`stemSnapV`,op:1213,type:`number`},{name:`languageGroup`,op:1217,type:`number`,value:0},{name:`expansionFactor`,op:1218,type:`number`,value:.06},{name:`vsindex`,op:22,type:`number`,value:0},{name:`subrs`,op:19,type:`offset`}],hn=[{name:`private`,op:18,type:[`number`,`offset`],value:[0,0]}];function gn(e,t,n,r){return ln(sn(e,t,e.byteLength,r),r>1?fn:dn,n)}function _n(e,t,n,r,i){return ln(sn(e,t,n,i),i>1?mn:pn,r)}function vn(e,t,n){return ln(sn(e,t,void 0,n),hn)}function yn(e,t,n){let r=[];for(let i=0;i<n.length;i++){let a=vn(new DataView(new Uint8Array(n[i]).buffer),0,2),o=a.private[0],s=a.private[1];if(o!==0&&s!==0){let n=_n(e,s+t,o,[],2);n.subrs&&(a._subrs=en(e,s+n.subrs+t,void 0,2).objects,a._subrsBias=$t(a._subrs)),a._privateDict=n}r.push(a)}return r}function bn(e,t,n,r,i){let a=[];for(let o=0;o<n.length;o+=1){let s=gn(new DataView(new Uint8Array(n[o]).buffer),0,r,i);s._subrs=[],s._subrsBias=0,s._defaultWidthX=0,s._nominalWidthX=0;let c=i<2?s.private[0]:0,l=i<2?s.private[1]:0;if(c!==0&&l!==0){let n=_n(e,l+t,c,r,i);s._defaultWidthX=n.defaultWidthX,s._nominalWidthX=n.nominalWidthX,n.subrs!==0&&(s._subrs=en(e,l+n.subrs+t,void 0,i).objects,s._subrsBias=$t(s._subrs)),s._privateDict=n}a.push(s)}return a}function xn(e,t,n,r,i){let a,o,s=new q.Parser(e,t);--n;let c=[`.notdef`],l=s.parseCard8();if(l===0)for(let e=0;e<n;e+=1)a=s.parseSID(),i?c.push(a):c.push(cn(r,a)||a);else if(l===1)for(;c.length<=n;){a=s.parseSID(),o=s.parseCard8();for(let e=0;e<=o;e+=1)i?c.push(`cid`+(`00000`+a).slice(-5)):c.push(cn(r,a)||a),a+=1}else if(l===2)for(;c.length<=n;){a=s.parseSID(),o=s.parseCard16();for(let e=0;e<=o;e+=1)i?c.push(`cid`+(`00000`+a).slice(-5)):c.push(cn(r,a)||a),a+=1}else throw Error(`Unknown charset format `+l);return c}function Sn(e,t){let n,r={},i=new q.Parser(e,t),a=i.parseCard8();if(a===0){let e=i.parseCard8();for(let t=0;t<e;t+=1)n=i.parseCard8(),r[n]=t}else if(a===1){let e=i.parseCard8();n=1;for(let t=0;t<e;t+=1){let e=i.parseCard8(),t=i.parseCard8();for(let i=e;i<=e+t;i+=1)r[i]=n,n+=1}}else throw Error(`Unknown encoding format `+a);return r}function Cn(e){let t=e.pop();for(;e.length>t;)e.pop()}function wn(e,t){let n=e.tables.cff&&e.tables.cff.topDict&&e.tables.cff.topDict.paintType||0;return n===2&&(t.fill=null,t.stroke=`black`,t.strokeWidth=e.tables.cff.topDict.strokeWidth||0),n}function Tn(e,t,n,r,i){let a,o,s,c,l=new L,u=[],d=0,f=!1,p=!1,m=0,h=0,g,_,v,y,b=0,x=[],S,C=0,w=e.tables.cff2||e.tables.cff;if(v=w.topDict._defaultWidthX,y=w.topDict._nominalWidthX,i||=e.variation&&e.variation.get(),t.getBlendPath||=function(i){return Tn(e,t,n,r,i)},e.isCIDFont||r>1){let e=w.topDict._fdSelect?w.topDict._fdSelect[t.index]:0,n=w.topDict._fdArray[e];g=n._subrs,_=n._subrsBias,r>1?(x=w.topDict._vstore.itemVariationStore,b=n._privateDict.vsindex):(v=n._defaultWidthX,y=n._nominalWidthX)}else g=w.topDict._subrs,_=w.topDict._subrsBias;let T=wn(e,l),E=v;function D(e,t){p&&T!==2&&l.closePath(),l.moveTo(e,t),p=!0}function O(){let e;e=!!(u.length&1),e&&!f&&(E=u.shift()+y),d+=u.length>>1,u.length=0,f=!0}function k(n){let v,w,A,j,M,ee,N,P,F,I,te,ne,re=0;for(;re<n.length;){let ce=n[re];switch(re+=1,ce){case 1:O();break;case 3:O();break;case 4:u.length>1&&!f&&(E=u.shift()+y,f=!0),h+=u.pop(),D(m,h);break;case 5:for(;u.length>0;)m+=u.shift(),h+=u.shift(),l.lineTo(m,h);break;case 6:for(;u.length>0&&(m+=u.shift(),l.lineTo(m,h),u.length!==0);)h+=u.shift(),l.lineTo(m,h);break;case 7:for(;u.length>0&&(h+=u.shift(),l.lineTo(m,h),u.length!==0);)m+=u.shift(),l.lineTo(m,h);break;case 8:for(;u.length>0;)a=m+u.shift(),o=h+u.shift(),s=a+u.shift(),c=o+u.shift(),m=s+u.shift(),h=c+u.shift(),l.curveTo(a,o,s,c,m,h);break;case 10:if(M=u.pop()+_,ee=g[M],ee){if(C>=Qt){console.warn(`CFF charstring subroutine call depth exceeded, skipping callsubr`);break}C++,k(ee),C--}break;case 11:if(r>1){console.error(`CFF CharString operator return (11) is not supported in CFF2`);break}return;case 12:switch(ce=n[re],re+=1,ce){case 35:a=m+u.shift(),o=h+u.shift(),s=a+u.shift(),c=o+u.shift(),N=s+u.shift(),P=c+u.shift(),F=N+u.shift(),I=P+u.shift(),te=F+u.shift(),ne=I+u.shift(),m=te+u.shift(),h=ne+u.shift(),u.shift(),l.curveTo(a,o,s,c,N,P),l.curveTo(F,I,te,ne,m,h);break;case 34:a=m+u.shift(),o=h,s=a+u.shift(),c=o+u.shift(),N=s+u.shift(),P=c,F=N+u.shift(),I=c,te=F+u.shift(),ne=h,m=te+u.shift(),l.curveTo(a,o,s,c,N,P),l.curveTo(F,I,te,ne,m,h);break;case 36:a=m+u.shift(),o=h+u.shift(),s=a+u.shift(),c=o+u.shift(),N=s+u.shift(),P=c,F=N+u.shift(),I=c,te=F+u.shift(),ne=I+u.shift(),m=te+u.shift(),l.curveTo(a,o,s,c,N,P),l.curveTo(F,I,te,ne,m,h);break;case 37:a=m+u.shift(),o=h+u.shift(),s=a+u.shift(),c=o+u.shift(),N=s+u.shift(),P=c+u.shift(),F=N+u.shift(),I=P+u.shift(),te=F+u.shift(),ne=I+u.shift(),Math.abs(te-m)>Math.abs(ne-h)?m=te+u.shift():h=ne+u.shift(),l.curveTo(a,o,s,c,N,P),l.curveTo(F,I,te,ne,m,h);break;default:console.log(`Glyph `+t.index+`: unknown operator 1200`+ce),u.length=0}break;case 14:if(r>1){console.error(`CFF CharString operator endchar (14) is not supported in CFF2`);break}if(u.length>=4){let n=yt[u.pop()],r=yt[u.pop()],i=u.pop(),a=u.pop();if(n&&r){t.isComposite=!0,t.components=[];let o=e.cffEncoding.charset.indexOf(n),s=e.cffEncoding.charset.indexOf(r);t.components.push({glyphIndex:s,dx:0,dy:0}),t.components.push({glyphIndex:o,dx:a,dy:i}),l.extend(e.glyphs.get(s).path);let c=e.glyphs.get(o),u=JSON.parse(JSON.stringify(c.path.commands));for(let e=0;e<u.length;e+=1){let t=u[e];t.type!==`Z`&&(t.x+=a,t.y+=i),(t.type===`Q`||t.type===`C`)&&(t.x1+=a,t.y1+=i),t.type===`C`&&(t.x2+=a,t.y2+=i)}l.extend(u)}}else u.length>0&&!f&&(E=u.shift()+y,f=!0);p&&T!==2&&(l.closePath(),p=!1);break;case 15:if(r<2){console.error(`CFF2 CharString operator vsindex (15) is not supported in CFF`);break}b=u.pop();break;case 16:if(r<2){console.error(`CFF2 CharString operator blend (16) is not supported in CFF`);break}S||=e.variation&&i&&e.variation.process.getBlendVector(x,b,i);var L=u.pop(),ie=S?S.length:x.itemVariationSubtables[b].regionIndexes.length,ae=L*ie,R=u.length-ae,oe=R-L;if(S)for(let e=0;e<L;e++){var se=u[oe+e];for(let e=0;e<ie;e++)se+=S[e]*u[R++];u[oe+e]=se}for(;ae--;)u.pop();break;case 18:O();break;case 19:case 20:O(),re+=d+7>>3;break;case 21:u.length>2&&!f&&(E=u.shift()+y,f=!0),h+=u.pop(),m+=u.pop(),D(m,h);break;case 22:u.length>1&&!f&&(E=u.shift()+y,f=!0),m+=u.pop(),D(m,h);break;case 23:O();break;case 24:for(;u.length>2;)a=m+u.shift(),o=h+u.shift(),s=a+u.shift(),c=o+u.shift(),m=s+u.shift(),h=c+u.shift(),l.curveTo(a,o,s,c,m,h);m+=u.shift(),h+=u.shift(),l.lineTo(m,h);break;case 25:for(;u.length>6;)m+=u.shift(),h+=u.shift(),l.lineTo(m,h);a=m+u.shift(),o=h+u.shift(),s=a+u.shift(),c=o+u.shift(),m=s+u.shift(),h=c+u.shift(),l.curveTo(a,o,s,c,m,h);break;case 26:for(u.length&1&&(m+=u.shift());u.length>0;)a=m,o=h+u.shift(),s=a+u.shift(),c=o+u.shift(),m=s,h=c+u.shift(),l.curveTo(a,o,s,c,m,h);break;case 27:for(u.length&1&&(h+=u.shift());u.length>0;)a=m+u.shift(),o=h,s=a+u.shift(),c=o+u.shift(),m=s+u.shift(),h=c,l.curveTo(a,o,s,c,m,h);break;case 28:v=n[re],w=n[re+1],u.push((v<<24|w<<16)>>16),re+=2;break;case 29:if(M=u.pop()+e.gsubrsBias,ee=e.gsubrs[M],ee){if(C>=Qt){console.warn(`CFF charstring subroutine call depth exceeded, skipping callgsubr`);break}C++,k(ee),C--}break;case 30:for(;u.length>0&&(a=m,o=h+u.shift(),s=a+u.shift(),c=o+u.shift(),m=s+u.shift(),h=c+(u.length===1?u.shift():0),l.curveTo(a,o,s,c,m,h),u.length!==0);)a=m+u.shift(),o=h,s=a+u.shift(),c=o+u.shift(),h=c+u.shift(),m=s+(u.length===1?u.shift():0),l.curveTo(a,o,s,c,m,h);break;case 31:for(;u.length>0&&(a=m+u.shift(),o=h,s=a+u.shift(),c=o+u.shift(),h=c+u.shift(),m=s+(u.length===1?u.shift():0),l.curveTo(a,o,s,c,m,h),u.length!==0);)a=m,o=h+u.shift(),s=a+u.shift(),c=o+u.shift(),m=s+u.shift(),h=c+(u.length===1?u.shift():0),l.curveTo(a,o,s,c,m,h);break;default:ce<32?console.log(`Glyph `+t.index+`: unknown operator `+ce):ce<247?u.push(ce-139):ce<251?(v=n[re],re+=1,u.push((ce-247)*256+v+108)):ce<255?(v=n[re],re+=1,u.push(-(ce-251)*256-v-108)):(v=n[re],w=n[re+1],A=n[re+2],j=n[re+3],re+=4,u.push((v<<24|w<<16|A<<8|j)/65536))}}}return k(n),e.variation&&i&&(l.commands=l.commands.map(e=>{let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n];r!==`type`&&(e[r]=Math.round(e[r]))}return e})),f&&(t.advanceWidth=E),l}function En(e,t,n,r,i){let a=[],o,s=new q.Parser(e,t),c=s.parseCard8();if(c===0)for(let e=0;e<n;e++){if(o=s.parseCard8(),o>=r)throw Error(`CFF table CID Font FDSelect has bad FD index value `+o+` (FD count `+r+`)`);a.push(o)}else if(c===3||i>1&&c===4){let e=c===4?s.parseULong():s.parseCard16(),t=c===4?s.parseULong():s.parseCard16();if(t!==0)throw Error(`CFF Table CID Font FDSelect format ${c} range has bad initial GID ${t}`);let l;for(let u=0;u<e;u++){if(o=c===4?s.parseUShort():s.parseCard8(),l=c===4?s.parseULong():s.parseCard16(),o>=r)throw Error(`CFF table CID Font FDSelect has bad FD index value `+o+` (FD count `+r+`)`);if(l>n)throw Error(`CFF Table CID Font FDSelect format ${i} range has bad GID ${l}`);for(;t<l;t++)a.push(o);t=l}if(l!==n)throw Error(`CFF Table CID Font FDSelect format 3 range has bad final (Sentinal) GID `+l)}else throw Error(`CFF Table CID Font FDSelect table has unsupported format `+c);return a}function Dn(e,t,n,r){let i,a=un(e,t);i=a.formatMajor===2?n.tables.cff2={}:n.tables.cff={};let o=a.formatMajor>1?null:en(e,a.endOffset,q.bytesToString),s=a.formatMajor>1?null:en(e,o.endOffset),c=a.formatMajor>1?null:en(e,s.endOffset,q.bytesToString);n.gsubrs=en(e,a.formatMajor>1?t+a.size+a.topDictLength:c.endOffset,void 0,a.formatMajor).objects,n.gsubrsBias=$t(n.gsubrs);let l;if(a.formatMajor>1){let n=t+a.size;l=bn(e,0,[q.getBytes(e,n,n+a.topDictLength)],void 0,a.formatMajor)[0]}else{let n=bn(e,t,s.objects,c.objects,a.formatMajor);if(n.length!==1)throw Error(`CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = `+n.length);l=n[0]}if(i.topDict=l,l._privateDict&&(n.defaultWidthX=l._privateDict.defaultWidthX,n.nominalWidthX=l._privateDict.nominalWidthX),a.formatMajor<2&&l.ros[0]!==void 0&&l.ros[1]!==void 0&&(n.isCIDFont=!0),a.formatMajor>1){let r=l.fdArray,i=l.fdSelect;if(!r)throw Error(`This is a CFF2 font, but FDArray information is missing`);let o=yn(e,t,en(e,t+r,null,a.formatMajor).objects);l._fdArray=o,i&&(l._fdSelect=En(e,t+i,n.numGlyphs,o.length,a.formatMajor))}else if(n.isCIDFont){let r=l.fdArray,i=l.fdSelect;if(r===0||i===0)throw Error(`Font is marked as a CID font, but FDArray and/or FDSelect information is missing`);r+=t;let o=bn(e,t,en(e,r).objects,c.objects,a.formatMajor);l._fdArray=o,i+=t,l._fdSelect=En(e,i,n.numGlyphs,o.length,a.formatMajor)}if(a.formatMajor<2){let r=t+l.private[1],i=_n(e,r,l.private[0],c.objects,a.formatMajor);n.defaultWidthX=i.defaultWidthX,n.nominalWidthX=i.nominalWidthX,i.subrs===0?(n.subrs=[],n.subrsBias=0):(n.subrs=en(e,r+i.subrs).objects,n.subrsBias=$t(n.subrs))}let u;if(r.lowMemory?(u=tn(e,t+l.charStrings,a.formatMajor),n.nGlyphs=u.offsets.length-+(a.formatMajor>1)):(u=en(e,t+l.charStrings,null,a.formatMajor),n.nGlyphs=u.objects.length),a.formatMajor>1&&n.tables.maxp&&n.nGlyphs!==n.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${n.nGlyphs}) must correspond to the glyph count in the maxp table (${n.tables.maxp.numGlyphs})`),a.formatMajor<2){let r=[],i=[];r=l.charset===0?gt:l.charset===1?_t:l.charset===2?vt:xn(e,t+l.charset,n.nGlyphs,c.objects,n.isCIDFont),i=l.encoding===0?yt:l.encoding===1?bt:Sn(e,t+l.encoding),n.cffEncoding=new wt(i,r),n.encoding=n.encoding||n.cffEncoding}if(n.glyphs=new Xt.GlyphSet(n),r.lowMemory)n._push=function(r){let i=nn(r,u.offsets,e,t+l.charStrings,void 0,a.formatMajor);n.glyphs.push(r,Xt.cffGlyphLoader(n,r,Tn,i,a.formatMajor))};else for(let e=0;e<n.nGlyphs;e+=1){let t=u.objects[e];n.glyphs.push(e,Xt.cffGlyphLoader(n,e,Tn,t,a.formatMajor))}if(l.vstore){let n=new q.Parser(e,t+l.vstore);l._vstore=n.parseVariationStore()}}function On(e,t){let n,r=ht.indexOf(e);return r>=0&&(n=r),r=t.indexOf(e),r>=0?n=r+ht.length:(n=ht.length+t.length,t.push(e)),n}function kn(){return new G.Record(`Header`,[{name:`major`,type:`Card8`,value:1},{name:`minor`,type:`Card8`,value:0},{name:`hdrSize`,type:`Card8`,value:4},{name:`major`,type:`Card8`,value:1}])}function An(e){let t=new G.Record(`Name INDEX`,[{name:`names`,type:`INDEX`,value:[]}]);t.names=[];for(let n=0;n<e.length;n+=1)t.names.push({name:`name_`+n,type:`NAME`,value:e[n]});return t}function jn(e,t,n){let r={};for(let i=0;i<e.length;i+=1){let a=e[i],o=t[a.name];o!==void 0&&!Zt(o,a.value)&&(a.type===`SID`&&(o=On(o,n)),r[a.op]={name:a.name,type:a.type,value:o})}return r}function Mn(e,t,n){let r=new G.Record(`Top DICT`,[{name:`dict`,type:`DICT`,value:{}}]);return r.dict=jn(n>1?fn:dn,e,t),r}function Nn(e){let t=new G.Record(`Top DICT INDEX`,[{name:`topDicts`,type:`INDEX`,value:[]}]);return t.topDicts=[{name:`topDict_0`,type:`TABLE`,value:e}],t}function Pn(e){let t=new G.Record(`String INDEX`,[{name:`strings`,type:`INDEX`,value:[]}]);t.strings=[];for(let n=0;n<e.length;n+=1)t.strings.push({name:`string_`+n,type:`STRING`,value:e[n]});return t}function Fn(){return new G.Record(`Global Subr INDEX`,[{name:`subrs`,type:`INDEX`,value:[]}])}function In(e,t){let n=new G.Record(`Charsets`,[{name:`format`,type:`Card8`,value:0}]);for(let r=0;r<e.length;r+=1){let i=e[r],a=On(i,t);n.fields.push({name:`glyph_`+r,type:`SID`,value:a})}return n}function Ln(e,t){let n=[],r=e.path;t<2&&n.push({name:`width`,type:`NUMBER`,value:e.advanceWidth});let i=0,a=0;for(let e=0;e<r.commands.length;e+=1){let t,o,s=r.commands[e];if(s.type===`Q`){let e=1/3,t=2/3;s={type:`C`,x:s.x,y:s.y,x1:Math.round(e*i+t*s.x1),y1:Math.round(e*a+t*s.y1),x2:Math.round(e*s.x+t*s.x1),y2:Math.round(e*s.y+t*s.y1)}}if(s.type===`M`)t=Math.round(s.x-i),o=Math.round(s.y-a),n.push({name:`dx`,type:`NUMBER`,value:t}),n.push({name:`dy`,type:`NUMBER`,value:o}),n.push({name:`rmoveto`,type:`OP`,value:21}),i=Math.round(s.x),a=Math.round(s.y);else if(s.type===`L`)t=Math.round(s.x-i),o=Math.round(s.y-a),n.push({name:`dx`,type:`NUMBER`,value:t}),n.push({name:`dy`,type:`NUMBER`,value:o}),n.push({name:`rlineto`,type:`OP`,value:5}),i=Math.round(s.x),a=Math.round(s.y);else if(s.type===`C`){let e=Math.round(s.x1-i),r=Math.round(s.y1-a),c=Math.round(s.x2-s.x1),l=Math.round(s.y2-s.y1);t=Math.round(s.x-s.x2),o=Math.round(s.y-s.y2),n.push({name:`dx1`,type:`NUMBER`,value:e}),n.push({name:`dy1`,type:`NUMBER`,value:r}),n.push({name:`dx2`,type:`NUMBER`,value:c}),n.push({name:`dy2`,type:`NUMBER`,value:l}),n.push({name:`dx`,type:`NUMBER`,value:t}),n.push({name:`dy`,type:`NUMBER`,value:o}),n.push({name:`rrcurveto`,type:`OP`,value:8}),i=Math.round(s.x),a=Math.round(s.y)}}return t<2&&n.push({name:`endchar`,type:`OP`,value:14}),n}function Rn(e,t){let n=new G.Record(`CharStrings INDEX`,[{name:`charStrings`,type:`INDEX`,value:[]}]);for(let r=0;r<e.length;r+=1){let i=e.get(r),a=Ln(i,t);n.charStrings.push({name:i.name,type:`CHARSTRING`,value:a})}return n}function zn(e,t,n){let r=new G.Record(`Private DICT`,[{name:`dict`,type:`DICT`,value:{}}]);return r.dict=jn(n>1?mn:pn,e,t),r}function Bn(e,t){let n=new G.Table(`CFF `,[{name:`header`,type:`RECORD`},{name:`nameIndex`,type:`RECORD`},{name:`topDictIndex`,type:`RECORD`},{name:`stringIndex`,type:`RECORD`},{name:`globalSubrIndex`,type:`RECORD`},{name:`charsets`,type:`RECORD`},{name:`charStringsIndex`,type:`RECORD`},{name:`privateDict`,type:`RECORD`}]),r=1/t.unitsPerEm,i={version:t.version,fullName:t.fullName,familyName:t.familyName,weight:t.weightName,fontBBox:t.fontBBox||[0,0,0,0],fontMatrix:[r,0,0,r,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},a=t&&t.topDict||{};a.paintType&&(i.paintType=a.paintType,i.strokeWidth=a.strokeWidth||0);let o={},s=[],c;for(let t=1;t<e.length;t+=1)c=e.get(t),s.push(c.name);let l=[];n.header=kn(),n.nameIndex=An([t.postScriptName]);let u=Mn(i,l);return n.topDictIndex=Nn(u),n.globalSubrIndex=Fn(),n.charsets=In(s,l),n.charStringsIndex=Rn(e,1),n.privateDict=zn(o,l),n.stringIndex=Pn(l),i.charset=n.header.sizeOf()+n.nameIndex.sizeOf()+n.topDictIndex.sizeOf()+n.stringIndex.sizeOf()+n.globalSubrIndex.sizeOf(),i.encoding=0,i.charStrings=i.charset+n.charsets.sizeOf(),i.private[1]=i.charStrings+n.charStringsIndex.sizeOf(),u=Mn(i,l),n.topDictIndex=Nn(u),n}var Vn={parse:Dn,make:Bn};function Hn(e,t){let n={},r=new q.Parser(e,t);return n.version=r.parseVersion(),n.fontRevision=Math.round(r.parseFixed()*1e3)/1e3,n.checkSumAdjustment=r.parseULong(),n.magicNumber=r.parseULong(),R.argument(n.magicNumber===1594834165,`Font header has wrong magic number.`),n.flags=r.parseUShort(),n.unitsPerEm=r.parseUShort(),n.created=r.parseLongDateTime(),n.modified=r.parseLongDateTime(),n.xMin=r.parseShort(),n.yMin=r.parseShort(),n.xMax=r.parseShort(),n.yMax=r.parseShort(),n.macStyle=r.parseUShort(),n.lowestRecPPEM=r.parseUShort(),n.fontDirectionHint=r.parseShort(),n.indexToLocFormat=r.parseShort(),n.glyphDataFormat=r.parseShort(),n}function Un(e){let t=Math.round((/* @__PURE__ */ new Date()).getTime()/1e3)+2082844800,n=t,r=e.macStyle||0;return e.createdTimestamp&&(n=e.createdTimestamp+2082844800),new G.Table(`head`,[{name:`version`,type:`FIXED`,value:65536},{name:`fontRevision`,type:`FIXED`,value:65536},{name:`checkSumAdjustment`,type:`ULONG`,value:0},{name:`magicNumber`,type:`ULONG`,value:1594834165},{name:`flags`,type:`USHORT`,value:0},{name:`unitsPerEm`,type:`USHORT`,value:1e3},{name:`created`,type:`LONGDATETIME`,value:n},{name:`modified`,type:`LONGDATETIME`,value:t},{name:`xMin`,type:`SHORT`,value:0},{name:`yMin`,type:`SHORT`,value:0},{name:`xMax`,type:`SHORT`,value:0},{name:`yMax`,type:`SHORT`,value:0},{name:`macStyle`,type:`USHORT`,value:r},{name:`lowestRecPPEM`,type:`USHORT`,value:0},{name:`fontDirectionHint`,type:`SHORT`,value:2},{name:`indexToLocFormat`,type:`SHORT`,value:0},{name:`glyphDataFormat`,type:`SHORT`,value:0}],e)}var Wn={parse:Hn,make:Un};function Gn(e,t){let n={},r=new q.Parser(e,t);return n.version=r.parseVersion(),n.ascender=r.parseShort(),n.descender=r.parseShort(),n.lineGap=r.parseShort(),n.advanceWidthMax=r.parseUShort(),n.minLeftSideBearing=r.parseShort(),n.minRightSideBearing=r.parseShort(),n.xMaxExtent=r.parseShort(),n.caretSlopeRise=r.parseShort(),n.caretSlopeRun=r.parseShort(),n.caretOffset=r.parseShort(),r.relativeOffset+=8,n.metricDataFormat=r.parseShort(),n.numberOfHMetrics=r.parseUShort(),n}function Kn(e){return new G.Table(`hhea`,[{name:`version`,type:`FIXED`,value:65536},{name:`ascender`,type:`FWORD`,value:0},{name:`descender`,type:`FWORD`,value:0},{name:`lineGap`,type:`FWORD`,value:0},{name:`advanceWidthMax`,type:`UFWORD`,value:0},{name:`minLeftSideBearing`,type:`FWORD`,value:0},{name:`minRightSideBearing`,type:`FWORD`,value:0},{name:`xMaxExtent`,type:`FWORD`,value:0},{name:`caretSlopeRise`,type:`SHORT`,value:1},{name:`caretSlopeRun`,type:`SHORT`,value:0},{name:`caretOffset`,type:`SHORT`,value:0},{name:`reserved1`,type:`SHORT`,value:0},{name:`reserved2`,type:`SHORT`,value:0},{name:`reserved3`,type:`SHORT`,value:0},{name:`reserved4`,type:`SHORT`,value:0},{name:`metricDataFormat`,type:`SHORT`,value:0},{name:`numberOfHMetrics`,type:`USHORT`,value:0}],e)}var qn={parse:Gn,make:Kn};function Jn(e,t,n,r,i){let a,o,s=new q.Parser(e,t);for(let e=0;e<r;e+=1){e<n&&(a=s.parseUShort(),o=s.parseShort());let t=i.get(e);t.advanceWidth=a,t.leftSideBearing=o}}function Yn(e,t,n,r,i){e._hmtxTableData={};let a,o,s=new q.Parser(t,n);for(let t=0;t<i;t+=1)t<r&&(a=s.parseUShort(),o=s.parseShort()),e._hmtxTableData[t]={advanceWidth:a,leftSideBearing:o}}function Xn(e,t,n,r,i,a,o){o.lowMemory?Yn(e,t,n,r,i):Jn(t,n,r,i,a)}function Zn(e){let t=new G.Table(`hmtx`,[]);for(let n=0;n<e.length;n+=1){let r=e.get(n),i=r.advanceWidth||0,a=r.leftSideBearing||0;t.fields.push({name:`advanceWidth_`+n,type:`USHORT`,value:i}),t.fields.push({name:`leftSideBearing_`+n,type:`SHORT`,value:a})}return t}var Qn={parse:Xn,make:Zn};function $n(e){let t=new G.Table(`ltag`,[{name:`version`,type:`ULONG`,value:1},{name:`flags`,type:`ULONG`,value:0},{name:`numTags`,type:`ULONG`,value:e.length}]),n=``,r=12+e.length*4;for(let i=0;i<e.length;++i){let a=n.indexOf(e[i]);a<0&&(a=n.length,n+=e[i]),t.fields.push({name:`offset `+i,type:`USHORT`,value:r+a}),t.fields.push({name:`length `+i,type:`USHORT`,value:e[i].length})}return t.fields.push({name:`stringPool`,type:`CHARARRAY`,value:n}),t}function er(e,t){let n=new q.Parser(e,t),r=n.parseULong();R.argument(r===1,`Unsupported ltag table version.`),n.skip(`uLong`,1);let i=n.parseULong(),a=[];for(let r=0;r<i;r++){let r=``,i=t+n.parseUShort(),o=n.parseUShort();for(let t=i;t<i+o;++t)r+=String.fromCharCode(e.getInt8(t));a.push(r)}return a}var tr={make:$n,parse:er};function nr(e,t){let n={},r=new q.Parser(e,t);return n.version=r.parseVersion(),n.numGlyphs=r.parseUShort(),n.version===1&&(n.maxPoints=r.parseUShort(),n.maxContours=r.parseUShort(),n.maxCompositePoints=r.parseUShort(),n.maxCompositeContours=r.parseUShort(),n.maxZones=r.parseUShort(),n.maxTwilightPoints=r.parseUShort(),n.maxStorage=r.parseUShort(),n.maxFunctionDefs=r.parseUShort(),n.maxInstructionDefs=r.parseUShort(),n.maxStackElements=r.parseUShort(),n.maxSizeOfInstructions=r.parseUShort(),n.maxComponentElements=r.parseUShort(),n.maxComponentDepth=r.parseUShort()),n}function rr(e){return new G.Table(`maxp`,[{name:`version`,type:`FIXED`,value:20480},{name:`numGlyphs`,type:`USHORT`,value:e}])}var ir={parse:nr,make:rr},ar=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function or(e){for(let t=0;t<ar.length;t+=1){let n=ar[t];if(e>=n.begin&&e<n.end)return t}return-1}function sr(e,t){let n={},r=new q.Parser(e,t);n.version=r.parseUShort(),n.xAvgCharWidth=r.parseShort(),n.usWeightClass=r.parseUShort(),n.usWidthClass=r.parseUShort(),n.fsType=r.parseUShort(),n.ySubscriptXSize=r.parseShort(),n.ySubscriptYSize=r.parseShort(),n.ySubscriptXOffset=r.parseShort(),n.ySubscriptYOffset=r.parseShort(),n.ySuperscriptXSize=r.parseShort(),n.ySuperscriptYSize=r.parseShort(),n.ySuperscriptXOffset=r.parseShort(),n.ySuperscriptYOffset=r.parseShort(),n.yStrikeoutSize=r.parseShort(),n.yStrikeoutPosition=r.parseShort(),n.sFamilyClass=r.parseShort(),n.panose=[];for(let e=0;e<10;e++)n.panose[e]=r.parseByte();return n.ulUnicodeRange1=r.parseULong(),n.ulUnicodeRange2=r.parseULong(),n.ulUnicodeRange3=r.parseULong(),n.ulUnicodeRange4=r.parseULong(),n.achVendID=String.fromCharCode(r.parseByte(),r.parseByte(),r.parseByte(),r.parseByte()),n.fsSelection=r.parseUShort(),n.usFirstCharIndex=r.parseUShort(),n.usLastCharIndex=r.parseUShort(),n.sTypoAscender=r.parseShort(),n.sTypoDescender=r.parseShort(),n.sTypoLineGap=r.parseShort(),n.usWinAscent=r.parseUShort(),n.usWinDescent=r.parseUShort(),n.version>=1&&(n.ulCodePageRange1=r.parseULong(),n.ulCodePageRange2=r.parseULong()),n.version>=2&&(n.sxHeight=r.parseShort(),n.sCapHeight=r.parseShort(),n.usDefaultChar=r.parseUShort(),n.usBreakChar=r.parseUShort(),n.usMaxContent=r.parseUShort()),n}function cr(e){return new G.Table(`OS/2`,[{name:`version`,type:`USHORT`,value:3},{name:`xAvgCharWidth`,type:`SHORT`,value:0},{name:`usWeightClass`,type:`USHORT`,value:0},{name:`usWidthClass`,type:`USHORT`,value:0},{name:`fsType`,type:`USHORT`,value:0},{name:`ySubscriptXSize`,type:`SHORT`,value:650},{name:`ySubscriptYSize`,type:`SHORT`,value:699},{name:`ySubscriptXOffset`,type:`SHORT`,value:0},{name:`ySubscriptYOffset`,type:`SHORT`,value:140},{name:`ySuperscriptXSize`,type:`SHORT`,value:650},{name:`ySuperscriptYSize`,type:`SHORT`,value:699},{name:`ySuperscriptXOffset`,type:`SHORT`,value:0},{name:`ySuperscriptYOffset`,type:`SHORT`,value:479},{name:`yStrikeoutSize`,type:`SHORT`,value:49},{name:`yStrikeoutPosition`,type:`SHORT`,value:258},{name:`sFamilyClass`,type:`SHORT`,value:0},{name:`bFamilyType`,type:`BYTE`,value:0},{name:`bSerifStyle`,type:`BYTE`,value:0},{name:`bWeight`,type:`BYTE`,value:0},{name:`bProportion`,type:`BYTE`,value:0},{name:`bContrast`,type:`BYTE`,value:0},{name:`bStrokeVariation`,type:`BYTE`,value:0},{name:`bArmStyle`,type:`BYTE`,value:0},{name:`bLetterform`,type:`BYTE`,value:0},{name:`bMidline`,type:`BYTE`,value:0},{name:`bXHeight`,type:`BYTE`,value:0},{name:`ulUnicodeRange1`,type:`ULONG`,value:0},{name:`ulUnicodeRange2`,type:`ULONG`,value:0},{name:`ulUnicodeRange3`,type:`ULONG`,value:0},{name:`ulUnicodeRange4`,type:`ULONG`,value:0},{name:`achVendID`,type:`CHARARRAY`,value:`XXXX`},{name:`fsSelection`,type:`USHORT`,value:0},{name:`usFirstCharIndex`,type:`USHORT`,value:0},{name:`usLastCharIndex`,type:`USHORT`,value:0},{name:`sTypoAscender`,type:`SHORT`,value:0},{name:`sTypoDescender`,type:`SHORT`,value:0},{name:`sTypoLineGap`,type:`SHORT`,value:0},{name:`usWinAscent`,type:`USHORT`,value:0},{name:`usWinDescent`,type:`USHORT`,value:0},{name:`ulCodePageRange1`,type:`ULONG`,value:0},{name:`ulCodePageRange2`,type:`ULONG`,value:0},{name:`sxHeight`,type:`SHORT`,value:0},{name:`sCapHeight`,type:`SHORT`,value:0},{name:`usDefaultChar`,type:`USHORT`,value:0},{name:`usBreakChar`,type:`USHORT`,value:0},{name:`usMaxContext`,type:`USHORT`,value:0}],e)}var lr={parse:sr,make:cr,unicodeRanges:ar,getUnicodeRange:or};function ur(e,t){let n={},r=new q.Parser(e,t);switch(n.version=r.parseVersion(),n.italicAngle=r.parseFixed(),n.underlinePosition=r.parseShort(),n.underlineThickness=r.parseShort(),n.isFixedPitch=r.parseULong(),n.minMemType42=r.parseULong(),n.maxMemType42=r.parseULong(),n.minMemType1=r.parseULong(),n.maxMemType1=r.parseULong(),n.version){case 1:n.names=xt.slice();break;case 2:n.numberOfGlyphs=r.parseUShort(),n.glyphNameIndex=Array(n.numberOfGlyphs);for(let e=0;e<n.numberOfGlyphs;e++)n.glyphNameIndex[e]=r.parseUShort();n.names=[];for(let e=0;e<n.numberOfGlyphs;e++)if(n.glyphNameIndex[e]>=xt.length){let e=r.parseChar();n.names.push(r.parseString(e))}break;case 2.5:n.numberOfGlyphs=r.parseUShort(),n.offset=Array(n.numberOfGlyphs);for(let e=0;e<n.numberOfGlyphs;e++)n.offset[e]=r.parseChar()}return n}function dr(e){let{italicAngle:t=Math.round((e.italicAngle||0)*65536),underlinePosition:n=0,underlineThickness:r=0,isFixedPitch:i=0,minMemType42:a=0,maxMemType42:o=0,minMemType1:s=0,maxMemType1:c=0}=e.tables.post||{};return new G.Table(`post`,[{name:`version`,type:`FIXED`,value:196608},{name:`italicAngle`,type:`FIXED`,value:t},{name:`underlinePosition`,type:`FWORD`,value:n},{name:`underlineThickness`,type:`FWORD`,value:r},{name:`isFixedPitch`,type:`ULONG`,value:i},{name:`minMemType42`,type:`ULONG`,value:a},{name:`maxMemType42`,type:`ULONG`,value:o},{name:`minMemType1`,type:`ULONG`,value:s},{name:`maxMemType1`,type:`ULONG`,value:c}])}var fr={parse:ur,make:dr},pr=Array(9);pr[1]=function(){let e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(K.coverage),deltaGlyphId:this.parseShort()};if(t===2)return{substFormat:2,coverage:this.parsePointer(K.coverage),substitute:this.parseOffset16List()};R.assert(!1,`0x`+e.toString(16)+`: lookup type 1 format must be 1 or 2.`)},pr[2]=function(){let e=this.parseUShort();return R.argument(e===1,`GSUB Multiple Substitution Subtable identifier-format must be 1`),{substFormat:e,coverage:this.parsePointer(K.coverage),sequences:this.parseListOfLists()}},pr[3]=function(){let e=this.parseUShort();return R.argument(e===1,`GSUB Alternate Substitution Subtable identifier-format must be 1`),{substFormat:e,coverage:this.parsePointer(K.coverage),alternateSets:this.parseListOfLists()}},pr[4]=function(){let e=this.parseUShort();return R.argument(e===1,`GSUB ligature table identifier-format must be 1`),{substFormat:e,coverage:this.parsePointer(K.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var mr={sequenceIndex:K.uShort,lookupListIndex:K.uShort};pr[5]=function(){let e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:t,coverage:this.parsePointer(K.coverage),ruleSets:this.parseListOfLists(function(){let e=this.parseUShort(),t=this.parseUShort();return{input:this.parseUShortList(e-1),lookupRecords:this.parseRecordList(t,mr)}})};if(t===2)return{substFormat:t,coverage:this.parsePointer(K.coverage),classDef:this.parsePointer(K.classDef),classSets:this.parseListOfLists(function(){let e=this.parseUShort(),t=this.parseUShort();return{classes:this.parseUShortList(e-1),lookupRecords:this.parseRecordList(t,mr)}})};if(t===3){let e=this.parseUShort(),n=this.parseUShort();return{substFormat:t,coverages:this.parseList(e,K.pointer(K.coverage)),lookupRecords:this.parseRecordList(n,mr)}}R.assert(!1,`0x`+e.toString(16)+`: lookup type 5 format must be 1, 2 or 3.`)},pr[6]=function(){let e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(K.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(mr)}})};if(t===2)return{substFormat:2,coverage:this.parsePointer(K.coverage),backtrackClassDef:this.parsePointer(K.classDef),inputClassDef:this.parsePointer(K.classDef),lookaheadClassDef:this.parsePointer(K.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(mr)}})};if(t===3)return{substFormat:3,backtrackCoverage:this.parseList(K.pointer(K.coverage)),inputCoverage:this.parseList(K.pointer(K.coverage)),lookaheadCoverage:this.parseList(K.pointer(K.coverage)),lookupRecords:this.parseRecordList(mr)};R.assert(!1,`0x`+e.toString(16)+`: lookup type 6 format must be 1, 2 or 3.`)},pr[7]=function(){let e=this.parseUShort();R.argument(e===1,`GSUB Extension Substitution subtable identifier-format must be 1`);let t=this.parseUShort(),n=new K(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:pr[t].call(n)}},pr[8]=function(){let e=this.parseUShort();return R.argument(e===1,`GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1`),{substFormat:e,coverage:this.parsePointer(K.coverage),backtrackCoverage:this.parseList(K.pointer(K.coverage)),lookaheadCoverage:this.parseList(K.pointer(K.coverage)),substitutes:this.parseUShortList()}};function hr(e,t){t||=0;let n=new K(e,t),r=n.parseVersion(1);return R.argument(r===1||r===1.1,`Unsupported GSUB table version.`),r===1?{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(pr)}:{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(pr),variations:n.parseFeatureVariationsList()}}var gr=Array(9);gr[1]=function(e){if(e.substFormat===1)return new G.Table(`substitutionTable`,[{name:`substFormat`,type:`USHORT`,value:1},{name:`coverage`,type:`TABLE`,value:new G.Coverage(e.coverage)},{name:`deltaGlyphID`,type:`SHORT`,value:e.deltaGlyphId}]);if(e.substFormat===2)return new G.Table(`substitutionTable`,[{name:`substFormat`,type:`USHORT`,value:2},{name:`coverage`,type:`TABLE`,value:new G.Coverage(e.coverage)}].concat(G.ushortList(`substitute`,e.substitute)));R.fail(`Lookup type 1 substFormat must be 1 or 2.`)},gr[2]=function(e){return R.assert(e.substFormat===1,`Lookup type 2 substFormat must be 1.`),new G.Table(`substitutionTable`,[{name:`substFormat`,type:`USHORT`,value:1},{name:`coverage`,type:`TABLE`,value:new G.Coverage(e.coverage)}].concat(G.tableList(`seqSet`,e.sequences,function(e){return new G.Table(`sequenceSetTable`,G.ushortList(`sequence`,e))})))},gr[3]=function(e){return R.assert(e.substFormat===1,`Lookup type 3 substFormat must be 1.`),new G.Table(`substitutionTable`,[{name:`substFormat`,type:`USHORT`,value:1},{name:`coverage`,type:`TABLE`,value:new G.Coverage(e.coverage)}].concat(G.tableList(`altSet`,e.alternateSets,function(e){return new G.Table(`alternateSetTable`,G.ushortList(`alternate`,e))})))},gr[4]=function(e){return R.assert(e.substFormat===1,`Lookup type 4 substFormat must be 1.`),new G.Table(`substitutionTable`,[{name:`substFormat`,type:`USHORT`,value:1},{name:`coverage`,type:`TABLE`,value:new G.Coverage(e.coverage)}].concat(G.tableList(`ligSet`,e.ligatureSets,function(e){return new G.Table(`ligatureSetTable`,G.tableList(`ligature`,e,function(e){return new G.Table(`ligatureTable`,[{name:`ligGlyph`,type:`USHORT`,value:e.ligGlyph}].concat(G.ushortList(`component`,e.components,e.components.length+1)))}))})))},gr[5]=function(e){if(e.substFormat===1)return new G.Table(`contextualSubstitutionTable`,[{name:`substFormat`,type:`USHORT`,value:e.substFormat},{name:`coverage`,type:`TABLE`,value:new G.Coverage(e.coverage)}].concat(G.tableList(`sequenceRuleSet`,e.ruleSets,function(e){return e?new G.Table(`sequenceRuleSetTable`,G.tableList(`sequenceRule`,e,function(e){let t=G.ushortList(`seqLookup`,[],e.lookupRecords.length).concat(G.ushortList(`inputSequence`,e.input,e.input.length+1));[t[0],t[1]]=[t[1],t[0]];for(let n=0;n<e.lookupRecords.length;n++){let r=e.lookupRecords[n];t=t.concat({name:`sequenceIndex`+n,type:`USHORT`,value:r.sequenceIndex}).concat({name:`lookupListIndex`+n,type:`USHORT`,value:r.lookupListIndex})}return new G.Table(`sequenceRuleTable`,t)})):new G.Table(`NULL`,null)})));if(e.substFormat===2)return new G.Table(`contextualSubstitutionTable`,[{name:`substFormat`,type:`USHORT`,value:e.substFormat},{name:`coverage`,type:`TABLE`,value:new G.Coverage(e.coverage)},{name:`classDef`,type:`TABLE`,value:new G.ClassDef(e.classDef)}].concat(G.tableList(`classSeqRuleSet`,e.classSets,function(e){return e?new G.Table(`classSeqRuleSetTable`,G.tableList(`classSeqRule`,e,function(e){let t=G.ushortList(`classes`,e.classes,e.classes.length+1).concat(G.ushortList(`seqLookupCount`,[],e.lookupRecords.length));for(let n=0;n<e.lookupRecords.length;n++){let r=e.lookupRecords[n];t=t.concat({name:`sequenceIndex`+n,type:`USHORT`,value:r.sequenceIndex}).concat({name:`lookupListIndex`+n,type:`USHORT`,value:r.lookupListIndex})}return new G.Table(`classSeqRuleTable`,t)})):new G.Table(`NULL`,null)})));if(e.substFormat===3){let t=[{name:`substFormat`,type:`USHORT`,value:e.substFormat}];t.push({name:`inputGlyphCount`,type:`USHORT`,value:e.coverages.length}),t.push({name:`substitutionCount`,type:`USHORT`,value:e.lookupRecords.length});for(let n=0;n<e.coverages.length;n++){let r=e.coverages[n];t.push({name:`inputCoverage`+n,type:`TABLE`,value:new G.Coverage(r)})}for(let n=0;n<e.lookupRecords.length;n++){let r=e.lookupRecords[n];t=t.concat({name:`sequenceIndex`+n,type:`USHORT`,value:r.sequenceIndex}).concat({name:`lookupListIndex`+n,type:`USHORT`,value:r.lookupListIndex})}return new G.Table(`contextualSubstitutionTable`,t)}R.assert(!1,`lookup type 5 format must be 1, 2 or 3.`)},gr[6]=function(e){if(e.substFormat===1)return new G.Table(`chainContextTable`,[{name:`substFormat`,type:`USHORT`,value:e.substFormat},{name:`coverage`,type:`TABLE`,value:new G.Coverage(e.coverage)}].concat(G.tableList(`chainRuleSet`,e.chainRuleSets,function(e){return new G.Table(`chainRuleSetTable`,G.tableList(`chainRule`,e,function(e){let t=G.ushortList(`backtrackGlyph`,e.backtrack,e.backtrack.length).concat(G.ushortList(`inputGlyph`,e.input,e.input.length+1)).concat(G.ushortList(`lookaheadGlyph`,e.lookahead,e.lookahead.length)).concat(G.ushortList(`substitution`,[],e.lookupRecords.length));for(let n=0;n<e.lookupRecords.length;n++){let r=e.lookupRecords[n];t=t.concat({name:`sequenceIndex`+n,type:`USHORT`,value:r.sequenceIndex}).concat({name:`lookupListIndex`+n,type:`USHORT`,value:r.lookupListIndex})}return new G.Table(`chainRuleTable`,t)}))})));if(e.substFormat===2)R.assert(!1,`lookup type 6 format 2 is not yet supported.`);else if(e.substFormat===3){let t=[{name:`substFormat`,type:`USHORT`,value:e.substFormat}];t.push({name:`backtrackGlyphCount`,type:`USHORT`,value:e.backtrackCoverage.length});for(let n=0;n<e.backtrackCoverage.length;n++){let r=e.backtrackCoverage[n];t.push({name:`backtrackCoverage`+n,type:`TABLE`,value:new G.Coverage(r)})}t.push({name:`inputGlyphCount`,type:`USHORT`,value:e.inputCoverage.length});for(let n=0;n<e.inputCoverage.length;n++){let r=e.inputCoverage[n];t.push({name:`inputCoverage`+n,type:`TABLE`,value:new G.Coverage(r)})}t.push({name:`lookaheadGlyphCount`,type:`USHORT`,value:e.lookaheadCoverage.length});for(let n=0;n<e.lookaheadCoverage.length;n++){let r=e.lookaheadCoverage[n];t.push({name:`lookaheadCoverage`+n,type:`TABLE`,value:new G.Coverage(r)})}t.push({name:`substitutionCount`,type:`USHORT`,value:e.lookupRecords.length});for(let n=0;n<e.lookupRecords.length;n++){let r=e.lookupRecords[n];t=t.concat({name:`sequenceIndex`+n,type:`USHORT`,value:r.sequenceIndex}).concat({name:`lookupListIndex`+n,type:`USHORT`,value:r.lookupListIndex})}return new G.Table(`chainContextTable`,t)}R.assert(!1,`lookup type 6 format must be 1, 2 or 3.`)};function _r(e){return new G.Table(`GSUB`,[{name:`version`,type:`ULONG`,value:65536},{name:`scripts`,type:`TABLE`,value:new G.ScriptList(e.scripts)},{name:`features`,type:`TABLE`,value:new G.FeatureList(e.features)},{name:`lookups`,type:`TABLE`,value:new G.LookupList(e.lookups,gr)}])}var vr={parse:hr,make:_r};function yr(e,t){let n=new q.Parser(e,t),r=n.parseULong();R.argument(r===1,`Unsupported META table version.`),n.parseULong(),n.parseULong();let i=n.parseULong(),a={};for(let r=0;r<i;r++){let r=n.parseTag(),i=n.parseULong(),o=n.parseULong();r!==`appl`&&r!==`bild`&&(a[r]=le.UTF8(e,t+i,o))}return a}function br(e){let t=Object.keys(e).length,n=``,r=16+t*12,i=new G.Table(`meta`,[{name:`version`,type:`ULONG`,value:1},{name:`flags`,type:`ULONG`,value:0},{name:`offset`,type:`ULONG`,value:r},{name:`numTags`,type:`ULONG`,value:t}]);for(let t in e){let a=n.length;n+=e[t],i.fields.push({name:`tag `+t,type:`TAG`,value:t}),i.fields.push({name:`offset `+t,type:`ULONG`,value:r+a}),i.fields.push({name:`length `+t,type:`ULONG`,value:e[t].length})}return i.fields.push({name:`stringPool`,type:`CHARARRAY`,value:n}),i}var xr={parse:yr,make:br};function Sr(e,t){let n=new K(e,t),r=n.parseUShort();r!==0&&console.warn(`Only COLRv0 is currently fully supported. A subset of color glyphs might be available in this font if provided in the v0 format.`);let i=n.parseUShort(),a=n.parseOffset32(),o=n.parseOffset32(),s=n.parseUShort();n.relativeOffset=a;let c=n.parseRecordList(i,{glyphID:K.uShort,firstLayerIndex:K.uShort,numLayers:K.uShort});return n.relativeOffset=o,{version:r,baseGlyphRecords:c,layerRecords:n.parseRecordList(s,{glyphID:K.uShort,paletteIndex:K.uShort})}}function Cr({version:e=0,baseGlyphRecords:t=[],layerRecords:n=[]}){R.argument(e===0,`Only COLRv0 supported.`);let r=14+t.length*6;return new G.Table(`COLR`,[{name:`version`,type:`USHORT`,value:e},{name:`numBaseGlyphRecords`,type:`USHORT`,value:t.length},{name:`baseGlyphRecordsOffset`,type:`ULONG`,value:14},{name:`layerRecordsOffset`,type:`ULONG`,value:r},{name:`numLayerRecords`,type:`USHORT`,value:n.length},...t.map((e,t)=>[{name:`glyphID_`+t,type:`USHORT`,value:e.glyphID},{name:`firstLayerIndex_`+t,type:`USHORT`,value:e.firstLayerIndex},{name:`numLayers_`+t,type:`USHORT`,value:e.numLayers}]).flat(),...n.map((e,t)=>[{name:`LayerGlyphID_`+t,type:`USHORT`,value:e.glyphID},{name:`paletteIndex_`+t,type:`USHORT`,value:e.paletteIndex}]).flat()])}var wr={parse:Sr,make:Cr};function Tr(e,t){return[{name:`tag_`+e,type:`TAG`,value:t.tag},{name:`minValue_`+e,type:`FIXED`,value:t.minValue<<16},{name:`defaultValue_`+e,type:`FIXED`,value:t.defaultValue<<16},{name:`maxValue_`+e,type:`FIXED`,value:t.maxValue<<16},{name:`flags_`+e,type:`USHORT`,value:0},{name:`nameID_`+e,type:`USHORT`,value:t.axisNameID}]}function Er(e,t,n){let r={},i=new q.Parser(e,t);r.tag=i.parseTag(),r.minValue=i.parseFixed(),r.defaultValue=i.parseFixed(),r.maxValue=i.parseFixed(),i.skip(`uShort`,1);let a=i.parseUShort();return r.axisNameID=a,r.name=rt(n,a),r}function Dr(e,t,n,r={}){let i=[{name:`nameID_`+e,type:`USHORT`,value:t.subfamilyNameID},{name:`flags_`+e,type:`USHORT`,value:0}];for(let r=0;r<n.length;++r){let a=n[r].tag;i.push({name:`axis_`+e+` `+a,type:`FIXED`,value:t.coordinates[a]<<16})}return r&&r.postScriptNameID&&i.push({name:`postScriptNameID_`,type:`USHORT`,value:t.postScriptNameID===void 0?65535:t.postScriptNameID}),i}function Or(e,t,n,r,i){let a={},o=new q.Parser(e,t),s=o.parseUShort();a.subfamilyNameID=s,a.name=rt(r,s,[2,17]),o.skip(`uShort`,1),a.coordinates={};for(let e=0;e<n.length;++e)a.coordinates[n[e].tag]=o.parseFixed();if(o.relativeOffset===i)return a.postScriptNameID=void 0,a.postScriptName=void 0,a;let c=o.parseUShort();return a.postScriptNameID=c==65535?void 0:c,a.postScriptName=a.postScriptNameID===void 0?``:rt(r,c,[6]),a}function kr(e,t){let n=new G.Table(`fvar`,[{name:`version`,type:`ULONG`,value:65536},{name:`offsetToData`,type:`USHORT`,value:0},{name:`countSizePairs`,type:`USHORT`,value:2},{name:`axisCount`,type:`USHORT`,value:e.axes.length},{name:`axisSize`,type:`USHORT`,value:20},{name:`instanceCount`,type:`USHORT`,value:e.instances.length},{name:`instanceSize`,type:`USHORT`,value:4+e.axes.length*4}]);n.offsetToData=n.sizeOf();for(let r=0;r<e.axes.length;r++)n.fields=n.fields.concat(Tr(r,e.axes[r],t));let r={};for(let t=0;t<e.instances.length;t++)if(e.instances[t].postScriptNameID!==void 0){n.instanceSize+=2,r.postScriptNameID=!0;break}for(let t=0;t<e.instances.length;t++)n.fields=n.fields.concat(Dr(t,e.instances[t],e.axes,r));return n}function Ar(e,t,n){let r=new q.Parser(e,t),i=r.parseULong();R.argument(i===65536,`Unsupported fvar table version.`);let a=r.parseOffset16();r.skip(`uShort`,1);let o=r.parseUShort(),s=r.parseUShort(),c=r.parseUShort(),l=r.parseUShort(),u=[];for(let r=0;r<o;r++)u.push(Er(e,t+a+r*s,n));let d=[],f=t+a+o*s;for(let t=0;t<c;t++)d.push(Or(e,f+t*l,u,n,l));return{axes:u,instances:d}}var jr={make:kr,parse:Ar},Mr={tag:K.tag,nameID:K.uShort,ordering:K.uShort},Nr=[,,,,,];Nr[1]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed()}},Nr[2]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),nominalValue:this.parseFixed(),rangeMinValue:this.parseFixed(),rangeMaxValue:this.parseFixed()}},Nr[3]=function(){return{axisIndex:this.parseUShort(),flags:this.parseUShort(),valueNameID:this.parseUShort(),value:this.parseFixed(),linkedValue:this.parseFixed()}},Nr[4]=function(){let e=this.parseUShort();return{flags:this.parseUShort(),valueNameID:this.parseUShort(),axisValues:this.parseList(e,function(){return{axisIndex:this.parseUShort(),value:this.parseFixed()}})}};function Pr(){let e=this.parseUShort(),t=Nr[e],n={format:e};return t===void 0?(console.warn(`Unknown axis value table format ${e}`),n):Object.assign(n,this.parseStruct(t.bind(this)))}function Fr(e,t,n){t||=0;let r=new q.Parser(e,t),i=r.parseUShort(),a=r.parseUShort();i!==1&&console.warn(`Unsupported STAT table version ${i}.${a}`);let o=[i,a],s=r.parseUShort(),c=r.parseUShort(),l=r.parseOffset32(),u=r.parseUShort(),d=r.parseOffset32(),f=i>1||a>0?r.parseUShort():void 0;n!==void 0&&R.argument(c>=n.axes.length,`STAT axis count must be greater than or equal to fvar axis count`),u>0&&R.argument(c>=0,`STAT axis count must be greater than 0 if STAT axis value count is greater than 0`);let p=[];for(let e=0;e<c;e++)r.offset=t+l,r.relativeOffset=e*s,p.push(r.parseStruct(Mr));r.offset=t,r.relativeOffset=d;let m=r.parseUShortList(u),h=[];for(let e=0;e<u;e++)r.offset=t+d,r.relativeOffset=m[e],h.push(Pr.apply(r));return{version:o,axes:p,values:h,elidedFallbackNameID:f}}var Ir=[,,,,,];Ir[1]=function(e,t){return[{name:`format${e}`,type:`USHORT`,value:1},{name:`axisIndex${e}`,type:`USHORT`,value:t.axisIndex},{name:`flags${e}`,type:`USHORT`,value:t.flags},{name:`valueNameID${e}`,type:`USHORT`,value:t.valueNameID},{name:`value${e}`,type:`FLOAT`,value:t.value}]},Ir[2]=function(e,t){return[{name:`format${e}`,type:`USHORT`,value:2},{name:`axisIndex${e}`,type:`USHORT`,value:t.axisIndex},{name:`flags${e}`,type:`USHORT`,value:t.flags},{name:`valueNameID${e}`,type:`USHORT`,value:t.valueNameID},{name:`nominalValue${e}`,type:`FLOAT`,value:t.nominalValue},{name:`rangeMinValue${e}`,type:`FLOAT`,value:t.rangeMinValue},{name:`rangeMaxValue${e}`,type:`FLOAT`,value:t.rangeMaxValue}]},Ir[3]=function(e,t){return[{name:`format${e}`,type:`USHORT`,value:3},{name:`axisIndex${e}`,type:`USHORT`,value:t.axisIndex},{name:`flags${e}`,type:`USHORT`,value:t.flags},{name:`valueNameID${e}`,type:`USHORT`,value:t.valueNameID},{name:`value${e}`,type:`FLOAT`,value:t.value},{name:`linkedValue${e}`,type:`FLOAT`,value:t.linkedValue}]},Ir[4]=function(e,t){let n=[{name:`format${e}`,type:`USHORT`,value:4},{name:`axisCount${e}`,type:`USHORT`,value:t.axisValues.length},{name:`flags${e}`,type:`USHORT`,value:t.flags},{name:`valueNameID${e}`,type:`USHORT`,value:t.valueNameID}];for(let r=0;r<t.axisValues.length;r++)n=n.concat([{name:`format${e}axisIndex${r}`,type:`USHORT`,value:t.axisValues[r].axisIndex},{name:`format${e}value${r}`,type:`FLOAT`,value:t.axisValues[r].value}]);return n};function Lr(e,t){return new G.Record(`axisRecord_`+e,[{name:`axisTag_`+e,type:`TAG`,value:t.tag},{name:`axisNameID_`+e,type:`USHORT`,value:t.nameID},{name:`axisOrdering_`+e,type:`USHORT`,value:t.ordering}])}function Rr(e,t){let n=t.format,r=Ir[n];R.argument(r!==void 0,`Unknown axis value table format ${n}`);let i=r(e,t);return new G.Table(`axisValueTable_`+e,i)}function zr(e){let t=new G.Table(`STAT`,[{name:`majorVersion`,type:`USHORT`,value:1},{name:`minorVersion`,type:`USHORT`,value:2},{name:`designAxisSize`,type:`USHORT`,value:8},{name:`designAxisCount`,type:`USHORT`,value:e.axes.length},{name:`designAxesOffset`,type:`ULONG`,value:0},{name:`axisValueCount`,type:`USHORT`,value:e.values.length},{name:`offsetToAxisValueOffsets`,type:`ULONG`,value:0},{name:`elidedFallbackNameID`,type:`USHORT`,value:e.elidedFallbackNameID}]);t.designAxesOffset=t.offsetToAxisValueOffsets=t.sizeOf();for(let n=0;n<e.axes.length;n++){let r=Lr(n,e.axes[n]);t.offsetToAxisValueOffsets+=r.sizeOf(),t.fields=t.fields.concat(r.fields)}let n=[],r=[],i=e.values.length*2;for(let t=0;t<e.values.length;t++){let a=Rr(t,e.values[t]);n.push({name:`offset_`+t,type:`USHORT`,value:i}),i+=a.sizeOf(),r=r.concat(a.fields)}return t.fields=t.fields.concat(n),t.fields=t.fields.concat(r),t}var Br={make:zr,parse:Fr};function Vr(e,t){return new G.Record(`axisValueMap_`+e,[{name:`fromCoordinate_`+e,type:`F2DOT14`,value:t.fromCoordinate},{name:`toCoordinate_`+e,type:`F2DOT14`,value:t.toCoordinate}])}function Hr(e,t){let n=new G.Record(`segmentMap_`+e,[{name:`positionMapCount_`+e,type:`USHORT`,value:t.axisValueMaps.length}]),r=[];for(let n=0;n<t.axisValueMaps.length;n++){let i=Vr(`${e}_${n}`,t.axisValueMaps[n]);r=r.concat(i.fields)}return n.fields=n.fields.concat(r),n}function Ur(e,t){R.argument(e.axisSegmentMaps.length===t.axes.length,`avar axis count must correspond to fvar axis count`);let n=new G.Table(`avar`,[{name:`majorVersion`,type:`USHORT`,value:1},{name:`minorVersion`,type:`USHORT`,value:0},{name:`reserved`,type:`USHORT`,value:0},{name:`axisCount`,type:`USHORT`,value:e.axisSegmentMaps.length}]);for(let t=0;t<e.axisSegmentMaps.length;t++){let r=Hr(t,e.axisSegmentMaps[t]);n.fields=n.fields.concat(r.fields)}return n}function Wr(e,t,n){t||=0;let r=new K(e,t),i=r.parseUShort(),a=r.parseUShort();i!==1&&console.warn(`Unsupported avar table version ${i}.${a}`),r.skip(`uShort`,1);let o=r.parseUShort();R.argument(o===n.axes.length,`avar axis count must correspond to fvar axis count`);let s=[];for(let e=0;e<o;e++){let e=[],t=r.parseUShort();for(let n=0;n<t;n++){let t=r.parseF2Dot14(),n=r.parseF2Dot14();e.push({fromCoordinate:t,toCoordinate:n})}s.push({axisValueMaps:e})}return{version:[i,a],axisSegmentMaps:s}}var Gr={make:Ur,parse:Wr};function Kr(e,t,n,r){let i=new q.Parser(e,t),a=i.parseTupleVariationStore(i.relativeOffset,n.axes.length,`cvar`,r),o=i.parseUShort(),s=i.parseUShort();return o!==1&&console.warn(`Unsupported cvar table version ${o}.${s}`),{version:[o,s],...a}}function qr(){console.warn(`Writing of cvar tables is not yet supported.`)}var Jr={make:qr,parse:Kr};function Yr(e,t,n,r){let i=new q.Parser(e,t),a=i.parseUShort(),o=i.parseUShort();a!==1&&console.warn(`Unsupported gvar table version ${a}.${o}`);let s=i.parseUShort();s!==n.axes.length&&console.warn(`axisCount ${s} in gvar table does not match the number of axes ${n.axes.length} in the fvar table!`);let c=i.parseUShort(),l=i.parsePointer32(function(){return this.parseTupleRecords(c,s)}),u=i.parseTupleVariationStoreList(s,`gvar`,r);return{version:[a,o],sharedTuples:l,glyphVariations:u}}function Xr(){console.warn(`Writing of gvar tables is not yet supported.`)}var Zr={make:Xr,parse:Yr};function Qr(e,t){let n={},r=new q.Parser(e,t);n.version=r.parseUShort(),R.argument(n.version<=1,`Unsupported gasp table version.`),n.numRanges=r.parseUShort(),n.gaspRanges=[];for(let e=0;e<n.numRanges;e++)n.gaspRanges[e]={rangeMaxPPEM:r.parseUShort(),rangeGaspBehavior:r.parseUShort()};return n}function $r(e){let t=new G.Table(`gasp`,[{name:`version`,type:`USHORT`,value:1},{name:`numRanges`,type:`USHORT`,value:e.numRanges}]);for(let n in e.gaspRanges)t.fields.push({name:`rangeMaxPPEM`,type:`USHORT`,value:e.gaspRanges[n].rangeMaxPPEM}),t.fields.push({name:`rangeGaspBehavior`,type:`USHORT`,value:e.gaspRanges[n].rangeGaspBehavior});return t}var ei={parse:Qr,make:$r};function ti(e,t){let n=/* @__PURE__ */ new Map,r=e.buffer,i=new K(e,t);if(i.parseUShort()!==0)return n;i.relativeOffset=i.parseOffset32();let a=e.byteOffset+t+i.relativeOffset,o=i.parseUShort(),s=/* @__PURE__ */ new Map;for(let e=0;e<o;e++){let e=i.parseUShort(),t=i.parseUShort(),o=a+i.parseOffset32(),c=i.parseULong(),l=s.get(o);l===void 0&&(l=new Uint8Array(r,o,c),s.set(o,l));for(let r=e;r<=t;r++)n.set(r,l)}return n}function ni(e){let t=Array.from(e.keys()).sort(),n=[],r=[],i=/* @__PURE__ */ new Map,a=0,o={endGlyphID:null};for(let s=0,c=t.length;s<c;s++){let c=t[s],l=e.get(c),u=i.get(l);u===void 0&&(u=a,r.push(l),i.set(l,u),a+=l.byteLength),c-1===o.endGlyphID&&u===o.svgDocOffset?o.endGlyphID=c:(o={startGlyphID:c,endGlyphID:c,svgDocOffset:u,svgDocLength:l.byteLength},n.push(o))}let s=n.length,c=r.length,l=2+s*12,u=Array(4+s*4+c),d=0;u[d++]={name:`version`,type:`USHORT`,value:0},u[d++]={name:`svgDocumentListOffset`,type:`ULONG`,value:10},u[d++]={name:`reserved`,type:`ULONG`,value:0},u[d++]={name:`numEntries`,type:`USHORT`,value:s};for(let e=0;e<s;e++){let t=`documentRecord_`+e,{startGlyphID:r,endGlyphID:i,svgDocOffset:a,svgDocLength:o}=n[e];u[d++]={name:t+`_startGlyphID`,type:`USHORT`,value:r},u[d++]={name:t+`_endGlyphID`,type:`USHORT`,value:i},u[d++]={name:t+`_svgDocOffset`,type:`ULONG`,value:l+a},u[d++]={name:t+`_svgDocLength`,type:`ULONG`,value:o}}for(let e=0;e<c;e++)u[d++]={name:`svgDoc_`+e,type:`LITERAL`,value:r[e]};return new G.Table(`SVG `,u)}var ri={make:ni,parse:ti};function ii(e){return Math.log(e)/Math.log(2)|0}function ai(e){for(;e.length%4!=0;)e.push(0);let t=0;for(let n=0;n<e.length;n+=4)t+=(e[n]<<24)+(e[n+1]<<16)+(e[n+2]<<8)+e[n+3];return t%=2**32,t}function oi(e,t,n,r){return new G.Record(`Table Record`,[{name:`tag`,type:`TAG`,value:e===void 0?``:e},{name:`checkSum`,type:`ULONG`,value:t===void 0?0:t},{name:`offset`,type:`ULONG`,value:n===void 0?0:n},{name:`length`,type:`ULONG`,value:r===void 0?0:r}])}function si(e){let t=new G.Table(`sfnt`,[{name:`version`,type:`TAG`,value:`OTTO`},{name:`numTables`,type:`USHORT`,value:0},{name:`searchRange`,type:`USHORT`,value:0},{name:`entrySelector`,type:`USHORT`,value:0},{name:`rangeShift`,type:`USHORT`,value:0}]);t.tables=e,t.numTables=e.length;let n=2**ii(t.numTables);t.searchRange=16*n,t.entrySelector=ii(n),t.rangeShift=t.numTables*16-t.searchRange;let r=[],i=[],a=t.sizeOf()+oi().sizeOf()*t.numTables;for(;a%4!=0;)a+=1,i.push({name:`padding`,type:`BYTE`,value:0});for(let t=0;t<e.length;t+=1){let n=e[t];R.argument(n.tableName.length===4,`Table name`+n.tableName+` is invalid.`);let o=n.sizeOf(),s=oi(n.tableName,ai(n.encode()),a,o);for(r.push({name:s.tag+` Table Record`,type:`RECORD`,value:s}),i.push({name:n.tableName+` table`,type:`RECORD`,value:n}),a+=o,R.argument(!isNaN(a),`Something went wrong calculating the offset.`);a%4!=0;)a+=1,i.push({name:`padding`,type:`BYTE`,value:0})}return r.sort(function(e,t){return e.value.tag>t.value.tag?1:-1}),t.fields=t.fields.concat(r),t.fields=t.fields.concat(i),t}function ci(e,t,n){for(let n=0;n<t.length;n+=1){let r=e.charToGlyphIndex(t[n]);if(r>0)return e.glyphs.get(r).getMetrics()}return n}function li(e){let t=0;for(let n=0;n<e.length;n+=1)t+=e[n];return t/e.length}function ui(e){let t=[],n=[],r=[],i=[],a=[],o=[],s=[],c,l=0,u=0,d=0,f=0,p=0;for(let m=0;m<e.glyphs.length;m+=1){let h=e.glyphs.get(m),g=h.unicode|0;if(isNaN(h.advanceWidth))throw Error(`Glyph `+h.name+` (`+m+`): advanceWidth is not a number.`);(c>g||c===void 0)&&g>0&&(c=g),l<g&&(l=g);let _=lr.getUnicodeRange(g);if(_<32)u|=1<<_;else if(_<64)d|=1<<_-32;else if(_<96)f|=1<<_-64;else if(_<123)p|=1<<_-96;else throw Error(`Unicode ranges bits > 123 are reserved for internal usage`);if(h.name===`.notdef`)continue;let v=h.getMetrics();t.push(v.xMin),n.push(v.yMin),r.push(v.xMax),i.push(v.yMax),o.push(v.leftSideBearing),s.push(v.rightSideBearing),a.push(h.advanceWidth)}let m={xMin:Math.min.apply(null,t),yMin:Math.min.apply(null,n),xMax:Math.max.apply(null,r),yMax:Math.max.apply(null,i),advanceWidthMax:Math.max.apply(null,a),advanceWidthAvg:li(a),minLeftSideBearing:Math.min.apply(null,o),maxLeftSideBearing:Math.max.apply(null,o),minRightSideBearing:Math.min.apply(null,s)};m.ascender=e.ascender,m.descender=e.descender;let h=0;e.weightClass>=600&&(h|=e.macStyleValues.BOLD),e.italicAngle<0&&(h|=e.macStyleValues.ITALIC);let g=Wn.make({flags:3,unitsPerEm:e.unitsPerEm,xMin:m.xMin,yMin:m.yMin,xMax:m.xMax,yMax:m.yMax,lowestRecPPEM:3,macStyle:h,createdTimestamp:e.createdTimestamp}),_=qn.make({ascender:m.ascender,descender:m.descender,advanceWidthMax:m.advanceWidthMax,minLeftSideBearing:m.minLeftSideBearing,minRightSideBearing:m.minRightSideBearing,xMaxExtent:m.maxLeftSideBearing+(m.xMax-m.xMin),numberOfHMetrics:e.glyphs.length}),v=ir.make(e.glyphs.length),y=lr.make(Object.assign({xAvgCharWidth:Math.round(m.advanceWidthAvg),usFirstCharIndex:c,usLastCharIndex:l,ulUnicodeRange1:u,ulUnicodeRange2:d,ulUnicodeRange3:f,ulUnicodeRange4:p,sTypoAscender:m.ascender,sTypoDescender:m.descender,sTypoLineGap:0,usWinAscent:m.yMax,usWinDescent:Math.abs(m.yMin),ulCodePageRange1:1,sxHeight:ci(e,`xyvw`,{yMax:Math.round(m.ascender/2)}).yMax,sCapHeight:ci(e,`HIKLEFJMNTZBDPRAGOQSUVWXY`,m).yMax,usDefaultChar:e.hasChar(` `)?32:0,usBreakChar:e.hasChar(` `)?32:0},e.tables.os2)),b=Qn.make(e.glyphs),x=mt.make(e.glyphs),S=e.getEnglishName(`fontFamily`),C=e.getEnglishName(`fontSubfamily`),w=S+` `+C,T=e.getEnglishName(`postScriptName`);T||=S.replace(/\s/g,``)+`-`+C;let E={};for(let t in e.names)E[t]=e.names[t];E.unicode=E.unicode||{},E.macintosh=E.macintosh||{},E.windows=E.windows||{};let D=e.names.unicode||{},O=e.names.macintosh||{},k=e.names.windows||{};for(let t in E){if(E[t]=E[t]||{},!E[t].uniqueID){let n=e.getEnglishName(`manufacturer`)||``;E[t].uniqueID={en:`${n}: ${w}`}}E[t].postScriptName||(E[t].postScriptName={en:T})}E.unicode.preferredFamily||(E.unicode.preferredFamily=D.fontFamily||O.fontFamily||k.fontFamily),E.macintosh.preferredFamily||(E.macintosh.preferredFamily=O.fontFamily||D.fontFamily||k.fontFamily),E.windows.preferredFamily||(E.windows.preferredFamily=k.fontFamily||D.fontFamily||O.fontFamily),E.unicode.preferredSubfamily||(E.unicode.preferredSubfamily=D.fontSubfamily||O.fontSubfamily||k.fontSubfamily),E.macintosh.preferredSubfamily||(E.macintosh.preferredSubfamily=O.fontSubfamily||D.fontSubfamily||k.fontSubfamily),E.windows.preferredSubfamily||(E.windows.preferredSubfamily=k.fontSubfamily||D.fontSubfamily||O.fontSubfamily);let A=[],j=it.make(E,A),M=A.length>0?tr.make(A):void 0,ee=fr.make(e),N=Vn.make(e.glyphs,{version:e.getEnglishName(`version`),fullName:w,familyName:S,weightName:C,postScriptName:T,unitsPerEm:e.unitsPerEm,fontBBox:[0,m.yMin,m.ascender,m.advanceWidthMax],topDict:e.tables.cff&&e.tables.cff.topDict||{}}),P=e.metas&&Object.keys(e.metas).length>0?xr.make(e.metas):void 0,F=[g,_,v,y,j,x,ee,N,b];M&&F.push(M);let I={gsub:vr,cpal:Vt,colr:wr,stat:Br,avar:Gr,cvar:Jr,fvar:jr,gvar:Zr,gasp:ei,svg:ri},te={avar:[e.tables.fvar],fvar:[e.names]};for(let t in I){let n=e.tables[t];if(n){let r=I[t].make.call(e,n,...te[t]||[]);r&&F.push(r)}}P&&F.push(P);let ne=si(F),re=ai(ne.encode()),L=ne.fields,ie=!1;for(let e=0;e<L.length;e+=1)if(L[e].name===`head table`){L[e].value.checkSumAdjustment=2981146554-re,ie=!0;break}if(!ie)throw Error(`Could not find head table with checkSum to adjust.`);return ne}var di={make:si,fontToTable:ui,computeCheckSum:ai};function fi(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=n+r>>>1,a=e[i].tag;if(a===t)return i;a<t?n=i+1:r=i-1}return-n-1}function pi(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=n+r>>>1,a=e[i];if(a===t)return i;a<t?n=i+1:r=i-1}return-n-1}function mi(e,t){let n,r=0,i=e.length-1;for(;r<=i;){let a=r+i>>>1;n=e[a];let o=n.start;if(o===t)return n;o<t?r=a+1:i=a-1}if(r>0)return n=e[r-1],t>n.end?0:n}function hi(e,t){this.font=e,this.tableName=t}hi.prototype={searchTag:fi,binSearch:pi,getTable:function(e){let t=this.font.tables[this.tableName];return!t&&e&&(t=this.font.tables[this.tableName]=this.createDefaultTable()),t},getScriptNames:function(){let e=this.getTable();return e?e.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let e=this.getTable();if(!e)return;let t=!1;for(let n=0;n<e.scripts.length;n++){let r=e.scripts[n].tag;if(r===`DFLT`)return r;r===`latn`&&(t=!0)}if(t)return`latn`},getScriptTable:function(e,t){let n=this.getTable(t);if(n){e||=`DFLT`;let r=n.scripts,i=fi(n.scripts,e);if(i>=0)return r[i].script;if(t){let t={tag:e,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return r.splice(-1-i,0,t),t.script}}},getLangSysTable:function(e,t,n){let r=this.getScriptTable(e,n);if(r){if(!t||t===`dflt`||t===`DFLT`)return r.defaultLangSys;let e=fi(r.langSysRecords,t);if(e>=0)return r.langSysRecords[e].langSys;if(n){let n={tag:t,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return r.langSysRecords.splice(-1-e,0,n),n.langSys}}},getFeatureTable:function(e,t,n,r){let i=this.getLangSysTable(e,t,r);if(i){let e,t=i.featureIndexes,a=this.font.tables[this.tableName].features;for(let r=0;r<t.length;r++)if(e=a[t[r]],e.tag===n)return e.feature;if(r){let r=a.length;return R.assert(r===0||n>=a[r-1].tag,`Features must be added in alphabetical order.`),e={tag:n,feature:{params:0,lookupListIndexes:[]}},a.push(e),t.push(r),e.feature}}},getLookupTables:function(e,t,n,r,i){let a=this.getFeatureTable(e,t,n,i),o=[];if(a){let e,t=a.lookupListIndexes,n=this.font.tables[this.tableName].lookups;for(let i=0;i<t.length;i++)e=n[t[i]],e.lookupType===r&&o.push(e);if(o.length===0&&i){e={lookupType:r,lookupFlag:0,subtables:[],markFilteringSet:void 0};let i=n.length;return n.push(e),t.push(i),[e]}}return o},getGlyphClass:function(e,t){switch(e.format){case 1:return e.startGlyph<=t&&t<e.startGlyph+e.classes.length?e.classes[t-e.startGlyph]:0;case 2:{let n=mi(e.ranges,t);return n?n.classId:0}}},getCoverageIndex:function(e,t){switch(e.format){case 1:{let n=pi(e.glyphs,t);return n>=0?n:-1}case 2:{let n=mi(e.ranges,t);return n?n.index+t-n.start:-1}}},expandCoverage:function(e){if(e.format===1)return e.glyphs;{let t=[],n=e.ranges;for(let e=0;e<n.length;e++){let r=n[e],i=r.start,a=r.end;for(let e=i;e<=a;e++)t.push(e)}return t}}};var gi=hi;function _i(e){gi.call(this,e,`gpos`)}_i.prototype=gi.prototype,_i.prototype.init=function(){let e=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(e)},_i.prototype.getKerningValue=function(e,t,n){for(let r=0;r<e.length;r++){let i=e[r].subtables;for(let e=0;e<i.length;e++){let r=i[e],a=this.getCoverageIndex(r.coverage,t);if(!(a<0))switch(r.posFormat){case 1:{let e=r.pairSets[a];for(let t=0;t<e.length;t++){let r=e[t];if(r.secondGlyph===n)return r.value1&&r.value1.xAdvance||0}break}case 2:{let e=this.getGlyphClass(r.classDef1,t),i=this.getGlyphClass(r.classDef2,n),a=r.classRecords[e][i];return a.value1&&a.value1.xAdvance||0}}}}return 0},_i.prototype.getKerningTables=function(e,t){if(this.font.tables.gpos)return this.getLookupTables(e,t,`kern`,2)};var vi=_i;function yi(e,t){let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}function bi(e,t,n){let r=0,i=e.length-1,a=null;for(;r<=i;){let o=Math.floor((r+i)/2),s=e[o],c=s[t];if(c<n)r=o+1;else if(c>n)i=o-1;else{a=s;break}}return a}function xi(e,t,n){let r=0,i=e.length-1;for(;r<=i;){let a=Math.floor((r+i)/2),o=e[a];if(o[t]<n)r=a+1;else if(o[t]>n)i=a-1;else return a}return-1}function Si(e,t,n){let r=0,i=e.length,a=(e,n)=>e[t]-n[t];for(;r<i;){let t=r+i>>>1;a(e[t],n)<0?r=t+1:i=t}return e.splice(r,0,n),r}function Ci(e){return e[0]===31&&e[1]===139&&e[2]===8}function wi(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=10,r=e.byteLength-8,i=t.getInt8(3);if(i&4&&(n+=2+t.getUint16(n,!0)),i&8)for(;n<r&&e[n++]!==0;);if(i&16)for(;n<r&&e[n++]!==0;);if(i&2&&(n+=2),n>=r)throw Error(`Can't find compressed blocks`);let a=t.getUint32(t.byteLength-4,!0);return j(e.subarray(n,r),new Uint8Array(a))}function Ti(e){return{x:e.x,y:e.y,onCurve:e.onCurve,lastPointOfContour:e.lastPointOfContour}}function Ei(e){return{glyphIndex:e.glyphIndex,xScale:e.xScale,scale01:e.scale01,scale10:e.scale10,yScale:e.yScale,dx:e.dx,dy:e.dy}}function Di(e){gi.call(this,e,`gsub`)}function Oi(e,t,n){let r=e.subtables;for(let e=0;e<r.length;e++){let n=r[e];if(n.substFormat===t)return n}if(n)return r.push(n),n}Di.prototype=gi.prototype,Di.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:`DFLT`,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},Di.prototype.getSingle=function(e,t,n){let r=[],i=this.getLookupTables(t,n,e,1);for(let e=0;e<i.length;e++){let t=i[e].subtables;for(let e=0;e<t.length;e++){let n=t[e],i=this.expandCoverage(n.coverage),a;if(n.substFormat===1){let e=n.deltaGlyphId;for(a=0;a<i.length;a++){let t=i[a];r.push({sub:t,by:t+e})}}else{let e=n.substitute;for(a=0;a<i.length;a++)r.push({sub:i[a],by:e[a]})}}}return r},Di.prototype.getMultiple=function(e,t,n){let r=[],i=this.getLookupTables(t,n,e,2);for(let e=0;e<i.length;e++){let t=i[e].subtables;for(let e=0;e<t.length;e++){let n=t[e],i=this.expandCoverage(n.coverage),a=0;for(;a<i.length;a++){let e=i[a],t=n.sequences[a];r.push({sub:e,by:t})}}}return r},Di.prototype.getAlternates=function(e,t,n){let r=[],i=this.getLookupTables(t,n,e,3);for(let e=0;e<i.length;e++){let t=i[e].subtables;for(let e=0;e<t.length;e++){let n=t[e],i=this.expandCoverage(n.coverage),a=n.alternateSets;for(let e=0;e<i.length;e++)r.push({sub:i[e],by:a[e]})}}return r},Di.prototype.getLigatures=function(e,t,n){let r=[],i=this.getLookupTables(t,n,e,4);for(let e=0;e<i.length;e++){let t=i[e].subtables;for(let e=0;e<t.length;e++){let n=t[e],i=this.expandCoverage(n.coverage),a=n.ligatureSets;for(let e=0;e<i.length;e++){let t=i[e],n=a[e];for(let e=0;e<n.length;e++){let i=n[e];r.push({sub:[t].concat(i.components),by:i.ligGlyph})}}}}return r},Di.prototype.addSingle=function(e,t,n,r){let i=this.getLookupTables(n,r,e,1,!0)[0],a=Oi(i,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});R.assert(a.coverage.format===1,`Single: unable to modify coverage table format `+a.coverage.format);let o=t.sub,s=this.binSearch(a.coverage.glyphs,o);s<0&&(s=-1-s,a.coverage.glyphs.splice(s,0,o),a.substitute.splice(s,0,0)),a.substitute[s]=t.by},Di.prototype.addMultiple=function(e,t,n,r){R.assert(t.by instanceof Array&&t.by.length>1,`Multiple: "by" must be an array of two or more ids`);let i=this.getLookupTables(n,r,e,2,!0)[0],a=Oi(i,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});R.assert(a.coverage.format===1,`Multiple: unable to modify coverage table format `+a.coverage.format);let o=t.sub,s=this.binSearch(a.coverage.glyphs,o);s<0&&(s=-1-s,a.coverage.glyphs.splice(s,0,o),a.sequences.splice(s,0,0)),a.sequences[s]=t.by},Di.prototype.addAlternate=function(e,t,n,r){let i=this.getLookupTables(n,r,e,3,!0)[0],a=Oi(i,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});R.assert(a.coverage.format===1,`Alternate: unable to modify coverage table format `+a.coverage.format);let o=t.sub,s=this.binSearch(a.coverage.glyphs,o);s<0&&(s=-1-s,a.coverage.glyphs.splice(s,0,o),a.alternateSets.splice(s,0,0)),a.alternateSets[s]=t.by},Di.prototype.addLigature=function(e,t,n,r){let i=this.getLookupTables(n,r,e,4,!0)[0],a=i.subtables[0];a||(a={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},i.subtables[0]=a),R.assert(a.coverage.format===1,`Ligature: unable to modify coverage table format `+a.coverage.format);let o=t.sub[0],s=t.sub.slice(1),c={ligGlyph:t.by,components:s},l=this.binSearch(a.coverage.glyphs,o);if(l>=0){let e=a.ligatureSets[l];for(let t=0;t<e.length;t++)if(yi(e[t].components,s))return;e.push(c)}else l=-1-l,a.coverage.glyphs.splice(l,0,o),a.ligatureSets.splice(l,0,[c])},Di.prototype.getFeature=function(e,t,n){if(/ss\d\d/.test(e))return this.getSingle(e,t,n);switch(e){case`aalt`:case`salt`:return this.getSingle(e,t,n).concat(this.getAlternates(e,t,n));case`dlig`:case`liga`:case`rlig`:return this.getLigatures(e,t,n);case`ccmp`:return this.getMultiple(e,t,n).concat(this.getLigatures(e,t,n));case`stch`:return this.getMultiple(e,t,n)}},Di.prototype.add=function(e,t,n,r){if(/ss\d\d/.test(e))return this.addSingle(e,t,n,r);switch(e){case`aalt`:case`salt`:return typeof t.by==`number`?this.addSingle(e,t,n,r):this.addAlternate(e,t,n,r);case`dlig`:case`liga`:case`rlig`:return this.addLigature(e,t,n,r);case`ccmp`:return t.by instanceof Array?this.addMultiple(e,t,n,r):this.addLigature(e,t,n,r)}};var ki=Di,Ai=class{constructor(e){this.defaultValue=255,this.font=e}cpal(){return this.font.tables&&this.font.tables.cpal?this.font.tables.cpal:!1}getAll(e){let t=[],n=this.cpal();if(!n)return t;for(let r=0;r<n.colorRecordIndices.length;r++){let i=n.colorRecordIndices[r],a=[];for(let t=i;t<i+n.numPaletteEntries;t++)a.push(Bt(n.colorRecords[t],e||`hexa`));t.push(a)}return t}toCPALcolor(e){return Array.isArray(e)?e.map(e=>zt(e,`raw`)):zt(e,`raw`)}fillPalette(e,t=[],n=this.cpal().numPaletteEntries){return e=Number.isInteger(e)?this.get(e,`raw`):e,Object.assign(Array(n).fill(this.defaultValue),this.toCPALcolor(e).concat(this.toCPALcolor(t)))}extend(e){if(this.ensureCPAL(Array(e).fill(this.defaultValue)))return;let t=this.cpal(),n=t.numPaletteEntries+e,r=this.getAll().map(e=>this.fillPalette(e,[],n));t.numPaletteEntries=n,t.colorRecords=this.toCPALcolor(r.flat()),this.updateIndices()}get(e,t=`hexa`){return this.getAll(t)[e]||null}getColor(e,t=0,n=`hexa`){return Pt(this.font,e,t,n)}setColor(e,t,n=0){e=parseInt(e),n=parseInt(n);let r=this.getAll(`raw`),i=r[n];if(!i)throw Error(`paletteIndex ${n} out of range`);let a=this.cpal(),o=a.numPaletteEntries;Array.isArray(t)||(t=[t]),t.length+e>o&&(this.extend(t.length+e-o),r=this.getAll(`raw`),i=r[n]);for(let n=0;n<t.length;n++)i[n+e]=this.toCPALcolor(t[n]);a.colorRecords=r.flat(),this.updateIndices()}add(e){if(this.ensureCPAL(e))return;let t=this.cpal(),n=t.numPaletteEntries;e&&e.length?(e=this.toCPALcolor(e),e.length>n?this.extend(e.length-n):e.length<n&&(e=this.fillPalette(e)),t.colorRecordIndices.push(t.colorRecords.length),t.colorRecords.push(...e)):(t.colorRecordIndices.push(t.colorRecords.length),t.colorRecords.push(...Array(n).fill(this.defaultValue)))}delete(e){let t=this.getAll(`raw`);delete t[e];let n=this.cpal();n.colorRecordIndices.pop(),n.colorRecords=t.flat()}deleteColor(e,t){if(e===t)throw Error(`replacementIndex cannot be the same as colorIndex`);let n=this.cpal(),r=this.getAll(`raw`),i=[];if(t>n.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${n.numPaletteEntries-1}, replacementIndex: ${t})`);for(let t=0;t<r.length;t++){let n=r[t].filter((t,n)=>n!==e);i.push(n)}let a=this.font.tables.colr;if(a){let n=a.layerRecords;for(let i=0;i<n.length;i++){let a=n[i].paletteIndex;if(a>e)--n[i].paletteIndex;else if(a===e){let a=0;for(let n=0;n<r.length;n++)if(t>e&&t<=e+r[n].length){a++;break}n[i].paletteIndex=t-a}}this.font.tables.colr={...a,layerRecords:n}}let o=i.flat();for(let e=0;e<r.length;e++)n.colorRecordIndices[e]-=e;n.numPaletteEntries=Math.max(0,n.numPaletteEntries-1),n.colorRecords=this.toCPALcolor(o)}ensureCPAL(e){return!this.cpal()&&(e=!e||!e.length?[this.defaultValue]:this.toCPALcolor(e),this.font.tables.cpal={version:0,numPaletteEntries:e.length,colorRecords:e,colorRecordIndices:[0]},!0)}updateIndices(){let e=this.cpal(),t=Math.ceil(e.colorRecords.length/e.numPaletteEntries);e.colorRecordIndices=[];for(let n=0;n<t;n++)e.colorRecordIndices.push(n*e.numPaletteEntries)}},ji=class{constructor(e){this.font=e}ensureCOLR(){return this.font.tables.colr||(this.font.tables.colr={version:0,baseGlyphRecords:[],layerRecords:[]}),this.font}get(e){let t=this.font,n=[],r=t.tables.colr,i=t.tables.cpal;if(!r||!i)return n;let a=bi(r.baseGlyphRecords,`glyphID`,e);if(!a)return n;let o=a.firstLayerIndex,s=a.numLayers;for(let e=0;e<s;e++){let i=r.layerRecords[o+e];n.push({glyph:t.glyphs.get(i.glyphID),paletteIndex:i.paletteIndex})}return n}add(e,t,n){let r=this.get(e);t=Array.isArray(t)?t:[t],n===void 0||n===1/0||n>r.length?n=r.length:n<0&&(n=r.length+1+n%(r.length+1),n>=r.length+1&&(n-=r.length+1));let i=[];for(let e=0;e<n;e++){let t=Number.isInteger(r[e].glyph)?r[e].glyph:r[e].glyph.index;i.push({glyphID:t,paletteIndex:r[e].paletteIndex})}for(let e of t){let t=Number.isInteger(e.glyph)?e.glyph:e.glyph.index;i.push({glyphID:t,paletteIndex:e.paletteIndex})}for(let e=n;e<r.length;e++){let t=Number.isInteger(r[e].glyph)?r[e].glyph:r[e].glyph.index;i.push({glyphID:t,paletteIndex:r[e].paletteIndex})}this.updateColrTable(e,i)}setPaletteIndex(e,t,n){let r=this.get(e);r[t]?(r=r.map((e,r)=>({glyphID:e.glyph.index,paletteIndex:r===t?n:e.paletteIndex})),this.updateColrTable(e,r)):console.error(`Invalid layer index`)}remove(e,t,n=t){let r=this.get(e);r=r.map(e=>({glyphID:e.glyph.index,paletteIndex:e.paletteIndex})),r.splice(t,n-t+1),this.updateColrTable(e,r)}updateColrTable(e,t){this.ensureCOLR();let n=this.font.tables.colr,r=xi(n.baseGlyphRecords,`glyphID`,e);if(r===-1){let t={glyphID:e,firstLayerIndex:n.layerRecords.length,numLayers:0};r=Si(n.baseGlyphRecords,`glyphID`,t)}let i=n.baseGlyphRecords[r],a=i.numLayers,o=t.length,s=o-a;if(s>0){let e=t.slice(a).map(e=>({glyphID:e.glyphID,paletteIndex:e.paletteIndex}));n.layerRecords.splice(i.firstLayerIndex+a,0,...e)}else s<0&&n.layerRecords.splice(i.firstLayerIndex+o,-s);for(let e=0;e<Math.min(a,o);e++)n.layerRecords[i.firstLayerIndex+e]={glyphID:t[e].glyphID,paletteIndex:t[e].paletteIndex};if(i.numLayers=o,s!==0)for(let e=0;e<n.baseGlyphRecords.length;e++){let t=n.baseGlyphRecords[e];e===r||t.firstLayerIndex<i.firstLayerIndex||(n.baseGlyphRecords[e].firstLayerIndex+=s)}}},Mi=class{constructor(e){this.font=e,this.cache=/* @__PURE__ */ new WeakMap}get(e){let t=this.getOrCreateSvgImageCacheEntry(e);return t&&t.image}getAsync(e){let t=this.getOrCreateSvgImageCacheEntry(e);return t&&t.promise}getOrCreateSvgImageCacheEntry(e){let t=this.font.tables.svg;if(t===void 0)return;let n=t.get(e);if(n===void 0)return;let r=this.cache.get(n);r===void 0&&(r=Ni(n),this.cache.set(n,r));let i=r.images.get(e);return i===void 0&&(i=Pi(this.font,r.template,e),i.promise.then(t=>{if(i.image=t,typeof this.font.onGlyphUpdated==`function`)try{this.font.onGlyphUpdated(e)}catch(t){console.error(`font.onGlyphUpdated`,e,t)}}),r.images.set(e,i)),i}};function Ni(e){return{template:Fi(e).then(Ri),images:/* @__PURE__ */ new Map}}function Pi(e,t,n){return{promise:t.then(t=>{let r;typeof t==`string`?r=t:(t[4]=n,r=t.join(``));let i=zi(r,e.unitsPerEm);return i.image.decode().then(()=>i)}),image:void 0}}var Fi=typeof DecompressionStream==`function`?Li:Ii;function Ii(e){try{return Promise.resolve(new TextDecoder().decode(Ci(e)?wi(e):e))}catch(e){return Promise.reject(e)}}function Li(e){if(Ci(e))return new Response(new Response(e).body.pipeThrough(new DecompressionStream(`gzip`))).text();try{return Promise.resolve(new TextDecoder().decode(e))}catch(e){return Promise.reject(e)}}function Ri(e){let t=e.indexOf(`<svg`),n=e.indexOf(`>`,t+4)+1;if(/ id=['"]glyph\d+['"]/.test(e.substring(t,n)))return e;let r=e.lastIndexOf(`</svg>`);return[e.substring(0,n),`<defs>`,e.substring(n,r),`</defs><use href="#glyph`,``,`"/>`,e.substring(r)]}function zi(e,t){let n=new DOMParser().parseFromString(e,`image/svg+xml`).documentElement,r=n.viewBox.baseVal,i=n.width.baseVal,a=n.height.baseVal,o=1,s=1;r.width>0&&r.height>0&&(i.unitType===1?(o=i.valueInSpecifiedUnits/r.width,s=a.unitType===1?a.valueInSpecifiedUnits/r.height:o):a.unitType===1?(s=a.valueInSpecifiedUnits/r.height,o=s):t&&(o=t/r.width,s=t/r.height));let c=document.createElement(`div`);c.style.position=`fixed`,c.style.visibility=`hidden`,c.appendChild(n),document.body.appendChild(c);let l=n.getBBox();document.body.removeChild(c);let u=(l.x-r.x)*o,d=(r.y-l.y)*s,f=l.width*o,p=l.height*s;n.setAttribute(`viewBox`,[l.x,l.y,l.width,l.height].join(` `)),o!==1&&n.setAttribute(`width`,f),s!==1&&n.setAttribute(`height`,p);let m=new Image(f,p);return m.src=`data:image/svg+xml;charset=utf-8,`+encodeURIComponent(n.outerHTML),{leftSideBearing:u,baseline:d,image:m}}var Bi=/* @__PURE__ */ new WeakMap;function Vi(e,t,n,r,i){let a;return(t&r)>0?(a=e.parseByte(),(t&i)===0&&(a=-a),a=n+a):a=(t&i)>0?n:n+e.parseShort(),a}function Hi(e,t,n){let r=new q.Parser(t,n);e._numberOfContours=r.parseShort(),e._xMin=r.parseShort(),e._yMin=r.parseShort(),e._xMax=r.parseShort(),e._yMax=r.parseShort();let i,a;if(e._numberOfContours>0){let t=e.endPointIndices=[];for(let n=0;n<e._numberOfContours;n+=1)t.push(r.parseUShort());e.instructionLength=r.parseUShort(),e.instructions=[];for(let t=0;t<e.instructionLength;t+=1)e.instructions.push(r.parseByte());let n=t[t.length-1]+1;i=[];for(let e=0;e<n;e+=1)if(a=r.parseByte(),i.push(a),(a&8)>0){let t=r.parseByte();for(let n=0;n<t;n+=1)i.push(a),e+=1}if(R.argument(i.length===n,`Bad flags.`),t.length>0){let o=[],s;if(n>0){for(let e=0;e<n;e+=1)a=i[e],s={},s.onCurve=!!(a&1),s.lastPointOfContour=t.indexOf(e)>=0,o.push(s);let e=0;for(let t=0;t<n;t+=1)a=i[t],s=o[t],s.x=Vi(r,a,e,2,16),e=s.x;let c=0;for(let e=0;e<n;e+=1)a=i[e],s=o[e],s.y=Vi(r,a,c,4,32),c=s.y}e.points=o}else e.points=[]}else if(e._numberOfContours===0)e.points=[];else{e.isComposite=!0,e.points=[],e.components=[];let t=!0;for(;t;){i=r.parseUShort();let n={glyphIndex:r.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(i&1)>0?(i&2)>0?(n.dx=r.parseShort(),n.dy=r.parseShort()):n.matchedPoints=[r.parseUShort(),r.parseUShort()]:(i&2)>0?(n.dx=r.parseChar(),n.dy=r.parseChar()):n.matchedPoints=[r.parseByte(),r.parseByte()],(i&8)>0?n.xScale=n.yScale=r.parseF2Dot14():(i&64)>0?(n.xScale=r.parseF2Dot14(),n.yScale=r.parseF2Dot14()):(i&128)>0&&(n.xScale=r.parseF2Dot14(),n.scale01=r.parseF2Dot14(),n.scale10=r.parseF2Dot14(),n.yScale=r.parseF2Dot14()),e.components.push(n),t=!!(i&32)}if(i&256){e.instructionLength=r.parseUShort(),e.instructions=[];for(let t=0;t<e.instructionLength;t+=1)e.instructions.push(r.parseByte())}}}function Ui(e,t){let n=[];for(let r=0;r<e.length;r+=1){let i=e[r],a={x:t.xScale*i.x+t.scale10*i.y+t.dx,y:t.scale01*i.x+t.yScale*i.y+t.dy,onCurve:i.onCurve,lastPointOfContour:i.lastPointOfContour};n.push(a)}return n}function Wi(e){let t=[],n=[];for(let r=0;r<e.length;r+=1){let i=e[r];n.push(i),i.lastPointOfContour&&(t.push(n),n=[])}return R.argument(n.length===0,`There are still points left in the current contour.`),t}function Gi(e){let t=new L;if(!e)return t;let n=Wi(e);for(let e=0;e<n.length;++e){let r=n[e],i=r[r.length-1],a=r[0];if(i.onCurve)t.moveTo(i.x,i.y);else if(a.onCurve)t.moveTo(a.x,a.y);else{let e={x:(i.x+a.x)*.5,y:(i.y+a.y)*.5};t.moveTo(e.x,e.y)}for(let e=0;e<r.length;++e)if(i=a,a=r[(e+1)%r.length],i.onCurve)t.lineTo(i.x,i.y);else{let e=a;a.onCurve||(e={x:(i.x+a.x)*.5,y:(i.y+a.y)*.5}),t.quadraticCurveTo(i.x,i.y,e.x,e.y)}t.closePath()}return t}function Ki(e,t){if(t.isComposite){Bi.has(e)||Bi.set(e,/* @__PURE__ */ new Set);let n=Bi.get(e);n.add(t.index);try{for(let r=0;r<t.components.length;r+=1){let i=t.components[r];if(n.has(i.glyphIndex))continue;let a=e.get(i.glyphIndex);if(a.getPath(),a.points){let e;if(i.matchedPoints===void 0)e=Ui(a.points,i);else{if(i.matchedPoints[0]>t.points.length-1||i.matchedPoints[1]>a.points.length-1)throw Error(`Matched points out of range in `+t.name);let n=t.points[i.matchedPoints[0]],r=a.points[i.matchedPoints[1]],o={xScale:i.xScale,scale01:i.scale01,scale10:i.scale10,yScale:i.yScale,dx:0,dy:0};r=Ui([r],o)[0],o.dx=n.x-r.x,o.dy=n.y-r.y,e=Ui(a.points,o)}t.points=t.points.concat(e)}}}finally{n.delete(t.index)}}return Gi(t.points)}function qi(e,t,n,r){let i=new Xt.GlyphSet(r);for(let a=0;a<n.length-1;a+=1){let o=n[a];o===n[a+1]?i.push(a,Xt.glyphLoader(r,a)):i.push(a,Xt.ttfGlyphLoader(r,a,Hi,e,t+o,Ki))}return i}function Ji(e,t,n,r){let i=new Xt.GlyphSet(r);return r._push=function(a){let o=n[a];o===n[a+1]?i.push(a,Xt.glyphLoader(r,a)):i.push(a,Xt.ttfGlyphLoader(r,a,Hi,e,t+o,Ki))},i}function Yi(e,t,n,r,i){return i.lowMemory?Ji(e,t,n,r):qi(e,t,n,r)}var Xi={getPath:Gi,parse:Yi},Zi=class{constructor(e){this.font=e}normalizeCoordTags(e){for(let t in e)if(t.length<4){let n=t.padEnd(4,` `);e[n]===void 0&&(e[n]=e[t]),delete e[t]}}getNormalizedCoords(e){e||=this.font.variation.get();let t=[];this.normalizeCoordTags(e);for(let n=0;n<this.fvar().axes.length;n++){let r=this.fvar().axes[n],i=e[r.tag];i===void 0&&(i=r.defaultValue),i<r.defaultValue?t.push((i-r.defaultValue+2**-52)/(r.defaultValue-r.minValue+2**-52)):t.push((i-r.defaultValue+2**-52)/(r.maxValue-r.defaultValue+2**-52))}if(this.avar())for(let e=0;e<this.avar().axisSegmentMaps.length;e++){let n=this.avar().axisSegmentMaps[e];for(let r=0;r<n.axisValueMaps.length;r++){let i=n.axisValueMaps[r];if(r>=1&&t[e]<i.fromCoordinate){let a=n.axisValueMaps[r-1];t[e]=((t[e]-a.fromCoordinate)*(i.toCoordinate-a.toCoordinate)+2**-52)/(i.fromCoordinate-a.fromCoordinate+2**-52)+a.toCoordinate;break}}}return t}interpolatePoints(e,t,n){if(e.length===0)return;let r=0;for(;r<e.length;){let i=r,a=r,o=e[a];for(;!o.lastPointOfContour;)o=e[++a];for(;r<=a&&!n[r];)r++;if(r>a)continue;let s=r,c=r;for(r++;r<=a;)n[r]&&(this.deltaInterpolate(c+1,r-1,c,r,t,e),c=r),r++;c===s?this.deltaShift(i,a,c,t,e):(this.deltaInterpolate(c+1,a,c,s,t,e),s>0&&this.deltaInterpolate(i,s-1,c,s,t,e)),r=a+1}}deltaInterpolate(e,t,n,r,i,a){if(e>t)return;let o=[`x`,`y`];for(let c=0;c<o.length;c++){let l=o[c];if(i[n][l]>i[r][l]){var s=n;n=r,r=s}let u=i[n][l],d=i[r][l],f=a[n][l],p=a[r][l];if(u!==d||f===p){let n=u===d?0:(p-f)/(d-u);for(let r=e;r<=t;r++){let e=i[r][l];e<=u?e+=f-u:e>=d?e+=p-d:e=f+(e-u)*n,a[r][l]=e}}}}deltaShift(e,t,n,r,i){let a=i[n].x-r[n].x,o=i[n].y-r[n].y;if(a!==0||o!==0)for(let r=e;r<=t;r++)r!==n&&(i[r].x+=a,i[r].y+=o)}transformComponents(e,t,n,r,i,a){let o=0;for(let s=0;s<e.components.length;s++){let c=e.components[s],l=this.font.glyphs.get(c.glyphIndex),u=Ei(c),d=r.indexOf(s);d>-1&&(u.dx+=Math.round(i.deltas[d]*a),u.dy+=Math.round(i.deltasY[d]*a));let f=Ui(this.getTransform(l,n).points,u);t.splice(o,f.length,...f),o+=l.points.length}}applyTupleVariationStore(e,t,n,r=`gvar`,i={}){n||=this.font.variation.get();let a=this.getNormalizedCoords(n),{headers:o,sharedPoints:s}=e,c=this.fvar().axes.length,l;r===`gvar`?l=t.map(Ti):r===`cvar`&&(l=[...t]);for(let e=0;e<o.length;e++){let u=o[e],d=1;for(let e=0;e<c;e++){let t=[0];switch(r){case`gvar`:t=u.peakTuple?u.peakTuple:this.gvar().sharedTuples[u.sharedTupleRecordsIndex];break;case`cvar`:t=u.peakTuple}if(t[e]!==0){if(a[e]===0){d=0;break}if(!u.intermediateStartTuple){if(a[e]<Math.min(0,t[e])||a[e]>Math.max(0,t[e])){d=0;break}d=(d*a[e]+2**-52)/(t[e]+2**-52)}else if(a[e]<u.intermediateStartTuple[e]||a[e]>u.intermediateEndTuple[e]){d=0;break}else d=a[e]<t[e]?d*(a[e]-u.intermediateStartTuple[e]+2**-52)/(t[e]-u.intermediateStartTuple[e]+2**-52):d*(u.intermediateEndTuple[e]-a[e]+2**-52)/(u.intermediateEndTuple[e]-t[e]+2**-52)}}if(d===0)continue;let f=u.privatePoints.length?u.privatePoints:s;if(r===`gvar`&&i.glyph&&i.glyph.isComposite)this.transformComponents(i.glyph,l,n,f,u,d);else if(f.length===0)for(let e=0;e<l.length;e++){let t=l[e];r===`gvar`?l[e]={x:Math.round(t.x+u.deltas[e]*d),y:Math.round(t.y+u.deltasY[e]*d),onCurve:t.onCurve,lastPointOfContour:t.lastPointOfContour}:r===`cvar`&&(l[e]=Math.round(t+u.deltas[e]*d))}else{let e;r===`gvar`?e=l.map(Ti):r===`cvar`&&(e=l);let n=Array(t.length).fill(!1);for(let i=0;i<f.length;i++){let a=f[i];if(a<t.length){let t=e[a];r===`gvar`?(n[a]=!0,t.x+=u.deltas[i]*d,t.y+=u.deltasY[i]*d):r===`cvar`&&(l[a]=Math.round(t+u.deltas[i]*d))}}if(r===`gvar`){this.interpolatePoints(e,l,n);for(let n=0;n<t.length;n++){let t=e[n].x-l[n].x,r=e[n].y-l[n].y;l[n].x=Math.round(l[n].x+t),l[n].y=Math.round(l[n].y+r)}}}}return l}getTransform(e,t){Number.isInteger(e)&&(e=this.font.glyphs.get(e));let n=e.getBlendPath,r=!!(e.points&&e.points.length),i=e;if(n||r){if(t||=this.font.variation.get(),r){let n=this.gvar()&&this.gvar().glyphVariations[e.index];if(n){let r=e.points,a=this.applyTupleVariationStore(n,r,t,`gvar`,{glyph:e});i=new Wt(Object.assign({},e,{points:a,path:Gi(a)}))}}else if(n){let n=e.getBlendPath(t);i=new Wt(Object.assign({},e,{path:n}))}}return this.font.tables.hvar&&(e._advanceWidth=e._advanceWidth===void 0?e.advanceWidth:e._advanceWidth,e.advanceWidth=i.advanceWidth=Math.round(e._advanceWidth+this.getVariableAdjustment(i.index,`hvar`,`advanceWidth`,t)),e._leftSideBearing=e._leftSideBearing===void 0?e.leftSideBearing:e._leftSideBearing,e.leftSideBearing=i.leftSideBearing=Math.round(e._leftSideBearing+this.getVariableAdjustment(i.index,`hvar`,`lsb`,t))),i}getCvarTransform(e){let t=this.font.tables.cvt,n=this.cvar();return!t||!t.length||!n||!n.headers.length?t:this.applyTupleVariationStore(n,t,e,`cvar`)}getVariableAdjustment(e,t,n,r){r||=this.font.variation.get();let i,a,o=this.font.tables[t];if(!o)throw Error(`trying to get variation adjustment from non-existent table "${o}"`);if(!o.itemVariationStore)throw Error(`trying to get variation adjustment from table "${o}" which does not have an itemVariationStore`);let s=o[n]&&o[n].map.length;if(s){let t=e;t>=s&&(t=s-1),{outerIndex:i,innerIndex:a}=o[n].map[t]}else i=0,a=e;return this.getDelta(o.itemVariationStore,i,a,r)}getDelta(e,t,n,r){if(t>=e.itemVariationSubtables.length)return 0;let i=e.itemVariationSubtables[t];if(n>=i.deltaSets.length)return 0;let a=i.deltaSets[n],o=this.getBlendVector(e,t,r),s=0;for(let e=0;e<i.regionIndexes.length;e++)s+=a[e]*o[e];return s}getBlendVector(e,t,n){n||=this.font.variation.get();let r=e.itemVariationSubtables[t],i=this.getNormalizedCoords(n),a=[];for(let t=0;t<r.regionIndexes.length;t++){let n=1,o=r.regionIndexes[t],s=e.variationRegions[o].regionAxes;for(let e=0;e<s.length;e++){let t=s[e],r;r=t.startCoord>t.peakCoord||t.peakCoord>t.endCoord||t.startCoord<0&&t.endCoord>0&&t.peakCoord!==0||t.peakCoord===0?1:i[e]<t.startCoord||i[e]>t.endCoord?0:i[e]===t.peakCoord?1:i[e]<t.peakCoord?(i[e]-t.startCoord+2**-52)/(t.peakCoord-t.startCoord+2**-52):(t.endCoord-i[e]+2**-52)/(t.endCoord-t.peakCoord+2**-52),n*=r}a[t]=n}return a}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},Qi=class{constructor(e){this.font=e,this.process=new Zi(this.font),this.activateDefaultVariation(),this.getTransform=this.process.getTransform.bind(this.process)}activateDefaultVariation(){let e=this.getDefaultInstanceIndex();e>-1?this.set(e):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((e,t)=>(e[t.tag]=t.defaultValue,e),{})}getDefaultInstanceIndex(){let e=this.getDefaultCoordinates(),t=this.getInstanceIndex(e);return t<0&&(t=this.fvar().instances.findIndex(e=>e.name&&e.name.en===`Regular`)),t}getInstanceIndex(e){return this.fvar().instances.findIndex(t=>Object.keys(e).every(n=>t.coordinates[n]===e[n]))}getInstance(e){return this.fvar().instances&&this.fvar().instances[e]}set(e){let t;if(Number.isInteger(e)){let n=this.getInstance(e);if(!n)throw Error(`Invalid instance index ${e}`);t={...n.coordinates}}else t=e,this.process.normalizeCoordTags(t);t=Object.assign({},this.font.defaultRenderOptions.variation,t),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:t})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},$i=1e6,ea=64,ta=1e4,na,ra,ia,aa;function oa(e){this.font=e,this.getCommands=function(e){return Xi.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function sa(e){return e}function ca(e){return Math.sign(e)*Math.round(Math.abs(e))}function la(e){return Math.sign(e)*Math.round(Math.abs(e*2))/2}function ua(e){return Math.sign(e)*(Math.round(Math.abs(e)+.5)-.5)}function da(e){return Math.sign(e)*Math.ceil(Math.abs(e))}function fa(e){return Math.sign(e)*Math.floor(Math.abs(e))}var pa=function(e){let t=this.srPeriod,n=this.srPhase,r=this.srThreshold,i=1;return e<0&&(e=-e,i=-1),e+=r-n,e=Math.trunc(e/t)*t,e+=n,e<0?n*i:e*i},ma={x:1,y:0,axis:`x`,distance:function(e,t,n,r){return(n?e.xo:e.x)-(r?t.xo:t.x)},interpolate:function(e,t,n,r){let i,a,o,s,c,l,u;if(!r||r===this){if(i=e.xo-t.xo,a=e.xo-n.xo,c=t.x-t.xo,l=n.x-n.xo,o=Math.abs(i),s=Math.abs(a),u=o+s,u===0){e.x=e.xo+(c+l)/2;return}e.x=e.xo+(c*s+l*o)/u}else i=r.distance(e,t,!0,!0),a=r.distance(e,n,!0,!0),c=r.distance(t,t,!1,!0),l=r.distance(n,n,!1,!0),o=Math.abs(i),s=Math.abs(a),u=o+s,u===0?ma.setRelative(e,e,(c+l)/2,r,!0):ma.setRelative(e,e,(c*s+l*o)/u,r,!0)},normalSlope:-1/0,setRelative:function(e,t,n,r,i){if(!r||r===this){e.x=(i?t.xo:t.x)+n;return}let a=i?t.xo:t.x,o=i?t.yo:t.y,s=a+n*r.x,c=o+n*r.y;e.x=s+(e.y-c)/r.normalSlope},slope:0,touch:function(e){e.xTouched=!0},touched:function(e){return e.xTouched},untouch:function(e){e.xTouched=!1}},ha={x:0,y:1,axis:`y`,distance:function(e,t,n,r){return(n?e.yo:e.y)-(r?t.yo:t.y)},interpolate:function(e,t,n,r){let i,a,o,s,c,l,u;if(!r||r===this){if(i=e.yo-t.yo,a=e.yo-n.yo,c=t.y-t.yo,l=n.y-n.yo,o=Math.abs(i),s=Math.abs(a),u=o+s,u===0){e.y=e.yo+(c+l)/2;return}e.y=e.yo+(c*s+l*o)/u}else i=r.distance(e,t,!0,!0),a=r.distance(e,n,!0,!0),c=r.distance(t,t,!1,!0),l=r.distance(n,n,!1,!0),o=Math.abs(i),s=Math.abs(a),u=o+s,u===0?ha.setRelative(e,e,(c+l)/2,r,!0):ha.setRelative(e,e,(c*s+l*o)/u,r,!0)},normalSlope:0,setRelative:function(e,t,n,r,i){if(!r||r===this){e.y=(i?t.yo:t.y)+n;return}let a=i?t.xo:t.x,o=i?t.yo:t.y,s=a+n*r.x;e.y=o+n*r.y+r.normalSlope*(e.x-s)},slope:1/0,touch:function(e){e.yTouched=!0},touched:function(e){return e.yTouched},untouch:function(e){e.yTouched=!1}};Object.freeze(ma),Object.freeze(ha);function ga(e,t){this.x=e,this.y=t,this.axis=void 0,this.slope=t/e,this.normalSlope=-e/t,Object.freeze(this)}ga.prototype.distance=function(e,t,n,r){return this.x*ma.distance(e,t,n,r)+this.y*ha.distance(e,t,n,r)},ga.prototype.interpolate=function(e,t,n,r){let i,a,o,s,c,l,u;o=r.distance(e,t,!0,!0),s=r.distance(e,n,!0,!0),i=r.distance(t,t,!1,!0),a=r.distance(n,n,!1,!0),c=Math.abs(o),l=Math.abs(s),u=c+l,u===0?this.setRelative(e,e,(i+a)/2,r,!0):this.setRelative(e,e,(i*l+a*c)/u,r,!0)},ga.prototype.setRelative=function(e,t,n,r,i){r||=this;let a=i?t.xo:t.x,o=i?t.yo:t.y,s=a+n*r.x,c=o+n*r.y,l=r.normalSlope,u=this.slope,d=e.x,f=e.y;e.x=(u*d-l*s+c-f)/(u-l),e.y=u*(e.x-d)+f},ga.prototype.touch=function(e){e.xTouched=!0,e.yTouched=!0};function _a(e,t){let n=Math.sqrt(e*e+t*t);return e/=n,t/=n,e===1&&t===0?ma:e===0&&t===1?ha:new ga(e,t)}function va(e,t,n,r){this.x=this.xo=Math.round(e*64)/64,this.y=this.yo=Math.round(t*64)/64,this.lastPointOfContour=n,this.onCurve=r,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}va.prototype.nextTouched=function(e){let t=this.nextPointOnContour;for(;!e.touched(t)&&t!==this;)t=t.nextPointOnContour;return t},va.prototype.prevTouched=function(e){let t=this.prevPointOnContour;for(;!e.touched(t)&&t!==this;)t=t.prevPointOnContour;return t};var J=Object.freeze(new va(0,0)),ya={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function ba(e,t){switch(this.env=e,this.stack=[],this.prog=t,e){case`glyf`:this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case`prep`:this.fv=this.pv=this.dpv=ma,this.round=ca}}oa.prototype.exec=function(e,t){if(typeof t!=`number`)throw Error(`Point size is not a number!`);if(this._errorState>2)return;let n=this.font,r=this._prepState;if(!r||r.ppem!==t){let e=this._fpgmState;if(!e){ba.prototype=ya,e=this._fpgmState=new ba(`fpgm`,n.tables.fpgm),e.funcs=[],e.font=n,e.instructionCount=0,e.callDepth=0;try{ra(e)}catch(e){console.log(`Hinting error in FPGM:`+e),this._errorState=3;return}}ba.prototype=e,r=this._prepState=new ba(`prep`,n.tables.prep),r.ppem=t,r.instructionCount=0,r.callDepth=0;let i=n.variation&&n.variation.process.getCvarTransform()||n.tables.cvt;if(i){let e=r.cvt=Array(i.length),a=t/n.unitsPerEm;for(let t=0;t<i.length;t++)e[t]=i[t]*a}else r.cvt=[];try{ra(r)}catch(e){this._errorState<2&&console.log(`Hinting error in PREP:`+e),this._errorState=2}}if(!(this._errorState>1))try{return ia(e,r)}catch(e){this._errorState<1&&(console.log(`Hinting error:`+e),console.log(`Note: further hinting errors are silenced`)),this._errorState=1;return}},ia=function(e,t){let n=t.ppem/t.font.unitsPerEm,r=n,i=e.components,a,o,s;if(ba.prototype=t,!i)s=new ba(`glyf`,e.instructions),s.instructionCount=0,s.callDepth=0,aa(e,s,n,r),o=s.gZone;else{let c=t.font;o=[],a=[];for(let e=0;e<i.length;e++){let t=i[e],l=c.glyphs.get(t.glyphIndex);s=new ba(`glyf`,l.instructions),s.instructionCount=0,s.callDepth=0,aa(l,s,n,r);let u=Math.round(t.dx*n),d=Math.round(t.dy*r),f=s.gZone,p=s.contours;for(let e=0;e<f.length;e++){let t=f[e];t.xTouched=t.yTouched=!1,t.xo=t.x+=u,t.yo=t.y+=d}let m=o.length;o.push.apply(o,f);for(let e=0;e<p.length;e++)a.push(p[e]+m)}e.instructions&&!s.inhibitGridFit&&(s=new ba(`glyf`,e.instructions),s.gZone=s.z0=s.z1=s.z2=o,s.contours=a,o.push(new va(0,0),new va(Math.round(e.advanceWidth*n),0)),ra(s),o.length-=2)}return o},aa=function(e,t,n,r){let i=e.points||[],a=i.length,o=t.gZone=t.z0=t.z1=t.z2=[],s=t.contours=[],c;for(let e=0;e<a;e++)c=i[e],o[e]=new va(c.x*n,c.y*r,c.lastPointOfContour,c.onCurve);let l,u;for(let e=0;e<a;e++)c=o[e],l||(l=c,s.push(e)),c.lastPointOfContour?(c.nextPointOnContour=l,l.prevPointOnContour=c,l=void 0):(u=o[e+1],c.nextPointOnContour=u,u.prevPointOnContour=c);t.inhibitGridFit||(o.push(new va(0,0),new va(Math.round(e.advanceWidth*n),0)),ra(t),o.length-=2)},ra=function(e){let t=e.prog;if(!t)return;let n=t.length,r;for(e.ip=0;e.ip<n;e.ip++){if(++e.instructionCount>$i)throw Error(`Hinting instructions exceeded maximum of `+$i);if(r=na[t[e.ip]],!r)throw Error(`unknown instruction: 0x`+Number(t[e.ip]).toString(16));r(e)}};function xa(e){let t=e.tZone=Array(e.gZone.length);for(let e=0;e<t.length;e++)t[e]=new va(0,0)}function Sa(e,t){let n=e.prog,r=e.ip,i=1,a;do if(a=n[++r],a===88)i++;else if(a===89)i--;else if(a===64)r+=n[r+1]+1;else if(a===65)r+=2*n[r+1]+1;else if(a>=176&&a<=183)r+=a-176+1;else if(a>=184&&a<=191)r+=(a-184+1)*2;else if(t&&i===1&&a===27)break;while(i>0);e.ip=r}function Ca(e,t){t.fv=t.pv=t.dpv=e}function wa(e,t){t.pv=t.dpv=e}function Ta(e,t){t.fv=e}function Ea(e,t){let n=t.stack,r=n.pop(),i=n.pop(),a=t.z2[r],o=t.z1[i],s,c;e?(s=a.y-o.y,c=o.x-a.x):(s=o.x-a.x,c=o.y-a.y),t.pv=t.dpv=_a(s,c)}function Da(e,t){let n=t.stack,r=n.pop(),i=n.pop(),a=t.z2[r],o=t.z1[i],s,c;e?(s=a.y-o.y,c=o.x-a.x):(s=o.x-a.x,c=o.y-a.y),t.fv=_a(s,c)}function Oa(e){let t=e.stack,n=t.pop();e.pv=e.dpv=_a(t.pop(),n)}function ka(e){let t=e.stack,n=t.pop();e.fv=_a(t.pop(),n)}function Aa(e){let t=e.stack,n=e.pv;t.push(n.x*16384),t.push(n.y*16384)}function ja(e){let t=e.stack,n=e.fv;t.push(n.x*16384),t.push(n.y*16384)}function Ma(e){e.fv=e.pv}function Na(e){let t=e.stack,n=t.pop(),r=t.pop(),i=t.pop(),a=t.pop(),o=t.pop(),s=e.z0,c=e.z1,l=s[n],u=s[r],d=c[i],f=c[a],p=e.z2[o],m=l.x,h=l.y,g=u.x,_=u.y,v=d.x,y=d.y,b=f.x,x=f.y,S=(m-g)*(y-x)-(h-_)*(v-b),C=m*_-h*g,w=v*x-y*b;p.x=(C*(v-b)-w*(m-g))/S,p.y=(C*(y-x)-w*(h-_))/S}function Pa(e){e.rp0=e.stack.pop()}function Fa(e){e.rp1=e.stack.pop()}function Ia(e){e.rp2=e.stack.pop()}function La(e){let t=e.stack.pop();switch(e.zp0=t,t){case 0:e.tZone||xa(e),e.z0=e.tZone;break;case 1:e.z0=e.gZone;break;default:throw Error(`Invalid zone pointer`)}}function Ra(e){let t=e.stack.pop();switch(e.zp1=t,t){case 0:e.tZone||xa(e),e.z1=e.tZone;break;case 1:e.z1=e.gZone;break;default:throw Error(`Invalid zone pointer`)}}function Y(e){let t=e.stack.pop();switch(e.zp2=t,t){case 0:e.tZone||xa(e),e.z2=e.tZone;break;case 1:e.z2=e.gZone;break;default:throw Error(`Invalid zone pointer`)}}function za(e){let t=e.stack.pop();switch(e.zp0=e.zp1=e.zp2=t,t){case 0:e.tZone||xa(e),e.z0=e.z1=e.z2=e.tZone;break;case 1:e.z0=e.z1=e.z2=e.gZone;break;default:throw Error(`Invalid zone pointer`)}}function Ba(e){e.loop=e.stack.pop(),e.loop>ta&&(e.loop=ta)}function Va(e){e.round=ca}function Ha(e){e.round=ua}function Ua(e){e.minDis=e.stack.pop()/64}function Wa(e){Sa(e,!1)}function Ga(e){let t=e.stack.pop();e.ip+=t-1}function Ka(e){e.cvCutIn=e.stack.pop()/64}function qa(e){let t=e.stack;t.push(t[t.length-1])}function Ja(e){e.stack.pop()}function Ya(e){e.stack.length=0}function Xa(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(n),t.push(r)}function Za(e){let t=e.stack;t.push(t.length)}function Qa(e){let t=e.stack,n=t.pop(),r=t.pop();if(r>ta&&(r=ta),++e.callDepth>ea)throw Error(`Hinting call depth exceeded maximum of `+ea);let i=e.ip,a=e.prog;e.prog=e.funcs[n];for(let t=0;t<r;t++)ra(e);e.ip=i,e.prog=a,e.callDepth--}function $a(e){let t=e.stack.pop();if(++e.callDepth>ea)throw Error(`Hinting call depth exceeded maximum of `+ea);let n=e.ip,r=e.prog;e.prog=e.funcs[t],ra(e),e.ip=n,e.prog=r,e.callDepth--}function eo(e){let t=e.stack,n=t.pop();t.push(t[t.length-n])}function to(e){let t=e.stack,n=t.pop();t.push(t.splice(t.length-n,1)[0])}function no(e){if(e.env!==`fpgm`)throw Error(`FDEF not allowed here`);let t=e.stack,n=e.prog,r=e.ip,i=t.pop(),a=r;for(;n[++r]!==45;);e.ip=r,e.funcs[i]=n.slice(a+1,r)}function ro(e,t){let n=t.stack.pop(),r=t.z0[n],i=t.fv,a=t.pv,o=a.distance(r,J);e&&(o=t.round(o)),i.setRelative(r,J,o,a),i.touch(r),t.rp0=t.rp1=n}function io(e,t){let n=t.z2,r=n.length-2,i,a,o;for(let t=0;t<r;t++)i=n[t],!e.touched(i)&&(a=i.prevTouched(e),a!==i&&(o=i.nextTouched(e),a===o&&e.setRelative(i,i,e.distance(a,a,!1,!0),e,!0),e.interpolate(i,a,o,e)))}function ao(e,t){let n=t.stack,r=e?t.rp1:t.rp2,i=(e?t.z0:t.z1)[r],a=t.fv,o=t.pv,s=t.loop,c=t.z2;for(;s--;){let e=c[n.pop()],t=o.distance(i,i,!1,!0);a.setRelative(e,e,t,o),a.touch(e)}t.loop=1}function oo(e,t){let n=t.stack,r=e?t.rp1:t.rp2,i=(e?t.z0:t.z1)[r],a=t.fv,o=t.pv,s=n.pop(),c=t.z2[t.contours[s]],l=c,u=o.distance(i,i,!1,!0);do l!==i&&a.setRelative(l,l,u,o),l=l.nextPointOnContour;while(l!==c)}function so(e,t){let n=t.stack,r=e?t.rp1:t.rp2,i=(e?t.z0:t.z1)[r],a=t.fv,o=t.pv,s=n.pop(),c;switch(s){case 0:c=t.tZone;break;case 1:c=t.gZone;break;default:throw Error(`Invalid zone`)}let l,u=o.distance(i,i,!1,!0),d=c.length-2;for(let e=0;e<d;e++)l=c[e],a.setRelative(l,l,u,o)}function co(e){let t=e.stack,n=e.loop,r=e.fv,i=t.pop()/64,a=e.z2;for(;n--;){let e=a[t.pop()];r.setRelative(e,e,i),r.touch(e)}e.loop=1}function lo(e){let t=e.stack,n=e.rp1,r=e.rp2,i=e.loop,a=e.z0[n],o=e.z1[r],s=e.fv,c=e.dpv,l=e.z2;for(;i--;){let e=l[t.pop()];s.interpolate(e,a,o,c),s.touch(e)}e.loop=1}function uo(e,t){let n=t.stack,r=n.pop()/64,i=n.pop(),a=t.z1[i],o=t.z0[t.rp0],s=t.fv,c=t.pv;s.setRelative(a,o,r,c),s.touch(a),t.rp1=t.rp0,t.rp2=i,e&&(t.rp0=i)}function fo(e){let t=e.stack,n=e.rp0,r=e.z0[n],i=e.loop,a=e.fv,o=e.pv,s=e.z1;for(;i--;){let e=s[t.pop()];a.setRelative(e,r,0,o),a.touch(e)}e.loop=1}function po(e){e.round=la}function mo(e,t){let n=t.stack,r=n.pop(),i=n.pop(),a=t.z0[i],o=t.fv,s=t.pv,c=t.cvt[r],l=s.distance(a,J);e&&(Math.abs(l-c)<t.cvCutIn&&(l=c),l=t.round(l)),o.setRelative(a,J,l,s),t.zp0===0&&(a.xo=a.x,a.yo=a.y),o.touch(a),t.rp0=t.rp1=i}function ho(e){let t=e.prog,n=e.ip,r=e.stack,i=t[++n];for(let e=0;e<i;e++)r.push(t[++n]);e.ip=n}function go(e){let t=e.ip,n=e.prog,r=e.stack,i=n[++t];for(let e=0;e<i;e++){let e=n[++t]<<8|n[++t];e&32768&&(e=-((e^65535)+1)),r.push(e)}e.ip=t}function _o(e){let t=e.stack,n=e.store;n||=e.store=[];let r=t.pop(),i=t.pop();n[i]=r}function vo(e){let t=e.stack,n=e.store,r=t.pop(),i=n&&n[r]||0;t.push(i)}function yo(e){let t=e.stack,n=t.pop(),r=t.pop();e.cvt[r]=n/64}function bo(e){let t=e.stack,n=t.pop();t.push(e.cvt[n]*64)}function xo(e,t){let n=t.stack,r=n.pop(),i=t.z2[r];n.push(t.dpv.distance(i,J,e,!1)*64)}function So(e,t){let n=t.stack,r=n.pop(),i=n.pop(),a=t.z1[r],o=t.z0[i],s=t.dpv.distance(o,a,e,e);t.stack.push(Math.round(s*64))}function Co(e){e.stack.push(e.ppem)}function wo(e){e.autoFlip=!0}function To(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(+(r<n))}function Eo(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(+(r<=n))}function Do(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(+(r>n))}function Oo(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(+(r>=n))}function ko(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(+(n===r))}function Ao(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(n===r?0:1)}function jo(e){let t=e.stack,n=t.pop();t.push(Math.trunc(n)&1?1:0)}function Mo(e){let t=e.stack,n=t.pop();t.push(Math.trunc(n)&1?0:1)}function No(e){e.stack.pop()||Sa(e,!0)}function Po(e){}function Fo(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(n&&r?1:0)}function Io(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(n||r?1:0)}function Lo(e){let t=e.stack,n=t.pop();t.push(+!n)}function Ro(e,t){let n=t.stack,r=n.pop(),i=t.fv,a=t.pv,o=t.ppem,s=t.deltaBase+(e-1)*16,c=t.deltaShift,l=t.z0;for(let e=0;e<r;e++){let e=n.pop(),t=n.pop();if(s+((t&240)>>4)!==o)continue;let r=(t&15)-8;r>=0&&r++;let u=l[e];i.setRelative(u,u,r*c,a)}}function zo(e){e.deltaBase=e.stack.pop()}function Bo(e){e.deltaShift=.5**e.stack.pop()}function Vo(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(r+n)}function Ho(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(r-n)}function Uo(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(r*64/n)}function Wo(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(r*n/64)}function Go(e){let t=e.stack,n=t.pop();t.push(Math.abs(n))}function Ko(e){let t=e.stack,n=t.pop();t.push(-n)}function qo(e){let t=e.stack,n=t.pop();t.push(Math.floor(n/64)*64)}function Jo(e){let t=e.stack,n=t.pop();t.push(Math.ceil(n/64)*64)}function Yo(e,t){let n=t.stack,r=n.pop();n.push(t.round(r/64)*64)}function Xo(e){let t=e.stack,n=t.pop(),r=t.pop();e.cvt[r]=n*e.ppem/e.font.unitsPerEm}function Zo(e,t){let n=t.stack,r=n.pop(),i=t.ppem,a=t.deltaBase+(e-1)*16,o=t.deltaShift;for(let e=0;e<r;e++){let e=n.pop(),r=n.pop();if(a+((r&240)>>4)!==i)continue;let s=(r&15)-8;s>=0&&s++;let c=s*o;t.cvt[e]+=c}}function Qo(e){let t=e.stack.pop();e.round=pa;let n;switch(t&192){case 0:n=.5;break;case 64:n=1;break;case 128:n=2;break;default:throw Error(`invalid SROUND value`)}switch(e.srPeriod=n,t&48){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*n;break;case 32:e.srPhase=.5*n;break;case 48:e.srPhase=.75*n;break;default:throw Error(`invalid SROUND value`)}t&=15,e.srThreshold=t===0?0:(t/8-.5)*n}function $o(e){let t=e.stack.pop();e.round=pa;let n;switch(t&192){case 0:n=Math.sqrt(2)/2;break;case 64:n=Math.sqrt(2);break;case 128:n=2*Math.sqrt(2);break;default:throw Error(`invalid S45ROUND value`)}switch(e.srPeriod=n,t&48){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*n;break;case 32:e.srPhase=.5*n;break;case 48:e.srPhase=.75*n;break;default:throw Error(`invalid S45ROUND value`)}t&=15,e.srThreshold=t===0?0:(t/8-.5)*n}function es(e){e.round=sa}function ts(e){e.round=da}function ns(e){e.round=fa}function rs(e){e.stack.pop()}function is(e,t){let n=t.stack,r=n.pop(),i=n.pop(),a=t.z2[r],o=t.z1[i],s,c;e?(s=a.y-o.y,c=o.x-a.x):(s=o.x-a.x,c=o.y-a.y),t.dpv=_a(s,c)}function as(e){let t=e.stack,n=t.pop(),r=0;n&1&&(r=35),n&32&&(r|=4096),t.push(r)}function os(e){let t=e.stack,n=t.pop(),r=t.pop(),i=t.pop();t.push(r),t.push(n),t.push(i)}function ss(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(Math.max(r,n))}function cs(e){let t=e.stack,n=t.pop(),r=t.pop();t.push(Math.min(r,n))}function ls(e){e.stack.pop()}function us(e){let t=e.stack.pop(),n=e.stack.pop();switch(t){case 1:e.inhibitGridFit=!!n;return;case 2:e.ignoreCvt=!!n;return;default:throw Error(`invalid INSTCTRL[] selector`)}}function ds(e,t){let n=t.stack,r=t.prog,i=t.ip;for(let t=0;t<e;t++)n.push(r[++i]);t.ip=i}function fs(e,t){let n=t.ip,r=t.prog,i=t.stack;for(let t=0;t<e;t++){let e=r[++n]<<8|r[++n];e&32768&&(e=-((e^65535)+1)),i.push(e)}t.ip=n}function X(e,t,n,r,i,a){let o=a.stack,s=e&&o.pop(),c=o.pop(),l=a.rp0,u=a.z0[l],d=a.z1[c],f=a.minDis,p=a.fv,m=a.dpv,h,g,_;h=m.distance(d,u,!0,!0),g=h>=0?1:-1,h=Math.abs(h),e&&(_=a.cvt[s],r&&Math.abs(h-_)<a.cvCutIn&&(h=_)),n&&h<f&&(h=f),r&&(h=a.round(h)),p.setRelative(d,u,g*h,m),p.touch(d),a.rp1=a.rp0,a.rp2=c,t&&(a.rp0=c)}na=[Ca.bind(void 0,ha),Ca.bind(void 0,ma),wa.bind(void 0,ha),wa.bind(void 0,ma),Ta.bind(void 0,ha),Ta.bind(void 0,ma),Ea.bind(void 0,0),Ea.bind(void 0,1),Da.bind(void 0,0),Da.bind(void 0,1),Oa,ka,Aa,ja,Ma,Na,Pa,Fa,Ia,La,Ra,Y,za,Ba,Va,Ha,Ua,Wa,Ga,Ka,void 0,void 0,qa,Ja,Ya,Xa,Za,eo,to,void 0,void 0,void 0,Qa,$a,no,void 0,ro.bind(void 0,0),ro.bind(void 0,1),io.bind(void 0,ha),io.bind(void 0,ma),ao.bind(void 0,0),ao.bind(void 0,1),oo.bind(void 0,0),oo.bind(void 0,1),so.bind(void 0,0),so.bind(void 0,1),co,lo,uo.bind(void 0,0),uo.bind(void 0,1),fo,po,mo.bind(void 0,0),mo.bind(void 0,1),ho,go,_o,vo,yo,bo,xo.bind(void 0,0),xo.bind(void 0,1),void 0,So.bind(void 0,0),So.bind(void 0,1),Co,void 0,wo,void 0,void 0,To,Eo,Do,Oo,ko,Ao,jo,Mo,No,Po,Fo,Io,Lo,Ro.bind(void 0,1),zo,Bo,Vo,Ho,Uo,Wo,Go,Ko,qo,Jo,Yo.bind(void 0,0),Yo.bind(void 0,1),Yo.bind(void 0,2),Yo.bind(void 0,3),void 0,void 0,void 0,void 0,Xo,Ro.bind(void 0,2),Ro.bind(void 0,3),Zo.bind(void 0,1),Zo.bind(void 0,2),Zo.bind(void 0,3),Qo,$o,void 0,void 0,es,void 0,ts,ns,Ja,Ja,void 0,void 0,void 0,void 0,void 0,rs,is.bind(void 0,0),is.bind(void 0,1),as,void 0,os,ss,cs,ls,us,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ds.bind(void 0,1),ds.bind(void 0,2),ds.bind(void 0,3),ds.bind(void 0,4),ds.bind(void 0,5),ds.bind(void 0,6),ds.bind(void 0,7),ds.bind(void 0,8),fs.bind(void 0,1),fs.bind(void 0,2),fs.bind(void 0,3),fs.bind(void 0,4),fs.bind(void 0,5),fs.bind(void 0,6),fs.bind(void 0,7),fs.bind(void 0,8),X.bind(void 0,0,0,0,0,0),X.bind(void 0,0,0,0,0,1),X.bind(void 0,0,0,0,0,2),X.bind(void 0,0,0,0,0,3),X.bind(void 0,0,0,0,1,0),X.bind(void 0,0,0,0,1,1),X.bind(void 0,0,0,0,1,2),X.bind(void 0,0,0,0,1,3),X.bind(void 0,0,0,1,0,0),X.bind(void 0,0,0,1,0,1),X.bind(void 0,0,0,1,0,2),X.bind(void 0,0,0,1,0,3),X.bind(void 0,0,0,1,1,0),X.bind(void 0,0,0,1,1,1),X.bind(void 0,0,0,1,1,2),X.bind(void 0,0,0,1,1,3),X.bind(void 0,0,1,0,0,0),X.bind(void 0,0,1,0,0,1),X.bind(void 0,0,1,0,0,2),X.bind(void 0,0,1,0,0,3),X.bind(void 0,0,1,0,1,0),X.bind(void 0,0,1,0,1,1),X.bind(void 0,0,1,0,1,2),X.bind(void 0,0,1,0,1,3),X.bind(void 0,0,1,1,0,0),X.bind(void 0,0,1,1,0,1),X.bind(void 0,0,1,1,0,2),X.bind(void 0,0,1,1,0,3),X.bind(void 0,0,1,1,1,0),X.bind(void 0,0,1,1,1,1),X.bind(void 0,0,1,1,1,2),X.bind(void 0,0,1,1,1,3),X.bind(void 0,1,0,0,0,0),X.bind(void 0,1,0,0,0,1),X.bind(void 0,1,0,0,0,2),X.bind(void 0,1,0,0,0,3),X.bind(void 0,1,0,0,1,0),X.bind(void 0,1,0,0,1,1),X.bind(void 0,1,0,0,1,2),X.bind(void 0,1,0,0,1,3),X.bind(void 0,1,0,1,0,0),X.bind(void 0,1,0,1,0,1),X.bind(void 0,1,0,1,0,2),X.bind(void 0,1,0,1,0,3),X.bind(void 0,1,0,1,1,0),X.bind(void 0,1,0,1,1,1),X.bind(void 0,1,0,1,1,2),X.bind(void 0,1,0,1,1,3),X.bind(void 0,1,1,0,0,0),X.bind(void 0,1,1,0,0,1),X.bind(void 0,1,1,0,0,2),X.bind(void 0,1,1,0,0,3),X.bind(void 0,1,1,0,1,0),X.bind(void 0,1,1,0,1,1),X.bind(void 0,1,1,0,1,2),X.bind(void 0,1,1,0,1,3),X.bind(void 0,1,1,1,0,0),X.bind(void 0,1,1,1,0,1),X.bind(void 0,1,1,1,0,2),X.bind(void 0,1,1,1,0,3),X.bind(void 0,1,1,1,1,0),X.bind(void 0,1,1,1,1,1),X.bind(void 0,1,1,1,1,2),X.bind(void 0,1,1,1,1,3)];var ps=oa;function ms(e){this.char=e,this.state={},this.activeState=null}function hs(e,t,n){this.contextName=n,this.startIndex=e,this.endOffset=t}function gs(e,t,n){this.contextName=e,this.openRange=null,this.ranges=[],this.checkStart=t,this.checkEnd=n}function _s(e,t){this.context=e,this.index=t,this.length=e.length,this.current=e[t],this.backtrack=e.slice(0,t),this.lookahead=e.slice(t+1)}function vs(e){this.eventId=e,this.subscribers=[]}function ys(e){let t=[`start`,`end`,`next`,`newToken`,`contextStart`,`contextEnd`,`insertToken`,`removeToken`,`removeRange`,`replaceToken`,`replaceRange`,`composeRUD`,`updateContextsRanges`];for(let e=0;e<t.length;e++){let n=t[e];Object.defineProperty(this.events,n,{value:new vs(n)})}if(e)for(let n=0;n<t.length;n++){let r=t[n],i=e[r];typeof i==`function`&&this.events[r].subscribe(i)}let n=[`insertToken`,`removeToken`,`removeRange`,`replaceToken`,`replaceRange`,`composeRUD`];for(let e=0;e<n.length;e++){let t=n[e];this.events[t].subscribe(this.updateContextsRanges)}}function bs(e){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],ys.call(this,e)}ms.prototype.setState=function(e,t){return this.state[e]=t,this.activeState={key:e,value:this.state[e]},this.activeState},ms.prototype.getState=function(e){return this.state[e]||null},bs.prototype.inboundIndex=function(e){return e>=0&&e<this.tokens.length},bs.prototype.composeRUD=function(e){let t=e.map(e=>this[e[0]].apply(this,e.slice(1).concat(!0))),n=e=>typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`FAIL`);if(t.every(n))return{FAIL:`composeRUD: one or more operations hasn't completed successfully`,report:t.filter(n)};this.dispatch(`composeRUD`,[t.filter(e=>!n(e))])},bs.prototype.replaceRange=function(e,t,n,r){t=t===null?this.tokens.length:t;let i=n.every(e=>e instanceof ms);if(!isNaN(e)&&this.inboundIndex(e)&&i){let i=this.tokens.splice.apply(this.tokens,[e,t].concat(n));return r||this.dispatch(`replaceToken`,[e,t,n]),[i,n]}return{FAIL:`replaceRange: invalid tokens or startIndex.`}},bs.prototype.replaceToken=function(e,t,n){if(!isNaN(e)&&this.inboundIndex(e)&&t instanceof ms){let r=this.tokens.splice(e,1,t);return n||this.dispatch(`replaceToken`,[e,t]),[r[0],t]}return{FAIL:`replaceToken: invalid token or index.`}},bs.prototype.removeRange=function(e,t,n){t=isNaN(t)?this.tokens.length:t;let r=this.tokens.splice(e,t);return n||this.dispatch(`removeRange`,[r,e,t]),r},bs.prototype.removeToken=function(e,t){if(!isNaN(e)&&this.inboundIndex(e)){let n=this.tokens.splice(e,1);return t||this.dispatch(`removeToken`,[n,e]),n}return{FAIL:`removeToken: invalid token index.`}},bs.prototype.insertToken=function(e,t,n){return e.every(e=>e instanceof ms)?(this.tokens.splice.apply(this.tokens,[t,0].concat(e)),n||this.dispatch(`insertToken`,[e,t]),e):{FAIL:`insertToken: invalid token(s).`}},bs.prototype.registerModifier=function(e,t,n){this.events.newToken.subscribe(function(r,i){let a=[r,i],o=t===null||t.apply(this,a)===!0,s=[r,i];if(o){let t=n.apply(this,s);r.setState(e,t)}}),this.registeredModifiers.push(e)},vs.prototype.subscribe=function(e){return typeof e==`function`?this.subscribers.push(e)-1:{FAIL:`invalid '${this.eventId}' event handler`}},vs.prototype.unsubscribe=function(e){this.subscribers.splice(e,1)},_s.prototype.setCurrentIndex=function(e){this.index=e,this.current=this.context[e],this.backtrack=this.context.slice(0,e),this.lookahead=this.context.slice(e+1)},_s.prototype.get=function(e){switch(!0){case e===0:return this.current;case e<0&&Math.abs(e)<=this.backtrack.length:return this.backtrack.slice(e)[0];case e>0&&e<=this.lookahead.length:return this.lookahead[e-1];default:return null}},bs.prototype.rangeToText=function(e){if(e instanceof hs)return this.getRangeTokens(e).map(e=>e.char).join(``)},bs.prototype.getText=function(){return this.tokens.map(e=>e.char).join(``)},bs.prototype.getContext=function(e){return this.registeredContexts[e]||null},bs.prototype.on=function(e,t){let n=this.events[e];return n?n.subscribe(t):null},bs.prototype.dispatch=function(e,t){let n=this.events[e];if(n instanceof vs)for(let e=0;e<n.subscribers.length;e++)n.subscribers[e].apply(this,t||[])},bs.prototype.registerContextChecker=function(e,t,n){if(this.getContext(e))return{FAIL:`context name '${e}' is already registered.`};if(typeof t!=`function`)return{FAIL:`missing context start check.`};if(typeof n!=`function`)return{FAIL:`missing context end check.`};let r=new gs(e,t,n);return this.registeredContexts[e]=r,this.contextCheckers.push(r),r},bs.prototype.getRangeTokens=function(e){let t=e.startIndex+e.endOffset;return[].concat(this.tokens.slice(e.startIndex,t))},bs.prototype.getContextRanges=function(e){let t=this.getContext(e);return t?t.ranges:{FAIL:`context checker '${e}' is not registered.`}},bs.prototype.resetContextsRanges=function(){let e=this.registeredContexts;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];n.ranges=[]}},bs.prototype.updateContextsRanges=function(){this.resetContextsRanges();let e=this.tokens.map(e=>e.char);for(let t=0;t<e.length;t++){let n=new _s(e,t);this.runContextCheck(n)}this.dispatch(`updateContextsRanges`,[this.registeredContexts])},bs.prototype.setEndOffset=function(e,t){let n=this.getContext(t).openRange.startIndex,r=new hs(n,e,t),i=this.getContext(t).ranges;return r.rangeId=`${t}.${i.length}`,i.push(r),this.getContext(t).openRange=null,r},bs.prototype.runContextCheck=function(e){let t=e.index;for(let n=0;n<this.contextCheckers.length;n++){let r=this.contextCheckers[n],i=r.contextName,a=this.getContext(i).openRange;if(!a&&r.checkStart(e)&&(a=new hs(t,null,i),this.getContext(i).openRange=a,this.dispatch(`contextStart`,[i,t])),a&&r.checkEnd(e)){let e=t-a.startIndex+1,n=this.setEndOffset(e,i);this.dispatch(`contextEnd`,[i,n])}}},bs.prototype.tokenize=function(e){this.tokens=[],this.resetContextsRanges();let t=Array.from(e);this.dispatch(`start`);for(let e=0;e<t.length;e++){let n=t[e],r=new _s(t,e);this.dispatch(`next`,[r]),this.runContextCheck(r);let i=new ms(n);this.tokens.push(i),this.dispatch(`newToken`,[i,r])}return this.dispatch(`end`,[this.tokens]),this.tokens};var xs=bs;function Ss(e){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(e)}function Cs(e){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(e)}function ws(e){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(e)}function Ts(e){return/[\u0E00-\u0E7F]/.test(e)}function Es(e){return/[A-z]/.test(e)}function Ds(e){return/\s/.test(e)}function Os(e){this.font=e,this.features={}}function ks(e){this.id=e.id,this.tag=e.tag,this.substitution=e.substitution}function As(e,t){if(!e)return-1;switch(t.format){case 1:return t.glyphs.indexOf(e);case 2:{let n=t.ranges;for(let t=0;t<n.length;t++){let r=n[t];if(e>=r.start&&e<=r.end){let t=e-r.start;return r.index+t}}break}default:return-1}return-1}function js(e,t){return As(e,t.coverage)===-1?null:e+t.deltaGlyphId}function Ms(e,t){let n=As(e,t.coverage);return n===-1?null:t.substitute[n]}function Ns(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.current;a=Array.isArray(a)?a[0]:a;let o=As(a,i);o!==-1&&n.push(o)}return n.length===e.length?n:-1}function Ps(e,t){let n=t.inputCoverage.length+t.lookaheadCoverage.length+t.backtrackCoverage.length;if(e.context.length<n)return[];let r=Ns(t.inputCoverage,e);if(r===-1)return[];let i=t.inputCoverage.length-1;if(e.lookahead.length<t.lookaheadCoverage.length)return[];let a=e.lookahead.slice(i);for(;a.length&&ws(a[0].char);)a.shift();let o=new _s(a,0),s=Ns(t.lookaheadCoverage,o),c=[].concat(e.backtrack);for(c.reverse();c.length&&ws(c[0].char);)c.shift();if(c.length<t.backtrackCoverage.length)return[];let l=new _s(c,0),u=Ns(t.backtrackCoverage,l),d=r.length===t.inputCoverage.length&&s.length===t.lookaheadCoverage.length&&u.length===t.backtrackCoverage.length,f=[];if(d)for(let n=0;n<t.lookupRecords.length;n++){let r=t.lookupRecords[n],i=r.lookupListIndex,a=this.getLookupByIndex(i);for(let t=0;t<a.subtables.length;t++){let n=a.subtables[t],i,o=this.getSubstitutionType(a,n);if(o===`71`?(o=this.getSubstitutionType(n,n.extension),i=this.getLookupMethod(n,n.extension),n=n.extension):i=this.getLookupMethod(a,n),o===`12`){let t=e.get(r.sequenceIndex),n=i(t);n&&f.push(n)}else if(o===`21`){let t=e.get(r.sequenceIndex),n=i(t);n&&f.push(n)}else throw Error(`Substitution type ${o} is not supported in chaining substitution`)}}return f}function Fs(e,t){let n=e.current,r=As(n,t.coverage);if(r===-1)return null;let i,a=t.ligatureSets[r];for(let t=0;t<a.length;t++){i=a[t];for(let t=0;t<i.components.length&&e.lookahead[t]===i.components[t];t++)if(t===i.components.length-1)return i}return null}function Is(e,t){let n=e.current;if(As(n,t.coverage)===-1)return null;for(let r of t.ruleSets)for(let t of r){let r=!0;for(let n=0;n<t.input.length;n++)if(e.lookahead[n]!==t.input[n]){r=!1;break}if(r){let e=[];e.push(n);for(let n=0;n<t.input.length;n++)e.push(t.input[n]);let r=(e,t)=>{let{lookupListIndex:n,sequenceIndex:r}=t,{subtables:i}=this.getLookupByIndex(n);for(let t of i)As(e[r],t.coverage)!==-1&&(e[r]=t.deltaGlyphId)};for(let n=0;n<t.lookupRecords.length;n++){let i=t.lookupRecords[n];r(e,i)}return e}}return null}function Ls(e,t){if(e.context.length<t.coverages.length)return[];for(let n=0;n<t.coverages.length;n++){let r=e.get(n);if(r=Array.isArray(r)?r[0]:r,As(r,t.coverages[n])===-1)return[]}let n=[];for(let r=0;r<t.lookupRecords.length;r++){let i=t.lookupRecords[r],a=i.lookupListIndex,o=this.getLookupByIndex(a);for(let t=0;t<o.subtables.length;t++){let r=o.subtables[t],a,s=this.getSubstitutionType(o,r);if(s===`71`?(s=this.getSubstitutionType(r,r.extension),a=this.getLookupMethod(r,r.extension),r=r.extension):a=this.getLookupMethod(o,r),s===`12`){let t=e.get(i.sequenceIndex),r=a(t);r&&n.push(r)}else if(s===`21`){let t=e.get(i.sequenceIndex),r=a(t);r&&n.push(r)}}}return n}function Rs(e,t){let n=As(e,t.coverage);return n===-1?null:t.sequences[n]}Os.prototype.getDefaultScriptFeaturesIndexes=function(){let e=this.font.tables.gsub.scripts;for(let t=0;t<e.length;t++){let n=e[t];if(n.tag===`DFLT`)return n.script.defaultLangSys.featureIndexes}return[]},Os.prototype.getScriptFeaturesIndexes=function(e){if(!this.font.tables.gsub)return[];if(!e)return this.getDefaultScriptFeaturesIndexes();let t=this.font.tables.gsub.scripts;for(let n=0;n<t.length;n++){let r=t[n];if(r.tag===e&&r.script.defaultLangSys)return r.script.defaultLangSys.featureIndexes;{let t=r.langSysRecords;if(t)for(let n=0;n<t.length;n++){let r=t[n];if(r.tag===e)return r.langSys.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},Os.prototype.mapTagsToFeatures=function(e,t){let n={};for(let t=0;t<e.length;t++){let r=e[t].tag;n[r]=e[t].feature}this.features[t].tags=n},Os.prototype.getScriptFeatures=function(e){let t=this.features[e];if(Object.prototype.hasOwnProperty.call(this.features,e))return t;let n=this.getScriptFeaturesIndexes(e);if(!n)return null;let r=this.font.tables.gsub;return t=n.map(e=>r.features[e]),this.features[e]=t,this.mapTagsToFeatures(t,e),t},Os.prototype.getSubstitutionType=function(e,t){return e.lookupType.toString()+t.substFormat.toString()},Os.prototype.getLookupMethod=function(e,t){let n=this.getSubstitutionType(e,t);switch(n){case`11`:return e=>js.apply(this,[e,t]);case`12`:return e=>Ms.apply(this,[e,t]);case`63`:return e=>Ps.apply(this,[e,t]);case`41`:return e=>Fs.apply(this,[e,t]);case`21`:return e=>Rs.apply(this,[e,t]);case`51`:return e=>Is.apply(this,[e,t]);case`53`:return e=>Ls.apply(this,[e,t]);default:throw Error(`substitutionType : ${n} lookupType: ${e.lookupType} - substFormat: ${t.substFormat} is not yet supported`)}},Os.prototype.lookupFeature=function(e){let t=e.contextParams,n=t.index,r=this.getFeature({tag:e.tag,script:e.script});if(!r)return/* @__PURE__ */ Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${e.tag}' for script '${e.script}'.`);let i=this.getFeatureLookups(r),a=[].concat(t.context);for(let r=0;r<i.length;r++){let o=i[r],s=this.getLookupSubtables(o);for(let r=0;r<s.length;r++){let i=s[r],c=this.getSubstitutionType(o,i),l;c===`71`?(c=this.getSubstitutionType(i,i.extension),l=this.getLookupMethod(i,i.extension),i=i.extension):l=this.getLookupMethod(o,i);let u;switch(c){case`11`:u=l(t.current),u&&a.splice(n,1,new ks({id:11,tag:e.tag,substitution:u}));break;case`12`:u=l(t.current),u&&a.splice(n,1,new ks({id:12,tag:e.tag,substitution:u}));break;case`63`:u=l(t),Array.isArray(u)&&u.length&&a.splice(n,1,new ks({id:63,tag:e.tag,substitution:u}));break;case`41`:u=l(t),u&&a.splice(n,1,new ks({id:41,tag:e.tag,substitution:u}));break;case`21`:u=l(t.current),u&&a.splice(n,1,new ks({id:21,tag:e.tag,substitution:u}));break;case`51`:case`53`:u=l(t),Array.isArray(u)&&u.length&&a.splice(n,1,new ks({id:parseInt(c),tag:e.tag,substitution:u}))}t=new _s(a,n),(!Array.isArray(u)||u.length)&&(u=null)}}return a.length?a:null},Os.prototype.supports=function(e){if(!e.script)return!1;this.getScriptFeatures(e.script);let t=Object.prototype.hasOwnProperty.call(this.features,e.script);if(!e.tag)return t;let n=this.features[e.script].some(t=>t.tag===e.tag);return t&&n},Os.prototype.getLookupSubtables=function(e){return e.subtables||null},Os.prototype.getLookupByIndex=function(e){return this.font.tables.gsub.lookups[e]||null},Os.prototype.getFeatureLookups=function(e){return e.lookupListIndexes.map(this.getLookupByIndex.bind(this))},Os.prototype.getFeature=function(e){if(!this.font)return{FAIL:`No font was found`};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);let t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var zs=Os;function Bs(e){let t=e.current,n=e.get(-1);return n===null&&Ss(t)||!Ss(n)&&Ss(t)}function Vs(e){let t=e.get(1);return t===null||!Ss(t)}var Hs={startCheck:Bs,endCheck:Vs};function Us(e){let t=e.current,n=e.get(-1);return(Ss(t)||ws(t))&&!Ss(n)}function Ws(e){let t=e.get(1);switch(!0){case t===null:return!0;case!Ss(t)&&!ws(t):{let n=Ds(t);if(!n)return!0;if(n){let t=!1;if(t=e.lookahead.some(e=>Ss(e)||ws(e)),!t)return!0}break}default:return!1}}var Gs={startCheck:Us,endCheck:Ws};function Ks(e,t,n){t[n].setState(e.tag,e.substitution)}function qs(e,t,n){t[n].setState(e.tag,e.substitution)}function Js(e,t,n){for(let r=0;r<e.substitution.length;r++){let i=e.substitution[r],a=t[n+r];Array.isArray(i)?i.length?a.setState(e.tag,i[0]):a.setState(`deleted`,!0):a.setState(e.tag,i)}}function Ys(e,t,n){let r=t[n];r.setState(e.tag,e.substitution.ligGlyph);let i=e.substitution.components.length;for(let e=0;e<i;e++)r=t[n+e+1],r.setState(`deleted`,!0)}var Xs={11:Ks,12:qs,63:Js,41:Ys,51:Js,53:Js};function Zs(e,t,n){e instanceof ks&&Xs[e.id]&&Xs[e.id](e,t,n)}var Qs=Zs;function $s(e){let t=[].concat(e.backtrack);for(let e=t.length-1;e>=0;e--){let n=t[e],r=Cs(n),i=ws(n);if(!r&&!i)return!0;if(r)return!1}return!1}function ec(e){if(Cs(e.current))return!1;for(let t=0;t<e.lookahead.length;t++){let n=e.lookahead[t];if(!ws(n))return!0}return!1}function tc(e){let t=`arab`,n=this.featuresTags[t],r=this.tokenizer.getRangeTokens(e);if(r.length===1)return;let i=new _s(r.map(e=>e.getState(`glyphIndex`)),0),a=new _s(r.map(e=>e.char),0);for(let e=0;e<r.length;e++){let o=r[e];if(ws(o.char))continue;i.setCurrentIndex(e),a.setCurrentIndex(e);let s=0;$s(a)&&(s|=1),ec(a)&&(s|=2);let c;switch(s){case 1:c=`fina`;break;case 2:c=`init`;break;case 3:c=`medi`}if(n.indexOf(c)===-1)continue;let l=this.query.lookupFeature({tag:c,script:t,contextParams:i});if(l instanceof Error)console.info(l.message);else for(let e=0;e<l.length;e++){let t=l[e];t instanceof ks&&(Qs(t,r,e),i.context[e]=t.substitution)}}}var nc=tc;function rc(e,t){return new _s(e.map(e=>e.activeState.value),t||0)}function ic(e){let t=this.tokenizer.getRangeTokens(e),n=rc(t);for(let e=0;e<n.context.length;e++){n.setCurrentIndex(e);let r=this.query.lookupFeature({tag:`rlig`,script:`arab`,contextParams:n});if(r.length){for(let n=0;n<r.length;n++){let i=r[n];Qs(i,t,e)}n=rc(t)}}}var ac=ic;function oc(e){return e.index===0&&e.context.length>1}function sc(e){return e.index===e.context.length-1}var cc={startCheck:oc,endCheck:sc};function lc(e,t){return new _s(e.map(e=>e.activeState.value),t||0)}function uc(e){let t=`delf`,n=`ccmp`,r=this.tokenizer.getRangeTokens(e),i=lc(r);for(let e=0;e<i.context.length;e++){if(!this.query.getFeature({tag:n,script:t,contextParams:i}))continue;i.setCurrentIndex(e);let a=this.query.lookupFeature({tag:n,script:t,contextParams:i});if(a.length){for(let t=0;t<a.length;t++){let n=a[t];Qs(n,r,e)}i=lc(r)}}}var dc=uc;function fc(e){let t=e.current,n=e.get(-1);return n===null&&Es(t)||!Es(n)&&Es(t)}function pc(e){let t=e.get(1);return t===null||!Es(t)}var mc={startCheck:fc,endCheck:pc};function hc(e,t){return new _s(e.map(e=>e.activeState.value),t||0)}function gc(e){let t=this.tokenizer.getRangeTokens(e),n=hc(t);for(let e=0;e<n.context.length;e++){n.setCurrentIndex(e);let r=this.query.lookupFeature({tag:`liga`,script:`latn`,contextParams:n});if(r.length){for(let n=0;n<r.length;n++){let i=r[n];Qs(i,t,e)}n=hc(t)}}}var _c=gc;function vc(e){let t=e.current,n=e.get(-1);return n===null&&Ts(t)||!Ts(n)&&Ts(t)}function yc(e){let t=e.get(1);return t===null||!Ts(t)}var bc={startCheck:vc,endCheck:yc};function xc(e,t){return new _s(e.map(e=>e.activeState.value),t||0)}function Sc(e){let t=this.tokenizer.getRangeTokens(e),n=xc(t,0);for(let e=0;e<n.context.length;e++){n.setCurrentIndex(e);let r=this.query.lookupFeature({tag:`ccmp`,script:`thai`,contextParams:n});if(r.length){for(let n=0;n<r.length;n++){let i=r[n];Qs(i,t,e)}n=xc(t,e)}}}var Cc=Sc;function wc(e,t){return new _s(e.map(e=>e.activeState.value),t||0)}function Tc(e){let t=this.tokenizer.getRangeTokens(e),n=wc(t,0);for(let e=0;e<n.context.length;e++){n.setCurrentIndex(e);let r=this.query.lookupFeature({tag:`liga`,script:`thai`,contextParams:n});if(r.length){for(let n=0;n<r.length;n++){let i=r[n];Qs(i,t,e)}n=wc(t,e)}}}var Z=Tc;function Ec(e,t){return new _s(e.map(e=>e.activeState.value),t||0)}function Dc(e){let t=this.tokenizer.getRangeTokens(e),n=Ec(t,0);for(let e=0;e<n.context.length;e++){n.setCurrentIndex(e);let r=this.query.lookupFeature({tag:`rlig`,script:`thai`,contextParams:n});if(r.length){for(let n=0;n<r.length;n++){let i=r[n];Qs(i,t,e)}n=Ec(t,e)}}}var Oc=Dc;function kc(e){if(e===null)return!1;let t=e.codePointAt(0);return t>=6155&&t<=6157||t>=65024&&t<=65039||t>=917760&&t<=917999}function Ac(e){let t=e.current,n=e.get(1);return n===null&&kc(t)||kc(n)}function jc(e){let t=e.get(1);return t===null||!kc(t)}var Mc={startCheck:Ac,endCheck:jc};function Nc(e){let t=this.query.font,n=this.tokenizer.getRangeTokens(e);if(n[1].setState(`deleted`,!0),t.tables.cmap&&t.tables.cmap.varSelectorList){let e=n[0].char.codePointAt(0),r=n[1].char.codePointAt(0),i=t.tables.cmap.varSelectorList[r];if(i!==void 0&&i.nonDefaultUVS){let r=i.nonDefaultUVS.uvsMappings;if(r[e]){let i=r[e].glyphID;t.glyphs.glyphs[i]!==void 0&&n[0].setState(`glyphIndex`,i)}}}}var Pc=Nc;function Fc(e){this.baseDir=e||`ltr`,this.tokenizer=new xs,this.featuresTags={}}Fc.prototype.setText=function(e){this.text=e},Fc.prototype.contextChecks={ccmpReplacementCheck:cc,latinWordCheck:mc,arabicWordCheck:Hs,arabicSentenceCheck:Gs,thaiWordCheck:bc,unicodeVariationSequenceCheck:Mc};function Ic(e){let t=this.contextChecks[`${e}Check`];return this.tokenizer.registerContextChecker(e,t.startCheck,t.endCheck)}function Lc(){return Ic.call(this,`ccmpReplacement`),Ic.call(this,`latinWord`),Ic.call(this,`arabicWord`),Ic.call(this,`arabicSentence`),Ic.call(this,`thaiWord`),Ic.call(this,`unicodeVariationSequence`),this.tokenizer.tokenize(this.text)}function Rc(){let e=this.tokenizer.getContextRanges(`arabicSentence`);for(let t=0;t<e.length;t++){let n=e[t],r=this.tokenizer.getRangeTokens(n);this.tokenizer.replaceRange(n.startIndex,n.endOffset,r.reverse())}}Fc.prototype.registerFeatures=function(e,t){let n=t.filter(t=>this.query.supports({script:e,tag:t}));Object.prototype.hasOwnProperty.call(this.featuresTags,e)?this.featuresTags[e]=this.featuresTags[e].concat(n):this.featuresTags[e]=n},Fc.prototype.applyFeatures=function(e,t){if(!e)throw Error(`No valid font was provided to apply features`);this.query||=new zs(e);for(let e=0;e<t.length;e++){let n=t[e];this.query.supports({script:n.script})&&this.registerFeatures(n.script,n.tags)}},Fc.prototype.registerModifier=function(e,t,n){this.tokenizer.registerModifier(e,t,n)};function zc(){if(this.tokenizer.registeredModifiers.indexOf(`glyphIndex`)===-1)throw Error(`glyphIndex modifier is required to apply arabic presentation features.`)}function Bc(){if(!Object.prototype.hasOwnProperty.call(this.featuresTags,`arab`))return;zc.call(this);let e=this.tokenizer.getContextRanges(`arabicWord`);for(let t=0;t<e.length;t++){let n=e[t];nc.call(this,n)}}function Vc(){zc.call(this);let e=this.tokenizer.getContextRanges(`ccmpReplacement`);for(let t=0;t<e.length;t++){let n=e[t];dc.call(this,n)}}function Hc(){if(!this.hasFeatureEnabled(`arab`,`rlig`))return;zc.call(this);let e=this.tokenizer.getContextRanges(`arabicWord`);for(let t=0;t<e.length;t++){let n=e[t];ac.call(this,n)}}function Uc(){if(!this.hasFeatureEnabled(`latn`,`liga`))return;zc.call(this);let e=this.tokenizer.getContextRanges(`latinWord`);for(let t=0;t<e.length;t++){let n=e[t];_c.call(this,n)}}function Wc(){let e=this.tokenizer.getContextRanges(`unicodeVariationSequence`);for(let t=0;t<e.length;t++){let n=e[t];Pc.call(this,n)}}function Gc(){zc.call(this);let e=this.tokenizer.getContextRanges(`thaiWord`);for(let t=0;t<e.length;t++){let n=e[t];this.hasFeatureEnabled(`thai`,`liga`)&&Z.call(this,n),this.hasFeatureEnabled(`thai`,`rlig`)&&Oc.call(this,n),this.hasFeatureEnabled(`thai`,`ccmp`)&&Cc.call(this,n)}}Fc.prototype.checkContextReady=function(e){return!!this.tokenizer.getContext(e)},Fc.prototype.applyFeaturesToContexts=function(){this.checkContextReady(`ccmpReplacement`)&&Vc.call(this),this.checkContextReady(`arabicWord`)&&(Bc.call(this),Hc.call(this)),this.checkContextReady(`latinWord`)&&Uc.call(this),this.checkContextReady(`arabicSentence`)&&Rc.call(this),this.checkContextReady(`thaiWord`)&&Gc.call(this),this.checkContextReady(`unicodeVariationSequence`)&&Wc.call(this)},Fc.prototype.hasFeatureEnabled=function(e,t){return(this.featuresTags[e]||[]).indexOf(t)!==-1},Fc.prototype.processText=function(e){this.text&&this.text===e||(this.setText(e),Lc.call(this),this.applyFeaturesToContexts())},Fc.prototype.getBidiText=function(e){return this.processText(e),this.tokenizer.getText()},Fc.prototype.getTextGlyphs=function(e){this.processText(e);let t=[];for(let e=0;e<this.tokenizer.tokens.length;e++){let n=this.tokenizer.tokens[e];if(n.state.deleted)continue;let r=n.activeState.value;t.push(Array.isArray(r)?r[0]:r)}return t};var Kc=Fc;function qc(e){return{fontFamily:{en:e.familyName||` `},fontSubfamily:{en:e.styleName||` `},fullName:{en:e.fullName||e.familyName+` `+e.styleName},postScriptName:{en:e.postScriptName||(e.familyName+e.styleName).replace(/\s/g,``)},designer:{en:e.designer||` `},designerURL:{en:e.designerURL||` `},manufacturer:{en:e.manufacturer||` `},manufacturerURL:{en:e.manufacturerURL||` `},license:{en:e.license||` `},licenseURL:{en:e.licenseURL||` `},version:{en:e.version||`Version 0.1`},description:{en:e.description||` `},copyright:{en:e.copyright||` `},trademark:{en:e.trademark||` `}}}function Jc(e){if(e||={},e.tables=e.tables||{},!e.empty){if(!e.familyName)throw Error(`When creating a new Font object, familyName is required.`);if(!e.styleName)throw Error(`When creating a new Font object, styleName is required.`);if(!e.unitsPerEm)throw Error(`When creating a new Font object, unitsPerEm is required.`);if(!e.ascender)throw Error(`When creating a new Font object, ascender is required.`);if(e.descender>0)throw Error(`When creating a new Font object, negative descender value is required.`);this.names={},this.names.unicode=qc(e),this.names.macintosh=qc(e),this.names.windows=qc(e),this.unitsPerEm=e.unitsPerEm||1e3,this.ascender=e.ascender,this.descender=e.descender,this.createdTimestamp=e.createdTimestamp,this.italicAngle=e.italicAngle||0,this.weightClass=e.weightClass||0;let t=0;e.fsSelection?t=e.fsSelection:(this.italicAngle<0?t|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(t|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(t|=this.fsSelectionValues.BOLD),t===0&&(t=this.fsSelectionValues.REGULAR)),e.panose&&Array.isArray(e.panose)||(e.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(e.tables,{os2:Object.assign({usWeightClass:e.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:e.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:e.panose[0]||0,bSerifStyle:e.panose[1]||0,bWeight:e.panose[2]||0,bProportion:e.panose[3]||0,bContrast:e.panose[4]||0,bStrokeVariation:e.panose[5]||0,bArmStyle:e.panose[6]||0,bLetterform:e.panose[7]||0,bMidline:e.panose[8]||0,bXHeight:e.panose[9]||0,fsSelection:t},e.tables.os2)})}this.supported=!0,this.glyphs=new Xt.GlyphSet(this,e.glyphs||[]),this.encoding=new St(this),this.position=new vi(this),this.substitution=new ki(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,t,n)=>(e[t]=n,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new Qi(this)),!0)}),this.palettes=new Ai(this),this.layers=new ji(this),this.svgImages=new Mi(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat===`truetype`?this._hinting=new ps(this):null}})}Jc.prototype.hasChar=function(e){return this.encoding.charToGlyphIndex(e)>0},Jc.prototype.charToGlyphIndex=function(e){return this.encoding.charToGlyphIndex(e)},Jc.prototype.charToGlyph=function(e){let t=this.charToGlyphIndex(e),n=this.glyphs.get(t);return n||=this.glyphs.get(0),n},Jc.prototype.updateFeatures=function(e){return this.defaultRenderOptions.features.map(t=>t.script===`latn`?{script:`latn`,tags:t.tags.filter(t=>e[t])}:t)},Jc.prototype.stringToGlyphIndexes=function(e,t){let n=new Kc;n.registerModifier(`glyphIndex`,null,e=>this.charToGlyphIndex(e.char));let r=t?this.updateFeatures(t.features):this.defaultRenderOptions.features;return n.applyFeatures(this,r),n.getTextGlyphs(e)},Jc.prototype.stringToGlyphs=function(e,t){let n=this.stringToGlyphIndexes(e,t),r=n.length,i=Array(r),a=this.glyphs.get(0);for(let e=0;e<r;e+=1)i[e]=this.glyphs.get(n[e])||a;return i},Jc.prototype.nameToGlyphIndex=function(e){return this.glyphNames.nameToGlyphIndex(e)},Jc.prototype.nameToGlyph=function(e){let t=this.nameToGlyphIndex(e),n=this.glyphs.get(t);return n||=this.glyphs.get(0),n},Jc.prototype.glyphIndexToName=function(e){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(e):``},Jc.prototype.getKerningValue=function(e,t){e=e.index||e,t=t.index||t;let n=this.position.defaultKerningTables;return n?this.position.getKerningValue(n,e,t):this.kerningPairs[e+`,`+t]||0},Jc.prototype.defaultRenderOptions={kerning:!0,features:[{script:`arab`,tags:[`init`,`medi`,`fina`,`rlig`]},{script:`latn`,tags:[`liga`,`rlig`]},{script:`thai`,tags:[`liga`,`rlig`,`ccmp`]}],hinting:!1,usePalette:0,drawLayers:!0,drawSVG:!0},Jc.prototype.forEachGlyph=function(e,t,n,r,i,a){t=t===void 0?0:t,n=n===void 0?0:n,r=r===void 0?72:r,i=Object.assign({},this.defaultRenderOptions,i);let o=1/this.unitsPerEm*r,s=this.stringToGlyphs(e,i),c;if(i.kerning){let e=i.script||this.position.getDefaultScriptName();c=this.position.getKerningTables(e,i.language)}for(let e=0;e<s.length;e+=1){let l=s[e];if(a.call(this,l,t,n,r,i),l.advanceWidth&&(t+=l.advanceWidth*o),i.kerning&&e<s.length-1){let n=c?this.position.getKerningValue(c,l.index,s[e+1].index):this.getKerningValue(l,s[e+1]);t+=n*o}i.letterSpacing?t+=i.letterSpacing*r:i.tracking&&(t+=i.tracking/1e3*r)}return t},Jc.prototype.getPath=function(e,t,n,r,i){i=Object.assign({},this.defaultRenderOptions,i);let a=new L;if(a._layers=[],wn(this,a,r),a.stroke){let e=1/(a.unitsPerEm||1e3)*r;a.strokeWidth*=e}return this.forEachGlyph(e,t,n,r,i,(e,t,n,r)=>{let o=e.getPath(t,n,r,i,this);if(i.drawSVG||i.drawLayers){let e=o._layers;if(e&&e.length){for(let t=0;t<e.length;t++){let n=e[t];a._layers.push(n)}return}}a.extend(o)}),a},Jc.prototype.getPaths=function(e,t,n,r,i){i=Object.assign({},this.defaultRenderOptions,i);let a=[];return this.forEachGlyph(e,t,n,r,i,function(e,t,n,r){let o=e.getPath(t,n,r,i,this);a.push(o)}),a},Jc.prototype.getAdvanceWidth=function(e,t,n){return n=Object.assign({},this.defaultRenderOptions,n),this.forEachGlyph(e,0,0,t,n,function(){})},Jc.prototype.draw=function(e,t,n,r,i,a){this.getPath(t,n,r,i,a).draw(e)},Jc.prototype.drawPoints=function(e,t,n,r,i,a){a=Object.assign({},this.defaultRenderOptions,a),this.forEachGlyph(t,n,r,i,a,function(t,n,r,i){t.drawPoints(e,n,r,i,a,this)})},Jc.prototype.drawMetrics=function(e,t,n,r,i,a){a=Object.assign({},this.defaultRenderOptions,a),this.forEachGlyph(t,n,r,i,a,function(t,n,r,i){t.drawMetrics(e,n,r,i)})},Jc.prototype.getEnglishName=function(e){let t=(this.names.unicode||this.names.macintosh||this.names.windows)[e];if(t)return t.en},Jc.prototype.validate=function(){let e=[],t=this;function n(t,n){t||(console.warn(`[opentype.js] ${n}`),e.push(n))}function r(e){let r=t.getEnglishName(e);n(r&&r.trim().length>0,`No English `+e+` specified.`)}if(r(`fontFamily`),r(`weightName`),r(`manufacturer`),r(`copyright`),r(`version`),n(this.unitsPerEm>0,`No unitsPerEm specified.`),this.tables.colr){let e=this.tables.colr.baseGlyphRecords,t=-1;for(let r=0;r<e.length;r++){let i=e[r].glyphID;if(n(t<e[r].glyphID,`baseGlyphs must be sorted by GlyphID in ascending order, but glyphID ${i} comes after ${t}`),t>e[r].glyphID)break;t=i}}return e},Jc.prototype.toTables=function(){return di.fontToTable(this)},Jc.prototype.toBuffer=function(){return console.warn(`Font.toBuffer is deprecated. Use Font.toArrayBuffer instead.`),this.toArrayBuffer()},Jc.prototype.toArrayBuffer=function(){let e=this.toTables().encode(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0;t<e.length;t++)n[t]=e[t];return t},Jc.prototype.download=function(){console.error(`DEPRECATED: platform-specific actions are to be implemented on user-side`)},Jc.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},Jc.prototype.macStyleValues={BOLD:1,ITALIC:2,UNDERLINE:4,OUTLINED:8,SHADOW:16,CONDENSED:32,EXTENDED:64},Jc.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},Jc.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var Yc=Jc;function Xc(e,t){let n=new q.Parser(e,t),r=n.parseUShort(),i=n.parseUShort();return r!==1&&console.warn(`Unsupported hvar table version ${r}.${i}`),{version:[r,i],itemVariationStore:n.parsePointer32(function(){return this.parseItemVariationStore()}),advanceWidth:n.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),lsb:n.parsePointer32(function(){return this.parseDeltaSetIndexMap()}),rsb:n.parsePointer32(function(){return this.parseDeltaSetIndexMap()})}}function Zc(){console.warn(`Writing of hvar tables is not yet supported.`)}var Qc={make:Zc,parse:Xc},$c=function(){return{coverage:this.parsePointer(K.coverage),attachPoints:this.parseList(K.pointer(K.uShortList))}},el=function(){var e=this.parseUShort();if(R.argument(e===1||e===2||e===3,`Unsupported CaretValue table version.`),e===1)return{coordinate:this.parseShort()};if(e===2)return{pointindex:this.parseShort()};if(e===3)return{coordinate:this.parseShort()}},tl=function(){return this.parseList(K.pointer(el))},nl=function(){return{coverage:this.parsePointer(K.coverage),ligGlyphs:this.parseList(K.pointer(tl))}},rl=function(){return this.parseUShort(),this.parseList(K.pointer(K.coverage))};function il(e,t){t||=0;let n=new K(e,t),r=n.parseVersion(1);R.argument(r===1||r===1.2||r===1.3,`Unsupported GDEF table version.`);var i={version:r,classDef:n.parsePointer(K.classDef),attachList:n.parsePointer($c),ligCaretList:n.parsePointer(nl),markAttachClassDef:n.parsePointer(K.classDef)};return r>=1.2&&(i.markGlyphSets=n.parsePointer(rl)),i}var al={parse:il},ol=Array(10);ol[1]=function(){let e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(K.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(K.coverage),values:this.parseValueRecordList()};R.assert(!1,`0x`+e.toString(16)+`: GPOS lookup type 1 format must be 1 or 2.`)},ol[2]=function(){let e=this.offset+this.relativeOffset,t=this.parseUShort();R.assert(t===1||t===2,`0x`+e.toString(16)+`: GPOS lookup type 2 format must be 1 or 2.`);let n=this.parsePointer(K.coverage),r=this.parseUShort(),i=this.parseUShort();if(t===1)return{posFormat:t,coverage:n,valueFormat1:r,valueFormat2:i,pairSets:this.parseList(K.pointer(K.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(r),value2:this.parseValueRecord(i)}})))};if(t===2){let e=this.parsePointer(K.classDef),a=this.parsePointer(K.classDef),o=this.parseUShort(),s=this.parseUShort();return{posFormat:t,coverage:n,valueFormat1:r,valueFormat2:i,classDef1:e,classDef2:a,class1Count:o,class2Count:s,classRecords:this.parseList(o,K.list(s,function(){return{value1:this.parseValueRecord(r),value2:this.parseValueRecord(i)}}))}}},ol[3]=function(){return{error:`GPOS Lookup 3 not supported`}},ol[4]=function(){return{error:`GPOS Lookup 4 not supported`}},ol[5]=function(){return{error:`GPOS Lookup 5 not supported`}},ol[6]=function(){return{error:`GPOS Lookup 6 not supported`}},ol[7]=function(){return{error:`GPOS Lookup 7 not supported`}},ol[8]=function(){return{error:`GPOS Lookup 8 not supported`}},ol[9]=function(){return{error:`GPOS Lookup 9 not supported`}};function sl(e,t){t||=0;let n=new K(e,t),r=n.parseVersion(1);return R.argument(r===1||r===1.1,`Unsupported GPOS table version `+r),r===1?{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(ol)}:{version:r,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(ol),variations:n.parseFeatureVariationsList()}}var cl=Array(10);function ll(e){return new G.Table(`GPOS`,[{name:`version`,type:`ULONG`,value:65536},{name:`scripts`,type:`TABLE`,value:new G.ScriptList(e.scripts)},{name:`features`,type:`TABLE`,value:new G.FeatureList(e.features)},{name:`lookups`,type:`TABLE`,value:new G.LookupList(e.lookups,cl)}])}var ul={parse:sl,make:ll};function dl(e){let t={};e.skip(`uShort`);let n=e.parseUShort();R.argument(n===0,`Unsupported kern sub-table version.`),e.skip(`uShort`,2);let r=e.parseUShort();e.skip(`uShort`,3);for(let n=0;n<r;n+=1){let n=e.parseUShort(),r=e.parseUShort(),i=e.parseShort();t[n+`,`+r]=i}return t}function fl(e){let t={};e.skip(`uShort`),e.parseULong()>1&&console.warn(`Only the first kern subtable is supported.`),e.skip(`uLong`);let n=e.parseUShort()&255;if(e.skip(`uShort`),n===0){let n=e.parseUShort();e.skip(`uShort`,3);for(let r=0;r<n;r+=1){let n=e.parseUShort(),r=e.parseUShort(),i=e.parseShort();t[n+`,`+r]=i}}return t}function pl(e,t){let n=new q.Parser(e,t),r=n.parseUShort();if(r===0)return dl(n);if(r===1)return fl(n);throw Error(`Unsupported kern table version (`+r+`).`)}var ml={parse:pl};function hl(e,t,n,r){let i=new q.Parser(e,t),a=r?i.parseUShort:i.parseULong,o=[];for(let e=0;e<n+1;e+=1){let e=a.call(i);r&&(e*=2),o.push(e)}return o}var gl={parse:hl};function _l(e,t){let n=[],r=12;for(let i=0;i<t;i+=1){let t=q.getTag(e,r),i=q.getULong(e,r+4),a=q.getULong(e,r+8),o=q.getULong(e,r+12);n.push({tag:t,checksum:i,offset:a,length:o,compression:!1}),r+=16}return n}function vl(e,t){let n=[],r=44;for(let i=0;i<t;i+=1){let t=q.getTag(e,r),i=q.getULong(e,r+4),a=q.getULong(e,r+8),o=q.getULong(e,r+12),s;s=a<o&&`WOFF`,n.push({tag:t,offset:i,compression:s,compressedLength:a,length:o}),r+=20}return n}function yl(e,t){if(t.compression===`WOFF`){let n=new Uint8Array(e.buffer,t.offset+2,t.compressedLength-2),r=new Uint8Array(t.length);if(j(n,r),r.byteLength!==t.length)throw Error(`Decompression error: `+t.tag+` decompressed length doesn't match recorded length`);return{data:new DataView(r.buffer,0),offset:0}}return{data:e,offset:t.offset}}function bl(e,t={}){let n,r,i=new Yc({empty:!0});e.constructor!==ArrayBuffer&&(e=new Uint8Array(e).buffer);let a=new DataView(e,0),o,s=[],c=q.getTag(a,0);if(c===`\0\0\0`||c===`true`||c===`typ1`)i.outlinesFormat=`truetype`,o=q.getUShort(a,4),s=_l(a,o);else if(c===`OTTO`)i.outlinesFormat=`cff`,o=q.getUShort(a,4),s=_l(a,o);else if(c===`wOFF`){let e=q.getTag(a,4);if(e===`\0\0\0`)i.outlinesFormat=`truetype`;else if(e===`OTTO`)i.outlinesFormat=`cff`;else throw Error(`Unsupported OpenType flavor `+c);o=q.getUShort(a,12),s=vl(a,o)}else if(c===`wOF2`)throw Error(`WOFF2 require an external decompressor library, see examples at: https://github.com/opentypejs/opentype.js/issues/183#issuecomment-1147228025`);else throw Error(`Unsupported OpenType signature `+c);let l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E;for(let e=0;e<o;e+=1){let t=s[e],o;switch(t.tag){case`avar`:h=t;break;case`cmap`:o=yl(a,t),i.tables.cmap=mt.parse(o.data,o.offset),i.encoding=new Ct(i.tables.cmap);break;case`cvt `:o=yl(a,t),E=new q.Parser(o.data,o.offset),i.tables.cvt=E.parseShortList(t.length/2);break;case`fvar`:d=t;break;case`STAT`:f=t;break;case`gvar`:p=t;break;case`cvar`:m=t;break;case`fpgm`:o=yl(a,t),E=new q.Parser(o.data,o.offset),i.tables.fpgm=E.parseByteList(t.length);break;case`head`:o=yl(a,t),i.tables.head=Wn.parse(o.data,o.offset),i.unitsPerEm=i.tables.head.unitsPerEm,n=i.tables.head.indexToLocFormat;break;case`hhea`:o=yl(a,t),i.tables.hhea=qn.parse(o.data,o.offset),i.ascender=i.tables.hhea.ascender,i.descender=i.tables.hhea.descender,i.numberOfHMetrics=i.tables.hhea.numberOfHMetrics;break;case`HVAR`:x=t;break;case`hmtx`:b=t;break;case`ltag`:o=yl(a,t),r=tr.parse(o.data,o.offset);break;case`COLR`:o=yl(a,t),i.tables.colr=wr.parse(o.data,o.offset);break;case`CPAL`:o=yl(a,t),i.tables.cpal=Vt.parse(o.data,o.offset);break;case`maxp`:o=yl(a,t),i.tables.maxp=ir.parse(o.data,o.offset),i.numGlyphs=i.tables.maxp.numGlyphs;break;case`name`:w=t;break;case`OS/2`:o=yl(a,t),i.tables.os2=lr.parse(o.data,o.offset);break;case`post`:o=yl(a,t),i.tables.post=fr.parse(o.data,o.offset),i.glyphNames=new Tt(i.tables.post);break;case`prep`:o=yl(a,t),E=new q.Parser(o.data,o.offset),i.tables.prep=E.parseByteList(t.length);break;case`glyf`:g=t;break;case`loca`:C=t;break;case`CFF `:l=t;break;case`CFF2`:u=t;break;case`kern`:S=t;break;case`GDEF`:_=t;break;case`GPOS`:v=t;break;case`GSUB`:y=t;break;case`meta`:T=t;break;case`gasp`:try{o=yl(a,t),i.tables.gasp=ei.parse(o.data,o.offset)}catch(e){console.warn(`Failed to parse gasp table, skipping.`),console.warn(e)}break;case`SVG `:o=yl(a,t),i.tables.svg=ri.parse(o.data,o.offset)}}let D=yl(a,w);if(i.tables.name=it.parse(D.data,D.offset,r),i.names=i.tables.name,g&&C){let e=n===0,r=yl(a,C),o=gl.parse(r.data,r.offset,i.numGlyphs,e),s=yl(a,g);i.glyphs=Xi.parse(s.data,s.offset,o,i,t)}else if(l){let e=yl(a,l);Vn.parse(e.data,e.offset,i,t)}else if(u){let e=yl(a,u);Vn.parse(e.data,e.offset,i,t)}else throw Error(`Font doesn't contain TrueType, CFF or CFF2 outlines.`);let O=yl(a,b);if(Qn.parse(i,O.data,O.offset,i.numberOfHMetrics,i.numGlyphs,i.glyphs,t),Ot(i,t),S){let e=yl(a,S);i.kerningPairs=ml.parse(e.data,e.offset)}else i.kerningPairs={};if(_){let e=yl(a,_);i.tables.gdef=al.parse(e.data,e.offset)}if(v){let e=yl(a,v);i.tables.gpos=ul.parse(e.data,e.offset),i.position.init()}if(y){let e=yl(a,y);i.tables.gsub=vr.parse(e.data,e.offset)}if(d){let e=yl(a,d);i.tables.fvar=jr.parse(e.data,e.offset,i.names)}if(f){let e=yl(a,f);i.tables.stat=Br.parse(e.data,e.offset,i.tables.fvar)}if(p){d||console.warn(`This font provides a gvar table, but no fvar table, which is required for variable fonts.`),g||console.warn(`This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.`);let e=yl(a,p);i.tables.gvar=Zr.parse(e.data,e.offset,i.tables.fvar,i.glyphs)}if(m){d||console.warn(`This font provides a cvar table, but no fvar table, which is required for variable fonts.`),i.tables.cvt||console.warn(`This font provides a cvar table, but no cvt table which could be made variable.`),g||console.warn(`This font provides a gvar table, but no glyf table. Glyph variation only works with TrueType outlines.`);let e=yl(a,m);i.tables.cvar=Jr.parse(e.data,e.offset,i.tables.fvar,i.tables.cvt||[])}if(h){d||console.warn(`This font provides an avar table, but no fvar table, which is required for variable fonts.`);let e=yl(a,h);i.tables.avar=Gr.parse(e.data,e.offset,i.tables.fvar)}if(x){d||console.warn(`This font provides an HVAR table, but no fvar table, which is required for variable fonts.`),b||console.warn(`This font provides an HVAR table, but no hmtx table to vary.`);let e=yl(a,x);i.tables.hvar=Qc.parse(e.data,e.offset,i.tables.fvar)}if(T){let e=yl(a,T);i.tables.meta=xr.parse(e.data,e.offset),i.metas=i.tables.meta}return i.palettes=new Ai(i),i}function xl(){console.error(`DEPRECATED! migrate to: opentype.parse(buffer, opt) See: https://github.com/opentypejs/opentype.js/issues/675`)}function Sl(){console.error(`DEPRECATED! migrate to: opentype.parse(require("fs").readFileSync(url), opt)`)}return o(s)})();(function(e,n){typeof define==`function`&&define.amd?define(n):typeof t==`object`&&t.exports?t.exports=n():e.opentype=n()})(typeof self<`u`?self:n,()=>({...r,default:r}))}));const Tl=/^[A-Z]{6}\+/;async function El(e,t){if(!e||!e.data||e.data.length===0)return null;let n=xl(e.name??``);if(!n.fullName)return null;let r=e._parsed??null,i=r?.names,a=(i?.fontFamily?.en?.trim()||i?.fontFamily?.und?.trim()||n.family).replace(Tl,``),o=r?.tables?.os2,s=n.weight??o?.usWeightClass??(e.black?900:e.bold?700:400),c=e.italic?`italic`:n.style,l=n.width??Al(o?.usWidthClass),u=await Rl(r,e.data instanceof Uint8Array?e.data:new Uint8Array(e.data),e.toFontChar??null,e.toUnicode?._map??null,t),d=Fl(u);return{postScriptName:`${n.fullName}#${kl(u)}`,family:a,weight:s,style:c,...l?{width:l}:{},data:u,mimeType:d}}function Dl(e){if(e.length<12)return;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=(t,n)=>{let r=0;for(let i=0;i<n;i+=4){let a=0;for(let r=i;r<i+4;r++)a=a*256+(r<n?e[t+r]:0);r=r+a>>>0}return r},r=t.getUint16(4);for(let i=12;i+16<=e.length;i+=16){if(i>=12+r*16)return;if(t.getUint32(i)!==1751474532)continue;let a=t.getUint32(i+8),o=t.getUint32(i+12);if(o<36||a+o>e.length)return;e.fill(0,a+20,a+36),t.setUint32(a+8,0),t.setUint32(i+4,n(a,o)),t.setUint32(a+8,2981146554-n(0,e.length)>>>0);return}}const Ol=/* @__PURE__ */ new WeakMap;function kl(e){let t=Ol.get(e);if(t===void 0){let n=3735928559,r=1103547991;for(let t=0;t<e.length;t++)n=Math.imul(n^e[t],2654435761),r=Math.imul(r^e[t],1597334677);n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),t=(4294967296*(2097151&r)+(n>>>0)).toString(16),Ol.set(e,t)}return t}function Al(e){if(typeof e==`number`)switch(e){case 1:return`ultraCondensed`;case 2:return`extraCondensed`;case 3:return`condensed`;case 4:return`semiCondensed`;case 5:return`normal`;case 6:return`semiExpanded`;case 7:return`expanded`;case 8:return`extraExpanded`;case 9:return`ultraExpanded`;default:return}}function jl(e,t){if(!Ml(e)||!t||t.length===0)return!1;for(let e of t){let t=e.unicode;if(!t||Il(t))return!1}return!0}function Ml(e){return!(!e||e.isType3Font||!e.data||e.data.length===0||!e._parsed)}function Nl(e){let t=Number(e)||400;return t<=150?`thin`:t<=250?`extraLight`:t<=350?`light`:t<=450?`normal`:t<=550?`medium`:t<=650?`semiBold`:t<=750?`bold`:t<=850?`extraBold`:`heavy`}function Pl(e){let t=xl(e?.name??``),n=e?._parsed?.tables?.os2,r=t.weight??n?.usWeightClass??(e?.black?900:e?.bold?700:400);return{style:e?.italic?`italic`:t.style,weight:Nl(r)}}function Fl(e){return e.length>=4&&e[0]===79&&e[1]===84&&e[2]===84&&e[3]===79?`font/otf`:`font/ttf`}function Il(e){for(let t of e){let e=t.codePointAt(0);if(e!=null&&(e>=57344&&e<=63743||e>=983040&&e<=1048573||e>=1048576&&e<=1114109))return!0}return!1}const Ll=[32,160];async function Rl(e,t,n,r,i){if(!e)return t;let a=Hl.get(e);if(a)return a;try{let{default:a}=await Promise.resolve().then(()=>/* @__PURE__ */ u(wl(),1)),o=zl(e,n);for(let{glyphIndex:t,unicode:n}of o)Vl(e,t,n);let s=Bl(e,n,r);for(let{unicode:t,from:n,to:r}of s.moves){let i=e.glyphs.get(n);i?.unicodes&&(i.unicodes=i.unicodes.filter(e=>e!==t)),Vl(e,r,t)}let c=e.substitution;s.ligatures.length>0&&c.getFeatureTable(`DFLT`,`dflt`,`liga`,!0);for(let{feature:e,sub:t,by:n}of s.ligatures)c.addLigature(e,{sub:t,by:n});let l=[],d=e.unitsPerEm||1e3,f=Math.round(d*.25),p=e.glyphs;for(let t of Ll){if(Wl(e,t))continue;let n=p.length,r=new a.Glyph({name:t===32?`space`:`uni${t.toString(16).toUpperCase()}`,unicode:t,advanceWidth:f,path:new a.Path});r.index=n,p.glyphs[n]=r,p.length=n+1,l.push(t)}if(o.length===0&&l.length===0&&s.moves.length===0&&s.ligatures.length===0)return Hl.set(e,t),t;for(let t=0;t<p.length;t+=1){let n=e.glyphs.get(t);n&&(typeof n.name!=`string`||n.name===``)&&(n.name=t===0?`.notdef`:`gid${t}`)}e.numGlyphs=p.length;let m=e.toArrayBuffer(),h=a.parse(m).toArrayBuffer(),g=new Uint8Array(h);if(Dl(g),Hl.set(e,g),Ul()){let t=e.names?.postScriptName?.en??`<unknown>`,n=l.map(e=>`U+`+e.toString(16).toUpperCase()).join(`,`)||`none`;i?.emit?.(`FONT_CMAP_AUGMENTED`,{fontName:t,cmapPatches:o.length,injectedGlyphs:n})}return g}catch(n){let r=e.names?.postScriptName?.en??`<unknown>`,a=n&&typeof n==`object`&&`message`in n?String(n.message):String(n);return i?.emit?.(`FONT_CMAP_AUGMENT_FAILED`,{fontName:r,error:a}),Hl.set(e,t),t}}function zl(e,t){let n=[];if(!t)return n;let r=e.tables?.cmap?.glyphIndexMap;if(!r)return n;for(let[e,i]of Object.entries(t)){let t=Number(e);if(!Number.isFinite(t)||t===i||r[t])continue;let a=r[i];a&&n.push({unicode:t,glyphIndex:a})}return n}function Bl(e,t,n){let r={moves:[],ligatures:[]},i=e.tables?.cmap?.glyphIndexMap;if(!t||!n||!i)return r;let a=[],o=/* @__PURE__ */ new Map,s=[];for(let[e,r]of Object.entries(n)){if(typeof r!=`string`)continue;let n=i[t[e]];if(!n)continue;let c=Array.from(r,e=>e.codePointAt(0));c.length>1?s.push({letters:c,glyph:n}):c.length===1&&(a.push({letter:c[0],glyph:n}),o.set(n,(o.get(n)??/* @__PURE__ */ new Set).add(c[0])))}if(s.length===0)return r;let c=new Map(a.filter(({glyph:e})=>o.get(e).size===1).map(({letter:e,glyph:t})=>[e,t])),l=/* @__PURE__ */ new Map,u=e=>l.get(e)??i[e],d=new Set(s.map(({glyph:e})=>e));for(let[e,t]of c){let n=u(e);n!==t&&d.has(n)&&(r.moves.push({unicode:e,from:n,to:t}),l.set(e,t))}for(let{letters:e,glyph:t}of s){let n=e.map(u);if(!n.every(e=>e>0))continue;let i=e.every(e=>c.has(e))?`liga`:`rlig`;r.ligatures.push({feature:i,sub:n,by:t})}return r.ligatures.sort((e,t)=>Number(e.feature===`liga`)-Number(t.feature===`liga`)||t.sub.length-e.sub.length),r}function Vl(e,t,n){let r=e.glyphs.get(t);r&&(r.unicodes||=r.unicode==null?[]:[r.unicode],r.unicodes.includes(n)||r.unicodes.push(n))}const Hl=/* @__PURE__ */ new WeakMap;function Ul(){return!!(typeof process<`u`&&process.env?.PDF2CESDK_DEBUG_FONTS||typeof globalThis<`u`&&globalThis.PDF2CESDK_DEBUG_FONTS)}function Wl(e,t){try{let n=e.charToGlyphIndex(String.fromCodePoint(t));if(!n)return!1;let r=e.glyphs.get(n);return!!r&&(r.advanceWidth??0)>0}catch{return!1}}function Gl(e,t,n,r){if(!e||e.length===0)return[];let i=e.map(e=>ql(e,t,n,r)),a=[],o=null;for(let e of i)e&&(o&&Kl(o,e)?o.items.push(e):(o&&a.push(Yl(o,t)),o={items:[e]}));return o&&a.push(Yl(o,t)),a}function Kl(e,t){let n=e.items[e.items.length-1];return!(t.fontObjId!==n.fontObjId||Math.abs(t.fontSizePt-n.fontSizePt)>1||Math.abs(t.baselineYPt-n.baselineYPt)>2||t.originXPt-(n.originXPt+n.advancePt)>.5*t.fontSizePt)}function ql(e,t,n,r){let i=t[e.fontObjId];if(!i)return null;let a=Zl(n,e.textMatrix),o=Zl(a,[e.fontSize,0,0,e.fontSize,0,0]),s=Math.hypot(o[2],o[3]),c=a[4],l=r-a[5],u=Jl(e,i,s);return{glyph:e,fontObjId:e.fontObjId,fontSizePt:s,originXPt:c,baselineYPt:l,advancePt:u}}function Jl(e,t,n){let r=t._parsed;if(r&&e.unicode)try{let t=r.charToGlyph?.(e.unicode);if(t&&t.advanceWidth&&r.unitsPerEm)return t.advanceWidth/r.unitsPerEm*n}catch{}return .5*n}function Yl(e,t){let n=e.items,r=n[0],i=n[n.length-1],a=t[r.fontObjId]?._parsed,o=Xl(n.map(e=>e.fontSizePt)),s=a?.unitsPerEm??1e3,c=a?.ascender?a.ascender/s*o:.8*o,l=a?.descender?Math.abs(a.descender/s)*o:.2*o,u=r.originXPt,d=Xl(n.map(e=>e.baselineYPt)),f=i.originXPt+i.advancePt-u+.05*o*n.length,p=``,m=null;for(let e of n){let t=e.glyph.unicode??``;if(m){let n=m.originXPt+m.advancePt;e.originXPt-n>.2*e.fontSizePt&&!t.startsWith(` `)&&!p.endsWith(` `)&&(p+=` `)}p+=t,m=e}return{glyphs:n.map(e=>e.glyph),fontObjId:r.fontObjId,fontSizePt:o,originXPt:u,baselineYPt:d,widthPt:f,ascenderPt:c,descenderPt:l,text:p}}function Xl(e){return e.length===0?0:e.reduce((e,t)=>e+t,0)/e.length}function Zl(e,t){let[n,r,i,a,o,s]=e,[c,l,u,d,f,p]=t;return[n*c+i*l,r*c+a*l,n*u+i*d,r*u+a*d,n*f+i*p+o,r*f+a*p+s]}function Ql(e){return Number.isFinite(e)?e.toFixed(1):String(e)}function $l(e){return e?`(${typeof e.x==`number`?Ql(e.x):`?`}, ${typeof e.y==`number`?Ql(e.y):`?`}) ${typeof e.width==`number`?Ql(e.width):`?`}×${typeof e.height==`number`?Ql(e.height):`?`} pt`:`(unknown position)`}function eu(e){if(!e||e.length<6)return`[invalid]`;let[t,n,r,i,a,o]=e;return`[a=${Ql(t)}, b=${Ql(n)}, c=${Ql(r)}, d=${Ql(i)}, e=${Ql(a)}, f=${Ql(o)}]`}function tu(e){if(e==null)return`none`;if(typeof e!=`object`)return String(e);let t=e;if(`type`in t)switch(t.type){case`rgb`:return`rgb(${nu(t.r)}, ${nu(t.g)}, ${nu(t.b)})`;case`cmyk`:return`cmyk(${nu(t.c)}, ${nu(t.m)}, ${nu(t.y)}, ${nu(t.k)})`;case`spot`:{let e=typeof t.name==`string`?`"${t.name}"`:`(unnamed)`,n=typeof t.tint==`number`?`, tint=${nu(t.tint)}`:``,r=t.fallback_rgb;return`spot ${e}${n}${Array.isArray(r)?`, fallback=rgb(${nu(r[0])}, ${nu(r[1])}, ${nu(r[2])})`:`, no fallback`}`}default:return`type="${String(t.type)}"`}if(`space`in t&&Array.isArray(t.values)){let e=t.values.map(e=>nu(e)).join(`, `);return`${String(t.space)}(${e})`}return`r`in t&&`g`in t&&`b`in t?`rgb(${nu(t.r)}, ${nu(t.g)}, ${nu(t.b)})`:`(opaque)`}function nu(e){return Number.isFinite(e)?e.toFixed(2):String(e)}function ru(){return[]}function iu(e,t,n,r){return[...e,{path:t,fillRule:n,ctm:r.slice()}]}function au(e){return e.slice()}function ou(e){return e.pop()??ru()}function su(e){return e.length===0}const cu=Object.freeze({moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19});Object.freeze([1,0,0,1,0,0]);function lu(e,t,n){let r=e.ops??[],i=e.coords??[],a=[],o=[],s=0,c=null,[l,u,d,f,p,m]=t,h=(e,t)=>[l*e+d*t+p,n-(u*e+f*t+m)];for(let e=0;e<r.length;e++)switch(r[e]){case cu.rectangle:{let e=i[s++],t=i[s++],n=i[s++],r=i[s++],c=h(e,t),l=h(e+n,t),u=h(e+n,t+r),d=h(e,t+r);a.push({cmd:`M`,pts:[c]}),a.push({cmd:`L`,pts:[l]}),a.push({cmd:`L`,pts:[u]}),a.push({cmd:`L`,pts:[d]}),a.push({cmd:`Z`}),o.push(c,l,u,d);break}case cu.moveTo:{let e=h(i[s++],i[s++]);a.push({cmd:`M`,pts:[e]}),o.push(e),c=e;break}case cu.lineTo:{let e=h(i[s++],i[s++]);a.push({cmd:`L`,pts:[e]}),o.push(e),c=e;break}case cu.curveTo:{let e=h(i[s++],i[s++]),t=h(i[s++],i[s++]),n=h(i[s++],i[s++]);a.push({cmd:`C`,pts:[e,t,n]}),o.push(e,t,n),c=n;break}case cu.curveTo2:{let e=h(i[s++],i[s++]),t=h(i[s++],i[s++]),n=c??e;a.push({cmd:`C`,pts:[n,e,t]}),o.push(e,t),c=t;break}case cu.curveTo3:{let e=h(i[s++],i[s++]),t=h(i[s++],i[s++]);a.push({cmd:`C`,pts:[e,t,t]}),o.push(e,t),c=t;break}case cu.closePath:a.push({cmd:`Z`})}return{cmds:a,devPoints:o}}function uu(e){if(e.length===0)return{x:0,y:0,width:0,height:0};let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let[a,o]of e)a<t&&(t=a),o<n&&(n=o),a>r&&(r=a),o>i&&(i=o);return{x:t,y:n,width:r-t,height:i-n}}function du(e,t,n){let r=e=>`${Math.round(e*100)/100}`,i=[];for(let a of e){if(a.cmd===`Z`){i.push(`Z`);continue}let e=a.pts.map(([e,i])=>`${r(e-t)} ${r(i-n)}`).join(` `);i.push(`${a.cmd} ${e}`)}return i.join(` `)}function fu(e,t,n){let{cmds:r,devPoints:i}=lu(e,t,n);if(i.length===0)return null;let a=uu(i);return{...a,d:du(r,a.x,a.y),cmds:r,devPoints:i}}function pu(e,t){let n=[];for(let r of e){let e=mu(r,t);e&&n.push(e)}return n}function mu(e,t){let n=fu(e.path,e.ctm,t.heightPt);return!n||n.width<=0&&n.height<=0?null:{d:n.d,x:n.x,y:n.y,width:n.width,height:n.height,fillRule:e.fillRule}}function hu(e){if(!Array.isArray(e)&&!ArrayBuffer.isView(e))return null;let t=e;return Number.isSafeInteger(t.length)&&t.length>=0?t:null}function gu({shadingIR:e,ctm:t,pageBox:n}){if(!Array.isArray(e)||e[0]!==`Mesh`||![4,5,6,7].includes(e[1])||t.length!==6||t.some(e=>!Number.isFinite(e))||!Number.isFinite(n.widthPt)||!Number.isFinite(n.heightPt)||n.widthPt<=0||n.heightPt<=0)return{status:`invalid`};let r=hu(e[2]),i=hu(e[3]),a=e[4];if(!r||!i||!Array.isArray(a)||r.length%2!=0||i.length%3!=0)return{status:`invalid`};let o=r.length+i.length+a.length;if(o>131072)return{status:`limit`};let s=0,c=[];for(let e of a){if(typeof e!=`object`||!e)return{status:`invalid`};let t=e,n=hu(t.coords),r=hu(t.colors);if(!n||!r||n.length!==r.length)return{status:`invalid`};if(o+=n.length+r.length,o>131072)return{status:`limit`};let i=0;if(t.type===`triangles`){if(n.length%3!=0)return{status:`invalid`};s+=n.length/3}else if(t.type===`lattice`){let e=t.verticesPerRow;if(typeof e!=`number`||!Number.isSafeInteger(e)||e<2||n.length%e!==0)return{status:`invalid`};i=e,s+=Math.max(0,n.length/e-1)*(e-1)*2}else return{status:`invalid`};if(s>8192)return{status:`limit`};c.push({type:t.type,coords:n,colors:r,verticesPerRow:i})}let l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Map,d=[],f=[0,0,0],p=0,m=1/0,h=1/0,g=-1/0,_=-1/0,[v,y,b,x,S,C]=t;function w(e,t){let a=e.coords[t],o=e.colors[t];if(!Number.isSafeInteger(a)||a<0||a%2!=0||a+1>=r.length||!Number.isSafeInteger(o)||o<0||o%3!=0||o+2>=i.length)return null;for(let e=0;e<3;e++){let t=i[o+e];if(!Number.isFinite(t)||t<0||t>255)return null}let s=l.get(a);if(!s){let e=r[a],t=r[a+1];if(!Number.isFinite(e)||!Number.isFinite(t))return null;let i=v*e+b*t+S,o=n.heightPt-(y*e+x*t+C);if(!Number.isFinite(i)||!Number.isFinite(o))return null;s=[i,o],l.set(a,s)}return{point:s,coord:a,color:o}}function T(e,t,n,r){let a=w(e,t),o=w(e,n),s=w(e,r);if(!a||!o||!s)return!1;let[c,l,v]=[a.point,o.point,s.point],y=(l[0]-c[0])*(v[1]-c[1])-(l[1]-c[1])*(v[0]-c[0]);if(!Number.isFinite(y))return!1;if(y===0)return!0;d.push(y>0?[c,l,v]:[c,v,l]);for(let e of[a,o,s]){m=Math.min(m,e.point[0]),h=Math.min(h,e.point[1]),g=Math.max(g,e.point[0]),_=Math.max(_,e.point[1]);let t=u.get(e.coord);if(t||u.set(e.coord,t=/* @__PURE__ */ new Set),!t.has(e.color)){t.add(e.color);for(let t=0;t<3;t++)f[t]+=i[e.color+t];p++}}return!0}for(let e of c)if(e.type===`triangles`){for(let t=0;t<e.coords.length;t+=3)if(!T(e,t,t+1,t+2))return{status:`invalid`}}else{let t=e.verticesPerRow,n=e.coords.length/t;for(let r=0;r<n-1;r++)for(let n=0;n<t-1;n++){let i=r*t+n;if(!T(e,i,i+1,i+t)||!T(e,i+t+1,i+1,i+t))return{status:`invalid`}}}if(d.length===0)return{status:`empty`};let E=g-m,D=_-h;if(!Number.isFinite(E)||!Number.isFinite(D))return{status:`invalid`};let O=e=>`${e[0]-m} ${e[1]-h}`;return{status:`ok`,triangleCount:d.length,block:{kind:`vector-path`,x:m,y:h,width:E,height:D,d:d.map(([e,t,n])=>`M ${O(e)} L ${O(t)} L ${O(n)} Z`).join(` `),fill:{space:`rgb`,values:f.map(e=>e/(255*p))},stroke:null,strokeWidth:0,fillRule:`nonzero`,opacity:1}}}function _u({shadingIR:e,ctm:t,clipEntry:n,remainingClips:r,pageBox:i,opacity:a,blendMode:o,logger:s,pageIndex:c,isPattern:l=!1}){let u=Array.isArray(e)?e[0]:null,d=c==null?``:`Page ${c}: `;if(u===`Dummy`||u==null)return s?.emit?.(`SHADING_UNRESOLVED`,{prefix:d,page:c}),null;if(u===`Mesh`){let u=gu({shadingIR:e,ctm:t,pageBox:i}),f=e=>(s?.emit?.(`SHADING_MESH_GEOMETRY_DROPPED`,{prefix:d,page:c,reason:e}),null);if(u.status!==`ok`)return f(u.status===`limit`?`its decoded geometry exceeds the import safety limit`:u.status===`empty`?`it contains no non-degenerate triangles`:`its decoded vertex or index data is invalid`);let p=u.block;p.opacity=a??1,p.blendMode=o??void 0;let m=[...r,...n?[n]:[]],h=e,g=h[6];if(g!=null){if(!Array.isArray(g)||g.length!==4||!g.every(e=>typeof e==`number`&&Number.isFinite(e))||g[2]<=g[0]||g[3]<=g[1])return f(`its shading BBox is invalid or empty`);m.push({path:{ops:[19],coords:[g[0],g[1],g[2]-g[0],g[3]-g[1]]},ctm:t,fillRule:`nonzero`})}let _=pu(m,i);return _.length!==m.length||_.some(e=>e.width<=0||e.height<=0)?null:(_.length&&(p.clips=_),s?.emit?.(`SHADING_MESH_FLATTENED`,{prefix:d,page:c,at:$l(p),triangles:u.triangleCount,fill:tu(p.fill),background:l&&h[7]!=null?` The pattern background was omitted.`:``}),p)}if(u!==`RadialAxial`)return s?.emit?.(`SHADING_UNKNOWN_IR_TAG`,{prefix:d,tag:String(u),page:c}),null;let f=xu(e[3]);if(f.length<2)return s?.emit?.(`SHADING_INSUFFICIENT_STOPS`,{prefix:d,page:c}),null;n??s?.emit?.(`SHADING_NO_CLIP_FALLBACK_BBOX`,{prefix:d,page:c});let p=n?fu(n.path,n.ctm,i.heightPt):null;if(!p||p.width<=0&&p.height<=0)return s?.emit?.(`SHADING_CLIP_DEGENERATE`,{prefix:d,page:c}),null;let m={kind:`vector-path`,x:p.x,y:p.y,width:p.width,height:p.height,d:p.d,fill:null,stroke:null,strokeWidth:0,fillRule:n?.fillRule??`nonzero`,opacity:1,blendMode:o??void 0},h=vu(e,f,t,i,{logger:s,prefix:d,pageIndex:c});if(!h)return null;if(m.fill=h,a!=null&&a<1&&(m.opacity=a),r&&r.length>0){let e=pu(r,i);e.length>0&&(m.clips=e)}return m}function vu(e,t,n,r,i){let[,a,,,o,s,c,l]=e;return a===`axial`?{kind:`linearGradient`,start:wu(o,n,r.heightPt),end:wu(s,n,r.heightPt),stops:t}:a===`radial`?(typeof c==`number`&&c>.001&&i.logger?.emit?.(`SHADING_RADIAL_FOCAL_DROPPED`,{prefix:i.prefix,page:i.pageIndex,innerRadius:c}),{kind:`radialGradient`,center:wu(s,n,r.heightPt),radius:Math.max(.001,Math.abs((l??0)*Tu(n))),stops:t}):(i.logger?.emit?.(`SHADING_UNKNOWN_RADIAL_SUBTYPE`,{prefix:i.prefix,kind:String(a),page:i.pageIndex}),null)}function yu({shadingIR:e,ctm:t,pageBox:n,logger:r,pageIndex:i}){if(!Array.isArray(e)||e[0]!==`RadialAxial`)return null;let a=xu(e[3]);if(a.length<2)return null;let o=i==null?``:`Page ${i}: `,s=vu(e,a,t,n,{logger:r,prefix:o,pageIndex:i});return s?(r?.emit?.(`SHADING_COLORSPACE_CONVERTED`,{prefix:o,page:i}),{gradient:s,solid:bu(a)}):null}function bu(e){let t=[...e].sort((e,t)=>e.offset-t.offset),n=[0,0,0],r=(e,t,r)=>{for(let i=0;i<3;i++)n[i]+=(e[i]+t[i])/2*r},i=t[0],a=t[t.length-1];r(i.color.values,i.color.values,i.offset),r(a.color.values,a.color.values,1-a.offset);for(let e=1;e<t.length;e++)r(t[e-1].color.values,t[e].color.values,t[e].offset-t[e-1].offset);return{space:`rgb`,values:n}}function xu(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!Array.isArray(n)||n.length<2)continue;let e=Cu(n[0]),r=Su(n[1]);if(!r)continue;let i={space:`rgb`,values:r};t.push({offset:e,color:i})}return t}function Su(e){if(typeof e!=`string`)return null;if(e===`transparent`)return[1,1,1];let t=/^#([0-9a-fA-F]{6})$/.exec(e.trim());if(!t)return null;let n=parseInt(t[1],16);return[(n>>16&255)/255,(n>>8&255)/255,(n&255)/255]}function Cu(e){return typeof e!=`number`||!Number.isFinite(e)||e<0?0:e>1?1:e}function wu(e,t,n){let r=Array.isArray(e)?e[0]:0,i=Array.isArray(e)?e[1]:0,[a,o,s,c,l,u]=t;return{x:a*r+s*i+l,y:n-(o*r+c*i+u)}}function Tu([e,t,n,r]){return Math.sqrt(Math.abs(e*r-t*n))}const Eu=/* @__PURE__ */ new Set([`DeviceGray`,`DeviceRGB`,`DeviceCMYK`,`ICCBased`]);function Du(e){if(e[0]!==255||e[1]!==216)return;let t=2;for(;t<e.length;){if(e[t++]!==255)return;for(;e[t]===255;)t++;let n=e[t++];if(n===void 0||n===218||n===217)return;if(n===1||n>=208&&n<=216)continue;if(t+2>e.length)return;let r=e[t]<<8|e[t+1];if(r<2||t+r>e.length)return;let i=t+2;if(n===238&&r>=14&&String.fromCharCode(...e.subarray(i,i+5))===`Adobe`)return e[i+11]===0?0:1;t+=r}}const Ou=e=>e==null||e.length===2&&e.every(Number.isFinite);function ku(e,t){let{mask:n,softMask:r,matte:i}=e;if(!n&&!r)return i?null:{};if(n&&r)return null;let a=e.width??0,o=e.height??0;if(a*o>67108864)return null;let s=({width:e,height:t})=>(e??1/0)<=a&&(t??1/0)<=o;if(r)return!r.bytes||!Ou(r.decode)||!s(r)||r.matte&&(r.matte.length!==t||r.width!==a||r.height!==o)?null:{mask:{kind:`Soft`,jpegBytes:r.bytes,width:r.width,height:r.height,...r.decode?{decode:r.decode}:{},...r.matte?{matte:r.matte}:{}}};if(i||!n)return null;if(n.ranges){let e=n.ranges;return e.length===2*t&&e.every((t,n)=>Number.isInteger(t)&&t>=0&&t<=255&&(n%2==0||e[n-1]<=t))?{colorKeyMask:e}:null}let c=n.decode;return!n.imageMask||!n.bytes||!s(n)||c!=null&&String(c)!==`0,1`&&String(c)!==`1,0`?null:{mask:{kind:`Stencil`,bitPackedBytes:n.bytes,width:n.width,height:n.height,...c?{decode:c}:{}}}}function Au(e,t){if(e?.version!==1||!e.eligible||!e.bytes?.length)return null;let n=e.effectiveColorSpace;if(!n||!Eu.has(n.kind))return null;let r=ku(e,n.components??0);if(!r)return null;let i=n.kind;if(i===`ICCBased`&&!t?.length)return null;let a=e.sourceColorSpace?.kind,o=a!=null&&Eu.has(a)&&(a!==`ICCBased`||i===`ICCBased`)?a:void 0,s=Du(e.bytes)??e.decodeParms?.[0]?.ColorTransform,c=e.intent?L.indexOf(ie(e.intent)):-1;return{bytes:e.bytes,definition:{colorSpace:i,...o?{declaredColorSpace:o}:{},...i===`ICCBased`?{iccProfile:t}:{},...e.decode?{decode:e.decode}:{},...s==null?{}:{colorTransform:s},...c>=0?{renderingIntent:c}:{},...r}}}const ju=/* @__PURE__ */ new Set([`ICC_PROFILE_TOO_LARGE`,`ICC_DOCUMENT_LIMIT`,`INVALID_ICC_PROFILE`,`INVALID_ICC_COMPONENT_COUNT`]),Mu=/* @__PURE__ */ new WeakSet;function Nu(e){if(e?.reason&&ju.has(e.reason)&&ku(e,e.effectiveColorSpace?.components??0)!==null&&!Mu.has(e))return Mu.add(e),e.reason}async function Pu(e,t){let n=t?.effectiveColorSpace?.profileId;if(!n)return;let{data:r}=await Xc(e,n);return r instanceof Uint8Array?r:void 0}const Fu=e=>e?.rawImage,Iu=e=>{let t=Fu(e)?.intent;return t?ie(t):void 0},Lu=/* @__PURE__ */ new Set([1,9,31,32,37,2,7,50,51,53,55,56,57,58,59,60,61]);async function Ru({page:e,pattern:t,logger:n,pageIndex:r}){let i=r==null?``:`Page ${r}: `,{fnArray:a,argsArray:o}=t.operatorList,s=0,c=0,l=0,u=[],d=null,f=[1,0,0,1,0,0],p=[];for(let e=0;e<a.length;e++){let t=a[e],n=o[e]??[];switch(t){case 10:p.push(f.slice());break;case 11:f=p.pop()??[1,0,0,1,0,0];break;case 12:f=zu(f,n);break;case 85:{s++;let e=n[0],t=Number(n[1]??0)||0,r=Number(n[2]??0)||0;typeof e==`string`&&u.push({objId:e,ctm:f.slice(),w:t,h:r});break}case 91:{let e=n,t=e[2];if(t&&t.length>=4)d={w:t[2]-t[0],h:t[3]-t[1]};else{let t=e[1];d=Vu(t)}break}case 22:case 23:case 24:case 25:d==null?c++:(l+=Bu(d,f),d=null);break;case 28:case 29:case 30:d=null;break;default:Lu.has(t)||c++}}if(u.length===0)return n?.emit?.(`TILING_PATTERN_UNSUPPORTED`,{prefix:i,patternId:t.patternId,imageCount:s,otherOpCount:c,page:r,reason:`no-images`}),null;u.sort((e,t)=>t.w*t.h-e.w*e.h);let m=u[0],h=m.w*m.h,g=u.slice(1).reduce((e,t)=>e+t.w*t.h,0),_=Math.abs(m.ctm[0]*m.ctm[3]-m.ctm[1]*m.ctm[2]);if(!(c===0&&h>0&&h>=10*g&&_>=l))return n?.emit?.(`TILING_PATTERN_UNSUPPORTED`,{prefix:i,patternId:t.patternId,imageCount:s,otherOpCount:c,page:r,reason:`not-image-dominant`,primarySrcArea:h,otherSrcArea:g,primaryPaintedArea:_,rectFillArea:l}),null;let v=(await(m.objId.startsWith(`g_`)?Xc(e,m.objId):Yc(e,m.objId))).data;if(!v)return n?.emit?.(`TILING_PATTERN_IMAGE_DECODE_FAILED`,{prefix:i,patternId:t.patternId,imageObjId:m.objId,page:r}),null;let y=await Qc(v,n,{objId:m.objId,pageIndex:r??void 0});return y?{bytes:y,width:v.width??0,height:v.height??0,renderingIntent:Iu(v)}:(n?.emit?.(`TILING_PATTERN_IMAGE_DECODE_FAILED`,{prefix:i,patternId:t.patternId,imageObjId:m.objId,page:r}),null)}function zu(e,t){let[n,r,i,a,o,s]=e,[c,l,u,d,f,p]=t;return[n*c+i*l,r*c+a*l,n*u+i*d,r*u+a*d,n*f+i*p+o,r*f+a*p+s]}function Bu(e,t){return Math.abs(t[0]*t[3]-t[1]*t[2])*e.w*e.h}function Vu(e){if(!e||e.length<2)return null;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a=0;a+1<e.length;a+=2){let o=e[a],s=e[a+1];o<t&&(t=o),s<n&&(n=s),o>r&&(r=o),s>i&&(i=s)}return!Number.isFinite(t)||!Number.isFinite(n)?null:{w:r-t,h:i-n}}const Hu={setRenderingIntent:7,setGState:9};function Uu(e){let t=typeof e==`object`&&e?e.name:e;return typeof t==`string`&&t!==``?ie(t):null}function Wu(e,t,n){n.has(e)||(n.add(e),e.fnArray.forEach((r,i)=>{let a=e.argsArray[i];if(r===Hu.setRenderingIntent){let e=Uu(a?.[0]);e!==null&&t.add(e)}else if(r===Hu.setGState)for(let[e,n]of a?.[0]??[]){let r=e===`RI`?Uu(n):null;r!==null&&t.add(r)}else a?.[0]===`TilingPattern`&&Wu(a[2],t,n)}))}function Gu(e){let t=/* @__PURE__ */ new Set;return Wu(e,t,/* @__PURE__ */ new Set),[...t].sort()}const Ku=/* @__PURE__ */ new Set([2,3,4,5,6,10,11,12,22,23,28,29,30,57,59,61,91]);function qu(e,t){let n=t?.[0];return e===9&&Array.isArray(n)&&n.every(e=>e?.[0]===`OP`||e?.[0]===`op`)}function Ju(e,t,n,r){let{fnArray:i,argsArray:a}=e.operatorList;if(e.paintType!==1||i.length>512||i.length!==a.length||i.some((e,t)=>!Ku.has(e)&&!qu(e,a[t])))return null;let o=0,s=0,c=0;for(let e=0;e<i.length;e++){if(i[e]===10&&++o>32||i[e]===11&&--o<0)return null;if(i[e]===91){let t=a[e]?.[1],n=a[e]?.[0];if(t==null||n==null||(s+=t.length,c+=n.length,s>16384||c>4096||Array.from(t).some(e=>!Number.isFinite(e))))return null}if(i[e]===12&&(a[e].length!==6||a[e].some(e=>typeof e!=`number`||!Number.isFinite(e))))return null}if(o!==0)return null;let l=e.matrix,u=e.bbox,d=Math.abs(e.xStep),f=Math.abs(e.yStep);if(l.length!==6||u.length!==4||[...l,...u,d,f,t.x,t.y,t.width,t.height].some(e=>!Number.isFinite(e))||!(d>0&&f>0&&u[2]>u[0]&&u[3]>u[1])||u[2]-u[0]>d+1e-8||u[3]-u[1]>f+1e-8)return null;let[p,m,h,g,_,v]=l,y=p*g-m*h;if(Math.abs(y)<1e-8)return null;let b=[],x=[];for(let e of[t.x,t.x+t.width])for(let i of[t.y,t.y+t.height]){let t=e+r.x-_,a=n-i+r.y-v;b.push((g*t-h*a)/y),x.push((-m*t+p*a)/y)}let S=Math.floor((Math.min(...b)-u[2])/d+1e-9)+1,C=Math.ceil((Math.max(...b)-u[0])/d-1e-9)-1,w=Math.floor((Math.min(...x)-u[3])/f+1e-9)+1,T=Math.ceil((Math.max(...x)-u[1])/f-1e-9)-1,E=Math.max(0,C-S+1)*Math.max(0,T-w+1),D=E*(i.length+10+s+c);if(![S,C,w,T,E].every(Number.isSafeInteger)||E>1024||D>32768)return null;let O=[];for(let e=w;e<=T;e++)for(let t=S;t<=C;t++)O.push({fnArray:[12,12,91,29,28,...i],argsArray:[l,[1,0,0,1,t*d,e*f],[[19],[u[0],u[1],u[2]-u[0],u[3]-u[1]]],[],[],...a]});return{tiles:O,work:D}}const Yu={0:`Butt`,1:`Round`,2:`Square`},Q={setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,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,beginText:31,endText:32,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,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColorN:53,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,paintImageXObject:85,paintInlineImageXObject:86,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,shadingFill:62},Xu=[1,0,0,1,0,0],Zu=/^\s/;async function Qu(e,t,n={}){let r=n.textMode??`outline`,i=n.docFonts??/* @__PURE__ */ new Map,a=n.logger,o=n.pageIndex,{opList:s}=await Jc(e),c=await $u(e,s,{logger:a,pageIndex:o}),l=e.colorSpaceResources??{};Object.values(l).some(e=>e.kind===`deviceN`)&&a?.emit?.(`COLOR_DEVICEN_INKS_NOT_PRESERVED`,{prefix:o==null?``:`Page ${o}: `});let{out:u,colorSnapshots:d,pathSpotColors:f}=await nd(s,t,e,c,{textMode:r,docFonts:i,logger:a,pageIndex:o,colorSpaceResources:l});return{out:u,colorSnapshots:d,renderingIntents:Gu(s),pathSpotColors:f,finalize:()=>Ld(rd(u),t,n.preserveWhitePageBackground)}}async function $u(e,t,n={}){let r=/* @__PURE__ */ new Set,i=t.fnArray,a=t.argsArray;for(let e=0;e<i.length;e++)i[e]===Q.setFont&&r.add(a[e][0]);let o={};for(let t of r){let r=(await Xc(e,t)).data;if(r&&!r.isType3Font&&r.data){let e=r.name||r.loadedName||r.fallbackName||`(font object ${t})`;r._parsed=await ed(r.data,e,n)}o[t]=r}return o}async function ed(e,t,n={}){try{let{default:t}=await Promise.resolve().then(()=>/* @__PURE__ */ u(wl(),1)),n=e instanceof Uint8Array?e:new Uint8Array(e),r=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength);return t.parse(r)}catch(e){let r=n.pageIndex==null?``:`Page ${n.pageIndex}: `,i=e&&typeof e==`object`&&`message`in e?String(e.message):null,a=i?` (${i})`:``;return n.logger?.emit?.(`FONT_OPENTYPE_PARSE_FAILED`,{prefix:r,fontName:t,reason:a,page:n.pageIndex,error:i}),null}}async function td(e,t){if(t.kind===`image`){let n=typeof t.objId==`string`?t.objId:null,r=await(n?.startsWith(`g_`)?Xc(e,n):Yc(e,n));return r.data==null?null:{kind:`image`,obj:r.data,ctm:t.ctm}}let n=typeof t.patternId==`string`?t.patternId:null;if(n==null)return null;let r=await Yc(e,n);return r.data==null?null:{kind:`shading`,ir:r.data,ctm:t.ctm}}async function nd(e,t,n,r,i){let a=e.fnArray,o=e.argsArray,s=[],c=i?.colorSpaceResources??{},l=[],u=/* @__PURE__ */ new Map,d=i.pageIndex==null?``:`Page ${i.pageIndex}: `,f=!1,p=()=>{f||(f=!0,i.logger?.emit?.(`COLOR_DEVICEN_TINT_UNRESOLVED`,{prefix:d}))},m=t.originShiftPt??{x:0,y:0},h=Ad(m),g=[],_=null,v=ru(),y=[],b=null,x=[],S=[],C=[],w=[],T=null,E=null,D=[],O=0,k=null,A=[],j=[],M=[],ee=[],N=[],P=0,F=!1,I=[],te=()=>{for(let e=I.length-1;e>=0;e--){let t=I[e];if(t.suppressing)return!0;if(t.composite)return!1}return!1},ne=()=>I.flatMap(e=>e.composite?[e.composite]:[]),re=()=>{if(P>0||te())return!0;for(let e=0;e<I.length-1;e++){let t=I[e].composite;t&&(t.keptUnmasked=!0)}return!1},L=null,ie=null,ae=()=>i.pageIndex==null?``:`Page ${i.pageIndex}: `,R=e=>{i.logger?.emit?.(`IMAGE_SOFT_MASK_DROPPED`,{prefix:ae(),detail:e})},se=e=>{if(!Array.isArray(e)||e.length<4)return`(unknown bbox)`;let[n,r,i,a]=e,o=n/72,s=(t.heightPt-a)/72,c=Math.abs(i-n)/72,l=Math.abs(a-r)/72;return`(${o.toFixed(2)} in, ${s.toFixed(2)} in) ${c.toFixed(2)}×${l.toFixed(2)} in`},ce=()=>{if(h.blendMode!=null&&h.blendMode!==`source-over`)return h.blendMode;for(let e=A.length-1;e>=0;e--){let t=A[e];if(t!=null&&t!==`source-over`)return t}return h.blendMode},z=e=>j.reduce((e,t)=>e*(t??1),e??1),le=()=>z(h.fillAlpha),B=()=>z(h.strokeAlpha),V=(e,t,n,r)=>{e.textString+=n,t.text+=n,r&&e.glyphs.push(r)},H=e=>{if(e)for(let e of D)V(e.run,e.snapshot,e.unicode,e.glyph);D=[]},U=()=>{H(!0),O=0,k=null},ue=()=>{U(),T&&T.glyphs.length>0?id(T,r,t,i):T&&dd(T.placeholder),T=null};for(let e=0;e<a.length;e++){let n=a[e],d=o[e];switch(n){case Q.save:g.push(h),h=jd(h),y.push(au(v));break;case Q.restore:h=g.pop()??Ad(m),v=ou(y);break;case Q.paintFormXObjectBegin:M.push(Array.isArray(d?.[0])&&d[0].some((e,t)=>e!==Xu[t])||h.ctm.some((e,t)=>e!==[1,0,0,1,-m.x,-m.y][t])),ee.push(jd(h)),e>0&&a[e-1]===Q.beginGroup?(j.push(h.fillAlpha),A.push(h.blendMode),h.fillAlpha=1,h.strokeAlpha=1,h.blendMode=null):(j.push(1),A.push(null));break;case Q.paintFormXObjectEnd:{M.pop(),A.pop(),j.pop();let e=ee.pop();e&&(h.blendMode=e.blendMode,e.fillAlpha!=null&&(h.fillAlpha=e.fillAlpha),h.fillColor=e.fillColor,h.fillColorSpaceName=e.fillColorSpaceName,h.fillPattern=e.fillPattern,h.strokeColor=e.strokeColor,h.strokeColorSpaceName=e.strokeColorSpaceName,h.strokePattern=e.strokePattern,h.strokeAlpha=e.strokeAlpha,h.fillOverprint=e.fillOverprint,h.strokeOverprint=e.strokeOverprint,h.lineWidth=e.lineWidth,h.lineDash=e.lineDash,h.lineDashPhase=e.lineDashPhase,h.lineCap=e.lineCap,h.lineJoin=e.lineJoin,h.miterLimit=e.miterLimit);break}case Q.beginGroup:{let e=d?.[0]??{},t=e.smask!=null;N.push(t),t&&P++;let n={candidate:F&&!t,suppressing:!1,composite:null};I.push(n),t&&e.smask?.subtype===`Luminosity`&&(L={groupBbox:Array.isArray(e.bbox)?e.bbox.slice():null,captured:null,abort:!1,abortReason:null}),n.candidate&&ie!=null&&(n.composite={mask:ie,solidColor:h.fillColor??null,formBbox:Array.isArray(e.bbox)?e.bbox.slice():null,alpha:null,paintedImage:!1,keptUnmasked:!1},ie=null),F=!1;break}case Q.endGroup:{let e=N.pop();e&&P--;let t=I.pop();e&&L!=null&&(L.abort?R(`a luminosity SMask group at ${se(L.groupBbox)} ${L.abortReason}.`):L.captured==null?R(`a luminosity SMask group at ${se(L.groupBbox)} has no grayscale image content.`):ie={groupBbox:L.groupBbox,captured:L.captured},L=null);let n=t?.composite;if(n?.keptUnmasked)i.logger?.emit?.(`IMAGE_SOFT_MASK_IGNORED`,{prefix:ae(),bbox:se(n.formBbox)});else if(n!=null&&!n.paintedImage){let{mask:e,solidColor:t,formBbox:r,alpha:i}=n;if(t==null)R(`a luminosity SMask at ${se(r)} modulates an unsupported paint shape (no solid fill colour or image was captured).`);else if(t.space!==`rgb`&&t.space!==`cmyk`&&t.space!==`gray`)R(`a luminosity SMask at ${se(r)} modulates a non-solid fill (${t.space}); compositing isn't supported.`);else if(e.captured.kind!==`image`)R(`a luminosity SMask at ${se(r)} uses a shading mask against a solid fill (only image masks are supported for solid targets).`);else{let n={kind:`image`,_placeholderIndex:s.length};s.push(n),x.push({placeholder:n,objId:e.captured.objId,inline:null,ctm:e.captured.ctm,opacity:i??1,blendMode:null,clips:null,compositeWith:t})}}break}case Q.transform:h.ctm=Id(h.ctm,d);break;case Q.setLineWidth:h.lineWidth=d[0];break;case Q.setLineCap:typeof d[0]==`number`&&(h.lineCap=d[0]);break;case Q.setLineJoin:typeof d[0]==`number`&&(h.lineJoin=d[0]);break;case Q.setMiterLimit:typeof d[0]==`number`&&(h.miterLimit=d[0]);break;case Q.setDash:h.lineDash=Array.isArray(d[0])?d[0].slice():[],h.lineDashPhase=typeof d[1]==`number`?d[1]:0;break;case Q.setFillRGBColor:h.fillColor=pd(d),h.fillPattern=null;break;case Q.setStrokeRGBColor:h.strokeColor=pd(d),h.strokePattern=null;break;case Q.setFillCMYKColor:h.fillColor={space:`cmyk`,values:[d[0],d[1],d[2],d[3]]},h.fillPattern=null;break;case Q.setStrokeCMYKColor:h.strokeColor={space:`cmyk`,values:[d[0],d[1],d[2],d[3]]},h.strokePattern=null;break;case Q.setFillGray:h.fillColor={space:`gray`,values:[d[0]]},h.fillPattern=null;break;case Q.setStrokeGray:h.strokeColor={space:`gray`,values:[d[0]]},h.strokePattern=null;break;case Q.setFillColorSpace:h.fillColorSpaceName=d?.[0]??null,h.fillColorSpaceName!==`Pattern`&&(h.fillPattern=null);break;case Q.setStrokeColorSpace:h.strokeColorSpaceName=d?.[0]??null,h.strokeColorSpaceName!==`Pattern`&&(h.strokePattern=null);break;case Q.setFillColorN:{if(d?.[0]===`Shading`){h.fillPattern={shadingId:d[1],matrix:Array.isArray(d[2])?d[2]:Xu.slice()};break}let e=Nd(d);if(e){h.fillPattern=e;break}let{key:t,components:n}=md(d);h.fillColor=hd(t??h.fillColorSpaceName,n,c,h.fillColor,p),h.fillPattern=null;break}case Q.setStrokeColorN:{if(d?.[0]===`Shading`){h.strokePattern={shadingId:d[1],matrix:Array.isArray(d[2])?d[2]:Xu.slice()};break}if(Nd(d)){h.strokePattern=`tiling`;break}h.strokePattern=null;let{key:e,components:t}=md(d);h.strokeColor=hd(e??h.strokeColorSpaceName,t,c,h.strokeColor,p);break}case Q.setGState:{let e=!1,t=!1,n=null;for(let[r,i]of d[0]??[])r===`BM`&&i===`multiply`&&(e=!0),r===`ca`&&typeof i==`number`&&(i<1&&(t=!0),n=i);if(e&&t&&I.length>0){let e=I[I.length-1];e.candidate&&!e.suppressing&&(e.suppressing=!0)}let r=I[I.length-1]?.composite;r!=null&&n!=null&&n<(r.alpha??1)&&(r.alpha=n);let i=d[0]??[];for(let[e,t]of i)if(e===`SMask`&&(t===!0?F=!0:(t===!1||t==null)&&(F=!1)),e===`ca`&&typeof t==`number`)h.fillAlpha=t;else if(e===`CA`&&typeof t==`number`)h.strokeAlpha=t;else if(e===`LW`&&typeof t==`number`)h.lineWidth=t;else if(e===`LC`&&typeof t==`number`)h.lineCap=t;else if(e===`LJ`&&typeof t==`number`)h.lineJoin=t;else if(e===`ML`&&typeof t==`number`)h.miterLimit=t;else if(e===`op`&&typeof t==`boolean`)h.fillOverprint=t;else if(e===`OP`&&typeof t==`boolean`)h.strokeOverprint=t,i.some(([e])=>e===`op`)||(h.fillOverprint=t);else if(e===`D`&&Array.isArray(t))h.lineDash=Array.isArray(t[0])?t[0].slice():[],h.lineDashPhase=typeof t[1]==`number`?t[1]:0;else if(e===`BM`){if(typeof t==`string`&&t!==``)h.blendMode=t;else if(Array.isArray(t)){for(let e of t)if(typeof e==`string`&&e!==``){h.blendMode=e;break}}}break}case Q.constructPath:_={ops:d[0],coords:d[1],minMax:d[2]};break;case Q.clip:b=`nonzero`;break;case Q.eoClip:b=`evenodd`;break;case Q.fill:case Q.eoFill:case Q.stroke:case Q.closeStroke:case Q.fillStroke:case Q.eoFillStroke:case Q.closeFillStroke:case Q.closeEOFillStroke:case Q.endPath:{if(_!=null&&gd(n)){let e=_,t=e.ops[e.ops.length-1];t!==Q.closePath&&t!==Q.rectangle&&(_={...e,ops:[...e.ops,Q.closePath]})}if(b&&_!=null&&(v=iu(v,_,b,h.ctm),b=null),_==null)break;let e=_d(n);if(e){if(h.textClipActive){wd(i,h.ctm,t,`vector ${e}`),_=null;break}if(P>0&&L!=null&&(L.abort=!0,L.abortReason=`contains vector paint operations (only single-paint image or shading masks are supported)`),re()){_=null;break}if(e.fill&&h.fillPattern&&`shadingId`in h.fillPattern){if(M.some(Boolean)&&(i.logger?.emit?.(`SHADING_PATTERN_TRANSFORM_UNSUPPORTED`,{prefix:i.pageIndex==null?``:`Page ${i.pageIndex}: `,page:i.pageIndex}),e.fill=!1,!e.stroke)){_=null;break}if(e.fill){let t={kind:`vector-path`,_placeholderIndex:s.length};if(s.push(t),S.push({placeholder:t,patternId:h.fillPattern.shadingId,isPattern:!0,ctm:Id([1,0,0,1,-m.x,-m.y],h.fillPattern.matrix),clipEntry:{path:_,ctm:h.ctm.slice(),fillRule:e.fillRule},remainingClips:au(v),opacity:le(),blendMode:ce()}),i.logger?.emit?.(`SHADING_COLORSPACE_CONVERTED`,{prefix:i.pageIndex==null?``:`Page ${i.pageIndex}: `,page:i.pageIndex}),!e.stroke){_=null;break}e.fill=!1}}if(e.fill&&h.fillPattern&&!(`shadingId`in h.fillPattern)){let n=Pd(_);if(n){let r=Fd(h.ctm,n),i={kind:`image`,_placeholderIndex:s.length};s.push(i),w.push({placeholder:i,pattern:h.fillPattern,placementCtm:r,fillClip:pu([{path:_,ctm:h.ctm.slice(),fillRule:e.fillRule}],t)[0]??null,insideForm:M.length>0,opacity:le(),blendMode:ce(),clips:su(v)?null:pu(v,t)})}if(e.fill=!1,!e.stroke){_=null;break}}let n=e.fill&&e.stroke&&le()!==B()?[{...e,stroke:!1},{...e,fill:!1}]:[e];for(let e of n){let n=bd(_,e,h,t);if(n){n.blendMode=ce();let r=e.fill?le():B();if(r<1&&(n.opacity=r),fd(n,v,t),s.push(n),e.stroke&&h.strokePattern){let e=n;C.push({block:e,paint:e.stroke?`stroke`:`fill`,pattern:h.strokePattern,ctm:h.strokePattern===`tiling`?null:Id([1,0,0,1,-m.x,-m.y],h.strokePattern.matrix),insideTransformedForm:M.some(Boolean),alpha:h.strokeAlpha,overprint:h.strokeOverprint})}}}e.fill&&vd(u,h.fillColor),e.stroke&&!h.strokePattern&&vd(u,h.strokeColor)}_=null;break}case Q.paintImageXObject:{if(P>0&&L!=null&&(L.captured==null?L.captured={kind:`image`,objId:d[0],ctm:h.ctm.slice()}:(L.abort=!0,L.abortReason=`contains multiple paint operations; only single-paint masks are supported`)),P>0)break;let e=ne();if(e.length>0&&!h.textClipActive){for(let t of e)t.paintedImage=!0;let n={kind:`image`,_placeholderIndex:s.length};s.push(n),x.push({placeholder:n,objId:d[0],inline:null,ctm:h.ctm.slice(),opacity:le(),blendMode:ce(),clips:su(v)?null:pu(v,t),compositeWithMasks:e.map(({mask:e})=>({mask:e.captured,maskGroupBbox:e.groupBbox}))});break}if(re())break;if(h.textClipActive){wd(i,h.ctm,t,`image objId="${d[0]}"`);break}let n={kind:`image`,_placeholderIndex:s.length};s.push(n),x.push({placeholder:n,objId:d[0],inline:null,ctm:h.ctm.slice(),opacity:le(),blendMode:ce(),clips:su(v)?null:pu(v,t)});break}case Q.paintInlineImageXObject:{if(P>0&&L!=null&&(L.abort=!0,L.abortReason=`contains an inline image (only image-xobject masks are supported)`),re())break;if(h.textClipActive){wd(i,h.ctm,t,`inline image`);break}let e={kind:`image`,_placeholderIndex:s.length};s.push(e),x.push({placeholder:e,objId:null,inline:d[0],ctm:h.ctm.slice(),opacity:le(),blendMode:ce(),clips:su(v)?null:pu(v,t)});break}case Q.paintImageMaskXObject:{if(P>0&&L!=null&&(L.abort=!0,L.abortReason=`contains a paintImageMaskXObject (only single-paint image or shading masks are supported)`),re())break;let e=(d[0]??{}).data;if(h.textClipActive){wd(i,h.ctm,t,`image mask objId="${e}"`);break}if(h.fillColor==null){let t=i.pageIndex==null?``:`Page ${i.pageIndex}: `;i.logger?.emit?.(`IMAGE_MASK_NO_FILL_COLOR`,{prefix:t,objId:e??null,page:i.pageIndex});break}let n={kind:`image`,_placeholderIndex:s.length};s.push(n),x.push({placeholder:n,objId:e,inline:null,stencilFill:h.fillColor,ctm:h.ctm.slice(),opacity:le(),blendMode:ce(),clips:su(v)?null:pu(v,t)});break}case Q.paintSolidColorImageMask:{if(P>0&&L!=null&&(L.abort=!0,L.abortReason=`contains a paintSolidColorImageMask (only single-paint image or shading masks are supported)`),re())break;if(h.textClipActive){wd(i,h.ctm,t,`solid-colour image mask`);break}if(h.fillColor==null){let e=i.pageIndex==null?``:`Page ${i.pageIndex}: `;i.logger?.emit?.(`IMAGE_MASK_NO_FILL_COLOR`,{prefix:e,objId:null,page:i.pageIndex});break}let e=bd({ops:[Q.rectangle],coords:[0,0,1,1]},{fill:!0,stroke:!1,fillRule:`nonzero`},h,t);if(e){e.blendMode=ce();let n=le();n!=null&&n<1&&(e.opacity=n),fd(e,v,t),s.push(e)}break}case Q.paintImageMaskXObjectGroup:{if(P>0&&L!=null&&(L.abort=!0,L.abortReason=`contains a paintImageMaskXObjectGroup (only single-paint image or shading masks are supported)`),re())break;let e=i.pageIndex==null?``:`Page ${i.pageIndex}: `,t=Array.isArray(d[0])?d[0].length:0;i.logger?.emit?.(`IMAGE_MASK_GROUP_UNSUPPORTED`,{prefix:e,count:t,page:i.pageIndex});break}case Q.paintImageMaskXObjectRepeat:{if(P>0&&L!=null&&(L.abort=!0,L.abortReason=`contains a paintImageMaskXObjectRepeat (only single-paint image or shading masks are supported)`),re())break;let e=i.pageIndex==null?``:`Page ${i.pageIndex}: `,t=d[5],n=Array.isArray(t)?Math.floor(t.length/2):0;i.logger?.emit?.(`IMAGE_MASK_REPEAT_UNSUPPORTED`,{prefix:e,count:n,page:i.pageIndex});break}case Q.shadingFill:{if(P>0&&L!=null&&(L.captured==null?L.captured={kind:`shading`,patternId:d?.[0],ctm:h.ctm.slice()}:(L.abort=!0,L.abortReason=`contains a shading fill plus another paint (only single-paint masks are supported)`)),re())break;if(h.textClipActive){wd(i,h.ctm,t,`shading fill`);break}let e={kind:`vector-path`,_placeholderIndex:s.length};s.push(e);let n=v.length>0?v[v.length-1]:null,r=v.length>1?v.slice(0,-1):[];S.push({placeholder:e,patternId:d?.[0],ctm:h.ctm.slice(),clipEntry:n??null,remainingClips:r,opacity:le(),blendMode:ce()});break}case Q.beginText:U(),h.textMatrix=Xu.slice(),h.textLineMatrix=Xu.slice(),E=null;break;case Q.endText:ue(),E?.complete&&E.path.ops.length>0?v=iu(v,E.path,`nonzero`,Xu):E?.clipsOnly&&(h.textClipActive=!0),E=null;break;case Q.setFont:(d[0]!==h.fontObjId||d[1]!==h.fontSize)&&U(),h.fontObjId=d[0],h.fontSize=d[1];break;case Q.setTextMatrix:U(),h.textMatrix=[d[0],d[1],d[2],d[3],d[4],d[5]],h.textLineMatrix=h.textMatrix.slice();break;case Q.moveText:U(),h.textLineMatrix=Id(h.textLineMatrix,[1,0,0,1,d[0],d[1]]),h.textMatrix=h.textLineMatrix.slice();break;case Q.setLeadingMoveText:U(),h.textLeading=-d[1],h.textLineMatrix=Id(h.textLineMatrix,[1,0,0,1,d[0],d[1]]),h.textMatrix=h.textLineMatrix.slice();break;case Q.nextLine:U(),h.textLineMatrix=Id(h.textLineMatrix,[1,0,0,1,0,-h.textLeading]),h.textMatrix=h.textLineMatrix.slice();break;case Q.setLeading:h.textLeading=d[0];break;case Q.setCharSpacing:h.charSpacing=d[0];break;case Q.setWordSpacing:h.wordSpacing=d[0];break;case Q.setHScale:h.textHScale=d[0]/100;break;case Q.setTextRise:h.textRise=d[0];break;case Q.setTextRenderingMode:h.textRenderingMode=d[0]??0;break;case Q.showText:case Q.nextLineShowText:case Q.nextLineSetSpacingShowText:case Q.showSpacedText:{let e=(n===Q.showText||Q.nextLineShowText,d[0]),t=h.textRenderingMode>=4&&h.textRenderingMode<=7;if(t&&(E??={path:{ops:[],coords:[]},complete:!0,clipsOnly:!1},h.textRenderingMode===7&&(E.clipsOnly=!0)),!T){let e={_placeholder:!0};s.push(e),T={placeholder:e,ctm:h.ctm.slice(),fillColor:h.fillColor,fillAlpha:h.fillAlpha,fontObjIdFirst:h.fontObjId,textString:``,glyphs:[]}}let i=h.fontObjId==null?null:r[h.fontObjId],a=i?.vertical===!0,o=(()=>{let e=Id(h.ctm,h.textMatrix),t=!a&&h.charSpacing===0&&h.wordSpacing!==0&&Number.isFinite(h.wordSpacing)&&h.fontSize>0&&Number.isFinite(h.fontSize)&&h.textHScale>0&&Number.isFinite(h.textHScale)&&e.every(Number.isFinite)&&e[0]>0&&e[1]===0&&e[2]===0&&e[3]>0?h.wordSpacing*h.textHScale*e[0]:void 0,n=a?0:h.charSpacing*h.textHScale*Math.hypot(e[0],e[1]),r={fontObjId:h.fontObjId??``,baselineX:e[4],baselineY:e[5],fill:oe(kd(h.fillColor,le()),h.fillOverprint),text:``,...t!=null&&Number.isFinite(t)&&t!==0?{wordSpacingPt:t}:{},...Number.isFinite(n)&&n!==0?{charSpacingPt:n}:{},placeholder:T.placeholder,renderMode:h.textRenderingMode};return l.push(r),r})(),c=i?.fontMatrix?.[0]??.001;for(let n of e){if(typeof n==`number`){n!==0&&delete o.wordSpacingPt;let e=-n*.001*h.fontSize*h.textHScale;h.textMatrix[4]+=e*h.textMatrix[0],h.textMatrix[5]+=e*h.textMatrix[1],O+=e;continue}let e=n.unicode??``;o.wordSpacingPt!==void 0&&(n.isSpace?e!==` `:e.includes(` `))&&delete o.wordSpacingPt;let i=n.isInFont===!1?null:{operatorListId:n.operatorListId,fontChar:n.fontChar,unicode:n.unicode,fontObjId:h.fontObjId??``,fontSize:h.fontSize,horizontalScale:h.textHScale,rise:h.textRise,textMatrix:h.textMatrix.slice(),overprint:h.fillOverprint};t&&E&&od(E,i,e,r,h);let s=h.textRenderingMode!==3&&h.textRenderingMode!==7?i:null,l=(n.width??0)*c,u=l*h.fontSize*h.textHScale;a?V(T,o,e,s):Zu.test(e)?(D.push({unicode:e,glyph:s,run:T,snapshot:o}),O+=u+(h.charSpacing+h.wordSpacing)*h.textHScale):(H(k===null||O-k>.03*h.fontSize),V(T,o,e,s),u!==0&&(k=O+u),O+=u+h.charSpacing*h.textHScale);let d=(l*h.fontSize+h.charSpacing+(n.isSpace?h.wordSpacing:0))*h.textHScale;h.textMatrix[4]+=d*h.textMatrix[0],h.textMatrix[5]+=d*h.textMatrix[1]}break}}}ue();for(let e of x){let r=e.inline,a=`ok`;if(!r){let t=typeof e.objId==`string`&&e.objId.startsWith(`g_`),i=typeof e.objId==`string`?e.objId:null,o=await(t?Xc(n,i):Yc(n,i));r=o.data,a=o.reason}if(!r){let n=i.pageIndex==null?``:`Page ${i.pageIndex}: `,r=Td(e.ctm,t.heightPt),o=e.objId?`objId="${e.objId}"`:`inline image`;i.logger?.emit?.(`IMAGE_PDFJS_UNRESOLVED`,{prefix:n,idLabel:o,bboxX:Ql(r.x),bboxY:Ql(r.y),bboxW:Ql(r.w),bboxH:Ql(r.h),page:i.pageIndex,objId:e.objId??null,reason:a}),dd(e.placeholder);continue}let o=null;if(e.stencilFill){if(o=await ol(r,e.stencilFill,i.logger,{objId:typeof e.objId==`string`?e.objId:null,pageIndex:i.pageIndex}),!o){let n=i.pageIndex==null?``:`Page ${i.pageIndex}: `,r=Td(e.ctm,t.heightPt),a=e.stencilFill?.space??`unknown`;i.logger?.emit?.(`IMAGE_MASK_COMPOSITE_FAIL`,{prefix:n,objId:e.objId??null,bboxX:Ql(r.x),bboxY:Ql(r.y),bboxW:Ql(r.w),bboxH:Ql(r.h),colourSpace:a,page:i.pageIndex}),dd(e.placeholder);continue}}else if(e.compositeWith){if(o=await $c(r,e.compositeWith,i.logger,{objId:typeof e.objId==`string`?e.objId:null,pageIndex:i.pageIndex}),!o){let n=i.pageIndex==null?``:`Page ${i.pageIndex}: `,a=Td(e.ctm,t.heightPt),o=e.compositeWith?.space??`unknown`,s=r?.kind,c=s==null?`bitmap`:`kind=${s}`;i.logger?.emit?.(`IMAGE_SOFT_MASK_DROPPED`,{prefix:n,detail:`a luminosity SMask at (${a.x.toFixed(2)} in, ${a.y.toFixed(2)} in) ${a.w.toFixed(2)}×${a.h.toFixed(2)} in could not be composited (mask ${c}, fill colour space "${o}").`}),dd(e.placeholder);continue}}else if(e.compositeWithMasks){let a=null,s=null;for(let{mask:o}of e.compositeWithMasks){let c=await td(n,o);if(c==null){s=`could not resolve its mask source (${o.kind})`;break}let l=await sl({maskSource:c,imageObj:r,imageCtm:e.ctm,pageBox:t,logger:i.logger,pageIndex:i.pageIndex});if(!l){s=`failed to rasterize (${o.kind} mask shape unsupported)`;break}if(a==null)a=l;else for(let e=0;e<l.length;e++)a[e]=Math.round(a[e]*l[e]/255)}if(s!=null||a==null){let n=Td(e.ctm,t.heightPt);i.logger?.emit?.(`IMAGE_SOFT_MASK_DROPPED`,{prefix:i.pageIndex==null?``:`Page ${i.pageIndex}: `,detail:`a luminosity SMask at (${n.x.toFixed(2)} in, ${n.y.toFixed(2)} in) ${s}.`}),dd(e.placeholder);continue}if(o=await cl(r,a),!o){dd(e.placeholder);continue}}else if(o=await Qc(r,i.logger,{objId:typeof e.objId==`string`?e.objId:null,ctm:e.ctm,pageIndex:i.pageIndex}),!o){dd(e.placeholder);continue}let s=Td(e.ctm,t.heightPt,{logger:i.logger,pageIndex:i.pageIndex,objId:e.objId}),c=Fu(r),l=e.compositeWith||e.compositeWithMasks?null:Au(c,await Pu(n,c)),u=l?void 0:Nu(c);u&&i.logger?.emit?.(`IMAGE_PROFILE_REFUSED`,{prefix:i.pageIndex==null?``:`Page ${i.pageIndex}: `,bbox:$l({x:s.x,y:s.y,width:s.w,height:s.h}),reason:u,page:i.pageIndex});let d=Iu(r);Object.assign(e.placeholder,{kind:`image`,x:s.x,y:s.y,width:s.w,height:s.h,...l?{mimeType:`image/jpeg`,bytes:l.bytes,colorDefinition:l.definition,fallbackBytes:o}:{mimeType:`image/png`,bytes:o},...d?{renderingIntent:d}:{},opacity:e.opacity??1,...Math.abs(s.rotation)>1e-6?{rotation:s.rotation}:{},...s.flipHorizontal?{flipHorizontal:!0}:{},...s.flipVertical?{flipVertical:!0}:{},...e.blendMode?{blendMode:e.blendMode}:{},...e.clips&&e.clips.length>0?{clips:e.clips}:{}})}let de=/* @__PURE__ */ new Map,fe=32768;for(let e of w){if(!e.pattern.operatorList.fnArray.includes(Q.paintImageXObject)){let a=(e.opacity==null||e.opacity===1)&&(e.blendMode==null||e.blendMode===`source-over`),o=e.fillClip&&!e.insideForm&&a?Ju(e.pattern,e.fillClip,t.heightPt,m):null;if(o==null||o.work>fe){i.logger?.emit?.(`TILING_PATTERN_UNSUPPORTED`,{prefix:i.pageIndex==null?``:`Page ${i.pageIndex}: `,patternId:e.pattern.patternId,imageCount:0,otherOpCount:e.pattern.operatorList.fnArray.length,page:i.pageIndex}),dd(e.placeholder);continue}fe-=o.work;let s=[];for(let a of o.tiles){let o=await nd(a,t,n,r,i);for(let t of rd(o.out)){if(t.kind!==`vector-path`)throw Error(`Vector tiling produced non-vector artwork`);t.clips=[...e.clips??[],e.fillClip,...t.clips??[]],s.push(t)}}Object.assign(e.placeholder,{_placeholder:!0,_replacements:s});continue}let a=de.get(e.pattern.patternId)??null;if(a==null){if(a=await Ru({page:n,pattern:e.pattern,logger:i.logger,pageIndex:i.pageIndex}),!a){dd(e.placeholder);continue}de.set(e.pattern.patternId,a)}let o=i.pageIndex==null?``:`Page ${i.pageIndex}: `;i.logger?.emit?.(`TILING_PATTERN_AS_IMAGE`,{prefix:o,patternId:e.pattern.patternId,page:i.pageIndex});let s=Td(e.placementCtm,t.heightPt,{logger:i.logger,pageIndex:i.pageIndex,objId:e.pattern.patternId});Object.assign(e.placeholder,{kind:`image`,x:s.x,y:s.y,width:s.w,height:s.h,mimeType:`image/png`,bytes:a.bytes,...a.renderingIntent?{renderingIntent:a.renderingIntent}:{},patternTile:!0,opacity:e.opacity??1,...Math.abs(s.rotation)>1e-6?{rotation:s.rotation}:{},...s.flipHorizontal?{flipHorizontal:!0}:{},...s.flipVertical?{flipVertical:!0}:{},...e.blendMode?{blendMode:e.blendMode}:{},...e.clips&&e.clips.length>0?{clips:e.clips}:{}})}for(let e of S){let r=i.pageIndex==null?``:`Page ${i.pageIndex}: `;if(typeof e.patternId!=`string`){i.logger?.emit?.(`SHADING_NO_PATTERN_REF`,{prefix:r,page:i.pageIndex}),dd(e.placeholder);continue}let a=(await Yc(n,e.patternId)).data,o=_u({shadingIR:a,ctm:e.ctm,clipEntry:e.clipEntry,remainingClips:e.remainingClips,pageBox:t,opacity:e.opacity,blendMode:e.blendMode,logger:i.logger,pageIndex:i.pageIndex,isPattern:e.isPattern});o?Object.assign(e.placeholder,o):dd(e.placeholder)}for(let e of C){let r=i.pageIndex==null?``:`Page ${i.pageIndex}: `,a=e.pattern!==`tiling`&&typeof e.pattern.shadingId==`string`?yu({shadingIR:(await Yc(n,e.pattern.shadingId)).data,ctm:e.ctm??Xu,pageBox:t,logger:i.logger,pageIndex:i.pageIndex}):null,o=e.paint===`stroke`&&!e.insideTransformedForm&&a?a.gradient:null;a&&(e.block[e.paint]=oe(kd(a.solid,e.alpha),e.overprint),o&&(e.block.strokeGradient=o)),o||i.logger?.emit?.(`PATTERN_PAINT_UNSUPPORTED`,{prefix:r,page:i.pageIndex,at:$l(e.block),paint:`stroke`,pattern:a?e.insideTransformedForm?`gradient inside a transformed PDF form`:`gradient on a stroke of no length`:e.pattern===`tiling`?`tiling pattern`:`shading pattern`,fallback:tu(e.block[e.paint])})}return{out:s,colorSnapshots:l,pathSpotColors:[...u.values()]}}function rd(e){let t=[];for(let n of e)n._removed||(n._placeholder?Array.isArray(n._replacements)&&t.push(...n._replacements):t.push(n));return t}function id(e,t,n,r){let i=r?.textMode??`outline`,a=[];if(e.placeholder._replacements=a,i===`outline`){let r=ad(e,e.glyphs,t,n);r&&a.push(r);return}let o=Gl(e.glyphs,t,e.ctm,n.heightPt),s=[];e.placeholder._lazyGlyphOutlines=s;for(let r of o){let o=t[r.fontObjId];if(jl(o,r.glyphs)){let i=r;s.push(()=>{let r=ad(e,i.glyphs,t,n);return!r||r.kind!==`text-outline`?null:{d:r.d,x:r.x,y:r.y,width:r.width,height:r.height}});continue}if(i===`editable`){let e=o?.name??r.fontObjId;throw Error(`textMode 'editable': embeddability gate failed for font ${e} (text: ${JSON.stringify(r.text)})`)}let c=ad(e,r.glyphs,t,n);c&&a.push(c)}}function ad(e,t,n,r){if(!t||t.length===0)return null;let i=[],a=[],o=0,s=0,c=``;for(let l of t){let t=n[l.fontObjId];if(!t)continue;let u=sd(t),d=[l.fontSize,0,0,l.fontSize,0,0],f=l.horizontalScale??1,p=l.rise??0,m=(t=>Id(e.ctm,Id(l.textMatrix,Id(t,u))))([l.fontSize*f,0,0,l.fontSize,0,p]),h=null;if(t.isType3Font?h=cd(t,l.operatorListId):t._parsed&&(h=ud(t,l)),h){let e=Sd(h,m,r.heightPt);i.push(...e.cmds),a.push(...e.devPoints)}let g=Id(e.ctm,Id(l.textMatrix,d));o+=Math.hypot(g[2],g[3]),s+=1,c+=l.unicode??``}let l=s>0?o/s:0,u=1/0,d=1/0,f=-1/0,p=-1/0;for(let[e,t]of a)e<u&&(u=e),t<d&&(d=t),e>f&&(f=e),t>p&&(p=t);Number.isFinite(u)||(u=d=f=p=0);let m=n[t[0].fontObjId],{style:h,weight:g}=Pl(m),_=xl(m?.name??``),v=_.family||_.fullName,y=Id(e.ctm,t[0].textMatrix),b=t[0].rise??0,x=y[2]*b+y[4],S=r.heightPt-(y[3]*b+y[5]),C=-Math.atan2(y[1],y[0]),w=Math.cos(-C),T=Math.sin(-C),E=1/0,D=1/0,O=-1/0,k=-1/0;for(let[e,t]of a){let n=e*w-t*T,r=e*T+t*w;n<E&&(E=n),r<D&&(D=r),n>O&&(O=n),r>k&&(k=r)}let A=Number.isFinite(E)?Math.max(0,O-E):0,j=Number.isFinite(D)?Math.max(0,k-D):0,M=t.filter(e=>!Zu.test(e.unicode??``));return{kind:`text-outline`,x:u,y:d,width:Math.max(0,f-u),height:Math.max(0,p-d),d:Cd(i,u,d),text:c,fontFamily:v,fontSize:l,fontStyle:h,fontWeight:g,fill:oe(kd(e.fillColor,e.fillAlpha),M.length>0&&M.every(e=>e.overprint===!0)),opacity:e.fillAlpha!=null&&e.fillAlpha<1?e.fillAlpha:1,textOriginX:x,textOriginY:S,rotation:C,unrotWidth:A,unrotHeight:j}}function od(e,t,n,r,i){let a=t?r[t.fontObjId]:null,o=t&&a?a.isType3Font?cd(a,t.operatorListId):a._parsed?ud(a,t):null:null;if(!t||!a||!o){/^\s+$/.test(n)||(e.complete=!1);return}let s=sd(a),c=[i.fontSize*i.textHScale,0,0,i.fontSize,0,i.textRise],l=Id(i.ctm,Id(t.textMatrix,Id(c,s)));ld(e.path,o.ops,o.coords,l)}function sd(e){let t=e.fontMatrix;if(t)return t;let n=e._parsed?.unitsPerEm,r=n&&n>0?1/n:.001;return[r,0,0,r,0,0]}function cd(e,t){let n=e?.charProcOperatorList?.[t];if(!n)return null;let r=n.fnArray,i=n.argsArray,a={ops:[],coords:[]},o=Xu,s=[];for(let e=0;e<r.length;e++)switch(r[e]){case Q.save:s.push(o);break;case Q.restore:o=s.pop()??Xu;break;case Q.transform:o=Id(o,i[e]);break;case Q.constructPath:ld(a,i[e][0],i[e][1],o)}return a.ops.length===0?null:a}function ld(e,t,n,r){let[i,a,o,s,c,l]=r;if(i===1&&a===0&&o===0&&s===1&&c===0&&l===0){e.ops.push(...t),e.coords.push(...n);return}let u=a===0&&o===0,d=(t,n)=>{e.coords.push(i*t+o*n+c,a*t+s*n+l)},f=0;for(let r of t)switch(r){case Q.rectangle:{let t=n[f++],r=n[f++],a=n[f++],o=n[f++];if(u){e.ops.push(Q.rectangle),d(t,r),e.coords.push(i*a,s*o);break}e.ops.push(Q.moveTo,Q.lineTo,Q.lineTo,Q.lineTo,Q.closePath),d(t,r),d(t+a,r),d(t+a,r+o),d(t,r+o);break}case Q.moveTo:case Q.lineTo:case Q.curveTo2:case Q.curveTo3:case Q.curveTo:{let t=r===Q.moveTo||r===Q.lineTo?1:r===Q.curveTo?3:2;e.ops.push(r);for(let e=0;e<t;e++)d(n[f++],n[f++]);break}default:e.ops.push(r)}}function ud(e,t){let n=e._parsed;if(!n)return null;let r=null,i=n.encoding,a=(e=>{if(e==null)return-1;let t=i?.cmap?.glyphIndexMap?.[e];if(typeof t==`number`)return t;try{let t=i?.charToGlyphIndex?.(e);return typeof t==`number`?t:-1}catch{return-1}})(t.fontChar?t.fontChar.codePointAt(0):null);if(a>0&&(r=n.glyphs.get(a)),!r)try{t.fontChar&&(r=n.charToGlyph(t.fontChar))}catch{}if((!r||r.index===0)&&t.unicode)try{let e=n.charToGlyph(t.unicode);e&&e.index>0&&(r=e)}catch{}if(!r||!r.path||r.index===0)return null;let o=[],s=[],c=0,l=0,u=0,d=0;for(let e of r.path.commands)switch(e.type){case`M`:o.push(Q.moveTo),s.push(e.x,e.y),c=u=e.x,l=d=e.y;break;case`L`:o.push(Q.lineTo),s.push(e.x,e.y),c=e.x,l=e.y;break;case`C`:o.push(Q.curveTo),s.push(e.x1,e.y1,e.x2,e.y2,e.x,e.y),c=e.x,l=e.y;break;case`Q`:o.push(Q.curveTo),s.push(c+2/3*(e.x1-c),l+2/3*(e.y1-l),e.x+2/3*(e.x1-e.x),e.y+2/3*(e.y1-e.y),e.x,e.y),c=e.x,l=e.y;break;case`Z`:o.push(Q.closePath),c=u,l=d}return o.length===0?null:{ops:o,coords:s}}function dd(e){e._removed=!0}function fd(e,t,n){if(su(t))return;let r=pu(t,n);r.length>0&&(e.clips=r)}function pd(e){return{space:`rgb`,values:[e[0]/255,e[1]/255,e[2]/255]}}function md(e){if(!Array.isArray(e)||e.length===0)return{key:null,components:[]};let t=e[e.length-1];return typeof t==`string`||t===null?{key:typeof t==`string`?t:null,components:e.slice(0,-1)}:{key:null,components:e}}function hd(e,t,n,r,i){if(e==null)return r;switch(e){case`DeviceGray`:return{space:`gray`,values:[t?.[0]??0]};case`DeviceRGB`:return{space:`rgb`,values:[t?.[0]??0,t?.[1]??0,t?.[2]??0]};case`DeviceCMYK`:return{space:`cmyk`,values:[t?.[0]??0,t?.[1]??0,t?.[2]??0,t?.[3]??0]}}let a=n[e];if(!a)return r;if(a.kind===`separation`){let e=t?.[0]??1,n=Array.isArray(a.solid)?a.solid:[],r=n.map(t=>t*e);return{space:`spot`,name:a.name,tint:e,alternateSpace:a.alternateSpace,solid:n,values:r}}if(a.kind===`deviceN`){i();let e=Array.isArray(a.solid)?a.solid:[];return a.alternateSpace===`DeviceCMYK`?{space:`cmyk`,values:e.slice(0,4)}:a.alternateSpace===`DeviceGray`?{space:`gray`,values:e.slice(0,1)}:{space:`rgb`,values:e.slice(0,3)}}return r}function gd(e){return e===Q.closeStroke||e===Q.closeFillStroke||e===Q.closeEOFillStroke}function _d(e){switch(e){case Q.fill:return{fill:!0,stroke:!1,fillRule:`nonzero`};case Q.eoFill:return{fill:!0,stroke:!1,fillRule:`evenodd`};case Q.stroke:case Q.closeStroke:return{fill:!1,stroke:!0,fillRule:`nonzero`};case Q.fillStroke:case Q.closeFillStroke:return{fill:!0,stroke:!0,fillRule:`nonzero`};case Q.eoFillStroke:case Q.closeEOFillStroke:return{fill:!0,stroke:!0,fillRule:`evenodd`};default:return null}}function vd(e,t){if(t==null||!R(t))return;let{name:n}=t;n!=null&&!e.has(n)&&e.set(n,t)}function yd(e,t,n,r){if(!t.stroke||Yu[n.lineCap]!==`Round`||Array.from(e.ops).every(e=>e===Q.moveTo))return null;let i=n.lineWidth/2,[a,o,s,c]=n.ctm;if(!(i>0)||a*c-o*s===0)return null;let[l,u]=e.coords,d=.5522847498*i;return bd({ops:[Q.moveTo,Q.curveTo,Q.curveTo,Q.curveTo,Q.curveTo],coords:[[l+i,u],[l+i,u+d],[l+d,u+i],[l,u+i],[l-d,u+i],[l-i,u+d],[l-i,u],[l-i,u-d],[l-d,u-i],[l,u-i],[l+d,u-i],[l+i,u-d],[l+i,u]].flat()},{fill:!0,stroke:!1,fillRule:`nonzero`},{...n,fillColor:n.strokeColor,fillAlpha:n.strokeAlpha,fillOverprint:n.strokeOverprint},r)}function bd(e,t,n,r){let i=xd(e,n.ctm,r.heightPt);if(!i)return null;let{devPoints:a,cmds:o}=i;if(a.length===0)return null;let s=1/0,c=1/0,l=-1/0,u=-1/0;for(let[e,t]of a)e<s&&(s=e),t<c&&(c=t),e>l&&(l=e),t>u&&(u=t);let d=l-s,f=u-c;if(d<=0&&f<=0)return yd(e,t,n,r);let p=t.stroke?Math.abs(Md(n.ctm)*n.lineWidth):0,m=Math.abs(Md(n.ctm)),h=t.stroke&&n.lineDash.length>0?n.lineDash.map(e=>e*m):void 0,g=t.stroke?Yu[n.lineCap]:void 0,_=t.stroke&&d<=0?p:0,v=t.stroke&&f<=0?p:0,y=s-_/2,b=c-v/2;return{kind:`vector-path`,x:y,y:b,width:d+_,height:f+v,d:Cd(o,y,b),fill:t.fill?oe(kd(n.fillColor,n.fillAlpha),n.fillOverprint):null,stroke:t.stroke?oe(kd(n.strokeColor,n.strokeAlpha),n.strokeOverprint):null,strokeWidth:p,strokeDashArray:h,strokeDashOffset:h==null?void 0:n.lineDashPhase*m,strokeCap:g,strokeJoin:t.stroke?[`Miter`,`Round`,`Bevel`][n.lineJoin]:void 0,strokeMiterLimit:t.stroke?n.miterLimit:void 0,fillRule:t.fillRule,opacity:1,blendMode:n.blendMode}}function xd(e,t,n){return Sd(e,t,n)}function Sd(e,t,n){let r=e.ops??[],i=e.coords??[],a=[],o=[],s=0,c=null,l=(e,r)=>{let[i,a,o,s,c,l]=t;return[i*e+o*r+c,n-(a*e+s*r+l)]};for(let e=0;e<r.length;e++)switch(r[e]){case Q.rectangle:{let e=i[s++],t=i[s++],n=i[s++],r=i[s++],c=l(e,t),u=l(e+n,t),d=l(e+n,t+r),f=l(e,t+r);o.push({cmd:`M`,pts:[c]}),o.push({cmd:`L`,pts:[u]}),o.push({cmd:`L`,pts:[d]}),o.push({cmd:`L`,pts:[f]}),o.push({cmd:`Z`}),a.push(c,u,d,f);break}case Q.moveTo:{let e=l(i[s++],i[s++]);o.push({cmd:`M`,pts:[e]}),a.push(e),c=e;break}case Q.lineTo:{let e=l(i[s++],i[s++]);o.push({cmd:`L`,pts:[e]}),a.push(e),c=e;break}case Q.curveTo:{let e=l(i[s++],i[s++]),t=l(i[s++],i[s++]),n=l(i[s++],i[s++]);o.push({cmd:`C`,pts:[e,t,n]}),a.push(e,t,n),c=n;break}case Q.curveTo2:{let e=l(i[s++],i[s++]),t=l(i[s++],i[s++]),n=c??e;o.push({cmd:`C`,pts:[n,e,t]}),a.push(e,t),c=t;break}case Q.curveTo3:{let e=l(i[s++],i[s++]),t=l(i[s++],i[s++]);o.push({cmd:`C`,pts:[e,t,t]}),a.push(e,t),c=t;break}case Q.closePath:o.push({cmd:`Z`})}return{devPoints:a,cmds:o}}function Cd(e,t,n){let r=e=>`${Math.round(e*100)/100}`,i=[];for(let a of e){if(a.cmd===`Z`){i.push(`Z`);continue}let e=(a.pts??[]).map(([e,i])=>`${r(e-t)} ${r(i-n)}`).join(` `);i.push(`${a.cmd} ${e}`)}return i.join(` `)}function wd(e,t,n,r){let i=e?.pageIndex==null?``:`Page ${e.pageIndex}: `,a=Td(t,n.heightPt);e?.logger?.emit?.(`TEXT_CLIP_MODE_7_DROPPED`,{prefix:i,label:r,bbox:`${Ql(a.x)}, ${Ql(a.y)}`,bboxSize:`${Ql(a.w)}×${Ql(a.h)}`,page:e?.pageIndex})}function Td(e,t,n=null){let[r,i,a,o,s,c]=e,l=Math.hypot(r,i),u=Math.hypot(a,o);if(Math.abs(i)<1e-6&&Math.abs(a)<1e-6)return Ed(e,t);let d=(r*a+i*o)/(l*u),f=!(Math.abs(d)<.01),p=f?Math.abs(r*o-i*a)/l:u;if(!(l>0&&p>0&&Number.isFinite(l)&&Number.isFinite(p)))return Dd(e,t);let m=s+(r+a)*.5,h=c+(i+o)*.5,g=Math.atan2(-i,r),_=r*o-i*a<0,v={x:m-l*.5,y:t-h-p*.5,w:l,h:p,rotation:g,flipHorizontal:!1,flipVertical:_};return f&&Od(e,v,n,d),v}function Ed(e,t){let[n,r,i,a,o,s]=e,c=Math.hypot(n,r),l=Math.hypot(i,a),u=o+(n+i)*.5,d=s+(r+a)*.5;return{x:u-c*.5,y:t-d-l*.5,w:c,h:l,rotation:0,flipHorizontal:n<0,flipVertical:a<0}}function Dd(e,t){let[n,r,i,a,o,s]=e,c=[o,o+n,o+i,o+n+i],l=[s,s+r,s+a,s+r+a],u=Math.min(...c),d=Math.max(...c),f=Math.min(...l),p=Math.max(...l);return{x:u,y:t-p,w:d-u,h:p-f,rotation:0,flipHorizontal:!1,flipVertical:!1}}function Od(e,t,n,r){if(!n?.logger?.emit)return;let i=n.pageIndex==null?``:`Page ${n.pageIndex}: `,a=`, residual=${Ql(r)}`,o=n.objId?` objId="${n.objId}"`:``;n.logger.emit(`IMAGE_SKEW_DROPPED`,{prefix:i,idLabel:o,bboxX:Ql(t.x),bboxY:Ql(t.y),bboxW:Ql(t.w),bboxH:Ql(t.h),ctm:eu(e),residualStr:a,page:n.pageIndex,objId:n.objId??null})}function kd(e,t){return e==null?null:t==null||t===1?e:{...e,alpha:t}}function Ad(e={x:0,y:0}){return{ctm:[1,0,0,1,-e.x,-e.y],fillColor:{space:`gray`,values:[0]},strokeColor:{space:`gray`,values:[0]},fillColorSpaceName:null,strokeColorSpaceName:null,fillPattern:null,strokePattern:null,fillAlpha:1,strokeAlpha:1,fillOverprint:!1,strokeOverprint:!1,lineWidth:1,lineDash:[],lineDashPhase:0,lineCap:0,lineJoin:0,miterLimit:10,blendMode:null,textMatrix:Xu.slice(),textLineMatrix:Xu.slice(),fontObjId:null,fontSize:0,charSpacing:0,wordSpacing:0,textHScale:1,textRise:0,textLeading:0,textRenderingMode:0,textClipActive:!1}}function jd(e){return{ctm:e.ctm.slice(),fillColor:e.fillColor,strokeColor:e.strokeColor,fillColorSpaceName:e.fillColorSpaceName,strokeColorSpaceName:e.strokeColorSpaceName,fillPattern:e.fillPattern,strokePattern:e.strokePattern,fillAlpha:e.fillAlpha,strokeAlpha:e.strokeAlpha,fillOverprint:e.fillOverprint,strokeOverprint:e.strokeOverprint,lineWidth:e.lineWidth,lineDash:e.lineDash,lineDashPhase:e.lineDashPhase,lineCap:e.lineCap,lineJoin:e.lineJoin,miterLimit:e.miterLimit,blendMode:e.blendMode,textMatrix:e.textMatrix.slice(),textLineMatrix:e.textLineMatrix.slice(),fontObjId:e.fontObjId,fontSize:e.fontSize,charSpacing:e.charSpacing,wordSpacing:e.wordSpacing,textHScale:e.textHScale,textRise:e.textRise,textLeading:e.textLeading,textRenderingMode:e.textRenderingMode,textClipActive:e.textClipActive}}function Md([e,t,n,r]){return(Math.hypot(e,t)+Math.hypot(n,r))/2}function Nd(e){if(!Array.isArray(e)||e.length<5||e[0]!==`TilingPattern`)return null;let t=e[2];if(!t||!Array.isArray(t.fnArray)||!Array.isArray(t.argsArray))return null;let n=e[3]??[1,0,0,1,0,0],r=e[4]??[0,0,0,0],i=`pattern`;for(let e=0;e<t.fnArray.length;e++)if(t.fnArray[e]===Q.paintImageXObject){let n=t.argsArray[e]?.[0];if(typeof n==`string`){i=`pattern[${n}]`;break}}return{patternId:i,operatorList:{fnArray:t.fnArray,argsArray:t.argsArray},matrix:n,bbox:r,xStep:Number(e[5]),yStep:Number(e[6]),paintType:Number(e[7])}}function Pd(e){let t=e.coords??[];if(t.length<2)return null;let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let e=0;e+1<t.length;e+=2){let o=t[e],s=t[e+1];o<n&&(n=o),s<r&&(r=s),o>i&&(i=o),s>a&&(a=s)}return!Number.isFinite(n)||!Number.isFinite(r)?null:{x:n,y:r,w:i-n,h:a-r}}function Fd(e,t){let[n,r,i,a,o,s]=e,c=t.y+t.h;return[n*t.w,r*t.w,-i*t.h,-a*t.h,n*t.x+i*c+o,r*t.x+a*c+s]}function Id(e,t){let[n,r,i,a,o,s]=e,[c,l,u,d,f,p]=t;return[n*c+i*l,r*c+a*l,n*u+i*d,r*u+a*d,n*f+i*p+o,r*f+a*p+s]}function Ld(e,t,n=!1){return e.filter(e=>{if(e.kind!==`vector-path`)return!0;let r=e.fill;return!(r&&`alpha`in r&&r.alpha===0&&!e.stroke||!n&&Rd(e,t))})}function Rd(e,t){if(e.kind!==`vector-path`||e.stroke||!e.fill||e.fill.space!==`rgb`)return!1;let[n,r,i]=e.fill.values;return n>=.98&&r>=.98&&i>=.98&&Math.abs(e.x)<=1&&Math.abs(e.y)<=1&&Math.abs(e.width-t.widthPt)<=1&&Math.abs(e.height-t.heightPt)<=1&&zd(e.d,e.x,e.y,e.width,e.height)}function zd(e,t,n,r,i){if(/[cqstaCQSTA]/.test(e))return!1;let a=Bd(e);if(a.length===0)return!1;let o=.5,s=[[t,n],[t+r,n],[t+r,n+i],[t,n+i]];for(let[e,t]of a)if(!s.some(([n,r])=>Math.abs(e-n)<=o&&Math.abs(t-r)<=o))return!1;return s.filter(([e,t])=>a.some(([n,r])=>Math.abs(n-e)<=o&&Math.abs(r-t)<=o)).length>=3}function Bd(e){let t=[],n=e.match(/[a-zA-Z]|-?\d*\.?\d+(?:[eE][+-]?\d+)?/g)??[],r=``,i=0,a=0,o=0;for(;o<n.length;){let e=n[o];if(/[a-zA-Z]/.test(e)){if(r=e,o++,r===`Z`||r===`z`)continue}else r===`M`||r===`L`?(i=parseFloat(n[o]),a=parseFloat(n[o+1]),t.push([i,a]),o+=2,r===`M`&&(r=`L`)):r===`m`||r===`l`?(i+=parseFloat(n[o]),a+=parseFloat(n[o+1]),t.push([i,a]),o+=2,r===`m`&&(r=`l`)):r===`H`?(i=parseFloat(n[o]),t.push([i,a]),o+=1):r===`h`?(i+=parseFloat(n[o]),t.push([i,a]),o+=1):r===`V`?(a=parseFloat(n[o]),t.push([i,a]),o+=1):(r===`v`&&(a+=parseFloat(n[o]),t.push([i,a])),o+=1)}return t}const Vd=1.5,Hd=/* @__PURE__ */ new Set([0,2,4,6]);async function Ud(e,t){let n=await e.getTextContent({includeMarkedContent:!1,disableNormalization:!0}),r=[],i={cursor:0,consumed:/* @__PURE__ */ new Set};for(let a of n.items){if(a.type||rf(a.str))continue;if(a.str&&a.str.length>0&&a.str.trim()===``){let e=t.pageBox.originShiftPt??{x:0,y:0};Yd({fontObjId:a.fontName,baselineX:a.transform[4]-e.x,baselineY:a.transform[5]-e.y,widthPt:a.width,str:a.str,dirSignX:a.transform[0]<0?-1:1},t.colorSnapshots,i);continue}if(!a.str)continue;let o=nf(e,a.fontName);if(!Ml(o))continue;let s=n.styles?.[a.fontName],c=await Wd(a,o,s,t,i);if(!c||!c.run)continue;let l=c.placeholder;if(l&&Array.isArray(l._replacements)){let e=l._lazyGlyphOutlines;Array.isArray(e)&&e.length>0&&(c.run._buildGlyphOutline=e.shift()),l._replacements.push(c.run)}else r.push(c.run)}return r}async function Wd(e,t,n,r,i){let[a,o,s,c,l,u]=e.transform,d=Math.hypot(s,c);if(!(d>0))return null;let f=Math.atan2(o,a),p=r.pageBox.originShiftPt??{x:0,y:0},m=l-p.x,h=u-p.y,{ascentRatio:g,descentRatio:_}=tf(n,t),v=d*g,y=d*_,b=e.width+d*.05,x=v+y,S=Math.cos(f),C=Math.sin(f),w=b/2,T=(v-y)/2,E=m+w*S-T*C,D=h+w*C+T*S,O=E-w,k=r.pageBox.heightPt-D-x/2,A=x/2,j=O-A*C,M=k+A*(1-S),ee=await El(t,r.logger);if(!ee)return null;r.docFonts.has(ee.postScriptName)||r.docFonts.set(ee.postScriptName,ee);let N=Kd({fontObjId:e.fontName,baselineX:m,baselineY:h,widthPt:e.width,str:e.str,dirSignX:a<0?-1:1},r.colorSnapshots,i);if(N==null)return null;let P=ee,F=N.walkerFontObjId;if(F&&F!==e.fontName&&r.page){let e=nf(r.page,F);if(e&&Ml(e)){let t=await El(e,r.logger);t&&(P=t,r.docFonts.has(t.postScriptName)||r.docFonts.set(t.postScriptName,t))}}if(N.renderMode===3||N.renderMode===7){let t=r.pageIndex==null?``:` on page ${r.pageIndex}`,n=N.renderMode===7?`7 (add to clipping path)`:`3 (invisible)`;return r.logger?.emit?.(`TEXT_RENDER_MODE_SKIPPED`,{pageTag:t,text:Gd(e.str,60),modeLabel:n,page:r.pageIndex,renderMode:N.renderMode}),null}let{fill:I,colorSpans:te,wordSpacingPt:ne,charSpacingPt:re}=N,L=(re??0)/d,ie=Number.isFinite(L)&&L>=.001?[{from:0,to:e.str.length,em:L}]:void 0,ae=ne==null?0:ne/d,R=Number.isFinite(ae)&&ae!==0&&e.str.includes(` `)?[{from:0,to:e.str.length,em:ae}]:void 0,oe=I?.alpha,se=oe!=null&&oe<1?oe:1,ce={kind:`text-run`,x:j,y:M,width:b,height:x,text:e.str,fontRef:P.postScriptName,family:P.family,...P.weight==null?{}:{fontWeight:P.weight},...P.style?{fontStyle:P.style}:{},...P.width?{fontWidth:P.width}:{},fontSize:d,rotation:-f,fill:I,...te?{colorSpans:te}:{},...R?{wordSpacingSpans:R}:{},...ie?{letterSpacingSpans:ie}:{},baselineXPt:m,baselineYPt:h,advanceWidthPt:e.width};return ce.opacity=se,{run:ce,placeholder:N.placeholder??null}}function Gd(e,t){return typeof e==`string`?e.length>t?`${e.slice(0,t)}…`:e:``}function Kd(e,t,n){let r=[],i=[],a=n.cursor,o=e.str.length,s=0;for(let c=n.cursor;c<t.length;c++){if(n.consumed.has(c)||!Qd(t[c])||!$d(t[c],e))continue;let l=t[c].text?.length??0;if(s>=o)break;r.push(t[c]),i.push(c),s+=l,a=c+1}if(r.length===0)for(let a=0;a<t.length;a++){if(n.consumed.has(a)||!Qd(t[a])||!$d(t[a],e))continue;let c=t[a].text?.length??0;if(s>=o)break;r.push(t[a]),i.push(a),s+=c}else n.cursor=a;if(r.length===0){for(let r=0;r<t.length;r++)if(n.consumed.has(r)&&Qd(t[r])&&$d(t[r],e)&&Zd(t[r].text,e.str))return null;let r=Math.max(e.widthPt,36)*4,i=null,a=!1,o=!1,s=!0;for(let c=0;c<t.length;c++){let l=t[c];if(!n.consumed.has(c)||!Qd(l)||!Hd.has(l.renderMode??0)||Math.abs(l.baselineY-e.baselineY)>Vd||Math.abs(l.baselineX-e.baselineX)>r)continue;let u=l.fill??null;if(s&&=u?.overprint===!0,!a)i=u,a=!0;else if(!se(i,u,!1)){o=!0;break}}return a&&!o&&i!=null?{fill:oe(i,s),colorSpans:void 0,renderMode:0,placeholder:null,walkerFontObjId:null}:{fill:null,colorSpans:void 0,renderMode:0,placeholder:null,walkerFontObjId:null}}for(let e of i)n.consumed.add(e);let c=r[0].renderMode??0,l=r[0].placeholder??null,u=Xd(r,e.str),d=r.length===1?r:r.filter(e=>e.text?.length),f=d.length===1&&d[0].text?.replace(/ +$/,``)===e.str?d[0]:void 0,p=f?.wordSpacingPt!=null&&Number.isFinite(f.wordSpacingPt)&&f.wordSpacingPt!==0?f.wordSpacingPt:void 0,m=d.map(e=>e.text??``).join(``).replace(/ +$/,``)===e.str&&d.every(e=>e.charSpacingPt===d[0].charSpacingPt)?d[0].charSpacingPt:void 0,h=r[0].fill??null;if(r.every(e=>se(e.fill??null,h)))return{fill:h,colorSpans:void 0,renderMode:c,placeholder:l,walkerFontObjId:u,wordSpacingPt:p,charSpacingPt:m};let g=qd(e.str,r);return g.length===0?{fill:h,colorSpans:void 0,renderMode:c,placeholder:l,walkerFontObjId:u,wordSpacingPt:p,charSpacingPt:m}:{fill:g[0].fill,colorSpans:g,renderMode:c,placeholder:l,walkerFontObjId:u,wordSpacingPt:p,charSpacingPt:m}}function qd(e,t){if(e.length===0||t.length===0)return[];let n=``,r=[];for(let e=0;e<t.length;e++){let i=t[e].text??``;for(let t=0;t<i.length;t++)n+=i[t],r.push(e)}if(n.length===0)return[];let i=Array(e.length),a=0,o=0,s=r[0];for(;a<e.length&&o<n.length;){let t=e[a],c=n[o];t===c?(i[a]=r[o],s=r[o],a++,o++):Jd(c)?o++:Jd(t)?(i[a]=s,a++):(i[a]=r[o],s=r[o],a++,o++)}for(;a<e.length;)i[a]=s,a++;let c=[];for(let n=0;n<e.length;n++){let e=t[i[n]]?.fill??null,r=c[c.length-1];r&&se(r.fill,e)?r.to=n+1:c.push({from:n,to:n+1,fill:e})}return c}function Jd(e){return e===` `||e===` `||e===`
17
+ `||e===`\r`||e===`\xA0`}function Yd(e,t,n){let r=[],i=n.cursor,a=e.str.length,o=0;for(let s=n.cursor;s<t.length;s++){if(n.consumed.has(s)||!Qd(t[s])||!$d(t[s],e))continue;let c=t[s].text??``;if(c.length>a-o||c.length>0&&c.trim()!==``||(r.push(s),o+=c.length,i=s+1,o>=a))break}if(r.length!==0){n.cursor=i;for(let e of r)n.consumed.add(e)}}function Xd(e,t){if(e.length===0)return null;let n=t.trim();if(e.length===1&&n.length>0&&e[0].text!=null&&e[0].text.trim().length===0)return null;if(e.length===1&&e[0].fontObjId)return e[0].fontObjId;if(n.length===0)return e[0].fontObjId||null;for(let t of e){if(!t.fontObjId||!t.text)continue;let e=t.text.replace(/^\s+/,``);if(e===n||e.startsWith(n)||n.startsWith(e)&&e.length>=2)return t.fontObjId}return null}function Zd(e,t){if(!e)return!1;let n=e.trim(),r=t.trim();return n.length===0||r.length===0?!1:n.includes(r)||r.includes(n)}function Qd(e){if(!e)return!1;let t=e.fill;return t?(t.alpha??1)>0:!1}function $d(e,t){if(Math.abs(e.baselineY-t.baselineY)>Vd)return!1;let n=ef(e.text),r,i;return t.dirSignX<0?(r=t.baselineX-t.widthPt-1,i=t.baselineX+1+n):(r=t.baselineX-1-n,i=t.baselineX+t.widthPt+1),!(e.baselineX<r||e.baselineX>i)}function ef(e){if(!e)return 0;let t=0;for(let n of e)if(n===` `||n===` `||n===`\xA0`)t++;else break;return t*5}function tf(e,t){if(Number.isFinite(e?.ascent)&&Number.isFinite(e?.descent))return{ascentRatio:e.ascent,descentRatio:Math.abs(e.descent)};let n=t?._parsed,r=n?.unitsPerEm,i=n?.tables?.hhea,a=i?.ascender,o=i?.descender;return typeof r==`number`&&Number.isFinite(r)&&r>0&&Number.isFinite(a)&&Number.isFinite(o)?{ascentRatio:a/r,descentRatio:Math.abs(o)/r}:{ascentRatio:.8,descentRatio:.2}}function nf(e,t){if(!t)return null;try{if(e.commonObjs.has(t))return e.commonObjs.get(t)}catch{}return null}function rf(e){for(let t of e){let e=t.codePointAt(0);if(e!=null&&(e>=57344&&e<=63743||e>=983040&&e<=1048573||e>=1048576&&e<=1114109))return!0}return!1}const af=.001;async function of(e,t,n){let r=[],i=e.flatMap((e,t)=>{let n=lf(e,t,r);return n?[n]:[]});if(i.length<2)return e;let a=n==null?``:`Page ${n}: `,o=/* @__PURE__ */ new Map,s=sf(o,e=>Kc(e.png));try{return await cf(e,i,s,t,a,n)}catch(r){return t?.emit?.(`IMAGE_TILES_MERGE_FAILED`,{prefix:a,reason:r instanceof Error?r.message:String(r),page:n}),e}finally{for(let e of await Promise.allSettled(o.values()))e.status===`fulfilled`&&e.value.close?.()}}function sf(e,t){return n=>{let r=e.get(n);return r||(r=t(n),e.set(n,r)),r}}async function cf(e,t,n,r,i,a){let o=sf(/* @__PURE__ */ new Map,Ef),s=[],c=/* @__PURE__ */ new Map;for(let[r,i]of t.entries()){let a;for(let l of t.slice(0,r)){let t=c.get(l);if(t===a||t.underlay.includes(i)||l.frame!==i.frame)continue;let r=xf(l.visible,i.visible,1)&&await o(i)&&!await o(l);(r||await Of(l,i,n))&&(a?await Cf(e,a,t,c)?s.splice(s.indexOf(t),1):r||t.underlay.push(i):await Sf(e,t,i)?(t.members.push(i),c.set(i,t),a=t):r||t.underlay.push(i))}if(!a){let e={first:i.index,members:[i],underlay:[]};s.push(e),c.set(i,e)}}let l=/* @__PURE__ */ new Map,u=/* @__PURE__ */ new Set,d=[];for(let e of s){if(e.members.length<2)continue;let t=await Pf(e,n);if(t){l.set(e.first,t),d.push(e);for(let t of e.members)u.add(t.index);r?.emit?.(`IMAGE_TILES_MERGED`,{prefix:i,count:e.members.length,bbox:`${t.x.toFixed(1)}, ${t.y.toFixed(1)}`,bboxSize:`${t.width.toFixed(1)}×${t.height.toFixed(1)}`,page:a})}}if(l.size===0)return e;let f=new Map(t.filter(e=>!u.has(e.index)&&e.block.colorDefinition!=null&&d.some(t=>t.members[0].frame===e.frame&&t.members.some(t=>xf(t.visible,e.visible,1)))).map(e=>[e.index,e]));return e.flatMap((e,t)=>{let n=l.get(t);if(n)return[n];if(u.has(t))return[];let r=f.get(t);return r?[{...r.block,mimeType:`image/png`,bytes:r.png,colorDefinition:void 0,fallbackBytes:void 0}]:[e]})}function lf(e,t,n){if(e.kind!==`image`)return null;let r=e.mimeType===`image/png`?e.bytes:e.fallbackBytes;if(!r||e.patternTile||(e.opacity??1)!==1||e.blendMode!=null&&e.blendMode!==`source-over`)return null;let i=uf(e,n),a=pf(e,i),o=a;for(let t of e.clips??[])o&&=vf(o,mf(t,i));let s=_f(r);return!o||!s||e.width<=0?null:{index:t,block:e,png:r,frame:i,rect:a,visible:o,scale:s.width/e.width}}function uf(e,t){let n=e.rotation??0,r=!!e.flipHorizontal,i=!!e.flipVertical,a=Math.cos(n),o=Math.sin(n),s=r?-1:1,c=i?-1:1,l={rotation:n,flipHorizontal:r,flipVertical:i,a:s*a,b:-c*o,c:s*o,d:c*a};return t.find(e=>Math.abs(e.a-l.a)<af&&Math.abs(e.b-l.b)<af&&Math.abs(e.c-l.c)<af&&Math.abs(e.d-l.d)<af)||(t.push(l),l)}function df(e,t,n){return[e.a*t+e.c*n,e.b*t+e.d*n]}function ff(e,t,n){return[e.a*t+e.b*n,e.c*t+e.d*n]}function pf(e,t){let[n,r]=df(t,e.x+e.width/2,e.y+e.height/2);return{x:n-e.width/2,y:r-e.height/2,width:e.width,height:e.height}}function mf(e,t){if(hf(t))return e;let n=Bd(e.d).map(([n,r])=>df(t,e.x+n,e.y+r));return n.length===0?uu(gf(e).map(([e,n])=>df(t,e,n))):uu(n)}function hf(e){return e.a===1&&e.d===1&&e.b===0&&e.c===0}function gf({x:e,y:t,width:n,height:r}){return[[e,t],[e+n,t],[e+n,t+r],[e,t+r]]}function _f(e){if(e.length<24||e[0]!==137||e[1]!==80)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:t.getUint32(16),height:t.getUint32(20)}}function vf(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width)-n,a=Math.min(e.y+e.height,t.y+t.height)-r;return i>0&&a>0?{x:n,y:r,width:i,height:a}:null}function yf(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function bf(e){let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y));return{x:t,y:n,width:Math.max(...e.map(e=>e.x+e.width))-t,height:Math.max(...e.map(e=>e.y+e.height))-n}}function xf(e,t,n){return e.x<=t.x+t.width+n&&t.x<=e.x+e.width+n&&e.y<=t.y+t.height+n&&t.y<=e.y+e.height+n}async function Sf(e,t,n){let r=new Set(t.members.map(e=>e.index));for(let i=t.first+1;i<n.index;i++){if(r.has(i))continue;let t=e[i];if(xf(wf(t,n.frame),n.visible,0)&&(t.kind!==`image`||t.patternTile||await Df(t,n)))return!1}return!0}async function Cf(e,t,n,r){let[i,a]=t.first<n.first?[t,n]:[n,t],o={...i,members:[...i.members]},s=[...a.members].sort((e,t)=>e.index-t.index);for(let t of s){if(!await Sf(e,o,t))return!1;o.members.push(t)}t.first=i.first,t.members=o.members,t.underlay=[...t.underlay,...n.underlay];for(let e of t.members)r.set(e,t);return!0}function wf(e,t){return uu(Tf(e).map(([e,n])=>df(t,e,n)))}function Tf(e){let t=`rotation`in e?e.rotation??0:0,n=Math.cos(t),r=Math.sin(t),i=e.x+e.width/2,a=e.y+e.height/2;return gf(e).map(([e,t])=>[i+(e-i)*n-(t-a)*r,a+(e-i)*r+(t-a)*n])}async function Ef(e){let{block:t,frame:n,visible:r,scale:i}=e;if(!t.clips?.length||Math.min(t.width,t.height)<2)return!1;let a=Math.max(1,Math.ceil(r.width*i)),o=Math.max(1,Math.ceil(r.height*i)),{canvas:s}=await Wc(a,o),c=s.getContext(`2d`);jf(c,n,i,i,r);let l=kf(e);Nf(c,[l,...t.clips??[]]),c.translate(l.x,l.y),c.fill(qc(l.d));let u=c.getImageData(0,0,a,o).data,d=0;for(let e=3;e<u.length;e+=4)d+=u[e]/255;return d/(i*i)/Math.max(r.width,r.height)<1}async function Df(e,t){let n=vf(wf(e,t.frame),t.visible);if(!n)return!1;let{frame:r,scale:i}=t,a=Math.max(1,Math.ceil(n.width*i)),o=Math.max(1,Math.ceil(n.height*i)),{canvas:s}=await Wc(a,o),c=s.getContext(`2d`);jf(c,r,i,i,n);let l=kf(t);Nf(c,[Af(Tf(e)),...e.clips??[]]),Nf(c,[l,...t.block.clips??[]]),c.translate(l.x,l.y),c.fill(qc(l.d));let u=c.getImageData(0,0,a,o).data;for(let e=3;e<u.length;e+=4)if(u[e]>=128)return!0;return!1}async function Of(e,t,n){let r=[t.rect,yf(e.visible,1),yf(t.visible,1)].reduce((e,t)=>e&&vf(e,t),e.rect);if(!r)return!1;let i=Math.max(e.scale,t.scale),a=Math.ceil(r.width*i),o=Math.ceil(r.height*i),s=async e=>{let{canvas:t}=await Wc(a,o),s=t.getContext(`2d`);return jf(s,e.frame,i,i,r),Mf(s,e,await n(e)),s.getImageData(0,0,a,o).data},c=async e=>{let{canvas:t}=await Wc(a,o),n=t.getContext(`2d`);jf(n,e.frame,i,i,r);let s=e.block.clips?.at(-1)??kf(e);n.translate(s.x,s.y);let c=qc(s.d);return n.fill(c,s.fillRule),n.lineWidth=4/i,n.stroke(c),n.getImageData(0,0,a,o).data},[l,u,d,f]=await Promise.all([s(e),s(t),c(e),c(t)]),p=[];for(let e=0;e<l.length;e+=4)l[e+3]<255||u[e+3]<255||d[e+3]<128||f[e+3]<128||p.push(e);if(p.length<8)return!1;let m=0,h=[0,0,0];for(let e of p)for(let t=0;t<3;t++)m+=Math.abs(l[e+t]-u[e+t]),h[t]+=l[e+t]/p.length;let g=0;for(let e of p)for(let t=0;t<3;t++)g+=Math.abs(l[e+t]-h[t]);return m/(3*p.length)<=12&&g/(3*p.length)>=2}function kf({rect:e,frame:t}){return Af(gf(e).map(([e,n])=>ff(t,e,n)))}function Af(e){let t=uu(e);return{d:`M ${e.map(([e,n])=>`${e-t.x} ${n-t.y}`).join(` L `)} Z`,...t,fillRule:`nonzero`}}function jf(e,t,n,r,i){e.setTransform(n,0,0,r,-i.x*n,-i.y*r),e.transform(t.a,t.b,t.c,t.d,0,0)}function Mf(e,{frame:t,rect:n},r){e.save(),e.transform(t.a,t.c,t.b,t.d,0,0),e.drawImage(r,n.x,n.y,n.width,n.height),e.restore()}function Nf(e,t){for(let n of t)e.translate(n.x,n.y),e.clip(qc(n.d),n.fillRule),e.translate(-n.x,-n.y)}async function Pf(e,t){let{frame:n,block:r}=e.members[0],i=bf(e.members.map(e=>e.visible)),a=Math.max(...e.members.map(e=>e.scale)),o=Math.max(1,Math.round(i.width*a)),s=Math.max(1,Math.round(i.height*a));if(o*s>16777216)return null;let c=o/i.width,l=s/i.height,u=[...e.underlay,...e.members],d=await Promise.all(u.map(t)),f=async()=>{let{canvas:e}=await Wc(o,s),t=e.getContext(`2d`);return jf(t,n,c,l,i),t.imageSmoothingQuality=`high`,{canvas:e,ctx:t}},p=await f();for(let[e,t]of u.entries())p.ctx.save(),Nf(p.ctx,t.block.clips??[]),Mf(p.ctx,t,d[e]),p.ctx.restore();let m=await f();for(let[e,t]of u.entries())Mf(m.ctx,t,d[e]);let h=await f();h.ctx.globalCompositeOperation=`lighter`,h.ctx.lineWidth=1/a;for(let e of u){let t=[kf(e),...e.block.clips??[]],n=t.pop();h.ctx.save(),Nf(h.ctx,t),h.ctx.translate(n.x,n.y);let r=qc(n.d);h.ctx.fill(r,n.fillRule),h.ctx.stroke(r),h.ctx.restore()}let g=h.ctx.getImageData(0,0,o,s).data,_=m.ctx.getImageData(0,0,o,s).data,v=p.ctx.getImageData(0,0,o,s);for(let e=3;e<g.length;e+=4)v.data[e]=Math.round(Math.min(255,g[e])*_[e]/255);p.ctx.setTransform(1,0,0,1,0,0),p.ctx.putImageData(v,0,0);let y=await Gc(p.canvas);if(!y)return null;let[b,x]=ff(n,i.x+i.width/2,i.y+i.height/2);return{kind:`image`,x:b-i.width/2,y:x-i.height/2,width:i.width,height:i.height,mimeType:`image/png`,bytes:y,opacity:1,...r.renderingIntent?{renderingIntent:r.renderingIntent}:{},...n.rotation?{rotation:n.rotation}:{},...n.flipHorizontal?{flipHorizontal:!0}:{},...n.flipVertical?{flipVertical:!0}:{}}}function Ff(e,t){let n=Math.round(e.width*100)/100,r=Math.round(e.height*100)/100;return(e.d===`M 0 ${r} L ${n} ${r} L ${n} 0 L 0 0 Z`||e.d===`M 0 0 L ${n} 0 L ${n} ${r} L 0 ${r} Z`)&&t.x>e.x+.02&&t.y>e.y+.02&&t.x+t.width<e.x+e.width-.02&&t.y+t.height<e.y+e.height-.02}function If(e,t){return e.x+e.width+.02<t.x||t.x+t.width+.02<e.x||e.y+e.height+.02<t.y||t.y+t.height+.02<e.y}function Lf(e){if(e.filter(e=>e.kind===`vector-path`).length<1e3)return e;let t=[],n=[],r,i=()=>{if(n.length===1&&t.push({...n[0],clips:void 0}),n.length>1){let e=Math.min(...n.map(e=>e.x)),r=Math.min(...n.map(e=>e.y));t.push({...n[0],clips:void 0,x:e,y:r,width:Math.max(...n.map(e=>e.x+e.width))-e,height:Math.max(...n.map(e=>e.y+e.height))-r,d:n.map(t=>{let n=0;return t.d.replace(/-?\d+(?:\.\d+)?(?:e[+-]?\d+)?/gi,i=>{let a=n++%2==0?t.x-e:t.y-r;return String(Math.round((Number(i)+a)*100)/100)})}).join(` `)})}n=[]};for(let a of e){if(a.kind!==`vector-path`||!a.fill||!(`space`in a.fill)||a.stroke||(a.opacity??1)!==1||(a.fill.alpha??1)!==1||a.blendMode!=null&&a.blendMode!==`source-over`){i(),t.push(a);continue}if(a.clips?.some(e=>If(a,e)))continue;if(a.clips?.some(e=>!Ff(e,a))){i(),t.push(a);continue}let e=JSON.stringify([a.fill.space,a.fill.values,a.fill.overprint===!0,a.fillRule,a.clips??[]]);r===e&&n.length!==256&&n.every(e=>If(a,e))||i(),r=e,n.push(a)}return i(),t}const Rf=e=>typeof e==`string`?e:null;async function zf(e,t){let n;try{({selected:n}=await e.getOutputIntents())}catch(e){t?.emit?.(`OUTPUT_INTENT_UNREADABLE`,{error:e instanceof Error?e.message:String(e)});return}if(typeof n!=`object`||!n)return;let r=n;return{subtype:Rf(r.subtype)??``,outputConditionIdentifier:Rf(r.outputConditionIdentifier),outputCondition:Rf(r.outputCondition),registryName:Rf(r.registryName),info:Rf(r.info),profile:r.profile instanceof Uint8Array?r.profile:null}}async function Bf(){let e=new URL(`./pdf.worker.mjs`,require("url").pathToFileURL(__filename).href);return(0,f.existsSync)(e)?e.href:(0,m.pathToFileURL)((0,h.createRequire)(require("url").pathToFileURL(__filename).href).resolve(`@imgly/pdfjs-dist/legacy/build/pdf.worker.mjs`)).href}async function Vf(){let e=new URL(`./standard_fonts/FoxitFixed.pfb`,require("url").pathToFileURL(__filename).href),t=new URL(`./standard_fonts/`,require("url").pathToFileURL(__filename).href);if((0,f.existsSync)(e))return(0,m.fileURLToPath)(t);let n=(0,h.createRequire)(require("url").pathToFileURL(__filename).href).resolve(`@imgly/pdfjs-dist/standard_fonts/FoxitFixed.pfb`);return(0,p.dirname)(n)+p.sep}async function Hf(){return{standardFontDataUrl:await Vf()}}const Uf=/\bg_d\d+_/g;function Wf(e){let t=e?.emit?.bind(e);return t?{emit:(e,n)=>t(e,Object.fromEntries(Object.entries(n).map(([e,t])=>[e,typeof t==`string`?t.replace(Uf,``):t])))}:e}function Gf(e){let t=e?.imglyPatchVersion??null;if(t!==4)throw Error(`[@imgly/pdf-importer] @imgly/pdfjs-dist patch missing or outdated (got ${t??`none`}, expected 4). The patched APIs (trimBox, bleedBox, colorSpaceResources, native CMYK args, output intents) are required for correct color and geometry import. Install @imgly/pdfjs-dist 4.10.38-imgly.4 with the repository patch in patches/.`)}async function Kf(e,t={}){let n=t.pdfjsModule??await Promise.resolve().then(()=>(Uc(),ce));n.GlobalWorkerOptions.workerSrc=t.workerSrc??await Bf();let r=t.standardFontDataUrl?{standardFontDataUrl:t.standardFontDataUrl}:await Hf(),i=t.textMode??`outline`,a=e instanceof Uint8Array?e:(()=>{let t=e;return new Uint8Array(t.buffer??e,t.byteOffset??0,t.byteLength??t.length)})(),o=await n.getDocument({data:a,password:t.password,disableFontFace:!0,useSystemFonts:!1,isEvalSupported:!1,fontExtraProperties:!0,exposeRawImageData:!0,...r}).promise,s=/* @__PURE__ */ new Map,c=Wf(t.logger),l=[];for(let e=1;e<=o.numPages;e++){let n=await o.getPage(e);e===1&&Gf(n),l.push(await qf(n,{textMode:i,preserveWhitePageBackground:t.preserveWhitePageBackground,docFonts:s,logger:c,pageIndex:e})),n.cleanup()}let u=await zf(o,t.logger);return await o.destroy(),{source:t.source??`unknown`,pages:l,fonts:s,outputIntent:u}}async function qf(e,t){let n=e.trimBox,r=e.bleedBox,i=e.view??[0,0,0,0],a=i[2]-i[0],o=i[3]-i[1],s={widthPt:a,heightPt:o,originShiftPt:{x:i[0],y:i[1]}},c=null,l={left:0,top:0,right:0,bottom:0},u=!1;n&&(c={xPt:n[0]-i[0],yPt:i[3]-n[3],widthPt:n[2]-n[0],heightPt:n[3]-n[1]},r&&(l={left:Math.max(0,n[0]-r[0]),bottom:Math.max(0,n[1]-r[1]),right:Math.max(0,r[2]-n[2]),top:Math.max(0,r[3]-n[3])},u=!0));let{colorSnapshots:d,renderingIntents:f,pathSpotColors:p,finalize:m}=await Qu(e,s,t),h=t.textMode===`outline`?[]:await Ud(e,{pageBox:s,docFonts:t.docFonts,colorSnapshots:d,logger:t.logger,pageIndex:t.pageIndex,page:e}),g=m();h.length>0&&g.push(...h);let _=e.rotate??0;if(_!==0){let e=t.pageIndex==null?``:`Page ${t.pageIndex}: `;t.logger?.emit?.(`DOC_PAGE_ROTATION_DROPPED`,{prefix:e,pageRotation:_,page:t.pageIndex})}return{widthPt:a,heightPt:o,rotation:_,trimPt:c,bleedPt:l,hasBleed:u,blocks:Lf(await of(g,t.logger,t.pageIndex)),renderingIntents:f,pathSpotColors:p}}const Jf=/* @__PURE__ */ new WeakMap;function Yf(e,t){Jf.set(e,Xf(t))}function Xf(e){return Jf.get(e)??e}const Zf=/* @__PURE__ */ new WeakMap;function Qf(e,t,n,r){let i=e.block;if(typeof i.setTypeface==`function`&&i.setTypeface(t,n),typeof i.setTextFontStyle==`function`&&typeof i.setTextFontWeight==`function`&&(r?.style||r?.weight))try{I(e,t,{weight:r.weight||void 0,style:r.style||void 0})}catch{}let a=r?.uri,o=e.editor;a&&typeof o?.getFontMetrics==`function`&&o.getFontMetrics(a).catch(()=>{})}function $f(e,t){let n=Xf(e),r=Zf.get(n);r||(r=/* @__PURE__ */ new Map,Zf.set(n,r));let i=r.get(t.postScriptName);if(i)try{return n.editor.getBufferLength(i.uri),i}catch{}let a=e.editor.createBuffer(),o=t.data instanceof Uint8Array?t.data:new Uint8Array(t.data);e.editor.setBufferData(a,0,o);let s={uri:a,typeface:{name:i?`${t.postScriptName}#${a}`:t.postScriptName,fonts:[{uri:a,subFamily:t.family,weight:Nl(t.weight),style:t.style??`normal`}]}};return r.set(t.postScriptName,s),s}function ep(e,t){return[...Zf.get(Xf(e))?.values()??[]].some(e=>e.uri===t)}function tp(e,t,n){let{uri:r,typeface:i}=$f(e,n);typeof e.block.setFont==`function`&&e.block.setFont(t,r,i)}const np=/* @__PURE__ */ new WeakSet;function rp(e){np.add(e)}function ip(e,t){let n=e.scene;return{designUnit:e.block.getEnum(t,`scene/designUnit`),fontSizeUnit:n.getFontSizeUnit===void 0?`Point`:e.block.getEnum(t,`scene/fontSizeUnit`),angleUnit:n.getAngleUnit===void 0?`Radian`:e.block.getEnum(t,`scene/angleUnit`),dpi:e.block.getFloat(t,`scene/dpi`)}}const ap=/* @__PURE__ */ new WeakMap;function op(e,t){return ap.set(e,t),()=>{ap.get(e)===t&&ap.delete(e)}}function sp(e){let t=ap.get(e);if(t!==void 0)return t;let n=e.scene.get();return n===null?null:ip(e,n)}function $(e,t){if(np.has(e))return t/72;let n=sp(e);if(n===null)return t/72;switch(n.designUnit){case`Inch`:return t/72;case`Millimeter`:return t*25.4/72;case`Pixel`:return t*n.dpi/72}}function cp(e,t){if(np.has(e))return t;let n=sp(e);return n?.fontSizeUnit===`Pixel`?t*n.dpi/72:t}function lp(e,t){return sp(e)?.angleUnit===`Degree`?t*180/Math.PI:t}function up(e,t){return sp(e)?.angleUnit===`Degree`?t*Math.PI/180:t}const dp=Object.freeze({"source-over":null,normal:null,multiply:`Multiply`,screen:`Screen`,overlay:`Overlay`,darken:`Darken`,lighten:`Lighten`,"color-dodge":`ColorDodge`,"color-burn":`ColorBurn`,"hard-light":`HardLight`,"soft-light":`SoftLight`,difference:`Difference`,exclusion:`Exclusion`,hue:`Hue`,saturation:`Saturation`,color:`Color`,luminosity:`Luminosity`});function fp(e,t){return e==null||e===``?null:Object.prototype.hasOwnProperty.call(dp,e)?dp[e]:(t?.emit?.(`BLEND_MODE_UNSUPPORTED`,{mode:e}),null)}function pp(e,t){return e.replace(/-?\d*\.?\d+(?:[eE][-+]?\d+)?/g,e=>{let n=parseFloat(e)*t;return Number(n.toPrecision(9)).toString()})}function mp(e,t,n,r){let i=e.block.createShape(`vector_path`);e.block.setString(i,`vector_path/path`,pp(t,$(e,1)));try{e.block.setFloat(i,`vector_path/width`,$(e,n)),e.block.setFloat(i,`vector_path/height`,$(e,r))}catch{}return i}const hp=()=>({state:`unknown`,warned:!1}),gp=`shape/vector_path/fillRule`,_p=e=>e===`nonzero`?`NonZero`:`EvenOdd`;function vp(e,t,n){if(n.state===`unknown`){let r=!1;try{r=e.block.findAllProperties(t).includes(gp)}catch{r=!1}n.state=r?`supported`:`unsupported`}return n.state===`supported`}function yp(e,t){if(t.state!==`unknown`)return t.state===`supported`;let n=e.block.createShape(`vector_path`);try{return vp(e,n,t)}finally{e.block.destroy(n)}}function bp(e,t,n,r){if(n==null||n===`evenodd`)return!0;if(!vp(e,t,r.support))return r.support.warned||(r.support.warned=!0,r.logger?.emit?.(`VECTOR_PATH_FILL_RULE_UNSUPPORTED`,{property:gp,sinceVersion:`1.75.0`})),!1;try{return e.block.setEnum(t,gp,_p(n)),!0}catch{return!1}}const xp=Symbol(`COMBINE_EMPTY_INTERSECTION`);function Sp(e,t,n){if(!Array.isArray(t)||t.length<2)return n?.logger?.emit?.(`CLIP_COMBINE_TOO_FEW_INPUTS`,{prefix:wp(n),inputCount:t?.length??0,label:n?.label??null}),null;if(n?.flush?.(),!e.block.isCombinable(t))return n?.logger?.emit?.(`CLIP_COMBINE_NOT_COMBINABLE`,{prefix:wp(n),inputCount:t.length,label:n?.label??null}),null;try{return e.block.combine(t,`Intersection`)}catch(e){let r=e&&typeof e==`object`&&`message`in e?String(e.message):String(e);return Cp(r)?xp:(n?.logger?.emit?.(`CLIP_COMBINE_THREW`,{prefix:wp(n),inputCount:t.length,reason:r,label:n?.label??null}),null)}}function Cp(e){return typeof e==`string`&&e.includes(`empty shape`)}function wp(e){return e?.label?`${e.label}: `:``}function Tp(e,t){for(let n of t)try{e.block.isValid?.(n)!==!1&&e.block.destroy(n)}catch{}}const Ep=Object.freeze({scaleX:1,scaleY:1,translationX:0,translationY:0});function Dp(e,t){return!(t.width>0)||!(t.height>0)?Ep:{scaleX:e.width/t.width,scaleY:e.height/t.height,translationX:(e.x-t.x)/t.width,translationY:(e.y-t.y)/t.height}}function Op(e,t){if(!t)return e;let n=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t)),i=e.width*n+e.height*r,a=e.width*r+e.height*n;return{x:e.x+(e.width-i)/2,y:e.y+(e.height-a)/2,width:i,height:a}}function kp(e,t,n){let r=Math.cos(t??0),i=Math.sin(t??0),a=e.width/2,o=e.height/2,s=n.width/2,c=n.height/2,l=n.x+s-(e.x+a),u=n.y+c-(e.y+o),d=Math.abs(r),f=Math.abs(i);return Math.abs(l)<a*d+o*f+s&&Math.abs(u)<a*f+o*d+c&&Math.abs(l*r+u*i)<a+s*d+c*f&&Math.abs(-l*i+u*r)<o+s*f+c*d}function Ap(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return{x:n,y:r,width:i-n,height:a-r}}function jp(e){let t=(e.strokeWidth??0)/2,n=(e.strokeJoin??`Miter`)===`Miter`?Math.max(e.strokeMiterLimit??10,1):1,r=e.strokeCap===`Square`?Math.SQRT2:1,i=t*Math.max(n,r);return{x:e.x-i,y:e.y-i,width:e.width+2*i,height:e.height+2*i}}function Mp(e){let t=e.strokeWidth??0;if(e.fill||!e.stroke||!(t>0)||e.strokeDashArray?.length)return null;let n=e.d.trim().split(/\s+/),r=[],i=!1;for(let e=0;e<n.length;){let t=n[e++];if(t===`Z`&&e===n.length){i=!0;break}if(t!==(r.length===0?`M`:`L`))return null;let a=Number(n[e++]),o=Number(n[e++]);if(!Number.isFinite(a)||!Number.isFinite(o))return null;r.push([a,o])}if(r.length>2&&((e,t)=>e[0]===t[0]&&e[1]===t[1])(r[0],r[r.length-1])){if(!i&&e.strokeCap!==`Square`)return null;i=!0,r.pop()}let a=r.map(([e])=>e),o=r.map(([,e])=>e),s=Math.min(...a),c=Math.min(...o),l=Math.max(...a),u=Math.max(...o),d=t/2,f=``;if(r.length===2&&!i){if(e.strokeCap===`Round`)return null;let t=c===u,n=s===l;if(t===n)return null;let r=e.strokeCap===`Square`?d:0;s-=t?r:d,l+=t?r:d,c-=n?r:d,u+=n?r:d}else if(r.length===4&&i){if(e.strokeJoin!==`Miter`||(e.strokeMiterLimit??0)<Math.SQRT2||new Set(r.map(e=>e.join(`,`))).size!==4)return null;for(let e=0;e<r.length;e++){let t=r[e],n=r[(e+1)%r.length];if(t[0]===n[0]==(t[1]===n[1]))return null}let n=l-s-t,i=u-c-t;if(s-=d,c-=d,l+=d,u+=d,n>0&&i>0){let e=t,r=t;f=` M ${e} ${r} L ${e} ${r+i} L ${e+n} ${r+i} L ${e+n} ${r} Z`}}else return null;let p=l-s,m=u-c;return{...e,x:e.x+s,y:e.y+c,width:p,height:m,d:`M 0 0 L ${p} 0 L ${p} ${m} L 0 ${m} Z${f}`,fill:e.strokeGradient??e.stroke,strokeGradient:void 0,stroke:null,fillRule:`evenodd`}}const Np=.01,Pp=2e5;function Fp(e){return Mp(e)??Ip(e)}function Ip(e){let t=e.strokeWidth??0;if(e.fill||!e.stroke||!(t>0))return null;let n=Lp(e.d);if(n==null)return null;let r=t/2,i=e.strokeDashArray?.filter(e=>e>=0)??[],a=i.length>0&&i.some(e=>e>0);if(a&&Bp(n,i)>2e4)return null;let o=a?n.flatMap(t=>Vp(t,i,e.strokeDashOffset??0)):n,s={half:r,cap:e.strokeCap??`Butt`,join:e.strokeJoin??`Miter`,miterLimit:e.strokeMiterLimit??10,arcStep:2*Math.acos(Math.max(0,1-Np/r))||Math.PI/2},c=[],l=0;for(let e of o){let t=Yp(e,s);if(l+=t?.reduce((e,t)=>e+t.length,0)??1/0,l>Pp)return null;c.push(...t)}if(c.length===0)return null;let u=1/0,d=1/0,f=-1/0,p=-1/0;for(let e of c)for(let[t,n]of e)u=Math.min(u,t),d=Math.min(d,n),f=Math.max(f,t),p=Math.max(p,n);let m=e=>`${Math.round(e*1e4)/1e4}`,h=c.map(e=>e.map(([e,t],n)=>`${n?`L`:`M`} ${m(e-u)} ${m(t-d)}`).join(` `)+` Z`).join(` `);return{...e,x:e.x+u,y:e.y+d,width:f-u,height:p-d,d:h,fill:e.strokeGradient??e.stroke,strokeGradient:void 0,stroke:null,fillRule:`nonzero`}}function Lp(e){let t=e.trim().split(/[\s,]+/).filter(Boolean),n=[],r=/* @__PURE__ */ new Set,i=null,a=[0,0],o=[0,0],s=e=>Number(t[e]),c=0;for(let e=0;e<t.length;){if(c>Pp)return null;let l=t[e++];if(l===`M`)o=a=[s(e),s(e+1)],e+=2,i={points:[o],closed:!1},n.push(i);else if(l===`L`&&i)o=[s(e),s(e+1)],e+=2,i.points.push(o),r.add(i),c+=1;else if(l===`C`&&i){let t=[s(e),s(e+1)],n=[s(e+2),s(e+3)],a=[s(e+4),s(e+5)];e+=6;let l=Rp(o,t,n,a);i.points.push(...l),r.add(i),o=a,c+=l.length}else if(l===`Z`&&i)i.closed=!0,r.add(i),o=a,i={points:[o],closed:!1},n.push(i);else return null;if(!Number.isFinite(o[0])||!Number.isFinite(o[1]))return null}return n.filter(e=>r.has(e)).map(e=>({...e,points:zp(e.points,e.closed)}))}function Rp(e,t,n,r){let i=Math.max(Math.hypot(e[0]-2*t[0]+n[0],e[1]-2*t[1]+n[1]),Math.hypot(t[0]-2*n[0]+r[0],t[1]-2*n[1]+r[1])),a=Math.min(256,Math.max(1,Math.ceil(Math.sqrt(.75*i/Np)))),o=[];for(let i=1;i<=a;i++){let s=i/a,c=1-s,l=c*c*c,u=3*c*c*s,d=3*c*s*s,f=s*s*s;o.push([l*e[0]+u*t[0]+d*n[0]+f*r[0],l*e[1]+u*t[1]+d*n[1]+f*r[1]])}return o}function zp(e,t){let n=e.filter((t,n)=>n===0||t[0]!==e[n-1][0]||t[1]!==e[n-1][1]);if(t&&n.length>1){let[e,t]=[n[0],n[n.length-1]];e[0]===t[0]&&e[1]===t[1]&&n.pop()}return n}function Bp(e,t){let n=t.reduce((e,t)=>e+t,0),r=0;for(let{points:t,closed:n}of e){let e=n?[...t,t[0]]:t;for(let t=1;t<e.length;t++)r+=Math.hypot(e[t][0]-e[t-1][0],e[t][1]-e[t-1][1])}return r/n*Math.ceil(t.length/2)+e.length}function Vp(e,t,n){if(e.points.length<2)return[e];let r=t.length%2?[...t,...t]:t,i=r.reduce((e,t)=>e+t,0),a=e.closed?[...e.points,e.points[0]]:e.points,o=0,s=r[0],c=!0,l=(n%i+i)%i;for(;l>0;)l>=s?(l-=s,o=(o+1)%r.length,s=r[o],c=!c):(s-=l,l=0);let u=[],d=c?[a[0]]:null,f=(e,t)=>{for(;s===0;)c&&u.push({points:d??[e],closed:!1,dir:t}),d=c?null:[e],o=(o+1)%r.length,s=r[o],c=!c};f(a[0],Gp(Hp(a[1],a[0])));for(let e=1;e<a.length;e++){let t=a[e-1],n=a[e],r=Math.hypot(n[0]-t[0],n[1]-t[1]),i=Gp(Hp(n,t));for(;r>0;){let e=Math.min(s,r),a=e/r,o=[t[0]+(n[0]-t[0])*a,t[1]+(n[1]-t[1])*a];c&&d?.push(o),s-=e,r-=e,t=o,f(o,i)}}return c&&d&&u.push({points:d,closed:!1}),u.map(e=>({...e,points:zp(e.points,!1)}))}const Hp=(e,t)=>[e[0]-t[0],e[1]-t[1]],Up=(e,t)=>[e[0]+t[0],e[1]+t[1]],Wp=(e,t)=>[e[0]*t,e[1]*t],Gp=e=>Wp(e,1/Math.hypot(e[0],e[1])),Kp=e=>[e[1],-e[0]],qp=(e,t)=>e[0]*t[1]-e[1]*t[0];function Jp(e){let t=0;for(let n=0;n<e.length;n++)t+=qp(e[n],e[(n+1)%e.length]);return t/2}function Yp(e,t){let{half:n}=t,r=e.points;if(r.length===1){let[i]=r;if(t.cap===`Round`)return[Qp(i,[n,0],2*Math.PI,t)];if(t.cap===`Square`&&e.dir){let t=Wp(e.dir,n),r=Wp(Kp(e.dir),n);return[[Hp(Hp(i,t),r),Hp(Up(i,t),r),Up(Up(i,t),r),Up(Hp(i,t),r)]]}return[]}if(e.closed){Jp(r)<0&&(r=[...r].reverse());let e=r.length,n=r.map((t,n)=>Gp(Hp(r[(n+1)%e],t))),i=i=>{let a=[];for(let o=0;o<e&&a.length<=Pp;o++)Xp(a,r[o],n[(o+e-1)%e],n[o],i,t);return a},a=i(1);return a.length>Pp?null:[a,i(-1).reverse()]}let i=r.length,a=r.slice(1).map((e,t)=>Gp(Hp(e,r[t]))),o=[];Zp(o,r[0],Wp(a[0],-1),t);for(let e=1;e<i-1&&o.length<=Pp;e++)Xp(o,r[e],a[e-1],a[e],1,t);Zp(o,r[i-1],a[i-2],t);for(let e=i-2;e>=1&&o.length<=Pp;e--)Xp(o,r[e],Wp(a[e],-1),Wp(a[e-1],-1),1,t);return[o]}function Xp(e,t,n,r,i,a){let o=Wp(Kp(n),i*a.half),s=Wp(Kp(r),i*a.half),c=qp(n,r)*i,l=Up(t,o),u=Up(t,s),d=Math.max(-1,Math.min(1,n[0]*r[0]+n[1]*r[1])),f=Math.sqrt((1+d)/2);if(f>1e-9&&a.half*(1/f-f)<=Np){let n=Up(o,s);e.push(Math.hypot(n[0],n[1])>0?Up(t,Wp(Gp(n),a.half/f)):l)}else if(c<0)e.push(l,t,u);else{if(e.push(l),a.join===`Round`){let s=(Math.sign(qp(n,r))||i)*Math.acos(d);e.push(...Qp(t,o,s,a).slice(1,-1))}else if(a.join===`Miter`){let n=Math.sqrt((1+d)/2);if(n>1e-9&&1/n<=a.miterLimit){let r=Gp(Up(o,s));e.push(Up(t,Wp(r,a.half/n)))}}e.push(u)}}function Zp(e,t,n,r){let{half:i}=r,a=Wp(Kp(n),i),o=Wp(a,-1);if(r.cap===`Round`)e.push(...Qp(t,a,Math.PI,r));else if(r.cap===`Square`){let r=Wp(n,i);e.push(Up(t,a),Up(Up(t,a),r),Up(Up(t,o),r),Up(t,o))}else e.push(Up(t,a),Up(t,o))}function Qp(e,t,n,r){let i=Math.min(Math.ceil(64*Math.abs(n)/Math.PI),Math.max(2,Math.ceil(Math.abs(n)/r.arcStep))),a=[],o=Math.abs(Math.abs(n)-2*Math.PI)<1e-9;for(let r=0;r<=(o?i-1:i);r++){let o=n*r/i,s=Math.cos(o),c=Math.sin(o);a.push([e[0]+t[0]*s-t[1]*c,e[1]+t[0]*c+t[1]*s])}return a}const $p=()=>({remainingBytes:536870912,reported:!1,definedFills:/* @__PURE__ */ new Map});function em(e,t,n){if(!n.mask&&!n.colorKeyMask)return!0;let r=e.unstable_getImportedImageDefinition?.(t);return(!n.mask||r?.mask?.kind===n.mask.kind)&&(!n.colorKeyMask||r?.colorKeyMask?.length===n.colorKeyMask.length)}const tm=/* @__PURE__ */ new WeakMap,nm=/* @__PURE__ */ new WeakMap;function rm(e){let t=Xf(e),n=nm.get(t);return n||(n=/* @__PURE__ */ new WeakMap,nm.set(t,n)),n}function im(e,t,n){if(t.colorDefinition==null||!(t.bytes instanceof Uint8Array))return null;let r=n?.profileBudget?.definedFills.get(t.bytes);return r==null||!e.block.isValid(r)?null:e.block.duplicate(r)}const am=/* @__PURE__ */ new WeakMap;function om(e){let t=Xf(e),n=am.get(t);return n||(n=/* @__PURE__ */ new WeakMap,am.set(t,n)),n}function sm(e,t){return om(e).get(t)===!0}function cm(e,t){let n=t instanceof Uint8Array?t:null,r=Xf(e),i=tm.get(r);i||(i=/* @__PURE__ */ new WeakMap,tm.set(r,i));let a=n==null?void 0:i.get(n);if(a!=null)try{r.editor.getBufferLength(a)}catch{a=void 0}return a??(a=e.editor.createBuffer(),e.editor.setBufferData(a,0,t instanceof Uint8Array?t:new Uint8Array(t)),n!=null&&i.set(n,a)),a}function lm(e,t){let n=t?.profileBudget,r=e.iccProfile?.length??0;return n==null||r===0?!0:r>n.remainingBytes?(n.remainingBytes=0,n.reported||(n.reported=!0,t?.logger?.emit?.(`IMAGE_PROFILE_BUDGET_EXCEEDED`,{prefix:t.pageIndex==null?``:`Page ${t.pageIndex}: `})),!1):(n.remainingBytes-=r,!0)}function um(e,t,n,r){if(!n?.bytes||n.bytes.length===0)return r?.logger?.emit?.(`IMAGE_NO_PIXELS`,{}),!1;let i=im(e,n,r);if(i!=null)return om(e).set(n,!1),e.block.setFill(t,i),!0;let a=e.block.createFill(`image`),o=e.block,s=rm(e),c=n.colorDefinition!=null&&n.fallbackBytes!=null&&n.bytes instanceof Uint8Array&&o.unstable_setImportedImageDefinition!==void 0&&s.get(n.bytes)!==!1&&lm(n.colorDefinition,r),l=cm(e,n.colorDefinition!=null&&!c?n.fallbackBytes??n.bytes:n.bytes);e.block.setString(a,`fill/image/imageFileURI`,l);let u=!c;if(c){let t=n.bytes,i=!s.has(t),c=!1,d;try{o.unstable_setImportedImageDefinition(a,n.colorDefinition),c=em(o,a,n.colorDefinition)}catch(e){d=e}c?(s.set(t,!0),r?.profileBudget?.definedFills.set(t,a)):(u=!0,s.set(t,!1),d!==void 0&&r?.logger?.emit?.(`IMAGE_DEFINITION_FALLBACK`,{prefix:r.pageIndex==null?``:`Page ${r.pageIndex}: `,bbox:$l(n),page:r.pageIndex,error:d instanceof Error?d.message:String(d)}),e.block.setString(a,`fill/image/imageFileURI`,cm(e,n.fallbackBytes)),i&&(tm.get(Xf(e))?.delete(t),e.editor.destroyBuffer(l)))}return om(e).set(n,u),e.block.setFill(t,a),!0}function dm(e,t,n,r){pm(e,t,n,r),mm(e,t,n,r)}function fm(e,t){e.block.getGlobalBoundingBoxX(t)}function pm(e,t,n,r){try{if(n.patternTile){e.block.setContentFillMode(t,`Cover`);return}let r=Dp({x:$(e,n.x),y:$(e,n.y),width:$(e,n.width),height:$(e,n.height)},hm(e,t));e.block.setContentFillMode(t,`Crop`),e.block.setCropScaleX(t,r.scaleX),e.block.setCropScaleY(t,r.scaleY),e.block.setCropTranslationX(t,r.translationX),e.block.setCropTranslationY(t,r.translationY)}catch{r?.logger?.emit?.(`IMAGE_PLACEMENT_UNSUPPORTED`,{})}}function mm(e,t,n,r){if(n?.flipHorizontal||n?.flipVertical)try{n.flipHorizontal&&e.block.flipCropHorizontal(t),n.flipVertical&&e.block.flipCropVertical(t)}catch{r?.logger?.emit?.(`IMAGE_FLIP_UNSUPPORTED`,{})}}function hm(e,t){let n=e.block.getWidth(t),r=e.block.getHeight(t),i=up(e,e.block.getRotation(t)),a=Math.cos(i),o=Math.sin(i),s=e.block.getPositionX(t)+(n*a-r*o)/2,c=e.block.getPositionY(t)+(n*o+r*a)/2;return{x:s-n/2,y:c-r/2,width:n,height:r}}const gm=Symbol(`EMITTED_DROPPED`);function _m(e,t,n,r,i){if(!t?.bytes||t.bytes.length===0)return i?.logger?.emit?.(`IMAGE_CLIPPED_NO_BYTES`,{prefix:Ym(i),bbox:$l(t),page:i?.pageIndex}),null;let a=e=>kp(t,t.rotation,e),o=n.filter(e=>qm(e)),s=n.filter(e=>!qm(e)&&!a(e)),c=n.filter(e=>!qm(e)&&a(e));if(c.length===0||s.length>0)return s.length>0?i?.logger?.emit?.(`IMAGE_CLIPPED_TO_EMPTY`,{prefix:Ym(i),bbox:$l(t),clipCount:n.length,degenerateCount:o.length,disjointCount:s.length,page:i?.pageIndex}):i?.logger?.emit?.(`IMAGE_CLIP_UNUSABLE`,{prefix:Ym(i),bbox:$l(t),clipCount:n.length,degenerateCount:o.length,disjointCount:s.length,page:i?.pageIndex}),gm;let l=vm(c,Op(t,t.rotation));return l.length===1?Tm(e,t,l[0],i):Dm(e,t,l,r,i)}function vm(e,t){let n=[],r=/* @__PURE__ */ new Set;for(let i of e)ym(i,t)||r.has(i.d)||(r.add(i.d),n.push(i));return n.length>0?n:[e[0]]}function ym(e,t){if(!bm(e.d))return!1;let n=.001;return e.x<=t.x+n&&e.y<=t.y+n&&e.x+e.width+n>=t.x+t.width&&e.y+e.height+n>=t.y+t.height}function bm(e){if(typeof e!=`string`)return!1;let t=e.trim().split(/\s+/),n=t.pop();if(n!==`Z`&&n!==`z`||t.length!==12&&t.length!==15)return!1;let r=[],i=[];for(let e=0;e<t.length;e+=3){if(t[e]!==(e===0?`M`:`L`))return!1;let n=Number(t[e+1]),a=Number(t[e+2]);if(!Number.isFinite(n)||!Number.isFinite(a))return!1;r.push(n),i.push(a)}let a=.001;if(r.length===5&&(Math.abs(r[4]-r[0])>a||Math.abs(i[4]-i[0])>a))return!1;for(let e=0;e<4;e++){let t=(e+1)%4;if(Math.abs(r[e]-r[t])<=a==Math.abs(i[e]-i[t])<=a)return!1;let n=(e+2)%4;if(Math.abs(r[e]-r[n])<=a&&Math.abs(i[e]-i[n])<=a)return!1}let o=e=>{let t=[];for(let n of e)t.some(e=>Math.abs(e-n)<=a)||t.push(n);return t};return o(r).length===2&&o(i).length===2}function xm(e,t,n,r,i){let a=n.filter(e=>qm(e)),o=n.filter(e=>!qm(e));if(o.length===0)return i?.logger?.emit?.(`CLIP_DEGENERATE_FALLBACK`,{prefix:Ym(i),bbox:$l(t),clipCount:n.length,degenerateCount:a.length,page:i?.pageIndex}),null;let s=jp(t);if(s.width>0&&s.height>0&&o.some(e=>!Jm(e,s)))return gm;let c=t.fill?t:i?.strokeOutline===void 0?Fp(t):i.strokeOutline,l=()=>(i?.logger?.emit?.(`CLIP_COMBINE_STROKE_ONLY`,{prefix:Ym(i),bbox:$l(t),clipCount:n.length,page:i?.pageIndex}),null);if(!c)return l();let u={support:i?.vectorPathFillRuleSupport??hp(),logger:i?.logger},d=Vm(e,c.d,{x:c.x,y:c.y,width:c.width,height:c.height},c.fill,c.opacity),f=bp(e,zm(e,d),c.fillRule,u);if(c!==t&&!f)return Tp(e,[d]),l();e.block.appendChild(r,d);let p=[];for(let t of o){let n=Bm(e,t);bp(e,zm(e,n),t.fillRule,u),e.block.appendChild(r,n),p.push(n)}let m=Sp(e,[d,...p],{logger:i?.logger,label:`${Ym(i)}vector path at ${$l(t)}`,flush:i?.flush});return m===xp?(Tp(e,[d,...p]),gm):m==null?(Tp(e,[d,...p]),null):(Sm(e,m,c),c.opacity!=null&&c.opacity!==1&&e.block.setOpacity(m,c.opacity),wm(e,m,c.blendMode,i?.logger),m)}function Sm(e,t,n){let r=n.fill,i=r?.kind;if(i===`linearGradient`||i===`radialGradient`){Cm(e,t,n);return}let a=e.block.createFill(`color`);e.block.setColor(a,`fill/color/value`,Xm(r)),e.block.setFill(t,a)}function Cm(e,t,n){let r=n.fill,i=r.kind===`linearGradient`?`gradient/linear`:`gradient/radial`,a=e.block.createFill(i),o=(r.stops??[]).map(e=>({color:Xm(e.color),stop:e.offset}));e.block.setGradientColorStops(a,`fill/gradient/colors`,o);let s=n.width>0?n.width:1,c=n.height>0?n.height:1;if(r.kind===`linearGradient`)e.block.setFloat(a,`fill/gradient/linear/startPointX`,(r.start.x-n.x)/s),e.block.setFloat(a,`fill/gradient/linear/startPointY`,(r.start.y-n.y)/c),e.block.setFloat(a,`fill/gradient/linear/endPointX`,(r.end.x-n.x)/s),e.block.setFloat(a,`fill/gradient/linear/endPointY`,(r.end.y-n.y)/c);else{let t=Math.max(.001,Math.min(s,c));e.block.setFloat(a,`fill/gradient/radial/centerPointX`,(r.center.x-n.x)/s),e.block.setFloat(a,`fill/gradient/radial/centerPointY`,(r.center.y-n.y)/c),e.block.setFloat(a,`fill/gradient/radial/radius`,r.radius/t)}e.block.setFill(t,a)}function wm(e,t,n,r){let i=fp(n,r);i!=null&&(typeof e.block.supportsBlendMode!=`function`||e.block.supportsBlendMode(t))&&e.block.setBlendMode(t,i)}function Tm(e,t,n,r){let i=e.block.create(`graphic`),a=!t.rotation&&!t.patternTile&&bm(n.d)?{...t,x:Math.max(t.x,n.x),y:Math.max(t.y,n.y),width:Math.min(t.x+t.width,n.x+n.width)-Math.max(t.x,n.x),height:Math.min(t.y+t.height,n.y+n.height)-Math.max(t.y,n.y)}:t,o=mp(e,a===t?Wm(n,t):`M 0 0 L ${a.width} 0 L ${a.width} ${a.height} L 0 ${a.height} Z`,a.width,a.height);return e.block.setShape(i,o),um(e,i,t,r??void 0),Um(e,i,a),t.rotation&&Math.abs(t.rotation)>1e-6&&Em(e,i,t.rotation,r),t.opacity!=null&&t.opacity!==1&&e.block.setOpacity(i,t.opacity),wm(e,i,t.blendMode,r?.logger),i}function Em(e,t,n,r){let i=()=>e.block.setRotation(t,lp(e,n));r?.unbatched?r.unbatched(i):i()}function Dm(e,t,n,r,i){if(t.rotation&&Math.abs(t.rotation)>1e-6){let a=km(e,t,n,r,i);if(a!==Om)return a}let a=Rm(e,t,i);e.block.appendChild(r,a);let o=[];for(let t of n){let n=Bm(e,t);e.block.appendChild(r,n),o.push(n)}let s=Sp(e,[a,...o],{logger:i?.logger,label:`${Ym(i)}clipped image at ${$l(t)}`,flush:i?.flush});return s===xp?(Tp(e,[a,...o]),gm):s==null?(Tp(e,[a,...o]),null):(um(e,s,t,i??void 0),t.opacity!=null&&t.opacity!==1&&e.block.setOpacity(s,t.opacity),wm(e,s,t.blendMode,i?.logger),s)}const Om=Symbol(`UNHANDLED`);function km(e,t,n,r,i){let a=jm(n);return a==null?Am(e,t,n,r,i):a.points.length<3?(i?.logger?.emit?.(`IMAGE_CLIP_EMPTY_INTERSECTION`,{prefix:Ym(i),bbox:$l(t),clipCount:n.length,page:i?.pageIndex}),gm):Tm(e,t,Lm(a.points),i)}function Am(e,t,n,r,i){let a=i?.vectorPathFillRuleSupport??hp(),o=n.map(t=>{let n=Bm(e,t);return bp(e,zm(e,n),t.fillRule,{support:a,logger:i?.logger}),e.block.appendChild(r,n),n}),s=Sp(e,o,{logger:i?.logger,label:`${Ym(i)}rotated image clips`,flush:i?.flush});if(s===xp)return Tp(e,o),gm;if(s==null)return Tp(e,o),Om;try{let n=e.block.getShape(s);if(n==null||!e.block.isValid(n)||e.block.getType(n)!==`//ly.img.ubq/shape/vector_path`)return Om;let r=$(e,1),a=e.block.getWidth(s)/r,o=e.block.getHeight(s)/r,c=e.block.getFloat(n,`vector_path/width`),l=e.block.getFloat(n,`vector_path/height`);if(!(c>0&&l>0))return Om;let u=e.block.getString(n,`vector_path/path`).match(/[A-Za-z]|[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?/g);return!u||u.some(e=>/^[A-Za-z]$/.test(e)&&!/^[MLCZ]$/.test(e))?Om:Tm(e,t,{x:e.block.getPositionX(s)/r,y:e.block.getPositionY(s)/r,width:a,height:o,d:Gm(u.join(` `),(e,t)=>[e*a/c,t*o/l]),fillRule:`evenodd`},i)}catch{return Om}finally{Tp(e,[s])}}function jm(e){if(e.length===0)return null;let t=Mm(e[0]);if(t==null)return null;for(let n=1;n<e.length;n++){let r=Mm(e[n]);if(r==null)return null;if(t=Nm(t,r),t.length===0)return{points:[]}}return{points:t}}function Mm(e){let t=e.d.split(/\s+/),n=[],r=0;for(;r<t.length;){let i=t[r++];if(i!==`Z`&&i!==`z`){if(i===`M`||i===`L`){let i=parseFloat(t[r++]),a=parseFloat(t[r++]);if(Number.isNaN(i)||Number.isNaN(a))return null;let o=e.x+i,s=e.y+a,c=n[n.length-1];if(c&&Math.abs(c[0]-o)<1e-6&&Math.abs(c[1]-s)<1e-6)continue;n.push([o,s])}else return null}}return n}function Nm(e,t){if(t.length<3)return[];let n=Math.sign(Pm(t))||1,r=e.slice();for(let e=0;e<t.length&&r.length!==0;e++){let i=t[e],a=t[(e+1)%t.length],o=r;r=[];let s=o[o.length-1];for(let e of o){let t=Fm(e,i,a)*n>=-1e-9,o=Fm(s,i,a)*n>=-1e-9;t?(o||r.push(Im(s,e,i,a)),r.push(e)):o&&r.push(Im(s,e,i,a)),s=e}}return r}function Pm(e){let t=0;for(let n=0;n<e.length;n++){let[r,i]=e[n],[a,o]=e[(n+1)%e.length];t+=r*o-a*i}return t*.5}function Fm(e,t,n){return(n[0]-t[0])*(e[1]-t[1])-(n[1]-t[1])*(e[0]-t[0])}function Im(e,t,n,r){let i=r[0]-n[0],a=r[1]-n[1],o=t[0]-e[0],s=t[1]-e[1],c=i*s-o*a;if(Math.abs(c)<1e-12)return t.slice();let l=(i*(n[1]-e[1])-a*(n[0]-e[0]))/c;return[e[0]+l*o,e[1]+l*s]}function Lm(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let[a,o]of e)a<t&&(t=a),o<n&&(n=o),a>r&&(r=a),o>i&&(i=o);let a=e=>`${Math.round(e*100)/100}`,o=[];for(let r=0;r<e.length;r++){let[i,s]=e[r];o.push(`${r===0?`M`:`L`} ${a(i-t)} ${a(s-n)}`)}return o.push(`Z`),{d:o.join(` `),x:t,y:n,width:r-t,height:i-n,fillRule:`nonzero`}}function Rm(e,t,n){let r=e.block.create(`graphic`);return e.block.setShape(r,e.block.createShape(`rect`)),e.block.setFill(r,e.block.createFill(`color`)),Um(e,r,t),t.rotation&&Math.abs(t.rotation)>1e-6&&Em(e,r,t.rotation,n),r}function zm(e,t){let n=e.block.getShape(t);if(n==null||!e.block.isValid(n))throw Error(`A clip carrier block has no shape.`);return n}function Bm(e,t){let n=e.block.create(`graphic`),r=mp(e,t.d,t.width,t.height);return e.block.setShape(n,r),e.block.setFill(n,Hm(e)),Um(e,n,t),n}function Vm(e,t,n,r,i){let a=e.block.create(`graphic`),o=mp(e,t,n.width,n.height);e.block.setShape(a,o);let s=r?.kind;if(r&&s!==`linearGradient`&&s!==`radialGradient`){let t=e.block.createFill(`color`);e.block.setColor(t,`fill/color/value`,Xm(r)),e.block.setFill(a,t)}else e.block.setFill(a,Hm(e));return Um(e,a,n),i!=null&&i!==1&&e.block.setOpacity(a,i),a}function Hm(e){let t=e.block.createFill(`color`);return e.block.setColor(t,`fill/color/value`,{r:0,g:0,b:0,a:0}),t}function Um(e,t,n){e.block.setPositionX(t,$(e,n.x)),e.block.setPositionY(t,$(e,n.y)),e.block.setWidth(t,$(e,n.width)),e.block.setHeight(t,$(e,n.height))}function Wm(e,t){let n=t.rotation??0;if(Math.abs(n)<1e-6)return Km(e.d,e.x-t.x,e.y-t.y);let r=t.x+t.width*.5,i=t.y+t.height*.5,a=Math.cos(n),o=Math.sin(n);return Gm(e.d,(n,s)=>{let c=n+e.x-r,l=s+e.y-i,u=a*c+o*l,d=-o*c+a*l;return[u+t.width*.5,d+t.height*.5]})}function Gm(e,t){let n=e=>`${Math.round(e*100)/100}`,r=e.split(/\s+/),i=[],a=0;for(;a<r.length;){let e=r[a++];if(e===`Z`||e===`z`)i.push(`Z`);else if(e===`M`||e===`L`){let[o,s]=t(parseFloat(r[a++]),parseFloat(r[a++]));i.push(`${e} ${n(o)} ${n(s)}`)}else if(e===`C`){let[e,o]=t(parseFloat(r[a++]),parseFloat(r[a++])),[s,c]=t(parseFloat(r[a++]),parseFloat(r[a++])),[l,u]=t(parseFloat(r[a++]),parseFloat(r[a++]));i.push(`C ${n(e)} ${n(o)} ${n(s)} ${n(c)} ${n(l)} ${n(u)}`)}else i.push(e)}return i.join(` `)}function Km(e,t,n){let r=e=>`${Math.round(e*100)/100}`,i=e.split(/\s+/),a=[],o=0;for(;o<i.length;){let e=i[o++];if(e===`Z`||e===`z`)a.push(`Z`);else if(e===`M`||e===`L`){let s=parseFloat(i[o++]),c=parseFloat(i[o++]);a.push(`${e} ${r(s+t)} ${r(c+n)}`)}else if(e===`C`){let e=parseFloat(i[o++]),s=parseFloat(i[o++]),c=parseFloat(i[o++]),l=parseFloat(i[o++]),u=parseFloat(i[o++]),d=parseFloat(i[o++]);a.push(`C ${r(e+t)} ${r(s+n)} ${r(c+t)} ${r(l+n)} ${r(u+t)} ${r(d+n)}`)}else a.push(e)}return a.join(` `)}function qm(e){return!(e.width>0&&e.height>0)}function Jm(e,t){let n=Ap({x:e.x,y:e.y,width:e.width,height:e.height},{x:t.x,y:t.y,width:t.width,height:t.height});return n.width>0&&n.height>0}function Ym(e){return e?.pageIndex==null?``:`Page ${e.pageIndex}: `}function Xm(e){if(!e)return{r:0,g:0,b:0,a:1};if(e.space===`rgb`){let[t,n,r]=e.values;return{r:t,g:n,b:r,a:1}}if(e.space===`gray`){let[t]=e.values;return{r:t,g:t,b:t,a:1}}if(e.space===`cmyk`){let[t,n,r,i]=e.values;return{c:t,m:n,y:r,k:i,tint:1}}let t=e;return t.space===`spot`?{name:t.name,tint:t.tint??1,externalReference:``}:{r:0,g:0,b:0,a:1}}const Zm=`features/implicitUpdatesEnabled`;async function Qm(e,t){let n=th(e),r=e.editor;if(n===void 0||typeof r.getSettingBool!=`function`||typeof r.setSettingBool!=`function`)return t($m,eh);let i;try{i=r.getSettingBool(Zm),r.setSettingBool(Zm,!1)}catch{return t($m,eh)}let a=e=>{r.setSettingBool?.(Zm,!0);try{return e()}finally{r.setSettingBool?.(Zm,!1)}};try{return await t(n,a)}finally{r.setSettingBool(Zm,i)}}const $m=()=>{},eh=e=>e();function th(e){let t=e;if(typeof t.update==`function`)return()=>t.update?.();if(typeof t.editor?._update==`function`)return()=>t.editor?._update?.()}async function nh(e,t,n,r){let i=`${t.family}|${t.style??`normal`}|${t.weight??`normal`}`,a=n.get(i);if(a!==void 0)return a;let o=null;try{o=await e(t,r)}catch{o=null}return n.set(i,o),o}function rh(e,t){if(e.substitutedFrom!=null)return!1;let n=(e.typeface?.name??``).toLowerCase().trim(),r=t.toLowerCase().trim();if(n===r)return!0;let i=e=>e.replace(/\s+/g,``);return i(n)===i(r)}const ih={name:`perfect-match-resolver`,async resolve(e,t){if(!t.resolver)return{kind:`pass`,reason:`no-resolver-configured`};if(!e.family)return{kind:`pass`,reason:`no-font-family`};let n=await nh(t.resolver,{family:e.family,style:e.style,weight:e.weight},t.resolverCache,t.engine);return n?rh(n,e.family)?{kind:`typeface`,typeface:n.typeface,font:n.font,provenance:`perfect-match`,substitutedFrom:n.substitutedFrom}:{kind:`pass`,reason:`not-perfect-match`}:{kind:`pass`,reason:`resolver-miss`}}},ah={name:`embedded-subset`,async resolve(e){return e.embeddedFont?{kind:`subset`,embeddedFont:e.embeddedFont,provenance:`embedded-subset`}:{kind:`pass`,reason:`no-embedded-font`}}},oh={name:`any-match-resolver`,async resolve(e,t){if(!t.resolver)return{kind:`pass`,reason:`no-resolver-configured`};if(!e.family)return{kind:`pass`,reason:`no-font-family`};let n=await nh(t.resolver,{family:e.family,style:e.style,weight:e.weight},t.resolverCache,t.engine);return n?{kind:`typeface`,typeface:n.typeface,font:n.font,provenance:`any-match`,substitutedFrom:n.substitutedFrom}:{kind:`pass`,reason:`resolver-miss`}}};function sh(e,t,n,r){if(typeof e.block?.setMetadata!=`function`)return;let i=(n,r)=>{if(r!=null&&r!==``)try{e.block.setMetadata(t,`ly.img.pdf-importer.text.${n}`,String(r))}catch{}};i(`content`,n.text),i(`fontFamily`,n.family);let a=n.source;`fontSize`in a&&typeof a.fontSize==`number`&&Number.isFinite(a.fontSize)&&i(`fontSize`,a.fontSize),i(`fontStyle`,n.style),i(`fontWeight`,n.weight),i(`fallbackReason`,r)}function ch(e,t){return t?e.family?`resolver-miss`:`no-font-family`:`resolver-disabled`}const lh={name:`default`,async emit(e,t,n){if(t?.kind===`typeface`){let r=await n.helpers.resolveLayoutForSubstitution(e,t),i=n.helpers.createEditableText(e,r,(e,n)=>{Qf(e,n,t.typeface,t.font)}),a=t.substitutedFrom!=null;return{blocks:[i],substituted:a,resolvedFamily:t.typeface.name}}if(t?.kind===`subset`)return{blocks:[n.helpers.createEditableText(e,e.source,(e,n)=>{tp(e,n,t.embeddedFont)})],substituted:!1,resolvedFamily:e.family};if(e.glyphPaths!=null||e.buildGlyphOutline!=null){let t=n.helpers.emitGlyphsAsVectorPath(e);if(t!=null){let r=ch(e,!0);return sh(n.engine,t,e,r),{blocks:[t],substituted:!1}}}return e.text.trim()===``||n.logger?.emit?.(`TEXT_RUN_SKIPPED_NO_RESOLUTION`,{fontFamily:e.family}),{blocks:[],substituted:!1}}};function uh(e,t){if(e.kind===ae.TEXT_RUN){let n=t.fonts?.get?.(e.fontRef);return n?{family:n.family,style:n.style??`normal`,weight:n.weight==null?`normal`:dh(n.weight),text:e.text,embeddedFont:n,buildGlyphOutline:e._buildGlyphOutline,source:e}:null}return e.fontFamily?{family:e.fontFamily,style:e.fontStyle??`normal`,weight:e.fontWeight??`normal`,text:e.text,glyphPaths:e.d,source:e}:null}function dh(e){let t=Number(e)||400;return t<=150?`thin`:t<=250?`extraLight`:t<=350?`light`:t<=450?`normal`:t<=550?`medium`:t<=650?`semiBold`:t<=750?`bold`:t<=850?`extraBold`:`heavy`}function fh(e){return{stages:e,async resolve(t,n){for(let r of e){let e=await r.resolve(t,n);if(e.kind!==`pass`)return e}return null}}}function ph(e){return{cascade:e.cascade,emission:e.emission}}const mh=ph({cascade:fh([ih,ah,oh]),emission:lh}),hh=ph({cascade:fh([ih,ah]),emission:lh}),gh=ph({cascade:fh([ih,oh]),emission:lh}),_h=mh;function vh(e){if(e?.aborted)throw new DOMException(`PDF import was aborted.`,`AbortError`)}function yh(e,t=0){if(vh(e.signal),e.maxBlocks!==void 0){if(!Number.isSafeInteger(e.maxBlocks)||e.maxBlocks<=0)throw RangeError(`maxBlocks must be a positive safe integer.`);if(t>e.maxBlocks)throw Error(`PDF import exceeds the block limit of ${e.maxBlocks}.`)}}function bh(e,t){return t?new Promise((n,r)=>{let i=()=>{t.removeEventListener(`abort`,i),r(new DOMException(`PDF import was aborted.`,`AbortError`))};t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)}),t.aborted&&i()}):e}const xh=/* @__PURE__ */ new Set([`create`,`createShape`,`createFill`,`createEffect`,`createBlur`,`group`,`combine`,`duplicate`]),Sh=/* @__PURE__ */ new WeakMap,Ch=/* @__PURE__ */ new WeakMap;var wh=class{original;options;engine;blocks=[];buffers=[];spots=/* @__PURE__ */ new Map;originalSpots;identity;scene;units;active=!0;disposed=!1;allocations=0;failure;pages=/* @__PURE__ */ new Set;parking;lastYield=performance.now();constructor(e,t){this.original=e,this.options=t,this.identity=Xf(e),this.scene=e.scene.get(),this.units=this.scene===null?null:ip(e,this.scene),this.originalSpots=new Set(e.editor.findAllSpotColors());let n=this.facade(e.block,(t,n,r)=>{if(this.check(),!xh.has(t))return r();if(this.checkBudget(1),t===`duplicate`||t===`combine`){let i=/* @__PURE__ */ new Set([...e.block.findAll(),...this.blocks]),a;try{return a=t===`combine`?this.withLayoutFor(n[0],r):r(),a}finally{let t=e.block.findAll().filter(e=>!i.has(e));typeof a==`number`&&!i.has(a)&&t.push(a);let n=this.withResources(t).filter(e=>!i.has(e));this.blocks.push(...n),this.allocations+=n.length,this.checkBudget(0)}}let i=t===`group`?this.withLayoutFor(n[0],r):r();if(this.blocks.push(i),this.allocations++,t===`create`){let e=this.withResources([i]).filter(e=>e!==i);this.blocks.push(...e),this.allocations+=e.length,this.checkBudget(0)}return i}),r=this.facade(e.editor,(e,t,n)=>{this.check();let r=n();if(e===`createBuffer`&&this.buffers.push(r),(e===`setSpotColorRGB`||e===`setSpotColorCMYK`)&&!this.originalSpots.has(t[0])){let e=t[0];this.spots.set(e,this.readSpotDefinition(e))}return r});this.engine=new Proxy(e,{get(e,t){if(t===`block`)return n;if(t===`editor`)return r;let i=Reflect.get(e,t,e);return typeof i==`function`?i.bind(e):i}}),Yf(this.engine,e),this.units!==null&&op(this.engine,this.units),Ch.set(this.identity,(Ch.get(this.identity)??0)+1)}parkPage(e){this.parking??=this.engine.block.create(`page`),this.pages.add(e),this.engine.block.appendChild(this.parking,e)}withLayout(e,t){if(this.check(),this.scene===null||this.parking===void 0)return t();this.original.block.getGlobalBoundingBoxX(this.scene),this.original.block.appendChild(this.scene,e);try{return this.original.block.getGlobalBoundingBoxX(e),t()}finally{this.original.block.appendChild(this.parking,e)}}withLayoutFor(e,t){let n=e[0]??null;for(;n!==null&&!this.pages.has(n);)n=this.original.block.getParent(n);return n===null?t():this.withLayout(n,t)}check(){if(this.failure)throw this.failure;if(vh(this.options.signal),!this.active)throw Error(`This PDF block import is no longer active.`);if((this.scene===null?this.original.scene.get()!==null:!this.original.block.isValid(this.scene))||this.unitsChanged())throw Error(`The scene or its units changed during PDF import.`)}async wait(e){let t=await bh(e,this.options.signal);return this.check(),performance.now()-this.lastYield>=16&&(await new Promise(e=>setTimeout(e,0)),this.check(),this.lastYield=performance.now()),t}finish(){this.check(),this.parking!==void 0&&this.original.block.destroy(this.parking),this.active=!1,this.releaseActiveSession();let e=Sh.get(this.identity);e&&(this.cleanupPendingSpots(e),e.buffers.size===0&&e.spots.size===0&&Sh.delete(this.identity))}rollback(e){try{this.dispose()}catch(t){throw AggregateError([e,t],`PDF import failed and cleanup was incomplete.`)}throw e}dispose(){if(this.disposed)return;this.disposed=!0;let e=this.active;this.active=!1,e&&this.releaseActiveSession();let t=Sh.get(this.identity)??{buffers:/* @__PURE__ */ new Set,spots:/* @__PURE__ */ new Map};Sh.set(this.identity,t);for(let e of this.buffers)t.buffers.add(e);for(let[e,n]of this.spots)t.spots.set(e,n);let n=[],r=e=>{try{e()}catch(e){n.push(e)}};for(let e of[...this.blocks].reverse())r(()=>{this.original.block.isValid(e)&&this.original.block.destroy(e)});if(t.buffers.size>0&&r(()=>{let e=new Set(this.original.editor.findAllTransientResources().map(({URL:e})=>e));for(let n of t.buffers)e.has(n)||r(()=>{this.original.editor.destroyBuffer(n),t.buffers.delete(n)})}),t.spots.size>0&&r(()=>this.cleanupPendingSpots(t)),t.buffers.size===0&&t.spots.size===0&&Sh.delete(this.identity),n.length>0)throw AggregateError(n,`PDF import cleanup was incomplete.`)}releaseActiveSession(){let e=Ch.get(this.identity);e===1?Ch.delete(this.identity):e!==void 0&&Ch.set(this.identity,e-1)}cleanupPendingSpots(e){if(Ch.has(this.identity)||e.spots.size===0)return;let t=this.referencedSpots(),n=new Set(this.original.editor.findAllSpotColors()),r=[];for(let[i,a]of e.spots)if(!n.has(i))e.spots.delete(i);else try{this.readSpotDefinition(i).every((e,t)=>Math.abs(e-a[t])<1e-6)?t.has(i)||(this.original.editor.removeSpotColor(i),e.spots.delete(i)):e.spots.delete(i)}catch(e){r.push(e)}if(r.length>0)throw AggregateError(r,`PDF spot color cleanup was incomplete.`)}readSpotDefinition(e){return[...this.original.editor.getSpotColorRGBA(e),...this.original.editor.getSpotColorCMYK(e)]}withResources(e){let t=this.original.block,n=new Set(e),r=e=>{e!=null&&t.isValid(e)&&n.add(e)};for(let n of e){if(t.supportsFill(n)&&r(t.getFill(n)),t.supportsShape(n)&&r(t.getShape(n)),t.supportsEffects(n))for(let e of t.getEffects(n))r(e);t.supportsBlur(n)&&r(t.getBlur(n))}return[...n]}referencedSpots(){let e=/* @__PURE__ */ new Set,t=t=>{`name`in t&&e.add(t.name)};for(let n of this.withResources(this.original.block.findAll())){for(let e of this.original.block.findAllProperties(n))if(e!==`fill/solid/color`&&e!==`camera/clearColor`){if(this.original.block.getPropertyType(e)===`Color`)t(this.original.block.getColor(n,e));else if(e===`fill/gradient/colors`)for(let r of this.original.block.getGradientColorStops(n,e))t(r.color)}if(this.original.block.getType(n)===`//ly.img.ubq/text`)for(let e of this.original.block.getTextColors(n))t(e);for(let t of this.original.block.findAllMetadata(n))t.startsWith(`ly.img.pdf-importer.spotColor.`)&&e.add(t.slice(30))}return e}checkBudget(e){if(this.options.maxBlocks!==void 0&&this.allocations+e>this.options.maxBlocks)throw this.failure=/* @__PURE__ */ Error(`PDF import exceeds the block limit of ${this.options.maxBlocks}.`),this.failure}unitsChanged(){if(this.scene===null||this.units===null)return!1;let e=ip(this.original,this.scene);return e.designUnit!==this.units.designUnit||e.fontSizeUnit!==this.units.fontSizeUnit||e.angleUnit!==this.units.angleUnit||e.dpi!==this.units.dpi}facade(e,t){let n=/* @__PURE__ */ new Map;return new Proxy(e,{get(e,r){let i=Reflect.get(e,r,e);return typeof i==`function`?(n.has(r)||n.set(r,(...n)=>t(r,n,()=>Reflect.apply(i,e,n))),n.get(r)):i}})}};const Th={CMYK:`CMYK`,"RGB ":`RGB`,GRAY:`Gray`},Eh=e=>e.outputConditionIdentifier||e.subtype;function Dh(e,t,n){if(t===void 0)return;let r=Eh(t);if(t.profile===null){n?.emit?.(`OUTPUT_INTENT_PROFILE_MISSING`,{identifier:r});return}let i=String.fromCharCode(...t.profile.subarray(16,20)),a=Th[i];if(a===void 0){n?.emit?.(`OUTPUT_INTENT_SPACE_UNSUPPORTED`,{identifier:r,space:i.trim()});return}let o=e.scene;if(o.setDocumentColorProfileFromData===void 0){n?.emit?.(`OUTPUT_INTENT_ENGINE_UNSUPPORTED`,{identifier:r});return}let s=a===`CMYK`?[{role:`Output`,space:a},{role:`Default`,space:a}]:[{role:`Output`,space:a}];try{for(let e of s)o.setDocumentColorProfileFromData(e,t.profile)}catch(e){n?.emit?.(`OUTPUT_INTENT_REJECTED`,{identifier:r,error:e instanceof Error?e.message:String(e)});return}n?.emit?.(`OUTPUT_INTENT_APPLIED`,{identifier:r,space:a,outputConditionIdentifier:t.outputConditionIdentifier,outputCondition:t.outputCondition,registryName:t.registryName,info:t.info})}function Oh(e,t){e?.profile!=null&&t?.emit?.(`OUTPUT_INTENT_DROPPED_DETACHED`,{identifier:Eh(e)})}function kh(e){let t=e.scene;return L[t.getColorRenderingIntent?.()??1]??`RelativeColorimetric`}function Ah(e,t,n){let r=kh(e);for(let{page:i,pageIndex:a}of t){let t=new Set(i.renderingIntents);for(let n of i.blocks)n.kind===`image`&&n.renderingIntent&&sm(e,n)&&t.add(n.renderingIntent);[...t].every(e=>e===r)||n?.emit?.(`RENDERING_INTENT_PER_OBJECT`,{prefix:`Page ${a+1}: `,page:a+1,intents:[...t].sort().join(`, `)})}}function jh(e){let t=[],n=null,r=()=>{if(n){if(n.runs.length===1)t.push(n.runs[0]);else if(Ph(n.runs))for(let e of n.runs)t.push(e);else t.push(Hh(n.runs));n=null}};for(let i of e){if(i.kind!==ae.TEXT_RUN){r(),t.push(i);continue}let e=i;if(!n){n={runs:[e]};continue}let a=n.runs[n.runs.length-1];Fh(a,e)?n.runs.push(e):(r(),n={runs:[e]})}return r(),t}const Mh=.15,Nh=.35;function Ph(e){let t=/* @__PURE__ */ new Map;for(let n of e){if(!n.family)continue;let e=`${n.family}|${n.fontWeight??``}|${n.fontStyle??``}|${n.fontWidth??``}`,r=t.get(e);if(r!==void 0&&r!==n.fontRef)return!0;r===void 0&&t.set(e,n.fontRef)}return!1}function Fh(e,t){let n=!1;if(e.fontRef!==t.fontRef){if(!e.family||!t.family||e.family!==t.family||!e.fontWidth||!t.fontWidth||e.fontWidth!==t.fontWidth)return!1;n=!0}return Math.abs(e.fontSize-t.fontSize)>.5||Math.abs((e.rotation??0)-(t.rotation??0))>.001?!1:e.baselineXPt!=null&&e.baselineYPt!=null&&e.advanceWidthPt!=null&&t.baselineXPt!=null&&t.baselineYPt!=null?Ih(e,t,n):Lh(e,t,n)}function Ih(e,t,n){let r=e.fontSize||10,i=e.rotation??0,a=Math.cos(i),o=Math.sin(i),s=e.baselineXPt,c=e.baselineYPt,l=e.advanceWidthPt,u=t.baselineXPt,d=t.baselineYPt,f=s+l*a,p=c+l*o,m=u-f,h=d-p,g=m*a+h*o,_=-m*o+h*a,v=(n?Nh:Mh)*r;return!(Math.abs(_)>.5*r||g<-.5*r||g>v)}function Lh(e,t,n){let r=e.fontSize||10,i=e.rotation??0,a=Math.cos(i),o=Math.sin(i),s=t.x+t.width/2-(e.x+e.width/2),c=t.y+t.height/2-(e.y+e.height/2);return!(Math.abs(s*-o+c*a)>.5*r||Math.abs(s*a+c*o)>(e.width+t.width)/2+(n?Nh*r:0))}function Rh(e,t){if(e.fontRef===t.fontRef||!e.family||!t.family||e.family!==t.family)return!1;let n=e.fontSize||10,r=Mh*n;if(e.baselineXPt!=null&&e.advanceWidthPt!=null&&t.baselineXPt!=null){let n=e.rotation??0,i=Math.cos(n),a=Math.sin(n),o=e.baselineXPt+e.advanceWidthPt*i,s=(e.baselineYPt??0)+e.advanceWidthPt*a,c=t.baselineXPt-o,l=(t.baselineYPt??0)-s;return c*i+l*a>r}return Math.abs(t.x+t.width/2-(e.x+e.width/2))-(e.width+t.width)/2>r}function zh(e){for(let t=1;t<e.length;t++){let n=e[t-1],r=e[t];r.from>n.to&&(n.to=r.from)}}function Bh(e){return Hh(e,` `)}function Vh(e){return{...Bh(e),advanceWidthPt:Uh(e)}}function Hh(e,t=``){let n=e[0],r=n.x,i=n.y,a=n.x+n.width,o=n.y+n.height;for(let t of e)r=Math.min(r,t.x),i=Math.min(i,t.y),a=Math.max(a,t.x+t.width),o=Math.max(o,t.y+t.height);let s=``,c=[],l=[],u=[],d=[],f=[];for(let n=0;n<e.length;n++){let r=e[n];if(n>0){let i=e[n-1];(t?!/\s$/.test(i.text)&&!/^\s/.test(r.text):Rh(i,r))&&(s+=` `)}let i=s.length;for(let e of r.underlineSpans??[])f.push({...e,from:i+e.from,to:i+e.to});for(let e of r.wordSpacingSpans??[])u.push({...e,from:i+e.from,to:i+e.to});for(let e of r.letterSpacingSpans??[])d.push({...e,from:i+e.from,to:i+e.to});if(Array.isArray(r.colorSpans)&&r.colorSpans.length>0)for(let e of r.colorSpans)c.push({from:i+e.from,to:i+e.to,fill:e.fill??null});else c.push({from:i,to:i+r.text.length,fill:r.fill??null});if(r.styleSpans?.length)for(let e of r.styleSpans)l.push({...e,from:i+e.from,to:i+e.to,fontRef:e.fontRef??r.fontRef});else l.push({from:i,to:i+r.text.length,fontWeight:r.fontWeight,fontStyle:r.fontStyle,fontRef:r.fontRef});s+=r.text}zh(c),zh(l);let p=[];for(let e of c){let t=p[p.length-1];t&&se(t.fill,e.fill)&&t.to===e.from?t.to=e.to:p.push({...e})}let m=p.every(e=>se(e.fill,p[0].fill)),h=[];for(let e of l){let t=h[h.length-1];t&&t.fontWeight===e.fontWeight&&t.fontStyle===e.fontStyle&&t.fontRef===e.fontRef&&t.to===e.from?t.to=e.to:h.push({...e})}let g=h.every(e=>e.fontWeight===h[0].fontWeight&&e.fontStyle===h[0].fontStyle&&e.fontRef===h[0].fontRef),_=h.map(e=>({from:e.from,to:e.to,...e.fontWeight==null?{}:{fontWeight:e.fontWeight},...e.fontStyle==null?{}:{fontStyle:e.fontStyle},fontRef:e.fontRef})),v=Wh(e),y=!m||!se(n.fill??null,p[0]?.fill??null),b=!g||e.some(e=>!!e.styleSpans?.length);return{...n,x:r,y:i,width:a-r,height:o-i,text:s,wordSpacingSpans:u.length?u:void 0,letterSpacingSpans:d.length?d:void 0,underlineSpans:f.length?f:void 0,advanceWidthPt:t===``?Uh(e):void 0,colorSpans:y?p:void 0,...b?{styleSpans:_}:{},...v?{_buildGlyphOutline:v}:{}}}function Uh(e){let t=e[0],n=t.baselineXPt,r=t.baselineYPt,i=t.rotation??0;if(n==null||r==null||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i))return;let a=Math.cos(i),o=Math.sin(i),s=0;for(let t of e){if(t.baselineXPt==null||t.baselineYPt==null||t.advanceWidthPt==null||!Number.isFinite(t.baselineXPt)||!Number.isFinite(t.baselineYPt)||!Number.isFinite(t.advanceWidthPt)||!Number.isFinite(t.rotation??0))return;let e=(t.baselineXPt-n)*a+(t.baselineYPt-r)*o+t.advanceWidthPt*Math.cos((t.rotation??0)-i);if(!Number.isFinite(e))return;s=Math.max(s,e)}return s}function Wh(e){let t=e.map(e=>e._buildGlyphOutline).filter(e=>e!=null);if(t.length!==0)return()=>{let e=t.map(e=>e()).filter(e=>e!=null);if(e.length===0)return null;let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let t of e)t.x<n&&(n=t.x),t.y<r&&(r=t.y),t.x+t.width>i&&(i=t.x+t.width),t.y+t.height>a&&(a=t.y+t.height);return{d:e.map(e=>Yh(e.d,e.x-n,e.y-r)).filter(e=>e.length>0).join(` `),x:n,y:r,width:i-n,height:a-r}}}const Gh=.3;function Kh(e){let t=[],n=null,r=()=>{n&&=(n.length===1?t.push(n[0]):t.push(Jh(n)),null)};for(let i of e){if(i.kind!==ae.TEXT_OUTLINE){r(),t.push(i);continue}let e=i;if(!n){n=[e];continue}let a=n[n.length-1];qh(a,e)?n.push(e):(r(),n=[e])}return r(),t}function qh(e,t){if(!e.fontFamily||!t.fontFamily||e.fontFamily!==t.fontFamily||Math.abs((e.fontSize??0)-(t.fontSize??0))>.5||(e.fontStyle??`normal`)!==(t.fontStyle??`normal`)||(e.fontWeight??`normal`)!==(t.fontWeight??`normal`)||!se(e.fill,t.fill))return!1;let n=e.fontSize||10;if(Math.abs(e.y-t.y)>n*Gh||Math.abs(e.y+e.height-(t.y+t.height))>n*Gh)return!1;let r=e.x+e.width,i=t.x-r,a=n*.5;return!(i>a||i<-a)}function Jh(e){let t=e[0],n=Math.min(...e.map(e=>e.x)),r=Math.min(...e.map(e=>e.y)),i=Math.max(...e.map(e=>e.x+e.width)),a=Math.max(...e.map(e=>e.y+e.height)),o=e.map(e=>e.text??``).join(``),s=e.map(e=>Yh(e.d??``,e.x-n,e.y-r)).filter(e=>e.length>0).join(` `),c=e.map(e=>e.textOriginX).filter(e=>Number.isFinite(e)),l=c.length>0?Math.min(...c):void 0;return{...t,x:n,y:r,width:i-n,height:a-r,text:o,d:s,textOriginX:l}}function Yh(e,t,n){if(!e)return``;if(Math.abs(t)<1e-9&&Math.abs(n)<1e-9)return e;let r=e.trim().split(/\s+/),i=[],a=0;for(;a<r.length;){let e=r[a];if(e===`Z`||e===`z`)i.push(e),a++;else if(/^[A-Za-z]$/.test(e)){let o=e,s=Xh(o);i.push(o);for(let e=0;e<s;e++){let o=Number(r[a+1+e*2]),s=Number(r[a+2+e*2]);!Number.isFinite(o)||!Number.isFinite(s)?i.push(r[a+1+e*2],r[a+2+e*2]):i.push(Zh(o+t),Zh(s+n))}a+=1+s*2}else i.push(e),a++}return i.join(` `)}function Xh(e){switch(e){case`M`:case`m`:case`L`:case`l`:case`T`:case`t`:return 1;case`Q`:case`q`:case`S`:case`s`:return 2;case`C`:case`c`:return 3;default:return 0}}function Zh(e){return`${Math.round(e*100)/100}`}function Qh(e){let t=e.wordSpacingSpans??[];if(t.length>256)return;let n=[],r=0;for(let{from:i,to:a,em:o}of t){if(!Number.isInteger(i)||!Number.isInteger(a)||i<r||a<=i||a>e.text.length||!Number.isFinite(o)||Math.abs(o)>2)return;if(r=a,o!==0)for(let t=e.text.indexOf(` `,i);t>=0&&t<a;t=e.text.indexOf(` `,t+1)){if(n.length===256)return;n.push({from:t,to:t+1,em:o})}}return n}const $h=.8,eg=1.8,tg=.1,ng=.35,rg=[`Left`,`Center`,`Right`],ig=.2,ag=/[\p{Script_Extensions=Han}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}\p{Script_Extensions=Hangul}\p{Script_Extensions=Thai}\p{Script_Extensions=Lao}\p{Script_Extensions=Khmer}\p{Script_Extensions=Myanmar}\p{Script_Extensions=Tibetan}]/u,og=/[/\\#&=@]|^\?(?=\S)|%[\da-f]{2}|www\./iu;function sg(e){let t=[],n=[],r=[],i=rg,a,o=/* @__PURE__ */ new Map,s=()=>{n.length>1&&t.push({runs:n,alignment:i[0],...r.some(e=>e.length>1)?{sourceLines:r}:{}}),n=[],r=[],i=rg,a=void 0,o.clear()},c=({run:e,sources:t})=>{_g(e,o)?(n.push(e),r.push(t)):o.clear()};for(let t of pg(e)){if(t===null){s();continue}let e=t.run;if(n.length===0){c(t);continue}let l=n[0],u=n[n.length-1],d=e.y-u.y,f=l.fontSize*tg,p=i.filter(t=>Math.abs(yg(l,t)-yg(e,t))<=f);e.fontRef!==l.fontRef||e.fontSize!==l.fontSize||(e.opacity??1)!==(l.opacity??1)||d<l.fontSize*$h||d>l.fontSize*eg||a!==void 0&&Math.abs(d-a)>f||p.length===0||!hg(u.text,e.text)||!_g(e,o)?(s(),c(t)):(i=p,a??=d,n.push(e),r.push(t.sources))}return s(),gg([...cg(e),...ug(e),...t],e)}function cg(e){let t=[],n=[],r=!1,i=()=>{r||t.push(...lg(n)),n=[],r=!1};for(let t of e)vg(t)?n.length<256?n.push(t):r=!0:i();return i(),t}function lg(e){let t=[];for(let n=0;n+1<e.length;n++){let r=e[n],i=e[n+1];if(!/^[•◦▪●‣⁃]$/u.test(r.text.trim()))continue;let a=r.fontSize*tg,o=i.baselineXPt-r.baselineXPt-r.advanceWidthPt;i.fontSize===r.fontSize&&(i.opacity??1)===(r.opacity??1)&&Math.abs(i.baselineYPt-r.baselineYPt)<=a&&r.advanceWidthPt<=r.fontSize&&o>0&&o<=r.fontSize*2&&!/^[•◦▪●‣⁃]$/u.test(i.text.trim())&&t.push({marker:r,body:i,index:n})}let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e=>{let t=i.body.fontSize*tg;return i.marker.text.trim()===e.marker.text.trim()&&i.body.fontSize===e.body.fontSize&&Math.abs(i.marker.baselineXPt-e.marker.baselineXPt)<=t&&Math.abs(i.body.baselineXPt-e.body.baselineXPt)<=t};if(!(r>0&&a(t[r-1]))&&!(r+1<t.length&&a(t[r+1])))continue;let o=t[r+1]?.index??e.length,s=[],c;for(let t of pg(e.slice(i.index+1,o))){if(t===null)break;if(s.length>0){let e=s[0].run,n=s[s.length-1].run,r=t.run,i=e.fontSize*tg,a=r.y-n.y;if(r.fontSize!==e.fontSize||r.fontRef!==e.fontRef&&(!r.family||r.family!==e.family)||r.fontWidth!==e.fontWidth||(r.opacity??1)!==(e.opacity??1)||Math.abs(r.baselineXPt-e.baselineXPt)>i||a<e.fontSize*$h||a>e.fontSize*eg||c!==void 0&&Math.abs(a-c)>i||!hg(n.text,r.text))break;c??=a}s.push(t)}let l=s[0];if(!l)continue;let u=Vh([{...i.marker,text:i.marker.text.trim()},l.run]),d=i.marker.text.trim().length;for(let e of[u.styleSpans,u.colorSpans])e&&e.length>1&&e[0].to===d+1&&(e[0].to=d,e[1].from=d);Object.assign(u,{fontRef:l.run.fontRef,family:l.run.family,fontWeight:l.run.fontWeight,fontStyle:l.run.fontStyle,fontWidth:l.run.fontWidth}),n.push({runs:[u,...s.slice(1).map(({run:e})=>e)],alignment:`Left`,sourceLines:[[i.marker,...l.sources],...s.slice(1).map(({sources:e})=>e)],bullet:{marker:i.marker,bodyXPt:l.run.baselineXPt}})}return n}function ug(e){let t=[],n=[],r=!1,i=()=>{!r&&n.length>1&&t.push(...dg(n)),n=[],r=!1};for(let t of e)!vg(t)||/\t/.test(t.text)?i():n.length<256?n.push(t):r=!0;return i(),t}function dg(e){let t=[],n=new Map(e.map((e,t)=>[e,t])),r=[...e].sort((e,t)=>e.y-t.y||e.baselineXPt-t.baselineXPt),i=[],a=[],o=()=>{let e=a[0],t=e.fontSize*tg,n=a.slice(1).map((e,t)=>e.baselineXPt-(a[t].baselineXPt+a[t].advanceWidthPt)),r=a.length<=32&&(a.length===1||a.every(e=>!/\s/u.test(e.text.trim())))&&a.slice(1).every((t,n)=>mg(e,a[n],t,2))&&n.every(e=>Math.abs(e-n[0])<=t);i.push(r?{run:a.length===1?e:Vh(a),sources:a}:null),a=[]};for(let e of r){let t=a[0];t&&(Math.abs(e.y-t.y)>t.fontSize*tg||Math.abs(e.baselineYPt-t.baselineYPt)>t.fontSize*tg)&&o(),a.push(e)}a.length>0&&o();let s=[],c,l=/* @__PURE__ */ new Map,u=()=>{fg(s,n)&&t.push({runs:s.map(({run:e})=>e),alignment:`Justify`,sourceLines:s.map(({sources:e})=>e)}),s=[],c=void 0,l.clear()};for(let e of i)if(e===null)u();else{if(s.length>0){let t=s[0].run,n=s[s.length-1].run,r=e.run,i=t.fontSize*tg,a=r.y-n.y;r.fontRef!==t.fontRef||r.fontSize!==t.fontSize||(r.opacity??1)!==(t.opacity??1)||Math.abs(r.baselineXPt-t.baselineXPt)>i||a<t.fontSize*$h||a>t.fontSize*eg||c!==void 0&&Math.abs(a-c)>i||!hg(n.text,r.text)||!_g(r,l)?u():c??=a}s.length>0||_g(e.run,l)?s.push(e):l.clear()}return u(),t}function fg(e,t){if(e.length<2)return!1;let n=e[0].run,r=n.fontSize*tg,i=n.baselineXPt+n.advanceWidthPt,a=e.slice(0,-1),o=e[e.length-1].run;if(i-(o.baselineXPt+o.advanceWidthPt)<=r||a.some(({run:e})=>Math.abs(e.baselineXPt+e.advanceWidthPt-i)>r)||!a.some(({sources:t})=>{if(t.length===1){let e=Qh(t[0]);return e!==void 0&&e.filter(({em:e})=>e>0).length>=2}return t.length<(e.length===2?3:2)?!1:t.slice(1).every((e,r)=>e.baselineXPt-(t[r].baselineXPt+t[r].advanceWidthPt)>n.fontSize*ng)}))return!1;let s=e.flatMap(({sources:e})=>e.map(e=>t.get(e)));return Math.max(...s)-Math.min(...s)+1===s.length}function*pg(e){let t=[],n=()=>({run:t.length===1?t[0]:Vh(t),sources:t});for(let r of e)vg(r)?(t.length>0&&!mg(t[0],t[t.length-1],r)&&(yield n(),t=[]),t.push(r)):(t.length>0&&(yield n(),t=[]),yield null);t.length>0&&(yield n())}function mg(e,t,n,r=ng){let i=e.fontSize*tg,a=n.baselineXPt-(t.baselineXPt+t.advanceWidthPt);return n.fontRef===e.fontRef&&n.fontSize===e.fontSize&&(n.opacity??1)===(e.opacity??1)&&Math.abs(n.baselineYPt-e.baselineYPt)<=i&&Math.abs(n.y-e.y)<=i&&a>e.fontSize*.15&&a<=e.fontSize*r&&hg(t.text,n.text)}function hg(e,t){let n=/(?:^|\s)(\S+)$/u.exec(e.trimEnd())?.[1]??``,r=/^\s*(\S+)/u.exec(t)?.[1]??``;return ag.test(n)||ag.test(r)?!1:!og.test(n)&&!og.test(r)}function gg(e,t){if(e.length===0)return e;let n=e.reduce((e,t)=>Math.max(e,t.runs[0].fontSize*ig),0),r=[];for(let e of t){if(e.kind!==`vector-path`||e.opacity===0)continue;let t=e.stroke?e.strokeWidth??0:0;if(!e.fill&&t<=0)continue;let{x:i,y:a,width:o,height:s}=e,c=Math.max(s,t);![i,a,o,s,t].every(Number.isFinite)||o<=0||s<0||t<0||c>n||o<=4*c||r.push({left:i-t/2,top:a-t/2,right:i+o+t/2,bottom:a+s+t/2,thickness:c})}if(r.length===0)return e;let i=e.reduce((e,t)=>e+t.runs.length,0);return r.length*i>4096?[]:e.filter(e=>!e.runs.some(e=>{let t=e.fontSize*tg;return r.some(n=>n.thickness<=e.fontSize*ig&&n.left<e.x+e.width&&n.right>e.x&&n.top<=e.y+e.height+t&&n.bottom>=e.y-t)}))}function _g(e,t){let n=e.styleSpans?.length?e.styleSpans:[e];for(let r of n){let n=`${r.fontWeight??e.fontWeight??400}|${r.fontStyle??e.fontStyle??`normal`}`,i=r.fontRef??e.fontRef,a=t.get(n);if(a!==void 0&&a!==i)return!1;t.set(n,i)}return!0}function vg(e){if(e.kind!==`text-run`)return!1;let t=e;return Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.width)&&t.width>0&&Number.isFinite(t.height)&&t.height>0&&Number.isFinite(t.fontSize)&&t.fontSize>0&&Number.isFinite(t.rotation)&&Math.abs(t.rotation)<=1e-6&&Number.isFinite(t.baselineXPt)&&Number.isFinite(t.baselineYPt)&&Number.isFinite(t.advanceWidthPt)&&t.advanceWidthPt>0&&Number.isFinite(t.opacity??1)&&(t.opacity??1)>=0&&(t.opacity??1)<=1&&(t.clips==null||t.clips.length===0)&&(t.blendMode==null||t.blendMode===`source-over`)&&(t.renderMode==null||t.renderMode===0)&&t.text.trim().length>0&&!/[\r\n\u2028\u2029]/.test(t.text)&&!/[-\u00ad\u2010]\s*$/.test(t.text)}function yg(e,t){switch(t){case`Left`:return e.baselineXPt;case`Center`:return e.baselineXPt+e.advanceWidthPt/2;case`Right`:return e.baselineXPt+e.advanceWidthPt}}async function bg(e,t,n,r,i,a,o={}){if(typeof e.block.getTextVisibleLineGlobalBoundingBoxXYWH!=`function`||typeof e.block.getTextVisibleLineContent!=`function`)return;let s=t.flatMap((e,t)=>sg(e).map(e=>({...e,pageIndex:t+1})));if(s.length===0)return;let c=new Map(n.map(e=>[e.ir,e.id])),l=new Map(n.map((e,t)=>[e.ir,t])),u=[],d=/* @__PURE__ */ new Set,f=$(e,.05),p,m=e.block.getTextCharacterInkBoxes,h=e.block.setTextKerning,g=512,_=0,v=/* @__PURE__ */ new Map,y=t=>{if(v.has(t))return v.get(t);if(g!==0&&m!==void 0){g--;try{let n=m.call(e.block,t).filter(e=>e.width!==0||e.height!==0).map(e=>[e.x,e.y,e.width,e.height]);return v.set(t,n),n}catch{v.set(t,void 0);return}}},b=[];i(()=>{a(),o.boundsAnchor!==void 0&&(p=xg(e,[o.boundsAnchor]));for(let t of s){if(t.bullet&&(!m||!h))continue;let n=t.runs.some(e=>e.wordSpacingSpans?.length);if(n&&(typeof e.block.setTextKerning!=`function`||Qh(Bh(t.runs))===void 0))continue;let r=t.sourceLines??t.runs.map(e=>[e]),i=r.map(e=>e.flatMap(e=>{let t=c.get(e);return t===void 0?[]:[t]}));if(i.some((e,t)=>e.length!==r[t].length))continue;let a=i.flat(),s=e.block.getParent(a[0]);if(s===null||a.some(t=>e.block.getParent(t)!==s))continue;let u=t.bullet?i[0][1]:a[0],d=e.block.getFloat(u,`text/letterSpacing`);if(a.some(n=>n!==(t.bullet?i[0][0]:void 0)&&e.block.getFloat(n,`text/letterSpacing`)!==d||!Og(e,n)))continue;let f=i.map(t=>Tg(e,t));if(t.bullet&&(f[0].text=t.runs[0].text),f.some(e=>e.box.some(e=>!Number.isFinite(e))))continue;let p=r.flatMap(e=>e.map(e=>l.get(e))),x=p.some((e,t)=>t>0&&e<p[t-1]),S=(t.runs[0].opacity??1)<1;if((x||S)&&f.slice(1).some((e,t)=>f[t].box[1]+f[t].box[3]>e.box[1])||S&&i.some(t=>Eg(e,t)))continue;let C=t.runs.some(e=>/[^\x20-\x7e\s]/u.test(e.text)),w=n||C||i.some(e=>e.length>1)||t.runs.some(e=>e.styleSpans?.length),T=t.bullet?2:1,E=a.filter(e=>!v.has(e)).length+T;if(w&&m!==void 0&&E>g-_)continue;let D=w?a.map(y):[],O=D.length>0&&D.every(e=>e!==void 0)?D.flatMap(e=>e):void 0;if(O!==void 0&&(_+=T),(n||C||i.some(e=>e.length>1))&&(!O?.length||O.some(e=>e.some(e=>!Number.isFinite(e)))))continue;let k=t.bullet?{fontSize:$(e,t.runs[0].fontSize),lineInkCounts:i.map(e=>e.reduce((e,t)=>e+(v.get(t)?.length??0),0)),markerInkCount:D[0]?.length??0}:void 0;if(k&&(k.markerInkCount!==1||!D[1]?.length))continue;let A=1/0,j=-1/0;for(let t of a){let n=e.block.getPositionX(t);A=Math.min(A,n),j=Math.max(j,n+e.block.getWidth(t))}b.push({run:Bh(t.runs),pageIndex:t.pageIndex,alignment:t.alignment,sources:a,spacing:d,expected:f,expectedInk:O,expectedFrame:o.preserveFrameBounds?xg(e,a):void 0,x:A,y:e.block.getPositionY(a[0]),width:t.alignment===`Justify`?$(e,t.runs[0].advanceWidthPt):j-A,bullet:k})}});try{for(let t of b){let{sources:n,spacing:i,expected:a,expectedInk:o,expectedFrame:s,x:c,y:l,width:f}=t,p=await r(t.run,t.pageIndex);p!==null&&(d.add(p),e.block.getType(p).endsWith(`/text`)&&(e.block.setPositionX(p,c),e.block.setPositionY(p,l),e.block.setWidth(p,f),e.block.setEnum(p,`text/horizontalAlignment`,t.alignment),e.block.setFloat(p,`text/letterSpacing`,i),e.block.setFloat(p,`text/lineHeight`,1),u.push({id:p,sources:n,expected:a,expectedInk:o,expectedFrame:s,first:[0,0,0,0],gap:0,keep:!1,bullet:t.bullet})))}if(u.length===0)return;i(()=>{for(let t of u)e.block.appendChild(e.block.getParent(t.sources[0]),t.id);a();let t=/* @__PURE__ */ new Set;for(let n of u){if(!n.bullet)continue;let r=y(n.id),i=n.expectedInk,a=n.bullet.markerInkCount;if(!r?.[a]||!i?.[a]){t.add(n);continue}let o=(i[a][0]-i[0][0]-(r[a][0]-r[0][0]))/n.bullet.fontSize;!Number.isFinite(o)||Math.abs(o)>2?t.add(n):(h.call(e.block,n.id,o,0,1),v.delete(n.id))}u.some(e=>e.bullet)&&(e.block.setRotation(u[0].id,0),a());let n=u.filter(n=>!t.has(n)&&Dg(e,n));for(let t of n)t.first=wg(e,t.id,0).box,t.gap=t.expected.length>1?wg(e,t.id,1).box[1]-t.first[1]:0;for(let t of n)e.block.setFloat(t.id,`text/lineHeight`,2);n.length>0&&e.block.setRotation(n[0].id,0),a();let r=[];for(let t of n){let n=wg(e,t.id,0).box;if(t.expected.length===1){r.push({probe:t,height:1,x:e.block.getPositionX(t.id)+t.expected[0].box[0]-n[0],y:e.block.getPositionY(t.id)+t.expected[0].box[1]-t.first[1]});continue}let i=wg(e,t.id,1).box[1]-n[1]-t.gap,a=1+(t.expected[1].box[1]-t.expected[0].box[1]-t.gap)/i;if(!Number.isFinite(a)||a<=0||Math.abs(i)<f)continue;let o=t.first[1]+(a-1)*(n[1]-t.first[1]);r.push({probe:t,height:a,x:e.block.getPositionX(t.id)+t.expected[0].box[0]-n[0],y:e.block.getPositionY(t.id)+t.expected[0].box[1]-o})}for(let{probe:t,height:n,x:i,y:a}of r)e.block.setFloat(t.id,`text/lineHeight`,n),e.block.setPositionX(t.id,i),e.block.setPositionY(t.id,a);r.length>0&&e.block.setRotation(r[0].probe.id,0),a();for(let{probe:t}of r)if(Dg(e,t)){if(t.keep=t.expected.every((n,r)=>wg(e,t.id,r).box.every((e,i)=>Number.isFinite(e)&&(t.bullet&&r>0&&i===0||Math.abs(e-n.box[i])<=f))),t.keep&&t.expectedInk!==void 0){let n=y(t.id);t.keep=n!==void 0&&n.length===t.expectedInk.length&&(t.bullet?Cg(e,t,n,f):t.expectedInk.every((e,t)=>n[t].every((t,n)=>Number.isFinite(t)&&Math.abs(t-e[n])<=f)))}if(t.keep&&t.expectedFrame!==void 0){let n=xg(e,[t.id]);t.keep=n.every((e,n)=>Number.isFinite(e)&&Number.isFinite(t.expectedFrame[n])&&Math.abs(e-t.expectedFrame[n])<=f)||p!==void 0&&Sg(p,t.expectedFrame,f)&&Sg(p,n,f)}}let i=/* @__PURE__ */ new Set;for(let t of u){if(!t.keep||t.sources.some(e=>i.has(e)))continue;let n=e.block.getParent(t.sources[0]),r=e.block.getChildren(n).indexOf(t.sources[0]);e.block.insertChild(n,t.id,r);for(let n of t.sources)e.block.destroy(n),i.add(n);d.delete(t.id)}for(let t of d)e.block.destroy(t);d.clear(),a()})}finally{for(let t of d)e.block.destroy(t)}}function xg(e,t){let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let o of t){let t=e.block.getGlobalBoundingBoxX(o),s=e.block.getGlobalBoundingBoxY(o);n=Math.min(n,t),r=Math.min(r,s),i=Math.max(i,t+e.block.getGlobalBoundingBoxWidth(o)),a=Math.max(a,s+e.block.getGlobalBoundingBoxHeight(o))}return[n,r,i-n,a-r]}function Sg(e,t,n){return[...e,...t].every(Number.isFinite)&&t[0]>=e[0]-n&&t[1]>=e[1]-n&&t[0]+t[2]<=e[0]+e[2]+n&&t[1]+t[3]<=e[1]+e[3]+n}function Cg(e,t,n,r){let i=0;for(let[a,o]of t.bullet.lineInkCounts.entries()){let s=a===0?0:wg(e,t.id,a).box[0]-t.expected[a].box[0];for(let e=i;e<i+o;e++){let i=t.expectedInk[e];if(!n[e].every((e,t)=>Number.isFinite(e)&&Math.abs(e-i[t]-(t===0?s:0))<=r))return!1}i+=o}return!0}function wg(e,t,n){try{return{text:e.block.getTextVisibleLineContent(t,n),box:e.block.getTextVisibleLineGlobalBoundingBoxXYWH(t,n)}}catch{return{text:``,box:[NaN,NaN,NaN,NaN]}}}function Tg(e,t){let n=1/0,r=1/0,i=-1/0,a=-1/0,o=``;for(let s of t){let t=wg(e,s,0);n=Math.min(n,t.box[0]),r=Math.min(r,t.box[1]),i=Math.max(i,t.box[0]+t.box[2]),a=Math.max(a,t.box[1]+t.box[3]),o+=(o&&!/\s$/.test(o)&&!/^\s/.test(t.text)?` `:``)+t.text}return{text:o,box:[n,r,i-n,a-r]}}function Eg(e,t){if(t.length<2)return!1;let n=t.map(t=>wg(e,t,0).box).sort((e,t)=>e[0]-t[0]),r=-1/0;for(let e of n){if(e[0]<r)return!0;r=Math.max(r,e[0]+e[2])}return!1}function Dg(e,t){try{return e.block.getTextVisibleLineCount(t.id)===t.expected.length&&t.expected.every((n,r)=>e.block.getTextVisibleLineContent(t.id,r)===n.text)}catch{return!1}}function Og(e,t){try{return e.block.getTextVisibleLineCount(t)===1}catch{return!1}}const kg=4096,Ag=.25;function jg(e,t,n){let r=e.block.setTextDecoration;if(n.length===0)return!0;if(typeof r!=`function`)return!1;for(let i of n)r.call(e.block,t,{lines:[`Underline`],...i.color?{underlineColor:Kg(i.color)}:{},underlineThickness:i.thickness,underlineOffset:i.offset,skipInk:!1},i.from,i.to);return!0}async function Mg(e,t,n,r,i,a={}){let o={textRuns:/* @__PURE__ */ new Map,consumed:/* @__PURE__ */ new Set},s=e.block,c=s.setTextDecoration,l=s.getTextCharacterInkBoxes;if(typeof c!=`function`||typeof l!=`function`||typeof e.editor.getFontMetrics!=`function`||typeof Intl.Segmenter!=`function`||t.length===0||n.length===0)return o;let u=n.flatMap(e=>{let t=Hg(e.ir);return t?[{...e,color:t}]:[]});if(u.length===0)return o;let d=[],f=[],p=/* @__PURE__ */ new Map,m=/* @__PURE__ */ new Map,h=new Intl.Segmenter(void 0,{granularity:`grapheme`}),g=/* @__PURE__ */ new Map,_=/* @__PURE__ */ new Map,v=/* @__PURE__ */ new Map,y=/* @__PURE__ */ new Set,b=0;r(()=>{i();for(let t of u)try{let n=Fg(e,t.id);Ig(n)&&n.width>4*n.height&&n.height>0&&d.push({...t,box:n,parent:e.block.getParent(t.id)})}catch{}if(d.length===0)return;for(let n of t){let t=n.ir;if(!(Math.abs(t.rotation)>1e-6||(t.opacity??1)!==1||t.clips?.length||!Ug(t.blendMode)||(t.renderMode??0)!==0||t.styleSpans?.some(e=>e.fontRef!==t.fontRef)))try{if(!e.block.getType(n.id).endsWith(`/text`)||e.block.getTextVisibleLineCount(n.id)!==1||e.block.getTextVisibleLineContent(n.id,0)!==t.text)continue;let[r,i,a,o]=e.block.getTextVisibleLineGlobalBoundingBoxXYWH(n.id,0),s={x:r,y:i,width:a,height:o},c=$(e,t.fontSize);Ig(s)&&Number.isFinite(c)&&c>0&&f.push({...n,line:s,em:c,parent:e.block.getParent(n.id)})}catch{}}for(let e of d){if(e.parent===null)continue;let t=p.get(e.parent)??[];t.push(e),p.set(e.parent,t)}for(let e of f){if(e.parent===null)continue;let t=m.get(e.parent)??[];t.push(e),m.set(e.parent,t)}for(let[e,t]of p)t.length*(m.get(e)?.length??0)>kg&&p.delete(e);for(let t of f){let n=t.parent===null?[]:p.get(t.parent);if(b>=512||!n?.some(e=>Bg(e,t)))continue;let r=[...h.segment(t.ir.text)];if(!(r.length>4096)){b++;try{let n=l.call(e.block,t.id),i=n.filter(e=>e.width!==0||e.height!==0),a=i[0]?.baselineY;if(!Number.isFinite(a)||i.some(e=>!Number.isFinite(e.baselineY)||Math.abs(e.baselineY-a)>t.em*.01))continue;_.set(t.id,a),v.set(t.id,n),g.set(t.id,Vg(t.ir.text,r,n))}catch{g.set(t.id,null)}}}let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,o=t=>(r.has(t)||r.set(t,Fg(e,t)),r.get(t)),s=0;for(let t of d){if(!p.has(t.parent))continue;let r=m.get(t.parent)?.filter(e=>Bg(t,e))??[];if(r.length===1&&g.get(r[0].id))try{if(a.preserveFrameBounds){let e=o(r[0].id),n=e=>Ig(e)&&Rg(e,t.box);if(!n(e)&&(a.boundsAnchor===void 0||!n(o(a.boundsAnchor))))continue}n.has(t.parent)||n.set(t.parent,e.block.getChildren(t.parent));let i=n.get(t.parent);if(i.length>kg)continue;let c=i.indexOf(r[0].id),l=i.indexOf(t.id);if(c<0||l<0||l<c&&!zg(r[0].ir,t.color)&&g.get(r[0].id).some(({box:e})=>Lg(e,t.box)))continue;let u=!1;for(let e=Math.min(c,l)+1;e<Math.max(c,l);e++){if(++s>kg)return;let n=i[e],r=o(n);if(!Ig(r)||Lg(r,t.box)){u=!0;break}}u||y.add(t)}catch{}}});let x=/* @__PURE__ */ new Map,S=Ng(e);for(let t of d){if(!y.has(t))continue;let n=(t.parent===null?[]:m.get(t.parent))?.filter(e=>Bg(t,e))??[];if(n.length!==1)continue;let r=n[0],i=g.get(r.id);if(!i)continue;let a=r.em*Ag,s=i.filter(({box:e})=>e.x+e.width>t.box.x&&e.x<t.box.x+t.box.width);if(!s.length||s.some(({box:e})=>e.x<t.box.x-a||e.x+e.width>t.box.x+t.box.width+a))continue;let c=s[0],l=s[s.length-1];if(Math.abs(c.box.x-t.box.x)>a||Math.abs(l.box.x+l.box.width-t.box.x-t.box.width)>a||!await Pg(e,r,t.box,c.from,l.to,v.get(r.id),S))continue;let u=o.textRuns.get(r.ir)??r.ir;if(u.underlineSpans?.some(e=>e.from<l.to&&e.to>c.from))continue;let d;try{let t=e.block.getString(r.id,`text/fontFileUri`);x.has(t)||x.set(t,e.editor.getFontMetrics(t).catch(()=>null)),d=await x.get(t)}catch{continue}if(!d||!(d.underlineOffset<0)||!(d.underlineSize>0))continue;let f=_.get(r.id),p=t.box.y-f;if(p<0||p>r.em*.3)continue;let h=ne(r.em,d,t.box.height,p+t.box.height/2);if(!h)continue;let b={from:c.from,to:l.to,color:t.color,thickness:h.thickness,offset:h.relativeOffset};try{if(!jg(e,r.id,[b]))continue}catch{continue}e.block.destroy(t.id),o.consumed.add(t.ir),o.textRuns.set(r.ir,{...u,underlineSpans:[...u.underlineSpans??[],b]})}return o.consumed.size>0&&r(i),o}function Ng(e){let t=/* @__PURE__ */ new Map,n=0;return r=>{if(!t.has(r)){if(t.size>=16)return Promise.resolve(null);t.set(r,(async()=>{try{if(typeof e.editor.getResourceData!=`function`)return null;let t=[],i=0,a=!1;if(e.editor.getResourceData(r,65536,e=>(n+=e.length,n>16777216?(a=!0,!1):(t.push(new Uint8Array(e)),i+=e.length,!0))),a||i===0)return null;let o=new Uint8Array(i),s=0;for(let e of t)o.set(e,s),s+=e.length;let c=new DataView(o.buffer);if(![65536,1330926671].includes(c.getUint32(0))||Array.from({length:c.getUint16(4)},(e,t)=>{let n=12+t*16;return String.fromCharCode(...o.subarray(n,n+4))}).some(e=>[`GSUB`,`GPOS`,`kern`,`kerx`,`morx`,`mort`,`fvar`,`CFF2`].includes(e)))return null;let{default:l}=await Promise.resolve().then(()=>/* @__PURE__ */ u(wl(),1));return l.parse(o.buffer)}catch{return null}})())}return t.get(r)}}async function Pg(e,t,n,r,i,a,o){let s=t.ir.text;if(t.ir.styleSpans?.length||t.ir.colorSpans?.length||!/^[\x20-\x7e]+$/.test(s)||!/^[A-Za-z]$/.test(s[r])||!/^[A-Za-z]$/.test(s[i-1])||i<s.length&&s[i]!==` `)return!1;try{let c=e.block.getTextKernings;if(typeof c!=`function`||c.call(e.block,t.id,r,i).some(e=>e!==0))return!1;let l=await o(e.block.getString(t.id,`text/fontFileUri`));if(!l||!(l.unitsPerEm>0))return!1;let u=l.charToGlyph(s[r]),d=l.charToGlyph(s[i-1]);if(u.index===0||d.index===0)return!1;let f=t.em/l.unitsPerEm,p=$(e,.05);for(let[e,t]of[[u,a[r]],[d,a[i-1]]]){let n=e.getBoundingBox();if(!t||!Ig(t)||Math.abs((n.x2-n.x1)*f-t.width)>p||Math.abs((n.y2-n.y1)*f-t.height)>p)return!1}let m=a[r].x-u.getBoundingBox().x1*f,h=a[i-1].x-d.getBoundingBox().x1*f+d.advanceWidth*f,g=Math.min($(e,.5),t.em*.05);return Number.isFinite(m)&&Number.isFinite(h)&&Math.abs(m-n.x)<=g&&Math.abs(h-n.x-n.width)<=g}catch{return!1}}function Fg(e,t){return{x:e.block.getGlobalBoundingBoxX(t),y:e.block.getGlobalBoundingBoxY(t),width:e.block.getGlobalBoundingBoxWidth(t),height:e.block.getGlobalBoundingBoxHeight(t)}}function Ig(e){return Object.values(e).every(Number.isFinite)&&e.width>0&&e.height>0}function Lg(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Rg(e,t){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height}function zg(e,t){let n=JSON.stringify(Kg(t));return[e.fill,...(e.colorSpans??[]).map(({fill:e})=>e)].every(e=>e!=null&&JSON.stringify(Kg(e))===n)}function Bg(e,t){return e.parent!==null&&e.parent===t.parent&&e.box.height<=t.em*.2&&e.box.x<t.line.x+t.line.width&&e.box.x+e.box.width>t.line.x&&e.box.y>=t.line.y+t.line.height*.55&&e.box.y<=t.line.y+t.line.height+t.em*Ag}function Vg(e,t,n){if(n.length!==t.length)return null;let r=[],i=0;for(let a of e.matchAll(/\S+/gu)){let e=a.index,o=e+a[0].length,s=[];for(;i<t.length&&t[i].index<e;)i++;for(;i<t.length&&t[i].index<o;){let e=n[i++];(e.width!==0||e.height!==0)&&s.push(e)}if(!s.length||s.some(e=>!Ig(e)))return null;let c=Math.min(...s.map(e=>e.x)),l=Math.min(...s.map(e=>e.y));r.push({from:e,to:o,box:{x:c,y:l,width:Math.max(...s.map(e=>e.x+e.width))-c,height:Math.max(...s.map(e=>e.y+e.height))-l}})}return r}function Hg(e){if((e.opacity??1)!==1||e.clips?.length||!Ug(e.blendMode)||e.strokeDashArray?.length||!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<0)return null;let t=e.fill&&`space`in e.fill?e.fill:null,n=e.stroke;if(!!t==!!n)return null;let r=t??n;if((r.alpha??1)!==1||![`rgb`,`gray`,`cmyk`].includes(r.space)||r.values.length!=={rgb:3,gray:1,cmyk:4}[r.space]||r.values.some(e=>!Number.isFinite(e)||e<0||e>1))return null;let i=Gg(e.d);if(!i||Math.abs(Math.min(...i.values.map(([e])=>e)))>.02||Math.abs(Math.max(...i.values.map(([e])=>e))-e.width)>.02)return null;if(n){if(e.fill||e.strokeCap&&e.strokeCap!==`Butt`||!(e.strokeWidth>0)||i.closed||i.values.length!==2||Math.abs(i.values[0][1]-i.values[1][1])>.02)return null}else{let t=i.values;if(t.length===5&&Wg(t[0],t[4])&&t.pop(),t.length!==4||!t.every((e,n)=>{let r=t[(n+1)%4];return Math.abs(e[0]-r[0])<=.02!=Math.abs(e[1]-r[1])<=.02})||new Set(t.map(([e,t])=>`${e},${t}`)).size!==4||Math.abs(Math.min(...t.map(([,e])=>e)))>.02||Math.abs(Math.max(...t.map(([,e])=>e))-e.height)>.02)return null}return r}function Ug(e){return e==null||e===`normal`||e===`source-over`}function Wg(e,t){return Math.abs(e[0]-t[0])<=.02&&Math.abs(e[1]-t[1])<=.02}function Gg(e){let t=e.match(/[MLHVZ]|[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:[eE][-+]?\d+)?/g);if(!t||t.length>20||e.replace(/[MLHVZ]|[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:[eE][-+]?\d+)?|[\s,]/g,``))return null;let n=[],r=!1;for(let e=0;e<t.length;){let i=t[e++];if(n.length===0&&i!==`M`)return null;if(i===`M`&&n.length>0){let r=[Number(t[e++]),Number(t[e++])];if(n.length!==1||!r.every(Number.isFinite)||!Wg(n[0],r))return null;continue}if(i===`Z`){if(r=!0,e!==t.length)return null;break}let a=Number(t[e++]),o=n[n.length-1],s=i===`H`?[a,o[1]]:i===`V`?[o[0],a]:[a,Number(t[e++])];if(![`M`,`L`,`H`,`V`].includes(i)||!s.every(Number.isFinite))return null;n.push(s)}return{values:n,closed:r}}function Kg(e){if(e.space===`cmyk`){let[t,n,r,i]=e.values;return{c:t,m:n,y:r,k:i,tint:1}}let[t,n=t,r=t]=e.values;return{r:t,g:n,b:r,a:1}}function qg(e){let t=e.letterSpacingSpans??[];if(t.length>256)return;let n=0;for(let{from:r,to:i,em:a}of t){if(!Number.isInteger(r)||!Number.isInteger(i)||r<n||i<=r||i>e.text.length||!Number.isFinite(a)||Math.abs(a)>2)return;n=i}return t}const Jg=.01;function*Yg(e={}){let t=yield 0;return t>1?yield*Xg(t):e.allowWiden===!1?{ls:0,lines:t,direction:`unchanged`}:yield*Zg()}function*Xg(e){let t=0,n=e;for(let e=0;e<15;e++){let e=Math.max(-.15,t-Jg);if(e===t)break;if(t=e,n=yield t,n<=1)return{ls:t,lines:n,direction:`tightened`}}return{ls:t,lines:n,direction:`tightened`}}function*Zg(){let e=0,t=1;for(let n=0;n<15;n++){let n=Math.min(.03,e+Jg);if(n===e)break;let r=yield n;if(r>1)break;e=n,t=r}let n=Math.max(0,e-2*Jg);return n!==e&&(t=yield n),{ls:n,lines:t,direction:n>0?`widened`:`unchanged`}}const Qg=`ly.img.pdf-importer.pageBounds`;async function $g(e,t,n={}){let r=e.scene.create(`VerticalStack`);e.scene.setDesignUnit(`Inch`);let i=e.block.findByType(`stack`)[0];e.block.setFloat(i,`stack/spacing`,H_),e.block.setBool(i,`stack/spacingInScreenspace`,U_);let a=[],o={fontResolver:n.fontResolver??null,fontStrategy:n.fontStrategy??_h,logger:n.logger??null,resolverCache:/* @__PURE__ */ new Map,textRuns:a,vectorPaths:[],substitutions:/* @__PURE__ */ new Map,subsetFallbacks:/* @__PURE__ */ new Set,vectorPathFillRuleSupport:hp(),strokeOutlines:/* @__PURE__ */ new WeakMap,irFonts:t.fonts,preserveWordSpacing:n.textLayout!==`lines`,profileBudget:$p()},s=n.pageBounds??`trim`;Dh(e,t.outputIntent,o.logger),X_(e,t,o.logger);let c=op(e,ip(e,r));return Qm(e,async(c,l)=>{o.flush=c,o.unbatched=l,o.pendingRotations=[];let u=[];for(let n=0;n<t.pages.length;n++){let r=t.pages[n];o.pageIndex=n+1;let i=e.block.create(`page`);e.block.setWidth(i,$(e,r.widthPt)),e.block.setHeight(i,$(e,r.heightPt));let a=[],s=[];for(let n of r.blocks.flatMap(t=>m_(e,t,o))){let r=await d_(e,n,t,i,o);r!=null&&(s.push(r),n.kind===ae.VECTOR_PATH&&o.vectorPaths.push({id:r,ir:n}),n.kind===ae.IMAGE&&a.push({block:r,ir:n}))}for(let t of n_(r))s.push(r_(e,r,t));for(let t of s)e.block.appendChild(i,t);u.push({pageBlock:i,page:r,placements:a})}for(let{pageBlock:t}of u)e.block.appendChild(i,t);c();for(let{id:t,rotation:n}of o.pendingRotations??[])e.block.setRotation(t,lp(e,n));for(let{pageBlock:t,page:n,placements:r}of u){r.length>0&&fm(e,r[0].block);for(let t of r)dm(e,t.block,t.ir,{logger:o.logger??void 0});l_(e,t,n,s)}if(await a_(e,a.map(({id:e})=>e),{flush:c,logger:o.logger}),c(),a.length>0&&fm(e,a[0].id),W_(e,a,o,c),n.textLayout!==`lines`){let n=await u_(e,t.pages.map(e=>e.blocks),a,o.vectorPaths,e=>e(),c),r,s=()=>{if(r!==void 0){for(let{pageBlock:t}of u)e.block.appendChild(i,t);e.block.destroy(r),r=void 0}};try{await bg(e,n.pages,n.entries,(n,i)=>{if(r===void 0){r=e.block.create(`page`);for(let{pageBlock:t}of u)e.block.appendChild(r,t)}return E_(e,n,t,{...o,pageIndex:i,textRuns:[],paragraphProbe:!0})},e=>{s(),e()},c)}finally{s()}}return Ah(e,t.pages.map((e,t)=>({page:e,pageIndex:t})),o.logger),s_(o),c_(o),r}).finally(c)}async function e_(e,t,n={}){yh(n,t.pages.reduce((e,t,r)=>n.pageIndex===void 0||n.pageIndex===r?e+t.blocks.length:e,0));let r=new wh(e,n),i=r.engine;n.legacyUnits&&rp(i);try{let e=[],a={fontResolver:n.fontResolver??null,fontStrategy:n.fontStrategy??_h,logger:n.logger??null,resolverCache:/* @__PURE__ */ new Map,textRuns:e,vectorPaths:[],substitutions:/* @__PURE__ */ new Map,subsetFallbacks:/* @__PURE__ */ new Set,vectorPathFillRuleSupport:hp(),strokeOutlines:/* @__PURE__ */ new WeakMap,irFonts:t.fonts,preserveWordSpacing:n.textLayout!==`lines`,profileBudget:$p()},o=n.pageIndex==null?t.pages.map((e,t)=>t):[n.pageIndex];X_(i,{...t,pages:o.map(e=>t.pages[e]).filter(Boolean)},a.logger,!0),Oh(t.outputIntent,a.logger);let s=[],c=[],l=/* @__PURE__ */ new Map;for(let u of o){let o=t.pages[u];if(o==null||o.blocks.length===0)continue;a.pageIndex=u+1;let d=n.pageBounds===`trim`?o.trimPt:null,f=i_(i,d?{...o,widthPt:d.widthPt,heightPt:d.heightPt}:o),p=i.block.create(`page`);r.parkPage(p),c.push(p),i.block.setWidth(p,$(i,o.widthPt)),i.block.setHeight(p,$(i,o.heightPt)),i.block.appendChild(p,f);let m=[],h=e.length,g=[];for(let e of o.blocks.flatMap(e=>m_(i,e,a))){let n=await r.wait(d_(i,e,t,p,a));n!=null&&(g.push(n),e.kind===ae.VECTOR_PATH&&a.vectorPaths.push({id:n,ir:e}),e.kind===ae.IMAGE&&m.push({block:n,ir:e}))}for(let e of g)i.block.appendChild(p,e);m.length>0&&r.withLayout(p,()=>{for(let e of m)dm(i,e.block,e.ir,{logger:a.logger??void 0})});let _=i.block.getChildren(p);if(_.length===1){i.block.destroy(p);continue}if(d)for(let e of _)e!==f&&(i.block.setPositionX(e,i.block.getPositionX(e)-$(i,d.xPt)),i.block.setPositionY(e,i.block.getPositionY(e)-$(i,d.yPt)));let v=i.block.group(_);t_(i,v,o),n.preservePageBounds||i.block.destroy(f),s.push(v),l.set(p,{runs:e.slice(h),widthPt:d?.widthPt??o.widthPt,blocks:o.blocks,pageIndex:u+1,boundsAnchor:n.preservePageBounds?f:void 0})}await r.wait(a_(i,e.map(({id:e})=>e),{signal:n.signal,logger:a.logger}));for(let[e,{runs:o,widthPt:s,blocks:c,pageIndex:u,boundsAnchor:d}]of l)if(o.length>0){if(n.legacyUnits)W_(i,o,a,void 0,!1);else{let l=th(i)??(()=>fm(i,e));if(r.withLayout(e,()=>{l(),W_(i,o,a,l),G_(i,o,s,l)}),n.textLayout!==`lines`&&n.maxBlocks===void 0){let n=await u_(i,[c],o,a.vectorPaths.filter(({ir:e})=>c.includes(e)),t=>r.withLayout(e,t),l,{preserveFrameBounds:!0,boundsAnchor:d});await bg(i,n.pages,n.entries,e=>r.wait(E_(i,e,t,{...a,pageIndex:u,textRuns:[],paragraphProbe:!0})),t=>r.withLayout(e,t),l,{preserveFrameBounds:!0,boundsAnchor:d})}}}Ah(i,o.filter(e=>t.pages[e]!=null).map(e=>({page:t.pages[e],pageIndex:e})),a.logger),s_(a),c_(a);let u=s.map(e=>{let t=i.block.duplicate(e,!1);for(let e of i.block.getChildren(t))i.block.findAllMetadata(e).includes(Qg)&&i.block.setScopeEnabled(e,`editor/select`,!1);return t});for(let e of c)i.block.isValid(e)&&i.block.destroy(e);return r.finish(),{blocks:u,dispose:()=>r.dispose()}}catch(e){return r.rollback(e)}}function t_(e,t,n){for(let r of n.pathSpotColors??[]){let{name:n}=r;n!=null&&e.block.setMetadata(t,`ly.img.pdf-importer.spotColor.${n}`,`true`)}}function n_(e){let t=/* @__PURE__ */ new Set,n=e=>{let n=e;n?.space===`spot`&&n.name!=null&&t.add(n.name)};for(let t of e.blocks){n(t.fill),n(t.stroke);let e=t.colorSpans;for(let t of e??[])n(t.fill)}return(e.pathSpotColors??[]).flatMap(e=>{let{name:n}=e;return n!=null&&!t.has(n)?[n]:[]})}function r_(e,t,n){let r=e.block.create(`graphic`),i=e.block.createShape(`vector_path`);e.block.setString(i,`vector_path/path`,`M 0 0 L 0 0`),e.block.setShape(r,i);let a=t.trimPt??{xPt:0,yPt:0,widthPt:t.widthPt,heightPt:t.heightPt};return e.block.setPositionX(r,$(e,a.xPt+a.widthPt/2)),e.block.setPositionY(r,$(e,a.yPt+a.heightPt/2)),e.block.setWidth(r,0),e.block.setHeight(r,0),e.block.setBool(r,`stroke/enabled`,!0),e.block.setColor(r,`stroke/color`,{name:n,tint:1,externalReference:``}),e.block.setFloat(r,`stroke/width`,$(e,1)),e.block.setName(r,`PDF ink ${n}`),e.block.setMetadata(r,`ly.img.pdf-importer.inkDeclaration`,n),e.block.setScopeEnabled(r,`editor/select`,!1),r}function i_(e,t){let n=e.block.create(`graphic`);e.block.setShape(n,e.block.createShape(`rect`)),e.block.setWidth(n,$(e,t.widthPt)),e.block.setHeight(n,$(e,t.heightPt)),e.block.setPositionX(n,0),e.block.setPositionY(n,0);let r=e.block.createFill(`color`);return e.block.setColor(r,`fill/color/value`,{r:0,g:0,b:0,a:0}),e.block.setFill(n,r),e.block.setBool(n,`fill/enabled`,!1),e.block.setName(n,`PDF page bounds`),e.block.setMetadata(n,Qg,`true`),e.block.setScopeEnabled(n,`editor/select`,!1),n}async function a_(e,t,n={}){let{timeoutMs:r=1e4,flush:i,logger:a,signal:o}=n;if(typeof e.block.getState!=`function`||typeof e.block.onStateChanged!=`function`)return;let s=t=>{try{let n=e.block.getState(t);return n.type===`Ready`||n.type===`Error`}catch{return!0}},c=t.filter(e=>!s(e));c.length!==0&&await new Promise((t,n)=>{let l=new Set(c),u=null,d=i===void 0?null:setInterval(i,o_),f=(e=!1,i)=>{u?.(),clearTimeout(m),d!==null&&clearInterval(d),o?.removeEventListener(`abort`,p),e&&l.size>0&&a?.emit?.(`TEXT_FONTS_READY_TIMEOUT`,{count:l.size,timeoutMs:r}),i?n(i):t()},p=()=>f(!1,new DOMException(`PDF import was aborted.`,`AbortError`)),m=setTimeout(()=>f(!0),r);o?.addEventListener(`abort`,p,{once:!0}),u=e.block.onStateChanged(c,e=>{for(let t of e)s(t)&&l.delete(t);l.size===0&&f()});for(let e of c)s(e)&&l.delete(e);l.size===0&&f(),o?.aborted&&p()})}const o_=100;function s_(e){if(e.substitutions.size===0)return;let t=Array.from(e.substitutions.entries()).map(([e,t])=>`${e} → ${t}`).join(`, `),n=e.substitutions.size;e.logger?.emit?.(`FONT_SUBSTITUTIONS`,{count:n,plural:n===1?`y`:`ies`,pairs:t})}function c_(e){if(e.subsetFallbacks.size===0)return;let t=Array.from(e.subsetFallbacks).sort().join(`, `),n=e.subsetFallbacks.size;e.logger?.emit?.(`FONT_SUBSET_FALLBACK`,{count:n,plural:n===1?`y`:`ies`,families:t})}function l_(e,t,n,r){if(r===`media`||!n.trimPt)return;let{xPt:i,yPt:a,widthPt:o,heightPt:s}=n.trimPt,c=$(e,i),l=$(e,a);if(c!==0||l!==0)for(let n of e.block.getChildren(t))e.block.setPositionX(n,e.block.getPositionX(n)-c),e.block.setPositionY(n,e.block.getPositionY(n)-l);e.block.setWidth(t,$(e,o)),e.block.setHeight(t,$(e,s)),n.hasBleed&&(e.block.setBool(t,`page/marginEnabled`,!0),e.block.setFloat(t,`page/margin/top`,$(e,n.bleedPt.top)),e.block.setFloat(t,`page/margin/bottom`,$(e,n.bleedPt.bottom)),e.block.setFloat(t,`page/margin/left`,$(e,n.bleedPt.left)),e.block.setFloat(t,`page/margin/right`,$(e,n.bleedPt.right)))}async function u_(e,t,n,r,i,a,o={}){let s=await Mg(e,n,r,i,a,o);return{pages:t.map(e=>e.filter(e=>e.kind!==ae.VECTOR_PATH||!s.consumed.has(e)).map(e=>e.kind===ae.TEXT_RUN?s.textRuns.get(e)??e:e)),entries:n.map(e=>({...e,ir:s.textRuns.get(e.ir)??e.ir}))}}async function d_(e,t,n,r,i){switch(t.kind){case ae.IMAGE:return f_(e,t,r,i);case ae.VECTOR_PATH:return v_(e,t,r,i);case ae.TEXT_OUTLINE:case ae.TEXT_RUN:return await E_(e,t,n,i);default:return i?.logger?.emit?.(`BLOCK_KIND_UNKNOWN`,{kind:t.kind}),null}}function f_(e,t,n,r){if(t.clips?.length){let i=_m(e,t,t.clips,n,{logger:r?.logger??void 0,pageIndex:r?.pageIndex,profileBudget:r?.profileBudget,flush:r?.flush,unbatched:r?.unbatched});return i===gm?null:i??(r?.logger?.emit?.(`IMAGE_CLIP_COMBINE_FAILED`,{prefix:Q_(r),bbox:$l(t),clipCount:t.clips.length,page:r?.pageIndex}),null)}let i=e.block.create(`graphic`),a=e.block.createShape(`rect`);if(e.block.setShape(i,a),!um(e,i,t,{logger:r?.logger??void 0,pageIndex:r?.pageIndex,profileBudget:r?.profileBudget})){try{e.block.destroy(i)}catch{}return null}return Y_(e,i,t),t.rotation&&Math.abs(t.rotation)>1e-6&&(r?.pendingRotations?r.pendingRotations.push({id:i,rotation:t.rotation}):e.block.setRotation(i,lp(e,t.rotation))),t.opacity!=null&&t.opacity!==1&&e.block.setOpacity(i,t.opacity),C_(e,i,t.blendMode,r),i}function p_(e){let t=e.block;return typeof t.setStrokeDashArray==`function`&&typeof t.setStrokeStartCap==`function`&&typeof t.setStrokeEndCap==`function`&&typeof t.setStrokeDashStartCap==`function`&&typeof t.setStrokeDashEndCap==`function`?t:null}function m_(e,t,n){if(t.kind!==ae.VECTOR_PATH||!t.fill||!t.stroke)return[t];let r={...t,fill:null},{clips:i,outline:a}=h_(e,r,n);return i.length===0?[t]:a?[{...t,stroke:null},r]:(h_(e,t,n).clips.length>0&&n.logger?.emit?.(`CLIP_STROKE_DROPPED`,{prefix:Q_(n),bbox:$l(t),page:n.pageIndex}),[t])}function h_(e,t,n){let r=t.clips??[];if(t.fill||!t.stroke||!((t.strokeWidth??0)>0))return{clips:r.filter(e=>!g_(e,t,__(e)?.5:1e-6))};let i=jp(t),a=r.filter(e=>!g_(e,i,1e-6));if(a.length===0)return{clips:a};let o=n.strokeOutlines.get(t);o===void 0&&(o=Mp(t)??(yp(e,n.vectorPathFillRuleSupport)?Ip(t):null),n.strokeOutlines.set(t,o));let s=o;return{clips:s?a.filter(e=>!g_(e,s,1e-6)):a,outline:o}}function g_(e,t,n=.5){let r=n;return e.x<=t.x+r&&e.y<=t.y+r&&e.x+e.width>=t.x+t.width-r&&e.y+e.height>=t.y+t.height-r&&bm(e.d)}function __(e){return Math.abs(e.x)<.01&&Math.abs(e.y)<.01}function v_(e,t,n,r){let{clips:i,outline:a}=h_(e,t,r);if(i.length){let o=xm(e,t,i,n,{strokeOutline:a,logger:r?.logger??void 0,pageIndex:r?.pageIndex,vectorPathFillRuleSupport:r.vectorPathFillRuleSupport,flush:r?.flush,unbatched:r?.unbatched});if(o===gm)return null;if(o!=null)return y_(e,o,{fill:b_(t.fill??t.stroke)}),o;r?.logger?.emit?.(`CLIP_COMBINE_FAILED`,{prefix:Q_(r),bbox:$l(t),clipCount:i.length,page:r?.pageIndex})}let o=e.block.create(`graphic`);r.paragraphAllocations?.add(o);let s=mp(e,t.d,t.width,t.height);if(bp(e,s,t.fillRule,{logger:r?.logger??null,support:r.vectorPathFillRuleSupport}),e.block.setShape(o,s),t.fill){let n=t.fill.kind;if(n===`linearGradient`||n===`radialGradient`)w_(e,o,t,r);else{let n=e.block.createFill(`color`);e.block.setColor(n,`fill/color/value`,Z_(t.fill,r,t,`vector path fill`)),e.block.setFill(o,n)}}else e.block.setFillEnabled(o,!1);if(t.stroke){if(e.block.setStrokeEnabled(o,!0),e.block.setStrokeColor(o,Z_(t.stroke,r,t,`vector path stroke`)),t.strokeWidth!=null&&e.block.setStrokeWidth(o,$(e,t.strokeWidth)),t.strokeGradient){let n=e.block.setStrokeFill;typeof n==`function`?n.call(e.block,o,T_(e,t.strokeGradient,t,r)):r.logger?.emit?.(`PATTERN_PAINT_UNSUPPORTED`,{prefix:Q_(r),page:r.pageIndex,at:$l(t),paint:`stroke`,pattern:`gradient (a gradient stroke needs CE.SDK 1.85 or newer)`,fallback:tu(t.stroke)})}let n=p_(e);n!=null&&(t.strokeDashArray!=null&&t.strokeDashArray.length>0&&(n.setStrokeDashArray(o,t.strokeDashArray.map(t=>$(e,t))),t.strokeDashOffset!=null&&n.setStrokeDashOffset?.(o,$(e,t.strokeDashOffset)),t.strokeCap!=null&&(n.setStrokeDashStartCap(o,t.strokeCap),n.setStrokeDashEndCap(o,t.strokeCap))),t.strokeCap!=null&&(n.setStrokeStartCap(o,t.strokeCap),n.setStrokeEndCap(o,t.strokeCap)));let i=e.block;t.strokeJoin!=null&&i.setStrokeCornerGeometry?.(o,t.strokeJoin)}return Y_(e,o,t),t.opacity!=null&&t.opacity!==1&&e.block.setOpacity(o,t.opacity),C_(e,o,t.blendMode,r),y_(e,o,{fill:b_(t.fill),stroke:b_(t.stroke)}),o}function y_(e,t,n){let r=e.block;n.fill&&r.setFillOverprint?.(t,!0),n.stroke&&r.setStrokeOverprint?.(t,!0)}function b_(e){return e!=null&&`overprint`in e&&e.overprint===!0}function x_(e){let t=e.colorSpans;return t?.length?t.filter(t=>e.text.slice(t.from,t.to).trim()!==``).map(e=>e.fill):[e.fill]}function S_(e){let t=x_(e).filter(e=>e!=null&&R(e));return t.length>0&&t.every(e=>e.overprint===!0)}function C_(e,t,n,r){let i=fp(n,r?.logger??void 0);i!=null&&(typeof e.block.supportsBlendMode!=`function`||e.block.supportsBlendMode(t))&&e.block.setBlendMode(t,i)}function w_(e,t,n,r){let i=n.fill;e.block.setFill(t,T_(e,i,n,r))}function T_(e,t,n,r){let i=t.kind===`linearGradient`?`gradient/linear`:`gradient/radial`,a=e.block.createFill(i),o=(t.stops??[]).map(e=>({color:Z_(e.color,r,n,`vector path gradient stop`),stop:e.offset}));e.block.setGradientColorStops(a,`fill/gradient/colors`,o);let s=n.width>0?n.width:1,c=n.height>0?n.height:1;if(t.kind===`linearGradient`)e.block.setFloat(a,`fill/gradient/linear/startPointX`,(t.start.x-n.x)/s),e.block.setFloat(a,`fill/gradient/linear/startPointY`,(t.start.y-n.y)/c),e.block.setFloat(a,`fill/gradient/linear/endPointX`,(t.end.x-n.x)/s),e.block.setFloat(a,`fill/gradient/linear/endPointY`,(t.end.y-n.y)/c);else{let r=Math.max(.001,Math.min(s,c));e.block.setFloat(a,`fill/gradient/radial/centerPointX`,(t.center.x-n.x)/s),e.block.setFloat(a,`fill/gradient/radial/centerPointY`,(t.center.y-n.y)/c),e.block.setFloat(a,`fill/gradient/radial/radius`,t.radius/r)}return a}async function E_(e,t,n,r){let i=uh(t,n);if(!i)return r.logger?.emit?.(t.kind===ae.TEXT_RUN?`FONT_REF_NOT_EXTRACTED`:`TEXT_OUTLINE_NO_FONT_FAMILY`,{fontRef:t.kind===ae.TEXT_RUN?t.fontRef:``}),null;let a=await r.fontStrategy.cascade.resolve(i,{engine:e,resolver:r.fontResolver,resolverCache:r.resolverCache,logger:r.logger}),o=r.paragraphProbe?/* @__PURE__ */ new Set:void 0,s=D_(e,o?{...r,paragraphAllocations:o}:r),c=(t,n)=>{for(let r of t)r!==n&&e.block.isValid(r)&&e.block.destroy(r)},l;try{l=await r.fontStrategy.emission.emit(i,a,{engine:e,logger:r.logger,pageIndex:r.pageIndex,helpers:s})}catch(e){throw o&&c(o),e}if(o){let e=l.blocks.length===1?l.blocks[0]:void 0;if(c(/* @__PURE__ */ new Set([...o,...l.blocks]),e),l.blocks.length>1)return null}if(l.substituted&&a?.kind===`typeface`){let e=a.typeface.name??`?`;r.substitutions.has(i.family)||r.substitutions.set(i.family,e)}if(a?.kind===`subset`&&t.kind===ae.TEXT_RUN&&l.blocks.length===1&&A_(e,l.blocks[0],t),a?.kind===`subset`&&r.subsetFallbacks.add(i.family),l.blocks.length===0)return null;let u=l.blocks[0];return r.textRuns&&(a?.kind===`typeface`||a?.kind===`subset`)&&(t.kind===ae.TEXT_RUN?r.textRuns.push({id:u,ir:t}):r.textRuns.push({id:u,ir:{kind:ae.TEXT_RUN,x:t.x,y:t.y,width:t.width,height:t.height,text:t.text,fontRef:t.fontFamily,fontSize:t.fontSize,rotation:0,fill:t.fill}})),u}function D_(e,t){return{createEditableText(n,r,i){return k_(e,n.source,i,r,t)},emitGlyphsAsVectorPath(n){let r=null;if(n.glyphPaths){let e=n.source;r={d:n.glyphPaths,x:e.x,y:e.y,width:e.width,height:e.height}}else n.buildGlyphOutline&&(r=n.buildGlyphOutline());if(!r)return null;let i=n.source,a=`opacity`in i&&typeof i.opacity==`number`?i.opacity:1,o=x_(i);return v_(e,{kind:ae.VECTOR_PATH,x:r.x,y:r.y,width:r.width,height:r.height,d:r.d,fill:oe(i.fill,o.every(e=>e?.overprint===!0)),stroke:null,strokeWidth:0,opacity:a},0,t)},async resolveLayoutForSubstitution(n,r){return n.source.kind!==ae.TEXT_OUTLINE||r.kind!==`typeface`?n.source:M_(e,n.source,{typeface:r.typeface,font:r.font},t)}}}async function O_(e,t,n,r){let i=t?.font?.uri,a=e.editor;if(!i||typeof a?.getFontMetrics!=`function`||!r)return null;r.fontMetricsCache||=/* @__PURE__ */ new Map;let o=r.fontMetricsCache.get(i);if(o===void 0){try{o=await a.getFontMetrics(i)}catch{o=null}r.fontMetricsCache.set(i,o)}return!o||!o.unitsPerEm||o.ascender==null?null:o.ascender/o.unitsPerEm*n}function k_(e,t,n,r,i){let a=e.block.create(`text`);return i.paragraphAllocations?.add(a),N_(e,a,r),n(e,a),P_(e,a,t,i),t.rotation&&e.block.setRotation(a,lp(e,t.rotation)),a}function A_(e,t,n){let r=e.block.setTextKerning;if(typeof r==`function`)for(let{em:i,from:a,to:o}of qg(n)??[])r.call(e.block,t,i,a,o)}function j_(e,t,n){let r=n.letterSpacingSpans;if(!r?.length||n.text.length===0)return;let i=e.block;if(typeof i.getTextKernings!=`function`||typeof i.setTextKerning!=`function`||!r.every(({from:n,to:r,em:a})=>{let o=i.getTextKernings.call(e.block,t,n,r);return o.length===1&&Math.abs(o[0]-a)<1e-6}))return;let a=e.block.getFloat(t,`text/letterSpacing`);if(!(a<0))return;let o=0;for(let{from:n,to:a,em:s}of r)o+=(a-n)*s,i.setTextKerning.call(e.block,t,0,n,a);e.block.setFloat(t,`text/letterSpacing`,Math.min(0,a+o/n.text.length))}async function M_(e,t,n,r){if(!(Math.abs(t.rotation??0)>1e-6)){if(!Number.isFinite(t.textOriginX)&&!Number.isFinite(t.textOriginY))return t;let i={};if(Number.isFinite(t.textOriginX)&&(i.x=t.textOriginX),Number.isFinite(t.textOriginY)){let a=await O_(e,n,t.fontSize,r);a!=null&&(i.y=(t.textOriginY??0)-a)}return{...t,...i}}let i=t.unrotWidth!=null&&Number.isFinite(t.unrotWidth)&&t.unrotWidth>0?t.unrotWidth:t.width,a=t.unrotHeight!=null&&Number.isFinite(t.unrotHeight)&&t.unrotHeight>0?t.unrotHeight:t.height,o=t.rotation??0,s=Math.sin(o),c=Math.cos(o),l=t.x+t.width/2,u=t.y+t.height/2,d=l-i/2+a/2*s,f=u-a/2*c;return{...t,x:d,y:f,width:i,height:a}}function N_(e,t,n){e.block.setPositionX(t,$(e,n.x)),e.block.setPositionY(t,$(e,n.y)),e.block.setWidth(t,$(e,n.width)),typeof e.block.setWidthMode==`function`&&e.block.setWidthMode(t,`Absolute`),typeof e.block.setHeightMode==`function`&&e.block.setHeightMode(t,`Auto`)}function P_(e,t,n,r){if(typeof e.block.setTextFontSize==`function`?e.block.setTextFontSize(t,cp(e,n.fontSize)):e.block.setFloat(t,`text/fontSize`,cp(e,n.fontSize)),typeof e.block.replaceText==`function`?e.block.replaceText(t,n.text):e.block.setString(t,`text/text`,n.text),z_(e,t,n,r),R_(e,t,n,r),n.kind===ae.TEXT_RUN&&n.underlineSpans?.length&&jg(e,t,n.underlineSpans),r.preserveWordSpacing&&n.kind===ae.TEXT_RUN){let r=e.block.setTextKerning;if(typeof r==`function`)for(let{em:i,from:a,to:o}of Qh(n)??[])r.call(e.block,t,i,a,o)}let i=n.opacity;i!=null&&i!==1&&e.block.setOpacity(t,i)}function F_(e){if(!e||e===`normal`)return null;switch(e){case`ultraCondensed`:return`Ultra Condensed`;case`extraCondensed`:return`Extra Condensed`;case`condensed`:return`Condensed`;case`semiCondensed`:return`Semi Condensed`;case`semiExpanded`:return`Semi Expanded`;case`expanded`:return`Expanded`;case`extraExpanded`:return`Extra Expanded`;case`ultraExpanded`:return`Ultra Expanded`;default:return null}}function I_(e,t,n,r){if(n===``||ep(e,n))return!1;let i,a,o;try{i=e.block.getTypeface(t).fonts,a=e.block.getTextFontWeights(t),o=e.block.getTextFontStyles(t)}catch{return!1}if(a.length!==1||o.length!==1)return!1;let[s]=a,[c]=o,l=(e,t)=>i.some(n=>n.weight===e&&(n.style??`normal`)===t),u=F(e);return r.every(e=>{let t=e.fontWeight==null?s:Nl(e.fontWeight),n=e.fontStyle??c;return l(t,n)&&(u||l(t,c)||l(s,n))})}function L_(e,t,n){try{I(e,t,{weight:n.fontWeight==null?void 0:Nl(n.fontWeight),style:n.fontStyle||void 0},n.from,n.to)}catch{}}function R_(e,t,n,r){let i=n.styleSpans;if(!Array.isArray(i)||i.length===0||!r.irFonts)return;let a=e.block;if(typeof a.setTypeface!=`function`||typeof a.setTextFontWeight!=`function`||typeof a.setTextFontStyle!=`function`)return;let o=``;try{o=e.block.getString(t,`text/fontFileUri`)}catch{}if(o.startsWith(`https://`)||I_(e,t,o,i)){for(let n of i)L_(e,t,n);return}let s=/* @__PURE__ */ new Map;for(let t of i){if(!t.fontRef||s.has(t.fontRef))continue;let i=r.irFonts.get(t.fontRef);if(!i){r.logger?.emit?.(`TEXT_STYLE_SPAN_FONT_MISSING`,{fontRef:t.fontRef,text:(n.text??``).slice(0,40)});return}let a=$f(e,i);s.set(t.fontRef,{fontRef:t.fontRef,ef:i,uri:a.uri,typefaceName:a.typeface.name,typeface:a.typeface})}if(s.size===0)return;let c=[...s.values()][0],l=c.ef.family??`PDF Imported Font`,u=c.ef.width,d=new Map(s),f=/* @__PURE__ */ new Set,p=e=>`${Nl(e.weight)}|${e.style??`normal`}`;for(let e of s.values())f.add(p(e.ef));for(let[t,n]of r.irFonts){if(d.has(t)||n.family!==l||n.width!==u)continue;let r=p(n);if(f.has(r))continue;f.add(r);let i=$f(e,n);d.set(t,{fontRef:t,ef:n,uri:i.uri,typefaceName:i.typeface.name,typeface:i.typeface})}let m=F_(u),h=m?`${l} ${m}`:l,g=[...d.values()],_={name:g.some(e=>e.typefaceName!==e.ef.postScriptName)?`${h}#${g.map(e=>e.uri).sort().join(`|`)}`:h,fonts:g.map(e=>({uri:e.uri,subFamily:e.ef.family,weight:Nl(e.ef.weight),style:e.ef.style??`normal`}))},v=s,y=/* @__PURE__ */ new Map,b=!1;for(let{fontRef:e,ef:t}of v.values()){let n=p(t),r=y.get(n);b||=r!==void 0&&r!==e,y.set(n,e)}let x=i[0],S=b&&n.kind===ae.TEXT_RUN?v.get(n.fontRef):x?.fontRef?v.get(x.fontRef):void 0,C=S?.uri??[...v.values()][0].uri,w=b?(S??[...v.values()][0]).typeface:_;try{typeof a.setFont==`function`?a.setFont(t,C,w):a.setTypeface(t,w)}catch{return}for(let n of i){if(b){let e=v.get(n.fontRef);if(e)try{a.setTypeface(t,e.typeface,n.from,n.to)}catch{return}}L_(e,t,n)}}function z_(e,t,n,r){let i=n.colorSpans;if(Array.isArray(i)&&i.length>0){if(typeof e.block.setTextColor==`function`)for(let a of i){if(!a.fill)continue;let i=Z_(a.fill,r,n,`text`);e.block.setTextColor(t,i,a.from,a.to)}}else if(n.fill){let i=Z_(n.fill,r,n,`text`);if(typeof e.block.setTextColor==`function`)e.block.setTextColor(t,i);else try{e.block.setColor(t,`fill/color/value`,i)}catch{}}y_(e,t,{fill:S_(n)})}const B_=1.05,V_=1.5,H_=32,U_=!0;function W_(e,t,n,r,i=!0){if(typeof e.block.getTextVisibleLineCount!=`function`)return;let a=[];for(let{id:n,ir:r}of t){let t=r.width;if(t<r.fontSize){let i=Math.max(1,r.text.length)*r.fontSize*.7;i>t&&(t=i,e.block.setWidth(n,$(e,t)))}if(!i){e.block.setFloat(n,`text/letterSpacing`,0);continue}let o=Yg({allowWiden:!1}),s=o.next();if(s.done)continue;let c=s.value;a.push({id:n,ir:r,gen:o,phase:`ls`,workingWidthScene:$(e,t),widen:1,widenIter:0,lines:1,write:()=>e.block.setFloat(n,`text/letterSpacing`,c)})}for(;a.length>0;){for(let e of a)e.write();let t=a[0].id;e.block.setRotation(t,e.block.getRotation(t)),r?.();for(let t=a.length-1;t>=0;t--){let r=a[t];K_(e,r,q_(e,r.id))&&(a.splice(t,1),j_(e,r.id,r.ir),r.lines>1&&n?.logger?.emit?.(`TEXT_OVERFLOW_AFTER_AUTOSIZE`,{text:J_(r.ir.text,30),overflowLines:r.lines-1}))}}}function G_(e,t,n,r){let i=$(e,n);for(let{id:n,ir:a}of t){if(Math.abs(a.rotation??0)>1e-6||a.advanceWidthPt==null||a.width-a.advanceWidthPt>a.fontSize*.05+1e-6)continue;let t=e.block.getWidth(n),o=i-e.block.getPositionX(n);o<=0||t<=o||$(e,a.advanceWidthPt)>o||e.block.getTextVisibleLineCount(n)!==1||(e.block.setWidth(n,o),e.block.setRotation(n,e.block.getRotation(n)),r?.(),q_(e,n)!==1&&(e.block.setWidth(n,t),e.block.setRotation(n,e.block.getRotation(n)),r?.(),q_(e,n)))}}function K_(e,t,n){if(t.phase===`ls`){let r=t.gen.next(n);if(!r.done){let n=r.value;return t.write=()=>e.block.setFloat(t.id,`text/letterSpacing`,n),!1}if(t.lines=r.value.lines,t.lines<=1)return!0;t.phase=`widen`,t.widenIter=1,t.widen=Math.min(V_,t.widen*B_);let i=t.workingWidthScene*t.widen;return t.write=()=>e.block.setWidth(t.id,i),!1}if(t.lines=n,n<=1||t.widen>=V_||t.widenIter>=9)return!0;t.widenIter+=1,t.widen=Math.min(V_,t.widen*B_);let r=t.workingWidthScene*t.widen;return t.write=()=>e.block.setWidth(t.id,r),!1}function q_(e,t){try{return e.block.getTextVisibleLineCount(t)}catch{return 1}}function J_(e,t){return e.length>t?e.slice(0,t-1)+`…`:e}function Y_(e,t,n){e.block.setPositionX(t,$(e,n.x)),e.block.setPositionY(t,$(e,n.y)),e.block.setWidth(t,$(e,n.width)),e.block.setHeight(t,$(e,n.height))}function X_(e,t,n,r=!1){if(!e?.editor?.setSpotColorCMYK)return;let i=/* @__PURE__ */ new Map,a=e=>{let t=e;t&&t.space===`spot`&&t.name&&!i.has(t.name)&&i.set(t.name,{alt:t.alternateSpace??`DeviceCMYK`,solid:Array.isArray(t.solid)?t.solid:[]})};for(let e of t.pages??[]){for(let t of e.blocks??[]){a(t.fill),a(t.stroke);let e=t.colorSpans;for(let t of e??[])a(t.fill)}for(let t of e.pathSpotColors??[])a(t)}let o=r?new Set(e.editor.findAllSpotColors()):/* @__PURE__ */ new Set;for(let[t,r]of i)try{if(o.has(t)){let i=r.alt===`DeviceCMYK`?e.editor.getSpotColorCMYK(t):e.editor.getSpotColorRGBA(t).slice(0,3),a=r.alt===`DeviceGray`?[,,,].fill(r.solid[0]):r.solid;(a.length!==i.length||a.some((e,t)=>Math.abs(e-i[t])>1e-6))&&n?.emit?.(`SPOT_COLOR_DEFINITION_PRESERVED`,{name:t});continue}if(r.alt===`DeviceCMYK`&&r.solid.length>=4){let[n,i,a,o]=r.solid;e.editor.setSpotColorCMYK(t,n,i,a,o)}else if(r.alt===`DeviceGray`&&r.solid.length>=1){let n=r.solid[0];e.editor.setSpotColorRGB(t,n,n,n)}else if(r.alt===`DeviceRGB`&&r.solid.length>=3){let[n,i,a]=r.solid;e.editor.setSpotColorRGB(t,n,i,a)}else n?.emit?.(`SPOT_COLOR_NO_ALTERNATE`,{name:t})}catch(e){let r=e&&typeof e==`object`&&`message`in e?String(e.message):String(e);n?.emit?.(`SPOT_COLOR_REGISTER_FAILED`,{name:t,error:r})}}function Z_(e,t,n,r){if(!e)return{r:0,g:0,b:0,a:1};if(e.space===`rgb`){let[t,n,r]=e.values;return{r:t,g:n,b:r,a:1}}if(e.space===`gray`){let[t]=e.values;return{r:t,g:t,b:t,a:1}}if(e.space===`cmyk`){let[t,n,r,i]=e.values;return{c:t,m:n,y:r,k:i,tint:1}}let i=e;return i.space===`spot`?{name:i.name,tint:i.tint??1,externalReference:``}:(t?.logger?.emit?.(`COLOR_SPACE_UNSUPPORTED`,{prefix:Q_(t),elementLabel:$_(r),space:i.space,color:tu(e),bbox:$l(n),page:t?.pageIndex,element:r??null}),{r:0,g:0,b:0,a:1})}function Q_(e){return e?.pageIndex==null?``:`Page ${e.pageIndex}: `}function $_(e){return e?`${e} `:``}var ev=class e{engine;pdfBytes;fontResolver;fontStrategy;pageBounds;preserveWhitePageBackground;textLayout;logger=new _(re);ir;constructor(e,t,n,r=`trim`,i=_h,a=!1,o=`paragraphs`){this.engine=e,this.pdfBytes=t,this.fontResolver=n??S,this.fontStrategy=i,this.pageBounds=r,this.preserveWhitePageBackground=a,this.textLayout=o}static async fromFile(t,n,r){let i;i=n instanceof ArrayBuffer?n.slice(0):await n.arrayBuffer();let a=new Uint8Array(i);return typeof r==`function`?new e(t,a,r):new e(t,a,r?.fontResolver,r?.pageBounds,r?.fontStrategy,r?.preserveWhitePageBackground,r?.textLayout)}async parse(){let e=await this.ensureIR(),t=await $g(this.engine,e,{fontResolver:this.fontResolver,fontStrategy:this.fontStrategy,logger:this.logger,pageBounds:this.pageBounds,textLayout:this.textLayout});return await this.zoomToFirstPage(),{scene:t,logger:this.logger}}async zoomToFirstPage(){try{let e=this.engine.scene.getPages()[0];if(e===void 0||typeof this.engine.scene.zoomToBlock!=`function`)return;await this.engine.scene.zoomToBlock(e,40,40,40,40)}catch{}}async loadAsBlocks(e){yh(e??{});let t=this.engine.scene.get(),n=await bh(this.ensureIR(),e?.signal);if(this.engine.scene.get()!==t)throw Error(`The scene changed during PDF import.`);return e?.pageIndex!=null&&(e.pageIndex<0||e.pageIndex>=n.pages.length)?(this.logger.emit(`PAGE_INDEX_OUT_OF_RANGE`,{requested:e.pageIndex,available:n.pages.length}),{blocks:[],logger:this.logger,dispose:()=>{}}):{...await e_(this.engine,n,{fontResolver:this.fontResolver,fontStrategy:this.fontStrategy,logger:this.logger,pageBounds:`media`,textLayout:this.textLayout,pageIndex:e?.pageIndex,legacyUnits:e?.units!==`scene`,preservePageBounds:e?.preservePageBounds,signal:e?.signal,maxBlocks:e?.maxBlocks}),logger:this.logger}}async getPageCount(){return(await this.ensureIR()).pages.length}getLogger(){return this.logger}async ensureIR(){if(this.ir)return this.ir;let e=await Kf(this.pdfBytes,{textMode:`auto`,preserveWhitePageBackground:this.preserveWhitePageBackground,logger:this.logger});this.logger.emit(`DOC_PAGE_COUNT`,{count:e.pages.length});for(let t=0;t<e.pages.length;t++){let n=tv(e.pages[t].blocks);this.logger.emit(`DOC_PAGE_BLOCK_COUNT`,{page:t,imageCount:n.image,vectorCount:n.vector,textCount:n.text,outlineCount:n.outline})}for(let t of e.pages)t.blocks=Kh(t.blocks),t.blocks=jh(t.blocks);return this.ir=e,e}};function tv(e){let t={image:0,vector:0,text:0,outline:0};for(let n of e)n.kind===`image`?t.image++:n.kind===`vector-path`?t.vector++:n.kind===`text-run`?t.text++:n.kind===`text-outline`&&t.outline++;return t}exports.Logger=_,exports.PDFParser=ev,exports.addGfontsAssetLibrary=x,exports.anyMatchResolverStage=oh,exports.assetLibraryStrategy=gh,exports.createFontCascade=fh,exports.createFontStrategy=ph,exports.defaultEmission=lh,exports.defaultStrategy=_h,exports.editableFirstStrategy=mh,exports.embeddedSubsetStage=ah,exports.exactFidelityStrategy=hh,exports.perfectMatchResolverStage=ih;