@arcgis/core 6.0.0-next.56 → 6.0.0-next.58

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 (695) hide show
  1. package/WebLinkChart.d.ts +0 -12
  2. package/WebLinkChart.js +1 -1
  3. package/applications/Components/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  4. package/applications/WebEditor/sketchUtils.js +1 -1
  5. package/arcade/arcadeCompiler.js +5 -5
  6. package/arcade/containerUtils.js +1 -1
  7. package/arcade/featureset/actions/Adapted.js +1 -1
  8. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  9. package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
  10. package/arcade/featureset/support/shared.js +1 -1
  11. package/arcade/featureset/support/sqlUtils.js +1 -1
  12. package/assets/esri/core/workers/RemoteClient.js +1 -1
  13. package/assets/esri/core/workers/chunks/00c227bcecc28fe278bb.js +1 -0
  14. package/assets/esri/core/workers/chunks/075e6c60e741482e673f.js +1 -0
  15. package/assets/esri/core/workers/chunks/076c2098570ee885d117.js +1 -0
  16. package/assets/esri/core/workers/chunks/091ce6b3de590e1d9ff6.js +1 -0
  17. package/assets/esri/core/workers/chunks/099dec4103f6e7556eb0.js +1 -0
  18. package/assets/esri/core/workers/chunks/{77267e0807cbbc00496d.js → 0be55d9bab7c3510a7f2.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{da69e8cd52aa77aa4c2c.js → 0fc1facd26c9ef96e081.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{f97dc99afe3375fc8e16.js → 1179a3574c580f7ce390.js} +1 -1
  21. package/assets/esri/core/workers/chunks/129140104be2620c0382.js +1 -0
  22. package/assets/esri/core/workers/chunks/1295fcf866e7347b2d53.js +1 -0
  23. package/assets/esri/core/workers/chunks/16219f0c56d6f6213c24.js +1 -0
  24. package/assets/esri/core/workers/chunks/185b317eec95f3370970.js +1 -0
  25. package/assets/esri/core/workers/chunks/1afc8820c283ef785729.js +1 -0
  26. package/assets/esri/core/workers/chunks/1bdef2e142e78341fec0.js +1 -0
  27. package/assets/esri/core/workers/chunks/1c874f86bfd0963aa3d2.js +1 -0
  28. package/assets/esri/core/workers/chunks/1ce0bf4ff14af8a68a5c.js +1 -0
  29. package/assets/esri/core/workers/chunks/1f1515313baeecc095a2.js +1 -0
  30. package/assets/esri/core/workers/chunks/1f710c91a82f6fd3d0f6.js +1 -0
  31. package/assets/esri/core/workers/chunks/{1894c39dabc78e7a5af8.js → 1fad7a7211bb8c9b58e3.js} +1 -1
  32. package/assets/esri/core/workers/chunks/24374aaa6fb3e12960d1.js +1 -0
  33. package/assets/esri/core/workers/chunks/24aa7b81814b4e519b01.js +1 -0
  34. package/assets/esri/core/workers/chunks/294097140e349e073b7e.js +1 -0
  35. package/assets/esri/core/workers/chunks/{c8c79d21dfce5695a089.js → 2b69fdf51b6f0b2abb75.js} +1 -1
  36. package/assets/esri/core/workers/chunks/2ba9b3b4d49eb2740a42.js +1 -0
  37. package/assets/esri/core/workers/chunks/2eb3297014f063fb4bc9.js +1 -0
  38. package/assets/esri/core/workers/chunks/2eb3cec44ce7587980a4.js +1 -0
  39. package/assets/esri/core/workers/chunks/2ee3cd6b2e5274932d31.js +1 -0
  40. package/assets/esri/core/workers/chunks/2f31766bc0f9d1d70c5a.js +1 -0
  41. package/assets/esri/core/workers/chunks/31df02c6f5b04a143ae6.js +1 -0
  42. package/assets/esri/core/workers/chunks/32d5aae2e0953420216a.js +1 -0
  43. package/assets/esri/core/workers/chunks/35109db6a6be66f895f7.js +1 -0
  44. package/assets/esri/core/workers/chunks/373b140f92eda3857f82.js +1 -0
  45. package/assets/esri/core/workers/chunks/3a1510650ce8de7edec8.js +1 -0
  46. package/assets/esri/core/workers/chunks/3b0933cea2a902a26bb7.js +1 -0
  47. package/assets/esri/core/workers/chunks/3d96676b94e8ecb6a4d1.js +1 -0
  48. package/assets/esri/core/workers/chunks/3edfd8ecf000b00a4a92.js +1 -0
  49. package/assets/esri/core/workers/chunks/3fc4b7d0ee460fc96176.js +1 -0
  50. package/assets/esri/core/workers/chunks/{f053cbfe671bd14c7d5b.js → 419d8116d8e7faccfed5.js} +1 -1
  51. package/assets/esri/core/workers/chunks/41d57b45cc2361305af3.js +1 -0
  52. package/assets/esri/core/workers/chunks/42ee1f8732e644371ea9.js +1 -0
  53. package/assets/esri/core/workers/chunks/4309f3e72c6332e01d75.js +1 -0
  54. package/assets/esri/core/workers/chunks/44ca7a56fb28227fdcbf.js +1 -0
  55. package/assets/esri/core/workers/chunks/4537f0866e903d2e9bb9.js +1 -0
  56. package/assets/esri/core/workers/chunks/49f61832e0d3b24e1608.js +1 -0
  57. package/assets/esri/core/workers/chunks/4a45505fb9a40b503672.js +29 -0
  58. package/assets/esri/core/workers/chunks/4b456c1f26d70392f7d4.js +1 -0
  59. package/assets/esri/core/workers/chunks/{28fae7da8cc4ae7a83e4.js → 4c510b1caffeec80dc6b.js} +1 -1
  60. package/assets/esri/core/workers/chunks/4ce5c9b658ba79a0b668.js +1 -0
  61. package/assets/esri/core/workers/chunks/{41694ee8990e799da225.js → 4d8f23b2e6721fb5b289.js} +1 -1
  62. package/assets/esri/core/workers/chunks/4fb8708666a614df583d.js +1 -0
  63. package/assets/esri/core/workers/chunks/4feec96a312dcc137911.js +1 -0
  64. package/assets/esri/core/workers/chunks/52ad9306fd40d488376d.js +1 -0
  65. package/assets/esri/core/workers/chunks/5375bdf46b602b19fa86.js +1 -0
  66. package/assets/esri/core/workers/chunks/549a8e7313f75ea3f85b.js +1 -0
  67. package/assets/esri/core/workers/chunks/55f97942c58455f47975.js +1 -0
  68. package/assets/esri/core/workers/chunks/566d72534d694c318e30.js +1 -0
  69. package/assets/esri/core/workers/chunks/5ce00674305e5716d27b.js +1 -0
  70. package/assets/esri/core/workers/chunks/5e032d209df500fad321.js +1 -0
  71. package/assets/esri/core/workers/chunks/{dfa1b0308e5e82d1ddfe.js → 5e4de4ddd3bdc74100e0.js} +34 -33
  72. package/assets/esri/core/workers/chunks/5ea8cdc28a81744913cd.js +1 -0
  73. package/assets/esri/core/workers/chunks/61565d4674cf77cbf1dd.js +1 -0
  74. package/assets/esri/core/workers/chunks/651e33be8bb3995d749f.js +1 -0
  75. package/assets/esri/core/workers/chunks/{d296c9561f6a6aeff973.js → 68b8dff748f1ef588653.js} +1 -1
  76. package/assets/esri/core/workers/chunks/690041373d03d02a3044.js +1 -0
  77. package/assets/esri/core/workers/chunks/{6d99e7e1aa007a6f1039.js → 69316db52d7bed746879.js} +1 -1
  78. package/assets/esri/core/workers/chunks/69384a9703abee1903c5.js +1 -0
  79. package/assets/esri/core/workers/chunks/6992a7728451c5a7b673.js +1 -0
  80. package/assets/esri/core/workers/chunks/69e5efe1acbdaddee90d.js +1 -0
  81. package/assets/esri/core/workers/chunks/6b2e09e43f449020d5ad.js +1 -0
  82. package/assets/esri/core/workers/chunks/6b5f8bf8b3480910666d.js +1 -0
  83. package/assets/esri/core/workers/chunks/70fe8b90f174ec64db2e.js +1 -0
  84. package/assets/esri/core/workers/chunks/720356fc6d5e18008471.js +1 -0
  85. package/assets/esri/core/workers/chunks/721f43554b9654481de7.js +1 -0
  86. package/assets/esri/core/workers/chunks/{3869ea1be105eaad4a38.js → 7328aca34c95fd0fc752.js} +1 -1
  87. package/assets/esri/core/workers/chunks/789567124c4a15235952.js +1 -0
  88. package/assets/esri/core/workers/chunks/{a24dc5350af001db417a.js → 7affab0d0692bdb76036.js} +1 -1
  89. package/assets/esri/core/workers/chunks/{b6e628b5d2643af4c19b.js → 7b4063f45b45ad8a7289.js} +1 -1
  90. package/assets/esri/core/workers/chunks/7c22d3669087f38c92b9.js +1 -0
  91. package/assets/esri/core/workers/chunks/7cb7bdc30f970eb9ff7f.js +1 -0
  92. package/assets/esri/core/workers/chunks/7d71cf65bbc1b3308856.js +1 -0
  93. package/assets/esri/core/workers/chunks/81cdb9705f7eee9e792f.js +1 -0
  94. package/assets/esri/core/workers/chunks/821003fe1be30d5d29aa.js +1 -0
  95. package/assets/esri/core/workers/chunks/822b9c1e172c835b9624.js +1 -0
  96. package/assets/esri/core/workers/chunks/{a7dfca326883384d2751.js → 823228f1fa6ba4e8bff2.js} +1 -1
  97. package/assets/esri/core/workers/chunks/84021d57822f374217ef.js +1 -0
  98. package/assets/esri/core/workers/chunks/847ec6b337cfb2e4a15b.js +1 -0
  99. package/assets/esri/core/workers/chunks/84f41ddd7366bfbf5b25.js +1 -0
  100. package/assets/esri/core/workers/chunks/8920d0b11951b57d6a66.js +1 -0
  101. package/assets/esri/core/workers/chunks/{c6e7c95391a54978402b.js → 893363ee500fc1288781.js} +1 -1
  102. package/assets/esri/core/workers/chunks/8b0cdbbf5c81283eae13.js +1 -0
  103. package/assets/esri/core/workers/chunks/{7850e306d7cd12653b23.js → 90de2f93b0ba1eb337fd.js} +1 -1
  104. package/assets/esri/core/workers/chunks/91b0035e3eae9e452fbc.js +1 -0
  105. package/assets/esri/core/workers/chunks/92d97e0fcc20dd5f5ac4.js +1 -0
  106. package/assets/esri/core/workers/chunks/93262d3616ac0cc4b532.js +1 -0
  107. package/assets/esri/core/workers/chunks/9748a0db6451336d51ef.js +1 -0
  108. package/assets/esri/core/workers/chunks/{69a09c6acb5ae03c67f6.js → 985ce51da8ae4984a4db.js} +1 -1
  109. package/assets/esri/core/workers/chunks/9bbff9230298b1bac46a.js +1 -0
  110. package/assets/esri/core/workers/chunks/9ca84fa9423654061d05.js +1 -0
  111. package/assets/esri/core/workers/chunks/9cae59db5b9cb37baea9.js +1 -0
  112. package/assets/esri/core/workers/chunks/{ed2626a895ca1d4a7216.js → 9dbb9e74754392b066a8.js} +1 -1
  113. package/assets/esri/core/workers/chunks/9dd3863b9d7c1a5ea20a.js +1 -0
  114. package/assets/esri/core/workers/chunks/9e62cfcb4e0188d51294.js +1 -0
  115. package/assets/esri/core/workers/chunks/a2a3edec2ee31273d609.js +1 -0
  116. package/assets/esri/core/workers/chunks/{d0e8d0f8b4e4cc13e837.js → a301aa62a03d3618eba9.js} +1 -1
  117. package/assets/esri/core/workers/chunks/a39d595fc11afedc1875.js +1 -0
  118. package/assets/esri/core/workers/chunks/a57b506c538e2186909d.js +1 -0
  119. package/assets/esri/core/workers/chunks/a722114f01e66a608cec.js +1 -0
  120. package/assets/esri/core/workers/chunks/{5bda285f6ecf725676b3.js → a7b4821fd3080cf2756f.js} +1 -1
  121. package/assets/esri/core/workers/chunks/a8d91c2654c5012400b4.js +1 -0
  122. package/assets/esri/core/workers/chunks/aa70d98e6bcbd06a8461.js +1 -0
  123. package/assets/esri/core/workers/chunks/add538f52c7bcfd154da.js +1 -0
  124. package/assets/esri/core/workers/chunks/ae0b0a562f0ab57e1883.js +1 -0
  125. package/assets/esri/core/workers/chunks/b10c534cbe311d17b7d5.js +1 -0
  126. package/assets/esri/core/workers/chunks/b2c3652c8ce9597dcf89.js +1 -0
  127. package/assets/esri/core/workers/chunks/b725d944ecd5da02fd9e.js +1 -0
  128. package/assets/esri/core/workers/chunks/b7fbbbeabaa5bfcdeabc.js +1 -0
  129. package/assets/esri/core/workers/chunks/{70ead4c231cba4084cf4.js → b856ef3a949ca06a4af5.js} +1 -1
  130. package/assets/esri/core/workers/chunks/{ae2cd50c2b938b39417b.js → b8b4f68305a4f654fa75.js} +1 -1
  131. package/assets/esri/core/workers/chunks/{97107e64407fa6825620.js → ba324fd300b6e6a584ae.js} +1 -1
  132. package/assets/esri/core/workers/chunks/bc40b96080346b91e507.js +1 -0
  133. package/assets/esri/core/workers/chunks/c5ca8245113576b35acc.js +1 -0
  134. package/assets/esri/core/workers/chunks/{c7a0c4ca37ebd1d98cf1.js → c629a676b707138e7a1c.js} +1 -1
  135. package/assets/esri/core/workers/chunks/c8a1aa90ec6d455ff82d.js +1 -0
  136. package/assets/esri/core/workers/chunks/c8dd8b67100177109619.js +1 -0
  137. package/assets/esri/core/workers/chunks/c8eb8744f1ed9d1897dc.js +1 -0
  138. package/assets/esri/core/workers/chunks/cb0e3614b78c78040662.js +1 -0
  139. package/assets/esri/core/workers/chunks/ccc89208aad7206aabd9.js +1 -0
  140. package/assets/esri/core/workers/chunks/cebd6732fe573f79849c.js +1 -0
  141. package/assets/esri/core/workers/chunks/d22e3b5d836dffdf91cc.js +1 -0
  142. package/assets/esri/core/workers/chunks/{c5ddf8b347c31fe772a3.js → d45769f8a02abe5d2917.js} +1 -1
  143. package/assets/esri/core/workers/chunks/d4b62e78bb27272a5f83.js +1 -0
  144. package/assets/esri/core/workers/chunks/d52b2a591e5e6abaa133.js +1 -0
  145. package/assets/esri/core/workers/chunks/{0978e12dd6a1cbc50b80.js → d572b125bed40a4d02b1.js} +1 -1
  146. package/assets/esri/core/workers/chunks/d65206fea850b1fc0712.js +1 -0
  147. package/assets/esri/core/workers/chunks/d6a42c936ead00ab7ad4.js +1 -0
  148. package/assets/esri/core/workers/chunks/d77887edc10d5be39ac9.js +1 -0
  149. package/assets/esri/core/workers/chunks/d7b9c16fe73f50a41099.js +1 -0
  150. package/assets/esri/core/workers/chunks/{7b6fd287e7043ad50f4e.js → d9bf0be2323e9df55834.js} +1 -1
  151. package/assets/esri/core/workers/chunks/dab98890d77a6b0b2741.js +1 -0
  152. package/assets/esri/core/workers/chunks/e2ac387e154d68fd10ca.js +1 -0
  153. package/assets/esri/core/workers/chunks/e39259ff441fb67cd3e4.js +1 -0
  154. package/assets/esri/core/workers/chunks/e3c152eeaa1c95f0f2d2.js +1 -0
  155. package/assets/esri/core/workers/chunks/e42e9dd3c933f5f864ab.js +1 -0
  156. package/assets/esri/core/workers/chunks/e4ae0fad312467f218df.js +1 -0
  157. package/assets/esri/core/workers/chunks/e50cc686db878d0a9399.js +1 -0
  158. package/assets/esri/core/workers/chunks/e7cd5eeb15d3783f803d.js +1 -0
  159. package/assets/esri/core/workers/chunks/e8042584e422044ca1d1.js +1 -0
  160. package/assets/esri/core/workers/chunks/e89640667b71c1bb4ee3.js +1 -0
  161. package/assets/esri/core/workers/chunks/e9649aa2d0fdd28d91ac.js +1 -0
  162. package/assets/esri/core/workers/chunks/ee31801144602ce816d3.js +1 -0
  163. package/assets/esri/core/workers/chunks/eff8a1a880e0eb1a6814.js +1 -0
  164. package/assets/esri/core/workers/chunks/f2b7c61462f530d812c4.js +1 -0
  165. package/assets/esri/core/workers/chunks/f56404d401dfbce29473.js +1 -0
  166. package/assets/esri/core/workers/chunks/f87416f2aa791cd1bebe.js +1 -0
  167. package/assets/esri/core/workers/chunks/{f3744b12a5d0d8ca8621.js → fa65aafac2b99478c32a.js} +1 -1
  168. package/assets/esri/core/workers/chunks/fb14a0c8d2edf868838c.js +1 -0
  169. package/assets/esri/core/workers/chunks/fb8a24aa04bd2fa43241.js +1 -0
  170. package/assets/esri/core/workers/chunks/fbb27d2cef962f725180.js +1 -0
  171. package/assets/esri/core/workers/chunks/{3c6e7dcb79d13e8aecc5.js → fc965ace82bef4c6111b.js} +1 -1
  172. package/assets/esri/core/workers/chunks/{5954f02c3901b28d8e73.js → fd9382e5207b6da74b91.js} +1 -1
  173. package/assets/esri/core/workers/chunks/fdb370546be4ad552959.js +1 -0
  174. package/assets/esri/core/workers/chunks/fefac70ebe29dff54b4c.js +1 -0
  175. package/chunks/BlurEmission.glsl.js +4 -17
  176. package/chunks/Bufferer-CclWhXVb.js +1 -1
  177. package/chunks/ColorMaterial.glsl.js +1 -1
  178. package/chunks/Component.glsl.js +2 -1
  179. package/chunks/EmissionComposite.glsl.js +2 -2
  180. package/chunks/Envelope.js +1 -1
  181. package/chunks/Envelope2D.js +1 -1
  182. package/chunks/Fog.glsl.js +3 -3
  183. package/chunks/GeodeticDistanceCalculator-zRp89-dW.js +1 -1
  184. package/chunks/GlobalIllumination.glsl.js +12 -11
  185. package/chunks/GlobalIlluminationBlur.glsl.js +6 -4
  186. package/chunks/ImageMaterial.glsl.js +1 -1
  187. package/chunks/LineMarker.glsl.js +2 -2
  188. package/chunks/MultiPathImpl.js +1 -1
  189. package/chunks/OperatorGeodesicBuffer.js +1 -1
  190. package/chunks/OperatorGeodeticArea.js +1 -1
  191. package/chunks/OperatorShapePreservingProject.js +1 -1
  192. package/chunks/Point2D.js +1 -1
  193. package/chunks/RealisticAtmosphere.glsl.js +7 -9
  194. package/chunks/RealisticAtmosphereCompositing.glsl.js +6 -10
  195. package/chunks/RibbonLine.glsl.js +2 -2
  196. package/chunks/Terrain.glsl.js +28 -27
  197. package/chunks/UPCPointRenderer.glsl.js +100 -0
  198. package/chunks/UnitFactory.js +1 -1
  199. package/chunks/Water.glsl.js +25 -24
  200. package/chunks/arcade.js +1 -1
  201. package/chunks/arcgis-knowledge-client-core-simd.js +4 -4
  202. package/chunks/arcgis-knowledge-client-core.js +4 -4
  203. package/chunks/array.js +1 -1
  204. package/chunks/basis_encoder.js +3 -3
  205. package/chunks/basis_transcoder.js +2 -2
  206. package/chunks/draco_mesh_decoder.js +2 -2
  207. package/chunks/dxt_encoder.js +3 -3
  208. package/chunks/i3s.js +2 -2
  209. package/chunks/languageUtils.js +1 -1
  210. package/chunks/lclayout.js +3 -3
  211. package/chunks/lerc-wasm.js +1 -1
  212. package/chunks/lyr3DWorker.js +2 -2
  213. package/chunks/pe.js +1 -1
  214. package/chunks/projector.js +1 -1
  215. package/chunks/qb3-wasm.js +1 -1
  216. package/chunks/vxlLayer.js +2 -2
  217. package/colorUtils.js +1 -1
  218. package/config.js +1 -1
  219. package/core/AsyncUpdate.js +1 -1
  220. package/core/Clonable.js +1 -1
  221. package/core/Identifiable.js +1 -1
  222. package/core/Loadable.js +1 -1
  223. package/core/MultiOriginJSONSupport.js +1 -1
  224. package/core/NumericIdentifiable.js +1 -1
  225. package/core/Promise.js +1 -1
  226. package/core/ReadOnlyMultiOriginJSONSupport.js +1 -1
  227. package/core/accessorSupport/metadata.js +1 -1
  228. package/core/accessorSupport/trackingUtils.js +1 -1
  229. package/core/asyncUtils.js +1 -1
  230. package/core/handleUtils.js +1 -1
  231. package/core/mapCollectionUtils.js +1 -1
  232. package/core/memoryEstimations.js +1 -1
  233. package/core/reactiveUtils.js +1 -1
  234. package/core/sql/SqlTimestampOffset.js +1 -1
  235. package/core/sql/WhereClause.js +1 -1
  236. package/core/sql/WhereGrammar.js +1 -1
  237. package/core/sql/writeUtils.js +1 -1
  238. package/core/sql.js +1 -1
  239. package/core/urlUtils.js +1 -1
  240. package/core/workers/workers.js +1 -1
  241. package/geohash/GeohashCell.js +1 -1
  242. package/geohash/GeohashTree.js +1 -1
  243. package/geometry/coordinateConversion/CoordinateConversionModel.d.ts +11 -56
  244. package/geometry/coordinateConversion/support/Conversion.d.ts +5 -17
  245. package/geometry/coordinateConversion/support/Format.d.ts +6 -30
  246. package/geometry/coordinateConversion/types.d.ts +15 -15
  247. package/geometry/operators/reshapeOperator.js +1 -1
  248. package/geometry/support/MeshMaterial.js +1 -1
  249. package/geometry/support/MeshMaterialMetallicRoughness.js +1 -1
  250. package/geometry/support/meshUtils/elevationSampler.js +1 -1
  251. package/graphic/AggregateGraphicOrigin.js +1 -1
  252. package/graphic/AnnotationFeatureGraphicOrigin.js +1 -1
  253. package/graphic/BuildingGraphicOrigin.js +1 -1
  254. package/graphic/CSVGraphicOrigin.js +1 -1
  255. package/graphic/CatalogGraphicOrigin.js +1 -1
  256. package/graphic/DimensionFeatureGraphicOrigin.js +1 -1
  257. package/graphic/FeatureGraphicOrigin.js +1 -1
  258. package/graphic/GeoJSONGraphicOrigin.js +1 -1
  259. package/graphic/GeoRSSGraphicOrigin.js +1 -1
  260. package/graphic/ImageryGraphicOrigin.js +1 -1
  261. package/graphic/ImageryTileGraphicOrigin.js +1 -1
  262. package/graphic/KMLGraphicOrigin.js +1 -1
  263. package/graphic/KnowledgeGraphGraphicOrigin.js +1 -1
  264. package/graphic/LinkChartGraphicOrigin.js +1 -1
  265. package/graphic/MapImageGraphicOrigin.js +1 -1
  266. package/graphic/MapNotesGraphicOrigin.js +1 -1
  267. package/graphic/OGCFeatureGraphicOrigin.js +1 -1
  268. package/graphic/OrientedImageryGraphicOrigin.js +1 -1
  269. package/graphic/ParquetGraphicOrigin.js +1 -1
  270. package/graphic/PointCloudGraphicOrigin.js +1 -1
  271. package/graphic/SceneGraphicOrigin.js +1 -1
  272. package/graphic/SketchGraphicOrigin.js +1 -1
  273. package/graphic/StreamGraphicOrigin.js +1 -1
  274. package/graphic/SubtypeGroupGraphicOrigin.js +1 -1
  275. package/graphic/TileGraphicOrigin.js +1 -1
  276. package/graphic/TrackGraphicOrigin.js +1 -1
  277. package/graphic/VectorTileGraphicOrigin.js +1 -1
  278. package/graphic/VoxelGraphicOrigin.js +1 -1
  279. package/graphic/WCSGraphicOrigin.js +1 -1
  280. package/graphic/WFSGraphicOrigin.js +1 -1
  281. package/graphic/getLayerViewLayer.js +2 -0
  282. package/identity/IdentityManagerBase.js +1 -1
  283. package/interfaces.d.ts +0 -1
  284. package/kernel.js +1 -1
  285. package/layers/ElevationLayer.js +1 -1
  286. package/layers/LinkChartLayer.d.ts +1 -1
  287. package/layers/LinkChartLayer.js +1 -1
  288. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  289. package/layers/PointCloudLayer.js +3 -3
  290. package/layers/VectorTileLayer.d.ts +17 -10
  291. package/layers/VoxelWasmPerSceneView.js +1 -1
  292. package/layers/WMTSLayer.js +1 -1
  293. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  294. package/layers/graphics/dehydratedFeatures.js +1 -1
  295. package/layers/graphics/transferFeatures.js +1 -1
  296. package/layers/knowledgeGraph/KnowledgeGraphSublayerBase.js +1 -1
  297. package/layers/mixins/APIKeyMixin.js +1 -1
  298. package/layers/mixins/ArcGISCachedService.js +1 -1
  299. package/layers/mixins/ArcGISImageService.js +1 -1
  300. package/layers/mixins/ArcGISMapService.js +1 -1
  301. package/layers/mixins/ArcGISService.js +1 -1
  302. package/layers/mixins/BlendLayer.js +1 -1
  303. package/layers/mixins/CustomParametersMixin.js +1 -1
  304. package/layers/mixins/DataElementMixin.js +1 -1
  305. package/layers/mixins/DataSeriesLayer.js +1 -1
  306. package/layers/mixins/DisplayFilteredLayer.js +1 -1
  307. package/layers/mixins/EditBusLayer.js +1 -1
  308. package/layers/mixins/FeatureEffectLayer.js +1 -1
  309. package/layers/mixins/FeatureLayerBase.js +1 -1
  310. package/layers/mixins/FeatureReductionLayer.js +1 -1
  311. package/layers/mixins/HeightModelInfoMixin.js +1 -1
  312. package/layers/mixins/OperationalLayer.js +1 -1
  313. package/layers/mixins/OrderedLayer.js +1 -1
  314. package/layers/mixins/PortalLayer.js +1 -1
  315. package/layers/mixins/PublishableLayer.js +1 -1
  316. package/layers/mixins/RasterJobHandlerMixin.js +1 -1
  317. package/layers/mixins/RasterPresetRendererMixin.js +1 -1
  318. package/layers/mixins/RefreshableLayer.js +1 -1
  319. package/layers/mixins/ReloadableLayer.js +1 -1
  320. package/layers/mixins/ScaleRangeLayer.js +1 -1
  321. package/layers/mixins/SceneService.js +1 -1
  322. package/layers/mixins/SublayersOwner.js +1 -1
  323. package/layers/mixins/TemporalLayer.js +1 -1
  324. package/layers/mixins/TrackableLayer.js +1 -1
  325. package/layers/orientedImagery/transformations/utils.js +1 -1
  326. package/layers/raster/datasets/TIFFRaster.js +1 -1
  327. package/layers/raster/datasets/pixelReader.js +1 -1
  328. package/layers/raster/datasets/xmlUtilities.js +1 -1
  329. package/layers/raster/formats/Lerc.js +1 -1
  330. package/layers/raster/formats/Qb3.js +1 -1
  331. package/layers/raster/formats/TiffDecoder.js +1 -1
  332. package/layers/raster/formats/blosc.js +1 -1
  333. package/layers/raster/formats/tiffParser.js +1 -1
  334. package/layers/raster/formats/tiffSpatialReferenceUtils.js +2 -0
  335. package/layers/raster/formats/tiffTag.js +1 -1
  336. package/layers/raster/functions/colormaps.js +1 -1
  337. package/layers/support/TitleCreator.js +1 -1
  338. package/layers/support/WMTSSublayer.js +1 -1
  339. package/layers/support/fieldUtils.d.ts +129 -57
  340. package/layers/support/fieldUtils.js +1 -1
  341. package/layers/support/geospatialPDFUtils.js +1 -1
  342. package/layers/support/imageUtils.js +1 -1
  343. package/layers/support/labelUtils.js +1 -1
  344. package/layers/support/tiles3DUtils.js +1 -1
  345. package/layers/video/VideoController.js +14 -14
  346. package/legend/ActiveLayerInfo.js +1 -1
  347. package/legend/support/sizeRampUtils.js +1 -1
  348. package/libs/basisu/BasisUEncoder.js +1 -1
  349. package/libs/basisu/BasisUTranscoder.js +1 -1
  350. package/libs/dracoMeshDecoder/dracoMeshDecoder.js +1 -1
  351. package/libs/dxtEncoder/DXTEncoder.js +1 -1
  352. package/libs/i3s/I3SModule.js +1 -1
  353. package/libs/librust-parquet/loadParquetModule.js +1 -1
  354. package/libs/librust-text/loadTextModule.js +1 -1
  355. package/libs/linkchartlayout/LinkChartLayout.js +1 -1
  356. package/libs/maquette-advanced-projector/projector.js +1 -1
  357. package/networks/Network.js +1 -1
  358. package/networks/support/TopologyValidationJobInfo.js +1 -1
  359. package/package.json +2 -2
  360. package/popup/FeaturesModel.d.ts +6 -0
  361. package/popup/FeaturesModel.js +1 -1
  362. package/portal/PortalUser.js +1 -1
  363. package/renderers/mixins/VisualVariablesMixin.js +1 -1
  364. package/renderers/visualVariables/VisualVariableFactory.js +1 -1
  365. package/rest/identify.js +1 -1
  366. package/rest/knowledgeGraph/wasmInterface/knowledgeWasmAccess.js +1 -1
  367. package/rest/layerSources/utils.js +1 -1
  368. package/rest/networks/validateNetworkTopology.js +1 -1
  369. package/rest/support/CameraInfoMixin.js +1 -1
  370. package/rest/support/NormalizationBinParametersMixin.js +1 -1
  371. package/rest/support/generateRendererUtils.js +1 -1
  372. package/smartMapping/raster/renderers/vectorField.js +1 -1
  373. package/smartMapping/renderers/type.js +1 -1
  374. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  375. package/smartMapping/support/adapters/FeatureLayerBinningAdapter.js +1 -1
  376. package/smartMapping/symbology/color.js +1 -1
  377. package/smartMapping/symbology/support/Theme.js +1 -1
  378. package/support/BasemapStyle.js +1 -1
  379. package/support/LayersMixin.js +1 -1
  380. package/support/TablesMixin.js +1 -1
  381. package/support/actions/ActionBase.d.ts +14 -2
  382. package/support/actions/ActionBase.js +1 -1
  383. package/support/actions/ActionButton.js +1 -1
  384. package/support/actions/ActionToggle.js +1 -1
  385. package/support/loadArcade.js +1 -1
  386. package/views/2d/engine/flow/styles/Imagery.js +1 -1
  387. package/views/2d/engine/flow/utils.js +1 -1
  388. package/views/2d/engine/vectorTiles/TextShaping.js +1 -1
  389. package/views/2d/engine/vectorTiles/TileHandler3D.js +1 -1
  390. package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
  391. package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
  392. package/views/2d/engine/webgl/GlyphWorker.js +1 -1
  393. package/views/2d/engine/webgl/cpuMapped/CpuMeshData.js +1 -1
  394. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/AFeatureShader.js +1 -1
  395. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/bitmapUtils.js +1 -1
  396. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/surface.js +1 -1
  397. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/utils.js +1 -1
  398. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  399. package/views/2d/layerViewModuleImportUtils.js +1 -1
  400. package/views/2d/layers/BitmapTileLayerView2D.js +1 -1
  401. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  402. package/views/2d/layers/LayerView2D.js +1 -1
  403. package/views/2d/layers/MapImageLayerView2D.js +1 -1
  404. package/views/2d/layers/TileLayerView2D.js +1 -1
  405. package/views/2d/layers/features/FeatureContainer.js +1 -1
  406. package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
  407. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  408. package/views/2d/layers/features/support/DisplayIdGenerator.js +1 -1
  409. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  410. package/views/2d/layers/support/visualVariableSimpleUtils.js +1 -1
  411. package/views/3d/GroundView3D.js +1 -1
  412. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  413. package/views/3d/layerViewModuleImportUtils.js +1 -1
  414. package/views/3d/layers/BuildingSublayerView3D.js +1 -1
  415. package/views/3d/layers/DynamicLayerView3D.js +1 -1
  416. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  417. package/views/3d/layers/FeatureLikeLayerViewBase3D.js +1 -1
  418. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  419. package/views/3d/layers/I3SMeshView3D.js +1 -1
  420. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  421. package/views/3d/layers/LayerView3D.js +1 -1
  422. package/views/3d/layers/Lyr3DWorker.js +1 -1
  423. package/views/3d/layers/PointCloudIntersector.js +2 -0
  424. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  425. package/views/3d/layers/SceneLayerWorker.js +1 -1
  426. package/views/3d/layers/TiledLayerView3D.js +1 -1
  427. package/views/3d/layers/UPCPointRenderer.js +2 -0
  428. package/views/3d/layers/UPCPointRendererNode.js +2 -0
  429. package/views/3d/layers/UpdatablePointCloudLayerView3D.js +2 -0
  430. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  431. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  432. package/views/3d/layers/i3s/PointCloudHighlights.js +1 -1
  433. package/views/3d/layers/i3s/PointCloudNodeHighlights.js +2 -0
  434. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  435. package/views/3d/layers/i3s/PointCloudRendererNode.js +1 -1
  436. package/views/3d/layers/support/DefinitionExpressionSceneLayerView.js +1 -1
  437. package/views/3d/layers/support/GraphicsProcessorLayerView3D.js +1 -1
  438. package/views/3d/layers/support/PopupSceneLayerView.js +1 -1
  439. package/views/3d/layers/support/TemporalSceneLayerView.js +1 -1
  440. package/views/3d/layers/support/Tiles3DBVH.js +1 -1
  441. package/views/3d/layers/support/Tiles3DLayerViewRegistration.js +1 -1
  442. package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
  443. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  444. package/views/3d/state/utils/groundNavigationUtils.js +1 -1
  445. package/views/3d/support/GroundAndIMSurface.js +1 -1
  446. package/views/3d/support/QualityProfile.js +1 -1
  447. package/views/3d/support/QualitySettings.js +1 -1
  448. package/views/3d/support/cameraUtils.js +1 -1
  449. package/views/3d/support/engineContent/sdfPrimitives.js +1 -1
  450. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  451. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  452. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  453. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  454. package/views/3d/terrain/TerrainRenderer.js +1 -1
  455. package/views/3d/webgl/RenderNode.js +1 -1
  456. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  457. package/views/3d/webgl-engine/collections/Component/ComponentObjectFixedBVH.js +1 -1
  458. package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
  459. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  460. package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +9 -9
  461. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  462. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  463. package/views/3d/webgl-engine/collections/Component/RenderSubmitSystem.js +1 -1
  464. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  465. package/views/3d/webgl-engine/core/shaderLibrary/attributes/RibbonVertexPosition.glsl.js +19 -19
  466. package/views/3d/webgl-engine/core/shaderLibrary/lastFrameUniforms.js +1 -1
  467. package/views/3d/webgl-engine/core/shaderLibrary/outputEmission.glsl.js +5 -0
  468. package/views/3d/webgl-engine/core/shaderLibrary/{util/CloudsParallaxShading.glsl.js → renderClouds.glsl.js} +5 -4
  469. package/views/3d/webgl-engine/core/shaderLibrary/shading/evaluateSceneLightingFragment.glsl.js +2 -2
  470. package/views/3d/webgl-engine/core/shaderLibrary/shading/forwardLocalUp.glsl.js +1 -5
  471. package/views/3d/webgl-engine/core/shaderLibrary/shading/readShadow.glsl.js +7 -7
  472. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +15 -12
  473. package/views/3d/webgl-engine/core/shaderLibrary/terrain/blendLayers.glsl.js +9 -9
  474. package/views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js +1 -1
  475. package/views/3d/webgl-engine/core/shaderModules/glsl.js +1 -1
  476. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js +1 -1
  477. package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
  478. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  479. package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphere.glsl.js +1 -1
  480. package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphere.js +1 -1
  481. package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphereCompositing.glsl.js +1 -1
  482. package/views/3d/webgl-engine/effects/atmosphere/RealisticAtmosphereConfiguration.js +1 -1
  483. package/views/3d/webgl-engine/effects/fog/Fog.js +1 -1
  484. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
  485. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  486. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationBlur.glsl.js +1 -1
  487. package/views/3d/webgl-engine/effects/globalIllumination/globalIlluminationUniforms.js +1 -1
  488. package/views/3d/webgl-engine/effects/glow/applyEmissiveGlow.glsl.js +30 -53
  489. package/views/3d/webgl-engine/lib/EmissionComposite.glsl.js +1 -1
  490. package/views/3d/webgl-engine/lib/EmissionComposite.js +1 -1
  491. package/views/3d/webgl-engine/lib/GaussianSplatShadows.js +1 -1
  492. package/views/3d/webgl-engine/lib/PathGeometry.js +1 -1
  493. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  494. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  495. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  496. package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
  497. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  498. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  499. package/views/3d/webgl-engine/materials/HUDMaterialBaseInstance.js +1 -1
  500. package/views/3d/webgl-engine/materials/LineCalloutMaterialBaseInstance.js +1 -1
  501. package/views/3d/webgl-engine/materials/Water.glsl.js +1 -1
  502. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  503. package/views/3d/webgl-engine/materials/WaterTechniqueConfiguration.js +1 -1
  504. package/views/3d/webgl-engine/materials/getWaterColor.glsl.js +89 -0
  505. package/views/3d/webgl-engine/materials/renderers/BufferCache.js +1 -1
  506. package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +12 -14
  507. package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
  508. package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
  509. package/views/3d/webgl-engine/shaders/UPCPointRenderer.glsl.js +2 -0
  510. package/views/3d/webgl-engine/shaders/UPCPointRendererTechnique.js +2 -0
  511. package/views/3d/webgl-engine/shaders/UPCPointRendererTechniqueConfiguration.js +2 -0
  512. package/views/BreakpointsOwner.js +1 -1
  513. package/views/DOMContainer.js +1 -1
  514. package/views/PopupView.js +1 -1
  515. package/views/View.d.ts +27 -1
  516. package/views/View.js +1 -1
  517. package/views/Viewport2DBaseMixin.js +1 -1
  518. package/views/Viewport2DMixin.js +1 -1
  519. package/views/animation/pointToPoint/Animation.js +1 -1
  520. package/views/interactive/Tooltip.d.ts +1 -1
  521. package/views/interactive/Tooltip.js +1 -1
  522. package/views/interactive/tooltip/components/TooltipEditableField.js +1 -1
  523. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  524. package/views/interactive/tooltip/infos/DynamicTooltipInfo.js +1 -1
  525. package/views/interactive/tooltip/infos/TooltipInfoWithCoordinates.js +1 -1
  526. package/views/layers/MapImageLayerView.js +1 -1
  527. package/views/layers/PointCloudLayerView.js +1 -1
  528. package/views/layers/RefreshableLayerView.js +1 -1
  529. package/views/layers/WMSLayerView.js +1 -1
  530. package/views/overlay/ViewOverlay.js +1 -1
  531. package/views/support/flow/utils.js +1 -1
  532. package/views/support/screenshotUtils.js +1 -1
  533. package/views/types.d.ts +15 -0
  534. package/views/webgl/AllocationTracer.js +1 -1
  535. package/views/webgl/InstanceCounter.js +1 -1
  536. package/views/webgl/RenderingContext.js +1 -1
  537. package/views/webgl/ShaderBuilder.js +23 -23
  538. package/views/webgl/ShaderTranspiler.js +1 -1
  539. package/views/webgl/capabilities/DisjointTimerQuery.js +1 -1
  540. package/views/webgl/capabilities.js +1 -1
  541. package/widgets/CoordinateConversion/CoordinateConversionViewModel.d.ts +1 -1
  542. package/widgets/CoordinateConversion/support/Conversion.d.ts +1 -0
  543. package/widgets/CoordinateConversion/support/Format.d.ts +1 -0
  544. package/widgets/Editor/EditorViewModel.js +1 -1
  545. package/widgets/Editor/workflowUtils.js +1 -1
  546. package/widgets/Feature/support/FeatureContentMixin.js +1 -1
  547. package/widgets/FeatureTable/support/EditableColumnTemplateMixin.js +1 -1
  548. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  549. package/widgets/Legend/support/sizeRampUtils.js +1 -1
  550. package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
  551. package/widgets/OrientedImageryViewer/mixins/DrawHandlerMixin.js +1 -1
  552. package/widgets/OrientedImageryViewer/mixins/ImageMeasurementMixin.js +1 -1
  553. package/widgets/OrientedImageryViewer/mixins/SketchHandlerMixin.js +1 -1
  554. package/widgets/OrientedImageryViewer/mixins/TriangulatedImageMeasurementMixin.js +1 -1
  555. package/widgets/OrientedImageryViewer/mixins/TriangulatedSketchHandlerMixin.js +1 -1
  556. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  557. package/widgets/Sketch/support/ResponsiveToolbar/ToolbarGroupBase.js +1 -1
  558. package/widgets/smartMapping/support/utils.js +1 -1
  559. package/widgets/support/AnalysisViewModelMixin.js +1 -1
  560. package/widgets/support/AnchorElementViewModel.js +1 -1
  561. package/widgets/support/GoTo.js +1 -1
  562. package/widgets/support/InteractiveToolViewModelMixin.js +1 -1
  563. package/assets/esri/core/workers/chunks/0329fa3aa3403f1c243b.js +0 -1
  564. package/assets/esri/core/workers/chunks/04f09e1afda92cbe09f5.js +0 -1
  565. package/assets/esri/core/workers/chunks/0a97b1974367382cfdf5.js +0 -1
  566. package/assets/esri/core/workers/chunks/0b74d353f80974ff6fea.js +0 -1
  567. package/assets/esri/core/workers/chunks/0e100855bb3832a68e4b.js +0 -1
  568. package/assets/esri/core/workers/chunks/0ede8ba757fd0976d485.js +0 -1
  569. package/assets/esri/core/workers/chunks/0f39576806866cff777d.js +0 -1
  570. package/assets/esri/core/workers/chunks/0fea695721a818955abf.js +0 -1
  571. package/assets/esri/core/workers/chunks/110f78d5e78732750097.js +0 -1
  572. package/assets/esri/core/workers/chunks/1507297550c3cd1268e2.js +0 -1
  573. package/assets/esri/core/workers/chunks/193a73a2c7f4f8482c21.js +0 -1
  574. package/assets/esri/core/workers/chunks/20acb6f3ed5140b6c6c6.js +0 -1
  575. package/assets/esri/core/workers/chunks/21aa29039a95debd7f44.js +0 -1
  576. package/assets/esri/core/workers/chunks/29b74a3ff03d3c8b65dc.js +0 -1
  577. package/assets/esri/core/workers/chunks/2ad6db80a508285a3e5d.js +0 -1
  578. package/assets/esri/core/workers/chunks/2b87d5b8931305b11ff6.js +0 -1
  579. package/assets/esri/core/workers/chunks/2d4788be418a4e5f6606.js +0 -1
  580. package/assets/esri/core/workers/chunks/2f07dc632e51fddb2d48.js +0 -1
  581. package/assets/esri/core/workers/chunks/2f9adf0b809ce8797ebf.js +0 -1
  582. package/assets/esri/core/workers/chunks/3169d639ab54bf508e2c.js +0 -1
  583. package/assets/esri/core/workers/chunks/333140b18aeb5a50b654.js +0 -1
  584. package/assets/esri/core/workers/chunks/3354f1fa90f8ce4c8fde.js +0 -1
  585. package/assets/esri/core/workers/chunks/3809a8b3f31bb811d964.js +0 -1
  586. package/assets/esri/core/workers/chunks/3982409149571a827390.js +0 -1
  587. package/assets/esri/core/workers/chunks/3b11e4d2e69b7aea1d65.js +0 -1
  588. package/assets/esri/core/workers/chunks/3c1651e9e8d2e83d22df.js +0 -1
  589. package/assets/esri/core/workers/chunks/3df6631895d0a7109e00.js +0 -1
  590. package/assets/esri/core/workers/chunks/3e8d70039800f2395d66.js +0 -1
  591. package/assets/esri/core/workers/chunks/3f8d66d8447036f122ae.js +0 -1
  592. package/assets/esri/core/workers/chunks/420c6a14107a77ddad36.js +0 -1
  593. package/assets/esri/core/workers/chunks/421b8244d01736d82e7a.js +0 -1
  594. package/assets/esri/core/workers/chunks/4761cd436abceee858bf.js +0 -1
  595. package/assets/esri/core/workers/chunks/48b60ff59afbae865de1.js +0 -1
  596. package/assets/esri/core/workers/chunks/4953314fd9afd52b6eec.js +0 -1
  597. package/assets/esri/core/workers/chunks/4cf8bddc3e0619e34424.js +0 -1
  598. package/assets/esri/core/workers/chunks/4d0bb5e4a1d789cc0d75.js +0 -1
  599. package/assets/esri/core/workers/chunks/4d8539674fc2e4fea03c.js +0 -1
  600. package/assets/esri/core/workers/chunks/4de08ead94660025075b.js +0 -1
  601. package/assets/esri/core/workers/chunks/5060be52a380fc4920f8.js +0 -1
  602. package/assets/esri/core/workers/chunks/5082cdc3e91e1c6d1070.js +0 -1
  603. package/assets/esri/core/workers/chunks/52ded087d19a93e29d93.js +0 -1
  604. package/assets/esri/core/workers/chunks/53bbb9aa6e4e4a0a8121.js +0 -1
  605. package/assets/esri/core/workers/chunks/54d3cb7d95d948998591.js +0 -1
  606. package/assets/esri/core/workers/chunks/560ebf5524ade7d1f85b.js +0 -1
  607. package/assets/esri/core/workers/chunks/56f227e1a9e51d1fd742.js +0 -1
  608. package/assets/esri/core/workers/chunks/5bd451c7db17ee8f0315.js +0 -1
  609. package/assets/esri/core/workers/chunks/5c34d49a6c9cc34b7626.js +0 -1
  610. package/assets/esri/core/workers/chunks/5d75fcaded78f76efd3e.js +0 -1
  611. package/assets/esri/core/workers/chunks/5f7505ada0991cfbdd84.js +0 -1
  612. package/assets/esri/core/workers/chunks/62ddd3a82864e26f009a.js +0 -1
  613. package/assets/esri/core/workers/chunks/6737b2a4a70bbdafaf67.js +0 -1
  614. package/assets/esri/core/workers/chunks/6a339a47e765b9937dd7.js +0 -1
  615. package/assets/esri/core/workers/chunks/6c21964eb7c25c8b1e9a.js +0 -1
  616. package/assets/esri/core/workers/chunks/6fd10891506925560443.js +0 -29
  617. package/assets/esri/core/workers/chunks/703373f529c1c334cfad.js +0 -1
  618. package/assets/esri/core/workers/chunks/71a05edd6f7f3197e621.js +0 -1
  619. package/assets/esri/core/workers/chunks/72b7e7b518c88b7569dd.js +0 -1
  620. package/assets/esri/core/workers/chunks/733c32d8091427d84de7.js +0 -1
  621. package/assets/esri/core/workers/chunks/73918ca7fdf41272d941.js +0 -1
  622. package/assets/esri/core/workers/chunks/7673217a688d739141e2.js +0 -1
  623. package/assets/esri/core/workers/chunks/76869c14dd7ffaae7eff.js +0 -1
  624. package/assets/esri/core/workers/chunks/7b156905d168bf973518.js +0 -1
  625. package/assets/esri/core/workers/chunks/7baa49055bc31618b56e.js +0 -1
  626. package/assets/esri/core/workers/chunks/7bd5a074d9f4ba137649.js +0 -1
  627. package/assets/esri/core/workers/chunks/7c13d7754fc914a87817.js +0 -1
  628. package/assets/esri/core/workers/chunks/7dc2e714234b2cee8701.js +0 -1
  629. package/assets/esri/core/workers/chunks/835e0315661003caa71f.js +0 -1
  630. package/assets/esri/core/workers/chunks/8570e3df90fb76a8741a.js +0 -1
  631. package/assets/esri/core/workers/chunks/860552f49f17de2f3353.js +0 -1
  632. package/assets/esri/core/workers/chunks/86578c191d76062157ec.js +0 -1
  633. package/assets/esri/core/workers/chunks/87d6e99d83db9a8cda7c.js +0 -1
  634. package/assets/esri/core/workers/chunks/88df1b8b295d3aed649f.js +0 -1
  635. package/assets/esri/core/workers/chunks/8c9934d30655dd2c48da.js +0 -1
  636. package/assets/esri/core/workers/chunks/9117c9b720c9ba6e7a6e.js +0 -1
  637. package/assets/esri/core/workers/chunks/939fb9a8c301ace07186.js +0 -1
  638. package/assets/esri/core/workers/chunks/94a38c9b3d086b37242f.js +0 -1
  639. package/assets/esri/core/workers/chunks/98e1751f888975532afc.js +0 -1
  640. package/assets/esri/core/workers/chunks/9b727f45dfea84357b57.js +0 -1
  641. package/assets/esri/core/workers/chunks/9d61f10f2bef15b5811d.js +0 -1
  642. package/assets/esri/core/workers/chunks/9dcf5be203f8b1e47d9d.js +0 -1
  643. package/assets/esri/core/workers/chunks/9eb00bb8dab995c2dcb3.js +0 -1
  644. package/assets/esri/core/workers/chunks/9ed81757937fe08363ed.js +0 -1
  645. package/assets/esri/core/workers/chunks/9fe07947cf4ec44014e8.js +0 -1
  646. package/assets/esri/core/workers/chunks/a05a2c2aaf0c288f9681.js +0 -1
  647. package/assets/esri/core/workers/chunks/a1d265614d038eb603f7.js +0 -1
  648. package/assets/esri/core/workers/chunks/a3d02885d6962b49eee4.js +0 -1
  649. package/assets/esri/core/workers/chunks/a66d6298236d59a615db.js +0 -1
  650. package/assets/esri/core/workers/chunks/a710c7a0584d9e45a469.js +0 -1
  651. package/assets/esri/core/workers/chunks/ab76170c374fd67ce8cd.js +0 -1
  652. package/assets/esri/core/workers/chunks/ab784764ddf9d7f693a1.js +0 -1
  653. package/assets/esri/core/workers/chunks/ace210d313ce53f3ae10.js +0 -1
  654. package/assets/esri/core/workers/chunks/aebd12488b4004e207a3.js +0 -1
  655. package/assets/esri/core/workers/chunks/b7426e5f290573cb9689.js +0 -1
  656. package/assets/esri/core/workers/chunks/b88e1084097a93a89f61.js +0 -1
  657. package/assets/esri/core/workers/chunks/baa5aa0670b23db86b50.js +0 -1
  658. package/assets/esri/core/workers/chunks/c0867890a84b4c98e0ba.js +0 -1
  659. package/assets/esri/core/workers/chunks/c1a551c4aa77f123d091.js +0 -1
  660. package/assets/esri/core/workers/chunks/c58f859dec9d6675dbd6.js +0 -1
  661. package/assets/esri/core/workers/chunks/c7425fb5e804f0f9d4dd.js +0 -1
  662. package/assets/esri/core/workers/chunks/c7b1c6d57603fa385c54.js +0 -1
  663. package/assets/esri/core/workers/chunks/c85184baccb4004bf42b.js +0 -1
  664. package/assets/esri/core/workers/chunks/ccf4b5fdcdace533bcb7.js +0 -1
  665. package/assets/esri/core/workers/chunks/cd8181600623e18f511c.js +0 -1
  666. package/assets/esri/core/workers/chunks/cef537fa9705dd1cf685.js +0 -1
  667. package/assets/esri/core/workers/chunks/d33403d578fbeecaf844.js +0 -1
  668. package/assets/esri/core/workers/chunks/d5bb6f479c0cdfc21d8a.js +0 -1
  669. package/assets/esri/core/workers/chunks/d689e7c685dd9a444d19.js +0 -1
  670. package/assets/esri/core/workers/chunks/d8b84d21144a58b6b911.js +0 -1
  671. package/assets/esri/core/workers/chunks/d8ffb1502def5c85740b.js +0 -1
  672. package/assets/esri/core/workers/chunks/db96d1d9f6d1a4d7fd2a.js +0 -1
  673. package/assets/esri/core/workers/chunks/ddbfa664e69612295785.js +0 -1
  674. package/assets/esri/core/workers/chunks/de35baceeb815e6befd5.js +0 -1
  675. package/assets/esri/core/workers/chunks/ded81c504bf44806ca7d.js +0 -1
  676. package/assets/esri/core/workers/chunks/e0466387b2ab54d706ca.js +0 -1
  677. package/assets/esri/core/workers/chunks/e164198dbb87ee202ba1.js +0 -1
  678. package/assets/esri/core/workers/chunks/e4eb6fdf5115bed48856.js +0 -1
  679. package/assets/esri/core/workers/chunks/e566102c7ed7a8ebf89e.js +0 -1
  680. package/assets/esri/core/workers/chunks/e59271f8b142a7602b7a.js +0 -1
  681. package/assets/esri/core/workers/chunks/ee70be138831cc2a0f56.js +0 -1
  682. package/assets/esri/core/workers/chunks/eef3fa804e456beac4c1.js +0 -1
  683. package/assets/esri/core/workers/chunks/efd6ea0966f60ab19520.js +0 -1
  684. package/assets/esri/core/workers/chunks/f23c4fd014126ea7abc6.js +0 -1
  685. package/assets/esri/core/workers/chunks/f319b59228b64e7f9008.js +0 -1
  686. package/assets/esri/core/workers/chunks/f42adcea81390fb21c66.js +0 -1
  687. package/assets/esri/core/workers/chunks/f52d081bbde5c95265cf.js +0 -1
  688. package/assets/esri/core/workers/chunks/f6e40f3faf0c80cf1b3a.js +0 -1
  689. package/assets/esri/core/workers/chunks/f7ab4bf14ec8e986ef7c.js +0 -1
  690. package/assets/esri/core/workers/chunks/f92c92c0fd1b5b33ca21.js +0 -1
  691. package/assets/esri/core/workers/chunks/fbd5f3b81cd9f061824d.js +0 -1
  692. package/assets/esri/core/workers/chunks/fdcc5fe4630a4ccf58de.js +0 -1
  693. package/assets/esri/core/workers/chunks/ff0a0819bba5e8264c47.js +0 -1
  694. package/assets/esri/core/workers/chunks/ff225735eba7f9130e19.js +0 -1
  695. package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +0 -70
@@ -1 +0,0 @@
1
- "use strict";(Array.isArray(self.webpackChunkRemoteClient)?self.webpackChunkRemoteClient:self.webpackChunkRemoteClient=[]).push([[8528],{32198(t,e,i){function s(t,e,i,s){var r,n=arguments.length,a=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var o=t.length-1;o>=0;o--)(r=t[o])&&(a=(n<3?r(a):n>3?r(e,i,a):r(e,i))||a);return n>3&&a&&Object.defineProperty(e,i,a),a}function r(t,e,i){if(null!=e){if("object"!=typeof e&&"function"!=typeof e)throw new TypeError("Object expected.");var s,r;if(i){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=e[Symbol.asyncDispose]}if(void 0===s){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=e[Symbol.dispose],i&&(r=s)}if("function"!=typeof s)throw new TypeError("Object not disposable.");r&&(s=function(){try{r.call(this)}catch(t){return Promise.reject(t)}}),t.stack.push({value:e,dispose:s,async:i})}else i&&t.stack.push({async:!0});return e}i.d(e,{Cg:()=>s,hk:()=>a,mS:()=>r}),Object.create,Object.create;var n="function"==typeof SuppressedError?SuppressedError:function(t,e,i){var s=new Error(i);return s.name="SuppressedError",s.error=t,s.suppressed=e,s};function a(t){function e(e){t.error=t.hasError?new n(e,t.error,"An error was suppressed during disposal."):e,t.hasError=!0}var i,s=0;return function r(){for(;i=t.stack.pop();)try{if(!i.async&&1===s)return s=0,t.stack.push(i),Promise.resolve().then(r);if(i.dispose){var n=i.dispose.call(i.value);if(i.async)return s|=2,Promise.resolve(n).then(r,function(t){return e(t),r()})}else s|=1}catch(t){e(t)}if(1===s)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}()}},69540(t,e,i){var s=i(32198),r=i(56372),n=i(64108),a=i(88620),o=(i(44208),i(4718)),l=(i(53966),i(97768));const h=Symbol("ClonableMixin"),d=t=>{var e;let i=t,r=class extends i{constructor(){super(...arguments),this[e]=!0}static{e=h}clone(t){let e=(0,a.oY)(this);(0,l.Lw)(e,"unable to clone instance of non-accessor class");let i=e.metadata,s=e.store,r={},n=new Map;for(let e in i){let a=i[e],l=s?.originOf(e),h=a.clonable;if(a.readOnly||!1===h||7!==l&&0!==l&&5!==l&&4!==l)continue;let d=this[e],c=null;if("function"==typeof h)c=h(d,t);else if("reference"===h)c=d;else if(c=(0,o.TU)(d,t),null!=d&&null==c)continue;0===l?n.set(e,c):r[e]=c}let h=new(Object.getPrototypeOf(this).constructor)(r);if(n.size){let t=(0,a.oY)(h)?.store;if(t)for(let[e,i]of n)t.set(e,i,0)}return h}};return r=(0,s.Cg)([(0,n.$K)("esri.core.Clonable")],r),r},c=d(r.A);i.d(e,["OU",0,d,"Pw",0,c])},95488(t,e,i){i.d(e,{I:()=>r});var s=i(30801);class r extends s.T{notify(){let t=this._observers;if(t&&t.length>0){if(1===t.length){let e=t[0];return e.onInvalidated(),void e.onCommitted()}let e=t.slice();for(let t of e)t.onInvalidated(),t.onCommitted()}}}},48163(t,e,i){function s(){return[0,0]}function r(t){return[t[0],t[1]]}function n(t,e){return[t,e]}function a(){return n(1,1)}function o(){return n(-1,-1)}function l(){return n(1,0)}function h(){return n(0,1)}i.d(e,{IA:()=>c,Un:()=>d,fA:()=>n,o8:()=>r,vt:()=>s});const d=a(),c=o(),u=l(),p=h();Object.freeze(Object.defineProperty({__proto__:null,NEGATIVE_ONES:c,ONES:d,UNIT_X:u,UNIT_Y:p,ZEROS:[0,0],clone:r,create:s,freeze:function(t,e){return[t,e]},fromArray:function(t,e=[0,0]){let i=Math.min(2,t.length);for(let s=0;s<i;++s)e[s]=t[s];return e},fromValues:n,negativeOnes:o,ones:a,unitX:l,unitY:h,zeros:function(){return[0,0]}},Symbol.toStringTag,{value:"Module"}))},16905(t,e,i){i.d(e,{$0:()=>h,B8:()=>n,D_:()=>r,Tl:()=>l,e$:()=>o,lw:()=>a});var s=i(34304);function r(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t}function n(t,e){let i=e[0],s=e[1],r=e[2],n=e[3],a=e[4],o=e[5],l=i*n-s*r;return l?(l=1/l,t[0]=n*l,t[1]=-s*l,t[2]=-r*l,t[3]=i*l,t[4]=(r*o-n*a)*l,t[5]=(s*a-i*o)*l,t):null}function a(t,e,i){let s=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5],h=i[0],d=i[1],c=i[2],u=i[3],p=i[4],g=i[5];return t[0]=s*h+n*d,t[1]=r*h+a*d,t[2]=s*c+n*u,t[3]=r*c+a*u,t[4]=s*p+n*g+o,t[5]=r*p+a*g+l,t}function o(t,e,i){let s=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5],h=Math.sin(i),d=Math.cos(i);return t[0]=s*d+n*h,t[1]=r*d+a*h,t[2]=s*-h+n*d,t[3]=r*-h+a*d,t[4]=o,t[5]=l,t}function l(t,e,i){let s=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5],h=i[0],d=i[1];return t[0]=s,t[1]=r,t[2]=n,t[3]=a,t[4]=s*h+n*d+o,t[5]=r*h+a*d+l,t}function h(t,e){let i=Math.sin(e),s=Math.cos(e);return t[0]=s,t[1]=i,t[2]=-i,t[3]=s,t[4]=0,t[5]=0,t}function d(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t[3]=e[3]-i[3],t[4]=e[4]-i[4],t[5]=e[5]-i[5],t}const c=a,u=d;Object.freeze(Object.defineProperty({__proto__:null,add:function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t[4]=e[4]+i[4],t[5]=e[5]+i[5],t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},determinant:function(t){return t[0]*t[3]-t[1]*t[2]},equals:function(t,e){let i=t[0],r=t[1],n=t[2],a=t[3],o=t[4],l=t[5],h=e[0],d=e[1],c=e[2],u=e[3],p=e[4],g=e[5],f=(0,s.FD)();return Math.abs(i-h)<=f*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(r-d)<=f*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(n-c)<=f*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(a-u)<=f*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(o-p)<=f*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(l-g)<=f*Math.max(1,Math.abs(l),Math.abs(g))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]},frob:function(t){return Math.sqrt(t[0]**2+t[1]**2+t[2]**2+t[3]**2+t[4]**2+t[5]**2+1)},fromRotation:h,fromScaling:function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t},fromTranslation:function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t},identity:r,invert:n,mul:c,multiply:a,multiplyScalar:function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*i,t[5]=e[5]*i,t},multiplyScalarAndAdd:function(t,e,i,s){return t[0]=e[0]+i[0]*s,t[1]=e[1]+i[1]*s,t[2]=e[2]+i[2]*s,t[3]=e[3]+i[3]*s,t[4]=e[4]+i[4]*s,t[5]=e[5]+i[5]*s,t},rotate:o,scale:function(t,e,i){let s=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5],h=i[0],d=i[1];return t[0]=s*h,t[1]=r*h,t[2]=n*d,t[3]=a*d,t[4]=o,t[5]=l,t},set:function(t,e,i,s,r,n,a){return t[0]=e,t[1]=i,t[2]=s,t[3]=r,t[4]=n,t[5]=a,t},str:function(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},sub:u,subtract:d,translate:l},Symbol.toStringTag,{value:"Module"}))},35522(t,e,i){i.d(e,{$A:()=>C,Bw:()=>n,C:()=>a,Cc:()=>M,DI:()=>x,Il:()=>U,Io:()=>b,Ln:()=>y,Om:()=>S,Qr:()=>c,Re:()=>h,S8:()=>_,T9:()=>f,WQ:()=>l,Z0:()=>k,_S:()=>p,aI:()=>R,ei:()=>P,fw:()=>E,gL:()=>T,hG:()=>v,hZ:()=>o,hs:()=>m,jb:()=>O,jk:()=>g,lo:()=>$,lw:()=>d,m3:()=>A,oW:()=>N,t2:()=>F,tn:()=>u,uE:()=>z,ze:()=>w});var s=i(51850),r=i(34304);function n(t){let e=t[0],i=t[1],s=t[2];return Math.sqrt(e*e+i*i+s*s)}function a(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function o(t,e,i,s){return t[0]=e,t[1]=i,t[2]=s,t}function l(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function h(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function d(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t}function c(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t[2]=e[2]/i[2],t}function u(t,e){return t[0]=Math.abs(e[0]),t[1]=Math.abs(e[1]),t[2]=Math.abs(e[2]),t}function p(t,e){return t[0]=Math.sign(e[0]),t[1]=Math.sign(e[1]),t[2]=Math.sign(e[2]),t}function g(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t[2]=Math.min(e[2],i[2]),t}function f(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t[2]=Math.max(e[2],i[2]),t}function m(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function y(t,e,i,s){return t[0]=e[0]+i[0]*s,t[1]=e[1]+i[1]*s,t[2]=e[2]+i[2]*s,t}function b(t,e){let i=e[0]-t[0],s=e[1]-t[1],r=e[2]-t[2];return Math.sqrt(i*i+s*s+r*r)}function v(t,e){let i=e[0]-t[0],s=e[1]-t[1],r=e[2]-t[2];return i*i+s*s+r*r}function A(t){let e=t[0],i=t[1],s=t[2];return e*e+i*i+s*s}function w(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function x(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function _(t,e=t){let i=e[0],s=e[1],r=e[2],n=i*i+s*s+r*r;return n>0&&(n=1/Math.sqrt(n),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n),t}function S(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function C(t,e,i){let s=e[0],r=e[1],n=e[2],a=i[0],o=i[1],l=i[2];return t[0]=r*l-n*o,t[1]=n*a-s*l,t[2]=s*o-r*a,t}function M(t,e,i,s){let r=e[0],n=e[1],a=e[2];return t[0]=r+s*(i[0]-r),t[1]=n+s*(i[1]-n),t[2]=a+s*(i[2]-a),t}function k(t,e,i){let s=e[0],r=e[1],n=e[2];return t[0]=i[0]*s+i[4]*r+i[8]*n+i[12],t[1]=i[1]*s+i[5]*r+i[9]*n+i[13],t[2]=i[2]*s+i[6]*r+i[10]*n+i[14],t}function P(t,e,i){let s=e[0],r=e[1],n=e[2];return t[0]=s*i[0]+r*i[3]+n*i[6],t[1]=s*i[1]+r*i[4]+n*i[7],t[2]=s*i[2]+r*i[5]+n*i[8],t}function T(t,e,i){return E(t,e,i[0],i[1],i[2],i[3])}function E(t,e,i,s,r,n){let a=e[0],o=e[1],l=e[2],h=s*l-r*o,d=r*a-i*l,c=i*o-s*a,u=s*c-r*d,p=r*h-i*c,g=i*d-s*h,f=2*n;return t[0]=a+h*f+2*u,t[1]=o+d*f+2*p,t[2]=l+c*f+2*g,t}const D=(0,s.vt)(),I=(0,s.vt)();function F(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function R(t,e){if(t===e)return!0;let i=t[0],s=t[1],n=t[2],a=e[0],o=e[1],l=e[2],h=(0,r.FD)();return Math.abs(i-a)<=h*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(s-o)<=h*Math.max(1,Math.abs(s),Math.abs(o))&&Math.abs(n-l)<=h*Math.max(1,Math.abs(n),Math.abs(l))}function N(t,e,i){let s=i[0]-e[0],r=i[1]-e[1],n=i[2]-e[2],a=s*s+r*r+n*n;return a>0?(a=1/Math.sqrt(a),t[0]=s*a,t[1]=r*a,t[2]=n*a,t):(t[0]=0,t[1]=0,t[2]=0,t)}const O=h,B=d,L=c,j=b,$=v,U=n,z=A;Object.freeze(Object.defineProperty({__proto__:null,abs:u,add:l,angle:function(t,e){_(D,t),_(I,e);let i=S(D,I);return i>1?0:i<-1?Math.PI:Math.acos(i)},applyTranslation:function(t,e,i){return t[0]=e[0]+i[12],t[1]=e[1]+i[13],t[2]=e[2]+i[14],t},bezier:function(t,e,i,s,r,n){let a=1-n,o=a*a,l=n*n,h=o*a,d=3*n*o,c=3*l*a,u=l*n;return t[0]=e[0]*h+i[0]*d+s[0]*c+r[0]*u,t[1]=e[1]*h+i[1]*d+s[1]*c+r[1]*u,t[2]=e[2]*h+i[2]*d+s[2]*c+r[2]*u,t},ceil:function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t},clamp:function(t,e=0,i=1){return t[0]=Math.min(Math.max(t[0],e),i),t[1]=Math.min(Math.max(t[1],e),i),t[2]=Math.min(Math.max(t[2],e),i),t},copy:a,cross:C,crossAndNormalize:function(t,e,i){let s=e[0],r=e[1],n=e[2],a=i[0],o=i[1],l=i[2],h=r*l-n*o,d=n*a-s*l,c=s*o-r*a,u=Math.sqrt(h*h+d*d+c*c);return t[0]=h/u,t[1]=d/u,t[2]=c/u,t},direction:N,dist:j,distance:b,div:L,divide:c,dot:S,equals:R,exactEquals:F,floor:function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t},hermite:function(t,e,i,s,r,n){let a=n*n,o=a*(2*n-3)+1,l=a*(n-2)+n,h=a*(n-1),d=a*(3-2*n);return t[0]=e[0]*o+i[0]*l+s[0]*h+r[0]*d,t[1]=e[1]*o+i[1]*l+s[1]*h+r[1]*d,t[2]=e[2]*o+i[2]*l+s[2]*h+r[2]*d,t},inverse:x,len:U,length:n,lerp:M,max:f,min:g,mul:B,multiply:d,negate:w,normalize:_,random:function(t,e=1){let i=r.Ov,s=2*i()*Math.PI,n=2*i()-1,a=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(s)*a,t[1]=Math.sin(s)*a,t[2]=n*e,t},rotateX:function(t,e,i,s){let r=[],n=[];return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],n[0]=r[0],n[1]=r[1]*Math.cos(s)-r[2]*Math.sin(s),n[2]=r[1]*Math.sin(s)+r[2]*Math.cos(s),t[0]=n[0]+i[0],t[1]=n[1]+i[1],t[2]=n[2]+i[2],t},rotateY:function(t,e,i,s){let r=[],n=[];return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],n[0]=r[2]*Math.sin(s)+r[0]*Math.cos(s),n[1]=r[1],n[2]=r[2]*Math.cos(s)-r[0]*Math.sin(s),t[0]=n[0]+i[0],t[1]=n[1]+i[1],t[2]=n[2]+i[2],t},rotateZ:function(t,e,i,s){let r=[],n=[];return r[0]=e[0]-i[0],r[1]=e[1]-i[1],r[2]=e[2]-i[2],n[0]=r[0]*Math.cos(s)-r[1]*Math.sin(s),n[1]=r[0]*Math.sin(s)+r[1]*Math.cos(s),n[2]=r[2],t[0]=n[0]+i[0],t[1]=n[1]+i[1],t[2]=n[2]+i[2],t},round:function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t},scale:m,scaleAndAdd:y,scaleTo:function(t,e){return m(t,t,e/U(t))},set:o,sign:p,sqrDist:$,sqrLen:z,squaredDistance:v,squaredLength:A,str:function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},sub:O,subtract:h,transformMat3:P,transformMat4:k,transformMat4Z:function(t,e){return e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]},transformQuat:T,transformQuatValues:E},Symbol.toStringTag,{value:"Module"}))},83529(t,e,i){i.d(e,{O:()=>u,W:()=>c});var s=i(77690),r=i(29242),n=i(37585),a=i(35522);const o=(0,i(51850).vt)(),l=(0,r.vt)(),h=(0,r.vt)(),d=(0,r.vt)();function c(t,e,i){return(0,a.hZ)(o,e[0],e[1],1),(0,a.ei)(o,o,(0,s.mg)(l,i)),0===o[2]?(0,n.hZ)(t,o[0],o[1]):(0,n.hZ)(t,o[0]/o[2],o[1]/o[2])}function u(t,e,i){return p(h,e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]),p(d,i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7]),(0,s.lw)(t,(0,s.KC)(h,h),d),0!==t[8]&&(t[0]/=t[8],t[1]/=t[8],t[2]/=t[8],t[3]/=t[8],t[4]/=t[8],t[5]/=t[8],t[6]/=t[8],t[7]/=t[8],t[8]/=t[8]),t}function p(t,e,i,r,n,h,d,c,u){(0,s.hZ)(t,e,r,h,i,n,d,1,1,1),(0,a.hZ)(o,c,u,1),(0,s.KC)(l,t);let[p,g,f]=(0,a.ei)(o,o,(0,s.mg)(l,l));return(0,s.hZ)(l,p,0,0,0,g,0,0,0,f),(0,s.lw)(t,l,t)}},90629(t,e,i){i.d(e,{L7:()=>n,Lz:()=>a,PN:()=>o,cr:()=>l,gs:()=>d,ps:()=>r,r_:()=>c,tc:()=>h}),i(39829);const s=/^-?(\d+(\.\d+)?)\s*((px)|(pt))?$/i,r=o(1),n=a(1);function a(t){return t?t/72*96:0}function o(t){return t?72*t/96:0}function l(t){if("string"==typeof t){let e=t.match(s);if(e){let i=Number(e[1]),s=e[3]&&e[3].toLowerCase(),r=t.startsWith("-"),n="px"===s?o(i):i;return r?-n:n}return console.warn("screenUtils.toPt: input not recognized!"),null}return t}function h(t=0,e=0){return{x:t,y:e}}function d(t=0,e=0){return[t,e]}function c(t=0,e=0,i=0){return[t,e,i]}},48526(t,e,i){var s,r=i(32198),n=i(91429),a=i(4576),o=i(4718),l=i(5443),h=i(91075),d=i(86738),c=i(16930),u=i(90634),p=i(47610),g=i(56993),f=i(43937);let m=s=class extends h.A{constructor(t){super(function(t){if(!t)return;let{points:e,hasM:i,hasZ:s,spatialReference:r}=t;switch(e??=[],e?.at(0)?.length){case 4:s??=!0,i??=!0;break;case 3:s??=!0!==i,i??=!s;break;default:s??=!1,i??=!1}return r??=c.A.WGS84,{...t,hasM:i,hasZ:s,points:e,spatialReference:r}}(t)),this.points=[],this.type="multipoint"}get cache(){return this.commitProperty("points"),this.commitProperty("hasZ"),this.commitProperty("hasM"),this.commitProperty("spatialReference"),{}}get extent(){let t=(0,u.ge)(this);return t?new l.A({...t,spatialReference:this.spatialReference}):null}writePoints(t,e){e.points=(0,o.o8)(this.points)}clone(){let{points:t,spatialReference:e,hasM:i,hasZ:r}=this;return new s({points:(0,o.o8)(t),spatialReference:e.clone(),hasM:i,hasZ:r})}equals(t){if(this===t)return!0;if(null==t)return!1;let e=this.spatialReference,i=t.spatialReference;return!(null!=e!=(null!=i)||null!=e&&null!=i&&!e.equals(i))&&(0,a.aI)(this.points,t.points,p.v6)}addPoint(t){return(0,g.h)(this,t),Array.isArray(t)?this.points.push(t):this.points.push(t.toArray()),this.notifyChange("points"),this}getPoint(t){if(!this._validateInputs(t))return null;let e=this.points[t],i={x:e[0],y:e[1],spatialReference:this.spatialReference},s=2;return this.hasZ&&(i.z=e[2],s=3),this.hasM&&(i.m=e[s]),new d.A(i)}removePoint(t){if(!this._validateInputs(t))return null;let[e,i,s,r]=this.points.splice(t,1)[0],n=new d.A({x:e,y:i,z:s,m:r,spatialReference:this.spatialReference});return this.notifyChange("points"),n}setPoint(t,e){return this._validateInputs(t)&&((0,g.h)(this,e),Array.isArray(e)||(e=e.toArray()),this.points[t]=e,this.notifyChange("points")),this}toJSON(t){return this.write({},t)}_validateInputs(t){return null!=t&&t>=0&&t<this.points.length}};(0,r.Cg)([(0,n.MZ)({readOnly:!0})],m.prototype,"cache",null),(0,r.Cg)([(0,n.MZ)({readOnly:!0})],m.prototype,"extent",null),(0,r.Cg)([(0,n.MZ)({type:[[Number]],json:{write:{isRequired:!0}}})],m.prototype,"points",void 0),(0,r.Cg)([(0,f.K)("points")],m.prototype,"writePoints",null),m=s=(0,r.Cg)([(0,n.$K)("esri.geometry.Multipoint")],m);const y=m;m.prototype.toJSON.isDefaultToJSON=!0,i.d(e,["A",0,y])},82799(t,e,i){var s,r=i(32198),n=i(91429),a=i(4718),o=i(5443),l=i(91075),h=i(86738),d=i(16930),c=i(90634),u=i(56993),p=i(43937);let g=s=class extends l.A{constructor(t){super(function(t){if(!t)return;let{paths:e,hasM:i,hasZ:s,spatialReference:r}=t;switch(e??=[],function(t){return"number"==typeof t[0]?.[0]}(e)&&(e=[e]),e[0]?.[0]?.length){case 4:s??=!0,i??=!0;break;case 3:s??=!0!==i,i??=!s;break;default:s??=!1,i??=!1}return r??=d.A.WGS84,{...t,hasM:i,hasZ:s,paths:e,spatialReference:r}}(t)),this.curvePaths=void 0,this.paths=[],this.type="polyline"}get cache(){return this.commitProperty("curvePaths"),this.commitProperty("hasM"),this.commitProperty("hasZ"),this.commitProperty("paths"),this.commitProperty("spatialReference"),{}}writeCurvePaths(t,e){e.curvePaths=(0,a.o8)(t)}get extent(){let t=(0,c.Z3)(this),{spatialReference:e}=this;return t?new o.A({...t,spatialReference:e}):null}writePaths(t,e){e.paths=(0,a.o8)(this.paths)}addPath(t){if(!t)return;let e=this.paths,i=e.length;if(function(t){return!Array.isArray(t[0])}(t)){let s=[];for(let e=0,i=t.length;e<i;e++)s[e]=t[e].toArray();e[i]=s}else e[i]=t.slice();return this.notifyChange("paths"),this}clone(){let t=new s;return t.spatialReference=this.spatialReference,t.paths=(0,a.o8)(this.paths),t.curvePaths=(0,a.o8)(this.curvePaths),t.hasZ=this.hasZ,t.hasM=this.hasM,t}getPoint(t,e){if(!this._validateInputs(t,e))return null;let i=this.paths[t][e],s=this.hasZ,r=this.hasM;return s&&!r?new h.A({x:i[0],y:i[1],z:i[2],spatialReference:this.spatialReference}):r&&!s?new h.A({x:i[0],y:i[1],m:i[2],spatialReference:this.spatialReference}):s&&r?new h.A({x:i[0],y:i[1],z:i[2],m:i[3],spatialReference:this.spatialReference}):new h.A({x:i[0],y:i[1],spatialReference:this.spatialReference})}insertPoint(t,e,i){return this._validateInputs(t,e,!0)&&((0,u.h)(this,i),Array.isArray(i)||(i=i.toArray()),this.paths[t].splice(e,0,i),this.notifyChange("paths")),this}removePath(t){if(!this._validateInputs(t,null))return null;let e=this.paths.splice(t,1)[0],i=this.spatialReference,s=e.map(t=>new h.A({x:t[0],y:t[1],z:t[2],m:t[3],spatialReference:i}));return this.notifyChange("paths"),s}removePoint(t,e){if(!this._validateInputs(t,e))return null;let[i,s,r,n]=this.paths[t].splice(e,1)[0],a=new h.A({x:i,y:s,z:r,m:n,spatialReference:this.spatialReference});return this.notifyChange("paths"),a}setPoint(t,e,i){return this._validateInputs(t,e)&&((0,u.h)(this,i),Array.isArray(i)||(i=i.toArray()),this.paths[t][e]=i,this.notifyChange("paths")),this}_validateInputs(t,e,i=!1){if(null==t||t<0||t>=this.paths.length)return!1;if(null!=e){let s=this.paths[t];if(i&&(e<0||e>s.length)||!i&&(e<0||e>=s.length))return!1}return!0}toJSON(t){return this.write({},t)}};(0,r.Cg)([(0,n.MZ)({readOnly:!0})],g.prototype,"cache",null),(0,r.Cg)([(0,n.MZ)({json:{write:!0,origins:{"portal-item":{write:!1},"web-map":{write:!1},"web-scene":{write:!1}}}})],g.prototype,"curvePaths",void 0),(0,r.Cg)([(0,p.K)("curvePaths")],g.prototype,"writeCurvePaths",null),(0,r.Cg)([(0,n.MZ)({readOnly:!0})],g.prototype,"extent",null),(0,r.Cg)([(0,n.MZ)({type:[[[Number]]],json:{write:{isRequired:!0}}})],g.prototype,"paths",void 0),(0,r.Cg)([(0,p.K)("paths")],g.prototype,"writePaths",null),g=s=(0,r.Cg)([(0,n.$K)("esri.geometry.Polyline")],g);const f=g;g.prototype.toJSON.isDefaultToJSON=!0,i.d(e,["A",0,f])},4144(t,e,i){i.r(e),i.d(e,{clipToSpatialReference:()=>l,execute:()=>h,executeMany:()=>d,foldInto360Range:()=>c,foldInto360RangeGeodetic:()=>u,isLoaded:()=>a,load:()=>o,normalizeGeometry:()=>p,supportsCurves:()=>g,transform:()=>f});var s=i(76061),r=i(83290);let n;function a(){return!!n&&(0,r.i)()}async function o(){if(!a()){let[t,e]=await Promise.all([Promise.all([i.e(9187),i.e(8885),i.e(9117),i.e(9192)]).then(()=>i(9192)),Promise.all([i.e(9187),i.e(8885),i.e(9117),i.e(5756)]).then(()=>i(15756)).then(({injectPe:t})=>t),(0,r.l)()]);n=new t.OperatorProject,e(r.p)}}function l(t,e,i){return n.clipToSpatialReference(t,e,null,i)}function h(t,e){return n.execute(t,e,null)}function d(t,e){let i=n.executeMany(new s.S(t),e,null);return Array.from(i)}function c(t,e){return n.foldInto360Range(t,e)}function u(t,e,i){return n.foldInto360RangeGeodetic(t,e,i)}function p(t,e,i){return n.normalizeGeometry(t,e,i)}function g(){return n.supportsCurves()}function f(t,e,i,s,r){return n.transform(t,e,i,s,r)}},83276(t,e,i){i.r(e),i.d(e,{execute:()=>b,executeMany:()=>A,isLoaded:()=>g,load:()=>m,projectExecute:()=>y,projectExecuteMany:()=>v,projectIsLoaded:()=>p,projectLoad:()=>f,projectSupportsCurves:()=>c,supportsCurves:()=>u});var s=i(4144),r=i(85036),n=i(17499);let a,o,l,h,d,c,u;function p(){return!!a&&(0,s.isLoaded)()}function g(){return(0,r.Q)("projectOperator","isLoaded","projectIsLoaded"),p()}async function f(){if(!p()){let[t,e]=await Promise.all([Promise.all([i.e(9187),i.e(8885),i.e(9117),i.e(3299),i.e(1666)]).then(()=>i(78125)),Promise.all([i.e(9187),i.e(8885),i.e(9117),i.e(6129)]).then(()=>i(86129)),(0,s.load)()]);a=t.fromGeometry,o=t.fromSpatialReference,l=t.getSpatialReference,h=t.toGeometry,d=e.createProjectionTransformation,c=(0,s.supportsCurves)(),u=c}}function m(){return(0,r.Q)("projectOperator","load","projectLoad"),f()}function y(t,e,i){let r=l(t),c=d(o(r),o(e),i),u=h((0,s.execute)(a(t),c),e);return!i?.zConversionDisabled&&u?.hasZ&&(0,n.g)([u],r,e),u}function b(t,e,i){return(0,r.Q)("projectOperator","execute","projectExecute"),y(t,e,i)}function v(t,e,i){let r=t.map(a),c=l(t),u=d(o(c),o(e),i),p=(0,s.executeMany)(r,u).map(t=>h(t,e));return!i?.zConversionDisabled&&p&&(0,n.g)(p,c,e),p}function A(t,e,i){return(0,r.Q)("projectOperator","executeMany","projectExecuteMany"),v(t,e,i)}},17499(t,e,i){i.d(e,{g:()=>n});var s=i(60408),r=i(62815);function n(t,e,i){let n;for(let a of t)if(a&&(0,s.Pv)(a)&&!("vertexAttributes"in a)){if(!n){let t="type"in a?a.type:(0,s.$B)(a);if(n=(0,r.N)(t,e,i),!n)return}n(a)}}},60408(t,e,i){function s(t){return void 0!==t.xmin&&void 0!==t.ymin&&void 0!==t.xmax&&void 0!==t.ymax}function r(t){return void 0!==t.points}function n(t){return void 0!==t.x&&void 0!==t.y}function a(t){return void 0!==t.paths||void 0!==t.curvePaths}function o(t){return void 0!==t.rings||void 0!==t.curveRings}function l(t){return"object"==typeof t&&"vertexAttributes"in t}function h(t){return t?n(t)?"esriGeometryPoint":a(t)?"esriGeometryPolyline":o(t)?"esriGeometryPolygon":s(t)?"esriGeometryEnvelope":r(t)?"esriGeometryMultipoint":null:null}function d(t){return null!=t&&("hasZ"in t&&t.hasZ||"z"in t&&null!=t.z)}function c(t){return null!=t&&("hasM"in t&&t.hasM||"m"in t&&null!=t.m)}i.d(e,{$B:()=>h,Bi:()=>o,Pv:()=>d,Rg:()=>a,U9:()=>r,W0:()=>c,ZC:()=>s,fT:()=>n,uW:()=>l})},65864(t,e,i){i.d(e,{rS:()=>d,xD:()=>u});var s=i(5443),r=i(91075),n=i(48526),a=i(86738),o=i(39829),l=i(82799),h=i(60408);function d(t){return null==t?null:t instanceof r.A?t:(0,h.fT)(t)?a.A.fromJSON(t):(0,h.Rg)(t)?l.A.fromJSON(t):(0,h.Bi)(t)?o.A.fromJSON(t):(0,h.U9)(t)?n.A.fromJSON(t):(0,h.ZC)(t)?s.A.fromJSON(t):null}const c={esriGeometryPoint:a.A,esriGeometryPolyline:l.A,esriGeometryPolygon:o.A,esriGeometryEnvelope:s.A,esriGeometryMultipoint:n.A,esriGeometryMultiPatch:o.A};function u(t){return t&&c[t]||null}},62815(t,e,i){i.d(e,{N:()=>o,d:()=>l});var s=i(86211),r=i(73941),n=i(52006),a=i(21325);function o(t,e,i){let s=l(e,i);if(1!==s)switch(t){case"point":case"esriGeometryPoint":return t=>function(t,e){null!=t?.z&&(t.z*=e)}(t,s);case"polyline":case"esriGeometryPolyline":return t=>function(t,e){if(t){if(t.curvePaths)for(let i of t.curvePaths)for(let t of i){let i=(0,n.yP)(t);i.length>2&&(i[2]*=e)}if(t.paths)for(let i of t.paths)for(let t of i)t.length>2&&(t[2]*=e)}}(t,s);case"polygon":case"esriGeometryPolygon":return t=>function(t,e){if(t){if(t.curveRings)for(let i of t.curveRings)for(let t of i){let i=(0,n.yP)(t);i.length>2&&(i[2]*=e)}if(t.rings)for(let i of t.rings)for(let t of i)t.length>2&&(t[2]*=e)}}(t,s);case"multipoint":case"esriGeometryMultipoint":return t=>function(t,e){if(t)for(let i of t.points)i.length>2&&(i[2]*=e)}(t,s);case"extent":case"esriGeometryEnvelope":return t=>function(t,e){t&&null!=t.zmin&&null!=t.zmax&&(t.zmin*=e,t.zmax*=e)}(t,s);default:return}}function l(t,e){return null==t||null==e||(0,a.aI)(t,e)||(0,r.xP)(t)||(0,r.xP)(e)?1:(0,s.G9)(t)/(0,s.G9)(e)}},68392(t,e,i){i.r(e),i.d(e,{default:()=>Tr});var s=i(2741),r=i(49186);function n(t,e,i,s,r,n){return[t,e,i,s,r,n]}Object.freeze(Object.defineProperty({__proto__:null,IDENTITY:[1,0,0,1,0,0],clone:function(t){return[t[0],t[1],t[2],t[3],t[4],t[5]]},create:function(){return[1,0,0,1,0,0]},fromValues:n},Symbol.toStringTag,{value:"Module"}));var a=i(16905),o=i(17676),l=i(5443);const h=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),d=[1/0,1/0,-1/0,-1/0],c=new Float32Array(d),u=[.001,0,0,.001,0,0],p=1.35,g="pdfjs_internal_id_",f="pdfjs_internal_editor_",m=12,y=31,b={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94};let v=1;function A(t){Number.isInteger(t)&&(v=t)}function w(){return v}function x(t){v>=5&&console.info(`Info: ${t}`)}function _(t){v>=1&&console.warn(`Warning: ${t}`)}function S(t){throw Error(t)}function C(t,e){t||S(e)}function M(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const k=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=Error(),t.constructor=t,t}();class P extends k{constructor(t,e){super(t,"PasswordException"),this.code=e}}class T extends k{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class E extends k{constructor(t){super(t,"InvalidPDFException")}}class D extends k{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class I extends k{constructor(t){super(t,"FormatError")}}class F extends k{constructor(t){super(t,"AbortException")}}function R(t){"string"!=typeof t&&S("Invalid argument for stringToBytes");let e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}class N{static get isLittleEndian(){let t=new Uint8Array(4);return t[0]=1,M(this,"isLittleEndian",1===new Uint32Array(t.buffer,0,1)[0])}static get isOffscreenCanvasSupported(){return M(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return M(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return M(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return M(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){let{platform:t,userAgent:e}=navigator;return M(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;return this.isOffscreenCanvasSupported?t=new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"&&(t=document.createElement("canvas").getContext("2d")),M(this,"isCanvasFilterSupported",void 0!==t?.filter)}static get isAlphaColorInputSupported(){return M(this,"isAlphaColorInputSupported",(()=>{if(typeof document>"u")return!1;let t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080","#ff0000"!==t.value})())}}class O{static get hexNums(){return M(this,"hexNums",Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0")))}static makeHexColor(t,e,i){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[i]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),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 multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,i=0){let s=t[i],r=t[i+1];t[i]=s*e[0]+r*e[2]+e[4],t[i+1]=s*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){let s=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5];for(let e=0;e<6;e+=2){let h=t[i+e],d=t[i+e+1];t[i+e]=h*s+d*n+o,t[i+e+1]=h*r+d*a+l}}static applyInverseTransform(t,e){let i=t[0],s=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,i){let s=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5],h=t[0],d=t[1],c=t[2],u=t[3],p=s*h+o,g=p,f=s*c+o,m=f,y=a*d+l,b=y,v=a*u+l,A=v;if(0!==r||0!==n){let t=r*h,e=r*c,i=n*d,s=n*u;p+=i,m+=i,f+=s,g+=s,y+=t,A+=t,v+=e,b+=e}i[0]=Math.min(i[0],p,f,g,m),i[1]=Math.min(i[1],y,v,b,A),i[2]=Math.max(i[2],p,f,g,m),i[3]=Math.max(i[3],y,v,b,A)}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){let i=t[0],s=t[1],r=t[2],n=t[3],a=i**2+s**2,o=i*r+s*n,l=r**2+n**2,h=(a+l)/2,d=Math.sqrt(h**2-(a*l-o**2));e[0]=Math.sqrt(h+d||1),e[1]=Math.sqrt(h-d||1)}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 i=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(i>s)return null;let r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),n=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>n?null:[i,r,s,n]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,s,r){r[0]=Math.min(r[0],t,i),r[1]=Math.min(r[1],e,s),r[2]=Math.max(r[2],t,i),r[3]=Math.max(r[3],e,s)}static#t(t,e,i,s,r,n,a,o,l,h){if(l<=0||l>=1)return;let d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*r+3*l*n)+3*c*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static#e(t,e,i,s,r,n,a,o,l,h,d,c){if(Math.abs(l)<1e-12)return void(Math.abs(h)>=1e-12&&this.#t(t,e,i,s,r,n,a,o,-d/h,c));let u=h**2-4*d*l;if(u<0)return;let p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,r,n,a,o,(-h+p)/g,c),this.#t(t,e,i,s,r,n,a,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,r,n,a,o,l){l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o),this.#e(t,i,r,a,e,s,n,o,3*(3*(i-r)-t+a),6*(t-2*i+r),3*(i-t),l),this.#e(t,i,r,a,e,s,n,o,3*(3*(s-n)-e+o),6*(e-2*s+n),3*(s-e),l)}}const B=()=>[],L=()=>new Map,j=()=>Object.create(null);function $(t,e,i){return Math.min(Math.max(t,e),i)}class U{static textContent(t){let e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let s=null,r=i.name;if("#text"===r)s=i.value;else{if(!U.shouldBuildText(r))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(let e of i.children)t(e)}(t),i}static shouldBuildText(t){return"textarea"!==t&&"input"!==t&&"option"!==t&&"select"!==t}}class z{static setupStorage(t,e,i,s,r){let n=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==n.value&&(t.textContent=n.value),"print"===r)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(n.value===i.attributes.xfaOn?t.setAttribute("checked",!0):n.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===r)break;t.addEventListener("change",t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==n.value&&t.setAttribute("value",n.value),"print"===r)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})})}break;case"select":if(null!==n.value){t.setAttribute("value",n.value);for(let t of i.children)t.attributes.value===n.value?t.attributes.selected=!0:Object.hasOwn(t.attributes,"selected")&&delete t.attributes.selected}t.addEventListener("input",t=>{let i=t.target.options,r=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:r})})}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:r}){let{attributes:n}=e,a=t instanceof HTMLAnchorElement;"radio"===n.type&&(n.name=`${n.name}-${s}`);for(let[e,i]of Object.entries(n))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:(!a||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}a&&r.addLinkAttributes(t,n.href,n.newWindow),i&&n.dataId&&this.setupStorage(t,n.dataId,e,i)}static render(t){let e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,r=t.intent||"display",n=document.createElement(s.name);s.attributes&&this.setAttributes({html:n,element:s,intent:r,linkService:i});let a="richText"!==r,o=t.div;if(o.append(n),t.viewport){let e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");let l=[];if(0===s.children.length){if(s.value){let t=document.createTextNode(s.value);n.append(t),a&&U.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}let h=[[s,-1,n]];for(;h.length>0;){let[t,s,n]=h.at(-1);if(s+1===t.children.length){h.pop();continue}let o=t.children[++h.at(-1)[1]];if(null===o)continue;let{name:d}=o;if("#text"===d){let t=document.createTextNode(o.value);l.push(t),n.append(t);continue}let c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(n.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:r,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){let t=document.createTextNode(o.value);a&&U.shouldBuildText(d)&&l.push(t),c.append(t)}}for(let t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const G="http://www.w3.org/2000/svg";class W{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function H(t,e="text"){if(Z(t,document.baseURI)){let i=await fetch(t);if(!i.ok)throw Error(i.statusText);switch(e){case"blob":return i.blob();case"bytes":return i.bytes();case"json":return i.json()}return i.text()}return new Promise((i,s)=>{let r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="bytes"===e?"arraybuffer":e,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE)if(200!==r.status&&0!==r.status)s(Error(r.statusText));else{switch(e){case"bytes":return void i(new Uint8Array(r.response));case"blob":case"json":return void i(r.response)}i(r.responseText)}},r.send(null)})}class V{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:r=0,offsetY:n=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=r,this.offsetY=n,i*=e;let o,l,h,d,c,u,p,g,f=(t[2]+t[0])/2,m=(t[3]+t[1])/2;switch((s%=360)<0&&(s+=360),s){case 180:o=-1,l=0,h=0,d=1;break;case 90:o=0,l=1,h=1,d=0;break;case 270:o=0,l=-1,h=-1,d=0;break;case 0:o=1,l=0,h=0,d=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(h=-h,d=-d),0===o?(c=Math.abs(m-t[1])*i+r,u=Math.abs(f-t[0])*i+n,p=(t[3]-t[1])*i,g=(t[2]-t[0])*i):(c=Math.abs(f-t[0])*i+r,u=Math.abs(m-t[1])*i+n,p=(t[2]-t[0])*i,g=(t[3]-t[1])*i),this.transform=[o*i,l*i,h*i,d*i,c-o*i*f-h*i*m,u-l*i*f-d*i*m],this.width=p,this.height=g}get rawDims(){let t=this.viewBox;return M(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:r=!1}={}){return new V({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:r})}convertToViewportPoint(t,e){let i=[t,e];return O.applyTransform(i,this.transform),i}convertToViewportRectangle(t){let e=[t[0],t[1]];O.applyTransform(e,this.transform);let i=[t[2],t[3]];return O.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){let i=[t,e];return O.applyInverseTransform(i,this.transform),i}}class X extends k{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function q(t){let e=t.length,i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function Y(t){return"string"==typeof t&&/\.pdf$/i.test(t)}class K{#t=new Map;times=[];time(t){this.#t.has(t)&&_(`Timer is already running for ${t}`),this.#t.set(t,Date.now())}timeEnd(t){this.#t.has(t)||_(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.#t.get(t),end:Date.now()}),this.#t.delete(t)}toString(){let t=Math.max(...this.times.map(t=>t.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms\n`).join("")}}function Z(t,e){let i=e?URL.parse(t,e):URL.parse(t);return/https?:/.test(i?.protocol??"")}function J(t){t.preventDefault()}function Q(t){t.preventDefault(),t.stopPropagation()}class tt{static#t;static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;this.#t||=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 i=parseInt(e[1],10),s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let n=parseInt(e[4],10);n=n>=0&&n<=23?n:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;let l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===l?(n+=h,a+=d):"+"===l&&(n-=h,a-=d),new Date(Date.UTC(i,s,r,n,a,o))}}function et(t){if(t.startsWith("#")){let e=t.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(t.startsWith("rgb(")){let[e,i,s]=t.slice(4,-1).split(",").map(t=>parseInt(t,10));return[e,i,s,1]}if(t.startsWith("rgba(")){let e=t.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}let e=t.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return e?[Math.round(255*parseFloat(e[1])),Math.round(255*parseFloat(e[2])),Math.round(255*parseFloat(e[3])),void 0!==e[4]&&"none"!==e[4]?parseFloat(e[4]):1]:null}function it(t){let e=et(t);return e?e.slice(0,3):(_(`Not a valid color format: "${t}"`),[0,0,0])}function st(t){let{a:e,b:i,c:s,d:r,e:n,f:a}=t.getTransform();return[e,i,s,r,n,a]}function rt(t){let{a:e,b:i,c:s,d:r,e:n,f:a}=t.getTransform().invertSelf();return[e,i,s,r,n,a]}function nt(t,e,i=!1,s=!0){if(e instanceof V){let{pageWidth:s,pageHeight:r}=e.rawDims,{style:n}=t,a=`round(down, var(--total-scale-factor) * ${s}px, var(--scale-round-x))`,o=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-y))`;i&&e.rotation%180!=0?(n.width=o,n.height=a):(n.width=a,n.height=o)}s&&t.setAttribute("data-main-rotation",e.rotation)}class at{constructor(){let{pixelRatio:t}=at;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,s,r=-1){let n=1/0,a=1/0,o=1/0;(i=at.capPixels(i,r))>0&&(n=Math.sqrt(i/(t*e))),-1!==s&&(a=s/t,o=s/e);let l=Math.min(n,a,o);return(this.sx>l||this.sy>l)&&(this.sx=l,this.sy=l,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){let i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}const ot=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class lt{static get isDarkMode(){return M(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}function ht(t){let e=new Path2D;if(!t)return e;for(let i=0,s=t.length;i<s;)switch(t[i++]){case 0:e.moveTo(t[i++],t[i++]);break;case 1:e.lineTo(t[i++],t[i++]);break;case 2:e.bezierCurveTo(t[i++],t[i++],t[i++],t[i++],t[i++],t[i++]);break;case 3:e.quadraticCurveTo(t[i++],t[i++],t[i++],t[i++]);break;case 4:e.closePath();break;default:_(`Unrecognized drawing path operator: ${t[i-1]}`)}return e}class dt{#t=null;#e=null;#i;#s=null;#r=null;#n=null;#a=null;#o=null;static#l=null;constructor(t){this.#i=t,dt.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){let t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#i._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",J,{signal:e}),t.addEventListener("pointerdown",dt.#h,{signal:e}));let i=this.#s=document.createElement("div");i.className="buttons",t.append(i);let s=this.#i.toolbarPosition;if(s){let{style:e}=t;e.insetInlineEnd=100*("ltr"===this.#i._uiManager.direction?1-s[0]:s[0])+"%",e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#t}static#h(t){t.stopPropagation()}#d(t){this.#i._focusEventsAllowed=!1,Q(t)}#c(t){this.#i._focusEventsAllowed=!0,Q(t)}#u(t){let e=this.#i._uiManager._signal;return e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("focusin",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",J,{signal:e}),!0)}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#r?.shown(),this.#n?.shown()}addDeleteButton(){let{editorType:t,_uiManager:e}=this.#i,i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",dt.#l[t]),this.#u(i)&&i.addEventListener("click",t=>{e.delete()},{signal:e._signal}),this.#s.append(i)}get#p(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#u(e),this.#s.append(e,this.#p),this.#r=t}addComment(t,e=null){if(this.#n)return;let i=t.renderForToolbar();if(!i)return;this.#u(i);let s=this.#a=this.#p;e?(this.#s.insertBefore(i,e),this.#s.insertBefore(s,e)):this.#s.append(i,s),this.#n=t,t.toolbar=this}addColorPicker(t){if(this.#e)return;this.#e=t;let e=t.renderButton();this.#u(e),this.#s.append(e,this.#p)}async addEditSignatureButton(t){let e=this.#o=await t.renderEditButton(this.#i);this.#u(e),this.#s.append(e,this.#p)}removeButton(t){"comment"===t&&(this.#n?.removeToolbarCommentButton(),this.#n=null,this.#a?.remove(),this.#a=null)}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e)}}async addButtonBefore(t,e,i){if(!e&&"comment"===t)return;let s=this.#s.querySelector(i);s&&"comment"===t&&this.addComment(e,s)}updateEditSignatureButton(t){this.#o&&(this.#o.title=t)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class ct{#t=null;#e=null;#i;constructor(t){this.#i=t}#s(){let t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");let e=this.#i._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",J,{signal:e});let i=this.#t=document.createElement("div");return i.className="buttons",t.append(i),this.#i.hasCommentManager()&&this.#n("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#i.commentSelection("floating_button")}),this.#n("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#i.highlightSelection("floating_button")}),t}#r(t,e){let i=0,s=0;for(let r of t){let t=r.y+r.height;if(t<i)continue;let n=r.x+(e?r.width:0);t>i?(s=n,i=t):e?n>s&&(s=n):n<s&&(s=n)}return[e?1-s:s,i]}show(t,e,i){let[s,r]=this.#r(e,i),{style:n}=this.#e||=this.#s();t.append(this.#e),n.insetInlineEnd=100*s+"%",n.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#n(t,e,i,s){let r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);let n=document.createElement("span");r.append(n),n.className="visuallyHidden",n.setAttribute("data-l10n-id",i);let a=this.#i._signal;a instanceof AbortSignal&&!a.aborted&&(r.addEventListener("contextmenu",J,{signal:a}),r.addEventListener("click",s,{signal:a})),this.#t.append(r)}}function ut(t,e,i){for(let s of i)e.addEventListener(s,t[s].bind(t))}class pt{static#t=NaN;static#e=null;static#i=NaN;static#s=null;static initializeAndAddPointerId(t){(pt.#e||=new Set).add(t)}static setPointer(t,e){pt.#t||=e,pt.#s??=t}static setTimeStamp(t){pt.#i=t}static isSamePointerId(t){return pt.#t===t}static isSamePointerIdOrRemove(t){return pt.#t===t||(pt.#e?.delete(t),!1)}static isSamePointerType(t){return pt.#s===t}static isInitializedAndDifferentPointerType(t){return null!==pt.#s&&!pt.isSamePointerType(t)}static isSameTimeStamp(t){return pt.#i===t}static isUsingMultiplePointers(){return pt.#e?.size>=1}static clearPointerType(){pt.#s=null}static clearPointerIds(){pt.#t=NaN,pt.#e=null}static clearTimeStamp(){pt.#i=NaN}}class gt{#t=0;get id(){return`${f}${this.#t++}`}}class ft{#t=function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();let t=new Uint8Array(32);return crypto.getRandomValues(t),function(t){"object"==typeof t&&void 0!==t?.length||S("Invalid argument for bytesToString");let e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);let s=[];for(let r=0;r<e;r+=i){let n=Math.min(r+i,e),a=t.subarray(r,n);s.push(String.fromCharCode.apply(null,a))}return s.join("")}(t)}();#e=0;#i=null;static get _isSVGFittingCanvas(){let t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.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>',M(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}async#s(t,e){this.#i||=new Map;let i=this.#i.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await H(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){let e=ft._isSVGFittingCanvas,s=new FileReader,r=new Image,n=new Promise((t,n)=>{r.onload=()=>{i.bitmap=r,i.isSvg=!0,t()},s.onload=async()=>{let t=i.svgUrl=s.result;r.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},r.onerror=s.onerror=n});s.readAsDataURL(t),await n}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){_(t),i=null}return this.#i.set(t,i),i&&this.#i.set(i.id,i),i}async getFromFile(t){let{lastModified:e,name:i,size:s,type:r}=t;return this.#s(`${e}_${i}_${s}_${r}`,t)}async getFromUrl(t){return this.#s(t,t)}async getFromBlob(t,e){let i=await e;return this.#s(t,i)}async getFromId(t){this.#i||=new Map;let e=this.#i.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:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#i||=new Map;let i=this.#i.get(t);if(i?.bitmap)return i.refCounter+=1,i;let s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#i.set(t,i),this.#i.set(i.id,i),i}getSvgUrl(t){let e=this.#i.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#i||=new Map;let e=this.#i.get(t);if(!e)return;if(--e.refCounter,0!==e.refCounter)return;let{bitmap:i}=e;if(!e.url&&!e.file){let t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class mt{#t=[];#e=!1;#i;#s=-1;constructor(t=128){this.#i=t}add({cmd:t,undo:e,post:i,mustExec:s,type:r=NaN,overwriteIfSameType:n=!1,keepUndo:a=!1}){if(s&&t(),this.#e)return;let o={cmd:t,undo:e,post:i,type:r};if(-1===this.#s)return this.#t.length>0&&(this.#t.length=0),this.#s=0,void this.#t.push(o);if(n&&this.#t[this.#s].type===r)return a&&(o.undo=this.#t[this.#s].undo),void(this.#t[this.#s]=o);let l=this.#s+1;l===this.#i?this.#t.splice(0,1):(this.#s=l,l<this.#t.length&&this.#t.splice(l)),this.#t.push(o)}undo(){if(-1===this.#s)return;this.#e=!0;let{undo:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1,--this.#s}redo(){if(this.#s<this.#t.length-1){this.#s+=1,this.#e=!0;let{cmd:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return-1!==this.#s}hasSomethingToRedo(){return this.#s<this.#t.length-1}cleanType(t){if(-1!==this.#s){for(let e=this.#s;e>=0;e--)if(this.#t[e].type!==t)return this.#t.splice(e+1,this.#s-e),void(this.#s=e);this.#t.length=0,this.#s=-1}}destroy(){this.#t=null}}class yt{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:e}=N.platform;for(let[i,s,r={}]of t)for(let t of i){let i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:r}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:r}),this.allKeys.add(t.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 i=this.callbacks.get(this.#t(e));if(!i)return;let{callback:s,options:{bubbles:r=!1,args:n=[],checker:a=null}}=i;a&&!a(t,e)||(s.bind(t,...n,e)(),r||Q(e))}}class bt{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){let e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(let i of t.keys()){e.style.color=i;let s=window.getComputedStyle(e).color;t.set(i,it(s))}e.remove()}(t),M(this,"_colors",t)}convert(t){let e=it(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[t,i]of this._colors)if(i.every((t,i)=>t===e[i]))return bt._colorsMapping.get(t);return e}getHexCode(t){let e=this._colors.get(t);return e?O.makeHexColor(...e):t}}class vt{#t=new AbortController;#e=null;#i=null;#s=new Map;#r=new Map;#n=null;#a=null;#o=null;#l=null;#h=new mt;#d=null;#c=null;#u=null;#p=0;#g=new Set;#f=null;#m=null;#y=new Set;_editorUndoBar=null;#b=!1;#v=!1;#A=!1;#w=null;#x=null;#_=null;#S=null;#C=!1;#M=null;#k=new gt;#P=!1;#T=!1;#E=!1;#D=null;#I=null;#F=null;#R=null;#N=null;#O=0;#B=new Set;#L=null;#j=null;#$=null;#U=null;#z=null;#G={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#W=[0,0];#H=null;#V=null;#X=null;#q=null;#Y=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=vt.prototype,e=t=>t.#V.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>{if(e instanceof HTMLInputElement){let{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return M(this,"_keyboardManager",new yt([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["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:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#V.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#V.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:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}constructor(t,e,i,s,r,n,a,o,l,h,d,c,u,p,g,f){let m=this._signal=this.#t.signal;this.#V=t,this.#X=e,this.#q=i,this.#a=s,this.#d=r,this.#j=n,this.#z=o,this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:m}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:m}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:m}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:m}),a._on("setpreference",this.onSetPreference.bind(this),{signal:m}),a._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:m}),window.addEventListener("pointerdown",()=>{this.#T=!0},{capture:!0,signal:m}),window.addEventListener("pointerup",()=>{this.#T=!1},{capture:!0,signal:m}),window.addEventListener("beforeunload",this.#K.bind(this),{capture:!0,signal:m}),this.#Z(),this.#J(),this.#Q(),this.#o=o.annotationStorage,this.#w=o.filterFactory,this.#$=l,this.#S=h||null,this.#b=d,this.#v=c,this.#A=u,this.#N=p||null,this.viewParameters={realScale:W.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=!1!==f,r?.setSidebarUiManager(this)}destroy(){this.#Y?.resolve(),this.#Y=null,this.#t?.abort(),this.#t=null,this._signal=null;for(let t of this.#r.values())t.destroy();this.#r.clear(),this.#s.clear(),this.#y.clear(),this.#R?.clear(),this.#e=null,this.#B.clear(),this.#h.destroy(),this.#a?.destroy(),this.#d?.destroy(),this.#j?.destroy(),this.#M?.hide(),this.#M=null,this.#F?.destroy(),this.#F=null,this.#i=null,this.#x&&(clearTimeout(this.#x),this.#x=null),this.#H&&(clearTimeout(this.#H),this.#H=null),this._editorUndoBar?.destroy(),this.#z=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#N}get useNewAltTextFlow(){return this.#v}get useNewAltTextWhenAddingImage(){return this.#A}get hcmFilter(){return M(this,"hcmFilter",this.#$?this.#w.addHCMFilter(this.#$.foreground,this.#$.background):"none")}get direction(){return M(this,"direction",getComputedStyle(this.#V).direction)}get _highlightColors(){return M(this,"_highlightColors",this.#S?new Map(this.#S.split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){let{_highlightColors:t}=this;if(!t)return M(this,"highlightColors",null);let e=new Map,i=!!this.#$;for(let[s,r]of t){let t=s.endsWith("_HCM");i&&t?e.set(s.replace("_HCM",""),r):i||t||e.set(s,r)}return M(this,"highlightColors",e)}get highlightColorNames(){return M(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;let e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#u=t}setMainHighlightColorPicker(t){this.#F=t}editAltText(t,e=!1){this.#a?.editAltText(this,t,e)}hasCommentManager(){return!!this.#d}editComment(t,e,i,s){this.#d?.showDialog(this,t,e,i,s)}selectComment(t,e){(this.#r.get(t)?.getEditorByUID(e))?.toggleComment(!0,!0)}updateComment(t){this.#d?.updateComment(t.getData())}updatePopupColor(t){this.#d?.updatePopupColor(t)}removeComment(t){this.#d?.removeComments([t.uid])}deleteComment(t,e){let i=()=>{t.comment=e};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,"comment"),this.toggleComment(null),t.comment=null},undo:i,mustExec:!0})}toggleComment(t,e,i=void 0){this.#d?.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){return t&&this.#d?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#d?.dialogElement||null}async waitForEditorsRendered(t){if(this.#r.has(t-1))return;let{resolve:e,promise:i}=Promise.withResolvers(),s=i=>{i.pageNumber===t&&(this._eventBus._off("editorsrendered",s),e())};this._eventBus.on("editorsrendered",s),await i}getSignature(t){this.#j?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#j}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}){"enableNewAltTextWhenAddingImage"===t&&(this.#A=e)}onPageChanging({pageNumber:t}){this.#p=t-1}deletePage(t){for(let e of this.getEditors(t))e.remove();this.#r.delete(t),this.#p===t&&(this.#p=0)}focusMainContainer(){this.#V.focus()}findParent(t,e){for(let i of this.#r.values()){let{x:s,y:r,width:n,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+n&&e>=r&&e<=r+a)return i}return null}disableUserSelect(t=!1){this.#X.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#y.add(t)}removeShouldRescale(t){this.#y.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*W.PDF_TO_CSS_UNITS;for(let t of this.#y)t.onScaleChanging();this.#u?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#tt({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#et(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let e of this.#r.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t="",e=!1){let i=document.getSelection();if(!i||i.isCollapsed)return;let{anchorNode:s,anchorOffset:r,focusNode:n,focusOffset:a}=i,o=i.toString(),l=this.#tt(i).closest(".textLayer"),h=this.getSelectionBoxes(l);if(!h)return;i.empty();let d=this.#et(l),c=0===this.#O,u=()=>{let i=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:r,focusNode:n,focusOffset:a,text:o});c&&this.showAllEditors("highlight",!0,!0),e&&i?.editComment()};c?this.switchToMode(9,u):u()}commentSelection(t=""){this.highlightSelection(t,!0)}#K(t){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#it(){let t=document.getSelection();if(!t||t.isCollapsed)return;let e=this.#tt(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#M||=new ct(this),this.#M.show(e,i,"ltr"===this.direction))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#o)return null;let e=`${f}${t}`,i=this.#o.getRawValue(e);return i&&this.#o.remove(e),i}addToAnnotationStorage(t){t.isEmpty()||!this.#o||this.#o.has(t.id)||this.#o.setValue(t.id,t)}a11yAlert(t,e=null){let i=this.#q;i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}#st(){let t=document.getSelection();if(!t||t.isCollapsed)return void(this.#L&&(this.#M?.hide(),this.#L=null,this.#rt({hasSelectedText:!1})));let{anchorNode:e}=t;if(e===this.#L)return;let i=this.#tt(t).closest(".textLayer");if(i){if(this.#M?.hide(),this.#L=e,this.#rt({hasSelectedText:!0}),(9===this.#O||0===this.#O)&&(9===this.#O&&this.showAllEditors("highlight",!0,!0),this.#C=this.isShiftKeyDown,!this.isShiftKeyDown)){let t=9===this.#O?this.#et(i):null;if(t?.toggleDrawing(),this.#T){let e=new AbortController,i=this.combinedSignal(e),s=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#nt("main_toolbar"))};window.addEventListener("pointerup",s,{signal:i}),window.addEventListener("blur",s,{signal:i})}else t?.toggleDrawing(!0),this.#nt("main_toolbar")}}else this.#L&&(this.#M?.hide(),this.#L=null,this.#rt({hasSelectedText:!1}))}#nt(t=""){9===this.#O?this.highlightSelection(t):this.#b&&this.#it()}#Z(){document.addEventListener("selectionchange",this.#st.bind(this),{signal:this._signal})}#at(){if(this.#_)return;this.#_=new AbortController;let t=this.combinedSignal(this.#_);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#ot(){this.#_?.abort(),this.#_=null}blur(){if(this.isShiftKeyDown=!1,this.#C&&(this.#C=!1,this.#nt("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#B)if(e.div.contains(t)){this.#I=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#I)return;let[t,e]=this.#I;this.#I=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#Q(){if(this.#D)return;this.#D=new AbortController;let t=this.combinedSignal(this.#D);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#lt(){this.#D?.abort(),this.#D=null}#ht(){if(this.#c)return;this.#c=new AbortController;let t=this.combinedSignal(this.#c);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})}#dt(){this.#c?.abort(),this.#c=null}#J(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Q(),this.setEditingState(!0)}removeEditListeners(){this.#lt(),this.setEditingState(!1)}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let i of this.#m)if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(let e of t.dataTransfer.items)for(let i of this.#m)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let t of this.#B){let i=t.serialize(!0);i&&e.push(i)}0!==e.length&&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 t of e.items)for(let e of this.#m)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){return void _(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();let s=this.currentLayer;try{let t=[];for(let e of i){let i=await s.deserialize(e);if(!i)return;t.push(i)}this.addCommands({cmd:()=>{for(let e of t)this.#ct(e);this.#ut(t)},undo:()=>{for(let e of t)e.remove()},mustExec:!0})}catch(t){_(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),0===this.#O||this.isEditorHandlingKeyboard||vt._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#C&&(this.#C=!1,this.#nt("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu")}}updatePageIndex(t,e){for(let i of this.getEditors(t))i.pageIndex=e;let i=this.#n.get(t);i&&(i.pageIndex=e,this.#r.set(e,i),this.#P?i.enable():i.disable())}startUpdatePages(){this.#n=new Map(this.#r),this.#r.clear()}endUpdatePages(){this.#n=null}clonePage(t,e){for(let i of this.getEditors(t)){let t=i.serialize(9!==i.mode);t&&(t.pageIndex=e,t.id=this.getId(),t.isClone=!0,delete t.popupRef,this.#o.setValue(t.id,t))}}findClonesForPage(t){let e=[],{pageIndex:i}=t;for(let[s,r]of this.#o)r.pageIndex===i&&r.isClone&&(this.#o.remove(s),e.push(t.deserialize(r).then(e=>{e&&(e.isClone=!0,t.addOrRebuild(e))})));return Promise.all(e)}#rt(t){Object.entries(t).some(([t,e])=>this.#G[t]!==e)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#G,t)}),9===this.#O&&!1===t.hasSelectedEditor&&this.#pt([[33,!0]]))}#pt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#at(),this.#ht(),this.#rt({isEditing:0!==this.#O,isEmpty:this.#gt(),hasSomethingToUndo:this.#h.hasSomethingToUndo(),hasSomethingToRedo:this.#h.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ot(),this.#dt(),this.#rt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#m){this.#m=t;for(let t of this.#m)this.#pt(t.defaultPropertiesToUpdate)}}getId(){return this.#k.id}get currentLayer(){return this.#r.get(this.#p)}getLayer(t){return this.#r.get(t)}get currentPageIndex(){return this.#p}addLayer(t){this.#r.set(t.pageIndex,t),this.#P?t.enable():t.disable()}removeLayer(t){this.#r.delete(t.pageIndex)}async updateMode(t,e=null,i=!1,s=!1,r=!1,n=!1){if(this.#O!==t){if(this.#Y&&(await this.#Y.promise,!this.#Y))return;if(this.#Y=Promise.withResolvers(),this.#u?.commitOrRemove(),16===this.#O&&this.#d?.hideSidebar(),this.#d?.destroyPopup(),this.#O=t,0!==t){for(let t of this.#s.values())t.addStandaloneCommentButton();101===t&&await(this.#j?.loadSignatures()),i&&pt.clearPointerType(),this.setEditingState(!0),await this.#ft(),this.unselectAll();for(let e of this.#r.values())e.updateMode(t);if(16===t){this.#i||=await this.#z.getAnnotationsByType(new Set(this.#m.map(t=>t._editorType)));let t=new Set,e=[];for(let i of this.#s.values()){let{annotationElementId:s,hasComment:r,deleted:n}=i;s&&t.add(s),r&&!n&&e.push(i.getData())}for(let i of this.#i){let{id:s,popupRef:r,contentsObj:n}=i;r&&n?.str&&!t.has(s)&&!this.#g.has(s)&&e.push(i)}this.#d?.showSidebar(e)}if(e){for(let t of this.#s.values())t.uid===e?(this.setSelected(t),n?t.editComment():r?t.enterInEditMode():t.focus()):t.unselect();this.#Y.resolve()}else s&&this.addNewEditorFromKeyboard(),this.#Y.resolve()}else{this.setEditingState(!1),this.#mt();for(let t of this.#s.values())t.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#Y.resolve()}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#O&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#m){switch(t){case 2:return void this.currentLayer.addNewEditor(e);case 34:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#U||=new Map).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(let i of this.#B)i.updateParams(t,e);else for(let i of this.#m)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(let i of this.#s.values())i.editorType===t&&i.show(e);(this.#U?.get(34)??!0)!==e&&this.#pt([[34,e]])}enableWaiting(t=!1){if(this.#E!==t){this.#E=t;for(let e of this.#r.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#ft(){if(!this.#P){this.#P=!0;let t=[];for(let e of this.#r.values())t.push(e.enable());await Promise.all(t);for(let t of this.#s.values())t.enable()}}#mt(){if(this.unselectAll(),this.#P){this.#P=!1;for(let t of this.#r.values())t.disable();for(let t of this.#s.values())t.disable()}}*getEditors(t){for(let e of this.#s.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#s.get(t)}addEditor(t){this.#s.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#x&&clearTimeout(this.#x),this.#x=setTimeout(()=>{this.focusMainContainer(),this.#x=null},0)),this.#s.delete(t.id),t.annotationElementId&&this.#R?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#g.has(t.annotationElementId)||this.#o?.remove(t.id)}addDeletedAnnotationElement(t){this.#g.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#g.has(t)}removeDeletedAnnotationElement(t){this.#g.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#ct(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.#pt(t.propertiesToUpdate))}get#yt(){let t=null;for(t of this.#B);return t}updateUI(t){this.#yt===t&&this.#pt(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#pt(t.defaultPropertiesToUpdate)}toggleSelected(t){this.#B.has(t)?(this.#B.delete(t),t.unselect(),this.#rt({hasSelectedEditor:this.hasSelection})):(this.#B.add(t),t.select(),this.#pt(t.propertiesToUpdate),this.#rt({hasSelectedEditor:!0}))}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#u?.commitOrRemove();for(let e of this.#B)e!==t&&e.unselect();this.#d?.destroyPopup(),this.#B.clear(),this.#B.add(t),t.select(),this.#pt(t.propertiesToUpdate),this.#rt({hasSelectedEditor:!0})}isSelected(t){return this.#B.has(t)}get firstSelectedEditor(){return this.#B.values().next().value}unselect(t){t.unselect(),this.#B.delete(t),this.#rt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#B.size}get isEnterHandled(){return 1===this.#B.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#h.undo(),this.#rt({hasSomethingToUndo:this.#h.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#gt()}),this._editorUndoBar?.hide()}redo(){this.#h.redo(),this.#rt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#h.hasSomethingToRedo(),isEmpty:this.#gt()})}addCommands(t){this.#h.add(t),this.#rt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#gt()})}cleanUndoStack(t){this.#h.cleanType(t)}#gt(){if(0===this.#s.size)return!0;if(1===this.#s.size)for(let t of this.#s.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.#B],i=()=>{for(let t of e)this.#ct(t)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,1===e.length?e[0].editorType:e.length);for(let t of e)t.remove()},undo:i,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#ut(t){for(let t of this.#B)t.unselect();this.#B.clear();for(let e of t)e.isEmpty()||(this.#B.add(e),e.select());this.#rt({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#B)t.commit();this.#ut(this.#s.values())}unselectAll(){if((!this.#e||(this.#e.commitOrRemove(),0===this.#O))&&!this.#u?.commitOrRemove()&&(this.#d?.destroyPopup(),this.hasSelection)){for(let t of this.#B)t.unselect();this.#B.clear(),this.#rt({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#W[0]+=t,this.#W[1]+=e;let[s,r]=this.#W,n=[...this.#B];this.#H&&clearTimeout(this.#H),this.#H=setTimeout(()=>{this.#H=null,this.#W[0]=this.#W[1]=0,this.addCommands({cmd:()=>{for(let t of n)this.#s.has(t.id)&&(t.translateInPage(s,r),t.translationDone())},undo:()=>{for(let t of n)this.#s.has(t.id)&&(t.translateInPage(-s,-r),t.translationDone())},mustExec:!1})},1e3);for(let i of n)i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(let t of this.#B)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:i,y:s,pageIndex:r},n]of t)n.newX=i,n.newY=s,n.newPageIndex=r,e||=i!==n.savedX||s!==n.savedY||r!==n.savedPageIndex;if(!e)return!1;let i=(t,e,i,s)=>{if(this.#s.has(t.id)){let r=this.#r.get(s);r?t._setParentAndPosition(r,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(let[e,{newX:s,newY:r,newPageIndex:n}]of t)i(e,s,r,n)},undo:()=>{for(let[e,{savedX:s,savedY:r,savedPageIndex:n}]of t)i(e,s,r,n)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#f)for(let i of this.#f.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){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()||1===this.#B.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#O}isEditingMode(){return 0!==this.#O}get imageManager(){return M(this,"imageManager",new ft)}getSelectionBoxes(t){if(!t)return null;let e=document.getSelection();for(let i=0,s=e.rangeCount;i<s;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;let i,{x:s,y:r,width:n,height:a}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":i=(t,e,i,o)=>({x:(e-r)/a,y:1-(t+i-s)/n,width:o/a,height:i/n});break;case"180":i=(t,e,i,o)=>({x:1-(t+i-s)/n,y:1-(e+o-r)/a,width:i/n,height:o/a});break;case"270":i=(t,e,i,o)=>({x:1-(e+o-r)/a,y:(t-s)/n,width:o/a,height:i/n});break;default:i=(t,e,i,o)=>({x:(t-s)/n,y:(e-r)/a,width:i/n,height:o/a})}let o=[];for(let t=0,s=e.rangeCount;t<s;t++){let s=e.getRangeAt(t);if(!s.collapsed)for(let{x:t,y:e,width:r,height:n}of s.getClientRects())0!==r&&0!==n&&o.push(i(t,e,r,n))}return 0===o.length?null:o}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 i=this.#o.getRawValue(e);i&&(0!==this.#O||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){let s=this.#R?.get(t);s&&(s.setCanvas(e,i),this.#R.delete(t))}addMissingCanvas(t,e){(this.#R||=new Map).set(t,e)}}class At{#t=null;#e=!1;#i=null;#s=null;#r=null;#n=null;#a=!1;#o=null;#l=null;#h=null;#d=null;#c=!1;static#u=null;static _l10n=null;constructor(t){this.#l=t,this.#c=t._uiManager.useNewAltTextFlow,At.#u||=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){At._l10n??=t}async render(){let t=this.#i=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#s=document.createElement("span");t.append(e),this.#c?(t.classList.add("new"),t.setAttribute("data-l10n-id",At.#u.missing),e.setAttribute("data-l10n-id",At.#u["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let i=this.#l._uiManager._signal;t.addEventListener("contextmenu",J,{signal:i}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=t=>{t.preventDefault(),this.#l._uiManager.editAltText(this.#l),this.#c&&this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#p}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#a=!0,s(e))},{signal:i}),await this.#g(),t}get#p(){return(this.#t?"added":null===this.#t&&this.guessedText&&"review")||"missing"}finish(){this.#i&&(this.#i.focus({focusVisible:this.#a}),this.#a=!1)}isEmpty(){return this.#c?null===this.#t:!this.#t&&!this.#e}hasData(){return this.#c?null!==this.#t||!!this.#h:this.isEmpty()}get guessedText(){return this.#h}async setGuessedText(t){null===this.#t&&(this.#h=t,this.#d=await At._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#g())}toggleAltTextBadge(t=!1){if(this.#c&&!this.#t){if(!this.#o){let t=this.#o=document.createElement("div");t.className="noAltTextBadge",this.#l.div.append(t)}this.#o.classList.toggle("hidden",!t)}else this.#o?.remove(),this.#o=null}serialize(t){let e=this.#t;return t||this.#h!==e||(e=this.#d),{altText:e,decorative:this.#e,guessedText:this.#h,textWithDisclaimer:this.#d}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:r=!1}){i&&(this.#h=i,this.#d=s),this.#t===t&&this.#e===e||(r||(this.#t=t,this.#e=e),this.#g())}toggle(t=!1){this.#i&&(!t&&this.#n&&(clearTimeout(this.#n),this.#n=null),this.#i.disabled=!t)}shown(){this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#p}})}destroy(){this.#i?.remove(),this.#i=null,this.#s=null,this.#r=null,this.#o?.remove(),this.#o=null}async#g(){let t=this.#i;if(!t)return;if(this.#c){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",At.#u[this.#p]),this.#s?.setAttribute("data-l10n-id",At.#u[`${this.#p}-label`]),!this.#t)return void this.#r?.remove()}else{if(!this.#t&&!this.#e)return t.classList.remove("done"),void this.#r?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#r;if(!e){this.#r=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#l.id}`;let i=this.#l._uiManager._signal;i.addEventListener("abort",()=>{clearTimeout(this.#n),this.#n=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#n=setTimeout(()=>{this.#n=null,this.#r.classList.add("show"),this.#l._reportTelemetry({action:"alt_text_tooltip"})},100)},{signal:i}),t.addEventListener("mouseleave",()=>{this.#n&&(clearTimeout(this.#n),this.#n=null),this.#r?.classList.remove("show")},{signal:i})}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.#l.getElementForAltText()?.setAttribute("aria-describedby",e.id)}}class wt{#t=null;#e=null;#i=!1;#s=null;#r=null;#n=null;#a=null;#o=null;#l=!1;#h=null;constructor(t){this.#s=t}renderForToolbar(){let t=this.#e=document.createElement("button");return t.className="comment",this.#d(t,!1)}renderForStandalone(){let t=this.#t=document.createElement("button");t.className="annotationCommentButton";let e=this.#s.commentButtonPosition;if(e){let{style:i}=t;i.insetInlineEnd=`calc(${100*("ltr"===this.#s._uiManager.direction?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;let s=this.#s.commentButtonColor;s&&(i.backgroundColor=s)}return this.#d(t,!0)}focusButton(){setTimeout(()=>{(this.#t??this.#e)?.focus()},0)}onUpdatedColor(){if(!this.#t)return;let t=this.#s.commentButtonColor;t&&(this.#t.style.backgroundColor=t),this.#s._uiManager.updatePopupColor(this.#s)}get commentButtonWidth(){return(this.#t?.getBoundingClientRect().width??0)/this.#s.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#h)return this.#h;if(!this.#t)return null;let{x:t,y:e,height:i}=this.#t.getBoundingClientRect(),{x:s,y:r,width:n,height:a}=this.#s.parent.boundingClientRect;return[(t-s)/n,(e+i-r)/a]}set commentPopupPositionInLayer(t){this.#h=t}hasDefaultPopupPosition(){return null===this.#h}removeStandaloneCommentButton(){this.#t?.remove(),this.#t=null}removeToolbarCommentButton(){this.#e?.remove(),this.#e=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#t&&(this.#t.classList.toggle("selected",t),this.#t.ariaExpanded=e)}#d(t,e){if(!this.#s._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[this.#s._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));let i=this.#s._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",J,{signal:i}),e&&(t.addEventListener("focusin",t=>{this.#s._focusEventsAllowed=!1,Q(t)},{capture:!0,signal:i}),t.addEventListener("focusout",t=>{this.#s._focusEventsAllowed=!0,Q(t)},{capture:!0,signal:i})),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=e=>{e.preventDefault(),t===this.#e?this.edit():this.#s.toggleComment(!0)};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#i=!0,s(e))},{signal:i}),t.addEventListener("pointerenter",()=>{this.#s.toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{this.#s.toggleComment(!1,!1)},{signal:i}),t}edit(t){let e,i,s=this.commentPopupPositionInLayer;if(s)[e,i]=s;else{[e,i]=this.#s.commentButtonPosition;let{width:t,height:s,x:r,y:n}=this.#s;e=r+e*t,i=n+i*s}let r=this.#s.parent.boundingClientRect,{x:n,y:a,width:o,height:l}=r;this.#s._uiManager.editComment(this.#s,n+e*o,a+i*l,{...t,parentDimensions:r})}finish(){this.#e&&(this.#e.focus({focusVisible:this.#i}),this.#i=!1)}isDeleted(){return this.#l||""===this.#a}isEmpty(){return null===this.#a}hasBeenEdited(){return this.isDeleted()||this.#a!==this.#r}serialize(){return this.data}get data(){return{text:this.#a,richText:this.#n,date:this.#o,deleted:this.isDeleted()}}set data(t){t!==this.#a&&(this.#n=null),null!==t?(this.#a=t,this.#o=new Date,this.#l=!1):(this.#a="",this.#l=!0)}restoreData({text:t,richText:e,date:i}){this.#a=t,this.#n=e,this.#o=i,this.#l=!1}setInitialText(t,e=null){this.#r=t,this.data=t,this.#o=null,this.#n=e}shown(){}destroy(){this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null,this.#a="",this.#n=null,this.#o=null,this.#s=null,this.#i=!1,this.#l=!1}}class xt{#t;#e=!1;#i=null;#s;#r;#n;#a;#o=null;#l;#h=null;#d;#c=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:r=null,onPinchEnd:n=null,signal:a}){this.#t=t,this.#i=i,this.#s=e,this.#r=s,this.#n=r,this.#a=n,this.#d=new AbortController,this.#l=AbortSignal.any([a,this.#d.signal]),t.addEventListener("touchstart",this.#u.bind(this),{passive:!1,signal:this.#l})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/at.pixelRatio}#u(t){if(this.#s?.())return;if(1===t.touches.length){if(this.#o)return;let t=this.#o=new AbortController,e=AbortSignal.any([this.#l,t.signal]),i=this.#t,s={capture:!0,signal:e,passive:!1},r=t=>{"touch"===t.pointerType&&(this.#o?.abort(),this.#o=null)};return i.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(Q(t),r(t))},s),i.addEventListener("pointerup",r,s),void i.addEventListener("pointercancel",r,s)}if(!this.#c){this.#c=new AbortController;let t=AbortSignal.any([this.#l,this.#c.signal]),e=this.#t,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#p.bind(this),i);let s=this.#g.bind(this);e.addEventListener("touchend",s,i),e.addEventListener("touchcancel",s,i),i.capture=!0,e.addEventListener("pointerdown",Q,i),e.addEventListener("pointermove",Q,i),e.addEventListener("pointercancel",Q,i),e.addEventListener("pointerup",Q,i),this.#r?.()}if(Q(t),2!==t.touches.length||this.#i?.())return void(this.#h=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#h={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#p(t){if(!this.#h||2!==t.touches.length)return;Q(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);let{screenX:s,screenY:r}=e,{screenX:n,screenY:a}=i,o=this.#h,{touch0X:l,touch0Y:h,touch1X:d,touch1Y:c}=o,u=d-l,p=c-h,g=n-s,f=a-r,m=Math.hypot(g,f)||1,y=Math.hypot(u,p)||1;if(!this.#e&&Math.abs(y-m)<=xt.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=s,o.touch0Y=r,o.touch1X=n,o.touch1Y=a,!this.#e)return void(this.#e=!0);let b=[(s+n)/2,(r+a)/2];this.#n?.(b,y,m)}#g(t){t.touches.length>=2||(this.#c&&(this.#c.abort(),this.#c=null,this.#a?.()),this.#h&&(Q(t),this.#h=null,this.#e=!1))}destroy(){this.#d?.abort(),this.#d=null,this.#o?.abort(),this.#o=null}}class _t{#t=null;#e=null;#i=null;#s=null;#r=null;#n=!1;#a=null;#o="";#l=null;#h=null;#d=null;#c=null;#u=null;#p="";#g=!1;#f=null;#m=!1;#y=!1;#b=!1;#v=null;#A=0;#w=0;#x=null;#_=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#S=!1;#C=_t._zIndex++;static _borderLineWidth=-1;static _colorManager=new bt;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=_t.prototype._resizeWithKeyboard,e=vt.TRANSLATE_SMALL,i=vt.TRANSLATE_BIG;return M(this,"_resizerKeyboardManager",new yt([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],_t.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;let{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:r,pageY:n}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[r,n];let[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return M(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new St({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(_t._l10n??=t,_t._l10nAlert??=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"}),_t._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"}),-1!==_t._borderLineWidth)return;let i=getComputedStyle(document.documentElement);_t._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){S("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#S}set _isDraggable(t){this.#S=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}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.#C}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#W(),this.#c?.remove(),this.#c=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#g?this.#g=!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.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){let[r,n]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/r,this.y=(e+s)/n,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone)return void delete this.isClone;let[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}#M([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#M(this.parentDimensions,t,e)}translateInPage(t,e){this.#f||=[this.x,this.y,this.width,this.height],this.#M(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#f||=[this.x,this.y,this.width,this.height];let{div:i,parentDimensions:[s,r]}=this;if(this.x+=t/s,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:a}=this,[o,l]=this.getBaseTranslation();n+=o,a+=l;let{style:h}=i;h.left=`${(100*n).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(n,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#f&&(this.#f[0]!==this.x||this.#f[1]!==this.y)}get _hasBeenResized(){return!!this.#f&&(this.#f[2]!==this.width||this.#f[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:i}=_t,s=i/t,r=i/e;switch(this.rotation){case 90:return[-s,r];case 180:return[s,r];case 270:return[s,-r];default:return[-s,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[i,s]}=this,{x:r,y:n,width:a,height:o}=this;if(a*=i,o*=s,r*=i,n*=s,this._mustFixPosition)switch(t){case 0:r=$(r,0,i-a),n=$(n,0,s-o);break;case 90:r=$(r,0,i-o),n=$(n,a,s);break;case 180:r=$(r,a,i),n=$(n,o,s);break;case 270:r=$(r,o,i),n=$(n,0,s-a)}this.x=r/=i,this.y=n/=s;let[l,h]=this.getBaseTranslation();r+=l,n+=h,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static#k(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return _t.#k(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return _t.#k(t,e,360-this.parentRotation)}#P(t){switch(t){case 90:{let[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{let[t,e]=this.pageDimensions;return[0,t/e,-e/t,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,i]}=this;return[e*t,i*t]}setDims(){let{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#T(){if(this.#l)return;this.#l=document.createElement("div"),this.#l.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let i of t){let t=document.createElement("div");this.#l.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#E.bind(this,i),{signal:e}),t.addEventListener("contextmenu",J,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#l)}#E(t,e){e.preventDefault();let{isMac:i}=N.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#i?.toggle(!1);let s=this._isDraggable;this._isDraggable=!1,this.#h=[e.screenX,e.screenY];let r=new AbortController,n=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#F.bind(this,t),{passive:!0,capture:!0,signal:n}),window.addEventListener("touchmove",Q,{passive:!1,signal:n}),window.addEventListener("contextmenu",J,{signal:n}),this.#d={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let l=()=>{r.abort(),this.parent.togglePointerEvents(!0),this.#i?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#I()};window.addEventListener("pointerup",l,{signal:n}),window.addEventListener("blur",l,{signal:n})}#D(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#I(){if(!this.#d)return;let{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#d;this.#d=null;let r=this.x,n=this.y,a=this.width,o=this.height;r===t&&n===e&&a===i&&o===s||this.addCommands({cmd:this.#D.bind(this,r,n,a,o),undo:this.#D.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#F(t,e){let i,s,[r,n]=this.parentDimensions,a=this.x,o=this.y,l=this.width,h=this.height,d=_t.MIN_SIZE/r,c=_t.MIN_SIZE/n,u=this.#P(this.rotation),p=(t,e)=>[u[0]*t+u[2]*e,u[1]*t+u[3]*e],g=this.#P(360-this.rotation),f=!1,m=!1;switch(t){case"topLeft":f=!0,i=(t,e)=>[0,0],s=(t,e)=>[t,e];break;case"topMiddle":i=(t,e)=>[t/2,0],s=(t,e)=>[t/2,e];break;case"topRight":f=!0,i=(t,e)=>[t,0],s=(t,e)=>[0,e];break;case"middleRight":m=!0,i=(t,e)=>[t,e/2],s=(t,e)=>[0,e/2];break;case"bottomRight":f=!0,i=(t,e)=>[t,e],s=(t,e)=>[0,0];break;case"bottomMiddle":i=(t,e)=>[t/2,e],s=(t,e)=>[t/2,0];break;case"bottomLeft":f=!0,i=(t,e)=>[0,e],s=(t,e)=>[t,0];break;case"middleLeft":m=!0,i=(t,e)=>[0,e/2],s=(t,e)=>[t,e/2]}let y,b,v=i(l,h),A=s(l,h),w=p(...A),x=_t._round(a+w[0]),_=_t._round(o+w[1]),S=1,C=1;if(e.fromKeyboard)({deltaX:y,deltaY:b}=e);else{let{screenX:t,screenY:i}=e,[s,r]=this.#h;[y,b]=this.screenToPageTranslation(t-s,i-r),this.#h[0]=t,this.#h[1]=i}var M,k;if([y,b]=(M=y/r,k=b/n,[g[0]*M+g[2]*k,g[1]*M+g[3]*k]),f){let t=Math.hypot(l,h);S=C=Math.max(Math.min(Math.hypot(A[0]-v[0]-y,A[1]-v[1]-b)/t,1/l,1/h),d/l,c/h)}else m?S=$(Math.abs(A[0]-v[0]-y),d,1)/l:C=$(Math.abs(A[1]-v[1]-b),c,1)/h;let P=_t._round(l*S),T=_t._round(h*C);w=p(...s(P,T));let E=x-w[0],D=_-w[1];this.#f||=[this.x,this.y,this.width,this.height],this.width=P,this.height=T,this.x=E,this.y=D,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#i?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#y)return this._editToolbar;this._editToolbar=new dt(this),this.div.append(this._editToolbar.render());let{toolbarButtons:t}=this;if(t)for(let[e,i]of t)await this._editToolbar.addButton(e,i);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#i?.destroy()}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#i||(At.initialize(_t._l10n),this.#i=new At(this),this.#t&&(this.#i.data=this.#t,this.#t=null)),this.#i}get altTextData(){return this.#i?.data}set altTextData(t){this.#i&&(this.#i.data=t)}get guessedAltText(){return this.#i?.guessedText}async setGuessedAltText(t){await(this.#i?.setGuessedText(t))}serializeAltText(t){return this.#i?.serialize(t)}hasAltText(){return!!this.#i&&!this.#i.isEmpty()}hasAltTextData(){return this.#i?.hasData()??!1}focusCommentButton(){this.#s?.focusButton()}addCommentButton(){return this.canAddComment?this.#s||=new wt(this):null}addStandaloneCommentButton(){this._uiManager.hasCommentManager()&&(this.#r?this._uiManager.isEditingMode()&&this.#r.classList.remove("hidden"):this.hasComment&&(this.#r=this.#s.renderForStandalone(),this.div.append(this.#r)))}removeStandaloneCommentButton(){this.#s.removeStandaloneCommentButton(),this.#r=null}hideStandaloneCommentButton(){this.#r?.classList.add("hidden")}get comment(){if(!this.#s)return null;let{data:{richText:t,text:e,date:i,deleted:s}}=this.#s;return{text:e,richText:t,date:i,deleted:s,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#s||=new wt(this),"object"==typeof t&&t?this.#s.restoreData(t):this.#s.data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:i}){if(!e)return;if(this.#s||=new wt(this),this.#s.setInitialText(t,i),!this.annotationElementId)return;let s=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);s&&this.updateFromAnnotationLayer(s)}get hasEditedComment(){return this.#s?.hasBeenEdited()}get hasDeletedComment(){return this.#s?.isDeleted()}get hasComment(){return!!this.#s&&!this.#s.isEmpty()&&!this.#s.isDeleted()}async editComment(t){this.#s||=new wt(this),this.#s.edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#s.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){let[,,,e]=t.rect,[i]=this.pageDimensions,[s]=this.pageTranslation,r=s+i+1,n=e-100,a=r+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[r,n,a,e]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#s.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#n?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#j();let[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);let[s,r]=this.getInitialTranslation();return this.translate(s,r),ut(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#_||=new xt({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#R.bind(this),onPinching:this.#N.bind(this),onPinchEnd:this.#O.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#R(){this.#d={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#i?.toggle(!1),this.parent.togglePointerEvents(!1)}#N(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;let r=this.#P(this.rotation),n=(t,e)=>[r[0]*t+r[2]*e,r[1]*t+r[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height,u=_t.MIN_SIZE/a,p=_t.MIN_SIZE/o;s=Math.max(Math.min(s,1/d,1/c),u/d,p/c);let g=_t._round(d*s),f=_t._round(c*s);if(g===d&&f===c)return;this.#f||=[l,h,d,c];let m=n(d/2,c/2),y=_t._round(l+m[0]),b=_t._round(h+m[1]),v=n(g/2,f/2);this.x=y-v[0],this.y=b-v[1],this.width=g,this.height=f,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#O(){this.#i?.toggle(!0),this.parent.togglePointerEvents(!0),this.#I()}pointerdown(t){let{isMac:e}=N.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#g=!0,this._isDraggable?this.#L(t):this.#B(t))}#B(t){let{isMac:e}=N.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#L(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1,s=new AbortController,r=this._uiManager.combinedSignal(s),n={capture:!0,passive:!1,signal:r},a=t=>{s.abort(),this.#a=null,this.#g=!1,this._uiManager.endDragSession()||this.#B(t),i&&this._onStopDragging()};e&&(this.#A=t.clientX,this.#w=t.clientY,this.#a=t.pointerId,this.#o=t.pointerType,window.addEventListener("pointermove",t=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:e,clientY:s,pointerId:r}=t;if(r!==this.#a)return void Q(t);let[n,a]=this.screenToPageTranslation(e-this.#A,s-this.#w);this.#A=e,this.#w=s,this._uiManager.dragSelectedEditors(n,a)},n),window.addEventListener("touchmove",Q,n),window.addEventListener("pointerdown",t=>{t.pointerType===this.#o&&(this.#_||t.isPrimary)&&a(t),Q(t)},n));let o=t=>{this.#a&&this.#a!==t.pointerId?Q(t):a(t)};window.addEventListener("pointerup",o,{signal:r}),window.addEventListener("blur",o,{signal:r})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#v&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){let s=this.parentScale,[r,n]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*r,c=this.y*n,u=this.width*r,p=this.height*n;switch(i){case 0:return[d+l+a,n-c-h-p+o,d+l+u+a,n-c-h+o];case 90:return[d+h+a,n-c+l+o,d+h+p+a,n-c+l+u+o];case 180:return[d-l-u+a,n-c+h+o,d-l+a,n-c+h+p+o];case 270:return[d-h-p+a,n-c-l-u+o,d-h+a,n-c-l+o];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[i,s,r,n]=t,a=r-i,o=n-s;switch(this.rotation){case 0:return[i,e-n,a,o];case 90:return[i,e-s,o,a];case 180:return[r,e-s,a,o];case 270:return[r,e-n,o,a];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&_t._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#s?.onUpdatedColor()}getData(){let{comment:{text:t,color:e,date:i,opacity:s,deleted:r,richText:n},uid:a,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:n,contentsObj:{str:t},creationDate:l,modificationDate:i||h,popupRef:!r,color:e,opacity:s}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#y=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#y=!1,!0)}isInEditMode(){return this.#y}shouldGetKeyboardEvents(){return this.#b}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:r,innerWidth:n}=window;return e<n&&s>0&&t<r&&i>0}#j(){if(this.#u||!this.div)return;this.#u=new AbortController;let t=this._uiManager.combinedSignal(this.#u);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#j()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,i){let s=new this.prototype.constructor({parent:e,id:i.getId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});s.rotation=t.rotation,s.#t=t.accessibilityData,s._isCopy=t.isCopy||!1;let[r,n]=s.pageDimensions,[a,o,l,h]=s.getRectInCurrentCoords(t.rect,n);return s.x=a/r,s.y=o/n,s.width=l/r,s.height=h/n,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#u?.abort(),this.#u=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#v&&(clearTimeout(this.#v),this.#v=null),this.#W(),this.removeEditToolbar(),this.#x){for(let t of this.#x.values())clearTimeout(t);this.#x=null}this.parent=null,this.#_?.destroy(),this.#_=null,this.#c?.remove(),this.#c=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#T(),this.#l.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,e]}=this,[i,s,r,n]=this.getPDFRect();return[_t._round(i+(r-i)*t),_t._round(s+(n-s)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#s.commentPopupPositionInLayer}set commentPopupPosition(t){this.#s.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#s.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#s.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#s?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#d={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#l.children;if(!this.#e){this.#e=Array.from(e);let t=this.#$.bind(this),i=this.#U.bind(this),s=this._uiManager._signal;for(let e of this.#e){let r=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#z.bind(this,r),{signal:s}),e.setAttribute("data-l10n-id",_t._l10nResizer[r])}}let i=this.#e[0],s=0;for(let t of e){if(t===i)break;s++}let r=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(r!==s){if(r<s)for(let t=0;t<s-r;t++)this.#l.append(this.#l.firstElementChild);else if(r>s)for(let t=0;t<r-s;t++)this.#l.firstElementChild.before(this.#l.lastElementChild);let t=0;for(let i of e){let e=this.#e[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",_t._l10nResizer[e])}}this.#G(0),this.#b=!0,this.#l.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#$(t){_t._resizerKeyboardManager.exec(this,t)}#U(t){this.#b&&t.relatedTarget?.parentNode!==this.#l&&this.#W()}#z(t){this.#p=this.#b?t:""}#G(t){if(this.#e)for(let e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#b&&this.#F(this.#p,{deltaX:t,deltaY:e,fromKeyboard:!0})}#W(){this.#b=!1,this.#G(-1),this.#I()}_stopResizingWithKeyboard(){this.#W(),this.div.focus()}select(){this.isSelected&&this._editToolbar?this._editToolbar.show():(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#i?.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()}))}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#l?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#i?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#m}set isEditing(t){this.#m=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#x||=new Map;let{action:e}=t,i=this.#x.get(e);return i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#x.delete(e),0===this.#x.size&&(this.#x=null)},_t._telemetryTimeout),void this.#x.set(e,i)}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.#n=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#n=!0}updateFakeAnnotationElement(t){this.#c||this.deleted?this.deleted?(this.#c.remove(),this.#c=null):(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#c.updateEdited({rect:this.getPDFRect(),popup:this.comment}):this.#c=t.addFakeAnnotation(this)}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){let t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){let{firstElementChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class St extends _t{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Ct=3285377520,Mt=4294901760,kt=65535;class Pt{constructor(t){this.h1=t?0|t:Ct,this.h2=t?0|t:Ct}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,r=t.length;s<r;s++){let r=t.charCodeAt(s);r<=255?e[i++]=r:(e[i++]=r>>>8,e[i++]=255&r)}}else{if(!ArrayBuffer.isView(t))throw Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}let s=i>>2,r=i-4*s,n=new Uint32Array(e.buffer,0,s),a=0,o=0,l=this.h1,h=this.h2,d=3432918353,c=461845907,u=11601,p=13715;for(let t=0;t<s;t++)1&t?(a=n[t],a=a*d&Mt|a*u&kt,a=a<<15|a>>>17,a=a*c&Mt|a*p&kt,l^=a,l=l<<13|l>>>19,l=5*l+3864292196):(o=n[t],o=o*d&Mt|o*u&kt,o=o<<15|o>>>17,o=o*c&Mt|o*p&kt,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(a=0,r){case 3:a^=e[4*s+2]<<16;case 2:a^=e[4*s+1]<<8;case 1:a^=e[4*s],a=a*d&Mt|a*u&kt,a=a<<15|a>>>17,a=a*c&Mt|a*p&kt,1&s?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&Mt|36045*t&kt,e=4283543511*e&Mt|(2950163797*(e<<16|t>>>16)&Mt)>>>16,t^=e>>>1,t=444984403*t&Mt|60499*t&kt,e=3301882366*e&Mt|(3120437893*(e<<16|t>>>16)&Mt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Tt=Object.freeze({map:null,hash:"",transfer:void 0});class Et{#t=!1;#e=null;#i=null;#s=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){let i=this.#s.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#s.get(t)}remove(t){let e=this.#s.get(t);void 0!==e&&(e instanceof _t&&this.#i.delete(e.annotationElementId),this.#s.delete(t),0===this.#s.size&&this.resetModified(),this.#s.values().some(t=>t instanceof _t)||this.onAnnotationEditor?.(null))}setValue(t,e){let i=this.#s.get(t),s=!1;if(void 0!==i)for(let[t,r]of Object.entries(e))i[t]!==r&&(s=!0,i[t]=r);else s=!0,this.#s.set(t,e);s&&this.#r(),e instanceof _t&&((this.#i||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type))}has(t){return this.#s.has(t)}get size(){return this.#s.size}#r(){this.#t||(this.#t=!0,this.onSetModified?.())}resetModified(){this.#t&&(this.#t=!1,this.onResetModified?.())}get print(){return new Dt(this)}get serializable(){if(0===this.#s.size)return Tt;let t=new Map,e=new Pt,i=[],s=Object.create(null),r=!1;for(let[i,n]of this.#s){let a=n instanceof _t?n.serialize(!1,s):n;n.page&&(n.pageIndex=n.page._pageIndex,delete n.page),a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),r||=!!a.bitmap)}if(r)for(let e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:Tt}get editorStats(){let t=null,e=new Map,i=0,s=0;for(let r of this.#s.values()){if(!(r instanceof _t)){r.popup&&(r.popup.deleted?s+=1:i+=1);continue}r.isCommentDeleted?s+=1:r.hasEditedComment&&(i+=1);let n=r.telemetryFinalData;if(!n)continue;let{type:a}=n;e.has(a)||e.set(a,Object.getPrototypeOf(r).constructor),t||=Object.create(null);let o=t[a]||=new Map;for(let[t,e]of Object.entries(n)){if("type"===t)continue;let i=o.getOrInsertComputed(t,L);i.set(e,(i.get(e)??0)+1)}}if((s>0||i>0)&&(t||=Object.create(null),t.comments={deleted:s,edited:i}),!t)return null;for(let[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#e=null}updateEditor(t,e){let i=this.#i?.get(t);return!!i&&(i.updateFromAnnotationLayer(e),!0)}getEditor(t){return this.#i?.get(t)||null}get modifiedIds(){if(this.#e)return this.#e;let t=[];if(this.#i)for(let e of this.#i.values())e.serialize()&&t.push(e.annotationElementId);let e="";if(t.length){let i=new Pt;i.update(t.join(",")),e=i.hexdigest()}return this.#e={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#s.entries()}}class Dt extends Et{#t=Tt;constructor(t){super();let{serializable:e}=t;if(e===Tt)return;let{map:i,hash:s,transfer:r}=e,n=structuredClone(i,r?{transfer:r}:null);this.#t={map:n,hash:s,transfer:[]}}get print(){S("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return M(this,"modifiedIds",{ids:new Set,hash:""})}}const It="__forcedDependency",{floor:Ft,ceil:Rt}=Math;function Nt(t,e,i,s,r,n){t[4*e+0]=Math.min(t[4*e+0],i),t[4*e+1]=Math.min(t[4*e+1],s),t[4*e+2]=Math.max(t[4*e+2],r),t[4*e+3]=Math.max(t[4*e+3],n)}const Ot=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class Bt{#t;#e;constructor(t,e){this.#t=t,this.#e=e}get length(){return this.#t.length}isEmpty(t){return this.#t[t]===Ot}minX(t){return this.#e[4*t+0]/256}minY(t){return this.#e[4*t+1]/256}maxX(t){return(this.#e[4*t+2]+1)/256}maxY(t){return(this.#e[4*t+3]+1)/256}}const Lt=(t,e)=>t?.getOrInsertComputed(e,()=>({dependencies:new Set,isRenderingOperation:!1}));class jt{#t=[[1,0,0,1,0,0]];#e=[-1/0,-1/0,1/0,1/0];#i=new Float64Array(d);_pendingBBoxIdx=-1;#s;#r;#n;#a;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#s=t.width,this.#r=t.height,this.#o(e)}growOperationsCount(t){t>=this.#a.length&&this.#o(t,this.#a)}#o(t,e){let i=new ArrayBuffer(4*t);this.#n=new Uint8ClampedArray(i),this.#a=new Uint32Array(i),e&&e.length>0?(this.#a.set(e),this.#a.fill(Ot,e.length)):this.#a.fill(Ot)}get clipBox(){return this.#e}save(t){return this.#e={__proto__:this.#e},this._savesStack.push(t),this}restore(t,e){let i=Object.getPrototypeOf(this.#e);if(null===i)return this;this.#e=i;let s=this._savesStack.pop();return void 0!==s&&(e?.(s,t),this.#a[t]=this.#a[s]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return 0===this._savesStack.length?null:this._savesStack.at(-1)}recordCloseMarker(t,e){let i=this._savesStack.pop();return void 0!==i&&(e?.(i,t),this.#a[t]=this.#a[i]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){let i=this._markedContentStack.pop();return void 0!==i&&(e?.(i,t),this.#a[t]=this.#a[i]),this}pushBaseTransform(t){return this.#t.push(O.multiplyByDOMMatrix(this.#t.at(-1),t.getTransform())),this}popBaseTransform(){return this.#t.length>1&&this.#t.pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,this.#i.set(d,0)),this}recordClipBox(t,e,i,s,r,n){let a=O.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform()),o=d.slice();O.axialAlignedBoundingBox([i,r,s,n],a,o);let l=O.intersect(this.#e,o);return l?(this.#e[0]=l[0],this.#e[1]=l[1],this.#e[2]=l[2],this.#e[3]=l[3]):(this.#e[0]=this.#e[1]=1/0,this.#e[2]=this.#e[3]=-1/0),this}recordBBox(t,e,i,s,r,n){let a=this.#e;if(a[0]===1/0)return this;let o=O.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform());if(a[0]===-1/0)return O.axialAlignedBoundingBox([i,r,s,n],o,this.#i),this;let l=d.slice();return O.axialAlignedBoundingBox([i,r,s,n],o,l),this.#i[0]=$(l[0],a[0],this.#i[0]),this.#i[1]=$(l[1],a[1],this.#i[1]),this.#i[2]=$(l[2],this.#i[2],a[2]),this.#i[3]=$(l[3],this.#i[3],a[3]),this}recordFullPageBBox(t){return this.#i[0]=Math.max(0,this.#e[0]),this.#i[1]=Math.max(0,this.#e[1]),this.#i[2]=Math.min(this.#s,this.#e[2]),this.#i[3]=Math.min(this.#r,this.#e[3]),this}recordOperation(t,e=!1,i){if(this._pendingBBoxIdx!==t)return this;let s=Ft(256*this.#i[0]/this.#s),r=Ft(256*this.#i[1]/this.#r),n=Rt(256*this.#i[2]/this.#s),a=Rt(256*this.#i[3]/this.#r);if(Nt(this.#n,t,s,r,n,a),i)for(let e of i)for(let i of e)i!==t&&Nt(this.#n,i,s,r,n,a);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,this.#e[0]=Math.max(this.#e[0],this.#i[0]),this.#e[1]=Math.max(this.#e[1],this.#i[1]),this.#e[2]=Math.min(this.#e[2],this.#i[2]),this.#e[3]=Math.min(this.#e[3],this.#i[3])),this}take(){return new Bt(this.#a,this.#n)}takeDebugMetadata(){throw Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,i,s=1,r=0,n=0,a){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}class $t{#t={__proto__:null};#e={__proto__:null,transform:[],moveText:[],sameLineText:[],[It]:[]};#i=new Map;#s=new Set;#r=new Map;#n;#a;#o;constructor(t,e=!1){this.#o=t,e&&(this.#n=new Map,this.#a=(t,e)=>{Lt(this.#n,e).dependencies.add(t)})}get clipBox(){return this.#o.clipBox}growOperationsCount(t){this.#o.growOperationsCount(t)}save(t){return this.#t={__proto__:this.#t},this.#e={__proto__:this.#e,transform:{__proto__:this.#e.transform},moveText:{__proto__:this.#e.moveText},sameLineText:{__proto__:this.#e.sameLineText},[It]:{__proto__:this.#e[It]}},this.#o.save(t),this}restore(t){this.#o.restore(t,this.#a);let e=Object.getPrototypeOf(this.#t);return null===e||(this.#t=e,this.#e=Object.getPrototypeOf(this.#e)),this}recordOpenMarker(t){return this.#o.recordOpenMarker(t,this.#a),this}getOpenMarker(){return this.#o.getOpenMarker()}recordCloseMarker(t){return this.#o.recordCloseMarker(t,this.#a),this}beginMarkedContent(t){return this.#o.beginMarkedContent(t),this}endMarkedContent(t){return this.#o.endMarkedContent(t,this.#a),this}pushBaseTransform(t){return this.#o.pushBaseTransform(t),this}popBaseTransform(){return this.#o.popBaseTransform(),this}recordSimpleData(t,e){return this.#t[t]=e,this}recordIncrementalData(t,e){return this.#e[t].push(e),this}resetIncrementalData(t,e){return this.#e[t].length=0,this}recordNamedData(t,e){return this.#i.set(t,e),this}recordSimpleDataFromNamed(t,e,i){this.#t[t]=this.#i.get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(It,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(let e of t)e in this.#t&&this.recordFutureForcedDependency(e,this.#t[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let t of this.#s)this.recordFutureForcedDependency(It,t);return this}resetBBox(t){return this.#o.resetBBox(t),this}recordClipBox(t,e,i,s,r,n){return this.#o.recordClipBox(t,e,i,s,r,n),this}recordBBox(t,e,i,s,r,n){return this.#o.recordBBox(t,e,i,s,r,n),this}recordCharacterBBox(t,e,i,s=1,r=0,n=0,a){let o,l,h=i.bbox;if(h&&(o=h[2]!==h[0]&&h[3]!==h[1]&&this.#r.get(i),!1!==o&&(l=[0,0,0,0],O.axialAlignedBoundingBox(h,i.fontMatrix,l),1===s&&0===r&&0===n||O.scaleMinMax([s,0,0,-s,r,n],l),o)))return this.recordBBox(t,e,l[0],l[2],l[1],l[3]);if(!a)return this.recordFullPageBBox(t);let d=a();return h&&l&&void 0===o&&(o=l[0]<=r-d.actualBoundingBoxLeft&&l[2]>=r+d.actualBoundingBoxRight&&l[1]<=n-d.actualBoundingBoxAscent&&l[3]>=n+d.actualBoundingBoxDescent,this.#r.set(i,o),o)?this.recordBBox(t,e,l[0],l[2],l[1],l[3]):this.recordBBox(t,e,r-d.actualBoundingBoxLeft,r+d.actualBoundingBoxRight,n-d.actualBoundingBoxAscent,n+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#o.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#t[t]}recordDependencies(t,e){let i=this.#s,s=this.#t,r=this.#e;for(let t of e)t in this.#t?i.add(s[t]):t in r&&r[t].forEach(i.add,i);return this}recordNamedDependency(t,e){return this.#i.has(e)&&this.#s.add(this.#i.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[It]),this.#n){let e=Lt(this.#n,t),{dependencies:i}=e;this.#s.forEach(i.add,i),this.#o._savesStack.forEach(i.add,i),this.#o._markedContentStack.forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}let i=!e&&t===this.#o._pendingBBoxIdx;return this.#o.recordOperation(t,e,[this.#s,this.#o._savesStack,this.#o._markedContentStack]),i&&this.#s.clear(),this}recordShowTextOperation(t,e=!1){let i=Array.from(this.#s);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(let t of i)this.recordIncrementalData("sameLineText",t);return this}bboxToClipBoxDropOperation(t,e=!1){let i=!e&&t===this.#o._pendingBBoxIdx;return this.#o.bboxToClipBoxDropOperation(t),i&&this.#s.clear(),this}take(){return this.#r.clear(),this.#o.take()}takeDebugMetadata(){return this.#n}}class Ut{#t;#e;#i;#s=0;#r=0;constructor(t,e,i){if(t instanceof Ut&&t.#i===!!i)return t;this.#t=t,this.#e=e,this.#i=!!i}get clipBox(){return this.#t.clipBox}growOperationsCount(){throw Error("Unreachable")}save(t){return this.#r++,this.#t.save(this.#e),this}restore(t){return this.#r>0&&(this.#t.restore(this.#e),this.#r--),this}recordOpenMarker(t){return this.#s++,this}getOpenMarker(){return this.#s>0?this.#e:this.#t.getOpenMarker()}recordCloseMarker(t){return this.#s--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#t.pushBaseTransform(t),this}popBaseTransform(){return this.#t.popBaseTransform(),this}recordSimpleData(t,e){return this.#t.recordSimpleData(t,this.#e),this}recordIncrementalData(t,e){return this.#t.recordIncrementalData(t,this.#e),this}resetIncrementalData(t,e){return this.#t.resetIncrementalData(t,this.#e),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this.#t.recordSimpleDataFromNamed(t,e,this.#e),this}recordFutureForcedDependency(t,e){return this.#t.recordFutureForcedDependency(t,this.#e),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#t.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#t.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#i||this.#t.resetBBox(this.#e),this}recordClipBox(t,e,i,s,r,n){return this.#i||this.#t.recordClipBox(this.#e,e,i,s,r,n),this}recordBBox(t,e,i,s,r,n){return this.#i||this.#t.recordBBox(this.#e,e,i,s,r,n),this}recordCharacterBBox(t,e,i,s,r,n,a){return this.#i||this.#t.recordCharacterBBox(this.#e,e,i,s,r,n,a),this}recordFullPageBBox(t){return this.#i||this.#t.recordFullPageBBox(this.#e),this}getSimpleIndex(t){return this.#t.getSimpleIndex(t)}recordDependencies(t,e){return this.#t.recordDependencies(this.#e,e),this}recordNamedDependency(t,e){return this.#t.recordNamedDependency(this.#e,e),this}recordOperation(t){return this.#t.recordOperation(this.#e,!0),this}recordShowTextOperation(t){return this.#t.recordShowTextOperation(this.#e,!0),this}bboxToClipBoxDropOperation(t){return this.#i||this.#t.bboxToClipBoxDropOperation(this.#e,!0),this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}const zt=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],Gt=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],Wt=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],Ht=["filter","fillColor","fillAlpha"],Vt=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],Xt=["transform"],qt=["transform","fillColor"];class Yt{#t;#e;#i=4;#s=0;#r=new Yt.#n(6*this.#i);static#n=N.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#t=t.width,this.#e=t.height}record(t,e,i,s){if(this.#s===this.#i){this.#i*=2;let t=new Yt.#n(6*this.#i);t.set(this.#r),this.#r=t}let r,n=O.domMatrixToTransform(t.getTransform());if(s[0]!==1/0){let t=d.slice();O.axialAlignedBoundingBox([0,-i,e,0],n,t);let a=O.intersect(s,t);if(!a)return;let[o,l,h,c]=a;if(o!==t[0]||l!==t[1]||h!==t[2]||c!==t[3]){let t=Math.atan2(n[1],n[0]),e=Math.abs(Math.sin(t)),i=Math.abs(Math.cos(t));if(e<1e-6||i<1e-6||Math.abs(e-i)<1e-6)r=[o,l,o,c,h,l];else{let t=h-o,s=c-l,n=e*e,a=i*i,d=i*e,u=a-n,p=(s*a-t*d)/u;r=[o+(s*d-t*n)/u,l,o,l+p,h,c-p]}}}r||(r=[0,-i,0,0,e,-i],O.applyTransform(r,n,0),O.applyTransform(r,n,2),O.applyTransform(r,n,4)),r[0]/=this.#t,r[1]/=this.#e,r[2]/=this.#t,r[3]/=this.#e,r[4]/=this.#t,r[5]/=this.#e,this.#r.set(r,6*this.#s),this.#s++}take(){return this.#r.subarray(0,6*this.#s)}}class Kt{#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,disableFontFace:e,_inspectFont:i}){if(t&&!this.#t.has(t.loadedName)){if(C(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:e,src:s,style:r}=t,n=new FontFace(e,s,r);this.addNativeFontFace(n);try{await n.load(),this.#t.add(e),i?.(t)}catch{_(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(n)}return}S("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)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){let e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw _(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{let i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){return M(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return M(this,"isSyncFontLoadingSupported",h||N.platform.isFirefox)}_queueLoadingCallback(t){let{loadingRequests:e}=this,i={done:!1,complete:function(){for(C(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;){let t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(i),i}get _loadTestFont(){return M(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function s(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let r,n,a=this._document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d"),l=0,h=`lt${Date.now()}${this.loadTestFontId++}`,d=this._loadTestFont;d=s(d,976,h.length,h);let c=1482184792,u=i(d,16);for(r=0,n=h.length-3;r<n;r+=4)u=u-c+i(h,r)|0;r<h.length&&(u=u-c+i(h+"XXX",r)|0),d=s(d,16,4,function(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}(u));let p=`@font-face {font-family:"${h}";src:url(data:font/opentype;base64,${btoa(d)});}`;this.insertRule(p);let g=this._document.createElement("div");g.style.visibility="hidden",g.style.width=g.style.height="10px",g.style.position="absolute",g.style.top=g.style.left="0px";for(let e of[t.loadedName,h]){let t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,g.append(t)}this._document.body.append(g),function t(e,i){if(++l>30)return _("Load test font never loaded."),void i();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(h,()=>{g.remove(),e.complete()})}}class Zt{compiledGlyphs=Object.create(null);#t;constructor(t,e=null,i,s){this.#t=t,this._inspectFont=e,i&&(this.charProcOperatorList=i),s&&Object.assign(this,s)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){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)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let t,e=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),t}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let i,s=this.loadedName+"_path_"+e;try{i=t.get(s)}catch(t){_(`getPathGenerator - ignoring character: "${t}".`)}let r=ht(i?.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return this.#t.black}get bold(){return this.#t.bold}get disableFontFace(){return this.#t.disableFontFace}set disableFontFace(t){M(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#t.fontExtraProperties}get isInvalidPDFjsFont(){return this.#t.isInvalidPDFjsFont}get isType3Font(){return this.#t.isType3Font}get italic(){return this.#t.italic}get missingFile(){return this.#t.missingFile}get remeasure(){return this.#t.remeasure}get vertical(){return this.#t.vertical}get ascent(){return this.#t.ascent}get defaultWidth(){return this.#t.defaultWidth}get descent(){return this.#t.descent}get bbox(){return this.#t.bbox}get fontMatrix(){return this.#t.fontMatrix}get fallbackName(){return this.#t.fallbackName}get loadedName(){return this.#t.loadedName}get mimetype(){return this.#t.mimetype}get name(){return this.#t.name}get data(){return this.#t.data}clearData(){this.#t.clearData()}get cssFontInfo(){return this.#t.cssFontInfo}get systemFontInfo(){return this.#t.systemFontInfo}get defaultVMetrics(){return this.#t.defaultVMetrics}}class Jt{static strings=["fontFamily","fontWeight","italicAngle"]}class Qt{static strings=["css","loadedName","baseFontName","src"]}class te{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(2*this.bools.length/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+8*this.numbers.length;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class ee{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class ie{#t;#e=new TextDecoder;#i;constructor(t){this.#t=t,this.#i=new DataView(t)}#s(t){C(t<Jt.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=this.#i.getUint32(e)+4;let i=this.#i.getUint32(e);return this.#e.decode(new Uint8Array(this.#t,e+4,i))}get fontFamily(){return this.#s(0)}get fontWeight(){return this.#s(1)}get italicAngle(){return this.#s(2)}}class se{#t;#e=new TextDecoder;#i;constructor(t){this.#t=t,this.#i=new DataView(t)}get guessFallback(){return 0!==this.#i.getUint8(0)}#s(t){C(t<Qt.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=this.#i.getUint32(e)+4;let i=this.#i.getUint32(e);return this.#e.decode(new Uint8Array(this.#t,e+4,i))}get css(){return this.#s(0)}get loadedName(){return this.#s(1)}get baseFontName(){return this.#s(2)}get src(){return this.#s(3)}get style(){let t=1;t+=4+this.#i.getUint32(t);let e=this.#i.getUint32(t),i=this.#e.decode(new Uint8Array(this.#t,t+4,e));t+=4+e;let s=this.#i.getUint32(t);return{style:i,weight:this.#e.decode(new Uint8Array(this.#t,t+4,s))}}}class re{#t;#e=new TextDecoder;#i;constructor({buffer:t,extra:e}){this.#t=t,this.#i=new DataView(t),e&&Object.assign(this,e)}#s(t){C(t<te.bools.length,"Invalid boolean index");let e=Math.floor(t/4),i=2*t%8,s=this.#i.getUint8(e)>>i&3;return 0===s?void 0:2===s}get black(){return this.#s(0)}get bold(){return this.#s(1)}get disableFontFace(){return this.#s(2)}get fontExtraProperties(){return this.#s(3)}get isInvalidPDFjsFont(){return this.#s(4)}get isType3Font(){return this.#s(5)}get italic(){return this.#s(6)}get missingFile(){return this.#s(7)}get remeasure(){return this.#s(8)}get vertical(){return this.#s(9)}#r(t){return C(t<te.numbers.length,"Invalid number index"),this.#i.getFloat64(te.OFFSET_NUMBERS+8*t)}get ascent(){return this.#r(0)}get defaultWidth(){return this.#r(1)}get descent(){return this.#r(2)}#n(t,e,i,s){let r=this.#i.getUint8(t);if(0===r)return;C(r===e,"Invalid array length."),t+=1;let n=Array(r);for(let e=0;e<r;e++)n[e]=this.#i[i](t,!0),t+=s;return n}get bbox(){return this.#n(te.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#n(te.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#n(te.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#a(t){C(t<te.strings.length,"Invalid string index");let e=te.OFFSET_STRINGS+4;for(let i=0;i<t;i++)e+=this.#i.getUint32(e)+4;let i=this.#i.getUint32(e);return this.#e.decode(new Uint8Array(this.#t,e+4,i))}get fallbackName(){return this.#a(0)}get loadedName(){return this.#a(1)}get mimetype(){return this.#a(2)}get name(){return this.#a(3)}#o(){let t=te.OFFSET_STRINGS;return t+=4+this.#i.getUint32(t),t+=4+this.#i.getUint32(t),t+=4+this.#i.getUint32(t),{offset:t,length:this.#i.getUint32(t)}}get data(){let{offset:t,length:e}=this.#o();return 0===e?void 0:new Uint8Array(this.#t,t+4,e)}clearData(){let{offset:t,length:e}=this.#o();0!==e&&(this.#i.setUint32(t,0),this.#t=new Uint8Array(this.#t,0,t+4).slice().buffer,this.#i=new DataView(this.#t))}get cssFontInfo(){let t=te.OFFSET_STRINGS;t+=4+this.#i.getUint32(t),t+=4+this.#i.getUint32(t);let e=this.#i.getUint32(t);if(0===e)return null;let i=new Uint8Array(e);return i.set(new Uint8Array(this.#t,t+4,e)),new ie(i.buffer)}get systemFontInfo(){let t=te.OFFSET_STRINGS;t+=4+this.#i.getUint32(t);let e=this.#i.getUint32(t);if(0===e)return null;let i=new Uint8Array(e);return i.set(new Uint8Array(this.#t,t+4,e)),new se(i.buffer)}}class ne{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){let t=this.view,e=this.data[ee.KIND],i=!!this.data[ee.HAS_BBOX],s=!!this.data[ee.HAS_BACKGROUND],r=t.getUint32(ee.N_COORD,!0),n=t.getUint32(ee.N_COLOR,!0),a=t.getUint32(ee.N_STOP,!0),o=20,l=new Float32Array(this.buffer,o,2*r);o+=8*r;let h=new Uint8Array(this.buffer,o,4*n);o+=4*n;let c=[];for(let e=0;e<a;++e){let e=t.getFloat32(o,!0);o+=4;let i=t.getUint32(o,!0);o+=4,c.push([e,`#${i.toString(16).padStart(6,"0")}`])}let u=null;if(i){u=[];for(let e=0;e<4;++e)u.push(t.getFloat32(o,!0)),o+=4}let p=null;if(s&&(p=new Uint8Array(this.buffer,o,3),o+=3),1===e)return["RadialAxial","axial",u,c,Array.from(l.slice(0,2)),Array.from(l.slice(2,4)),null,null];if(2===e)return["RadialAxial","radial",u,c,[l[0],l[1]],[l[3],l[4]],l[2],l[5]];if(3===e){let t=this.data[ee.SHADING_TYPE],e=null;if(l.length>0){e=d.slice();for(let t=0,i=l.length;t<i;t+=2)O.pointBoundingBox(l[t],l[t+1],e)}return["Mesh",t,l,h,r,e,u,p]}throw Error(`Unsupported pattern kind: ${e}`)}}class ae{#t;constructor(t){this.#t=t}get path(){return N.isFloat16ArraySupported?new Float16Array(this.#t):new Float32Array(this.#t)}}function oe(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw Error(`Invalid factory url: "${t}" must include trailing slash.`)}const le=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0;(function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;let[s,r,...n]=i;if(!t(s)&&!Number.isInteger(s))return!1;if(!e(r))return!1;let a=n.length,o=!0;switch(r.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return 0===a;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(4!==a)return!1;o=!1;break;default:return!1}for(let t of n)if(!("number"==typeof t||o&&null===t))return!1;return!0}).bind(null,le,t=>"object"==typeof t&&"string"==typeof t?.name);class he{#t=new Map;#e=Promise.resolve();postMessage(t,e){let i={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(let[t]of this.#t)t.call(this,i)})}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){let{signal:r}=i;if(r.aborted)return void _("LoopbackPort - cannot use an `aborted` signal.");let n=()=>this.removeEventListener(t,e);s=()=>r.removeEventListener("abort",n),r.addEventListener("abort",n)}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()}}function de(){}function ce(t){if(t instanceof F||t instanceof E||t instanceof P||t instanceof D||t instanceof T)return t;switch(t instanceof Error||"object"==typeof t&&t||S('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new F(t.message);case"InvalidPDFException":return new E(t.message);case"PasswordException":return new P(t.message,t.code);case"ResponseException":return new D(t.message,t.status,t.missing);case"UnknownErrorException":return new T(t.message,t.details)}return new T(t.message,t.toString())}class ue{#t=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,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),i.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#s(t);if(t.callback){let e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)i.resolve(t.data);else{if(2!==t.callback)throw Error("Unexpected callback case");i.reject(ce(t.reason))}return}let e=this.actionHandler[t.action];if(!e)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let i=this.sourceName,s=t.sourceName,r=this.comObj;return void Promise.try(e,t.data).then(function(e){r.postMessage({sourceName:i,targetName:s,callback:1,callbackId:t.callbackId,data:e})},function(e){r.postMessage({sourceName:i,targetName:s,callback:2,callbackId:t.callbackId,reason:ce(e)})})}t.streamId?this.#i(t):e(t.data)}on(t,e){let i=this.actionHandler;if(i[t])throw Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){let s=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[s]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){r.reject(t)}return r.promise}sendWithStream(t,e,i,s){let r=this.streamId++,n=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{let l=Promise.withResolvers();return this.streamControllers[r]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:n,targetName:a,action:t,streamId:r,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{let e=Promise.withResolvers();return this.streamControllers[r].pullCall=e,o.postMessage({sourceName:n,targetName:a,stream:6,streamId:r,desiredSize:t.desiredSize}),e.promise},cancel:t=>{C(t instanceof Error,"cancel must have a valid reason");let e=Promise.withResolvers();return this.streamControllers[r].cancelCall=e,this.streamControllers[r].isClosed=!0,o.postMessage({sourceName:n,targetName:a,stream:1,streamId:r,reason:ce(t)}),e.promise}},i)}#i(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,r=this.comObj,n=this,a=this.actionHandler[t.action],o={enqueue(t,n=1,a){if(this.isCancelled)return;let o=this.desiredSize;this.desiredSize-=n,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:i,targetName:s,stream:4,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:s,stream:3,streamId:e}),delete n.streamSinks[e])},error(t){C(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:s,stream:5,streamId:e,reason:ce(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then(function(){r.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,reason:ce(t)})})}#s(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,r=this.comObj,n=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case 8:t.success?n.startCall.resolve():n.startCall.reject(ce(t.reason));break;case 7:t.success?n.pullCall.resolve():n.pullCall.reject(ce(t.reason));break;case 6:if(!a){r.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||de).then(function(){r.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,reason:ce(t)})});break;case 4:if(C(n,"enqueue should have stream controller"),n.isClosed)break;n.controller.enqueue(t.chunk);break;case 3:if(C(n,"close should have stream controller"),n.isClosed)break;n.isClosed=!0,n.controller.close(),this.#r(n,e);break;case 5:C(n,"error should have stream controller"),n.controller.error(ce(t.reason)),this.#r(n,e);break;case 2:t.success?n.cancelCall.resolve():n.cancelCall.reject(ce(t.reason)),this.#r(n,e);break;case 1:if(!a)break;let o=ce(t.reason);Promise.try(a.onCancel||de,o).then(function(){r.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,reason:ce(t)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw Error("Unexpected stream case")}}async#r(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}}class pe{#t=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:i=null}){this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=i}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:S(`Not implemented: ${t}`)}let i=this[t];if(!i)throw Error(`Ensure that the \`${t}\` API parameter is provided.`);let s=`${i}${e}`;return this._fetch(s,t).catch(e=>{throw Error(`Unable to load ${this.#t[t]} data at: ${s}`)})}async _fetch(t,e){S("Abstract method `_fetch` called.")}}class ge extends pe{async _fetch(t,e){let i=await H(t,"cMapUrl"!==e||t.endsWith(".bcmap")?"bytes":"text");return i instanceof Uint8Array?i:R(i)}}class fe{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");let i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#t})}}reset({canvas:t},e,i){if(!t)throw Error("Canvas is not specified");if(e<=0||i<=0)throw Error("Invalid canvas size");t.width=e,t.height=i}destroy(t){let{canvas:e}=t;if(!e)throw Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){S("Abstract method `_createCanvas` called.")}}class me extends fe{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class ye{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,i,s,r){return"none"}destroy(t=!1){}}class be extends ye{#t;#e;#i;#s;#r;#n;#a=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#s=t,this.#r=e}get#o(){return this.#e||=new Map}get#l(){return this.#n||=new Map}get#h(){if(!this.#i){let t=this.#r.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 i=this.#r.createElementNS(G,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#i=this.#r.createElementNS(G,"defs"),t.append(i),i.append(this.#i),this.#r.body.append(t)}return this.#i}#d(t){if(1===t.length){let e=t[0],i=Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;let s=i.join(",");return[s,s,s]}let[e,i,s]=t,r=Array(256),n=Array(256),a=Array(256);for(let t=0;t<256;t++)r[t]=e[t]/255,n[t]=i[t]/255,a[t]=s[t]/255;return[r.join(","),n.join(","),a.join(",")]}#c(t){if(void 0===this.#t){this.#t="";let t=this.#r.URL;t!==this.#r.baseURI&&(q(t)?_('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=function(t,e,i=!1){let s=URL.parse(t);return s?(s.hash=e,s.href):i&&function(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t&&(i.addDefaultProtocol&&t.startsWith("www.")&&t.match(/\./g)?.length>=2&&(t=`http://${t}`),i.tryConvertEncoding))try{t=function(t){return decodeURIComponent(escape(t))}(t)}catch{}let s=e?URL.parse(t,e):URL.parse(t);return function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s)?s:null}(t,"http://example.com")?t.split("#",1)[0]+"":""}(t,""))}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#o.get(t);if(e)return e;let[i,s,r]=this.#d(t),n=1===t.length?i:`${i}${s}${r}`;if(e=this.#o.get(n),e)return this.#o.set(t,e),e;let a=`g_${this.#s}_transfer_map_${this.#a++}`,o=this.#c(a);this.#o.set(t,o),this.#o.set(n,o);let l=this.#g(a);return this.#m(i,s,r,l),o}addHCMFilter(t,e){let i=`${t}-${e}`,s="base",r=this.#l.get(s);if(r?.key===i)return r.url;if(r?(r.filter?.remove(),r.key=i,r.url="none",r.filter=null):(r={key:i,url:"none",filter:null},this.#l.set(s,r)),!t||!e)return r.url;let n=this.#b(t);t=O.makeHexColor(...n);let a=this.#b(e);if(e=O.makeHexColor(...a),this.#h.style.color="","#000000"===t&&"#ffffff"===e||t===e)return r.url;let o=Array(256);for(let t=0;t<=255;t++){let e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}let l=o.join(","),h=`g_${this.#s}_hcm_filter`,d=r.filter=this.#g(h);this.#m(l,l,l,d),this.#p(d);let c=(t,e)=>{let i=n[t]/255,s=a[t]/255,r=Array(e+1);for(let t=0;t<=e;t++)r[t]=i+t/e*(s-i);return r.join(",")};return this.#m(c(0,5),c(1,5),c(2,5),d),r.url=this.#c(h),r.url}addAlphaFilter(t){let e=this.#o.get(t);if(e)return e;let[i]=this.#d([t]),s=`alpha_${i}`;if(e=this.#o.get(s),e)return this.#o.set(t,e),e;let r=`g_${this.#s}_alpha_map_${this.#a++}`,n=this.#c(r);this.#o.set(t,n),this.#o.set(s,n);let a=this.#g(r);return this.#y(i,a),n}addLuminosityFilter(t){let e,i,s=this.#o.get(t||"luminosity");if(s)return s;if(t?([e]=this.#d([t]),i=`luminosity_${e}`):i="luminosity",s=this.#o.get(i),s)return this.#o.set(t,s),s;let r=`g_${this.#s}_luminosity_map_${this.#a++}`,n=this.#c(r);this.#o.set(t,n),this.#o.set(i,n);let a=this.#g(r);return this.#u(a),t&&this.#y(e,a),n}addKnockoutFilter(t=0){let e=t>0?Math.min(1/t,1e6):1e6,i=`knockout_${e}`,s=this.#o.get(i);if(s)return s;let r=`g_${this.#s}_knockout_filter_${this.#a++}`,n=this.#c(r);this.#o.set(i,n);let a=this.#g(r),o=this.#r.createElementNS(G,"feComponentTransfer");a.append(o);let l=this.#r.createElementNS(G,"feFuncA");return l.setAttribute("type","linear"),l.setAttribute("slope",`${e}`),l.setAttribute("intercept","0"),o.append(l),n}addHighlightHCMFilter(t,e,i,s,r){let n=`${e}-${i}-${s}-${r}`,a=this.#l.get(t);if(a?.key===n)return a.url;if(a?(a.filter?.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},this.#l.set(t,a)),!e||!i)return a.url;let[o,l]=[e,i].map(this.#b.bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,r].map(this.#b.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#h.style.color="";let p=(t,e,i)=>{let s=Array(256),r=(d-h)/i,n=t/255,a=(e-t)/(255*i),o=0;for(let t=0;t<=i;t++){let e=Math.round(h+t*r),i=n+t*a;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#s}_hcm_${t}_filter`,f=a.filter=this.#g(g);return this.#p(f),this.#m(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),f),a.url=this.#c(g),a.url}destroy(t=!1){t&&this.#n?.size||(this.#i?.parentNode.parentNode.remove(),this.#i=null,this.#e?.clear(),this.#e=null,this.#n?.clear(),this.#n=null,this.#a=0)}#u(t){let e=this.#r.createElementNS(G,"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)}#p(t){let e=this.#r.createElementNS(G,"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)}#g(t){let e=this.#r.createElementNS(G,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#h.append(e),e}#f(t,e,i){let s=this.#r.createElementNS(G,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#m(t,e,i,s){let r=this.#r.createElementNS(G,"feComponentTransfer");s.append(r),this.#f(r,"feFuncR",t),this.#f(r,"feFuncG",e),this.#f(r,"feFuncB",i)}#y(t,e){let i=this.#r.createElementNS(G,"feComponentTransfer");e.append(i),this.#f(i,"feFuncA",t)}#b(t){return this.#h.style.color=t,it(getComputedStyle(this.#h).getPropertyValue("color"))}}h&&_("Please use the `legacy` build in Node.js environments.");class ve extends ye{}class Ae extends fe{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire("file:///__w/webgis-sdk/webgis-sdk/packages/core-packages/core/output/npm/esm/chunks/pdf.js")("@napi-rs/canvas").createCanvas(t,e)}}class we extends pe{async _fetch(t,e){return async function(t){let e=await process.getBuiltinModule("fs/promises").readFile(t);return new Uint8Array(e)}(t)}}const xe=new class{#t=null;#e=null;#i=null;#s=null;async#r(){if(!globalThis.navigator?.gpu)return!1;try{let t=await navigator.gpu.requestAdapter();return!!t&&(this.#s=navigator.gpu.getPreferredCanvasFormat(),this.#e=await t.requestDevice(),!0)}catch{return!1}}init(){return this.#t||=this.#r()}get isReady(){return null!==this.#e}loadMeshShader(){if(!this.#e||this.#i)return;let t=this.#e.createShaderModule({code:"\nstruct Uniforms {\n offsetX : f32,\n offsetY : f32,\n scaleX : f32,\n scaleY : f32,\n paddedWidth : f32,\n paddedHeight : f32,\n borderSize : f32,\n _pad : f32,\n};\n\n@group(0) @binding(0) var<uniform> u : Uniforms;\n\nstruct VertexInput {\n @location(0) position : vec2<f32>,\n @location(1) color : vec4<f32>,\n};\n\nstruct VertexOutput {\n @builtin(position) position : vec4<f32>,\n @location(0) color : vec3<f32>,\n};\n\n@vertex\nfn vs_main(in : VertexInput) -> VertexOutput {\n var out : VertexOutput;\n let cx = (in.position.x + u.offsetX) * u.scaleX;\n let cy = (in.position.y + u.offsetY) * u.scaleY;\n out.position = vec4<f32>(\n ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,\n 1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,\n 0.0,\n 1.0\n );\n out.color = in.color.rgb;\n return out;\n}\n\n@fragment\nfn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {\n return vec4<f32>(in.color, 1.0);\n}\n"});this.#i=this.#e.createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:this.#s}]},primitive:{topology:"triangle-list"}})}draw(t,e,i,s,r,n,a,o){this.loadMeshShader();let l=this.#e,{offsetX:h,offsetY:d,scaleX:c,scaleY:u}=s,p=l.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&l.queue.writeBuffer(p,0,t);let g=l.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&l.queue.writeBuffer(g,0,e);let f=l.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l.queue.writeBuffer(f,0,new Float32Array([h,d,c,u,n,a,o,0]));let m=l.createBindGroup({layout:this.#i.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:f}}]}),y=new OffscreenCanvas(n,a),b=y.getContext("webgpu");b.configure({device:l,format:this.#s,alphaMode:r?"opaque":"premultiplied"});let v=r?{r:r[0]/255,g:r[1]/255,b:r[2]/255,a:1}:{r:0,g:0,b:0,a:0},A=l.createCommandEncoder(),w=A.beginRenderPass({colorAttachments:[{view:b.getCurrentTexture().createView(),clearValue:v,loadOp:"clear",storeOp:"store"}]});return i>0&&(w.setPipeline(this.#i),w.setBindGroup(0,m),w.setVertexBuffer(0,p),w.setVertexBuffer(1,g),w.draw(i)),w.end(),l.queue.submit([A.finish()]),p.destroy(),g.destroy(),f.destroy(),y.transferToImageBitmap()}},_e="Fill",Se="Stroke",Ce="Shading";function Me(t,e){if(!e)return;let i=e[2]-e[0],s=e[3]-e[1],r=new Path2D;r.rect(e[0],e[1],i,s),t.clip(r)}class ke{isModifyingCurrentTransform(){return!1}getPattern(){S("Abstract method `getPattern` called.")}}class Pe extends ke{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}isOriginBased(){return 0===this._p0[0]&&0===this._p0[1]&&(!this.isRadial()||0===this._p1[0]&&0===this._p1[1])}isRadial(){return"radial"===this._type}areConic(){if(!this.isRadial())return!1;let t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let i,s=this._p0,r=this._p1;if(e&&(s=s.slice(),r=r.slice(),O.applyTransform(s,e),O.applyTransform(r,e)),"axial"===this._type)i=t.createLinearGradient(s[0],s[1],r[0],r[1]);else if("radial"===this._type){let n=this._r0,a=this._r1;if(e){let t=new Float32Array(2);O.singularValueDecompose2dScale(e,t),n*=t[0],a*=t[0]}i=t.createRadialGradient(s[0],s[1],n,r[0],r[1],a)}for(let t of this._colorStops)i.addColorStop(t[0],t[1]);return i}_createReversedGradient(t,e=null){let i=this._p1,s=this._p0;e&&(i=i.slice(),s=s.slice(),O.applyTransform(i,e),O.applyTransform(s,e));let r=this._r1,n=this._r0;if(e){let t=new Float32Array(2);O.singularValueDecompose2dScale(e,t),r*=t[0],n*=t[0]}let a=t.createRadialGradient(i[0],i[1],r,s[0],s[1],n),o=this._colorStops.map(([t,e])=>[1-t,e]).reverse();for(let[t,e]of o)a.addColorStop(t,e);return a}getPattern(t,e,i,s){let r;if(s===Se||s===_e){if(this.isOriginBased()){let s=O.transform(i,e.baseTransform);this.matrix&&(s=O.transform(s,this.matrix));let r=.001,n=Math.hypot(s[0],s[1]),a=Math.hypot(s[2],s[3]),o=(s[0]*s[2]+s[1]*s[3])/(n*a);if(Math.abs(o)<r){if(!this.isRadial())return this._createGradient(t,s);if(Math.abs(n-a)<r)return this._createGradient(t,s)}}let n=e.current.getClippedPathBoundingBox(s,st(t))||[0,0,0,0],a=Math.ceil(n[2]-n[0])||1,o=Math.ceil(n[3]-n[1])||1,l=e.canvasFactory.create(a,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-n[0],-n[1]),i=O.transform(i,[1,0,0,1,n[0],n[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),Me(h,this._bbox),this.areConic()&&(h.fillStyle=this._createReversedGradient(h),h.fill()),h.fillStyle=this._createGradient(h),h.fill(),r=t.createPattern(l.canvas,"no-repeat"),e.canvasFactory.destroy(l);let d=new DOMMatrix(i);r.setTransform(d)}else this.areConic()&&(t.save(),Me(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),Me(t,this._bbox),r=this._createGradient(t);return r}}function Te(t,e,i,s,r,n,a,o){let l,h=e.coords,d=e.colors,c=t.data,u=4*t.width;h[2*i+1]>h[2*s+1]&&(l=i,i=s,s=l,l=n,n=a,a=l),h[2*s+1]>h[2*r+1]&&(l=s,s=r,r=l,l=a,a=o,o=l),h[2*i+1]>h[2*s+1]&&(l=i,i=s,s=l,l=n,n=a,a=l);let p=(h[2*i]+e.offsetX)*e.scaleX,g=(h[2*i+1]+e.offsetY)*e.scaleY,f=(h[2*s]+e.offsetX)*e.scaleX,m=(h[2*s+1]+e.offsetY)*e.scaleY,y=(h[2*r]+e.offsetX)*e.scaleX,b=(h[2*r+1]+e.offsetY)*e.scaleY;if(g>=b)return;let v,A,w,x,_,S,C,M,k=d[4*n],P=d[4*n+1],T=d[4*n+2],E=d[4*a],D=d[4*a+1],I=d[4*a+2],F=d[4*o],R=d[4*o+1],N=d[4*o+2],O=Math.round(g),B=Math.round(b);for(let t=O;t<=B;t++){if(t<m){let e=t<g?0:(g-t)/(g-m);v=p-(p-f)*e,A=k-(k-E)*e,w=P-(P-D)*e,x=T-(T-I)*e}else{let e;e=t>b?1:m===b?0:(m-t)/(m-b),v=f-(f-y)*e,A=E-(E-F)*e,w=D-(D-R)*e,x=I-(I-N)*e}let e;e=t<g?0:t>b?1:(g-t)/(g-b),_=p-(p-y)*e,S=k-(k-F)*e,C=P-(P-R)*e,M=T-(T-N)*e;let i=Math.round(Math.min(v,_)),s=Math.round(Math.max(v,_)),r=u*t+4*i;for(let t=i;t<=s;t++)e=(v-t)/(v-_),e<0?e=0:e>1&&(e=1),c[r++]=A-(A-S)*e|0,c[r++]=w-(w-C)*e|0,c[r++]=x-(x-M)*e|0,c[r++]=255}}class Ee extends ke{constructor(t){super(),this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null,xe.loadMeshShader()}_createMeshCanvas(t,e,i){let s=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),n=Math.ceil(this._bounds[2])-s,a=Math.ceil(this._bounds[3])-r,o=Math.min(Math.ceil(Math.abs(n*t[0]*1.1)),3e3)||1,l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3)||1,h=n?n/o:1,d=a?a/l:1,c={coords:this._posData,colors:this._colData,offsetX:-s,offsetY:-r,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.create(u,p);if(xe.isReady&&this._vertexCount>48)g.context.drawImage(function(t,e,i,s,r,n,a){return xe.draw(t,e,i,s,r,n,a,2)}(this._posData,this._colData,this._vertexCount,c,e,u,p),0,0);else{let t=g.context.createImageData(o,l);if(e){let i=t.data;for(let t=0,s=i.length;t<s;t+=4)i[t]=e[0],i[t+1]=e[1],i[t+2]=e[2],i[t+3]=255}for(let e=0,i=this._vertexCount;e<i;e+=3)Te(t,c,e,e+1,e+2,e,e+1,e+2);g.context.putImageData(t,2,2)}return{canvas:g.canvas,offsetX:s-2*h,offsetY:r-2*d,scaleX:h,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){Me(t,this._bbox);let r=new Float32Array(2);if(s===Ce)O.singularValueDecompose2dScale(st(t),r);else if(this.matrix){O.singularValueDecompose2dScale(this.matrix,r);let[t,i]=r;O.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=t,r[1]*=i}else O.singularValueDecompose2dScale(e.baseTransform,r);let n=this._createMeshCanvas(r,s===Ce?null:this._background,e.canvasFactory);s!==Ce&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(n.offsetX,n.offsetY),t.scale(n.scaleX,n.scaleY);let a=t.createPattern(n.canvas,"no-repeat");return e.canvasFactory.destroy(n),a}}class De extends ke{getPattern(){return"hotpink"}}class Ie{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s,this.patternBaseMatrix=this.matrix?O.transform(s,this.matrix):s}canSkipPatternCanvas([t,e,i,s]){let[r,n,a,o]=this.bbox,l=Math.abs(this.xstep),h=Math.abs(this.ystep);if(t>l+1e-6||e>h+1e-6)return null;let d=Math.floor((i-a)/l)+1,c=Math.ceil((i+t-r)/l)-1,u=Math.floor((s-o)/h)+1,p=Math.ceil((s+e-n)/h)-1;return c<=d&&p<=u?[d,u]:null}updatePatternDims(t,e){let i=O.inverseTransform(this.patternBaseMatrix),s=[t[0],t[1]],r=[t[2],t[3]];O.applyTransform(s,i),O.applyTransform(r,i),e[0]=Math.abs(r[0]-s[0]),e[1]=Math.abs(r[1]-s[1]),e[2]=Math.min(s[0],r[0]),e[3]=Math.min(s[1],r[1])}_renderTileCanvas(t,e,i,s){let[r,n,a,o]=this.bbox,l=t.canvasFactory.create(i.size,s.size),h=l.context,d=this.canvasGraphicsFactory.createCanvasGraphics(h,e);return d.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(d,this.paintType,this.color),h.translate(-i.scale*r,-s.scale*n),d.transform(0,i.scale,0,0,s.scale,0,0),h.save(),d.dependencyTracker?.save(),this.clipBbox(d,r,n,a,o),d.baseTransform=st(d.ctx),d.executeOperatorList(this.operatorList),d.endDrawing(),d.dependencyTracker?.restore(),h.restore(),l}_getCombinedScales(){let t=new Float32Array(2);O.singularValueDecompose2dScale(this.matrix,t);let[e,i]=t;return O.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],i*t[1]]}drawPattern(t,e,i=!1,[s,r],n){let[a,o,l,h]=this.bbox,d=t.dependencyTracker;if(d&&(t.dependencyTracker=new Ut(d,n)),t.save(),i?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(s*this.xstep,r*this.ystep),this.needsIsolation||1!==t.ctx.globalAlpha||"source-over"!==t.ctx.globalCompositeOperation||t.inSMaskMode){let e=l-a,i=h-o,[s,r]=this._getCombinedScales(),d=this.getSizeAndScale(e,this.ctx.canvas.width,s),c=this.getSizeAndScale(i,this.ctx.canvas.height,r),u=this._renderTileCanvas(t,n,d,c);t.ctx.drawImage(u.canvas,a,o,e,i),t.canvasFactory.destroy(u)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,a,o,l,h),t.baseTransformStack.push(t.baseTransform),t.baseTransform=st(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore(),d&&(t.dependencyTracker=d)}createPatternCanvas(t,e){let[i,s,r,n]=this.bbox,a=r-i,o=n-s,{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),x("TilingType: "+this.tilingType);let[d,c]=this._getCombinedScales(),u=a,p=o,g=!1,f=!1;Math.ceil(l*d)>=Math.ceil(a*d)?u=l:g=!0,Math.ceil(h*c)>=Math.ceil(o*c)?p=h:f=!0;let m=this.getSizeAndScale(u,this.ctx.canvas.width,d),y=this.getSizeAndScale(p,this.ctx.canvas.height,c),b=this._renderTileCanvas(t,e,m,y);if(g||f){let e=b.canvas;g&&(u=l),f&&(p=h);let r=this.getSizeAndScale(u,this.ctx.canvas.width,d),n=this.getSizeAndScale(p,this.ctx.canvas.height,c),m=r.size,y=n.size,v=t.canvasFactory.create(m,y),A=v.context,w=g?Math.floor(a/l):0,x=f?Math.floor(o/h):0;for(let t=0;t<=w;t++)for(let i=0;i<=x;i++)A.drawImage(e,m*t,y*i,m,y,0,0,m,y);return t.canvasFactory.destroy(b),{canvas:v.canvas,canvasEntry:v,scaleX:r.scale,scaleY:n.scale,offsetX:i,offsetY:s}}return{canvas:b.canvas,canvasEntry:b,scaleX:m.scale,scaleY:y.scale,offsetX:i,offsetY:s}}getSizeAndScale(t,e,i){let s=Math.max(Ie.MAX_PATTERN_SIZE,e),r=Math.ceil(t*i);return r>=s?r=s:i=r/t,{scale:i,size:r}}clipBbox(t,e,i,s,r){let n=s-e,a=r-i,o=new Path2D;o.rect(e,i,n,a),O.axialAlignedBoundingBox([e,i,s,r],st(t.ctx),t.current.minMax),t.ctx.clip(o),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,i){let s=t.ctx,r=t.current;switch(r.patternFill=r.patternStroke=!1,e){case 1:let{fillStyle:t,strokeStyle:n}=this.ctx;s.fillStyle=r.fillColor=t,s.strokeStyle=r.strokeColor=n;break;case 2:s.fillStyle=s.strokeStyle=i,r.fillColor=r.strokeColor=i;break;default:throw new I(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s,r){let n=s===Ce?i:O.transform(i,this.patternBaseMatrix),a=this.createPatternCanvas(e,r),o=new DOMMatrix(n);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);let l=t.createPattern(a.canvas,"repeat");return e.canvasFactory.destroy(a.canvasEntry),l.setTransform(o),l}}function Fe({src:t,srcPos:e=0,dest:i,width:s,height:r,nonBlackColor:n=4294967295,inverseDecode:a=!1}){let o=N.isLittleEndian?4278190080:255,[l,h]=a?[n,o]:[o,n],d=s>>3,c=7&s,u=l^h,p=t.length;i=new Uint32Array(i.buffer);let g=0;for(let s=0;s<r;++s){for(let s=e+d;e<s;++e,g+=8){let s=t[e];i[g]=l^-(s>>7&1)&u,i[g+1]=l^-(s>>6&1)&u,i[g+2]=l^-(s>>5&1)&u,i[g+3]=l^-(s>>4&1)&u,i[g+4]=l^-(s>>3&1)&u,i[g+5]=l^-(s>>2&1)&u,i[g+6]=l^-(s>>1&1)&u,i[g+7]=l^-(1&s)&u}if(0===c)continue;let s=e<p?t[e++]:255;for(let t=0;t<c;++t,++g)i[g]=l^-(s>>7-t&1)&u}return{srcPos:e,destPos:g}}const Re=new DOMMatrix,Ne=new Float32Array(2);function Oe(t,e){if(t._removeMirroring)throw Error("Context is already forwarding operations.");let i=new Map;for(let s of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){let r=t[s];"function"==typeof r&&"function"==typeof e[s]&&(i.set(s,r),t[s]=function(...t){return e[s](...t),r.apply(this,t)})}t._removeMirroring=()=>{for(let[e,s]of i)t[e]=s;delete t._removeMirroring}}function Be(t,e,i,s,r,n,a,o,l,h){let[d,c,u,p,g,f]=st(t);if(0===c&&0===u){let m=a*d+g,y=Math.round(m),b=o*p+f,v=Math.round(b),A=(a+l)*d+g,w=Math.abs(Math.round(A)-y)||1,x=(o+h)*p+f,_=Math.abs(Math.round(x)-v)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),y,v),t.drawImage(e,i,s,r,n,0,0,w,_),t.setTransform(d,c,u,p,g,f),[w,_]}if(0===d&&0===p){let m=o*u+g,y=Math.round(m),b=a*c+f,v=Math.round(b),A=(o+h)*u+g,w=Math.abs(Math.round(A)-y)||1,x=(a+l)*c+f,_=Math.abs(Math.round(x)-v)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,y,v),t.drawImage(e,i,s,r,n,0,0,_,w),t.setTransform(d,c,u,p,g,f),[_,w]}return t.drawImage(e,i,s,r,n,a,o,l,h),[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class Le{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=u;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=0;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";minMax=c.slice();constructor(t,e){this.clipBox=new Float32Array([0,0,t,e])}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=this.tilingPatternDims?.slice(),t}getPathBoundingBox(t=_e,e=null){let i=this.minMax.slice();if(t===Se){e||S("Stroke bounding box must include transform."),O.singularValueDecompose2dScale(e,Ne);let t=Ne[0]*this.lineWidth/2,s=Ne[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){let t=O.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(c,0)}getClippedPathBoundingBox(t=_e,e=null){return O.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function je(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);let i,s,r,n,a,o=e.height,l=e.width,h=o%16,d=(o-h)/16,c=0===h?d:d+1,u=t.createImageData(l,16),p=0,g=e.data,f=u.data;if(1===e.kind){let e=g.byteLength,a=new Uint32Array(f.buffer,0,f.byteLength>>2),o=a.length,m=l+7>>3,y=4294967295,b=N.isLittleEndian?4278190080:255;for(s=0;s<c;s++){for(n=s<d?16:h,i=0,r=0;r<n;r++){let t=e-p,s=0,r=t>m?l:8*t-7,n=-8&r,o=0,h=0;for(;s<n;s+=8)h=g[p++],a[i++]=128&h?y:b,a[i++]=64&h?y:b,a[i++]=32&h?y:b,a[i++]=16&h?y:b,a[i++]=8&h?y:b,a[i++]=4&h?y:b,a[i++]=2&h?y:b,a[i++]=1&h?y:b;for(;s<r;s++)0===o&&(h=g[p++],o=128),a[i++]=h&o?y:b,o>>=1}for(;i<o;)a[i++]=0;t.putImageData(u,0,16*s)}}else if(3===e.kind){for(r=0,a=16*l*4,s=0;s<d;s++)f.set(g.subarray(p,p+a)),p+=a,t.putImageData(u,0,r),r+=16;s<c&&(a=l*h*4,f.set(g.subarray(p,p+a)),t.putImageData(u,0,r))}else{if(2!==e.kind)throw Error(`bad image kind: ${e.kind}`);for(n=16,a=l*n,s=0;s<c;s++){for(s>=d&&(n=h,a=l*n),i=0,r=a;r--;)f[i++]=g[p++],f[i++]=g[p++],f[i++]=g[p++],f[i++]=255;t.putImageData(u,0,16*s)}}}function $e(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);let i=e.height,s=e.width,r=i%16,n=(i-r)/16,a=0===r?n:n+1,o=t.createImageData(s,16),l=0,h=e.data,d=o.data;for(let e=0;e<a;e++){let i=e<n?16:r;({srcPos:l}=Fe({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,16*e)}}function Ue(t,e){for(let i of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[i]&&(e[i]=t[i]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function ze(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0);let{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function Ge(t,e){if(e)return!0;O.singularValueDecompose2dScale(t,Ne);let i=Math.fround(at.pixelRatio*W.PDF_TO_CSS_UNITS);return Ne[0]<=i&&Ne[1]<=i}const We=["butt","round","square"],He=["miter","round","bevel"],Ve={},Xe={};class qe{#t=0;#e=0;#i=null;#s=null;#r=null;#n=null;#a=1;#o;#l=null;#h=[];constructor(t,e,i,s,r,{optionalContentConfig:n,markedContentStack:a=null},o,l,h,d){this.ctx=t,this.current=new Le(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=n,this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null,this.imagesTracker=d??null}getObject(t,e,i=null){return"string"==typeof e?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){let r=this.ctx.canvas.width,n=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,r,n),this.ctx.fillStyle=a,i){let t=this.transparentCanvasEntry=this.canvasFactory.create(r,n);this.compositeCtx=this.ctx,({canvas:this.transparentCanvas,context:this.ctx}=t),this.ctx.save(),this.ctx.transform(...st(this.compositeCtx))}this.ctx.save(),ze(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=st(this.ctx)}executeOperatorList(t,e,i,s,r,n=null,a=null){let o=Number.isFinite(n?.executionTime)&&n.executionTime>0?n.executionTime:15,l=Number.isInteger(n?.executionSteps)&&n.executionSteps>0?n.executionSteps:10,h=t.argsArray,d=t.fnArray,c=e||0,u=h.length;if(u===c)return c;let p,g,f=u-c>l&&"function"==typeof i,m=f?performance.now()+o:0,y=0,v=this.commonObjs,A=this.objs;for(;;){if(void 0!==s){if(c===s.nextBreakPoint)return s.breakIt(c,i),c;if(s.shouldSkip(c)){if(++c===u)return c;continue}}if(!r||r(c))if(p=d[c],g=h[c]??null,p!==b.dependency)null===g?this[p](c):this[p](c,...g);else for(let t of g){this.dependencyTracker?.recordNamedData(t,c);let e=t.startsWith("g_")?v:A;if(!e.has(t))return e.get(t,i),c}if(c++,c===u)return c;if(f&&++y>l){let t=performance.now()>m;if("function"==typeof a&&a()||t)return i(),c;y=0}}}#d(){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.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)}endDrawing(){this.#d();for(let t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(let t of this.#h)this.#b(t);this.#h.length=0,this.#i=null,this.#s=null,this.#r=null,this.#n=null,this.#a=1,this.#l=null,this.#e=0,this.#t=0,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.#c()}#c(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){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 i=t.width??t.displayWidth,s=t.height??t.displayHeight,r=[],n=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=i,l=s;for(;n>2&&o>1||a>2&&l>1;){let t=o,e=l;n>2&&o>1&&(t=Math.ceil(o/2),n/=o/t),a>2&&l>1&&(e=Math.ceil(l/2),a/=l/e),r.push({newWidth:t,newHeight:e}),o=t,l=e}if(0===r.length)return{img:t,paintWidth:i,paintHeight:s,tmpCanvas:null};if(1===r.length){let{newWidth:e,newHeight:n}=r[0],a=this.canvasFactory.create(e,n);return a.context.drawImage(t,0,0,i,s,0,0,e,n),{img:a.canvas,paintWidth:e,paintHeight:n,tmpCanvas:a}}let h=this.canvasFactory.create(1,1),d=this.canvasFactory.create(1,1),c=i,u=s,p=t;for(let{newWidth:t,newHeight:e}of r)this.canvasFactory.reset(d,t,e),d.context.drawImage(p,0,0,c,u,0,0,t,e),[h,d]=[d,h],p=h.canvas,c=t,u=e;return this.canvasFactory.destroy(d),{img:h.canvas,paintWidth:c,paintHeight:u,tmpCanvas:h}}_createMaskCanvas(t,e){let i,s,r,n,a=this.ctx,{width:o,height:l}=e,h=this.current.fillColor,d=this.current.patternFill,u=st(a);if((e.bitmap||e.data)&&e.count>1){let n=e.bitmap||e.data.buffer;s=JSON.stringify(d?u:[u.slice(0,4),h]),i=this._cachedBitmapsMap.getOrInsertComputed(n,L);let a=i.get(s);if(a&&!d){let e=Math.round(Math.min(u[0],u[2])+u[4]),i=Math.round(Math.min(u[1],u[3])+u[5]);return this.dependencyTracker?.recordDependencies(t,qt),{canvas:a,offsetX:e,offsetY:i}}r=a}r||(n=this.canvasFactory.create(o,l),$e(n.context,e));let p=O.transform(u,[1/o,0,0,-1/l,0,0]);p=O.transform(p,[1,0,0,1,0,-l]);let g=c.slice();O.axialAlignedBoundingBox([0,0,o,l],p,g);let[f,m,y,b]=g,v=Math.round(y-f)||1,A=Math.round(b-m)||1,w=this.canvasFactory.create(v,A),x=w.context,_=f,S=m;x.translate(-_,-S),x.transform(...p);let C=null;if(!r){let t=this._scaleImage(n.canvas,rt(x));r=t.img,C=t.tmpCanvas,r!==n.canvas&&(this.canvasFactory.destroy(n),n=null),i&&d&&(i.set(s,r),C=null,n=null)}x.imageSmoothingEnabled=Ge(st(x),e.interpolate),Be(x,r,0,0,r.width,r.height,0,0,o,l),C&&this.canvasFactory.destroy(C),n&&this.canvasFactory.destroy(n),x.globalCompositeOperation="source-in";let M=O.transform(rt(x),[1,0,0,1,-_,-S]);return x.fillStyle=d?h.getPattern(a,this,M,_e,t):h,x.fillRect(0,0,o,l),i&&!d&&i.set(s,w.canvas),this.dependencyTracker?.recordDependencies(t,qt),{canvas:w.canvas,canvasEntry:i&&!d?null:w,offsetX:Math.round(_),offsetY:Math.round(S)}}setLineWidth(t,e){this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=We[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=He[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){this.dependencyTracker?.recordSimpleData("dash",t);let s=this.ctx;void 0!==s.setLineDash&&(s.setLineDash(e),s.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(let[i,s]of e)switch(i){case"LW":this.setLineWidth(t,s);break;case"LC":this.setLineCap(t,s);break;case"LJ":this.setLineJoin(t,s);break;case"ML":this.setMiterLimit(t,s);break;case"D":this.setDash(t,s[0],s[1]);break;case"RI":this.setRenderingIntent(t,s);break;case"FL":this.setFlatness(t,s);break;case"Font":this.setFont(t,s[0],s[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=s;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=s;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=s;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=s?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s)}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(t){t!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(t))}checkSMaskState(t){let e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode(t):!this.current.activeSMask&&e?this.endSMaskMode():this.current.activeSMask&&e&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(t){let e,{canvas:i,subtype:s,backdrop:r,transferMap:n}=t,a="Luminosity"===s||"Alpha"===s&&n;if(!(a||"Luminosity"===s&&r))return void(this.smaskPreparedFor=t);if("Luminosity"===s&&r){let[t,i,s]=et(r),a=Math.round(.3*t+.59*i+.11*s);e=n?.[a]??a}else e=n?.[0]??0;let o,l,h,{width:d,height:c}=this.ctx.canvas,u=d*c<i.width*i.height*4,p=a?{url:"Alpha"===s?this.filterFactory.addAlphaFilter(n):this.filterFactory.addLuminosityFilter(n),subtype:s,transferMap:n}:null,g="Luminosity"===s?r:null;u?(o=this._bakeSMaskCanvas(i,t.offsetX,t.offsetY,d,c,g,p),l=0,h=0):(o=this._bakeSMaskCanvas(i,0,0,i.width,i.height,g,p),l=t.offsetX,h=t.offsetY),this.smaskPreparedEntry=o,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=l,this.smaskPreparedOffsetY=h,this.smaskPreparedOOBAlpha=u||0===e?null:e}_bakeSMaskCanvas(t,e,i,s,r,n,a){n||a||S("_bakeSMaskCanvas with neither backdrop nor filter");let o=this.canvasFactory.create(s,r),l=o.context;if(l.drawImage(t,e,i),n&&(l.globalCompositeOperation="destination-atop",l.fillStyle=n,l.fillRect(0,0,s,r)),!a)return o;let h=this.canvasFactory.create(s,r),d=h.context;d.filter=a.url;let c=N.isCanvasFilterSupported&&"none"!==d.filter&&""!==d.filter;if(d.drawImage(o.canvas,0,0),N.isCanvasFilterSupported&&(d.filter="none"),!c){let t=d.getImageData(0,0,s,r),{data:e}=t,{transferMap:i}=a;if("Luminosity"===a.subtype)for(let t=0,s=e.length;t<s;t+=4){let s=.3*e[t]+.59*e[t+1]+.11*e[t+2]+.5|0;e[t]=e[t+1]=e[t+2]=0,e[t+3]=i?.[s]??s}else for(let t=3,s=e.length;t<s;t+=4)e[t]=i[e[t]];d.putImageData(t,0,0)}return this.canvasFactory.destroy(o),h}beginSMaskMode(t){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let{width:e,height:i}=this.ctx.canvas,s=this.canvasFactory.create(e,i);this.smaskScratchCanvas=s,this.suspendedCtx=this.ctx;let r=this.ctx=s.context;r.setTransform(this.suspendedCtx.getTransform()),Ue(this.suspendedCtx,r),Oe(r,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Ue(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}#u(t,e=null,i=1){let{width:s,height:r}=t,n=e??this.canvasFactory.create(s,r),a=n.context,o=(i=Math.round(255*i)/255)<1;o&&void 0===this.#o&&(this.#o=N.isCanvasFilterSupported?new Map:"none");let l="none";if(o&&this.#o instanceof Map&&(l=this.#o.get(i),l||(l=this.filterFactory.addKnockoutFilter(i),this.#o.set(i,l))),!o||"none"!==l)return e&&(a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,s,r),a.restore()),a.filter=l,a.drawImage(t,0,0),a.filter="none",n;let h=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,s,r),d=a.createImageData(s,r),c=h.data,u=d.data,p=i>0?1/i:1e6;for(let t=3,e=c.length;t<e;t+=4)u[t]=Math.min(Math.round(c[t]*p),255);return a.putImageData(d,0,0),n}#p(t,e,i,s){let r=t?.[e]??null;if(!r||r.canvas.width===i&&r.canvas.height===s||(this.canvasFactory.destroy(r),r=null),!r)return r=this.canvasFactory.create(i,s),t&&(t[e]=r),r;let n=r.context;return n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,i,s),n.restore(),r}#g(t,e,i={}){let{backdropCanvas:s=null,destTransform:r=[1,0,0,1,0,0],backdropOffset:n=[0,0],reuseMaskEntry:a=null,poolMeta:o=null,sourceAlpha:l=1,sourceFilter:h="none",knockoutAlpha:d=1}=i,{width:c,height:u}=e,p=this.#u(e,a,d),g=t.globalCompositeOperation;if(t.save(),t.setTransform(...r),t.globalAlpha=1,N.isCanvasFilterSupported&&(t.filter="none"),t.globalCompositeOperation="destination-out",t.drawImage(p.canvas,0,0),s){let[e,i]=n,r=this.#p(o,"knockoutBackdropEntry",c,u),a=r.context;a.drawImage(s,e,i,c,u,0,0,c,u),a.globalCompositeOperation="destination-in",a.drawImage(p.canvas,0,0),a.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(r.canvas,0,0),o||this.canvasFactory.destroy(r)}t.globalCompositeOperation=g,t.globalAlpha=l,N.isCanvasFilterSupported&&(t.filter=h??"none"),t.drawImage(e,0,0),t.restore(),a||this.canvasFactory.destroy(p)}#f(t=1){if(0===this.#t||this.#e>0||!this.contentVisible)return!1;this.#e++,this.#a=t;let e=this.#h.at(-1),{canvas:i}=this.ctx,s=this.#p(e,"knockoutTempEntry",i.width,i.height);this.#i=s;let r=s.context;return r.save(),r.setTransform(this.ctx.getTransform()),Ue(this.ctx,r),this.#n=r.globalCompositeOperation,r.globalCompositeOperation="source-over",Oe(r,this.ctx),this.#l=e,this.#s=this.ctx,this.#r=this.suspendedCtx,this.ctx=r,this.inSMaskMode&&(this.suspendedCtx=r),!0}#m(t){if(!t)return;let e=this.#i,i=this.#s,s=this.#r,r=e.context;this.#i=null,this.#s=null,this.#r=null,this.inSMaskMode&&this.suspendedCtx===r&&this.ctx!==r&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=s),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=this.#n,this.#n=null,Ue(this.ctx,i),this.ctx=i;let n=this.#l;this.#l=null;let a=this.#a;this.#a=1;try{this.#g(s??i,e.canvas,{backdropCanvas:n?.backdropCtx?.canvas??null,backdropOffset:n?.backdropCtx?[n.offsetX,n.offsetY]:[0,0],reuseMaskEntry:n?.knockoutMaskEntry??null,poolMeta:n,knockoutAlpha:a})}finally{r.restore(),this.#e--,n||this.canvasFactory.destroy(e)}}compose(t){if(!this.current.activeSMask)return;t=t?[Math.floor(t[0]),Math.floor(t[1]),Math.ceil(t[2]),Math.ceil(t[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let e=this.current.activeSMask,i=this.suspendedCtx,s=this.#e>0&&i===this.ctx;this.composeSMask(s?null:i,e,this.ctx,t),s||(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(t[0],t[1],t[2]-t[0],t[3]-t[1]),this.ctx.restore())}composeSMask(t,e,i,s){let r=s[0],n=s[1],a=s[2]-r,o=s[3]-n;if(0===a||0===o)return;let l=this.smaskPreparedEntry;if(l){let t=r,s=n,h=a,d=o,c=this.smaskPreparedOOBAlpha,u=null!==c;if(u&&(t=Math.max(r,e.offsetX),s=Math.max(n,e.offsetY),h=Math.min(r+a,e.offsetX+e.canvas.width)-t,d=Math.min(n+o,e.offsetY+e.canvas.height)-s),h>0&&d>0){let e=t-this.smaskPreparedOffsetX,r=s-this.smaskPreparedOffsetY;i.save(),i.globalAlpha=1,i.setTransform(1,0,0,1,0,0);let n=new Path2D;n.rect(t,s,h,d),i.clip(n),i.globalCompositeOperation="destination-in",i.drawImage(l.canvas,e,r,h,d,t,s,h,d),i.restore()}u&&c<255&&this._applySMaskOOBAlpha(i,r,n,a,o,t,s,t+h,s+d,c)}else this.genericComposeSMask(e,i,a,o,r,n);t&&(t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,r,n,a,o,r,n,a,o),t.restore())}_applySMaskOOBAlpha(t,e,i,s,r,n,a,o,l,h){let d=n<o&&a<l;if(d&&n===e&&a===i&&o===e+s&&l===i+r)return;let c=new Path2D;c.rect(e,i,s,r),d&&c.rect(n,a,o-n,l-a),t.save(),t.globalAlpha=h/255,t.setTransform(1,0,0,1,0,0),t.clip(c,"evenodd"),t.globalCompositeOperation="destination-in",t.fillStyle="#000000",t.fillRect(e,i,s,r),t.restore()}genericComposeSMask(t,e,i,s,r,n){let{context:a,offsetX:o,offsetY:l}=t;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);let h=new Path2D;h.rect(r,n,i,s),e.clip(h),e.globalCompositeOperation="destination-in",e.drawImage(a.canvas,r-o,n-l,i,s,r,n,i,s),e.restore()}save(t){this.inSMaskMode&&Ue(this.ctx,this.suspendedCtx),this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){this.dependencyTracker?.restore(t),0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(Ue(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,i,s,r,n,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,i,s,r,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,s){let[r]=i;if(!s)return r||=i[0]=new Path2D,e!==b.stroke&&e!==b.closeStroke&&(this.current.tilingPatternDims=null),void this[e](t,r);if(null!==this.dependencyTracker){let i=e===b.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,s[0]-i,s[2]+i,s[1]-i,s[3]+i).recordDependencies(t,["transform"])}r instanceof Path2D||(r=i[0]=ht(r)),O.axialAlignedBoundingBox(s,st(this.ctx),this.current.minMax);let n=this.current.tilingPatternDims;if(n&&e!==b.stroke&&e!==b.closeStroke&&this.current.fillColor instanceof Ie){let t=O.intersect(this.current.clipBox,this.current.minMax);t?this.current.fillColor.updatePatternDims(t,n):this.current.tilingPatternDims=null}this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){let s=i&&this.#f(this.current.strokeAlpha),r=this.ctx,n=this.current.strokeColor;if(r.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof n&&n?.getPattern){let i=n.isModifyingCurrentTransform()?r.getTransform():null;if(r.save(),r.strokeStyle=n.getPattern(r,this,rt(r),Se,t),i){let t=new Path2D;t.addPath(e,r.getTransform().invertSelf().multiplySelf(i)),e=t}this.rescaleAndStroke(e,!1),r.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,zt),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(Se,st(this.ctx))),r.globalAlpha=this.current.fillAlpha,this.#m(s)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){let s=i&&this.#f(this.current.fillAlpha),r=this.ctx,n=this.current.fillColor,a=this.current.patternFill,o=!1,l=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(t,Gt),a){let a=this.current.tilingPatternDims,h=a&&n.canSkipPatternCanvas(a);if(h)return n.drawPattern(this,e,this.pendingEOFill,h,t),this.pendingEOFill=!1,i&&this.consumePath(t,e,l),this.current.tilingPatternDims=null,void this.#m(s);let d=n.isModifyingCurrentTransform()?r.getTransform():null;if(this.dependencyTracker?.save(t),r.save(),r.fillStyle=n.getPattern(r,this,rt(r),_e,t),d){let t=new Path2D;t.addPath(e,r.getTransform().invertSelf().multiplySelf(d)),e=t}o=!0}this.contentVisible&&null!==l&&(this.pendingEOFill?(r.fill(e,"evenodd"),this.pendingEOFill=!1):r.fill(e)),o&&(r.restore(),this.dependencyTracker?.restore(t)),i&&this.consumePath(t,e,l),this.#m(s)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){let i=this.#f(Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e),this.#m(i)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){let i=this.#f(this.current.fillAlpha);this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,Ht).recordOperation(t),this.#m(i)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Ve}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Xe}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){let e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){let{dependencyTracker:i}=this;void 0!==e&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(void 0!==e){let t=new Path2D,s=i.getTransform().invertSelf();for(let{transform:i,x:r,y:n,fontSize:a,path:o}of e)o&&t.addPath(o,new DOMMatrix(i).preMultiplySelf(s).translate(r,n).scale(a,-a));i.clip(t)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);let s=this.commonObjs.get(e),r=this.current;if(!s)throw Error(`Can't find font for ${e}`);if(r.fontMatrix=s.fontMatrix||u,0!==r.fontMatrix[0]&&0!==r.fontMatrix[3]||_("Invalid font matrix for font "+e),i<0?(i=-i,r.fontDirection=-1):r.fontDirection=1,this.current.font=s,this.current.fontSize=i,s.isType3Font)return;let n=s.loadedName||"sans-serif",a=s.systemFontInfo?.css||`"${n}", ${s.fallbackName}`,o="normal";s.black?o="900":s.bold&&(o="bold");let l=s.italic?"italic":"normal",h=i;i<16?h=16:i>100&&(h=100),this.current.fontSizeScale=i/h,this.ctx.font=`${l} ${o} ${h}px ${a}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);let{current:i}=this;i.textMatrix=e,i.textMatrixScale=Math.hypot(e[0],e[1]),i.x=i.lineX=0,i.y=i.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#y(t,e,i){let s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,r,n){let a,o=this.ctx,l=this.current,h=l.font,d=l.textRenderingMode,c=l.fontSize/l.fontSizeScale,u=3&d,p=!!(4&d),g=l.patternFill&&!h.missingFile,f=l.patternStroke&&!h.missingFile;if((h.disableFontFace||p||g||f)&&!h.missingFile&&(a=h.getPathGenerator(this.commonObjs,e)),a&&(h.disableFontFace||g||f)){let e;if(o.save(),o.translate(i,s),o.scale(c,-c),this.dependencyTracker?.recordCharacterBBox(t,o,h),0===u||2===u)if(r){e=o.getTransform(),o.setTransform(...r);let t=this.#y(a,e,r);o.fill(t)}else o.fill(a);if(1===u||2===u)if(n){e||=o.getTransform(),o.setTransform(...n);let{a:t,b:i,c:s,d:r}=e,l=O.inverseTransform(n),h=O.transform([t,i,s,r,0,0],l);O.singularValueDecompose2dScale(h,Ne),o.lineWidth*=Math.max(Ne[0],Ne[1])/c,o.stroke(this.#y(a,e,n))}else o.lineWidth/=c,o.stroke(a);o.restore()}else 0!==u&&2!==u||(o.fillText(e,i,s),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s,()=>o.measureText(e))),1!==u&&2!==u||(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s,()=>o.measureText(e)).recordDependencies(t,zt),o.strokeText(e,i,s));p&&((this.pendingTextPaths||=[]).push({transform:st(o),x:i,y:s,fontSize:c,path:a}),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s))}get isFontSubpixelAAEnabled(){let t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);let i=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let s=!1;for(let t=3;t<i.length;t+=4)if(i[t]>0&&i[t]<255){s=!0;break}return M(this,"isFontSubpixelAAEnabled",s)}showText(t,e){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,Vt).resetBBox(t),4&this.current.textRenderingMode&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());let i=this.current,s=i.font;if(s.isType3Font){let s=this.#f(i.fillAlpha);return this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t),void this.#m(s)}let r=i.fontSize;if(0===r)return void this.dependencyTracker?.recordOperation(t);let n=this.#f(i.fillAlpha),a=this.ctx,o=i.fontSizeScale,l=i.charSpacing,h=i.wordSpacing,d=i.fontDirection,c=i.textHScale*d,u=e.length,p=s.vertical,g=p?1:-1,f=s.defaultVMetrics,m=r*i.fontMatrix[0],y=0===i.textRenderingMode&&!s.disableFontFace&&!i.patternFill;a.save(),i.textMatrix&&a.transform(...i.textMatrix),a.translate(i.x,i.y+i.textRise),d>0?a.scale(c,-1):a.scale(c,1);let b,v,A=3&i.textRenderingMode,w=0===A||2===A,x=1===A||2===A,_=i.lineWidth,S=i.textMatrixScale;if(0===S||0===_?x&&(_=this.getSinglePixelWidth()):_/=S,1!==o&&(a.scale(o,o),_/=o),a.lineWidth=_,w&&i.patternFill){a.save();let e=i.fillColor.getPattern(a,this,rt(a),_e,t);b=st(a),a.restore(),a.fillStyle=e}if(x&&i.patternStroke){a.save();let e=i.strokeColor.getPattern(a,this,rt(a),Se,t);v=st(a),a.restore(),a.strokeStyle=e}if(s.isInvalidPDFjsFont){let s=[],r=0;for(let t of e)s.push(t.unicode),r+=t.width;let o=s.join("");if(a.fillText(o,0,0),null!==this.dependencyTracker){let e=a.measureText(o);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}return i.x+=r*m*c,a.restore(),this.compose(),void this.#m(n)}let C,M=0;for(C=0;C<u;++C){let i=e[C];if("number"==typeof i){M+=g*i*r/1e3;continue}let n,c,u,A=!1,w=(i.isSpace?h:0)+l,x=i.fontChar,_=i.accent,S=i.width;if(p){let t=i.vmetric||f,e=-(i.vmetric?t[1]:.5*S)*m,s=t[2]*m;S=t?-t[0]:S,n=e/o,c=(M+s)/o}else n=M/o,c=0;if(s.remeasure&&S>0){u=a.measureText(x);let t=1e3*u.width/r*o;if(S<t&&this.isFontSubpixelAAEnabled){let e=S/t;A=!0,a.save(),a.scale(e,1),n/=e}else S!==t&&(n+=(S-t)/2e3*r/o)}if(this.contentVisible&&(i.isInFont||s.missingFile))if(y&&!_)a.fillText(x,n,c),this.dependencyTracker?.recordCharacterBBox(t,a,u?{bbox:null}:s,r/o,n,c,()=>u??a.measureText(x));else if(this.paintChar(t,x,n,c,b,v),_){let e=n+r*_.offset.x/o,i=c-r*_.offset.y/o;this.paintChar(t,_.fontChar,e,i,b,v)}M+=p?S*m-w*d:S*m+w*d,A&&a.restore()}p?i.y-=M:i.x+=M*c,a.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t),this.#m(n)}showType3Text(t,e){let i,s,r,n,a=this.ctx,o=this.current,l=o.font,h=o.fontSize,d=o.fontDirection,c=l.vertical?1:-1,p=o.charSpacing,g=o.wordSpacing,f=o.textHScale*d,m=o.fontMatrix||u,y=e.length;if(3===o.textRenderingMode||0===h)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,a.save(),o.textMatrix&&a.transform(...o.textMatrix),a.translate(o.x,o.y+o.textRise),a.scale(f,d);let b=this.dependencyTracker;for(this.dependencyTracker=b?new Ut(b,t):null,i=0;i<y;++i){if(s=e[i],"number"==typeof s){n=c*s*h/1e3,this.ctx.translate(n,0),o.x+=n*f;continue}let t=(s.isSpace?g:0)+p,d=l.charProcOperatorList[s.operatorListId];d?this.contentVisible&&(this.save(),a.scale(h,h),a.transform(...m),this.executeOperatorList(d),this.restore()):_(`Type3 character "${s.operatorListId}" is not available.`);let u=[s.width,0];O.applyTransform(u,m),r=u[0]*h+t,a.translate(r,0),o.x+=r*f}a.restore(),b&&(this.dependencyTracker=b)}setCharWidth(t,e,i){}setCharWidthAndBounds(t,e,i,s,r,n,a){let o=new Path2D;o.rect(s,r,n-s,a-r),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,s,n,r,a).recordClipBox(t,this.ctx,s,n,r,a),this.endPath(t)}getColorN_Pattern(t,e){let i;if("TilingPattern"===e[0]){let t=this.baseTransform||st(this.ctx);i=new Ie(e,this.ctx,{createCanvasGraphics:(t,e)=>new qe(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Ut(this.dependencyTracker,e,!0):null)},t)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t);let i=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=i instanceof Ie?[0,0,0,0]:null}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,i=null){let s;return this.cachedPatterns.has(e)?s=this.cachedPatterns.get(e):(s=function(t){switch(t[0]){case"RadialAxial":return new Pe(t);case"Mesh":return new Ee(t);case"Dummy":return new De}throw Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e)),this.cachedPatterns.set(e,s)),i&&(s.matrix=i),s}shadingFill(t,e){if(!this.contentVisible)return;let i=this.#f(this.current.fillAlpha),s=this.ctx;this.save(t),s.fillStyle=this._getPattern(t,e).getPattern(s,this,rt(s),Ce,t);let r=rt(s);if(r){let{width:t,height:e}=s.canvas,i=c.slice();O.axialAlignedBoundingBox([0,0,t,e],r,i);let[n,a,o,l]=i;this.ctx.fillRect(n,a,o-n,l-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Xt).recordDependencies(t,Gt).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),this.#m(i)}beginInlineImage(){S("Should not call beginInlineImage")}beginImageData(){S("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=st(this.ctx),i)){O.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);let[e,s,r,n]=i,a=new Path2D;a.rect(e,s,r-e,n-s),this.ctx.clip(a),this.dependencyTracker?.recordClipBox(t,this.ctx,e,r,s,n),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){if(!this.contentVisible)return;this.save(t);let{inSMaskMode:i}=this;i&&(this.endSMaskMode(),this.current.activeSMask=null);let s=this.ctx;if(e.isolated||e.knockout||0!==this.#t||x("TODO: Fully support non-isolated non-knockout groups."),!e.needsIsolation&&!e.knockout&&0===this.#t&&1===s.globalAlpha&&"source-over"===s.globalCompositeOperation&&!i){if(e.bbox){let t=new Path2D,[i,r,n,a]=e.bbox;if(t.rect(i,r,n-i,a-r),e.matrix){let i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix)),t=i}s.clip(t)}return this.groupStack.push(null),this.#h.push(null),void this.groupLevel++}let r=st(s);e.matrix&&s.transform(...e.matrix);let n,a=[0,0,s.canvas.width,s.canvas.height];e.bbox?(n=c.slice(),O.axialAlignedBoundingBox(e.bbox,st(s),n),n=O.intersect(n,a)||[0,0,0,0]):n=a;let o=Math.floor(n[0]),l=Math.floor(n[1]),h=Math.max(Math.ceil(n[2])-o,1),d=Math.max(Math.ceil(n[3])-l,1);this.current.startNewPathAndClipBox([0,0,h,d]);let u=this.canvasFactory.create(h,d);e.smask&&this.smaskGroupCanvases.push(u);let p=u.context,g=e.knockout&&!e.isolated?s:null,f=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&this.#t>0,m=e.knockout?this.canvasFactory.create(h,d):null,y=this.#t;if(e.knockout?this.#t++:this.#t=0,p.translate(-o,-l),p.transform(...r),!e.isolated&&!e.smask&&i&&e.needsIsolation&&(p.save(),p.setTransform(1,0,0,1,0,0),p.drawImage(s.canvas,-o,-l),p.restore()),e.bbox){let t=new Path2D,[i,s,r,n]=e.bbox;if(t.rect(i,s,r-i,n-s),e.matrix){let i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix)),t=i}p.clip(t)}e.smask&&this.smaskStack.push({canvas:u.canvas,context:p,offsetX:o,offsetY:l,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null}),e.smask&&!this.dependencyTracker||(s.setTransform(1,0,0,1,0,0),s.translate(o,l),s.save()),Ue(s,p),this.ctx=p,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(s),this.#h.push({backdropCtx:g,savedKnockoutLevel:y,offsetX:o,offsetY:l,hasInnerBackdrop:f,knockoutMaskEntry:m,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;let i=this.ctx,s=this.groupStack.pop(),r=this.#h.pop();if(r&&(this.#t=r.savedKnockoutLevel),null!==s)if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),this.#b(r);else{this.ctx.restore();let e=st(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);let n=c.slice();O.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],e,n);let a=this.#h.at(-1);if(this.#t>0)if(r.hasInnerBackdrop){let{width:t,height:n}=i.canvas,a=this.canvasFactory.create(t,n),o=a.context;o.drawImage(s.canvas,r.offsetX,r.offsetY,t,n,0,0,t,n),o.globalCompositeOperation="source-over",o.drawImage(i.canvas,0,0);let l=this.#u(i.canvas);o.globalCompositeOperation="destination-in",o.drawImage(l.canvas,0,0);let h=this.ctx.globalCompositeOperation,d=this.ctx.globalAlpha,c=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...e),this.ctx.globalAlpha=1,N.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(l.canvas,0,0),this.ctx.globalCompositeOperation=h,this.ctx.globalAlpha=d,N.isCanvasFilterSupported&&(this.ctx.filter=c??"none"),this.ctx.drawImage(a.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(l),this.canvasFactory.destroy(a)}else{let t=a?.backdropCtx??null;this.#g(this.ctx,i.canvas,{backdropCanvas:t?.canvas??null,destTransform:e,backdropOffset:t?[a.offsetX+r.offsetX,a.offsetY+r.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else this.ctx.drawImage(i.canvas,0,0);this.ctx.restore(),this.canvasFactory.destroy({canvas:i.canvas,context:i}),this.#b(r),this.compose(n)}else this.restore(t)}#b(t){t&&(t.knockoutMaskEntry&&(this.canvasFactory.destroy(t.knockoutMaskEntry),t.knockoutMaskEntry=null),t.knockoutTempEntry&&(this.canvasFactory.destroy(t.knockoutTempEntry),t.knockoutTempEntry=null),t.knockoutBackdropEntry&&(this.canvasFactory.destroy(t.knockoutBackdropEntry),t.knockoutBackdropEntry=null))}beginAnnotation(t,e,i,s,r,n){if(this.#d(),ze(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){let r=i[2]-i[0],a=i[3]-i[1];if(n&&this.annotationCanvasMap){(s=s.slice())[4]-=i[0],s[5]-=i[1],(i=i.slice())[0]=i[1]=0,i[2]=r,i[3]=a,O.singularValueDecompose2dScale(st(this.ctx),Ne);let{viewportScale:t}=this,n=Math.ceil(r*this.outputScaleX*t),o=Math.ceil(a*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(n,o);let{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(Ne[0],0,0,-Ne[1],0,a*Ne[1]),ze(this.ctx)}else{ze(this.ctx),this.endPath(t);let e=new Path2D;e.rect(i[0],i[1],r,a),this.ctx.clip(e)}}this.current=new Le(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...s),this.transform(t,...r),this.baseTransform=st(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#c(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){if(!this.contentVisible)return;let i=e.count;(e=this.getObject(t,e.data,e)).count=i;let s=this.#f(this.current.fillAlpha),r=this.ctx,n=this._createMaskCanvas(t,e),a=n.canvas;r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(a,n.offsetX,n.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,n.offsetX,n.offsetX+a.width,n.offsetY,n.offsetY+a.height).recordOperation(t),r.restore(),n.canvasEntry&&this.canvasFactory.destroy(n.canvasEntry),this.compose(),this.#m(s)}paintImageMaskXObjectRepeat(t,e,i,s=0,r=0,n,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);let o=this.#f(this.current.fillAlpha),l=this.ctx;l.save();let h=st(l);l.transform(i,s,r,n,0,0);let d=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,d.offsetX-h[4],d.offsetY-h[5]),this.dependencyTracker?.resetBBox(t);for(let e=0,o=a.length;e<o;e+=2){let o=O.transform(h,[i,s,r,n,a[e],a[e+1]]);l.drawImage(d.canvas,o[4],o[5]),this.dependencyTracker?.recordBBox(t,this.ctx,o[4],o[4]+d.canvas.width,o[5],o[5]+d.canvas.height)}l.restore(),d.canvasEntry&&this.canvasFactory.destroy(d.canvasEntry),this.compose(),this.dependencyTracker?.recordOperation(t),this.#m(o)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;let i=this.#f(this.current.fillAlpha),s=this.ctx,r=this.current.fillColor,n=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,qt);for(let i of e){let{data:e,width:a,height:o,transform:l}=i,h=this.canvasFactory.create(a,o),d=h.context;d.save(),$e(d,this.getObject(t,e,i)),d.globalCompositeOperation="source-in",d.fillStyle=n?r.getPattern(d,this,rt(s),_e,t):r,d.fillRect(0,0,a,o),d.restore(),s.save(),s.transform(...l),s.scale(1,-1),Be(s,h.canvas,0,0,a,o,0,-1,1,1),this.canvasFactory.destroy(h),this.dependencyTracker?.recordBBox(t,s,0,a,0,o),s.restore()}this.compose(),this.dependencyTracker?.recordOperation(t),this.#m(i)}paintImageXObject(t,e){if(!this.contentVisible)return;let i=this.getObject(t,e);i?this.paintInlineImageXObject(t,i):_("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s,r){if(!this.contentVisible)return;let n=this.getObject(t,e);if(!n)return void _("Dependent image isn't ready yet");let a=n.width,o=n.height,l=[];for(let t=0,e=r.length;t<e;t+=2)l.push({transform:[i,0,0,s,r[t],r[t+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,n,l)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return{img:t.bitmap,canvasEntry:null};let{bitmap:e,width:i,height:s}=t,r=this.canvasFactory.create(i,s),n=r.context;return n.filter=this.current.transferMaps,n.drawImage(e,0,0),n.filter="none",{img:r.canvas,canvasEntry:r}}paintInlineImageXObject(t,e){if(!this.contentVisible)return;let i=e.width,s=e.height,r=this.#f(this.current.fillAlpha),n=this.ctx;this.save(t);let{filter:a}=n;"none"!==a&&""!==a&&(n.filter="none"),n.scale(1/i,-1/s);let o,l=null;if(e.bitmap){let t=this.applyTransferMapsToBitmap(e);o=t.img,l=t.canvasEntry}else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)o=e;else{let t=this.canvasFactory.create(i,s);je(t.context,e),o=this.applyTransferMapsToCanvas(t.context),l=t}let h=this._scaleImage(o,rt(n));n.imageSmoothingEnabled=Ge(st(n),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,n,0,i,-s,0).recordDependencies(t,Wt).recordOperation(t),this.imagesTracker?.record(n,i,s,this.dependencyTracker.clipBox)),Be(n,h.img,0,0,h.paintWidth,h.paintHeight,0,-s,i,s),h.tmpCanvas&&this.canvasFactory.destroy(h.tmpCanvas),l&&this.canvasFactory.destroy(l),this.compose(),this.restore(t),this.#m(r)}paintInlineImageXObjectGroup(t,e,i){if(!this.contentVisible)return;let s,r=this.#f(this.current.fillAlpha),n=this.ctx,a=null;if(e.bitmap)s=e.bitmap;else{let t=e.width,i=e.height,r=this.canvasFactory.create(t,i);je(r.context,e),s=this.applyTransferMapsToCanvas(r.context),a=r}this.dependencyTracker?.resetBBox(t);for(let e of i)n.save(),n.transform(...e.transform),n.scale(1,-1),Be(n,s,e.x,e.y,e.w,e.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,n,0,1,-1,0),n.restore();a&&this.canvasFactory.destroy(a),this.dependencyTracker?.recordOperation(t),this.compose(),this.#m(r)}paintSolidColorImageMask(t){if(!this.contentVisible)return;let e=this.#f(this.current.fillAlpha);this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Gt).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),this.#m(e)}markPoint(t,e){}markPointProps(t,e,i){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){this.dependencyTracker?.beginMarkedContent(t),"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){let s=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);let r=this.ctx;this.pendingClip?(s||(this.pendingClip===Xe?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let t=st(this.ctx);if(0===t[1]&&0===t[2])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]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){let t,e,{lineWidth:i}=this.current,{a:s,b:r,c:n,d:a}=this.ctx.getTransform();if(0===r&&0===n){let r=Math.abs(s),n=Math.abs(a);if(r===n)if(0===i)t=e=1/r;else{let s=r*i;t=e=s<1?1/s:1}else if(0===i)t=1/r,e=1/n;else{let s=r*i,a=n*i;t=s<1?1/s:1,e=a<1?1/a:1}}else{let o=Math.abs(s*a-r*n),l=Math.hypot(s,r),h=Math.hypot(n,a);if(0===i)t=h/o,e=l/o;else{let s=i*o;t=h>s?h/s:1,e=l>s?l/s:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t,e){let{ctx:i,current:{lineWidth:s}}=this,[r,n]=this.getScaleForStroking();if(r===n)return i.lineWidth=(s||1)*r,void i.stroke(t);let a=i.getLineDash();e&&i.save(),i.scale(r,n),Re.a=1/r,Re.d=1/n;let o=new Path2D;if(o.addPath(t,Re),a.length>0){let t=Math.max(r,n);i.setLineDash(a.map(e=>e/t)),i.lineDashOffset/=t}i.lineWidth=s||1,i.stroke(o),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(let t in b)void 0!==qe.prototype[t]&&(qe.prototype[b[t]]=qe.prototype[t]);class Ye{#t=null;#e=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,i){this._source=t,this.#t=e,this.#e=i}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return C(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#t(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new this.#e(this,t,e);return this._rangeReaders.add(i),i}cancelAllRequests(t){this._fullReader?.cancel(t);for(let e of new Set(this._rangeReaders))e.cancel(t)}}class Ke{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(t){this._stream=t}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){S("Abstract method `read` called")}cancel(t){S("Abstract method `cancel` called")}}class Ze{_stream=null;constructor(t,e,i){this._stream=t}async read(){S("Abstract method `read` called")}cancel(t){S("Abstract method `cancel` called")}}function Je(t,e){let i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(let t in e){let s=e[t];void 0!==s&&i.append(t,s)}return i}function Qe(t){return URL.parse(t)?.origin??null}function ti({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){let r={contentLength:0,isRangeSupported:!1},n=parseInt(t.get("Content-Length"),10);return Number.isInteger(n)?(r.contentLength=n,n<=2*i||s||!e||"bytes"!==t.get("Accept-Ranges")||"identity"===(t.get("Content-Encoding")||"identity")&&(r.isRangeSupported=!0),r):r}function ei(t){let e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){i=i[1];let t=a(i);return t=unescape(t),t=o(t),t=l(t),n(t)}if(i=function(t){let e,i=[],r=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(e=r.exec(t));){let[,t,s,r]=e;if(t=parseInt(t,10),t in i){if(0===t)break}else i[t]=[s,r]}let n=[];for(let t=0;t<i.length&&t in i;++t){let[e,s]=i[t];s=a(s),e&&(s=unescape(s),0===t&&(s=o(s))),n.push(s)}return n.join("")}(t),i)return n(l(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=a(i);return t=l(t),n(t)}function s(t,e){return RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function r(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{let s=new TextDecoder(t,{fatal:!0}),r=R(i);i=s.decode(r),e=!1}catch{}}return i}function n(t){return e&&/[\x80-\xff]/.test(t)&&(t=r("utf-8",t),e&&(t=r("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){let e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){let i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){let e=t.indexOf("'");return-1===e?t:r(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,i,s){if("q"===i||"Q"===i)return r(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{s=atob(s)}catch{}return r(e,s)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(Y(t))return t}return null}function ii(t,e){return new D(`Unexpected server response (${t}) while retrieving PDF "${e.href}".`,t,404===t||0===t&&"file:"===e.protocol)}function si(t,e){if(t!==e)throw Error(`Expected range response-origin "${t}" to match "${e}".`)}function ri(t,e,i,s){return fetch(t,{method:"GET",headers:e,signal:s.signal,mode:"cors",credentials:i?"include":"same-origin",redirect:"follow"})}function ni(t,e){if(200!==t&&206!==t)throw ii(t,e)}function ai(t){if(t instanceof Uint8Array)return t.buffer;if(t instanceof ArrayBuffer)return t;throw Error(`getArrayBuffer - unexpected data: ${t}`)}class oi extends Ye{_responseOrigin=null;constructor(t){super(t,li,hi);let{httpHeaders:e,url:i}=t;C(/https?:/.test(i.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=Je(!0,e)}}class li extends Ke{_abortController=new AbortController;_reader=null;constructor(t){super(t);let{disableRange:e,disableStream:i,rangeChunkSize:s,url:r,withCredentials:n}=t._source;this._isStreamingSupported=!i,ri(r,new Headers(t.headers),n,this._abortController).then(i=>{t._responseOrigin=Qe(i.url),ni(i.status,r),this._reader=i.body.getReader();let n=i.headers,{contentLength:a,isRangeSupported:o}=ti({responseHeaders:n,isHttp:!0,rangeChunkSize:s,disableRange:e});this._contentLength=a,this._isRangeSupported=o,this._filename=ei(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new F("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:ai(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class hi extends Ze{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);let{url:s,withCredentials:r}=t._source,n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`),ri(s,n,r,this._abortController).then(e=>{si(Qe(e.url),t._responseOrigin),ni(e.status,s),this._reader=e.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:ai(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}function di(t){return t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer}function ci(){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}class ui extends Ye{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,pi,gi);let{pdfDataRangeTransport:e}=t,{initialData:i,progressiveDone:s}=e;if(i?.length>0){let t=di(i);this._queuedChunks.push(t)}this._progressiveDone=s,e.transportReady(t=>{switch(t.type){case"range":case"progressiveRead":this.#t(t.begin,t.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone(),this._progressiveDone=!0}})}#t(t,e){let i=di(e);if(void 0===t)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{let e=this._rangeReaders.keys().find(e=>e._begin===t);C(e,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),e._enqueue(i)}}getFullReader(){let t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){let i=super.getRangeReader(t,e);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(t,e)),i}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class pi extends Ke{#t=ci.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);let{pdfDataRangeTransport:e,disableRange:i,disableStream:s}=t._source,{length:r,contentDispositionFilename:n}=e;this._queuedChunks=t._queuedChunks||[];for(let t of this._queuedChunks)this._loaded+=t.byteLength;this._done=t._progressiveDone,this._contentLength=r,this._isStreamingSupported=!s,this._isRangeSupported=!i,Y(n)&&(this._filename=n),this._headersCapability.resolve();let a=this._loaded;Promise.resolve().then(()=>{a>0&&this._loaded===a&&this._callOnProgress()})}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength,this._callOnProgress())}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t()}progressiveDone(){this._done||=!0,0===this._queuedChunks.length&&this.#t()}}class gi extends Ze{#t=ci.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,i){super(t,e,i),this._begin=e}_enqueue(t){this._done||(0===this._requests.length?this._queuedChunk=t:(this._requests.shift().resolve({value:t,done:!1}),this.#t()),this._done=!0,this.onDone?.())}async read(){if(this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this.onDone?.()}}class fi extends Ye{#t=new WeakMap;_responseOrigin=null;constructor(t){super(t,mi,yi);let{httpHeaders:e,url:i}=t;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=Je(this.isHttp,e)}_request(t){let e=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};this.#t.set(e,i),e.open("GET",this.url),e.withCredentials=this._source.withCredentials;for(let[t,i]of this.headers)e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.validateStatus=t=>206===t||200===t):i.validateStatus=t=>200===t,e.responseType="arraybuffer",C(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#i.bind(this,e),e.onprogress=this.#e.bind(this,e),e.send(null),e}#e(t,e){this.#t.get(t)?.onProgress?.(e)}#i(t,e){let i=this.#t.get(t);if(!i)return;if(t.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==t.readyState)return;if(!this.#t.has(t))return;if(this.#t.delete(t),0===t.status&&this.isHttp)return void i.onError(t.status);let s=t.status||200;if(!i.validateStatus(s))return void i.onError(t.status);let r=function(t){return"string"==typeof t?R(t).buffer:t}(t.response);if(206===s){let e=t.getResponseHeader("Content-Range");/bytes (\d+)-(\d+)\/(\d+)/.test(e)?i.onDone(r):(_('Missing or invalid "Content-Range" header.'),i.onError(0))}else r?i.onDone(r):i.onError(t.status)}_abortRequest(t){this.#t.has(t)&&(this.#t.delete(t),t.abort())}getRangeReader(t,e){let i=super.getRangeReader(t,e);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}class mi extends Ke{#t=ci.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t),this._fullRequestXhr=t._request({onHeadersReceived:this.#e.bind(this),onDone:this.#i.bind(this),onError:this.#s.bind(this),onProgress:this.#r.bind(this)})}#e(){let t=this._stream,{disableRange:e,rangeChunkSize:i}=t._source,s=this._fullRequestXhr;t._responseOrigin=Qe(s.responseURL);let r=s.getAllResponseHeaders(),n=new Headers(r?r.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{let[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{contentLength:a,isRangeSupported:o}=ti({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:i,disableRange:e});this._contentLength=a,this._isRangeSupported=o,this._filename=ei(n),this._isRangeSupported&&t._abortRequest(s),this._headersCapability.resolve()}#i(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._cachedChunks.push(t),this._done=!0,0===this._cachedChunks.length&&this.#t()}#s(t){this._storedError=ii(t,this._stream.url),this._headersCapability.reject(this._storedError);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#r(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t),this.#t(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class yi extends Ze{#t=ci.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,i){super(t,e,i),this._requestXhr=t._request({begin:e,end:i,onHeadersReceived:this.#e.bind(this),onDone:this.#i.bind(this),onError:this.#s.bind(this),onProgress:null})}#e(){let t=Qe(this._requestXhr?.responseURL);try{si(t,this._stream._responseOrigin)}catch(t){this._storedError=t,this.#s(0)}}#i(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0,this.#t(),this.onClosed?.()}#s(t){this._storedError??=ii(t,this._stream.url);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function bi(t,e=null){let i=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),r=i.createReadStream(t,e);return s.toWeb(r)}class vi extends Ye{constructor(t){super(t,Ai,wi);let{url:e}=t;C("file:"===e.protocol,"PDFNodeStream only supports file:// URLs.")}}class Ai extends Ke{_reader=null;constructor(t){super(t);let{disableRange:e,disableStream:i,rangeChunkSize:s,url:r}=t._source;this._isStreamingSupported=!i,process.getBuiltinModule("fs/promises").lstat(r).then(t=>{let i=bi(r);this._reader=i.getReader();let{size:n}=t;this._contentLength=n,this._isRangeSupported=!e&&n>2*s,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new F("Streaming is disabled.")),this._headersCapability.resolve()}).catch(t=>{"ENOENT"===t.code&&(t=ii(0,r)),this._headersCapability.reject(t)})}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._callOnProgress(),{value:ai(t),done:!1})}cancel(t){this._reader?.cancel(t)}}class wi extends Ze{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);let{url:s}=t._source;try{let t=bi(s,{start:e,end:i-1});this._reader=t.getReader(),this._readCapability.resolve()}catch(t){this._readCapability.reject(t)}}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:ai(t),done:!1}}cancel(t){this._reader?.cancel(t)}}class xi{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&null!==t)throw Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if("string"!=typeof t)throw Error("Invalid `workerSrc` type.");this.#e=t}}class _i{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}[Symbol.iterator](){return this.#t.entries()}}const Si=Symbol("INTERNAL");class Ci{#t=!1;#e=!1;#i=!1;#s=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:r}){this.#t=!!(2&t),this.#e=!!(4&t),this.name=e,this.intent=i,this.usage=s,this.rbGroups=r}get visible(){if(this.#i)return this.#s;if(!this.#s)return!1;let{print:t,view:e}=this.usage;return this.#t?"OFF"!==e?.viewState:!this.#e||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==Si&&S("Internal method `_setVisible` called."),this.#i=i,this.#s=e}}class Mi{#t=null;#e=new Map;#i=null;#s=null;constructor(t,e=2){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#s=t.order;for(let i of t.groups)this.#e.set(i.id,new Ci(e,i));if("OFF"===t.baseState)for(let t of this.#e.values())t._setVisible(Si,!1);for(let e of t.on)this.#e.get(e)._setVisible(Si,!0);for(let e of t.off)this.#e.get(e)._setVisible(Si,!1);this.#i=this.getHash()}}#r(t){let e=t.length;if(e<2)return!0;let i=t[0];for(let s=1;s<e;s++){let e,r=t[s];if(Array.isArray(r))e=this.#r(r);else{if(!this.#e.has(r))return _(`Optional content group not found: ${r}`),!0;e=this.#e.get(r).visible}switch(i){case"And":if(!e)return!1;break;case"Or":if(e)return!0;break;case"Not":return!e;default:return!0}}return"And"===i}isVisible(t){if(0===this.#e.size)return!0;if(!t)return x("Optional content group not defined."),!0;if("OCG"===t.type)return this.#e.has(t.id)?this.#e.get(t.id).visible:(_(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#r(t.expression);if(!t.policy||"AnyOn"===t.policy){for(let e of t.ids){if(!this.#e.has(e))return _(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(let e of t.ids){if(!this.#e.has(e))return _(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(let e of t.ids){if(!this.#e.has(e))return _(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(let e of t.ids){if(!this.#e.has(e))return _(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return _(`Unknown optional content policy ${t.policy}.`),!0}return _(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){let s=this.#e.get(t);if(s){if(i&&e&&s.rbGroups.length)for(let e of s.rbGroups)for(let i of e)i!==t&&this.#e.get(i)?._setVisible(Si,!1,!0);s._setVisible(Si,!!e,!0),this.#t=null}else _(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(let s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}let t=this.#e.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#t=null}get hasInitialVisibility(){return null===this.#i||this.getHash()===this.#i}getOrder(){return this.#e.size?this.#s?this.#s.slice():[...this.#e.keys()]:null}getGroup(t){return this.#e.get(t)||null}getHash(){if(null!==this.#t)return this.#t;let t=new Pt;for(let[e,i]of this.#e)t.update(`${e}:${i.visible}`);return this.#t=t.hexdigest()}[Symbol.iterator](){return this.#e.entries()}}class ki{#t=null;#e=null;#i=0;#s=null;#r=null;get pagesNumber(){return this.#i}set pagesNumber(t){this.#i!==t&&(this.#i=t,this.#t=null,this.#e=null)}#n(){if(this.#t)return;let t=this.#i,e=this.#t=new Uint32Array(t);for(let i=0;i<t;i++)e[i]=i+1;this.#e=new Int32Array(e)}#a(){let t=new Map,e=this.#t;for(let i=0,s=this.#i;i<s;i++){let s=e[i],r=t.get(s);r?r.push(i+1):t.set(s,[i+1])}return t}movePages(t,e,i){this.#n();let s=this.#t,r=this.#a(),n=e.length,a=new Uint32Array(n),o=0;for(let t=0;t<n;t++){let r=e[t]-1;a[t]=s[r],r<i&&o++}let l=this.#i,h=l-n,d=$(i-o,0,h);for(let e=0,i=0;e<l;e++)t.has(e+1)||(s[i++]=s[e]);s.copyWithin(d+n,d,h),s.set(a,d),this.#o(r),s.every((t,e)=>t===e+1)&&(this.#t=null)}deletePages(t){this.#n();let e=this.#t,i=this.#a();this.#r={pageNumberToId:e.slice(),pagesNumber:this.#i,prevPageNumbers:this.#e.slice()};let s=this.#i-t.length;this.#i=s;let r=this.#t=new Uint32Array(s);this.#e=new Int32Array(s);let n=0,a=0;for(let i of t){let t=i-1;t!==n&&(r.set(e.subarray(n,t),a),a+=t-n),n=t+1}n<e.length&&r.set(e.subarray(n),a),this.#o(i,new Set(t))}cancelDelete(){this.#r&&(this.#t=this.#r.pageNumberToId,this.#i=this.#r.pagesNumber,this.#e=this.#r.prevPageNumbers,this.#r=null)}cleanSavedData(){this.#r=null}copyPages(t){this.#n(),this.#s={pageNumbers:t,pageIds:t.map(t=>this.#t[t-1])}}cancelCopy(){this.#s=null}pastePages(t){this.#n();let e=this.#t,i=this.#a(),{pageNumbers:s,pageIds:r}=this.#s,n=this.#i+s.length;this.#i=n;let a=this.#t=new Uint32Array(n);this.#e=new Int32Array(n),a.set(e.subarray(0,t),0),a.set(r,t),a.set(e.subarray(t),t+s.length),this.#o(i,null,t,s),this.#s=null}#o(t,e=null,i=-1,s=null){let r=this.#e,n=this.#t,a=i+(s?.length??0),o=new Map;for(let l=0,h=this.#i;l<h;l++){if(l>=i&&l<a){r[l]=-s[l-i];continue}let h=n[l],d=t.get(h),c=o.get(h)||0;if(e&&d)for(;c<d.length&&e.has(d[c]);)c++;r[l]=d?.[c],o.set(h,c+1)}}hasBeenAltered(){return null!==this.#t}getPageMappingForSaving(t=null){t??=this.#a();let e=0;for(let i of t.values())e=Math.max(e,i.length);let i=Array(e);for(let t=0;t<e;t++)i[t]={document:null,pageIndices:[],includePages:[]};for(let[e,s]of t)for(let t=0,r=s.length;t<r;t++)i[t].includePages.push([e-1,s[t]-1]);for(let{includePages:t,pageIndices:e}of i){t.sort((t,e)=>t[0]-e[0]);for(let i=0,s=t.length;i<s;i++)e.push(t[i][1]),t[i]=t[i][0]}return i}extractPages(t){t=Array.from(t).sort((t,e)=>t-e);let e=new Map;for(let i=0,s=t.length;i<s;i++){let s=this.getPageId(t[i]);e.getOrInsertComputed(s,B).push(i+1)}return this.getPageMappingForSaving(e)}getPrevPageNumber(t){return this.#e?.[t-1]??0}getPageNumber(t){if(!this.#t)return t;let e=this.#t;for(let i=0,s=this.#i;i<s;i++)if(e[i]===t)return i+1;return 0}getPageId(t){return this.#t?.[t-1]??t}getMapping(){return this.#t?.subarray(0,this.pagesNumber)}}const Pi=Symbol("INITIAL_DATA"),Ti=()=>({...Promise.withResolvers(),data:Pi});class Ei{#t=new Map;get(t,e=null){if(e){let i=this.#t.getOrInsertComputed(t,Ti);return i.promise.then(()=>e(i.data)),null}let i=this.#t.get(t);if(!i||i.data===Pi)throw Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){let e=this.#t.get(t);return!!e&&e.data!==Pi}delete(t){let e=this.#t.get(t);return!(!e||e.data===Pi||(this.#t.delete(t),0))}resolve(t,e=null){let i=this.#t.getOrInsertComputed(t,Ti);if(i.data!==Pi)throw Error(`Object already resolved ${t}.`);i.data=e,i.resolve()}clear(){for(let{data:t}of this.#t.values())t?.bitmap?.close();this.#t.clear()}*[Symbol.iterator](){for(let[t,{data:e}]of this.#t)e!==Pi&&(yield[t,e])}}class Di{#t=Promise.withResolvers();#e=null;#i=!1;#s=!!globalThis.FontInspector?.enabled;#r=null;#n=null;#a=null;#o=0;#l=0;#h=null;#d=null;#c=0;#u=0;#p=Object.create(null);#g=[];#f=null;#m=[];#y=new WeakMap;#b=null;static#v=new Map;static#A=new Map;static#w=new WeakMap;static#x=null;static#_=new Set;constructor({textContentSource:t,images:e,container:i,viewport:s}){if(t instanceof ReadableStream)this.#f=t;else{if("object"!=typeof t)throw Error('No "textContentSource" parameter specified.');this.#f=new ReadableStream({start(e){e.enqueue(t),e.close()}})}this.#e=this.#d=i,this.#r=e,this.#u=s.scale*at.pixelRatio,this.#c=s.rotation,this.#a={div:null,properties:null,ctx:null};let{pageWidth:r,pageHeight:n,pageX:a,pageY:o}=s.rawDims;this.#b=[1,0,0,-1,-a,o+n],this.#l=r,this.#o=n,Di.#T(),i.style.setProperty("--min-font-size",Di.#x),nt(i,s),this.#t.promise.finally(()=>{Di.#_.delete(this),this.#a=null,this.#p=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=N.platform;return M(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){this.#r&&this.#e.append(this.#r.render());let t=()=>{this.#h.read().then(({value:e,done:i})=>{i?this.#t.resolve():(this.#n??=e.lang,Object.assign(this.#p,e.styles),this.#S(e.items),t())},this.#t.reject)};return this.#h=this.#f.getReader(),Di.#_.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){let i=t.scale*at.pixelRatio,s=t.rotation;if(s!==this.#c&&(e?.(),this.#c=s,nt(this.#d,{rotation:s})),i!==this.#u){e?.(),this.#u=i;let t={div:null,properties:null,ctx:Di.#k(this.#n)};for(let e of this.#m)t.properties=this.#y.get(e),t.div=e,this.#M(t)}}cancel(){let t=new F("TextLayer task cancelled.");this.#h?.cancel(t).catch(()=>{}),this.#h=null,this.#t.reject(t)}get textDivs(){return this.#m}get textContentItemsStr(){return this.#g}#S(t){if(this.#i)return;this.#a.ctx??=Di.#k(this.#n);let e=this.#m,i=this.#g;for(let s of t){if(e.length>1e5)return _("Ignoring additional textDivs for performance reasons."),void(this.#i=!0);if(void 0!==s.str)i.push(s.str),this.#C(s);else if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){let t=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),s.id&&this.#e.setAttribute("id",`${s.id}`),"Artifact"===s.tag&&(this.#e.ariaHidden=!0),t.append(this.#e)}else"endMarkedContent"===s.type&&(this.#e=this.#e.parentNode)}}#C(t){let e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#m.push(e);let s=O.transform(this.#b,t.transform),r=Math.atan2(s[1],s[0]),n=this.#p[t.fontName];n.vertical&&(r+=Math.PI/2);let a=this.#s&&n.fontSubstitution||n.fontFamily;a=Di.fontFamilyMap.get(a)||a;let o,l,h=Math.hypot(s[2],s[3]),d=h*Di.#E(a,n,this.#n);0===r?(o=s[4],l=s[5]-d):(o=s[4]+d*Math.sin(r),l=s[5]-d*Math.cos(r));let c=e.style;c.left=`${(100*o/this.#l).toFixed(2)}%`,c.top=`${(100*l/this.#o).toFixed(2)}%`,c.setProperty("--font-height",`${h.toFixed(2)}px`),c.fontFamily=a,i.fontSize=h,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#s&&(e.dataset.fontName=n.fontSubstitutionLoadedName||t.fontName),0!==r&&(i.angle=180/Math.PI*r);let u=!1;if(t.str.length>1)u=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(u=!0)}if(u&&(i.canvasWidth=n.vertical?t.height:t.width),this.#y.set(e,i),this.#a.div=e,this.#a.properties=i,this.#M(this.#a),i.hasText&&this.#e.append(e),i.hasEOL){let t=document.createElement("br");t.setAttribute("role","presentation"),this.#e.append(t)}}#M(t){let{div:e,properties:i,ctx:s}=t,{style:r}=e;if(0!==i.canvasWidth&&i.hasText){let{fontFamily:t}=r,{canvasWidth:n,fontSize:a}=i;Di.#P(s,a*this.#u,t);let{width:o}=s.measureText(e.textContent);o>0&&r.setProperty("--scale-x",n*this.#u/o)}0!==i.angle&&r.setProperty("--rotate",`${i.angle}deg`)}static cleanup(){if(!(this.#_.size>0)){this.#v.clear();for(let{canvas:t}of this.#A.values())t.remove();this.#A.clear()}}static#k(t=null){let e=this.#A.get(t||="");if(!e){let i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#A.set(t,e),this.#w.set(e,{size:0,family:""})}return e}static#P(t,e,i){let s=this.#w.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#T(){if(null!==this.#x)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.#x=t.getBoundingClientRect().height,t.remove()}static#E(t,e,i){let s=this.#v.get(t);if(s)return s;let r=this.#k(i);r.canvas.width=r.canvas.height=30,this.#P(r,30,t);let n=r.measureText(""),a=n.fontBoundingBoxAscent,o=Math.abs(n.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let l=.8;return a?l=a/(a+o):(N.platform.isFirefox&&_("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)),this.#v.set(t,l),l}}class Ii{static#t=0;_capability=Promise.withResolvers();_setupCapability=Promise.withResolvers();_transport=null;_worker=null;docId="d"+Ii.#t++;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0,this._capability.promise.catch(()=>{});try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._setupCapability.promise,await(this._transport?.destroy())}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class Fi{#t=Promise.withResolvers();#e=null;constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s}onDataRange(t,e){this.#e({type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){this.#t.promise.then(()=>{this.#e({type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){this.#t.promise.then(()=>{this.#e({type:"progressiveDone"})})}transportReady(t){this.#e=t,this.#t.resolve()}requestDataRange(t,e){S("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Ri{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return M(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()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(t){return this._transport.extractPages(t)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(t){return this._transport.getRawData(t)}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class Ni{#t=!1;#e=null;constructor(t,e,i,s,r=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=r?new K:null,this._pdfBug=r,this.commonObjs=i.commonObjs,this.objs=new Ei,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#e=s,this.imageCoordinates=null}clone(t){let e=new Ni(t,this._pageInfo,this._transport,this.#e,this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:r=!1}={}){return new V({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:r})}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 M(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:s="display",annotationMode:r=1,transform:n=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:d=null,isEditing:c=!1,recordImages:u=!1,recordOperations:p=!1,operationsFilter:g=null,renderingBudget:f=null,renderingScheduler:m=null}){this._stats?.time("Overall");let y=this._transport.getRenderingIntent(s,r,d,c),{renderingIntent:b,cacheKey:v}=y;this.#t=!1,o||=this._transport.getOptionalContentConfig(b);let A=this._intentStates.getOrInsertComputed(v,j);A.streamReaderCancelTimeout&&(clearTimeout(A.streamReaderCancelTimeout),A.streamReaderCancelTimeout=null);let w=!!(4&b);A.displayReadyCapability||(A.displayReadyCapability=Promise.withResolvers(),A.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(y));let x=!(!this._pdfBug||!globalThis.StepperManager?.enabled),_=!!e&&!this.recordedBBoxes&&(p||x),S=!!e&&!this.imageCoordinates&&u,C=t=>{if(A.renderTasks.delete(P),_){let t=P.gfx?.dependencyTracker.take();t&&(P.stepper?.setOperatorBBoxes(t,P.gfx.dependencyTracker.takeDebugMetadata()),p&&(this.recordedBBoxes=t))}S&&!t&&(this.imageCoordinates=P.gfx?.imagesTracker.take()),w&&(this.#t=!0),this.#i(),t?(P.capability.reject(t),this._abortOperatorList({intentState:A,reason:t instanceof Error?t:Error(t)})):P.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},M=null,k=null;(_||S)&&(k=new jt(e,A.operatorList.length)),_&&(M=new $t(k,x));let P=new ji({callback:C,params:{canvas:e,canvasContext:t,dependencyTracker:M??k,imagesTracker:S?new Yt(e):null,viewport:i,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:A.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!w,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:g,renderingBudget:f,renderingScheduler:m});(A.renderTasks||=new Set).add(P);let T=P.task;return Promise.all([A.displayReadyCapability.promise,o]).then(([t,e])=>{if(this.destroyed)C();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&b))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");P.initializeGraphics({transparency:t,optionalContentConfig:e}),P.operatorListChanged()}}).catch(C),T}getOperatorList({intent:t="display",annotationMode:e=1,printAnnotationStorage:i=null,isEditing:s=!1}={}){let r,n=this._transport.getRenderingIntent(t,e,i,s,!0),a=this._intentStates.getOrInsertComputed(n.cacheKey,j);return a.opListReadCapability||(r=Object.create(null),r.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(r))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(r),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>U.textContent(t));let e=this.streamTextContent(t),i={items:[],styles:Object.create(null),lang:null};for await(let t of e)i.lang??=t.lang,Object.assign(i.styles,t.styles),i.items.push(...t.items);return i}getStructTree(){return this._transport.getStructTree(this._pageIndex)}getGeospatialPDFMetadata(){return this._transport.getGeospatialPDFMetadata(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#t=!1,Promise.all(t)}cleanup(t=!1){this.#t=!0;let e=this.#i();return t&&e&&(this._stats&&=new K),e}#i(){if(!this.#t||this.destroyed)return!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#t=!1,!0}_startRenderPage(t,e){let i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(let t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this.#i()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){let{map:r,transfer:n}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:s},void 0,n).getReader(),o=this._intentStates.get(e);o.streamReader=a;let l=()=>{a.read().then(({value:t,done:e})=>{e?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,o),l())},t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(let t of o.renderTasks)t.operatorListChanged();this.#i()}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}})};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof X){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i))}}if(t.streamReader.cancel(new F(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class Oi{#t=Promise.withResolvers();#e=null;#i=null;#s=null;static#r=0;static#n=!1;static#a=new WeakMap;static{h&&(this.#n=!0,xi.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;let s=new URL(e,i);return i.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:i=w()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(Oi.#a.has(e))throw Error("Cannot use more than one PDFWorker per port.");Oi.#a.set(e,this),this.#l(e)}else this.#h()}get promise(){return this.#t.promise}#o(){this.#t.resolve(),this.#e.send("configure",{verbosity:this.verbosity})}get port(){return this.#i}get messageHandler(){return this.#e}#l(t){this.#i=t,this.#e=new ue("main","worker",t),this.#e.on("ready",()=>{}),this.#o()}#h(){if(Oi.#n||Oi.#c)return void this.#d();let{workerSrc:t}=Oi;try{Oi._isSameOrigin(window.location,t)||(t=Oi._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),i=new ue("main","worker",e),s=()=>{r.abort(),i.destroy(),e.terminate(),this.destroyed?this.#t.reject(Error("Worker was destroyed")):this.#d()},r=new AbortController;e.addEventListener("error",()=>{this.#s||s()},{signal:r.signal}),i.on("test",t=>{r.abort(),!this.destroyed&&t?(this.#e=i,this.#i=e,this.#s=e,this.#o()):s()}),i.on("ready",t=>{if(r.abort(),this.destroyed)s();else try{n()}catch{this.#d()}});let n=()=>{let t=new Uint8Array;i.send("test",t,[t.buffer])};return void n()}catch{x("The worker has been disabled.")}this.#d()}#d(){Oi.#n||(_("Setting up fake worker."),Oi.#n=!0),Oi._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void this.#t.reject(Error("Worker was destroyed"));let e=new he;this.#i=e;let i="fake"+Oi.#r++,s=new ue(i+"_worker",i,e);t.setup(s,e),this.#e=new ue(i,i+"_worker",e),this.#o()}).catch(t=>{this.#t.reject(Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#s?.terminate(),this.#s=null,Oi.#a.delete(this.#i),this.#i=null,this.#e?.destroy(),this.#e=null}static create(t){let e=this.#a.get(t?.port);if(e){if(e._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Oi(t)}static get workerSrc(){if(xi.workerSrc)return xi.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#c(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return M(this,"_setupFakeWorkerGlobal",(async()=>this.#c?this.#c:(await(import(this.workerSrc))).WorkerMessageHandler)())}}class Bi{downloadInfoCapability=Promise.withResolvers();#t=null;#e=new Map;#i=null;#s=new Map;#r=new Map;#n=new Map;#a=null;constructor(t,e,i,s,r,n){this.messageHandler=t,this.loadingTask=e,this.#i=i,this.commonObjs=new Ei,this.fontLoader=new Kt({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.enableHWA=s.enableHWA,this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.binaryDataFactory=r.binaryDataFactory,this.pagesMapper=n,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){let{_pageIndex:e}=t;this.#s.set(e,t),this.#r.set(e,Promise.resolve(t))}#o(t,e=null){return this.#e.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))}#l({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:e?$(Math.round(t/e*100),0,100):NaN})}get annotationStorage(){return M(this,"annotationStorage",new Et)}getRenderingIntent(t,e=1,i=null,s=!1,r=!1){let n=2,a=Tt;switch(t){case"any":n=1;break;case"display":break;case"print":n=4;break;default:_(`getRenderingIntent - invalid intent: ${t}`)}let o=4&n&&i instanceof Dt?i:this.annotationStorage;switch(e){case 0:n+=64;break;case 1:break;case 2:n+=16;break;case 3:n+=32,a=o.serializable;break;default:_(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(n+=128),r&&(n+=256);let{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:n,cacheKey:[n,a.hash,h].join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#a?.reject(Error("Worker was destroyed during onPassword callback"));let t=[];for(let e of this.#s.values())t.push(e._destroy());this.#s.clear(),this.#r.clear(),this.#n.clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(),Di.cleanup(),this.#i?.cancelAllRequests(new F("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",(t,e)=>{C(this.#i,"GetReader - no `BasePDFStream` instance available."),this.#t=this.#i.getFullReader(),this.#t.onProgress=t=>this.#l(t),e.onPull=()=>{this.#t.read().then(function({value:t,done:i}){i?e.close():(C(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this.#t.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{await this.#t.headersReady;let{isStreamingSupported:e,isRangeSupported:i,contentLength:s}=this.#t;return e&&i&&(this.#t.onProgress=null),{isStreamingSupported:e,isRangeSupported:i,contentLength:s}}),t.on("GetRangeReader",(t,e)=>{C(this.#i,"GetRangeReader - no `BasePDFStream` instance available.");let i=this.#i.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then(function({value:t,done:i}){i?e.close():(C(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{i.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this.pagesMapper.pagesNumber=t.numPages,this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new Ri(t,this))}),t.on("DocException",t=>{e._capability.reject(ce(t))}),t.on("PasswordRequest",t=>{this.#a=Promise.withResolvers();try{if(!e.onPassword)throw ce(t);e.onPassword(t=>{t instanceof Error?this.#a.reject(t):this.#a.resolve({password:t})},t.code)}catch(t){this.#a.reject(t)}return this.#a.promise}),t.on("DataLoaded",t=>{this.#l({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{this.destroyed||this.#s.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,s])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in s){let t=s.error;_(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let r=new re(s),n=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,a=new Zt(r,n,s.charProcOperatorList,s.extra);this.fontLoader.bind(a).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{a.fontExtraProperties||a.clearData(),this.commonObjs.resolve(e,a)});break;case"CopyLocalImage":let{imageRef:o}=s;C(o,"The imageRef must be defined.");for(let t of this.#s.values())for(let[,i]of t.objs){if(i?.ref!==o)continue;if(!i.dataLen)return null;let t=structuredClone(i);return this.commonObjs.resolve(e,t),i.dataLen}break;case"FontPath":this.commonObjs.resolve(e,new ae(s));break;case"Image":this.commonObjs.resolve(e,s);break;case"Pattern":let l=new ne(s);this.commonObjs.resolve(e,l.getIR());break;default:throw Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,s])=>{if(this.destroyed)return;let r=this.#s.get(e);if(!r.objs.has(t))if(0!==r._intentStates.size)switch(i){case"Image":case"Pattern":r.objs.resolve(t,s);break;default:throw Error(`Got unknown object type ${i}`)}else s?.bitmap?.close()}),t.on("DocProgress",t=>{this.destroyed||this.#l(t)}),t.on("FetchBinaryData",async t=>{if(this.destroyed)throw Error("Worker was destroyed.");if(!this.binaryDataFactory)throw Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&_("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this.#t?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t){let e,i={pageInfos:t};if(this.annotationStorage.size>0){let t=this.annotationStorage.serializable,{map:s}=t;e=t.transfer;let r=this.pagesMapper.getMapping();if(r){let t=new Map;for(let[e,i]of s){if(void 0!==i?.pageIndex&&i.pageIndex>=0&&i.pageIndex<r.length){let s=r[i.pageIndex]-1;if(s!==i.pageIndex){t.set(e,{...i,pageIndex:s});continue}}t.set(e,i)}s=t}i.annotationStorage=s}return this.messageHandler.sendWithPromise("ExtractPages",i,e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(Error("Invalid page request."));let e=t-1,i=this.pagesMapper.getPageId(t)-1,s=this.#r.get(e);if(s)return s;let r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:i}).then(t=>{if(this.destroyed)throw Error("Transport destroyed");t.refStr&&this.#n.set(t.refStr,i);let s=new Ni(e,t,this,this.pagesMapper,this._params.pdfBug);return this.#s.set(e,s),s});return this.#r.set(e,r),r}async getPageIndex(t){if(!le(t))throw Error("Invalid pageIndex request.");let e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),i=this.pagesMapper.getPageNumber(e+1);if(0===i)throw Error("GetPageIndex: page has been removed.");return i-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#o("GetFieldObjects")}hasJSActions(){return this.#o("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"==typeof t?this.messageHandler.sendWithPromise("GetDestination",{id:t}):Promise.reject(Error("Invalid destination request."))}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#o("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#o("GetOptionalContentConfig").then(e=>new Mi(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata";return this.#e.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new _i(t[1]):null,contentDispositionFilename:this.#t?.filename??null,contentLength:this.#t?.contentLength??null,hasStructTree:t[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(t){return this.messageHandler.sendWithPromise("GetRawData",t)}getGeospatialPDFMetadata(t){return this.messageHandler.sendWithPromise("GetGeospatialPDFMetadata",{pageIndex:t})}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(let t of this.#s.values())if(!t.cleanup())throw Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#e.clear(),this.filterFactory.destroy(!0),Di.cleanup()}}cachedPageNumber(t){if(!le(t))return null;let e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`,i=this.#n.get(e);if(i>=0){let t=this.pagesMapper.getPageNumber(i+1);if(0!==t)return t}return null}}class Li{_internalRenderTask=null;onContinue=null;onError=null;constructor(t){this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&e?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}class ji{#t=null;#e=null;static#i=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:r,operatorList:n,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null,enableHWA:u=!1,operationsFilter:p=null,renderingBudget:g=null,renderingScheduler:f=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=n,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Li(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,this._operationsFilter=p,this._renderingBudget=g,this._renderingScheduler=f}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(ji.#i.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.");ji.#i.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{viewport:i,transform:s,background:r,dependencyTracker:n,imagesTracker:a}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new qe(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,n,a),this.gfx.beginDrawing({transform:s,viewport:i,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this._cancelScheduledContinue(),ji.#i.delete(this._canvas),t||=new X(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}_cancelScheduledContinue(){this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),this.#e?.(),this.#e=null}operatorListChanged(){this.graphicsReady?(this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),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(){let t=t=>{this.#t=null,this.#e=null,this._nextBound(t||null).catch(this._cancelBound)};this._renderingScheduler?.scheduleContinue?this.#e=this._renderingScheduler.scheduleContinue(t)||null:this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{t(null)}):Promise.resolve().then(()=>t(null)).catch(this._cancelBound)}async _next(t=null){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter,this._renderingBudget,t),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),ji.#i.delete(this._canvas),this.callback())))}}class $i{#t=null;#e=null;#i;#s=null;#r=!1;#n=!1;#a=null;#o;#l=null;#h=null;static#d=null;static get _keyboardManager(){return M(this,"_keyboardManager",new yt([[["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.#n=!1,this.#a=t):this.#n=!0,this.#h=t?._uiManager||e,this.#o=this.#h._eventBus,this.#i=t?.color?.toUpperCase()||this.#h?.highlightColors.values().next().value||"#FFFF98",$i.#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 t=this.#t=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#a&&(t.ariaControls=`${this.#a.id}_colorpicker_dropdown`);let e=this.#h._signal;t.addEventListener("click",this.#g.bind(this),{signal:e}),t.addEventListener("keydown",this.#p.bind(this),{signal:e});let i=this.#e=document.createElement("span");return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=this.#i,t.append(i),t}renderMainDropdown(){let t=this.#s=this.#c();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#c(){let t=document.createElement("div"),e=this.#h._signal;t.addEventListener("contextmenu",J,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#a&&(t.id=`${this.#a.id}_colorpicker_dropdown`);for(let[i,s]of this.#h.highlightColors){let r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",s),r.title=i,r.setAttribute("data-l10n-id",$i.#d[i]);let n=document.createElement("span");r.append(n),n.className="swatch",n.style.backgroundColor=s,r.ariaSelected=s===this.#i,r.addEventListener("click",this.#u.bind(this,s),{signal:e}),t.append(r)}return t.addEventListener("keydown",this.#p.bind(this),{signal:e}),t}#u(t,e){e.stopPropagation(),this.#o.dispatch("switchannotationeditorparams",{source:this,type:y,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#t)return void this.#g(t);let e=t.target.getAttribute("data-color");e&&this.#u(e,t)}_moveToNext(t){this.#m?t.target===this.#t?this.#s.firstElementChild?.focus():t.target.nextSibling?.focus():this.#g(t)}_moveToPrevious(t){t.target!==this.#s?.firstElementChild&&t.target!==this.#t?(this.#m||this.#g(t),t.target.previousSibling?.focus()):this.#m&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#m?this.#s.firstElementChild?.focus():this.#g(t)}_moveToEnd(t){this.#m?this.#s.lastElementChild?.focus():this.#g(t)}#p(t){$i._keyboardManager.exec(this,t)}#g(t){if(this.#m)return void this.hideDropdown();if(this.#r=0===t.detail,this.#l||(this.#l=new AbortController,window.addEventListener("pointerdown",this.#f.bind(this),{signal:this.#h.combinedSignal(this.#l)})),this.#t.ariaExpanded="true",this.#s)return void this.#s.classList.remove("hidden");let e=this.#s=this.#c();this.#t.append(e)}#f(t){this.#s?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#s?.classList.add("hidden"),this.#t.ariaExpanded="false",this.#l?.abort(),this.#l=null}get#m(){return this.#s&&!this.#s.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#n||(this.#m?(this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#r})):this.#a?.unselect())}updateColor(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#s)return;let e=this.#h.highlightColors.values();for(let i of this.#s.children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#s?.remove(),this.#s=null}}class Ui{#t=null;#e=!1;#i=null;#s=null;static#r=null;constructor(t){this.#i=t,this.#s=t._uiManager,Ui.#r||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#t)return this.#t;let{editorType:t,colorType:e,colorAndOpacityType:i,opacityType:s,color:r,opacity:n}=this.#i,a=this.#e=N.isAlphaColorInputSupported&&void 0!==s,o=this.#t=document.createElement("input");if(o.type="color",a){o.setAttribute("alpha","");let t=O.hexNums[Math.round(255*(n??1))];o.value=(r||"#000000")+t}else o.value=r||"#000000";return o.className="basicColorPicker",o.tabIndex=0,o.setAttribute("data-l10n-id",Ui.#r[t]),o.addEventListener("input",()=>{if(a){let t=et(o.value);if(!t)return;let[r,n,a,l]=t,h=O.makeHexColor(r,n,a);void 0!==i?this.#s.updateParams(i,{color:h,opacity:l}):(this.#s.updateParams(e,h),this.#s.updateParams(s,l))}else this.#s.updateParams(e,o.value)},{signal:this.#s._signal}),o}update(t){if(this.#t)if(this.#e){let e=O.hexNums[Math.round(255*this.#i.opacity)];this.#t.value=t+e}else this.#t.value=t}updateOpacity(t){if(!this.#t||!this.#e)return;let e=O.hexNums[Math.round(255*t)];this.#t.value=this.#i.color+e}destroy(){this.#t?.remove(),this.#t=null}hideDropdown(){}}function zi(t){return Math.floor(255*$(t,0,1)).toString(16).padStart(2,"0")}function Gi(t){return 255*$(t,0,1)}class Wi{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.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=Gi(t),t,t]}static G_HTML([t]){let e=zi(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(Gi)}static RGB_HTML(t){return`#${t.map(zi).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[Gi(1-Math.min(1,t+s)),Gi(1-Math.min(1,i+s)),Gi(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,i]){let s=1-t,r=1-e,n=1-i;return["CMYK",s,r,n,Math.min(s,r,n)]}}const Hi=new WeakSet;(new Date).getTimezoneOffset();class Vi{#t=null;#e=!1;#i=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!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.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!(!t?.str&&!e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Vi._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){let t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;let{quadPoints:e,inkLists:i,rect:s}=this.data,r=-1/0,n=-1/0;if(e?.length>=8){for(let t=0;t<e.length;t+=8)e[t+1]>n?(n=e[t+1],r=e[t+2]):e[t+1]===n&&(r=Math.max(r,e[t+2]));return[r,n]}if(i?.length>=1){for(let t of i)for(let e=0,i=t.length;e<i;e+=2)t[e+1]>n?(n=t[e+1],r=t[e]):t[e+1]===n&&(r=Math.max(r,t[e]));if(r!==1/0)return[r,n]}return s?[s[2],s[3]]:null}_normalizePoint(t){let{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:s,pageX:r,pageY:n}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/i,t[1]=100*(t[1]-n)/s,t}get commentText(){let{data:t}=this;return this.annotationStorage.getRawValue(`${f}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){let{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${f}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#i?.popup||this.popup)?.remove(),this.#i=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#t||={rect:this.data.rect.slice(0)});let{rect:e,popup:i}=t;e&&this.#s(e);let s=this.#i?.popup||this.popup;!s&&i?.text&&(this._createPopup(i),s=this.#i.popup),s&&(s.updateEdited(t),i?.deleted&&(s.remove(),this.#i=null,this.popup=null))}resetEdited(){this.#t&&(this.#s(this.#t.rect),this.#i?.popup.resetEdited(),this.#t=null)}#s(t){let{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:n,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=100*(t[0]-a)/r+"%",e.top=100*(n-t[3]+o)/n+"%",0===s?(e.width=100*(t[2]-t[0])/r+"%",e.height=100*(t[3]-t[1])/n+"%"):this.setRotation(s)}_createContainer(t){let{data:e,parent:{page:i,viewport:s}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),this instanceof qi||this instanceof Xi||(r.tabIndex=0);let{style:n}=r;if(n.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof Ki){let{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,r),r}let{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){n.borderWidth=`${e.borderStyle.width}px`;let t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;switch(t>0||i>0?n.borderRadius=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`:this instanceof Yi&&(n.borderRadius=`calc(${a}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`),e.borderStyle.style){case 1:n.borderStyle="solid";break;case 2:n.borderStyle="dashed";break;case 3:_("Unimplemented border style: beveled");break;case 4:_("Unimplemented border style: inset");break;case 5:n.borderBottomStyle="solid"}let s=e.borderColor||null;s?(this.#e=!0,n.borderColor=O.makeHexColor(...s)):n.borderWidth=0}let l=O.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:d,pageX:c,pageY:u}=s.rawDims;n.left=100*(l[0]-c)/h+"%",n.top=100*(l[1]-u)/d+"%";let{rotation:p}=e;return e.hasOwnCanvas||0===p?(n.width=100*a/h+"%",n.height=100*o/d+"%"):this.setRotation(p,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:r,height:n}=this;t%180!=0&&([r,n]=[n,r]),e.style.width=100*r/i+"%",e.style.height=100*n/s+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(t,e,i)=>{let s=i.detail[t],r=s[0],n=s.slice(1);i.target.style[e]=Wi[`${r}_HTML`](n),this.annotationStorage.setValue(this.data.id,{[e]:Wi[`${r}_rgb`](n)})};return M(this,"_commonActions",{display:t=>{let{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{let{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.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:t=>{let e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){let i=this._commonActions;for(let s of Object.keys(e.detail))(t[s]||i[s])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let i=this._commonActions;for(let[s,r]of Object.entries(e)){let n=i[s];n&&(n({detail:{[s]:r},target:t}),delete e[s])}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:t}=this.data;if(!t)return;let[e,i,s,r]=this.data.rect.map(t=>Math.fround(t));if(8===t.length){let[n,a,o,l]=t.subarray(2,6);if(s===n&&r===a&&e===o&&i===l)return}let n,{style:a}=this.container;if(this.#e){let{borderColor:t,borderWidth:e}=a;a.borderWidth=0,n=["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="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}let o=s-e,l=r-i,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";let c=h.createElement("defs");d.append(c);let u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let i=2,s=t.length;i<s;i+=8){let s=t[i],a=t[i+1],d=t[i+2],c=t[i+3],p=h.createElement("rect"),g=(d-e)/o,f=(r-a)/l,m=(s-d)/o,y=(a-c)/l;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",m),p.setAttribute("height",y),u.append(p),n?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${m}" height="${y}"/>`)}this.#e&&(n.push("</g></svg>')"),a.backgroundImage=n.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){let e,i,{data:s}=this;t?(e={str:t.text},i=t.date):(e=s.contentsObj,i=s.modificationDate),this.#i=new Ki({data:{color:s.color,titleObj:s.titleObj,modificationDate:i,contentsObj:e,richText:s.richText,parentRect:s.rect,borderStyle:0,id:`popup_${s.id}`,rotation:s.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#i||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#i}render(){S("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let i=[];if(this._fieldObjects){let s=this._fieldObjects[t];if(s)for(let{page:t,id:r,exportValues:n}of s){if(-1===t)continue;if(r===e)continue;let s="string"==typeof n?n:null,a=document.querySelector(`[data-element-id="${r}"]`);!a||Hi.has(a)?i.push({id:r,exportValue:s,domElement:a}):_(`_getElementsByName - element not allowed: ${r}`)}return i}for(let s of document.getElementsByName(t)){let{exportValue:t}=s,r=s.getAttribute("data-element-id");r!==e&&Hi.has(s)&&i.push({id:r,exportValue:t,domElement:s})}return i}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,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class Xi extends Vi{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,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action,t.overlaidText),s=!0):t.attachment?(this.#e(i,t.attachment,t.overlaidText,t.attachmentDest),s=!0):t.setOCGState?(this.#i(i,t.setOCGState,t.overlaidText),s=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&(this.contentElement=i,this.container.append(i)),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,i=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#t(),i&&(t.title=i)}_bindNamedAction(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),i&&(t.title=i),this.#t()}#e(t,e,i="",s=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:i&&(t.title=i),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#t()}#i(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let s of Object.keys(e.actions)){let r=i.get(s);r&&(t[r]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}e.overlaidText&&(t.title=e.overlaidText),t.onclick||=()=>!1,this.#t()}_bindResetFormAction(t,e){let i=t.onclick;i||(t.href=this.linkService.getAnchorUrl("")),this.#t(),this._fieldObjects?t.onclick=()=>{i?.();let{fields:t,refs:s,include:r}=e,n=[];if(0!==t.length||0!==s.length){let e=new Set(s);for(let i of t){let t=this._fieldObjects[i]||[];for(let{id:i}of t)e.add(i)}for(let t of Object.values(this._fieldObjects))for(let i of t)e.has(i.id)===r&&n.push(i)}else for(let t of Object.values(this._fieldObjects))n.push(...t);let a=this.annotationStorage,o=[];for(let t of n){let{id:e}=t;switch(o.push(e),t.type){case"text":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{let i=t.defaultValue===t.exportValues;a.setValue(e,{value:i});break}case"combobox":case"listbox":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}default:continue}let i=document.querySelector(`[data-element-id="${e}"]`);i&&(Hi.has(i)?i.dispatchEvent(new Event("resetform")):_(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}:(_('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1))}}class qi extends Vi{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return N.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,r){i.includes("mouse")?t.addEventListener(i,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:r(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(i,t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:r(t)}})})}_setEventListeners(t,e,i,s){for(let[r,n]of i)("Action"===n||this.data.actions?.[n])&&("Focus"!==n&&"Blur"!==n||(e||={focused:!1}),this._setEventListener(t,e,r,n,s),"Focus"!==n||this.data.actions?.Blur?"Blur"!==n||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":O.makeHexColor(...e)}_setTextStyle(t){let e,{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,r=t.style,n=t=>Math.round(10*t)/10;if(this.data.multiLine){let t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),i=t/(Math.round(t/(p*s))||1);e=Math.min(s,n(i/p))}else{let t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);e=Math.min(s,n(t/p))}r.fontSize=`calc(${e}px * var(--total-scale-factor))`,r.color=O.makeHexColor(...i),null!==this.data.textAlignment&&(r.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Yi extends qi{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(let s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});let r=document.createElement("input");if(Hi.add(r),r.setAttribute("data-element-id",i),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,s&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",e=>{let{name:s,checked:r}=e.target;for(let e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:r})}),r.addEventListener("resetform",t=>{let i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){let s=e.buttonValue;r.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value:e=>{let r=s===e.detail.value;for(let s of this._getElementsByName(e.target.name)){let e=r&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}},e)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class Ki extends Vi{constructor(t){let{data:e,elements:i,parent:s}=t,r=!!s._commentManager;if(super(t,{isRenderable:!r&&Vi._hasPopupData(e)}),this.elements=i,r&&Vi._hasPopupData(e)){let t=this.popup=this.#t();for(let e of i)e.popup=t}else this.popup=null}#t(){return new Zi({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})}render(){let{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";let e=this.popup=this.#t(),i=[];for(let t of this.elements)t.popup=e,t.container.ariaHasPopup="dialog",i.push(t.data.id),t.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(t=>`${g}${t}`).join(",")),this.container}}class Zi{#t=null;#e=this.#R.bind(this);#i=this.#L.bind(this);#s=this.#B.bind(this);#r=this.#O.bind(this);#n=null;#a=null;#o=null;#l=null;#h=null;#d=null;#c=null;#u=!1;#p=null;#g=null;#f=null;#m=null;#y=null;#b=null;#v=null;#A=null;#w=null;#x=null;#_=!1;#S=null;#C=null;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:r,contentsObj:n,richText:a,parent:o,rect:l,parentRect:h,open:d,commentManager:c=null}){this.#a=t,this.#w=s,this.#o=n,this.#A=a,this.#d=o,this.#n=e,this.#v=l,this.#c=h,this.#h=i,this.#t=c,this.#S=i[0],this.#l=tt.toDateObject(r),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),c||(this.#M(),this.#a.hidden=!0,d&&this.#O())}#M(){if(this.#g)return;this.#g=new AbortController;let{signal:t}=this.#g;for(let e of this.trigger)e.addEventListener("click",this.#r,{signal:t}),e.addEventListener("pointerenter",this.#s,{signal:t}),e.addEventListener("pointerleave",this.#i,{signal:t}),e.classList.add("popupTriggerArea");for(let e of this.#h)e.container?.addEventListener("keydown",this.#e,{signal:t})}#k(){let t=this.#h.find(t=>t.hasCommentButton);t&&(this.#y=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#m)return void(this.#m.parentNode||this.#S.container.after(this.#m));if(this.#y||this.#k(),!this.#y)return;let{signal:t}=this.#g=new AbortController,e=this.#S.hasOwnCommentButton,i=()=>{this.#t.toggleCommentPopup(this,!0,void 0,!e)},s=()=>{this.#t.toggleCommentPopup(this,!1,!0,!e)},r=()=>{this.#t.toggleCommentPopup(this,!1,!1)};if(e){this.#m=this.#S.container;for(let e of this.trigger)e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.addEventListener("keydown",this.#e,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",r,{signal:t}),e.classList.add("popupTriggerArea")}else{let e=this.#m=document.createElement("button");e.className="annotationCommentButton";let n=this.#S.container;e.style.zIndex=parseInt(n.style.zIndex,10)+1,e.tabIndex=0,e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#T(),this.#P(),e.addEventListener("keydown",this.#e,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",r,{signal:t}),n.after(e)}}#P(){if(this.#S.extraPopupElement&&!this.#S.editor)return;this.#m||this.renderCommentButton();let[t,e]=this.#y,{style:i}=this.#m;i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`}#T(){this.#S.extraPopupElement||(this.#m||this.renderCommentButton(),this.#m.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){let{color:t,opacity:e}=this.#S.commentData;return t?this.#d._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#m?.focus()},0)}getData(){let{richText:t,color:e,opacity:i,creationDate:s,modificationDate:r}=this.#S.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:s,modificationDate:r}}get elementBeforePopup(){return this.#m}get comment(){return this.#C||=this.#S.commentText,this.#C}set comment(t){t!==this.comment&&(this.#S.commentText=this.#C=t)}focus(){this.#S.container?.focus()}get parentBoundingClientRect(){return this.#S.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#m&&(this.#m.classList.toggle("selected",t),this.#m.ariaExpanded=e)}setSelectedCommentButton(t){this.#m.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#b)return this.#b;let{x:t,y:e,height:i}=this.#m.getBoundingClientRect(),{x:s,y:r,width:n,height:a}=this.#S.layer.getBoundingClientRect();return[(t-s)/n,(e+i-r)/a]}set commentPopupPosition(t){this.#b=t}hasDefaultPopupPosition(){return null===this.#b}get commentButtonPosition(){return this.#y}get commentButtonWidth(){return this.#m.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){let[e,i]=this.#b||this.commentButtonPosition.map(t=>t/100),s=this.parentBoundingClientRect,{x:r,y:n,width:a,height:o}=s;this.#t.showDialog(null,this,r+e*a,n+i*o,{...t,parentDimensions:s})}render(){if(this.#p)return;let t=this.#p=document.createElement("div");if(t.className="popup",this.#n){let e=t.style.outlineColor=O.makeHexColor(...this.#n);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}let e=document.createElement("span");if(e.className="header",this.#w?.str){let t=document.createElement("span");t.className="title",e.append(t),({dir:t.dir,str:t.textContent}=this.#w)}if(t.append(e),this.#l){let t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#l.valueOf()})),t.dateTime=this.#l.toISOString(),e.append(t)}!function({html:t,dir:e,className:i},s){let r=document.createDocumentFragment();if("string"==typeof t){let i=document.createElement("p");i.dir=e||"auto";let s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){let r=s[t];i.append(document.createTextNode(r)),t<e-1&&i.append(document.createElement("br"))}r.append(i)}else z.render({xfaHtml:t,div:r,intent:"richText"});r.firstElementChild.classList.add("richText",i),s.append(r)}({html:this.#E||this.#o.str,dir:this.#o?.dir,className:"popupContent"},t),this.#a.append(t)}get#E(){let t=this.#A,e=this.#o;return!t?.str||e?.str&&e.str!==t.str?null:this.#A.html||null}get#D(){return this.#E?.attributes?.style?.fontSize||0}get#I(){return this.#E?.attributes?.style?.color||null}#F(t){let e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#I,fontSize:this.#D?`calc(${this.#D}px * var(--total-scale-factor))`:""}};for(let i of t.split("\n"))e.push({name:"span",value:i,attributes:s});return i}#R(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#u)&&this.#O()}updateEdited({rect:t,popup:e,deleted:i}){this.#t?(i?(this.remove(),this.#C=null):e&&(e.deleted?this.remove():(this.#T(),this.#C=e.text)),t&&(this.#y=null,this.#k(),this.#P())):i||e?.deleted?this.remove():(this.#M(),this.#x||={contentsObj:this.#o,richText:this.#A},t&&(this.#f=null),e&&e.text&&(this.#A=this.#F(e.text),this.#l=tt.toDateObject(e.date),this.#o=null),this.#p?.remove(),this.#p=null)}resetEdited(){this.#x&&(({contentsObj:this.#o,richText:this.#A}=this.#x),this.#x=null,this.#p?.remove(),this.#p=null,this.#f=null)}remove(){if(this.#g?.abort(),this.#g=null,this.#p?.remove(),this.#p=null,this.#_=!1,this.#u=!1,this.#m?.remove(),this.#m=null,this.trigger)for(let t of this.trigger)t.classList.remove("popupTriggerArea")}#N(){if(null!==this.#f)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:r}}}=this.#d,n=!!this.#c,a=n?this.#c:this.#v;for(let t of this.#h)if(!a||null!==O.intersect(t.data.rect,a)){a=t.data.rect,n=!0;break}let o=O.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=n?a[2]-a[0]+5:0,h=o[0]+l,d=o[1];this.#f=[100*(h-s)/e,100*(d-r)/i];let{style:c}=this.#a;c.left=`${this.#f[0]}%`,c.top=`${this.#f[1]}%`}#O(){this.#t?this.#t.toggleCommentPopup(this,!1):(this.#u=!this.#u,this.#u?(this.#B(),this.#a.addEventListener("click",this.#r),this.#a.addEventListener("keydown",this.#e)):(this.#L(),this.#a.removeEventListener("click",this.#r),this.#a.removeEventListener("keydown",this.#e)))}#B(){this.#p||this.render(),this.isVisible?this.#u&&this.#a.classList.add("focused"):(this.#N(),this.#a.hidden=!1,this.#a.style.zIndex=parseInt(this.#a.style.zIndex,10)+1e3)}#L(){this.#a.classList.remove("focused"),!this.#u&&this.isVisible&&(this.#a.hidden=!0,this.#a.style.zIndex=parseInt(this.#a.style.zIndex,10)-1e3)}forceHide(){this.#_=this.isVisible,this.#_&&(this.#a.hidden=!0)}maybeShow(){this.#t||(this.#M(),this.#_&&(this.#p||this.#B(),this.#_=!1,this.#a.hidden=!1))}get isVisible(){return!this.#t&&!1===this.#a.hidden}}class Ji extends Vi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=3}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(let e of this.textContent){let i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class Qi extends Vi{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?9:15}#i(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:i,borderStyle:s,popupRef:r}}=this,{transform:n,width:a,height:o}=this.#i(e,t),l=this.svgFactory.create(a,o,!0),h=this.#t=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",n);for(let t=0,e=i.length;t<e;t++){let e=this.svgFactory.createElement(this.svgElementName);this.#e.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!r&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:i,rect:s}=t,r=this.#t;if(e>=0&&r.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#e.length;t<e;t++)this.#e[t].setAttribute("points",i[t].join(","));if(s){let{transform:t,width:e,height:i}=this.#i(this.data.rotation,s);r.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),r.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class ts extends Vi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=9}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){let e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class es extends Vi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=13}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}const is=/\r\n?|\n/g;class ss extends _t{#t="";#e=`${this.id}-editor`;#i=null;#s;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=ss.prototype,e=t=>t.isEmpty(),i=vt.TRANSLATE_SMALL,s=vt.TRANSLATE_BIG;return M(this,"_keyboardManager",new yt([[["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:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=3;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||ss._defaultColor||_t._defaultLineColor,this.#s=t.fontSize||ss._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert(_t._l10nAlert.freetext),this.canAddComment=!1}static initialize(t,e){_t.initialize(t,e);let i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case 11:ss._defaultFontSize=e;break;case m:ss._defaultColor=e}}updateParams(t,e){switch(t){case 11:this.#r(e);break;case m:this.#n(e)}}static get defaultPropertiesToUpdate(){return[[11,ss._defaultFontSize],[m,ss._defaultColor||_t._defaultLineColor]]}get propertiesToUpdate(){return[[11,this.#s],[m,this.color]]}get toolbarButtons(){return this._colorPicker||=new Ui(this),[["colorPicker",this._colorPicker]]}get colorType(){return m}#r(t){let e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#s)*this.parentScale),this.#s=t,this.#o()},i=this.#s;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:11,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#n(t){let e=t=>{this.color=t,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:m,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-ss._internalPadding*t,-(ss._internalPadding+this.#s)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#i=new AbortController;let t=this._uiManager.combinedSignal(this.#i);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#e),this._isDraggable=!0,this.#i?.abort(),this.#i=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}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 i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(ss.#l(i)),e=i);return t.join("\n")}#o(){let t,[e,i]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{let{currentLayer:e,div:i}=this,s=i.style.display,r=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",e.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=s,i.classList.toggle("hidden",r)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/i):(this.width=t.height/e,this.height=t.width/i),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#t,e=this.#t=this.#a().trimEnd();if(t===e)return;let i=t=>{this.#t=t,t?(this.#h(),this._uiManager.rebuild(this),this.#o()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#o()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){ss._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#e),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#s}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){let[i,s]=this.parentDimensions;if(this.annotationElementId){let{position:r}=this._initialData,[n,a]=this.getInitialTranslation();[n,a]=this.pageTranslationToScreen(n,a);let o,l,[h,d]=this.pageDimensions,[c,u]=this.pageTranslation;switch(this.rotation){case 0:o=t+(r[0]-c)/h,l=e+this.height-(r[1]-u)/d;break;case 90:o=t+(r[0]-c)/h,l=e-(r[1]-u)/d,[n,a]=[a,-n];break;case 180:o=t-this.width+(r[0]-c)/h,l=e-(r[1]-u)/d,[n,a]=[-n,-a];break;case 270:o=t+(r[0]-c-this.height*d)/h,l=e+(r[1]-u-this.width*h)/d,[n,a]=[-a,n]}this.setAt(o*i,l*s,n,a)}else this._moveAfterPaste(t,e);this.#h(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#l(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(is,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();let s=ss.#c(e.getData("text")||"").replaceAll(is,"\n");if(!s)return;let r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();let n=r.getRangeAt(0);if(!s.includes("\n"))return n.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void r.collapseToStart();let{startContainer:a,startOffset:o}=n,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){let t=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(is,"")),t!==this.editorDiv){let e=l;for(let i of this.editorDiv.childNodes)i===t?e=h:e.push(ss.#l(i))}l.push(a.nodeValue.slice(0,o).replaceAll(is,""))}else if(a===this.editorDiv){let t=l,e=0;for(let i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(ss.#l(i))}this.#t=`${l.join("\n")}${s}${h.join("\n")}`,this.#h();let d=new Range,c=Math.sumPrecise(l.map(t=>t.length));for(let{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){let e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}r.removeAllRanges(),r.addRange(d)}#h(){if(this.editorDiv.replaceChildren(),this.#t)for(let t of this.#t.split("\n")){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#d(){return this.#t.replaceAll(" "," ")}static#c(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){let t=ss._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,i){let s=null;if(t instanceof Ji){let{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:r,rotation:n,id:a,popupRef:o,richText:l,contentsObj:h,creationDate:d,modificationDate:c},textContent:u,textPosition:p,parent:{page:{pageNumber:g}}}=t;if(!u||0===u.length)return null;s=t={annotationType:3,color:Array.from(i),fontSize:e,value:u.join("\n"),position:p,pageIndex:g-1,rect:r.slice(0),rotation:n,annotationElementId:a,id:a,deleted:!1,popupRef:o,comment:h?.str||null,richText:l,creationDate:d,modificationDate:c}}let r=await super.deserialize(t,e,i);return r.#s=t.fontSize,r.color=O.makeHexColor(...t.color),r.#t=ss.#c(t.value),r._initialData=s,t.comment&&r.setCommentData(t),r}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=_t._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:this.#s,value:this.#d()});return this.addComment(i),t?(i.isCopy=!0,i):this.annotationElementId&&!this.#u(i)?null:(i.id=this.annotationElementId,i)}#u(t){let{value:e,fontSize:i,color:s,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==s[e])||t.pageIndex!==r}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(!e)return null;let{style:i}=e;i.fontSize=`calc(${this.#s}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren();for(let t of this.#t.split("\n")){let i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#t}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class rs{static PRECISION=1e-4;toSVGPath(){S("Abstract method `toSVGPath` must be implemented.")}get box(){S("Abstract getter `box` must be implemented.")}serialize(t,e){S("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a]*s,n[a+1]=i+t[a+1]*r;return n}static _rescaleAndSwap(t,e,i,s,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a+1]*s,n[a+1]=i+t[a]*r;return n}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let r=0,n=t.length;r<n;r+=2)s[r]=e+t[r],s[r+1]=i+t[r+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,r){switch(r){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){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,i,s,r,n){return[(t+5*i)/6,(e+5*s)/6,(5*i+r)/6,(5*s+n)/6,(i+r)/2,(s+n)/2]}}class ns{#t;#e=[];#i;#s;#r=[];#n=new Float32Array(18);#a;#o;#l;#h;#d;#c;#u=[];static#p=8;static#g=2;static#f=ns.#p+ns.#g;constructor({x:t,y:e},i,s,r,n,a=0){this.#t=i,this.#c=r*s,this.#s=n,this.#n.set([NaN,NaN,NaN,NaN,t,e],6),this.#i=a,this.#h=ns.#p*s,this.#l=ns.#f*s,this.#d=s,this.#u.push(t,e)}isEmpty(){return isNaN(this.#n[8])}#m(){let t=this.#n.subarray(4,6),e=this.#n.subarray(16,18),[i,s,r,n]=this.#t;return[(this.#a+(t[0]-e[0])/2-i)/r,(this.#o+(t[1]-e[1])/2-s)/n,(this.#a+(e[0]-t[0])/2-i)/r,(this.#o+(e[1]-t[1])/2-s)/n]}add({x:t,y:e}){this.#a=t,this.#o=e;let[i,s,r,n]=this.#t,[a,o,l,h]=this.#n.subarray(8,12),d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#l)return!1;let p=u-this.#h,g=p/u,f=g*d,m=g*c,y=a,b=o;a=l,o=h,l+=f,h+=m,this.#u?.push(t,e);let v=f/p,A=-m/p*this.#c,w=v*this.#c;return this.#n.set(this.#n.subarray(2,8),0),this.#n.set([l+A,h+w],4),this.#n.set(this.#n.subarray(14,18),12),this.#n.set([l-A,h-w],16),isNaN(this.#n[6])?(0===this.#r.length&&(this.#n.set([a+A,o+w],2),this.#r.push(NaN,NaN,NaN,NaN,(a+A-i)/r,(o+w-s)/n),this.#n.set([a-A,o-w],14),this.#e.push(NaN,NaN,NaN,NaN,(a-A-i)/r,(o-w-s)/n)),this.#n.set([y,b,a,o,l,h],6),!this.isEmpty()):(this.#n.set([y,b,a,o,l,h],6),Math.abs(Math.atan2(b-o,y-a)-Math.atan2(m,f))<Math.PI/2?([a,o,l,h]=this.#n.subarray(2,6),this.#r.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/r,((o+h)/2-s)/n),[a,o,y,b]=this.#n.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((y+a)/2-i)/r,((b+o)/2-s)/n),!0):([y,b,a,o,l,h]=this.#n.subarray(0,6),this.#r.push(((y+5*a)/6-i)/r,((b+5*o)/6-s)/n,((5*a+l)/6-i)/r,((5*o+h)/6-s)/n,((a+l)/2-i)/r,((o+h)/2-s)/n),[l,h,a,o,y,b]=this.#n.subarray(12,18),this.#e.push(((y+5*a)/6-i)/r,((b+5*o)/6-s)/n,((5*a+l)/6-i)/r,((5*o+h)/6-s)/n,((a+l)/2-i)/r,((o+h)/2-s)/n),!0))}toSVGPath(){if(this.isEmpty())return"";let t=this.#r,e=this.#e;if(isNaN(this.#n[6])&&!this.isEmpty())return this.#y();let i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#v(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#b(i),i.join(" ")}#y(){let[t,e,i,s]=this.#t,[r,n,a,o]=this.#m();return`M${(this.#n[2]-t)/i} ${(this.#n[3]-e)/s} L${(this.#n[4]-t)/i} ${(this.#n[5]-e)/s} L${r} ${n} L${a} ${o} L${(this.#n[16]-t)/i} ${(this.#n[17]-e)/s} L${(this.#n[14]-t)/i} ${(this.#n[15]-e)/s} Z`}#b(t){let e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#v(t){let[e,i,s,r]=this.#t,n=this.#n.subarray(4,6),a=this.#n.subarray(16,18),[o,l,h,d]=this.#m();t.push(`L${(n[0]-e)/s} ${(n[1]-i)/r} L${o} ${l} L${h} ${d} L${(a[0]-e)/s} ${(a[1]-i)/r}`)}newFreeDrawOutline(t,e,i,s,r,n){return new as(t,e,i,s,r,n)}getOutlines(){let t=this.#r,e=this.#e,i=this.#n,[s,r,n,a]=this.#t,o=new Float32Array((this.#u?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#u[t]-s)/n,o[t+1]=(this.#u[t+1]-r)/a;if(o[o.length-2]=(this.#a-s)/n,o[o.length-1]=(this.#o-r)/a,isNaN(i[6])&&!this.isEmpty())return this.#A(o);let l=new Float32Array(this.#r.length+24+this.#e.length),h=t.length;for(let e=0;e<h;e+=2)isNaN(t[e])?l[e]=l[e+1]=NaN:(l[e]=t[e],l[e+1]=t[e+1]);h=this.#x(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2)isNaN(e[t+i])?(l[h]=l[h+1]=NaN,h+=2):(l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2);return this.#w(l,h),this.newFreeDrawOutline(l,o,this.#t,this.#d,this.#i,this.#s)}#A(t){let e=this.#n,[i,s,r,n]=this.#t,[a,o,l,h]=this.#m(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/r,(e[3]-s)/n,NaN,NaN,NaN,NaN,(e[4]-i)/r,(e[5]-s)/n,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/r,(e[17]-s)/n,NaN,NaN,NaN,NaN,(e[14]-i)/r,(e[15]-s)/n],0),this.newFreeDrawOutline(d,t,this.#t,this.#d,this.#i,this.#s)}#w(t,e){let i=this.#e;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#x(t,e){let i=this.#n.subarray(4,6),s=this.#n.subarray(16,18),[r,n,a,o]=this.#t,[l,h,d,c]=this.#m();return t.set([NaN,NaN,NaN,NaN,(i[0]-r)/a,(i[1]-n)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-r)/a,(s[1]-n)/o],e),e+24}}class as extends rs{#t;#e=new Float32Array(4);#i;#s;#r;#n;#a;constructor(t,e,i,s,r,n){super(),this.#a=t,this.#r=e,this.#t=i,this.#n=s,this.#i=r,this.#s=n,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#o(n);let[a,o,l,h]=this.#e;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-a)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-a)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){let t=[`M${this.#a[4]} ${this.#a[5]}`];for(let e=6,i=this.#a.length;e<i;e+=6)isNaN(this.#a[e])?t.push(`L${this.#a[e+4]} ${this.#a[e+5]}`):t.push(`C${this.#a[e]} ${this.#a[e+1]} ${this.#a[e+2]} ${this.#a[e+3]} ${this.#a[e+4]} ${this.#a[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],r){let n,a,o=i-t,l=s-e;switch(r){case 0:n=rs._rescale(this.#a,t,s,o,-l),a=rs._rescale(this.#r,t,s,o,-l);break;case 90:n=rs._rescaleAndSwap(this.#a,t,e,o,l),a=rs._rescaleAndSwap(this.#r,t,e,o,l);break;case 180:n=rs._rescale(this.#a,i,e,-o,l),a=rs._rescale(this.#r,i,e,-o,l);break;case 270:n=rs._rescaleAndSwap(this.#a,i,s,-o,-l),a=rs._rescaleAndSwap(this.#r,i,s,-o,-l)}return{outline:Array.from(n),points:[Array.from(a)]}}#o(t){let e=this.#a,i=e[4],s=e[5],r=[i,s,i,s],n=i,a=s,o=i,l=s,h=t?Math.max:Math.min,c=new Float32Array(4);for(let t=6,u=e.length;t<u;t+=6){let u=e[t+4],p=e[t+5];isNaN(e[t])?(O.pointBoundingBox(u,p,r),a>p?(n=u,a=p):a===p&&(n=h(n,u)),l<p?(o=u,l=p):l===p&&(o=h(o,u))):(c.set(d,0),O.bezierBoundingBox(i,s,...e.slice(t,t+6),c),O.rectBoundingBox(...c,r),a>c[1]?(n=c[0],a=c[1]):a===c[1]&&(n=h(n,c[0])),l<c[3]?(o=c[2],l=c[3]):l===c[3]&&(o=h(o,c[2]))),i=u,s=p}let u=this.#e;u[0]=r[0]-this.#i,u[1]=r[1]-this.#i,u[2]=r[2]-r[0]+2*this.#i,u[3]=r[3]-r[1]+2*this.#i,this.firstPoint=[n,a],this.lastPoint=[o,l]}get box(){return this.#e}newOutliner(t,e,i,s,r,n=0){return new ns(t,e,i,s,r,n)}getNewOutline(t,e){let[i,s,r,n]=this.#e,[a,o,l,h]=this.#t,d=r*l,c=n*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:this.#r[0]*d+u,y:this.#r[1]*c+p},this.#t,this.#n,t,this.#s,e??this.#i);for(let t=2;t<this.#r.length;t+=2)g.add({x:this.#r[t]*d+u,y:this.#r[t+1]*c+p});return g.getOutlines()}}class os{#t;#e;#i;#s=[];#r=[];constructor(t,e=0,i=0,s=!0){let r=d.slice(),n=1e-4;for(let{x:i,y:s,width:a,height:o}of t){let t=Math.floor((i-e)/n)*n,l=Math.ceil((i+a+e)/n)*n,h=Math.floor((s-e)/n)*n,d=Math.ceil((s+o+e)/n)*n,c=[t,h,d,!0],u=[l,h,d,!1];this.#s.push(c,u),O.rectBoundingBox(t,h,l,d,r)}let a=r[2]-r[0]+2*i,o=r[3]-r[1]+2*i,l=r[0]-i,h=r[1]-i,c=s?-1/0:1/0,u=1/0,p=this.#s.at(s?-1:-2),g=[p[0],p[2]];for(let t of this.#s){let[e,i,r,n]=t;!n&&s?i<u?(u=i,c=e):i===u&&(c=Math.max(c,e)):n&&!s&&(i<u?(u=i,c=e):i===u&&(c=Math.min(c,e))),t[0]=(e-l)/a,t[1]=(i-h)/o,t[2]=(r-h)/o}this.#t=new Float32Array([l,h,a,o]),this.#e=[c,u],this.#i=g}getOutlines(){this.#s.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);let t=[];for(let e of this.#s)e[3]?(t.push(...this.#h(e)),this.#o(e)):(this.#l(e),t.push(...this.#h(e)));return this.#n(t)}#n(t){let e=[],i=new Set;for(let i of t){let[t,s,r]=i;e.push([t,s,i],[t,r,i])}e.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,s=e.length;t<s;t+=2){let s=e[t][2],r=e[t+1][2];s.push(r),r.push(s),i.add(s),i.add(r)}let s,r=[];for(;i.size>0;){let t=i.values().next().value,[e,n,a,o,l]=t;i.delete(t);let h=e,d=n;for(s=[e,a],r.push(s);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,n,a,o,l]=t,h!==e&&(s.push(h,d,e,d===n?n:a),h=e),d=d===n?a:n}s.push(h,d)}return new ls(r,this.#t,this.#e,this.#i)}#a(t){let e=this.#r,i=0,s=e.length-1;for(;i<=s;){let r=i+s>>1,n=e[r][0];if(n===t)return r;n<t?i=r+1:s=r-1}return s+1}#o([,t,e]){let i=this.#a(t);this.#r.splice(i,0,[t,e])}#l([,t,e]){let i=this.#a(t);for(let s=i;s<this.#r.length;s++){let[i,r]=this.#r[s];if(i!==t)break;if(i===t&&r===e)return void this.#r.splice(s,1)}for(let s=i-1;s>=0;s--){let[i,r]=this.#r[s];if(i!==t)break;if(i===t&&r===e)return void this.#r.splice(s,1)}}#h(t){let[e,i,s]=t,r=[[e,i,s]],n=this.#a(s);for(let t=0;t<n;t++){let[i,s]=this.#r[t];for(let t=0,n=r.length;t<n;t++){let[,a,o]=r[t];if(!(s<=a||o<=i))if(a>=i)if(o>s)r[t][1]=s;else{if(1===n)return[];r.splice(t,1),t--,n--}else r[t][2]=i,o>s&&r.push([e,s,o])}}return r}}class ls extends rs{#t;#e;constructor(t,e,i,s){super(),this.#e=t,this.#t=e,this.firstPoint=i,this.lastPoint=s}toSVGPath(){let t=[];for(let e of this.#e){let[i,s]=e;t.push(`M${i} ${s}`);for(let r=2;r<e.length;r+=2){let n=e[r],a=e[r+1];n===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${n}`),i=n)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],r){let n=[],a=i-t,o=s-e;for(let e of this.#e){let i=Array(e.length);for(let r=0;r<e.length;r+=2)i[r]=t+e[r]*a,i[r+1]=s-e[r+1]*o;n.push(i)}return n}get box(){return this.#t}get classNamesForOutlining(){return["highlightOutline"]}}class hs extends ns{newFreeDrawOutline(t,e,i,s,r,n){return new ds(t,e,i,s,r,n)}}class ds extends as{newOutliner(t,e,i,s,r,n=0){return new hs(t,e,i,s,r,n)}}class cs extends _t{#t=null;#e=0;#i;#s=null;#r=null;#n=null;#a=null;#o=0;#l=null;#h=null;#d=null;#c=!1;#u=null;#p=null;#g=null;#f="";#m;#y="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=9;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=cs.prototype;return M(this,"_keyboardManager",new yt([[["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||cs._defaultColor,this.#m=t.thickness||cs._defaultThickness,this.opacity=t.opacity||cs._defaultOpacity,this.#i=t.boxes||null,this.#y=t.methodOfCreation||"",this.#f=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#c=!0,this.#v(t),this.#S()):this.#i&&(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#a=t.focusNode,this.#o=t.focusOffset,this.#b(),this.#S(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(_t._l10nAlert.highlight)}get telemetryInitialData(){return{action:"added",type:this.#c?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#m,methodOfCreation:this.#y}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#b(){let t=new os(this.#i,.001);this.#h=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#h.box;let e=new os(this.#i,.0025,.001,"ltr"===this._uiManager.direction);this.#n=e.getOutlines();let{firstPoint:i}=this.#h;this.#u=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height];let{lastPoint:s}=this.#n;this.#p=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#v({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#h=t,this.#n=t.getNewOutline(this.#m/2+1.5,.0025),e>=0)this.#d=e,this.#s=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#g=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#n.box,path:{d:this.#n.toSVGPath()}},!0);else if(this.parent){let e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#d,{bbox:cs.#C(this.#h.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#g,{bbox:cs.#C(this.#n.box,e),path:{d:this.#n.toSVGPath()}})}let[s,r,n,a]=t.box;switch(this.rotation){case 0:this.x=s,this.y=r,this.width=n,this.height=a;break;case 90:{let[t,e]=this.parentDimensions;this.x=r,this.y=1-s,this.width=n*e/t,this.height=a*t/e;break}case 180:this.x=1-s,this.y=1-r,this.width=n,this.height=a;break;case 270:{let[t,e]=this.parentDimensions;this.x=1-r,this.y=s,this.width=n*e/t,this.height=a*t/e;break}}let{firstPoint:o}=t;this.#u=[(o[0]-s)/n,(o[1]-r)/a];let{lastPoint:l}=this.#n;this.#p=[(l[0]-s)/n,(l[1]-r)/a]}static initialize(t,e){_t.initialize(t,e),cs._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case y:cs._defaultColor=e;break;case 32:cs._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#p}get commentButtonPosition(){return this.#u}updateParams(t,e){switch(t){case y:this.#A(e);break;case 32:this.#w(e)}}static get defaultPropertiesToUpdate(){return[[y,cs._defaultColor],[32,cs._defaultThickness]]}get propertiesToUpdate(){return[[y,this.color||cs._defaultColor],[32,this.#m||cs._defaultThickness],[33,this.#c]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#d,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#r?.updateColor(this.color),super.onUpdatedColor()}#A(t){let e=(t,e)=>{this.color=t,this.opacity=e,this.onUpdatedColor()},i=this.color,s=this.opacity;this.addCommands({cmd:e.bind(this,t,cs._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:y,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#w(t){let e=this.#m,i=t=>{this.#m=t,this.#x(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:22,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",this.#r=new $i({editor:this})]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#P())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#P())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#_(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#S(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#_():t&&(this.#S(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#x(t){this.#c&&(this.#v({highlightOutlines:this.#h.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims())}#_(){null!==this.#d&&this.parent&&(this.parent.drawLayer.remove(this.#d),this.#d=null,this.parent.drawLayer.remove(this.#g),this.#g=null)}#S(t=this.parent){null===this.#d&&(({id:this.#d,clipPathId:this.#s}=t.drawLayer.draw({bbox:this.#h.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#c},path:{d:this.#h.toSVGPath()}},!1,!0)),this.#g=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#c},bbox:this.#n.box,path:{d:this.#n.toSVGPath()}},this.#c),this.#l&&(this.#l.style.clipPath=this.#s))}static#C([t,e,i,s],r){switch(r){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){let e,{drawLayer:i}=this.parent;this.#c?(t=(t-this.rotation+360)%360,e=cs.#C(this.#h.box,t)):e=cs.#C([this.x,this.y,this.width,this.height],t),i.updateProperties(this.#d,{bbox:e,root:{"data-main-rotation":t}}),i.updateProperties(this.#g,{bbox:cs.#C(this.#n.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#f&&(t.setAttribute("aria-label",this.#f),t.setAttribute("role","mark")),this.#c?t.classList.add("free"):this.div.addEventListener("keydown",this.#M.bind(this),{signal:this._uiManager._signal});let e=this.#l=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#s,this.setDims(),ut(this,this.#l,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{hovered:!1}})}#M(t){cs._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#k(!0);break;case 1:case 3:this.#k(!1)}}#k(t){if(!this.#t)return;let e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#a,this.#o)}select(){super.select(),this.#g&&this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#g&&(this.parent?.drawLayer.updateProperties(this.#g,{rootClass:{selected:!1}}),this.#c||this.#k(!1))}get _mustFixPosition(){return!this.#c}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#d,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#g,{rootClass:{hidden:!t}}))}#P(){return this.#c?this.rotation:0}#T(){if(this.#c)return null;let[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,r=this.#i,n=new Float32Array(8*r.length),a=0;for(let{x:o,y:l,width:h,height:d}of r){let r=o*t+i,c=(1-l)*e+s;n[a]=n[a+4]=r,n[a+1]=n[a+3]=c,n[a+2]=n[a+6]=r+h*t,n[a+5]=n[a+7]=c-d*e,a+=8}return n}#E(t){return this.#h.serialize(t,this.#P())}static startHighlighting(t,e,{target:i,x:s,y:r}){let{x:n,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#I(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",Q,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",J,{signal:d}),i.addEventListener("pointermove",this.#D.bind(this,t),{signal:d}),this._freeHighlight=new hs({x:s,y:r},[n,a,o,l],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#D(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#I(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,i){let s=null;if(t instanceof ts){let{data:{quadPoints:e,rect:i,rotation:r,id:n,color:a,opacity:o,popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:u},parent:{page:{pageNumber:p}}}=t;s=t={annotationType:9,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:r,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:u}}else if(t instanceof Qi){let{data:{inkLists:e,rect:i,rotation:r,id:n,color:a,borderStyle:{rawWidth:o},popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:u},parent:{page:{pageNumber:p}}}=t;s=t={annotationType:9,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:r,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:u}}let{color:r,quadPoints:n,inkLists:a,outlines:o,opacity:l}=t,h=await super.deserialize(t,e,i);h.color=O.makeHexColor(...r),h.opacity=l||1,a&&(h.#m=t.thickness),h._initialData=s,t.comment&&h.setCommentData(t);let[d,c]=h.pageDimensions,[u,p]=h.pageTranslation;if(n){let t=h.#i=[];for(let e=0;e<n.length;e+=8)t.push({x:(n[e]-u)/d,y:1-(n[e+1]-p)/c,width:(n[e+2]-n[e])/d,height:(n[e+1]-n[e+5])/c});h.#b(),h.#S(),h.rotate(h.rotation)}else if(a||o){h.#c=!0;let t=(a||o.points)[0],i={x:t[0]-u,y:c-(t[1]-p)},s=new hs(i,[0,0,d,c],1,h.#m/2,!0,.001);for(let e=0,r=t.length;e<r;e+=2)i.x=t[e]-u,i.y=c-(t[e+1]-p),s.add(i);let{id:r,clipPathId:n}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);h.#v({highlightOutlines:s.getOutlines(),highlightId:r,clipPathId:n}),h.#S(),h.rotate(h.parentRotation)}return h}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=_t._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return Object.assign(i,{color:e,opacity:this.opacity,thickness:this.#m,quadPoints:this.#T(),outlines:this.#E(i.rect)}),this.addComment(i),this.annotationElementId&&!this.#F(i)?null:(i.id=this.annotationElementId,i)}#F(t){let{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,i)=>t!==e[i])}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}}class us{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}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(){S("Not implemented")}}class ps extends _t{#t=null;#e;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#i=null;static#s=null;static#r=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(t){t.drawOutlines&&(this.#n(t),this.#l())}#n({drawOutlines:t,drawId:e,drawingOptions:i}){this.#t=t,this._drawingOptions||=i,this.annotationElementId||this._uiManager.a11yAlert(_t._l10nAlert[this.editorType]),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#a(t,this.parent),this.#c(t.box)}#a(t,e){let{id:i}=e.drawLayer.draw(ps._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){let i=new Set(Object.keys(t));for(let[s,r]of Object.entries(e))i.has(s)?Object.assign(t[s],r):t[s]=r;return t}static getDefaultDrawingOptions(t){S("Not implemented")}static get typesMap(){S("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(ps.#i.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){let s=this._drawingOptions,r=s[e],n=i=>{s.updateProperty(e,i);let r=this.#t.updateProperty(e,i);r&&this.#c(r),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:n.bind(this,i),undo:n.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e){let i=this.constructor.typesMap.get(this.colorType),s=this.constructor.typesMap.get(this.opacityType),r=this._drawingOptions,n=r[i],a=r[s],o=(t,e)=>{r.updateProperty(i,t),r.updateProperty(s,e),this.#t.updateProperty(i,t),this.#t.updateProperty(s,e),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,t,e),undo:o.bind(this,n,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:24,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,ps._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#d()),{bbox:this.#u()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,ps._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#d()),{bbox:this.#u()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#u()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,ps._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#d(),this.parentDimensions),{bbox:this.#u()}))}_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.#o(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#l(),this.#c(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#o()):t&&(this._uiManager.addShouldRescale(this),this.#l(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#o(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#l(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#a(this.#t,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#h([t,e,i,s]){let{parentDimensions:[r,n],rotation:a}=this;switch(a){case 90:return[e,1-t,n/r*i,r/n*s];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,n/r*i,r/n*s];default:return[t,e,i,s]}}#d(){let{x:t,y:e,width:i,height:s,parentDimensions:[r,n],rotation:a}=this;switch(a){case 90:return[1-e,t,r/n*i,n/r*s];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,r/n*i,n/r*s];default:return[t,e,i,s]}}#c(t){[this.x,this.y,this.width,this.height]=this.#h(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#u(){let{x:t,y:e,width:i,height:s,rotation:r,parentRotation:n,parentDimensions:[a,o]}=this;switch((4*r+n)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-a/o*i,o/a*s,a/o*i];case 5:return[1-e,t,a/o*i,o/a*s];case 6:return[1-t-o/a*s,1-e,o/a*s,a/o*i];case 7:return[e-a/o*i,1-t-o/a*s,a/o*i,o/a*s];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-o/a*s,e,o/a*s,a/o*i];case 13:return[1-e-a/o*i,t-o/a*s,a/o*i,o/a*s];case 14:return[1-t,1-e-a/o*i,o/a*s,a/o*i];case 15:return[e,1-t,a/o*i,o/a*s];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,ps._mergeSVGProperties({bbox:this.#u()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#c(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);let i=super.render();i.classList.add("draw");let s=document.createElement("div");return i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,r){S("Not implemented")}static startDrawing(t,e,i,s){let{target:r,offsetX:n,offsetY:a,pointerId:o,pointerType:l}=s;if(pt.isInitializedAndDifferentPointerType(l))return;let{viewport:{rotation:h}}=t,{width:d,height:c}=r.getBoundingClientRect(),u=ps.#s=new AbortController,p=t.combinedSignal(u);pt.setPointer(l,o),window.addEventListener("pointerup",t=>{pt.isSamePointerIdOrRemove(t.pointerId)&&this._endDraw(t)},{signal:p}),window.addEventListener("pointercancel",t=>{pt.isSamePointerIdOrRemove(t.pointerId)&&this._currentParent.endDrawingSession()},{signal:p}),window.addEventListener("pointerdown",t=>{pt.isSamePointerType(t.pointerType)&&(pt.initializeAndAddPointerId(t.pointerId),ps.#i.isCancellable()&&(ps.#i.removeLastElement(),ps.#i.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",J,{signal:p}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),r.addEventListener("touchmove",t=>{pt.isSameTimeStamp(t.timeStamp)&&Q(t)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),ps.#i?t.drawLayer.updateProperties(this._currentDrawId,ps.#i.startNew(n,a,d,c,h)):(e.updateUIForDefaultProperties(this),ps.#i=this.createDrawerInstance(n,a,d,c,h),ps.#r=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(ps.#r.toSVGProperties(),ps.#i.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(pt.isSameTimeStamp(t.timeStamp),!ps.#i)return;let{offsetX:e,offsetY:i,pointerId:s}=t;pt.isSamePointerId(s)&&(pt.isUsingMultiplePointers()?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,ps.#i.add(e,i)),pt.setTimeStamp(t.timeStamp),Q(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,ps.#i=null,ps.#r=null,pt.clearTimeStamp()),ps.#s&&(ps.#s.abort(),ps.#s=null,pt.clearPointerIds())}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,ps.#i.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let t=ps.#i,i=this._currentDrawId,s=t.getLastElement();return void e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:41})}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(41),!ps.#i.isEmpty()){let{pageDimensions:[i,s],scale:r}=e,n=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:ps.#i.getOutlines(i*r,s*r,r,this._INNER_MARGIN),drawingOptions:ps.#r,mustBeCommitted:!t});return this._cleanup(!0),n}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,r,n){S("Not implemented")}static async deserialize(t,e,i){let{rawDims:{pageWidth:s,pageHeight:r,pageX:n,pageY:a}}=e.viewport,o=this.deserializeDraw(n,a,s,r,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#n({drawOutlines:o}),l.#l(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){let[e,i]=this.pageTranslation,[s,r]=this.pageDimensions;return this.#t.serialize([e,i,s,r],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class gs{#t=new Float64Array(6);#e;#i;#s;#r;#n;#a="";#o=0;#l=new fs;#h;#d;constructor(t,e,i,s,r,n){this.#h=i,this.#d=s,this.#s=r,this.#r=n,[t,e]=this.#c(t,e);let a=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#n=[t,e],this.#i=[{line:a,points:this.#n}],this.#t.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#r=e)}#c(t,e){return rs._normalizePoint(t,e,this.#h,this.#d,this.#s)}isEmpty(){return!this.#i||0===this.#i.length}isCancellable(){return this.#n.length<=10}add(t,e){[t,e]=this.#c(t,e);let[i,s,r,n]=this.#t.subarray(2,6),a=t-r,o=e-n;return Math.hypot(this.#h*a,this.#d*o)<=2?null:(this.#n.push(t,e),isNaN(i)?(this.#t.set([r,n,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([i,s,r,n,t,e],0),this.#e.push(...rs.createBezierPoints(i,s,r,n,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){return this.add(t,e)||(2===this.#n.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,r){this.#h=i,this.#d=s,this.#s=r,[t,e]=this.#c(t,e);let n=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#n=[t,e];let a=this.#i.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#i.push({line:n,points:this.#n}),this.#t.set(n,0),this.#o=0,this.toSVGPath(),null}getLastElement(){return this.#i.at(-1)}setLastElement(t){return this.#i?(this.#i.push(t),this.#e=t.line,this.#n=t.points,this.#o=0,{path:{d:this.toSVGPath()}}):this.#l.setLastElement(t)}removeLastElement(){if(!this.#i)return this.#l.removeLastElement();this.#i.pop(),this.#a="";for(let t=0,e=this.#i.length;t<e;t++){let{line:e,points:i}=this.#i[t];this.#e=e,this.#n=i,this.#o=0,this.toSVGPath()}return{path:{d:this.#a}}}toSVGPath(){let t=rs.svgRound(this.#e[4]),e=rs.svgRound(this.#e[5]);if(2===this.#n.length)return this.#a=`${this.#a} M ${t} ${e} Z`,this.#a;if(this.#n.length<=6){let i=this.#a.lastIndexOf("M");this.#a=`${this.#a.slice(0,i)} M ${t} ${e}`,this.#o=6}if(4===this.#n.length){let t=rs.svgRound(this.#e[10]),e=rs.svgRound(this.#e[11]);return this.#a=`${this.#a} L ${t} ${e}`,this.#o=12,this.#a}let i=[];0===this.#o&&(i.push(`M ${t} ${e}`),this.#o=6);for(let t=this.#o,e=this.#e.length;t<e;t+=6){let[e,s,r,n,a,o]=this.#e.slice(t,t+6).map(rs.svgRound);i.push(`C${e} ${s} ${r} ${n} ${a} ${o}`)}return this.#a+=i.join(" "),this.#o=this.#e.length,this.#a}getOutlines(t,e,i,s){let r=this.#i.at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),this.#l.build(this.#i,t,e,i,this.#s,this.#r,s),this.#t=null,this.#e=null,this.#i=null,this.#a=null,this.#l}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class fs extends rs{#t;#e=0;#i;#s;#r;#n;#a;#o;#l;build(t,e,i,s,r,n,a){this.#r=e,this.#n=i,this.#a=s,this.#o=r,this.#l=n,this.#i=a??0,this.#s=t,this.#c()}get thickness(){return this.#l}setLastElement(t){return this.#s.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#s.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#s)if(t.push(`M${rs.svgRound(e[4])} ${rs.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${rs.svgRound(e[10])} ${rs.svgRound(e[11])}`);else for(let i=6,s=e.length;i<s;i+=6){let[s,r,n,a,o,l]=e.subarray(i,i+6).map(rs.svgRound);t.push(`C${s} ${r} ${n} ${a} ${o} ${l}`)}else t.push("Z");return t.join("")}serialize([t,e,i,s],r){let n,a,o,l,h,d,c,u,p,g=[],f=[],[m,y,b,v]=this.#d();switch(this.#o){case 0:p=rs._rescale,n=t,a=e+s,o=i,l=-s,h=t+m*i,d=e+(1-y-v)*s,c=t+(m+b)*i,u=e+(1-y)*s;break;case 90:p=rs._rescaleAndSwap,n=t,a=e,o=i,l=s,h=t+y*i,d=e+m*s,c=t+(y+v)*i,u=e+(m+b)*s;break;case 180:p=rs._rescale,n=t+i,a=e,o=-i,l=s,h=t+(1-m-b)*i,d=e+y*s,c=t+(1-m)*i,u=e+(y+v)*s;break;case 270:p=rs._rescaleAndSwap,n=t+i,a=e+s,o=-i,l=-s,h=t+(1-y-v)*i,d=e+(1-m-b)*s,c=t+(1-y)*i,u=e+(1-m)*s}for(let{line:t,points:e}of this.#s)g.push(p(t,n,a,o,l,r?Array(t.length):null)),f.push(p(e,n,a,o,l,r?Array(e.length):null));return{lines:g,points:f,rect:[h,d,c,u]}}static deserialize(t,e,i,s,r,{paths:{lines:n,points:a},rotation:o,thickness:l}){let h,d,c,u,p,g=[];switch(o){case 0:p=rs._rescale,h=-t/i,d=e/s+1,c=1/i,u=-1/s;break;case 90:p=rs._rescaleAndSwap,h=-e/s,d=-t/i,c=1/s,u=1/i;break;case 180:p=rs._rescale,h=t/i+1,d=-e/s,c=-1/i,u=1/s;break;case 270:p=rs._rescaleAndSwap,h=e/s+1,d=t/i+1,c=-1/s,u=-1/i}if(!n){n=[];for(let t of a){let e=t.length;if(2===e){n.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){n.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}let i=new Float32Array(3*(e-2));n.push(i);let[s,r,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,r],0);for(let n=4;n<e;n+=2){let e=t[n],l=t[n+1];i.set(rs.createBezierPoints(s,r,a,o,e,l),3*(n-2)),[s,r,a,o]=[a,o,e,l]}}}for(let t=0,e=n.length;t<e;t++)g.push({line:p(n[t].map(t=>t??NaN),h,d,c,u),points:p(a[t].map(t=>t??NaN),h,d,c,u)});let f=new this.prototype.constructor;return f.build(g,i,s,1,o,l,r),f}#h(t=this.#l){let e=this.#i+t/2*this.#a;return this.#o%180==0?[e/this.#r,e/this.#n]:[e/this.#n,e/this.#r]}#d(){let[t,e,i,s]=this.#t,[r,n]=this.#h(0);return[t+r,e+n,i-2*r,s-2*n]}#c(){let t=this.#t=c.slice();for(let{line:e}of this.#s){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6)O.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],s=e[5];for(let r=6,n=e.length;r<n;r+=6){let[n,a,o,l,h,d]=e.subarray(r,r+6);O.bezierBoundingBox(i,s,n,a,o,l,h,d,t),i=h,s=d}}let[e,i]=this.#h();t[0]=$(t[0]-e,0,1),t[1]=$(t[1]-i,0,1),t[2]=$(t[2]+e,0,1),t[3]=$(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return"stroke-width"===t?this.#u(e):null}#u(t){let[e,i]=this.#h();this.#l=t;let[s,r]=this.#h(),[n,a]=[s-e,r-i],o=this.#t;return o[0]-=n,o[1]-=a,o[2]+=2*n,o[3]+=2*a,o}updateParentDimensions([t,e],i){let[s,r]=this.#h();this.#r=t,this.#n=e,this.#a=i;let[n,a]=this.#h(),o=n-s,l=a-r,h=this.#t;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(rs.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${rs.svgRound(t)} ${rs.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#t,i=0,s=0,r=0,n=0,a=0,o=0;switch(this.#e){case 90:s=e/t,r=-t/e,a=t;break;case 180:i=-1,n=-1,a=t,o=e;break;case 270:s=-e/t,r=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${r} ${n} ${rs.svgRound(a)} ${rs.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){let[r,n]=this.#h(),[a,o,l,h]=this.#t;if(Math.abs(l-r)<=rs.PRECISION||Math.abs(h-n)<=rs.PRECISION){let r=t+i/2-(a+l/2),n=e+s/2-(o+h/2);return{path:{"transform-origin":`${rs.svgRound(t)} ${rs.svgRound(e)}`,transform:`${this.rotationTransform} translate(${r} ${n})`}}}let d=(i-2*r)/(l-2*r),c=(s-2*n)/(h-2*n),u=l/i,p=h/s;return{path:{"transform-origin":`${rs.svgRound(a)} ${rs.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${rs.svgRound(r)} ${rs.svgRound(n)}) scale(${d} ${c}) translate(${rs.svgRound(-r)} ${rs.svgRound(-n)})`}}}getPathResizedSVGProperties([t,e,i,s]){let[r,n]=this.#h(),a=this.#t,[o,l,h,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-r)<=rs.PRECISION||Math.abs(d-n)<=rs.PRECISION){let r=t+i/2-(o+h/2),n=e+s/2-(l+d/2);for(let{line:t,points:e}of this.#s)rs._translate(t,r,n,t),rs._translate(e,r,n,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${rs.svgRound(t)} ${rs.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let c=(i-2*r)/(h-2*r),u=(s-2*n)/(d-2*n),p=-c*(o+r)+t+r,g=-u*(l+n)+e+n;if(1!==c||1!==u||0!==p||0!==g)for(let{line:t,points:e}of this.#s)rs._rescale(t,p,g,c,u,t),rs._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${rs.svgRound(t)} ${rs.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){let[s,r]=i,n=this.#t,a=t-n[0],o=e-n[1];if(this.#r===s&&this.#n===r)for(let{line:t,points:e}of this.#s)rs._translate(t,a,o,t),rs._translate(e,a,o,e);else{let t=this.#r/s,e=this.#n/r;this.#r=s,this.#n=r;for(let{line:i,points:s}of this.#s)rs._rescale(i,a,o,t,e,i),rs._rescale(s,a,o,t,e,s);n[2]*=t,n[3]*=e}return n[0]=t,n[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${rs.svgRound(t)} ${rs.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${rs.svgRound(t[0])} ${rs.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class ms extends us{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:_t._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){let t=new ms(this._viewParameters);return t.updateAll(this),t}}class ys extends ps{static _type="ink";static _editorType=15;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){_t.initialize(t,e),this._defaultDrawingOptions=new ms(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return M(this,"typesMap",new Map([[22,"stroke-width"],[21,"stroke"],[23,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,r){return new gs(t,e,i,s,r,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,r,n){return fs.deserialize(t,e,i,s,r,n)}static async deserialize(t,e,i){let s=null;if(t instanceof Qi){let{data:{inkLists:e,rect:i,rotation:r,id:n,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h,richText:d,contentsObj:c,creationDate:u,modificationDate:p},parent:{page:{pageNumber:g}}}=t;s=t={annotationType:15,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:r,annotationElementId:n,id:n,deleted:!1,popupRef:h,richText:d,comment:c?.str||null,creationDate:u,modificationDate:p}}let r=await super.deserialize(t,e,i);return r._initialData=s,t.comment&&r.setCommentData(t),r}get toolbarButtons(){return this._colorPicker||=new Ui(this),[["colorPicker",this._colorPicker]]}get colorType(){return 21}get colorAndOpacityType(){return 24}get opacityType(){return 23}updateParams(t,e){24===t?this._updateColorAndOpacity(e.color,e.opacity):super.updateParams(t,e)}static updateDefaultParams(t,e){24!==t?super.updateDefaultParams(t,e):(super.updateDefaultParams(21,e.color),super.updateDefaultParams(23,e.opacity))}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.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:i}){this._drawingOptions=ys.getDefaultDrawingOptions({stroke:O.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":r,"stroke-width":n}}=this,a=Object.assign(super.serialize(t),{color:_t._colorManager.convert(s),opacity:r,thickness:n,paths:{lines:e,points:i}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!this.#t(a)?null:(a.id=this.annotationElementId,a)}#t(t){let{color:e,thickness:i,opacity:s,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==s||t.pageIndex!==r}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class bs extends fs{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class vs{static#t={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#e(t,e,i,s){return s-=e,0===(i-=t)?s>0?0:4:1===i?s+6:2-s}static#i=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#s(t,e,i,s,r,n,a){let o=this.#e(i,s,r,n);for(let r=0;r<8;r++){let n=(-r+o-a+16)%8;if(0!==t[(i+this.#i[2*n])*e+(s+this.#i[2*n+1])])return n}return-1}static#r(t,e,i,s,r,n,a){let o=this.#e(i,s,r,n);for(let r=0;r<8;r++){let n=(r+o+a+16)%8;if(0!==t[(i+this.#i[2*n])*e+(s+this.#i[2*n+1])])return n}return-1}static#n(t,e,i,s){let r=t.length,n=new Int32Array(r);for(let e=0;e<r;e++)n[e]=+(t[e]<=s);for(let t=1;t<i-1;t++)n[t*e]=n[t*e+e-1]=0;for(let t=0;t<e;t++)n[t]=n[e*i-1-t]=0;let a,o=1,l=[];for(let t=1;t<i-1;t++){a=1;for(let i=1;i<e-1;i++){let s=t*e+i,r=n[s];if(0===r)continue;let h=t,d=i;if(1===r&&0===n[s-1])o+=1,--d;else{if(!(r>=1&&0===n[s+1])){1!==r&&(a=Math.abs(r));continue}o+=1,d+=1,r>1&&(a=r)}let c,u=[i,t],p=d===i+1,g={isHole:p,points:u,id:o,parent:0};l.push(g);for(let t of l)if(t.id===a){c=t;break}g.parent=c?c.isHole?p?c.parent:a:p?a:c.parent:p?a:0;let f=this.#s(n,e,t,i,h,d,0);if(-1===f){n[s]=-o,1!==n[s]&&(a=Math.abs(n[s]));continue}let m=this.#i[2*f],y=this.#i[2*f+1],b=t+m,v=i+y;h=b,d=v;let A=t,w=i;for(;;){let r=this.#r(n,e,A,w,h,d,1);m=this.#i[2*r],y=this.#i[2*r+1];let l=A+m,c=w+y;u.push(c,l);let p=A*e+w;if(0===n[p+1]?n[p]=-o:1===n[p]&&(n[p]=o),l===t&&c===i&&A===b&&w===v){1!==n[s]&&(a=Math.abs(n[s]));break}h=A,d=w,A=l,w=c}}}return l}static#a(t,e,i,s){if(i-e<=4){for(let r=e;r<i-2;r+=2)s.push(t[r],t[r+1]);return}let r=t[e],n=t[e+1],a=t[i-4]-r,o=t[i-3]-n,l=Math.hypot(a,o),h=a/l,d=o/l,c=h*n-d*r,u=o/a,p=1/l,g=Math.atan(u),f=Math.cos(g),m=Math.sin(g),y=p*(Math.abs(f)+Math.abs(m)),b=p*(1-y+y**2),v=Math.max(Math.atan(Math.abs(m+f)*b),Math.atan(Math.abs(m-f)*b)),A=0,w=e;for(let s=e+2;s<i-2;s+=2){let e=Math.abs(c-h*t[s+1]+d*t[s]);e>A&&(w=s,A=e)}A>(l*v)**2?(this.#a(t,e,w+2,s),this.#a(t,w,i,s)):s.push(r,n)}static#o(t){let e=[],i=t.length;return this.#a(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static#l(t,e,i,s,r,n){let a=new Float32Array(n**2),o=-2*s**2,l=n>>1;for(let t=0;t<n;t++){let e=(t-l)**2;for(let i=0;i<n;i++)a[t*n+i]=Math.exp((e+(i-l)**2)/o)}let h=new Float32Array(256),d=-2*r**2;for(let t=0;t<256;t++)h[t]=Math.exp(t**2/d);let c=t.length,u=new Uint8Array(c),p=new Uint32Array(256);for(let s=0;s<i;s++)for(let r=0;r<e;r++){let o=s*e+r,d=t[o],c=0,g=0;for(let o=0;o<n;o++){let u=s+o-l;if(!(u<0||u>=i))for(let i=0;i<n;i++){let s=r+i-l;if(s<0||s>=e)continue;let p=t[u*e+s],f=a[o*n+i]*h[Math.abs(p-d)];c+=p*f,g+=f}}p[u[o]=Math.round(c/g)]++}return[u,p]}static#h(t){let e=new Uint32Array(256);for(let i of t)e[i]++;return e}static#d(t){let e=t.length,i=new Uint8ClampedArray(e>>2),s=-1/0,r=1/0;for(let e=0,n=i.length;e<n;e++){let n=i[e]=t[e<<2];s=Math.max(s,n),r=Math.min(r,n)}let n=255/(s-r);for(let t=0,e=i.length;t<e;t++)i[t]=(i[t]-r)*n;return i}static#c(t){let e,i=-1/0,s=-1/0,r=t.findIndex(t=>0!==t),n=r,a=r;for(e=r;e<256;e++){let r=t[e];r>i&&(e-n>s&&(s=e-n,a=e-1),i=r,n=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#u(t){let e=t,{width:i,height:s}=t,{maxDim:r}=this.#t,n=i,a=s;if(i>r||s>r){let o=i,l=s,h=Math.log2(Math.max(i,s)/r),d=Math.floor(h);h=h===d?d-1:d;for(let i=0;i<h;i++){n=Math.ceil(o/2),a=Math.ceil(l/2);let i=new OffscreenCanvas(n,a);i.getContext("2d").drawImage(t,0,0,o,l,0,0,n,a),o=n,l=a,t!==e&&t.close(),t=i.transferToImageBitmap()}let c=Math.min(r/n,r/a);n=Math.round(n*c),a=Math.round(a*c)}let o=new OffscreenCanvas(n,a).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,n,a),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,n,a);let l=o.getImageData(0,0,n,a).data;return[this.#d(l),n,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},r,n,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1}),d=h.font=`${i} ${s} 200px ${e}`,{actualBoundingBoxLeft:c,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:f,fontBoundingBoxDescent:m,width:y}=h.measureText(t),b=Math.ceil(1.5*Math.max(Math.abs(c)+Math.abs(u)||0,y)),v=Math.ceil(1.5*Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(f)+Math.abs(m)||200));l=new OffscreenCanvas(b,v),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,b,v),h.fillStyle="black",h.fillText(t,.5*b/2,1.5*v/2);let A=this.#d(h.getImageData(0,0,b,v).data),w=this.#h(A),x=this.#c(w),_=this.#n(A,b,v,x);return this.processDrawnLines({lines:{curves:_,width:b,height:v},pageWidth:r,pageHeight:n,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,r){let[n,a,o]=this.#u(t),[l,h]=this.#l(n,a,o,Math.hypot(a,o)*this.#t.sigmaSFactor,this.#t.sigmaR,this.#t.kernelSize),d=this.#c(h),c=this.#n(l,a,o,d);return this.processDrawnLines({lines:{curves:c,width:a,height:o},pageWidth:e,pageHeight:i,rotation:s,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:r,mustSmooth:n,areContours:a}){s%180!=0&&([e,i]=[i,e]);let{curves:o,width:l,height:h}=t,d=t.thickness??0,c=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,f=[];for(let{points:t}of o){let e=n?this.#o(t):t;if(!e)continue;f.push(e);let i=e.length,s=new Float32Array(i),r=new Float32Array(3*(2===i?2:i-2));if(c.push({line:r,points:s}),2===i){s[0]=e[0]*p,s[1]=e[1]*g,r.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let[a,o,l,h]=e;a*=p,o*=g,l*=p,h*=g,s.set([a,o,l,h],0),r.set([NaN,NaN,NaN,NaN,a,o],0);for(let t=4;t<i;t+=2){let i=s[t]=e[t]*p,n=s[t+1]=e[t+1]*g;r.set(rs.createBezierPoints(a,o,l,h,i,n),3*(t-2)),[a,o,l,h]=[l,h,i,n]}}if(0===c.length)return null;let m=a?new bs:new fs;return m.build(c,e,i,1,s,a?0:d,r),{outline:m,newCurves:f,areContours:a,thickness:d,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:r}){let n,a=1/0,o=-1/0,l=0;for(let e of t){l+=e.length;for(let t=2,i=e.length;t<i;t++){let i=e[t]-e[t-2];a=Math.min(a,i),o=Math.max(o,i)}}n=a>=-128&&o<=127?Int8Array:a>=-32768&&o<=32767?Int16Array:Int32Array;let h=t.length,d=8+3*h,c=new Uint32Array(d),u=0;c[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*n.BYTES_PER_ELEMENT,c[u++]=0,c[u++]=s,c[u++]=r,c[u++]=+!e,c[u++]=Math.max(0,Math.floor(i??0)),c[u++]=h,c[u++]=n.BYTES_PER_ELEMENT;for(let e of t)c[u++]=e.length-2,c[u++]=e[0],c[u++]=e[1];let p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(c);let f=n.prototype.constructor;for(let e of t){let t=new f(e.length-2);for(let i=2,s=e.length;i<s;i++)t[i-2]=e[i]-e[i-2];g.write(t)}return g.close(),(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(t){try{let e=Uint8Array.fromBase64(t),{readable:i,writable:s}=new DecompressionStream("deflate-raw"),r=s.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let n=null,a=0;for await(let t of i)n||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0]),n.set(t,a),a+=t.length;let o=new Uint32Array(n.buffer,0,n.length>>2),l=o[1];if(0!==l)throw Error(`Invalid version: ${l}`);let h,d=o[2],c=o[3],u=0===o[4],p=o[5],g=o[6],f=o[7],m=[],y=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;switch(f){case Int8Array.BYTES_PER_ELEMENT:h=new Int8Array(n.buffer,y);break;case Int16Array.BYTES_PER_ELEMENT:h=new Int16Array(n.buffer,y);break;case Int32Array.BYTES_PER_ELEMENT:h=new Int32Array(n.buffer,y)}a=0;for(let t=0;t<g;t++){let e=o[3*t+8],i=new Float32Array(e+2);m.push(i);for(let e=0;e<2;e++)i[e]=o[3*t+8+e+1];for(let t=0;t<e;t++)i[t+2]=i[t]+h[a++]}return{areContours:u,thickness:p,outlines:m,width:d,height:c}}catch(t){return _(`decompressSignature: ${t}`),null}}}class As extends us{constructor(){super(),super.updateProperties({fill:_t._defaultLineColor,"stroke-width":0})}clone(){let t=new As;return t.updateAll(this),t}}class ws extends ms{constructor(t){super(t),super.updateProperties({stroke:_t._defaultLineColor,"stroke-width":1})}clone(){let t=new ws(this._viewParameters);return t.updateAll(this),t}}class xs extends ps{#t=!1;#e=null;#i=null;#s=null;static _type="signature";static _editorType=101;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#i=t.signatureData||null,this.#e=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){_t.initialize(t,e),this._defaultDrawingOptions=new As,this._defaultDrawnSignatureOptions=new ws(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return M(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#e}}static computeTelemetryFinalData(t){let e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e,{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#i){let{lines:t,mustSmooth:e,areContours:i,description:s,uuid:r,heightInPage:n}=this.#i,{rawDims:{pageWidth:a,pageHeight:o},rotation:l}=this.parent.viewport,h=vs.processDrawnLines({lines:t,pageWidth:a,pageHeight:o,rotation:l,innerMargin:xs._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(h,n,s,r)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#e||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#s=t,this.addEditToolbar()}getUuid(){return this.#s}get description(){return this.#e}set description(t){this.#e=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){let{newCurves:t,areContours:e,thickness:i,width:s,height:r}=this.#i,n=Math.max(s,r);return{areContours:e,outline:vs.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:i,width:s,height:r},pageWidth:n,pageHeight:n,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,i,s){let r,{x:n,y:a}=this,{outline:o}=this.#i=t;this.#t=o instanceof bs,this.description=i,this.#t?r=xs.getDefaultDrawingOptions():(r=xs._defaultDrawnSignatureOptions.clone(),r.updateProperties({"stroke-width":o.thickness})),this._addOutlines({drawOutlines:o,drawingOptions:r});let[,l]=this.pageDimensions,h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=n,this.y=a,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(s),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!s,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){let{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return vs.process(t,e,i,s,xs._INNER_MARGIN)}getFromText(t,e){let{rawDims:{pageWidth:i,pageHeight:s},rotation:r}=this.parent.viewport;return vs.extractContoursFromText(t,e,i,s,r,xs._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return vs.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:xs._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=xs.getDefaultDrawingOptions():(this._drawingOptions=xs._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":s}}=this,r=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#t,color:[0,0,0],thickness:this.#t?0:s});return this.addComment(r),t?(r.paths={lines:e,points:i},r.uuid=this.#s,r.isCopy=!0):r.lines=e,this.#e&&(r.accessibilityData={type:"Figure",alt:this.#e}),r}static deserializeDraw(t,e,i,s,r,n){return n.areContours?bs.deserialize(t,e,i,s,r,n):fs.deserialize(t,e,i,s,r,n)}static async deserialize(t,e,i){let s=await super.deserialize(t,e,i);return s.#t=t.areContours,s.description=t.accessibilityData?.alt||"",s.#s=t.uuid,s}}new Map([ss,ys,class extends _t{#t=null;#e=null;#i=null;#s=null;#r=null;#n="";#a=null;#o=!1;#l=null;#h=!1;#d=!1;static _type="stamp";static _editorType=13;constructor(t){super({...t,name:"stampEditor"}),this.#s=t.bitmapUrl,this.#r=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){_t.initialize(t,e)}static isHandlingMimeForPasting(t){return ot.includes(t)}static paste(t,e){e.pasteEditor({mode:13},{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}}#c(t,e=!1){t?(this.#t=t.bitmap,e||(this.#e=t.id,this.#h=t.isSvg),t.file&&(this.#n=t.file.name),this.#g()):this.remove()}#u(){if(this.#i=null,this._uiManager.enableWaiting(!1),this.#a)if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t)this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});else{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:i}=this._uiManager;if(!i)throw Error("No ML.");if(!await i.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:s,width:r,height:n}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:r,height:n,channels:s.length/(r*n)}});if(!a)throw Error("No response from the AI service.");if(a.error)throw Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw Error("No valid response from the AI service.");let o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#p(){if(this.#e)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#e).then(t=>this.#c(t,!0)).finally(()=>this.#u());if(this.#s){let t=this.#s;return this.#s=null,this._uiManager.enableWaiting(!0),void(this.#i=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#c(t)).finally(()=>this.#u()))}if(this.#r){let t=this.#r;return this.#r=null,this._uiManager.enableWaiting(!0),void(this.#i=this._uiManager.imageManager.getFromFile(t).then(t=>this.#c(t)).finally(()=>this.#u()))}let t=document.createElement("input");t.type="file",t.accept=ot.join(",");let e=this._uiManager._signal;this.#i=new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){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.#c(e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#u()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#a?.remove(),this.#a=null,this.#l&&(clearTimeout(this.#l),this.#l=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#e&&null===this.#a&&this.#p(),this.isAttachedToDOM||this.parent.add(this))):this.#e&&this.#p()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#i||this.#t||this.#s||this.#r||this.#e||this.#o)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#o||(this.#t?this.#g():this.#p()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){let{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#e=i,s&&(this.#t=s),this.#o=!1,this.#g())}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#l&&clearTimeout(this.#l),this.#l=setTimeout(()=>{this.#l=null,this.#m()},200))}#g(){let{div:t}=this,{width:e,height:i}=this.#t,[s,r]=this.pageDimensions,n=.75;if(this.width)e=this.width*s,i=this.height*r;else if(e>n*s||i>n*r){let t=Math.min(n*s/e,n*r/i);e*=t,i*=t}this._uiManager.enableWaiting(!1);let a=this.#a=document.createElement("canvas");a.setAttribute("role","img"),this.addContainer(a),this.width=e/s,this.height=i/r,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#m(),this.#d||(this.parent.addUndoableEditor(this),this.#d=!0),this._reportTelemetry({action:"inserted_image"}),this.#n&&this.div.setAttribute("aria-description",this.#n),this.annotationElementId||this._uiManager.a11yAlert(_t._l10nAlert.stamp)}copyCanvas(t,e,i=!1){t||=224;let{width:s,height:r}=this.#t,n=new at,a=this.#t,o=s,l=r,h=null;if(e){if(s>e||r>e){let t=Math.min(e/s,e/r);o=Math.floor(s*t),l=Math.floor(r*t)}h=document.createElement("canvas");let t=h.width=Math.ceil(o*n.sx),i=h.height=Math.ceil(l*n.sy);this.#h||(a=this.#f(t,i));let d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":lt.isDarkMode&&(c="#8f8f9d",u="#42414d");let p=15*n.sx,g=15*n.sy,f=new OffscreenCanvas(2*p,2*g),m=f.getContext("2d");m.fillStyle=c,m.fillRect(0,0,2*p,2*g),m.fillStyle=u,m.fillRect(0,0,p,g),m.fillRect(p,g,p,g),d.fillStyle=d.createPattern(f,"repeat"),d.fillRect(0,0,t,i),d.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let d=null;if(i){let e,i;if(n.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=this.#t,s>t||r>t){let n=Math.min(t/s,t/r);e=Math.floor(s*n),i=Math.floor(r*n),this.#h||(a=this.#f(e,i))}let o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),d={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:d}}#f(t,e){let{width:i,height:s}=this.#t,r=i,n=s,a=this.#t;for(;r>2*t||n>2*e;){let i=r,s=n;r>2*t&&(r=Math.ceil(r/2)),n>2*e&&(n=Math.ceil(n/2));let o=new OffscreenCanvas(r,n);o.getContext("2d").drawImage(a,0,0,i,s,0,0,r,n),a=o.transferToImageBitmap()}return a}#m(){let[t,e]=this.parentDimensions,{width:i,height:s}=this,r=new at,n=Math.ceil(i*t*r.sx),a=Math.ceil(s*e*r.sy),o=this.#a;if(!o||o.width===n&&o.height===a)return;o.width=n,o.height=a;let l=this.#h?this.#t:this.#f(n,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,n,a)}#y(t){if(t){if(this.#h){let t=this._uiManager.imageManager.getSvgUrl(this.#e);if(t)return t}let t=document.createElement("canvas");return({width:t.width,height:t.height}=this.#t),t.getContext("2d").drawImage(this.#t,0,0),t.toDataURL()}if(this.#h){let[t,e]=this.pageDimensions,i=Math.round(this.width*t*W.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*W.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,s);return r.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,s),r.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,i){let s=null,r=!1;if(t instanceof es){let n,a,{data:{rect:o,rotation:l,id:h,structParent:d,popupRef:c,richText:u,contentsObj:p,creationDate:f,modificationDate:m},container:y,parent:{page:{pageNumber:b}},canvas:v}=t;v?(delete t.canvas,({id:n,bitmap:a}=i.imageManager.getFromCanvas(y.id,v)),v.remove()):(r=!0,t._hasNoCanvas=!0);let A=(await e._structTree.getAriaAttributes(`${g}${h}`))?.get("aria-label")||"";s=t={annotationType:13,bitmapId:n,bitmap:a,pageIndex:b-1,rect:o.slice(0),rotation:l,annotationElementId:h,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:A},isSvg:!1,structParent:d,popupRef:c,richText:u,comment:p?.str||null,creationDate:f,modificationDate:m}}let n=await super.deserialize(t,e,i),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:d,accessibilityData:c}=t;r?(i.addMissingCanvas(t.id,n),n.#o=!0):h&&i.imageManager.isValidId(h)?(n.#e=h,o&&(n.#t=o)):n.#s=l,n.#h=d;let[u,p]=n.pageDimensions;return n.width=(a[2]-a[0])/u,n.height=(a[3]-a[1])/p,c&&(n.altTextData=c),n._initialData=s,t.comment&&n.setCommentData(t),n.#d=!!s,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let i=Object.assign(super.serialize(t),{bitmapId:this.#e,isSvg:this.#h});if(this.addComment(i),t)return i.bitmapUrl=this.#y(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;let{decorative:s,altText:r}=this.serializeAltText(!1);if(!s&&r&&(i.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){let t=this.#b(i);return t.isSame?null:(t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(null===e)return i;e.stamps||=new Map;let n=this.#h?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#e)){if(this.#h){let t=e.stamps.get(this.#e);n>t.area&&(t.area=n,t.serialized.bitmap.close(),t.serialized.bitmap=this.#y(!1))}}else e.stamps.set(this.#e,{area:n,serialized:i}),i.bitmap=this.#y(!1);return i}#b(t){let{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,r=(t.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&s&&r,isSameAltText:r}}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}},cs,xs].map(t=>[t._editorType,t])),globalThis._pdfjsTestingUtils={HighlightOutliner:os};var _s=i(78888);function Ss(t){let e=Cs(t,"westbc"),i=Cs(t,"eastbc"),s=Cs(t,"northbc"),r=Cs(t,"southbc");if(null!=e&&null!=i&&null!=s&&null!=r)return{west:e,east:i,north:s,south:r}}function Cs(t,e){let i=t.match(RegExp(`<${e}>\\s*([^<]+)\\s*</${e}>`,"i"));if(!i)return;let s=Number(i[1].trim());return Number.isFinite(s)?s:void 0}i(44208);var Ms=i(48163),ks=i(37585),Ps=i(88411),Ts=i(83276),Es=i(39829);class Ds{constructor(t){this.ctm=t.ctm,this.spatialReference=t.spatialReference,this.originalPairedNeatline=t.originalPairedNeatline,this.pairedNeatline=t.pairedNeatline,this.outerExtentMediabox=Fs(t.outerExtentMediaBox,this.ctm,this.spatialReference),this.geoControlPoints=t.geoControlPoints,this.outerMediaBox=t.outerExtentMediaBox,this.sourceMediaBoxPolygon=Is(t.outerExtentMediaBox,this.ctm,this.spatialReference),this.sourceNeatlinePolygon=Is(t.pairedNeatline,this.ctm,this.spatialReference)}createNeatline(t,e){let i=e?this.sourceMediaBoxPolygon:this.sourceNeatlinePolygon;if(this.spatialReference.equals(t)||!t)return i;if(!i||!i.extent)throw new r.A("geospatial-pdf-layer:load","Could not project neatline");let s=Math.max(i.extent.width,i.extent.height)/256,n=(0,Ps.densifyExecute)(i,s);return(0,Ts.projectExecute)(n,t)}toExtent(){return Fs(this.pairedNeatline,this.ctm,this.spatialReference)}getPageCoveragePercent(){let t=t=>{let e=t.map(([t])=>t),i=t.map(([,t])=>t);return(Math.max(...e)-Math.min(...e))*(Math.max(...i)-Math.min(...i))},e=t(this.outerMediaBox),i=t(this.originalPairedNeatline);return e>0?i/e*100:0}}function Is(t,e,i){let s=[];for(let[i,r]of t){let t=Rs(e,i,r);s.push([t[0],t[1]])}return new Es.A({rings:[s],spatialReference:i})}function Fs(t,e,i){let s=1/0,r=1/0,n=-1/0,a=-1/0;for(let i=0;i<t.length;i++){let o=Rs(e,t[i][0],t[i][1]);s=Math.min(s,o[0]),r=Math.min(r,o[1]),n=Math.max(n,o[0]),a=Math.max(a,o[1])}return new l.A({xmin:s,ymin:r,xmax:n,ymax:a,spatialReference:i})}function Rs(t,e,i){let[s,r,n,a,o,l]=t,h=(0,Ms.vt)();return(0,ks.hZ)(h,s*e+n*i+o,r*e+a*i+l),h}var Ns=i(99917),Os=i(16930),Bs=i(86738),Ls=i(48237);function js(t,e,i,s){let r=Math.min(t.length,e.length,3),n=t.slice(0,r).map((t,s)=>({sourcePoint:{x:t[0],y:t[1]},mapPoint:new Bs.A({x:e[s][0],y:e[s][1],spatialReference:i})}));return new Ls.A({controlPoints:n,width:s.xmax-s.xmin,height:s.ymax-s.ymin})}function $s(t){if(!t?.transform||t.transform.length<6)throw new r.A("geospatial-pdf-layer:georefrencer","created georeferencer does not have valid transform");return t.transform}function Us(t){return n(t[0],-t[1],-t[3],t[4],t[2],t[5])}function zs(t){return[[t[0],t[1]],[t[0],t[3]],[t[2],t[3]],[t[2],t[1]]]}function Gs(t){if(!t)return!1;let{west:e,east:i,north:s,south:r}=t;return!(!Number.isFinite(e)||!Number.isFinite(i)||!Number.isFinite(s)||!Number.isFinite(r)||e<-180||e>180||i<-180||i>180||s<-90||s>90||r<-90||r>90||e===i||s<=r)}function Ws(t,e,i,s){if(!t)return s;try{let r=[1,0,0,1,0,0];if(!(0,a.B8)(r,e))return s;let n=[[t.west,t.south],[t.west,t.north],[t.east,t.north],[t.east,t.south]],o=[];for(let[t,e]of n){let n=new Bs.A({x:t,y:e,spatialReference:Os.A.WGS84}),a=(0,Ns.project)(n,i);if(!a||!Number.isFinite(a.x)||!Number.isFinite(a.y))return s;let l=(0,ks.l0)([0,0],[a.x,a.y],r);if(!l.every(Number.isFinite))return s;o.push([l[0],l[1]])}return o}catch{return s}}class Hs{static async create(t){let e=Hs._inputValidation(t);return e.geographicBounds&&await(0,Ns.initializeProjection)(Os.A.WGS84,e.projection),new Hs(e)}constructor(t){this._registration=t.registration,this._projection=t.projection,this._neatline=t.neatline,this.spatialReference=this._projection,this.originalPairedNeatline=function(t){let e=[];for(let i=0;i<t.length;i+=2){let s=t[i],r=t[i+1];Number.isFinite(s)&&Number.isFinite(r)&&e.push([s,r])}return 2===e.length&&(e.splice(1,0,[e[1][0],e[0][1]]),e.push([e[0][0],e[2][1]])),e}(this._neatline),this.outerExtentMediaBox=zs(t.mediaBox),this.geoControlPoints=Xs("geo",this._registration),this.ctm=t.ctm??function(t,e,i,s){let n=[],a=[];for(let t of i)t.length<4||(n.push((0,Ms.fA)(t[0],t[1])),a.push((0,Ms.fA)(t[2],t[3])));let o=function(t,e,i){if(4===t.length)return Vs(t);if(e.length>=6)return Vs(e);let s=Xs("page",i);if(s.length>=2)return Vs(s);throw new r.A("geospatial-pdf-layer:invalid-frame","Cannot build source rectangle from Neatline or Registration points.")}(t,e,i);return Us($s(js(n,a,s,o)))}(this.outerExtentMediaBox,this.originalPairedNeatline,this._registration,this.spatialReference),this.pairedNeatline=Ws(t.geographicBounds,this.ctm,this.spatialReference,this.originalPairedNeatline),this._outputValidation()}static _inputValidation(t){let{ctm:e,registration:i,projection:s,display:a,neatline:o,mediaBox:l,geographicBounds:h}=t;if(e&&6!==e.length)throw new r.A("geospatial-pdf-layer:invalid-frame","LGIDict has invalid CTM.");if(!e&&(!i||i.length<3))throw new r.A("geospatial-pdf-layer:invalid-frame","LGIDict missing CTM and minimum registration points");if(!l||4!==l.length)throw new r.A("geospatial-pdf-layer:invalid-frame","LGIDict missing or invalid MediaBox.");if(!o||o.length<4||o.length%2!=0)throw new r.A("geospatial-pdf-layer:invalid-frame","LGIDict missing or invalid amount of neatline points");let d=Gs(h)?h:void 0;return{ctm:e?n(e[0],e[1],e[2],e[3],e[4],e[5]):void 0,registration:i??[],projection:s,display:a,neatline:o,mediaBox:l,geographicBounds:d}}_outputValidation(){if(6!==this.ctm.length)throw new r.A("geospatial-pdf-layer:invalid-frame","LGIDict missing or invalid CTM");if(this.pairedNeatline.length<4)throw new r.A("geospatial-pdf-layer:invalid-frame","Map Frame should have at least 4 neatline points.");if(4!==this.outerExtentMediaBox.length)throw new r.A("geospatial-pdf-layer:invalid-frame","Failed to generate outerextent from mediaBox.");if(!this.ctm&&this.geoControlPoints.length<2)throw new r.A("geospatial-pdf-layer:invalid-frame","Map Frame should have at least 2 geoControlPoints if defaulting.")}}function Vs(t){let e=1/0,i=1/0,s=-1/0,n=-1/0;for(let r=0;r<t.length;r++){let a=t[r];e=Math.min(e,a[0]),i=Math.min(i,a[1]),s=Math.max(s,a[0]),n=Math.max(n,a[1])}if(!(Number.isFinite(e)&&Number.isFinite(i)&&Number.isFinite(s)&&Number.isFinite(n)))throw new r.A("geospatial-pdf-layer:invalid-frame","Failed to compute extent from registration.");return{xmin:e,ymin:i,xmax:s,ymax:n}}function Xs(t,e){let[i,s]="page"===t?[0,1]:[2,3];return e.filter(t=>t.length>s).map(t=>[t[i],t[s]])}const qs=/^(?:NAD83|NORTH AMERICAN 1983|NAR(?:-[A-Z])?)$/i,Ys=/^(?:NAD27|NORTH AMERICAN 1927|NAS(?:-[A-Z])?)$/i,Ks=/^(?:WGS84|WGS 84|WGE|WE)$/i;function Zs(t){return t.name?function(t){return t.trim().toUpperCase().replace(/_/g," ").replace(/\s+/g," ")}(t.name):null}function Js(t){return qs.test(t)}function Qs(t){return Ys.test(t)}function tr(t){return Ks.test(t)}function er(t){return`GEOGCS["${function(t){let e=Zs(t);return e?Js(e)?"GCS_North_American_1983":Qs(e)?"GCS_North_American_1927":tr(e)?"GCS_WGS_1984":"GCS_GeospatialPDF":"GCS_GeospatialPDF"}(t)}",${function(t){if("definition"===t.kind){let e=t.raw.Ellipsoid;if("string"==typeof e)throw new r.A("geospatial-pdf-layer:unsupported-ellipsoid","Only ellipsoid definitions are supported but found predefined code",{code:e});let i=t.raw.ToWGS84;if("string"==typeof i)throw new r.A("geospatial-pdf-layer:unsupported-datum-shift","Only shift definitions are supported but found predefined code",{code:i});let s=t.ellipsoid;if(!s?.semi_Major_Axis)throw new r.A("geospatial-pdf-layer:invalid-Datum","Datum definition requires semi-major axis");let n=function(t){if(null!=t.inverse_Flattening)return t.inverse_Flattening;let e=t.semi_Major_Axis,i=t.semi_Minor_Axis;if(null==e||null==i)throw new r.A("geospatial-pdf-layer:invalid-Datum","Ellipsoid definition missing InvFlattening or SemiMinorAxis.");return e===i?0:e/(e-i)}(s),a=t.name??"GeospatialPDF_Datum",o=`SPHEROID["${s.description??"GeospatialPDF_Spheroid"}",${s.semi_Major_Axis},${n}]`,l=t.to_WGS84;return`DATUM["${a}",${o}${l?`,TOWGS84[${l.dx??0},${l.dy??0},${l.dz??0},${l.rx??0},${l.ry??0},${l.rz??0},${l.sf??0}]`:""}]`}if(t.name){let e=t.name.toUpperCase();if(Js(e))return'DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]]';if(Qs(e))return'DATUM["D_North_American_1927",SPHEROID["Clarke_1866",6378206.4,294.9786982]]';if(tr(e))return'DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]]'}throw new r.A("geospatial-pdf-layer:invalid-Datum","Unsupported datum "+t.name)}(t)},PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]]`}function ir(t,e,i){let s=function(t,e,i){let s=function(t){let e=Zs(t);return e?Js(e)?"NAD_1983":Qs(e)?"NAD_1927":tr(e)?"WGS_1984":"geospatialPDF":"geospatialPDF"}(i);switch(e){case"TC":return`${s}_GeospatialPDF_Transverse_Mercator`;case"PH":return`${s}_GeospatialPDF_Polyconic`;case"UT":return`${s}_GeospatialPDF_UTM_Zone_${t.Zone}_${t.Hemisphere}`;case"AC":return`${s}_GeospatialPDF_Albers_Equal_Area`;case"LE":return`${s}_GeospatialPDF_Lambert_Conformal_Conic`}}(t,e,i),n=function(t){switch(t){case"TC":case"UT":return"Transverse_Mercator";case"PH":return"Polyconic";case"AC":return"Albers";case"LE":return"Lambert_Conformal_Conic"}}(e),a=er(i),o=function(t){let e=t.toLowerCase();return["m","meter","meters","metre","metres"].includes(e)?'UNIT["Meter",1.0]':["ft","foot","feet"].includes(e)?'UNIT["Foot",0.3048]':`UNIT["${t}",1.0]`}(t.Units??"M");return`PROJCS["${s}",${a},PROJECTION["${n}"],${function(t,e){switch(e){case"TC":return[`PARAMETER["False_Easting",${t.False_Easting}]`,`PARAMETER["False_Northing",${t.False_Northing}]`,`PARAMETER["Central_Meridian",${t.Central_Meridian}]`,`PARAMETER["Latitude_Of_Origin",${t.Origin_Latitude}]`,`PARAMETER["Scale_Factor",${t.Scale_Factor}]`];case"PH":return[`PARAMETER["False_Easting",${t.False_Easting}]`,`PARAMETER["False_Northing",${t.False_Northing}]`,`PARAMETER["Central_Meridian",${t.Central_Meridian}]`,`PARAMETER["Latitude_Of_Origin",${t.Origin_Latitude}]`];case"AC":case"LE":return[`PARAMETER["False_Easting",${t.False_Easting}]`,`PARAMETER["False_Northing",${t.False_Northing}]`,`PARAMETER["Central_Meridian",${t.Central_Meridian}]`,`PARAMETER["Latitude_Of_Origin",${t.Origin_Latitude}]`,`PARAMETER["Standard_Parallel_1",${t.Standard_Parallel_One}]`,`PARAMETER["Standard_Parallel_2",${t.Standard_Parallel_Two}]`];case"UT":return function(t){if(!t.Zone)throw new r.A("geospatial-pdf-layer:invalid-projection","No zone found for projection code UT");let e=6*t.Zone-183;return['PARAMETER["False_Easting",500000]',`PARAMETER["False_Northing",${/^s/i.test(t.Hemisphere??"")?1e7:0}]`,`PARAMETER["Central_Meridian",${e}]`,'PARAMETER["Latitude_Of_Origin",0]','PARAMETER["Scale_Factor",0.9996]']}(t)}}(t,e).join(",\n ")},${o}]`}const sr={OriginLatitude:"Origin_Latitude",CentralMeridian:"Central_Meridian",ScaleFactor:"Scale_Factor",FalseEasting:"False_Easting",FalseNorthing:"False_Northing",Zone:"Zone",Hemisphere:"Hemisphere",StandardParallelOne:"Standard_Parallel_One",StandardParallelTwo:"Standard_Parallel_Two"};function rr(t){switch(t){case"Projection":case"Display":return t;default:return}}function nr(t){let e=function(t){let e=t.Projection_Type;switch(e){case"GEODETIC":case"GEOGRAPHIC":return function(t,e){if(!rr(t.Type))throw new r.A("geospatial-pdf-layer:invalid-projection","Expected Projection or Display dictionary.");let i=t.Datum;if(!i)throw new r.A("geospatial-pdf-layer:invalid-projection","Missing datum definition or code for GEODETIC WKT");if("unknown"===i.kind){let t=i.name??"unknown";throw new r.A("geospatial-pdf-layer:invalid-projection",`Invalid Datum: ${t}`)}return{kind:"geographic",projectionType:e,datum:t.Datum}}(t,e);default:return function(t){let e,i=rr(t.Type);i||(e="Projection dictionary is missing or has invalid Type. Expected Projection or Display.");let s=t.Projection_Type;s||(e="Missing a projection Code");let n=function(t){switch(t){case"TC":case"PH":case"UT":case"AC":case"LE":case"SPCS":return t;default:return}}(t.Projection_Type);n||(e="Unsupported projection code: "+s);let a=t.Datum;if(a?"unknown"===a.kind&&(e="Invalid datum: "+(a.name??"unknown")):e="Missing datum definition or code for LGI Dict Frame",e)throw new r.A("geospatial-pdf-layer:invalid-projection",e);return function(t,e){for(let i of function(t){switch(t){case"TC":return["OriginLatitude","CentralMeridian","ScaleFactor","FalseEasting","FalseNorthing"];case"PH":return["OriginLatitude","CentralMeridian","FalseEasting","FalseNorthing"];case"UT":return["Zone","Hemisphere"];case"AC":case"LE":return["OriginLatitude","CentralMeridian","StandardParallelOne","StandardParallelTwo","FalseEasting","FalseNorthing"];case"SPCS":return["Zone"]}}(e)){let s=t[sr[i]];if(void 0===s||""===s)throw new r.A("geospatial-pdf-layer:invalid-projection",`Projection ${e} missing required parameter ${i}.`)}}(t,n),{kind:"projected",dictionaryType:i,projectionType:n,datum:t.Datum}}(t)}}(t);switch(e.kind){case"geographic":return new Os.A({wkt:er(e.datum)});case"projected":return"SPCS"===e.projectionType?function(t,e){let i=Zs(e);if(2800===t.Zone&&i&&Js(i))return new Os.A({wkid:32110});throw new r.A("geospatial-pdf-layer:invalid-projection",`Unsupported State Plane projection: datum ${e.name}, zone ${t.Zone}`)}(t,e.datum):new Os.A({wkt:ir(t,e.projectionType,e.datum)})}}class ar{static async create(t){let e=t.gcs;if(!e?.WKT&&!e?.EPSG)throw new r.A("geospatial-pdf-layer:invalid-frame","MeasureFrame missing WKT or EPSG.");let i=function(t){if(t?.WKT)return new Os.A({wkt:t.WKT});if(t?.EPSG)return new Os.A({wkid:t.EPSG});throw new r.A("geospatial-pdf-layer:invalid-frame","MeasureFrame missing WKT or EPSG.")}(e);return await(0,Ns.initializeProjection)(Os.A.WGS84,i),new ar(t,i)}constructor(t,e){let{bbox:i,gpts:s,bounds:r,lpts:n,mediaBox:a,geographicBounds:o}=this._inputValidation(t);this._bbox=i,this._bounds=r,this._gpts=s,this._lpts=n,this.spatialReference=e,this.outerExtentMediaBox=zs(a),this.geoControlPoints=lr(this._gpts,this.spatialReference).map(([t,e])=>[t,e]),this._georeference=function(t,e,i,s){let r=or(e,t),n=lr(i,s),a=function(t){let[e,i,s,r]=t;return{xmin:Math.min(e,s),ymin:Math.min(i,r),xmax:Math.max(e,s),ymax:Math.max(i,r)}}(t);return js(r,n,s,a)}(this._bbox,this._lpts,this._gpts,this.spatialReference);let l=$s(this._georeference);this.ctm=Us(l);let h=function(t,e){return function(t){if(!t||t.length<8||t.length%2!=0)return null;let e=[];for(let i=0;i<t.length;i+=2)e.push({u:t[i],v:t[i+1]});return e}(e)?.map(e=>hr(t,e.u,e.v))??null}(this._bbox,this._bounds)??or(this._lpts,this._bbox);this.originalPairedNeatline=h.map(([t,e])=>[t,e]),this.pairedNeatline=Ws(o,this.ctm,this.spatialReference,this.originalPairedNeatline),this._outputValidation()}_inputValidation(t){let{bbox:e,bounds:i,gpts:s,lpts:n,gcs:a,mediaBox:o,geographicBounds:l}=t;if(!e||4!==e.length)throw new r.A("geospatial-pdf-layer:invalid-frame","Viewport missing or invalid BBox");if(!o||4!==o.length)throw new r.A("geospatial-pdf-layer:invalid-frame","Viewport missing or invalid MediaBox");if(!s||s.length<6||s.length%2!=0)throw new r.A("geospatial-pdf-layer:invalid-frame","MeasureFrame missing or invalid GPTS");if(!n||n.length<6||n.length%2!=0)throw new r.A("geospatial-pdf-layer:invalid-frame","MeasureFrame missing or invalid LPTS");if(n.length!==s.length)throw new r.A("geospatial-pdf-layer:invalid-frame","MeasureFrame LPTS and GPTS must be same length");if(!a?.WKT&&!a?.EPSG)throw new r.A("geospatial-pdf-layer:invalid-frame","MeasureFrame missing a WKT or EPSG code");return{bbox:e,bounds:i,gpts:s,lpts:n,gcs:a,mediaBox:o,geographicBounds:Gs(l)?l:void 0}}_outputValidation(){if(4!==this.outerExtentMediaBox.length)throw new r.A("geospatial-pdf-layer:invalid-frame","Failed to generate outer extent from mediaBox");if(this.geoControlPoints.length<2)throw new r.A("geospatial-pdf-layer:invalid-frame","Map Frame should have at least 2 geoControlPoints");if(this.pairedNeatline.length<4)throw new r.A("geospatial-pdf-layer:invalid-frame","Map Frame should have at least 4 neatline points");if(!this.ctm||6!==this.ctm.length)throw new r.A("geospatial-pdf-layer:invalid-frame","Missing or invalid Map Frame CTM")}}function or(t,e){let i=[];for(let s=0;s<t.length;s+=2){let r=t[s],n=t[s+1];i.push(hr(e,r,n))}return i}function lr(t,e){let i=[];for(let s=0;s<t.length;s+=2){let r=t[s],n=t[s+1],a=new Bs.A({x:n,y:r}),o=(0,Ns.project)(a,e);i.push((0,Ms.fA)(o.x,o.y))}return i}function hr(t,e,i){let[s,r,n,a]=t;return(0,Ms.fA)(s+e*(n-s),r+i*(a-r))}async function dr(t,e=0){Ar(t.MediaBox),Sr(t.Rotate),t.LGIDict,t.VP;let{mapFrames:i,errors:s}=await async function(t){let e=[],i=[],s=Ar(t.MediaBox),n=[{sourceType:"VP",value:t.VP},{sourceType:"LGIDict",value:t.LGIDict}];for(let{sourceType:a,value:o}of n){if(null==o)continue;let n=Array.isArray(o)?o:[o];for(let o=0;o<n.length;o++)try{let i="VP"===a?await ur(gr(n[o]),s,t.geographicBounds):await cr(pr(n[o]),s,t.geographicBounds),[l,h,d,c]=i.ctm,u=l*c-h*d;if(!i.ctm.every(Number.isFinite)||!Number.isFinite(u)||0===u)throw new r.A("geospatial-pdf-layer:invalid-frame","Map frame has an invalid CTM.");let p=new Ds(i),g=p.getPageCoveragePercent();e.push({sourceType:a,frameIndex:o,frame:p,pageCoveragePercent:g})}catch(t){i.push({sourceType:a,frameIndex:o,message:t instanceof Error?t.message:String(t)})}}return e.sort((t,e)=>e.pageCoveragePercent-t.pageCoveragePercent),{mapFrames:e,errors:i}}(t);if(!i.length){if(s.length){let t=s[0];throw new r.A("geospatial-pdf-layer:load",`${t.sourceType} frame ${t.frameIndex} is invalid`,`${t.message}`)}throw new r.A("geospatial-pdf-layer:load","PDF does not contain LGIDict or VP/Measure geospatial metadata.")}let n=e??0;if(!Number.isInteger(n)||n<0||n>=i.length)throw new r.A("geospatial-pdf-layer:invalid-frame",`Invalid map frame index: ${n}.`);return i[n].frame}async function cr(t,e,i){if(!t.Projection)throw new r.A("geospatial-pdf-layer:parse","LGIDict map frame missing Projection.");let s,n=nr(t.Projection);try{s=t.Display?nr(t.Display):void 0}catch{s=n}return await Hs.create({ctm:t.CTM,registration:t.Registration,projection:n,display:s,neatline:t.Neatline,mediaBox:e,geographicBounds:i})}async function ur(t,e,i){return await ar.create({bbox:t.BBox,bounds:t.Measure?.Bounds,gpts:t.Measure?.GPTS,lpts:t.Measure?.LPTS,gcs:t.Measure?.GCS,mediaBox:e,geographicBounds:i})}function pr(t){let e=Mr(t,"LGIDict map frame must be an object.");return{CTM:Ar(e.CTM),Registration:wr(e.Registration),Neatline:Ar(e.Neatline),Projection:mr(e.Projection),Display:mr(e.Display)}}function gr(t){let e=Mr(t,"Viewport frame must be an object."),i=function(t){if(Cr(t))return{Bounds:Ar(t.Bounds),GPTS:Ar(t.GPTS),LPTS:Ar(t.LPTS),GCS:fr(t.GCS)}}(e.Measure);return{BBox:Ar(e.BBox),Measure_Raw:e.Measure,Measure:i,Raw:e}}function fr(t){if(Cr(t))return{WKT:xr(t.WKT),EPSG:Sr(t.EPSG)}}function mr(t){if(Cr(t))return{Type:_r(t.Type),Units:_r(t.Units),Datum:yr(t.Datum),Projection_Type:_r(t.ProjectionType),Central_Meridian:Sr(t.CentralMeridian),False_Easting:Sr(t.FalseEasting),False_Northing:Sr(t.FalseNorthing),Height:Sr(t.Height),Hemisphere:_r(t.Hemisphere),Latitude_One:Sr(t.LatitudeOne),Latitude_Two:Sr(t.LatitudeTwo),Latitude_Of_True_Scale:Sr(t.LatitudeOfTrueScale),Longitude_One:Sr(t.LongitudeOne),Longitude_Two:Sr(t.LongitudeTwo),Longitude_Down_From_Pole:Sr(t.LongitudeDownFromPole),Orientation:_r(t.Orientation),Origin_Height:Sr(t.OriginHeight),Origin_Latitude:Sr(t.OriginLatitude),Origin_Longitude:Sr(t.OriginLongitude),Scale_Factor:Sr(t.ScaleFactor),Standard_Parallel:Sr(t.StandardParallel),Standard_Parallel_One:Sr(t.StandardParallelOne),Standard_Parallel_Two:Sr(t.StandardParallelTwo),Zone:Sr(t.Zone),Description:_r(t.Description),raw:t}}function yr(t){return null==t?null:"string"==typeof t?{kind:"name",name:_r(t),ellipsoid:null,to_WGS84:null,raw:t}:Cr(t)?{kind:"definition",name:_r(t.Description),ellipsoid:br(t.Ellipsoid),to_WGS84:vr(t.ToWGS84),raw:t}:{kind:"unknown",name:_r(t),ellipsoid:null,to_WGS84:null,raw:t}}function br(t){if(Cr(t))return{semi_Major_Axis:Sr(t.SemiMajorAxis),inverse_Flattening:Sr(t.InvFlattening),semi_Minor_Axis:Sr(t.SemiMinorAxis),description:_r(t.Description)}}function vr(t){if(Cr(t))return{dx:Sr(t.dx)??0,dy:Sr(t.dy)??0,dz:Sr(t.dz)??0,rx:Sr(t.rx)??0,ry:Sr(t.ry)??0,rz:Sr(t.rz)??0,sf:Sr(t.sf)??0}}function Ar(t){if(!Array.isArray(t))return;let e=[];for(let i of t){let t=Sr(i);if(void 0===t)return;e.push(t)}return e}function wr(t){if(Array.isArray(t))return t.filter(t=>Array.isArray(t)).map(t=>t.map(t=>Sr(t)).filter(t=>void 0!==t))}function xr(t){if(null!=t)return"string"==typeof t?t:String(t)}function _r(t){let e=xr(t);if(void 0!==e)return e.trim()}function Sr(t){if(null==t)return;if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"!=typeof t)return;let e=t.trim();if(""===e)return;let i=Number(e);return Number.isFinite(i)?i:void 0}function Cr(t){return"object"==typeof t&&!!t&&!Array.isArray(t)}function Mr(t,e){if(!Cr(t))throw new r.A("geospatial-pdf-layer:parse",e);return t}function kr(t,e,i){let s=(t.xmax-t.xmin)/e,r=(t.ymax-t.ymin)/i;return n(1/s,0,0,-1/r,-t.xmin/s,t.ymax/r)}const Pr={fonts:globalThis.fonts,createElement:t=>"canvas"===t.toLowerCase()?new OffscreenCanvas(1,1):null};class Tr{constructor(){this._pdfDocument=null,this._page=null,this._geospatialMetadata=null,this._baseViewport=null,this._inverseBaseViewport=null,this._pdfWorker=null,this._pdfWorkerBlobUrl=null,this._pdfWorkerPort=null}async loadPDF(t,e={}){let[{data:i},l]=await Promise.all([(0,_s.A)(t.url,{responseType:"array-buffer",signal:e?.signal}),this._getPDFWorker(e)]),d=function(t={}){let e=new Ii,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t;if("string"==typeof t){if(h){if(/^[a-z][a-z0-9\-+.]+:/i.test(t))return new URL(t);let e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}let e=URL.parse(t,window.location);if(e)return e}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,r=t.data?function(t){if(h&&typeof Buffer<"u"&&t instanceof Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return R(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,n=t.httpHeaders||null,a=!0===t.withCredentials,o=t.password??null,l=t.range instanceof Fi?t.range:null,d=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536,c=t.worker instanceof Oi?t.worker:null,u=t.verbosity,p="string"!=typeof t.docBaseUrl||q(t.docBaseUrl)?null:t.docBaseUrl,g=oe(t.cMapUrl),f=!1!==t.cMapPacked,m=oe(t.iccUrl),y=oe(t.standardFontDataUrl),b=oe(t.wasmUrl),v=!0!==t.stopAtErrors,w=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,x="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!h,_="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!h,S=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,C="boolean"==typeof t.disableFontFace?t.disableFontFace:h,M=!0===t.fontExtraProperties,k=!0===t.enableXfa,P=t.ownerDocument||globalThis.document,T=!0===t.disableRange,E=!0===t.disableStream,D=!0===t.disableAutoFetch,I=!0===t.pdfBug,F=t.CanvasFactory||(h?Ae:me),N=t.FilterFactory||(h?ve:be),O=t.BinaryDataFactory||(h?we:ge),B=!0===t.enableHWA,L=!0===t.enableWebGPU?xe.init():Promise.resolve(!1),j=!1!==t.useWasm,$=t.pagesMapper||new ki,U="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!h&&!C,z="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(O===ge&&g&&f&&y&&b&&Z(g,document.baseURI)&&Z(y,document.baseURI)&&Z(b,document.baseURI));A(u);let G={canvasFactory:new F({ownerDocument:P,enableHWA:B}),filterFactory:new N({docId:i,ownerDocument:P}),binaryDataFactory:z?null:new O({cMapUrl:g,standardFontDataUrl:y,wasmUrl:b})};c||(c=Oi.create({verbosity:u,port:xi.workerPort}),e._worker=c);let W={docId:i,apiVersion:"6.0.92",data:r,password:o,disableAutoFetch:D,rangeChunkSize:d,docBaseUrl:p,enableXfa:k,evaluatorOptions:{maxImageSize:w,disableFontFace:C,ignoreErrors:v,isOffscreenCanvasSupported:x,isImageDecoderSupported:_,canvasMaxAreaInBytes:S,fontExtraProperties:M,useSystemFonts:U,useWasm:j,useWorkerFetch:z,cMapUrl:g,cMapPacked:f,iccUrl:m,standardFontDataUrl:y,wasmUrl:b,hasGPU:!1}},H={ownerDocument:P,pdfBug:I,styleElement:null,enableHWA:B,loadingParams:{disableAutoFetch:D,enableXfa:k}};return Promise.all([c.promise,L]).then(function([,t]){if(c.destroyed)throw Error("Worker was destroyed");W.evaluatorOptions.hasGPU=t;let o,u=c.messageHandler.sendWithPromise("GetDocRequest",W,r?[r.buffer]:null);if(!r)if(l)o=new ui({pdfDataRangeTransport:l,disableRange:T,disableStream:E});else{if(!s)throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");o=new(function(t){return Z(t)?oi:h?vi:fi}(s))({url:s,httpHeaders:n,withCredentials:a,rangeChunkSize:d,disableRange:T,disableStream:E})}return u.then(t=>{if(c.destroyed)throw Error("Worker was destroyed");let s=new ue(i,t,c.port),r=new Bi(s,e,o,H,G,$);if(e._transport=r,e.destroyed)throw Error("Loading aborted");s.send("Ready",null)})}).catch(e._capability.reject).finally(e._setupCapability.resolve),e}({data:i,wasmUrl:(0,s.s)("esri/libs/pdfjs/wasm/"),ownerDocument:Pr,enableHWA:!0,useWorkerFetch:!0,worker:l,useWasm:!0,verbosity:0});try{this._pdfDocument=await d.promise,(0,o.Te)(e);let i=this._pdfDocument.numPages,s=t.page??1,l=i;if(!Number.isInteger(s)||s<1||s>i)throw new r.A("geospatial-pdf-layer:load","Invalid PDF page number.");let h=await this._pdfDocument.getAttachments();(0,o.Te)(e);let c=function(t){if(!t)return;let e=t instanceof Map?t.values():Object.values(t);for(let t of e){if(!(t.content instanceof Uint8Array))continue;let e=Ss(new TextDecoder("utf-8").decode(t.content));if(e)return e}}(h),u=null;for(let t=s;t<=l;t++){(0,o.Te)(e);let i=await this._pdfDocument.getPage(t),s=!1;try{(0,o.Te)(e);let t=await i.getGeospatialPDFMetadata();if((0,o.Te)(e),null==t.LGIDict&&null==t.VP)continue;let r={...t,geographicBounds:c};try{await dr(r),(0,o.Te)(e)}catch(t){if((0,o.Te)(e),(0,o.zf)(t))throw t;u??=t;continue}this._page=i,this._geospatialMetadata=r,s=!0;break}finally{s||i.cleanup()}}if(!this._page||!this._geospatialMetadata)throw u||new r.A("geospatial-pdf-layer:load","pdf does not contain supported LGIDict or VP/Measure.");return this._baseViewport=this._page.getViewport({scale:1}),this._inverseBaseViewport=[1,0,0,1,0,0],(0,a.B8)(this._inverseBaseViewport,n(...this._baseViewport.transform)),{geospatialMetadata:this._geospatialMetadata,pageNumber:this._page.pageNumber,numPages:i}}catch(t){throw this.destroy(),t}}destroy(){this._page?.cleanup?.(),this._page=null,this._pdfDocument?.cleanup(),this._pdfDocument=null,this._geospatialMetadata=null,this._baseViewport=null,this._inverseBaseViewport=null,this._pdfWorker?.destroy(),this._pdfWorker=null,this._pdfWorkerPort?.terminate(),this._pdfWorkerPort=null,this._pdfWorkerBlobUrl&&=(URL.revokeObjectURL(this._pdfWorkerBlobUrl),null)}async renderPDF(t,e={}){if(!this._page||!this._baseViewport||!this._inverseBaseViewport)throw new r.A("geospatial-pdf-layer-worker:not-loaded","PDF not loaded");(0,o.Te)(e);let{width:i,height:s,sourceExtentAsJSON:n,currentRing:h,ctm:d}=t,c=l.A.fromJSON(n),u=await async function(t,e,i,s,n,l,h,d,c){let u=kr(t,e,i),p=[1,0,0,1,0,0];(0,a.lw)(p,u,s);let g=[1,0,0,1,0,0];(0,a.lw)(g,p,h);let f=new OffscreenCanvas(e,i),m=f.getContext("2d");if(!m)throw new r.A("geospatial-pdf-layer:invalid-canvas","Failed to create bitmap canvas context.");if(d.length){let s=function(t,e,i,s){let r=new Path2D,n=kr(e,i,s);for(let e=0;e<t.length;e++){let[i,s]=t[e],a=n[0]*i+n[2]*s+n[4],o=n[1]*i+n[3]*s+n[5];0===e?r.moveTo(a,o):r.lineTo(a,o)}return r.closePath(),r}(d,t,e,i);m.save(),m.fillStyle="white",m.fill(s),m.restore()}let y=n.render({canvas:null,canvasContext:m,viewport:l,transform:g,annotationMode:2,background:"rgba(0,0,0,0)"}),b=(0,o.u7)(c?.signal,()=>{y.cancel()});try{await y.promise}catch(t){throw(0,o.Te)(c),t}finally{b?.remove()}return f}(c,i,s,d,this._page,this._baseViewport,this._inverseBaseViewport,h,e);return(0,o.Te)(e),function(t,e,i){let s=t.getContext("2d");if(!s)throw new r.A("geospatial-pdf-raster:canvas","Failed to create canvas context.");let n=s.getImageData(0,0,e,i).data,a=e*i,o=new Uint8Array(a),l=new Uint8Array(a),h=new Uint8Array(a),d=new Uint8Array(a);for(let t=0,e=0;t<a;t++,e+=4)o[t]=n[e],l[t]=n[e+1],h[t]=n[e+2],d[t]=n[e+3];return{width:e,height:i,red:o,green:l,blue:h,mask:d}}(u,i,s)}async _getPDFWorker(t={}){if(this._pdfWorker)return this._pdfWorker;let e=(0,s.s)("esri/libs/pdfjs/pdf.worker.mjs"),i=(await(0,_s.A)(e,{responseType:"blob",authMode:"anonymous",signal:t.signal})).data,r="application/javascript"===i.type||"text/javascript"===i.type?i:new Blob([i],{type:"application/javascript"}),n=URL.createObjectURL(r),a=null,o=null;try{return a=new Worker(n,{type:"module",name:"geospatial-pdf-pdfjs-worker"}),o=new Oi({port:a,verbosity:0}),this._pdfWorkerPort=a,this._pdfWorker=o,this._pdfWorkerBlobUrl=n,await o.promise,o}catch(t){throw URL.revokeObjectURL(n),t}}}},56560(t,e,i){i.d(e,{A:()=>o});var s=i(32198),r=i(91429),n=i(69540),a=i(86738);let o=class extends n.Pw{constructor(t){super(t),this.sourcePoint=null,this.mapPoint=null}};(0,s.Cg)([(0,r.MZ)()],o.prototype,"sourcePoint",void 0),(0,s.Cg)([(0,r.MZ)({type:a.A})],o.prototype,"mapPoint",void 0),o=(0,s.Cg)([(0,r.$K)("esri.layers.support.ControlPoint")],o)},48237(t,e,i){i.d(e,{A:()=>M});var s=i(32198),r=i(91429),n=i(69540),a=i(49186),o=i(25482),l=i(77690),h=i(29242),d=i(37585),c=i(48163),u=i(53966),p=i(83529),g=i(90629),f=i(86738),m=i(39829),y=i(99917),b=i(16930),v=i(56560),A=i(33905),w=i(36005),x=i(43937);const _=(0,h.vt)(),S=(0,c.vt)();let C=class extends o.o{};(0,s.Cg)([(0,r.MZ)({type:Number,json:{write:{isRequired:!0}}})],C.prototype,"x",void 0),(0,s.Cg)([(0,r.MZ)({type:Number,json:{write:{isRequired:!0}}})],C.prototype,"y",void 0),C=(0,s.Cg)([(0,r.$K)("esri.layers.support.ControlPointsGeoreference.ControlPointJSONType")],C);let M=class extends((0,o.T)((0,A.L)(n.Pw))){constructor(t){super(t),this.height=0,this.type="control-points",this.width=0}get controlPoints(){return this._get("controlPoints")??null}set controlPoints(t){this._set("controlPoints",t)}readControlPoints(t,e){let i=b.A.fromJSON(e.spatialReference),s=(0,h.fA)(...e.coefficients,1);return t.map(t=>((0,d.hZ)(S,t.x,t.y),(0,p.W)(S,S,s),{sourcePoint:t,mapPoint:new f.A({x:S[0],y:S[1],spatialReference:i})}))}writeControlPoints(t,e,i,s){if(null==this.transform){let t=new a.A("web-document-write:invalid-georeference","Invalid 'controlPoints', 'width', 'height' configuration. Make sure the parent media element is loaded i.e. the ImageElement or VideoElement set as 'MediaLayer.source'.",{layer:s?.layer,georeference:this});s?.messages?s.messages.push(t):u.A.getLogger(this).error(t.name,t.message)}else null!=t&&k(t[0])&&(e.controlPoints=t.map(t=>{let e=t.sourcePoint;return{x:e.x,y:e.y}}),e.spatialReference=t[0].mapPoint.spatialReference.toJSON(),e.coefficients=this.transform.slice(0,8))}get coords(){if(null==this.controlPoints)return null;let t=this._updateTransform(_);if(null==t||!k(this.controlPoints[0]))return null;let e=this.controlPoints[0].mapPoint.spatialReference;return function(t,e,i,s){let r=(0,c.fA)(0,i),n=(0,c.fA)(0,0),a=(0,c.fA)(e,0),o=(0,c.fA)(e,i);return(0,p.W)(r,r,t),(0,p.W)(n,n,t),(0,p.W)(a,a,t),(0,p.W)(o,o,t),new m.A({rings:[[r,n,a,o,r]],spatialReference:s})}(t,this.width,this.height,e)}set coords(t){if(null==this.controlPoints||!k(this.controlPoints[0]))return;let e=this.controlPoints[0].mapPoint.spatialReference;if(null==(t=this.projectOrWarn(t,e)))return;let{width:i,height:s}=this,{rings:[[r,n,a,o]]}=t,l=new v.A({sourcePoint:(0,g.tc)(0,s),mapPoint:new f.A({x:r[0],y:r[1],spatialReference:e})}),h=new v.A({sourcePoint:(0,g.tc)(0,0),mapPoint:new f.A({x:n[0],y:n[1],spatialReference:e})}),c=new v.A({sourcePoint:(0,g.tc)(i,0),mapPoint:new f.A({x:a[0],y:a[1],spatialReference:e})}),u=new v.A({sourcePoint:(0,g.tc)(i,s),mapPoint:new f.A({x:o[0],y:o[1],spatialReference:e})});k(l)&&k(h)&&k(c)&&k(u)&&(L(_,l,h,c,u),this.controlPoints=this.controlPoints.map(({sourcePoint:t})=>((0,d.hZ)(S,t.x,t.y),(0,p.W)(S,S,_),{sourcePoint:t,mapPoint:new f.A({x:S[0],y:S[1],spatialReference:e})})))}get inverseTransform(){return null==this.transform?null:(0,l.B8)((0,h.vt)(),this.transform)}get transform(){return this._updateTransform()}toMap(t){if(null==t||null==this.transform||null==this.controlPoints||!k(this.controlPoints[0]))return null;(0,d.hZ)(S,t.x,t.y);let e=this.controlPoints[0].mapPoint.spatialReference;return(0,p.W)(S,S,this.transform),new f.A({x:S[0],y:S[1],spatialReference:e})}toSource(t){if(null==t||null==this.inverseTransform||null==this.controlPoints||!k(this.controlPoints[0]))return null;let e=this.controlPoints[0].mapPoint.spatialReference;return t=t.normalize(),null==(t=(0,y.projectOrLoad)(t,e).geometry)?null:((0,d.hZ)(S,t.x,t.y),(0,p.W)(S,S,this.inverseTransform),(0,g.tc)(S[0],S[1]))}toSourceNormalized(t){let e=this.toSource(t);return null!=e&&(e.x/=this.width,e.y/=this.height),e}_updateTransform(t){let{controlPoints:e,width:i,height:s}=this;if(!(null!=e&&i>0&&s>0))return null;let[r,n,a,o]=e;if(!k(r))return null;let l=r.mapPoint.spatialReference,c=this._projectControlPoint(n,l),u=this._projectControlPoint(a,l),p=this._projectControlPoint(o,l);if(!(c.valid&&u.valid&&p.valid&&k(c.controlPoint)))return null;t??=(0,h.vt)();let g=null;return g=k(u.controlPoint)&&k(p.controlPoint)?L(t,r,c.controlPoint,u.controlPoint,p.controlPoint):k(u.controlPoint)?function(t,e,i,s){return B(P,I,e),B(T,F,i),B(E,R,s),(0,d.Cc)(D,P,T,.5),(0,d.e$)(D,E,D,Math.PI),(0,d.Cc)(N,I,F,.5),(0,d.e$)(N,R,N,Math.PI),z(t,P,T,E,D,I,F,R,N)}(t,r,c.controlPoint,u.controlPoint):function(t,e,i){return B(P,I,e),B(T,F,i),(0,d.e$)(E,T,P,O),(0,d.e$)(D,P,T,O),(0,d.e$)(R,F,I,-O),(0,d.e$)(N,I,F,-O),z(t,P,T,E,D,I,F,R,N)}(t,r,c.controlPoint),g.every(t=>0===t)?null:g}_projectControlPoint(t,e){if(!k(t))return{valid:!0,controlPoint:t};let{sourcePoint:i,mapPoint:s}=t,{geometry:r,pending:n}=(0,y.projectOrLoad)(s,e);return n?{valid:!1,controlPoint:null}:n||r?{valid:!0,controlPoint:new v.A({sourcePoint:i,mapPoint:r})}:(u.A.getLogger(this).warn("map point could not be projected to the spatial reference",{georeference:this,controlPoint:t,sourceSpatialReference:s.spatialReference,targetSpatialReference:e}),{valid:!1,controlPoint:null})}};function k(t){return null!=t?.sourcePoint&&null!=t.mapPoint}(0,s.Cg)([(0,r.MZ)({type:[v.A],json:{write:{allowNull:!1,isRequired:!0,target:{controlPoints:{type:[C],isRequired:!0},coefficients:{type:[Number],isRequired:!0},spatialReference:{type:b.A,isRequired:!0}}}}})],M.prototype,"controlPoints",null),(0,s.Cg)([(0,w.w)("controlPoints")],M.prototype,"readControlPoints",null),(0,s.Cg)([(0,x.K)("controlPoints")],M.prototype,"writeControlPoints",null),(0,s.Cg)([(0,r.MZ)({clonable:!1})],M.prototype,"coords",null),(0,s.Cg)([(0,r.MZ)({type:Number,nonNullable:!0,json:{write:{isRequired:!0}}})],M.prototype,"height",void 0),(0,s.Cg)([(0,r.MZ)({readOnly:!0})],M.prototype,"inverseTransform",null),(0,s.Cg)([(0,r.MZ)({readOnly:!0})],M.prototype,"transform",null),(0,s.Cg)([(0,r.MZ)({type:Number,nonNullable:!0,json:{write:{isRequired:!0}}})],M.prototype,"width",void 0),M=(0,s.Cg)([(0,r.$K)("esri.layers.support.ControlPointsGeoreference")],M);const P=(0,c.vt)(),T=(0,c.vt)(),E=(0,c.vt)(),D=(0,c.vt)(),I=(0,c.vt)(),F=(0,c.vt)(),R=(0,c.vt)(),N=(0,c.vt)(),O=Math.PI/2;function B(t,e,i){(0,d.hZ)(t,i.sourcePoint.x,i.sourcePoint.y),(0,d.hZ)(e,i.mapPoint.x,i.mapPoint.y)}function L(t,e,i,s,r){return B(P,I,e),B(T,F,i),B(E,R,s),B(D,N,r),z(t,P,T,E,D,I,F,R,N)}const j=Array(8).fill(0),$=Array(8).fill(0);function U(t,e,i,s,r){return t[0]=e[0],t[1]=e[1],t[2]=i[0],t[3]=i[1],t[4]=s[0],t[5]=s[1],t[6]=r[0],t[7]=r[1],t}function z(t,e,i,s,r,n,a,o,l){return(0,p.O)(t,U(j,e,i,s,r),U($,n,a,o,l))}},33905(t,e,i){var s=i(53966),r=i(99917);i.d(e,["L",0,t=>{let e=t;return class extends e{projectOrWarn(t,e){if(null==t)return t;let{geometry:i,pending:n}=(0,r.projectOrLoad)(t,e);return n?null:n||i?i:(s.A.getLogger(this).warn("geometry could not be projected to the spatial reference",{georeference:this,geometry:t,sourceSpatialReference:t.spatialReference,targetSpatialReference:e}),null)}}}])}}]);