@arcgis/core 6.0.0-next.41 → 6.0.0-next.43
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.
- package/Basemap.js +1 -1
- package/Camera.js +1 -1
- package/Graphic.js +1 -1
- package/Ground.js +1 -1
- package/WebDocument2D.js +1 -1
- package/WebScene.js +1 -1
- package/analysis/ElevationProfile/ElevationProfileLineScene.d.ts +1 -0
- package/analysis/ElevationProfileAnalysis.d.ts +15 -0
- package/analysis/LineOfSightAnalysis.d.ts +6 -1
- package/analysis/ShadowCastAnalysis.d.ts +18 -22
- package/analysis/ShadowCastAnalysis.js +1 -1
- package/analysis/ViewshedAnalysis.d.ts +6 -1
- package/applications/Components/analysisUtils.d.ts +6 -0
- package/applications/Components/analysisUtils.js +1 -1
- package/arcade/ArcadeModuleResolver.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/featureset/actions/Adapted.js +1 -1
- package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
- package/arcade/featureset/support/FeatureSet.js +1 -1
- package/arcade/featureset/support/shared.js +1 -1
- package/arcade/featureset/support/sqlUtils.js +1 -1
- package/arcade/functions/knowledgegraph.js +1 -1
- package/arcade/functions/maths.js +1 -1
- package/arcgisGlobal.d.ts +0 -2
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{2f54e4feb554c1a7b9c4.js → 02debe67e6fef9d88bdd.js} +1 -1
- package/assets/esri/core/workers/chunks/{bd046399e05e759e0bc2.js → 035204000954973b0ebc.js} +1 -1
- package/assets/esri/core/workers/chunks/05225506fdba0c827407.js +1 -0
- package/assets/esri/core/workers/chunks/075fe33152fd79fe6d72.js +1 -0
- package/assets/esri/core/workers/chunks/077b755688346e0dc8d3.js +1 -0
- package/assets/esri/core/workers/chunks/0c1d8e0c2eae21f97fc0.js +1 -0
- package/assets/esri/core/workers/chunks/105865a4d8cb4ddf8a8a.js +1 -0
- package/assets/esri/core/workers/chunks/11877d4dc97f756e4711.js +1 -0
- package/assets/esri/core/workers/chunks/{afe3e89737fb45189a99.js → 14ed0c34b910eba3434e.js} +1 -1
- package/assets/esri/core/workers/chunks/{f67b37253d6d05d1e339.js → 14ef986665b4a1f6ccdc.js} +1 -1
- package/assets/esri/core/workers/chunks/158cbf4075d3eca83a6a.js +1 -0
- package/assets/esri/core/workers/chunks/{a03f15f2cbc3fed291c2.js → 15f2b27b8edc0d53e399.js} +1 -1
- package/assets/esri/core/workers/chunks/181d24ced5ef6b1f959b.js +1 -0
- package/assets/esri/core/workers/chunks/18dbee576b7b9dbe69fb.js +1 -0
- package/assets/esri/core/workers/chunks/1aebb8fe0692058bf2fb.js +1 -0
- package/assets/esri/core/workers/chunks/1cdb55d9a5ab1a5e3f08.js +1 -0
- package/assets/esri/core/workers/chunks/{cf2e5f827cea7d7319ce.js → 1e5c5029b0653047a769.js} +1 -1
- package/assets/esri/core/workers/chunks/20db6e844708d3e71437.js +1 -0
- package/assets/esri/core/workers/chunks/21a4c3d8265aca775616.js +1 -0
- package/assets/esri/core/workers/chunks/23fff0505e02fd364909.js +1 -0
- package/assets/esri/core/workers/chunks/{14d81280807a3d3c1b7e.js → 244ffdb91237d1cbade3.js} +1 -1
- package/assets/esri/core/workers/chunks/286e3e050b29e6158e6f.js +1 -0
- package/assets/esri/core/workers/chunks/29ef9d357e30082d267a.js +1 -0
- package/assets/esri/core/workers/chunks/29feef121b0916fb90bf.js +1 -0
- package/assets/esri/core/workers/chunks/2ef91e8da260454f46d8.js +1 -0
- package/assets/esri/core/workers/chunks/32b9bedd4bb0504f0b1d.js +1 -0
- package/assets/esri/core/workers/chunks/348f28d7ab46df878c6f.js +1 -0
- package/assets/esri/core/workers/chunks/{279089a6a3f08022c678.js → 361d620b3f91868b1490.js} +1 -1
- package/assets/esri/core/workers/chunks/37c16e20f022ca27cdae.js +1 -0
- package/assets/esri/core/workers/chunks/380aefa522dfeccb8c65.js +1 -0
- package/assets/esri/core/workers/chunks/394ae3199c78a94c6a2a.js +1 -0
- package/assets/esri/core/workers/chunks/39c23a52d7c3e1ee121c.js +1 -0
- package/assets/esri/core/workers/chunks/{fdd2b35388f9fe42b623.js → 3a90b6eafa92f1a68ac5.js} +1 -1
- package/assets/esri/core/workers/chunks/{6a65fc1a2931230fe994.js → 3bb1e06861cd0563ed9f.js} +1 -1
- package/assets/esri/core/workers/chunks/3f92afa58c895bf87e62.js +1 -0
- package/assets/esri/core/workers/chunks/422784ceae0d511868a0.js +1 -0
- package/assets/esri/core/workers/chunks/44782e8318dc47cb08a0.js +1 -0
- package/assets/esri/core/workers/chunks/{5882f349f3771868e67f.js → 4521f72ab0ea872e5d7c.js} +1 -1
- package/assets/esri/core/workers/chunks/45b5a61c4e9fbd9ca0b3.js +1 -0
- package/assets/esri/core/workers/chunks/47af220003adfca2167e.js +1 -0
- package/assets/esri/core/workers/chunks/487500443a6037d3599f.js +1 -0
- package/assets/esri/core/workers/chunks/4a4fab74442c3d914505.js +1 -0
- package/assets/esri/core/workers/chunks/4a8903fb1a5d30a68df9.js +1 -0
- package/assets/esri/core/workers/chunks/{46504fc81f357bc7465a.js → 4d62877f521cc9663535.js} +1 -1
- package/assets/esri/core/workers/chunks/4d818b231e6d1fa73cc5.js +1 -0
- package/assets/esri/core/workers/chunks/{e0cf6e1e21d0ee739009.js → 4e03aa5518d46a36661c.js} +1 -1
- package/assets/esri/core/workers/chunks/{1a614bac5db42c6263f8.js → 4fe10650ba3cd30aa9a2.js} +1 -1
- package/assets/esri/core/workers/chunks/50b8b1cce0a5f77c8372.js +1 -0
- package/assets/esri/core/workers/chunks/5470a29a69010c8361c4.js +1 -0
- package/assets/esri/core/workers/chunks/564d7f2e58fbc16853c0.js +1 -0
- package/assets/esri/core/workers/chunks/5c2e79f2ca401741bf3e.js +1 -0
- package/assets/esri/core/workers/chunks/5c9ab86bec07264dc9f2.js +1 -0
- package/assets/esri/core/workers/chunks/{04d55ed51e8b2683c4b4.js → 5d908a823b324bafda1e.js} +1 -1
- package/assets/esri/core/workers/chunks/{54de7dc0597fc80d7a52.js → 5dea74fe52583e77f3ce.js} +1 -1
- package/assets/esri/core/workers/chunks/5e6d6676a5c47c0e132a.js +1 -0
- package/assets/esri/core/workers/chunks/5fd4d3cb3c9350131a59.js +1 -0
- package/assets/esri/core/workers/chunks/60637f38159e9bf68d4e.js +1 -0
- package/assets/esri/core/workers/chunks/69b73251257088ce7099.js +1 -0
- package/assets/esri/core/workers/chunks/6cd17c3a254a0b5c2476.js +1 -0
- package/assets/esri/core/workers/chunks/{06102715e9a8f218e07c.js → 6f3732e7ba2d031ba789.js} +1 -1
- package/assets/esri/core/workers/chunks/7191ab31fa040a7c561e.js +1 -0
- package/assets/esri/core/workers/chunks/71ba848c3352ea3ff96f.js +1 -0
- package/assets/esri/core/workers/chunks/76dc8e3264a456f33e61.js +1 -0
- package/assets/esri/core/workers/chunks/77d80b6d65d761214a7c.js +1 -0
- package/assets/esri/core/workers/chunks/{e2430bc3a1edeb5c3266.js → 78a69594c82d37aecbfb.js} +1 -1
- package/assets/esri/core/workers/chunks/{1ec772eaa63eb6937231.js → 8140ed6e44c3d8536d3e.js} +1 -1
- package/assets/esri/core/workers/chunks/{787c1a8bda7d745633f2.js → 81b9894e81cce3490984.js} +1 -1
- package/assets/esri/core/workers/chunks/85cd525705eec6803dd3.js +1 -0
- package/assets/esri/core/workers/chunks/863f04cacdc843d3f208.js +1 -0
- package/assets/esri/core/workers/chunks/8766832c7253557da8fe.js +1 -0
- package/assets/esri/core/workers/chunks/87992070008812f8ae6f.js +1 -0
- package/assets/esri/core/workers/chunks/892fd2c3533ce46a9258.js +1 -0
- package/assets/esri/core/workers/chunks/89b9d716d96135d4f057.js +1 -0
- package/assets/esri/core/workers/chunks/{4b2d392ad8e381bfd6b3.js → 89e9ebc8d5c1022cb265.js} +1 -1
- package/assets/esri/core/workers/chunks/8b38798ac6d774185238.js +1 -0
- package/assets/esri/core/workers/chunks/8b53369cace136ed1329.js +1 -0
- package/assets/esri/core/workers/chunks/8ba4f5e1912edf397947.js +1 -0
- package/assets/esri/core/workers/chunks/{987424121cf30b0f3c50.js → 8d3e92a3367a3ddc02bd.js} +1 -1
- package/assets/esri/core/workers/chunks/8e7a3b1b088c160f4db7.js +1 -0
- package/assets/esri/core/workers/chunks/8f4fba4d2339c91c8b3f.js +1 -0
- package/assets/esri/core/workers/chunks/{45aaefbdffe5e15dfb24.js → 919a6aedf38e9631ee09.js} +1 -1
- package/assets/esri/core/workers/chunks/{487c46d5245cfb35c4bb.js → 921917e53bac82693ec8.js} +1 -1
- package/assets/esri/core/workers/chunks/92809b209b68abcb97ee.js +1 -0
- package/assets/esri/core/workers/chunks/{beccbfff549902733c4e.js → 9869c696e6321c8db0a9.js} +1 -1
- package/assets/esri/core/workers/chunks/98957dba728c93506e50.js +1 -0
- package/assets/esri/core/workers/chunks/99ffb839407cb3c26ad8.js +1 -0
- package/assets/esri/core/workers/chunks/9b517c8d26a86dedb921.js +1 -0
- package/assets/esri/core/workers/chunks/{cb2329d1ea72ce5cc057.js → 9c3f56f22e9baa80a387.js} +1 -1
- package/assets/esri/core/workers/chunks/9d0976f5979c4f9154dc.js +1 -0
- package/assets/esri/core/workers/chunks/9fe1812aad6e566aea31.js +1 -0
- package/assets/esri/core/workers/chunks/a1602995ef96beb7df29.js +1 -0
- package/assets/esri/core/workers/chunks/{dff845574c0037a1dca6.js → a332e31165b65a6fb92e.js} +1 -1
- package/assets/esri/core/workers/chunks/a553478664a688f32488.js +1 -0
- package/assets/esri/core/workers/chunks/a7937b06f4b0860c7671.js +1 -0
- package/assets/esri/core/workers/chunks/a95186214f1206efd8ed.js +1 -0
- package/assets/esri/core/workers/chunks/{853563c66ecf58d53d36.js → ab60e8fbe0f92340616a.js} +1 -1
- package/assets/esri/core/workers/chunks/acea0946049136578354.js +1 -0
- package/assets/esri/core/workers/chunks/{342a97974a78007b25e0.js → ad94f54b4c88b3a047bc.js} +1 -1
- package/assets/esri/core/workers/chunks/ae29fec228e70a93ced1.js +1 -0
- package/assets/esri/core/workers/chunks/ae6dc159be974ca0e8da.js +1 -0
- package/assets/esri/core/workers/chunks/ae70972bf88d586fd453.js +1 -0
- package/assets/esri/core/workers/chunks/b021fa4654ede1d04279.js +1 -0
- package/assets/esri/core/workers/chunks/b03f32f02858244c6cd0.js +1 -0
- package/assets/esri/core/workers/chunks/b2d922ecc2c4899dbee1.js +1 -0
- package/assets/esri/core/workers/chunks/b42e50ec6b819f669400.js +1 -0
- package/assets/esri/core/workers/chunks/b6a82775b83d20599635.js +1 -0
- package/assets/esri/core/workers/chunks/b6d365b9198b74b05338.js +1 -0
- package/assets/esri/core/workers/chunks/bc21241bc9acb83d1b1c.js +1 -0
- package/assets/esri/core/workers/chunks/bd02d927b0b4991b61c5.js +1 -0
- package/assets/esri/core/workers/chunks/bdf1c4c038d556527483.js +1 -0
- package/assets/esri/core/workers/chunks/c1273f14a5ef3d81de0d.js +1 -0
- package/assets/esri/core/workers/chunks/c752f1e732bb019f657d.js +1 -0
- package/assets/esri/core/workers/chunks/{5504ec9bd9ee4d10af07.js → c7f49493bd548d5dc1e0.js} +1 -1
- package/assets/esri/core/workers/chunks/c86d3af148b28ded5875.js +1121 -0
- package/assets/esri/core/workers/chunks/{692f0093c444fcc752b5.js → cadd60fa4370284c7ae3.js} +1 -1
- package/assets/esri/core/workers/chunks/{947f3a1cad976bba9738.js → cb62326b6526cde429c1.js} +1 -1
- package/assets/esri/core/workers/chunks/cd8304b1db83d48c57db.js +1 -0
- package/assets/esri/core/workers/chunks/cdf0c7706d3e1221f49b.js +1 -0
- package/assets/esri/core/workers/chunks/d00dd961a5b79f563123.js +1 -0
- package/assets/esri/core/workers/chunks/d893c3bb093104d3db95.js +1 -0
- package/assets/esri/core/workers/chunks/d8fb1d9da16492574a11.js +1 -0
- package/assets/esri/core/workers/chunks/{520f499d79fa71f262c7.js → dd7e4c94a88452425750.js} +1 -1
- package/assets/esri/core/workers/chunks/ddb4689624d091922471.js +1 -0
- package/assets/esri/core/workers/chunks/df32a3fe81d60f0d7462.js +1 -0
- package/assets/esri/core/workers/chunks/dfc6b33f51dc81f3a7be.js +1 -0
- package/assets/esri/core/workers/chunks/e55934eb4a17a5b24c94.js +1 -0
- package/assets/esri/core/workers/chunks/{5473409fee59db80f87d.js → e5bdfef7c2cc5354be52.js} +1 -1
- package/assets/esri/core/workers/chunks/e8cdec961e9cff1cb73b.js +1 -0
- package/assets/esri/core/workers/chunks/{6738b3d6bce34a1e8be2.js → eaf720dfdf6ceca31249.js} +1 -1
- package/assets/esri/core/workers/chunks/ef274db3fa260eadf371.js +1 -0
- package/assets/esri/core/workers/chunks/efca82a4dc494f57380b.js +1 -0
- package/assets/esri/core/workers/chunks/f05990e6fb378e2e1a3b.js +1 -0
- package/assets/esri/core/workers/chunks/f0fc89cdf50a40913c02.js +1 -0
- package/assets/esri/core/workers/chunks/{8b5dcc4282772bf6b675.js → f11eaab5354cc6aa9569.js} +1 -1
- package/assets/esri/core/workers/chunks/f1c2f7c7ce4bd4096eb0.js +1 -0
- package/assets/esri/core/workers/chunks/f4e63c5f82b8c2bbfacb.js +1 -0
- package/assets/esri/core/workers/chunks/f86ff791a10c802879ec.js +1 -0
- package/assets/esri/core/workers/chunks/{7452b5ae971a9ff2e6e9.js → fdffefd7de540272a8a6.js} +1 -1
- package/assets/esri/core/workers/chunks/fe0248af95d3f37e099e.js +1 -0
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/assets/esri/themes/base/_core.scss +0 -2
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/languageUtils.js +1 -1
- package/chunks/lyr3DMain.js +1 -1
- package/chunks/lyr3DWorker.js +1 -1
- package/config.js +1 -1
- package/core/Accessor.js +1 -1
- package/core/Collection.js +1 -1
- package/core/LRUCache.js +1 -1
- package/core/Logger.js +1 -1
- package/core/MapUtils.js +1 -1
- package/core/Version.js +1 -1
- package/core/asyncUtils.js +1 -1
- package/core/deprecate.js +1 -1
- package/core/fontUtils.js +1 -1
- package/core/has.js +1 -1
- package/core/sql/SqlInterval.js +1 -1
- package/core/sql/WhereClause.js +1 -1
- package/core/sql/writeUtils.js +1 -1
- package/core/sql.js +1 -1
- package/core/types.d.ts +0 -5
- package/core/urlUtils.js +1 -1
- package/editing/sharedTemplates/executor/builders/pointAtIntersectionVerticesOfLine.js +1 -1
- package/editing/sharedTemplates/executor/builders/polygonBoundary.js +1 -1
- package/editing/sharedTemplates/executor/builders/support/builderUtils.js +1 -1
- package/editing/sharedTemplates/executor/support/createFeatureServiceEdit.js +1 -1
- package/geometry/Point.js +1 -1
- package/geometry/Polygon.js +1 -1
- package/geometry/SpatialReference.js +1 -1
- package/geometry/support/webMercatorUtils.js +1 -1
- package/interfaces.d.ts +0 -17
- package/kernel.js +1 -1
- package/layers/BuildingSceneLayer.js +1 -1
- package/layers/ElevationLayer.d.ts +1 -1
- package/layers/ElevationLayer.js +1 -1
- package/layers/FeatureLayer.js +1 -1
- package/layers/GeoJSONLayer.d.ts +5 -1
- package/layers/GeoRSSLayer.js +1 -1
- package/layers/GeospatialPDFLayer.js +1 -1
- package/layers/ImageryLayer.js +1 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.d.ts +4 -3
- package/layers/IntegratedMeshLayer.d.ts +4 -3
- package/layers/IntegratedMeshLayer.js +1 -1
- package/layers/KMLLayer.js +1 -1
- package/layers/KnowledgeGraphLayer.js +1 -1
- package/layers/LineOfSightLayer.d.ts +6 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/MapImageLayer.js +1 -1
- package/layers/PointCloudLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/StreamLayer.js +1 -1
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/TileLayer.js +1 -1
- package/layers/VectorTileLayer.d.ts +53 -0
- package/layers/VectorTileLayer.js +1 -1
- package/layers/VideoLayer.js +1 -1
- package/layers/ViewshedLayer.d.ts +6 -1
- package/layers/VoxelLayer.js +1 -1
- package/layers/WCSLayer.js +1 -1
- package/layers/WMSLayer.js +1 -1
- package/layers/WMTSLayer.js +1 -1
- package/layers/WebTileLayer.js +1 -1
- package/layers/effects/jsonUtils.js +1 -1
- package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +1 -1
- package/layers/geospatialPDF/GeospatialPDFWorkerClient.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/graphics/data/projectionSupport.js +1 -1
- package/layers/graphics/sources/connections/WebSocketConnection.js +1 -1
- package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
- package/layers/graphics/sources/geojson/geojson.js +1 -1
- package/layers/graphics/sources/parquet/FileProvider.js +1 -1
- package/layers/graphics/sources/support/QueryTask.js +1 -1
- package/layers/graphics/sources/support/uploads.js +1 -1
- package/layers/knowledgeGraph/cypherUtils.js +1 -1
- package/layers/mixins/refresh.js +1 -1
- package/layers/ogc/ogcFeatureUtils.js +1 -1
- package/layers/ogc/wfsUtils.js +1 -1
- package/layers/orientedImagery/transformations/updateElevationUtils.js +1 -1
- package/layers/parquet.js +1 -1
- package/layers/raster/datasets/BaseRaster.js +1 -1
- package/layers/raster/datasets/GeospatialPDFRaster.js +1 -1
- package/layers/raster/datasets/ImageServerRaster.js +1 -1
- package/layers/raster/datasets/RasterFactory.js +1 -1
- package/layers/raster/datasets/TIFFRaster.js +1 -1
- package/layers/raster/datasets/ZarrRaster.js +2 -0
- package/layers/raster/datasets/datasetUtils.js +1 -1
- package/layers/raster/datasets/wcsCoverageParser.js +1 -1
- package/layers/raster/datasets/zarrParser.js +2 -0
- package/layers/raster/datasets/zarrUtils.js +2 -0
- package/layers/raster/formats/Lerc.js +1 -1
- package/layers/raster/formats/pixelRangeUtils.js +1 -1
- package/layers/support/ClientSideConnection.js +1 -1
- package/layers/support/ElevationSampler.js +1 -1
- package/layers/support/MultidimensionalSubset.js +1 -1
- package/layers/support/SceneModifications.d.ts +1 -3
- package/layers/support/SceneModifications.js +1 -1
- package/layers/support/SpriteSource.js +1 -1
- package/layers/support/TileInfo.js +1 -1
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/infoFor3D.js +1 -1
- package/layers/support/vectorTileLayerLoader.js +1 -1
- package/layers/support/wmsUtils.js +1 -1
- package/layers/support/wmtsUtils.js +1 -1
- package/layers/video/videoUtils.js +1 -1
- package/legend/ActiveLayerInfo.js +1 -1
- package/libs/lyr3d/Lyr3DModule.js +1 -1
- package/linkChart/utils.js +1 -1
- package/networks/support/Circuit.js +1 -1
- package/networks/support/CircuitSection.js +1 -1
- package/package.json +3 -3
- package/portal/Portal.js +1 -1
- package/portal/PortalItemResource.js +1 -1
- package/portal/PortalQueryParams.js +1 -1
- package/renderers/HeatmapRenderer.js +1 -1
- package/renderers/UniqueValueRenderer.js +1 -1
- package/rest/knowledgeGraphService.js +1 -1
- package/rest/query/operations/pbfFeatureServiceParser.js +1 -1
- package/rest/query/operations/queryAttachments.js +1 -1
- package/support/LayersMixin.d.ts +2 -2
- package/symbols/PictureFillSymbol.js +1 -1
- package/symbols/PictureMarkerSymbol.js +1 -1
- package/symbols/SimpleFillSymbol.js +1 -1
- package/symbols/SimpleLineSymbol.js +1 -1
- package/symbols/SimpleMarkerSymbol.js +1 -1
- package/symbols/Symbol3D.js +1 -1
- package/symbols/TextSymbol.js +1 -1
- package/symbols/cim/placements/PlacementInsidePolygon.js +1 -1
- package/symbols/cim/types.d.ts +15 -11
- package/symbols/support/previewSymbol3D.js +1 -1
- package/tables/support/templateUtils.js +1 -1
- package/views/2d/engine/vectorTiles/SourceLayerData.js +1 -1
- package/views/2d/engine/vectorTiles/SpriteMosaic.js +1 -1
- package/views/2d/engine/vectorTiles/TileHandler.js +1 -1
- package/views/2d/engine/vectorTiles/TileHandler3D.js +1 -1
- package/views/2d/engine/vectorTiles/TileManager.js +1 -1
- package/views/2d/engine/vectorTiles/TileParser.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileFeatureIndex.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileSourceData.js +2 -0
- package/views/2d/engine/vectorTiles/WorkerTile.js +1 -1
- package/views/2d/engine/vectorTiles/WorkerTileHandler.js +1 -1
- package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
- package/views/2d/engine/vectorTiles/expression/expression.js +1 -1
- package/views/2d/engine/vectorTiles/style/Filter.js +1 -1
- package/views/2d/engine/vectorTiles/style/GeoJSONVectorTileSourceWorker.js +1 -1
- package/views/2d/engine/vectorTiles/style/StyleProperty.js +1 -1
- package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
- package/views/2d/engine/webgl/mesh/factories/MeshWriterGroupCoordinator.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/graph/ShaderGraphContext.js +4 -4
- package/views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js +1 -1
- package/views/2d/layers/VectorTileLayerView2D.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/support/TileStore.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/2d/tiling/TileKey.js +1 -1
- package/views/2d/tiling/TileStrategy.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionComputation.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightManipulators.js +1 -1
- package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
- package/views/3d/analysis/images/generateTextures.js +1 -1
- package/views/3d/environment/EnvironmentView.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/VisualElementResources.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/layers/VectorTileLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolCreationContext.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/MeshFastUpdateProcessor.js +1 -1
- package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/graphics/polygonUtils.js +1 -1
- package/views/3d/layers/graphics/wosrLoader.js +1 -1
- package/views/3d/layers/i3s/I3SAsyncElevationUpdater.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SQueryEngine.js +1 -1
- package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
- package/views/3d/layers/support/Tiles3DLayerViewRegistration.js +2 -0
- package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
- package/views/3d/layers/support/createTileBVHForLayer.js +2 -0
- package/views/3d/layers/support/tileBoundingVolumeUtils.js +2 -0
- package/views/3d/state/ConstraintsManager.js +1 -1
- package/views/3d/state/controllers/GroundNavigationController.js +1 -1
- package/views/3d/support/GaussianSplatSortWorker.js +1 -1
- package/views/3d/support/QualityProfile.js +1 -1
- package/views/3d/support/TextureCollection.js +1 -1
- package/views/3d/support/engineContent/line.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatIntersectionHandler.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatSortCoordinator.js +2 -0
- package/views/3d/support/gaussianSplatting/GaussianTile.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserlinePathTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/CutFill.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/LineMaterial.js +1 -1
- package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
- package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
- package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/materials/intersectWithPolygonOffset.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadedMaterialConfiguration.js +2 -0
- package/views/SceneView.d.ts +2 -4
- package/views/SceneView.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/views/View.d.ts +1 -3
- package/views/View2D.d.ts +2 -2
- package/views/analysis/ElevationProfile/ElevationProfileChart.js +2 -2
- package/views/analysis/ElevationProfile/elevationProfileChartBoundsUtils.js +1 -1
- package/views/draw/DrawAction.js +1 -1
- package/views/draw/support/PluginContext.js +1 -1
- package/views/interactive/options/ViewOptions.d.ts +0 -2
- package/views/interactive/sketch/normalizedPoint.js +1 -1
- package/views/interactive/tooltip/fields/TooltipFieldElevation.js +1 -1
- package/views/interactive/tooltip/fields/TooltipFieldOrientation.js +1 -1
- package/views/interactive/tooltip/fields/TooltipFieldSize.js +1 -1
- package/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel.js +1 -1
- package/widgets/Attachments.js +1 -1
- package/widgets/Attribution/AttributionViewModel.js +1 -1
- package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
- package/widgets/BasemapLayerList/BasemapLayerListViewModel.js +1 -1
- package/widgets/BasemapToggle/BasemapToggleViewModel.js +1 -1
- package/widgets/BatchAttributeForm/ReactiveContingentValuesManager.js +1 -1
- package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/Bookmarks/BookmarksViewModel.js +1 -1
- package/widgets/BuildingExplorer/BuildingExplorerViewModel.js +1 -1
- package/widgets/BuildingExplorer/BuildingNumericFilterViewModel.js +1 -1
- package/widgets/CatalogLayerList/CatalogLayerListViewModel.js +1 -1
- package/widgets/CatalogLayerList.js +1 -1
- package/widgets/Compass/CompassViewModel.js +1 -1
- package/widgets/CoordinateConversion/support/Format.js +1 -1
- package/widgets/CoordinateConversion/support/formatUtils.js +1 -1
- package/widgets/Daylight/DaylightViewModel.js +1 -1
- package/widgets/DistanceMeasurement2D/DistanceMeasurement2DViewModel.js +1 -1
- package/widgets/Editor/EditorViewModel.d.ts +0 -1
- package/widgets/Editor/support/SketchController.js +1 -1
- package/widgets/Editor.d.ts +0 -1
- package/widgets/ElevationProfile/ElevationProfileLine.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileViewModel.js +1 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/Expand/ExpandViewModel.js +1 -1
- package/widgets/Expand.js +1 -1
- package/widgets/Feature/FeatureMedia.js +1 -1
- package/widgets/Feature/FeatureViewModel.js +1 -1
- package/widgets/Feature.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTemplates.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
- package/widgets/Fullscreen/FullscreenViewModel.js +1 -1
- package/widgets/Histogram/HistogramViewModel.js +1 -1
- package/widgets/Histogram.js +1 -1
- package/widgets/HistogramRangeSlider/HistogramRangeSliderViewModel.js +1 -1
- package/widgets/Home/HomeViewModel.js +1 -1
- package/widgets/LayerList/LayerListViewModel.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/styles/card/CardView.js +1 -1
- package/widgets/Legend/styles/classic/ClassicView.js +1 -1
- package/widgets/Locate/LocateViewModel.js +1 -1
- package/widgets/Locate.js +1 -1
- package/widgets/NavigationToggle/NavigationToggleViewModel.js +1 -1
- package/widgets/NavigationToggle.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
- package/widgets/OrientedImageryViewer/services/SuperimposeService.js +1 -1
- package/widgets/OrientedImageryViewer/support/urlUtils.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
- package/widgets/Search.js +1 -1
- package/widgets/ShadowCast/DiscreteOptions.js +1 -1
- package/widgets/ShadowCast/DurationOptions.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/widgets/ShadowCast/ThresholdOptions.js +1 -1
- package/widgets/Sketch/SketchViewModel.d.ts +0 -1
- package/widgets/Sketch.d.ts +0 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/Slider/SliderViewModel.js +1 -1
- package/widgets/Slider.js +1 -1
- package/widgets/TableList/TableListViewModel.js +1 -1
- package/widgets/TimeSlider/TimeSliderViewModel.js +1 -1
- package/widgets/Weather/WeatherViewModel.js +1 -1
- package/widgets/Widget.js +1 -1
- package/widgets/Zoom/ZoomViewModel.js +1 -1
- package/widgets/support/AnalysisViewModelMixin.js +1 -1
- package/widgets/support/GridControls.js +1 -1
- package/widgets/support/dateUtils.js +1 -1
- package/assets/esri/core/workers/chunks/00d43f02119167531d1b.js +0 -1
- package/assets/esri/core/workers/chunks/059cda6f11a91dbc9e28.js +0 -1
- package/assets/esri/core/workers/chunks/0696fa44a04b99738d7b.js +0 -1
- package/assets/esri/core/workers/chunks/073f0232135f71b6c7a5.js +0 -1
- package/assets/esri/core/workers/chunks/091ec4fe83038f3558f4.js +0 -1
- package/assets/esri/core/workers/chunks/098ac10877d92fde1006.js +0 -1
- package/assets/esri/core/workers/chunks/0a29d87b6e58a3c6df8f.js +0 -1
- package/assets/esri/core/workers/chunks/0bf43d80cb40c2b43333.js +0 -1
- package/assets/esri/core/workers/chunks/0d04353843ccb7440342.js +0 -1
- package/assets/esri/core/workers/chunks/1132e28aaa5825b10b6e.js +0 -1
- package/assets/esri/core/workers/chunks/123541f79be7adff0818.js +0 -1
- package/assets/esri/core/workers/chunks/1380cec385426673f294.js +0 -1
- package/assets/esri/core/workers/chunks/1866f832e5f52958bc97.js +0 -1
- package/assets/esri/core/workers/chunks/19e51cbb354954ddafbd.js +0 -1
- package/assets/esri/core/workers/chunks/1b24a40c0fa197014873.js +0 -1
- package/assets/esri/core/workers/chunks/1c7096eb48a3a7f27d4f.js +0 -1
- package/assets/esri/core/workers/chunks/1cc03067f8405285057c.js +0 -1
- package/assets/esri/core/workers/chunks/1deca3de77b1a9a07da4.js +0 -1
- package/assets/esri/core/workers/chunks/1f76f6dcdae9f55389cb.js +0 -1
- package/assets/esri/core/workers/chunks/1fd82fcba2758741996a.js +0 -1
- package/assets/esri/core/workers/chunks/21e1d423ee33f916547e.js +0 -1
- package/assets/esri/core/workers/chunks/23f3692c7426173e8352.js +0 -1
- package/assets/esri/core/workers/chunks/247617c0dbae2386ab3b.js +0 -1
- package/assets/esri/core/workers/chunks/25657f70c5f04a4ed978.js +0 -1
- package/assets/esri/core/workers/chunks/2853606099602f73d379.js +0 -1
- package/assets/esri/core/workers/chunks/28ed020d9995b6577be5.js +0 -1
- package/assets/esri/core/workers/chunks/2b27d3bc492e000bbe58.js +0 -1
- package/assets/esri/core/workers/chunks/2d64a13c2303e9cae613.js +0 -1
- package/assets/esri/core/workers/chunks/2dfe6af28cd1b29d5ebc.js +0 -1
- package/assets/esri/core/workers/chunks/305eeaac0b4d5b79ebde.js +0 -1
- package/assets/esri/core/workers/chunks/353976c812ebf0c98549.js +0 -1
- package/assets/esri/core/workers/chunks/3b5e9e0b180dc10491ec.js +0 -1
- package/assets/esri/core/workers/chunks/46edd6c9ed6701e6b975.js +0 -1
- package/assets/esri/core/workers/chunks/4caebb64a365da18453f.js +0 -1
- package/assets/esri/core/workers/chunks/4d8833f48348cbbcc947.js +0 -1
- package/assets/esri/core/workers/chunks/4e17665dd9048c300d87.js +0 -1
- package/assets/esri/core/workers/chunks/4e4f747de424941a0bfa.js +0 -1
- package/assets/esri/core/workers/chunks/4e8e322b469657ac22e2.js +0 -1
- package/assets/esri/core/workers/chunks/5396b6e99a0546a25d19.js +0 -1
- package/assets/esri/core/workers/chunks/553a8bf5bc5c56d1bcaf.js +0 -1
- package/assets/esri/core/workers/chunks/55c0c074e4afe05f5d4d.js +0 -1
- package/assets/esri/core/workers/chunks/598ba405e93ebccf7b2d.js +0 -1
- package/assets/esri/core/workers/chunks/5bfb962ca192f90a2724.js +0 -1
- package/assets/esri/core/workers/chunks/60c8eedd06080edab3e3.js +0 -1
- package/assets/esri/core/workers/chunks/61d36730564c5ac5edab.js +0 -1
- package/assets/esri/core/workers/chunks/6588725275c75fae0d9c.js +0 -1
- package/assets/esri/core/workers/chunks/661c6324529dd17b297e.js +0 -1
- package/assets/esri/core/workers/chunks/6699fac01ccd842851ba.js +0 -1
- package/assets/esri/core/workers/chunks/672a5390182b20d632be.js +0 -1
- package/assets/esri/core/workers/chunks/67caef2ecf0dc5f2eed3.js +0 -1
- package/assets/esri/core/workers/chunks/68dd1fd2025c7125ead1.js +0 -1
- package/assets/esri/core/workers/chunks/68fd7b314377d27aaa54.js +0 -1
- package/assets/esri/core/workers/chunks/69627b2634da64dd885f.js +0 -1
- package/assets/esri/core/workers/chunks/6f2e7e663229b223b4df.js +0 -1
- package/assets/esri/core/workers/chunks/7390af96250e89194332.js +0 -1
- package/assets/esri/core/workers/chunks/7b45ac83e279fe9516a5.js +0 -1
- package/assets/esri/core/workers/chunks/7e0ed6e8f7b77e43f628.js +0 -1
- package/assets/esri/core/workers/chunks/832c887fdc5af4c08cf2.js +0 -1
- package/assets/esri/core/workers/chunks/84fb27e3425515cd0e3f.js +0 -1
- package/assets/esri/core/workers/chunks/8502274806ea52308822.js +0 -1
- package/assets/esri/core/workers/chunks/8b0be232723424dda320.js +0 -1
- package/assets/esri/core/workers/chunks/8b0efcc30184593a0812.js +0 -1121
- package/assets/esri/core/workers/chunks/8b38fad017c4c0d9e1ec.js +0 -1
- package/assets/esri/core/workers/chunks/8c3779de09291170497f.js +0 -1
- package/assets/esri/core/workers/chunks/8e391b5b82429f39791e.js +0 -1
- package/assets/esri/core/workers/chunks/8e6276ddd8d094c61f08.js +0 -1
- package/assets/esri/core/workers/chunks/90d797ab82d4a68ba32f.js +0 -1
- package/assets/esri/core/workers/chunks/96f87c8efd4b11b37686.js +0 -1
- package/assets/esri/core/workers/chunks/9826baa3c15ea2062669.js +0 -1
- package/assets/esri/core/workers/chunks/98958203a5ca45b24d72.js +0 -1
- package/assets/esri/core/workers/chunks/9c3de54513bf8619271c.js +0 -1
- package/assets/esri/core/workers/chunks/a125650edbed802e419a.js +0 -1
- package/assets/esri/core/workers/chunks/a18c3cbe505a19d29569.js +0 -1
- package/assets/esri/core/workers/chunks/a5f17e9a025ac2b6e1bf.js +0 -1
- package/assets/esri/core/workers/chunks/a6e846361bf5dd3a11c7.js +0 -1
- package/assets/esri/core/workers/chunks/ac107079342251a984dd.js +0 -1
- package/assets/esri/core/workers/chunks/acf4737ba509cbd73cce.js +0 -1
- package/assets/esri/core/workers/chunks/af2087b75225d7d7dbd8.js +0 -1
- package/assets/esri/core/workers/chunks/b386e921c273de3ac7a5.js +0 -1
- package/assets/esri/core/workers/chunks/b3aa29589dcfb5b93106.js +0 -1
- package/assets/esri/core/workers/chunks/b7205620ca248f4efc88.js +0 -1
- package/assets/esri/core/workers/chunks/c0eb27263f608dc3684b.js +0 -1
- package/assets/esri/core/workers/chunks/c5364ff8dd1358af3603.js +0 -1
- package/assets/esri/core/workers/chunks/ca21786e519c914fc9e1.js +0 -1
- package/assets/esri/core/workers/chunks/cd46d9b4a8de644e7332.js +0 -1
- package/assets/esri/core/workers/chunks/da1e6962ba0c85c37953.js +0 -1
- package/assets/esri/core/workers/chunks/dcdf837a452dc0cac582.js +0 -1
- package/assets/esri/core/workers/chunks/e0864ca82ffa3c9a0776.js +0 -1
- package/assets/esri/core/workers/chunks/e69cd62f824ce7a22fa0.js +0 -1
- package/assets/esri/core/workers/chunks/e9457a67befc61e11095.js +0 -1
- package/assets/esri/core/workers/chunks/efc1a90742813b55602e.js +0 -1
- package/assets/esri/core/workers/chunks/f190a3124d6d03417d73.js +0 -1
- package/assets/esri/core/workers/chunks/f4135779bfdaf349352a.js +0 -1
- package/assets/esri/core/workers/chunks/f6bd7b52745b82ba73dc.js +0 -1
- package/assets/esri/core/workers/chunks/f6f5937a1308f28bb959.js +0 -1
- package/assets/esri/core/workers/chunks/fc77eb7683e708774168.js +0 -1
- package/assets/esri/core/workers/chunks/fd967a9f3cf0e2890dbb.js +0 -1
- package/assets/esri/core/workers/chunks/fe24e039385473bf77f9.js +0 -1
- package/assets/esri/core/workers/chunks/fecaf0bc28aeea4d15db.js +0 -1
- package/assets/esri/themes/base/widgets/_UtilityNetworkValidateTopology.scss +0 -46
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.ar.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.bg.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.bs.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.ca.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.cs.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.da.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.de.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.el.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.en.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.es.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.et.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.fi.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.fr.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.he.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.hr.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.hu.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.id.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.it.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.ja.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.ko.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.lt.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.lv.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.nl.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.no.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.pl.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.pt-BR.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.pt-PT.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.ro.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.ru.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.sk.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.sl.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.sr.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.sv.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.th.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.tr.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.uk.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.vi.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.zh-CN.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.zh-HK.json +0 -1
- package/assets/esri/widgets/UtilityNetworkValidateTopology/t9n/messages.zh-TW.json +0 -1
- package/views/2d/engine/vectorTiles/style/VectorTilePbfWriter.js +0 -2
- package/views/2d/engine/vectorTiles/style/encodeVectorTileFeatures.js +0 -2
- package/views/2d/layers/features/support/FeatureSetReaderVectorTileFeatureCursor.js +0 -2
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.d.ts +0 -72
- package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +0 -2
- package/widgets/UtilityNetworkValidateTopology.d.ts +0 -130
- package/widgets/UtilityNetworkValidateTopology.js +0 -2
- /package/views/2d/engine/vectorTiles/{Feature.js → PbfFeature.js} +0 -0
package/layers/WebTileLayer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../request.js";import n from"../core/Error.js";import{MultiOriginJSONSupportMixin as r}from"../core/MultiOriginJSONSupport.js";import{replace as i}from"../core/string.js";import{Url as a,ensureTrailingSlash as o,isProtocolRelative as s,normalize as c}from"../core/urlUtils.js";import{property as l,subclass as u}from"../core/accessorSupport/decorators.js";import d from"../geometry/Extent.js";import f from"../geometry/Point.js";import p from"../geometry/SpatialReference.js";import m from"./Layer.js";import{BlendLayer as h}from"./mixins/BlendLayer.js";import{OperationalLayer as g}from"./mixins/OperationalLayer.js";import{PortalLayer as _}from"./mixins/PortalLayer.js";import{RefreshableLayer as v}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as y}from"./mixins/ScaleRangeLayer.js";import{createTileBitmap as b}from"./support/imageBitmapUtils.js";import x from"./support/LOD.js";import S from"./support/TileInfo.js";import{WMTSLayerInfo as C}from"./support/WMTSLayerInfo.js";import{reader as w}from"../core/accessorSupport/decorators/reader.js";import{writer as T}from"../core/accessorSupport/decorators/writer.js";var E;let D=E=class extends h(v(y(g(_(r(m)))))){constructor(e){super(e),this.copyright=``,this.fullExtent=new d({xmin:-20037508.342787,ymin:-20037508.34278,xmax:20037508.34278,ymax:20037508.342787,spatialReference:p.WebMercator}),this.legendEnabled=!1,this.isReference=null,this.popupEnabled=!1,this.spatialReference=p.WebMercator,this.subDomains=null,this.tileInfo=new S({size:[256,256],dpi:96,format:`png8`,compressionQuality:0,origin:new f({x:-20037508.342787,y:20037508.342787,spatialReference:p.WebMercator}),spatialReference:p.WebMercator,lods:[new x({level:0,scale:591657527.591555,resolution:156543.033928}),new x({level:1,scale:295828763.795777,resolution:78271.5169639999}),new x({level:2,scale:147914381.897889,resolution:39135.7584820001}),new x({level:3,scale:73957190.948944,resolution:19567.8792409999}),new x({level:4,scale:36978595.474472,resolution:9783.93962049996}),new x({level:5,scale:18489297.737236,resolution:4891.96981024998}),new x({level:6,scale:9244648.868618,resolution:2445.98490512499}),new x({level:7,scale:4622324.434309,resolution:1222.99245256249}),new x({level:8,scale:2311162.217155,resolution:611.49622628138}),new x({level:9,scale:1155581.108577,resolution:305.748113140558}),new x({level:10,scale:577790.554289,resolution:152.874056570411}),new x({level:11,scale:288895.277144,resolution:76.4370282850732}),new x({level:12,scale:144447.638572,resolution:38.2185141425366}),new x({level:13,scale:72223.819286,resolution:19.1092570712683}),new x({level:14,scale:36111.909643,resolution:9.55462853563415}),new x({level:15,scale:18055.954822,resolution:4.77731426794937}),new x({level:16,scale:9027.977411,resolution:2.38865713397468}),new x({level:17,scale:4513.988705,resolution:1.19432856685505}),new x({level:18,scale:2256.994353,resolution:.597164283559817}),new x({level:19,scale:1128.497176,resolution:.298582141647617}),new x({level:20,scale:564.248588,resolution:.14929107082380833}),new x({level:21,scale:282.124294,resolution:.07464553541190416}),new x({level:22,scale:141.062147,resolution:.03732276770595208}),new x({level:23,scale:70.5310735,resolution:.01866138385297604})]}),this.type=`web-tile`,this.urlTemplate=null,this.wmtsInfo=null}
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../request.js";import n from"../core/Error.js";import{MultiOriginJSONSupportMixin as r}from"../core/MultiOriginJSONSupport.js";import{replace as i}from"../core/string.js";import{Url as a,ensureTrailingSlash as o,isProtocolRelative as s,normalize as c}from"../core/urlUtils.js";import{property as l,subclass as u}from"../core/accessorSupport/decorators.js";import d from"../geometry/Extent.js";import f from"../geometry/Point.js";import p from"../geometry/SpatialReference.js";import m from"./Layer.js";import{BlendLayer as h}from"./mixins/BlendLayer.js";import{OperationalLayer as g}from"./mixins/OperationalLayer.js";import{PortalLayer as _}from"./mixins/PortalLayer.js";import{RefreshableLayer as v}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as y}from"./mixins/ScaleRangeLayer.js";import{createTileBitmap as b}from"./support/imageBitmapUtils.js";import x from"./support/LOD.js";import S from"./support/TileInfo.js";import{WMTSLayerInfo as C}from"./support/WMTSLayerInfo.js";import{reader as w}from"../core/accessorSupport/decorators/reader.js";import{writer as T}from"../core/accessorSupport/decorators/writer.js";var E;let D=E=class extends h(v(y(g(_(r(m)))))){constructor(e){super(e),this.copyright=``,this.fullExtent=new d({xmin:-20037508.342787,ymin:-20037508.34278,xmax:20037508.34278,ymax:20037508.342787,spatialReference:p.WebMercator}),this.legendEnabled=!1,this.isReference=null,this.popupEnabled=!1,this.spatialReference=p.WebMercator,this.subDomains=null,this.tileInfo=new S({size:[256,256],dpi:96,format:`png8`,compressionQuality:0,origin:new f({x:-20037508.342787,y:20037508.342787,spatialReference:p.WebMercator}),spatialReference:p.WebMercator,lods:[new x({level:0,scale:591657527.591555,resolution:156543.033928}),new x({level:1,scale:295828763.795777,resolution:78271.5169639999}),new x({level:2,scale:147914381.897889,resolution:39135.7584820001}),new x({level:3,scale:73957190.948944,resolution:19567.8792409999}),new x({level:4,scale:36978595.474472,resolution:9783.93962049996}),new x({level:5,scale:18489297.737236,resolution:4891.96981024998}),new x({level:6,scale:9244648.868618,resolution:2445.98490512499}),new x({level:7,scale:4622324.434309,resolution:1222.99245256249}),new x({level:8,scale:2311162.217155,resolution:611.49622628138}),new x({level:9,scale:1155581.108577,resolution:305.748113140558}),new x({level:10,scale:577790.554289,resolution:152.874056570411}),new x({level:11,scale:288895.277144,resolution:76.4370282850732}),new x({level:12,scale:144447.638572,resolution:38.2185141425366}),new x({level:13,scale:72223.819286,resolution:19.1092570712683}),new x({level:14,scale:36111.909643,resolution:9.55462853563415}),new x({level:15,scale:18055.954822,resolution:4.77731426794937}),new x({level:16,scale:9027.977411,resolution:2.38865713397468}),new x({level:17,scale:4513.988705,resolution:1.19432856685505}),new x({level:18,scale:2256.994353,resolution:.597164283559817}),new x({level:19,scale:1128.497176,resolution:.298582141647617}),new x({level:20,scale:564.248588,resolution:.14929107082380833}),new x({level:21,scale:282.124294,resolution:.07464553541190416}),new x({level:22,scale:141.062147,resolution:.03732276770595208}),new x({level:23,scale:70.5310735,resolution:.01866138385297604})]}),this.type=`web-tile`,this.urlTemplate=null,this.wmtsInfo=null}load(e){let t=this.loadFromPortal({supportedTypes:[`WMTS`]},e).then(()=>{let e=``;if(!this.urlTemplate)e=`is missing the required 'urlTemplate' property value`;else if(!this.spatialReference.equals(this.tileInfo.spatialReference))e=`spatialReference must match tileInfo.spatialReference`;else{let t=new a(this.urlTemplate);!(this.subDomains&&this.subDomains.length>0)&&t.authority?.includes(`{subDomain}`)&&(e=`is missing 'subDomains' property`)}if(e)throw new n(`web-tile-layer:load`,`WebTileLayer (title: '${this.title}', id: '${this.id}') ${e}`)});return this.addResolvingPromise(t),Promise.resolve(this)}get levelValues(){let e=[];if(!this.tileInfo)return null;for(let t of this.tileInfo.lods)e[t.level]=t.levelValue||t.level;return e}get loaded(){return super.loaded}readSpatialReference(e,t){return e||p.fromJSON(t.fullExtent?.spatialReference)}get tileServers(){if(!this.urlTemplate)return null;let e=[],{urlTemplate:t,subDomains:n}=this,r=new a(t),i=r.scheme?r.scheme+`://`:`//`,s=i+r.authority+`/`,c=r.authority;if(!c?.includes(`{subDomain}`))e.push(s);else if(n&&n.length>0&&c.split(`.`).length>1)for(let t of n)e.push(i+c.replaceAll(/\{subDomain\}/gi,t)+`/`);return e.map(o)}get urlPath(){if(!this.urlTemplate)return null;let e=this.urlTemplate,t=new a(e),n=(t.scheme?t.scheme+`://`:`//`)+t.authority+`/`;return e.slice(n.length)}readUrlTemplate(e,t){return e||t.templateUrl}writeUrlTemplate(e,t){s(e)&&(e=`https:`+e),e&&=(e=e.replaceAll(/\{z\}/gi,`{level}`).replaceAll(/\{x\}/gi,`{col}`).replaceAll(/\{y\}/gi,`{row}`),c(e)),t.templateUrl=e}fetchTile(e,n,r,i={}){let{signal:a}=i,o=this.getTileUrl(e,n,r),s={responseType:`image`,signal:a,query:{...this.refreshParameters}};return t(o,s).then(e=>e.data)}async fetchImageBitmapTile(e,n,r,i={}){let{signal:a}=i;if(this.fetchTile!==E.prototype.fetchTile){let t=await this.fetchTile(e,n,r,i);return b(t,e,n,r,i)}let o=this.getTileUrl(e,n,r),s={responseType:`blob`,signal:a,query:{...this.refreshParameters}},{data:c}=await t(o,s);return b(c,e,n,r,i)}getTileUrl(e,t,n){let{levelValues:r,tileServers:a,urlPath:o}=this;if(!r||!a||!o)return``;let s=r[e];return a[t%a.length]+i(o,{level:s,z:s,col:n,x:n,row:t,y:t})}};e([l({type:String,value:``,json:{write:!0}})],D.prototype,`copyright`,void 0),e([l({type:d,json:{write:!0},nonNullable:!0})],D.prototype,`fullExtent`,void 0),e([l({readOnly:!0,json:{read:!1,write:!1}})],D.prototype,`legendEnabled`,void 0),e([l({type:[`show`,`hide`]})],D.prototype,`listMode`,void 0),e([l({json:{read:!0,write:!0}})],D.prototype,`blendMode`,void 0),e([l()],D.prototype,`levelValues`,null),e([l({type:Boolean,json:{read:!1,write:{enabled:!0,overridePolicy:()=>({enabled:!1})}}})],D.prototype,`isReference`,void 0),e([l({type:[`WebTiledLayer`],value:`WebTiledLayer`})],D.prototype,`operationalLayerType`,void 0),e([l({readOnly:!0,json:{read:!1,write:!1}})],D.prototype,`popupEnabled`,void 0),e([l({type:p})],D.prototype,`spatialReference`,void 0),e([w(`spatialReference`,[`spatialReference`,`fullExtent.spatialReference`])],D.prototype,`readSpatialReference`,null),e([l({type:[String],json:{write:!0}})],D.prototype,`subDomains`,void 0),e([l({type:S,json:{write:!0}})],D.prototype,`tileInfo`,void 0),e([l({readOnly:!0})],D.prototype,`tileServers`,null),e([l({json:{read:!1}})],D.prototype,`type`,void 0),e([l()],D.prototype,`urlPath`,null),e([l({type:String,json:{origins:{"portal-item":{read:{source:`url`}}}}})],D.prototype,`urlTemplate`,void 0),e([w(`urlTemplate`,[`urlTemplate`,`templateUrl`])],D.prototype,`readUrlTemplate`,null),e([T(`urlTemplate`,{templateUrl:{type:String}})],D.prototype,`writeUrlTemplate`,null),e([l({type:C,json:{write:!0}})],D.prototype,`wmtsInfo`,void 0),D=E=e([u(`esri.layers.WebTileLayer`)],D);export{D as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import e from"../../core/Error.js";import{setDeepValue as t}from"../../core/object.js";import{parse as n}from"./parser.js";import{isEffectFunctions as r}from"./utils.js";function i(e,t,n){try{return s(e)}catch(e){n?.messages?.push(e)}return null}function a(e,n,r,i){try{let i=o(e);t(r,i,n)}catch(e){i.messages&&i.messages.push(e)}}function o(e){let t=n(e);return t?r(t)?t.map(e=>e.toJSON()):t.map(({scale:e,effects:t})=>({scale:e,value:t.map(e=>e.toJSON())})):null}function s(e){
|
|
2
|
+
import e from"../../core/Error.js";import{setDeepValue as t}from"../../core/object.js";import{parse as n}from"./parser.js";import{isEffectFunctions as r}from"./utils.js";function i(e,t,n){try{return s(e)}catch(e){n?.messages?.push(e)}return null}function a(e,n,r,i){try{let i=o(e);t(r,i,n)}catch(e){i.messages&&i.messages.push(e)}}function o(e){let t=n(e);return t?r(t)?t.map(e=>e.toJSON()):t.map(({scale:e,effects:t})=>({scale:e,value:t.map(e=>e.toJSON())})):null}function s(e){return!e||e.length===0?null:c(e)?Array.from(e,e=>({scale:e.scale,value:l(e.value)})):l(e)}function c(e){let t=e[0];return t?`scale`in t:!1}function l(e){if(!e?.length)return``;let t=[];for(let r of e){let e=[];switch(r.type){case`grayscale`:case`sepia`:case`saturate`:case`invert`:case`brightness`:case`contrast`:case`opacity`:e=[u(r,`amount`)];break;case`blur`:e=[u(r,`radius`,`pt`)];break;case`hue-rotate`:e=[u(r,`angle`,`deg`)];break;case`drop-shadow`:e=[u(r,`xoffset`,`pt`),u(r,`yoffset`,`pt`),u(r,`blurRadius`,`pt`),d(r,`color`)];break;case`bloom`:e=[u(r,`strength`),u(r,`radius`,`pt`),u(r,`threshold`)]}let i=`${r.type}(${e.filter(Boolean).join(` `)})`;n(i),t.push(i)}return t.join(` `)}function u(t,n,r){if(t[n]==null)throw new e(`effect:missing-parameter`,`Missing parameter '${n}' in ${t.type} effect`,{effect:t});return r?t[n]+r:``+t[n]}function d(t,n){if(t[n]==null)throw new e(`effect:missing-parameter`,`Missing parameter '${n}' in ${t.type} effect`,{effect:t});let r=t[n];return`rgba(${r[0]||0}, ${r[1]||0}, ${r[2]||0}, ${r[3]/255||0})`}export{l as effectFunctionsFromJSON,s as fromJSON,i as read,o as toJSON,a as write};
|
|
@@ -54,4 +54,4 @@ this.workerSrc)).WorkerMessageHandler})())}}class Zn{downloadInfoCapability=Prom
|
|
|
54
54
|
`)}`;this.#l();let u=new Range,d=Math.sumPrecise(c.map(e=>e.length));for(let{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){let t=e.nodeValue.length;if(d<=t){u.setStart(e,d);u.setEnd(e,d);break}d-=t}i.removeAllRanges();i.addRange(u)}#l(){this.editorDiv.replaceChildren();if(this.#e)for(let e of this.#e.split(`
|
|
55
55
|
`)){let t=document.createElement(`div`);t.append(e?document.createTextNode(e):document.createElement(`br`));this.editorDiv.append(t)}}#u(){return this.#e.replaceAll(`\xA0`,` `)}static#d(e){return e.replaceAll(` `,`\xA0`)}get contentDiv(){return this.editorDiv}getPDFRect(){let e=X._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,t,n){let r=null;if(e instanceof dr){let{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:i,rotation:a,id:o,popupRef:s,richText:c,contentsObj:l,creationDate:u,modificationDate:d},textContent:f,textPosition:p,parent:{page:{pageNumber:m}}}=e;if(!f||f.length===0)return null;r=e={annotationType:_.FREETEXT,color:Array.from(n),fontSize:t,value:f.join(`
|
|
56
56
|
`),position:p,pageIndex:m-1,rect:i.slice(0),rotation:a,annotationElementId:o,id:o,deleted:!1,popupRef:s,comment:l?.str||null,richText:c,creationDate:u,modificationDate:d}}let i=await super.deserialize(e,t,n);i.#r=e.fontSize;i.color=P.makeHexColor(...e.color);i.#e=X.#d(e.value);i._initialData=r;e.comment&&i.setCommentData(e);return i}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let t=H._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),n=Object.assign(super.serialize(e),{color:t,fontSize:this.#r,value:this.#u()});this.addComment(n);if(e){n.isCopy=!0;return n}if(this.annotationElementId&&!this.#f(n))return null;n.id=this.annotationElementId;return n}#f(e){let{value:t,fontSize:n,color:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==t||e.fontSize!==n||e.color.some((e,t)=>e!==r[t])||e.pageIndex!==i}renderAnnotationElement(e){let t=super.renderAnnotationElement(e);if(!t)return null;let{style:n}=t;n.fontSize=`calc(${this.#r}px * var(--total-scale-factor))`;n.color=this.color;t.replaceChildren();for(let e of this.#e.split(`
|
|
57
|
-
`)){let n=document.createElement(`div`);n.append(e?document.createTextNode(e):document.createElement(`br`));t.append(n)}e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#e}});return t}resetAnnotationElement(e){super.resetAnnotationElement(e);e.resetEdited()}}class Z{static PRECISION=1e-4;toSVGPath(){D("Abstract method `toSVGPath` must be implemented.")}get box(){D("Abstract getter `box` must be implemented.")}serialize(e,t){D("Abstract method `serialize` must be implemented.")}static _rescale(e,t,n,r,i,a){a||=new Float32Array(e.length);for(let o=0,s=e.length;o<s;o+=2){a[o]=t+e[o]*r;a[o+1]=n+e[o+1]*i}return a}static _rescaleAndSwap(e,t,n,r,i,a){a||=new Float32Array(e.length);for(let o=0,s=e.length;o<s;o+=2){a[o]=t+e[o+1]*r;a[o+1]=n+e[o]*i}return a}static _translate(e,t,n,r){r||=new Float32Array(e.length);for(let i=0,a=e.length;i<a;i+=2){r[i]=t+e[i];r[i+1]=n+e[i+1]}return r}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,t,n,r,i){switch(i){case 90:return[1-t/n,e/r];case 180:return[1-e/n,1-t/r];case 270:return[t/n,1-e/r];default:return[e/n,t/r]}}static _normalizePagePoint(e,t,n){switch(n){case 90:return[1-t,e];case 180:return[1-e,1-t];case 270:return[t,1-e];default:return[e,t]}}static createBezierPoints(e,t,n,r,i,a){return[(e+5*n)/6,(t+5*r)/6,(5*n+i)/6,(5*r+a)/6,(n+i)/2,(r+a)/2]}}class gr{#e;#t=[];#n;#r;#i=[];#a=new Float32Array(18);#o;#s;#c;#l;#u;#d;#f=[];static#p=8;static#m=2;static#h=gr.#p+gr.#m;constructor({x:e,y:t},n,r,i,a,o=0){this.#e=n;this.#d=i*r;this.#r=a;this.#a.set([NaN,NaN,NaN,NaN,e,t],6);this.#n=o;this.#l=gr.#p*r;this.#c=gr.#h*r;this.#u=r;this.#f.push(e,t)}isEmpty(){return isNaN(this.#a[8])}#g(){let e=this.#a.subarray(4,6),t=this.#a.subarray(16,18),[n,r,i,a]=this.#e;return[(this.#o+(e[0]-t[0])/2-n)/i,(this.#s+(e[1]-t[1])/2-r)/a,(this.#o+(t[0]-e[0])/2-n)/i,(this.#s+(t[1]-e[1])/2-r)/a]}add({x:e,y:t}){this.#o=e;this.#s=t;let[n,r,i,a]=this.#e,[o,s,c,l]=this.#a.subarray(8,12),u=e-c,d=t-l,f=Math.hypot(u,d);if(f<this.#c)return!1;let p=f-this.#l,m=p/f,h=m*u,g=m*d,_=o,v=s;o=c;s=l;c+=h;l+=g;this.#f?.push(e,t);let y=h/p,b=-g/p*this.#d,x=y*this.#d;this.#a.set(this.#a.subarray(2,8),0);this.#a.set([c+b,l+x],4);this.#a.set(this.#a.subarray(14,18),12);this.#a.set([c-b,l-x],16);if(isNaN(this.#a[6])){if(this.#i.length===0){this.#a.set([o+b,s+x],2);this.#i.push(NaN,NaN,NaN,NaN,(o+b-n)/i,(s+x-r)/a);this.#a.set([o-b,s-x],14);this.#t.push(NaN,NaN,NaN,NaN,(o-b-n)/i,(s-x-r)/a)}this.#a.set([_,v,o,s,c,l],6);return!this.isEmpty()}this.#a.set([_,v,o,s,c,l],6);if(Math.abs(Math.atan2(v-s,_-o)-Math.atan2(g,h))<Math.PI/2){[o,s,c,l]=this.#a.subarray(2,6);this.#i.push(NaN,NaN,NaN,NaN,((o+c)/2-n)/i,((s+l)/2-r)/a);[o,s,_,v]=this.#a.subarray(14,18);this.#t.push(NaN,NaN,NaN,NaN,((_+o)/2-n)/i,((v+s)/2-r)/a);return!0}[_,v,o,s,c,l]=this.#a.subarray(0,6);this.#i.push(((_+5*o)/6-n)/i,((v+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a);[c,l,o,s,_,v]=this.#a.subarray(12,18);this.#t.push(((_+5*o)/6-n)/i,((v+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a);return!0}toSVGPath(){if(this.isEmpty())return``;let e=this.#i,t=this.#t;if(isNaN(this.#a[6])&&!this.isEmpty())return this.#_();let n=[];n.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?n.push(`L${e[t+4]} ${e[t+5]}`):n.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);this.#y(n);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?n.push(`L${t[e+4]} ${t[e+5]}`):n.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#v(n);return n.join(` `)}#_(){let[e,t,n,r]=this.#e,[i,a,o,s]=this.#g();return`M${(this.#a[2]-e)/n} ${(this.#a[3]-t)/r} L${(this.#a[4]-e)/n} ${(this.#a[5]-t)/r} L${i} ${a} L${o} ${s} L${(this.#a[16]-e)/n} ${(this.#a[17]-t)/r} L${(this.#a[14]-e)/n} ${(this.#a[15]-t)/r} Z`}#v(e){let t=this.#t;e.push(`L${t[4]} ${t[5]} Z`)}#y(e){let[t,n,r,i]=this.#e,a=this.#a.subarray(4,6),o=this.#a.subarray(16,18),[s,c,l,u]=this.#g();e.push(`L${(a[0]-t)/r} ${(a[1]-n)/i} L${s} ${c} L${l} ${u} L${(o[0]-t)/r} ${(o[1]-n)/i}`)}newFreeDrawOutline(e,t,n,r,i,a){return new _r(e,t,n,r,i,a)}getOutlines(){let e=this.#i,t=this.#t,n=this.#a,[r,i,a,o]=this.#e,s=new Float32Array((this.#f?.length??0)+2);for(let e=0,t=s.length-2;e<t;e+=2){s[e]=(this.#f[e]-r)/a;s[e+1]=(this.#f[e+1]-i)/o}s[s.length-2]=(this.#o-r)/a;s[s.length-1]=(this.#s-i)/o;if(isNaN(n[6])&&!this.isEmpty())return this.#b(s);let c=new Float32Array(this.#i.length+24+this.#t.length),l=e.length;for(let t=0;t<l;t+=2)if(isNaN(e[t]))c[t]=c[t+1]=NaN;else{c[t]=e[t];c[t+1]=e[t+1]}l=this.#S(c,l);for(let e=t.length-6;e>=6;e-=6)for(let n=0;n<6;n+=2)if(isNaN(t[e+n])){c[l]=c[l+1]=NaN;l+=2}else{c[l]=t[e+n];c[l+1]=t[e+n+1];l+=2}this.#x(c,l);return this.newFreeDrawOutline(c,s,this.#e,this.#u,this.#n,this.#r)}#b(e){let t=this.#a,[n,r,i,a]=this.#e,[o,s,c,l]=this.#g(),u=new Float32Array(36);u.set([NaN,NaN,NaN,NaN,(t[2]-n)/i,(t[3]-r)/a,NaN,NaN,NaN,NaN,(t[4]-n)/i,(t[5]-r)/a,NaN,NaN,NaN,NaN,o,s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,(t[16]-n)/i,(t[17]-r)/a,NaN,NaN,NaN,NaN,(t[14]-n)/i,(t[15]-r)/a],0);return this.newFreeDrawOutline(u,e,this.#e,this.#u,this.#n,this.#r)}#x(e,t){let n=this.#t;e.set([NaN,NaN,NaN,NaN,n[4],n[5]],t);return t+6}#S(e,t){let n=this.#a.subarray(4,6),r=this.#a.subarray(16,18),[i,a,o,s]=this.#e,[c,l,u,d]=this.#g();e.set([NaN,NaN,NaN,NaN,(n[0]-i)/o,(n[1]-a)/s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,(r[0]-i)/o,(r[1]-a)/s],t);return t+24}}class _r extends Z{#e;#t=new Float32Array(4);#n;#r;#i;#a;#o;constructor(e,t,n,r,i,a){super();this.#o=e;this.#i=t;this.#e=n;this.#a=r;this.#n=i;this.#r=a;this.firstPoint=[NaN,NaN];this.lastPoint=[NaN,NaN];this.#s(a);let[o,s,c,l]=this.#t;for(let t=0,n=e.length;t<n;t+=2){e[t]=(e[t]-o)/c;e[t+1]=(e[t+1]-s)/l}for(let e=0,n=t.length;e<n;e+=2){t[e]=(t[e]-o)/c;t[e+1]=(t[e+1]-s)/l}}toSVGPath(){let e=[`M${this.#o[4]} ${this.#o[5]}`];for(let t=6,n=this.#o.length;t<n;t+=6)isNaN(this.#o[t])?e.push(`L${this.#o[t+4]} ${this.#o[t+5]}`):e.push(`C${this.#o[t]} ${this.#o[t+1]} ${this.#o[t+2]} ${this.#o[t+3]} ${this.#o[t+4]} ${this.#o[t+5]}`);e.push(`Z`);return e.join(` `)}serialize([e,t,n,r],i){let a=n-e,o=r-t,s,c;switch(i){case 0:s=Z._rescale(this.#o,e,r,a,-o);c=Z._rescale(this.#i,e,r,a,-o);break;case 90:s=Z._rescaleAndSwap(this.#o,e,t,a,o);c=Z._rescaleAndSwap(this.#i,e,t,a,o);break;case 180:s=Z._rescale(this.#o,n,t,-a,o);c=Z._rescale(this.#i,n,t,-a,o);break;case 270:s=Z._rescaleAndSwap(this.#o,n,r,-a,-o);c=Z._rescaleAndSwap(this.#i,n,r,-a,-o)}return{outline:Array.from(s),points:[Array.from(c)]}}#s(e){let t=this.#o,n=t[4],r=t[5],i=[n,r,n,r],a=n,o=r,s=n,c=r,l=e?Math.max:Math.min,d=new Float32Array(4);for(let e=6,f=t.length;e<f;e+=6){let f=t[e+4],p=t[e+5];if(isNaN(t[e])){P.pointBoundingBox(f,p,i);if(o>p){a=f;o=p}else o===p&&(a=l(a,f));if(c<p){s=f;c=p}else c===p&&(s=l(s,f))}else{d.set(u,0);P.bezierBoundingBox(n,r,...t.slice(e,e+6),d);P.rectBoundingBox(...d,i);if(o>d[1]){a=d[0];o=d[1]}else o===d[1]&&(a=l(a,d[0]));if(c<d[3]){s=d[2];c=d[3]}else c===d[3]&&(s=l(s,d[2]))}n=f;r=p}let f=this.#t;f[0]=i[0]-this.#n;f[1]=i[1]-this.#n;f[2]=i[2]-i[0]+2*this.#n;f[3]=i[3]-i[1]+2*this.#n;this.firstPoint=[a,o];this.lastPoint=[s,c]}get box(){return this.#t}newOutliner(e,t,n,r,i,a=0){return new gr(e,t,n,r,i,a)}getNewOutline(e,t){let[n,r,i,a]=this.#t,[o,s,c,l]=this.#e,u=i*c,d=a*l,f=n*c+o,p=r*l+s,m=this.newOutliner({x:this.#i[0]*u+f,y:this.#i[1]*d+p},this.#e,this.#a,e,this.#r,t??this.#n);for(let e=2;e<this.#i.length;e+=2)m.add({x:this.#i[e]*u+f,y:this.#i[e+1]*d+p});return m.getOutlines()}}class vr{#e;#t;#n;#r=[];#i=[];constructor(e,t=0,n=0,r=!0){let i=u.slice(),a=1e-4;for(let{x:n,y:r,width:o,height:s}of e){let e=Math.floor((n-t)/a)*a,c=Math.ceil((n+o+t)/a)*a,l=Math.floor((r-t)/a)*a,u=Math.ceil((r+s+t)/a)*a,d=[e,l,u,!0],f=[c,l,u,!1];this.#r.push(d,f);P.rectBoundingBox(e,l,c,u,i)}let o=i[2]-i[0]+2*n,s=i[3]-i[1]+2*n,c=i[0]-n,l=i[1]-n,d=r?-1/0:1/0,f=1/0,p=this.#r.at(r?-1:-2),m=[p[0],p[2]];for(let e of this.#r){let[t,n,i,a]=e;if(!a&&r){if(n<f){f=n;d=t}else n===f&&(d=Math.max(d,t))}else if(a&&!r){if(n<f){f=n;d=t}else n===f&&(d=Math.min(d,t))}e[0]=(t-c)/o;e[1]=(n-l)/s;e[2]=(i-l)/s}this.#e=new Float32Array([c,l,o,s]);this.#t=[d,f];this.#n=m}getOutlines(){this.#r.sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);let e=[];for(let t of this.#r)if(t[3]){e.push(...this.#l(t));this.#s(t)}else{this.#c(t);e.push(...this.#l(t))}return this.#a(e)}#a(e){let t=[],n=new Set;for(let n of e){let[e,r,i]=n;t.push([e,r,n],[e,i,n])}t.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,r=t.length;e<r;e+=2){let r=t[e][2],i=t[e+1][2];r.push(i);i.push(r);n.add(r);n.add(i)}let r=[],i;for(;n.size>0;){let e=n.values().next().value,[t,a,o,s,c]=e;n.delete(e);let l=t,u=a;i=[t,o];r.push(i);for(;;){let e;if(n.has(s))e=s;else{if(!n.has(c))break;e=c}n.delete(e);[t,a,o,s,c]=e;if(l!==t){i.push(l,u,t,u===a?a:o);l=t}u=u===a?o:a}i.push(l,u)}return new yr(r,this.#e,this.#t,this.#n)}#o(e){let t=this.#i,n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i][0];if(a===e)return i;a<e?n=i+1:r=i-1}return r+1}#s([,e,t]){let n=this.#o(e);this.#i.splice(n,0,[e,t])}#c([,e,t]){let n=this.#o(e);for(let r=n;r<this.#i.length;r++){let[n,i]=this.#i[r];if(n!==e)break;if(n===e&&i===t){this.#i.splice(r,1);return}}for(let r=n-1;r>=0;r--){let[n,i]=this.#i[r];if(n!==e)break;if(n===e&&i===t){this.#i.splice(r,1);return}}}#l(e){let[t,n,r]=e,i=[[t,n,r]],a=this.#o(r);for(let e=0;e<a;e++){let[n,r]=this.#i[e];for(let e=0,a=i.length;e<a;e++){let[,o,s]=i[e];if(!(r<=o||s<=n)){if(o>=n){if(s>r)i[e][1]=r;else{if(a===1)return[];i.splice(e,1);e--;a--}}else{i[e][2]=n;s>r&&i.push([t,r,s])}}}}return i}}class yr extends Z{#e;#t;constructor(e,t,n,r){super();this.#t=e;this.#e=t;this.firstPoint=n;this.lastPoint=r}toSVGPath(){let e=[];for(let t of this.#t){let[n,r]=t;e.push(`M${n} ${r}`);for(let i=2;i<t.length;i+=2){let a=t[i],o=t[i+1];if(a===n){e.push(`V${o}`);r=o}else if(o===r){e.push(`H${a}`);n=a}}e.push(`Z`)}return e.join(` `)}serialize([e,t,n,r],i){let a=[],o=n-e,s=r-t;for(let t of this.#t){let n=Array(t.length);for(let i=0;i<t.length;i+=2){n[i]=e+t[i]*o;n[i+1]=r-t[i+1]*s}a.push(n)}return a}get box(){return this.#e}get classNamesForOutlining(){return[`highlightOutline`]}}class br extends gr{newFreeDrawOutline(e,t,n,r,i,a){return new xr(e,t,n,r,i,a)}}class xr extends _r{newOutliner(e,t,n,r,i,a=0){return new br(e,t,n,r,i,a)}}class Q extends H{#e=null;#t=0;#n;#r=null;#i=null;#a=null;#o=null;#s=0;#c=null;#l=null;#u=null;#d=!1;#f=null;#p=null;#m=null;#h=``;#g;#_=``;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type=`highlight`;static _editorType=_.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId=``;static get _keyboardManager(){let e=Q.prototype;return j(this,`_keyboardManager`,new Ie([[[`ArrowLeft`,`mac+ArrowLeft`],e._moveCaret,{args:[0]}],[[`ArrowRight`,`mac+ArrowRight`],e._moveCaret,{args:[1]}],[[`ArrowUp`,`mac+ArrowUp`],e._moveCaret,{args:[2]}],[[`ArrowDown`,`mac+ArrowDown`],e._moveCaret,{args:[3]}]]))}constructor(e){super({...e,name:`highlightEditor`});this.color=e.color||Q._defaultColor;this.#g=e.thickness||Q._defaultThickness;this.opacity=e.opacity||Q._defaultOpacity;this.#n=e.boxes||null;this.#_=e.methodOfCreation||``;this.#h=e.text||``;this._isDraggable=!1;this.defaultL10nId=`pdfjs-editor-highlight-editor`;if(e.highlightId>-1){this.#d=!0;this.#y(e);this.#w()}else if(this.#n){this.#e=e.anchorNode;this.#t=e.anchorOffset;this.#o=e.focusNode;this.#s=e.focusOffset;this.#v();this.#w();this.rotate(this.rotation)}this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert.highlight)}get telemetryInitialData(){return{action:`added`,type:this.#d?`free_highlight`:`highlight`,color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#g,methodOfCreation:this.#_}}get telemetryFinalData(){return{type:`highlight`,color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get(`color`).size}}#v(){let e=new vr(this.#n,.001);this.#l=e.getOutlines();[this.x,this.y,this.width,this.height]=this.#l.box;let t=new vr(this.#n,.0025,.001,this._uiManager.direction===`ltr`);this.#a=t.getOutlines();let{firstPoint:n}=this.#l;this.#f=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height];let{lastPoint:r}=this.#a;this.#p=[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height]}#y({highlightOutlines:e,highlightId:t,clipPathId:n}){this.#l=e;this.#a=e.getNewOutline(this.#g/2+1.5,.0025);if(t>=0){this.#u=t;this.#r=n;this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}});this.#m=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},!0)}else if(this.parent){let t=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:Q.#T(this.#l.box,(t-this.rotation+360)%360),path:{d:e.toSVGPath()}});this.parent.drawLayer.updateProperties(this.#m,{bbox:Q.#T(this.#a.box,t),path:{d:this.#a.toSVGPath()}})}let[r,i,a,o]=e.box;switch(this.rotation){case 0:this.x=r;this.y=i;this.width=a;this.height=o;break;case 90:{let[e,t]=this.parentDimensions;this.x=i;this.y=1-r;this.width=a*t/e;this.height=o*e/t;break}case 180:this.x=1-r;this.y=1-i;this.width=a;this.height=o;break;case 270:{let[e,t]=this.parentDimensions;this.x=1-i;this.y=r;this.width=a*t/e;this.height=o*e/t;break}}let{firstPoint:s}=e;this.#f=[(s[0]-r)/a,(s[1]-i)/o];let{lastPoint:c}=this.#a;this.#p=[(c[0]-r)/a,(c[1]-i)/o]}static initialize(e,t){H.initialize(e,t);Q._defaultColor||=t.highlightColors?.values().next().value||`#fff066`}static updateDefaultParams(e,t){switch(e){case v.HIGHLIGHT_COLOR:Q._defaultColor=t;break;case v.HIGHLIGHT_THICKNESS:Q._defaultThickness=t}}translateInPage(e,t){}get toolbarPosition(){return this.#p}get commentButtonPosition(){return this.#f}updateParams(e,t){switch(e){case v.HIGHLIGHT_COLOR:this.#b(t);break;case v.HIGHLIGHT_THICKNESS:this.#x(t)}}static get defaultPropertiesToUpdate(){return[[v.HIGHLIGHT_COLOR,Q._defaultColor],[v.HIGHLIGHT_THICKNESS,Q._defaultThickness]]}get propertiesToUpdate(){return[[v.HIGHLIGHT_COLOR,this.color||Q._defaultColor],[v.HIGHLIGHT_THICKNESS,this.#g||Q._defaultThickness],[v.HIGHLIGHT_FREE,this.#d]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:this.color,"fill-opacity":this.opacity}});this.#i?.updateColor(this.color);super.onUpdatedColor()}#b(e){let t=(e,t)=>{this.color=e;this.opacity=t;this.onUpdatedColor()},n=this.color,r=this.opacity;this.addCommands({cmd:t.bind(this,e,Q._defaultOpacity),undo:t.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:`color_changed`,color:this._uiManager.getNonHCMColorName(e)},!0)}#x(e){let t=this.#g,n=e=>{this.#g=e;this.#S(e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:`thickness_changed`,thickness:e},!0)}get toolbarButtons(){if(this._uiManager.highlightColors)return[[`colorPicker`,this.#i=new Y({editor:this})]];return 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.#O())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#O())}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this);e&&this.div.focus()}remove(){this.#C();this._reportTelemetry({action:`deleted`});super.remove()}rebuild(){if(this.parent){super.rebuild();if(this.div!==null){this.#w();this.isAttachedToDOM||this.parent.add(this)}}}setParent(e){let t=!1;if(this.parent&&!e)this.#C();else if(e){this.#w(e);t=!this.parent&&this.div?.classList.contains(`selectedEditor`)}super.setParent(e);this.show(this._isVisible);t&&this.select()}#S(e){if(this.#d){this.#y({highlightOutlines:this.#l.getNewOutline(e/2)});this.fixAndSetPosition();this.setDims()}}#C(){if(this.#u!==null&&this.parent){this.parent.drawLayer.remove(this.#u);this.#u=null;this.parent.drawLayer.remove(this.#m);this.#m=null}}#w(e=this.parent){if(this.#u===null){({id:this.#u,clipPathId:this.#r}=e.drawLayer.draw({bbox:this.#l.box,root:{viewBox:`0 0 1 1`,fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#d},path:{d:this.#l.toSVGPath()}},!1,!0));this.#m=e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},this.#d);this.#c&&(this.#c.style.clipPath=this.#r)}}static#T([e,t,n,r],i){switch(i){case 90:return[1-t-r,e,r,n];case 180:return[1-e-n,1-t-r,n,r];case 270:return[t,1-e-n,r,n]}return[e,t,n,r]}rotate(e){let{drawLayer:t}=this.parent,n;if(this.#d){e=(e-this.rotation+360)%360;n=Q.#T(this.#l.box,e)}else n=Q.#T([this.x,this.y,this.width,this.height],e);t.updateProperties(this.#u,{bbox:n,root:{"data-main-rotation":e}});t.updateProperties(this.#m,{bbox:Q.#T(this.#a.box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;let e=super.render();if(this.#h){e.setAttribute(`aria-label`,this.#h);e.setAttribute(`role`,`mark`)}this.#d?e.classList.add(`free`):this.div.addEventListener(`keydown`,this.#E.bind(this),{signal:this._uiManager._signal});let t=this.#c=document.createElement(`div`);e.append(t);t.setAttribute(`aria-hidden`,`true`);t.className=`internal`;t.style.clipPath=this.#r;this.setDims();Me(this,this.#c,[`pointerover`,`pointerleave`]);this.enableEditing();return e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!1}})}#E(e){Q._keyboardManager.exec(this,e)}_moveCaret(e){this.parent.unselect(this);switch(e){case 0:case 2:this.#D(!0);break;case 1:case 3:this.#D(!1)}}#D(e){if(!this.#e)return;let t=window.getSelection();e?t.setPosition(this.#e,this.#t):t.setPosition(this.#o,this.#s)}select(){super.select();this.#m&&this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect();if(this.#m){this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{selected:!1}});this.#d||this.#D(!1)}}get _mustFixPosition(){return!this.#d}show(e=this._isVisible){super.show(e);if(this.parent){this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!e}});this.parent.drawLayer.updateProperties(this.#m,{rootClass:{hidden:!e}})}}#O(){return this.#d?this.rotation:0}#k(){if(this.#d)return null;let[e,t]=this.pageDimensions,[n,r]=this.pageTranslation,i=this.#n,a=new Float32Array(8*i.length),o=0;for(let{x:s,y:c,width:l,height:u}of i){let i=s*e+n,d=(1-c)*t+r;a[o]=a[o+4]=i;a[o+1]=a[o+3]=d;a[o+2]=a[o+6]=i+l*e;a[o+5]=a[o+7]=d-u*t;o+=8}return a}#A(e){return this.#l.serialize(e,this.#O())}static startHighlighting(e,t,{target:n,x:r,y:i}){let{x:a,y:o,width:s,height:c}=n.getBoundingClientRect(),l=new AbortController,u=e.combinedSignal(l),d=t=>{l.abort();this.#M(e,t)};window.addEventListener(`blur`,d,{signal:u});window.addEventListener(`pointerup`,d,{signal:u});window.addEventListener(`pointerdown`,R,{capture:!0,passive:!1,signal:u});window.addEventListener(`contextmenu`,L,{signal:u});n.addEventListener(`pointermove`,this.#j.bind(this,e),{signal:u});this._freeHighlight=new br({x:r,y:i},[a,o,s,c],e.scale,this._defaultThickness/2,t,.001);({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#j(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#M(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:`main_toolbar`});this._freeHighlightId=-1;this._freeHighlight=null;this._freeHighlightClipId=``}static async deserialize(e,t,n){let r=null;if(e instanceof pr){let{data:{quadPoints:t,rect:n,rotation:i,id:a,color:o,opacity:s,popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;r=e={annotationType:_.HIGHLIGHT,color:Array.from(o),opacity:s,quadPoints:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}else if(e instanceof fr){let{data:{inkLists:t,rect:n,rotation:i,id:a,color:o,borderStyle:{rawWidth:s},popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;r=e={annotationType:_.HIGHLIGHT,color:Array.from(o),thickness:s,inkLists:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}let{color:i,quadPoints:a,inkLists:o,outlines:s,opacity:c}=e,l=await super.deserialize(e,t,n);l.color=P.makeHexColor(...i);l.opacity=c||1;o&&(l.#g=e.thickness);l._initialData=r;e.comment&&l.setCommentData(e);let[u,d]=l.pageDimensions,[f,p]=l.pageTranslation;if(a){let e=l.#n=[];for(let t=0;t<a.length;t+=8)e.push({x:(a[t]-f)/u,y:1-(a[t+1]-p)/d,width:(a[t+2]-a[t])/u,height:(a[t+1]-a[t+5])/d});l.#v();l.#w();l.rotate(l.rotation)}else if(o||s){l.#d=!0;let e=(o||s.points)[0],n={x:e[0]-f,y:d-(e[1]-p)},r=new br(n,[0,0,u,d],1,l.#g/2,!0,.001);for(let t=0,i=e.length;t<i;t+=2){n.x=e[t]-f;n.y=d-(e[t+1]-p);r.add(n)}let{id:i,clipPathId:a}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:r.toSVGPath()}},!0,!0);l.#y({highlightOutlines:r.getOutlines(),highlightId:i,clipPathId:a});l.#w();l.rotate(l.parentRotation)}return l}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();let t=H._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),n=super.serialize(e);Object.assign(n,{color:t,opacity:this.opacity,thickness:this.#g,quadPoints:this.#k(),outlines:this.#A(n.rect)});this.addComment(n);if(this.annotationElementId&&!this.#N(n))return null;n.id=this.annotationElementId;return n}#N(e){let{color:t}=this._initialData;return this.hasEditedComment||e.color.some((e,n)=>e!==t[n])}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}static canCreateNewEmptyEditor(){return!1}}class Sr{#e=Object.create(null);updateProperty(e,t){this[e]=t;this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(let[t,n]of Object.entries(e))t.startsWith(`_`)||this.updateProperty(t,n)}updateSVGProperty(e,t){this.#e[e]=t}toSVGProperties(){let e=this.#e;this.#e=Object.create(null);return{root:e}}reset(){this.#e=Object.create(null)}updateAll(e=this){this.updateProperties(e)}clone(){D(`Not implemented`)}}class $ extends H{#e=null;#t;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#n=null;static#r=null;static#i=null;static _INNER_MARGIN=3;constructor(e){super(e);this.#t=e.mustBeCommitted||!1;this._addOutlines(e)}onUpdatedColor(){this._colorPicker?.update(this.color);super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(e){if(e.drawOutlines){this.#a(e);this.#c()}}#a({drawOutlines:e,drawId:t,drawingOptions:n}){this.#e=e;this._drawingOptions||=n;this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert[this.editorType]);if(t>=0){this._drawId=t;this.parent.drawLayer.finalizeDraw(t,e.defaultProperties)}else this._drawId=this.#o(e,this.parent);this.#d(e.box)}#o(e,t){let{id:n}=t.drawLayer.draw($._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n}static _mergeSVGProperties(e,t){let n=new Set(Object.keys(e));for(let[r,i]of Object.entries(t))n.has(r)?Object.assign(e[r],i):e[r]=i;return e}static getDefaultDrawingOptions(e){D(`Not implemented`)}static get typesMap(){D(`Not implemented`)}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,t){let n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,t);if(this._currentParent){$.#n.updateProperty(n,t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}updateParams(e,t){let n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,t)}static get defaultPropertiesToUpdate(){let e=[],t=this._defaultDrawingOptions;for(let[n,r]of this.typesMap)e.push([n,t[r]]);return e}get propertiesToUpdate(){let e=[],{_drawingOptions:t}=this;for(let[n,r]of this.constructor.typesMap)e.push([n,t[r]]);return e}_updateProperty(e,t,n){let r=this._drawingOptions,i=r[t],a=n=>{r.updateProperty(t,n);let i=this.#e.updateProperty(t,n);i&&this.#d(i);this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties());e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:a.bind(this,n),undo:a.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,t){let n=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),i=this._drawingOptions,a=i[n],o=i[r],s=(e,t)=>{i.updateProperty(n,e);i.updateProperty(r,t);this.#e.updateProperty(n,e);this.#e.updateProperty(r,t);this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties());this.onUpdatedColor();this.onUpdatedOpacity()};this.addCommands({cmd:s.bind(this,e,t),undo:s.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#e.getPathResizingSVGProperties(this.#u()),{bbox:this.#f()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#e.getPathResizedSVGProperties(this.#u()),{bbox:this.#f()}))}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#f()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#e.getPathTranslatedSVGProperties(this.#u(),this.parentDimensions),{bbox:this.#f()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit();this.disableEditMode();this.disableEditing()}disableEditing(){super.disableEditing();this.div.classList.toggle(`disabled`,!0)}enableEditing(){super.enableEditing();this.div.classList.toggle(`disabled`,!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this);this._isDraggable=!0;if(this.#t){this.#t=!1;this.commit();this.parent.setSelected(this);e&&this.isOnScreen&&this.div.focus()}}remove(){this.#s();super.remove()}rebuild(){if(this.parent){super.rebuild();if(this.div!==null){this.#c();this.#d(this.#e.box);this.isAttachedToDOM||this.parent.add(this)}}}setParent(e){let t=!1;if(this.parent&&!e){this._uiManager.removeShouldRescale(this);this.#s()}else if(e){this._uiManager.addShouldRescale(this);this.#c(e);t=!this.parent&&this.div?.classList.contains(`selectedEditor`)}super.setParent(e);t&&this.select()}#s(){if(this._drawId!==null&&this.parent){this.parent.drawLayer.remove(this._drawId);this._drawId=null;this._drawingOptions.reset()}}#c(e=this.parent){if(this._drawId===null||this.parent!==e){if(this._drawId===null){this._drawingOptions.updateAll();this._drawId=this.#o(this.#e,e)}else this.parent.drawLayer.updateParent(this._drawId,e.drawLayer)}}#l([e,t,n,r]){let{parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[t,1-e,a/i*n,i/a*r];case 180:return[1-e,1-t,n,r];case 270:return[1-t,e,a/i*n,i/a*r];default:return[e,t,n,r]}}#u(){let{x:e,y:t,width:n,height:r,parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[1-t,e,i/a*n,a/i*r];case 180:return[1-e,1-t,n,r];case 270:return[t,1-e,i/a*n,a/i*r];default:return[e,t,n,r]}}#d(e){[this.x,this.y,this.width,this.height]=this.#l(e);if(this.div){this.fixAndSetPosition();this.setDims()}this._onResized()}#f(){let{x:e,y:t,width:n,height:r,rotation:i,parentRotation:a,parentDimensions:[o,s]}=this;switch((4*i+a)/90){case 1:return[1-t-r,e,r,n];case 2:return[1-e-n,1-t-r,n,r];case 3:return[t,1-e-n,r,n];case 4:return[e,t-o/s*n,s/o*r,o/s*n];case 5:return[1-t,e,o/s*n,s/o*r];case 6:return[1-e-s/o*r,1-t,s/o*r,o/s*n];case 7:return[t-o/s*n,1-e-s/o*r,o/s*n,s/o*r];case 8:return[e-n,t-r,n,r];case 9:return[1-t,e-n,r,n];case 10:return[1-e,1-t,n,r];case 11:return[t-r,1-e,r,n];case 12:return[e-s/o*r,t,s/o*r,o/s*n];case 13:return[1-t-o/s*n,e-s/o*r,o/s*n,s/o*r];case 14:return[1-e,1-t-o/s*n,s/o*r,o/s*n];case 15:return[t,1-e,o/s*n,s/o*r];default:return[e,t,n,r]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties({bbox:this.#f()},this.#e.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#d(this.#e.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}let n=super.render();n.classList.add(`draw`);let r=document.createElement(`div`);n.append(r);r.setAttribute(`aria-hidden`,`true`);r.className=`internal`;this.setDims();this._uiManager.addShouldRescale(this);this.disableEditing();this._isCopy&&this._moveAfterPaste(e,t);return n}static createDrawerInstance(e,t,n,r,i){D(`Not implemented`)}static startDrawing(e,t,n,r){let{target:i,offsetX:a,offsetY:o,pointerId:s,pointerType:c}=r;if(V.isInitializedAndDifferentPointerType(c))return;let{viewport:{rotation:l}}=e,{width:u,height:d}=i.getBoundingClientRect(),f=$.#r=new AbortController,p=e.combinedSignal(f);V.setPointer(c,s);window.addEventListener(`pointerup`,e=>{V.isSamePointerIdOrRemove(e.pointerId)&&this._endDraw(e)},{signal:p});window.addEventListener(`pointercancel`,e=>{V.isSamePointerIdOrRemove(e.pointerId)&&this._currentParent.endDrawingSession()},{signal:p});window.addEventListener(`pointerdown`,e=>{if(V.isSamePointerType(e.pointerType)){V.initializeAndAddPointerId(e.pointerId);if($.#n.isCancellable()){$.#n.removeLastElement();$.#n.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)}}},{capture:!0,passive:!1,signal:p});window.addEventListener(`contextmenu`,L,{signal:p});i.addEventListener(`pointermove`,this._drawMove.bind(this),{signal:p});i.addEventListener(`touchmove`,e=>{V.isSameTimeStamp(e.timeStamp)&&R(e)},{signal:p});e.toggleDrawing();t._editorUndoBar?.hide();if($.#n)e.drawLayer.updateProperties(this._currentDrawId,$.#n.startNew(a,o,u,d,l));else{t.updateUIForDefaultProperties(this);$.#n=this.createDrawerInstance(a,o,u,d,l);$.#i=this.getDefaultDrawingOptions();this._currentParent=e;({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties($.#i.toSVGProperties(),$.#n.defaultSVGProperties),!0,!1))}}static _drawMove(e){V.isSameTimeStamp(e.timeStamp);if(!$.#n)return;let{offsetX:t,offsetY:n,pointerId:r}=e;if(V.isSamePointerId(r)){if(V.isUsingMultiplePointers())this._endDraw(e);else{this._currentParent.drawLayer.updateProperties(this._currentDrawId,$.#n.add(t,n));V.setTimeStamp(e.timeStamp);R(e)}}}static _cleanup(e){if(e){this._currentDrawId=-1;this._currentParent=null;$.#n=null;$.#i=null;V.clearTimeStamp()}if($.#r){$.#r.abort();$.#r=null;V.clearPointerIds()}}static _endDraw(e){let t=this._currentParent;if(t){t.toggleDrawing(!0);this._cleanup(!1);e?.target===t.div&&t.drawLayer.updateProperties(this._currentDrawId,$.#n.end(e.offsetX,e.offsetY));if(this.supportMultipleDrawings){let e=$.#n,n=this._currentDrawId,r=e.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(n,e.setLastElement(r))},undo:()=>{t.drawLayer.updateProperties(n,e.removeLastElement())},mustExec:!1,type:v.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){let t=this._currentParent;if(!t)return null;t.toggleDrawing(!0);t.cleanUndoStack(v.DRAW_STEP);if(!$.#n.isEmpty()){let{pageDimensions:[n,r],scale:i}=t,a=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:$.#n.getOutlines(n*i,r*i,i,this._INNER_MARGIN),drawingOptions:$.#i,mustBeCommitted:!e});this._cleanup(!0);return a}t.drawLayer.remove(this._currentDrawId);this._cleanup(!0);return null}createDrawingOptions(e){}static deserializeDraw(e,t,n,r,i,a){D(`Not implemented`)}static async deserialize(e,t,n){let{rawDims:{pageWidth:r,pageHeight:i,pageX:a,pageY:o}}=t.viewport,s=this.deserializeDraw(a,o,r,i,this._INNER_MARGIN,e),c=await super.deserialize(e,t,n);c.createDrawingOptions(e);c.#a({drawOutlines:s});c.#c();c.onScaleChanging();c.rotate();return c}serializeDraw(e){let[t,n]=this.pageTranslation,[r,i]=this.pageDimensions;return this.#e.serialize([t,n,r,i],e)}renderAnnotationElement(e){e.updateEdited({rect:this.getPDFRect()});return null}static canCreateNewEmptyEditor(){return!1}}class Cr{#e=new Float64Array(6);#t;#n;#r;#i;#a;#o=``;#s=0;#c=new wr;#l;#u;constructor(e,t,n,r,i,a){this.#l=n;this.#u=r;this.#r=i;this.#i=a;[e,t]=this.#d(e,t);let o=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#a=[e,t];this.#n=[{line:o,points:this.#a}];this.#e.set(o,0)}updateProperty(e,t){e===`stroke-width`&&(this.#i=t)}#d(e,t){return Z._normalizePoint(e,t,this.#l,this.#u,this.#r)}isEmpty(){return!this.#n||this.#n.length===0}isCancellable(){return this.#a.length<=10}add(e,t){[e,t]=this.#d(e,t);let[n,r,i,a]=this.#e.subarray(2,6),o=e-i,s=t-a;if(Math.hypot(this.#l*o,this.#u*s)<=2)return null;this.#a.push(e,t);if(isNaN(n)){this.#e.set([i,a,e,t],2);this.#t.push(NaN,NaN,NaN,NaN,e,t);return{path:{d:this.toSVGPath()}}}isNaN(this.#e[0])&&this.#t.splice(6,6);this.#e.set([n,r,i,a,e,t],0);this.#t.push(...Z.createBezierPoints(n,r,i,a,e,t));return{path:{d:this.toSVGPath()}}}end(e,t){return this.add(e,t)||(this.#a.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,n,r,i){this.#l=n;this.#u=r;this.#r=i;[e,t]=this.#d(e,t);let a=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#a=[e,t];let o=this.#n.at(-1);if(o){o.line=new Float32Array(o.line);o.points=new Float32Array(o.points)}this.#n.push({line:a,points:this.#a});this.#e.set(a,0);this.#s=0;this.toSVGPath();return null}getLastElement(){return this.#n.at(-1)}setLastElement(e){if(!this.#n)return this.#c.setLastElement(e);this.#n.push(e);this.#t=e.line;this.#a=e.points;this.#s=0;return{path:{d:this.toSVGPath()}}}removeLastElement(){if(!this.#n)return this.#c.removeLastElement();this.#n.pop();this.#o=``;for(let e=0,t=this.#n.length;e<t;e++){let{line:t,points:n}=this.#n[e];this.#t=t;this.#a=n;this.#s=0;this.toSVGPath()}return{path:{d:this.#o}}}toSVGPath(){let e=Z.svgRound(this.#t[4]),t=Z.svgRound(this.#t[5]);if(this.#a.length===2){this.#o=`${this.#o} M ${e} ${t} Z`;return this.#o}if(this.#a.length<=6){let n=this.#o.lastIndexOf(`M`);this.#o=`${this.#o.slice(0,n)} M ${e} ${t}`;this.#s=6}if(this.#a.length===4){let e=Z.svgRound(this.#t[10]),t=Z.svgRound(this.#t[11]);this.#o=`${this.#o} L ${e} ${t}`;this.#s=12;return this.#o}let n=[];if(this.#s===0){n.push(`M ${e} ${t}`);this.#s=6}for(let e=this.#s,t=this.#t.length;e<t;e+=6){let[t,r,i,a,o,s]=this.#t.slice(e,e+6).map(Z.svgRound);n.push(`C${t} ${r} ${i} ${a} ${o} ${s}`)}this.#o+=n.join(` `);this.#s=this.#t.length;return this.#o}getOutlines(e,t,n,r){let i=this.#n.at(-1);i.line=new Float32Array(i.line);i.points=new Float32Array(i.points);this.#c.build(this.#n,e,t,n,this.#r,this.#i,r);this.#e=null;this.#t=null;this.#n=null;this.#o=null;return this.#c}get defaultSVGProperties(){return{root:{viewBox:`0 0 10000 10000`},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class wr extends Z{#e;#t=0;#n;#r;#i;#a;#o;#s;#c;build(e,t,n,r,i,a,o){this.#i=t;this.#a=n;this.#o=r;this.#s=i;this.#c=a;this.#n=o??0;this.#r=e;this.#d()}get thickness(){return this.#c}setLastElement(e){this.#r.push(e);return{path:{d:this.toSVGPath()}}}removeLastElement(){this.#r.pop();return{path:{d:this.toSVGPath()}}}toSVGPath(){let e=[];for(let{line:t}of this.#r){e.push(`M${Z.svgRound(t[4])} ${Z.svgRound(t[5])}`);if(t.length!==6){if(t.length===12&&isNaN(t[6]))e.push(`L${Z.svgRound(t[10])} ${Z.svgRound(t[11])}`);else for(let n=6,r=t.length;n<r;n+=6){let[r,i,a,o,s,c]=t.subarray(n,n+6).map(Z.svgRound);e.push(`C${r} ${i} ${a} ${o} ${s} ${c}`)}}else e.push(`Z`)}return e.join(``)}serialize([e,t,n,r],i){let a=[],o=[],[s,c,l,u]=this.#u(),d,f,p,m,h,g,_,v,y;switch(this.#s){case 0:y=Z._rescale;d=e;f=t+r;p=n;m=-r;h=e+s*n;g=t+(1-c-u)*r;_=e+(s+l)*n;v=t+(1-c)*r;break;case 90:y=Z._rescaleAndSwap;d=e;f=t;p=n;m=r;h=e+c*n;g=t+s*r;_=e+(c+u)*n;v=t+(s+l)*r;break;case 180:y=Z._rescale;d=e+n;f=t;p=-n;m=r;h=e+(1-s-l)*n;g=t+c*r;_=e+(1-s)*n;v=t+(c+u)*r;break;case 270:y=Z._rescaleAndSwap;d=e+n;f=t+r;p=-n;m=-r;h=e+(1-c-u)*n;g=t+(1-s-l)*r;_=e+(1-c)*n;v=t+(1-s)*r}for(let{line:e,points:t}of this.#r){a.push(y(e,d,f,p,m,i?Array(e.length):null));o.push(y(t,d,f,p,m,i?Array(t.length):null))}return{lines:a,points:o,rect:[h,g,_,v]}}static deserialize(e,t,n,r,i,{paths:{lines:a,points:o},rotation:s,thickness:c}){let l=[],u,d,f,p,m;switch(s){case 0:m=Z._rescale;u=-e/n;d=t/r+1;f=1/n;p=-1/r;break;case 90:m=Z._rescaleAndSwap;u=-t/r;d=-e/n;f=1/r;p=1/n;break;case 180:m=Z._rescale;u=e/n+1;d=-t/r;f=-1/n;p=1/r;break;case 270:m=Z._rescaleAndSwap;u=t/r+1;d=e/n+1;f=-1/r;p=-1/n}if(!a){a=[];for(let e of o){let t=e.length;if(t===2){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(t===4){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}let n=new Float32Array(3*(t-2));a.push(n);let[r,i,o,s]=e.subarray(0,4);n.set([NaN,NaN,NaN,NaN,r,i],0);for(let a=4;a<t;a+=2){let t=e[a],c=e[a+1];n.set(Z.createBezierPoints(r,i,o,s,t,c),3*(a-2));[r,i,o,s]=[o,s,t,c]}}}for(let e=0,t=a.length;e<t;e++)l.push({line:m(a[e].map(e=>e??NaN),u,d,f,p),points:m(o[e].map(e=>e??NaN),u,d,f,p)});let h=new this.prototype.constructor;h.build(l,n,r,1,s,c,i);return h}#l(e=this.#c){let t=this.#n+e/2*this.#o;return this.#s%180==0?[t/this.#i,t/this.#a]:[t/this.#a,t/this.#i]}#u(){let[e,t,n,r]=this.#e,[i,a]=this.#l(0);return[e+i,t+a,n-2*i,r-2*a]}#d(){let e=this.#e=d.slice();for(let{line:t}of this.#r){if(t.length<=12){for(let n=4,r=t.length;n<r;n+=6)P.pointBoundingBox(t[n],t[n+1],e);continue}let n=t[4],r=t[5];for(let i=6,a=t.length;i<a;i+=6){let[a,o,s,c,l,u]=t.subarray(i,i+6);P.bezierBoundingBox(n,r,a,o,s,c,l,u,e);n=l;r=u}}let[t,n]=this.#l();e[0]=F(e[0]-t,0,1);e[1]=F(e[1]-n,0,1);e[2]=F(e[2]+t,0,1);e[3]=F(e[3]+n,0,1);e[2]-=e[0];e[3]-=e[1]}get box(){return this.#e}updateProperty(e,t){return e===`stroke-width`?this.#f(t):null}#f(e){let[t,n]=this.#l();this.#c=e;let[r,i]=this.#l(),[a,o]=[r-t,i-n],s=this.#e;s[0]-=a;s[1]-=o;s[2]+=2*a;s[3]+=2*o;return s}updateParentDimensions([e,t],n){let[r,i]=this.#l();this.#i=e;this.#a=t;this.#o=n;let[a,o]=this.#l(),s=a-r,c=o-i,l=this.#e;l[0]-=s;l[1]-=c;l[2]+=2*s;l[3]+=2*c;return l}updateRotation(e){this.#t=e;return{path:{transform:this.rotationTransform}}}get viewBox(){return this.#e.map(Z.svgRound).join(` `)}get defaultProperties(){let[e,t]=this.#e;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`}}}get rotationTransform(){let[,,e,t]=this.#e,n=0,r=0,i=0,a=0,o=0,s=0;switch(this.#t){case 90:r=t/e;i=-e/t;o=e;break;case 180:n=-1;a=-1;o=e;s=t;break;case 270:r=-t/e;i=e/t;s=t;break;default:return``}return`matrix(${n} ${r} ${i} ${a} ${Z.svgRound(o)} ${Z.svgRound(s)})`}getPathResizingSVGProperties([e,t,n,r]){let[i,a]=this.#l(),[o,s,c,l]=this.#e;if(Math.abs(c-i)<=Z.PRECISION||Math.abs(l-a)<=Z.PRECISION){let i=e+n/2-(o+c/2),a=t+r/2-(s+l/2);return{path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:`${this.rotationTransform} translate(${i} ${a})`}}}let u=(n-2*i)/(c-2*i),d=(r-2*a)/(l-2*a),f=c/n,p=l/r;return{path:{"transform-origin":`${Z.svgRound(o)} ${Z.svgRound(s)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${Z.svgRound(i)} ${Z.svgRound(a)}) scale(${u} ${d}) translate(${Z.svgRound(-i)} ${Z.svgRound(-a)})`}}}getPathResizedSVGProperties([e,t,n,r]){let[i,a]=this.#l(),o=this.#e,[s,c,l,u]=o;o[0]=e;o[1]=t;o[2]=n;o[3]=r;if(Math.abs(l-i)<=Z.PRECISION||Math.abs(u-a)<=Z.PRECISION){let i=e+n/2-(s+l/2),a=t+r/2-(c+u/2);for(let{line:e,points:t}of this.#r){Z._translate(e,i,a,e);Z._translate(t,i,a,t)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let d=(n-2*i)/(l-2*i),f=(r-2*a)/(u-2*a),p=-d*(s+i)+e+i,m=-f*(c+a)+t+a;if(d!==1||f!==1||p!==0||m!==0)for(let{line:e,points:t}of this.#r){Z._rescale(e,p,m,d,f,e);Z._rescale(t,p,m,d,f,t)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],n){let[r,i]=n,a=this.#e,o=e-a[0],s=t-a[1];if(this.#i===r&&this.#a===i)for(let{line:e,points:t}of this.#r){Z._translate(e,o,s,e);Z._translate(t,o,s,t)}else{let e=this.#i/r,t=this.#a/i;this.#i=r;this.#a=i;for(let{line:n,points:r}of this.#r){Z._rescale(n,o,s,e,t,n);Z._rescale(r,o,s,e,t,r)}a[2]*=e;a[3]*=t}a[0]=e;a[1]=t;return{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`}}}get defaultSVGProperties(){let e=this.#e;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Z.svgRound(e[0])} ${Z.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}class Tr extends Sr{constructor(e){super();this._viewParameters=e;super.updateProperties({fill:`none`,stroke:H._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-miterlimit":10})}updateSVGProperty(e,t){if(e===`stroke-width`){t??=this[`stroke-width`];t*=this._viewParameters.realScale}super.updateSVGProperty(e,t)}clone(){let e=new Tr(this._viewParameters);e.updateAll(this);return e}}class Er extends ${static _type=`ink`;static _editorType=_.INK;static _defaultDrawingOptions=null;constructor(e){super({...e,name:`inkEditor`});this._willKeepAspectRatio=!0;this.defaultL10nId=`pdfjs-editor-ink-editor`}static initialize(e,t){H.initialize(e,t);this._defaultDrawingOptions=new Tr(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!0}static get typesMap(){return j(this,`typesMap`,new Map([[v.INK_THICKNESS,`stroke-width`],[v.INK_COLOR,`stroke`],[v.INK_OPACITY,`stroke-opacity`]]))}static createDrawerInstance(e,t,n,r,i){return new Cr(e,t,n,r,i,this._defaultDrawingOptions[`stroke-width`])}static deserializeDraw(e,t,n,r,i,a){return wr.deserialize(e,t,n,r,i,a)}static async deserialize(e,t,n){let r=null;if(e instanceof fr){let{data:{inkLists:t,rect:n,rotation:i,id:a,color:o,opacity:s,borderStyle:{rawWidth:c},popupRef:l,richText:u,contentsObj:d,creationDate:f,modificationDate:p},parent:{page:{pageNumber:m}}}=e;r=e={annotationType:_.INK,color:Array.from(o),thickness:c,opacity:s,paths:{points:t},boxes:null,pageIndex:m-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:l,richText:u,comment:d?.str||null,creationDate:f,modificationDate:p}}let i=await super.deserialize(e,t,n);i._initialData=r;e.comment&&i.setCommentData(e);return i}get toolbarButtons(){this._colorPicker||=new er(this);return[[`colorPicker`,this._colorPicker]]}get colorType(){return v.INK_COLOR}get colorAndOpacityType(){return v.INK_COLOR_AND_OPACITY}get opacityType(){return v.INK_OPACITY}updateParams(e,t){e===v.INK_COLOR_AND_OPACITY?this._updateColorAndOpacity(t.color,t.opacity):super.updateParams(e,t)}static updateDefaultParams(e,t){if(e!==v.INK_COLOR_AND_OPACITY)super.updateDefaultParams(e,t);else{super.updateDefaultParams(v.INK_COLOR,t.color);super.updateDefaultParams(v.INK_OPACITY,t.opacity)}}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions[`stroke-opacity`]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:e,_drawingOptions:t,parent:n}=this;t.updateSVGProperty(`stroke-width`);n.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){let e=this._currentParent;if(e){super.onScaleChangingWhenDrawing();this._defaultDrawingOptions.updateSVGProperty(`stroke-width`);e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}createDrawingOptions({color:e,thickness:t,opacity:n}){this._drawingOptions=Er.getDefaultDrawingOptions({stroke:P.makeHexColor(...e),"stroke-width":t,"stroke-opacity":n})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":i,"stroke-width":a}}=this,o=Object.assign(super.serialize(e),{color:H._colorManager.convert(r),opacity:i,thickness:a,paths:{lines:t,points:n}});this.addComment(o);if(e){o.isCopy=!0;return o}if(this.annotationElementId&&!this.#e(o))return null;o.id=this.annotationElementId;return o}#e(e){let{color:t,thickness:n,opacity:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((e,n)=>e!==t[n])||e.thickness!==n||e.opacity!==r||e.pageIndex!==i}renderAnnotationElement(e){if(this.deleted){e.hide();return null}let{points:t,rect:n}=this.serializeDraw(!1);e.updateEdited({rect:n,thickness:this._drawingOptions[`stroke-width`],points:t,popup:this.comment});return null}}class Dr extends wr{toSVGPath(){let e=super.toSVGPath();e.endsWith(`Z`)||(e+=`Z`);return e}}class Or{static#e={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#t(e,t,n,r){r-=t;return(n-=e)===0?r>0?0:4:n===1?r+6:2-r}static#n=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#r(e,t,n,r,i,a,o){let s=this.#t(n,r,i,a);for(let i=0;i<8;i++){let a=(-i+s-o+16)%8;if(e[(n+this.#n[2*a])*t+(r+this.#n[2*a+1])]!==0)return a}return-1}static#i(e,t,n,r,i,a,o){let s=this.#t(n,r,i,a);for(let i=0;i<8;i++){let a=(i+s+o+16)%8;if(e[(n+this.#n[2*a])*t+(r+this.#n[2*a+1])]!==0)return a}return-1}static#a(e,t,n,r){let i=e.length,a=new Int32Array(i);for(let t=0;t<i;t++)a[t]=+(e[t]<=r);for(let e=1;e<n-1;e++)a[e*t]=a[e*t+t-1]=0;for(let e=0;e<t;e++)a[e]=a[t*n-1-e]=0;let o,s=1,c=[];for(let e=1;e<n-1;e++){o=1;for(let n=1;n<t-1;n++){let r=e*t+n,i=a[r];if(i===0)continue;let l=e,u=n;if(i===1&&a[r-1]===0){s+=1;--u}else{if(!(i>=1&&a[r+1]===0)){i!==1&&(o=Math.abs(i));continue}s+=1;u+=1;i>1&&(o=i)}let d=[n,e],f=u===n+1,p={isHole:f,points:d,id:s,parent:0};c.push(p);let m;for(let e of c)if(e.id===o){m=e;break}p.parent=m?m.isHole?f?m.parent:o:f?o:m.parent:f?o:0;let h=this.#r(a,t,e,n,l,u,0);if(h===-1){a[r]=-s;a[r]!==1&&(o=Math.abs(a[r]));continue}let g=this.#n[2*h],_=this.#n[2*h+1],v=e+g,y=n+_;l=v;u=y;let b=e,x=n;for(;;){let i=this.#i(a,t,b,x,l,u,1);g=this.#n[2*i];_=this.#n[2*i+1];let c=b+g,f=x+_;d.push(f,c);let p=b*t+x;a[p+1]===0?a[p]=-s:a[p]===1&&(a[p]=s);if(c===e&&f===n&&b===v&&x===y){a[r]!==1&&(o=Math.abs(a[r]));break}l=b;u=x;b=c;x=f}}}return c}static#o(e,t,n,r){if(n-t<=4){for(let i=t;i<n-2;i+=2)r.push(e[i],e[i+1]);return}let i=e[t],a=e[t+1],o=e[n-4]-i,s=e[n-3]-a,c=Math.hypot(o,s),l=o/c,u=s/c,d=l*a-u*i,f=s/o,p=1/c,m=Math.atan(f),h=Math.cos(m),g=Math.sin(m),_=p*(Math.abs(h)+Math.abs(g)),v=p*(1-_+_**2),y=Math.max(Math.atan(Math.abs(g+h)*v),Math.atan(Math.abs(g-h)*v)),b=0,x=t;for(let r=t+2;r<n-2;r+=2){let t=Math.abs(d-l*e[r+1]+u*e[r]);if(t>b){x=r;b=t}}if(b>(c*y)**2){this.#o(e,t,x+2,r);this.#o(e,x,n,r)}else r.push(i,a)}static#s(e){let t=[],n=e.length;this.#o(e,0,n,t);t.push(e[n-2],e[n-1]);return t.length<=4?null:t}static#c(e,t,n,r,i,a){let o=new Float32Array(a**2),s=-2*r**2,c=a>>1;for(let e=0;e<a;e++){let t=(e-c)**2;for(let n=0;n<a;n++)o[e*a+n]=Math.exp((t+(n-c)**2)/s)}let l=new Float32Array(256),u=-2*i**2;for(let e=0;e<256;e++)l[e]=Math.exp(e**2/u);let d=e.length,f=new Uint8Array(d),p=new Uint32Array(256);for(let r=0;r<n;r++)for(let i=0;i<t;i++){let s=r*t+i,u=e[s],d=0,m=0;for(let s=0;s<a;s++){let f=r+s-c;if(!(f<0||f>=n))for(let n=0;n<a;n++){let r=i+n-c;if(r<0||r>=t)continue;let p=e[f*t+r],h=o[s*a+n]*l[Math.abs(p-u)];d+=p*h;m+=h}}p[f[s]=Math.round(d/m)]++}return[f,p]}static#l(e){let t=new Uint32Array(256);for(let n of e)t[n]++;return t}static#u(e){let t=e.length,n=new Uint8ClampedArray(t>>2),r=-1/0,i=1/0;for(let t=0,a=n.length;t<a;t++){let a=n[t]=e[t<<2];r=Math.max(r,a);i=Math.min(i,a)}let a=255/(r-i);for(let e=0,t=n.length;e<t;e++)n[e]=(n[e]-i)*a;return n}static#d(e){let t,n=-1/0,r=-1/0,i=e.findIndex(e=>e!==0),a=i,o=i;for(t=i;t<256;t++){let i=e[t];if(i>n){if(t-a>r){r=t-a;o=t-1}n=i;a=t}}for(t=o-1;t>=0&&!(e[t]>e[t+1]);t--);return t}static#f(e){let t=e,{width:n,height:r}=e,{maxDim:i}=this.#e,a=n,o=r;if(n>i||r>i){let s=n,c=r,l=Math.log2(Math.max(n,r)/i),u=Math.floor(l);l=l===u?u-1:u;for(let n=0;n<l;n++){a=Math.ceil(s/2);o=Math.ceil(c/2);let n=new OffscreenCanvas(a,o);n.getContext(`2d`).drawImage(e,0,0,s,c,0,0,a,o);s=a;c=o;e!==t&&e.close();e=n.transferToImageBitmap()}let d=Math.min(i/a,i/o);a=Math.round(a*d);o=Math.round(o*d)}let s=new OffscreenCanvas(a,o).getContext(`2d`,{willReadFrequently:!0});s.fillStyle=`white`;s.fillRect(0,0,a,o);s.filter=`grayscale(1)`;s.drawImage(e,0,0,e.width,e.height,0,0,a,o);let c=s.getImageData(0,0,a,o).data;return[this.#u(c),a,o]}static extractContoursFromText(e,{fontFamily:t,fontStyle:n,fontWeight:r},i,a,o,s){let c=new OffscreenCanvas(1,1),l=c.getContext(`2d`,{alpha:!1}),u=l.font=`${n} ${r} 200px ${t}`,{actualBoundingBoxLeft:d,actualBoundingBoxRight:f,actualBoundingBoxAscent:p,actualBoundingBoxDescent:m,fontBoundingBoxAscent:h,fontBoundingBoxDescent:g,width:_}=l.measureText(e),v=1.5,y=Math.ceil(Math.max(Math.abs(d)+Math.abs(f)||0,_)*v),b=Math.ceil(Math.max(Math.abs(p)+Math.abs(m)||200,Math.abs(h)+Math.abs(g)||200)*v);c=new OffscreenCanvas(y,b);l=c.getContext(`2d`,{alpha:!0,willReadFrequently:!0});l.font=u;l.filter=`grayscale(1)`;l.fillStyle=`white`;l.fillRect(0,0,y,b);l.fillStyle=`black`;l.fillText(e,.5*y/2,1.5*b/2);let x=this.#u(l.getImageData(0,0,y,b).data),S=this.#l(x),C=this.#d(S),w=this.#a(x,y,b,C);return this.processDrawnLines({lines:{curves:w,width:y,height:b},pageWidth:i,pageHeight:a,rotation:o,innerMargin:s,mustSmooth:!0,areContours:!0})}static process(e,t,n,r,i){let[a,o,s]=this.#f(e),[c,l]=this.#c(a,o,s,Math.hypot(o,s)*this.#e.sigmaSFactor,this.#e.sigmaR,this.#e.kernelSize),u=this.#d(l),d=this.#a(c,o,s,u);return this.processDrawnLines({lines:{curves:d,width:o,height:s},pageWidth:t,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:e,pageWidth:t,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:a,areContours:o}){r%180!=0&&([t,n]=[n,t]);let{curves:s,width:c,height:l}=e,u=e.thickness??0,d=[],f=Math.min(t/c,n/l),p=f/t,m=f/n,h=[];for(let{points:e}of s){let t=a?this.#s(e):e;if(!t)continue;h.push(t);let n=t.length,r=new Float32Array(n),i=new Float32Array(3*(n===2?2:n-2));d.push({line:i,points:r});if(n===2){r[0]=t[0]*p;r[1]=t[1]*m;i.set([NaN,NaN,NaN,NaN,r[0],r[1]],0);continue}let[o,s,c,l]=t;o*=p;s*=m;c*=p;l*=m;r.set([o,s,c,l],0);i.set([NaN,NaN,NaN,NaN,o,s],0);for(let e=4;e<n;e+=2){let n=r[e]=t[e]*p,a=r[e+1]=t[e+1]*m;i.set(Z.createBezierPoints(o,s,c,l,n,a),3*(e-2));[o,s,c,l]=[c,l,n,a]}}if(d.length===0)return null;let g=o?new Dr:new wr;g.build(d,t,n,1,r,o?0:u,i);return{outline:g,newCurves:h,areContours:o,thickness:u,width:c,height:l}}static async compressSignature({outlines:e,areContours:t,thickness:n,width:r,height:i}){let a,o=1/0,s=-1/0,c=0;for(let t of e){c+=t.length;for(let e=2,n=t.length;e<n;e++){let n=t[e]-t[e-2];o=Math.min(o,n);s=Math.max(s,n)}}a=o>=-128&&s<=127?Int8Array:o>=-32768&&s<=32767?Int16Array:Int32Array;let l=e.length,u=8+3*l,d=new Uint32Array(u),f=0;d[f++]=u*Uint32Array.BYTES_PER_ELEMENT+(c-2*l)*a.BYTES_PER_ELEMENT;d[f++]=0;d[f++]=r;d[f++]=i;d[f++]=+!t;d[f++]=Math.max(0,Math.floor(n??0));d[f++]=l;d[f++]=a.BYTES_PER_ELEMENT;for(let t of e){d[f++]=t.length-2;d[f++]=t[0];d[f++]=t[1]}let p=new CompressionStream(`deflate-raw`),m=p.writable.getWriter();await m.ready;m.write(d);let h=a.prototype.constructor;for(let t of e){let e=new h(t.length-2);for(let n=2,r=t.length;n<r;n++)e[n-2]=t[n]-t[n-2];m.write(e)}m.close();return(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(e){try{let t=Uint8Array.fromBase64(e),{readable:n,writable:r}=new DecompressionStream(`deflate-raw`),i=r.getWriter();await i.ready;i.write(t).then(async()=>{await i.ready;await i.close()}).catch(()=>{});let a=null,o=0;for await(let e of n){a||=new Uint8Array(new Uint32Array(e.buffer,0,4)[0]);a.set(e,o);o+=e.length}let s=new Uint32Array(a.buffer,0,a.length>>2),c=s[1];if(c!==0)throw Error(`Invalid version: ${c}`);let l=s[2],u=s[3],d=s[4]===0,f=s[5],p=s[6],m=s[7],h=[],g=(8+3*p)*Uint32Array.BYTES_PER_ELEMENT,_;switch(m){case Int8Array.BYTES_PER_ELEMENT:_=new Int8Array(a.buffer,g);break;case Int16Array.BYTES_PER_ELEMENT:_=new Int16Array(a.buffer,g);break;case Int32Array.BYTES_PER_ELEMENT:_=new Int32Array(a.buffer,g)}o=0;for(let e=0;e<p;e++){let t=s[3*e+8],n=new Float32Array(t+2);h.push(n);for(let t=0;t<2;t++)n[t]=s[3*e+8+t+1];for(let e=0;e<t;e++)n[e+2]=n[e]+_[o++]}return{areContours:d,thickness:f,outlines:h,width:l,height:u}}catch(e){E(`decompressSignature: ${e}`);return null}}}class kr extends Sr{constructor(){super();super.updateProperties({fill:H._defaultLineColor,"stroke-width":0})}clone(){let e=new kr;e.updateAll(this);return e}}class Ar extends Tr{constructor(e){super(e);super.updateProperties({stroke:H._defaultLineColor,"stroke-width":1})}clone(){let e=new Ar(this._viewParameters);e.updateAll(this);return e}}class jr extends ${#e=!1;#t=null;#n=null;#r=null;static _type=`signature`;static _editorType=_.SIGNATURE;static _defaultDrawingOptions=null;constructor(e){super({...e,mustBeCommitted:!0,name:`signatureEditor`});this._willKeepAspectRatio=!0;this.#n=e.signatureData||null;this.#t=null;this.defaultL10nId=`pdfjs-editor-signature-editor1`}static initialize(e,t){H.initialize(e,t);this._defaultDrawingOptions=new kr;this._defaultDrawnSignatureOptions=new Ar(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!1}static get typesMap(){return j(this,`typesMap`,new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:`signature`,hasDescription:!!this.#t}}static computeTelemetryFinalData(e){let t=e.get(`hasDescription`);return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,t,{_isCopy:n}=this;if(n){this._isCopy=!1;e=this.x;t=this.y}super.render();if(this._drawId===null){if(this.#n){let{lines:e,mustSmooth:t,areContours:n,description:r,uuid:i,heightInPage:a}=this.#n,{rawDims:{pageWidth:o,pageHeight:s},rotation:c}=this.parent.viewport,l=Or.processDrawnLines({lines:e,pageWidth:o,pageHeight:s,rotation:c,innerMargin:jr._INNER_MARGIN,mustSmooth:t,areContours:n});this.addSignature(l,a,r,i)}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.#t||``}));if(n){this._isCopy=!0;this._moveAfterPaste(e,t)}return this.div}setUuid(e){this.#r=e;this.addEditToolbar()}getUuid(){return this.#r}get description(){return this.#t}set description(e){this.#t=e;if(this.div){this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:e}));super.addEditToolbar().then(t=>{t?.updateEditSignatureButton(e)})}}getSignaturePreview(){let{newCurves:e,areContours:t,thickness:n,width:r,height:i}=this.#n,a=Math.max(r,i);return{areContours:t,outline:Or.processDrawnLines({lines:{curves:e.map(e=>({points:e})),thickness:n,width:r,height:i},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:t}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[[`editSignature`,this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,t,n,r){let{x:i,y:a}=this,{outline:o}=this.#n=e;this.#e=o instanceof Dr;this.description=n;let s;if(this.#e)s=jr.getDefaultDrawingOptions();else{s=jr._defaultDrawnSignatureOptions.clone();s.updateProperties({"stroke-width":o.thickness})}this._addOutlines({drawOutlines:o,drawingOptions:s});let[,c]=this.pageDimensions,l=t/c;l=l>=1?.5:l;this.width*=l/this.height;if(this.width>=1){l*=.9/this.width;this.width=.9}this.height=l;this.setDims();this.x=i;this.y=a;this.center();this._onResized();this.onScaleChanging();this.rotate();this._uiManager.addToAnnotationStorage(this);this.setUuid(r);this._reportTelemetry({action:`pdfjs.signature.inserted`,data:{hasBeenSaved:!!r,hasDescription:!!n}});this.div.hidden=!1}getFromImage(e){let{rawDims:{pageWidth:t,pageHeight:n},rotation:r}=this.parent.viewport;return Or.process(e,t,n,r,jr._INNER_MARGIN)}getFromText(e,t){let{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return Or.extractContoursFromText(e,t,n,r,i,jr._INNER_MARGIN)}getDrawnSignature(e){let{rawDims:{pageWidth:t,pageHeight:n},rotation:r}=this.parent.viewport;return Or.processDrawnLines({lines:e,pageWidth:t,pageHeight:n,rotation:r,innerMargin:jr._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:t}){if(e)this._drawingOptions=jr.getDefaultDrawingOptions();else{this._drawingOptions=jr._defaultDrawnSignatureOptions.clone();this._drawingOptions.updateProperties({"stroke-width":t})}}serialize(e=!1){if(this.isEmpty())return null;let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,i=Object.assign(super.serialize(e),{isSignature:!0,areContours:this.#e,color:[0,0,0],thickness:this.#e?0:r});this.addComment(i);if(e){i.paths={lines:t,points:n};i.uuid=this.#r;i.isCopy=!0}else i.lines=t;this.#t&&(i.accessibilityData={type:`Figure`,alt:this.#t});return i}static deserializeDraw(e,t,n,r,i,a){return a.areContours?Dr.deserialize(e,t,n,r,i,a):wr.deserialize(e,t,n,r,i,a)}static async deserialize(e,t,n){let r=await super.deserialize(e,t,n);r.#e=e.areContours;r.description=e.accessibilityData?.alt||``;r.#r=e.uuid;return r}}class Mr extends H{#e=null;#t=null;#n=null;#r=null;#i=null;#a=``;#o=null;#s=!1;#c=null;#l=!1;#u=!1;static _type=`stamp`;static _editorType=_.STAMP;constructor(e){super({...e,name:`stampEditor`});this.#r=e.bitmapUrl;this.#i=e.bitmapFile;this.defaultL10nId=`pdfjs-editor-stamp-editor`}static initialize(e,t){H.initialize(e,t)}static isHandlingMimeForPasting(e){return Ee.includes(e)}static paste(e,t){t.pasteEditor({mode:_.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1);super.altTextFinish()}get telemetryFinalData(){return{type:`stamp`,hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){let t=e.get(`hasAltText`);return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}#d(e,t=!1){if(e){this.#e=e.bitmap;if(!t){this.#t=e.id;this.#l=e.isSvg}e.file&&(this.#a=e.file.name);this.#m()}else this.remove()}#f(){this.#n=null;this._uiManager.enableWaiting(!1);if(this.#o){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e)this.addEditToolbar().then(()=>{this._editToolbar.hide();this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e){this._reportTelemetry({action:`pdfjs.image.image_added`,data:{alt_text_modal:!1,alt_text_type:`empty`}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}}async mlGuessAltText(e=null,t=!0){if(this.hasAltTextData())return null;let{mlManager:n}=this._uiManager;if(!n)throw Error(`No ML.`);if(!await n.isEnabledFor(`altText`))throw Error(`ML isn't enabled for alt text.`);let{data:r,width:i,height:a}=e||this.copyCanvas(null,null,!0).imageData,o=await n.guess({name:`altText`,request:{data:r,width:i,height:a,channels:r.length/(i*a)}});if(!o)throw Error(`No response from the AI service.`);if(o.error)throw Error(`Error from the AI service.`);if(o.cancel)return null;if(!o.output)throw Error(`No valid response from the AI service.`);let s=o.output;await this.setGuessedAltText(s);t&&!this.hasAltTextData()&&(this.altTextData={alt:s,decorative:!1});return s}#p(){if(this.#t){this._uiManager.enableWaiting(!0);this._uiManager.imageManager.getFromId(this.#t).then(e=>this.#d(e,!0)).finally(()=>this.#f());return}if(this.#r){let e=this.#r;this.#r=null;this._uiManager.enableWaiting(!0);this.#n=this._uiManager.imageManager.getFromUrl(e).then(e=>this.#d(e)).finally(()=>this.#f());return}if(this.#i){let e=this.#i;this.#i=null;this._uiManager.enableWaiting(!0);this.#n=this._uiManager.imageManager.getFromFile(e).then(e=>this.#d(e)).finally(()=>this.#f());return}let e=document.createElement(`input`);e.type=`file`;e.accept=Ee.join(`,`);let t=this._uiManager._signal;this.#n=new Promise(n=>{e.addEventListener(`change`,async()=>{if(e.files&&e.files.length!==0){this._uiManager.enableWaiting(!0);let t=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:`pdfjs.image.image_selected`,data:{alt_text_modal:this._uiManager.useNewAltTextFlow}});this.#d(t)}else this.remove();n()},{signal:t});e.addEventListener(`cancel`,()=>{this.remove();n()},{signal:t})}).finally(()=>this.#f());e.click()}remove(){if(this.#t){this.#e=null;this._uiManager.imageManager.deleteId(this.#t);this.#o?.remove();this.#o=null;if(this.#c){clearTimeout(this.#c);this.#c=null}}super.remove()}rebuild(){if(this.parent){super.rebuild();if(this.div!==null){this.#t&&this.#o===null&&this.#p();this.isAttachedToDOM||this.parent.add(this)}}else this.#t&&this.#p()}onceAdded(e){this._isDraggable=!0;e&&this.div.focus()}isEmpty(){return!(this.#n||this.#e||this.#r||this.#i||this.#t||this.#s)}get toolbarButtons(){return[[`altText`,this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}super.render();this.div.hidden=!0;this.createAltText();this.#s||(this.#e?this.#m():this.#p());this._isCopy&&this._moveAfterPaste(e,t);this._uiManager.addShouldRescale(this);return this.div}setCanvas(e,t){let{id:n,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,t);t.remove();if(n&&this._uiManager.imageManager.isValidId(n)){this.#t=n;r&&(this.#e=r);this.#s=!1;this.#m()}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#c!==null&&clearTimeout(this.#c);this.#c=setTimeout(()=>{this.#c=null;this.#g()},200)}#m(){let{div:e}=this,{width:t,height:n}=this.#e,[r,i]=this.pageDimensions,a=.75;if(this.width){t=this.width*r;n=this.height*i}else if(t>a*r||n>a*i){let e=Math.min(a*r/t,a*i/n);t*=e;n*=e}this._uiManager.enableWaiting(!1);let o=this.#o=document.createElement(`canvas`);o.setAttribute(`role`,`img`);this.addContainer(o);this.width=t/r;this.height=n/i;this.setDims();this._initialOptions?.isCentered?this.center():this.fixAndSetPosition();this._initialOptions=null;this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1);this.#g();if(!this.#u){this.parent.addUndoableEditor(this);this.#u=!0}this._reportTelemetry({action:`inserted_image`});this.#a&&this.div.setAttribute(`aria-description`,this.#a);this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert.stamp)}copyCanvas(e,t,n=!1){e||=224;let{width:r,height:i}=this.#e,a=new Te,o=this.#e,s=r,c=i,l=null;if(t){if(r>t||i>t){let e=Math.min(t/r,t/i);s=Math.floor(r*e);c=Math.floor(i*e)}l=document.createElement(`canvas`);let e=l.width=Math.ceil(s*a.sx),n=l.height=Math.ceil(c*a.sy);this.#l||(o=this.#h(e,n));let u=l.getContext(`2d`);u.filter=this._uiManager.hcmFilter;let d=`white`,f=`#cfcfd8`;if(this._uiManager.hcmFilter!==`none`)f=`black`;else if(De.isDarkMode){d=`#8f8f9d`;f=`#42414d`}let p=15*a.sx,m=15*a.sy,h=new OffscreenCanvas(2*p,2*m),g=h.getContext(`2d`);g.fillStyle=d;g.fillRect(0,0,2*p,2*m);g.fillStyle=f;g.fillRect(0,0,p,m);g.fillRect(p,m,p,m);u.fillStyle=u.createPattern(h,`repeat`);u.fillRect(0,0,e,n);u.drawImage(o,0,0,o.width,o.height,0,0,e,n)}let u=null;if(n){let t,n;if(a.symmetric&&o.width<e&&o.height<e){t=o.width;n=o.height}else{o=this.#e;if(r>e||i>e){let a=Math.min(e/r,e/i);t=Math.floor(r*a);n=Math.floor(i*a);this.#l||(o=this.#h(t,n))}}let s=new OffscreenCanvas(t,n).getContext(`2d`,{willReadFrequently:!0});s.drawImage(o,0,0,o.width,o.height,0,0,t,n);u={width:t,height:n,data:s.getImageData(0,0,t,n).data}}return{canvas:l,width:s,height:c,imageData:u}}#h(e,t){let{width:n,height:r}=this.#e,i=n,a=r,o=this.#e;for(;i>2*e||a>2*t;){let n=i,r=a;i>2*e&&(i=Math.ceil(i/2));a>2*t&&(a=Math.ceil(a/2));let s=new OffscreenCanvas(i,a);s.getContext(`2d`).drawImage(o,0,0,n,r,0,0,i,a);o=s.transferToImageBitmap()}return o}#g(){let[e,t]=this.parentDimensions,{width:n,height:r}=this,i=new Te,a=Math.ceil(n*e*i.sx),o=Math.ceil(r*t*i.sy),s=this.#o;if(!s||s.width===a&&s.height===o)return;s.width=a;s.height=o;let c=this.#l?this.#e:this.#h(a,o),l=s.getContext(`2d`);l.filter=this._uiManager.hcmFilter;l.drawImage(c,0,0,c.width,c.height,0,0,a,o)}#_(e){if(e){if(this.#l){let e=this._uiManager.imageManager.getSvgUrl(this.#t);if(e)return e}let e=document.createElement(`canvas`);({width:e.width,height:e.height}=this.#e);e.getContext(`2d`).drawImage(this.#e,0,0);return e.toDataURL()}if(this.#l){let[e,t]=this.pageDimensions,n=Math.round(this.width*e*pe.PDF_TO_CSS_UNITS),r=Math.round(this.height*t*pe.PDF_TO_CSS_UNITS),i=new OffscreenCanvas(n,r);i.getContext(`2d`).drawImage(this.#e,0,0,this.#e.width,this.#e.height,0,0,n,r);return i.transferToImageBitmap()}return structuredClone(this.#e)}static async deserialize(e,t,n){let r=null,i=!1;if(e instanceof mr){let{data:{rect:a,rotation:o,id:s,structParent:c,popupRef:l,richText:u,contentsObj:d,creationDate:f,modificationDate:p},container:m,parent:{page:{pageNumber:g}},canvas:v}=e,y,b;if(v){delete e.canvas;({id:y,bitmap:b}=n.imageManager.getFromCanvas(m.id,v));v.remove()}else{i=!0;e._hasNoCanvas=!0}let x=(await t._structTree.getAriaAttributes(`${h}${s}`))?.get(`aria-label`)||``;r=e={annotationType:_.STAMP,bitmapId:y,bitmap:b,pageIndex:g-1,rect:a.slice(0),rotation:o,annotationElementId:s,id:s,deleted:!1,accessibilityData:{decorative:!1,altText:x},isSvg:!1,structParent:c,popupRef:l,richText:u,comment:d?.str||null,creationDate:f,modificationDate:p}}let a=await super.deserialize(e,t,n),{rect:o,bitmap:s,bitmapUrl:c,bitmapId:l,isSvg:u,accessibilityData:d}=e;if(i){n.addMissingCanvas(e.id,a);a.#s=!0}else if(l&&n.imageManager.isValidId(l)){a.#t=l;s&&(a.#e=s)}else a.#r=c;a.#l=u;let[f,p]=a.pageDimensions;a.width=(o[2]-o[0])/f;a.height=(o[3]-o[1])/p;d&&(a.altTextData=d);a._initialData=r;e.comment&&a.setCommentData(e);a.#u=!!r;return a}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let n=Object.assign(super.serialize(e),{bitmapId:this.#t,isSvg:this.#l});this.addComment(n);if(e){n.bitmapUrl=this.#_(!0);n.accessibilityData=this.serializeAltText(!0);n.isCopy=!0;return n}let{decorative:r,altText:i}=this.serializeAltText(!1);!r&&i&&(n.accessibilityData={type:`Figure`,alt:i});if(this.annotationElementId){let e=this.#v(n);if(e.isSame)return null;e.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1;n.id=this.annotationElementId;delete n.bitmapId;return n}if(t===null)return n;t.stamps||=new Map;let a=this.#l?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(t.stamps.has(this.#t)){if(this.#l){let e=t.stamps.get(this.#t);if(a>e.area){e.area=a;e.serialized.bitmap.close();e.serialized.bitmap=this.#_(!1)}}}else{t.stamps.set(this.#t,{area:a,serialized:n});n.bitmap=this.#_(!1)}return n}#v(e){let{pageIndex:t,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===t,i=(e.accessibilityData?.alt||``)===n;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&i,isSameAltText:i}}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}}class Nr{#e;#t=!1;#n=null;#r=null;#i=null;#a=new Map;#o=!1;#s=!1;#c=!1;#l=null;#u=null;#d=null;#f=null;#p=null;#m=-1;#h;static _initialized=!1;static#g=new Map([X,Er,Mr,Q,jr].map(e=>[e._editorType,e]));constructor({uiManager:e,pageIndex:t,div:n,structTreeLayer:r,accessibilityManager:i,annotationLayer:a,drawLayer:o,textLayer:s,viewport:c,l10n:l}){let u=[...Nr.#g.values()];if(!Nr._initialized){Nr._initialized=!0;for(let t of u)t.initialize(l,e)}e.registerEditorTypes(u);this.#h=e;this.pageIndex=t;this.div=n;this.#e=i;this.#n=a;this.viewport=c;this.#d=s;this.drawLayer=o;this._structTree=r;this.#h.addLayer(this)}get isEmpty(){return this.#a.size===0}get isInvisible(){return this.isEmpty&&this.#h.getMode()===_.NONE}updateToolbar(e){this.#h.updateToolbar(e)}updateMode(e=this.#h.getMode()){this.#S();switch(e){case _.NONE:this.div.classList.toggle(`nonEditing`,!0);this.disableTextSelection();this.togglePointerEvents(!1);this.toggleAnnotationLayerPointerEvents(!0);this.disableClick();return;case _.INK:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick();break;case _.HIGHLIGHT:this.enableTextSelection();this.togglePointerEvents(!1);this.disableClick();break;default:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:t}=this.div;t.toggle(`nonEditing`,!1);if(e===_.POPUP)t.toggle(`commentEditing`,!0);else{t.toggle(`commentEditing`,!1);for(let n of Nr.#g.values())t.toggle(`${n._type}Editing`,e===n._editorType)}this.div.hidden=!1}hasTextLayer(e){return e===this.#d?.div}setEditingState(e){this.#h.setEditingState(e)}addCommands(e){this.#h.addCommands(e)}cleanUndoStack(e){this.#h.cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle(`drawing`,!e)}togglePointerEvents(e=!1){this.div.classList.toggle(`disabled`,!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#n?.togglePointerEvents(e)}get#_(){return this.#a.size===0?this.#h.getEditors(this.pageIndex):this.#a.values()}async enable(){this.#c=!0;this.div.tabIndex=0;this.togglePointerEvents(!0);this.div.classList.toggle(`nonEditing`,!1);this.#p?.abort();this.#p=null;let e=new Set;for(let t of this.#_){t.enableEditing();t.show(!0);if(t.annotationElementId){this.#h.removeChangedExistingAnnotation(t);e.add(t.annotationElementId)}}let t=this.#n;if(t)for(let n of t.getEditableAnnotations()){n.hide();if(this.#h.isDeletedAnnotationElement(n.data.id))continue;if(e.has(n.data.id))continue;let t=await this.deserialize(n);if(t){this.addOrRebuild(t);t.enableEditing()}}this.#c=!1;this.#h._eventBus.dispatch(`editorsrendered`,{source:this,pageNumber:this.pageIndex+1})}disable(){this.#s=!0;this.div.tabIndex=-1;this.togglePointerEvents(!1);this.div.classList.toggle(`nonEditing`,!0);if(this.#d&&!this.#p){this.#p=new AbortController;let e=this.#h.combinedSignal(this.#p);this.#d.div.addEventListener(`pointerdown`,e=>{let{clientX:t,clientY:n,timeStamp:r}=e;if(r-this.#m>500){this.#m=r;return}this.#m=-1;let{classList:i}=this.div;i.toggle(`getElements`,!0);let a=document.elementsFromPoint(t,n);i.toggle(`getElements`,!1);if(!this.div.contains(a[0]))return;let o,s=RegExp(`^${g}[0-9]+$`);for(let e of a)if(s.test(e.id)){o=e.id;break}if(!o)return;let c=this.#a.get(o);if(c?.annotationElementId===null){R(e);c.dblclick(e)}},{signal:e,capture:!0})}let e=this.#n,t=[];if(e){let n=new Map,r=new Map;for(let e of this.#_){e.disableEditing();if(e.annotationElementId){if(e.serialize()===null){r.set(e.annotationElementId,e);this.getEditableAnnotation(e.annotationElementId)?.show();e.remove()}else n.set(e.annotationElementId,e)}else t.push(e)}for(let t of e.getEditableAnnotations()){let{id:e}=t.data;if(this.#h.isDeletedAnnotationElement(e)){t.updateEdited({deleted:!0});continue}let i=r.get(e);if(i){i.resetAnnotationElement(t);i.show(!1);t.show()}else{i=n.get(e);if(i){this.#h.addChangedExistingAnnotation(i);i.renderAnnotationElement(t)&&i.show(!1)}t.show()}}}this.#S();this.isEmpty&&(this.div.hidden=!0);let{classList:n}=this.div;for(let e of Nr.#g.values())n.remove(`${e._type}Editing`);this.disableTextSelection();this.toggleAnnotationLayerPointerEvents(!0);e?.updateFakeAnnotations(t);this.#s=!1}getEditableAnnotation(e){return this.#n?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#h.getActive()!==e&&this.#h.setActiveEditor(e)}enableTextSelection(){this.div.tabIndex=-1;if(this.#d?.div&&!this.#f){this.#f=new AbortController;let e=this.#h.combinedSignal(this.#f);this.#d.div.addEventListener(`pointerdown`,this.#v.bind(this),{signal:e});this.#d.div.classList.add(`highlighting`)}}disableTextSelection(){this.div.tabIndex=0;if(this.#d?.div&&this.#f){this.#f.abort();this.#f=null;this.#d.div.classList.remove(`highlighting`)}}#v(e){this.#h.unselectAll();let{target:t}=e;if(t===this.#d.div||(t.getAttribute(`role`)===`img`||t.classList.contains(`endOfContent`)||t.classList.contains(`textLayerImages`)||t.classList.contains(`textLayerImagePlaceholder`))&&this.#d.div.contains(t)){let{isMac:t}=N.platform;if(e.button!==0||e.ctrlKey&&t)return;this.#h.showAllEditors(`highlight`,!0,!0);this.#d.div.classList.add(`free`);this.toggleDrawing();Q.startHighlighting(this,this.#h.direction===`ltr`,{target:this.#d.div,x:e.x,y:e.y});this.#d.div.addEventListener(`pointerup`,()=>{this.#d.div.classList.remove(`free`);this.toggleDrawing(!0)},{once:!0,signal:this.#h._signal});e.preventDefault()}}enableClick(){if(this.#r)return;this.#r=new AbortController;let e=this.#h.combinedSignal(this.#r);this.div.addEventListener(`pointerdown`,this.pointerdown.bind(this),{signal:e});let t=this.pointerup.bind(this);this.div.addEventListener(`pointerup`,t,{signal:e});this.div.addEventListener(`pointercancel`,t,{signal:e})}disableClick(){this.#r?.abort();this.#r=null}attach(e){this.#a.set(e.id,e);let{annotationElementId:t}=e;t&&this.#h.isDeletedAnnotationElement(t)&&this.#h.removeDeletedAnnotationElement(e)}detach(e){this.#a.delete(e.id);this.#e?.removePointerInTextLayer(e.contentDiv);!this.#s&&e.annotationElementId&&this.#h.addDeletedAnnotationElement(e)}remove(e){this.detach(e);this.#h.removeEditor(e);e.div.remove();e.isAttachedToDOM=!1}changeParent(e){if(e.parent!==this){if(e.parent&&e.annotationElementId){this.#h.addDeletedAnnotationElement(e);H.deleteAnnotationElement(e);e.annotationElementId=null}this.attach(e);e.parent?.detach(e);e.setParent(this);if(e.div&&e.isAttachedToDOM){e.div.remove();this.div.append(e.div)}}}add(e){if(e.parent!==this||!e.isAttachedToDOM){this.changeParent(e);this.#h.addEditor(e);this.attach(e);if(!e.isAttachedToDOM){let t=e.render();this.div.append(t);e.isAttachedToDOM=!0}e.fixAndSetPosition();e.onceAdded(!this.#c);this.#h.addToAnnotationStorage(e);e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;let{activeElement:t}=document;if(e.div.contains(t)&&!this.#i){e._focusEventsAllowed=!1;this.#i=setTimeout(()=>{this.#i=null;if(e.div.contains(document.activeElement))e._focusEventsAllowed=!0;else{e.div.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this.#h._signal});t.focus()}},0)}e._structTreeParentId=this.#e?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){if(e.needsToBeRebuilt()){e.parent||=this;e.rebuild();e.show()}else this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getEditorByUID(e){for(let t of this.#a.values())if(t.uid===e)return t;return null}get#y(){return Nr.#g.get(this.#h.getMode())}combinedSignal(e){return this.#h.combinedSignal(e)}#b(e){let t=this.#y;return t?new t.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#y?.canCreateNewEmptyEditor()}async pasteEditor(e,t){this.updateToolbar(e);await this.#h.updateMode(e.mode);let{offsetX:n,offsetY:r}=this.#x(),i=this.#h.getId(),a=this.#b({parent:this,id:i,x:n,y:r,uiManager:this.#h,isCentered:!0,...t});a&&this.add(a)}async deserialize(e){return await Nr.#g.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#h)||null}createAndAddNewEditor(e,t,n={}){let r=this.#h.getId(),i=this.#b({parent:this,id:r,x:e.offsetX,y:e.offsetY,uiManager:this.#h,isCentered:t,...n});i&&this.add(i);return i}get boundingClientRect(){return this.div.getBoundingClientRect()}#x(){let{x:e,y:t,width:n,height:r}=this.boundingClientRect,i=Math.max(0,e),a=Math.max(0,t),o=(i+Math.min(window.innerWidth,e+n))/2-e,s=(a+Math.min(window.innerHeight,t+r))/2-t,[c,l]=this.viewport.rotation%180==0?[o,s]:[s,o];return{offsetX:c,offsetY:l}}addNewEditor(e={}){this.createAndAddNewEditor(this.#x(),!0,e)}setSelected(e){this.#h.setSelected(e)}toggleSelected(e){this.#h.toggleSelected(e)}unselect(e){this.#h.unselect(e)}pointerup(e){let{isMac:t}=N.platform;if(e.button!==0||e.ctrlKey&&t)return;if(e.target!==this.div)return;if(!this.#o)return;this.#o=!1;if(this.#y?.isDrawer&&this.#y.supportMultipleDrawings)return;if(!this.#t){this.#t=!0;return}let n=this.#h.getMode();n!==_.STAMP&&n!==_.POPUP&&n!==_.SIGNATURE?this.createAndAddNewEditor(e,!1):this.#h.unselectAll()}pointerdown(e){this.#h.getMode()===_.HIGHLIGHT&&this.enableTextSelection();if(this.#o){this.#o=!1;return}let{isMac:t}=N.platform;if(e.button!==0||e.ctrlKey&&t)return;if(e.target!==this.div)return;this.#o=!0;if(this.#y?.isDrawer){this.startDrawingSession(e);return}let n=this.#h.getActive();this.#t=!n||n.isEmpty()}startDrawingSession(e){this.div.focus({preventScroll:!0});if(this.#l){this.#y.startDrawing(this,this.#h,!1,e);return}this.#h.setCurrentDrawingSession(this);this.#l=new AbortController;let t=this.#h.combinedSignal(this.#l);this.div.addEventListener(`blur`,({relatedTarget:e})=>{if(e&&!this.div.contains(e)){this.#u=null;this.commitOrRemove()}},{signal:t});this.#y.startDrawing(this,this.#h,!1,e)}pause(e){if(e){let{activeElement:e}=document;this.div.contains(e)&&(this.#u=e);return}this.#u&&setTimeout(()=>{this.#u?.focus();this.#u=null},0)}endDrawingSession(e=!1){if(!this.#l)return null;this.#h.setCurrentDrawingSession(null);this.#l.abort();this.#l=null;this.#u=null;return this.#y.endDrawing(e)}findNewParent(e,t,n){let r=this.#h.findParent(t,n);if(r===null||r===this)return!1;r.changeParent(e);return!0}commitOrRemove(){if(this.#l){this.endDrawingSession();return!0}return!1}onScaleChanging(){this.#l&&this.#y.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove();if(this.#h.getActive()?.parent===this){this.#h.commitOrRemove();this.#h.setActiveEditor(null)}if(this.#i){clearTimeout(this.#i);this.#i=null}for(let e of this.#a.values()){this.#e?.removePointerInTextLayer(e.contentDiv);e.setParent(null);e.isAttachedToDOM=!1;e.div.remove()}this.div=null;this.#a.clear();this.#h.removeLayer(this)}#S(){for(let e of this.#a.values())e.isEmpty()&&e.remove()}async render({viewport:e}){this.viewport=e;we(this.div,e);for(let e of this.#h.getEditors(this.pageIndex)){this.add(e);e.rebuild()}await this.#h.findClonesForPage(this);this.div.hidden=this.isEmpty;this.updateMode()}update({viewport:e}){this.#h.commitOrRemove();this.#S();let t=this.viewport.rotation,n=e.rotation;this.viewport=e;we(this.div,{rotation:n});if(t!==n)for(let e of this.#a.values())e.rotate(n)}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return this.#h.viewParameters.realScale}}globalThis._pdfjsTestingUtils={HighlightOutliner:vr};const Pr={fonts:globalThis.fonts,createElement(e){if(e.toLowerCase()===`canvas`)return new OffscreenCanvas(1,1);return null}};class Fr{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(n,s={}){let[{data:c},l]=await Promise.all([t(n.url,{responseType:`array-buffer`,signal:s?.signal}),this._getPDFWorker(s)]),u=Kn({data:c,wasmUrl:e(`esri/libs/pdfjs/wasm/`),ownerDocument:Pr,enableHWA:!0,useWorkerFetch:!0,worker:l,useWasm:!0,verbosity:0});this._pdfDocument=await u.promise;r(s);this._page=await this._pdfDocument.getPage(n.page);r(s);this._geospatialMetadata=await this._page.getGeospatialPDFMetadata();r(s);this._baseViewport=this._page.getViewport({scale:1});this._inverseBaseViewport=i();o(this._inverseBaseViewport,a(...this._baseViewport.transform));return{geospatialMetadata:this._geospatialMetadata}}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;if(this._pdfWorkerBlobUrl){URL.revokeObjectURL(this._pdfWorkerBlobUrl);this._pdfWorkerBlobUrl=null}}async renderPDF(e,t={}){if(!this._page||!this._baseViewport||!this._inverseBaseViewport)throw new n(`geospatial-pdf-layer-worker:not-loaded`,`PDF not loaded`);r(t);let{width:i,height:a,sourceExtentAsJSON:o,currentRing:l,ctm:u}=e,d=s.fromJSON(o),f=await c(d,i,a,u,this._page,this._baseViewport,this._inverseBaseViewport,l,t);r(t);return Ir(f,i,a)}async _getPDFWorker(n={}){if(this._pdfWorker)return this._pdfWorker;let r=e(`esri/libs/pdfjs/pdf.worker.mjs`),i=(await t(r,{responseType:`blob`,authMode:`anonymous`,signal:n.signal})).data,a=i.type===`application/javascript`||i.type===`text/javascript`?i:new Blob([i],{type:`application/javascript`}),o=URL.createObjectURL(a),s=null,c=null;try{s=new Worker(o,{type:`module`,name:`geospatial-pdf-pdfjs-worker`});c=new J({port:s,verbosity:0});this._pdfWorkerPort=s;this._pdfWorker=c;this._pdfWorkerBlobUrl=o;await c.promise;return c}catch(e){URL.revokeObjectURL(o);throw e}}}function Ir(e,t,r){let i=e.getContext(`2d`);if(!i)throw new n(`geospatial-pdf-raster:canvas`,`Failed to create canvas context.`);let a=i.getImageData(0,0,t,r).data,o=t*r,s=new Uint8Array(o),c=new Uint8Array(o),l=new Uint8Array(o),u=new Uint8Array(o);for(let e=0,t=0;e<o;e++,t+=4){s[e]=a[t];c[e]=a[t+1];l[e]=a[t+2];u[e]=a[t+3]}return{width:t,height:r,red:s,green:c,blue:l,mask:u}}export{Fr as default};
|
|
57
|
+
`)){let n=document.createElement(`div`);n.append(e?document.createTextNode(e):document.createElement(`br`));t.append(n)}e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#e}});return t}resetAnnotationElement(e){super.resetAnnotationElement(e);e.resetEdited()}}class Z{static PRECISION=1e-4;toSVGPath(){D("Abstract method `toSVGPath` must be implemented.")}get box(){D("Abstract getter `box` must be implemented.")}serialize(e,t){D("Abstract method `serialize` must be implemented.")}static _rescale(e,t,n,r,i,a){a||=new Float32Array(e.length);for(let o=0,s=e.length;o<s;o+=2){a[o]=t+e[o]*r;a[o+1]=n+e[o+1]*i}return a}static _rescaleAndSwap(e,t,n,r,i,a){a||=new Float32Array(e.length);for(let o=0,s=e.length;o<s;o+=2){a[o]=t+e[o+1]*r;a[o+1]=n+e[o]*i}return a}static _translate(e,t,n,r){r||=new Float32Array(e.length);for(let i=0,a=e.length;i<a;i+=2){r[i]=t+e[i];r[i+1]=n+e[i+1]}return r}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,t,n,r,i){switch(i){case 90:return[1-t/n,e/r];case 180:return[1-e/n,1-t/r];case 270:return[t/n,1-e/r];default:return[e/n,t/r]}}static _normalizePagePoint(e,t,n){switch(n){case 90:return[1-t,e];case 180:return[1-e,1-t];case 270:return[t,1-e];default:return[e,t]}}static createBezierPoints(e,t,n,r,i,a){return[(e+5*n)/6,(t+5*r)/6,(5*n+i)/6,(5*r+a)/6,(n+i)/2,(r+a)/2]}}class gr{#e;#t=[];#n;#r;#i=[];#a=new Float32Array(18);#o;#s;#c;#l;#u;#d;#f=[];static#p=8;static#m=2;static#h=gr.#p+gr.#m;constructor({x:e,y:t},n,r,i,a,o=0){this.#e=n;this.#d=i*r;this.#r=a;this.#a.set([NaN,NaN,NaN,NaN,e,t],6);this.#n=o;this.#l=gr.#p*r;this.#c=gr.#h*r;this.#u=r;this.#f.push(e,t)}isEmpty(){return isNaN(this.#a[8])}#g(){let e=this.#a.subarray(4,6),t=this.#a.subarray(16,18),[n,r,i,a]=this.#e;return[(this.#o+(e[0]-t[0])/2-n)/i,(this.#s+(e[1]-t[1])/2-r)/a,(this.#o+(t[0]-e[0])/2-n)/i,(this.#s+(t[1]-e[1])/2-r)/a]}add({x:e,y:t}){this.#o=e;this.#s=t;let[n,r,i,a]=this.#e,[o,s,c,l]=this.#a.subarray(8,12),u=e-c,d=t-l,f=Math.hypot(u,d);if(f<this.#c)return!1;let p=f-this.#l,m=p/f,h=m*u,g=m*d,_=o,v=s;o=c;s=l;c+=h;l+=g;this.#f?.push(e,t);let y=h/p,b=-g/p*this.#d,x=y*this.#d;this.#a.set(this.#a.subarray(2,8),0);this.#a.set([c+b,l+x],4);this.#a.set(this.#a.subarray(14,18),12);this.#a.set([c-b,l-x],16);if(isNaN(this.#a[6])){if(this.#i.length===0){this.#a.set([o+b,s+x],2);this.#i.push(NaN,NaN,NaN,NaN,(o+b-n)/i,(s+x-r)/a);this.#a.set([o-b,s-x],14);this.#t.push(NaN,NaN,NaN,NaN,(o-b-n)/i,(s-x-r)/a)}this.#a.set([_,v,o,s,c,l],6);return!this.isEmpty()}this.#a.set([_,v,o,s,c,l],6);if(Math.abs(Math.atan2(v-s,_-o)-Math.atan2(g,h))<Math.PI/2){[o,s,c,l]=this.#a.subarray(2,6);this.#i.push(NaN,NaN,NaN,NaN,((o+c)/2-n)/i,((s+l)/2-r)/a);[o,s,_,v]=this.#a.subarray(14,18);this.#t.push(NaN,NaN,NaN,NaN,((_+o)/2-n)/i,((v+s)/2-r)/a);return!0}[_,v,o,s,c,l]=this.#a.subarray(0,6);this.#i.push(((_+5*o)/6-n)/i,((v+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a);[c,l,o,s,_,v]=this.#a.subarray(12,18);this.#t.push(((_+5*o)/6-n)/i,((v+5*s)/6-r)/a,((5*o+c)/6-n)/i,((5*s+l)/6-r)/a,((o+c)/2-n)/i,((s+l)/2-r)/a);return!0}toSVGPath(){if(this.isEmpty())return``;let e=this.#i,t=this.#t;if(isNaN(this.#a[6])&&!this.isEmpty())return this.#_();let n=[];n.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?n.push(`L${e[t+4]} ${e[t+5]}`):n.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);this.#y(n);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?n.push(`L${t[e+4]} ${t[e+5]}`):n.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#v(n);return n.join(` `)}#_(){let[e,t,n,r]=this.#e,[i,a,o,s]=this.#g();return`M${(this.#a[2]-e)/n} ${(this.#a[3]-t)/r} L${(this.#a[4]-e)/n} ${(this.#a[5]-t)/r} L${i} ${a} L${o} ${s} L${(this.#a[16]-e)/n} ${(this.#a[17]-t)/r} L${(this.#a[14]-e)/n} ${(this.#a[15]-t)/r} Z`}#v(e){let t=this.#t;e.push(`L${t[4]} ${t[5]} Z`)}#y(e){let[t,n,r,i]=this.#e,a=this.#a.subarray(4,6),o=this.#a.subarray(16,18),[s,c,l,u]=this.#g();e.push(`L${(a[0]-t)/r} ${(a[1]-n)/i} L${s} ${c} L${l} ${u} L${(o[0]-t)/r} ${(o[1]-n)/i}`)}newFreeDrawOutline(e,t,n,r,i,a){return new _r(e,t,n,r,i,a)}getOutlines(){let e=this.#i,t=this.#t,n=this.#a,[r,i,a,o]=this.#e,s=new Float32Array((this.#f?.length??0)+2);for(let e=0,t=s.length-2;e<t;e+=2){s[e]=(this.#f[e]-r)/a;s[e+1]=(this.#f[e+1]-i)/o}s[s.length-2]=(this.#o-r)/a;s[s.length-1]=(this.#s-i)/o;if(isNaN(n[6])&&!this.isEmpty())return this.#b(s);let c=new Float32Array(this.#i.length+24+this.#t.length),l=e.length;for(let t=0;t<l;t+=2)if(isNaN(e[t]))c[t]=c[t+1]=NaN;else{c[t]=e[t];c[t+1]=e[t+1]}l=this.#S(c,l);for(let e=t.length-6;e>=6;e-=6)for(let n=0;n<6;n+=2)if(isNaN(t[e+n])){c[l]=c[l+1]=NaN;l+=2}else{c[l]=t[e+n];c[l+1]=t[e+n+1];l+=2}this.#x(c,l);return this.newFreeDrawOutline(c,s,this.#e,this.#u,this.#n,this.#r)}#b(e){let t=this.#a,[n,r,i,a]=this.#e,[o,s,c,l]=this.#g(),u=new Float32Array(36);u.set([NaN,NaN,NaN,NaN,(t[2]-n)/i,(t[3]-r)/a,NaN,NaN,NaN,NaN,(t[4]-n)/i,(t[5]-r)/a,NaN,NaN,NaN,NaN,o,s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,(t[16]-n)/i,(t[17]-r)/a,NaN,NaN,NaN,NaN,(t[14]-n)/i,(t[15]-r)/a],0);return this.newFreeDrawOutline(u,e,this.#e,this.#u,this.#n,this.#r)}#x(e,t){let n=this.#t;e.set([NaN,NaN,NaN,NaN,n[4],n[5]],t);return t+6}#S(e,t){let n=this.#a.subarray(4,6),r=this.#a.subarray(16,18),[i,a,o,s]=this.#e,[c,l,u,d]=this.#g();e.set([NaN,NaN,NaN,NaN,(n[0]-i)/o,(n[1]-a)/s,NaN,NaN,NaN,NaN,c,l,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,(r[0]-i)/o,(r[1]-a)/s],t);return t+24}}class _r extends Z{#e;#t=new Float32Array(4);#n;#r;#i;#a;#o;constructor(e,t,n,r,i,a){super();this.#o=e;this.#i=t;this.#e=n;this.#a=r;this.#n=i;this.#r=a;this.firstPoint=[NaN,NaN];this.lastPoint=[NaN,NaN];this.#s(a);let[o,s,c,l]=this.#t;for(let t=0,n=e.length;t<n;t+=2){e[t]=(e[t]-o)/c;e[t+1]=(e[t+1]-s)/l}for(let e=0,n=t.length;e<n;e+=2){t[e]=(t[e]-o)/c;t[e+1]=(t[e+1]-s)/l}}toSVGPath(){let e=[`M${this.#o[4]} ${this.#o[5]}`];for(let t=6,n=this.#o.length;t<n;t+=6)isNaN(this.#o[t])?e.push(`L${this.#o[t+4]} ${this.#o[t+5]}`):e.push(`C${this.#o[t]} ${this.#o[t+1]} ${this.#o[t+2]} ${this.#o[t+3]} ${this.#o[t+4]} ${this.#o[t+5]}`);e.push(`Z`);return e.join(` `)}serialize([e,t,n,r],i){let a=n-e,o=r-t,s,c;switch(i){case 0:s=Z._rescale(this.#o,e,r,a,-o);c=Z._rescale(this.#i,e,r,a,-o);break;case 90:s=Z._rescaleAndSwap(this.#o,e,t,a,o);c=Z._rescaleAndSwap(this.#i,e,t,a,o);break;case 180:s=Z._rescale(this.#o,n,t,-a,o);c=Z._rescale(this.#i,n,t,-a,o);break;case 270:s=Z._rescaleAndSwap(this.#o,n,r,-a,-o);c=Z._rescaleAndSwap(this.#i,n,r,-a,-o)}return{outline:Array.from(s),points:[Array.from(c)]}}#s(e){let t=this.#o,n=t[4],r=t[5],i=[n,r,n,r],a=n,o=r,s=n,c=r,l=e?Math.max:Math.min,d=new Float32Array(4);for(let e=6,f=t.length;e<f;e+=6){let f=t[e+4],p=t[e+5];if(isNaN(t[e])){P.pointBoundingBox(f,p,i);if(o>p){a=f;o=p}else o===p&&(a=l(a,f));if(c<p){s=f;c=p}else c===p&&(s=l(s,f))}else{d.set(u,0);P.bezierBoundingBox(n,r,...t.slice(e,e+6),d);P.rectBoundingBox(...d,i);if(o>d[1]){a=d[0];o=d[1]}else o===d[1]&&(a=l(a,d[0]));if(c<d[3]){s=d[2];c=d[3]}else c===d[3]&&(s=l(s,d[2]))}n=f;r=p}let f=this.#t;f[0]=i[0]-this.#n;f[1]=i[1]-this.#n;f[2]=i[2]-i[0]+2*this.#n;f[3]=i[3]-i[1]+2*this.#n;this.firstPoint=[a,o];this.lastPoint=[s,c]}get box(){return this.#t}newOutliner(e,t,n,r,i,a=0){return new gr(e,t,n,r,i,a)}getNewOutline(e,t){let[n,r,i,a]=this.#t,[o,s,c,l]=this.#e,u=i*c,d=a*l,f=n*c+o,p=r*l+s,m=this.newOutliner({x:this.#i[0]*u+f,y:this.#i[1]*d+p},this.#e,this.#a,e,this.#r,t??this.#n);for(let e=2;e<this.#i.length;e+=2)m.add({x:this.#i[e]*u+f,y:this.#i[e+1]*d+p});return m.getOutlines()}}class vr{#e;#t;#n;#r=[];#i=[];constructor(e,t=0,n=0,r=!0){let i=u.slice(),a=1e-4;for(let{x:n,y:r,width:o,height:s}of e){let e=Math.floor((n-t)/a)*a,c=Math.ceil((n+o+t)/a)*a,l=Math.floor((r-t)/a)*a,u=Math.ceil((r+s+t)/a)*a,d=[e,l,u,!0],f=[c,l,u,!1];this.#r.push(d,f);P.rectBoundingBox(e,l,c,u,i)}let o=i[2]-i[0]+2*n,s=i[3]-i[1]+2*n,c=i[0]-n,l=i[1]-n,d=r?-1/0:1/0,f=1/0,p=this.#r.at(r?-1:-2),m=[p[0],p[2]];for(let e of this.#r){let[t,n,i,a]=e;if(!a&&r){if(n<f){f=n;d=t}else n===f&&(d=Math.max(d,t))}else if(a&&!r){if(n<f){f=n;d=t}else n===f&&(d=Math.min(d,t))}e[0]=(t-c)/o;e[1]=(n-l)/s;e[2]=(i-l)/s}this.#e=new Float32Array([c,l,o,s]);this.#t=[d,f];this.#n=m}getOutlines(){this.#r.sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);let e=[];for(let t of this.#r)if(t[3]){e.push(...this.#l(t));this.#s(t)}else{this.#c(t);e.push(...this.#l(t))}return this.#a(e)}#a(e){let t=[],n=new Set;for(let n of e){let[e,r,i]=n;t.push([e,r,n],[e,i,n])}t.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,r=t.length;e<r;e+=2){let r=t[e][2],i=t[e+1][2];r.push(i);i.push(r);n.add(r);n.add(i)}let r=[],i;for(;n.size>0;){let e=n.values().next().value,[t,a,o,s,c]=e;n.delete(e);let l=t,u=a;i=[t,o];r.push(i);for(;;){let e;if(n.has(s))e=s;else{if(!n.has(c))break;e=c}n.delete(e);[t,a,o,s,c]=e;if(l!==t){i.push(l,u,t,u===a?a:o);l=t}u=u===a?o:a}i.push(l,u)}return new yr(r,this.#e,this.#t,this.#n)}#o(e){let t=this.#i,n=0,r=t.length-1;for(;n<=r;){let i=n+r>>1,a=t[i][0];if(a===e)return i;a<e?n=i+1:r=i-1}return r+1}#s([,e,t]){let n=this.#o(e);this.#i.splice(n,0,[e,t])}#c([,e,t]){let n=this.#o(e);for(let r=n;r<this.#i.length;r++){let[n,i]=this.#i[r];if(n!==e)break;if(n===e&&i===t){this.#i.splice(r,1);return}}for(let r=n-1;r>=0;r--){let[n,i]=this.#i[r];if(n!==e)break;if(n===e&&i===t){this.#i.splice(r,1);return}}}#l(e){let[t,n,r]=e,i=[[t,n,r]],a=this.#o(r);for(let e=0;e<a;e++){let[n,r]=this.#i[e];for(let e=0,a=i.length;e<a;e++){let[,o,s]=i[e];if(!(r<=o||s<=n)){if(o>=n){if(s>r)i[e][1]=r;else{if(a===1)return[];i.splice(e,1);e--;a--}}else{i[e][2]=n;s>r&&i.push([t,r,s])}}}}return i}}class yr extends Z{#e;#t;constructor(e,t,n,r){super();this.#t=e;this.#e=t;this.firstPoint=n;this.lastPoint=r}toSVGPath(){let e=[];for(let t of this.#t){let[n,r]=t;e.push(`M${n} ${r}`);for(let i=2;i<t.length;i+=2){let a=t[i],o=t[i+1];if(a===n){e.push(`V${o}`);r=o}else if(o===r){e.push(`H${a}`);n=a}}e.push(`Z`)}return e.join(` `)}serialize([e,t,n,r],i){let a=[],o=n-e,s=r-t;for(let t of this.#t){let n=Array(t.length);for(let i=0;i<t.length;i+=2){n[i]=e+t[i]*o;n[i+1]=r-t[i+1]*s}a.push(n)}return a}get box(){return this.#e}get classNamesForOutlining(){return[`highlightOutline`]}}class br extends gr{newFreeDrawOutline(e,t,n,r,i,a){return new xr(e,t,n,r,i,a)}}class xr extends _r{newOutliner(e,t,n,r,i,a=0){return new br(e,t,n,r,i,a)}}class Q extends H{#e=null;#t=0;#n;#r=null;#i=null;#a=null;#o=null;#s=0;#c=null;#l=null;#u=null;#d=!1;#f=null;#p=null;#m=null;#h=``;#g;#_=``;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type=`highlight`;static _editorType=_.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId=``;static get _keyboardManager(){let e=Q.prototype;return j(this,`_keyboardManager`,new Ie([[[`ArrowLeft`,`mac+ArrowLeft`],e._moveCaret,{args:[0]}],[[`ArrowRight`,`mac+ArrowRight`],e._moveCaret,{args:[1]}],[[`ArrowUp`,`mac+ArrowUp`],e._moveCaret,{args:[2]}],[[`ArrowDown`,`mac+ArrowDown`],e._moveCaret,{args:[3]}]]))}constructor(e){super({...e,name:`highlightEditor`});this.color=e.color||Q._defaultColor;this.#g=e.thickness||Q._defaultThickness;this.opacity=e.opacity||Q._defaultOpacity;this.#n=e.boxes||null;this.#_=e.methodOfCreation||``;this.#h=e.text||``;this._isDraggable=!1;this.defaultL10nId=`pdfjs-editor-highlight-editor`;if(e.highlightId>-1){this.#d=!0;this.#y(e);this.#w()}else if(this.#n){this.#e=e.anchorNode;this.#t=e.anchorOffset;this.#o=e.focusNode;this.#s=e.focusOffset;this.#v();this.#w();this.rotate(this.rotation)}this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert.highlight)}get telemetryInitialData(){return{action:`added`,type:this.#d?`free_highlight`:`highlight`,color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#g,methodOfCreation:this.#_}}get telemetryFinalData(){return{type:`highlight`,color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get(`color`).size}}#v(){let e=new vr(this.#n,.001);this.#l=e.getOutlines();[this.x,this.y,this.width,this.height]=this.#l.box;let t=new vr(this.#n,.0025,.001,this._uiManager.direction===`ltr`);this.#a=t.getOutlines();let{firstPoint:n}=this.#l;this.#f=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height];let{lastPoint:r}=this.#a;this.#p=[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height]}#y({highlightOutlines:e,highlightId:t,clipPathId:n}){this.#l=e;this.#a=e.getNewOutline(this.#g/2+1.5,.0025);if(t>=0){this.#u=t;this.#r=n;this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}});this.#m=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},!0)}else if(this.parent){let t=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:Q.#T(this.#l.box,(t-this.rotation+360)%360),path:{d:e.toSVGPath()}});this.parent.drawLayer.updateProperties(this.#m,{bbox:Q.#T(this.#a.box,t),path:{d:this.#a.toSVGPath()}})}let[r,i,a,o]=e.box;switch(this.rotation){case 0:this.x=r;this.y=i;this.width=a;this.height=o;break;case 90:{let[e,t]=this.parentDimensions;this.x=i;this.y=1-r;this.width=a*t/e;this.height=o*e/t;break}case 180:this.x=1-r;this.y=1-i;this.width=a;this.height=o;break;case 270:{let[e,t]=this.parentDimensions;this.x=1-i;this.y=r;this.width=a*t/e;this.height=o*e/t;break}}let{firstPoint:s}=e;this.#f=[(s[0]-r)/a,(s[1]-i)/o];let{lastPoint:c}=this.#a;this.#p=[(c[0]-r)/a,(c[1]-i)/o]}static initialize(e,t){H.initialize(e,t);Q._defaultColor||=t.highlightColors?.values().next().value||`#fff066`}static updateDefaultParams(e,t){switch(e){case v.HIGHLIGHT_COLOR:Q._defaultColor=t;break;case v.HIGHLIGHT_THICKNESS:Q._defaultThickness=t}}translateInPage(e,t){}get toolbarPosition(){return this.#p}get commentButtonPosition(){return this.#f}updateParams(e,t){switch(e){case v.HIGHLIGHT_COLOR:this.#b(t);break;case v.HIGHLIGHT_THICKNESS:this.#x(t)}}static get defaultPropertiesToUpdate(){return[[v.HIGHLIGHT_COLOR,Q._defaultColor],[v.HIGHLIGHT_THICKNESS,Q._defaultThickness]]}get propertiesToUpdate(){return[[v.HIGHLIGHT_COLOR,this.color||Q._defaultColor],[v.HIGHLIGHT_THICKNESS,this.#g||Q._defaultThickness],[v.HIGHLIGHT_FREE,this.#d]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:this.color,"fill-opacity":this.opacity}});this.#i?.updateColor(this.color);super.onUpdatedColor()}#b(e){let t=(e,t)=>{this.color=e;this.opacity=t;this.onUpdatedColor()},n=this.color,r=this.opacity;this.addCommands({cmd:t.bind(this,e,Q._defaultOpacity),undo:t.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:`color_changed`,color:this._uiManager.getNonHCMColorName(e)},!0)}#x(e){let t=this.#g,n=e=>{this.#g=e;this.#S(e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:`thickness_changed`,thickness:e},!0)}get toolbarButtons(){if(this._uiManager.highlightColors)return[[`colorPicker`,this.#i=new Y({editor:this})]];return 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.#O())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#O())}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this);e&&this.div.focus()}remove(){this.#C();this._reportTelemetry({action:`deleted`});super.remove()}rebuild(){if(this.parent){super.rebuild();if(this.div!==null){this.#w();this.isAttachedToDOM||this.parent.add(this)}}}setParent(e){let t=!1;if(this.parent&&!e)this.#C();else if(e){this.#w(e);t=!this.parent&&this.div?.classList.contains(`selectedEditor`)}super.setParent(e);this.show(this._isVisible);t&&this.select()}#S(e){if(this.#d){this.#y({highlightOutlines:this.#l.getNewOutline(e/2)});this.fixAndSetPosition();this.setDims()}}#C(){if(this.#u!==null&&this.parent){this.parent.drawLayer.remove(this.#u);this.#u=null;this.parent.drawLayer.remove(this.#m);this.#m=null}}#w(e=this.parent){if(this.#u===null){({id:this.#u,clipPathId:this.#r}=e.drawLayer.draw({bbox:this.#l.box,root:{viewBox:`0 0 1 1`,fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#d},path:{d:this.#l.toSVGPath()}},!1,!0));this.#m=e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#a.box,path:{d:this.#a.toSVGPath()}},this.#d);this.#c&&(this.#c.style.clipPath=this.#r)}}static#T([e,t,n,r],i){switch(i){case 90:return[1-t-r,e,r,n];case 180:return[1-e-n,1-t-r,n,r];case 270:return[t,1-e-n,r,n]}return[e,t,n,r]}rotate(e){let{drawLayer:t}=this.parent,n;if(this.#d){e=(e-this.rotation+360)%360;n=Q.#T(this.#l.box,e)}else n=Q.#T([this.x,this.y,this.width,this.height],e);t.updateProperties(this.#u,{bbox:n,root:{"data-main-rotation":e}});t.updateProperties(this.#m,{bbox:Q.#T(this.#a.box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;let e=super.render();if(this.#h){e.setAttribute(`aria-label`,this.#h);e.setAttribute(`role`,`mark`)}this.#d?e.classList.add(`free`):this.div.addEventListener(`keydown`,this.#E.bind(this),{signal:this._uiManager._signal});let t=this.#c=document.createElement(`div`);e.append(t);t.setAttribute(`aria-hidden`,`true`);t.className=`internal`;t.style.clipPath=this.#r;this.setDims();Me(this,this.#c,[`pointerover`,`pointerleave`]);this.enableEditing();return e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!1}})}#E(e){Q._keyboardManager.exec(this,e)}_moveCaret(e){this.parent.unselect(this);switch(e){case 0:case 2:this.#D(!0);break;case 1:case 3:this.#D(!1)}}#D(e){if(!this.#e)return;let t=window.getSelection();e?t.setPosition(this.#e,this.#t):t.setPosition(this.#o,this.#s)}select(){super.select();this.#m&&this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect();if(this.#m){this.parent?.drawLayer.updateProperties(this.#m,{rootClass:{selected:!1}});this.#d||this.#D(!1)}}get _mustFixPosition(){return!this.#d}show(e=this._isVisible){super.show(e);if(this.parent){this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!e}});this.parent.drawLayer.updateProperties(this.#m,{rootClass:{hidden:!e}})}}#O(){return this.#d?this.rotation:0}#k(){if(this.#d)return null;let[e,t]=this.pageDimensions,[n,r]=this.pageTranslation,i=this.#n,a=new Float32Array(8*i.length),o=0;for(let{x:s,y:c,width:l,height:u}of i){let i=s*e+n,d=(1-c)*t+r;a[o]=a[o+4]=i;a[o+1]=a[o+3]=d;a[o+2]=a[o+6]=i+l*e;a[o+5]=a[o+7]=d-u*t;o+=8}return a}#A(e){return this.#l.serialize(e,this.#O())}static startHighlighting(e,t,{target:n,x:r,y:i}){let{x:a,y:o,width:s,height:c}=n.getBoundingClientRect(),l=new AbortController,u=e.combinedSignal(l),d=t=>{l.abort();this.#M(e,t)};window.addEventListener(`blur`,d,{signal:u});window.addEventListener(`pointerup`,d,{signal:u});window.addEventListener(`pointerdown`,R,{capture:!0,passive:!1,signal:u});window.addEventListener(`contextmenu`,L,{signal:u});n.addEventListener(`pointermove`,this.#j.bind(this,e),{signal:u});this._freeHighlight=new br({x:r,y:i},[a,o,s,c],e.scale,this._defaultThickness/2,t,.001);({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#j(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#M(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:`main_toolbar`});this._freeHighlightId=-1;this._freeHighlight=null;this._freeHighlightClipId=``}static async deserialize(e,t,n){let r=null;if(e instanceof pr){let{data:{quadPoints:t,rect:n,rotation:i,id:a,color:o,opacity:s,popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;r=e={annotationType:_.HIGHLIGHT,color:Array.from(o),opacity:s,quadPoints:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}else if(e instanceof fr){let{data:{inkLists:t,rect:n,rotation:i,id:a,color:o,borderStyle:{rawWidth:s},popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=e;r=e={annotationType:_.HIGHLIGHT,color:Array.from(o),thickness:s,inkLists:t,boxes:null,pageIndex:p-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}let{color:i,quadPoints:a,inkLists:o,outlines:s,opacity:c}=e,l=await super.deserialize(e,t,n);l.color=P.makeHexColor(...i);l.opacity=c||1;o&&(l.#g=e.thickness);l._initialData=r;e.comment&&l.setCommentData(e);let[u,d]=l.pageDimensions,[f,p]=l.pageTranslation;if(a){let e=l.#n=[];for(let t=0;t<a.length;t+=8)e.push({x:(a[t]-f)/u,y:1-(a[t+1]-p)/d,width:(a[t+2]-a[t])/u,height:(a[t+1]-a[t+5])/d});l.#v();l.#w();l.rotate(l.rotation)}else if(o||s){l.#d=!0;let e=(o||s.points)[0],n={x:e[0]-f,y:d-(e[1]-p)},r=new br(n,[0,0,u,d],1,l.#g/2,!0,.001);for(let t=0,i=e.length;t<i;t+=2){n.x=e[t]-f;n.y=d-(e[t+1]-p);r.add(n)}let{id:i,clipPathId:a}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:`0 0 1 1`,fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:r.toSVGPath()}},!0,!0);l.#y({highlightOutlines:r.getOutlines(),highlightId:i,clipPathId:a});l.#w();l.rotate(l.parentRotation)}return l}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();let t=H._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),n=super.serialize(e);Object.assign(n,{color:t,opacity:this.opacity,thickness:this.#g,quadPoints:this.#k(),outlines:this.#A(n.rect)});this.addComment(n);if(this.annotationElementId&&!this.#N(n))return null;n.id=this.annotationElementId;return n}#N(e){let{color:t}=this._initialData;return this.hasEditedComment||e.color.some((e,n)=>e!==t[n])}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}static canCreateNewEmptyEditor(){return!1}}class Sr{#e=Object.create(null);updateProperty(e,t){this[e]=t;this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(let[t,n]of Object.entries(e))t.startsWith(`_`)||this.updateProperty(t,n)}updateSVGProperty(e,t){this.#e[e]=t}toSVGProperties(){let e=this.#e;this.#e=Object.create(null);return{root:e}}reset(){this.#e=Object.create(null)}updateAll(e=this){this.updateProperties(e)}clone(){D(`Not implemented`)}}class $ extends H{#e=null;#t;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#n=null;static#r=null;static#i=null;static _INNER_MARGIN=3;constructor(e){super(e);this.#t=e.mustBeCommitted||!1;this._addOutlines(e)}onUpdatedColor(){this._colorPicker?.update(this.color);super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(e){if(e.drawOutlines){this.#a(e);this.#c()}}#a({drawOutlines:e,drawId:t,drawingOptions:n}){this.#e=e;this._drawingOptions||=n;this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert[this.editorType]);if(t>=0){this._drawId=t;this.parent.drawLayer.finalizeDraw(t,e.defaultProperties)}else this._drawId=this.#o(e,this.parent);this.#d(e.box)}#o(e,t){let{id:n}=t.drawLayer.draw($._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n}static _mergeSVGProperties(e,t){let n=new Set(Object.keys(e));for(let[r,i]of Object.entries(t))n.has(r)?Object.assign(e[r],i):e[r]=i;return e}static getDefaultDrawingOptions(e){D(`Not implemented`)}static get typesMap(){D(`Not implemented`)}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,t){let n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,t);if(this._currentParent){$.#n.updateProperty(n,t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}updateParams(e,t){let n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,t)}static get defaultPropertiesToUpdate(){let e=[],t=this._defaultDrawingOptions;for(let[n,r]of this.typesMap)e.push([n,t[r]]);return e}get propertiesToUpdate(){let e=[],{_drawingOptions:t}=this;for(let[n,r]of this.constructor.typesMap)e.push([n,t[r]]);return e}_updateProperty(e,t,n){let r=this._drawingOptions,i=r[t],a=n=>{r.updateProperty(t,n);let i=this.#e.updateProperty(t,n);i&&this.#d(i);this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties());e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:a.bind(this,n),undo:a.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,t){let n=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),i=this._drawingOptions,a=i[n],o=i[r],s=(e,t)=>{i.updateProperty(n,e);i.updateProperty(r,t);this.#e.updateProperty(n,e);this.#e.updateProperty(r,t);this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties());this.onUpdatedColor();this.onUpdatedOpacity()};this.addCommands({cmd:s.bind(this,e,t),undo:s.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#e.getPathResizingSVGProperties(this.#u()),{bbox:this.#f()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#e.getPathResizedSVGProperties(this.#u()),{bbox:this.#f()}))}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#f()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties(this.#e.getPathTranslatedSVGProperties(this.#u(),this.parentDimensions),{bbox:this.#f()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit();this.disableEditMode();this.disableEditing()}disableEditing(){super.disableEditing();this.div.classList.toggle(`disabled`,!0)}enableEditing(){super.enableEditing();this.div.classList.toggle(`disabled`,!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this);this._isDraggable=!0;if(this.#t){this.#t=!1;this.commit();this.parent.setSelected(this);e&&this.isOnScreen&&this.div.focus()}}remove(){this.#s();super.remove()}rebuild(){if(this.parent){super.rebuild();if(this.div!==null){this.#c();this.#d(this.#e.box);this.isAttachedToDOM||this.parent.add(this)}}}setParent(e){let t=!1;if(this.parent&&!e){this._uiManager.removeShouldRescale(this);this.#s()}else if(e){this._uiManager.addShouldRescale(this);this.#c(e);t=!this.parent&&this.div?.classList.contains(`selectedEditor`)}super.setParent(e);t&&this.select()}#s(){if(this._drawId!==null&&this.parent){this.parent.drawLayer.remove(this._drawId);this._drawId=null;this._drawingOptions.reset()}}#c(e=this.parent){if(this._drawId===null||this.parent!==e){if(this._drawId===null){this._drawingOptions.updateAll();this._drawId=this.#o(this.#e,e)}else this.parent.drawLayer.updateParent(this._drawId,e.drawLayer)}}#l([e,t,n,r]){let{parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[t,1-e,a/i*n,i/a*r];case 180:return[1-e,1-t,n,r];case 270:return[1-t,e,a/i*n,i/a*r];default:return[e,t,n,r]}}#u(){let{x:e,y:t,width:n,height:r,parentDimensions:[i,a],rotation:o}=this;switch(o){case 90:return[1-t,e,i/a*n,a/i*r];case 180:return[1-e,1-t,n,r];case 270:return[t,1-e,i/a*n,a/i*r];default:return[e,t,n,r]}}#d(e){[this.x,this.y,this.width,this.height]=this.#l(e);if(this.div){this.fixAndSetPosition();this.setDims()}this._onResized()}#f(){let{x:e,y:t,width:n,height:r,rotation:i,parentRotation:a,parentDimensions:[o,s]}=this;switch((4*i+a)/90){case 1:return[1-t-r,e,r,n];case 2:return[1-e-n,1-t-r,n,r];case 3:return[t,1-e-n,r,n];case 4:return[e,t-o/s*n,s/o*r,o/s*n];case 5:return[1-t,e,o/s*n,s/o*r];case 6:return[1-e-s/o*r,1-t,s/o*r,o/s*n];case 7:return[t-o/s*n,1-e-s/o*r,o/s*n,s/o*r];case 8:return[e-n,t-r,n,r];case 9:return[1-t,e-n,r,n];case 10:return[1-e,1-t,n,r];case 11:return[t-r,1-e,r,n];case 12:return[e-s/o*r,t,s/o*r,o/s*n];case 13:return[1-t-o/s*n,e-s/o*r,o/s*n,s/o*r];case 14:return[1-e,1-t-o/s*n,s/o*r,o/s*n];case 15:return[t,1-e,o/s*n,s/o*r];default:return[e,t,n,r]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,$._mergeSVGProperties({bbox:this.#f()},this.#e.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#d(this.#e.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}let n=super.render();n.classList.add(`draw`);let r=document.createElement(`div`);n.append(r);r.setAttribute(`aria-hidden`,`true`);r.className=`internal`;this.setDims();this._uiManager.addShouldRescale(this);this.disableEditing();this._isCopy&&this._moveAfterPaste(e,t);return n}static createDrawerInstance(e,t,n,r,i){D(`Not implemented`)}static startDrawing(e,t,n,r){let{target:i,offsetX:a,offsetY:o,pointerId:s,pointerType:c}=r;if(V.isInitializedAndDifferentPointerType(c))return;let{viewport:{rotation:l}}=e,{width:u,height:d}=i.getBoundingClientRect(),f=$.#r=new AbortController,p=e.combinedSignal(f);V.setPointer(c,s);window.addEventListener(`pointerup`,e=>{V.isSamePointerIdOrRemove(e.pointerId)&&this._endDraw(e)},{signal:p});window.addEventListener(`pointercancel`,e=>{V.isSamePointerIdOrRemove(e.pointerId)&&this._currentParent.endDrawingSession()},{signal:p});window.addEventListener(`pointerdown`,e=>{if(V.isSamePointerType(e.pointerType)){V.initializeAndAddPointerId(e.pointerId);if($.#n.isCancellable()){$.#n.removeLastElement();$.#n.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)}}},{capture:!0,passive:!1,signal:p});window.addEventListener(`contextmenu`,L,{signal:p});i.addEventListener(`pointermove`,this._drawMove.bind(this),{signal:p});i.addEventListener(`touchmove`,e=>{V.isSameTimeStamp(e.timeStamp)&&R(e)},{signal:p});e.toggleDrawing();t._editorUndoBar?.hide();if($.#n)e.drawLayer.updateProperties(this._currentDrawId,$.#n.startNew(a,o,u,d,l));else{t.updateUIForDefaultProperties(this);$.#n=this.createDrawerInstance(a,o,u,d,l);$.#i=this.getDefaultDrawingOptions();this._currentParent=e;({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties($.#i.toSVGProperties(),$.#n.defaultSVGProperties),!0,!1))}}static _drawMove(e){V.isSameTimeStamp(e.timeStamp);if(!$.#n)return;let{offsetX:t,offsetY:n,pointerId:r}=e;if(V.isSamePointerId(r)){if(V.isUsingMultiplePointers())this._endDraw(e);else{this._currentParent.drawLayer.updateProperties(this._currentDrawId,$.#n.add(t,n));V.setTimeStamp(e.timeStamp);R(e)}}}static _cleanup(e){if(e){this._currentDrawId=-1;this._currentParent=null;$.#n=null;$.#i=null;V.clearTimeStamp()}if($.#r){$.#r.abort();$.#r=null;V.clearPointerIds()}}static _endDraw(e){let t=this._currentParent;if(t){t.toggleDrawing(!0);this._cleanup(!1);e?.target===t.div&&t.drawLayer.updateProperties(this._currentDrawId,$.#n.end(e.offsetX,e.offsetY));if(this.supportMultipleDrawings){let e=$.#n,n=this._currentDrawId,r=e.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(n,e.setLastElement(r))},undo:()=>{t.drawLayer.updateProperties(n,e.removeLastElement())},mustExec:!1,type:v.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){let t=this._currentParent;if(!t)return null;t.toggleDrawing(!0);t.cleanUndoStack(v.DRAW_STEP);if(!$.#n.isEmpty()){let{pageDimensions:[n,r],scale:i}=t,a=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:$.#n.getOutlines(n*i,r*i,i,this._INNER_MARGIN),drawingOptions:$.#i,mustBeCommitted:!e});this._cleanup(!0);return a}t.drawLayer.remove(this._currentDrawId);this._cleanup(!0);return null}createDrawingOptions(e){}static deserializeDraw(e,t,n,r,i,a){D(`Not implemented`)}static async deserialize(e,t,n){let{rawDims:{pageWidth:r,pageHeight:i,pageX:a,pageY:o}}=t.viewport,s=this.deserializeDraw(a,o,r,i,this._INNER_MARGIN,e),c=await super.deserialize(e,t,n);c.createDrawingOptions(e);c.#a({drawOutlines:s});c.#c();c.onScaleChanging();c.rotate();return c}serializeDraw(e){let[t,n]=this.pageTranslation,[r,i]=this.pageDimensions;return this.#e.serialize([t,n,r,i],e)}renderAnnotationElement(e){e.updateEdited({rect:this.getPDFRect()});return null}static canCreateNewEmptyEditor(){return!1}}class Cr{#e=new Float64Array(6);#t;#n;#r;#i;#a;#o=``;#s=0;#c=new wr;#l;#u;constructor(e,t,n,r,i,a){this.#l=n;this.#u=r;this.#r=i;this.#i=a;[e,t]=this.#d(e,t);let o=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#a=[e,t];this.#n=[{line:o,points:this.#a}];this.#e.set(o,0)}updateProperty(e,t){e===`stroke-width`&&(this.#i=t)}#d(e,t){return Z._normalizePoint(e,t,this.#l,this.#u,this.#r)}isEmpty(){return!this.#n||this.#n.length===0}isCancellable(){return this.#a.length<=10}add(e,t){[e,t]=this.#d(e,t);let[n,r,i,a]=this.#e.subarray(2,6),o=e-i,s=t-a;if(Math.hypot(this.#l*o,this.#u*s)<=2)return null;this.#a.push(e,t);if(isNaN(n)){this.#e.set([i,a,e,t],2);this.#t.push(NaN,NaN,NaN,NaN,e,t);return{path:{d:this.toSVGPath()}}}isNaN(this.#e[0])&&this.#t.splice(6,6);this.#e.set([n,r,i,a,e,t],0);this.#t.push(...Z.createBezierPoints(n,r,i,a,e,t));return{path:{d:this.toSVGPath()}}}end(e,t){return this.add(e,t)||(this.#a.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,n,r,i){this.#l=n;this.#u=r;this.#r=i;[e,t]=this.#d(e,t);let a=this.#t=[NaN,NaN,NaN,NaN,e,t];this.#a=[e,t];let o=this.#n.at(-1);if(o){o.line=new Float32Array(o.line);o.points=new Float32Array(o.points)}this.#n.push({line:a,points:this.#a});this.#e.set(a,0);this.#s=0;this.toSVGPath();return null}getLastElement(){return this.#n.at(-1)}setLastElement(e){if(!this.#n)return this.#c.setLastElement(e);this.#n.push(e);this.#t=e.line;this.#a=e.points;this.#s=0;return{path:{d:this.toSVGPath()}}}removeLastElement(){if(!this.#n)return this.#c.removeLastElement();this.#n.pop();this.#o=``;for(let e=0,t=this.#n.length;e<t;e++){let{line:t,points:n}=this.#n[e];this.#t=t;this.#a=n;this.#s=0;this.toSVGPath()}return{path:{d:this.#o}}}toSVGPath(){let e=Z.svgRound(this.#t[4]),t=Z.svgRound(this.#t[5]);if(this.#a.length===2){this.#o=`${this.#o} M ${e} ${t} Z`;return this.#o}if(this.#a.length<=6){let n=this.#o.lastIndexOf(`M`);this.#o=`${this.#o.slice(0,n)} M ${e} ${t}`;this.#s=6}if(this.#a.length===4){let e=Z.svgRound(this.#t[10]),t=Z.svgRound(this.#t[11]);this.#o=`${this.#o} L ${e} ${t}`;this.#s=12;return this.#o}let n=[];if(this.#s===0){n.push(`M ${e} ${t}`);this.#s=6}for(let e=this.#s,t=this.#t.length;e<t;e+=6){let[t,r,i,a,o,s]=this.#t.slice(e,e+6).map(Z.svgRound);n.push(`C${t} ${r} ${i} ${a} ${o} ${s}`)}this.#o+=n.join(` `);this.#s=this.#t.length;return this.#o}getOutlines(e,t,n,r){let i=this.#n.at(-1);i.line=new Float32Array(i.line);i.points=new Float32Array(i.points);this.#c.build(this.#n,e,t,n,this.#r,this.#i,r);this.#e=null;this.#t=null;this.#n=null;this.#o=null;return this.#c}get defaultSVGProperties(){return{root:{viewBox:`0 0 10000 10000`},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class wr extends Z{#e;#t=0;#n;#r;#i;#a;#o;#s;#c;build(e,t,n,r,i,a,o){this.#i=t;this.#a=n;this.#o=r;this.#s=i;this.#c=a;this.#n=o??0;this.#r=e;this.#d()}get thickness(){return this.#c}setLastElement(e){this.#r.push(e);return{path:{d:this.toSVGPath()}}}removeLastElement(){this.#r.pop();return{path:{d:this.toSVGPath()}}}toSVGPath(){let e=[];for(let{line:t}of this.#r){e.push(`M${Z.svgRound(t[4])} ${Z.svgRound(t[5])}`);if(t.length!==6){if(t.length===12&&isNaN(t[6]))e.push(`L${Z.svgRound(t[10])} ${Z.svgRound(t[11])}`);else for(let n=6,r=t.length;n<r;n+=6){let[r,i,a,o,s,c]=t.subarray(n,n+6).map(Z.svgRound);e.push(`C${r} ${i} ${a} ${o} ${s} ${c}`)}}else e.push(`Z`)}return e.join(``)}serialize([e,t,n,r],i){let a=[],o=[],[s,c,l,u]=this.#u(),d,f,p,m,h,g,_,v,y;switch(this.#s){case 0:y=Z._rescale;d=e;f=t+r;p=n;m=-r;h=e+s*n;g=t+(1-c-u)*r;_=e+(s+l)*n;v=t+(1-c)*r;break;case 90:y=Z._rescaleAndSwap;d=e;f=t;p=n;m=r;h=e+c*n;g=t+s*r;_=e+(c+u)*n;v=t+(s+l)*r;break;case 180:y=Z._rescale;d=e+n;f=t;p=-n;m=r;h=e+(1-s-l)*n;g=t+c*r;_=e+(1-s)*n;v=t+(c+u)*r;break;case 270:y=Z._rescaleAndSwap;d=e+n;f=t+r;p=-n;m=-r;h=e+(1-c-u)*n;g=t+(1-s-l)*r;_=e+(1-c)*n;v=t+(1-s)*r}for(let{line:e,points:t}of this.#r){a.push(y(e,d,f,p,m,i?Array(e.length):null));o.push(y(t,d,f,p,m,i?Array(t.length):null))}return{lines:a,points:o,rect:[h,g,_,v]}}static deserialize(e,t,n,r,i,{paths:{lines:a,points:o},rotation:s,thickness:c}){let l=[],u,d,f,p,m;switch(s){case 0:m=Z._rescale;u=-e/n;d=t/r+1;f=1/n;p=-1/r;break;case 90:m=Z._rescaleAndSwap;u=-t/r;d=-e/n;f=1/r;p=1/n;break;case 180:m=Z._rescale;u=e/n+1;d=-t/r;f=-1/n;p=1/r;break;case 270:m=Z._rescaleAndSwap;u=t/r+1;d=e/n+1;f=-1/r;p=-1/n}if(!a){a=[];for(let e of o){let t=e.length;if(t===2){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(t===4){a.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}let n=new Float32Array(3*(t-2));a.push(n);let[r,i,o,s]=e.subarray(0,4);n.set([NaN,NaN,NaN,NaN,r,i],0);for(let a=4;a<t;a+=2){let t=e[a],c=e[a+1];n.set(Z.createBezierPoints(r,i,o,s,t,c),3*(a-2));[r,i,o,s]=[o,s,t,c]}}}for(let e=0,t=a.length;e<t;e++)l.push({line:m(a[e].map(e=>e??NaN),u,d,f,p),points:m(o[e].map(e=>e??NaN),u,d,f,p)});let h=new this.prototype.constructor;h.build(l,n,r,1,s,c,i);return h}#l(e=this.#c){let t=this.#n+e/2*this.#o;return this.#s%180==0?[t/this.#i,t/this.#a]:[t/this.#a,t/this.#i]}#u(){let[e,t,n,r]=this.#e,[i,a]=this.#l(0);return[e+i,t+a,n-2*i,r-2*a]}#d(){let e=this.#e=d.slice();for(let{line:t}of this.#r){if(t.length<=12){for(let n=4,r=t.length;n<r;n+=6)P.pointBoundingBox(t[n],t[n+1],e);continue}let n=t[4],r=t[5];for(let i=6,a=t.length;i<a;i+=6){let[a,o,s,c,l,u]=t.subarray(i,i+6);P.bezierBoundingBox(n,r,a,o,s,c,l,u,e);n=l;r=u}}let[t,n]=this.#l();e[0]=F(e[0]-t,0,1);e[1]=F(e[1]-n,0,1);e[2]=F(e[2]+t,0,1);e[3]=F(e[3]+n,0,1);e[2]-=e[0];e[3]-=e[1]}get box(){return this.#e}updateProperty(e,t){return e===`stroke-width`?this.#f(t):null}#f(e){let[t,n]=this.#l();this.#c=e;let[r,i]=this.#l(),[a,o]=[r-t,i-n],s=this.#e;s[0]-=a;s[1]-=o;s[2]+=2*a;s[3]+=2*o;return s}updateParentDimensions([e,t],n){let[r,i]=this.#l();this.#i=e;this.#a=t;this.#o=n;let[a,o]=this.#l(),s=a-r,c=o-i,l=this.#e;l[0]-=s;l[1]-=c;l[2]+=2*s;l[3]+=2*c;return l}updateRotation(e){this.#t=e;return{path:{transform:this.rotationTransform}}}get viewBox(){return this.#e.map(Z.svgRound).join(` `)}get defaultProperties(){let[e,t]=this.#e;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`}}}get rotationTransform(){let[,,e,t]=this.#e,n=0,r=0,i=0,a=0,o=0,s=0;switch(this.#t){case 90:r=t/e;i=-e/t;o=e;break;case 180:n=-1;a=-1;o=e;s=t;break;case 270:r=-t/e;i=e/t;s=t;break;default:return``}return`matrix(${n} ${r} ${i} ${a} ${Z.svgRound(o)} ${Z.svgRound(s)})`}getPathResizingSVGProperties([e,t,n,r]){let[i,a]=this.#l(),[o,s,c,l]=this.#e;if(Math.abs(c-i)<=Z.PRECISION||Math.abs(l-a)<=Z.PRECISION){let i=e+n/2-(o+c/2),a=t+r/2-(s+l/2);return{path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:`${this.rotationTransform} translate(${i} ${a})`}}}let u=(n-2*i)/(c-2*i),d=(r-2*a)/(l-2*a),f=c/n,p=l/r;return{path:{"transform-origin":`${Z.svgRound(o)} ${Z.svgRound(s)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${Z.svgRound(i)} ${Z.svgRound(a)}) scale(${u} ${d}) translate(${Z.svgRound(-i)} ${Z.svgRound(-a)})`}}}getPathResizedSVGProperties([e,t,n,r]){let[i,a]=this.#l(),o=this.#e,[s,c,l,u]=o;o[0]=e;o[1]=t;o[2]=n;o[3]=r;if(Math.abs(l-i)<=Z.PRECISION||Math.abs(u-a)<=Z.PRECISION){let i=e+n/2-(s+l/2),a=t+r/2-(c+u/2);for(let{line:e,points:t}of this.#r){Z._translate(e,i,a,e);Z._translate(t,i,a,t)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let d=(n-2*i)/(l-2*i),f=(r-2*a)/(u-2*a),p=-d*(s+i)+e+i,m=-f*(c+a)+t+a;if(d!==1||f!==1||p!==0||m!==0)for(let{line:e,points:t}of this.#r){Z._rescale(e,p,m,d,f,e);Z._rescale(t,p,m,d,f,t)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],n){let[r,i]=n,a=this.#e,o=e-a[0],s=t-a[1];if(this.#i===r&&this.#a===i)for(let{line:e,points:t}of this.#r){Z._translate(e,o,s,e);Z._translate(t,o,s,t)}else{let e=this.#i/r,t=this.#a/i;this.#i=r;this.#a=i;for(let{line:n,points:r}of this.#r){Z._rescale(n,o,s,e,t,n);Z._rescale(r,o,s,e,t,r)}a[2]*=e;a[3]*=t}a[0]=e;a[1]=t;return{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Z.svgRound(e)} ${Z.svgRound(t)}`}}}get defaultSVGProperties(){let e=this.#e;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Z.svgRound(e[0])} ${Z.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}class Tr extends Sr{constructor(e){super();this._viewParameters=e;super.updateProperties({fill:`none`,stroke:H._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-miterlimit":10})}updateSVGProperty(e,t){if(e===`stroke-width`){t??=this[`stroke-width`];t*=this._viewParameters.realScale}super.updateSVGProperty(e,t)}clone(){let e=new Tr(this._viewParameters);e.updateAll(this);return e}}class Er extends ${static _type=`ink`;static _editorType=_.INK;static _defaultDrawingOptions=null;constructor(e){super({...e,name:`inkEditor`});this._willKeepAspectRatio=!0;this.defaultL10nId=`pdfjs-editor-ink-editor`}static initialize(e,t){H.initialize(e,t);this._defaultDrawingOptions=new Tr(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!0}static get typesMap(){return j(this,`typesMap`,new Map([[v.INK_THICKNESS,`stroke-width`],[v.INK_COLOR,`stroke`],[v.INK_OPACITY,`stroke-opacity`]]))}static createDrawerInstance(e,t,n,r,i){return new Cr(e,t,n,r,i,this._defaultDrawingOptions[`stroke-width`])}static deserializeDraw(e,t,n,r,i,a){return wr.deserialize(e,t,n,r,i,a)}static async deserialize(e,t,n){let r=null;if(e instanceof fr){let{data:{inkLists:t,rect:n,rotation:i,id:a,color:o,opacity:s,borderStyle:{rawWidth:c},popupRef:l,richText:u,contentsObj:d,creationDate:f,modificationDate:p},parent:{page:{pageNumber:m}}}=e;r=e={annotationType:_.INK,color:Array.from(o),thickness:c,opacity:s,paths:{points:t},boxes:null,pageIndex:m-1,rect:n.slice(0),rotation:i,annotationElementId:a,id:a,deleted:!1,popupRef:l,richText:u,comment:d?.str||null,creationDate:f,modificationDate:p}}let i=await super.deserialize(e,t,n);i._initialData=r;e.comment&&i.setCommentData(e);return i}get toolbarButtons(){this._colorPicker||=new er(this);return[[`colorPicker`,this._colorPicker]]}get colorType(){return v.INK_COLOR}get colorAndOpacityType(){return v.INK_COLOR_AND_OPACITY}get opacityType(){return v.INK_OPACITY}updateParams(e,t){e===v.INK_COLOR_AND_OPACITY?this._updateColorAndOpacity(t.color,t.opacity):super.updateParams(e,t)}static updateDefaultParams(e,t){if(e!==v.INK_COLOR_AND_OPACITY)super.updateDefaultParams(e,t);else{super.updateDefaultParams(v.INK_COLOR,t.color);super.updateDefaultParams(v.INK_OPACITY,t.opacity)}}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions[`stroke-opacity`]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:e,_drawingOptions:t,parent:n}=this;t.updateSVGProperty(`stroke-width`);n.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){let e=this._currentParent;if(e){super.onScaleChangingWhenDrawing();this._defaultDrawingOptions.updateSVGProperty(`stroke-width`);e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}createDrawingOptions({color:e,thickness:t,opacity:n}){this._drawingOptions=Er.getDefaultDrawingOptions({stroke:P.makeHexColor(...e),"stroke-width":t,"stroke-opacity":n})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":i,"stroke-width":a}}=this,o=Object.assign(super.serialize(e),{color:H._colorManager.convert(r),opacity:i,thickness:a,paths:{lines:t,points:n}});this.addComment(o);if(e){o.isCopy=!0;return o}if(this.annotationElementId&&!this.#e(o))return null;o.id=this.annotationElementId;return o}#e(e){let{color:t,thickness:n,opacity:r,pageIndex:i}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((e,n)=>e!==t[n])||e.thickness!==n||e.opacity!==r||e.pageIndex!==i}renderAnnotationElement(e){if(this.deleted){e.hide();return null}let{points:t,rect:n}=this.serializeDraw(!1);e.updateEdited({rect:n,thickness:this._drawingOptions[`stroke-width`],points:t,popup:this.comment});return null}}class Dr extends wr{toSVGPath(){let e=super.toSVGPath();e.endsWith(`Z`)||(e+=`Z`);return e}}class Or{static#e={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#t(e,t,n,r){r-=t;return(n-=e)===0?r>0?0:4:n===1?r+6:2-r}static#n=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#r(e,t,n,r,i,a,o){let s=this.#t(n,r,i,a);for(let i=0;i<8;i++){let a=(-i+s-o+16)%8;if(e[(n+this.#n[2*a])*t+(r+this.#n[2*a+1])]!==0)return a}return-1}static#i(e,t,n,r,i,a,o){let s=this.#t(n,r,i,a);for(let i=0;i<8;i++){let a=(i+s+o+16)%8;if(e[(n+this.#n[2*a])*t+(r+this.#n[2*a+1])]!==0)return a}return-1}static#a(e,t,n,r){let i=e.length,a=new Int32Array(i);for(let t=0;t<i;t++)a[t]=+(e[t]<=r);for(let e=1;e<n-1;e++)a[e*t]=a[e*t+t-1]=0;for(let e=0;e<t;e++)a[e]=a[t*n-1-e]=0;let o,s=1,c=[];for(let e=1;e<n-1;e++){o=1;for(let n=1;n<t-1;n++){let r=e*t+n,i=a[r];if(i===0)continue;let l=e,u=n;if(i===1&&a[r-1]===0){s+=1;--u}else{if(!(i>=1&&a[r+1]===0)){i!==1&&(o=Math.abs(i));continue}s+=1;u+=1;i>1&&(o=i)}let d=[n,e],f=u===n+1,p={isHole:f,points:d,id:s,parent:0};c.push(p);let m;for(let e of c)if(e.id===o){m=e;break}p.parent=m?m.isHole?f?m.parent:o:f?o:m.parent:f?o:0;let h=this.#r(a,t,e,n,l,u,0);if(h===-1){a[r]=-s;a[r]!==1&&(o=Math.abs(a[r]));continue}let g=this.#n[2*h],_=this.#n[2*h+1],v=e+g,y=n+_;l=v;u=y;let b=e,x=n;for(;;){let i=this.#i(a,t,b,x,l,u,1);g=this.#n[2*i];_=this.#n[2*i+1];let c=b+g,f=x+_;d.push(f,c);let p=b*t+x;a[p+1]===0?a[p]=-s:a[p]===1&&(a[p]=s);if(c===e&&f===n&&b===v&&x===y){a[r]!==1&&(o=Math.abs(a[r]));break}l=b;u=x;b=c;x=f}}}return c}static#o(e,t,n,r){if(n-t<=4){for(let i=t;i<n-2;i+=2)r.push(e[i],e[i+1]);return}let i=e[t],a=e[t+1],o=e[n-4]-i,s=e[n-3]-a,c=Math.hypot(o,s),l=o/c,u=s/c,d=l*a-u*i,f=s/o,p=1/c,m=Math.atan(f),h=Math.cos(m),g=Math.sin(m),_=p*(Math.abs(h)+Math.abs(g)),v=p*(1-_+_**2),y=Math.max(Math.atan(Math.abs(g+h)*v),Math.atan(Math.abs(g-h)*v)),b=0,x=t;for(let r=t+2;r<n-2;r+=2){let t=Math.abs(d-l*e[r+1]+u*e[r]);if(t>b){x=r;b=t}}if(b>(c*y)**2){this.#o(e,t,x+2,r);this.#o(e,x,n,r)}else r.push(i,a)}static#s(e){let t=[],n=e.length;this.#o(e,0,n,t);t.push(e[n-2],e[n-1]);return t.length<=4?null:t}static#c(e,t,n,r,i,a){let o=new Float32Array(a**2),s=-2*r**2,c=a>>1;for(let e=0;e<a;e++){let t=(e-c)**2;for(let n=0;n<a;n++)o[e*a+n]=Math.exp((t+(n-c)**2)/s)}let l=new Float32Array(256),u=-2*i**2;for(let e=0;e<256;e++)l[e]=Math.exp(e**2/u);let d=e.length,f=new Uint8Array(d),p=new Uint32Array(256);for(let r=0;r<n;r++)for(let i=0;i<t;i++){let s=r*t+i,u=e[s],d=0,m=0;for(let s=0;s<a;s++){let f=r+s-c;if(!(f<0||f>=n))for(let n=0;n<a;n++){let r=i+n-c;if(r<0||r>=t)continue;let p=e[f*t+r],h=o[s*a+n]*l[Math.abs(p-u)];d+=p*h;m+=h}}p[f[s]=Math.round(d/m)]++}return[f,p]}static#l(e){let t=new Uint32Array(256);for(let n of e)t[n]++;return t}static#u(e){let t=e.length,n=new Uint8ClampedArray(t>>2),r=-1/0,i=1/0;for(let t=0,a=n.length;t<a;t++){let a=n[t]=e[t<<2];r=Math.max(r,a);i=Math.min(i,a)}let a=255/(r-i);for(let e=0,t=n.length;e<t;e++)n[e]=(n[e]-i)*a;return n}static#d(e){let t,n=-1/0,r=-1/0,i=e.findIndex(e=>e!==0),a=i,o=i;for(t=i;t<256;t++){let i=e[t];if(i>n){if(t-a>r){r=t-a;o=t-1}n=i;a=t}}for(t=o-1;t>=0&&!(e[t]>e[t+1]);t--);return t}static#f(e){let t=e,{width:n,height:r}=e,{maxDim:i}=this.#e,a=n,o=r;if(n>i||r>i){let s=n,c=r,l=Math.log2(Math.max(n,r)/i),u=Math.floor(l);l=l===u?u-1:u;for(let n=0;n<l;n++){a=Math.ceil(s/2);o=Math.ceil(c/2);let n=new OffscreenCanvas(a,o);n.getContext(`2d`).drawImage(e,0,0,s,c,0,0,a,o);s=a;c=o;e!==t&&e.close();e=n.transferToImageBitmap()}let d=Math.min(i/a,i/o);a=Math.round(a*d);o=Math.round(o*d)}let s=new OffscreenCanvas(a,o).getContext(`2d`,{willReadFrequently:!0});s.fillStyle=`white`;s.fillRect(0,0,a,o);s.filter=`grayscale(1)`;s.drawImage(e,0,0,e.width,e.height,0,0,a,o);let c=s.getImageData(0,0,a,o).data;return[this.#u(c),a,o]}static extractContoursFromText(e,{fontFamily:t,fontStyle:n,fontWeight:r},i,a,o,s){let c=new OffscreenCanvas(1,1),l=c.getContext(`2d`,{alpha:!1}),u=l.font=`${n} ${r} 200px ${t}`,{actualBoundingBoxLeft:d,actualBoundingBoxRight:f,actualBoundingBoxAscent:p,actualBoundingBoxDescent:m,fontBoundingBoxAscent:h,fontBoundingBoxDescent:g,width:_}=l.measureText(e),v=1.5,y=Math.ceil(Math.max(Math.abs(d)+Math.abs(f)||0,_)*v),b=Math.ceil(Math.max(Math.abs(p)+Math.abs(m)||200,Math.abs(h)+Math.abs(g)||200)*v);c=new OffscreenCanvas(y,b);l=c.getContext(`2d`,{alpha:!0,willReadFrequently:!0});l.font=u;l.filter=`grayscale(1)`;l.fillStyle=`white`;l.fillRect(0,0,y,b);l.fillStyle=`black`;l.fillText(e,.5*y/2,1.5*b/2);let x=this.#u(l.getImageData(0,0,y,b).data),S=this.#l(x),C=this.#d(S),w=this.#a(x,y,b,C);return this.processDrawnLines({lines:{curves:w,width:y,height:b},pageWidth:i,pageHeight:a,rotation:o,innerMargin:s,mustSmooth:!0,areContours:!0})}static process(e,t,n,r,i){let[a,o,s]=this.#f(e),[c,l]=this.#c(a,o,s,Math.hypot(o,s)*this.#e.sigmaSFactor,this.#e.sigmaR,this.#e.kernelSize),u=this.#d(l),d=this.#a(c,o,s,u);return this.processDrawnLines({lines:{curves:d,width:o,height:s},pageWidth:t,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:e,pageWidth:t,pageHeight:n,rotation:r,innerMargin:i,mustSmooth:a,areContours:o}){r%180!=0&&([t,n]=[n,t]);let{curves:s,width:c,height:l}=e,u=e.thickness??0,d=[],f=Math.min(t/c,n/l),p=f/t,m=f/n,h=[];for(let{points:e}of s){let t=a?this.#s(e):e;if(!t)continue;h.push(t);let n=t.length,r=new Float32Array(n),i=new Float32Array(3*(n===2?2:n-2));d.push({line:i,points:r});if(n===2){r[0]=t[0]*p;r[1]=t[1]*m;i.set([NaN,NaN,NaN,NaN,r[0],r[1]],0);continue}let[o,s,c,l]=t;o*=p;s*=m;c*=p;l*=m;r.set([o,s,c,l],0);i.set([NaN,NaN,NaN,NaN,o,s],0);for(let e=4;e<n;e+=2){let n=r[e]=t[e]*p,a=r[e+1]=t[e+1]*m;i.set(Z.createBezierPoints(o,s,c,l,n,a),3*(e-2));[o,s,c,l]=[c,l,n,a]}}if(d.length===0)return null;let g=o?new Dr:new wr;g.build(d,t,n,1,r,o?0:u,i);return{outline:g,newCurves:h,areContours:o,thickness:u,width:c,height:l}}static async compressSignature({outlines:e,areContours:t,thickness:n,width:r,height:i}){let a,o=1/0,s=-1/0,c=0;for(let t of e){c+=t.length;for(let e=2,n=t.length;e<n;e++){let n=t[e]-t[e-2];o=Math.min(o,n);s=Math.max(s,n)}}a=o>=-128&&s<=127?Int8Array:o>=-32768&&s<=32767?Int16Array:Int32Array;let l=e.length,u=8+3*l,d=new Uint32Array(u),f=0;d[f++]=u*Uint32Array.BYTES_PER_ELEMENT+(c-2*l)*a.BYTES_PER_ELEMENT;d[f++]=0;d[f++]=r;d[f++]=i;d[f++]=+!t;d[f++]=Math.max(0,Math.floor(n??0));d[f++]=l;d[f++]=a.BYTES_PER_ELEMENT;for(let t of e){d[f++]=t.length-2;d[f++]=t[0];d[f++]=t[1]}let p=new CompressionStream(`deflate-raw`),m=p.writable.getWriter();await m.ready;m.write(d);let h=a.prototype.constructor;for(let t of e){let e=new h(t.length-2);for(let n=2,r=t.length;n<r;n++)e[n-2]=t[n]-t[n-2];m.write(e)}m.close();return(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(e){try{let t=Uint8Array.fromBase64(e),{readable:n,writable:r}=new DecompressionStream(`deflate-raw`),i=r.getWriter();await i.ready;i.write(t).then(async()=>{await i.ready;await i.close()}).catch(()=>{});let a=null,o=0;for await(let e of n){a||=new Uint8Array(new Uint32Array(e.buffer,0,4)[0]);a.set(e,o);o+=e.length}let s=new Uint32Array(a.buffer,0,a.length>>2),c=s[1];if(c!==0)throw Error(`Invalid version: ${c}`);let l=s[2],u=s[3],d=s[4]===0,f=s[5],p=s[6],m=s[7],h=[],g=(8+3*p)*Uint32Array.BYTES_PER_ELEMENT,_;switch(m){case Int8Array.BYTES_PER_ELEMENT:_=new Int8Array(a.buffer,g);break;case Int16Array.BYTES_PER_ELEMENT:_=new Int16Array(a.buffer,g);break;case Int32Array.BYTES_PER_ELEMENT:_=new Int32Array(a.buffer,g)}o=0;for(let e=0;e<p;e++){let t=s[3*e+8],n=new Float32Array(t+2);h.push(n);for(let t=0;t<2;t++)n[t]=s[3*e+8+t+1];for(let e=0;e<t;e++)n[e+2]=n[e]+_[o++]}return{areContours:d,thickness:f,outlines:h,width:l,height:u}}catch(e){E(`decompressSignature: ${e}`);return null}}}class kr extends Sr{constructor(){super();super.updateProperties({fill:H._defaultLineColor,"stroke-width":0})}clone(){let e=new kr;e.updateAll(this);return e}}class Ar extends Tr{constructor(e){super(e);super.updateProperties({stroke:H._defaultLineColor,"stroke-width":1})}clone(){let e=new Ar(this._viewParameters);e.updateAll(this);return e}}class jr extends ${#e=!1;#t=null;#n=null;#r=null;static _type=`signature`;static _editorType=_.SIGNATURE;static _defaultDrawingOptions=null;constructor(e){super({...e,mustBeCommitted:!0,name:`signatureEditor`});this._willKeepAspectRatio=!0;this.#n=e.signatureData||null;this.#t=null;this.defaultL10nId=`pdfjs-editor-signature-editor1`}static initialize(e,t){H.initialize(e,t);this._defaultDrawingOptions=new kr;this._defaultDrawnSignatureOptions=new Ar(t.viewParameters)}static getDefaultDrawingOptions(e){let t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!1}static get typesMap(){return j(this,`typesMap`,new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:`signature`,hasDescription:!!this.#t}}static computeTelemetryFinalData(e){let t=e.get(`hasDescription`);return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,t,{_isCopy:n}=this;if(n){this._isCopy=!1;e=this.x;t=this.y}super.render();if(this._drawId===null){if(this.#n){let{lines:e,mustSmooth:t,areContours:n,description:r,uuid:i,heightInPage:a}=this.#n,{rawDims:{pageWidth:o,pageHeight:s},rotation:c}=this.parent.viewport,l=Or.processDrawnLines({lines:e,pageWidth:o,pageHeight:s,rotation:c,innerMargin:jr._INNER_MARGIN,mustSmooth:t,areContours:n});this.addSignature(l,a,r,i)}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.#t||``}));if(n){this._isCopy=!0;this._moveAfterPaste(e,t)}return this.div}setUuid(e){this.#r=e;this.addEditToolbar()}getUuid(){return this.#r}get description(){return this.#t}set description(e){this.#t=e;if(this.div){this.div.setAttribute(`data-l10n-args`,JSON.stringify({description:e}));super.addEditToolbar().then(t=>{t?.updateEditSignatureButton(e)})}}getSignaturePreview(){let{newCurves:e,areContours:t,thickness:n,width:r,height:i}=this.#n,a=Math.max(r,i);return{areContours:t,outline:Or.processDrawnLines({lines:{curves:e.map(e=>({points:e})),thickness:n,width:r,height:i},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:t}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[[`editSignature`,this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,t,n,r){let{x:i,y:a}=this,{outline:o}=this.#n=e;this.#e=o instanceof Dr;this.description=n;let s;if(this.#e)s=jr.getDefaultDrawingOptions();else{s=jr._defaultDrawnSignatureOptions.clone();s.updateProperties({"stroke-width":o.thickness})}this._addOutlines({drawOutlines:o,drawingOptions:s});let[,c]=this.pageDimensions,l=t/c;l=l>=1?.5:l;this.width*=l/this.height;if(this.width>=1){l*=.9/this.width;this.width=.9}this.height=l;this.setDims();this.x=i;this.y=a;this.center();this._onResized();this.onScaleChanging();this.rotate();this._uiManager.addToAnnotationStorage(this);this.setUuid(r);this._reportTelemetry({action:`pdfjs.signature.inserted`,data:{hasBeenSaved:!!r,hasDescription:!!n}});this.div.hidden=!1}getFromImage(e){let{rawDims:{pageWidth:t,pageHeight:n},rotation:r}=this.parent.viewport;return Or.process(e,t,n,r,jr._INNER_MARGIN)}getFromText(e,t){let{rawDims:{pageWidth:n,pageHeight:r},rotation:i}=this.parent.viewport;return Or.extractContoursFromText(e,t,n,r,i,jr._INNER_MARGIN)}getDrawnSignature(e){let{rawDims:{pageWidth:t,pageHeight:n},rotation:r}=this.parent.viewport;return Or.processDrawnLines({lines:e,pageWidth:t,pageHeight:n,rotation:r,innerMargin:jr._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:t}){if(e)this._drawingOptions=jr.getDefaultDrawingOptions();else{this._drawingOptions=jr._defaultDrawnSignatureOptions.clone();this._drawingOptions.updateProperties({"stroke-width":t})}}serialize(e=!1){if(this.isEmpty())return null;let{lines:t,points:n}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,i=Object.assign(super.serialize(e),{isSignature:!0,areContours:this.#e,color:[0,0,0],thickness:this.#e?0:r});this.addComment(i);if(e){i.paths={lines:t,points:n};i.uuid=this.#r;i.isCopy=!0}else i.lines=t;this.#t&&(i.accessibilityData={type:`Figure`,alt:this.#t});return i}static deserializeDraw(e,t,n,r,i,a){return a.areContours?Dr.deserialize(e,t,n,r,i,a):wr.deserialize(e,t,n,r,i,a)}static async deserialize(e,t,n){let r=await super.deserialize(e,t,n);r.#e=e.areContours;r.description=e.accessibilityData?.alt||``;r.#r=e.uuid;return r}}class Mr extends H{#e=null;#t=null;#n=null;#r=null;#i=null;#a=``;#o=null;#s=!1;#c=null;#l=!1;#u=!1;static _type=`stamp`;static _editorType=_.STAMP;constructor(e){super({...e,name:`stampEditor`});this.#r=e.bitmapUrl;this.#i=e.bitmapFile;this.defaultL10nId=`pdfjs-editor-stamp-editor`}static initialize(e,t){H.initialize(e,t)}static isHandlingMimeForPasting(e){return Ee.includes(e)}static paste(e,t){t.pasteEditor({mode:_.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1);super.altTextFinish()}get telemetryFinalData(){return{type:`stamp`,hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){let t=e.get(`hasAltText`);return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}#d(e,t=!1){if(e){this.#e=e.bitmap;if(!t){this.#t=e.id;this.#l=e.isSvg}e.file&&(this.#a=e.file.name);this.#m()}else this.remove()}#f(){this.#n=null;this._uiManager.enableWaiting(!1);if(this.#o){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e)this.addEditToolbar().then(()=>{this._editToolbar.hide();this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#e){this._reportTelemetry({action:`pdfjs.image.image_added`,data:{alt_text_modal:!1,alt_text_type:`empty`}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}}async mlGuessAltText(e=null,t=!0){if(this.hasAltTextData())return null;let{mlManager:n}=this._uiManager;if(!n)throw Error(`No ML.`);if(!await n.isEnabledFor(`altText`))throw Error(`ML isn't enabled for alt text.`);let{data:r,width:i,height:a}=e||this.copyCanvas(null,null,!0).imageData,o=await n.guess({name:`altText`,request:{data:r,width:i,height:a,channels:r.length/(i*a)}});if(!o)throw Error(`No response from the AI service.`);if(o.error)throw Error(`Error from the AI service.`);if(o.cancel)return null;if(!o.output)throw Error(`No valid response from the AI service.`);let s=o.output;await this.setGuessedAltText(s);t&&!this.hasAltTextData()&&(this.altTextData={alt:s,decorative:!1});return s}#p(){if(this.#t){this._uiManager.enableWaiting(!0);this._uiManager.imageManager.getFromId(this.#t).then(e=>this.#d(e,!0)).finally(()=>this.#f());return}if(this.#r){let e=this.#r;this.#r=null;this._uiManager.enableWaiting(!0);this.#n=this._uiManager.imageManager.getFromUrl(e).then(e=>this.#d(e)).finally(()=>this.#f());return}if(this.#i){let e=this.#i;this.#i=null;this._uiManager.enableWaiting(!0);this.#n=this._uiManager.imageManager.getFromFile(e).then(e=>this.#d(e)).finally(()=>this.#f());return}let e=document.createElement(`input`);e.type=`file`;e.accept=Ee.join(`,`);let t=this._uiManager._signal;this.#n=new Promise(n=>{e.addEventListener(`change`,async()=>{if(e.files&&e.files.length!==0){this._uiManager.enableWaiting(!0);let t=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:`pdfjs.image.image_selected`,data:{alt_text_modal:this._uiManager.useNewAltTextFlow}});this.#d(t)}else this.remove();n()},{signal:t});e.addEventListener(`cancel`,()=>{this.remove();n()},{signal:t})}).finally(()=>this.#f());e.click()}remove(){if(this.#t){this.#e=null;this._uiManager.imageManager.deleteId(this.#t);this.#o?.remove();this.#o=null;if(this.#c){clearTimeout(this.#c);this.#c=null}}super.remove()}rebuild(){if(this.parent){super.rebuild();if(this.div!==null){this.#t&&this.#o===null&&this.#p();this.isAttachedToDOM||this.parent.add(this)}}else this.#t&&this.#p()}onceAdded(e){this._isDraggable=!0;e&&this.div.focus()}isEmpty(){return!(this.#n||this.#e||this.#r||this.#i||this.#t||this.#s)}get toolbarButtons(){return[[`altText`,this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}super.render();this.div.hidden=!0;this.createAltText();this.#s||(this.#e?this.#m():this.#p());this._isCopy&&this._moveAfterPaste(e,t);this._uiManager.addShouldRescale(this);return this.div}setCanvas(e,t){let{id:n,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,t);t.remove();if(n&&this._uiManager.imageManager.isValidId(n)){this.#t=n;r&&(this.#e=r);this.#s=!1;this.#m()}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#c!==null&&clearTimeout(this.#c);this.#c=setTimeout(()=>{this.#c=null;this.#g()},200)}#m(){let{div:e}=this,{width:t,height:n}=this.#e,[r,i]=this.pageDimensions,a=.75;if(this.width){t=this.width*r;n=this.height*i}else if(t>a*r||n>a*i){let e=Math.min(a*r/t,a*i/n);t*=e;n*=e}this._uiManager.enableWaiting(!1);let o=this.#o=document.createElement(`canvas`);o.setAttribute(`role`,`img`);this.addContainer(o);this.width=t/r;this.height=n/i;this.setDims();this._initialOptions?.isCentered?this.center():this.fixAndSetPosition();this._initialOptions=null;this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1);this.#g();if(!this.#u){this.parent.addUndoableEditor(this);this.#u=!0}this._reportTelemetry({action:`inserted_image`});this.#a&&this.div.setAttribute(`aria-description`,this.#a);this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert.stamp)}copyCanvas(e,t,n=!1){e||=224;let{width:r,height:i}=this.#e,a=new Te,o=this.#e,s=r,c=i,l=null;if(t){if(r>t||i>t){let e=Math.min(t/r,t/i);s=Math.floor(r*e);c=Math.floor(i*e)}l=document.createElement(`canvas`);let e=l.width=Math.ceil(s*a.sx),n=l.height=Math.ceil(c*a.sy);this.#l||(o=this.#h(e,n));let u=l.getContext(`2d`);u.filter=this._uiManager.hcmFilter;let d=`white`,f=`#cfcfd8`;if(this._uiManager.hcmFilter!==`none`)f=`black`;else if(De.isDarkMode){d=`#8f8f9d`;f=`#42414d`}let p=15*a.sx,m=15*a.sy,h=new OffscreenCanvas(2*p,2*m),g=h.getContext(`2d`);g.fillStyle=d;g.fillRect(0,0,2*p,2*m);g.fillStyle=f;g.fillRect(0,0,p,m);g.fillRect(p,m,p,m);u.fillStyle=u.createPattern(h,`repeat`);u.fillRect(0,0,e,n);u.drawImage(o,0,0,o.width,o.height,0,0,e,n)}let u=null;if(n){let t,n;if(a.symmetric&&o.width<e&&o.height<e){t=o.width;n=o.height}else{o=this.#e;if(r>e||i>e){let a=Math.min(e/r,e/i);t=Math.floor(r*a);n=Math.floor(i*a);this.#l||(o=this.#h(t,n))}}let s=new OffscreenCanvas(t,n).getContext(`2d`,{willReadFrequently:!0});s.drawImage(o,0,0,o.width,o.height,0,0,t,n);u={width:t,height:n,data:s.getImageData(0,0,t,n).data}}return{canvas:l,width:s,height:c,imageData:u}}#h(e,t){let{width:n,height:r}=this.#e,i=n,a=r,o=this.#e;for(;i>2*e||a>2*t;){let n=i,r=a;i>2*e&&(i=Math.ceil(i/2));a>2*t&&(a=Math.ceil(a/2));let s=new OffscreenCanvas(i,a);s.getContext(`2d`).drawImage(o,0,0,n,r,0,0,i,a);o=s.transferToImageBitmap()}return o}#g(){let[e,t]=this.parentDimensions,{width:n,height:r}=this,i=new Te,a=Math.ceil(n*e*i.sx),o=Math.ceil(r*t*i.sy),s=this.#o;if(!s||s.width===a&&s.height===o)return;s.width=a;s.height=o;let c=this.#l?this.#e:this.#h(a,o),l=s.getContext(`2d`);l.filter=this._uiManager.hcmFilter;l.drawImage(c,0,0,c.width,c.height,0,0,a,o)}#_(e){if(e){if(this.#l){let e=this._uiManager.imageManager.getSvgUrl(this.#t);if(e)return e}let e=document.createElement(`canvas`);({width:e.width,height:e.height}=this.#e);e.getContext(`2d`).drawImage(this.#e,0,0);return e.toDataURL()}if(this.#l){let[e,t]=this.pageDimensions,n=Math.round(this.width*e*pe.PDF_TO_CSS_UNITS),r=Math.round(this.height*t*pe.PDF_TO_CSS_UNITS),i=new OffscreenCanvas(n,r);i.getContext(`2d`).drawImage(this.#e,0,0,this.#e.width,this.#e.height,0,0,n,r);return i.transferToImageBitmap()}return structuredClone(this.#e)}static async deserialize(e,t,n){let r=null,i=!1;if(e instanceof mr){let{data:{rect:a,rotation:o,id:s,structParent:c,popupRef:l,richText:u,contentsObj:d,creationDate:f,modificationDate:p},container:m,parent:{page:{pageNumber:g}},canvas:v}=e,y,b;if(v){delete e.canvas;({id:y,bitmap:b}=n.imageManager.getFromCanvas(m.id,v));v.remove()}else{i=!0;e._hasNoCanvas=!0}let x=(await t._structTree.getAriaAttributes(`${h}${s}`))?.get(`aria-label`)||``;r=e={annotationType:_.STAMP,bitmapId:y,bitmap:b,pageIndex:g-1,rect:a.slice(0),rotation:o,annotationElementId:s,id:s,deleted:!1,accessibilityData:{decorative:!1,altText:x},isSvg:!1,structParent:c,popupRef:l,richText:u,comment:d?.str||null,creationDate:f,modificationDate:p}}let a=await super.deserialize(e,t,n),{rect:o,bitmap:s,bitmapUrl:c,bitmapId:l,isSvg:u,accessibilityData:d}=e;if(i){n.addMissingCanvas(e.id,a);a.#s=!0}else if(l&&n.imageManager.isValidId(l)){a.#t=l;s&&(a.#e=s)}else a.#r=c;a.#l=u;let[f,p]=a.pageDimensions;a.width=(o[2]-o[0])/f;a.height=(o[3]-o[1])/p;d&&(a.altTextData=d);a._initialData=r;e.comment&&a.setCommentData(e);a.#u=!!r;return a}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let n=Object.assign(super.serialize(e),{bitmapId:this.#t,isSvg:this.#l});this.addComment(n);if(e){n.bitmapUrl=this.#_(!0);n.accessibilityData=this.serializeAltText(!0);n.isCopy=!0;return n}let{decorative:r,altText:i}=this.serializeAltText(!1);!r&&i&&(n.accessibilityData={type:`Figure`,alt:i});if(this.annotationElementId){let e=this.#v(n);if(e.isSame)return null;e.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1;n.id=this.annotationElementId;delete n.bitmapId;return n}if(t===null)return n;t.stamps||=new Map;let a=this.#l?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(t.stamps.has(this.#t)){if(this.#l){let e=t.stamps.get(this.#t);if(a>e.area){e.area=a;e.serialized.bitmap.close();e.serialized.bitmap=this.#_(!1)}}}else{t.stamps.set(this.#t,{area:a,serialized:n});n.bitmap=this.#_(!1)}return n}#v(e){let{pageIndex:t,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===t,i=(e.accessibilityData?.alt||``)===n;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&i,isSameAltText:i}}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}}class Nr{#e;#t=!1;#n=null;#r=null;#i=null;#a=new Map;#o=!1;#s=!1;#c=!1;#l=null;#u=null;#d=null;#f=null;#p=null;#m=-1;#h;static _initialized=!1;static#g=new Map([X,Er,Mr,Q,jr].map(e=>[e._editorType,e]));constructor({uiManager:e,pageIndex:t,div:n,structTreeLayer:r,accessibilityManager:i,annotationLayer:a,drawLayer:o,textLayer:s,viewport:c,l10n:l}){let u=[...Nr.#g.values()];if(!Nr._initialized){Nr._initialized=!0;for(let t of u)t.initialize(l,e)}e.registerEditorTypes(u);this.#h=e;this.pageIndex=t;this.div=n;this.#e=i;this.#n=a;this.viewport=c;this.#d=s;this.drawLayer=o;this._structTree=r;this.#h.addLayer(this)}get isEmpty(){return this.#a.size===0}get isInvisible(){return this.isEmpty&&this.#h.getMode()===_.NONE}updateToolbar(e){this.#h.updateToolbar(e)}updateMode(e=this.#h.getMode()){this.#S();switch(e){case _.NONE:this.div.classList.toggle(`nonEditing`,!0);this.disableTextSelection();this.togglePointerEvents(!1);this.toggleAnnotationLayerPointerEvents(!0);this.disableClick();return;case _.INK:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick();break;case _.HIGHLIGHT:this.enableTextSelection();this.togglePointerEvents(!1);this.disableClick();break;default:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:t}=this.div;t.toggle(`nonEditing`,!1);if(e===_.POPUP)t.toggle(`commentEditing`,!0);else{t.toggle(`commentEditing`,!1);for(let n of Nr.#g.values())t.toggle(`${n._type}Editing`,e===n._editorType)}this.div.hidden=!1}hasTextLayer(e){return e===this.#d?.div}setEditingState(e){this.#h.setEditingState(e)}addCommands(e){this.#h.addCommands(e)}cleanUndoStack(e){this.#h.cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle(`drawing`,!e)}togglePointerEvents(e=!1){this.div.classList.toggle(`disabled`,!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#n?.togglePointerEvents(e)}get#_(){return this.#a.size===0?this.#h.getEditors(this.pageIndex):this.#a.values()}async enable(){this.#c=!0;this.div.tabIndex=0;this.togglePointerEvents(!0);this.div.classList.toggle(`nonEditing`,!1);this.#p?.abort();this.#p=null;let e=new Set;for(let t of this.#_){t.enableEditing();t.show(!0);if(t.annotationElementId){this.#h.removeChangedExistingAnnotation(t);e.add(t.annotationElementId)}}let t=this.#n;if(t)for(let n of t.getEditableAnnotations()){n.hide();if(this.#h.isDeletedAnnotationElement(n.data.id))continue;if(e.has(n.data.id))continue;let t=await this.deserialize(n);if(t){this.addOrRebuild(t);t.enableEditing()}}this.#c=!1;this.#h._eventBus.dispatch(`editorsrendered`,{source:this,pageNumber:this.pageIndex+1})}disable(){this.#s=!0;this.div.tabIndex=-1;this.togglePointerEvents(!1);this.div.classList.toggle(`nonEditing`,!0);if(this.#d&&!this.#p){this.#p=new AbortController;let e=this.#h.combinedSignal(this.#p);this.#d.div.addEventListener(`pointerdown`,e=>{let{clientX:t,clientY:n,timeStamp:r}=e;if(r-this.#m>500){this.#m=r;return}this.#m=-1;let{classList:i}=this.div;i.toggle(`getElements`,!0);let a=document.elementsFromPoint(t,n);i.toggle(`getElements`,!1);if(!this.div.contains(a[0]))return;let o,s=RegExp(`^${g}[0-9]+$`);for(let e of a)if(s.test(e.id)){o=e.id;break}if(!o)return;let c=this.#a.get(o);if(c?.annotationElementId===null){R(e);c.dblclick(e)}},{signal:e,capture:!0})}let e=this.#n,t=[];if(e){let n=new Map,r=new Map;for(let e of this.#_){e.disableEditing();if(e.annotationElementId){if(e.serialize()===null){r.set(e.annotationElementId,e);this.getEditableAnnotation(e.annotationElementId)?.show();e.remove()}else n.set(e.annotationElementId,e)}else t.push(e)}for(let t of e.getEditableAnnotations()){let{id:e}=t.data;if(this.#h.isDeletedAnnotationElement(e)){t.updateEdited({deleted:!0});continue}let i=r.get(e);if(i){i.resetAnnotationElement(t);i.show(!1);t.show()}else{i=n.get(e);if(i){this.#h.addChangedExistingAnnotation(i);i.renderAnnotationElement(t)&&i.show(!1)}t.show()}}}this.#S();this.isEmpty&&(this.div.hidden=!0);let{classList:n}=this.div;for(let e of Nr.#g.values())n.remove(`${e._type}Editing`);this.disableTextSelection();this.toggleAnnotationLayerPointerEvents(!0);e?.updateFakeAnnotations(t);this.#s=!1}getEditableAnnotation(e){return this.#n?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#h.getActive()!==e&&this.#h.setActiveEditor(e)}enableTextSelection(){this.div.tabIndex=-1;if(this.#d?.div&&!this.#f){this.#f=new AbortController;let e=this.#h.combinedSignal(this.#f);this.#d.div.addEventListener(`pointerdown`,this.#v.bind(this),{signal:e});this.#d.div.classList.add(`highlighting`)}}disableTextSelection(){this.div.tabIndex=0;if(this.#d?.div&&this.#f){this.#f.abort();this.#f=null;this.#d.div.classList.remove(`highlighting`)}}#v(e){this.#h.unselectAll();let{target:t}=e;if(t===this.#d.div||(t.getAttribute(`role`)===`img`||t.classList.contains(`endOfContent`)||t.classList.contains(`textLayerImages`)||t.classList.contains(`textLayerImagePlaceholder`))&&this.#d.div.contains(t)){let{isMac:t}=N.platform;if(e.button!==0||e.ctrlKey&&t)return;this.#h.showAllEditors(`highlight`,!0,!0);this.#d.div.classList.add(`free`);this.toggleDrawing();Q.startHighlighting(this,this.#h.direction===`ltr`,{target:this.#d.div,x:e.x,y:e.y});this.#d.div.addEventListener(`pointerup`,()=>{this.#d.div.classList.remove(`free`);this.toggleDrawing(!0)},{once:!0,signal:this.#h._signal});e.preventDefault()}}enableClick(){if(this.#r)return;this.#r=new AbortController;let e=this.#h.combinedSignal(this.#r);this.div.addEventListener(`pointerdown`,this.pointerdown.bind(this),{signal:e});let t=this.pointerup.bind(this);this.div.addEventListener(`pointerup`,t,{signal:e});this.div.addEventListener(`pointercancel`,t,{signal:e})}disableClick(){this.#r?.abort();this.#r=null}attach(e){this.#a.set(e.id,e);let{annotationElementId:t}=e;t&&this.#h.isDeletedAnnotationElement(t)&&this.#h.removeDeletedAnnotationElement(e)}detach(e){this.#a.delete(e.id);this.#e?.removePointerInTextLayer(e.contentDiv);!this.#s&&e.annotationElementId&&this.#h.addDeletedAnnotationElement(e)}remove(e){this.detach(e);this.#h.removeEditor(e);e.div.remove();e.isAttachedToDOM=!1}changeParent(e){if(e.parent!==this){if(e.parent&&e.annotationElementId){this.#h.addDeletedAnnotationElement(e);H.deleteAnnotationElement(e);e.annotationElementId=null}this.attach(e);e.parent?.detach(e);e.setParent(this);if(e.div&&e.isAttachedToDOM){e.div.remove();this.div.append(e.div)}}}add(e){if(e.parent!==this||!e.isAttachedToDOM){this.changeParent(e);this.#h.addEditor(e);this.attach(e);if(!e.isAttachedToDOM){let t=e.render();this.div.append(t);e.isAttachedToDOM=!0}e.fixAndSetPosition();e.onceAdded(!this.#c);this.#h.addToAnnotationStorage(e);e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;let{activeElement:t}=document;if(e.div.contains(t)&&!this.#i){e._focusEventsAllowed=!1;this.#i=setTimeout(()=>{this.#i=null;if(e.div.contains(document.activeElement))e._focusEventsAllowed=!0;else{e.div.addEventListener(`focusin`,()=>{e._focusEventsAllowed=!0},{once:!0,signal:this.#h._signal});t.focus()}},0)}e._structTreeParentId=this.#e?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){if(e.needsToBeRebuilt()){e.parent||=this;e.rebuild();e.show()}else this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getEditorByUID(e){for(let t of this.#a.values())if(t.uid===e)return t;return null}get#y(){return Nr.#g.get(this.#h.getMode())}combinedSignal(e){return this.#h.combinedSignal(e)}#b(e){let t=this.#y;return t?new t.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#y?.canCreateNewEmptyEditor()}async pasteEditor(e,t){this.updateToolbar(e);await this.#h.updateMode(e.mode);let{offsetX:n,offsetY:r}=this.#x(),i=this.#h.getId(),a=this.#b({parent:this,id:i,x:n,y:r,uiManager:this.#h,isCentered:!0,...t});a&&this.add(a)}async deserialize(e){return await Nr.#g.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#h)||null}createAndAddNewEditor(e,t,n={}){let r=this.#h.getId(),i=this.#b({parent:this,id:r,x:e.offsetX,y:e.offsetY,uiManager:this.#h,isCentered:t,...n});i&&this.add(i);return i}get boundingClientRect(){return this.div.getBoundingClientRect()}#x(){let{x:e,y:t,width:n,height:r}=this.boundingClientRect,i=Math.max(0,e),a=Math.max(0,t),o=(i+Math.min(window.innerWidth,e+n))/2-e,s=(a+Math.min(window.innerHeight,t+r))/2-t,[c,l]=this.viewport.rotation%180==0?[o,s]:[s,o];return{offsetX:c,offsetY:l}}addNewEditor(e={}){this.createAndAddNewEditor(this.#x(),!0,e)}setSelected(e){this.#h.setSelected(e)}toggleSelected(e){this.#h.toggleSelected(e)}unselect(e){this.#h.unselect(e)}pointerup(e){let{isMac:t}=N.platform;if(e.button!==0||e.ctrlKey&&t)return;if(e.target!==this.div)return;if(!this.#o)return;this.#o=!1;if(this.#y?.isDrawer&&this.#y.supportMultipleDrawings)return;if(!this.#t){this.#t=!0;return}let n=this.#h.getMode();n!==_.STAMP&&n!==_.POPUP&&n!==_.SIGNATURE?this.createAndAddNewEditor(e,!1):this.#h.unselectAll()}pointerdown(e){this.#h.getMode()===_.HIGHLIGHT&&this.enableTextSelection();if(this.#o){this.#o=!1;return}let{isMac:t}=N.platform;if(e.button!==0||e.ctrlKey&&t)return;if(e.target!==this.div)return;this.#o=!0;if(this.#y?.isDrawer){this.startDrawingSession(e);return}let n=this.#h.getActive();this.#t=!n||n.isEmpty()}startDrawingSession(e){this.div.focus({preventScroll:!0});if(this.#l){this.#y.startDrawing(this,this.#h,!1,e);return}this.#h.setCurrentDrawingSession(this);this.#l=new AbortController;let t=this.#h.combinedSignal(this.#l);this.div.addEventListener(`blur`,({relatedTarget:e})=>{if(e&&!this.div.contains(e)){this.#u=null;this.commitOrRemove()}},{signal:t});this.#y.startDrawing(this,this.#h,!1,e)}pause(e){if(e){let{activeElement:e}=document;this.div.contains(e)&&(this.#u=e);return}this.#u&&setTimeout(()=>{this.#u?.focus();this.#u=null},0)}endDrawingSession(e=!1){if(!this.#l)return null;this.#h.setCurrentDrawingSession(null);this.#l.abort();this.#l=null;this.#u=null;return this.#y.endDrawing(e)}findNewParent(e,t,n){let r=this.#h.findParent(t,n);if(r===null||r===this)return!1;r.changeParent(e);return!0}commitOrRemove(){if(this.#l){this.endDrawingSession();return!0}return!1}onScaleChanging(){this.#l&&this.#y.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove();if(this.#h.getActive()?.parent===this){this.#h.commitOrRemove();this.#h.setActiveEditor(null)}if(this.#i){clearTimeout(this.#i);this.#i=null}for(let e of this.#a.values()){this.#e?.removePointerInTextLayer(e.contentDiv);e.setParent(null);e.isAttachedToDOM=!1;e.div.remove()}this.div=null;this.#a.clear();this.#h.removeLayer(this)}#S(){for(let e of this.#a.values())e.isEmpty()&&e.remove()}async render({viewport:e}){this.viewport=e;we(this.div,e);for(let e of this.#h.getEditors(this.pageIndex)){this.add(e);e.rebuild()}await this.#h.findClonesForPage(this);this.div.hidden=this.isEmpty;this.updateMode()}update({viewport:e}){this.#h.commitOrRemove();this.#S();let t=this.viewport.rotation,n=e.rotation;this.viewport=e;we(this.div,{rotation:n});if(t!==n)for(let e of this.#a.values())e.rotate(n)}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return this.#h.viewParameters.realScale}}globalThis._pdfjsTestingUtils={HighlightOutliner:vr};const Pr={fonts:globalThis.fonts,createElement(e){if(e.toLowerCase()===`canvas`)return new OffscreenCanvas(1,1);return null}};class Fr{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(s,c={}){let[{data:l},u]=await Promise.all([t(s.url,{responseType:`array-buffer`,signal:c?.signal}),this._getPDFWorker(c)]),d=Kn({data:l,wasmUrl:e(`esri/libs/pdfjs/wasm/`),ownerDocument:Pr,enableHWA:!0,useWorkerFetch:!0,worker:u,useWasm:!0,verbosity:0});try{this._pdfDocument=await d.promise;r(c);let e=this._pdfDocument.numPages,t=s.page??1,l=e;if(!Number.isInteger(t)||t<1||t>e)throw new n(`geospatial-pdf-layer:load`,`Invalid PDF page number.`);for(let e=t;e<=l;e++){r(c);let t=await this._pdfDocument.getPage(e),n=!1;try{r(c);let e=await t.getGeospatialPDFMetadata();r(c);if(e.LGIDict==null&&e.VP==null)continue;this._page=t;this._geospatialMetadata=e;n=!0;break}finally{n||t.cleanup()}}if(!this._page||!this._geospatialMetadata)throw new n(`geospatial-pdf-layer:load`,`pdf does not contain supported LGIDict or VP/Measure.`);this._baseViewport=this._page.getViewport({scale:1});this._inverseBaseViewport=i();o(this._inverseBaseViewport,a(...this._baseViewport.transform));return{geospatialMetadata:this._geospatialMetadata,pageNumber:this._page.pageNumber,numPages:e}}catch(e){this.destroy();throw e}}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;if(this._pdfWorkerBlobUrl){URL.revokeObjectURL(this._pdfWorkerBlobUrl);this._pdfWorkerBlobUrl=null}}async renderPDF(e,t={}){if(!this._page||!this._baseViewport||!this._inverseBaseViewport)throw new n(`geospatial-pdf-layer-worker:not-loaded`,`PDF not loaded`);r(t);let{width:i,height:a,sourceExtentAsJSON:o,currentRing:l,ctm:u}=e,d=s.fromJSON(o),f=await c(d,i,a,u,this._page,this._baseViewport,this._inverseBaseViewport,l,t);r(t);return Ir(f,i,a)}async _getPDFWorker(n={}){if(this._pdfWorker)return this._pdfWorker;let r=e(`esri/libs/pdfjs/pdf.worker.mjs`),i=(await t(r,{responseType:`blob`,authMode:`anonymous`,signal:n.signal})).data,a=i.type===`application/javascript`||i.type===`text/javascript`?i:new Blob([i],{type:`application/javascript`}),o=URL.createObjectURL(a),s=null,c=null;try{s=new Worker(o,{type:`module`,name:`geospatial-pdf-pdfjs-worker`});c=new J({port:s,verbosity:0});this._pdfWorkerPort=s;this._pdfWorker=c;this._pdfWorkerBlobUrl=o;await c.promise;return c}catch(e){URL.revokeObjectURL(o);throw e}}}function Ir(e,t,r){let i=e.getContext(`2d`);if(!i)throw new n(`geospatial-pdf-raster:canvas`,`Failed to create canvas context.`);let a=i.getImageData(0,0,t,r).data,o=t*r,s=new Uint8Array(o),c=new Uint8Array(o),l=new Uint8Array(o),u=new Uint8Array(o);for(let e=0,t=0;e<o;e++,t+=4){s[e]=a[t];c[e]=a[t+1];l[e]=a[t+2];u[e]=a[t+3]}return{width:t,height:r,red:s,green:c,blue:l,mask:u}}export{Fr as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{Loadable as n}from"../../core/Loadable.js";import{open as r}from"../../core/workers.js";import{subclass as i}from"../../core/accessorSupport/decorators.js";import a from"./GeospatialPDFFrame.js";import{parse as o}from"./geospatialPDFParserUtils.js";let s=class extends n{constructor(){super(...arguments),this._connection=null,this._workerHandler=null}load(e){let t=r(`GeospatialPDFLayerWorker`,{...e,strategy:`dedicated`,registryTarget:this}).then(e=>{this._connection=e,this._workerHandler=this._connection.createInvokeProxy()});return this.addResolvingPromise(t),Promise.resolve(this)}destroy(){this._connection?.close(),this._connection=null,this._workerHandler=null,super.destroy()}async loadPDF(e,n={}){await this.load(n);let{geospatialMetadata:r}=await this._workerHandler.loadPDF(e,n),
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import"../../core/has.js";import{Loadable as n}from"../../core/Loadable.js";import{open as r}from"../../core/workers.js";import{subclass as i}from"../../core/accessorSupport/decorators.js";import a from"./GeospatialPDFFrame.js";import{parse as o}from"./geospatialPDFParserUtils.js";let s=class extends n{constructor(){super(...arguments),this._connection=null,this._workerHandler=null}load(e){let t=r(`GeospatialPDFLayerWorker`,{...e,strategy:`dedicated`,registryTarget:this}).then(e=>{this._connection=e,this._workerHandler=this._connection.createInvokeProxy()});return this.addResolvingPromise(t),Promise.resolve(this)}destroy(){this._connection?.close(),this._connection=null,this._workerHandler=null,super.destroy()}async loadPDF(e,n={}){await this.load(n);let{geospatialMetadata:r,pageNumber:i,numPages:s}=await this._workerHandler.loadPDF(e,n),c=o(r,0),l=c.lgiDictFrame??c.vpFrame;if(!l)throw new t(`geospatial-pdf-layer:load`,`pdf does not contain supported LGIDict or VP/Measure.`);let u=new a(l);return{frame:u,sourceSpatialReference:u.spatialReference.toJSON(),neatlineExtent:u.toExtent()}}async render(e,t,n,r,i,a){let o={sourceExtentAsJSON:e.toJSON(),width:t,height:n,ctm:r,currentRing:i};return this._workerHandler.renderPDF(o,a)}};s=e([i(`esri.layers.geospatialPDF.GeospatialPDFWorkerClient`)],s);export{s as GeospatialPDFWorkerClient};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{insertSortedStableTopN as e}from"../../../core/arrayUtils.js";import{importLazily as t}from"../../../core/importUtils.js";import{clone as n}from"../../../core/lang.js";import r from"../../../geometry/SpatialReference.js";import{polygonCentroid as i,extentCentroid as a}from"../../../geometry/support/centroid.js";import{getPolygonExtent as o,getGeometryExtent as s,expandExtent as c}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as l}from"../../../geometry/support/quantizationUtils.js";import{isValid as u,equals as d}from"../../../geometry/support/spatialReferenceUtils.js";import{closestPointOnCurve as f}from"../../../geometry/support/curves/closestPointOnCurve.js";import{getEndpoint as p,isCoordinate as m,cloneCurve as h}from"../../../geometry/support/curves/curveUtils.js";import g from"./AttributesBuilder.js";import{getGeometry as _,transformCentroid as v}from"./geometryUtils.js";import{project as y}from"./projectionSupport.js";import{getDateInNumber as b}from"./queryUtils.js";import{SnappingCandidateEdge as x,SnappingCandidateVertex as S}from"./SnappingCandidate.js";import{isDateField as C,isDateOnlyField as w,isTimestampOffsetField as T,isStringField as E,isTimeOnlyField as D}from"../../support/fieldUtils.js";import O from"../../../rest/support/AutoIntervalBinParameters.js";import k from"../../../rest/support/DateBinParameters.js";import{unitsDict as A}from"../../../rest/support/DateBinUtils.js";import j from"../../../rest/support/FixedBoundariesBinParameters.js";import M from"../../../rest/support/FixedIntervalBinParameters.js";import{isNullCountSupported as N,calculateStringStatistics as P,calculateStatistics as F,processSummaryStatisticsResult as I,calculateUniqueValuesCount as L,createUVResult as R,calculateClassBreaks as z,resolveCBResult as B,calculateHistogram as V,calculatePercentile as H,binIndex as U,getBinParams as W,getAttributeComparator as G}from"../../../statistics/utils.js";import{utc as K}from"../../../time/constants.js";import{DateTime as q}from"luxon";const J=t(()=>import(`../../../geometry/operators/json/convexHullOperator.js`));class Y{constructor(e,t,n){this.items=e,this.query=t,this.geometryType=n.geometryType,this.hasZ=!!t.returnZ&&n.hasZ,this.hasM=!!t.returnM&&n.hasM,this.fieldsIndex=n.fieldsIndex,this.spatialReference=n.spatialReference,this.featureAdapter=n.featureAdapter,this.featureIdInfo=n.featureIdInfo}get size(){return this.items.length}createQueryResponseForCount(){let e=new g(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);let{groupByFieldsForStatistics:t,having:n,outStatistics:r}=this.query;if(!t?.length)return 1;let i=new Map,a=new Map,o=new Set;for(let s of r){let{statisticType:r}=s,c=r===`exceedslimit`?void 0:s.onStatisticField;if(!a.has(c)){let n=[];for(let r of t){let t=this._getAttributeValues(e,r,this.items,i);n.push(t)}a.set(c,this._calculateUniqueValues(n,this.items,e.returnDistinctValues))}let l=a.get(c);for(let t in l){let{data:r,items:i}=l[t],a=r.join(`,`);(!n||e.validateItems(i,n))&&o.add(a)}}return o.size}async createQueryResponse(){let e;if(e=this.query.outStatistics?this.query.outStatistics.some(e=>e.statisticType===`exceedslimit`)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items):this._createFeatureQueryResponse(this.query),this.query.returnQueryGeometry){let t=this.query.geometry;e.queryGeometry={spatialReference:this.query.outSR,...u(this.query.outSR)&&!d(t.spatialReference,this.query.outSR)?y(t,t.spatialReference,this.query.outSR):t}}return e}createSnappingResponse(e,t,n){let r=this.featureAdapter,{point:i}=e,a=typeof e.distance==`number`?e.distance:e.distance.x,o=typeof e.distance==`number`?e.distance:e.distance.y;function s(e,t){let n=(e-i.x)/a,r=(t-i.y)/o;return n*n+r*r}let c={candidates:[]},l=this.geometryType===`esriGeometryPolygon`,u=this.geometryType===`esriGeometryPolyline`||this.geometryType===`esriGeometryPoint`,d=this._getPointCreator(t,this.spatialReference,n),g=new Q(null,0),_=new Q(null,0),v={x:0,y:0,z:0};for(let e of this.items){let t=r.getObjectId(e),n=r.getGeometryWithCurves?.(e);if(n!=null){b(n,t);continue}let i=r.getGeometry(e);i!=null&&y(i,t)}return c.candidates.sort((e,t)=>e.distance-t.distance),c;function y(t,n){let{coords:r,stride:a}=t,o=t.isPoint?ee:t.lengths;if(g.coords=r,_.coords=r,e.returnEdge){let e=0;for(let t=0;t<o.length;t++){let r=o[t],u=e;for(let t=0;t<r;t++,e+=a){if(!l&&t===r-1||(g.coordsIndex=e,_.coordsIndex=t===r-1?u:e+a,!Z(v,i,g,_)))continue;let o=s(v.x,v.y);o<=1&&c.candidates.push(new x(n,d(v),Math.sqrt(o),d(g),d(_)))}}}if(e.vertexMode===`all`){let e=0;for(let t=0;t<o.length;t++){let r=o[t],i=e,u=_;u.coordsIndex=i;for(let t=0;t<r;t++,e+=a){if(g.coordsIndex=e,l&&t===r-1&&g.x===u.x&&g.y===u.y)continue;let i=s(g.x,g.y);i<=1&&c.candidates.push(new S(n,d(g),Math.sqrt(i)))}}}else if(u&&e.vertexMode===`ends`){let e=0,t=[];for(let n=0;n<o.length;n++){t.push(e);let r=o[n];e+=r*a,r>1&&t.push(e-a)}for(let e of t){g.coordsIndex=e;let t=s(g.x,g.y);t<=1&&c.candidates.push(new S(n,d(g),Math.sqrt(t)))}}}function b(t,n){let{candidates:r}=c,a={x:0,y:0,z:0};if(e.returnEdge){let e=[i.x,i.y],o=new Q(e,0),c=new Q(e,0);for(let{segments:i}of t.parts)for(let{start:t,curve:l}of i){let{curvePoint:i}=f(t,l,e),u=s(...i);if(u>1)continue;[a.x,a.y]=i,o.coords=t,c.coords=p(l);let g=m(l)?null:h(l);r.push(new x(n,d(a),Math.sqrt(u),d(o),d(c),!1,g))}}function o(e){a.x=t.vertexXY[e*2],a.y=t.vertexXY[e*2+1];let i=s(a.x,a.y);i>1||(a.z=t.vertexZ?.[e]??0,r.push(new S(n,d(a),Math.sqrt(i))))}if(e.vertexMode===`all`){let{vertexCount:e}=t;for(let t=0;t<e;++t)o(t)}else if(e.vertexMode===`ends`)switch(t.type){case`point`:o(0);break;case`polyline`:for(let e=0;e<t.partCount;++e){let n=t.partOffsets[e],r=t.partOffsets[e+1]-1;o(n),r!==n&&o(r)}}}}_getPointCreator(e,t,n){let r=n!=null&&!d(t,n)?e=>y(e,t,n):e=>e,{hasZ:i}=this;return i&&e?({x:e,y:t,z:n})=>r({x:e,y:t,z:n}):({x:e,y:t})=>r({x:e,y:t,z:0})}async createSummaryStatisticsResponse(e){let{field:t,valueExpression:n,normalizationField:r,normalizationType:i,normalizationTotal:a,minValue:o,maxValue:s,scale:c,timeZone:l,outStatisticTypes:u}=e,d=this.fieldsIndex.get(t),f=C(d)||w(d)||T(d),p=await this._getDataValues({field:t,valueExpression:n,normalizationField:r,normalizationType:i,normalizationTotal:a,scale:c,timeZone:l},this.items),m=N({normalizationType:i,normalizationField:r,minValue:o,maxValue:s}),h={value:.5,fieldType:d?.type},g=E(d)?P({values:p,supportsNullCount:m,percentileParams:h,outStatisticTypes:u}):F({values:p,minValue:o,maxValue:s,useSampleStdDev:!i,supportsNullCount:m,percentileParams:h,outStatisticTypes:u});return I(g,u,f)}async createUniqueValuesResponse(e){let{field:t,valueExpression:n,domains:r,returnAllCodedValues:i,scale:a,timeZone:o}=e,s=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:n,scale:a,timeZone:o},this.items,!1),c=L(s);return R(c,r,i,e.fieldDelimiter)}async createClassBreaksResponse(e){let{field:t,valueExpression:n,normalizationField:r,normalizationType:i,normalizationTotal:a,classificationMethod:o,standardDeviationInterval:s,minValue:c,maxValue:l,numClasses:u,scale:d,timeZone:f}=e,p=await this._getDataValues({field:t,valueExpression:n,normalizationField:r,normalizationType:i,normalizationTotal:a,scale:d,timeZone:f},this.items),m=z(p,{field:t,normalizationField:r,normalizationType:i,normalizationTotal:a,classificationMethod:o,standardDeviationInterval:s,minValue:c,maxValue:l,numClasses:u});return B(m,o)}async createHistogramResponse(e){let{field:t,valueExpression:n,normalizationField:r,normalizationType:i,normalizationTotal:a,classificationMethod:o,standardDeviationInterval:s,minValue:c,maxValue:l,numBins:u,scale:d,timeZone:f}=e,p=await this._getDataValues({field:t,valueExpression:n,normalizationField:r,normalizationType:i,normalizationTotal:a,scale:d,timeZone:f},this.items);return V(p,{field:t,normalizationField:r,normalizationType:i,normalizationTotal:a,classificationMethod:o,standardDeviationInterval:s,minValue:c,maxValue:l,numBins:u})}_sortFeatures(e,t,n){if(e.length>1&&t?.length)for(let r of t.slice().reverse()){let{compare:t,fieldOrExpression:i,fieldInfo:a}=$(r,this.fieldsIndex);e.sort((e,r)=>t(n(e,i,a),n(r,i,a)))}}_topNFeatures(t,n,r,i){if(t.length>1&&n?.length){let a=n.map(e=>{let{compare:t,fieldOrExpression:n,fieldInfo:r}=$(e,this.fieldsIndex);return(e,a)=>t(i(e,n,r),i(a,n,r))}).reduceRight((e,t)=>(n,r)=>{let i=t(n,r);return i!==0&&!Number.isNaN(i)?i:e(n,r)}),o=[];for(let n of t)e(o,n,r,a);return o}return t.slice(0,r)}_createFeatureQueryResponse(e){let{items:t,geometryType:n,hasM:r,hasZ:i,featureIdInfo:a,spatialReference:o}=this,{outFields:s,outSR:c,quantizationParameters:u,resultRecordCount:d,resultOffset:f,returnZ:p,returnM:m}=e,h=d!=null&&t.length>(f||0)+d,g=s&&(s.includes(`*`)?[...this.fieldsIndex.fields]:s.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:h,features:this._createFeatures(e,t),fields:g,geometryType:n,hasM:r&&m,hasZ:i&&p,objectIdFieldName:a.type===`object-id`?a.fieldName:null,spatialReference:c||o,transform:u&&l(u)||null}}_createFeatures(e,t){let n=new g(e,this.featureAdapter,this.fieldsIndex),{hasM:r,hasZ:i}=this,{orderByFields:a,quantizationParameters:o,returnGeometry:s,returnCentroid:c,maxAllowableOffset:u,resultOffset:d,resultRecordCount:f,returnZ:p=!1,returnM:m=!1}=e,h=i&&p,y=r&&m,b,x=d||0,S=f==null?null:x+f;S!=null&&S<=5e3&&S<t.length?b=this._topNFeatures(t,a,S,(e,t,r)=>n.getFieldValue(e,t,r)):(b=[...t],this._sortFeatures(b,a,(e,t,r)=>n.getFieldValue(e,t,r))),(x>0||S!=null)&&(b=b.slice(x,S??void 0));let C=[],w=0;if(!this.geometryType||!s&&!c)for(let e of b){let t=n.getAttributes(e);t&&(C[w++]=this._addFeatureJSONMetadata(e,{attributes:t}))}else{let e=l(o)??void 0,t=this.geometryType===`esriGeometryPolygon`||this.geometryType===`esriGeometryPolyline`;if(s&&!c)for(let r of b){let i=this.featureAdapter.getGeometry(r),a=this._addFeatureJSONMetadata(r,{attributes:n.getAttributes(r),geometry:_(this.geometryType,i,u,e,h,y)});t&&i&&!a.geometry&&(a.centroid=v(this,this.featureAdapter.getCentroid(r,this),e)),C[w++]=a}else if(!s&&c)for(let t of b)C[w++]=this._addFeatureJSONMetadata(t,{attributes:n.getAttributes(t),centroid:v(this,this.featureAdapter.getCentroid(t,this),e)});else for(let t of b)C[w++]=this._addFeatureJSONMetadata(t,{attributes:n.getAttributes(t),centroid:v(this,this.featureAdapter.getCentroid(t,this),e),geometry:_(this.geometryType,this.featureAdapter.getGeometry(t),u,e,h,y)})}return C}_addFeatureJSONMetadata(e,t){let n=this.featureAdapter.getMetadata?.(e);return n!==void 0&&(t.metadata=n),t}_createExceedsLimitQueryResponse(){let e=!1,t=1/0,n=1/0,r=1/0;for(let e of this.query.outStatistics??[])if(e.statisticType===`exceedslimit`){t=e.maxPointCount==null?1/0:e.maxPointCount,n=e.maxRecordCount==null?1/0:e.maxRecordCount,r=e.maxVertexCount==null?1/0:e.maxVertexCount;break}return e=this.geometryType===`esriGeometryPoint`?this.items.length>t:this.items.length>n||this.items.reduce((e,t)=>e+(this.featureAdapter.getGeometry(t)?.size??0),0)>r,{fields:[{name:`exceedslimit`,type:`esriFieldTypeInteger`,alias:`exceedslimit`,sqlType:`sqlTypeInteger`,domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,n={attributes:{}}){let r=[],i=new Map,a=new Map,o=new Map,s=new Map,c=new g(e,this.featureAdapter,this.fieldsIndex),l=e.outStatistics,{groupByFieldsForStatistics:u,having:d,orderByFields:f,resultRecordCount:p}=e,m=u?.length,h=!!m,_=h?u[0]:null,v=h&&!this.fieldsIndex.get(_);for(let f of l??[]){let{outStatisticFieldName:l,statisticType:p}=f,g=f,y=p===`exceedslimit`?void 0:f.onStatisticField,b=p===`percentile_disc`||p===`percentile_cont`,x=p===`EnvelopeAggregate`||p===`CentroidAggregate`||p===`ConvexHullAggregate`,S=h&&m===1&&(y===_||v)&&p===`count`;if(h){if(!o.has(y)){let e=[];for(let n of u){let r=this._getAttributeValues(c,n,t,i);e.push(r)}o.set(y,this._calculateUniqueValues(e,t,!x&&c.returnDistinctValues))}let n=o.get(y);if(!n)continue;let r=Object.keys(n);for(let a of r){let{count:r,data:o,items:f,itemPositions:p}=n[a],m=o.join(`,`);if(!d||c.validateItems(f,d)){let n=s.get(m)||{attributes:{}};if(e.returnAggIds&&(n.aggregateIds=f.map(e=>this.featureAdapter.getObjectId(e)).filter(e=>e!=null)),x){n.aggregateGeometries||={};let{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(g,f);n.aggregateGeometries[t]=e}else{let e=null;if(S)e=r;else{let n=this._getAttributeValues(c,y,t,i),r=p.map(e=>n[e]);e=b&&`statisticParameters`in g?this._getPercentileValue(g,r):this._getStatisticValue(g,r,null,c.returnDistinctValues)}n.attributes[l]=e}let a=0;u.forEach((e,t)=>n.attributes[this.fieldsIndex.get(e)?e:`EXPR_${++a}`]=o[t]),s.set(m,n)}}}else if(x){n.aggregateGeometries||={};let{aggregateGeometries:e,outStatisticFieldName:r}=await this._getAggregateGeometry(g,t);n.aggregateGeometries[r]=e}else{let e=this._getAttributeValues(c,y,t,i);n.attributes[l]=b&&`statisticParameters`in g?this._getPercentileValue(g,e):this._getStatisticValue(g,e,a,c.returnDistinctValues)}let C=(p===`min`||p===`max`)&&(E(this.fieldsIndex.get(y))||this._isAnyDateField(y))?this.fieldsIndex.get(y)?.type:null;r.push({name:l,alias:l,type:C||`esriFieldTypeDouble`})}let y=h?Array.from(s.values()):[n];return this._sortFeatures(y,f,(e,t)=>e.attributes[t]),p&&(y.length=Math.min(p,y.length)),{fields:r,features:y}}_isAnyDateField(e){let t=this.fieldsIndex.get(e);return C(t)||w(t)||T(t)||D(t)}async _getAggregateGeometry(e,t){let{statisticType:n,outStatisticFieldName:r}=e,{featureAdapter:s,spatialReference:c,geometryType:l}=this,u=t.map(e=>_(l,s.getGeometry(e))),d={aggregateGeometries:null,outStatisticFieldName:null},{convexHullExecuteMany:f}=await J.getImportPromise(),[p]=f(u,{merge:!0});if(p&&p.rings[0].length<=3&&(p=null),n===`EnvelopeAggregate`)d.aggregateGeometries={...p?o(p):X(u),spatialReference:c},d.outStatisticFieldName=r||`extent`;else if(n===`CentroidAggregate`){let[e,t]=p?i(p):a(X(u));d.aggregateGeometries={x:e,y:t,spatialReference:c},d.outStatisticFieldName=r||`centroid`}else n===`ConvexHullAggregate`&&(d.aggregateGeometries=p&&{...p,spatialReference:c},d.outStatisticFieldName=r||`convexHull`);return d}_getStatisticValue(e,t,n,r){let{onStatisticField:i,statisticType:a}=e,o=null;return o=n?.has(i)?n.get(i):E(this.fieldsIndex.get(i))||this._isAnyDateField(i)?P({values:t,returnDistinct:r}):F({values:r?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),n&&n.set(i,o),o[a===`var`?`variance`:a]}_getPercentileValue(e,t){let{onStatisticField:n,statisticParameters:r,statisticType:i}=e,{value:a,orderBy:o}=r,s={value:a,orderBy:o,fieldType:this.fieldsIndex.get(n)?.type,isDiscrete:i===`percentile_disc`};return H(t,s)}_getAttributeValues(e,t,n,r){if(r.has(t))return r.get(t);let i=this.fieldsIndex.get(t),a=n.map(n=>e.getFieldValue(n,t,i));return r.set(t,a),a}_calculateUniqueValues(e,t,n){let r={},i=t.length;for(let a=0;a<i;a++){let i=t[a],o=[];for(let t of e)o.push(t[a]);let s=o.join(`,`);r[s]==null?r[s]={count:1,data:o,items:[i],itemPositions:[a]}:(n||r[s].count++,r[s].items.push(i),r[s].itemPositions.push(a))}return r}async _getDataValues(e,t,i=!0){let a=new g(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:o,scale:s,timeZone:c}=e,l=r.fromJSON(this.query.outSR||this.spatialReference);return o?a.getExpressionValues(t,o,{viewingMode:`map`,scale:s,spatialReference:l},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},c):a.getDataValues(t,n(e),i)}_calculateHistogramBins(e,t,n){if(t.min==null&&t.max==null)return[];let r=t.intervals,i=t.min??0,a=t.max??0,o=r.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let t=0;t<e.length;t++){let s=e[t],c=n[t];if(s!=null&&s>=i&&s<=a){let e=U(r,s);e>-1&&(o[e].count++,o[e].items.push(c))}}return o}async createQueryBinsResponse(e){let t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);let{value:n,outAlias:r,valueType:i}=t,a=[],o=[{name:r??n,alias:r??n,type:i??`esriFieldTypeString`},{name:`bin`,alias:`bin`,type:`esriFieldTypeInteger`}],s=new g(e,this.featureAdapter,this.fieldsIndex),c=new Map,l=[...this.items];this._sortFeatures(l,[n],(e,t,n)=>s.getFieldValue(e,t,n));let u=this._getAttributeValues(s,n,l,c),d=this._calculateUniqueValues([u],l,s.returnDistinctValues);for(let t in d){let{items:i}=d[t],s=await this._createBinsResponse(e,i);if(a.push(...s.features.map(e=>({...e,attributes:{...e.attributes,[r??n]:t}}))),s.fields)for(let e of s.fields)o.some(t=>t.name===e.name)||o.push(e)}return{fields:o,features:a}}async _createBinsResponse(e,t){let n=e.bin;switch(t??=this.items,n.type){case`autoIntervalBin`:return this._createAutoIntervalBinsResponse(O.fromJSON(n),e,t);case`dateBin`:return this._createDateBinsResponse(k.fromJSON(n),e,t);case`fixedBoundariesBin`:return this._createFixedBoundariesBinsResponse(j.fromJSON(n),e,t);case`fixedIntervalBin`:return this._createFixedIntervalBinsResponse(M.fromJSON(n),e,t)}}async _createAutoIntervalBinsResponse(e,t,n){let{field:r,normalizationField:i,numBins:a,normalizationType:o,normalizationTotal:s,start:c,end:l}=e,u=await this._getDataValues({field:e.field||e.expression,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},n),d=W(u,{field:r,normalizationField:i,normalizationType:o,normalizationTotal:s,numBins:a,minValue:b(o?e.normalizationMinValue:c,!1),maxValue:b(o?e.normalizationMaxValue:l,!1)}),f=this._calculateHistogramBins(u,d,n);return this._createFeaturesFromHistogramBins(f,t)}async _createDateBinsResponse(e,t,n){let{field:r,interval:i,start:a,end:o,snapToData:s,returnFullIntervalBin:c,offset:l,firstDayOfWeek:u}=e,d=i.unit,f=await this._getDataValues({field:r||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},n),p=D(this.fieldsIndex.get(r)),m=A.toJSON(d),h=f.filter(Boolean).sort((e,t)=>e-t),g=a==null?h[0]:b(a,p),_=o==null?h[h.length-1]:b(o,p),v=[];if(g!=null&&_!=null){let e={zone:t.outTimeReference?.ianaTimeZone??K},n={[l?.unit?A.toJSON(l.unit):`milliseconds`]:l?.value||0},r=q.fromMillis(g,e).minus(n),a=q.fromMillis(_,e).minus(n),o=typeof u==`number`&&u>=1&&u<=7?u:7,d=(e,t)=>{let n=(e.weekday-t+7)%7;return e.minus({days:n}).startOf(`day`)},f=(e,t)=>d(e,t).plus({days:7});if(s===`last`){let e=m===`week`?f(a,o):a;for(;e>r;){let t=e.minus({[m]:i.value});if(t<r){v.unshift([c?t.plus(n).toMillis():r.plus(n).toMillis(),e.plus(n).toMillis()]);break}v.unshift([t.plus(n).toMillis(),e.plus(n).toMillis()]),e=t}}else{let e=s===`first`?r:m===`week`?d(r,o):r.startOf(m);for(;e<=a;){let t=e.plus({[m]:i.value});if(t>a){v.push([e.plus(n).toMillis(),c?t.plus(n).toMillis():a.plus(n).toMillis()]);break}v.push([e.plus(n).toMillis(),t.plus(n).toMillis()]),e=t}}}let y=this._calculateHistogramBins(f,{intervals:v,min:g,max:_},n);return this._createFeaturesFromHistogramBins(y,t)}async _createFixedBoundariesBinsResponse(e,t,n){let{field:r}=e,i=await this._getDataValues({field:r||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},n),a=D(this.fieldsIndex.get(r)),o=e.boundaries.map(e=>b(e,a)).sort((e,t)=>e-t),s=[];for(let e=0;e<o.length-1;e++)s.push([o[e],o[e+1]]);let c={intervals:s,min:o.at(0),max:o.at(-1)},l=this._calculateHistogramBins(i,c,n);return this._createFeaturesFromHistogramBins(l,t)}async _createFixedIntervalBinsResponse(e,t,n){let{field:r,interval:i,normalizationType:a,start:o,end:s}=e,c=await this._getDataValues({field:r||e.expression,normalizationField:e.normalizationField,normalizationType:a,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},n),l=D(this.fieldsIndex.get(r)),u=W(c,{field:r,classificationMethod:`defined-interval`,definedInterval:i,minValue:b(a?e.normalizationMinValue:o,l),maxValue:b(a?e.normalizationMaxValue:s,l)},!0),d=this._calculateHistogramBins(c,u,n);return this._createFeaturesFromHistogramBins(d,t)}async _createFeaturesFromHistogramBins(e,t){let{upperBoundaryAlias:n,lowerBoundaryAlias:r}=t,i=r||`lowerBoundary`,a=n||`upperBoundary`,o=[],s=[{name:i,alias:i,type:`esriFieldTypeDouble`},{name:a,alias:a,type:`esriFieldTypeDouble`}],c=t.bin?.stackBy?.value,l=t.bin?.stackBy?.outAlias;c&&s.push({name:`bin`,alias:`bin`,type:`esriFieldTypeInteger`},{name:l??c,alias:l??c,type:`esriFieldTypeString`});let u=0,d=t.bin.type===`dateBin`,f=t.outTimeReference?.ianaTimeZone;for(let n of e){let{minValue:e,maxValue:r,items:p}=n,m={attributes:{}};m.attributes[i]=d&&f&&e!=null?q.fromMillis(e,{zone:f}).toISO():e,t.bin.hideUpperBound||(m.attributes[a]=d&&f&&r!=null?q.fromMillis(r,{zone:f}).toISO():r),t.returnAggIds&&(m.aggregateIds=p.map(e=>this.featureAdapter.getObjectId(e)).filter(e=>e!=null));let h;if(c?(h=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[c],orderByFields:[c]},p),m.attributes.bin=++u,t.bin.jsonStyle===`flat`?o.push(...h.features.map(({attributes:{EXPR_1:e,...t},...n})=>({...n,attributes:l??e?{...t,[l??e]:e,...m.attributes}:{...t,...m.attributes}}))):(m.stackedAttributes=h.features.map(({attributes:{EXPR_1:e,...t}})=>l??e?{...t,[l??e]:e}:t),o.push(m))):(t.bin?.splitBy&&(m.attributes.bin=++u),h=await this._createStatisticsQueryResponse(t,p,m),o.push(m)),h.fields)for(let e of h.fields)s.some(t=>t.name===e.name)||s.push(e)}return t.binOrder===`desc`&&o.reverse(),{fields:s,features:o}}}function X(e){let t=s(e[0]);for(let n of e.slice(1))c(t,s(n));return t}function Z(e,t,n,r){let i=r.x-n.x,a=r.y-n.y,o=t.x-n.x,s=t.y-n.y,c=i*i+a*a;if(c===0)return!1;let l=o*i+s*a,u=Math.min(1,Math.max(0,l/c));return e.x=n.x+i*u,e.y=n.y+a*u,!0}class Q{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}const ee=[1];function $(e,t){let n=e.split(` `),r=n[0],i=t.get(r),a=n[1]?n[1].toLowerCase()===`desc`:!1;return{compare:G(i?.type,a,`case-insensitive`),fieldOrExpression:r,fieldInfo:i}}export{Y as QueryEngineResult};
|
|
2
|
+
import{insertSortedStableTopN as e}from"../../../core/arrayUtils.js";import{importLazily as t}from"../../../core/importUtils.js";import{clone as n}from"../../../core/lang.js";import r from"../../../geometry/SpatialReference.js";import{polygonCentroid as i,extentCentroid as a}from"../../../geometry/support/centroid.js";import{getPolygonExtent as o,getGeometryExtent as s,expandExtent as c}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as l}from"../../../geometry/support/quantizationUtils.js";import{isValid as u,equals as d}from"../../../geometry/support/spatialReferenceUtils.js";import{closestPointOnCurve as f}from"../../../geometry/support/curves/closestPointOnCurve.js";import{getEndpoint as p,isCoordinate as m,cloneCurve as h}from"../../../geometry/support/curves/curveUtils.js";import g from"./AttributesBuilder.js";import{getGeometry as _,transformCentroid as v}from"./geometryUtils.js";import{project as y}from"./projectionSupport.js";import{getDateInNumber as b}from"./queryUtils.js";import{SnappingCandidateEdge as x,SnappingCandidateVertex as S}from"./SnappingCandidate.js";import{isDateField as C,isDateOnlyField as w,isTimestampOffsetField as T,isStringField as E,isTimeOnlyField as D}from"../../support/fieldUtils.js";import O from"../../../rest/support/AutoIntervalBinParameters.js";import k from"../../../rest/support/DateBinParameters.js";import{unitsDict as A}from"../../../rest/support/DateBinUtils.js";import j from"../../../rest/support/FixedBoundariesBinParameters.js";import M from"../../../rest/support/FixedIntervalBinParameters.js";import{isNullCountSupported as N,calculateStringStatistics as P,calculateStatistics as F,processSummaryStatisticsResult as I,calculateUniqueValuesCount as L,createUVResult as R,calculateClassBreaks as z,resolveCBResult as B,calculateHistogram as V,calculatePercentile as H,binIndex as U,getBinParams as W,getAttributeComparator as G}from"../../../statistics/utils.js";import{utc as K}from"../../../time/constants.js";import{DateTime as q}from"luxon";const J=t(()=>import(`../../../geometry/operators/json/convexHullOperator.js`));class Y{constructor(e,t,n){this.items=e,this.query=t,this.geometryType=n.geometryType,this.hasZ=!!t.returnZ&&n.hasZ,this.hasM=!!t.returnM&&n.hasM,this.fieldsIndex=n.fieldsIndex,this.spatialReference=n.spatialReference,this.featureAdapter=n.featureAdapter,this.featureIdInfo=n.featureIdInfo}get size(){return this.items.length}createQueryResponseForCount(){let e=new g(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);let{groupByFieldsForStatistics:t,having:n,outStatistics:r}=this.query;if(!t?.length)return 1;let i=new Map,a=new Map,o=new Set;for(let s of r){let{statisticType:r}=s,c=r===`exceedslimit`?void 0:s.onStatisticField;if(!a.has(c)){let n=[];for(let r of t){let t=this._getAttributeValues(e,r,this.items,i);n.push(t)}a.set(c,this._calculateUniqueValues(n,this.items,e.returnDistinctValues))}let l=a.get(c);for(let t in l){let{data:r,items:i}=l[t],a=r.join(`,`);(!n||e.validateItems(i,n))&&o.add(a)}}return o.size}async createQueryResponse(){let e;if(e=this.query.outStatistics?this.query.outStatistics.some(e=>e.statisticType===`exceedslimit`)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items):this._createFeatureQueryResponse(this.query),this.query.returnQueryGeometry){let t=this.query.geometry;e.queryGeometry={spatialReference:this.query.outSR,...u(this.query.outSR)&&!d(t.spatialReference,this.query.outSR)?y(t,t.spatialReference,this.query.outSR):t}}return e}createSnappingResponse(e,t,n){let r=this.featureAdapter,{point:i}=e,a=typeof e.distance==`number`?e.distance:e.distance.x,o=typeof e.distance==`number`?e.distance:e.distance.y;function s(e,t){let n=(e-i.x)/a,r=(t-i.y)/o;return n*n+r*r}let c={candidates:[]},l=this.geometryType===`esriGeometryPolygon`,u=this.geometryType===`esriGeometryPolyline`||this.geometryType===`esriGeometryPoint`,d=this._getPointCreator(t,this.spatialReference,n),g=new Q(null,0),_=new Q(null,0),v={x:0,y:0,z:0};for(let e of this.items){let t=r.getObjectId(e),n=r.getGeometryWithCurves?.(e);if(n!=null){b(n,t);continue}let i=r.getGeometry(e);i!=null&&y(i,t)}return c.candidates.sort((e,t)=>e.distance-t.distance),c;function y(t,n){let{coords:r,stride:a}=t,o=t.isPoint?ee:t.lengths;if(g.coords=r,_.coords=r,e.returnEdge){let e=0;for(let t=0;t<o.length;t++){let r=o[t],u=e;for(let t=0;t<r;t++,e+=a){if(!l&&t===r-1||(g.coordsIndex=e,_.coordsIndex=t===r-1?u:e+a,!Z(v,i,g,_)))continue;let o=s(v.x,v.y);o<=1&&c.candidates.push(new x(n,d(v),Math.sqrt(o),d(g),d(_)))}}}if(e.vertexMode===`all`){let e=0;for(let t=0;t<o.length;t++){let r=o[t],i=e,u=_;u.coordsIndex=i;for(let t=0;t<r;t++,e+=a){if(g.coordsIndex=e,l&&t===r-1&&g.x===u.x&&g.y===u.y)continue;let i=s(g.x,g.y);i<=1&&c.candidates.push(new S(n,d(g),Math.sqrt(i)))}}}else if(u&&e.vertexMode===`ends`){let e=0,t=[];for(let n=0;n<o.length;n++){t.push(e);let r=o[n];e+=r*a,r>1&&t.push(e-a)}for(let e of t){g.coordsIndex=e;let t=s(g.x,g.y);t<=1&&c.candidates.push(new S(n,d(g),Math.sqrt(t)))}}}function b(t,n){let{candidates:r}=c,a={x:0,y:0,z:0};if(e.returnEdge){let e=[i.x,i.y],o=new Q(e,0),c=new Q(e,0);for(let{segments:i}of t.parts)for(let{start:t,curve:l}of i){let{curvePoint:i}=f(t,l,e),u=s(...i);if(u>1)continue;[a.x,a.y]=i,o.coords=t,c.coords=p(l);let g=m(l)?null:h(l);r.push(new x(n,d(a),Math.sqrt(u),d(o),d(c),!1,g))}}function o(e){a.x=t.vertexXY[e*2],a.y=t.vertexXY[e*2+1];let i=s(a.x,a.y);i>1||(a.z=t.vertexZ?.[e]??0,r.push(new S(n,d(a),Math.sqrt(i))))}if(e.vertexMode===`all`){let{vertexCount:e}=t;for(let t=0;t<e;++t)o(t)}else if(e.vertexMode===`ends`)switch(t.type){case`point`:o(0);break;case`polyline`:for(let e=0;e<t.partCount;++e){let n=t.partOffsets[e],r=t.partOffsets[e+1]-1;o(n),r!==n&&o(r)}}}}_getPointCreator(e,t,n){let r=n!=null&&!d(t,n)?e=>y(e,t,n):e=>e,{hasZ:i}=this;return i&&e?({x:e,y:t,z:n})=>r({x:e,y:t,z:n}):({x:e,y:t})=>r({x:e,y:t,z:0})}async createSummaryStatisticsResponse(e){let{field:t,valueExpression:n,normalizationField:r,normalizationType:i,normalizationTotal:a,minValue:o,maxValue:s,scale:c,timeZone:l,outStatisticTypes:u}=e,d=this.fieldsIndex.get(t),f=C(d)||w(d)||T(d),p=await this._getDataValues({field:t,valueExpression:n,normalizationField:r,normalizationType:i,normalizationTotal:a,scale:c,timeZone:l},this.items),m=N({normalizationType:i,normalizationField:r,minValue:o,maxValue:s}),h={value:.5,fieldType:d?.type},g=E(d)?P({values:p,supportsNullCount:m,percentileParams:h,outStatisticTypes:u}):F({values:p,minValue:o,maxValue:s,useSampleStdDev:!i,supportsNullCount:m,percentileParams:h,outStatisticTypes:u});return I(g,u,f)}async createUniqueValuesResponse(e){let{field:t,valueExpression:n,domains:r,returnAllCodedValues:i,scale:a,timeZone:o}=e,s=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:n,scale:a,timeZone:o},this.items,!1),c=L(s);return R(c,r,i,e.fieldDelimiter)}async createClassBreaksResponse(e){let{field:t,valueExpression:n,normalizationField:r,normalizationType:i,normalizationTotal:a,classificationMethod:o,standardDeviationInterval:s,minValue:c,maxValue:l,numClasses:u,scale:d,timeZone:f}=e,p=await this._getDataValues({field:t,valueExpression:n,normalizationField:r,normalizationType:i,normalizationTotal:a,scale:d,timeZone:f},this.items),m=z(p,{field:t,normalizationField:r,normalizationType:i,normalizationTotal:a,classificationMethod:o,standardDeviationInterval:s,minValue:c,maxValue:l,numClasses:u});return B(m,o)}async createHistogramResponse(e){let{field:t,valueExpression:n,normalizationField:r,normalizationType:i,normalizationTotal:a,classificationMethod:o,standardDeviationInterval:s,minValue:c,maxValue:l,numBins:u,scale:d,timeZone:f}=e,p=await this._getDataValues({field:t,valueExpression:n,normalizationField:r,normalizationType:i,normalizationTotal:a,scale:d,timeZone:f},this.items);return V(p,{field:t,normalizationField:r,normalizationType:i,normalizationTotal:a,classificationMethod:o,standardDeviationInterval:s,minValue:c,maxValue:l,numBins:u})}_sortFeatures(e,t,n){if(e.length>1&&t?.length)for(let r of t.slice().reverse()){let{compare:t,fieldOrExpression:i,fieldInfo:a}=$(r,this.fieldsIndex);e.sort((e,r)=>t(n(e,i,a),n(r,i,a)))}}_topNFeatures(t,n,r,i){if(t.length>1&&n?.length){let a=n.map(e=>{let{compare:t,fieldOrExpression:n,fieldInfo:r}=$(e,this.fieldsIndex);return(e,a)=>t(i(e,n,r),i(a,n,r))}).reduceRight((e,t)=>(n,r)=>{let i=t(n,r);return i!==0&&!Number.isNaN(i)?i:e(n,r)}),o=[];for(let n of t)e(o,n,r,a);return o}return t.slice(0,r)}_createFeatureQueryResponse(e){let{items:t,geometryType:n,hasM:r,hasZ:i,featureIdInfo:a,spatialReference:o}=this,{outFields:s,outSR:c,quantizationParameters:u,resultRecordCount:d,resultOffset:f,returnZ:p,returnM:m}=e,h=d!=null&&t.length>(f||0)+d,g=s&&(s.includes(`*`)?[...this.fieldsIndex.fields]:s.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:h,features:this._createFeatures(e,t),fields:g,geometryType:n,hasM:r&&m,hasZ:i&&p,objectIdFieldName:a.type===`object-id`?a.fieldName:null,spatialReference:c||o,transform:u&&l(u)||null}}_createFeatures(e,t){let n=new g(e,this.featureAdapter,this.fieldsIndex),{hasM:r,hasZ:i}=this,{orderByFields:a,quantizationParameters:o,returnGeometry:s,returnCentroid:c,maxAllowableOffset:u,resultOffset:d,resultRecordCount:f,returnZ:p=!1,returnM:m=!1}=e,h=i&&p,y=r&&m,b,x=d||0,S=f==null?null:x+f;S!=null&&S<=5e3&&S<t.length?b=this._topNFeatures(t,a,S,(e,t,r)=>n.getFieldValue(e,t,r)):(b=[...t],this._sortFeatures(b,a,(e,t,r)=>n.getFieldValue(e,t,r))),(x>0||S!=null)&&(b=b.slice(x,S??void 0));let C=[],w=0;if(!this.geometryType||!s&&!c)for(let e of b){let t=n.getAttributes(e);t&&(C[w++]=this._addFeatureJSONMetadata(e,{attributes:t}))}else{let e=l(o)??void 0,t=this.geometryType===`esriGeometryPolygon`||this.geometryType===`esriGeometryPolyline`;if(s&&!c)for(let r of b){let i=this.featureAdapter.getGeometry(r),a=this._addFeatureJSONMetadata(r,{attributes:n.getAttributes(r),geometry:_(this.geometryType,i,u,e,h,y)});t&&i&&!a.geometry&&(a.centroid=v(this,this.featureAdapter.getCentroid(r,this),e)),C[w++]=a}else if(!s&&c)for(let t of b)C[w++]=this._addFeatureJSONMetadata(t,{attributes:n.getAttributes(t),centroid:v(this,this.featureAdapter.getCentroid(t,this),e)});else for(let t of b)C[w++]=this._addFeatureJSONMetadata(t,{attributes:n.getAttributes(t),centroid:v(this,this.featureAdapter.getCentroid(t,this),e),geometry:_(this.geometryType,this.featureAdapter.getGeometry(t),u,e,h,y)})}return C}_addFeatureJSONMetadata(e,t){let n=this.featureAdapter.getMetadata?.(e);return n!==void 0&&(t.metadata=n),t}_createExceedsLimitQueryResponse(){let e=!1,t=1/0,n=1/0,r=1/0;for(let e of this.query.outStatistics??[])if(e.statisticType===`exceedslimit`){t=e.maxPointCount==null?1/0:e.maxPointCount,n=e.maxRecordCount==null?1/0:e.maxRecordCount,r=e.maxVertexCount==null?1/0:e.maxVertexCount;break}return e=this.geometryType===`esriGeometryPoint`?this.items.length>t:this.items.length>n||this.items.reduce((e,t)=>e+(this.featureAdapter.getGeometry(t)?.size??0),0)>r,{fields:[{name:`exceedslimit`,type:`esriFieldTypeInteger`,alias:`exceedslimit`,sqlType:`sqlTypeInteger`,domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,n={attributes:{}}){let r=[],i=new Map,a=new Map,o=new Map,s=new Map,c=new g(e,this.featureAdapter,this.fieldsIndex),l=e.outStatistics,{groupByFieldsForStatistics:u,having:d,orderByFields:f,resultRecordCount:p}=e,m=u?.length,h=!!m,_=h?u[0]:null,v=h&&!this.fieldsIndex.get(_);for(let f of l??[]){let{outStatisticFieldName:l,statisticType:p}=f,g=f,y=p===`exceedslimit`?void 0:f.onStatisticField,b=p===`percentile_disc`||p===`percentile_cont`,x=p===`EnvelopeAggregate`||p===`CentroidAggregate`||p===`ConvexHullAggregate`,S=h&&m===1&&(y===_||v)&&p===`count`;if(h){if(!o.has(y)){let e=[];for(let n of u){let r=this._getAttributeValues(c,n,t,i);e.push(r)}o.set(y,this._calculateUniqueValues(e,t,!x&&c.returnDistinctValues))}let n=o.get(y);if(!n)continue;let r=Object.keys(n);for(let a of r){let{count:r,data:o,items:f,itemPositions:p}=n[a],m=o.join(`,`);if(!d||c.validateItems(f,d)){let n=s.get(m)||{attributes:{}};if(e.returnAggIds&&(n.aggregateIds=f.map(e=>this.featureAdapter.getObjectId(e)).filter(e=>e!=null)),x){n.aggregateGeometries||={};let{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(g,f);n.aggregateGeometries[t]=e}else{let e=null;if(S)e=r;else{let n=this._getAttributeValues(c,y,t,i),r=p.map(e=>n[e]);e=b&&`statisticParameters`in g?this._getPercentileValue(g,r):this._getStatisticValue(g,r,null,c.returnDistinctValues)}n.attributes[l]=e}let a=0;u.forEach((e,t)=>n.attributes[this.fieldsIndex.get(e)?e:`EXPR_${++a}`]=o[t]),s.set(m,n)}}}else if(x){n.aggregateGeometries||={};let{aggregateGeometries:e,outStatisticFieldName:r}=await this._getAggregateGeometry(g,t);n.aggregateGeometries[r]=e}else{let e=this._getAttributeValues(c,y,t,i);n.attributes[l]=b&&`statisticParameters`in g?this._getPercentileValue(g,e):this._getStatisticValue(g,e,a,c.returnDistinctValues)}let C=(p===`min`||p===`max`)&&(E(this.fieldsIndex.get(y))||this._isAnyDateField(y))?this.fieldsIndex.get(y)?.type:null;r.push({name:l,alias:l,type:C||`esriFieldTypeDouble`})}let y=h?Array.from(s.values()):[n];return this._sortFeatures(y,f,(e,t)=>e.attributes[t]),p&&(y.length=Math.min(p,y.length)),{fields:r,features:y}}_isAnyDateField(e){let t=this.fieldsIndex.get(e);return C(t)||w(t)||T(t)||D(t)}async _getAggregateGeometry(e,t){let{statisticType:n,outStatisticFieldName:r}=e,{featureAdapter:s,spatialReference:c,geometryType:l}=this,u=t.map(e=>_(l,s.getGeometry(e))),d={aggregateGeometries:null,outStatisticFieldName:null},{convexHullExecuteMany:f}=await J.getImportPromise(),[p]=f(u,{merge:!0});if(p&&p.rings[0].length<=3&&(p=null),n===`EnvelopeAggregate`)d.aggregateGeometries={...p?o(p):X(u),spatialReference:c},d.outStatisticFieldName=r||`extent`;else if(n===`CentroidAggregate`){let[e,t]=p?i(p):a(X(u));d.aggregateGeometries={x:e,y:t,spatialReference:c},d.outStatisticFieldName=r||`centroid`}else n===`ConvexHullAggregate`&&(d.aggregateGeometries=p&&{...p,spatialReference:c},d.outStatisticFieldName=r||`convexHull`);return d}_getStatisticValue(e,t,n,r){let{onStatisticField:i,statisticType:a}=e,o=null;return o=n?.has(i)?n.get(i):E(this.fieldsIndex.get(i))||this._isAnyDateField(i)?P({values:t,returnDistinct:r}):F({values:r?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),n&&n.set(i,o),o[a===`var`?`variance`:a]}_getPercentileValue(e,t){let{onStatisticField:n,statisticParameters:r,statisticType:i}=e,{value:a,orderBy:o}=r,s={value:a,orderBy:o,fieldType:this.fieldsIndex.get(n)?.type,isDiscrete:i===`percentile_disc`};return H(t,s)}_getAttributeValues(e,t,n,r){if(r.has(t))return r.get(t);let i=this.fieldsIndex.get(t),a=n.map(n=>e.getFieldValue(n,t,i));return r.set(t,a),a}_calculateUniqueValues(e,t,n){let r={},i=t.length;for(let a=0;a<i;a++){let i=t[a],o=Array.from(e,e=>e[a]),s=o.join(`,`);r[s]==null?r[s]={count:1,data:o,items:[i],itemPositions:[a]}:(n||r[s].count++,r[s].items.push(i),r[s].itemPositions.push(a))}return r}async _getDataValues(e,t,i=!0){let a=new g(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:o,scale:s,timeZone:c}=e,l=r.fromJSON(this.query.outSR||this.spatialReference);return o?a.getExpressionValues(t,o,{viewingMode:`map`,scale:s,spatialReference:l},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},c):a.getDataValues(t,n(e),i)}_calculateHistogramBins(e,t,n){if(t.min==null&&t.max==null)return[];let r=t.intervals,i=t.min??0,a=t.max??0,o=r.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let t=0;t<e.length;t++){let s=e[t],c=n[t];if(s!=null&&s>=i&&s<=a){let e=U(r,s);e>-1&&(o[e].count++,o[e].items.push(c))}}return o}async createQueryBinsResponse(e){let t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);let{value:n,outAlias:r,valueType:i}=t,a=[],o=[{name:r??n,alias:r??n,type:i??`esriFieldTypeString`},{name:`bin`,alias:`bin`,type:`esriFieldTypeInteger`}],s=new g(e,this.featureAdapter,this.fieldsIndex),c=new Map,l=[...this.items];this._sortFeatures(l,[n],(e,t,n)=>s.getFieldValue(e,t,n));let u=this._getAttributeValues(s,n,l,c),d=this._calculateUniqueValues([u],l,s.returnDistinctValues);for(let t in d){let{items:i}=d[t],s=await this._createBinsResponse(e,i);if(a.push(...s.features.map(e=>({...e,attributes:{...e.attributes,[r??n]:t}}))),s.fields)for(let e of s.fields)o.some(t=>t.name===e.name)||o.push(e)}return{fields:o,features:a}}async _createBinsResponse(e,t){let n=e.bin;switch(t??=this.items,n.type){case`autoIntervalBin`:return this._createAutoIntervalBinsResponse(O.fromJSON(n),e,t);case`dateBin`:return this._createDateBinsResponse(k.fromJSON(n),e,t);case`fixedBoundariesBin`:return this._createFixedBoundariesBinsResponse(j.fromJSON(n),e,t);case`fixedIntervalBin`:return this._createFixedIntervalBinsResponse(M.fromJSON(n),e,t)}}async _createAutoIntervalBinsResponse(e,t,n){let{field:r,normalizationField:i,numBins:a,normalizationType:o,normalizationTotal:s,start:c,end:l}=e,u=await this._getDataValues({field:e.field||e.expression,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},n),d=W(u,{field:r,normalizationField:i,normalizationType:o,normalizationTotal:s,numBins:a,minValue:b(o?e.normalizationMinValue:c,!1),maxValue:b(o?e.normalizationMaxValue:l,!1)}),f=this._calculateHistogramBins(u,d,n);return this._createFeaturesFromHistogramBins(f,t)}async _createDateBinsResponse(e,t,n){let{field:r,interval:i,start:a,end:o,snapToData:s,returnFullIntervalBin:c,offset:l,firstDayOfWeek:u}=e,d=i.unit,f=await this._getDataValues({field:r||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},n),p=D(this.fieldsIndex.get(r)),m=A.toJSON(d),h=f.filter(Boolean).sort((e,t)=>e-t),g=a==null?h[0]:b(a,p),_=o==null?h[h.length-1]:b(o,p),v=[];if(g!=null&&_!=null){let e={zone:t.outTimeReference?.ianaTimeZone??K},n={[l?.unit?A.toJSON(l.unit):`milliseconds`]:l?.value||0},r=q.fromMillis(g,e).minus(n),a=q.fromMillis(_,e).minus(n),o=typeof u==`number`&&u>=1&&u<=7?u:7,d=(e,t)=>{let n=(e.weekday-t+7)%7;return e.minus({days:n}).startOf(`day`)},f=(e,t)=>d(e,t).plus({days:7});if(s===`last`){let e=m===`week`?f(a,o):a;for(;e>r;){let t=e.minus({[m]:i.value});if(t<r){v.unshift([c?t.plus(n).toMillis():r.plus(n).toMillis(),e.plus(n).toMillis()]);break}v.unshift([t.plus(n).toMillis(),e.plus(n).toMillis()]),e=t}}else{let e=s===`first`?r:m===`week`?d(r,o):r.startOf(m);for(;e<=a;){let t=e.plus({[m]:i.value});if(t>a){v.push([e.plus(n).toMillis(),c?t.plus(n).toMillis():a.plus(n).toMillis()]);break}v.push([e.plus(n).toMillis(),t.plus(n).toMillis()]),e=t}}}let y=this._calculateHistogramBins(f,{intervals:v,min:g,max:_},n);return this._createFeaturesFromHistogramBins(y,t)}async _createFixedBoundariesBinsResponse(e,t,n){let{field:r}=e,i=await this._getDataValues({field:r||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},n),a=D(this.fieldsIndex.get(r)),o=e.boundaries.map(e=>b(e,a)).sort((e,t)=>e-t),s=[];for(let e=0;e<o.length-1;e++)s.push([o[e],o[e+1]]);let c={intervals:s,min:o.at(0),max:o.at(-1)},l=this._calculateHistogramBins(i,c,n);return this._createFeaturesFromHistogramBins(l,t)}async _createFixedIntervalBinsResponse(e,t,n){let{field:r,interval:i,normalizationType:a,start:o,end:s}=e,c=await this._getDataValues({field:r||e.expression,normalizationField:e.normalizationField,normalizationType:a,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},n),l=D(this.fieldsIndex.get(r)),u=W(c,{field:r,classificationMethod:`defined-interval`,definedInterval:i,minValue:b(a?e.normalizationMinValue:o,l),maxValue:b(a?e.normalizationMaxValue:s,l)},!0),d=this._calculateHistogramBins(c,u,n);return this._createFeaturesFromHistogramBins(d,t)}async _createFeaturesFromHistogramBins(e,t){let{upperBoundaryAlias:n,lowerBoundaryAlias:r}=t,i=r||`lowerBoundary`,a=n||`upperBoundary`,o=[],s=[{name:i,alias:i,type:`esriFieldTypeDouble`},{name:a,alias:a,type:`esriFieldTypeDouble`}],c=t.bin?.stackBy?.value,l=t.bin?.stackBy?.outAlias;c&&s.push({name:`bin`,alias:`bin`,type:`esriFieldTypeInteger`},{name:l??c,alias:l??c,type:`esriFieldTypeString`});let u=0,d=t.bin.type===`dateBin`,f=t.outTimeReference?.ianaTimeZone;for(let n of e){let{minValue:e,maxValue:r,items:p}=n,m={attributes:{}};m.attributes[i]=d&&f&&e!=null?q.fromMillis(e,{zone:f}).toISO():e,t.bin.hideUpperBound||(m.attributes[a]=d&&f&&r!=null?q.fromMillis(r,{zone:f}).toISO():r),t.returnAggIds&&(m.aggregateIds=p.map(e=>this.featureAdapter.getObjectId(e)).filter(e=>e!=null));let h;if(c?(h=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[c],orderByFields:[c]},p),m.attributes.bin=++u,t.bin.jsonStyle===`flat`?o.push(...h.features.map(({attributes:{EXPR_1:e,...t},...n})=>({...n,attributes:l??e?{...t,[l??e]:e,...m.attributes}:{...t,...m.attributes}}))):(m.stackedAttributes=h.features.map(({attributes:{EXPR_1:e,...t}})=>l??e?{...t,[l??e]:e}:t),o.push(m))):(t.bin?.splitBy&&(m.attributes.bin=++u),h=await this._createStatisticsQueryResponse(t,p,m),o.push(m)),h.fields)for(let e of h.fields)s.some(t=>t.name===e.name)||s.push(e)}return t.binOrder===`desc`&&o.reverse(),{fields:s,features:o}}}function X(e){let t=s(e[0]);for(let n of e.slice(1))c(t,s(n));return t}function Z(e,t,n,r){let i=r.x-n.x,a=r.y-n.y,o=t.x-n.x,s=t.y-n.y,c=i*i+a*a;if(c===0)return!1;let l=o*i+s*a,u=Math.min(1,Math.max(0,l/c));return e.x=n.x+i*u,e.y=n.y+a*u,!0}class Q{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}const ee=[1];function $(e,t){let n=e.split(` `),r=n[0],i=t.get(r),a=n[1]?n[1].toLowerCase()===`desc`:!1;return{compare:G(i?.type,a,`case-insensitive`),fieldOrExpression:r,fieldInfo:i}}export{Y as QueryEngineResult};
|